From: Marc G. K. <st...@us...> - 2006-04-05 00:22:44
|
Update of /cvsroot/squirrelmail/squirrelmail/plugins/filters In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15615/plugins/filters Modified Files: filters.php options.php setup.php spamoptions.php Log Message: Centralized init Index: filters.php =================================================================== RCS file: /cvsroot/squirrelmail/squirrelmail/plugins/filters/filters.php,v retrieving revision 1.85 retrieving revision 1.86 diff -u -w -r1.85 -r1.86 --- filters.php 26 Feb 2006 14:51:00 -0000 1.85 +++ filters.php 5 Apr 2006 00:22:05 -0000 1.86 @@ -10,8 +10,14 @@ * @subpackage filters */ -/** @ignore */ -if (! defined('SM_PATH')) define('SM_PATH','../../'); +/** + * do not allow to call this file directly + */ +if ((isset($_SERVER) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) || + (isset($HTTP_SERVER_SERVER) && $HTTP_SERVER_SERVER['SCRIPT_FILENAME'] == __FILE__) ) { + header("Location: ../../src/login.php"); + die(); +} /** load globals */ global $UseSeparateImapConnection, @@ -41,6 +47,28 @@ } /** + * Init Hooks + * @access private + */ +function filters_init_hooks () { + global $squirrelmail_plugin_hooks; + + if (! sqgetGlobalVar('mailbox',$mailbox,SQ_FORM)) { + $mailbox = 'INBOX'; + } + + $squirrelmail_plugin_hooks['left_main_before']['filters'] = 'start_filters_hook'; + if (isset($mailbox) && $mailbox == 'INBOX') { + $squirrelmail_plugin_hooks['right_main_after_header']['filters'] = 'start_filters_hook'; + } + $squirrelmail_plugin_hooks['optpage_register_block']['filters'] = 'filters_optpage_register_block_hook'; + $squirrelmail_plugin_hooks['special_mailbox']['filters'] = 'filters_special_mailbox'; + $squirrelmail_plugin_hooks['rename_or_delete_folder']['filters'] = 'update_for_folder_hook'; + $squirrelmail_plugin_hooks['webmail_bottom']['filters'] = 'start_filters_hook'; + $squirrelmail_plugin_hooks['folder_status']['filters'] = 'filters_folder_status'; +} + +/** * Register option blocks * @access private */ @@ -70,6 +98,10 @@ global $filter_inbox_count; if (empty($filter_inbox_count)) $filter_inbox_count=0; + //echo "GOT HOOK<br><pre>"; + //var_dump($statusarr); + //echo "</pre><br>\n"; + if ($statusarr['MAILBOX'] == 'INBOX') { if (!empty($statusarr['MESSAGES'])) $filter_inbox_count=$statusarr['MESSAGES']; @@ -174,26 +206,15 @@ /** * Starts the filtering process - * @param array $hook_args (since 1.5.2) do hook arguments. Is used to check - * hook name, array key = 0. * @access private */ -function start_filters($hook_args) { +function start_filters() { global $imapServerAddress, $imapPort, $imap_stream, $imapConnection, $UseSeparateImapConnection, $AllowSpamFilters, $filter_inbox_count; sqgetGlobalVar('username', $username, SQ_SESSION); sqgetGlobalVar('key', $key, SQ_COOKIE); - /** - * check hook that calls filtering. If filters are called by right_main_after_header, - * do filtering only when we are in INBOX folder. - */ - if ($hook_args[0]=='right_main_after_header' && - (sqgetGlobalVar('mailbox',$mailbox,SQ_FORM) && $mailbox!='INBOX')) { - return; - } - $filters = load_filters(); // No point running spam filters if there aren't any to run // @@ -349,6 +370,7 @@ /* read data back from IMAP */ $read = sqimap_run_command($imap_stream, $search_str, true, $response, $message, TRUE); } else { + // TODO BADCHARSET $search_str .= ' ' . $where . ' {' . strlen($what) . "}"; $sid = sqimap_session_id(true); fputs ($imap_stream, $sid . ' ' . $search_str . "\r\n"); Index: options.php =================================================================== RCS file: /cvsroot/squirrelmail/squirrelmail/plugins/filters/options.php,v retrieving revision 1.53 retrieving revision 1.54 diff -u -w -r1.53 -r1.54 --- options.php 11 Feb 2006 17:42:27 -0000 1.53 +++ options.php 5 Apr 2006 00:22:05 -0000 1.54 @@ -11,14 +11,10 @@ */ /** - * Path for SquirrelMail required files. - * @ignore + * Include the SquirrelMail initialization file. */ -define('SM_PATH','../../'); - -/* SquirrelMail required files. */ -require_once(SM_PATH . 'include/validate.php'); -include_once(SM_PATH . 'functions/imap.php'); +require('../../include/init.php'); +include_once(SM_PATH . 'functions/imap_general.php'); include_once(SM_PATH . 'plugins/filters/filters.php'); displayPageHeader($color, 'None'); Index: setup.php =================================================================== RCS file: /cvsroot/squirrelmail/squirrelmail/plugins/filters/setup.php,v retrieving revision 1.44 retrieving revision 1.45 diff -u -w -r1.44 -r1.45 --- setup.php 26 Feb 2006 14:45:20 -0000 1.44 +++ setup.php 5 Apr 2006 00:22:05 -0000 1.45 @@ -15,15 +15,8 @@ * @access private */ function squirrelmail_plugin_init_filters() { - global $squirrelmail_plugin_hooks; - - $squirrelmail_plugin_hooks['left_main_before']['filters'] = 'start_filters_hook'; - $squirrelmail_plugin_hooks['right_main_after_header']['filters'] = 'start_filters_hook'; - $squirrelmail_plugin_hooks['optpage_register_block']['filters'] = 'filters_optpage_register_block_hook'; - $squirrelmail_plugin_hooks['special_mailbox']['filters'] = 'filters_special_mailbox'; - $squirrelmail_plugin_hooks['rename_or_delete_folder']['filters'] = 'update_for_folder_hook'; - $squirrelmail_plugin_hooks['webmail_bottom']['filters'] = 'start_filters_hook'; - $squirrelmail_plugin_hooks['folder_status']['filters'] = 'filters_folder_status'; + include_once(SM_PATH . 'plugins/filters/filters.php'); + filters_init_hooks (); } /** @@ -53,7 +46,7 @@ */ function start_filters_hook($args) { include_once(SM_PATH . 'plugins/filters/filters.php'); - start_filters ($args); + start_filters (); } /** Index: spamoptions.php =================================================================== RCS file: /cvsroot/squirrelmail/squirrelmail/plugins/filters/spamoptions.php,v retrieving revision 1.38 retrieving revision 1.39 diff -u -w -r1.38 -r1.39 --- spamoptions.php 5 Feb 2006 11:18:50 -0000 1.38 +++ spamoptions.php 5 Apr 2006 00:22:05 -0000 1.39 @@ -11,14 +11,12 @@ */ /** - * Path for SquirrelMail required files. - * @ignore + * Include the SquirrelMail initialization file. */ -define('SM_PATH','../../'); +require('../../include/init.php'); -/* SquirrelMail required files. */ -require_once(SM_PATH . 'include/validate.php'); -include_once(SM_PATH . 'functions/imap.php'); +include_once(SM_PATH . 'functions/imap_general.php'); +include_once(SM_PATH . 'functions/imap_messages.php'); include_once(SM_PATH . 'plugins/filters/filters.php'); /* get globals */ |