Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [MyBB] Inny formularz kontaktowy
mbujak
post 21.03.2011, 01:50:24
Post #1





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 20.03.2011

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


Witam. Nie do końca wiedziałem w którym miejscu napisać, proszę o przeniesienie tematu jeśli wybrałem zły dział.
Mam własne forum a na nim formularz kontaktowy poprzez który użytkownicy wysyłają różnego rodzaju informacje (np. o błędach) na email administratora. Jest to trochę uciążliwe, ponieważ dostęp do tego maila mam tylko ja, a jako że zgłoszenia użytkowników dotyczą wielu kwestii, nie są one kontrolowanych przez jedną osobę. doszedłem do wniosku że lepszą metodą byłoby tworzenie wątków w wyznaczonym dziale zamiast wysyłanie emaili, wtedy wszyscy mieliby dostęp do zgłoszeń i zajmowali się tymi którymi powinni.
Kod formularza wygląda w ten sposób:
  1. <?php
  2.  
  3. global $headerinclude, $header, $theme, $footer, $templates, $lang;
  4.  
  5. $lang->load('member');
  6. $lang->load('messages');
  7. $lang->load('datahandler_user');
  8.  
  9. $subject = htmlspecialchars_uni(trim($mybb->input['subject']));
  10. $message = htmlspecialchars_uni(trim($mybb->input['message']));
  11.  
  12. if(!$mybb->user['uid'])
  13. {
  14. $name = htmlspecialchars_uni(trim($mybb->input['name']));
  15. $email = htmlspecialchars_uni(trim($mybb->input['email']));
  16.  
  17. $usertemplate = '<tr>
  18. <td width="40%" class="trow1"><strong>{$lang->full_name}</strong></td>
  19. <td width="60%" class="trow1"><input type="text" class="textbox" size="50" name="name" value="{$name}" /></td>
  20. </tr>
  21. <tr>
  22. <td width="40%" class="trow2"><strong>{$lang->email_address}</strong></td>
  23. <td width="60%" class="trow2"><input type="text" class="textbox" size="50" name="email" value="{$email}" /></td>
  24. </tr>';
  25.  
  26. $usertemplate = str_replace("\'", "'", addslashes($usertemplate));
  27.  
  28. eval("\$usertemplate = \"" . $usertemplate . "\";");
  29. }
  30. else
  31. {
  32. $name = $mybb->user['username'];
  33. $email = $mybb->user['email'];
  34.  
  35. eval("\$usertemplate = \"" . $templates->get('changeuserbox') . "\";");
  36. }
  37.  
  38. if($mybb->input['action'] == 'do_email' && $mybb->request_method == 'post')
  39. {
  40. verify_post_check($mybb->input['my_post_key']);
  41.  
  42. if(empty($name))
  43. {
  44. $errors[] = $lang->userdata_missing_username;
  45. }
  46. elseif(strpos($name, '<') !== false || strpos($name, '>') !== false || strpos($name, '&') !== false || my_strpos($name, '\\') !== false || strpos($name, ';') !== false || strpos($name, ',') !== false)
  47. {
  48. $errors[] = $lang->userdata_bad_characters_username;
  49. }
  50.  
  51. if(empty($email))
  52. {
  53. $errors[] = $lang->userdata_missing_email;
  54. }
  55. elseif(!validate_email_format($email))
  56. {
  57. $errors[] = $lang->userdata_invalid_email_format;
  58. }
  59.  
  60. if(empty($subject))
  61. {
  62. $errors[] = $lang->error_no_email_subject;
  63. }
  64.  
  65. if(empty($message))
  66. {
  67. $errors[] = $lang->error_no_email_message;
  68. }
  69.  
  70. if($mybb->settings['captchaimage'] == 1 && function_exists("imagepng") && !$mybb->user['uid'])
  71. {
  72. $imagehash = $db->escape_string($mybb->input['imagehash']);
  73. $imagestring = $db->escape_string($mybb->input['imagestring']);
  74. $query = $db->simple_select('captcha', '*', 'imagehash="' . $imagehash . '"');
  75. $imgcheck = $db->fetch_array($query);
  76. if(my_strtolower($imgcheck['imagestring']) != my_strtolower($imagestring) || !$imgcheck['imagehash'])
  77. {
  78. $errors[] = $lang->error_regimageinvalid;
  79. }
  80. $db->delete_query('captcha', 'imagehash="' . $imagehash . '"');
  81. }
  82.  
  83. if(count($errors) == 0)
  84. {
  85. if($mybb->settings['mail_handler'] == 'smtp')
  86. {
  87. $from = $email;
  88. }
  89. else
  90. {
  91. $from = $name . ' <' . $email . '>';
  92. }
  93. my_mail($mybb->settings['adminemail'], '[' . $mybb->settings['bbname'] . ' ' . $pages['name'] . '] ' . $subject, $message, $from, '', '', false, 'text', '', $email);
  94.  
  95. redirect($mybb->settings['bburl'], $lang->redirect_emailsent);
  96. }
  97. else
  98. {
  99. $errors = inline_error($errors);
  100. }
  101. }
  102.  
  103. if($mybb->settings['captchaimage'] == 1 && function_exists('imagepng') && !$mybb->user['uid'])
  104. {
  105. $randomstr = random_str(5);
  106. $imagehash = md5(random_str(12));
  107. $imagearray= array(
  108. 'imagehash' => $imagehash,
  109. 'imagestring' => $randomstr,
  110. 'dateline' => TIME_NOW
  111. );
  112. $db->insert_query('captcha', $imagearray);
  113. eval("\$captcha = \"" . $templates->get('post_captcha') . "\";");
  114. }
  115.  
  116. $template = '<html>
  117. <head>
  118. <title>' . $pages['name'] . '</title>
  119. {$headerinclude}
  120. </head>
  121. <body>
  122. {$header}
  123. {$errors}
  124. <form action="' . $_SERVER['REQUEST_URI'] . '" method="post">
  125. <input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
  126. <table border="0" cellspacing="' . $theme['borderwidth'] . '" cellpadding="' . $theme['tablespace'] . '" class="tborder">
  127. <thead>
  128. <tr>
  129. <td colspan="2" class="thead">
  130. <strong>' . $pages['name'] . '</strong>
  131. </td>
  132. </tr>
  133. </thead>
  134. <tbody>
  135. {$usertemplate}
  136. <tr>
  137. <td width="40%" class="trow1"><strong>{$lang->email_subject}</strong></td>
  138. <td width="60%" class="trow1"><input type="text" class="textbox" size="50" name="subject" value="{$subject}" /></td>
  139. </tr>
  140. <tr>
  141. <td valign="top" width="40%" class="trow2"><strong>{$lang->email_message}</strong></td>
  142. <td width="60%" class="trow2"><textarea cols="50" rows="10" name="message">{$message}</textarea></td>
  143. </tr>
  144. {$captcha}
  145. </tbody>
  146. </table>
  147. <br />
  148. <input type="hidden" name="action" value="do_email" />
  149. <div align="center"><input type="submit" class="button" value="{$lang->send_email}" /></div>
  150. </form>
  151. {$footer}
  152. </body>
  153. </html>';
  154.  
  155. $template = str_replace("\'", "'", addslashes($template));
  156.  
  157. add_breadcrumb($pages['name']);
  158.  
  159. eval("\$page = \"" . $template . "\";");
  160.  
  161. output_page($page);
  162.  
  163. ?>


Próbowałem to modyfikować po swojemu ale zawsze sypało syntax errorami, więc nie widze sensu wstawiać swoje próby modyfikacji.
Jeśli ktoś jest w stanie pomóc/naprowadzić mnie, byłbym bardzo wdzięczny za wypowiedzenie się w tym temacie.
Pozdrawiam.

PS:
Dodam jeszcze tylko, że nigdy specjalnie nie bawiłem się w PHP w związku z tym mój poziom wiedzy nie należy do wysokich, dopiero od niedawna zacząłem bardziej intensywną naukę.

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: 28.03.2024 - 16:27