Linux multi-monitor fullscreen support
[ryzomcore.git] / web / public_php / admin / functions_auth.php
blob6f478bbc9aed5900ffb34ddc13fc9db1955a3e5b
1 <?php
3 /*
4 * THIS FILE SHOULD ONLY INCLUDE AUTHENTIFICATION RELATED FUNCTIONS
5 */
7 function nt_auth_set_logging_count($user_id)
9 global $db;
11 $sql = "UPDATE ". NELDB_USER_TABLE ." SET user_logged_count=user_logged_count+1,user_logged_last=". time() ." WHERE user_id=". (int)$user_id;
12 $db->sql_query($sql);
15 function nt_auth_load_user($nelid)
17 global $db;
19 $data = null;
21 $sql = "SELECT * FROM ". NELDB_USER_TABLE ." LEFT JOIN ". NELDB_GROUP_TABLE ." ON (user_group_id=group_id) WHERE user_id=". (int)$nelid;
22 if ($result = $db->sql_query($sql))
24 if ($db->sql_numrows($result))
26 $data = $db->sql_fetchrow($result);
30 return $data;
33 function nt_auth_get_group_name($group_id)
35 global $db;
37 $sql = "SELECT user_name FROM ". NELDB_USER_TABLE ." WHERE user_id=". (int)$group_id;
38 if ($result = $db->sql_query($sql))
40 if ($db->sql_numrows($result))
42 $row = $db->sql_fetchrow($result);
43 return $row['user_name'];
47 return null;
50 function nt_auth_check_login($user, $passwd)
52 global $db;
54 $data = null;
56 $user = $db->sql_escape_string(trim($user));
57 $passwd = md5(trim($passwd));
59 $sql = "SELECT * FROM ". NELDB_USER_TABLE ." LEFT JOIN ". NELDB_GROUP_TABLE ." ON (user_group_id=group_id) WHERE user_name='". $user ."' AND user_password='". $passwd ."' AND user_active=1 AND group_active=1";
60 if ($result = $db->sql_query($sql))
62 if ($db->sql_numrows($result))
64 $data = $db->sql_fetchrow($result);
67 return $data;
70 function nt_auth_load_login()
72 global $tpl;
74 $tpl->assign('tool_login_title', 'Login');
75 $tpl->display('index_login.tpl');
78 function nt_auth_start_session()
80 global $NEL_SETUP_SESSION;
81 if (isset($NEL_SETUP_SESSION) && ($NEL_SETUP_SESSION))
83 return;
86 session_name(NELTOOL_SESSIONID);
87 session_cache_limiter('nocache');
88 session_start();
90 header("Expires: Mon, 01 May 2000 06:00:00 GMT");
91 header("Last-Modified: ". gmdate("D, d M Y H:i:s") ." GMT");
92 header("Cache-Control: no-store, no-cache, must-revalidate");
93 header("Cache-Control: post-check=0, pre-check=0", false);
94 header("Pragma: no-cache");
97 function nt_auth_stop_session()
99 global $NEL_SETUP_SESSION;
100 if (isset($NEL_SETUP_SESSION) && ($NEL_SETUP_SESSION))
102 return;
105 global $NELTOOL;
107 foreach($NELTOOL['SESSION_VARS'] as $key => $val)
109 unset($NELTOOL['SESSION_VARS'][$key]);
113 function nt_auth_set_session_var($name, $value)
115 global $NELTOOL;
117 $NELTOOL['SESSION_VARS'][$name] = $value;
120 function nt_auth_get_session_var($name)
122 global $NELTOOL;
124 if (isset($NELTOOL['SESSION_VARS'][$name])) return $NELTOOL['SESSION_VARS'][$name];
125 return null;
128 function nt_auth_unset_session_var($name)
130 global $NELTOOL;
132 unset($NELTOOL['SESSION_VARS'][$name]);