PageRenderTime 56ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/opencart/trunk/upload/admin/controller/setting/setting.php

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