Example #1
0
 /**
  * Singleton instance getter
  *
  * @return	vB5_User
  */
 public static function instance()
 {
     if (self::$instance === null) {
         $class = __CLASS__;
         self::$instance = new $class();
     }
     return self::$instance;
 }
Example #2
0
 protected function fetchStyleVars()
 {
     $res = Api_InterfaceAbstract::instance()->callApi('style', 'fetchStyleVars', array($this->stylePreference));
     // api method returns unserealized stylevars
     if (empty($res) or !empty($res['errors'])) {
         return;
     }
     $user = vB5_User::instance();
     if (is_null($user['lang_options']) or isset($user['lang_options']) and is_array($user['lang_options']) and !empty($user['lang_options']['direction'])) {
         // if user has a LTR language selected
         $res['textdirection'] = array('datatype' => 'string', 'string' => 'ltr');
         $res['left'] = array('datatype' => 'string', 'string' => 'left');
         $res['right'] = array('datatype' => 'string', 'string' => 'right');
     } else {
         // if user has a RTL language selected
         $res['textdirection'] = array('datatype' => 'string', 'string' => 'rtl');
         $res['left'] = array('datatype' => 'string', 'string' => 'right');
         $res['right'] = array('datatype' => 'string', 'string' => 'left');
     }
     foreach ($res as $key => $value) {
         $this->cache[$key] = $value;
     }
 }
Example #3
0
 public function getCssFile($filename)
 {
     $options = vB5_Template_Options::instance();
     $storecssasfile = $options->get('options.storecssasfile');
     $user = vB5_User::instance();
     $textdirection = $user['lang_options']['direction'] ? 'ltr' : 'rtl';
     // we cannot query user directly for styleid, we need to consider other parameters
     $styleid = vB5_Template_Stylevar::instance()->getPreferredStyleId();
     $vbcsspath = $this->getCssPath($storecssasfile, $textdirection, $styleid);
     if ($storecssasfile) {
         $cssfiledate = $this->getCssFileDate($options, $styleid);
         $file = htmlspecialchars($vbcsspath . $cssfiledate . '-' . $filename);
     } else {
         if (!($cssdate = intval($options->get('miscoptions.cssdate')))) {
             $cssdate = time();
             // fallback so we get the latest css
         }
         $joinChar = strpos($vbcsspath, '?') === false ? '?' : '&';
         $file = htmlspecialchars($vbcsspath . $filename . "{$joinChar}ts={$cssdate}");
     }
     return $file;
 }
Example #4
0
 public function actionInlinemodLogin()
 {
     $api = Api_InterfaceAbstract::instance();
     $currentuser = vB5_User::instance();
     if (empty($currentuser['userid'])) {
         if (!empty($_POST['username'])) {
             $loginInfo = $api->callApi('user', 'login', array($_POST['username'], $_POST['password']));
             if (empty($loginInfo['errors']) and !empty($loginInfo['userid'])) {
                 $userInfo = $api->callApi('user', 'fetchUserinfo', array($loginInfo['userid']));
                 $username = $userInfo['username'];
                 vB5_Auth::setLoginCookies($loginInfo, '', !empty($_POST['rememberme']));
             } else {
                 $this->sendAsJson(array('error' => 'inlinemod_auth_login_failed'));
                 return false;
             }
         }
         if (empty($username)) {
             $this->sendAsJson(array('error' => 'inlinemod_auth_login_first'));
             return false;
         }
     } else {
         $username = $currentuser['username'];
     }
     if (empty($_POST['password'])) {
         $this->sendAsJson(array('error' => 'inlinemod_auth_password_empty'));
         return false;
     }
     $loginInfo = $api->callApi('user', 'login', array($username, $_POST['password'], '', '', 'cplogin'));
     if (isset($loginInfo['errors']) and !empty($loginInfo['errors'])) {
         $this->sendAsJson(array('error' => 'inlinemod_auth_login_failed'));
         return false;
     } else {
         vB5_Auth::setLoginCookies($loginInfo, 'cplogin', !empty($_POST['rememberme']));
         $this->sendAsJson(true);
         return true;
     }
 }
Example #5
0
 /**
  * Handle any delayed rendering. Currently delayed urls and node texts.
  *
  * @param	string
  * @param	boolean	true if we are rendering for a call to /ajax/render/ and we want CSS <link>s separate
  *
  * @return	string
  */
 protected function renderDelayed(&$final_rendered_orig, $isAjaxTemplateRender = false)
 {
     $javascript = vB5_Template_Javascript::instance();
     $javascript->insertJs($final_rendered_orig);
     $javascript->resetPending();
     $stylesheet = vB5_Template_Stylesheet::instance();
     $stylesheet->insertCss($final_rendered_orig, $isAjaxTemplateRender);
     $stylesheet->resetPending();
     $link = vB5_Template_Headlink::instance();
     $link->insertLinks($final_rendered_orig);
     $link->resetPending();
     $phrase = vB5_Template_Phrase::instance();
     $phrase->replacePlaceholders($final_rendered_orig);
     $phrase->resetPending();
     // we do not reset pending urls, since they may be required by nodetext
     vB5_Template_Url::instance()->replacePlaceholders($final_rendered_orig);
     $nodeText = vB5_Template_NodeText::instance();
     $nodeText->replacePlaceholders($final_rendered_orig);
     $nodeText->resetPending();
     $templateCache = vB5_Template_Cache::instance();
     $templateCache->replaceTextOnly($final_rendered_orig);
     //We should keep the debug info for truly last.
     if (vB5_Frontend_Controller_Bbcode::needDebug()) {
         $config = vB5_Config::instance();
         if (!$config->debug) {
             return $final_rendered_orig;
         }
         self::$renderedTemplateNames[] = 'debug_info';
         self::$renderedTemplates[] = array('templateName' => 'debug_info', 'isParentTemplate' => (bool) 0, 'indent' => str_repeat('|----', 2));
         $user = vB5_User::instance();
         $this->register('user', $user, true);
         extract(self::$globalRegistered, EXTR_SKIP | EXTR_REFS);
         extract($this->registered, EXTR_OVERWRITE | EXTR_REFS);
         $vboptions = vB5_Template_Options::instance()->getOptions();
         $vboptions = $vboptions['options'];
         $renderedTemplates = array('count' => count(self::$renderedTemplates), 'countUnique' => count(array_unique(self::$renderedTemplateNames)), 'templates' => self::$renderedTemplates, 'styleid' => vB5_Template_Stylevar::instance()->getPreferredStyleId());
         $cssDebugLog = vB5_Template_Stylesheet::getDebugLog();
         $jsDebugLog = vB5_Template_Javascript::instance()->getDebugLog();
         $templateCode = $templateCache->getTemplate('debug_info');
         if ($templateCache->isTemplateText()) {
             @eval($templateCode);
         } else {
             @(include $templateCode);
         }
         $phrase->replacePlaceholders($final_rendered);
         $phrase->resetPending();
         $final_rendered_orig = str_replace('<!-DebugInfo-->', $final_rendered, $final_rendered_orig);
     }
 }