示例#1
0
 public static function load()
 {
     self::$modules = new stdClass();
     $sql = new SQLObject();
     if ($sql->query("SELECT filename,core,seq FROM " . $sql->table('modules') . " WHERE (active = 1 AND core = 1) ORDER BY seq ASC")) {
         $core = $sql->fetch();
         if ($sql->query("SELECT filename,core,seq FROM " . $sql->table('modules') . " WHERE (active = 1 AND core = 0) ORDER BY seq ASC")) {
             $modules = array_merge($core, $sql->fetch());
             foreach ($modules as $module) {
                 if ((int) $module->core == 1) {
                     $path = './app/modules/' . $module->filename;
                 } else {
                     $path = './modules/' . $module->filename;
                 }
                 $GLOBALS['MODULE_NAME'] = str_replace('-', '_', preg_replace('#^([a-z-_]+)\\.mod\\.php$#is', '$1', $module->filename));
                 if (include_once $path) {
                     core::s('syslog')->success('Modules', '__construct()', $path);
                     if (defined('IN_ACP') && IN_ACP && isset($_GET['c'], $_GET['module']) && $_GET['c'] == 'config' && $_GET['module'] == $GLOBALS['MODULE_NAME'] && method_exists($this->modules[$GLOBALS['MODULE_NAME']], '_module_config_load')) {
                         core::s('tpl')->addTpl('config-' . $GLOBALS['MODULE_NAME']);
                         $this->modules[$GLOBALS['MODULE_NAME']]->_module_config_load();
                     }
                 } else {
                     core::s('syslog')->error('Modules', '__construct()', $path, 'Cannot load the module!');
                 }
             }
         }
     }
 }
示例#2
0
 public function fetch()
 {
     if (!$this->made) {
         return array();
     }
     $start = $this->current_page * $this->per_page - $this->per_page;
     $query = $this->query . " LIMIT " . $start . "," . $this->per_page;
     $sql = new SQLObject();
     if (!$sql->query($query)) {
         return array();
     }
     return $sql->fetch();
 }
