PageRenderTime 29ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 1ms

/opencart_v1.4/upload/admin/controller/setting/setting.php

http://coderstalk.googlecode.com/
PHP | 715 lines | 574 code | 141 blank | 0 comment | 182 complexity | a22a62a7f66b6eecb48bc94ed144c42b MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.1, AGPL-3.0
  1. <?php
  2. class ControllerSettingSetting extends Controller {
  3. private $error = array();
  4. public function index() {
  5. $this->load->language('setting/setting');
  6. $this->document->title = $this->language->get('heading_title');
  7. $this->load->model('setting/setting');
  8. if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
  9. if ($this->config->get('config_currency_auto')) {
  10. $this->load->model('localisation/currency');
  11. $this->model_localisation_currency->updateCurrencies();
  12. }
  13. $this->model_setting_setting->editSetting('config', $this->request->post);
  14. $this->session->data['success'] = $this->language->get('text_success');
  15. $this->redirect($this->url->https('setting/setting'));
  16. }
  17. $this->data['heading_title'] = $this->language->get('heading_title');
  18. $this->data['text_none'] = $this->language->get('text_none');
  19. $this->data['text_yes'] = $this->language->get('text_yes');
  20. $this->data['text_no'] = $this->language->get('text_no');
  21. $this->data['text_mail'] = $this->language->get('text_mail');
  22. $this->data['text_smtp'] = $this->language->get('text_smtp');
  23. $this->data['text_image_manager'] = $this->language->get('text_image_manager');
  24. $this->data['entry_store'] = $this->language->get('entry_store');
  25. $this->data['entry_title'] = $this->language->get('entry_title');
  26. $this->data['entry_meta_description'] = $this->language->get('entry_meta_description');
  27. $this->data['entry_welcome'] = $this->language->get('entry_welcome');
  28. $this->data['entry_owner'] = $this->language->get('entry_owner');
  29. $this->data['entry_address'] = $this->language->get('entry_address');
  30. $this->data['entry_email'] = $this->language->get('entry_email');
  31. $this->data['entry_telephone'] = $this->language->get('entry_telephone');
  32. $this->data['entry_fax'] = $this->language->get('entry_fax');
  33. $this->data['entry_template'] = $this->language->get('entry_template');
  34. $this->data['entry_country'] = $this->language->get('entry_country');
  35. $this->data['entry_zone'] = $this->language->get('entry_zone');
  36. $this->data['entry_language'] = $this->language->get('entry_language');
  37. $this->data['entry_admin_language'] = $this->language->get('entry_admin_language');
  38. $this->data['entry_currency'] = $this->language->get('entry_currency');
  39. $this->data['entry_currency_auto'] = $this->language->get('entry_currency_auto');
  40. $this->data['entry_tax'] = $this->language->get('entry_tax');
  41. $this->data['entry_weight_class'] = $this->language->get('entry_weight_class');
  42. $this->data['entry_measurement_class'] = $this->language->get('entry_measurement_class');
  43. $this->data['entry_alert_mail'] = $this->language->get('entry_alert_mail');
  44. $this->data['entry_customer_group'] = $this->language->get('entry_customer_group');
  45. $this->data['entry_customer_price'] = $this->language->get('entry_customer_price');
  46. $this->data['entry_customer_approval'] = $this->language->get('entry_customer_approval');
  47. $this->data['entry_guest_checkout'] = $this->language->get('entry_guest_checkout');
  48. $this->data['entry_account'] = $this->language->get('entry_account');
  49. $this->data['entry_checkout'] = $this->language->get('entry_checkout');
  50. $this->data['entry_order_status'] = $this->language->get('entry_order_status');
  51. $this->data['entry_stock_display'] = $this->language->get('entry_stock_display');
  52. $this->data['entry_stock_check'] = $this->language->get('entry_stock_check');
  53. $this->data['entry_stock_checkout'] = $this->language->get('entry_stock_checkout');
  54. $this->data['entry_stock_subtract'] = $this->language->get('entry_stock_subtract');
  55. $this->data['entry_stock_status'] = $this->language->get('entry_stock_status');
  56. $this->data['entry_download'] = $this->language->get('entry_download');
  57. $this->data['entry_download_status'] = $this->language->get('entry_download_status');
  58. $this->data['entry_logo'] = $this->language->get('entry_logo');
  59. $this->data['entry_icon'] = $this->language->get('entry_icon');
  60. $this->data['entry_image_thumb'] = $this->language->get('entry_image_thumb');
  61. $this->data['entry_image_popup'] = $this->language->get('entry_image_popup');
  62. $this->data['entry_image_category'] = $this->language->get('entry_image_category');
  63. $this->data['entry_image_product'] = $this->language->get('entry_image_product');
  64. $this->data['entry_image_additional'] = $this->language->get('entry_image_additional');
  65. $this->data['entry_image_related'] = $this->language->get('entry_image_related');
  66. $this->data['entry_image_cart'] = $this->language->get('entry_image_cart');
  67. $this->data['entry_mail_protocol'] = $this->language->get('entry_mail_protocol');
  68. $this->data['entry_smtp_host'] = $this->language->get('entry_smtp_host');
  69. $this->data['entry_smtp_username'] = $this->language->get('entry_smtp_username');
  70. $this->data['entry_smtp_password'] = $this->language->get('entry_smtp_password');
  71. $this->data['entry_smtp_port'] = $this->language->get('entry_smtp_port');
  72. $this->data['entry_smtp_timeout'] = $this->language->get('entry_smtp_timeout');
  73. $this->data['entry_ssl'] = $this->language->get('entry_ssl');
  74. $this->data['entry_encryption'] = $this->language->get('entry_encryption');
  75. $this->data['entry_seo_url'] = $this->language->get('entry_seo_url');
  76. $this->data['entry_compression'] = $this->language->get('entry_compression');
  77. $this->data['entry_error_display'] = $this->language->get('entry_error_display');
  78. $this->data['entry_error_log'] = $this->language->get('entry_error_log');
  79. $this->data['entry_error_filename'] = $this->language->get('entry_error_filename');
  80. $this->data['button_save'] = $this->language->get('button_save');
  81. $this->data['button_cancel'] = $this->language->get('button_cancel');
  82. $this->data['tab_shop'] = $this->language->get('tab_shop');
  83. $this->data['tab_local'] = $this->language->get('tab_local');
  84. $this->data['tab_option'] = $this->language->get('tab_option');
  85. $this->data['tab_image'] = $this->language->get('tab_image');
  86. $this->data['tab_mail'] = $this->language->get('tab_mail');
  87. $this->data['tab_server'] = $this->language->get('tab_server');
  88. if (isset($this->error['warning'])) {
  89. $this->data['error_warning'] = $this->error['warning'];
  90. } else {
  91. $this->data['error_warning'] = '';
  92. }
  93. if (isset($this->error['store'])) {
  94. $this->data['error_store'] = $this->error['store'];
  95. } else {
  96. $this->data['error_store'] = '';
  97. }
  98. if (isset($this->error['title'])) {
  99. $this->data['error_title'] = $this->error['title'];
  100. } else {
  101. $this->data['error_title'] = '';
  102. }
  103. if (isset($this->error['error_filename'])) {
  104. $this->data['error_error_filename'] = $this->error['error_filename'];
  105. } else {
  106. $this->data['error_error_filename'] = '';
  107. }
  108. if (isset($this->error['owner'])) {
  109. $this->data['error_owner'] = $this->error['owner'];
  110. } else {
  111. $this->data['error_owner'] = '';
  112. }
  113. if (isset($this->error['address'])) {
  114. $this->data['error_address'] = $this->error['address'];
  115. } else {
  116. $this->data['error_address'] = '';
  117. }
  118. if (isset($this->error['email'])) {
  119. $this->data['error_email'] = $this->error['email'];
  120. } else {
  121. $this->data['error_email'] = '';
  122. }
  123. if (isset($this->error['telephone'])) {
  124. $this->data['error_telephone'] = $this->error['telephone'];
  125. } else {
  126. $this->data['error_telephone'] = '';
  127. }
  128. $this->document->breadcrumbs = array();
  129. $this->document->breadcrumbs[] = array(
  130. 'href' => $this->url->https('common/home'),
  131. 'text' => $this->language->get('text_home'),
  132. 'separator' => FALSE
  133. );
  134. $this->document->breadcrumbs[] = array(
  135. 'href' => $this->url->https('setting/setting'),
  136. 'text' => $this->language->get('heading_title'),
  137. 'separator' => ' :: '
  138. );
  139. if (isset($this->session->data['success'])) {
  140. $this->data['success'] = $this->session->data['success'];
  141. unset($this->session->data['success']);
  142. } else {
  143. $this->data['success'] = '';
  144. }
  145. $this->data['action'] = $this->url->https('setting/setting');
  146. $this->data['cancel'] = $this->url->https('setting/setting');
  147. if (isset($this->request->post['config_store'])) {
  148. $this->data['config_store'] = $this->request->post['config_store'];
  149. } else {
  150. $this->data['config_store'] = $this->config->get('config_store');
  151. }
  152. if (isset($this->request->post['config_title'])) {
  153. $this->data['config_title'] = $this->request->post['config_title'];
  154. } else {
  155. $this->data['config_title'] = $this->config->get('config_title');
  156. }
  157. if (isset($this->request->post['config_meta_description'])) {
  158. $this->data['config_meta_description'] = $this->request->post['config_meta_description'];
  159. } else {
  160. $this->data['config_meta_description'] = $this->config->get('config_meta_description');
  161. }
  162. $this->load->model('localisation/language');
  163. $languages = $this->model_localisation_language->getLanguages();
  164. foreach ($languages as $language) {
  165. if (isset($this->request->post['config_welcome_' . $language['language_id']])) {
  166. $this->data['config_welcome_' . $language['language_id']] = $this->request->post['config_welcome_' . $language['language_id']];
  167. } else {
  168. $this->data['config_welcome_' . $language['language_id']] = $this->config->get('config_welcome_' . $language['language_id']);
  169. }
  170. }
  171. if (isset($this->request->post['config_owner'])) {
  172. $this->data['config_owner'] = $this->request->post['config_owner'];
  173. } else {
  174. $this->data['config_owner'] = $this->config->get('config_owner');
  175. }
  176. if (isset($this->request->post['config_address'])) {
  177. $this->data['config_address'] = $this->request->post['config_address'];
  178. } else {
  179. $this->data['config_address'] = $this->config->get('config_address');
  180. }
  181. if (isset($this->request->post['config_email'])) {
  182. $this->data['config_email'] = $this->request->post['config_email'];
  183. } else {
  184. $this->data['config_email'] = $this->config->get('config_email');
  185. }
  186. if (isset($this->request->post['config_telephone'])) {
  187. $this->data['config_telephone'] = $this->request->post['config_telephone'];
  188. } else {
  189. $this->data['config_telephone'] = $this->config->get('config_telephone');
  190. }
  191. if (isset($this->request->post['config_fax'])) {
  192. $this->data['config_fax'] = $this->request->post['config_fax'];
  193. } else {
  194. $this->data['config_fax'] = $this->config->get('config_fax');
  195. }
  196. $this->data['templates'] = array();
  197. $directories = glob(DIR_CATALOG . 'view/theme/*', GLOB_ONLYDIR);
  198. foreach ($directories as $directory) {
  199. $this->data['templates'][] = basename($directory);
  200. }
  201. if (isset($this->request->post['config_template'])) {
  202. $this->data['config_template'] = $this->request->post['config_template'];
  203. } else {
  204. $this->data['config_template'] = $this->config->get('config_template');
  205. }
  206. if (isset($this->request->post['config_country_id'])) {
  207. $this->data['config_country_id'] = $this->request->post['config_country_id'];
  208. } else {
  209. $this->data['config_country_id'] = $this->config->get('config_country_id');
  210. }
  211. $this->load->model('localisation/country');
  212. $this->data['countries'] = $this->model_localisation_country->getCountries();
  213. if (isset($this->request->post['config_zone_id'])) {
  214. $this->data['config_zone_id'] = $this->request->post['config_zone_id'];
  215. } else {
  216. $this->data['config_zone_id'] = $this->config->get('config_zone_id');
  217. }
  218. if (isset($this->request->post['config_language'])) {
  219. $this->data['config_language'] = $this->request->post['config_language'];
  220. } else {
  221. $this->data['config_language'] = $this->config->get('config_language');
  222. }
  223. if (isset($this->request->post['config_admin_language'])) {
  224. $this->data['config_admin_language'] = $this->request->post['config_admin_language'];
  225. } else {
  226. $this->data['config_admin_language'] = $this->config->get('config_admin_language');
  227. }
  228. $this->load->model('localisation/language');
  229. $this->data['languages'] = $this->model_localisation_language->getLanguages();
  230. if (isset($this->request->post['config_currency'])) {
  231. $this->data['config_currency'] = $this->request->post['config_currency'];
  232. } else {
  233. $this->data['config_currency'] = $this->config->get('config_currency');
  234. }
  235. if (isset($this->request->post['config_currency_auto'])) {
  236. $this->data['config_currency_auto'] = $this->request->post['config_currency_auto'];
  237. } else {
  238. $this->data['config_currency_auto'] = $this->config->get('config_currency_auto');
  239. }
  240. $this->load->model('localisation/currency');
  241. $this->data['currencies'] = $this->model_localisation_currency->getCurrencies();
  242. if (isset($this->request->post['config_tax'])) {
  243. $this->data['config_tax'] = $this->request->post['config_tax'];
  244. } else {
  245. $this->data['config_tax'] = $this->config->get('config_tax');
  246. }
  247. if (isset($this->request->post['config_weight_class_id'])) {
  248. $this->data['config_weight_class_id'] = $this->request->post['config_weight_class_id'];
  249. } else {
  250. $this->data['config_weight_class_id'] = $this->config->get('config_weight_class_id');
  251. }
  252. $this->load->model('localisation/weight_class');
  253. $this->data['weight_classes'] = $this->model_localisation_weight_class->getWeightClasses();
  254. if (isset($this->request->post['config_measurement_class_id'])) {
  255. $this->data['config_measurement_class_id'] = $this->request->post['config_measurement_class_id'];
  256. } else {
  257. $this->data['config_measurement_class_id'] = $this->config->get('config_measurement_class_id');
  258. }
  259. $this->load->model('localisation/measurement_class');
  260. $this->data['measurement_classes'] = $this->model_localisation_measurement_class->getMeasurementClasses();
  261. if (isset($this->request->post['config_alert_mail'])) {
  262. $this->data['config_alert_mail'] = $this->request->post['config_alert_mail'];
  263. } else {
  264. $this->data['config_alert_mail'] = $this->config->get('config_alert_mail');
  265. }
  266. $this->load->model('sale/customer_group');
  267. $this->data['customer_groups'] = $this->model_sale_customer_group->getCustomerGroups();
  268. if (isset($this->request->post['config_customer_group_id'])) {
  269. $this->data['config_customer_group_id'] = $this->request->post['config_customer_group_id'];
  270. } else {
  271. $this->data['config_customer_group_id'] = $this->config->get('config_customer_group_id');
  272. }
  273. if (isset($this->request->post['config_customer_price'])) {
  274. $this->data['config_customer_price'] = $this->request->post['config_customer_price'];
  275. } else {
  276. $this->data['config_customer_price'] = $this->config->get('config_customer_price');
  277. }
  278. if (isset($this->request->post['config_customer_approval'])) {
  279. $this->data['config_customer_approval'] = $this->request->post['config_customer_approval'];
  280. } else {
  281. $this->data['config_customer_approval'] = $this->config->get('config_customer_approval');
  282. }
  283. if (isset($this->request->post['config_guest_checkout'])) {
  284. $this->data['config_guest_checkout'] = $this->request->post['config_guest_checkout'];
  285. } else {
  286. $this->data['config_guest_checkout'] = $this->config->get('config_guest_checkout');
  287. }
  288. if (isset($this->request->post['config_account'])) {
  289. $this->data['config_account'] = $this->request->post['config_account'];
  290. } else {
  291. $this->data['config_account'] = $this->config->get('config_account');
  292. }
  293. if (isset($this->request->post['config_checkout'])) {
  294. $this->data['config_checkout'] = $this->request->post['config_checkout'];
  295. } else {
  296. $this->data['config_checkout'] = $this->config->get('config_checkout');
  297. }
  298. $this->load->model('catalog/information');
  299. $this->data['informations'] = $this->model_catalog_information->getInformations();
  300. if (isset($this->request->post['config_stock_display'])) {
  301. $this->data['config_stock_display'] = $this->request->post['config_stock_display'];
  302. } else {
  303. $this->data['config_stock_display'] = $this->config->get('config_stock_display');
  304. }
  305. if (isset($this->request->post['config_stock_check'])) {
  306. $this->data['config_stock_check'] = $this->request->post['config_stock_check'];
  307. } else {
  308. $this->data['config_stock_check'] = $this->config->get('config_stock_check');
  309. }
  310. if (isset($this->request->post['config_stock_checkout'])) {
  311. $this->data['config_stock_checkout'] = $this->request->post['config_stock_checkout'];
  312. } else {
  313. $this->data['config_stock_checkout'] = $this->config->get('config_stock_checkout');
  314. }
  315. if (isset($this->request->post['config_stock_subtract'])) {
  316. $this->data['config_stock_subtract'] = $this->request->post['config_stock_subtract'];
  317. } else {
  318. $this->data['config_stock_subtract'] = $this->config->get('config_stock_subtract');
  319. }
  320. $this->load->model('localisation/order_status');
  321. $this->data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
  322. if (isset($this->request->post['config_order_status_id'])) {
  323. $this->data['config_order_status_id'] = $this->request->post['config_order_status_id'];
  324. } else {
  325. $this->data['config_order_status_id'] = $this->config->get('config_order_status_id');
  326. }
  327. $this->load->model('localisation/stock_status');
  328. $this->data['stock_statuses'] = $this->model_localisation_stock_status->getStockStatuses();
  329. if (isset($this->request->post['config_stock_status_id'])) {
  330. $this->data['config_stock_status_id'] = $this->request->post['config_stock_status_id'];
  331. } else {
  332. $this->data['config_stock_status_id'] = $this->config->get('config_stock_status_id');
  333. }
  334. if (isset($this->request->post['config_download'])) {
  335. $this->data['config_download'] = $this->request->post['config_download'];
  336. } else {
  337. $this->data['config_download'] = $this->config->get('config_download');
  338. }
  339. if (isset($this->request->post['config_download_status'])) {
  340. $this->data['config_download_status'] = $this->request->post['config_download_status'];
  341. } else {
  342. $this->data['config_download_status'] = $this->config->get('config_download_status');
  343. }
  344. $this->load->helper('image');
  345. $this->data['config_logo'] = $this->config->get('config_logo');
  346. if ($this->config->get('config_logo') && file_exists(DIR_IMAGE . $this->config->get('config_logo'))) {
  347. if ((isset($this->request->server['HTTPS'])) && ($this->request->server['HTTPS'] == 'on')) {
  348. $this->data['preview_logo'] = HTTPS_IMAGE . $this->config->get('config_logo');
  349. } else {
  350. $this->data['preview_logo'] = HTTP_IMAGE . $this->config->get('config_logo');
  351. }
  352. } else {
  353. $this->data['preview_logo'] = image_resize('no_image.jpg', 100, 100);
  354. }
  355. $this->data['config_icon'] = $this->config->get('config_icon');
  356. if ($this->config->get('config_icon') && file_exists(DIR_IMAGE . $this->config->get('config_icon'))) {
  357. if ((isset($this->request->server['HTTPS'])) && ($this->request->server['HTTPS'] == 'on')) {
  358. $this->data['preview_icon'] = HTTPS_IMAGE . $this->config->get('config_icon');
  359. } else {
  360. $this->data['preview_icon'] = HTTP_IMAGE . $this->config->get('config_icon');
  361. }
  362. } else {
  363. $this->data['preview_icon'] = image_resize('no_image.jpg', 100, 100);
  364. }
  365. if (isset($this->request->post['config_image_thumb_width'])) {
  366. $this->data['config_image_thumb_width'] = $this->request->post['config_image_thumb_width'];
  367. } else {
  368. $this->data['config_image_thumb_width'] = $this->config->get('config_image_thumb_width');
  369. }
  370. if (isset($this->request->post['config_image_thumb_height'])) {
  371. $this->data['config_image_thumb_height'] = $this->request->post['config_image_thumb_height'];
  372. } else {
  373. $this->data['config_image_thumb_height'] = $this->config->get('config_image_thumb_height');
  374. }
  375. if (isset($this->request->post['config_image_popup_width'])) {
  376. $this->data['config_image_popup_width'] = $this->request->post['config_image_popup_width'];
  377. } else {
  378. $this->data['config_image_popup_width'] = $this->config->get('config_image_popup_width');
  379. }
  380. if (isset($this->request->post['config_image_popup_height'])) {
  381. $this->data['config_image_popup_height'] = $this->request->post['config_image_popup_height'];
  382. } else {
  383. $this->data['config_image_popup_height'] = $this->config->get('config_image_popup_height');
  384. }
  385. if (isset($this->request->post['config_image_category_width'])) {
  386. $this->data['config_image_category_width'] = $this->request->post['config_image_category_width'];
  387. } else {
  388. $this->data['config_image_category_width'] = $this->config->get('config_image_category_width');
  389. }
  390. if (isset($this->request->post['config_image_category_height'])) {
  391. $this->data['config_image_category_height'] = $this->request->post['config_image_category_height'];
  392. } else {
  393. $this->data['config_image_category_height'] = $this->config->get('config_image_category_height');
  394. }
  395. if (isset($this->request->post['config_image_product_width'])) {
  396. $this->data['config_image_product_width'] = $this->request->post['config_image_product_width'];
  397. } else {
  398. $this->data['config_image_product_width'] = $this->config->get('config_image_product_width');
  399. }
  400. if (isset($this->request->post['config_image_product_height'])) {
  401. $this->data['config_image_product_height'] = $this->request->post['config_image_product_height'];
  402. } else {
  403. $this->data['config_image_product_height'] = $this->config->get('config_image_product_height');
  404. }
  405. if (isset($this->request->post['config_image_additional_width'])) {
  406. $this->data['config_image_additional_width'] = $this->request->post['config_image_additional_width'];
  407. } else {
  408. $this->data['config_image_additional_width'] = $this->config->get('config_image_additional_width');
  409. }
  410. if (isset($this->request->post['config_image_additional_height'])) {
  411. $this->data['config_image_additional_height'] = $this->request->post['config_image_additional_height'];
  412. } else {
  413. $this->data['config_image_additional_height'] = $this->config->get('config_image_additional_height');
  414. }
  415. if (isset($this->request->post['config_image_related_width'])) {
  416. $this->data['config_image_related_width'] = $this->request->post['config_image_related_width'];
  417. } else {
  418. $this->data['config_image_related_width'] = $this->config->get('config_image_related_width');
  419. }
  420. if (isset($this->request->post['config_image_related_height'])) {
  421. $this->data['config_image_related_height'] = $this->request->post['config_image_related_height'];
  422. } else {
  423. $this->data['config_image_related_height'] = $this->config->get('config_image_related_height');
  424. }
  425. if (isset($this->request->post['config_image_cart_width'])) {
  426. $this->data['config_image_cart_width'] = $this->request->post['config_image_cart_width'];
  427. } else {
  428. $this->data['config_image_cart_width'] = $this->config->get('config_image_cart_width');
  429. }
  430. if (isset($this->request->post['config_image_cart_height'])) {
  431. $this->data['config_image_cart_height'] = $this->request->post['config_image_cart_height'];
  432. } else {
  433. $this->data['config_image_cart_height'] = $this->config->get('config_image_cart_height');
  434. }
  435. if (isset($this->request->post['config_mail_protocol'])) {
  436. $this->data['config_mail_protocol'] = $this->request->post['config_mail_protocol'];
  437. } else {
  438. $this->data['config_mail_protocol'] = $this->config->get('config_mail_protocol');
  439. }
  440. if (isset($this->request->post['config_smtp_host'])) {
  441. $this->data['config_smtp_host'] = $this->request->post['config_smtp_host'];
  442. } else {
  443. $this->data['config_smtp_host'] = $this->config->get('config_smtp_host');
  444. }
  445. if (isset($this->request->post['config_smtp_username'])) {
  446. $this->data['config_smtp_username'] = $this->request->post['config_smtp_username'];
  447. } else {
  448. $this->data['config_smtp_username'] = $this->config->get('config_smtp_username');
  449. }
  450. if (isset($this->request->post['config_smtp_password'])) {
  451. $this->data['config_smtp_password'] = $this->request->post['config_smtp_password'];
  452. } else {
  453. $this->data['config_smtp_password'] = $this->config->get('config_smtp_password');
  454. }
  455. if (isset($this->request->post['config_smtp_port'])) {
  456. $this->data['config_smtp_port'] = $this->request->post['config_smtp_port'];
  457. } elseif ($this->config->get('config_smtp_port')) {
  458. $this->data['config_smtp_port'] = $this->config->get('config_smtp_port');
  459. } else {
  460. $this->data['config_smtp_port'] = 25;
  461. }
  462. if (isset($this->request->post['config_smtp_timeout'])) {
  463. $this->data['config_smtp_timeout'] = $this->request->post['config_smtp_timeout'];
  464. } elseif ($this->config->get('config_smtp_timeout')) {
  465. $this->data['config_smtp_timeout'] = $this->config->get('config_smtp_timeout');
  466. } else {
  467. $this->data['config_smtp_timeout'] = 5;
  468. }
  469. if (isset($this->request->post['config_ssl'])) {
  470. $this->data['config_ssl'] = $this->request->post['config_ssl'];
  471. } else {
  472. $this->data['config_ssl'] = $this->config->get('config_ssl');
  473. }
  474. if (isset($this->request->post['config_encryption'])) {
  475. $this->data['config_encryption'] = $this->request->post['config_encryption'];
  476. } else {
  477. $this->data['config_encryption'] = $this->config->get('config_encryption');
  478. }
  479. if (isset($this->request->post['config_seo_url'])) {
  480. $this->data['config_seo_url'] = $this->request->post['config_seo_url'];
  481. } else {
  482. $this->data['config_seo_url'] = $this->config->get('config_seo_url');
  483. }
  484. if (isset($this->request->post['config_compression'])) {
  485. $this->data['config_compression'] = $this->request->post['config_compression'];
  486. } else {
  487. $this->data['config_compression'] = $this->config->get('config_compression');
  488. }
  489. if (isset($this->request->post['config_error_display'])) {
  490. $this->data['config_error_display'] = $this->request->post['config_error_display'];
  491. } else {
  492. $this->data['config_error_display'] = $this->config->get('config_error_display');
  493. }
  494. if (isset($this->request->post['config_error_log'])) {
  495. $this->data['config_error_log'] = $this->request->post['config_error_log'];
  496. } else {
  497. $this->data['config_error_log'] = $this->config->get('config_error_log');
  498. }
  499. if (isset($this->request->post['config_error_filename'])) {
  500. $this->data['config_error_filename'] = $this->request->post['config_error_filename'];
  501. } else {
  502. $this->data['config_error_filename'] = $this->config->get('config_error_filename');
  503. }
  504. $this->template = 'setting/setting.tpl';
  505. $this->children = array(
  506. 'common/header',
  507. 'common/footer'
  508. );
  509. $this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
  510. }
  511. private function validate() {
  512. if (!$this->user->hasPermission('modify', 'setting/setting')) {
  513. $this->error['warning'] = $this->language->get('error_permission');
  514. }
  515. if (!$this->request->post['config_store']) {
  516. $this->error['store'] = $this->language->get('error_store');
  517. }
  518. if (!$this->request->post['config_title']) {
  519. $this->error['title'] = $this->language->get('error_title');
  520. }
  521. if ((strlen(utf8_decode($this->request->post['config_owner'])) < 3) || (strlen(utf8_decode($this->request->post['config_owner'])) > 64)) {
  522. $this->error['owner'] = $this->language->get('error_owner');
  523. }
  524. if ((strlen(utf8_decode($this->request->post['config_address'])) < 3) || (strlen(utf8_decode($this->request->post['config_address'])) > 128)) {
  525. $this->error['address'] = $this->language->get('error_address');
  526. }
  527. $pattern = '/^[A-Z0-9._%-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z]{2,6}$/i';
  528. if ((strlen(utf8_decode($this->request->post['config_email'])) > 32) || (!preg_match($pattern, $this->request->post['config_email']))) {
  529. $this->error['email'] = $this->language->get('error_email');
  530. }
  531. if ((strlen(utf8_decode($this->request->post['config_telephone'])) < 3) || (strlen(utf8_decode($this->request->post['config_telephone'])) > 32)) {
  532. $this->error['telephone'] = $this->language->get('error_telephone');
  533. }
  534. if (!$this->request->post['config_error_filename']) {
  535. $this->error['error_filename'] = $this->language->get('error_error_filename');
  536. }
  537. if (!$this->error) {
  538. return TRUE;
  539. } else {
  540. return FALSE;
  541. }
  542. }
  543. public function zone() {
  544. $output = '';
  545. $this->load->model('localisation/zone');
  546. $results = $this->model_localisation_zone->getZonesByCountryId($this->request->get['country_id']);
  547. foreach ($results as $result) {
  548. $output .= '<option value="' . $result['zone_id'] . '"';
  549. if (isset($this->request->get['zone_id']) && ($this->request->get['zone_id'] == $result['zone_id'])) {
  550. $output .= ' selected="selected"';
  551. }
  552. $output .= '>' . $result['name'] . '</option>';
  553. }
  554. if (!$results) {
  555. $output .= '<option value="0">' . $this->language->get('text_none') . '</option>';
  556. }
  557. $this->response->setOutput($output, $this->config->get('config_compression'));
  558. }
  559. public function template() {
  560. $template = basename($this->request->get['template']);
  561. if ((!isset($this->request->server['HTTPS'])) || ($this->request->server['HTTPS'] != 'on')) {
  562. $server = HTTP_IMAGE;
  563. } else {
  564. $server = HTTPS_IMAGE;
  565. }
  566. if (file_exists(DIR_IMAGE . 'templates/' . $template . '.png')) {
  567. $image = $server . 'templates/' . $template . '.png';
  568. } else {
  569. $image = $server . 'no_image.jpg';
  570. }
  571. $this->response->setOutput('<img src="' . $image . '" alt="" title="" style="border: 1px solid #EEEEEE;" />');
  572. }
  573. }
  574. ?>