Esempio n. 1
0
File: admin.php Progetto: rigidus/ea
 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', '&nbsp;<a href="javascript:void(null);" class="ico ico11 ico_popup popupLoad" id="site_list_load">&nbsp;</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);
 }