includes/sessions.php
changeset 209 8a00247d1dee
parent 204 473cc747022a
child 221 e5302cb1945c
equal deleted inserted replaced
208:c75ad574b56d 209:8a00247d1dee
   360    */
   360    */
   361   
   361   
   362   function start()
   362   function start()
   363   {
   363   {
   364     global $db, $session, $paths, $template, $plugins; // Common objects
   364     global $db, $session, $paths, $template, $plugins; // Common objects
       
   365     global $lang;
   365     if($this->started) return;
   366     if($this->started) return;
   366     $this->started = true;
   367     $this->started = true;
   367     $user = false;
   368     $user = false;
   368     if(isset($_COOKIE['sid']))
   369     if(isset($_COOKIE['sid']))
   369     {
   370     {
   379       {
   380       {
   380         $data = RenderMan::strToPageID($paths->get_pageid_from_url());
   381         $data = RenderMan::strToPageID($paths->get_pageid_from_url());
   381         
   382         
   382         if(!$this->compat && $userdata['account_active'] != 1 && $data[1] != 'Special' && $data[1] != 'Admin')
   383         if(!$this->compat && $userdata['account_active'] != 1 && $data[1] != 'Special' && $data[1] != 'Admin')
   383         {
   384         {
       
   385           $language = intval(getConfig('default_language'));
       
   386           $lang = new Language($language);
       
   387           
   384           $this->logout();
   388           $this->logout();
   385           $a = getConfig('account_activation');
   389           $a = getConfig('account_activation');
   386           switch($a)
   390           switch($a)
   387           {
   391           {
   388             case 'none':
   392             case 'none':
   478             $this->style = $template->default_style;
   482             $this->style = $template->default_style;
   479           }
   483           }
   480         }
   484         }
   481         $user = true;
   485         $user = true;
   482         
   486         
       
   487         // Set language
       
   488         if ( !defined('ENANO_ALLOW_LOAD_NOLANG') )
       
   489         {
       
   490           $lang_id = intval($userdata['user_lang']);
       
   491           $lang = new Language($lang_id);
       
   492         }
       
   493         
   483         if(isset($_REQUEST['auth']) && !$this->sid_super)
   494         if(isset($_REQUEST['auth']) && !$this->sid_super)
   484         {
   495         {
   485           // Now he thinks he's a moderator. Or maybe even an administrator. Let's find out if he's telling the truth.
   496           // Now he thinks he's a moderator. Or maybe even an administrator. Let's find out if he's telling the truth.
   486           if($this->compat)
   497           if($this->compat)
   487           {
   498           {
  1109    */
  1120    */
  1110    
  1121    
  1111   function register_guest_session()
  1122   function register_guest_session()
  1112   {
  1123   {
  1113     global $db, $session, $paths, $template, $plugins; // Common objects
  1124     global $db, $session, $paths, $template, $plugins; // Common objects
       
  1125     global $lang;
  1114     $this->username = $_SERVER['REMOTE_ADDR'];
  1126     $this->username = $_SERVER['REMOTE_ADDR'];
  1115     $this->user_level = USER_LEVEL_GUEST;
  1127     $this->user_level = USER_LEVEL_GUEST;
  1116     if($this->compat || defined('IN_ENANO_INSTALL'))
  1128     if($this->compat || defined('IN_ENANO_INSTALL'))
  1117     {
  1129     {
  1118       $this->theme = 'oxygen';
  1130       $this->theme = 'oxygen';
  1122     {
  1134     {
  1123       $this->theme = ( isset($_GET['theme']) && isset($template->named_theme_list[$_GET['theme']])) ? $_GET['theme'] : $template->default_theme;
  1135       $this->theme = ( isset($_GET['theme']) && isset($template->named_theme_list[$_GET['theme']])) ? $_GET['theme'] : $template->default_theme;
  1124       $this->style = ( isset($_GET['style']) && file_exists(ENANO_ROOT.'/themes/'.$this->theme . '/css/'.$_GET['style'].'.css' )) ? $_GET['style'] : substr($template->named_theme_list[$this->theme]['default_style'], 0, strlen($template->named_theme_list[$this->theme]['default_style'])-4);
  1136       $this->style = ( isset($_GET['style']) && file_exists(ENANO_ROOT.'/themes/'.$this->theme . '/css/'.$_GET['style'].'.css' )) ? $_GET['style'] : substr($template->named_theme_list[$this->theme]['default_style'], 0, strlen($template->named_theme_list[$this->theme]['default_style'])-4);
  1125     }
  1137     }
  1126     $this->user_id = 1;
  1138     $this->user_id = 1;
       
  1139     if ( !defined('ENANO_ALLOW_LOAD_NOLANG') )
       
  1140     {
       
  1141       // This is a VERY special case we are allowing. It lets the installer create languages using the Enano API.
       
  1142       $language = intval(getConfig('default_language'));
       
  1143       $lang = new Language($language);
       
  1144     }
  1127   }
  1145   }
  1128   
  1146   
  1129   /**
  1147   /**
  1130    * Validates a session key, and returns the userdata associated with the key or false
  1148    * Validates a session key, and returns the userdata associated with the key or false
  1131    * @param string $key The session key to validate
  1149    * @param string $key The session key to validate
  1149       // echo '(debug) $session->validate_session: Key does not match regex<br />Decrypted key: '.$decrypted_key;
  1167       // echo '(debug) $session->validate_session: Key does not match regex<br />Decrypted key: '.$decrypted_key;
  1150       return false;
  1168       return false;
  1151     }
  1169     }
  1152     $keyhash = md5($key);
  1170     $keyhash = md5($key);
  1153     $salt = $db->escape($keydata[3]);
  1171     $salt = $db->escape($keydata[3]);
  1154     $query = $db->sql_query('SELECT u.user_id AS uid,u.username,u.password,u.email,u.real_name,u.user_level,u.theme,u.style,u.signature,u.reg_time,u.account_active,u.activation_key,k.source_ip,k.time,k.auth_level,COUNT(p.message_id) AS num_pms,x.* FROM '.table_prefix.'session_keys AS k
  1172     $query = $db->sql_query('SELECT u.user_id AS uid,u.username,u.password,u.email,u.real_name,u.user_level,u.theme,u.style,u.signature,u.reg_time,u.account_active,u.activation_key,k.source_ip,k.time,k.auth_level,COUNT(p.message_id) AS num_pms,u.user_lang,x.* FROM '.table_prefix.'session_keys AS k
  1155                                LEFT JOIN '.table_prefix.'users AS u
  1173                                LEFT JOIN '.table_prefix.'users AS u
  1156                                  ON ( u.user_id=k.user_id )
  1174                                  ON ( u.user_id=k.user_id )
  1157                                LEFT JOIN '.table_prefix.'users_extra AS x
  1175                                LEFT JOIN '.table_prefix.'users_extra AS x
  1158                                  ON ( u.user_id=x.user_id OR x.user_id IS NULL )
  1176                                  ON ( u.user_id=x.user_id OR x.user_id IS NULL )
  1159                                LEFT JOIN '.table_prefix.'privmsgs AS p
  1177                                LEFT JOIN '.table_prefix.'privmsgs AS p