Ejemplo n.º 1
0
 /**
  *
  *
  * @version 1.0
  * @since   1.0
  * @author  Dan Aldridge
  *
  * @return bool
  */
 public function setLanguage()
 {
     $objUser = Core_Classes_coreObj::getUser();
     // Grab the default language info, and test to see if user has a request
     $language = $this->config('site', 'language');
     $langDir = cmsROOT . 'languages/';
     if (Core_Classes_User::$IS_ONLINE) {
         $lang = $objUser->grab('language');
         if (is_dir($langdir . $lang . '/')) {
             $language = $lang;
         }
     }
     $language = strtolower($language);
     if (is_dir($langDir . $language . '/') || is_readable($langDir . $language . '/main.php')) {
         translateFile($langDir . $language . '/main.php');
     } else {
         trigger_error('objPage->setLanguage() - Could not load language files.');
     }
 }
Ejemplo n.º 2
0
 /**
  * Set the Page Theme
  *
  * @version 1.0
  * @since   1.0.0
  * @author  xLink
  *
  * @param   bool     $theme
  *
  * @return  bool
  */
 public function setTheme($theme = null)
 {
     if (is_empty($theme)) {
         $theme = $this->config('site', 'theme');
     }
     if (User::$IS_ONLINE && $this->objUser->grab('theme') && is_dir(cmsROOT . 'themes/' . $this->objUser->grab('theme') . '/')) {
         $theme = $this->objUser->grab('theme');
     }
     if ($this->config('site', 'theme_override', false)) {
         $theme = $this->config('site', 'theme');
         if (!is_dir(cmsROOT . 'themes/' . $theme . '/') || !is_readable(cmsROOT . 'themes/' . $theme . '/cfg.php')) {
             $theme = 'default';
         }
     }
     if (!is_dir(cmsROOT . 'themes/' . $theme . '/') || !is_readable(cmsROOT . 'themes/' . $theme . '/cfg.php')) {
         return false;
     }
     $langFile = cmsROOT . 'themes/' . $theme . '/languages/' . $this->config('global', 'language') . '/main.php';
     if (is_file($langFile) && is_readable($langFile)) {
         translateFile($langFile);
     }
     self::$THEME = $theme;
     self::$THEME_ROOT = cmsROOT . 'themes/' . $theme . '/';
     return true;
 }
