* @copyright 2004-2007 Alexandros Vellis * @package plugins * @subpackage avelsieve */ /** Includes */ include_once(SM_PATH . 'plugins/avelsieve/config/config.php'); include_once(SM_PATH . 'plugins/avelsieve/include/html_main.inc.php'); /** * Informational message and link to Junk Mail options, from Junk Folder * Screen. * * @return void */ function junkmail_right_main_do() { global $PHP_SELF; sq_bindtextdomain ('avelsieve', SM_PATH . 'plugins/avelsieve/locale'); textdomain ('avelsieve'); require_once(SM_PATH . 'plugins/avelsieve/include/constants.inc.php'); sqgetGlobalVar('rules', $rules, SQ_SESSION); sqgetGlobalVar('haschanged', $avelsieve_changed, SQ_SESSION); /* Initialization of the Sieve storage backend class, for the following * two actions */ if (!isset($rules) || isset($avelsieve_changed)) { global $avelsieve_backend; $backend_class_name = 'DO_Sieve_'.$avelsieve_backend; include_once(SM_PATH . 'plugins/avelsieve/include/sieve.inc.php'); $s = new $backend_class_name; $s->init(); $s->login(); } /* If this page is called before table.php is ever shown, then we have to make * the current filtering rules available in the Session. This will happen when * a user clicks either: * i) creation of a rule from the message commands (while viewing a message) * ii) creation of a rule from some search criteria. */ if (!isset($rules)) { /* Actually get the script 'phpscript' (hardcoded ATM). */ if($s->load('phpscript', $rules, $scriptinfo)) { $_SESSION['rules'] = $rules; $_SESSION['scriptinfo'] = $scriptinfo; } $s->logout(); } /** * Replicate the script-saving code from table.php. * This is for when we get back in this page. The rules have * to be saved to server then. */ if(isset($avelsieve_changed) && $avelsieve_changed == true) { $newscript = makesieverule($rules); $s->save($newscript, 'phpscript'); avelsieve_spam_highlight_update($rules); sqsession_unregister('haschanged'); $s->logout(); } $rule_exists = false; for($i=0; $iuseimages = true; // FIXME echo $ht->all_sections_start() . $ht->section_start( ($ht->useimages == true ? '(i) ' : '') . _("Junk Folder Information")) . '

'. ($ht->useimages == true ? '(i) ' : ''). _("Messages in this folder have been identified as SPAM / Junk."); if(!$rule_exists || !$rule_enabled) { echo '
' . ($ht->useimages == true? '(!) ' : '') . '' . sprintf( _("Note: Junk Mail is currently not enabled. Select "%s" to enable it."), ''._("Edit Junk Mail Options...").'' ) . ''; } else { echo ' ' . sprintf( _("Any messages older than %s days are automatically deleted."), $junkmailDays); } echo '

'; echo '

'. ''. _("Edit Junk Mail Options...") . '

'; $avelsieveMessages = $ht->retrieve_avelsieve_messages(); if($avelsieveMessages) { echo '

' .$avelsieveMessages . '

'; $ht->clear_avelsieve_messages(); } echo $ht->section_end() . $ht->all_sections_end(); sq_bindtextdomain('squirrelmail', SM_PATH . 'locale'); textdomain('squirrelmail'); } /** * Informational message and link to Junk Mail options, from Folders Screen * (folders.php). * * TODO - Implement * * @return void */ function junkmail_folders_do() { } /** * Ask LDAP Server's Sendmail configuration for configured RBLs. * * The global variable $ldap_server from Squirrelmail's ldap server * configuration is used to determine if this feature will be enabled. * * *** Advanced Administrators Option *** (Needs custom configuration * in LDAP server and possible tweaking of this function). * * @return RBLs structure, or false if no such configuration present. Structure * looks like this: * Array( * [0] => Array * ( * [host] => relays.ordb.org * [name] => Open Relay DataBase * [serverweight] => 50 * ) */ function avelsieve_askldapforrbls() { /* If they were retrieved before, do not ask LDAP again. */ if(isset($_SESSION['avelsieve_spamrbls_ldap'])) { return($_SESSION['avelsieve_spamrbls_ldap']); } global $ldap_server; foreach($ldap_server as $ldapno=>$info) { if(isset($info['mtarblspamfilter'])) { $mtarblspamfilter = $info['mtarblspamfilter']; $ls = $ldapno; break; } } if(!isset($mtarblspamfilter)) { return false; } if(!($ldap = ldap_connect($ldap_server[$ls]['host']))) { print "Could not connect to LDAP!"; return false; } ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); if(isset($ldap_server[$ls]['binddn'])) { $bind_result = ldap_bind($ldap, $ldap_server[$ls]['binddn'], $ldap_server[$ls]['bindpw']); if (!$bind_result) { print "Error while binding to LDAP server"; return false; } } if (!($search_result = ldap_search($ldap, $ldap_server[$ls]['mtarblspambase'], $ldap_server[$ls]['mtarblspamfilter']))) { print "Failed to search for SPAM RBLs."; return false; } $info = ldap_get_entries($ldap, $search_result); $spamrbls = array(); $sp_index = 0; for($j=0; $j<$info['count']; $j++) { if(isset($info[$j]['sendmailmtaclassname'])) { $spamrule_temp = array(); for($i=0; $i<$info[$j]['sendmailmtaclassvalue']['count']; $i++) { $spamrule_temp[] = $info[$j]['sendmailmtaclassvalue'][$i]; } $spamrule_temp = str_replace('<', '', $spamrule_temp); $spamrule_temp = str_replace('>', '', $spamrule_temp); $temp=array(); for($i=0; $i $avelsieve_hili_name, 'color' => $avelsieve_hili_color, 'value' => $avelsieve_hili_value, 'match_type' => $avelsieve_hili_match_type ); setPref($data_dir, $username, 'hililist', serialize($hilight)); } } else { if($hilight_exists) { /* Here we could remove the highlight rule, but I guess it won't * hurt leaving it in there. */ } } } /** * JunkPrune Update: LDAPuserdata backend. (Saves the days number in LDAP attribute). * * @param string $username * @param int $junkFolderDays * @return boolean */ function avelsieve_junkprune_ldapuserdata_update($username, $junkFolderDays) { global $plugins, $data_dir, $username; if(in_array('ldapuserdata', $plugins)) { if(!isset($_SESSION['ldap_prefs_cache']['junkprune']) || $_SESSION['ldap_prefs_cache']['junkprune'] != $junkFolderDays) { setPref($data_dir, $username, 'junkprune', $junkFolderDays); ldapuserdata_flush(); return true; } return false; } }