includes/sessions.php
changeset 711 f70d764aab33
parent 697 8e9ba8b131fa
child 725 b64f2618ef25
child 733 e5f638c216f7
equal deleted inserted replaced
710:1fbce408813c 711:f70d764aab33
   471             $this->theme = $template->default_theme;
   471             $this->theme = $template->default_theme;
   472             $this->style = $template->default_style;
   472             $this->style = $template->default_style;
   473           }
   473           }
   474         }
   474         }
   475         $user = true;
   475         $user = true;
       
   476         
       
   477         // set timezone params
   476         $GLOBALS['timezone'] = $userdata['user_timezone'];
   478         $GLOBALS['timezone'] = $userdata['user_timezone'];
       
   479         $GLOBALS['dst_params'] = explode(';', $userdata['user_dst']);
       
   480         foreach ( $GLOBALS['dst_params'] as &$parm )
       
   481         {
       
   482           if ( substr($parm, -1) != 'd' )
       
   483             $parm = intval($parm);
       
   484         }
   477         
   485         
   478         // Set language
   486         // Set language
   479         if ( !defined('ENANO_ALLOW_LOAD_NOLANG') )
   487         if ( !defined('ENANO_ALLOW_LOAD_NOLANG') )
   480         {
   488         {
   481           $lang_id = intval($userdata['user_lang']);
   489           $lang_id = intval($userdata['user_lang']);
  1036     $salt = $db->escape($keydata[3]);
  1044     $salt = $db->escape($keydata[3]);
  1037     profiler_log("SessionManager: checking session: " . sha1($key) . ": decrypted session key to $decrypted_key");
  1045     profiler_log("SessionManager: checking session: " . sha1($key) . ": decrypted session key to $decrypted_key");
  1038     // using a normal call to $db->sql_query to avoid failing on errors here
  1046     // using a normal call to $db->sql_query to avoid failing on errors here
  1039     $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,' . "\n"
  1047     $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,' . "\n"
  1040                              . '    u.reg_time,u.account_active,u.activation_key,u.user_lang,u.user_title,k.source_ip,k.time,k.auth_level,k.key_type,COUNT(p.message_id) AS num_pms,' . "\n"
  1048                              . '    u.reg_time,u.account_active,u.activation_key,u.user_lang,u.user_title,k.source_ip,k.time,k.auth_level,k.key_type,COUNT(p.message_id) AS num_pms,' . "\n"
  1041                              . '    u.user_timezone, x.* FROM '.table_prefix.'session_keys AS k' . "\n"
  1049                              . '    u.user_timezone, u.user_dst, x.* FROM '.table_prefix.'session_keys AS k' . "\n"
  1042                              . '  LEFT JOIN '.table_prefix.'users AS u' . "\n"
  1050                              . '  LEFT JOIN '.table_prefix.'users AS u' . "\n"
  1043                              . '    ON ( u.user_id=k.user_id )' . "\n"
  1051                              . '    ON ( u.user_id=k.user_id )' . "\n"
  1044                              . '  LEFT JOIN '.table_prefix.'users_extra AS x' . "\n"
  1052                              . '  LEFT JOIN '.table_prefix.'users_extra AS x' . "\n"
  1045                              . '    ON ( u.user_id=x.user_id OR x.user_id IS NULL )' . "\n"
  1053                              . '    ON ( u.user_id=x.user_id OR x.user_id IS NULL )' . "\n"
  1046                              . '  LEFT JOIN '.table_prefix.'privmsgs AS p' . "\n"
  1054                              . '  LEFT JOIN '.table_prefix.'privmsgs AS p' . "\n"
  1049                              . '    AND k.salt=\''.$salt.'\'' . "\n"
  1057                              . '    AND k.salt=\''.$salt.'\'' . "\n"
  1050                              . '  GROUP BY u.user_id,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,u.user_lang,u.user_timezone,u.user_title,k.source_ip,k.time,k.auth_level,x.user_id, x.user_aim, x.user_yahoo, x.user_msn, x.user_xmpp, x.user_homepage, x.user_location, x.user_job, x.user_hobbies, x.email_public, x.disable_js_fx;');
  1058                              . '  GROUP BY u.user_id,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,u.user_lang,u.user_timezone,u.user_title,k.source_ip,k.time,k.auth_level,x.user_id, x.user_aim, x.user_yahoo, x.user_msn, x.user_xmpp, x.user_homepage, x.user_location, x.user_job, x.user_hobbies, x.email_public, x.disable_js_fx;');
  1051     
  1059     
  1052     if ( !$query && ( defined('IN_ENANO_INSTALL') or defined('IN_ENANO_UPGRADE') ) )
  1060     if ( !$query && ( defined('IN_ENANO_INSTALL') or defined('IN_ENANO_UPGRADE') ) )
  1053     {
  1061     {
  1054       $query = $this->sql('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, 1440 AS user_timezone, ' . SK_SHORT . ' AS key_type FROM '.table_prefix.'session_keys AS k
  1062       $query = $this->sql('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, 1440 AS user_timezone, \'0;0;0;0;60\' AS user_dst, ' . SK_SHORT . ' AS key_type FROM '.table_prefix.'session_keys AS k
  1055                              LEFT JOIN '.table_prefix.'users AS u
  1063                              LEFT JOIN '.table_prefix.'users AS u
  1056                                ON ( u.user_id=k.user_id )
  1064                                ON ( u.user_id=k.user_id )
  1057                              LEFT JOIN '.table_prefix.'privmsgs AS p
  1065                              LEFT JOIN '.table_prefix.'privmsgs AS p
  1058                                ON ( p.message_to=u.username AND p.message_read=0 )
  1066                                ON ( p.message_to=u.username AND p.message_read=0 )
  1059                              WHERE k.session_key=\''.$keyhash.'\'
  1067                              WHERE k.session_key=\''.$keyhash.'\'
  2705                         . "    ON ( g.group_id = m.group_id )\n"
  2713                         . "    ON ( g.group_id = m.group_id )\n"
  2706                         . "  WHERE $uid_column;");
  2714                         . "  WHERE $uid_column;");
  2707       if ( !$q )
  2715       if ( !$q )
  2708         $db->_die();
  2716         $db->_die();
  2709       
  2717       
  2710       $groups = array();
  2718       // The l10n engine takes care of this later.
       
  2719       $groups = array(1 => 'Everyone');
  2711       
  2720       
  2712       if ( $row = $db->fetchrow() )
  2721       if ( $row = $db->fetchrow() )
  2713       {
  2722       {
  2714         $user_id = intval($row['user_id']);
  2723         $user_id = intval($row['user_id']);
  2715         if ( $row['group_id'] )
  2724         if ( $row['group_id'] )
  2981     }
  2990     }
  2982     foreach ( $perm1 as $i => $p )
  2991     foreach ( $perm1 as $i => $p )
  2983     {
  2992     {
  2984       if ( isset($perm2[$i]) )
  2993       if ( isset($perm2[$i]) )
  2985       {
  2994       {
  2986         if ( $is_everyone && !$defaults_used[$i] )
  2995         if ( $is_everyone && isset($defaults_used[$i]) && $defaults_used[$i] === false )
  2987           continue;
  2996           continue;
  2988         // Decide precedence
  2997         // Decide precedence
  2989         if ( isset($defaults_used[$i]) )
  2998         if ( isset($defaults_used[$i]) )
  2990         {
  2999         {
  2991           // echo "$i: default in use, overriding to: {$perm2[$i]}<br />";
  3000           // echo "$i: default in use, overriding to: {$perm2[$i]}<br />";