function start() { db::connect(); if (!router::get(1)) { return true; } self::$map = array('mode' => router::get(0), 'app' => router::get(1), 'module' => 'main', 'action' => router::get(2), 'id' => router::get(4)); s::set('SYS_PATH', 'http://' . SERVER . SYS_DIR); define('APP', APPS . self::get('app') . '/'); s::set('APP', APP); define('MODULE', APP . self::get('module') . '/'); s::set('MODULE', MODULE); if (stristr(self::$map['mode'], 'admin')) { self::$map['mode'] = 'admin'; } else { self::$map['mode'] = 'web'; } if (self::$map['mode'] == 'admin') { if (defined('ADMIN_USER_SITE_ID')) { admin::observer(); define('ADMIN_SITE_ID', ADMIN_USER_SITE_ID); s::set('ADMIN_SITE_ID', ADMIN_USER_SITE_ID); db::table('admin_sites'); db::where('site_id', ADMIN_USER_SITE_ID); db::limit(1); $row = db::select(); define('ADMIN_SITE', db::get('site_domain')); s::set('ADMIN_SITE', ADMIN_SITE); } } else { web::getSite(); $lang = lang::gets(LANG_INDEX, SITE_ID); /* Authentification webUser */ web::observer(); } /* Set params */ params::send(); if (router::get(0) == 'feed' || router::get(0) == 'rss') { self::$map['module'] = 'feed'; } if (self::$map['mode'] == 'admin') { load::module(self::get('app'), self::get('module'), self::get('action')); } else { load::handler(self::get('app'), self::get('module'), self::get('action')); } }
function observer($mode = false) { foreach (self::$handles as $k => $v) { foreach ($v as $d => $f) { if (self::$handles[$k][$d]['work']) { continue; } if (self::detect($k)) { params::send(self::gets()); unset($_POST[$k], $_GET[$k]); self::$events[$k] = true; self::$handles[$k]['work'] = true; if ($f['handler']) { load::handler($f['app'], $f['module'], $f['action']); } else { load::module($f['app'], $f['module'], $f['action']); } } } } }
function start() { self::observerLogout('adminlogoff'); db::connect(); define('LANG_INDEX', SYS_INDEX); $lang = lang::gets(LANG_INDEX); define('STYLE_PATH', SYS_DIR . 'gui/' . SYS_STYLE . '/'); s::set('STYLE_PATH', 'http://' . SERVER . STYLE_PATH); define('GUI_PATH', SYS_DIR . 'gui/'); s::set('GUI_PATH', 'http://' . SERVER . GUI_PATH); s::set('SERVER', SERVER); s::set('SYS_PATH', 'http://' . SERVER . SYS_DIR); s::set('SYS_DIR', SYS_DIR); /* Authentification */ $sys_tmpl = 'common'; $sys_tmpl = 'common'; if (!self::observer()) { $sys_tmpl = 'login'; s::set('title', 'Legenda'); self::display($sys_tmpl, $lang); return true; } self::groupRules(); self::map(); self::adapter(); s::set('admin_title', self::$map['title']); s::set('admin_header', self::$map['title']); s::set('admin_mode', self::$map['mode']); define('APP', APPS . self::$map['app'] . '/'); s::set('APP', APP); define('MODULE', APP . self::$map['module'] . '/'); s::set('MODULE', MODULE); /* Get sites list */ db::table('admin_sites'); $res = db::select(); if (db::rows() > 1) { $str = '<div class="popup popupSimple" id="site_list_load_popup" style="display: none;"><ul>'; while ($row = mysql_fetch_assoc($res)) { if (self::$sites_excl) { if (!isset(self::$sites_excl[$row['site_id']])) { continue; } } if ($row['site_id'] == ADMIN_USER_SITE_ID) { define('ADMIN_SITE', $row['site_domain']); s::set('ADMIN_SITE', ADMIN_SITE); s::set('admin_site_selector', ' <a href="javascript:void(null);" class="ico ico11 ico_popup popupLoad" id="site_list_load"> </a>'); } else { $str .= '<li><a class="popup_right" title="Перейти на сайт" href="http://' . $row['site_domain'] . '"></a><a href="javascript:void(null);" title="Выбрать сайт" onclick="sysSetSite(' . $row['site_id'] . ');">' . $row['site_domain'] . '</a></li>'; } } $str .= '</ul></div>'; s::set('admin_site_list', $str); } else { $row = mysql_fetch_assoc($res); define('ADMIN_SITE', $row['site_domain']); s::set('ADMIN_SITE', ADMIN_SITE); } define('ADMIN_SITE_ID', ADMIN_USER_SITE_ID); s::set('ADMIN_SITE_ID', ADMIN_USER_SITE_ID); /* Action tmpls */ if (self::$map['rule'] == 'all') { $rule_folder = 'all/'; } else { $rule_folder = RULE . '/'; } // context_menu $context_tmpl = MODULE . $rule_folder . self::$map['action'] . '.context.html'; s::set('admin_context_menu', files::get($context_tmpl)); // area $area_tmpl = MODULE . $rule_folder . self::$map['action'] . '.html'; s::set('admin_area', files::get($area_tmpl)); // sidebar $sidebar_tmpl = MODULE . $rule_folder . self::$map['action'] . '.bar.html'; s::set('admin_sidebar', files::get($sidebar_tmpl)); /* App CSS and JS */ $app_css = 'apps/' . self::$map['app'] . '/' . self::$map['app'] . '.css'; $app_js = 'apps/' . self::$map['app'] . '/' . self::$map['app'] . '.js'; if (file_exists(SYS_ROOT . $app_css)) { self::insertCSS('http://' . SERVER . SYS_DIR . $app_css); } if (file_exists(SYS_ROOT . $app_js)) { self::insertJS('http://' . SERVER . SYS_DIR . $app_js); } /* Module CSS and JS */ $module_css = 'apps/' . self::$map['app'] . '/' . self::$map['module'] . '/' . self::$map['module'] . '.css'; $module_js = 'apps/' . self::$map['app'] . '/' . self::$map['module'] . '/' . self::$map['module'] . '.js'; if (file_exists(SYS_ROOT . $module_css)) { self::insertCSS('http://' . SERVER . SYS_DIR . $module_css); } if (file_exists(SYS_ROOT . $module_js)) { self::insertJS('http://' . SERVER . SYS_DIR . $module_js); } /* Legenda app, module and action */ load::appSetup(self::$map['app']); load::moduleSetup(self::$map['app'], self::$map['module']); load::module(self::$map['app'], self::$map['module'], self::$map['action']); /* User log */ adminUser::update('user_date_last', 'NOW()', ADMIN_USER_ID); /* Action log */ db::table('admin_log_actions'); db::where('log_path', URI_SELF); db::where('user_id', ADMIN_USER_ID); db::order('log_date', 'DESC'); db::limit(1); db::select('log_id'); if (db::rows() == 0) { db::table('admin_log_actions'); db::insert('', 'NOW()', self::get('app'), self::get('module'), self::get('action'), URI_SELF, self::get('title'), ADMIN_USER_ID); } /* Legenda display */ self::adminMenu(); self::display($sys_tmpl, $lang); }
define('M_ACTION', $_GET['a']); } //当前文件夹地址 if (M_TYPE == 'system') { if (M_MODULE == 'include') { define('PATH_OWN_FILE', PATH_APP . M_TYPE . '/' . M_MODULE . '/module/'); } else { define('PATH_OWN_FILE', PATH_APP . M_TYPE . '/' . M_MODULE . '/' . M_NAME . '/'); } } else { define('PATH_OWN_FILE', PATH_APP . M_TYPE . '/' . M_NAME . '/' . M_MODULE . '/'); define('PATH_APP_FILE', PATH_APP . M_TYPE . '/' . M_NAME . '/'); } define('PATH_MODULE_FILE', PATH_APP . 'system' . '/' . M_MODULE . '/'); //程序运行开始时间 define('TIME_SYS_START', time()); //表单变量自动过滤 define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc()); //当前访问的主机名 define('HTTP_HOST', $_SERVER['HTTP_HOST']); //来源页面 define('HTTP_REFERER', $_SERVER['HTTP_REFERER']); //脚本路径 define('PHP_SELF', $_SERVER['PHP_SELF']); if (!preg_match('/^[A-Za-z0-9_]+$/', M_TYPE . M_NAME . M_MODULE . M_CLASS . M_ACTION)) { echo 'Constants must be numbers or letters or underlined'; die; } require_once PATH_SYS_CLASS . 'load.class.php'; load::module();
function start() { db::connect(); if (!router::get(1)) { return true; } self::$map = array('mode' => router::get(0), 'app' => router::get(1), 'module' => 'main', 'action' => router::get(2)); if (router::get(3)) { self::set('module', router::get(2)); self::set('action', router::get(3)); } s::set('SYS_PATH', 'http://' . SERVER . SYS_DIR); define('APP', APPS . self::get('app') . '/'); s::set('APP', APP); define('MODULE', APP . self::get('module') . '/'); s::set('MODULE', MODULE); /* Lang items */ if (self::get('mode') == 'webAjax') { web::getSite(); $lang = lang::gets(LANG_INDEX, SITE_ID); /* Authentification webUser */ web::observer(); } else { define('LANG_INDEX', SYS_INDEX); $lang = lang::gets(LANG_INDEX); admin::observer(); if (defined('ADMIN_USER_SITE_ID')) { define('ADMIN_SITE_ID', ADMIN_USER_SITE_ID); s::set('ADMIN_SITE_ID', ADMIN_USER_SITE_ID); $group_rules = ini::parse(SYS_ROOT . 'conf/admin/groups.ini', ADMIN_USER_GROUP_ID); define('RULE', $group_rules['rule']); db::table('admin_sites'); db::where('site_id', ADMIN_USER_SITE_ID); db::limit(1); define('ADMIN_SITE', db::get('site_domain')); s::set('ADMIN_SITE', ADMIN_SITE); } } /* Set params */ params::send(); $tmpl = params::get('tmpl'); $sys = false; if (self::get('mode') == 'adminAjax') { $sys = true; } buffer::init(0, self::get('app'), false, $tmpl); if (self::get('mode') == 'webAjax') { load::handler(self::get('app'), self::get('module'), self::get('action')); } else { load::module(self::get('app'), self::get('module'), self::get('action')); } /* Get plugin action */ ob_start(); /* запуск обработчика с возвратом данных тут два варианта либо данные просто выводим если нет шаблона, а если есть то сначала обрабатываем шаблон если буффер полный выводим информацию из него */ $buffer = buffer::gets(); if ($buffer[0]) { if ($sys) { buffer::$module = self::get('module'); } $section = params::get('section'); echo buffer::get($buffer[0]['app'], $buffer[0]['tmpl'], $buffer[0]['data'], $section, $sys); } $code = ob_get_contents(); ob_clean(); s::$mode = 'code'; s::setTmpl($code, $lang); s::display(); }