Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] Problem z skryptem do maill
Forum PHP.pl > Forum > Przedszkole
adri
czesc

mam skrypt do wysyłania maill tylko ze wyskakuje mi pare błedów które nie potrafię usunoć prosze o pilną pomoc

  1. <?
  2. require('config.inc.php');
  3. require('functions.inc.php');
  4.  
  5. // Max execution time of script. This does not include sleep time, so only restricts time
  6. // allowed for mailing.
  7.  
  8. $type = $_GET['type'];{}
  9. $addr = stripslashes(urldecode($_GET['email']));{}
  10.  
  11. if ($type == 'sub') {
  12. // subscribe address. Actually, all it does is send the confirmation email
  13. if (!preg_match('#^([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+[^\".,?! ])$#i', $addr)) {
  14. $err = 'Your email address appears to be invalid.';
  15. }
  16. if (!isset($err)) {
  17. $f = openfile($cfg['listfile']);
  18. $exists = false;
  19. while ($item = readitem($f)) {
  20. if ($item['addr'] == $addr) {$exists = true;break;}
  21. }
  22. if ($exists) {
  23. $err = 'That address is already subscribed to the list.';
  24. }
  25. }
  26. if (!isset($err)) {
  27. // send confirmation email
  28. $headers = 'From: '.$cfg['from'];
  29. if ($cfg['headers']) {
  30. foreach ($cfg['headers'] as $val) $headers .= "\n".$val;
  31. }
  32. $headers .= "\n".$cfg['header_plain'];
  33. if (!@mail($addr, $cfg['subj_conf'], sprintf($cfg['msg_conf'], '?type=confirm&email='.urlencode($addr)), $headers)) {
  34. $err = 'There was an error sending the confirmation email. Please try again later.';
  35. }
  36. }
  37. if (!isset($err)) {
  38. // confirmation sent
  39. if (isset($cfg['returnto_conf']) && $cfg['returnto_conf'] != '') {
  40. header('Location: '.$cfg['returnto_conf']);
  41. }
  42. else {
  43. printf($cfg['template'], 'Awaiting confirmation', 'An email has been sent to your address, '.$addr.', with a URL you must visit to confirm your subscription.');
  44. }
  45. }
  46. else {
  47. // problem with subscription
  48. echoerr($err);
  49. }
  50. }
  51. elseif ($type == 'unsub') {
  52. // unsubscribe address
  53. $f = openfile($cfg['listfile']);
  54. $exists = false;
  55. while ($item = readitem($f)) {
  56. if ($item['addr'] == $addr) {$exists = true;break;}
  57. }
  58. if ($exists) {
  59. delitem($f, $item['id']);
  60. }
  61. else {
  62. $err = 'That address was not found.';
  63. }
  64. if (!isset($err)) {
  65. // unsubscribe successful
  66. if (isset($cfg['returnto_unsub']) && $cfg['returnto_unsub'] != '') {
  67. header('Location: '.$cfg['returnto_unsub']);
  68. }
  69. else {
  70. printf($cfg['template'], 'Unsubscribed', 'Your address, '.$addr.' has successfully been unsubscribed from our mailing list.');
  71. }
  72. }
  73. else {
  74. // problem with unsubscription
  75. echoerr($err);
  76. }
  77. }
  78. elseif ($type == 'confirm') {
  79. // subscribe a confirmed address
  80. if (!preg_match('#^([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+[^\".,?! ])$#i', $addr)) {
  81. $err = 'Your email address appears to be invalid. If you are pasting the URL from your confirmation email, make sure the URL wasn\'t split into two lines.';
  82. }
  83. if (!isset($err)) {
  84. $f = openfile($cfg['listfile']);
  85. $exists = false;
  86. while ($item = readitem($f)) {
  87. if ($item['addr'] == $addr) {$exists = true;break;}
  88. }
  89. if ($exists) {
  90. $err = 'That address is already subscribed to the list.';
  91. }
  92. }
  93. if (!isset($err)) {
  94. // subscribe successful
  95. writeitem($f, $addr);
  96. if (isset($cfg['returnto_sub']) && $cfg['returnto_sub'] != '') {
  97. header('Location: '.$cfg['returnto_sub']);
  98. }
  99. else {
  100. printf($cfg['template'], 'Subscribed', 'Your address, '.$addr.', is now subscribed to our mailing list!');
  101. }
  102. }
  103. else {
  104. // problem with subscription
  105. echoerr($err);
  106. }
  107. }
  108.  
  109. function echoerr($err) {
  110. printf($GLOBALS['cfg']['template'], 'Error', '<font color="red">Error: '.$err.'</font>');
  111. }
  112. ?>


