PageRenderTime 45ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/controller/extension/modification.php

https://gitlab.com/reclamare/mao
PHP | 791 lines | 521 code | 207 blank | 63 comment | 118 complexity | c2dc1e6004fdc4727e4b315e453c49ee MD5 | raw file
  1. <?php
  2. /**
  3. * Modifcation XML Documentation can be found here:
  4. *
  5. * https://github.com/opencart/opencart/wiki/Modification-System
  6. */
  7. class ControllerExtensionModification extends Controller {
  8. private $error = array();
  9. public function index() {
  10. $this->load->language('extension/modification');
  11. $this->document->setTitle($this->language->get('heading_title'));
  12. $this->load->model('extension/modification');
  13. $this->getList();
  14. }
  15. public function delete() {
  16. $this->load->language('extension/modification');
  17. $this->document->setTitle($this->language->get('heading_title'));
  18. $this->load->model('extension/modification');
  19. if (isset($this->request->post['selected']) && $this->validate()) {
  20. foreach ($this->request->post['selected'] as $modification_id) {
  21. $this->model_extension_modification->deleteModification($modification_id);
  22. }
  23. $this->session->data['success'] = $this->language->get('text_success');
  24. $url = '';
  25. if (isset($this->request->get['sort'])) {
  26. $url .= '&sort=' . $this->request->get['sort'];
  27. }
  28. if (isset($this->request->get['order'])) {
  29. $url .= '&order=' . $this->request->get['order'];
  30. }
  31. if (isset($this->request->get['page'])) {
  32. $url .= '&page=' . $this->request->get['page'];
  33. }
  34. $this->response->redirect($this->url->link('extension/modification', 'token=' . $this->session->data['token'] . $url, 'SSL'));
  35. }
  36. $this->getList();
  37. }
  38. public function refresh() {
  39. $this->load->language('extension/modification');
  40. $this->document->setTitle($this->language->get('heading_title'));
  41. $this->load->model('extension/modification');
  42. if ($this->validate()) {
  43. // Just before files are deleted, if config settings say maintenance mode is off then turn it on
  44. $maintenance = $this->config->get('config_maintenance');
  45. $this->load->model('setting/setting');
  46. $this->model_setting_setting->editSettingValue('config', 'config_maintenance', true);
  47. //Log
  48. $log = array();
  49. // Clear all modification files
  50. $files = array();
  51. // Make path into an array
  52. $path = array(DIR_MODIFICATION . '*');
  53. // While the path array is still populated keep looping through
  54. while (count($path) != 0) {
  55. $next = array_shift($path);
  56. foreach (glob($next) as $file) {
  57. // If directory add to path array
  58. if (is_dir($file)) {
  59. $path[] = $file . '/*';
  60. }
  61. // Add the file to the files to be deleted array
  62. $files[] = $file;
  63. }
  64. }
  65. // Reverse sort the file array
  66. rsort($files);
  67. // Clear all modification files
  68. foreach ($files as $file) {
  69. if ($file != DIR_MODIFICATION . 'index.html') {
  70. // If file just delete
  71. if (is_file($file)) {
  72. unlink($file);
  73. // If directory use the remove directory function
  74. } elseif (is_dir($file)) {
  75. rmdir($file);
  76. }
  77. }
  78. }
  79. // Begin
  80. $xml = array();
  81. // Load the default modification XML
  82. $xml[] = file_get_contents(DIR_SYSTEM . 'modification.xml');
  83. // This is purly for developers so they can run mods directly and have them run without upload sfter each change.
  84. $files = glob(DIR_SYSTEM . '*.ocmod.xml');
  85. if ($files) {
  86. foreach ($files as $file) {
  87. $xml[] = file_get_contents($file);
  88. }
  89. }
  90. // Get the default modification file
  91. $results = $this->model_extension_modification->getModifications();
  92. foreach ($results as $result) {
  93. if ($result['status']) {
  94. $xml[] = $result['xml'];
  95. }
  96. }
  97. $modification = array();
  98. foreach ($xml as $xml) {
  99. $dom = new DOMDocument('1.0', 'UTF-8');
  100. $dom->preserveWhiteSpace = false;
  101. $dom->loadXml($xml);
  102. // Log
  103. $log[] = 'MOD: ' . $dom->getElementsByTagName('name')->item(0)->textContent;
  104. // Wipe the past modification store in the backup array
  105. $recovery = array();
  106. // Set the a recovery of the modification code in case we need to use it if an abort attribute is used.
  107. if (isset($modification)) {
  108. $recovery = $modification;
  109. }
  110. $files = $dom->getElementsByTagName('modification')->item(0)->getElementsByTagName('file');
  111. foreach ($files as $file) {
  112. $operations = $file->getElementsByTagName('operation');
  113. $files = explode('|', $file->getAttribute('path'));
  114. foreach ($files as $file) {
  115. $path = '';
  116. // Get the full path of the files that are going to be used for modification
  117. if (substr($file, 0, 7) == 'catalog') {
  118. $path = DIR_CATALOG . str_replace('../', '', substr($file, 8));
  119. }
  120. if (substr($file, 0, 5) == 'admin') {
  121. $path = DIR_APPLICATION . str_replace('../', '', substr($file, 6));
  122. }
  123. if (substr($file, 0, 6) == 'system') {
  124. $path = DIR_SYSTEM . str_replace('../', '', substr($file, 7));
  125. }
  126. if ($path) {
  127. $files = glob($path, GLOB_BRACE);
  128. if ($files) {
  129. foreach ($files as $file) {
  130. // Get the key to be used for the modification cache filename.
  131. if (substr($file, 0, strlen(DIR_CATALOG)) == DIR_CATALOG) {
  132. $key = 'catalog/' . substr($file, strlen(DIR_CATALOG));
  133. }
  134. if (substr($file, 0, strlen(DIR_APPLICATION)) == DIR_APPLICATION) {
  135. $key = 'admin/' . substr($file, strlen(DIR_APPLICATION));
  136. }
  137. if (substr($file, 0, strlen(DIR_SYSTEM)) == DIR_SYSTEM) {
  138. $key = 'system/' . substr($file, strlen(DIR_SYSTEM));
  139. }
  140. // If file contents is not already in the modification array we need to load it.
  141. if (!isset($modification[$key])) {
  142. $content = file_get_contents($file);
  143. $modification[$key] = preg_replace('~\r?\n~', "\n", $content);
  144. $original[$key] = preg_replace('~\r?\n~', "\n", $content);
  145. // Log
  146. $log[] = 'FILE: ' . $key;
  147. }
  148. foreach ($operations as $operation) {
  149. $error = $operation->getAttribute('error');
  150. // Ignoreif
  151. $ignoreif = $operation->getElementsByTagName('ignoreif')->item(0);
  152. if ($ignoreif) {
  153. if ($ignoreif->getAttribute('regex') != 'true') {
  154. if (strpos($modification[$key], $ignoreif->textContent) !== false) {
  155. continue;
  156. }
  157. } else {
  158. if (preg_match($ignoreif->textContent, $modification[$key])) {
  159. continue;
  160. }
  161. }
  162. }
  163. $status = false;
  164. // Search and replace
  165. if ($operation->getElementsByTagName('search')->item(0)->getAttribute('regex') != 'true') {
  166. // Search
  167. $search = $operation->getElementsByTagName('search')->item(0)->textContent;
  168. $trim = $operation->getElementsByTagName('search')->item(0)->getAttribute('trim');
  169. $index = $operation->getElementsByTagName('search')->item(0)->getAttribute('index');
  170. // Trim line if no trim attribute is set or is set to true.
  171. if (!$trim || $trim == 'true') {
  172. $search = trim($search);
  173. }
  174. // Add
  175. $add = $operation->getElementsByTagName('add')->item(0)->textContent;
  176. $trim = $operation->getElementsByTagName('add')->item(0)->getAttribute('trim');
  177. $position = $operation->getElementsByTagName('add')->item(0)->getAttribute('position');
  178. $offset = $operation->getElementsByTagName('add')->item(0)->getAttribute('offset');
  179. if ($offset == '') {
  180. $offset = 0;
  181. }
  182. // Trim line if is set to true.
  183. if ($trim == 'true') {
  184. $add = trim($add);
  185. }
  186. // Log
  187. $log[] = 'CODE: ' . $search;
  188. // Check if using indexes
  189. if ($index !== '') {
  190. $indexes = explode(',', $index);
  191. } else {
  192. $indexes = array();
  193. }
  194. // Get all the matches
  195. $i = 0;
  196. $lines = explode("\n", $modification[$key]);
  197. for ($line_id = 0; $line_id < count($lines); $line_id++) {
  198. $line = $lines[$line_id];
  199. // Status
  200. $match = false;
  201. // Check to see if the line matches the search code.
  202. if (stripos($line, $search) !== false) {
  203. // If indexes are not used then just set the found status to true.
  204. if (!$indexes) {
  205. $match = true;
  206. } elseif (in_array($i, $indexes)) {
  207. $match = true;
  208. }
  209. $i++;
  210. }
  211. // Now for replacing or adding to the matched elements
  212. if ($match) {
  213. switch ($position) {
  214. default:
  215. case 'replace':
  216. $new_lines = explode("\n", $add);
  217. if ($offset < 0) {
  218. array_splice($lines, $line_id + $offset, abs($offset) + 1, array(str_replace($search, $add, $line)));
  219. $line_id -= $offset;
  220. } else {
  221. array_splice($lines, $line_id, $offset + 1, array(str_replace($search, $add, $line)));
  222. }
  223. break;
  224. case 'before':
  225. $new_lines = explode("\n", $add);
  226. array_splice($lines, $line_id - $offset, 0, $new_lines);
  227. $line_id += count($new_lines);
  228. break;
  229. case 'after':
  230. $new_lines = explode("\n", $add);
  231. array_splice($lines, ($line_id + 1) + $offset, 0, $new_lines);
  232. $line_id += count($new_lines);
  233. break;
  234. }
  235. // Log
  236. $log[] = 'LINE: ' . $line_id;
  237. $status = true;
  238. }
  239. }
  240. $modification[$key] = implode("\n", $lines);
  241. } else {
  242. $search = trim($operation->getElementsByTagName('search')->item(0)->textContent);
  243. $limit = $operation->getElementsByTagName('search')->item(0)->getAttribute('limit');
  244. $replace = trim($operation->getElementsByTagName('add')->item(0)->textContent);
  245. // Limit
  246. if (!$limit) {
  247. $limit = -1;
  248. }
  249. // Log
  250. $match = array();
  251. preg_match_all($search, $modification[$key], $match, PREG_OFFSET_CAPTURE);
  252. // Remove part of the the result if a limit is set.
  253. if ($limit > 0) {
  254. $match[0] = array_slice($match[0], 0, $limit);
  255. }
  256. if ($match[0]) {
  257. $log[] = 'REGEX: ' . $search;
  258. for ($i = 0; $i < count($match[0]); $i++) {
  259. $log[] = 'LINE: ' . (substr_count(substr($modification[$key], 0, $match[0][$i][1]), "\n") + 1);
  260. }
  261. $status = true;
  262. }
  263. // Make the modification
  264. $modification[$key] = preg_replace($search, $replace, $modification[$key], $limit);
  265. }
  266. if (!$status) {
  267. // Log
  268. $log[] = 'NOT FOUND!';
  269. // Skip current operation
  270. if ($error == 'skip') {
  271. break;
  272. }
  273. // Abort applying this modification completely.
  274. if ($error == 'abort') {
  275. $modification = $recovery;
  276. // Log
  277. $log[] = 'ABORTING!';
  278. break 5;
  279. }
  280. }
  281. }
  282. }
  283. }
  284. }
  285. }
  286. }
  287. // Log
  288. $log[] = '----------------------------------------------------------------';
  289. }
  290. // Log
  291. $ocmod = new Log('ocmod.log');
  292. $ocmod->write(implode("\n", $log));
  293. // Write all modification files
  294. foreach ($modification as $key => $value) {
  295. // Only create a file if there are changes
  296. if ($original[$key] != $value) {
  297. $path = '';
  298. $directories = explode('/', dirname($key));
  299. foreach ($directories as $directory) {
  300. $path = $path . '/' . $directory;
  301. if (!is_dir(DIR_MODIFICATION . $path)) {
  302. @mkdir(DIR_MODIFICATION . $path, 0777);
  303. }
  304. }
  305. $handle = fopen(DIR_MODIFICATION . $key, 'w');
  306. fwrite($handle, $value);
  307. fclose($handle);
  308. }
  309. }
  310. // Maintance mode back to original settings
  311. $this->model_setting_setting->editSettingValue('config', 'config_maintenance', $maintenance);
  312. $this->session->data['success'] = $this->language->get('text_success');
  313. $url = '';
  314. if (isset($this->request->get['sort'])) {
  315. $url .= '&sort=' . $this->request->get['sort'];
  316. }
  317. if (isset($this->request->get['order'])) {
  318. $url .= '&order=' . $this->request->get['order'];
  319. }
  320. if (isset($this->request->get['page'])) {
  321. $url .= '&page=' . $this->request->get['page'];
  322. }
  323. $this->response->redirect($this->url->link('extension/modification', 'token=' . $this->session->data['token'] . $url, 'SSL'));
  324. }
  325. $this->getList();
  326. }
  327. public function clear() {
  328. $this->load->language('extension/modification');
  329. $this->document->setTitle($this->language->get('heading_title'));
  330. $this->load->model('extension/modification');
  331. if ($this->validate()) {
  332. $files = array();
  333. // Make path into an array
  334. $path = array(DIR_MODIFICATION . '*');
  335. // While the path array is still populated keep looping through
  336. while (count($path) != 0) {
  337. $next = array_shift($path);
  338. foreach (glob($next) as $file) {
  339. // If directory add to path array
  340. if (is_dir($file)) {
  341. $path[] = $file . '/*';
  342. }
  343. // Add the file to the files to be deleted array
  344. $files[] = $file;
  345. }
  346. }
  347. // Reverse sort the file array
  348. rsort($files);
  349. // Clear all modification files
  350. foreach ($files as $file) {
  351. if ($file != DIR_MODIFICATION . 'index.html') {
  352. // If file just delete
  353. if (is_file($file)) {
  354. unlink($file);
  355. // If directory use the remove directory function
  356. } elseif (is_dir($file)) {
  357. rmdir($file);
  358. }
  359. }
  360. }
  361. $this->session->data['success'] = $this->language->get('text_success');
  362. $url = '';
  363. if (isset($this->request->get['sort'])) {
  364. $url .= '&sort=' . $this->request->get['sort'];
  365. }
  366. if (isset($this->request->get['order'])) {
  367. $url .= '&order=' . $this->request->get['order'];
  368. }
  369. if (isset($this->request->get['page'])) {
  370. $url .= '&page=' . $this->request->get['page'];
  371. }
  372. $this->response->redirect($this->url->link('extension/modification', 'token=' . $this->session->data['token'] . $url, 'SSL'));
  373. }
  374. $this->getList();
  375. }
  376. public function enable() {
  377. $this->load->language('extension/modification');
  378. $this->document->setTitle($this->language->get('heading_title'));
  379. $this->load->model('extension/modification');
  380. if (isset($this->request->get['modification_id']) && $this->validate()) {
  381. $this->model_extension_modification->enableModification($this->request->get['modification_id']);
  382. $this->session->data['success'] = $this->language->get('text_success');
  383. $url = '';
  384. if (isset($this->request->get['sort'])) {
  385. $url .= '&sort=' . $this->request->get['sort'];
  386. }
  387. if (isset($this->request->get['order'])) {
  388. $url .= '&order=' . $this->request->get['order'];
  389. }
  390. if (isset($this->request->get['page'])) {
  391. $url .= '&page=' . $this->request->get['page'];
  392. }
  393. $this->response->redirect($this->url->link('extension/modification', 'token=' . $this->session->data['token'] . $url, 'SSL'));
  394. }
  395. $this->getList();
  396. }
  397. public function disable() {
  398. $this->load->language('extension/modification');
  399. $this->document->setTitle($this->language->get('heading_title'));
  400. $this->load->model('extension/modification');
  401. if (isset($this->request->get['modification_id']) && $this->validate()) {
  402. $this->model_extension_modification->disableModification($this->request->get['modification_id']);
  403. $this->session->data['success'] = $this->language->get('text_success');
  404. $url = '';
  405. if (isset($this->request->get['sort'])) {
  406. $url .= '&sort=' . $this->request->get['sort'];
  407. }
  408. if (isset($this->request->get['order'])) {
  409. $url .= '&order=' . $this->request->get['order'];
  410. }
  411. if (isset($this->request->get['page'])) {
  412. $url .= '&page=' . $this->request->get['page'];
  413. }
  414. $this->response->redirect($this->url->link('extension/modification', 'token=' . $this->session->data['token'] . $url, 'SSL'));
  415. }
  416. $this->getList();
  417. }
  418. public function clearlog() {
  419. $this->load->language('extension/modification');
  420. if ($this->validate()) {
  421. $handle = fopen(DIR_LOGS . 'ocmod.log', 'w+');
  422. fclose($handle);
  423. $this->session->data['success'] = $this->language->get('text_success');
  424. $url = '';
  425. if (isset($this->request->get['sort'])) {
  426. $url .= '&sort=' . $this->request->get['sort'];
  427. }
  428. if (isset($this->request->get['order'])) {
  429. $url .= '&order=' . $this->request->get['order'];
  430. }
  431. if (isset($this->request->get['page'])) {
  432. $url .= '&page=' . $this->request->get['page'];
  433. }
  434. $this->response->redirect($this->url->link('extension/modification', 'token=' . $this->session->data['token'] . $url, 'SSL'));
  435. }
  436. $this->getList();
  437. }
  438. protected function getList() {
  439. if (isset($this->request->get['sort'])) {
  440. $sort = $this->request->get['sort'];
  441. } else {
  442. $sort = 'name';
  443. }
  444. if (isset($this->request->get['order'])) {
  445. $order = $this->request->get['order'];
  446. } else {
  447. $order = 'ASC';
  448. }
  449. if (isset($this->request->get['page'])) {
  450. $page = $this->request->get['page'];
  451. } else {
  452. $page = 1;
  453. }
  454. $url = '';
  455. if (isset($this->request->get['sort'])) {
  456. $url .= '&sort=' . $this->request->get['sort'];
  457. }
  458. if (isset($this->request->get['order'])) {
  459. $url .= '&order=' . $this->request->get['order'];
  460. }
  461. if (isset($this->request->get['page'])) {
  462. $url .= '&page=' . $this->request->get['page'];
  463. }
  464. $data['breadcrumbs'] = array();
  465. $data['breadcrumbs'][] = array(
  466. 'text' => $this->language->get('text_home'),
  467. 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL')
  468. );
  469. $data['breadcrumbs'][] = array(
  470. 'text' => $this->language->get('heading_title'),
  471. 'href' => $this->url->link('extension/modification', 'token=' . $this->session->data['token'], 'SSL')
  472. );
  473. $data['refresh'] = $this->url->link('extension/modification/refresh', 'token=' . $this->session->data['token'] . $url, 'SSL');
  474. $data['clear'] = $this->url->link('extension/modification/clear', 'token=' . $this->session->data['token'] . $url, 'SSL');
  475. $data['delete'] = $this->url->link('extension/modification/delete', 'token=' . $this->session->data['token'] . $url, 'SSL');
  476. $data['modifications'] = array();
  477. $filter_data = array(
  478. 'sort' => $sort,
  479. 'order' => $order,
  480. 'start' => ($page - 1) * $this->config->get('config_limit_admin'),
  481. 'limit' => $this->config->get('config_limit_admin')
  482. );
  483. $modification_total = $this->model_extension_modification->getTotalModifications();
  484. $results = $this->model_extension_modification->getModifications($filter_data);
  485. foreach ($results as $result) {
  486. $data['modifications'][] = array(
  487. 'modification_id' => $result['modification_id'],
  488. 'name' => $result['name'],
  489. 'author' => $result['author'],
  490. 'version' => $result['version'],
  491. 'status' => $result['status'] ? $this->language->get('text_enabled') : $this->language->get('text_disabled'),
  492. 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
  493. 'link' => $result['link'],
  494. 'enable' => $this->url->link('extension/modification/enable', 'token=' . $this->session->data['token'] . '&modification_id=' . $result['modification_id'], 'SSL'),
  495. 'disable' => $this->url->link('extension/modification/disable', 'token=' . $this->session->data['token'] . '&modification_id=' . $result['modification_id'], 'SSL'),
  496. 'enabled' => $result['status'],
  497. );
  498. }
  499. $data['heading_title'] = $this->language->get('heading_title');
  500. $data['text_list'] = $this->language->get('text_list');
  501. $data['text_no_results'] = $this->language->get('text_no_results');
  502. $data['text_confirm'] = $this->language->get('text_confirm');
  503. $data['text_refresh'] = $this->language->get('text_refresh');
  504. $data['column_name'] = $this->language->get('column_name');
  505. $data['column_author'] = $this->language->get('column_author');
  506. $data['column_version'] = $this->language->get('column_version');
  507. $data['column_status'] = $this->language->get('column_status');
  508. $data['column_date_added'] = $this->language->get('column_date_added');
  509. $data['column_action'] = $this->language->get('column_action');
  510. $data['button_refresh'] = $this->language->get('button_refresh');
  511. $data['button_clear'] = $this->language->get('button_clear');
  512. $data['button_delete'] = $this->language->get('button_delete');
  513. $data['button_link'] = $this->language->get('button_link');
  514. $data['button_enable'] = $this->language->get('button_enable');
  515. $data['button_disable'] = $this->language->get('button_disable');
  516. $data['tab_general'] = $this->language->get('tab_general');
  517. $data['tab_log'] = $this->language->get('tab_log');
  518. $data['token'] = $this->session->data['token'];
  519. if (isset($this->error['warning'])) {
  520. $data['error_warning'] = $this->error['warning'];
  521. } else {
  522. $data['error_warning'] = '';
  523. }
  524. if (isset($this->session->data['success'])) {
  525. $data['success'] = $this->session->data['success'];
  526. unset($this->session->data['success']);
  527. } else {
  528. $data['success'] = '';
  529. }
  530. if (isset($this->request->post['selected'])) {
  531. $data['selected'] = (array)$this->request->post['selected'];
  532. } else {
  533. $data['selected'] = array();
  534. }
  535. $url = '';
  536. if ($order == 'ASC') {
  537. $url .= '&order=DESC';
  538. } else {
  539. $url .= '&order=ASC';
  540. }
  541. if (isset($this->request->get['page'])) {
  542. $url .= '&page=' . $this->request->get['page'];
  543. }
  544. $data['sort_name'] = $this->url->link('extension/modification', 'token=' . $this->session->data['token'] . '&sort=name' . $url, 'SSL');
  545. $data['sort_author'] = $this->url->link('extension/modification', 'token=' . $this->session->data['token'] . '&sort=author' . $url, 'SSL');
  546. $data['sort_version'] = $this->url->link('extension/version', 'token=' . $this->session->data['token'] . '&sort=author' . $url, 'SSL');
  547. $data['sort_status'] = $this->url->link('extension/modification', 'token=' . $this->session->data['token'] . '&sort=status' . $url, 'SSL');
  548. $data['sort_date_added'] = $this->url->link('extension/modification', 'token=' . $this->session->data['token'] . '&sort=date_added' . $url, 'SSL');
  549. $url = '';
  550. if (isset($this->request->get['sort'])) {
  551. $url .= '&sort=' . $this->request->get['sort'];
  552. }
  553. if (isset($this->request->get['order'])) {
  554. $url .= '&order=' . $this->request->get['order'];
  555. }
  556. $pagination = new Pagination();
  557. $pagination->total = $modification_total;
  558. $pagination->page = $page;
  559. $pagination->limit = $this->config->get('config_limit_admin');
  560. $pagination->url = $this->url->link('extension/modification', 'token=' . $this->session->data['token'] . $url . '&page={page}', 'SSL');
  561. $data['pagination'] = $pagination->render();
  562. $data['results'] = sprintf($this->language->get('text_pagination'), ($modification_total) ? (($page - 1) * $this->config->get('config_limit_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_limit_admin')) > ($modification_total - $this->config->get('config_limit_admin'))) ? $modification_total : ((($page - 1) * $this->config->get('config_limit_admin')) + $this->config->get('config_limit_admin')), $modification_total, ceil($modification_total / $this->config->get('config_limit_admin')));
  563. $data['sort'] = $sort;
  564. $data['order'] = $order;
  565. // Log
  566. $file = DIR_LOGS . 'ocmod.log';
  567. if (file_exists($file)) {
  568. $data['log'] = htmlentities(file_get_contents($file, FILE_USE_INCLUDE_PATH, null));
  569. } else {
  570. $data['log'] = '';
  571. }
  572. $data['clear_log'] = $this->url->link('extension/modification/clearlog', 'token=' . $this->session->data['token'], 'SSL');
  573. $data['header'] = $this->load->controller('common/header');
  574. $data['column_left'] = $this->load->controller('common/column_left');
  575. $data['footer'] = $this->load->controller('common/footer');
  576. $this->response->setOutput($this->load->view('extension/modification.tpl', $data));
  577. }
  578. protected function validate() {
  579. if (!$this->user->hasPermission('modify', 'extension/modification')) {
  580. $this->error['warning'] = $this->language->get('error_permission');
  581. }
  582. return !$this->error;
  583. }
  584. }