public function __construct($name = null) { $this->_cache = \Phpfox_Cache::instance(); if ($name !== null) { $this->_name = $name; $this->_id = $this->_cache->set($name); } }
/** * Loads and outputs the current page based on the controller we loaded with the method setController(). * * @see self::setController() */ public function getController() { // Get the component $this->_oController = $this->getComponent($this->_sModule . '.' . $this->_sController, array('bNoTemplate' => true), 'controller'); if (!Phpfox::isAdminPanel() && !defined('PHPFOX_INSTALLER') || defined('PHPFOX_DEBUG') && PHPFOX_DEBUG) { $db = Phpfox_Database::instance(); $cache = Phpfox_Cache::instance(); $name = Phpfox_Module::instance()->getFullControllerName(); $pageMeta = $cache->set('page_meta_' . $name); $meta = $cache->get($pageMeta); if (PHPFOX_DEBUG) { $meta = false; } if ($meta === false) { $query = function ($name) use($db) { return $db->select('*')->from(':theme_template')->where(['type_id' => 'meta', 'name' => $name])->get(); }; $theme = $query(['LIKE' => $name . '/' . Phpfox_Request::instance()->segment(3)]); if (!$theme) { $theme = $query($name); } $cache->save($pageMeta, isset($theme['template_id']) ? json_decode($theme['html_data']) : []); $meta = $cache->get($pageMeta); } // $this->_meta = $meta; // d($theme); exit; Phpfox_Template::instance()->setPageMeta($meta); } }
/** * Based on what storage system is set within the global settings this is where we load the file. * You can also pass any params to the storage object. * * @param array $aParams Any extra params you may want to pass to the storage object. */ public function __construct($aParams = array()) { if (!self::$_oObject) { $dir = PHPFOX_DIR_SITE . 'Apps/'; if (is_dir($dir)) { foreach (scandir($dir) as $app) { $path = $dir . $app . '/'; if (file_exists($path . 'app.lock') && file_exists($path . 'app.json')) { $json = json_decode(file_get_contents($path . 'app.json')); if (is_object($json) && isset($json->lib) && isset($json->lib->cache)) { if (file_exists($path . 'vendor/autoload.php')) { require $path . 'vendor/autoload.php'; } try { self::$_oObject = (new \ReflectionClass($json->lib->cache))->newInstance(); } catch (\Exception $e) { } break; } } } } if (!self::$_oObject) { $sStorage = isset($aParams['storage']) ? $aParams['storage'] : Phpfox::getParam('core.cache_storage'); switch ($sStorage) { case 'memcache': $sStorage = 'phpfox.cache.storage.memcache'; break; default: $sStorage = 'phpfox.cache.storage.file'; } self::$_oObject = Phpfox::getLib($sStorage, $aParams); } } }
public function remove($sName = null, $sType = '') { if (file_exists(PHPFOX_DIR_CACHE . 'cache.lock')) { return false; } $oCache = parent::getInstance(); if (class_exists('Phpfox_Cache_Storage_File') && Phpfox::getParam('core.cache_storage') == 'file') { return $oCache->remove($sName, $sType); } if (class_exists('Phpfox_Cache_Storage_Memcache') && Phpfox::getParam('core.cache_storage') == 'memcache') { $oMemcache = $this->getMemcache(); if ($sName === null) { return $oMemcache->flush(); } switch ($sType) { case 'substr': $sPrefix = is_array($sName) ? $sName[0] : $sName; $aPrefix = $this->get($sPrefix); if ($aPrefix && is_array($aPrefix)) { $oMemcache->delete($sPrefix); foreach ($aPrefix as $key) { if ($key) { $oMemcache->delete($sPrefix . $key); } } } break; default: if (is_array($sName)) { $sName = $sName[0] . isset($sName[1]) ? $sName[1] : ''; } $oMemcache->delete($sName); } } }
/** * Loads and outputs the current page based on the controller we loaded with the method setController(). * * @see self::setController() */ public function getController() { // Get the component $this->_oController = $this->getComponent($this->_sModule . '.' . $this->_sController, array('bNoTemplate' => true), 'controller'); if (!Phpfox::isAdminPanel() && !defined('PHPFOX_INSTALLER')) { $db = Phpfox_Database::instance(); $cache = Phpfox_Cache::instance(); $name = Phpfox_Module::instance()->getFullControllerName(); $pageMeta = $cache->set('page_meta_' . $name); $meta = $cache->get($pageMeta); if ($meta === false) { $theme = $db->select('*')->from(':theme_template')->where(['type_id' => 'meta', 'name' => $name])->get(); $cache->save($pageMeta, isset($theme['template_id']) ? json_decode($theme['html_data']) : []); $meta = $cache->get($pageMeta); } // $this->_meta = $meta; Phpfox_Template::instance()->setPageMeta($meta); } }
public function delete() { (new \Core\Home(PHPFOX_LICENSE_ID, PHPFOX_LICENSE_KEY))->uninstall(['product_id' => $this->internal_id]); $path = $this->path; if (is_dir($path)) { \Phpfox_File::instance()->delete_directory($path); } \Phpfox_Cache::instance()->remove(); }
public function process() { $Theme = new Core\Theme(); $file = null; if ($this->request()->get('type') == 'in-app') { $product = json_decode($this->request()->get('product')); $app = (new Core\App())->getByInternalId($this->request()->get('parent_id')); $this->url()->send('admincp.app', ['id' => $app->id, 'child_id' => $product->id]); exit; } 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); Phpfox_Cache::instance()->remove(); echo '<script>window.top.location.href = \'' . $this->url()->makeUrl('admincp.language.import', ['dir' => base64_encode($path)]) . '\';</script>'; exit; } if ($this->request()->get('type') == 'theme') { $product = json_decode($this->request()->get('product')); $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, $product); // $this->url()->send('admincp.theme'); Phpfox_Cache::instance()->remove(); echo '<script>window.top.location.href = \'' . $this->url()->makeUrl('admincp.theme.manage', ['id' => is_numeric($id) ? $id : $id->theme_id]) . '\';</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); Phpfox_Cache::instance()->remove(); 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 ($val = $this->request()->getArray('val')) { $App = (new Core\App())->make($val['name']); Phpfox::addMessage('App successfully created.'); Phpfox_Cache::instance()->remove(); return ['redirect' => $this->url()->makeUrl('admincp.app', ['id' => $App->id])]; } $this->template()->setBreadCrumb('New App', $this->url()->current(), true); }
public function delete() { if ($this->menu && isset($this->menu->url)) { \Phpfox_Database::instance()->delete(':menu', ['m_connection' => 'main', 'url_value' => $this->menu->url]); } (new \Core\Home(PHPFOX_LICENSE_ID, PHPFOX_LICENSE_KEY))->uninstall(['product_id' => $this->internal_id]); $path = $this->path; /*https://github.com/moxi9/phpfox/issues/523*/ $json_path = $path . 'app.json'; if (file_exists($json_path)) { $json = json_decode(file_get_contents($json_path)); //remove menu if exist if (isset($json->menu)) { \Admincp_Service_Menu_Process::instance()->delete($json->menu->url, true); } } if (is_dir($path)) { \Phpfox_File::instance()->delete_directory($path); } \Phpfox_Cache::instance()->remove(); }