Changeset 957 in subversion


Ignore:
Timestamp:
Jan 27, 2008 1:45:44 PM (5 years ago)
Author:
tomekp
Message:

first part of devel-vnext to trunk merging process
this broke the devel-vnext branch, we switched to error_reporting(E_ALL|E_STRICT)
more to come shortly

Location:
branches/devel-vnext
Files:
1 added
1 deleted
22 edited

Legend:

Unmodified
Added
Removed
  • branches/devel-vnext/CHANGELOG

    r916 r957  
    22--------------------------- 
    33 
    4 2007/11/12 (tomekp) 
    5 - MFH: ar, ca, de_DE, en_GB, en_US, eu, fa, fr, ja, lt, ru, se, sk, sl localizations 
     42008/01/08 (tomekp) 
     5---------- 
     6- add he (Hebrew) localization (#1484713) 
     7 
     8 
     92008/01/08 (tomekp) 
     10---------- 
     11- update fr localization 
     12 
     13 
     142008/01/04 (tomekp) 
     15- purge kur_KU because it has no messages translation 
     16- bump copyright for all localization files 
     17 
     18 
     192007/12/31 (tomekp) 
     20---------- 
     21- update es localization 
     22 
     23 
     242007/12/28 (tomekp) 
     25---------- 
     26- update mk localization 
     27 
     28 
     292007/12/27 (tomekp) 
     30---------- 
     31- update se localization 
     32 
     33 
     342007/12/13 (robin) 
     35---------- 
     36- Add Received header on outgoing mail 
     37 
     38 
     392007/12/10 (estadtherr) 
     40---------- 
     41- Upgrade to TinyMCE 2.1.3 
     42- Allow inserting image attachments into HTML messages while composing (#1484557) 
     43 
     44 
     452007/12/10 (thomasb) 
     46---------- 
     47- Delegate user-stuff to new class rcube_user 
     48- Implement Message-Disposition-Notification (Receipts) 
     49 
     50 
     512007/12/05 (tomekp) 
     52---------- 
     53- update bg, uk localization 
     54 
     55 
     562007/12/04 (tomekp) 
     57---------- 
     58- update bg localization 
     59 
     60 
     612007/11/25 (thomasb) 
     62---------- 
     63- Applied UID fetch patch by Glen Ogilvie 
     64- Applied patch for correct Postgres instructions from ticket #1484674 
     65- Fix overriding of session vars when register_globals is on (#1484670) 
     66- Fix wrong Postgres setup instructions in INSTALL (#1484674) 
     67- Fix bug with case-sensitive folder names (#1484245) 
     68- Don't create default folders by default 
     69- Added Georgian localization by Zaza Zviadadze 
     70- Updated Russian localization 
     71- Fixed some potential security risks (audited by Andris) 
     72- Only show new messages if they match the current search (#1484176) 
     73 
     74 
     752007/11/20 (tomekp) 
     76---------- 
     77- add Korean (kr) localization 
     78 
     79 
     802007/11/14 (tomekp) 
     81---------- 
     82- update id_ID localization 
     83 
     84 
     852007/11/06 (thomasb) 
     86---------- 
     87- Switch to/from when searcing in Sent folder (#1484555) 
     88- Correctly read the References header (#1484646) 
     89- Unset old cookie in before sending a new value (#1484639) 
     90- Correctly decode attachments when downloading them (#1484645 and #1484642) 
     91 
    692 
    7932007/10/22 (tomekp) 
    8 - MFH: da, eo, gl, hu, ru localizations 
    9  
    10 2007/10/17 (tomekp) 
    11 - MFH: update ca, cz, es, it, pt_BR, pt_PT localizations 
    12  
    13 2007/10/05 
    14 - MFH: add Esperanto localization 
    15 - MFH: update German localization 
    16  
    17 2007/10/04 (tomekp) 
    18 ---------- 
    19 - MFH: all localizations 
     94---------- 
     95- update ru, eo localizations 
     96 
     97 
     982007/10/17 (thomasb) 
     99---------- 
     100- Make message listing less error prone 
     101 
     102 
     1032007/10/10 (thomasb) 
     104---------- 
     105- Suppress IE errors when clearing attachments form (#1484356) 
     106- Set preferences field in user table to NULL (#1484386) 
     107- Log error when login fails due to auto_create_user turned off 
     108- Update UPGRADING instructions 
     109 
     110 
     1112007/10/05 (tomekp) 
     112---------- 
     113- Add Esperanto localization 
     114 
     115 
     116+2007/10/04 (Stiwi) 
     117---------- 
     118- Updated German localization 
     119 
     120 
     1212007/10/04 (yllar) 
     122---------- 
     123- Added Malay localization 
     124- Updated Lithuanian localization 
     125 
    20126 
    211272007/09/27 (tomekp) 
    22128---------- 
     129- Update dutch localization (closes #1484588) 
     130 
     131 
     1322007/09/29 (thomasb) 
     133---------- 
     134- Filter linked/imported CSS files (closes #1484056) 
     135 
     136 
     1372007/09/27 (tomekp) 
     138---------- 
    23139- Update brazilian portuguese localization (#1484580) 
    24140 
     141 
     1422007/09/26 (thomasb) 
     143---------- 
     144- Improve message compose screen (closes #1484383) 
     145- Select next row after removing one from list (#1484387) 
     146 
     147 
    251482007/09/26 (tomekp) 
    26149---------- 
     150- Add polish labels for changes in r816. 
    27151- Update polish localization (#1484579) 
    28152- Update thai localization (#1484578) 
    29153 
     154 
     1552007/09/25 (robin) 
     156---------- 
     157- Enable drag-/dropping of folders to a new parent folder (#1457344) 
     158 
     159 
     1602007/09/24 (robin) 
     161---------- 
     162- Fix preview pane size for Safari & Konqueror (#1484187) 
     163 
     164 
     1652007/09/20 (robin) 
     166---------- 
     167- Make smtp HELO/EHLO hostname configurable (#1484067) 
     168 
     169 
     1702007/09/19 (thomasb) 
     171---------- 
     172- IPv6 Compatability (#1484322), Patch #1484373 
     173- Unlock interface when message sending fails (#1484570) 
     174- Eval PHP code in template includes (if configured) 
     175- Show message when folder is empty. Mo more static text in table (#1484395) 
     176- Only display unread count in page title when new messages arrived 
     177- Show mailbox name in page title 
     178 
     179 
     1802007/09/09 (thomasb) 
     181---------- 
     182- Fixed wrong delete button tooltip (#1483965) 
     183- Fixed charset encoding bug (#1484429) 
     184- Applied patch for LDAP version (#1484552) 
     185- Improved XHTML validation 
     186 
     187 
     1882007/09/05 (thomasb) 
     189---------- 
     190- Fix message list selection (#1484550) 
     191- Better fix lowercased usernames (#1484473) 
     192- Update pngbehavior Script as suggested in #1484490 
     193 
     194 
     1952007/08/29 (richs) 
     196---------- 
     197- Fixed moving/deleting messages when more than 1 is selected 
     198 
     199 
     2002007/08/15 (thomasb) 
     201---------- 
     202- Applied patch for LDAP contacts listing by Glen Ogilvie 
     203- Applied patch for more address fields in LDAP contacts (#1484402) 
     204- Close LDAP connections on script shutdown 
     205 
     206 
     2072007/08/13 (thomasb) 
     208---------- 
     209- Add alternative for getallheaders() (fix #1484508) 
     210- Revert changes for mbstring usage (fix #1484509) 
     211 
     212 
     2132007/08/10 (thomasb) 
     214---------- 
     215- Identify mailboxes case-sensitive 
     216- Sort mailbox list case-insensitive (closes #1484338) 
     217- Fix display of multipart messages from Apple Mail (closes #1484027) 
     218- Protect AJAX request from being fetched by a foreign site (XSS) 
     219- Make autocomplete for loginform configurable by the skin template 
     220- Fix compose function from address book (closes #1484426) 
     221- Added //IGNORE to iconv call (patch #1484420, closes #1484023) 
     222- Check if mbstring supports charset (#1484290 and #1484292) 
     223- Prefer iconv over mbstring (as suggested in #1484292) 
     224- Check filesize of template includes (#1484409) 
     225- Updated Simplified Chinese localization 
     226- Added Ukrainian translation 
     227 
     228 
     2292007/08/09 (richs) 
     230---------- 
     231- Fixed bug with buttons not dimming/enabling properly after switching folders 
     232- Fixed compose window becoming unresponsive after saving a draft (#1484487) 
     233- Re-enabled "Back" button in compose window now that bug #1484487 is fixed 
     234- Fixed unresponsive interface issue when downloading attachments (#1484496) 
     235- Lowered status message time from 5 to 3 seconds to improve responsiveness 
     236- Added note to INSTALL about .htaccess limiting upload_max_filesize 
     237- Raised .htaccess upload_max_filesize from 2M to 5M to differ from default php.ini 
     238- Increased "mailboxcontrols" mail.css width from 160 to 170px to fix non-english languages (#1484499) 
     239- Fixed empty-message sending with TinyMCE plain-text mode, or if it's not installed 
     240 
     241 
     2422007/07/03 (thomasb) 
     243---------- 
     244- Added Macedonian (Slavic FYROM) localization 
     245- Fix status message bug #1484464 with regard to #1484353 
     246- Fix address adding bug reported by David Koblas 
     247- Applied socket error patch by Thomas Mangin 
     248 
     249 
     2502007/06/28 (tomekp) 
     251---------- 
     252- fix typos in Polish localization (Janusz Zamecki) 
     253 
     254 
     2552007/06/27 (tomekp) 
     256---------- 
     257- Update Polish (Janusz Zamecki), Croatian (Svebor Prstacic) localization 
     258 
     259 
     2602007/06/12 (thomasb) 
     261---------- 
     262- Updated Turkish, Polish, Finnish/Suomi, Japanese, Hungarian, Greek, Euskara localization 
     263- Added Irish/Gaelic translation 
     264- Little correction in Swedish translation 
     265- Quote username for virtuser_query 
     266- Pass-by-reference workarround for PHP5 in sendmail.inc 
     267 
     268 
     2692007/06/04 (estadtherr) 
     270---------- 
     271- Fixed bug in HTML->Plain editor toggling 
     272 
     273 
     2742007/05/28 (thomasb) 
     275--------- 
     276- Fixed buggy imap_root settings (closes #1484379) 
     277- Prevent default events on subject links (#1484399) 
     278- Typo in rcube_smtp.inc 
     279 
     280 
     2812007/05/23 (estadtherr) 
     282---------- 
     283- Upgrade to TinyMCE v2.1.1.1 
     284 
     285 
    302862007/05/18 (thomasb) 
    31287---------- 
     288- Enable drag-&-dropping of folders to a new parent and allow to create subfolders (#1457344) 
     289- Suppress IE errors when clearing attachments form (#1484356) 
     290- Set preferences field in user table to NULL (#1484386) 
     291- Log error when login fails due to auto_create_user turned off 
     292- Filter linked/imported CSS files (closes #1484056) 
     293- Improve message compose screen (closes #1484383) 
     294- Select next row after removing one from list (#1484387) 
     295- Make smtp HELO/EHLO hostname configurable (#1484067) 
     296- IPv6 Compatability (#1484322), Patch #1484373 
     297- Unlock interface when message sending fails (#1484570) 
     298- Eval PHP code in template includes (if configured) 
     299- Show message when folder is empty. Mo more static text in table (#1484395) 
     300- Only display unread count in page title when new messages arrived 
     301- Fixed wrong delete button tooltip (#1483965) 
     302- Fixed charset encoding bug (#1484429) 
     303- Applied patch for LDAP version (#1484552) 
     304- Improved XHTML validation 
     305- Fix message list selection (#1484550) 
     306- Better fix lowercased usernames (#1484473) 
     307- Update pngbehavior Script as suggested in #1484490 
     308- Fixed moving/deleting messages when more than 1 is selected 
     309- Applied patch for LDAP contacts listing by Glen Ogilvie 
     310- Applied patch for more address fields in LDAP contacts (#1484402) 
     311- Add alternative for getallheaders() (fix #1484508) 
     312- Identify mailboxes case-sensitive 
     313- Sort mailbox list case-insensitive (closes #1484338) 
     314- Fix display of multipart messages from Apple Mail (closes #1484027) 
     315- Protect AJAX request from being fetched by a foreign site (XSS) 
     316- Make autocomplete for loginform configurable by the skin template 
     317- Fix compose function from address book (closes #1484426) 
     318- Added //IGNORE to iconv call (patch #1484420, closes #1484023) 
     319- Check if mbstring supports charset (#1484290 and #1484292) 
     320- Prefer iconv over mbstring (as suggested in #1484292) 
     321- Check filesize of template includes (#1484409) 
     322- Fixed bug with buttons not dimming/enabling properly after switching folders 
     323- Fixed compose window becoming unresponsive after saving a draft (#1484487) 
     324- Re-enabled "Back" button in compose window now that bug #1484487 is fixed 
     325- Fixed unresponsive interface issue when downloading attachments (#1484496) 
     326- Lowered status message time from 5 to 3 seconds to improve responsiveness 
     327- Raised .htaccess upload_max_filesize from 2M to 5M to differ from default php.ini 
     328- Increased "mailboxcontrols" mail.css width from 160 to 170px to fix non-english languages (#1484499) 
     329- Fix status message bug #1484464 with regard to #1484353 
     330- Fix address adding bug reported by David Koblas 
     331- Applied socket error patch by Thomas Mangin 
     332- Pass-by-reference workarround for PHP5 in sendmail.inc 
     333- Fixed buggy imap_root settings (closes #1484379) 
     334- Prevent default events on subject links (#1484399) 
    32335- Use HTTP-POST requests for actions that change state 
    33336 
     337 
     338RELEASE 0.1.-RC1 
    34339 
    353402007/05/17 (thomasb) 
  • branches/devel-vnext/INSTALL

    r589 r957  
     1INTRODUCTION 
     2============ 
     3 
     4This file describes the basic steps to install RoundCube Webmail on your 
     5web server. For additional information, please also consult the project's 
     6wiki page at 
     7 
     8     http://trac.roundcube.net/wiki 
     9 
    110 
    211REQUIREMENTS 
    312============ 
    413 
    5 * The Apache Webserver 
     14* The Apache or Lighttpd Webserver 
    615* .htaccess support allowing overrides for DirectoryIndex 
    7 * PHP Version 4.3.1 or greater 
    8 * PCRE (perl compatible regular expression) installed with PHP 
     16* PHP Version 4.3.1 or greater including 
     17   - PCRE (perl compatible regular expression) 
     18   - libiconv (recommended) 
     19   - mbstring (optional) 
    920* php.ini options: 
    1021   - error_reporting E_ALL & ~E_NOTICE (or lower) 
    1122   - file_uploads on (for attachment upload features) 
    1223   - memory_limit (increase as suitable to support large attachments) 
     24* PHP compiled with Open SSL to connect to IMAPS and to use the spell checker 
    1325* A MySQL or PostgreSQL database engine or the SQLite extension for PHP 
    14 * A database with permission to create tables 
     26* One of the above databases with permission to create tables 
     27* An SMTP server or PHP configured for mail delivery 
    1528 
    1629 
     
    8194* PostgreSQL 
    8295------------ 
    83 To use RoundCube with PostgreSQL support you have to follow the next 
    84 simple steps, which have to be done with the postgres system user (or 
     96 
     97To use RoundCube with PostgreSQL support you have to follow these 
     98simple steps, which have to be done as the postgres system user (or 
    8599which ever is the database superuser): 
    86100 
    87 $ createuser roundcubemail 
    88 $ createdb -O roundcubemail roundcubemail 
     101$ createuser roundcube 
     102$ createdb -O roundcube roundcubemail 
    89103$ psql roundcubemail 
    90104 
    91105roundcubemail =# ALTER USER roundcube WITH PASSWORD 'the_new_password'; 
    92 roundcubemail =# \c - roundcubemail 
     106roundcubemail =# \c - roundcube 
    93107roundcubemail => \i SQL/postgres.initial.sql 
    94108 
    95 All this has been tested with PostgreSQL 8.0.x and 7.4.x. Older 
     109All this has been tested with PostgreSQL 8.x and 7.4.x. Older 
    96110versions don't have a -O option for the createdb, so if you are 
    97111using that version you'll have to change ownership of the DB later. 
     
    101115============= 
    102116 
    103 Change the files in config/* according your to environment and your needs. 
    104 Details about the config parameters can be found in the config files 
    105 or in the wiki: http://trac.roundcube.net/trac.cgi/wiki/Howto_Config 
     117First of all, rename the files config/*.inc.php.dist to config/*.inc.php. 
     118You can then change these files according to your environment and your needs. 
     119Details about the config parameters can be found in the config files. 
     120 
     121You can also modify the default .htaccess file. This is necessary to 
     122increase the allowed size of file attachments, for example: 
     123       php_value       upload_max_filesize     2M 
    106124 
    107125 
     
    112130please refer to the instructions in UPGRADING guide. 
    113131 
    114  
  • branches/devel-vnext/SQL/mssql.initial.sql

    r589 r957  
    5959        [created] [datetime] NOT NULL , 
    6060        [changed] [datetime] NULL , 
    61         [ip] [varchar] (15) COLLATE Latin1_General_CI_AI NOT NULL , 
     61        [ip] [varchar] (40) COLLATE Latin1_General_CI_AI NOT NULL , 
    6262        [vars] [text] COLLATE Latin1_General_CI_AI NOT NULL  
    6363) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] 
  • branches/devel-vnext/SQL/mysql.initial.sql

    r589 r957  
    7474  `created` datetime NOT NULL default '0000-00-00 00:00:00', 
    7575  `changed` datetime NOT NULL default '0000-00-00 00:00:00', 
    76   `ip` VARCHAR(15) NOT NULL default '', 
     76  `ip` VARCHAR(40) NOT NULL default '', 
    7777  `vars` text NOT NULL, 
    7878  PRIMARY KEY  (`sess_id`) 
     
    9393  `last_login` datetime NOT NULL default '0000-00-00 00:00:00', 
    9494  `language` varchar(5) NOT NULL default 'en', 
    95   `preferences` text NOT NULL default '', 
     95  `preferences` text, 
    9696  PRIMARY KEY  (`user_id`) 
    9797); 
  • branches/devel-vnext/SQL/mysql.update.sql

    r589 r957  
    11-- RoundCube Webmail update script for MySQL databases 
    22-- Updates from version 0.1-beta and 0.1-beta2 
     3 
     4TRUNCATE TABLE `messages`; 
    35 
    46ALTER TABLE `messages` 
     
    1113  ADD `html_signature` tinyint(1) default 0 NOT NULL; 
    1214 
     15ALTER TABLE `session` CHANGE `ip` `ip` VARCHAR(40); 
     16 
    1317-- Uncomment these lines if you're using MySQL 4.1 or higher 
    1418-- ALTER TABLE `users` 
  • branches/devel-vnext/SQL/mysql5.initial.sql

    r630 r957  
    1313 `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', 
    1414 `changed` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', 
    15  `ip` varchar(15) NOT NULL, 
     15 `ip` varchar(40) NOT NULL, 
    1616 `vars` text NOT NULL, 
    1717 PRIMARY KEY(`sess_id`) 
     
    2929 `last_login` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', 
    3030 `language` varchar(5) NOT NULL DEFAULT 'en', 
    31  `preferences` text NOT NULL DEFAULT '', 
     31 `preferences` text, 
    3232 PRIMARY KEY(`user_id`) 
    3333) TYPE=MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci; 
  • branches/devel-vnext/SQL/postgres.initial.sql

    r589 r957  
    3737    created timestamp with time zone DEFAULT now() NOT NULL, 
    3838    changed timestamp with time zone DEFAULT now() NOT NULL, 
    39     ip character varying(16) NOT NULL, 
     39    ip character varying(41) NOT NULL, 
    4040    vars text NOT NULL 
    4141); 
  • branches/devel-vnext/SQL/postgres.update.sql

    r589 r957  
    66ALTER TABLE "messages" ADD UNIQUE (user_id, cache_key, uid); 
    77 
    8 ALTER TABLE "identities" ADD html_signature integer DEFAULT 0 NOT NULL; 
    9  
     8ALTER TABLE "identities" ADD html_signature INTEGER; 
     9ALTER TABLE "identities" ALTER html_signature SET DEFAULT 0; 
     10UPDATE identities SET html_signature = 0; 
     11ALTER TABLE "identities" ALTER html_signature SET NOT NULL; 
  • branches/devel-vnext/SQL/sqlite.initial.sql

    r589 r957  
    9494  created datetime NOT NULL default '0000-00-00 00:00:00', 
    9595  changed datetime NOT NULL default '0000-00-00 00:00:00', 
    96   ip varchar(15) NOT NULL default '', 
     96  ip varchar(40) NOT NULL default '', 
    9797  vars text NOT NULL 
    9898); 
  • branches/devel-vnext/UPGRADING

    r589 r957  
    55of RoundCube Webmail. 
    66 
     7from version 0.1-rc 
     8---------------------------------------- 
     9* replace index.php 
     10* replace all files in folder /program/ 
     11* replace all files in folder /skins/default/ 
     12* If you have LDAP servers configured you should re-configure 
     13  the config entries using the template given in /config/main.inc.php.dist 
    714 
    815from version 1.0-beta2 
     
    1118* replace all files in folder /program/ 
    1219* replace all files in folder /skins/default/ 
    13 * run all commands in SQL/*.update.sql or re-initalize database with *.initial.sql 
     20* run all commands in SQL/[yourdbtype].update.sql or 
     21  re-initalize the database with [yourdbtype].initial.sql 
    1422* add these lines to /config/main.inc.php 
    15   $rcmail_config['draft_autosave'] = 300; 
    16   $rcmail_config['date_today'] = 'H:i'; 
    17 * If you have LDAP servers configured, change prop key 'mail_field' 
    18   to 'email_field' for each server confgured in /config/main.inc.php 
    19  
     23   $rcmail_config['draft_autosave'] = 300; 
     24   $rcmail_config['date_today'] = 'H:i'; 
     25* If you have LDAP servers configured you should re-configure 
     26  the config entries using the template given in /config/main.inc.php.dist 
    2027 
    2128form version 0.1-beta 
     
    2431* replace all files in folder /program/ 
    2532* replace all files in folder /skins/default/ 
    26 * run all commands in SQL/*.update.sql or re-initalize database with *.initial.sql 
    27 * add these line to /config/db.inc.php 
    28   $rcmail_config['db_persistent'] = TRUE; 
     33* run all commands in SQL/[yourdbtype].update.sql or 
     34  re-initalize the database with [yourdbtype].initial.sql 
     35* add this line to /config/db.inc.php 
     36   $rcmail_config['db_persistent'] = false; 
    2937* add these lines to /config/main.inc.php 
    30   $rcmail_config['drafts_mbox'] = 'Drafts'; 
    31   $rcmail_config['junk_mbox'] = 'Junk'; 
    32   $rcmail_config['product_name'] = 'RoundCube Webmail'; 
    33   $rcmail_config['read_when_deleted'] = TRUE; 
    34   $rcmail_config['enable_spellcheck'] = TRUE; 
    35   $rcmail_config['protect_default_folders'] = TRUE; 
    36   $rcmail_config['draft_autosave'] = 300; 
    37   $rcmail_config['date_today'] = 'H:i'; 
     38   $rcmail_config['drafts_mbox'] = 'Drafts'; 
     39   $rcmail_config['junk_mbox'] = 'Junk'; 
     40   $rcmail_config['product_name'] = 'RoundCube Webmail'; 
     41   $rcmail_config['read_when_deleted'] = false; 
     42   $rcmail_config['enable_spellcheck'] = false; 
     43   $rcmail_config['protect_default_folders'] = false; 
    3844* replace the following line from /config/main.inc.php 
    3945   @include($_SERVER['HTTP_HOST'].'.inc.php'); 
    40   with  
    41    $rcmail_config['include_host_config'] = TRUE; 
    42  
    43  
    44  
    45 from version 0.1-20051021 
    46 ---------------------------------------- 
    47 * replace index.php 
    48 * replace all files in folder /program/ 
    49 * replace all files in folder /skins/default/ 
    50 * run all commands in SQL/*.update-0.1a.sql or re-initalize database with *.initial.sql 
    51 * add these lines to /config/main.inc.php 
    52   $rcmail_config['skip_deleted'] = FALSE; 
    53   $rcmail_config['message_sort_col'] = 'date'; 
    54   $rcmail_config['message_sort_order'] = 'DESC'; 
    55   $rcmail_config['log_dir'] = 'logs/'; 
    56   $rcmail_config['temp_dir'] = 'temp/'; 
    57   $rcmail_config['message_cache_lifetime'] = '10d'; 
    58   $rcmail_config['drafts_mbox'] = 'Drafts'; 
    59   $rcmail_config['product_name'] = 'RoundCube Webmail'; 
    60   $rcmail_config['read_when_deleted'] = TRUE; 
    61   $rcmail_config['enable_spellcheck'] = TRUE; 
    62 * add these lines to /config/db.inc.php 
    63   $rcmail_config['db_max_length'] = 512000; 
    64   $rcmail_config['db_sequence_user_ids'] = 'user_ids'; 
    65   $rcmail_config['db_sequence_identity_ids'] = 'identity_ids'; 
    66   $rcmail_config['db_sequence_contact_ids'] = 'contact_ids'; 
    67   $rcmail_config['db_sequence_cache_ids'] = 'cache_ids'; 
    68   $rcmail_config['db_sequence_message_ids'] = 'message_ids'; 
    69   $rcmail_config['db_persistent'] = TRUE; 
    70  
    71  
    72  
    73 from version 0.1-20051007 
    74 ---------------------------------------- 
    75 * replace index.php 
    76 * replace all files in folder /program/ 
    77 * replace all files in folder /skins/default/ 
    78 * run all commands in SQL/*.update-0.1a.sql or re-initalize database with *.initial.sql 
    79 * add these lines to /config/main.inc.php 
    80   $rcmail_config['smtp_auth_type'] = '';  // if you need to specify an auth method for SMTP 
    81   $rcmail_config['session_lifetime'] = 20;  // to specify the session lifetime in minutes 
    82   $rcmail_config['skip_deleted'] = FALSE; 
    83   $rcmail_config['message_sort_col'] = 'date'; 
    84   $rcmail_config['message_sort_order'] = 'DESC'; 
    85   $rcmail_config['log_dir'] = 'logs/'; 
    86   $rcmail_config['temp_dir'] = 'temp/'; 
    87   $rcmail_config['message_cache_lifetime'] = '10d'; 
    88   $rcmail_config['drafts_mbox'] = 'Drafts'; 
    89   $rcmail_config['product_name'] = 'RoundCube Webmail'; 
    90   $rcmail_config['read_when_deleted'] = TRUE; 
    91   $rcmail_config['enable_spellcheck'] = TRUE; 
    92 * add these lines to /config/db.inc.php 
    93   $rcmail_config['db_max_length'] = 512000;   
    94   $rcmail_config['db_sequence_user_ids'] = 'user_ids'; 
    95   $rcmail_config['db_sequence_identity_ids'] = 'identity_ids'; 
    96   $rcmail_config['db_sequence_contact_ids'] = 'contact_ids'; 
    97   $rcmail_config['db_sequence_cache_ids'] = 'cache_ids'; 
    98   $rcmail_config['db_sequence_message_ids'] = 'message_ids';   
    99   $rcmail_config['db_persistent'] = TRUE; 
    100  
    101  
    102  
    103 from version 0.1-20050820 
    104 ---------------------------------------- 
    105 * replace index.php 
    106 * replace all files in folder /program/ 
    107 * replace all files in folder /skins/default/ 
    108 * run all commands in SQL/*.update-0.1a.sql or re-initalize database with *.initial.sql 
    109 * add these line to /config/main.inc.php 
    110   $rcmail_config['prettydate'] = TRUE; 
    111   $rcmail_config['smtp_port'] = 25; 
    112   $rcmail_config['default_port'] = 143; 
    113   $rcmail_config['session_lifetime'] = 20; 
    114   $rcmail_config['skip_deleted'] = FALSE; 
    115   $rcmail_config['message_sort_col'] = 'date'; 
    116   $rcmail_config['message_sort_order'] = 'DESC'; 
    117   $rcmail_config['log_dir'] = 'logs/'; 
    118   $rcmail_config['temp_dir'] = 'temp/'; 
    119   $rcmail_config['message_cache_lifetime'] = '10d'; 
    120 * replace database properties (db_type, db_host, db_user, db_pass, $d_name) 
    121   in /config/db.inc.php with the following line: 
    122   $rcmail_config['db_dsnw'] = 'mysql://roundcube:pass@localhost/roundcubemail'; 
    123 * add these lines to /config/db.inc.php 
    124   $rcmail_config['db_max_length'] = 512000; 
    125  
    126  
    127  
    128 from versions 0.1-alpha and 0.1-20050811 
    129 ---------------------------------------- 
    130 * replace index.php 
    131 * replace all files in folder /program/ 
    132 * replace all files in folder /skins/default/ 
    133 * run all commands in SQL/*.update-0.1a.sql or re-initalize database with *.initial.sql 
    134 * add these line to /config/main.inc.php 
    135   $rcmail_config['trash_mbox'] = 'Trash'; 
    136   $rcmail_config['default_imap_folders'] = array('INBOX', 'Drafts', 'Sent', 'Junk', 'Trash'); 
    137   $rcmail_config['prefer_html'] = TRUE; 
    138   $rcmail_config['prettydate'] = TRUE; 
    139   $rcmail_config['smtp_port'] = 25; 
    140   $rcmail_config['default_port'] = 143; 
    141   $rcmail_config['session_lifetime'] = 20; 
    142   $rcmail_config['skip_deleted'] = FALSE; 
    143   $rcmail_config['message_sort_col'] = 'date'; 
    144   $rcmail_config['message_sort_order'] = 'DESC'; 
    145   $rcmail_config['log_dir'] = 'logs/'; 
    146   $rcmail_config['temp_dir'] = 'temp/'; 
    147   $rcmail_config['message_cache_lifetime'] = '10d'; 
    148 * replace database properties (db_type, db_host, db_user, db_pass, $d_name) 
    149   in /config/db.inc.php with the following line: 
    150   $rcmail_config['db_dsnw'] = 'mysql://roundcube:pass@localhost/roundcubemail'; 
    151 * add these lines to /config/db.inc.php 
    152   $rcmail_config['db_max_length'] = 512000; 
    153  
     46  with 
     47   $rcmail_config['include_host_config'] = false; 
  • branches/devel-vnext/config/db.inc.php.dist

    r784 r957  
    1717// PEAR database DSN for read/write operations 
    1818// format is db_provider://user:password@host/databse 
    19 // currentyl suported db_providers: mysql, sqlite 
     19// currently supported db_providers: mysql, mysqli, pgsql, sqlite, mssql 
    2020 
    2121$rcmail_config['db_dsnw'] = 'mysql://roundcube:pass@localhost/roundcubemail'; 
     
    3434 
    3535// use persistent db-connections 
     36// beware this will not "always" work as expected 
     37// see: http://www.php.net/manual/en/features.persistent-connections.php 
    3638$rcmail_config['db_persistent'] = FALSE; 
    37  
    3839 
    3940// you can define specific table names used to store webmail data 
     
    6263$rcmail_config['db_sequence_messages'] = 'message_ids'; 
    6364 
     65// end db config file 
    6466 
    65 // end db config file 
    6667?> 
  • branches/devel-vnext/config/main.inc.php.dist

    r769 r957  
    7878$rcmail_config['smtp_auth_type'] = ''; 
    7979 
     80// SMTP HELO host 
     81// Hostname to give to the remote server for SMTP 'HELO' or 'EHLO' messages 
     82// Leave this blank and you will get the server variable 'server_name' or 
     83// localhost if that isn't defined. 
     84$rcmail_config['smtp_helo_host'] = ''; 
     85 
    8086// Log sent messages 
    8187$rcmail_config['smtp_log'] = TRUE; 
     
    8793// relative path to the skin folder 
    8894$rcmail_config['skin_path'] = 'skins/default/'; 
     95 
     96// includes should be interpreted as PHP files 
     97$rcmail_config['skin_include_php'] = FALSE; 
    8998 
    9099// use this folder to store temp files (must be writebale for apache user) 
     
    149158$rcmail_config['default_imap_folders'] = array('INBOX', 'Drafts', 'Sent', 'Junk', 'Trash'); 
    150159 
     160// automatically create the above listed default folders on login 
     161$rcmail_config['create_default_folders'] = FALSE; 
     162 
    151163// protect the default folders from renames, deletes, and subscription changes 
    152164$rcmail_config['protect_default_folders'] = TRUE; 
     
    166178 
    167179// Make use of the built-in spell checker. It is based on GoogieSpell. 
     180// Since Google only accepts connections over https your PHP installatation 
     181// requires to be compiled with Open SSL support 
    168182$rcmail_config['enable_spellcheck'] = TRUE; 
    169183 
     
    200214 *  'bind_dn'       => '', 
    201215 *  'bind_pass'     => '', 
     216 *  'ldap_version'  => 3,       // using LDAPv3 
    202217 *  'search_fields' => array('mail', 'cn'),  // fields to search in 
    203218 *  'name_field'    => 'cn',    // this field represents the contact's name 
    204219 *  'email_field'   => 'mail',  // this field represents the contact's e-mail 
     220 *  'surname_field' => 'sn',    // this field represents the contact's last name 
     221 *  'firstname_field' => 'gn',  // this field represents the contact's first name 
    205222 *  'scope'         => 'sub',   // search mode: sub|base|list 
    206  *  'filter'        => '',      // will be &'d with search field ex: (status=act) 
     223 *  'filter'        => '',      // used for basic listing (if not empty) and will be &'d with search queries. ex: (status=act) 
    207224 *  'fuzzy_search'  => true);   // server allows wildcard search 
    208225 */ 
     226 
     227// enable composing html formatted messages (experimental) 
     228$rcmail_config['enable_htmleditor'] = FALSE; 
    209229 
    210230// addressbook plugin? ;-) 
     
    234254 
    235255// use this timezone to display date/time 
    236 $rcmail_config['timezone'] = 1; 
    237  
    238 // daylight savings are On 
    239 $rcmail_config['dst_active'] = TRUE; 
     256$rcmail_config['timezone'] = intval(date('O'))/100 - date('I'); 
     257 
     258// is daylight saving On? 
     259$rcmail_config['dst_active'] = (bool)date('I'); 
    240260 
    241261// prefer displaying HTML messages 
     
    256276// save compose message every 300 seconds (5min) 
    257277$rcmail_config['draft_autosave'] = 300; 
     278 
     279// default setting if preview pane is enabled 
     280$rcmail_config['preview_pane'] = FALSE; 
     281 
     282// don't let users set pagesize to more than this value if set 
     283$rcmail_config['max_pagesize'] = 200; 
    258284 
    259285// default setting if preview pane is enabled 
  • branches/devel-vnext/program/include/bootstrap.php

    r806 r957  
    5151ini_set('session.gc_maxlifetime', 21600); 
    5252ini_set('session.gc_divisor', 500); 
    53 ini_set('error_reporting', E_ALL&~E_NOTICE); 
     53ini_set('error_reporting', E_ALL|E_STRICT); 
    5454set_magic_quotes_runtime(0); 
    5555 
     
    5757// (does not work in safe mode) 
    5858if (!ini_get('safe_mode')) { 
    59     @set_time_limit(120); 
     59    set_time_limit(120); 
    6060} 
    61  
    6261 
    6362/** 
    6463 * Use PHP5 autoload for dynamic class loading 
    6564 */ 
    66 function __autoload($classname) 
    67 { 
     65function __autoload($classname) { 
    6866    $filename = preg_replace( 
    6967        array('/MDB2_(.+)/', '/Mail_(.+)/', '/^html_.+/'), 
     
    7270    ); 
    7371 
    74     @include_once($filename. ".php"); 
     72    include_once $filename. '.php'; 
    7573} 
    76  
    7774 
    7875// include global functions 
    7976require_once 'globals.php'; 
    8077 
    81  
    8278/** 
    8379 * Local callback function for PEAR errors 
    8480 */ 
    85 function rcube_pear_error($err) 
    86 { 
     81function rcube_pear_error($err) { 
    8782  error_log(sprintf("%s (%s): %s", 
    8883    $err->getMessage(), 
     
    9186} 
    9287 
    93  
    9488// set PEAR error handling 
    9589PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'rcube_pear_error'); 
    96  
    9790 
    9891// create registry and set some global properties 
     
    10194 
    10295 
     96?> 
  • branches/devel-vnext/program/include/globals.php

    r806 r957  
    1616 +-----------------------------------------------------------------------+ 
    1717 
    18  $Id$ 
    19  
    20 */ 
     18 $Id$ 
     19 
     20 */ 
    2121 
    2222/** 
    2323 * RoundCube global functions 
    24  *  
     24 * 
    2525 * @package Core 
    2626 */ 
     
    3232 * @see rcube::rep_specialchars_output() 
    3333 */ 
    34 function Q($str, $mode='strict', $newlines=TRUE) 
    35 { 
     34function Q($str, $mode = 'strict', $newlines = TRUE) { 
    3635    return rcube::rep_specialchars_output($str, 'html', $mode, $newlines); 
    3736} 
     
    4241 * @see rcube::rep_specialchars_output() 
    4342 */ 
    44 function JQ($str) 
    45 { 
     43function JQ($str) { 
    4644    return rcube::rep_specialchars_output($str, 'js'); 
    4745} 
     
    5452 * @return string Dequoted string 
    5553 */ 
    56 function strip_quotes($str) 
    57 { 
     54function strip_quotes($str) { 
    5855    return preg_replace('/[\'"]/', '', $str); 
    5956} 
     
    6562 * @return string Stripped string 
    6663 */ 
    67 function strip_newlines($str) 
    68 { 
     64function strip_newlines($str) { 
    6965    return preg_replace('/[\r\n]/', '', $str); 
    7066} 
     
    7470 * Send HTTP headers to prevent caching this page 
    7571 */ 
    76 function send_nocacheing_headers() 
    77 { 
     72function send_nocacheing_headers() { 
    7873    if (headers_sent()) { 
    7974        return; 
     
    9186 * @param int Expiration time in seconds 
    9287 */ 
    93 function send_future_expire_header($offset = 2600000) 
    94   { 
    95   if (headers_sent()) 
    96     return; 
    97  
    98   header("Expires: ".gmdate("D, d M Y H:i:s", mktime()+$offset)." GMT"); 
    99   header("Cache-Control: max-age=$offset"); 
    100   header("Pragma: "); 
    101   } 
     88function send_future_expire_header($offset = 2600000) { 
     89    if (headers_sent()) { 
     90        return; 
     91    } 
     92 
     93    header('Expires: '.gmdate('D, d M Y H:i:s', mktime()+$offset).' GMT'); 
     94    header('Cache-Control: max-age='.$offset); 
     95    header('Pragma: '); 
     96} 
    10297 
    10398 
     
    108103 * @param int Modified date as unix timestamp 
    109104 * @param string Etag value for caching 
    110 */ 
    111 function send_modified_header($mdate, $etag=null) 
    112 { 
     105 */ 
     106function send_modified_header($mdate, $etag = null) { 
    113107    if (headers_sent()) { 
    114108        return; 
    115109    } 
    116110    $iscached = false; 
    117     if ( 
    118         $_SERVER['HTTP_IF_MODIFIED_SINCE'] 
    119         && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $mdate 
    120     ) { 
     111    if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $mdate) { 
    121112        $iscached = true; 
    122113    } 
    123114 
    124     $etag = $etag ? "\"$etag\"" : null; 
     115    $etag = $etag ? '"'.$etag.'"' : null; 
    125116    if ($etag && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) { 
    126117        $iscached = true; 
    127118    } 
    128119    if ($iscached) { 
    129         header("HTTP/1.x 304 Not Modified"); 
    130     } 
    131     else { 
    132         header("Last-Modified: ".gmdate("D, d M Y H:i:s", $mdate)." GMT"); 
    133     } 
    134     header("Cache-Control: max-age=0"); 
    135     header("Expires: "); 
    136     header("Pragma: "); 
     120        header('HTTP/1.x 304 Not Modified'); 
     121    } else { 
     122        header('Last-Modified: '.gmdate('D, d M Y H:i:s', $mdate).' GMT'); 
     123    } 
     124    header('Cache-Control: max-age=0'); 
     125    header('Expires: '); 
     126    header('Pragma: '); 
    137127 
    138128    if ($etag) { 
     
    152142 * @return string Serialized JSON string 
    153143 */ 
    154 function json_serialize($var) 
    155 { 
     144function json_serialize($var) { 
    156145    if (is_object($var)) { 
    157146        $var = get_object_vars($var); 
     
    161150        if (!sizeof($var)) { 
    162151            return '[]'; 
    163         } 
    164         else { 
     152        } else { 
    165153            $keys_arr = array_keys($var); 
    166154            $is_assoc = $have_numeric = 0; 
     
    183171            foreach ($var as $key => $value) { 
    184172                // enclose key with quotes if it is not variable-name conform 
    185                 if (!ereg("^[_a-zA-Z]{1}[_a-zA-Z0-9]*$", $key) /* || is_js_reserved_word($key) */) 
    186                     $key = "'$key'"; 
    187  
    188                 $pairs[] = sprintf("%s%s", $is_assoc ? "$key:" : '', json_serialize($value)); 
     173                if (!ereg('^[_a-zA-Z]{1}[_a-zA-Z0-9]*$', $key) /* || is_js_reserved_word($key) */) 
     174                $key = "'$key'"; 
     175 
     176                $pairs[] = sprintf("%s%s", $is_assoc ? $key.':' : '', json_serialize($value)); 
    189177            } 
    190178            return $brackets{0} . implode(',', $pairs) . $brackets{1}; 
    191179        } 
    192     } 
    193     else if (is_numeric($var) && strval(intval($var)) === strval($var)) { 
     180    } else if (is_numeric($var) && strval(intval($var)) === strval($var)) { 
    194181        return $var; 
    195     } 
    196     else if (is_bool($var)) { 
     182    } else if (is_bool($var)) { 
    197183        return $var ? '1' : '0'; 
    198     } 
    199     else { 
     184    } else { 
    200185        return "'" . JQ($var) . "'"; 
    201186    } 
     
    207192 * @deprecated 
    208193 */ 
    209 function array2js($arr, $type='') 
    210 { 
     194// TODO is it really not used? rcmail_compose line 368 
     195function array2js($arr, $type='') { 
    211196    return json_serialize($arr); 
    212197} 
     
    220205 * @return boolean True if found, False if not 
    221206 */ 
    222 function in_array_nocase($needle, $haystack) 
    223 { 
     207function in_array_nocase($needle, $haystack) { 
    224208    foreach ($haystack as $value) { 
    225         if (strtolower($needle)===strtolower($value)) { 
     209        if (strtolower($needle) === strtolower($value)) { 
    226210            return TRUE; 
    227211        } 
     
    237221 * @return boolean Imagine what! 
    238222 */ 
    239 function get_boolean($str) 
    240 { 
     223function get_boolean($str) { 
    241224    $str = strtolower($str); 
    242225    if(in_array($str, array('false', '0', 'no', 'nein', ''), TRUE)) { 
    243226        return FALSE; 
    244     } 
    245     else { 
     227    } else { 
    246228        return TRUE; 
    247229    } 
     
    255237 * @return int Number of bytes 
    256238 */ 
    257 function parse_bytes($str) 
    258 { 
    259     if (is_numeric($str)) 
     239function parse_bytes($str) { 
     240    if (is_numeric($str)) { 
    260241        return intval($str); 
     242    } 
    261243 
    262244    if (preg_match('/([0-9]+)([a-z])/i', $str, $regs)) { 
    263245        $bytes = floatval($regs[1]); 
    264246        switch (strtolower($regs[2])) { 
    265         case 'g': 
    266             $bytes *= 1073741824; 
    267             break; 
    268         case 'm': 
    269             $bytes *= 1048576; 
    270             break; 
    271         case 'k': 
    272             $bytes *= 1024; 
    273             break; 
     247            case 'g': 
     248                $bytes *= 1073741824; 
     249                break; 
     250            case 'm': 
     251                $bytes *= 1048576; 
     252                break; 
     253            case 'k': 
     254                $bytes *= 1024; 
     255                break; 
    274256        } 
    275257    } 
     
    279261 
    280262 
    281  /** 
    282   * Create a human readable string for a number of bytes 
    283   * 
    284   * @param int Number of bytes 
    285   * @return string Byte string 
    286   */ 
    287 function show_bytes($bytes) 
    288 { 
     263/** 
     264 * Create a human readable string for a number of bytes 
     265 * 
     266 * @param int Number of bytes 
     267 * @return string Byte string 
     268 */ 
     269function show_bytes($bytes) { 
    289270    if ($bytes > 1073741824) { 
    290271        $gb = $bytes/1073741824; 
    291272        $str = sprintf($gb>=10 ? "%d GB" : "%.1f GB", $gb); 
    292     } 
    293     else if ($bytes > 1048576) { 
     273    } else if ($bytes > 1048576) { 
    294274        $mb = $bytes/1048576; 
    295275        $str = sprintf($mb>=10 ? "%d MB" : "%.1f MB", $mb); 
    296     } 
    297     else if ($bytes > 1024) 
     276    } else if ($bytes > 1024) { 
    298277        $str = sprintf("%d KB",  round($bytes/1024)); 
    299     else 
     278    } else { 
    300279        $str = sprintf('%d B', $bytes); 
    301  
     280    } 
    302281    return $str; 
    303282} 
     
    311290 * @return string Absolute URL 
    312291 */ 
    313 function make_absolute_url($path, $base_url) 
    314 { 
     292function make_absolute_url($path, $base_url) { 
    315293    $host_url = $base_url; 
    316294    $abs_path = $path; 
    317295 
    318296    // cut base_url to the last directory 
    319     if (strpos($base_url, '/')>7) { 
     297    if (strpos($base_url, '/') > 7) { 
    320298        $host_url = substr($base_url, 0, strpos($base_url, '/')); 
    321299        $base_url = substr($base_url, 0, strrpos($base_url, '/')); 
     
    323301 
    324302    // $path is absolute 
    325     if ($path{0}=='/') 
     303    if ($path{0} == '/') { 
    326304        $abs_path = $host_url.$path; 
    327     else { 
     305    } else { 
    328306        // strip './' because its the same as '' 
    329307        $path = preg_replace('/^\.\//', '', $path); 
    330308 
    331     if (preg_match_all('/\.\.\//', $path, $matches, PREG_SET_ORDER)) 
    332         foreach($matches as $a_match) { 
    333             if (strrpos($base_url, '/')) 
    334                 $base_url = substr($base_url, 0, strrpos($base_url, '/')); 
    335  
    336             $path = substr($path, 3); 
    337         } 
    338  
     309        if (preg_match_all('/\.\.\//', $path, $matches, PREG_SET_ORDER)) { 
     310            foreach($matches as $a_match) { 
     311                if (strrpos($base_url, '/')) { 
     312                    $base_url = substr($base_url, 0, strrpos($base_url, '/')); 
     313                } 
     314                $path = substr($path, 3); 
     315            } 
     316        } 
    339317        $abs_path = $base_url.'/'.$path; 
    340318    } 
    341  
    342319    return $abs_path; 
    343320} 
     
    347324 * Wrapper function for strlen 
    348325 */ 
    349 function rc_strlen($str) 
    350 { 
    351     if (function_exists('mb_strlen')) 
     326function rc_strlen($str) { 
     327    if (function_exists('mb_strlen')) { 
    352328        return mb_strlen($str); 
    353     else 
     329    } else { 
    354330        return strlen($str); 
     331    } 
    355332} 
    356333 
     
    358335 * Wrapper function for strtolower 
    359336 */ 
    360 function rc_strtolower($str) 
    361 { 
    362     if (function_exists('mb_strtolower')) 
     337function rc_strtolower($str) { 
     338    if (function_exists('mb_strtolower')) { 
    363339        return mb_strtolower($str); 
    364     else 
     340    } else { 
    365341        return strtolower($str); 
     342    } 
    366343} 
    367344 
     
    369346 * Wrapper function for substr 
    370347 */ 
    371 function rc_substr($str, $start, $len=null) 
    372 { 
    373     if (function_exists('mb_substr')) 
     348function rc_substr($str, $start, $len = null) { 
     349    if (function_exists('mb_substr')) { 
    374350        return mb_substr($str, $start, $len); 
    375     else 
     351    } else { 
    376352        return substr($str, $start, $len); 
     353    } 
    377354} 
    378355 
     
    380357 * Wrapper function for strpos 
    381358 */ 
    382 function rc_strpos($haystack, $needle, $offset=0) 
    383 { 
    384     if (function_exists('mb_strpos')) 
     359function rc_strpos($haystack, $needle, $offset = 0) { 
     360    if (function_exists('mb_strpos')) { 
    385361        return mb_strpos($haystack, $needle, $offset); 
    386     else 
     362    } else { 
    387363        return strpos($haystack, $needle, $offset); 
     364    } 
    388365} 
    389366 
     
    391368 * Wrapper function for strrpos 
    392369 */ 
    393 function rc_strrpos($haystack, $needle, $offset=0) 
    394 { 
    395     if (function_exists('mb_strrpos')) 
     370function rc_strrpos($haystack, $needle, $offset = 0) { 
     371    if (function_exists('mb_strrpos')) { 
    396372        return mb_strrpos($haystack, $needle, $offset); 
    397     else 
     373    } else { 
    398374        return strrpos($haystack, $needle, $offset); 
     375    } 
    399376} 
    400377 
     
    409386 * @return string Abbrevated string 
    410387 */ 
    411 function abbrevate_string($str, $maxlength, $place_holder='...') 
    412 { 
     388function abbrevate_string($str, $maxlength, $place_holder = '...') { 
    413389    $length = rc_strlen($str); 
    414390    $first_part_length = floor($maxlength/2) - rc_strlen($place_holder); 
     
    426402 * Make sure the string ends with a slash 
    427403 */ 
    428 function slashify($str) 
    429 { 
     404function slashify($str) { 
    430405    return unslashify($str).'/'; 
    431406} 
     
    435410 * Remove slash at the end of the string 
    436411 */ 
    437 function unslashify($str) 
    438 { 
     412function unslashify($str) { 
    439413    return preg_replace('/\/$/', '', $str); 
    440414} 
     
    447421 * @return boolean True on success, False if directory was not found 
    448422 */ 
    449 function clear_directory($dir_path) 
    450 { 
    451     $dir = @opendir($dir_path); 
    452     if (!$dir) 
     423function clear_directory($dir_path) { 
     424    $dir = opendir($dir_path); 
     425    if (!$dir) { 
    453426        return false; 
    454  
    455     while ($file = readdir($dir)) 
    456         if (strlen($file) > 2) 
     427    } 
     428 
     429    while ($file = readdir($dir)) { 
     430        if (strlen($file) > 2) { 
    457431            unlink("$dir_path/$file"); 
     432        } 
     433    } 
    458434 
    459435    closedir($dir); 
     
    469445 * @return int Unix timestamp 
    470446 */ 
    471 function get_offset_time($offset_str, $factor=1) 
    472 { 
     447function get_offset_time($offset_str, $factor = 1) { 
    473448    if (preg_match('/^([0-9]+)\s*([smhdw])/i', $offset_str, $regs)) { 
    474449        $amount = (int)$regs[1]; 
    475450        $unit = strtolower($regs[2]); 
    476     } 
    477     else { 
     451    } else { 
    478452        $amount = (int)$offset_str; 
    479453        $unit = 's'; 
     
    482456    $ts = mktime(); 
    483457    switch ($unit) { 
    484     case 'w': 
    485         $amount *= 7; 
    486     case 'd': 
    487         $amount *= 24; 
    488     case 'h': 
    489         $amount *= 60; 
    490     case 'm': 
    491         $amount *= 60; 
    492     case 's': 
    493         $ts += $amount * $factor; 
     458        case 'w': 
     459            $amount *= 7; 
     460        case 'd': 
     461            $amount *= 24; 
     462        case 'h': 
     463            $amount *= 60; 
     464        case 'm': 
     465            $amount *= 60; 
     466        case 's': 
     467            $ts += $amount * $factor; 
    494468    } 
    495469 
     
    505479 * @return index of needle within haystack, or false if not found 
    506480 */ 
    507 function strrstr($haystack, $needle) 
    508 { 
     481function strrstr($haystack, $needle) { 
    509482    $pver = phpversion(); 
    510483    if ($pver[0] >= 5) { 
    511484        return strrpos($haystack, $needle); 
    512     } 
    513     else { 
     485    } else { 
    514486        $index = strpos(strrev($haystack), strrev($needle)); 
    515487        if ($index === false) { 
     
    521493} 
    522494 
    523  
     495?> 
  • branches/devel-vnext/program/include/rcube.php

    r954 r957  
    2525require_once 'lib/utf8.class.php'; 
    2626 
    27  
    2827/** 
    2928 * rcube 
     
    3837 * @since    0.1-rc1 
    3938 */ 
    40 class rcube 
    41 { 
     39class rcube { 
    4240    const INPUT_GET  = 0x0101; 
    4341    const INPUT_POST = 0x0102; 
     
    5351     * @return void 
    5452     */ 
    55     static function startup($task = 'mail') 
    56     { 
     53    static function startup($task = 'mail') { 
    5754        $registry = rcube_registry::get_instance(); 
    5855        $registry->set('task', $task, 'core'); 
  • branches/devel-vnext/program/include/rcube_contacts.php

    r806 r957  
    115115    } 
    116116 
     117        /** 
     118         * Close connection to source 
     119         * Called on script shutdown 
     120         */ 
     121    function close() {} 
    117122 
    118123    /** 
     
    120125     * 
    121126     * @param  array  List of cols to show 
     127     * @param  int    Only return this number of records, use negative values for tail 
    122128     * @return array  Indexed list of contact records, each a hash array 
    123129     */ 
     
    167173     * @return Indexed list of contact records and 'count' value 
    168174     */ 
    169     function search($fields, $value, $select=true) 
     175    function search($fields, $value, $strict = false, $select = true) 
    170176    { 
    171177        if (!is_array($fields)) { 
     
    177183                $ids         = !is_array($value) ? split(',', $value) : $value; 
    178184                $add_where[] = $this->primary_key." IN (".join(',', $ids).")"; 
     185            } 
     186            elseif ($strict) { 
     187                $add_where[] = $this->db->quoteIdentifier($col)."=".$this->db->quote($value); 
    179188            } 
    180189            else { 
     
    279288 
    280289        if ($check) { 
    281             $existing = $this->search('email', $save_data['email'], false); 
     290            $existing = $this->search('email', $save_data['email'], true, false); 
    282291        } 
    283292        $a_insert_cols = $a_insert_values = array(); 
  • branches/devel-vnext/program/include/rcube_error.php

    r806 r957  
    55 |                                                                       | 
    66 | This file is part of the RoundCube Webmail client                     | 
    7  | Copyright (C) 2005-2007, RoundCube Dev, - Switzerland                 | 
     7 | Copyright (C) 2005-2008, RoundCube Dev, - Switzerland                 | 
    88 | Licensed under the GNU GPL                                            | 
    99 |                                                                       | 
  • branches/devel-vnext/program/include/rcube_ldap.php

    r806 r957  
    66 |                                                                       | 
    77 | This file is part of the RoundCube Webmail client                     | 
    8  | Copyright (C) 2006-2007, RoundCube Dev. - Switzerland                 | 
     8 | Copyright (C) 2006-2008, RoundCube Dev. - Switzerland                 | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
     
    1818 $Id: rcube_ldap.inc 563 2007-05-17 15:58:51Z thomasb $ 
    1919 
    20 */ 
     20 */ 
    2121 
    2222/** 
     
    2525 * @package Addressbook 
    2626 */ 
    27 class rcube_ldap 
    28 { 
    29   var $conn; 
    30   var $prop = array(); 
    31   var $fieldmap = array(); 
    32    
    33   var $filter = ''; 
    34   var $result = null; 
    35   var $ldap_result = null; 
    36   var $sort_col = ''; 
    37    
    38   /** public properties */ 
    39   var $primary_key = 'ID'; 
    40   var $readonly = true; 
    41   var $list_page = 1; 
    42   var $page_size = 10; 
    43   var $ready = false; 
    44    
    45    
    46   /** 
    47    * Object constructor 
    48    * 
    49    * @param array LDAP connection properties 
    50    * @param integer User-ID 
    51    */ 
    52   function __construct($p) 
    53   { 
    54     $this->prop = $p; 
    55      
    56     foreach ($p as $prop => $value) 
    57       if (preg_match('/^(.+)_field$/', $prop, $matches)) 
     27class rcube_ldap { 
     28    var $conn; 
     29    var $prop = array(); 
     30    var $fieldmap = array(); 
     31 
     32    var $filter = ''; 
     33    var $result = null; 
     34    var $ldap_result = null; 
     35    var $sort_col = ''; 
     36 
     37    /** public properties */ 
     38    var $primary_key = 'ID'; 
     39    var $readonly = true; 
     40    var $list_page = 1; 
     41    var $page_size = 10; 
     42    var $ready = false; 
     43 
     44 
     45    /** 
     46     * Object constructor 
     47     * 
     48     * @param array LDAP connection properties 
     49     * @param integer User-ID 
     50     */ 
     51    public function __construct($p) { 
     52        $this->prop = $p; 
     53 
     54        foreach ($p as $prop => $value) 
     55        if (preg_match('/^(.+)_field$/', $prop, $matches)) 
    5856        $this->fieldmap[$matches[1]] = $value; 
    59      
    60     // $this->filter = "(dn=*)"; 
    61     $this->connect(); 
    62   } 
    63  
    64   /** 
    65    * PHP 4 object constructor 
    66    * 
    67    * @see  rcube_ldap::__construct 
    68    */ 
    69   function rcube_ldap($p) 
    70   { 
    71     $this->__construct($p); 
    72   } 
    73    
    74  
    75   /** 
    76    * Establish a connection to the LDAP server 
    77    */ 
    78   function connect() 
    79   { 
    80     if (!function_exists('ldap_connect')) 
    81       rcube_error::raise(array('type' => 'ldap', 'message' => "No ldap support in this installation of PHP"), true); 
    82  
    83     if (is_resource($this->conn)) 
    84       return true; 
    85      
    86     if (!is_array($this->prop['hosts'])) 
    87       $this->prop['hosts'] = array($this->prop['hosts']); 
    88  
    89     foreach ($this->prop['hosts'] as $host) 
    90     { 
    91       if ($lc = @ldap_connect($host, $this->prop['port'])) 
    92       { 
    93         ldap_set_option($lc, LDAP_OPT_PROTOCOL_VERSION, $this->prop['port']); 
    94         $this->prop['host'] = $host; 
    95         $this->conn = $lc; 
    96         break; 
    97       } 
    98     } 
    99      
    100     if (is_resource($this->conn)) 
    101     { 
    102       $this->ready = true; 
    103       if (!empty($this->prop['bind_dn']) && !empty($this->prop['bind_pass'])) 
    104         $this->ready = $this->bind($this->prop['bind_dn'], $this->prop['bind_pass']); 
    105     } 
    106     else 
    107       rcube_error::raise(array('type' => 'ldap', 'message' => "Could not connect to any LDAP server, tried $host:{$this->prop[port]} last"), true); 
    108   } 
    109  
    110  
    111   /** 
    112    * Bind connection with DN and password 
    113    */ 
    114   function bind($dn, $pass) 
    115   { 
    116     if (!$this->conn) 
    117       return false; 
    118      
    119     if (@ldap_bind($this->conn, $dn, $pass)) 
    120       return true; 
    121     else 
    122     { 
    123       rcube_error::raise(array( 
    124         'code' => ldap_errno($this->conn), 
    125         'type' => 'ldap', 
    126         'message' => "Bind failed for dn=$dn: ".ldap_error($this->conn)), 
    127       true); 
    128     } 
    129      
    130     return false; 
    131   } 
    132  
    133  
    134   /** 
    135    * Close connection to LDAP server 
    136    */ 
    137   function close() 
    138   { 
    139     if ($this->conn) 
    140       @ldap_unbind($this->conn); 
    141   } 
    142  
    143  
    144   /** 
    145    * Set internal list page 
    146    * 
    147    * @param  number  Page number to list 
    148    * @access public 
    149    */ 
    150   function set_page($page) 
    151   { 
    152     $this->list_page = (int)$page; 
    153   } 
    154  
    155  
    156   /** 
    157    * Set internal page size 
    158    * 
    159    * @param  number  Number of messages to display on one page 
    160    * @access public 
    161    */ 
    162   function set_pagesize($size) 
    163   { 
    164     $this->page_size = (int)$size; 
    165   } 
    166  
    167  
    168   /** 
    169    * Save a search string for future listings 
    170    * 
    171    * @param string ?? 
    172    */ 
    173   function set_search_set($filter) 
    174   { 
    175     $this->filter = $filter; 
    176   } 
    177    
    178    
     57 
     58        $this->connect(); 
     59    } 
     60 
     61    /** 
     62     * Establish a connection to the LDAP server 
     63     */ 
     64    function connect() { 
     65        if (!function_exists('ldap_connect')) { 
     66            rcube_error::raise(array('type' => 'ldap', 'message' => "No ldap support in this installation of PHP"), true); 
     67        } 
     68 
     69        if (is_resource($this->conn)) { 
     70            return true; 
     71        } 
     72 
     73        if (!is_array($this->prop['hosts'])) { 
     74            $this->prop['hosts'] = array($this->prop['hosts']); 
     75        } 
     76 
     77        if (empty($this->prop['ldap_version'])) { 
     78            $this->prop['ldap_version'] = 3; 
     79        } 
     80 
     81        foreach ($this->prop['hosts'] as $host) { 
     82            if ($lc = ldap_connect($host, $this->prop['port'])) { 
     83                ldap_set_option($lc, LDAP_OPT_PROTOCOL_VERSION, $this->prop['ldap_version']); 
     84                $this->prop['host'] = $host; 
     85                $this->conn = $lc; 
     86                break; 
     87            } 
     88        } 
     89 
     90        if (is_resource($this->conn)) { 
     91            $this->ready = true; 
     92            if (!empty($this->prop['bind_dn']) && !empty($this->prop['bind_pass'])) { 
     93                $this->ready = $this->bind($this->prop['bind_dn'], $this->prop['bind_pass']); 
     94            } 
     95        } else { 
     96            rcube_error::raise(array('type' => 'ldap', 'message' => 'Could not connect to any LDAP server, tried '.$host.':'.$this->prop['port'].' last'), true); 
     97        } 
     98    } 
     99 
     100 
     101    /** 
     102     * Bind connection with DN and password 
     103     */ 
     104    function bind($dn, $pass) { 
     105        if (!$this->conn) { 
     106            return false; 
     107        } 
     108 
     109        if (ldap_bind($this->conn, $dn, $pass)) { 
     110            return true; 
     111        } else { 
     112            rcube_error::raise( 
     113                    array( 
     114                        'code' => ldap_errno($this->conn), 
     115                        'type' => 'ldap', 
     116                        'message' => 'Bind failed for dn='.$dn.': '.ldap_error($this->conn)), 
     117                    true); 
     118            return false; 
     119        } 
     120    } 
     121 
     122 
     123    /** 
     124     * Close connection to LDAP server 
     125     */ 
     126    function close() { 
     127        if ($this->conn) { 
     128            ldap_unbind($this->conn); 
     129            $this->conn = null; 
     130        } 
     131    } 
     132 
     133 
     134    /** 
     135     * Set internal list page 
     136     * 
     137     * @param  number  Page number to list 
     138     * @access public 
     139     */ 
     140    function set_page($page) { 
     141        $this->list_page = (int)$page; 
     142    } 
     143 
     144 
     145    /** 
     146     * Set internal page size 
     147     * 
     148     * @param  number  Number of messages to display on one page 
     149     * @access public 
     150     */ 
     151    function set_pagesize($size) { 
     152        $this->page_size = (int)$size; 
     153    } 
     154 
     155 
     156    /** 
     157     * Save a search string for future listings 
     158     * 
     159     * @param string Filter string 
     160     */ 
     161    function set_search_set($filter) { 
     162        $this->filter = $filter; 
     163    } 
     164 
     165 
    179166    /** 
    180167     * Getter for saved search properties 
     
    182169     * @return mixed Search properties used by this class 
    183170     */ 
    184     function get_search_set() 
    185     { 
     171    function get_search_set() { 
    186172        return $this->filter; 
    187173    } 
     
    191177     * Reset all saved results and search parameters 
    192178     */ 
    193     function reset() 
    194     { 
     179    function reset() { 
    195180        $this->result = null; 
    196181        $this->ldap_result = null; 
    197182        $this->filter = ''; 
    198183    } 
    199    
     184 
    200185    /** 
    201186     * List the current set of contact records 
    202187     * 
    203188     * @param  array  List of cols to show 
     189     * @param  int    Only return this number of records (not implemented) 
    204190     * @return array  Indexed list of contact records, each a hash array 
    205191     */ 
    206     function list_records($cols=null, $subset=0) 
    207     { 
     192    function list_records($cols=null, $subset=0) { 
    208193        // add general filter to query 
    209194        if (!empty($this->prop['filter'])) { 
    210195            $filter = $this->prop['filter']; 
    211         } 
    212         $this->set_search_set($filter); 
     196            $this->set_search_set($filter); 
     197        } 
    213198 
    214199        // exec LDAP search if no result resource is stored 
     
    219204        // count contacts for this user 
    220205        $this->result = $this->count(); 
    221      
     206 
    222207        // we have a search result resource 
    223208        if ($this->ldap_result && $this->result->count > 0) { 
    224209            if ($this->sort_col && $this->prop['scope'] !== "base") { 
    225                 @ldap_sort($this->conn, $this->ldap_result, $this->sort_col); 
     210                ldap_sort($this->conn, $this->ldap_result, $this->sort_col); 
    226211            } 
    227212 
     
    235220 
    236221 
    237   /** 
    238    * Search contacts 
    239    * 
    240    * @param array   List of fields to search in 
    241    * @param string  Search value 
    242    * @param boolean True if results are requested, False if count only 
    243    * @return Indexed list of contact records and 'count' value 
    244    */ 
    245   function search($fields, $value, $select=true) 
    246   { 
    247     // special treatment for ID-based search 
    248     if ($fields == 'ID' || $fields == $this->primary_key) 
    249     { 
    250       $ids = explode(',', $value); 
    251       $result = new rcube_result_set(); 
    252       foreach ($ids as $id) 
    253         if ($rec = $this->get_record($id, true)) 
    254         { 
    255           $result->add($rec); 
    256           $result->count++; 
    257         } 
    258        
    259       return $result; 
    260     } 
    261      
    262     $filter = '(|'; 
    263     $wc = $this->prop['fuzzy_search'] ? '*' : ''; 
    264     if (is_array($this->prop['search_fields'])) 
    265     { 
    266       foreach ($this->prop['search_fields'] as $k => $field) 
    267         $filter .= "($field=$wc" . rcube_ldap::quote_string($value) . "$wc)"; 
    268     } 
    269     else 
    270     { 
    271       foreach ((array)$fields as $field) 
    272         if ($f = $this->_map_field($field)) 
    273           $filter .= "($f=$wc" . rcube_ldap::quote_string($value) . "$wc)"; 
    274     } 
    275     $filter .= ')'; 
    276      
    277     // add general filter to query 
    278     if (!empty($this->prop['filter'])) 
    279       $filter = '(&'.$this->prop['filter'] . $filter . ')'; 
    280  
    281     // set filter string and execute search 
    282     $this->set_search_set($filter); 
    283     $this->_exec_search(); 
    284      
    285     if ($select) 
    286       $this->list_records(); 
    287     else 
    288       $this->result = $this->count(); 
    289     
    290     return $this->result;  
    291   } 
    292  
    293  
    294   /** 
    295    * Count number of available contacts in database 
    296    * 
    297    * @return Result array with values for 'count' and 'first' 
    298    */ 
    299   function count() 
    300   { 
    301     $count = 0; 
    302     if ($this->conn && $this->ldap_result) 
    303       $count = ldap_count_entries($this->conn, $this->ldap_result); 
    304  
    305     return new rcube_result_set($count, ($this->list_page-1) * $this->page_size); 
    306   } 
    307  
    308  
    309   /** 
    310    * Return the last result set 
    311    * 
    312    * @return Result array or NULL if nothing selected yet 
    313    */ 
    314   function get_result() 
    315   { 
    316     return $this->result; 
    317   } 
    318    
    319    
    320   /** 
    321    * Get a specific contact record 
    322    * 
    323    * @param mixed record identifier 
    324    * @return Hash array with all record fields or False if not found 
    325    */ 
    326   function get_record($dn, $assoc=false) 
    327   { 
    328     $res = null; 
    329     if ($this->conn && $dn) 
    330     { 
    331       $this->ldap_result = @ldap_read($this->conn, base64_decode($dn), "(objectclass=*)", array_values($this->fieldmap)); 
    332       $entry = @ldap_first_entry($this->conn, $this->ldap_result); 
    333        
    334       if ($entry && ($rec = ldap_get_attributes($this->conn, $entry))) 
    335       { 
    336         $res = $this->_ldap2result($rec); 
    337         $this->result = new rcube_result_set(1); 
    338         $this->result->add($res); 
    339       } 
    340     } 
    341  
    342     return $assoc ? $res : $this->result; 
    343   } 
    344    
    345    
    346   /** 
    347    * Create a new contact record 
    348    * 
    349    * @param array Assoziative array with save data 
    350    * @return The create record ID on success, False on error 
    351    */ 
    352   function insert($save_cols) 
    353   { 
    354     // TODO 
    355     return false; 
    356   } 
    357    
    358    
    359   /** 
    360    * Update a specific contact record 
    361    * 
    362    * @param mixed Record identifier 
    363    * @param array Assoziative array with save data 
    364    * @return True on success, False on error 
    365    */ 
    366   function update($id, $save_cols) 
    367   { 
    368     // TODO     
    369     return false; 
    370   } 
    371    
    372    
    373   /** 
    374    * Mark one or more contact records as deleted 
    375    * 
    376    * @param array  Record identifiers 
    377    */ 
    378   function delete($ids) 
    379   { 
    380     // TODO 
    381     return false; 
    382   } 
    383  
    384  
    385   /** 
    386    * Execute the LDAP search based on the stored credentials 
    387    * 
    388    * @private 
    389    */ 
    390   function _exec_search() 
    391   { 
    392     if ($this->conn && $this->filter) 
    393     { 
    394       $function = $this->prop['scope'] == 'sub' ? 'ldap_search' : ($this->prop['scope'] == 'base' ? 'ldap_read' : 'ldap_list'); 
    395       $this->ldap_result = $function($this->conn, $this->prop['base_dn'], $this->filter, array_values($this->fieldmap), 0, 0); 
    396       return true; 
    397     } 
    398     else 
    399       return false; 
    400   } 
    401    
    402    
    403   /** 
    404    * @private 
    405    */ 
    406   function _ldap2result($rec) 
    407   { 
    408     $out = array(); 
    409      
    410     if ($rec['dn']) 
    411       $out[$this->primary_key] = base64_encode($rec['dn']); 
    412      
    413     foreach ($this->fieldmap as $rf => $lf) 
    414     { 
    415       if ($rec[$lf]['count']) 
    416         $out[$rf] = $rec[$lf][0]; 
    417     } 
    418      
    419     return $out; 
    420   } 
    421    
    422    
    423   /** 
    424    * @private 
    425    */ 
    426   function _map_field($field) 
    427   { 
    428     return $this->fieldmap[$field]; 
    429   } 
    430    
    431    
    432   /** 
    433    * @static 
    434    */ 
    435   function quote_string($str) 
    436   { 
    437     return strtr($str, array('*'=>'\2a', '('=>'\28', ')'=>'\29', '\\'=>'\5c')); 
    438   } 
    439  
    440  
     222    /** 
     223     * Search contacts 
     224     * 
     225     * @param array   List of fields to search in 
     226     * @param string  Search value 
     227     * @param boolean True if results are requested, False if count only 
     228     * @return array  Indexed list of contact records and 'count' value 
     229     */ 
     230    function search($fields, $value, $strict=false, $select=true) { 
     231        // special treatment for ID-based search 
     232        if ($fields == 'ID' || $fields == $this->primary_key) { 
     233            $ids = explode(',', $value); 
     234            $result = new rcube_result_set(); 
     235            foreach ($ids as $id) { 
     236                if ($rec = $this->get_record($id, true)) { 
     237                    $result->add($rec); 
     238                    $result->count++; 
     239                } 
     240            } 
     241            return $result; 
     242        } 
     243 
     244        $filter = '(|'; 
     245        $wc = !$strict && $this->prop['fuzzy_search'] ? '*' : ''; 
     246        if (is_array($this->prop['search_fields'])) { 
     247            foreach ($this->prop['search_fields'] as $k => $field) { 
     248                $filter .= "($field=$wc" . rcube_ldap::quote_string($value) . "$wc)"; 
     249            } 
     250        } else { 
     251            foreach ((array)$fields as $field) { 
     252                if ($f = $this->_map_field($field)) { 
     253                    $filter .= "($f=$wc" . rcube_ldap::quote_string($value) . "$wc)"; 
     254                } 
     255            } 
     256        } 
     257        $filter .= ')'; 
     258 
     259        // add general filter to query 
     260        if (!empty($this->prop['filter'])) { 
     261            $filter = '(&'.$this->prop['filter'] . $filter . ')'; 
     262        } 
     263 
     264        // set filter string and execute search 
     265        $this->set_search_set($filter); 
     266        $this->_exec_search(); 
     267 
     268        if ($select) { 
     269            $this->list_records(); 
     270        } else { 
     271            $this->result = $this->count(); 
     272        } 
     273 
     274        return $this->result; 
     275    } 
     276 
     277 
     278    /** 
     279     * Count number of available contacts in database 
     280     * 
     281     * @return object rcube_result_set Resultset with values for 'count' and 'first' 
     282     */ 
     283    function count() { 
     284        $count = 0; 
     285        if ($this->conn && $this->ldap_result) { 
     286            $count = ldap_count_entries($this->conn, $this->ldap_result); 
     287        } 
     288 
     289        return new rcube_result_set($count, ($this->list_page-1) * $this->page_size); 
     290    } 
     291 
     292 
     293    /** 
     294     * Return the last result set 
     295     * 
     296     * @return object rcube_result_set Current resultset or NULL if nothing selected yet 
     297     */ 
     298    function get_result() { 
     299        return $this->result; 
     300    } 
     301 
     302 
     303    /** 
     304     * Get a specific contact record 
     305     * 
     306         * @param mixed   Record identifier 
     307         * @param boolean Return as associative array 
     308         * @return mixed  Hash array or rcube_result_set with all record fields 
     309     */ 
     310    function get_record($dn, $assoc=false) { 
     311        $res = null; 
     312        if ($this->conn && $dn) { 
     313            $this->ldap_result = ldap_read($this->conn, base64_decode($dn), "(objectclass=*)", array_values($this->fieldmap)); 
     314            $entry = ldap_first_entry($this->conn, $this->ldap_result); 
     315 
     316            if ($entry && ($rec = ldap_get_attributes($this->conn, $entry))) { 
     317                $res = $this->_ldap2result($rec); 
     318                $this->result = new rcube_result_set(1); 
     319                $this->result->add($res); 
     320            } 
     321        } 
     322 
     323        return $assoc ? $res : $this->result; 
     324    } 
     325 
     326 
     327    /** 
     328     * Create a new contact record 
     329     * 
     330         * @param array    Hash array with save data 
     331         * @return boolean The create record ID on success, False on error 
     332     */ 
     333    function insert($save_cols) { 
     334        // TODO 
     335        return false; 
     336    } 
     337 
     338 
     339    /** 
     340     * Update a specific contact record 
     341     * 
     342     * @param mixed Record identifier 
     343         * @param array Hash array with save data 
     344         * @return boolean True on success, False on error 
     345     */ 
     346    function update($id, $save_cols) { 
     347        // TODO 
     348        return false; 
     349    } 
     350 
     351 
     352    /** 
     353     * Mark one or more contact records as deleted 
     354     * 
     355         * @return boolean True on success, False on error 
     356     */ 
     357    function delete($ids) { 
     358        // TODO 
     359        return false; 
     360    } 
     361 
     362 
     363    /** 
     364     * Execute the LDAP search based on the stored credentials 
     365     * 
     366     * @return boolean true on success, false on error 
     367     */ 
     368    private function _exec_search() { 
     369        if ($this->conn && $this->filter) { 
     370            $function = $this->prop['scope'] == 'sub' ? 'ldap_search' : ($this->prop['scope'] == 'base' ? 'ldap_read' : 'ldap_list'); 
     371            $this->ldap_result = $function($this->conn, $this->prop['base_dn'], $this->filter, array_values($this->fieldmap), 0, 0); 
     372            return true; 
     373        } else { 
     374            return false; 
     375        } 
     376    } 
     377 
     378 
     379    /** 
     380     * ldap2result 
     381     *  
     382     * @param array 
     383     * @return array 
     384     */ 
     385    private function _ldap2result($rec) { 
     386        $out = array(); 
     387 
     388        if ($rec['dn']) { 
     389            $out[$this->primary_key] = base64_encode($rec['dn']); 
     390        } 
     391 
     392        foreach ($this->fieldmap as $rf => $lf) { 
     393            if ($rec[$lf]['count']) { 
     394                $out[$rf] = $rec[$lf][0]; 
     395            } 
     396        } 
     397 
     398        return $out; 
     399    } 
     400 
     401 
     402    /** 
     403     * map field 
     404     * @param string field 
     405     * @return string returns mapped field 
     406     */ 
     407    private function _map_field($field) { 
     408        return $this->fieldmap[$field]; 
     409    } 
     410 
     411 
     412    /** 
     413     * translate char2hex 
     414     * @param string char 
     415     * @return string hex 
     416     */ 
     417    private static function quote_string($str) { 
     418        return strtr($str, array('*'=>'\2a', '('=>'\28', ')'=>'\29', '\\'=>'\5c')); 
     419    } 
    441420} 
    442421 
  • branches/devel-vnext/program/include/rcube_smtp.php

    r806 r957  
    66 |                                                                       | 
    77 | This file is part of the RoundCube Webmail client                     | 
    8  | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 | 
     8 | Copyright (C) 2006-2008, RoundCube Dev. - Switzerland                 | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
     
    7070    // create Net_SMTP object and connect to server 
    7171    if (!is_object($smtp_conn)) { 
    72         $helo_host = !empty($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost'; 
     72        $helo_host = empty($CONFIG['smtp_helo_host']) ? ((empty($_SERVER['SERVER_NAME']) ? 'localhost' : $_SERVER['SERVER_NAME'])) : $CONFIG['smtp_helo_host']; 
    7373        $SMTP_CONN = new Net_SMTP($smtp_host, $smtp_port, $helo_host); 
    7474 
  • branches/devel-vnext/program/include/rcube_sqlite.inc

    r806 r957  
    66 |                                                                       | 
    77 | This file is part of the RoundCube Webmail client                     | 
    8  | Copyright (C) 2005, RoundCube Dev. - Switzerland                      | 
     8 | Copyright (C) 2006-2008, RoundCube Dev. - Switzerland                 | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
     
    2222 
    2323 
    24 function rcube_sqlite_from_unixtime($timestamp) 
    25   { 
    26         $timestamp = trim($timestamp); 
    27         if (!preg_match("/^[0-9]+$/is", $timestamp)) 
    28           $ret = strtotime($timestamp); 
    29         else 
    30           $ret = $timestamp; 
    31            
    32         $ret = date("Y-m-d H:i:s", $ret); 
    33         rcube_sqlite_debug("FROM_UNIXTIME ($timestamp) = $ret"); 
    34         return $ret; 
    35   } 
     24function rcube_sqlite_from_unixtime($timestamp) { 
     25    $timestamp = trim($timestamp); 
     26    if (!preg_match('/^[0-9]+$/is', $timestamp)) { 
     27        $ret = strtotime($timestamp); 
     28    } else { 
     29        $ret = $timestamp; 
     30    } 
     31    $ret = date('Y-m-d H:i:s', $ret); 
     32    rcube_sqlite_debug("FROM_UNIXTIME ($timestamp) = $ret"); 
     33    return $ret; 
     34} 
    3635 
    3736 
    38 function rcube_sqlite_unix_timestamp($timestamp="") 
    39   { 
    40         $timestamp = trim($timestamp); 
    41         if (!$timestamp) 
    42           $ret = time(); 
    43         else if (!preg_match("/^[0-9]+$/is", $timestamp)) 
    44           $ret = strtotime($timestamp); 
    45         else 
    46           $ret = $timestamp; 
     37function rcube_sqlite_unix_timestamp($timestamp = '') { 
     38    $timestamp = trim($timestamp); 
     39    if (!$timestamp) { 
     40        $ret = time(); 
     41    } else if (!preg_match('/^[0-9]+$/is', $timestamp)) { 
     42        $ret = strtotime($timestamp); 
     43    } else { 
     44        $ret = $timestamp; 
     45    } 
    4746 
    48         rcube_sqlite_debug("UNIX_TIMESTAMP ($timestamp) = $ret"); 
    49         return $ret; 
    50   } 
     47    rcube_sqlite_debug("UNIX_TIMESTAMP ($timestamp) = $ret"); 
     48    return $ret; 
     49} 
    5150 
    5251 
    53 function rcube_sqlite_now() 
    54   { 
    55         rcube_sqlite_debug("NOW() = ".date("Y-m-d H:i:s")); 
    56         return date("Y-m-d H:i:s"); 
    57   } 
     52function rcube_sqlite_now() { 
     53    rcube_sqlite_debug("NOW() = ".date('Y-m-d H:i:s')); 
     54    return date('Y-m-d H:i:s'); 
     55} 
    5856 
    5957 
    60 function rcube_sqlite_md5($str) 
    61   { 
    62         return md5($str); 
    63   } 
     58function rcube_sqlite_md5($str) { 
     59    return md5($str); 
     60} 
    6461 
    6562 
    66 function rcube_sqlite_debug($str) 
    67   { 
     63function rcube_sqlite_debug($str) { 
    6864        //rcube::console($str); 
    69   } 
     65} 
    7066         
    7167?> 
  • branches/devel-vnext/program/include/rcube_template.php

    r953 r957  
    66 |                                                                       | 
    77 | This file is part of the RoundCube Webmail client                     | 
    8  | Copyright (C) 2007, RoundCube Dev. - Switzerland                      | 
     8 | Copyright (C) 2006-2008, RoundCube Dev. - Switzerland                 | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
     
    1717 +-----------------------------------------------------------------------+ 
    1818 
    19  $Id$ 
    20  
    21 */ 
     19 $Id$ 
     20 
     21 */ 
    2222 
    2323 
     
    4848     * @todo   Use jQuery's $(document).ready() here. 
    4949     */ 
    50     public function __construct() 
    51     { 
     50    public function __construct() { 
    5251        parent::__construct(); 
    53          
     52 
    5453        $registry     = rcube_registry::get_instance(); 
    5554        $this->task   = $registry->get('task', 'core'); 
    5655        $this->config = $registry->get_all('config'); 
    57          
     56 
    5857        // add common javascripts 
    59         $javascript = "var ".JS_OBJECT_NAME." = new rcube_webmail();"; 
     58        $javascript = 'var '.JS_OBJECT_NAME.' = new rcube_webmail();'; 
    6059 
    6160        // don't wait for page onload. Call init at the bottom of the page (delayed) 
     
    6867        $this->include_script('common.js'); 
    6968        $this->include_script('app.js'); 
    70          
     69 
    7170        // register common UI objects 
    7271        $this->add_handlers(array( 
     
    8584     * @param boolean True if this property should be added to client environment 
    8685     */ 
    87     public function set_env($name, $value, $addtojs=true) 
    88     { 
     86    public function set_env($name, $value, $addtojs = true) { 
    8987        $this->env[$name] = $value; 
    9088        if ($addtojs || isset($this->js_env[$name])) { 
     
    9795     * Set page title variable 
    9896     */ 
    99     public function set_pagetitle($title) 
    100     { 
     97    public function set_pagetitle($title) { 
    10198        $this->pagetitle = $title; 
    10299    } 
     
    110107     * @return void 
    111108     */ 
    112     public function add_handler($obj, $func) 
    113     { 
     109    public function add_handler($obj, $func) { 
    114110        $this->object_handlers[$obj] = $func; 
    115111    } 
     
    121117     * @return void 
    122118     */ 
    123     public function add_handlers($arr) 
    124     { 
     119    public function add_handlers($arr) { 
    125120        $this->object_handlers = array_merge($this->object_handlers, $arr); 
    126121    } 
     
    133128     * @return void 
    134129     */ 
    135     public function add_gui_object($obj, $id) 
    136     { 
     130    public function add_gui_object($obj, $id) { 
    137131        $this->add_script(JS_OBJECT_NAME.".gui_object('$obj', '$id');"); 
    138132    } 
     
    144138     * @param ... Additional arguments 
    145139     */ 
    146     public function command() 
    147     { 
     140    public function command() { 
    148141        $this->js_commands[] = func_get_args(); 
    149142    } 
    150      
    151      
     143 
     144 
    152145    /** 
    153146     * Add a localized label to the client environment 
    154147     */ 
    155     public function add_label() 
    156     { 
     148    public function add_label() { 
    157149        $arg_list = func_get_args(); 
    158150        foreach ($arg_list as $i => $name) { 
     
    160152        } 
    161153    } 
    162      
     154 
    163155 
    164156    /** 
     
    170162     * @uses self::command() 
    171163     */ 
    172     public function show_message($message, $type='notice', $vars=NULL) 
    173     { 
     164    public function show_message($message, $type='notice', $vars=NULL) { 
    174165        $this->command( 
    175166                'display_message', 
    176                 rcube::gettext(array('name' => $message, 'vars' => $vars)), 
    177                 $type 
     167        rcube::gettext(array('name' => $message, 'vars' => $vars)), 
     168        $type 
    178169        ); 
    179170    } 
     
    190181     * @uses   self::$object_handlers 
    191182     */ 
    192     public public function reset() 
    193     { 
     183    public public function reset() { 
    194184        $this->env = array(); 
    195185        $this->js_env = array(); 
     
    207197     * @param boolean True if script should terminate (default) 
    208198     */ 
    209     public function send($templ=null, $exit=true) 
    210     { 
     199    public function send($templ = null, $exit = true) { 
    211200        if ($templ != 'iframe') { 
    212201            //rcube::tfk_debug("/Parsing $templ"); 
    213202            $this->parse($templ, false); 
    214         } 
    215         else { 
     203        } else { 
    216204            $this->framed = $templ == 'iframe' ? true : $this->framed; 
    217205            $this->write(); 
     
    230218     * @override 
    231219     */ 
    232     public function write($template='') 
    233     { 
     220    public function write($template = '') { 
     221        // unlock interface after iframe load 
     222        if ($this->framed) { 
     223            array_unshift($this->js_commands, array('set_busy', false)); 
     224        } 
    234225        // write all env variables to client 
    235226        $js = $this->framed ? "if(window.parent) {\n" : ''; 
     
    251242     * @link   http://php.net/manual/en/function.exit.php 
    252243     */ 
    253     private function parse($name='main', $exit=true) 
    254     { 
     244    private function parse($name = 'main', $exit = true) { 
    255245        $skin_path = $this->config['skin_path']; 
    256246 
     
    261251        $path = "$skin_path/templates/$name.html"; 
    262252 
    263         if(($fp = @fopen($path, 'r')) === false) { 
     253        if (($fp = fopen($path, 'r')) === false) { 
    264254            $message = ''; 
    265255            ob_start(); 
     
    268258            ob_end_clean(); 
    269259            rcube_error::raise( 
    270                 array( 
    271                     'code' => 501, 
    272                     'type' => 'php', 
    273                     'line' => __LINE__, 
    274                     'file' => __FILE__, 
    275                     'message' => "Error loading template for '$name': $message" 
    276                 ), 
    277                 TRUE, 
    278                 TRUE 
     260            array( 
     261                        'code' => 501, 
     262                        'type' => 'php', 
     263                        'line' => __LINE__, 
     264                        'file' => __FILE__, 
     265                        'message' => 'Error loading template for '.$name.': '.$message 
     266            ), 
     267            TRUE, 
     268            TRUE 
    279269            ); 
    280270            return FALSE; 
    281271        } 
    282272        $templ = fread($fp, filesize($path)); 
    283         @fclose($fp); 
     273        fclose($fp); 
    284274 
    285275        //rcube::tfk_debug("// parsed: $path"); 
     
    294284                            <a href="#toggle" onclick="con=document.getElementById(\'dbgconsole\');con.style.display=(con.style.display==\'none\'?\'block\':\'none\');return false">console</a> 
    295285                            <form action="/" name="debugform"><textarea name="console" id="dbgconsole" rows="20" cols="40" wrap="off" style="display:none;width:400px;border:none;font-size:x-small"></textarea></form></div>' 
    296             ); 
     286                            ); 
    297287        } 
    298288        $output = $this->parse_with_globals($output); 
     
    309299     * @return string $out 
    310300     */ 
    311     private function get_js_commands() 
    312     { 
     301    private function get_js_commands() { 
    313302        $out = ''; 
    314303        if (!$this->framed && !empty($this->js_env)) { 
     
    323312            $out .= sprintf( 
    324313                "%s.%s(%s);\n", 
    325                 ($parent ? 'parent.' : '') . JS_OBJECT_NAME, 
    326                 preg_replace('/^parent\./', '', $method), 
    327                 implode(',', $args) 
     314            ($parent ? 'parent.' : '') . JS_OBJECT_NAME, 
     315            preg_replace('/^parent\./', '', $method), 
     316            implode(',', $args) 
     317            ); 
     318        } 
     319        // add command to set page title 
     320        if ($this->ajax_call && !empty($this->pagetitle)) { 
     321            $out .= sprintf( 
     322                                "this.set_pagetitle('%s');\n", 
     323            JQ((!empty($this->config['product_name']) ? $this->config['product_name'].' :: ' : '') . $this->pagetitle) 
    328324            ); 
    329325        } 
     
    338334     * @return string 
    339335     */ 
    340     public function abs_url($str) 
    341     { 
     336    private function abs_url($str) { 
    342337        return preg_replace('/^\//', $this->config['skin_path'].'/', $str); 
    343338    } 
    344339 
    345  
    346  
    347340    /*****  Template parsing methods  *****/ 
    348341 
    349342    /** 
    350      * Replace all strings ($varname) with the content 
    351      * of the according global variable. 
    352      */ 
    353     private function parse_with_globals($input) 
    354     { 
     343     * Replace all strings ($varname) 
     344     * with the content of the according global variable. 
     345     */ 
     346    private function parse_with_globals($input) { 
    355347        $registry  = rcube_registry::get_instance(); 
    356348        $COMM_PATH = $registry->get('COMM_PATH', 'core'); 
    357349 
    358         $GLOBALS['__comm_path'] = $COMM_PATH; 
     350        $GLOBALS['__comm_path'] = urlencode($COMM_PATH); 
    359351        return preg_replace('/\$(__[a-z0-9_\-]+)/e', '$GLOBALS["\\1"]', $input); 
    360352    } 
     
    368360     * @since  0.1-rc1 
    369361     */ 
    370     public function just_parse($input) 
    371     { 
     362    public function just_parse($input) { 
    372363        return $this->parse_xml($input); 
    373364    } 
     
    379370     * @return string 
    380371     */ 
    381     private function parse_conditions($input) 
    382     { 
     372    private function parse_conditions($input) { 
    383373        $matches = preg_split( 
    384374                        '/<roundcube:(if|elseif|else|endif)\s+([^>]+)>/is', 
    385                         $input, 
    386                         2, 
    387                         PREG_SPLIT_DELIM_CAPTURE 
     375        $input, 
     376        2, 
     377        PREG_SPLIT_DELIM_CAPTURE 
    388378        ); 
    389         if ($matches && count($matches)==4) { 
     379        if ($matches && count($matches) == 4) { 
    390380            if (preg_match('/^(else|endif)$/i', $matches[1])) { 
    391381                return $matches[0] . $this->parse_conditions($matches[3]); 
     
    396386                $submatches = preg_split( 
    397387                                '/<roundcube:(elseif|else|endif)\s+([^>]+)>/is', 
    398                                 $matches[3], 
    399                                 2, 
    400                                 PREG_SPLIT_DELIM_CAPTURE 
     388                $matches[3], 
     389                2, 
     390                PREG_SPLIT_DELIM_CAPTURE 
    401391                ); 
    402392                if ($condmet) { 
    403393                    $result = $submatches[0]; 
    404394                    $result.= ($submatches[1] != 'endif' ? preg_replace('/.*<roundcube:endif\s+[^>]+>/Uis', '', $submatches[3], 1) : $submatches[3]); 
    405                 } 
    406                 else { 
     395                } else { 
    407396                    $result = "<roundcube:$submatches[1] $submatches[2]>" . $submatches[3]; 
    408397                } 
     
    410399            } 
    411400            rcube_error::raise( 
    412                 array( 
     401            array( 
    413402                    'code' => 500, 
    414403                    'type' => 'php', 
     
    416405                    'file' => __FILE__, 
    417406                    'message' => "Unable to parse conditional tag " . $matches[2] 
    418                 ), 
    419                 TRUE, 
    420                 FALSE 
     407            ), 
     408            TRUE, 
     409            FALSE 
    421410            ); 
    422411        } 
     
    433422     * @return boolean True if condition is met, False is not 
    434423     */ 
    435     private function check_condition($condition) 
    436     { 
     424    private function check_condition($condition) { 
    437425        $condition = preg_replace( 
    438                 array( 
     426        array( 
    439427                    '/session:([a-z0-9_]+)/i', 
    440428                    '/config:([a-z0-9_]+)/i', 
    441429                    '/env:([a-z0-9_]+)/i', 
    442430                    '/request:([a-z0-9_]+)/ie' 
    443                 ), 
    444                 array( 
     431                    ), 
     432                    array( 
    445433                    "\$_SESSION['\\1']", 
    446434                    "\$this->config['\\1']", 
    447435                    "\$this->env['\\1']", 
    448436                    "rcube::get_input_value('\\1', rcube::INPUT_GPC)" 
    449                 ), 
    450                 $condition 
    451         ); 
    452         return @eval("return (".$condition.");"); 
    453     } 
    454  
    455  
    456    /** 
    457     * Search for special tags in input and replace them 
    458     * with the appropriate content 
    459     * 
    460     * @param  string Input string to parse 
    461     * @return string Altered input string 
    462     * @todo   Maybe a cache. 
    463     */ 
    464    private function parse_xml($input) 
    465    { 
     437                    ), 
     438                    $condition 
     439                    ); 
     440                    return eval("return (".$condition.");"); 
     441    } 
     442 
     443 
     444    /** 
     445     * Search for special tags in input and replace them 
     446     * with the appropriate content 
     447     * 
     448     * @param  string Input string to parse 
     449     * @return string Altered input string 
     450     * @todo   Maybe a cache. 
     451     */ 
     452    private function parse_xml($input) { 
    466453        return preg_replace('/<roundcube:([-_a-z]+)\s+([^>]+)>/Uie', "\$this->xml_command('\\1', '\\2')", $input); 
    467    } 
     454    } 
    468455 
    469456 
     
    475462     * @return string Tag/Object content 
    476463     */ 
    477     private function xml_command($command, $str_attrib, $add_attrib=array()) 
    478     { 
     464    private function xml_command($command, $str_attrib, $add_attrib = array()) { 
    479465        $command = strtolower($command); 
    480466        $attrib  = rcube::parse_attrib_string($str_attrib) + $add_attrib; 
     
    499485                break; 
    500486 
    501             // show a label 
     487                // show a label 
    502488            case 'label': 
    503489                if ($attrib['name'] || $attrib['command']) { 
     
    506492                break; 
    507493 
    508             // include a file 
     494                // include a file 
    509495            case 'include': 
    510496                $path = realpath($this->config['skin_path'].$attrib['file']); 
     
    516502                    return $this->parse_xml(''); 
    517503                } 
    518                 if ($fp = @fopen($path, 'r')) { 
     504                if ($this->config['skin_include_php']) { 
     505                    $incl = $this->include_php($path); 
     506                } else if ($fp = fopen($path, 'r')) { 
    519507                    $incl = fread($fp, $tpl_filesize); 
    520508                    fclose($fp); 
    521                     return $this->parse_xml($incl); 
    522                 } 
     509                } 
     510                return $this->parse_xml($incl); 
    523511                break; 
    524512 
     
    540528                break; 
    541529 
    542             // return code for a specific application object 
     530                // return code for a specific application object 
    543531            case 'object': 
    544532                $object = strtolower($attrib['name']); 
     
    547535                if (($handler = $this->object_handlers[$object]) && is_array($handler)) { 
    548536                    if ((is_object($handler[0]) && method_exists($handler[0], $handler[1])) || 
    549                         (is_string($handler[0]) && class_exists($handler[0]))) 
    550                             return call_user_func($handler, $attrib); 
    551                 } 
    552                 // execute object handler function 
    553                 else if (function_exists($handler)) 
     537                    (is_string($handler[0]) && class_exists($handler[0]))) 
    554538                    return call_user_func($handler, $attrib); 
     539                } else if (function_exists($handler)) { 
     540                    // execute object handler function 
     541                    return call_user_func($handler, $attrib); 
     542                } 
    555543 
    556544                if ($object=='productname') { 
     
    565553                    $title = !empty($this->config['product_name']) ? $this->config['product_name'].' :: ' : ''; 
    566554 
    567                     if (!empty($this->pagetitle)) 
     555                    if (!empty($this->pagetitle)) { 
    568556                        $title .= $this->pagetitle; 
    569                     else if ($task == 'login') 
     557                    } else if ($task == 'login') { 
    570558                        $title = rcube::gettext(array('name' => 'welcome', 'vars' => array('product' => $this->config['product_name']))); 
    571                     else 
     559                    } else { 
    572560                        $title .= ucfirst($task); 
     561                    } 
    573562 
    574563                    return Q($title); 
    575564                } 
    576565                break; 
     566                // return variable 
     567            case 'var': 
     568                $var = explode(':', $attrib['name']); 
     569                $name = $var[1]; 
     570                $value = ''; 
     571 
     572                switch ($var[0]) { 
     573                    case 'env': 
     574                        $value = $this->env[$name]; 
     575                        break; 
     576                    case 'config': 
     577                        $value = $this->config[$name]; 
     578                        if (is_array($value) && $value[$_SESSION['imap_host']]) { 
     579                            $value = $value[$_SESSION['imap_host']]; 
     580                        } 
     581                        break; 
     582                    case 'request': 
     583                        $value = get_input_value($name, RCUBE_INPUT_GPC); 
     584                        break; 
     585                    case 'session': 
     586                        $value = $_SESSION[$name]; 
     587                        break; 
     588                } 
     589 
     590                if (is_array($value)) { 
     591                    $value = implode(', ', $value); 
     592                } 
     593 
     594                return Q($value); 
     595                break; 
    577596        } 
    578597        return ''; 
     598    } 
     599 
     600    /** 
     601     * Include a specific file and return it's contents 
     602     * 
     603     * @param string File path 
     604     * @return string Contents of the processed file 
     605     */ 
     606    private function include_php($file) { 
     607        ob_start(); 
     608        // TODO i'm not sure but i think this can be require_once 
     609        include $file; 
     610        $out = ob_get_contents(); 
     611        ob_end_clean(); 
     612 
     613        return $out; 
    579614    } 
    580615 
     
    588623     * @todo   Remove all sprintf()'s - they are pretty, but also slow. 
    589624     */ 
    590     public function button($attrib) 
    591     { 
     625    private function button($attrib) { 
    592626        static $sa_buttons = array(); 
    593627        static $s_button_count = 100; 
    594          
     628 
    595629        $browser    = new rcube_browser(); 
    596630        $MAIN_TASKS = rcube_registry::get_instance()->get('MAIN_TASKS', 'core'); 
     
    608642        if ($attrib['type']) { 
    609643            $attrib['type'] = strtolower($attrib['type']); 
    610         } 
    611         else { 
     644        } else { 
    612645            $attrib['type'] = ($attrib['image'] || $attrib['imagepas'] || $attrib['imageact']) ? 'image' : 'link'; 
    613646        } 
     
    615648 
    616649        // take the button from the stack 
    617         if($attrib['name'] && $sa_buttons[$attrib['name']]) { 
     650        if ($attrib['name'] && $sa_buttons[$attrib['name']]) { 
    618651            $attrib = $sa_buttons[$attrib['name']]; 
    619         } 
    620         // add button to button stack 
    621         else if($attrib['image'] || $attrib['imageact'] || $attrib['imagepas'] || $attrib['class']) 
    622         { 
     652        } else if($attrib['image'] || $attrib['imageact'] || $attrib['imagepas'] || $attrib['class']) { 
     653            // add button to button stack 
    623654            if (!$attrib['name']) { 
    624655                $attrib['name'] = $command; 
     
    628659            } 
    629660            $sa_buttons[$attrib['name']] = $attrib; 
    630         } 
    631  
    632         // get saved button for this command/name 
    633         else if ($command && $sa_buttons[$command]) { 
     661        } else if ($command && $sa_buttons[$command]) { 
     662            // get saved button for this command/name 
    634663            $attrib = $sa_buttons[$command]; 
    635664        } 
    636         //else 
    637         //  return ''; 
    638  
    639665 
    640666        // set border to 0 because of the link arround the button 
     
    667693 
    668694        // register button in the system 
    669         if ($attrib['command']) 
    670         { 
     695        if ($attrib['command']) { 
    671696            $this->add_script( 
    672                 sprintf( 
     697            sprintf( 
    673698                    "%s.register_button('%s', '%s', '%s', '%s', '%s', '%s');", 
    674                     JS_OBJECT_NAME, 
    675                     $command, 
    676                     $attrib['id'], 
    677                     $attrib['type'], 
    678                     $attrib['imageact'] ? $skin_path.$attrib['imageact'] : $attrib['classact'], 
    679                     $attrib['imagesel'] ? $skin_path.$attrib['imagesel'] : $attrib['classsel'], 
    680                     $attrib['imageover'] ? $skin_path.$attrib['imageover'] : '' 
    681                 ) 
     699            JS_OBJECT_NAME, 
     700            $command, 
     701            $attrib['id'], 
     702            $attrib['type'], 
     703            $attrib['imageact'] ? $skin_path.$attrib['imageact'] : $attrib['classact'], 
     704            $attrib['imagesel'] ? $skin_path.$attrib['imagesel'] : $attrib['classsel'], 
     705            $attrib['imageover'] ? $skin_path.$attrib['imageover'] : '' 
     706            ) 
    682707            ); 
    683708 
     
    685710            if (in_array($attrib['command'], $MAIN_TASKS)) { 
    686711                $attrib['href'] = Q(rcube::url(null, null, $attrib['command'])); 
    687             } 
    688             else if (in_array($attrib['command'], $a_static_commands)) { 
     712            } else if (in_array($attrib['command'], $a_static_commands)) { 
    689713                $attrib['href'] = Q(rcube::url($attrib['command'])); 
    690714            } 
     
    698722            $attrib['onclick'] = sprintf( 
    699723                "return %s.command('%s','%s',this)", 
    700                 JS_OBJECT_NAME, 
    701                 $command, 
    702                 $attrib['prop'] 
     724            JS_OBJECT_NAME, 
     725            $command, 
     726            $attrib['prop'] 
    703727            ); 
    704728        } 
     
    706730            $attrib['onmouseover'] = sprintf( 
    707731                "return %s.button_over('%s','%s')", 
    708                 JS_OBJECT_NAME, 
    709                 $command, 
    710                 $attrib['id'] 
     732            JS_OBJECT_NAME, 
     733            $command, 
     734            $attrib['id'] 
    711735            ); 
    712736            $attrib['onmouseout'] = sprintf( 
    713737                "return %s.button_out('%s','%s')", 
    714                 JS_OBJECT_NAME, 
    715                 $command, 
    716                 $attrib['id'] 
     738            JS_OBJECT_NAME, 
     739            $command, 
     740            $attrib['id'] 
    717741            ); 
    718742        } 
     
    721745            $attrib['onmousedown'] = sprintf( 
    722746                "return %s.button_sel('%s','%s')", 
    723                 JS_OBJECT_NAME, 
    724                 $command, 
    725                 $attrib['id'] 
     747            JS_OBJECT_NAME, 
     748            $command, 
     749            $attrib['id'] 
    726750            ); 
    727751            $attrib['onmouseup'] = sprintf( 
    728752                "return %s.button_out('%s','%s')", 
    729                 JS_OBJECT_NAME, 
    730                 $command, 
    731                 $attrib['id'] 
     753            JS_OBJECT_NAME, 
     754            $command, 
     755            $attrib['id'] 
    732756            ); 
    733757        } 
     
    738762        if ($attrib['type']=='image') { 
    739763            $attrib_str = rcube::create_attrib_string( 
    740                 $attrib, 
    741                 array( 
     764            $attrib, 
     765            array( 
    742766                    'style', 'class', 'id', 'width', 
    743767                    'height', 'border', 'hspace', 
    744768                    'vspace', 'align', 'alt', 
    745                 ) 
     769            ) 
    746770            ); 
    747771            $img_tag = sprintf('<img src="%%s"%s />', $attrib_str); 
     
    751775            } 
    752776            $link_attrib = array('href', 'onclick', 'onmouseover', 'onmouseout', 'onmousedown', 'onmouseup', 'title'); 
    753         } 
    754         else if ($attrib['type']=='link') { 
     777        } else if ($attrib['type']=='link') { 
    755778            $btn_content = $attrib['label'] ? $attrib['label'] : $attrib['command']; 
    756779            $link_attrib = array('href', 'onclick', 'title', 'id', 'class', 'style'); 
    757         } 
    758         else if ($attrib['type']=='input') { 
     780        } else if ($attrib['type']=='input') { 
    759781            $attrib['type'] = 'button'; 
    760782 
    761             if ($attrib['label']) 
     783            if ($attrib['label']) { 
    762784                $attrib['value'] = $attrib['label']; 
     785            } 
    763786 
    764787            $attrib_str = rcube::create_attrib_string( 
    765                 $attrib, 
    766                 array( 
     788            $attrib, 
     789            array( 
    767790                    'type', 'value', 'onclick', 
    768791                    'id', 'class', 'style' 
    769                 ) 
    770             ); 
    771             $out = sprintf('<input%s disabled="disabled" />', $attrib_str); 
     792                    ) 
     793                    ); 
     794                    $out = sprintf('<input%s disabled="disabled" />', $attrib_str); 
    772795        } 
    773796 
     
    780803        return $out; 
    781804    } 
    782      
    783      
     805 
     806 
    784807    /*  ************* common functions delivering gui objects **************  */ 
    785      
    786      
     808 
     809 
    787810    /** 
    788811     * GUI object 'username' 
     
    809832        $_query.= " AND del<>1"; 
    810833        $sql_result = $DB->query( 
    811                             $_query, 
    812                             $_SESSION['user_id'] 
     834        $_query, 
     835        $_SESSION['user_id'] 
    813836        ); 
    814837 
     
    823846            $username = $_SESSION['username'].'@'.$_SESSION['imap_host']; 
    824847        } 
    825          
     848 
    826849        $registry->set('username', $username, 'core'); 
    827850        return $username; 
     
    867890        $form_name  = !empty($attrib['form']) ? $attrib['form'] : 'form'; 
    868891        $this->add_gui_object('loginform', $form_name); 
    869          
     892 
    870893        // create HTML table with two cols 
    871894        $table = new html_table(array('cols' => 2)); 
    872          
     895 
    873896        $table->add('title', html::label('rcmloginuser', Q(rcube::gettext('username')))); 
    874897        $table->add(null, $input_user->show(rcube::get_input_value('_user', rcube::INPUT_POST))); 
     
    876899        $table->add('title', html::label('rcmloginpwd', Q(rcube::gettext('password')))); 
    877900        $table->add(null, $input_pass->show()); 
    878          
     901 
    879902        // add host selection row 
    880903        if (is_object($input_host)) { 
     
    886909        $out .= $input_action->show(); 
    887910        $out .= $table->show(); 
    888          
     911 
    889912        if (empty($attrib['form'])) 
    890             $out = html::tag( 
     913        $out = html::tag( 
    891914                'form', 
    892                 array( 
     915        array( 
    893916                    'name' => $form_name, 
    894917                    'action' => $registry->get('BASE_URI', $BASE_URI), 
    895918                    'method' => "post" 
    896                 ), 
    897                 $out); 
    898  
    899         return $out; 
     919                    ), 
     920                    $out); 
     921 
     922                    return $out; 
    900923    } 
    901924 
     
    933956                    'onsubmit' => JS_OBJECT_NAME . ".command('search');return false;", 
    934957                    'style' => "display:inline", 
    935                 ), 
    936                 $out 
    937             ); 
    938         } 
    939          
     958            ), 
     959            $out 
     960            ); 
     961        } 
     962 
    940963        return $out; 
    941964    } 
     
    9911014            'Windows-1257' => 'Windows-1257 (Baltic)', 
    9921015            'UTF-8'        => 'UTF-8' 
    993         ); 
    994  
    995         $select = new html_select($field_attrib); 
    996         $select->add(array_values($charsets), array_keys($charsets)); 
    997  
    998         $set = $_POST['_charset'] ? $_POST['_charset'] : $this->get_charset(); 
    999         return $select->show($set); 
     1016            ); 
     1017 
     1018            $select = new html_select($field_attrib); 
     1019            $select->add(array_values($charsets), array_keys($charsets)); 
     1020 
     1021            $set = $_POST['_charset'] ? $_POST['_charset'] : $this->get_charset(); 
     1022            return $select->show($set); 
    10001023    } 
    10011024 
  • branches/devel-vnext/program/include/session.inc

    r806 r957  
    66 |                                                                       | 
    77 | This file is part of the RoundCube Webmail client                     | 
    8  | Copyright (C) 2005-2007, RoundCube Dev, - Switzerland                 | 
     8 | Copyright (C) 2006-2008, RoundCube Dev. - Switzerland                 | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
     
    2121 
    2222 
    23 function sess_open($save_path, $session_name) 
    24 { 
     23function sess_open($save_path, $session_name) { 
    2524    return true; 
    2625} 
    2726 
    2827 
    29 function sess_close() 
    30 { 
     28function sess_close() { 
    3129    return true; 
    3230} 
     
    3432 
    3533// read session data 
    36 function sess_read($key) 
    37 { 
     34function sess_read($key) { 
    3835    $registry       = rcube_registry::get_instance(); 
    3936    $DB             = $registry->get('DB', 'core'); 
     
    6663 
    6764// save session data 
    68 function sess_write($key, $vars) 
    69 { 
     65function sess_write($key, $vars) { 
    7066    $DB = rcube_registry::get_instance()->get('DB', 'core'); 
    7167 
    72     if (!is_object($DB) || $DB->is_error()) 
     68    if (!is_object($DB) || $DB->is_error()) { 
    7369        return false; 
     70    } 
    7471 
    7572    $sql_result = $DB->query( 
     
    8885            $vars, 
    8986            $key); 
    90     } 
    91     else { 
     87    } else { 
    9288        $DB->query( 
    9389            "INSERT INTO " . rcube::get_table_name('session') . " 
     
    104100 
    105101// handler for session_destroy() 
    106 function sess_destroy($key) 
    107 { 
     102function sess_destroy($key) { 
    108103    $DB = rcube_registry::get_instance()->get('DB', 'core'); 
    109104 
     
    127122 
    128123// garbage collecting function 
    129 function sess_gc($maxlifetime) 
    130 { 
     124function sess_gc($maxlifetime) { 
    131125    $DB = rcube_registry::get_instance()->get('DB', 'core'); 
    132126 
     
    165159 
    166160 
    167 function sess_regenerate_id() 
    168 { 
     161function sess_regenerate_id() { 
    169162    $randlen = 32; 
    170163    $randval = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
     
    183176    $cookie = session_get_cookie_params(); 
    184177    setcookie(session_name(), $random, $cookie['lifetime'], $cookie['path']); 
     178    setcookie(session_name(), '', time() - 3600); 
     179    setcookie(session_name(), $random, $cookie['lifetime'] ? time() + $cookie['lifetime'] : 0, $cookie['path']); 
    185180 
    186181    return true; 
Note: See TracChangeset for help on using the changeset viewer.