function _parse_methods($string, $depth = 0) { if ($depth > 50) { //super simple recursive fix return $string; } if (FALSE === ($matches = $this->_match_methods($string, 'module'))) { return $string; } foreach ($matches[0] as $match) { $result = str_replace($this->l_delim . "module:", '', $match); $result = str_replace($this->r_delim, '', $result); $values = explode('|', $result); $handler = $values[0] . "/_remap"; $arguments = array(); if (array_key_exists(1, $values)) { $arguments = explode(',', $values[1]); } if (count($arguments) == 0) { array_push($arguments, "index"); } $module_content = Modules::run_with_params($handler, $arguments); $string = str_replace($match, $module_content, $string); } return $this->_parse_methods($string, ++$depth); }
public function install_product($product_id) { $response = $this->communication->request('get_product_system_information', $product_id); if ($response->status != "success") { die("error"); } @mkdir(APPPATH . 'download'); $file = $this->communication->request_raw('download_product', $product_id); file_put_contents(APPPATH . "download/download.zip", $file); if (file_exists(APPPATH . "download/download.zip")) { PC::builder_market("Downloaded product zip."); } else { PC::builder_market("Unable to download product zip."); } $product = new Product(); $product->remote_id = $response->info->product_id; $product->type = $response->info->type; $product->version = $response->info->version; $product->save(); switch ($response->info->type) { case "theme": $zip = new ZipArchive(); $file_path = APPPATH . "download/download.zip"; if ($zip->open($file_path) === TRUE) { $zip->extractTo(APPPATH . '../themes'); $zip->close(); unlink(APPPATH . "download/download.zip"); echo 'success'; } else { echo 'failed'; } break; case "module": $zip = new ZipArchive(); $file_path = APPPATH . "download/download.zip"; if ($zip->open($file_path) === TRUE) { $zip->extractTo(APPPATH . '../modules'); PC::builder_market("Zip extracted successfully."); $folder = $zip->getNameIndex(0); $folder = str_replace("/", "", $folder); PC::builder_market("Unzipped folder " . $folder); //$this->load->module('module_system/admin'); //$this->load->module('module_system'); //$this->module_system->admin->install(); echo Modules::run_with_params("module_system/install", array($folder)); $zip->close(); unlink(APPPATH . "download/download.zip"); echo "success"; } else { PC::builder_market("Unable to extract zip."); echo 'failed'; } break; } }
function process_admin($par1) { $this->load->model('users'); if (!$this->user->is_member_of("Administrators")) { redirect(base_url("/admin/main/login"), 'location'); } $argv = func_get_args(); $handler = ""; for ($i = 0; $i < 3; $i++) { $handler .= $argv[$i] . "/"; unset($argv[$i]); } $handler = trim($handler, "/"); $argv = array_values($argv); $module_folder = explode("/", $handler); $module = new Module(); $module = $module->where('folder', $module_folder[0])->get(); if (empty($module->id)) { if (is_dir(APPPATH . "../modules/" . $module_folder[0])) { $module->folder = $module_folder[0]; $module->installer_id = -1; $module->installed = 'no'; $module->save(); } else { return show_404(); } } if (($module->installed == 'no' || !$this->user->can_access_module($module, 'frontend')) && !$this->module_exclusive_rights($module)) { //show_404(); echo "Forbidden"; return; } if (!is_array($argv)) { $argv = array($argv); } $data['contents'] = Modules::run_with_params($handler, $argv); $breadcrumb = explode("/", $handler); $breadcrumb[0][0] = strtoupper($breadcrumb[0][0]); if (!isset($this->show->breadcrumb[0])) { $this->show->breadcrumb[0]['name'] = $breadcrumb[0]; $this->show->breadcrumb[0]['url'] = ""; } $name = explode("_", $breadcrumb[2]); foreach ($name as &$segment) { $segment[0] = strtoupper($segment[0]); } $breadcrumb[2] = implode(" ", $name); $this->show->breadcrumb[1]['name'] = $breadcrumb[2]; $this->show->breadcrumb[1]['url'] = "#"; $this->show->backend('blank', $data); }
function process_admin($par1) { $this->load->model('users'); if (!$this->user->is_member_of("Administrators")) { redirect(base_url("/admin/main/login"), 'location'); } $argv = func_get_args(); $handler = ""; for ($i = 0; $i < 3; $i++) { $handler .= $argv[$i] . "/"; unset($argv[$i]); } $handler = trim($handler, "/"); $argv = array_shift($argv); $module = explode("/", $handler); $this->load->model("modules_db"); $module = $this->modules_db->get_by_folder($module[0]); if (!$this->user->is_member_of_any($module->permissions['frontend']['ids']) || count($this->user->is_member_of_any($module->permissions['frontend']['ids'])) == 0) { show_404(); return; } if (!is_array($argv)) { $argv = array($argv); } $data['contents'] = Modules::run_with_params($handler, $argv); $breadcrumb = explode("/", $handler); $breadcrumb[0][0] = strtoupper($breadcrumb[0][0]); if (!isset($this->show->breadcrumb[0])) { $this->show->breadcrumb[0]['name'] = $breadcrumb[0]; $this->show->breadcrumb[0]['url'] = ""; } $name = explode("_", $breadcrumb[2]); foreach ($name as &$segment) { $segment[0] = strtoupper($segment[0]); } $breadcrumb[2] = implode(" ", $name); $this->show->breadcrumb[1]['name'] = $breadcrumb[2]; $this->show->breadcrumb[1]['url'] = "#"; $this->show->backend('blank', $data); }