Changeset 3633 in subversion


Ignore:
Timestamp:
May 19, 2010 2:58:42 AM (3 years ago)
Author:
alec
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/include/rcmail.php

    r3627 r3633  
    6262    return self::$instance; 
    6363  } 
    64    
    65    
     64 
     65 
    6666  /** 
    6767   * Private constructor 
     
    7171    // load configuration 
    7272    $this->config = new rcube_config(); 
    73      
     73 
    7474    register_shutdown_function(array($this, 'shutdown')); 
    7575  } 
    76    
    77    
     76 
     77 
    7878  /** 
    7979   * Initial startup function 
     
    127127    $this->plugins->init(); 
    128128  } 
    129    
    130    
     129 
     130 
    131131  /** 
    132132   * Setter for application task 
     
    145145    $this->task = $task; 
    146146    $this->comm_path = $this->url(array('task' => $this->task)); 
    147      
     147 
    148148    if ($this->output) 
    149149      $this->output->set_env('task', $this->task); 
    150150  } 
    151    
    152    
     151 
     152 
    153153  /** 
    154154   * Setter for system user object 
     
    161161      $this->user = $user; 
    162162      $GLOBALS['USER'] = $this->user; 
    163        
     163 
    164164      // overwrite config with user preferences 
    165165      $this->config->set_user_prefs((array)$this->user->get_prefs()); 
    166166    } 
    167      
     167 
    168168    $_SESSION['language'] = $this->user->language = $this->language_prop($this->config->get('language', $_SESSION['language'])); 
    169169 
     
    171171    setlocale(LC_ALL, $_SESSION['language'] . '.utf8', 'en_US.utf8'); 
    172172 
    173     // workaround for http://bugs.php.net/bug.php?id=18556  
    174     if (in_array($_SESSION['language'], array('tr_TR', 'ku', 'az_AZ')))  
    175       setlocale(LC_CTYPE, 'en_US' . '.utf8');  
    176   } 
    177    
    178    
     173    // workaround for http://bugs.php.net/bug.php?id=18556 
     174    if (in_array($_SESSION['language'], array('tr_TR', 'ku', 'az_AZ'))) 
     175      setlocale(LC_CTYPE, 'en_US' . '.utf8'); 
     176  } 
     177 
     178 
    179179  /** 
    180180   * Check the given string and return a valid language code 
     
    186186  { 
    187187    static $rcube_languages, $rcube_language_aliases; 
    188      
     188 
    189189    // user HTTP_ACCEPT_LANGUAGE if no language is specified 
    190190    if (empty($lang) || $lang == 'auto') { 
     
    192192       $lang = str_replace('-', '_', $accept_langs[0]); 
    193193     } 
    194       
     194 
    195195    if (empty($rcube_languages)) { 
    196196      @include(INSTALL_PATH . 'program/localization/index.inc'); 
    197197    } 
    198      
     198 
    199199    // check if we have an alias for that language 
    200200    if (!isset($rcube_languages[$lang]) && isset($rcube_language_aliases[$lang])) { 
     
    204204    else if (!isset($rcube_languages[$lang])) { 
    205205      $short = substr($lang, 0, 2); 
    206       
     206 
    207207      // check if we have an alias for the short language code 
    208208      if (!isset($rcube_languages[$short]) && isset($rcube_language_aliases[$short])) { 
     
    221221    return $lang; 
    222222  } 
    223    
    224    
     223 
     224 
    225225  /** 
    226226   * Get the current database connection 
     
    241241    return $this->db; 
    242242  } 
    243    
    244    
     243 
     244 
    245245  /** 
    246246   * Return instance of the internal address book class 
     
    257257 
    258258    $plugin = $this->plugins->exec_hook('get_address_book', array('id' => $id, 'writeable' => $writeable)); 
    259      
     259 
    260260    // plugin returned instance of a rcube_addressbook 
    261261    if ($plugin['instance'] instanceof rcube_addressbook) { 
     
    280280      $contacts = new rcube_contacts($this->db, $this->user->ID); 
    281281    } 
    282      
     282 
    283283    return $contacts; 
    284284  } 
     
    335335    return $list; 
    336336  } 
    337    
    338    
     337 
     338 
    339339  /** 
    340340   * Init output object for GUI and add common scripts. 
     
    368368    // add some basic label to client 
    369369    $this->output->add_label('loading', 'servererror'); 
    370      
     370 
    371371    return $this->output; 
    372372  } 
    373    
    374    
     373 
     374 
    375375  /** 
    376376   * Create an output object for JSON responses 
     
    382382    if (!($this->output instanceof rcube_json_output)) 
    383383      $this->output = new rcube_json_output($this->task); 
    384      
     384 
    385385    return $this->output; 
    386386  } 
     
    395395  { 
    396396    $this->smtp = new rcube_smtp(); 
    397    
     397 
    398398    if ($connect) 
    399399      $this->smtp->connect(); 
    400400  } 
    401    
    402    
     401 
     402 
    403403  /** 
    404404   * Create global IMAP object and connect to server 
     
    412412    if (is_object($this->imap)) 
    413413      return; 
    414        
     414 
    415415    $this->imap = new rcube_imap($this->db); 
    416416    $this->imap->debug_level = $this->config->get('debug_level'); 
     
    424424    // set pagesize from config 
    425425    $this->imap->set_pagesize($this->config->get('pagesize', 50)); 
    426      
     426 
    427427    // Setting root and delimiter before establishing the connection 
    428     // can save time detecting them using NAMESPACE and LIST  
     428    // can save time detecting them using NAMESPACE and LIST 
    429429    $options = array( 
    430430      'auth_method' => $this->config->get('imap_auth_type', 'check'), 
     
    436436 
    437437    $this->imap->set_options($options); 
    438    
     438 
    439439    // set global object for backward compatibility 
    440440    $GLOBALS['IMAP'] = $this->imap; 
     
    443443    if ($hook['fetch_headers']) 
    444444      $this->imap->fetch_add_headers = $hook['fetch_headers']; 
    445      
     445 
    446446    // support this parameter for backward compatibility but log warning 
    447447    if ($connect) { 
     
    462462    if (!$this->imap) 
    463463      $this->imap_init(); 
    464      
     464 
    465465    if ($_SESSION['imap_host'] && !$this->imap->conn->connected()) { 
    466466      if (!$this->imap->connect($_SESSION['imap_host'], $_SESSION['username'], $this->decrypt($_SESSION['password']), $_SESSION['imap_port'], $_SESSION['imap_ssl'])) { 
     
    501501    ini_set('session.name', 'roundcube_sessid'); 
    502502    ini_set('session.use_cookies', 1); 
    503     ini_set('session.use_only_cookies', 1);   
     503    ini_set('session.use_only_cookies', 1); 
    504504    ini_set('session.serialize_handler', 'php'); 
    505505 
     
    588588        $imap_port = 993; 
    589589    } 
    590      
     590 
    591591    $imap_port = $imap_port ? $imap_port : $config['default_port']; 
    592592 
    593     /* Modify username with domain if required   
     593    /* Modify username with domain if required 
    594594       Inspired by Marco <P0L0_notspam_binware.org> 
    595595    */ 
     
    667667      $_SESSION['password']  = $this->encrypt($pass); 
    668668      $_SESSION['login_time'] = mktime(); 
    669        
    670       if ($_REQUEST['_timezone'] != '_default_') 
     669 
     670      if (isset($_REQUEST['_timezone']) && $_REQUEST['_timezone'] != '_default_') 
    671671        $_SESSION['timezone'] = floatval($_REQUEST['_timezone']); 
    672672 
     
    698698      $this->imap->set_page($_SESSION['page']); 
    699699    } 
    700      
     700 
    701701    // cache IMAP root and delimiter in session for performance reasons 
    702702    $_SESSION['imap_root'] = $this->imap->root_dir; 
     
    714714    $default_host = $this->config->get('default_host'); 
    715715    $host = null; 
    716      
     716 
    717717    if (is_array($default_host)) { 
    718718      $post_host = get_input_value('_host', RCUBE_INPUT_POST); 
    719        
     719 
    720720      // direct match in default_host array 
    721721      if ($default_host[$post_host] || in_array($post_host, array_values($default_host))) { 
    722722        $host = $post_host; 
    723723      } 
    724        
     724 
    725725      // try to select host by mail domain 
    726726      list($user, $domain) = explode('@', get_input_value('_user', RCUBE_INPUT_POST)); 
     
    760760    if (empty($this->texts)) 
    761761      $this->load_language(); 
    762      
     762 
    763763    // extract attributes 
    764764    if (is_string($attrib)) 
     
    776776    } 
    777777 
    778     // make text item array  
     778    // make text item array 
    779779    $a_text_item = is_array($text_item) ? $text_item : array('single' => $text_item); 
    780780 
     
    826826  { 
    827827    $lang = $this->language_prop(($lang ? $lang : $_SESSION['language'])); 
    828      
     828 
    829829    // load localized texts 
    830830    if (empty($this->texts) || $lang != $_SESSION['language']) { 
     
    850850          $this->texts = array_merge($this->texts, $messages); 
    851851      } 
    852        
     852 
    853853      $_SESSION['language'] = $lang; 
    854854    } 
     
    929929  { 
    930930    $this->plugins->exec_hook('kill_session'); 
    931      
     931 
    932932    $this->session->remove(); 
    933933    $_SESSION = array('language' => $this->user->language, 'auth_time' => time(), 'temp' => true); 
     
    943943  { 
    944944    $config = $this->config->all(); 
    945      
    946     // on logout action we're not connected to imap server   
     945 
     946    // on logout action we're not connected to imap server 
    947947    if (($config['logout_purge'] && !empty($config['trash_mbox'])) || $config['logout_expunge']) { 
    948948      if (!$this->authenticate_session()) 
     
    995995    } 
    996996  } 
    997    
    998    
     997 
     998 
    999999  /** 
    10001000   * Generate a unique token to be used in a form request 
     
    10051005  { 
    10061006    $key = $this->task; 
    1007      
     1007 
    10081008    if (!$_SESSION['request_tokens'][$key]) 
    10091009      $_SESSION['request_tokens'][$key] = md5(uniqid($key . mt_rand(), true)); 
    1010      
     1010 
    10111011    return $_SESSION['request_tokens'][$key]; 
    10121012  } 
    1013    
    1014    
     1013 
     1014 
    10151015  /** 
    10161016   * Check if the current request contains a valid token 
     
    10241024    return !empty($token) && $_SESSION['request_tokens'][$this->task] == $token; 
    10251025  } 
    1026    
    1027    
     1026 
     1027 
    10281028  /** 
    10291029   * Create unique authorization hash 
     
    10671067     */ 
    10681068    $clear = pack("a*H2", $clear, "80"); 
    1069    
     1069 
    10701070    if (function_exists('mcrypt_module_open') && 
    10711071        ($td = mcrypt_module_open(MCRYPT_TripleDES, "", MCRYPT_MODE_CBC, ""))) 
     
    11121112    if (!$cipher) 
    11131113      return ''; 
    1114    
     1114 
    11151115    $cipher = $base64 ? base64_decode($cipher) : $cipher; 
    11161116 
     
    11271127    else { 
    11281128      @include_once('lib/des.inc'); 
    1129      
     1129 
    11301130      if (function_exists('des')) { 
    11311131        $des_iv_size = 8; 
     
    11481148     */ 
    11491149    $clear = substr(rtrim($clear, "\0"), 0, -1); 
    1150    
     1150 
    11511151    return $clear; 
    11521152  } 
     
    11621162    if (!is_array($p)) 
    11631163      $p = array('_action' => @func_get_arg(0)); 
    1164      
     1164 
    11651165    $task = $p['_task'] ? $p['_task'] : ($p['task'] ? $p['task'] : $this->task); 
    11661166    $p['_task'] = $task; 
Note: See TracChangeset for help on using the changeset viewer.