Beispiel #1
0
 public function getSource($name)
 {
     if ($name == '@Theme/layout.html') {
         $Theme = \Phpfox_Template::instance()->theme()->get();
         $Service = new \Core\Theme\Service($Theme);
         return $Service->html()->get();
     }
     return parent::getSource($name);
 }
Beispiel #2
0
 public function process()
 {
     $Theme = (new Core\Theme())->get($this->request()->get('theme'));
     $Service = new Core\Theme\Service($Theme);
     if ($this->request()->isPost()) {
         $val = $this->request()->getArray('val');
         return $Service->flavor()->make($val);
     }
     $this->template()->setBreadcrumb('New Flavor', $this->url()->makeUrl('current'), true);
     $this->template()->assign(['Theme' => $Theme, 'flavors' => $Theme->flavors()]);
 }
Beispiel #3
0
 public function process()
 {
     $Theme = (new Core\Theme())->get($this->request()->get('theme'));
     $Service = new Core\Theme\Service($Theme);
     if ($this->request()->isPost()) {
         $val = $this->request()->getArray('val');
         $flavorId = $Service->flavor()->make($val);
         return ['redirect' => $this->url()->makeUrl('admincp.theme.manage', ['id' => $Theme->theme_id, 'flavor' => $flavorId])];
     }
     $this->template()->setBreadcrumb('New Flavor', $this->url()->makeUrl('current'), true);
     $this->template()->assign(['Theme' => $Theme, 'flavors' => $Theme->flavors()]);
 }
Beispiel #4
0
 public function getSource($name)
 {
     if ($name == '@Theme/layout.html') {
         $Theme = \Phpfox_Template::instance()->theme()->get();
         $Service = new \Core\Theme\Service($Theme);
         return $Service->html()->get();
     } else {
         if (substr($name, 0, 7) == '@Theme/') {
             $Theme = \Phpfox_Template::instance()->theme()->get();
             $name = str_replace('@Theme/', '', $name);
             $file = $Theme->getPath() . $name;
             if (!file_exists($file)) {
                 $file = PHPFOX_DIR . 'theme/default/html/' . $name;
             }
             $html = file_get_contents($file);
             return $html;
         }
     }
     return parent::getSource($name);
 }
