*
* Based on Dan Ellis' test scripts that came with sieve-php.lib
*
";
$errormsg .= _("(Probably the script is size null).");
$errormsg .= _("Please contact your administrator.");
print_errormsg($errormsg);
exit;
}
}
/* $sievescript has a SIEVE script. Parse that. */
$scriptinfo = array();
$rules = getruledata($sievescript, $scriptinfo);
}
unset($sieve->response);
/* On to the code that executes if phpscript exists or if a new rule has been
* created. */
if ($logout) {
/* Activate phpscript and log out. */
avelsieve_login();
if ($newscript = makesieverule($rules)) {
avelsieve_upload_script($newscript);
if(!($sieve->sieve_setactivescript("phpscript"))){
/* Just to be safe. */
$errormsg = _("Could not set active script on your IMAP server");
$errormsg .= " " . $imapServerAddress.".
";
$errormsg .= _("Please contact your administrator.");
print_errormsg($errormsg);
exit;
}
$sieve->sieve_logout();
} else {
/* upload a null thingie!!! :-) This works for now... some time
* it will get better. */
avelsieve_upload_script("");
/* if(sizeof($rules) == "0") {
avelsieve_delete_script();
} */
}
session_unregister('rules');
header("Location: $location/../../src/options.php\n\n");
// header("Location: $location/../../src/options.php?optpage=avelsieve\n\n");
exit;
} elseif (isset($_POST['addrule'])) {
header("Location: $location/addrule.php");
exit;
} elseif (isset($_POST['addspamrule'])) {
header("Location: $location/addspamrule.php");
exit;
}
/* Routine for Delete / Delete selected / edit / duplicate / moveup/down */
if(isset($_GET['rule']) || isset($_POST['deleteselected'])) {
if (isset($_GET['edit'])) {
header("Location: $location/edit.php?edit=".$_POST['rule']."");
exit;
} elseif (isset($_GET['dup'])) {
header("Location: $location/edit.php?edit=".$_POST['rule']."&dup=1");
exit;
} elseif (isset($_GET['rm']) || ( isset($_POST['deleteselected']) && isset($_POST['selectedrules'])) ) {
if (isset($_POST['deleteselected'])) {
$rules2 = $rules;
foreach($_POST['selectedrules'] as $no=>$sel) {
unset($rules2[$sel]);
}
$rules = array_values($rules2);
$_SESSION['comm']['deleted'] = $_POST['selectedrules'];
} elseif(isset($_GET['rm'])) {
$rules2 = $rules;
unset($rules2[$_GET['rule']]);
$rules = array_values($rules2);
$_SESSION['comm']['deleted'] = $_GET['rule'];
}
if(sizeof($rules) == "0") {
// print "DEBUG: Ok, size of rules is 0 apparently.";
if (!$conservative) {
avelsieve_login();
// avelsieve_upload_script("");
avelsieve_delete_script();
}
$prev = bindtextdomain ('squirrelmail', SM_PATH . 'locale');
textdomain ('squirrelmail');
displayPageHeader($color, 'None');
$prev = bindtextdomain ('avelsieve', SM_PATH . 'plugins/avelsieve/locale');
textdomain ('avelsieve');
printheader2(false);
print_all_sections_start();
print_section_start(_("All your rules have been deleted"));
print_create_new();
print_section_end();
print_all_sections_end();
print_buttons();
print_footer();
printfooter2();
sqsession_register($rules, 'rules');
exit;
}
} elseif (isset($_GET['mvup'])) {
$rules = array_swapval($rules, $_GET['rule'], $_GET['rule']-1);
} elseif (isset($_GET['mvdn'])) {
$rules = array_swapval($rules, $_GET['rule'], $_GET['rule']+1);
} elseif (isset($_GET['mvtop'])) {
/* Rule to get to the top: */
$ruletop = $rules[$_GET['rule']];
unset($rules[$_GET['rule']]);
array_unshift($rules, $ruletop);
} elseif (isset($_GET['mvbottom'])) {
/* Rule to get to the bottom: */
$rulebot = $rules[$_GET['rule']];
unset($rules[$_GET['rule']]);
/* Reindex */
$rules = array_values($rules);
/* Now Append it */
$rules[] = $rulebot;
}
sqsession_register($rules, 'rules');
/* Register changes to timsieved if we are not conservative in our
* connections with him. */
if ($conservative == false && $rules) {
$newscript = makesieverule($rules);
avelsieve_login();
avelsieve_upload_script($newscript);
}
}
if (isset($_SESSION['returnnewrule'])) { /* Get the new rule and put it in the script */
$newrule = $_SESSION['returnnewrule'];
// unserialize(base64_decode(urldecode($returnnewrule)));
session_unregister('returnnewrule');
// print "DEBUG: Adding new: "; print_r($newrule);
if (!is_array($rules)) {
unset($rules);
$rules[0] = $newrule;
} else {
$rules[] = $newrule;
}
$haschanged = true;
}
if( (!$conservative && isset($haschanged) ) ) {
avelsieve_login();
$newscript = makesieverule($rules);
avelsieve_upload_script($newscript);
if(isset($_SESSION['haschanged'])) {
unset($_SESSION['haschanged']);
}
}
if(isset($rules)) {
$_SESSION['rules'] = $rules;
$_SESSION['scriptinfo'] = $scriptinfo;
}
if(isset($sieve_loggedin)) {
$sieve->sieve_logout();
}
/* --------------------------------- main --------------------------------- */
/* Printing, part zero: Headers et al */
$prev = bindtextdomain ('squirrelmail', SM_PATH . 'locale');
textdomain ('squirrelmail');
displayPageHeader($color, 'None');
$prev = bindtextdomain ('avelsieve', SM_PATH . 'plugins/avelsieve/locale');
textdomain ('avelsieve');
if (!isset($rules) ||
isset($rules) && sizeof($rules) == 0 ) {
// printheader2( _("Current Mail Filtering Rules") );
printheader2(false);
print_all_sections_start();
print_section_start(_("No Filtering Rules Defined Yet"));
print_create_new();
print_section_end();
print_all_sections_end();
print_buttons();
// print_footer();
printfooter2();
exit;
}
//print "SESSION: "; print_r($_SESSION); print "
";
//print "POST: "; print_r($_POST); print "
";
//print "COOKIE: "; print_r($_COOKIE); print "
";
//print "rules: "; print_r($rules); print "
";
if(isset($_GET['mode'])) {
if(array_key_exists($_GET['mode'], $displaymodes)) {
$mode = $_GET['mode'];
} else {
$mode = $avelsieve_default_mode;
}
sqsession_register($mode, 'mode');
} else {
if(isset($_SESSION['mode'])) {
if(array_key_exists($_SESSION['mode'], $displaymodes)) {
$mode = $_SESSION['mode'];
} else {
$mode = "verbose";
}
} else {
$mode = $avelsieve_default_mode;
}
}
// print_my_header();
printheader2( _("Current Mail Filtering Rules") );
print_all_sections_start();
/* Printing the table with the rules. */
print '
'. ' '. ' | '. ''; print_addnewrulebutton(); print ' |