public function install($response) { $Request = new \Core\Request(); $Url = new \Core\Url(); $zip = PHPFOX_DIR_FILE . 'static/' . uniqid() . '.zip'; file_put_contents($zip, file_get_contents($response->download)); switch ($Request->get('type')) { case 'isAppInstalled': echo "OK"; break; case 'language': $file = PHPFOX_DIR_FILE . 'static/' . uniqid() . '/'; mkdir($file); $Zip = new \ZipArchive(); $Zip->open($zip); $Zip->extractTo($file); $Zip->close(); // $xml = \Phpfox::getLib('xml.parser')->parse($file . 'phpfox-language-import.xml'); $name = false; $fullPath = $file . 'upload/include/'; foreach (scandir($fullPath . 'xml/language/') as $dir) { if (file_exists($fullPath . 'xml/language/' . $dir . '/phpfox-language-import.xml')) { $name = $dir; } } if (!$name) { throw new \Exception('Not a valid language package to install.'); } \Language_Service_Process::instance()->installPackFromFolder($name, $fullPath . 'xml/language/' . $name . '/'); $Url->send('admincp/language/import', ['dir' => base64_encode($fullPath . 'xml/language/' . $name . '/')]); break; default: $Theme = new \Core\Theme(); $Theme->import($zip, ['image' => $response->image, 'id' => $response->internal_id, 'version' => $response->internal_version]); $Url->send('admincp/theme', null, 'Theme successfully installed!'); break; } exit; }
public function process() { $Theme = new Core\Theme(); $file = null; if ($this->request()->get('type') == 'language') { $dir = PHPFOX_DIR_FILE . 'static/' . uniqid() . '/'; mkdir($dir); $file = $dir . 'import.zip'; file_put_contents($file, file_get_contents($this->request()->get('download'))); register_shutdown_function(function () use($dir) { // Phpfox_File::instance()->delete_directory($dir); }); $Zip = new \ZipArchive(); $Zip->open($file); $Zip->extractTo($dir); $Zip->close(); $pack = ''; $path = $dir . 'upload/include/xml/language/'; foreach (scandir($path) as $newDir) { if ($newDir == '.' || $newDir == '..') { continue; } $pack = $newDir; $path .= $newDir . '/'; break; } \Language_Service_Process::instance()->installPackFromFolder($pack, $path); echo '<script>window.top.location.href = \'' . $this->url()->makeUrl('admincp.language.import', ['dir' => base64_encode($path)]) . '\';</script>'; exit; } if ($this->request()->get('type') == 'theme') { $dir = PHPFOX_DIR_FILE . 'static/' . uniqid() . '/'; mkdir($dir); $file = $dir . 'import.zip'; file_put_contents($file, file_get_contents($this->request()->get('download'))); register_shutdown_function(function () use($dir) { Phpfox_File::instance()->delete_directory($dir); }); Phpfox::addMessage('Theme successfully installed.'); $id = $Theme->import($file); // $this->url()->send('admincp.theme'); echo '<script>window.top.location.href = \'' . $this->url()->makeUrl('admincp.theme') . '\';</script>'; exit; } if (isset($_SERVER['HTTP_X_FILE_NAME']) || $this->request()->get('download')) { $App = (new Core\App())->import($this->request()->get('download'), $this->request()->get('download') ? true : false); if ($this->request()->get('download')) { // $this->url()->send('admincp.app', ['id' => $App->id]); echo '<script>window.top.location.href = \'' . $this->url()->makeUrl('admincp.app', ['id' => $App->id]) . '\';</script>'; exit; } return ['redirect' => $this->url()->makeUrl('admincp.app', ['id' => $App->id])]; } if ($token = $this->request()->get('m9token')) { (new Core\App())->vendor($token); d($token); exit; } if ($val = $this->request()->getArray('val')) { $App = (new Core\App())->make($val['name']); Phpfox::addMessage('App successfully created.'); return ['redirect' => $this->url()->makeUrl('admincp.app', ['id' => $App->id])]; } $this->template()->setBreadCrumb('New App', $this->url()->current(), true); }
public function process() { $Theme = new Core\Theme(); $id = $Theme->import(); return ['redirect' => $this->url()->makeUrl('admincp.theme.manage', ['id' => $id])]; }