Beispiel #5
0
 /**
  * Starts the phpFox engine. Used to get and display the pages controller.
  *
  */
 public static function run()
 {
     if (isset($_REQUEST['m9callback'])) {
         header('Content-type: application/json');
         try {
             $Home = new Core\Home(PHPFOX_LICENSE_ID, PHPFOX_LICENSE_KEY);
             $callback = $_REQUEST['m9callback'];
             unset($_GET['m9callback'], $_GET['do']);
             if (!$_GET) {
                 $_GET = [];
             }
             echo json_encode(call_user_func([$Home, $callback], $_GET));
         } catch (\Exception $e) {
             // throw new \Exception($e->getMessage(), 0, $e);
             echo json_encode(['error' => $e->getMessage()]);
         }
         exit;
     }
     $oTpl = Phpfox_Template::instance();
     $aLocale = Phpfox_Locale::instance()->getLang();
     $oReq = Phpfox_Request::instance();
     $oModule = Phpfox_Module::instance();
     if ($oReq->segment(1) == 'favicon.ico') {
         header('Content-type: image/x-icon');
         echo file_get_contents('http://www.phpfox.com/favicon.ico');
         exit;
     }
     $aStaticFolders = ['file', 'static', 'module', 'apps', 'Apps', 'themes'];
     if (in_array($oReq->segment(1), $aStaticFolders) || $oReq->segment(1) == 'theme' && $oReq->segment(2) != 'demo' && $oReq->segment(1) == 'theme' && $oReq->segment(2) != 'sample') {
         $sUri = Phpfox_Url::instance()->getUri();
         if ($sUri == '/static/ajax.php') {
             $oAjax = Phpfox_Ajax::instance();
             $oAjax->process();
             echo $oAjax->getData();
             exit;
         }
         if (Phpfox::getParam('core.url_rewrite') == '1') {
             header("HTTP/1.0 404 Not Found");
             header('Content-type: application/json');
             echo json_encode(['error' => 404]);
             exit;
         }
         $HTTPCache = new Core\HTTP\Cache();
         $HTTPCache->checkCache();
         $sDir = PHPFOX_DIR;
         if ($oReq->segment(1) == 'Apps' || $oReq->segment(1) == 'apps' || $oReq->segment(1) == 'themes') {
             $sDir = PHPFOX_DIR_SITE;
         }
         $sPath = $sDir . ltrim($sUri, '/');
         if ($oReq->segment(1) == 'themes' && $oReq->segment(2) == 'default') {
             $sPath = PHPFOX_DIR . str_replace('themes/default', 'theme/default', $sUri);
         }
         if ($oReq->segment(3) == 'emoticon') {
             $sPath = str_replace('/file/pic/emoticon/default/', PHPFOX_DIR . 'static/image/emoticon/', $sUri);
         }
         $sType = Phpfox_File::instance()->mime($sUri);
         $sExt = Phpfox_File::instance()->extension($sUri);
         if (!file_exists($sPath)) {
             $sPath = str_replace('PF.Base', 'PF.Base/..', $sPath);
             // header('Content-type: ' . $sType);
             if (!file_exists($sPath)) {
                 header("HTTP/1.0 404 Not Found");
                 header('Content-type: application/json');
                 echo json_encode(['error' => 404]);
                 exit;
             }
         }
         // header('Content-type: ' . $sType);
         $HTTPCache->cache($sType, filemtime($sPath), 7);
         if ($oReq->segment(1) == 'themes') {
             $Theme = $oTpl->theme()->get();
             $Service = new Core\Theme\Service($Theme);
             if ($sType == 'text/css') {
                 echo $Service->css()->getParsed();
             } else {
                 echo $Service->js()->get();
             }
         } else {
             echo @file_get_contents($sPath);
         }
         exit;
     }
     ($sPlugin = Phpfox_Plugin::get('run_start')) ? eval($sPlugin) : false;
     // Load module blocks
     $oModule->loadBlocks();
     if (!Phpfox::getParam('core.branding')) {
         $oTpl->setHeader(array('<meta name="author" content="PHPfox" />'));
     }
     if (strtolower(Phpfox_Request::instance()->get('req1')) == Phpfox::getParam('admincp.admin_cp')) {
         self::$_bIsAdminCp = true;
     }
     $View = $oModule->setController();
     if ($View instanceof Core\View) {
     } else {
         if (!self::$_bIsAdminCp) {
             $View = new Core\View();
         }
     }
     if (!PHPFOX_IS_AJAX_PAGE) {
         $oTpl->setImage(array('ajax_small' => 'ajax/small.gif', 'ajax_large' => 'ajax/large.gif', 'loading_animation' => 'misc/loading_animation.gif', 'close' => 'misc/close.gif', 'move' => 'misc/move.png', 'calendar' => 'jquery/calendar.gif'));
         $oTpl->setHeader(array('<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />', '<meta http-equiv="Content-Type" content="text/html; charset=' . $aLocale['charset'] . '" />', '<meta http-equiv="cache-control" content="no-cache" />', '<meta http-equiv="expires" content="-1" />', '<meta http-equiv="pragma" content="no-cache" />', '<link rel="shortcut icon" type="image/x-icon" href="' . Phpfox::getParam('core.path') . 'favicon.ico?v=' . $oTpl->getStaticVersion() . '" />'))->setMeta('keywords', Phpfox_Locale::instance()->convert(Phpfox::getParam('core.keywords')))->setMeta('robots', 'index,follow');
         $oTpl->setHeader('cache', Phpfox::getMasterFiles());
         if (Phpfox::isModule('friend')) {
             $oTpl->setPhrase(array('friend.show_more_results_for_search_term'));
         }
         if (PHPFOX_DEBUG) {
             $oTpl->setHeader('cache', array('debug.css' => 'style_css'));
         }
         if (!Phpfox::isMobile() && Phpfox::isUser() && Phpfox::getParam('user.enable_user_tooltip')) {
             $oTpl->setHeader('cache', array('user_info.js' => 'static_script'));
         }
         if (Phpfox::isModule('captcha') && Phpfox::getParam('captcha.recaptcha')) {
             // http://www.phpfox.com/tracker/view/14456/
             $sUrl = (Phpfox::getParam('core.force_https_secure_pages') ? 'https' : 'http') . "://www.google.com/recaptcha/api/js/recaptcha_ajax.js";
             $oTpl->setHeader('<script type="text/javascript" src="' . $sUrl . '"></script>');
         }
     }
     if ($sPlugin = Phpfox_Plugin::get('get_controller')) {
         eval($sPlugin);
     }
     $oTpl->assign(['aGlobalUser' => Phpfox::isUser() ? Phpfox::getUserBy(null) : array()]);
     $oModule->getController();
     Phpfox::getService('admincp.seo')->setHeaders();
     if (!defined('PHPFOX_DONT_SAVE_PAGE')) {
         Phpfox::getLib('session')->set('redirect', Phpfox_Url::instance()->getFullUrl(true));
     }
     if (!defined('PHPFOX_NO_CSRF')) {
         Phpfox::getService('log.session')->verifyToken();
     }
     ($sPlugin = Phpfox_Plugin::get('run')) ? eval($sPlugin) : false;
     if (!self::isAdminPanel()) {
         if (!Phpfox::isMobile() && !PHPFOX_IS_AJAX_PAGE && Phpfox::isModule('rss') && !defined('PHPFOX_IS_USER_PROFILE')) {
             $aFeeds = Phpfox::getService('rss')->getLinks();
             if (is_array($aFeeds) && count($aFeeds)) {
                 foreach ($aFeeds as $sLink => $sPhrase) {
                     $oTpl->setHeader('<link rel="alternate" type="application/rss+xml" title="' . $sPhrase . '" href="' . $sLink . '" />');
                 }
             }
         }
         $aPageLastLogin = Phpfox::isModule('pages') && Phpfox::getUserBy('profile_page_id') ? Phpfox::getService('pages')->getLastLogin() : false;
         $oTpl->assign(array('aMainMenus' => $oTpl->getMenu('main'), 'aSubMenus' => $oTpl->getMenu(), 'bIsUsersProfilePage' => defined('PHPFOX_IS_USER_PROFILE') ? true : false, 'sGlobalUserFullName' => Phpfox::isUser() ? Phpfox::getUserBy('full_name') : null, 'sFullControllerName' => str_replace(array('.', '/'), '_', Phpfox_Module::instance()->getFullControllerName()), 'iGlobalProfilePageId' => Phpfox::getUserBy('profile_page_id'), 'aGlobalProfilePageLogin' => $aPageLastLogin));
         $oTpl->setEditor();
         if (Phpfox::isModule('captcha')) {
             $sCaptchaHeader = Phpfox::getParam('captcha.recaptcha_header');
             if (strlen(preg_replace('/\\s\\s+/', '', $sCaptchaHeader)) > 0) {
                 $oTpl->setHeader(array($sCaptchaHeader));
             }
         }
         if (Phpfox::isModule('notification') && Phpfox::isUser() && Phpfox::getParam('notification.notify_on_new_request')) {
             $oTpl->setHeader('cache', array('update.js' => 'module_notification'));
         }
     }
     if (!PHPFOX_IS_AJAX_PAGE && ($sHeaderFile = $oTpl->getHeaderFile())) {
         ($sPlugin = Phpfox_Plugin::get('run_get_header_file_1')) ? eval($sPlugin) : false;
         require_once $sHeaderFile;
     }
     list($aBreadCrumbs, $aBreadCrumbTitle) = $oTpl->getBreadCrumb();
     $oTpl->assign(array('aErrors' => Phpfox_Error::getDisplay() ? Phpfox_Error::get() : array(), 'sPublicMessage' => Phpfox::getMessage(), 'sLocaleDirection' => $aLocale['direction'], 'sLocaleCode' => $aLocale['language_code'], 'sLocaleFlagId' => $aLocale['image'], 'sLocaleName' => $aLocale['title'], 'aBreadCrumbs' => $aBreadCrumbs, 'aBreadCrumbTitle' => $aBreadCrumbTitle, 'sCopyright' => '&copy; ' . Phpfox::getPhrase('core.copyright') . ' ' . Phpfox::getParam('core.site_copyright')));
     Phpfox::clearMessage();
     unset($_SESSION['phpfox']['image']);
     if (Phpfox::getParam('core.cron')) {
         require_once PHPFOX_DIR_CRON . 'exec.php';
     }
     if ($oReq->isPost()) {
         header('X-Is-Posted: true');
         exit;
     }
     if ($oReq->get('is_ajax_get')) {
         header('X-Is-Get: true');
         exit;
     }
     if (defined('PHPFOX_SITE_IS_OFFLINE')) {
         $oTpl->sDisplayLayout = 'blank';
         unset($View);
     }
     if (!PHPFOX_IS_AJAX_PAGE && $oTpl->sDisplayLayout && !isset($View) || !PHPFOX_IS_AJAX_PAGE && self::isAdminPanel()) {
         $oTpl->getLayout($oTpl->sDisplayLayout);
     }
     if (PHPFOX_IS_AJAX_PAGE) {
         header('Content-type: application/json; charset=utf-8');
         /*
         if (isset($View) && $View instanceof \Core\View) {
         	$content = $View->getContent();
         }
         else {
         	Phpfox_Module::instance()->getControllerTemplate();
         	$content = ob_get_contents(); ob_clean();
         }
         */
         if ($View instanceof \Core\View) {
             $content = $View->getContent();
         } else {
             Phpfox_Module::instance()->getControllerTemplate();
             $content = ob_get_contents();
             ob_clean();
         }
         $oTpl->getLayout('breadcrumb');
         $breadcrumb = ob_get_contents();
         ob_clean();
         $aHeaderFiles = Phpfox_Template::instance()->getHeader(true);
         $aCss = [];
         $aLoadFiles = [];
         foreach ($aHeaderFiles as $sHeaderFile) {
             if (!is_string($sHeaderFile)) {
                 continue;
             }
             if (preg_match('/<style(.*)>(.*)<\\/style>/i', $sHeaderFile)) {
                 $aCss[] = strip_tags($sHeaderFile);
                 continue;
             }
             if (preg_match('/href=(["\']?([^"\'>]+)["\']?)/', $sHeaderFile, $aMatches) > 0 && strpos($aMatches[1], '.css') !== false) {
                 $sHeaderFile = str_replace(array('"', "'"), '', $aMatches[1]);
                 $sHeaderFile = substr($sHeaderFile, 0, strpos($sHeaderFile, '?'));
             }
             $sHeaderFile = strip_tags($sHeaderFile);
             $sNew = preg_replace('/\\s+/', '', $sHeaderFile);
             if (empty($sNew)) {
                 continue;
             }
             $aLoadFiles[] = $sHeaderFile;
         }
         $blocks = [];
         foreach (range(1, 12) as $location) {
             if ($location == 3) {
                 echo \Phpfox_Template::instance()->getSubMenu();
             }
             $aBlocks = Phpfox_Module::instance()->getModuleBlocks($location);
             $blocks[$location] = [];
             foreach ($aBlocks as $sBlock) {
                 Phpfox::getBlock($sBlock);
                 $blocks[$location][] = ob_get_contents();
                 ob_clean();
             }
         }
         $oTpl->getLayout('search');
         $search = ob_get_contents();
         ob_clean();
         Phpfox::getBlock('core.template-menusub');
         $menuSub = ob_get_contents();
         ob_clean();
         $h1 = '';
         if (isset($aBreadCrumbTitle[1])) {
             $h1 .= '<h1><a href="' . $aBreadCrumbTitle[1] . '">' . Phpfox_Parse_Output::instance()->clean($aBreadCrumbTitle[0]) . '</a></h1>';
         }
         $oTpl->getLayout('error');
         $error = ob_get_contents();
         ob_clean();
         $controller = Phpfox_Module::instance()->getFullControllerName();
         $data = json_encode(['content' => str_replace(['&#039;'], ["'"], Phpfox_Parse_Input::instance()->convert($content)), 'title' => html_entity_decode($oTpl->instance()->getTitle()), 'phrases' => Phpfox_Template::instance()->getPhrases(), 'files' => $aLoadFiles, 'css' => $aCss, 'breadcrumb' => $breadcrumb, 'blocks' => $blocks, 'search' => $search, 'menuSub' => $menuSub, 'id' => Phpfox_Module::instance()->getPageId(), 'class' => Phpfox_Module::instance()->getPageClass(), 'h1' => $h1, 'h1_clean' => strip_tags($h1), 'error' => $error, 'controller_e' => Phpfox::isAdmin() ? Phpfox_Url::instance()->makeUrl('admincp.element.edit', ['controller' => base64_encode(Phpfox_Module::instance()->getFullControllerName())]) : null, 'meta' => Phpfox_Template::instance()->getPageMeta(), 'keep_body' => Phpfox_Template::instance()->keepBody()]);
         // header("Content-length: " . strlen($data));
         echo $data;
         // sleep(4);
     } else {
         if (isset($View)) {
             echo $View->getContent();
         }
     }
 }
