Changeset 2eb7943 in github


Ignore:
Timestamp:
Apr 23, 2010 7:25:37 AM (3 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
a03c9809
Parents:
6319670
Message:
  • code cleanup (mostly identation fixes)
Location:
program/include
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • program/include/bugs.inc

    r4a941f7 r2eb7943  
    66 |                                                                       | 
    77 | This file is part of the RoudCube Webmail client                      | 
    8  | Copyright (C) 2005-2009, RoudCube Dev - Switzerland                   | 
     8 | Copyright (C) 2005-2010, RoudCube Dev - Switzerland                   | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
     
    4141 */ 
    4242function raise_error($arg=array(), $log=false, $terminate=false) 
    43   { 
    44   global $__page_content, $CONFIG, $OUTPUT, $ERROR_CODE, $ERROR_MESSAGE; 
     43{ 
     44    global $__page_content, $CONFIG, $OUTPUT, $ERROR_CODE, $ERROR_MESSAGE; 
    4545   
    46   // report bug (if not incompatible browser) 
    47   if ($log && $arg['type'] && $arg['message']) 
    48     log_bug($arg); 
     46    // report bug (if not incompatible browser) 
     47    if ($log && $arg['type'] && $arg['message']) 
     48        log_bug($arg); 
    4949 
    50   // display error page and terminate script 
    51   if ($terminate) 
    52     { 
    53     $ERROR_CODE = $arg['code']; 
    54     $ERROR_MESSAGE = $arg['message']; 
    55     include("program/steps/error.inc"); 
    56     exit; 
     50    // display error page and terminate script 
     51    if ($terminate) { 
     52        $ERROR_CODE = $arg['code']; 
     53        $ERROR_MESSAGE = $arg['message']; 
     54        include("program/steps/error.inc"); 
     55        exit; 
    5756    } 
    58   } 
     57} 
    5958 
    6059 
     
    6766function log_bug($arg_arr) 
    6867{ 
    69   global $CONFIG; 
    70   $program = strtoupper($arg_arr['type']); 
     68    global $CONFIG; 
     69    $program = strtoupper($arg_arr['type']); 
    7170 
    72   // write error to local log file 
    73   if ($CONFIG['debug_level'] & 1) 
    74   { 
    75     $post_query = ($_SERVER['REQUEST_METHOD'] == 'POST' ? '?_task='.urlencode($_POST['_task']).'&_action='.urlencode($_POST['_action']) : ''); 
    76     $log_entry = sprintf("%s Error: %s%s (%s %s)", 
    77       $program, 
    78       $arg_arr['message'], 
    79       $arg_arr['file'] ? sprintf(' in %s on line %d', $arg_arr['file'], $arg_arr['line']) : '', 
    80       $_SERVER['REQUEST_METHOD'], 
    81       $_SERVER['REQUEST_URI'] . $post_query); 
     71    // write error to local log file 
     72    if ($CONFIG['debug_level'] & 1) { 
     73        $post_query = ($_SERVER['REQUEST_METHOD'] == 'POST' ? '?_task='.urlencode($_POST['_task']).'&_action='.urlencode($_POST['_action']) : ''); 
     74        $log_entry = sprintf("%s Error: %s%s (%s %s)", 
     75            $program, 
     76            $arg_arr['message'], 
     77            $arg_arr['file'] ? sprintf(' in %s on line %d', $arg_arr['file'], $arg_arr['line']) : '', 
     78            $_SERVER['REQUEST_METHOD'], 
     79            $_SERVER['REQUEST_URI'] . $post_query); 
    8280     
    83     if (!write_log('errors', $log_entry)) 
    84     { 
    85       // send error to PHPs error handler if write_log didn't succeed 
    86       trigger_error($arg_arr['message']); 
     81        if (!write_log('errors', $log_entry)) { 
     82            // send error to PHPs error handler if write_log didn't succeed 
     83            trigger_error($arg_arr['message']); 
     84        } 
    8785    } 
    88   } 
    8986 
    90   // resport the bug to the global bug reporting system 
    91   if ($CONFIG['debug_level'] & 2) 
    92   { 
    93     // TODO: Send error via HTTP 
    94   } 
     87    // resport the bug to the global bug reporting system 
     88    if ($CONFIG['debug_level'] & 2) { 
     89        // TODO: Send error via HTTP 
     90    } 
    9591 
    96   // show error if debug_mode is on 
    97   if ($CONFIG['debug_level'] & 4) 
    98   { 
    99     print "<b>$program Error"; 
     92    // show error if debug_mode is on 
     93    if ($CONFIG['debug_level'] & 4) { 
     94        print "<b>$program Error"; 
    10095 
    101     if (!empty($arg_arr['file']) && !empty($arg_arr['line'])) 
    102       print " in $arg_arr[file] ($arg_arr[line])"; 
     96        if (!empty($arg_arr['file']) && !empty($arg_arr['line'])) 
     97            print " in $arg_arr[file] ($arg_arr[line])"; 
    10398 
    104     print ":</b>&nbsp;"; 
    105     print nl2br($arg_arr['message']); 
    106     print '<br />'; 
    107     flush(); 
    108   } 
     99        print ':</b>&nbsp;'; 
     100        print nl2br($arg_arr['message']); 
     101        print '<br />'; 
     102        flush(); 
     103    } 
    109104} 
    110105 
  • program/include/iniset.php

    rcd96fd6 r2eb7943  
    4343 
    4444if (!defined('INSTALL_PATH')) { 
    45   define('INSTALL_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/'); 
     45    define('INSTALL_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/'); 
    4646} 
    4747 
     
    5050// make sure path_separator is defined 
    5151if (!defined('PATH_SEPARATOR')) { 
    52   define('PATH_SEPARATOR', (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') ? ';' : ':'); 
     52    define('PATH_SEPARATOR', (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') ? ';' : ':'); 
    5353} 
    5454 
     
    6363 
    6464if (set_include_path($include_path) === false) { 
    65   die('Fatal error: ini_set/set_include_path does not work.'); 
     65    die('Fatal error: ini_set/set_include_path does not work.'); 
    6666} 
    6767 
     
    7474// set internal encoding for mbstring extension 
    7575if(extension_loaded('mbstring')) 
    76   mb_internal_encoding(RCMAIL_CHARSET); 
     76    mb_internal_encoding(RCMAIL_CHARSET); 
    7777               
    7878 
     
    8585function rcube_autoload($classname) 
    8686{ 
    87   $filename = preg_replace( 
    88       array( 
    89         '/MDB2_(.+)/', 
    90         '/Mail_(.+)/', 
    91         '/Net_(.+)/', 
    92         '/^html_.+/', 
    93         '/^utf8$/', 
    94         '/html2text/' 
    95       ), 
    96       array( 
    97         'MDB2/\\1', 
    98         'Mail/\\1', 
    99         'Net/\\1', 
    100         'html', 
    101         'utf8.class', 
    102         'lib/html2text'  // see #1485505 
    103       ), 
    104       $classname 
    105   ); 
    106   include $filename. '.php'; 
     87    $filename = preg_replace( 
     88        array( 
     89            '/MDB2_(.+)/', 
     90            '/Mail_(.+)/', 
     91            '/Net_(.+)/', 
     92            '/^html_.+/', 
     93            '/^utf8$/', 
     94            '/html2text/' 
     95        ), 
     96        array( 
     97            'MDB2/\\1', 
     98            'Mail/\\1', 
     99            'Net/\\1', 
     100            'html', 
     101            'utf8.class', 
     102            'lib/html2text'  // see #1485505 
     103        ), 
     104        $classname 
     105    ); 
     106    include $filename. '.php'; 
    107107} 
    108108 
     
    114114function rcube_pear_error($err) 
    115115{ 
    116   error_log(sprintf("%s (%s): %s", 
    117     $err->getMessage(), 
    118     $err->getCode(), 
    119     $err->getUserinfo()), 0); 
     116    error_log(sprintf("%s (%s): %s", 
     117        $err->getMessage(), 
     118        $err->getCode(), 
     119        $err->getUserinfo()), 0); 
    120120} 
     121 
     122// set PEAR error handling (will also load the PEAR main class) 
     123PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'rcube_pear_error'); 
    121124 
    122125// include global functions 
     
    124127require_once 'include/main.inc'; 
    125128require_once 'include/rcube_shared.inc'; 
    126  
    127  
    128 // set PEAR error handling (will also load the PEAR main class) 
    129 PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'rcube_pear_error'); 
  • program/include/rcube_addressbook.php

    r04adaac r2eb7943  
    118118    function set_page($page) 
    119119    { 
    120       $this->list_page = (int)$page; 
     120        $this->list_page = (int)$page; 
    121121    } 
    122122 
     
    129129    function set_pagesize($size) 
    130130    { 
    131       $this->page_size = (int)$size; 
     131        $this->page_size = (int)$size; 
    132132    } 
    133133 
     
    147147    function insert($save_data, $check=false) 
    148148    { 
    149       /* empty for read-only address books */ 
     149        /* empty for read-only address books */ 
    150150    } 
    151151 
     
    159159    function update($id, $save_cols) 
    160160    { 
    161       /* empty for read-only address books */ 
     161        /* empty for read-only address books */ 
    162162    } 
    163163 
     
    169169    function delete($ids) 
    170170    { 
    171       /* empty for read-only address books */ 
     171        /* empty for read-only address books */ 
    172172    } 
    173173 
     
    177177    function delete_all() 
    178178    { 
    179       /* empty for read-only address books */ 
     179        /* empty for read-only address books */ 
    180180    } 
    181181 
     
    188188    function create_group($name) 
    189189    { 
    190       /* empty for address books don't supporting groups */ 
    191       return false; 
     190        /* empty for address books don't supporting groups */ 
     191        return false; 
    192192    } 
    193193     
     
    200200    function delete_group($gid) 
    201201    { 
    202       /* empty for address books don't supporting groups */ 
    203       return false; 
     202        /* empty for address books don't supporting groups */ 
     203        return false; 
    204204    } 
    205205     
     
    213213    function rename_group($gid, $newname) 
    214214    { 
    215       /* empty for address books don't supporting groups */ 
    216       return false; 
     215        /* empty for address books don't supporting groups */ 
     216        return false; 
    217217    } 
    218218     
     
    226226    function add_to_group($group_id, $ids) 
    227227    { 
    228       /* empty for address books don't supporting groups */ 
    229       return 0; 
     228        /* empty for address books don't supporting groups */ 
     229        return 0; 
    230230    } 
    231231     
     
    239239    function remove_from_group($group_id, $ids) 
    240240    { 
    241       /* empty for address books don't supporting groups */ 
    242       return 0; 
     241        /* empty for address books don't supporting groups */ 
     242        return 0; 
    243243    } 
    244244} 
    245   
  • program/include/rcube_config.php

    rb545d3e r2eb7943  
    66 |                                                                       | 
    77 | This file is part of the RoundCube Webmail client                     | 
    8  | Copyright (C) 2008-2009, RoundCube Dev. - Switzerland                 | 
     8 | Copyright (C) 2008-2010, RoundCube Dev. - Switzerland                 | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
     
    2727class rcube_config 
    2828{ 
    29   private $prop = array(); 
    30   private $errors = array(); 
    31   private $userprefs = array(); 
    32  
    33  
    34   /** 
    35    * Object constructor 
    36    */ 
    37   public function __construct() 
    38   { 
    39     $this->load(); 
    40   } 
    41  
    42  
    43   /** 
    44    * Load config from local config file 
    45    * 
    46    * @todo Remove global $CONFIG 
    47    */ 
    48   private function load() 
    49   { 
    50     // start output buffering, we don't need any output yet,  
    51     // it'll be cleared after reading of config files, etc. 
    52     ob_start(); 
    53      
    54     // load main config file 
    55     if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/main.inc.php')) 
    56       $this->errors[] = 'main.inc.php was not found.'; 
    57  
    58     // load database config 
    59     if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/db.inc.php')) 
    60       $this->errors[] = 'db.inc.php was not found.'; 
    61      
    62     // load host-specific configuration 
    63     $this->load_host_config(); 
    64  
    65     // set skin (with fallback to old 'skin_path' property) 
    66     if (empty($this->prop['skin']) && !empty($this->prop['skin_path'])) 
    67       $this->prop['skin'] = str_replace('skins/', '', unslashify($this->prop['skin_path'])); 
    68     else if (empty($this->prop['skin'])) 
    69       $this->prop['skin'] = 'default'; 
    70  
    71     // fix paths 
    72     $this->prop['log_dir'] = $this->prop['log_dir'] ? realpath(unslashify($this->prop['log_dir'])) : INSTALL_PATH . 'logs'; 
    73     $this->prop['temp_dir'] = $this->prop['temp_dir'] ? realpath(unslashify($this->prop['temp_dir'])) : INSTALL_PATH . 'temp'; 
    74      
    75     // fix default imap folders encoding 
    76     foreach (array('drafts_mbox', 'junk_mbox', 'sent_mbox', 'trash_mbox') as $folder) 
    77       $this->prop[$folder] = rcube_charset_convert($this->prop[$folder], RCMAIL_CHARSET, 'UTF7-IMAP'); 
    78  
    79     if (!empty($this->prop['default_imap_folders'])) 
    80       foreach ($this->prop['default_imap_folders'] as $n => $folder) 
    81         $this->prop['default_imap_folders'][$n] = rcube_charset_convert($folder, RCMAIL_CHARSET, 'UTF7-IMAP'); 
    82  
    83     // set PHP error logging according to config 
    84     if ($this->prop['debug_level'] & 1) { 
    85       ini_set('log_errors', 1); 
    86  
    87       if ($this->prop['log_driver'] == 'syslog') { 
    88         ini_set('error_log', 'syslog'); 
    89       } else { 
    90         ini_set('error_log', $this->prop['log_dir'].'/errors'); 
    91       } 
    92     } 
    93     if ($this->prop['debug_level'] & 4) { 
    94       ini_set('display_errors', 1); 
    95     } 
    96     else { 
    97       ini_set('display_errors', 0); 
    98     } 
    99      
    100     // clear output buffer 
    101     ob_end_clean(); 
    102  
    103     // export config data 
    104     $GLOBALS['CONFIG'] = &$this->prop; 
    105   } 
     29    private $prop = array(); 
     30    private $errors = array(); 
     31    private $userprefs = array(); 
     32 
     33 
     34    /** 
     35     * Object constructor 
     36     */ 
     37    public function __construct() 
     38    { 
     39        $this->load(); 
     40    } 
     41 
     42 
     43    /** 
     44     * Load config from local config file 
     45     * 
     46     * @todo Remove global $CONFIG 
     47     */ 
     48    private function load() 
     49    { 
     50        // start output buffering, we don't need any output yet,  
     51        // it'll be cleared after reading of config files, etc. 
     52        ob_start(); 
     53     
     54        // load main config file 
     55        if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/main.inc.php')) 
     56            $this->errors[] = 'main.inc.php was not found.'; 
     57 
     58        // load database config 
     59        if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/db.inc.php')) 
     60            $this->errors[] = 'db.inc.php was not found.'; 
     61     
     62        // load host-specific configuration 
     63        $this->load_host_config(); 
     64 
     65        // set skin (with fallback to old 'skin_path' property) 
     66        if (empty($this->prop['skin']) && !empty($this->prop['skin_path'])) 
     67            $this->prop['skin'] = str_replace('skins/', '', unslashify($this->prop['skin_path'])); 
     68        else if (empty($this->prop['skin'])) 
     69            $this->prop['skin'] = 'default'; 
     70 
     71        // fix paths 
     72        $this->prop['log_dir'] = $this->prop['log_dir'] ? realpath(unslashify($this->prop['log_dir'])) : INSTALL_PATH . 'logs'; 
     73        $this->prop['temp_dir'] = $this->prop['temp_dir'] ? realpath(unslashify($this->prop['temp_dir'])) : INSTALL_PATH . 'temp'; 
     74     
     75        // fix default imap folders encoding 
     76        foreach (array('drafts_mbox', 'junk_mbox', 'sent_mbox', 'trash_mbox') as $folder) 
     77            $this->prop[$folder] = rcube_charset_convert($this->prop[$folder], RCMAIL_CHARSET, 'UTF7-IMAP'); 
     78 
     79        if (!empty($this->prop['default_imap_folders'])) 
     80            foreach ($this->prop['default_imap_folders'] as $n => $folder) 
     81                $this->prop['default_imap_folders'][$n] = rcube_charset_convert($folder, RCMAIL_CHARSET, 'UTF7-IMAP'); 
     82 
     83        // set PHP error logging according to config 
     84        if ($this->prop['debug_level'] & 1) { 
     85            ini_set('log_errors', 1); 
     86 
     87            if ($this->prop['log_driver'] == 'syslog') { 
     88                ini_set('error_log', 'syslog'); 
     89            } 
     90            else { 
     91                ini_set('error_log', $this->prop['log_dir'].'/errors'); 
     92            } 
     93        } 
     94        if ($this->prop['debug_level'] & 4) { 
     95            ini_set('display_errors', 1); 
     96        } 
     97        else { 
     98            ini_set('display_errors', 0); 
     99        } 
     100 
     101        // clear output buffer 
     102        ob_end_clean(); 
     103 
     104        // export config data 
     105        $GLOBALS['CONFIG'] = &$this->prop; 
     106    } 
     107 
     108    /** 
     109     * Load a host-specific config file if configured 
     110     * This will merge the host specific configuration with the given one 
     111     */ 
     112    private function load_host_config() 
     113    { 
     114        $fname = null; 
     115 
     116        if (is_array($this->prop['include_host_config'])) { 
     117            $fname = $this->prop['include_host_config'][$_SERVER['HTTP_HOST']]; 
     118        } 
     119        else if (!empty($this->prop['include_host_config'])) { 
     120            $fname = preg_replace('/[^a-z0-9\.\-_]/i', '', $_SERVER['HTTP_HOST']) . '.inc.php'; 
     121        } 
     122 
     123        if ($fname) { 
     124            $this->load_from_file(RCMAIL_CONFIG_DIR . '/' . $fname); 
     125        } 
     126    } 
     127 
     128 
     129    /** 
     130     * Read configuration from a file 
     131     * and merge with the already stored config values 
     132     * 
     133     * @param string Full path to the config file to be loaded 
     134     * @return booelan True on success, false on failure 
     135     */ 
     136    public function load_from_file($fpath) 
     137    { 
     138        if (is_file($fpath) && is_readable($fpath)) { 
     139            include($fpath); 
     140            if (is_array($rcmail_config)) { 
     141                $this->prop = array_merge($this->prop, $rcmail_config, $this->userprefs); 
     142                return true; 
     143            } 
     144        } 
     145 
     146        return false; 
     147    } 
     148 
     149 
     150    /** 
     151     * Getter for a specific config parameter 
     152     * 
     153     * @param  string Parameter name 
     154     * @param  mixed  Default value if not set 
     155     * @return mixed  The requested config value 
     156     */ 
     157    public function get($name, $def = null) 
     158    { 
     159        return isset($this->prop[$name]) ? $this->prop[$name] : $def; 
     160    } 
     161 
     162 
     163    /** 
     164     * Setter for a config parameter 
     165     * 
     166     * @param string Parameter name 
     167     * @param mixed  Parameter value 
     168     */ 
     169    public function set($name, $value) 
     170    { 
     171        $this->prop[$name] = $value; 
     172    } 
     173 
     174 
     175    /** 
     176     * Override config options with the given values (eg. user prefs) 
     177     * 
     178     * @param array Hash array with config props to merge over 
     179     */ 
     180    public function merge($prefs) 
     181    { 
     182        $this->prop = array_merge($this->prop, $prefs, $this->userprefs); 
     183    } 
     184 
     185 
     186    /** 
     187     * Merge the given prefs over the current config 
     188     * and make sure that they survive further merging. 
     189     * 
     190     * @param array  Hash array with user prefs 
     191     */ 
     192    public function set_user_prefs($prefs) 
     193    { 
     194        $this->userprefs = $prefs; 
     195        $this->prop = array_merge($this->prop, $prefs); 
     196    } 
     197 
     198 
     199    /** 
     200     * Getter for all config options 
     201     * 
     202     * @return array  Hash array containg all config properties 
     203     */ 
     204    public function all() 
     205    { 
     206        return $this->prop; 
     207    } 
     208 
     209 
     210    /** 
     211     * Return requested DES crypto key. 
     212     * 
     213     * @param string Crypto key name 
     214     * @return string Crypto key 
     215     */ 
     216    public function get_crypto_key($key) 
     217    { 
     218        // Bomb out if the requested key does not exist 
     219        if (!array_key_exists($key, $this->prop)) { 
     220            raise_error(array( 
     221                'code' => 500, 'type' => 'php', 
     222                'file' => __FILE__, 'line' => __LINE__, 
     223                'message' => "Request for unconfigured crypto key \"$key\"" 
     224            ), true, true); 
     225        } 
     226 
     227        $key = $this->prop[$key]; 
     228 
     229        // Bomb out if the configured key is not exactly 24 bytes long 
     230        if (strlen($key) != 24) { 
     231            raise_error(array( 
     232                'code' => 500, 'type' => 'php', 
     233                    'file' => __FILE__, 'line' => __LINE__, 
     234                'message' => "Configured crypto key '$key' is not exactly 24 bytes long" 
     235            ), true, true); 
     236        } 
     237 
     238        return $key; 
     239    } 
     240 
     241 
     242    /** 
     243     * Try to autodetect operating system and find the correct line endings 
     244     * 
     245     * @return string The appropriate mail header delimiter 
     246     */ 
     247    public function header_delimiter() 
     248    { 
     249        // use the configured delimiter for headers 
     250        if (!empty($this->prop['mail_header_delimiter'])) 
     251            return $this->prop['mail_header_delimiter']; 
     252 
     253        $php_os = strtolower(substr(PHP_OS, 0, 3)); 
     254 
     255        if ($php_os == 'win') 
     256            return "\r\n"; 
     257 
     258        if ($php_os == 'mac') 
     259            return "\r\n"; 
     260 
     261        return "\n"; 
     262    } 
     263 
     264 
     265    /** 
     266     * Return the mail domain configured for the given host 
     267     * 
     268     * @param string IMAP host 
     269     * @return string Resolved SMTP host 
     270     */ 
     271    public function mail_domain($host) 
     272    { 
     273        $domain = $host; 
     274 
     275        if (is_array($this->prop['mail_domain'])) { 
     276            if (isset($this->prop['mail_domain'][$host])) 
     277                $domain = $this->prop['mail_domain'][$host]; 
     278        } 
     279        else if (!empty($this->prop['mail_domain'])) 
     280            $domain = $this->prop['mail_domain']; 
     281     
     282        return $domain; 
     283    } 
    106284   
    107285   
    108   /** 
    109    * Load a host-specific config file if configured 
    110    * This will merge the host specific configuration with the given one 
    111    */ 
    112   private function load_host_config() 
    113   { 
    114     $fname = null; 
    115  
    116     if (is_array($this->prop['include_host_config'])) { 
    117       $fname = $this->prop['include_host_config'][$_SERVER['HTTP_HOST']]; 
    118     } 
    119     else if (!empty($this->prop['include_host_config'])) { 
    120       $fname = preg_replace('/[^a-z0-9\.\-_]/i', '', $_SERVER['HTTP_HOST']) . '.inc.php'; 
    121     } 
    122  
    123     if ($fname) { 
    124       $this->load_from_file(RCMAIL_CONFIG_DIR . '/' . $fname); 
    125     } 
    126   } 
    127    
    128    
    129   /** 
    130    * Read configuration from a file 
    131    * and merge with the already stored config values 
    132    * 
    133    * @param string Full path to the config file to be loaded 
    134    * @return booelan True on success, false on failure 
    135    */ 
    136   public function load_from_file($fpath) 
    137   { 
    138     if (is_file($fpath) && is_readable($fpath)) { 
    139       include($fpath); 
    140       if (is_array($rcmail_config)) { 
    141         $this->prop = array_merge($this->prop, $rcmail_config, $this->userprefs); 
    142         return true; 
    143       } 
    144     } 
    145      
    146     return false; 
    147   } 
    148    
    149    
    150   /** 
    151    * Getter for a specific config parameter 
    152    * 
    153    * @param  string Parameter name 
    154    * @param  mixed  Default value if not set 
    155    * @return mixed  The requested config value 
    156    */ 
    157   public function get($name, $def = null) 
    158   { 
    159     return isset($this->prop[$name]) ? $this->prop[$name] : $def; 
    160   } 
    161    
    162    
    163   /** 
    164    * Setter for a config parameter 
    165    * 
    166    * @param string Parameter name 
    167    * @param mixed  Parameter value 
    168    */ 
    169   public function set($name, $value) 
    170   { 
    171     $this->prop[$name] = $value; 
    172   } 
    173    
    174    
    175   /** 
    176    * Override config options with the given values (eg. user prefs) 
    177    * 
    178    * @param array Hash array with config props to merge over 
    179    */ 
    180   public function merge($prefs) 
    181   { 
    182     $this->prop = array_merge($this->prop, $prefs, $this->userprefs); 
    183   } 
    184    
    185    
    186   /** 
    187    * Merge the given prefs over the current config 
    188    * and make sure that they survive further merging. 
    189    * 
    190    * @param array  Hash array with user prefs 
    191    */ 
    192   public function set_user_prefs($prefs) 
    193   { 
    194     $this->userprefs = $prefs; 
    195     $this->prop = array_merge($this->prop, $prefs); 
    196   } 
    197  
    198    
    199   /** 
    200    * Getter for all config options 
    201    * 
    202    * @return array  Hash array containg all config properties 
    203    */ 
    204   public function all() 
    205   { 
    206     return $this->prop; 
    207   } 
    208  
    209  
    210   /** 
    211    * Return requested DES crypto key. 
    212    * 
    213    * @param string Crypto key name 
    214    * @return string Crypto key 
    215    */ 
    216   public function get_crypto_key($key) 
    217   { 
    218     // Bomb out if the requested key does not exist 
    219     if (!array_key_exists($key, $this->prop)) 
    220     { 
    221       raise_error(array( 
    222         'code' => 500, 'type' => 'php', 
    223         'file' => __FILE__, 'line' => __LINE__, 
    224         'message' => "Request for unconfigured crypto key \"$key\"" 
    225       ), true, true); 
    226     } 
    227    
    228     $key = $this->prop[$key]; 
    229    
    230     // Bomb out if the configured key is not exactly 24 bytes long 
    231     if (strlen($key) != 24) 
    232     { 
    233       raise_error(array( 
    234         'code' => 500, 'type' => 'php', 
    235         'file' => __FILE__, 'line' => __LINE__, 
    236         'message' => "Configured crypto key \"$key\" is not exactly 24 bytes long" 
    237       ), true, true); 
    238     } 
    239  
    240     return $key; 
    241   } 
    242  
    243  
    244   /** 
    245    * Try to autodetect operating system and find the correct line endings 
    246    * 
    247    * @return string The appropriate mail header delimiter 
    248    */ 
    249   public function header_delimiter() 
    250   { 
    251     // use the configured delimiter for headers 
    252     if (!empty($this->prop['mail_header_delimiter'])) 
    253       return $this->prop['mail_header_delimiter']; 
    254     else if (strtolower(substr(PHP_OS, 0, 3)) == 'win') 
    255       return "\r\n"; 
    256     else if (strtolower(substr(PHP_OS, 0, 3)) == 'mac') 
    257       return "\r\n"; 
    258     else 
    259       return "\n"; 
    260   } 
    261    
    262  
    263   /** 
    264    * Return the mail domain configured for the given host 
    265    * 
    266    * @param string IMAP host 
    267    * @return string Resolved SMTP host 
    268    */ 
    269   public function mail_domain($host) 
    270   { 
    271     $domain = $host; 
    272      
    273     if (is_array($this->prop['mail_domain'])) { 
    274       if (isset($this->prop['mail_domain'][$host])) 
    275         $domain = $this->prop['mail_domain'][$host]; 
    276     } 
    277     else if (!empty($this->prop['mail_domain'])) 
    278       $domain = $this->prop['mail_domain']; 
    279      
    280     return $domain; 
    281   } 
    282    
    283    
    284   /** 
    285    * Getter for error state 
    286    * 
    287    * @return mixed Error message on error, False if no errors 
    288    */ 
    289   public function get_error() 
    290   { 
    291     return empty($this->errors) ? false : join("\n", $this->errors); 
    292   } 
    293  
     286    /** 
     287     * Getter for error state 
     288     * 
     289     * @return mixed Error message on error, False if no errors 
     290     */ 
     291    public function get_error() 
     292    { 
     293        return empty($this->errors) ? false : join("\n", $this->errors); 
     294    } 
    294295 
    295296} 
    296  
  • program/include/rcube_html_page.php

    r74be739 r2eb7943  
    5757         
    5858        if (!preg_match('|^https?://|i', $file) && $file[0] != '/') 
    59           $file = $this->scripts_path . $file . (($fs = @filemtime($this->scripts_path . $file)) ? '?s='.$fs : ''); 
     59            $file = $this->scripts_path . $file . (($fs = @filemtime($this->scripts_path . $file)) ? '?s='.$fs : ''); 
    6060 
    6161        if (in_array($file, $sa_files)) { 
     
    131131    { 
    132132        $this->script_files = array(); 
    133         $this->scripts = array(); 
    134         $this->title = ''; 
    135         $this->header = ''; 
    136         $this->footer = ''; 
    137         $this->body = ''; 
     133        $this->scripts      = array(); 
     134        $this->title        = ''; 
     135        $this->header       = ''; 
     136        $this->footer       = ''; 
     137        $this->body         = ''; 
    138138    } 
    139139 
     
    249249        $__page_header = $__page_footer = ''; 
    250250 
    251         $this->base_path = $base_path; 
     251            $this->base_path = $base_path; 
    252252        // correct absolute paths in images and other tags 
    253         // add timestamp to .js and .css filename 
     253            // add timestamp to .js and .css filename 
    254254        $output = preg_replace_callback('!(src|href|background)=(["\']?)([a-z0-9/_.-]+)(["\'\s>])!i', 
    255255            array($this, 'file_callback'), $output); 
     
    257257 
    258258        if ($this->charset != RCMAIL_CHARSET) 
    259             echo rcube_charset_convert($output, RCMAIL_CHARSET, $this->charset); 
    260         else 
    261             echo $output; 
     259                echo rcube_charset_convert($output, RCMAIL_CHARSET, $this->charset); 
     260            else 
     261                echo $output; 
    262262    } 
    263263     
     
    267267    private function file_callback($matches) 
    268268    { 
    269         $file = $matches[3]; 
     269            $file = $matches[3]; 
    270270 
    271271        // correct absolute paths 
    272         if ($file[0] == '/') 
    273             $file = $this->base_path . $file; 
     272            if ($file[0] == '/') 
     273                $file = $this->base_path . $file; 
    274274 
    275275        // add file modification timestamp 
    276         if (preg_match('/\.(js|css)$/', $file)) 
     276            if (preg_match('/\.(js|css)$/', $file)) 
    277277            $file .= '?s=' . @filemtime($file); 
    278278 
    279         return sprintf("%s=%s%s%s", $matches[1], $matches[2], $file, $matches[4]); 
     279            return sprintf("%s=%s%s%s", $matches[1], $matches[2], $file, $matches[4]); 
    280280    } 
    281281} 
  • program/include/rcube_json_output.php

    r1d786c8 r2eb7943  
    66 |                                                                       | 
    77 | This file is part of the RoundCube Webmail client                     | 
    8  | Copyright (C) 2008-2009, RoundCube Dev. - Switzerland                 | 
     8 | Copyright (C) 2008-2010, RoundCube Dev. - Switzerland                 | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
     
    4848        $this->config = rcmail::get_instance()->config; 
    4949    } 
    50      
    51      
     50 
     51 
    5252    /** 
    5353     * Set environment variable 
     
    6060        $this->env[$name] = $value; 
    6161    } 
    62      
     62 
     63 
    6364    /** 
    6465     * Issue command to set page title 
     
    7172        $this->command('set_pagetitle', empty($name) ? $title : $name.' :: '.$title); 
    7273    } 
     74 
    7375 
    7476    /** 
     
    104106    } 
    105107 
     108 
    106109    /** 
    107110     * Register a list of template object handlers 
     
    114117        // ignore 
    115118    } 
    116      
    117      
     119 
     120 
    118121    /** 
    119122     * Call a client method 
     
    146149        } 
    147150    } 
    148      
     151 
    149152 
    150153    /** 
     
    168171        } 
    169172    } 
    170      
     173 
     174 
    171175    /** 
    172176     * Delete all stored env variables and commands 
     
    178182        $this->commands = array(); 
    179183    } 
    180      
     184 
     185 
    181186    /** 
    182187     * Redirect to a certain url 
     
    228233         
    229234        if (!empty($this->env)) 
    230           $response['env'] = $this->env; 
     235            $response['env'] = $this->env; 
    231236           
    232237        if (!empty($this->texts)) 
    233           $response['texts'] = $this->texts; 
     238            $response['texts'] = $this->texts; 
    234239 
    235240        // send function calls 
     
    237242         
    238243        if (!empty($this->callbacks)) 
    239           $response['callbacks'] = $this->callbacks; 
     244            $response['callbacks'] = $this->callbacks; 
    240245 
    241246        echo json_serialize($response); 
    242247    } 
    243      
    244      
     248 
     249 
    245250    /** 
    246251     * Return executable javascript code for all registered commands 
     
    268273    } 
    269274} 
    270  
    271  
  • program/include/rcube_result_set.php

    r638fb8a r2eb7943  
    66 |                                                                       | 
    77 | This file is part of the RoundCube Webmail client                     | 
    8  | Copyright (C) 2006-2009, RoundCube Dev. - Switzerland                 | 
     8 | Copyright (C) 2006-2010, RoundCube Dev. - Switzerland                 | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
     
    2929class rcube_result_set 
    3030{ 
    31   var $count = 0; 
    32   var $first = 0; 
    33   var $current = 0; 
    34   var $records = array(); 
     31    var $count = 0; 
     32    var $first = 0; 
     33    var $current = 0; 
     34    var $records = array(); 
     35 
     36 
     37    function __construct($c=0, $f=0) 
     38    { 
     39        $this->count = (int)$c; 
     40        $this->first = (int)$f; 
     41    } 
     42 
     43    function add($rec) 
     44    { 
     45        $this->records[] = $rec; 
     46    } 
    3547   
    36   function __construct($c=0, $f=0) 
    37   { 
    38     $this->count = (int)$c; 
    39     $this->first = (int)$f; 
    40   } 
     48    function iterate() 
     49    { 
     50        return $this->records[$this->current++]; 
     51    } 
    4152   
    42   function add($rec) 
    43   { 
    44     $this->records[] = $rec; 
    45   } 
     53    function first() 
     54    { 
     55        $this->current = 0; 
     56        return $this->records[$this->current++]; 
     57    } 
    4658   
    47   function iterate() 
    48   { 
    49     return $this->records[$this->current++]; 
    50   } 
     59    // alias for iterate() 
     60    function next() 
     61    { 
     62        return $this->iterate(); 
     63    } 
    5164   
    52   function first() 
    53   { 
    54     $this->current = 0; 
    55     return $this->records[$this->current++]; 
    56   } 
    57    
    58   // alias 
    59   function next() 
    60   { 
    61     return $this->iterate(); 
    62   } 
    63    
    64   function seek($i) 
    65   { 
    66     $this->current = $i; 
    67   } 
     65    function seek($i) 
     66    { 
     67        $this->current = $i; 
     68    } 
    6869   
    6970} 
  • program/include/rcube_sqlite.inc

    r5349b78 r2eb7943  
    66 |                                                                       | 
    77 | This file is part of the RoundCube Webmail client                     | 
    8  | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 | 
     8 | Copyright (C) 2005-2010, RoundCube Dev. - Switzerland                 | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
     
    2929 
    3030function rcube_sqlite_from_unixtime($timestamp) 
    31   { 
    32   $timestamp = trim($timestamp); 
    33   if (!preg_match("/^[0-9]+$/is", $timestamp)) 
    34     $ret = strtotime($timestamp); 
    35   else 
    36     $ret = $timestamp; 
     31{ 
     32    $timestamp = trim($timestamp); 
     33    if (!preg_match('/^[0-9]+$/is', $timestamp)) 
     34        $ret = strtotime($timestamp); 
     35    else 
     36        $ret = $timestamp; 
    3737     
    38   $ret = date("Y-m-d H:i:s", $ret); 
    39   rcube_sqlite_debug("FROM_UNIXTIME ($timestamp) = $ret"); 
    40   return $ret; 
    41   } 
     38    $ret = date('Y-m-d H:i:s', $ret); 
     39    rcube_sqlite_debug("FROM_UNIXTIME ($timestamp) = $ret"); 
     40    return $ret; 
     41} 
    4242 
    4343 
    44 function rcube_sqlite_unix_timestamp($timestamp="") 
    45   { 
    46   $timestamp = trim($timestamp); 
    47   if (!$timestamp) 
    48     $ret = time(); 
    49   else if (!preg_match("/^[0-9]+$/is", $timestamp)) 
    50     $ret = strtotime($timestamp); 
    51   else 
    52     $ret = $timestamp; 
     44function rcube_sqlite_unix_timestamp($timestamp='') 
     45{ 
     46    $timestamp = trim($timestamp); 
     47    if (!$timestamp) 
     48        $ret = time(); 
     49    else if (!preg_match('/^[0-9]+$/is', $timestamp)) 
     50        $ret = strtotime($timestamp); 
     51    else 
     52        $ret = $timestamp; 
    5353 
    54   rcube_sqlite_debug("UNIX_TIMESTAMP ($timestamp) = $ret"); 
    55   return $ret; 
    56   } 
     54    rcube_sqlite_debug("UNIX_TIMESTAMP ($timestamp) = $ret"); 
     55    return $ret; 
     56} 
    5757 
    5858 
    5959function rcube_sqlite_now() 
    60   { 
    61   rcube_sqlite_debug("NOW() = ".date("Y-m-d H:i:s")); 
    62   return date("Y-m-d H:i:s"); 
    63   } 
     60{ 
     61    rcube_sqlite_debug("NOW() = ".date("Y-m-d H:i:s")); 
     62    return date("Y-m-d H:i:s"); 
     63} 
    6464 
    6565 
    6666function rcube_sqlite_md5($str) 
    67   { 
    68   return md5($str); 
    69   } 
     67{ 
     68    return md5($str); 
     69} 
    7070 
    7171 
    7272function rcube_sqlite_debug($str) 
    73   { 
    74   //console($str); 
    75   } 
     73{ 
     74    //console($str); 
     75} 
    7676   
    7777?> 
  • program/include/rcube_template.php

    rf3e1010 r2eb7943  
    66 |                                                                       | 
    77 | This file is part of the RoundCube Webmail client                     | 
    8  | Copyright (C) 2006-2009, RoundCube Dev. - Switzerland                 | 
     8 | Copyright (C) 2006-2010, RoundCube Dev. - Switzerland                 | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
     
    537537     
    538538    /** 
    539      * 
     539     * Inserts hidden field with CSRF-prevention-token into POST forms 
    540540     */ 
    541541    private function alter_form_tag($matches) 
     
    11251125        } 
    11261126        if ($attrib['type'] == 'search' && !$this->browser->khtml) { 
    1127           unset($attrib['type'], $attrib['results']); 
     1127            unset($attrib['type'], $attrib['results']); 
    11281128        } 
    11291129         
     
    11391139                'onsubmit' => JS_OBJECT_NAME . ".command('search');return false;", 
    11401140                'style' => "display:inline"), 
    1141               $out); 
     1141                $out); 
    11421142        } 
    11431143 
     
    12161216 
    12171217        if (!empty($_POST['_charset'])) 
    1218             $set = $_POST['_charset']; 
    1219         else if (!empty($attrib['selected'])) 
    1220             $set = $attrib['selected']; 
    1221         else 
    1222             $set = $this->get_charset(); 
    1223  
    1224         $set = strtoupper($set); 
    1225         if (!isset($charsets[$set])) 
    1226             $charsets[$set] = $set; 
     1218                $set = $_POST['_charset']; 
     1219            else if (!empty($attrib['selected'])) 
     1220                $set = $attrib['selected']; 
     1221            else 
     1222                $set = $this->get_charset(); 
     1223 
     1224            $set = strtoupper($set); 
     1225            if (!isset($charsets[$set])) 
     1226                $charsets[$set] = $set; 
    12271227 
    12281228        $select = new html_select($field_attrib); 
Note: See TracChangeset for help on using the changeset viewer.