Linux multi-monitor fullscreen support
[ryzomcore.git] / web / public_php / admin / common.php
blobceb9aa87bce52e4f9c193c44bb5e2cab85718266
1 <?php
3 //error_reporting(E_ALL); // extreme debug info ;)
4 set_time_limit(180); // 3 min time out
6 // add the path for the nel class files
7 ini_set('include_path',ini_get('include_path') .':./nel/');
9 require_once('config.php');
11 if (isset($NEL_SETUP_SESSION) && ($NEL_SETUP_SESSION))
12 define('NELTOOL_NO_USER_NEEDED', true);
14 require_once(NELTOOL_SYSTEMBASE .'functions_common.php');
15 require_once(NELTOOL_SYSTEMBASE .'functions_auth.php');
17 //assert_options(ASSERT_ACTIVE, 1);
18 //assert_options(ASSERT_WARNING, 0);
19 //assert_options(ASSERT_QUIET_EVAL, 1);
20 //assert_options(ASSERT_CALLBACK, 'nt_common_assert');
22 require_once(NELTOOL_SYSTEMBASE .'functions_mysqli.php');
23 require_once(NELTOOL_SYSTEMBASE .'smarty/Smarty.class.php');
24 require_once(NELTOOL_SYSTEMBASE. 'functions_tool_administration.php');
25 require_once(NELTOOL_SYSTEMBASE. 'nel/admin_modules_itf.php');
27 // lets set up the database
28 $db = new sql_db(NELTOOL_DBHOST, NELTOOL_DBUSER, NELTOOL_DBPASS, NELTOOL_DBNAME);
29 if (!is_object($db)) die("error on db init");
31 // lets set up the smarty template engine
32 $tpl = new Smarty;
33 if (!is_object($tpl)) die("error on smarty init");
35 $iPhone = (strstr($_SERVER['HTTP_USER_AGENT'], "iPhone") !== FALSE);
36 $tpl->assign('iPhone', $iPhone);
38 $tpl->template_dir = NELTOOL_SYSTEMBASE .'/templates/default/';
39 $tpl->compile_dir = NELTOOL_SYSTEMBASE .'/templates/default_c/';
40 $tpl->config_dir = NELTOOL_SYSTEMBASE .'/templates/config/';
41 $tpl->cache_dir = NELTOOL_SYSTEMBASE .'/templates/cache/';
43 $tpl->caching = false;
44 $tpl->clear_all_cache();
45 if (NELTOOL_DEBUG) $tpl->debugging = false;
47 if (defined('NELTOOL_NO_USER_NEEDED'))
49 // this is used for cron jobs that don't need authentifications when running
51 else
53 nt_auth_start_session();
55 $NELTOOL = array(
56 'POST_VARS' => &$_POST,
57 'GET_VARS' => &$_GET,
58 'COOKIE_VARS' => &$_COOKIE,
59 'SESSION_VARS' => &$_SESSION,
60 'SERVER_VARS' => &$_SERVER,
63 $nel_user = null;
64 $nel_debug = array();
66 nt_common_add_debug(date("Y-m-d H:i:s",time()));
67 nt_common_add_debug('-- Basic init complete, time to get some work done.');
70 // login and session process
71 if (isset($NELTOOL['GET_VARS']['mode']) && ($NELTOOL['GET_VARS']['mode'] == 'logout'))
73 $nel_user = null;
74 nt_auth_stop_session();
75 nt_common_redirect('');
76 exit();
78 elseif (isset($NELTOOL['SESSION_VARS']['nelid']) && !empty($NELTOOL['SESSION_VARS']['nelid']))
80 $nel_user = nt_auth_load_user($NELTOOL['SESSION_VARS']['nelid']);
82 elseif (isset($NELTOOL['POST_VARS']['nel_login']) && isset($NELTOOL['POST_VARS']['nel_passwd']) && ($NELTOOL['POST_VARS']['action'] == 'login'))
84 $nel_user = nt_auth_check_login($NELTOOL['POST_VARS']['nel_login'], $NELTOOL['POST_VARS']['nel_passwd']);
85 if ($nel_user)
87 nt_auth_set_session_var('nelid',$nel_user['user_id']);
88 nt_auth_set_logging_count($nel_user['user_id']);
89 $nel_user['new_login'] = true;
93 if (!$nel_user)
95 nt_auth_load_login();
96 exit();
99 nt_common_add_debug('-- User authentification complete.');
101 // some site settings
103 if (NELTOOL_DEBUG && ($nel_user['group_level'] == 10)) // need to use the array instead of the value being hardcoded
105 $tpl->assign('NELTOOL_DEBUG', true); //$nel_debug);
108 $tpl->assign('nel_script', $NELTOOL['SERVER_VARS']['SCRIPT_NAME']);
109 $tpl->assign('nel_request_uri', basename($NELTOOL['SERVER_VARS']['REQUEST_URI']));
110 $tpl->assign('nel_tool_title', NELTOOL_SITETITLE);
111 $tpl->assign('nel_web_base_uri', NELTOOL_SITEBASE);
113 $tpl->assign('tool_title', "&lt;unknown&gt;");
114 $tpl->assign('user_info', $nel_user['user_name'] .' ('. $nel_user['group_name'] .')');
116 // load user & group applications/domains/shards
118 $nel_user['access'] = array(
119 'applications' => tool_admin_applications_get_list(),
120 'user_applications' => tool_admin_users_applications_get_list($nel_user['user_id']),
121 'user_domains' => tool_admin_users_domains_get_list($nel_user['user_id']),
122 'user_shards' => tool_admin_users_shards_get_list($nel_user['user_id']),
123 'group_applications' => tool_admin_groups_applications_get_list($nel_user['user_group_id']),
124 'group_domains' => tool_admin_groups_domains_get_list($nel_user['user_group_id']),
125 'group_shards' => tool_admin_groups_shards_get_list($nel_user['user_group_id']),
128 $nel_user['access']['domains'] = tool_admin_users_groups_domains_merge();
129 $nel_user['access']['shards'] = tool_admin_users_groups_shards_merge();
130 $nel_user['has_lock'] = false;
132 //nt_common_add_debug($nel_user);
134 // load the user application menu
136 $tool_application_list = tool_admin_applications_build_menu_list($nel_user['access']);
137 $tpl->assign('nel_menu', $tool_application_list);
138 $tpl->assign('menu_style', $nel_user['user_menu_style']);
139 $tpl->assign('unknown_menu', 'imgs/icon_unknown.png');
141 if (isset($nel_user['new_login']))
143 $default_user_application_id = 0;
144 if (isset( $nel_user['user_default_application_id']) &&($nel_user['user_default_application_id'] > 0)) {
145 $default_user_application_id = $nel_user['user_default_application_id'];
146 }elseif (isset( $nel_user['group_default_application_id']) &&($nel_user['group_default_application_id'] > 0)) {
147 $default_user_application_id = $nel_user['group_default_application_id'];
150 if ($default_user_application_id > 0)
152 nt_common_add_debug("default application : user:". $nel_user['user_default_application_id'] ." group:". $nel_user['group_default_application_id']);
153 $default_user_application_data = tool_admin_applications_get_default($tool_application_list, $default_user_application_id);
154 nt_common_redirect($default_user_application_data['application_uri']);
155 exit();
159 $nel_tool_extra_css = '';
160 if (BG_IMG !== null)
162 $nel_tool_extra_css .= "<style><!--\n";
163 $nel_tool_extra_css .= "body { background: url(". BG_IMG ."); }\n";
164 $nel_tool_extra_css .= "--></style>\n";
166 $tpl->assign('nel_tool_extra_css', $nel_tool_extra_css);
167 $tpl->assign('system_time', time());
169 nt_common_add_debug('-- Common init. complete.');