Changeset 2359


Ignore:
Timestamp:
03/26/10 18:09:04 (14 years ago)
Author:
niltonneto
Message:

Ticket #1007 - Corrigido problema de sobrecarga de sessão devido ao list_sessions().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.1/phpgwapi/inc/class.sessions_php4.inc.php

    r2 r2359  
    125125                        else 
    126126                        { 
    127                                 $sessions = $this->list_sessions(0,'','',True); 
    128                                  
    129                                 if (isset($sessions[$sessionid])) 
    130                                 { 
    131                                         //echo "<p>session_php4::destroy($session_id): unlink('".$sessions[$sessionid]['php_session_file'].")</p>\n"; 
    132                                         @unlink($sessions[$sessionid]['php_session_file']); 
     127                                if(@opendir($path = ini_get('session.save_path'))){ 
     128                                        $session_file = $path."/sess_".$sessionid; 
     129                                        if (file_exists($session_file)) 
     130                                                @unlink($session_file); 
    133131                                } 
    134132                        } 
     
    199197                function list_sessions($start,$order,$sort,$all_no_sort = False) 
    200198                { 
    201                         //echo "<p>session_php4::list_sessions($start,'$order','$sort',$all)</p>\n"; 
    202                         $session_cache = $this->appsession('php4_session_cache','phpgwapi'); 
    203  
    204199                        $values = array(); 
    205200                        $maxmatchs = $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']; 
     
    211206                        while ($file = readdir($dir)) 
    212207                        { 
    213                                 if (substr($file,0,5) != 'sess_') 
     208                                if (substr($file,0,5) != 'sess_' || !is_readable($path. '/' . $file)) 
    214209                                { 
    215210                                        continue; 
    216211                                } 
    217                                 if (isset($session_cache[$file]))       // use copy from cache 
    218                                 { 
    219                                         $session = $session_cache[$file]; 
    220  
    221                                         if ($session['session_flags'] == 'A' || !$session['session_id'] || 
    222                                                 $session['session_install_id'] != $GLOBALS['phpgw_info']['server']['install_id']) 
    223                                         { 
    224                                                 continue;       // no anonymous sessions or other domains or installations 
    225                                         } 
    226                                         if (!$all_no_sort)      // we need the up-to-date data --> unset and reread it 
    227                                         { 
    228                                                 unset($session_cache[$file]); 
    229                                         } 
    230                                 } 
    231                                 if (!isset($session_cache[$file]))      // not in cache, read and cache it 
    232                                 { 
    233                                         if (!is_readable($path. '/' . $file)) 
    234                                         { 
    235                                                 continue;       // happens if webserver runs multiple user-ids 
    236                                         } 
    237                                         $session = ''; 
    238                                         if (($fd = fopen ($path . '/' . $file,'r'))) 
    239                                         { 
    240                                                 $session = ($size = filesize ($path . '/' . $file)) ? @fread ($fd, $size) : 0; 
    241                                                 fclose ($fd); 
    242                                         } 
    243                                         if (substr($session,0,14) != 'phpgw_session|') 
    244                                         { 
    245                                                 continue; 
    246                                         } 
    247                                         $session = unserialize(substr($session,14)); 
    248                                         unset($session['phpgw_app_sessions']);  // not needed, saves memory 
    249                                         $session_cache[$file] = $session; 
    250                                 } 
    251                                 if($session['session_flags'] == 'A' || !$session['session_id'] || 
    252                                         $session['session_install_id'] != $GLOBALS['phpgw_info']['server']['install_id']) 
    253                                 { 
    254                                         continue;       // no anonymous sessions or other domains or installations 
    255                                 } 
    256                                 //echo "file='$file'=<pre>"; print_r($session); echo "</pre>";  
    257  
    258                                 $session['php_session_file'] = $path . '/' . $file; 
     212 
     213                                $session = ''; 
     214                                if (($fd = fopen ($path . '/' . $file,'r'))) 
     215                                { 
     216                                        $session = ($size = filesize ($path . '/' . $file)) ? @fread ($fd, $size) : 0; 
     217                                        fclose ($fd); 
     218                                } 
     219                                $session = unserialize(substr($session,14)); 
    259220                                $values[$session['session_id']] = $session; 
    260221                        } 
     
    280241                                reset($values); 
    281242                        } 
    282                         $this->appsession('php4_session_cache','phpgwapi',$session_cache); 
    283243 
    284244                        return $values; 
Note: See TracChangeset for help on using the changeset viewer.