i ten pokazuje mi błąd

Notice: Undefined index: type in /home/adri/public_html/ok/index.php on line 9 Notice: Undefined index: email in /home/adri/public_html/ok/index.php on line 10

i drugi skrypt

  1. <?
  2. require('config.inc.php');
  3. require('functions.inc.php');
  4.  
  5. define('IN_ADMIN',true);
  6.  
  7. session_name('txtlist');
  8.  
  9. if (isset($_POST['logsub'])) {
  10. if ($_POST['uname'] == $cfg['uname'] && $_POST['pword'] == $cfg['pword']) {
  11. $_SESSION['lin'] = true;
  12. }
  13. else {
  14. $err = 'Invalid username or password';
  15. }
  16. }
  17. elseif ($_GET['do'] == 'logout') {
  18. $_SESSION = array();
  19. }
  20. // write header
  21. ?>
  22. <html>
  23. <head>
  24. <title>txtList admin</title>
  25. <style type="text/css">
  26. body {
  27. font-family: Arial, sans-serif;
  28. font-size: 10pt;
  29. }
  30. td {
  31. font-family: Arial, sans-serif;
  32. font-size: 10pt;
  33. }
  34. .txtbox {
  35. font-family: Arial, sans-serif;
  36. font-size: 10pt;
  37. }
  38. .smalltxt {
  39. font-size: 8pt;
  40. color: #cdcdcd;
  41. }
  42. A {
  43. color: #C43232;
  44. }
  45. .smalltxt A {
  46. color: #cdcdcd;
  47. }
  48. </style>
  49. <script language="JavaScript">
  50. function phelp(pg) {
  51. window.open('admin_help.php?pg='+pg,'help','width=400,height=500,resizable=yes,toolbars=no,scrollbars=yes,status=no');
  52. }
  53. </script>
  54. </head>
  55. <body>
  56. <?
  57. if ($_SESSION['lin']) {
  58. // we are logged in.
  59. function writemenu($item) {
  60. $items = array(
  61. 'email' => 'send email',
  62. 'archive' => 'email archive',
  63. 'newsub' => 'add subscribers',
  64. 'list' => 'subscriber list',
  65. 'logout' => 'log out'
  66. );
  67. foreach ($items as $a => $b) {
  68. if (isset($str)) $str .= ' &middot; ';else $str = '';
  69. $str .= ($a == $item)?'<b>':'<a href="admin.php?do='.$a.'&'.strip_tags(SID).'">';
  70. $str .= $b;
  71. $str .= ($a == $item)?'</b>':'</a>';
  72. }
  73. return $str;
  74. }
  75. ?>
  76. <div style="font-size: 14pt;" align="center">txtList admin</div>
  77. <div align="center"><?=writemenu($_GET['do'])?> &middot <a href="java script:phelp('<?=$_GET['do']?>')">help</a></div>
  78. <hr width="300" size="1" noshade color="#cdcdcd">
  79. <p>
  80. <?
  81.  
  82. if ($_GET['do'] == 'email') {
  83. // ---------------------------- EMAIL SUBSCRIBERS
  84. require('admin_email.inc.php');
  85. }
  86. elseif ($_GET['do'] == 'archive') {
  87. // ---------------------------- EMAIL ARCHIVE
  88. require('admin_archive.inc.php');
  89. }
  90. elseif ($_GET['do'] == 'list') {
  91. // ---------------------------- LIST SUBSCRIBERS
  92. require('admin_list.inc.php');
  93. }
  94. elseif ($_GET['do'] == 'newsub') {
  95. // ---------------------------- ADD SUBSCRIBERS
  96. require('admin_newsub.inc.php');
  97. }
  98. else {
  99. // ---------------------------- DISPLAY MENU
  100. ?>
  101. <center>You are logged-in. Choose a function from the list above</center>
  102. <p>
  103. <?
  104. if (ini_get('safe_mode')) {
  105. ?>
  106. <table border="0" cellpadding="0" cellspacing="0" width="400" align="center">
  107. <tr><td>
  108. <p><center><font color="red"><b>Note:</b></font> PHP is running in safe mode. This means txtList
  109. cannot set the script time limit itself.<p>
  110. <?
  111. if (ini_get('max_execution_time') == 0) {
  112. ?>
  113. However, currently PHP is not set up to impose a time limit, so this may not be a problem.
  114. <?
  115. }
  116. else {
  117. ?>
  118. Your current time limit is <?=ini_get('max_execution_time')?> seconds. This may not be enough if you
  119. intend to email large numbers of subscribers.
  120. <?
  121. }
  122. ?>
  123. </td></tr></table>
  124. <?
  125. }
  126. }
  127. }
  128. elseif ($_GET['do'] == 'logout') {
  129. // ---------------------------- JUST LOGGED-OUT
  130. ?>
  131. <div style="font-size: 14pt;" align="center">txtList admin</div>
  132. <hr width="50%" size="1" noshade color="#cdcdcd">
  133. <p>
  134. <div align="center">
  135. You have been logged-out successfully.
  136. <p>
  137. <a href="admin.php">Click here</a> to log-in again.
  138. </div>
  139. <?
  140. }
  141. else {
  142. // ---------------------------- LOGIN FORM
  143. ?>
  144. <div style="font-size: 14pt;" align="center">txtList admin</div>
  145. <hr width="50%" size="1" noshade color="#cdcdcd">
  146. <p>
  147. <form name="txtlist" action="admin.php?do=<?=$_GET['do']?>" method="post">
  148. <table border="0" cellpadding="4" cellspacing="0" bgcolor="#efefef" align="center" style="border: #dedede 3px double;">
  149. <?=(isset($err))?'<tr><td colspan="2" align="center"><font color="red">'.$err.'</font></td></tr>':''?>
  150. <tr><td>username:</td><td><input type="text" name="uname" value="" size="20" maxlength="100"></td></tr>
  151. <tr><td>password:</td><td><input type="password" name="pword" value="" size="20" maxlength="100"></td></tr>
  152. <tr><td colspan="2" align="center"><input type="submit" name="logsub" value="login"></td></tr>
  153. </table>
  154. </form>
  155. <?
  156. }
  157. // footer
  158. ?>
  159. <br><br><br>
  160. <hr width="300" size="1" noshade color="#cdcdcd">
  161. <div class="smalltxt" align="center">powered by <a href="http://txtbox.co.za/p_txtlist.php">txtList</a> &middot; copyright &copy; 2004, Txtbox</div>
  162.  
  163. </body>
  164. </html>