Beispiel #6
0
 public function process()
 {
     $Session = new Core\Session();
     $key = 'admincp_flavor_' . $this->request()->get('id');
     if ($flavor = $this->request()->get('flavor')) {
         $Session->set($key, $flavor);
     }
     $Theme = $this->template()->theme()->get($this->request()->get('id'));
     if ($flavor = $Session->get($key)) {
         $Theme->setFlavor($flavor);
     }
     if ($default = $this->request()->get('default')) {
         return $Theme->setDefault();
     } else {
         if ($flavorId = $this->request()->get('flavor-delete')) {
             $Session->remove($key);
             $Theme->deleteFlavor($flavorId);
             $this->url()->send('admincp.theme.manage', ['id' => $this->request()->get('id')], 'Flavor successfully deleted.');
         } else {
             if ($this->request()->get('export')) {
                 $Theme->export();
             } else {
                 if ($this->request()->get('merge')) {
                     $Theme->merge();
                     $this->url()->send('admincp.theme.manage', ['id' => $this->request()->get('id')], 'Successfully merged the theme.');
                 } else {
                     if ($this->request()->get('rebuild')) {
                         $Theme->rebuild();
                         $this->url()->send('admincp.theme.manage', ['id' => $this->request()->get('id')], 'Successfully merged the theme.');
                     }
                 }
             }
         }
     }
     $Service = new Core\Theme\Service($Theme);
     if ($design = $this->request()->get('design')) {
         $Service->design()->set($design);
         return ['posted' => true];
     }
     $Request = $this->request();
     if ($Request->getHeader('X-File-Name')) {
         $dir = PHPFOX_DIR_FILE . 'logos/';
         if (!is_dir($dir)) {
             mkdir($dir);
         }
         $file = uniqid() . '.' . \Phpfox_File::instance()->extension($Request->getHeader('X-File-Name'));
         if (isset($_FILES['ajax_upload'])) {
             $_FILES['image'] = $_FILES['ajax_upload'];
             file_put_contents($dir . $file, file_get_contents($_FILES['image']['tmp_name']));
         } else {
             file_put_contents($dir . $file, file_get_contents('php://input'));
         }
         $url = str_replace(['/index.php', 'http://'], ['', '//'], \Phpfox::getParam('core.path')) . 'PF.Base/file/logos/' . $file;
         return ['run' => "\$('input[name=\"design[logoUrl]\"]').val(\"'{$url}'\").trigger('change');"];
     }
     if ($load = $this->request()->get('load')) {
         if ($this->request()->isPost()) {
             $content = $this->request()->get('content');
             switch ($load) {
                 case 'html':
                     $Service->html()->set($content);
                     break;
                 case 'css':
                     $Service->css()->set($content);
                     break;
                 case 'javascript':
                     $Service->js()->set($content);
                     break;
             }
             return ['posting' => true];
         }
         $data = '';
         switch ($load) {
             case 'html':
                 $data = $Service->html()->get();
                 break;
             case 'css':
                 $data = $Service->css()->get();
                 break;
             case 'javascript':
                 $data = $Service->js()->get();
                 break;
         }
         return ['ace' => $data, 'run' => "\$AceEditor.mode('{$load}'); " . (string) j('.ace_editor')->data('ace-mode', $load)->data('ace-save', $this->url()->makeUrl('admincp.theme.manage', ['id' => $this->request()->get('id'), 'load' => $load]))];
     } else {
         $this->template()->assign('design', $Service->design()->get());
     }
     $this->template()->setTitle('Theme Manager');
     $this->template()->setTemplate('blank');
     $this->template()->setHeader(['colorpicker.css' => 'style_css', 'colorpicker/js/colpick.js' => 'static_script']);
     $this->template()->assign(['theme' => $Theme, 'flavors' => $Theme->flavors()]);
 }