Ejemplo n.º 3
0
//generate user stuff
$config['global'] = array('user' => isset($_SESSION['user']['id']) ? $_SESSION['user'] : $guest['user'], 'ip' => User::getIP(), 'useragent' => doArgs('HTTP_USER_AGENT', null, $_SERVER), 'browser' => getBrowser($_SERVER['HTTP_USER_AGENT']), 'language' => $language, 'secure' => $_SERVER['HTTPS'] ? true : false, 'referer' => doArgs('HTTP_REFERER', null, $_SERVER), 'rootPath' => '/' . root(), 'fullPath' => $_SERVER['REQUEST_URI'], 'rootUrl' => ($_SERVER['HTTPS'] ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/' . root(), 'url' => ($_SERVER['HTTPS'] ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
//hook the session template, this is the place to add some more if you want
$objPlugins->hook('CMSCore_session_tpl', $config['global']);
$objUser->setIsOnline(!($config['global']['user']['id'] == 0 ? true : false));
$objUser->initPerms();
if (!defined('NO_DB')) {
    //start the tracker, this sets out a few things so we can kill, ban etc
    $objCore->objUser->tracker();
}
$theme = !User::$IS_ONLINE || !$objCore->config('site', 'theme_override') ? $objCore->config('site', 'theme') : $objUser->grab('theme');
if (!$objPage->setTheme($theme)) {
    msgDie('FAIL', sprintf($errorTPL, 'Fatal Error', 'Cannot find template. Please make sure atleast default/ is uploaded correctly and try again.'));
}
if (is_file(cmsROOT . 'modules/core/lang.' . $language . '.php')) {
    translateFile(cmsROOT . 'modules/core/lang.' . $language . '.php');
}
//include the templates settings, these will assign them to an array in the page class
if (is_readable(Page::$THEME_ROOT . 'settings.php')) {
    include Page::$THEME_ROOT . 'settings.php';
}
//this sets the global theme vars
$objPage->setThemeVars();
//set a default breadcrumb
$objPage->addPagecrumb(array(array('url' => '/' . root(), 'name' => langVar('B_MAINSITE'))));
//
//--Setup modules, online system and bbcode stuffz
//
//
//--BBCode Setup
//
Ejemplo n.º 4
0
 /**
  * Loads a module and its languagefile with the name from the parameter $module
  *
  * @version 2.0
  * @since   0.8.0
  * @author  xLink
  *
  * @param   string  $module         The name of the module to be loaded
  * @param   bool    $languageFile   Defines weather the language file accociated with the module should be loaded.
  *
  * @return  bool
  */
 function loadModule($module, $languageFile = false, $mode = 'class')
 {
     if ($mode === NULL) {
         $mode = 'class';
     }
     if ($mode == 'class') {
         //check weather we've already used this module
         $module_enable = isset($_SESSION['site']['modules'][$module]) ? $_SESSION['site']['modules'][$module] == 1 ? 'enabled' : 'disabled' : 'first';
         $module_enable = 'enabled';
         switch ($module_enable) {
             case 'disabled':
                 //false means the module is disabled so stop here.
                 $this->objPage->setTitle('Module Disabled');
                 hmsgDie('FAIL', 'Module: "' . $module . '" is disabled.');
                 exit;
                 break;
             case 'first':
                 //null means we havent so continue
                 $enable_check = $this->objSQL->getValue('modules', 'enabled', array('name = "%s"', $module));
                 switch ($enable_check) {
                     case NULL:
                         $this->objPage->setTitle('Module Not Installed');
                         $msg = NULL;
                         if (!is_dir(cmsROOT . 'modules/' . $module . '/')) {
                             $this->throwHTTP(404);
                         }
                         if (file_exists(cmsROOT . 'modules/' . $module . '/install.php') && User::$IS_ADMIN) {
                             $msg = '<br />But it can be, <a href="/' . root() . 'modules/' . $module . '/install/">Click Here</a>';
                         }
                         if (User::$IS_ADMIN) {
                             hmsgDie('FAIL', 'Module "' . secureMe($module) . '" isnt installed.' . $msg);
                         } else {
                             $this->throwHTTP(404);
                         }
                         exit;
                         break;
                     case 0:
                         return false;
                         break;
                     default:
                         //cache it in session so we dont have to run the query everytime we use this module
                         $_SESSION['site']['modules'][$module] = $enable_check;
                 }
                 break;
         }
     }
     //now with the rest of the checks
     if (!is_file(cmsROOT . 'modules/' . $module . '/cfg.php')) {
         hmsgDie('FAIL', 'Could not locate the configuration file for "' . $module . '". Load Failed');
     }
     if (!is_file(cmsROOT . 'modules/' . $module . '/' . $mode . '.' . $module . '.php')) {
         hmsgDie('FAIL', 'Could not locate Module "' . $module . '". Load Failed');
     }
     include_once cmsROOT . 'modules/' . $module . '/' . $mode . '.' . $module . '.php';
     if ($languageFile) {
         translateFile(cmsROOT . 'modules/' . $module . '/language/lang.' . $this->config('global', 'language') . '.php');
     }
     return true;
 }
Ejemplo n.º 5
0
    msgDie('FAIL', sprintf($errorTPL, 'Fatal Error', 'Cannot load CMS Classes, make sure file structure is intact and $cmsROOT is defined properly if applicable.'));
}
unset($classes, $doneSetup);
//
//--Language Setup
//
//grab the default language info, and test to see if user has a request
$language = doArgs('language', 'en', $config['site']);
$langDir = cmsROOT . 'languages/';
if (isset($_SESSION['user']['language'])) {
    if (is_dir($langDir . $_SESSION['user']['language'] . '/') && is_readable($langDir . $_SESSION['user']['language'] . '/main.php')) {
        $language = $_SESSION['user']['language'];
    }
}
if (is_dir($langDir . $language . '/') || is_readable($langDir . $language . '/main.php')) {
    translateFile($langDir . $language . '/main.php');
} else {
    msgDie('FAIL', sprintf($errorTPL, 'Fatal Error', 'Cannot open ' . ($langDir . $language . '/main.php') . ' for include.'));
}
//
//-- and now load the rest of the classes
//
$classes['objTPL'] = array($classDir . 'class.template.php', array('root' => '.', 'useCache' => $cacheWritable, 'cacheDir' => $cachePath . 'template/'));
$classes['objPage'] = array($classDir . 'class.page.php');
$classes['objGroups'] = array($classDir . 'class.groups.php');
$classes['objForm'] = array($classDir . 'class.form.php');
$classes['objTime'] = array($classDir . 'class.time.php');
$classes['objNotify'] = array($classDir . 'class.notify.php');
//init these classes
$doneSetup = $objCore->setup($classes);
if (!$doneSetup) {