Guest User

Untitled

a guest
Dec 10th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.65 KB | None | 0 0
  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20. 100% Скрипт выполенен за 0.10 секунд
  21.  
  22.  
  23. japanese.ftp.ukraine.com.ua
  24.  
  25.  
  26. Просмотр файла contact.php
  27.  
  28.  
  29. <?php
  30. class ControllerInformationContact extends Controller {
  31. private $error = array();
  32.  
  33. public function index() {
  34. $this->language->load('information/contact');
  35.  
  36. $this->document->setTitle($this->language->get('heading_title'));
  37.  
  38. if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
  39. $mail = new Mail();
  40. $mail->protocol = $this->config->get('config_mail_protocol');
  41. $mail->parameter = $this->config->get('config_mail_parameter');
  42. $mail->hostname = $this->config->get('config_smtp_host');
  43. $mail->username = $this->config->get('config_smtp_username');
  44. $mail->password = $this->config->get('config_smtp_password');
  45. $mail->port = $this->config->get('config_smtp_port');
  46. $mail->timeout = $this->config->get('config_smtp_timeout');
  47. $mail->setTo($this->config->get('config_email'));
  48. $mail->setFrom($this->request->post['email']);
  49. $mail->setSender($this->request->post['name']);
  50. $mail->setSubject(sprintf($this->language->get('email_subject'), $this->request->post['name']));
  51. $mail->setText(strip_tags(html_entity_decode($this->request->post['enquiry'], ENT_QUOTES, 'UTF-8')));
  52. $mail->send();
  53.  
  54. $this->redirect($this->url->link('information/contact/success'));
  55. }
  56.  
  57. $this->data['breadcrumbs'] = array();
  58.  
  59. $this->data['breadcrumbs'][] = array(
  60. 'text' => $this->language->get('text_home'),
  61. 'href' => $this->url->link('common/home'),
  62. 'separator' => false
  63. );
  64.  
  65. $this->data['breadcrumbs'][] = array(
  66. 'text' => $this->language->get('heading_title'),
  67. 'href' => $this->url->link('information/contact'),
  68. 'separator' => $this->language->get('text_separator')
  69. );
  70.  
  71. $this->data['heading_title'] = $this->language->get('heading_title');
  72.  
  73. $this->data['text_location'] = $this->language->get('text_location');
  74. $this->data['text_contact'] = $this->language->get('text_contact');
  75. $this->data['text_address'] = $this->language->get('text_address');
  76. $this->data['text_telephone'] = $this->language->get('text_telephone');
  77. $this->data['text_fax'] = $this->language->get('text_fax');
  78.  
  79. $this->data['entry_name'] = $this->language->get('entry_name');
  80. $this->data['entry_email'] = $this->language->get('entry_email');
  81. $this->data['entry_enquiry'] = $this->language->get('entry_enquiry');
  82. $this->data['entry_captcha'] = $this->language->get('entry_captcha');
  83.  
  84. if (isset($this->error['name'])) {
  85. $this->data['error_name'] = $this->error['name'];
  86. } else {
  87. $this->data['error_name'] = '';
  88. }
  89.  
  90. if (isset($this->error['email'])) {
  91. $this->data['error_email'] = $this->error['email'];
  92. } else {
  93. $this->data['error_email'] = '';
  94. }
  95.  
  96. if (isset($this->error['enquiry'])) {
  97. $this->data['error_enquiry'] = $this->error['enquiry'];
  98. } else {
  99. $this->data['error_enquiry'] = '';
  100. }
  101. if (isset($this->error['captcha'])) {
  102. $this->data['error_captcha'] = $this->error['captcha'];
  103. } else {
  104. $this->data['error_captcha'] = '';
  105. }
  106.  
  107. $this->data['button_continue'] = $this->language->get('button_continue');
  108.  
  109. $this->data['action'] = $this->url->link('information/contact');
  110. $this->data['store'] = $this->config->get('config_name');
  111. $this->data['address'] = nl2br($this->config->get('config_address'));
  112. $this->data['telephone'] = $this->config->get('config_telephone');
  113. $this->data['fax'] = $this->config->get('config_fax');
  114.  
  115. if (isset($this->request->post['name'])) {
  116. $this->data['name'] = $this->request->post['name'];
  117. } else {
  118. $this->data['name'] = '';
  119. }
  120.  
  121. if (isset($this->request->post['email'])) {
  122. $this->data['email'] = $this->request->post['email'];
  123. } else {
  124. $this->data['email'] = '';
  125. }
  126.  
  127. if (isset($this->request->post['enquiry'])) {
  128. $this->data['enquiry'] = $this->request->post['enquiry'];
  129. } else {
  130. $this->data['enquiry'] = '';
  131. }
  132.  
  133. if (isset($this->request->post['captcha'])) {
  134. $this->data['captcha'] = $this->request->post['captcha'];
  135. } else {
  136. $this->data['captcha'] = '';
  137. }
  138.  
  139. if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/information/contact.tpl')) {
  140. $this->template = $this->config->get('config_template') . '/template/information/contact.tpl';
  141. } else {
  142. $this->template = 'default/template/information/contact.tpl';
  143. }
  144.  
  145. $this->children = array(
  146. 'common/column_left',
  147. 'common/column_right',
  148. 'common/content_top',
  149. 'common/content_bottom',
  150. 'common/footer',
  151. 'common/header'
  152. );
  153.  
  154. $this->response->setOutput($this->render());
  155. }
  156.  
  157. public function success() {
  158. $this->language->load('information/contact');
  159.  
  160. $this->document->setTitle($this->language->get('heading_title'));
  161.  
  162. $this->data['breadcrumbs'] = array();
  163.  
  164. $this->data['breadcrumbs'][] = array(
  165. 'text' => $this->language->get('text_home'),
  166. 'href' => $this->url->link('common/home'),
  167. 'separator' => false
  168. );
  169.  
  170. $this->data['breadcrumbs'][] = array(
  171. 'text' => $this->language->get('heading_title'),
  172. 'href' => $this->url->link('information/contact'),
  173. 'separator' => $this->language->get('text_separator')
  174. );
  175.  
  176. $this->data['heading_title'] = $this->language->get('heading_title');
  177.  
  178. $this->data['text_message'] = $this->language->get('text_message');
  179.  
  180. $this->data['button_continue'] = $this->language->get('button_continue');
  181.  
  182. $this->data['continue'] = $this->url->link('common/home');
  183.  
  184. if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/success.tpl')) {
  185. $this->template = $this->config->get('config_template') . '/template/common/success.tpl';
  186. } else {
  187. $this->template = 'default/template/common/success.tpl';
  188. }
  189.  
  190. $this->children = array(
  191. 'common/column_left',
  192. 'common/column_right',
  193. 'common/content_top',
  194. 'common/content_bottom',
  195. 'common/footer',
  196. 'common/header'
  197. );
  198.  
  199. $this->response->setOutput($this->render());
  200. }
  201.  
  202. public function captcha() {
  203. $this->load->library('captcha');
  204.  
  205. $captcha = new Captcha();
  206.  
  207. $this->session->data['captcha'] = $captcha->getCode();
  208.  
  209. $captcha->showImage();
  210. }
  211.  
  212. private function validate() {
  213. if ((strlen(utf8_decode($this->request->post['name'])) < 3) || (strlen(utf8_decode($this->request->post['name'])) > 32)) {
  214. $this->error['name'] = $this->language->get('error_name');
  215. }
  216.  
  217. if (!preg_match('/^[^\@]+@.*\.[a-z]{2,6}$/i', $this->request->post['email'])) {
  218. $this->error['email'] = $this->language->get('error_email');
  219. }
  220.  
  221. if ((strlen(utf8_decode($this->request->post['enquiry'])) < 10) || (strlen(utf8_decode($this->request->post['enquiry'])) > 3000)) {
  222. $this->error['enquiry'] = $this->language->get('error_enquiry');
  223. }
  224.  
  225. if (!isset($this->session->data['captcha']) || ($this->session->data['captcha'] != $this->request->post['captcha'])) {
  226. $this->error['captcha'] = $this->language->get('error_captcha');
  227. }
  228.  
  229. if (!$this->error) {
  230. return true;
  231. } else {
  232. return false;
  233. }
  234. }
  235. }
  236. ?>
  237.  
  238. Подсветка синтаксиса реализована GeSHi
  239. Помощь | Форумы| Лицензия
  240. Создано на net2ftp - a web based FTP client
  241. Add to: Del.icio.us | Digg | Reddit
Add Comment
Please, Sign In to add comment