public function remove() { $this->load->language('extension/installer'); $json = array(); if (!$this->user->hasPermission('modify', 'extension/installer')) { $json['error'] = $this->language->get('error_permission'); } $directory = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->request->post['path']); if (!is_dir($directory)) { $json['error'] = $this->language->get('error_directory'); } if (!$json) { // Fire event $this->trigger->fire('pre.admin.extension.remove', $directory); // Add addon to addon table if (isset($this->request->post['product_id']) and isset($this->request->post['product_name']) and isset($this->request->post['store']) and isset($this->request->post['product_version'])) { $addon = new Addon($this->registry); $data = array('product_id' => $this->request->post['product_id'], 'product_name' => $this->request->post['product_name'], 'product_type' => rtrim($this->request->post['store'], 's'), 'product_version' => $this->request->post['product_version'], 'addon_params' => isset($this->session->data['addon_params']) ? $this->session->data['addon_params'] : null, 'dir' => $directory); $addon->addAddon($data); unset($this->session->data['addon_params']); $this->cache->remove('addon'); $this->cache->remove('update'); $this->cache->remove('version'); } // Get a list of files ready to upload $files = array(); $path = array($directory); while (count($path) != 0) { $next = array_shift($path); // We have to use scandir function because glob will not pick up dot files. foreach (array_diff(scandir($next), array('.', '..')) as $file) { $file = $next . '/' . $file; if (is_dir($file)) { $path[] = $file; } $files[] = $file; } } sort($files); rsort($files); foreach ($files as $file) { if (is_file($file)) { unlink($file); } elseif (is_dir($file)) { rmdir($file); } } if (file_exists($directory)) { rmdir($directory); } $json['success'] = $this->language->get('text_success'); } $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($json)); }