示例#3
0
     ob_start();
     if (include_once './app/lib/' . $file) {
         $syslog->success('(root)', 'include_once()', './app/lib/' . $file);
     } else {
         $syslog->success('(root)', 'include_once()', './app/lib/' . $file, ob_get_contents());
     }
     ob_end_clean();
 }
 unset($dir, $file);
 rm_magicquotes();
 require_once './app/layers/sqlite.layer.php';
 // Init the connection to the database
 $sqlite = new SQLite('./data/sql/.database.sqlite', 'scms_', 0777);
 if (defined('REQUEST')) {
     $sql = new SQLObject();
     if ($sql->query("\r\nSELECT request_id,request_regexp,request_uri,request_target\r\nFROM " . $sql->table('requests') . "\r\nORDER BY request_order ASC")) {
         foreach ($sql->fetch() as $request) {
             if ((bool) $request->request_regexp === false) {
                 if (REQUEST == $request->request_uri || REQUEST . '/' == $request->request_uri) {
                     define('LOC', $request->request_target);
                 }
             } elseif (preg_match($request->request_uri, REQUEST) || preg_match($request->request_uri, REQUEST . '/')) {
                 define('LOC', $request->request_target);
             }
         }
     }
     unset($sql);
     if (!defined('LOC')) {
         header('Location: ../index.php');
     } else {
         define('REDIRECTED', true);
示例#4
0
文件: init.php 项目: jankuca/smog-cms
<?php

require_once './app/layers/langs.layer.php';
require_once './app/layers/tpl.layer.php';
require_once './app/layers/modules.layer.php';
require_once './app/layers/core.layer.php';
// Load the cms configuration
$sql = new SQLObject();
if ($sql->query("\r\nSELECT name,value,assign,type,module\r\nFROM " . $sql->table('config') . "\r\nWHERE (name NOT LIKE 'info:%')\r\nUNION\r\nSELECT name,value,assign,type,module\r\nFROM " . $sql->table('config') . "\r\nWHERE (name LIKE 'info:%')")) {
    foreach ($sql->fetch() as $item) {
        switch ((string) $item->type) {
            case 'integer':
                $cfg['etc'][$item->module][$item->name] = (int) $item->value;
                if ((int) $item->assign) {
                    TPL::add(strtoupper($item->name), $cfg['etc'][$item->module][$item->name]);
                }
                break;
            case 'timestamp':
                $cfg['etc'][$item->module][$item->name] = strtotime($item->value);
                if ((int) $item->assign) {
                    TPL::add(strtoupper($item->name), formatDateTime($cfg['etc'][$item->module][$item->name]));
                }
                break;
            default:
                $cfg['etc'][$item->module][$item->name] = $item->value;
                if ((int) $item->assign) {
                    TPL::add(strtoupper($item->name), $cfg['etc'][$item->module][$item->name]);
                }
                break;
        }
    }
示例#5
0
 public function _module_config_load()
 {
     $cfg = core::s('cfg');
     TPL::add('SITE_TITLE', '{L_SITE_CONFIG} &mdash; {SITE_HEADER} / {L_ACP}');
     $sql = new SQLObject();
     if ($sql->query("\r\nSELECT module,name,value,type\r\nFROM " . $sql->table('config') . "\r\nWHERE (module = 'core')")) {
         foreach ($sql->fetch() as $item) {
             switch ($item->type) {
                 case 'integer':
                     $value = (int) $item->value;
                     break;
                 case 'string':
                     $value = (string) $item->value;
                     break;
                 case 'float':
                     $value = (double) $item->value;
                     break;
                 case 'timestamp':
                     $value = strtotime((string) $item->value);
                     break;
                 case 'boolean':
                     if ((int) $item->value == 0) {
                         $value = false;
                     } else {
                         $value = true;
                     }
                     TPL::cond('MODULE_CONFIG:' . strtoupper($item->name), $value);
                     break;
                 default:
                     $value = $item->value;
                     break;
             }
             TPL::add('MODULE_CONFIG:' . strtoupper($item->name), $value);
         }
     }
     $dir = dir('./langs/');
     while ($file = $dir->read()) {
         if ($file == '.' || $file == '..') {
             continue;
         }
         $langs[] = $file;
     }
     sort($langs);
     $f_langs = array();
     foreach ($langs as $lang) {
         $f_langs[] = array('LANG_CODENAME' => $lang, 'conds' => array('LANG_ACTIVE' => $lang == $cfg['etc']['core']['site_lang'] ? true : false));
     }
     TPL::assignAsLoop('MODULE_CONFIG:SITE_LANG', $f_langs);
     $f_langs = array();
     foreach ($langs as $lang) {
         $f_langs[] = array('LANG_CODENAME' => $lang, 'conds' => array('LANG_ACTIVE' => $lang == $cfg['etc']['core']['acp_lang'] ? true : false));
     }
     TPL::assignAsLoop('MODULE_CONFIG:ACP_LANG', $f_langs);
     $dir = dir('./styles/');
     while ($file = $dir->read()) {
         if ($file == '.' || $file == '..' || $file == '.acp') {
             continue;
         }
         $styles[] = $file;
     }
     sort($styles);
     $f_styles = array();
     foreach ($styles as $style) {
         $info = array();
         $path = './styles/' . $style . '/style.cfg';
         if (file_exists($path)) {
             $data = simplexml_load_file($path);
             foreach ($data->children() as $item) {
                 switch ($item['name']) {
                     case 'name':
                         $info['name'] = $item['value'];
                         break;
                     case 'author':
                         $info['author'] = $item['value'];
                         break;
                     case 'author_link':
                         $info['author_link'] = $item['value'];
                         break;
                     case 'preview':
                         $preview = true;
                         $info['preview'] = './styles/' . $style . '/' . $item['value'];
                         break;
                 }
             }
         }
         if (!isset($info['name'])) {
             $info['name'] = $style;
         }
         if (!isset($info['author'])) {
             $info['author'] = '{L_UNKNOWN}';
         }
         if (!isset($info['preview'])) {
             $preview = false;
             $info['preview'] = './styles/.acp/media/images/style_preview.png';
         }
         if ($style == $cfg['etc']['core']['site_style']) {
             TPL::add('MODULE_CONFIG:SITE_STYLE_NAME', strlen($info['name']) > 24 ? mb_substr($info['name'], 0, 24, 'UTF-8') . '...' : $info['name']);
         }
         $f_styles[] = array('STYLE_CODENAME' => $style, 'STYLE_NAME' => $info['name'], 'STYLE_AUTHOR' => $info['author'], 'STYLE_AUTHOR_LINK' => $info['author_link'], 'STYLE_PREVIEW' => $info['preview'], 'conds' => array('STYLE_ACTIVE' => $style == $cfg['etc']['core']['site_style'] ? true : false, 'STYLE_AUTHOR_LINK' => isset($info['author_link']) ? true : false, 'STYLE_PREVIEW' => $preview));
     }
     TPL::assignAsLoop('MODULE_CONFIG:SITE_STYLE', $f_styles);
 }
示例#6
0
 public function getPermissionsAvailable($empty = false)
 {
     $sql = new SQLObject();
     if ($sql->query("\r\nSELECT p.permission_module_codename AS module_codename, p.permission_name AS codename, p.permission_value AS value, m.name AS module_name\r\nFROM " . $sql->table('modules_permissions') . " AS p\r\nLEFT JOIN " . $sql->table('modules') . " AS m\r\nON p.permission_module_codename||'.mod.php' = m.filename")) {
         $f_permissions_modules = array();
         $f_permissions = array();
         $modules = array();
         foreach ($sql->fetch() as $perm) {
             if (!in_array($perm->module_name, $modules)) {
                 $f_permissions_modules[] = array('PERMISSIONS_MODULE' => $perm->module_name, 'PERMISSIONS_MODULE_CODENAME' => $perm->module_codename);
                 $modules[] = $perm->module_name;
             }
             $f_permissions[$perm->module_codename][] = array('PERMISSIONS_CODENAME' => $perm->codename, 'PERMISSIONS_NAME' => '{L_PERMISSION.' . $perm->module_codename . '.' . $perm->codename . '}');
             $values = explode(';', $perm->value);
             $f_values = array();
             $i = 0;
             foreach ($values as $value) {
                 $f_values[] = array('PERMISSION_NAME' => '{L_PERMISSION.' . $perm->module_codename . '.' . $perm->codename . '.' . $value . '}', 'PERMISSION_VALUE' => $value);
                 $i++;
             }
             core::s('tpl')->assignLoop('GROUP_PERMISSIONS-' . $perm->module_codename . '-' . $perm->codename, $f_values);
         }
         core::s('tpl')->assignLoop('GROUP_PERMISSIONS', $f_permissions_modules);
         foreach ($f_permissions as $module_codename => $loop) {
             core::s('tpl')->assignLoop('GROUP_PERMISSIONS-' . $module_codename, $loop);
         }
     }
 }