Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Jak zrobić link ze zmienna?
deejey90
post 21.12.2009, 12:02:48
Post #1





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 17.12.2009

Ostrzeżenie: (0%)
-----


  1. // confirmation sent
  2. if (isset($cfg['returnto_conf']) && $cfg['returnto_conf'] != '') {
  3. header('Location: '.$cfg['returnto_conf']);
  4. }
  5. else {
  6. printf($cfg['template'], 'KLIKNIJ ABY ZATWIERDZIC', 'http://www.club-acme.pl/txtlist/?type=confirm&email='.$addr.' ');
  7. }
  8. }
  9. else {




Chciałbym zrobić z tego link (http://www... )

caly plik index.php


  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'], 'KLIKNIJ ABY ZATWIERDZIC', 'http://www.club-acme.pl/txtlist/?type=confirm&email='.$addr.' ');
  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. ?>



  1. <?
  2. // Change these login details first!
  3. $cfg['uname'] = 'deejey90';
  4. $cfg['pword'] = 'dawidek321';
  5.  
  6. // The default FROM address, and the address subscription confirmation emails will come from.
  7. $cfg['from'] = 'deejey90@gmail.com';
  8.  
  9. // The address to which CC'd emails and test emails will be sent.
  10. $cfg['ccaddress'] = 'deejey90@gmail.com';
  11.  
  12. // When sending, txtList will pause every pauseinterval'th email, for pausetime seconds.
  13. $cfg['pauseinterval'] = 100;
  14.  
  15. // Number of seconds to pause at each pauseinterval.
  16. $cfg['pausetime'] = 3;
  17.  
  18. // The file storing the list of email addresses. Move it for security.
  19. $cfg['listfile'] = 'mailing.txt';
  20.  
  21. // The subject of the confirmation email
  22. $cfg['subj_conf'] = 'Dodawanie e-mailu do newslettera ACME MUSIC CLUB';
  23.  
  24. // The body of the confirmation email. Note the confirmation URL: it must point to the same place
  25. // the subscribe / unsubscribe form does, and the %s characters must appear at the end.
  26. $cfg['msg_conf'] = "Czesc,
  27.  
  28. Aby dodac swoj adres do newslettera strony www.club-acme.pl, wystarczy kliknac w link.
  29.  
  30. link: <a href="http://www.club-acme.pl/txtlist/%s&quot;;" target="_blank">http://www.club-acme.pl/txtlist/%s";</a>
  31.  
  32. // These three values are optional URLs to which to redirect, instead of displaying the default
  33. // success messages. Currently, error messages are always displayed in the standard
  34. // template. Note: URLs must be absolute, e.g. <a href="http://mysite.com/subscribe.html" target="_blank">http://mysite.com/subscribe.html</a>, not subscribe.html
  35.  
  36. // Page to redirect to after confirmation email is sent.
  37. $cfg['returnto_conf'] = '';
  38.  
  39. // Page to redirect to after successful subscription.
  40. $cfg['returnto_sub'] = '';
  41.  
  42. // Page to redirect to after unsubscription.
  43. $cfg['returnto_unsub'] = '';
  44.  
  45. // This is the default template for success and error pages. The two '%s' identifiers are replaced
  46. // by the title and body of the page, in that order. Use %% to represent literal %.
  47. $cfg['template'] = '
  48. <html><head><title>Newsletter: %s</title>
  49. <style type="text/css">
  50. body {font-family: Arial; font-size: 10pt;}
  51. .smalltxt A {font-size: 8pt; color: #cdcdcd;position:absolute;top:85%%;left:65%%}
  52. </style></head><body>
  53. <div align="center">
  54. %s
  55. <br><br><br><br><a href="java script:window.close()">Close</a></div><br><div align="right" class="smalltxt"><a href="http://www.club-acme.pl" target="_new"> deejey90</a></div></body></html>';
  56.  
  57. // Additional headers to apply to outgoing emails.
  58. $cfg['headers'][] = 'Mime-Version: 1.0';
  59. $cfg['headers'][] = 'Content-Transfer-Encoding: 8bit';
  60.  
  61. // The HTML and plaintext headers are applied depending on the mail type. You may need to change
  62. // the charset attribute if you use a different character set.
  63. $cfg['header_html'] = 'Content-type: text/html; charset="iso-8859-1"';
  64. $cfg['header_plain'] = 'Content-type: text/plain; charset="iso-8859-1"';
  65.  
  66. // Specifies whether to archive emails sent to the list. This must be on for send resuming to be an
  67. // option. true = on, false = off.
  68. $cfg['savemail'] = true;
  69.  
  70. // Specifies the directory to which to save archived emails. Do not include a trailing slash!
  71. // If you want to indicate the current directory, use '.'
  72. $cfg['savemailto'] = 'archive';
  73.  
  74. // Specifies whether to save resume data as emails are sent. If disabled, you cannot
  75. // resume a failed send. This option has no effect unless savemail is on. true = on, false = off.
  76. $cfg['enableresume'] = true;
  77.  
  78. ?>



okienko ktore wyskakuje po wpisaniu adresu email

  1. <html><head><title>Newsletter: KLIKNIJ ABY ZATWIERDZIC</title>
  2. <style type="text/css">
  3. body {font-family: Arial; font-size: 10pt;}
  4. .smalltxt A {font-size: 8pt; color: #cdcdcd;position:absolute;top:85%;left:65%}
  5. <div align="center">
  6. <a href="http://www.club-acme.pl/txtlist/?type=conf...=deejeyff@o2.pl" target="_blank">http://www.club-acme.pl/txtlist/?type=conf...=deejeyff@o2.pl</a>
  7. <br><br><br><br><a href="java script:window.close()">Close</a></div><br><div align="right" class="smalltxt"><a href="http://www.club-acme.pl" target="_new"> deejey90</a></div></body></html>




Podpowie mi ktoś jak to zmienic? Dopiero się ucze , a nawet w necie nie ma nic na ten temat.... Wszedzie piszą że trzeba użyć <a href="link" target="_new">tekst</a> i itp a mi wtedy wyskakuje ze jest blad w 44 linijce...
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
lessi
post 21.12.2009, 16:10:38
Post #2





Grupa: Zarejestrowani
Postów: 89
Pomógł: 12
Dołączył: 1.12.2009

Ostrzeżenie: (0%)
-----


Nie czytałem za bardzo co tam napisałeś. Ale z tego co widzę próbujesz w zmiennej zapisać treść a w niej link. Masz błąd składni echo. Jeżeli używasz echo z cudzysłowem to cudzysłów musi być tylko na końcu i na początku określania zawartości zmiennej. Tak więc twoje:
  1. $cfg['msg_conf'] = "Czesc,
  2. Aby dodac swoj adres do newslettera strony www.club-acme.pl, wystarczy kliknac w link.
  3. link: <a href="http://www.club-acme.pl/txtlist/%s&quot;;" target="_blank">http://www.club-acme.pl/txtlist/%s";</a>
  4. $cfg['returnto_conf'] = '';
  5. $cfg['returnto_sub'] = '';
  6. $cfg['returnto_unsub'] = '';

Jest nie poprawne. I jeszcze jedno
  1. $cfg['returnto_sub'] = '';

Masz tylko jeden cudzysłów a gdzie zawartość albo zamknięcie cudzysłowowa (chyba tak się to pisze).

Ja uważam że powinno to być tak
  1. $cfg['msg_conf'] = "Czesc,
  2. Aby dodac swoj adres do newslettera strony www.club-acme.pl, wystarczy kliknac w link.
  3. link: <a href=\"http://www.club-acme.pl/txtlist/%s&quot;;\" target=\"_blank\">http://www.club-acme.pl/txtlist/%s</a>";
  4. $cfg['returnto_conf'] = "Wartość";
  5. //lub
  6. $cfg['returnto_conf'] = "";

Chyba to tak powinno być jeżeli nie to napisz. Albo niech ktoś inny sprawdzi.
Ja całości nie sprawdzałem bo za bardzo nie mam czasu
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 07:48