Beispiel #7
0
 public function process()
 {
     $Session = new Core\Session();
     $key = 'admincp_flavor_' . $this->request()->get('id');
     if ($flavor = $this->request()->get('flavor')) {
         $Session->set($key, $flavor);
     }
     $Theme = $this->template()->theme()->get($this->request()->get('id'));
     if ($flavor = $Session->get($key)) {
         $Theme->setFlavor($flavor);
     }
     if ($default = $this->request()->get('default')) {
         return $Theme->setDefault();
     } else {
         if ($this->request()->get('export')) {
             $Theme->export();
         } else {
             if ($this->request()->get('merge')) {
                 $Theme->merge();
                 $this->url()->send('admincp.theme.manage', ['id' => $this->request()->get('id')], 'Successfully merged the theme.');
             }
         }
     }
     $Service = new Core\Theme\Service($Theme);
     if ($design = $this->request()->get('design')) {
         $Service->design()->set($design);
         return ['posted' => true];
     }
     if ($load = $this->request()->get('load')) {
         if ($this->request()->isPost()) {
             $content = $this->request()->get('content');
             switch ($load) {
                 case 'html':
                     $Service->html()->set($content);
                     break;
                 case 'css':
                     $Service->css()->set($content);
                     break;
                 case 'javascript':
                     $Service->js()->set($content);
                     break;
             }
             return ['posting' => true];
         }
         $data = '';
         switch ($load) {
             case 'html':
                 $data = $Service->html()->get();
                 break;
             case 'css':
                 $data = $Service->css()->get();
                 break;
             case 'javascript':
                 $data = $Service->js()->get();
                 break;
         }
         return ['ace' => $data, 'run' => "\$AceEditor.mode('{$load}'); " . (string) j('.ace_editor')->data('ace-mode', $load)->data('ace-save', $this->url()->makeUrl('admincp.theme.manage', ['id' => $this->request()->get('id'), 'load' => $load]))];
     } else {
         $this->template()->assign('design', $Service->design()->get());
     }
     $this->template()->setTitle('Theme Manager');
     $this->template()->setTemplate('blank');
     $this->template()->setHeader(['colorpicker.css' => 'style_css', 'colorpicker/js/colpick.js' => 'static_script']);
     $this->template()->assign(['theme' => $Theme, 'flavors' => $Theme->flavors()]);
 }