wyświetla mi cos takiego

Notice: Undefined index: do in /home/compart1/public_html/ok/admin.php on line 18

Notice: Undefined index: do in /home/compart1/public_html/ok/admin.php on line 79

Notice: Undefined index: do in /home/compart1/public_html/ok/admin.php on line 84 Notice: Undefined index: do in /home/compart1/public_html/ok/admin.php on line 88 Notice: Undefined index: do in /home/compart1/public_html/ok/admin.php on line 92 Notice: Undefined index: do in /home/compart1/public_html/ok/admin.php on line 96

Evinek
Po prostu musisz prędzej sprawdzać zmienne.
  1. $type = $_GET['type'];{}

zamień na:
  1. if(!empty($_GET['type'])){
  2. $type = $_GET['type']
  3. }
adri
dalej mi pokazuje błąd

Parse error: syntax error, unexpected '}' in /home/compart1/public_html/ok/index.php on line 11
d.stp
brakuje klamerki w którymś IF-ie
adri
wkleiłem to co kolega tam podpowiedział i pomogło troche ale dalej pokazuje bład

Parse error: syntax error, unexpected '}' in /home/compart1/public_html/ok/index.php on line 11

ale z tego co ja widze ze są chyba wszystkie klamerki zamkniete
albo ja juz slepy jestem
Evinek
foreach ($items as $a => $b) {
if (isset($str)) $str .= ' &middot; ';else $str = '';
$str .= ($a == $item)?'<b>':'<a href="admin.php?do='.$a.'&'.strip_tags(SID).'">';
$str .= $b;
$str .= ($a == $item)?'</b>':'</a>';
}

Tu nawet nie otworzyłeś klamerki... musimy za Ciebie szukać?
Zainstaluj program który koloruje składnie i szukaj... więcej Ci nie będę tak szukał.
Kubaru
Spróbuj zapisać to tak:
  1. if(!empty($_GET['type'])){
  2. $type = $_GET['type'];
  3. }
piotrooo89
nie no zamykam, forum to nie parser...
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.