| 1 | <?php |
| 2 | /******************************************************************************** |
| 3 | * index.php : index page |
| 4 | * --------- |
| 5 | * |
| 6 | * This file is part of the philter distribution |
| 7 | * Copyright: See COPYING files that comes with this distribution |
| 8 | ********************************************************************************/ |
| 9 | |
| 10 | require("include/header.inc.php"); |
| 11 | require("include/philter.inc.php"); |
| 12 | require("include/config.inc.php"); |
| 13 | |
| 14 | $mail_pool = new EmailPool(get_user_id()); |
| 15 | $filter = new Filter(get_user_id()); |
| 16 | |
| 17 | if(count($_POST)) { // a FORM has been submitted |
| 18 | if(isset($_POST['emails'])) // FORM emails |
| 19 | if(!$mail_pool->handle_form()) |
| 20 | echo "<p style=\"color:red;\">".$philter->error()."</p>\n"; |
| 21 | |
| 22 | if(!empty($_POST['order']['action'])) // FORM order |
| 23 | if($_POST['order']['action']=='submit') { |
| 24 | foreach($filter->rules as $id=>$rule) |
| 25 | if(isset($_POST['order'][$id])) |
| 26 | $filter->rules[$id]->move_to($_POST['order'][$id], $filter->uid, $id); |
| 27 | uasort($filter->rules, 'rule_cmp'); |
| 28 | } elseif($_POST['order']['action']=='delete' && !empty($_POST['order']['select'])) { |
| 29 | $filter->delete_rule($_POST['order']['select']); |
| 30 | $_POST['order']['select'] = min(count($filter->rules),$_POST['order']['select']); |
| 31 | } |
| 32 | |
| 33 | if(!empty($_POST['rule'])) // FORM rule |
| 34 | if(!$filter->handle_form()) |
| 35 | echo "<p style=\"color:red;\">".$philter->error()."</p>\n"; |
| 36 | } |
| 37 | |
| 38 | require("include/js_factory.inc.php"); |
| 39 | |
| 40 | /********** globals plugins **********/ |
| 41 | ?> |
| 42 | <div class="rubrique">The global configuration |
| 43 | </div> |
| 44 | <?php |
| 45 | if(count($philter->config['global_plugin'])) { |
| 46 | echo "<form action=\"{$_SERVER['REQUEST_URI']}\" method=\"post\">\n" |
| 47 | ."<table width=\"95%\" class=\"bicol\" cellspacing=\"1\" cellpadding=\"1\" align=\"center\">\n"; |
| 48 | |
| 49 | foreach($philter->config['global_plugin'] as $g_plugin) { |
| 50 | echo "<tr><td>\n"; |
| 51 | echo $g_plugin->to_form(/* data */); |
| 52 | echo "</td></tr>\n"; |
| 53 | |
| 54 | } |
| 55 | |
| 56 | echo "</table>\n" |
| 57 | ."</form>\n"; |
| 58 | } |
| 59 | |
| 60 | /********** emails **********/ |
| 61 | ?> |
| 62 | <br /> |
| 63 | <div class="rubrique">The redirection address pool |
| 64 | </div> |
| 65 | <?php |
| 66 | echo $mail_pool->to_form(); |
| 67 | |
| 68 | /********** filters **********/ |
| 69 | ?> |
| 70 | |
| 71 | <br /> |
| 72 | <div class="rubrique">The individuals rules |
| 73 | </div> |
| 74 | <table width="95%" cellspacing="0" cellpadding="2" align="center"> |
| 75 | <tr><td width="25%" valign="top"> |
| 76 | <form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post" id="order" name="order" onsubmit="return false;"> |
| 77 | <table class="bicol" width="100%" cellpadding="1" cellspacing="1"> |
| 78 | <tr><th>Filter List</th></tr> |
| 79 | <tr><td> |
| 80 | <?php |
| 81 | foreach($filter->rules as $id=>$rule) |
| 82 | echo "<input type=\"hidden\" id=\"order$id\" name=\"order[$id]\" value=\"{$rule->rank}\" />\n"; |
| 83 | |
| 84 | $presel = (isset($_POST['rule']['id']) ? $_POST['rule']['id'] |
| 85 | : (isset($_POST['order']['select']) ? $_POST['order']['select'] : 0)); |
| 86 | |
| 87 | echo "<select size=\"16\" style=\"width:100%;\" id=\"orderSelect\" name=\"order[select]\" onchange=\"createRuleForm()\">\n"; |
| 88 | echo "<option value=\"0\" ".($presel ? "" : " selected=\"selected\"") |
| 89 | .">[ new rule ]</option>\n"; |
| 90 | |
| 91 | foreach($filter->rules as $id=>$rule) |
| 92 | echo "<option value=\"$id\"" |
| 93 | .($presel==$id ? " selected=\"selected\"":"") |
| 94 | .">{$rule->name}</option>\n"; |
| 95 | ?> |
| 96 | </select> |
| 97 | </td></tr><tr><td> |
| 98 | <input type="submit" value="Up" name="order[up]" onclick="order_up();" /> |
| 99 | <input type="submit" value="Down" name="order[dn]" onclick="order_dn();" /><br /> |
| 100 | <input type="submit" value="Delete" name="order[delete]" onclick="order_submit(this)" /> |
| 101 | <input type="submit" value="Submit" name="order[submit]" onclick="order_submit(this)" /> |
| 102 | <input type="hidden" value="" name="order[action]" /> |
| 103 | </td></tr> |
| 104 | </table> |
| 105 | </form> |
| 106 | </td> |
| 107 | <td valign="top"> |
| 108 | <form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post" id="rule" name="rule" onsubmit="return false;"> |
| 109 | <table width="100%" class="bicol" cellspacing="1" cellpadding="1"> |
| 110 | <tr class="impair"><th>Rule Configuration |
| 111 | </th></tr><tr class="impair"><td> |
| 112 | <input type="hidden" value="0" id="ruleId" name="rule[id]" /> |
| 113 | Name of this rule : |
| 114 | <input type="text" size="60" value="" id="ruleName" name="rule[name]" |
| 115 | onfocus="text_onfocus(this,'[ new rule ]')" onblur="text_onblur(this,'[ new rule ]')" /> |
| 116 | <br /> |
| 117 | <input type="radio" value="1" id="ruleAll1" name="rule[all]" />All matches |
| 118 | <input type="radio" value="0" id="ruleAll0" name="rule[all]" />One match |
| 119 | <br /> |
| 120 | <input type="checkbox" checked="checked" id="ruleBlock" name="rule[block]" />Blocking Rule |
| 121 | </td></tr><tr class="impair"><th>Matches List |
| 122 | </th></tr><tr class="impair"><td id="matchesRow"> |
| 123 | </td></tr><tr class="impair"><th>Actions List |
| 124 | </th></tr><tr class="impair"><td id="actionsRow"> |
| 125 | </td></tr><tr class="impair"><td> |
| 126 | <input type="submit" value="New Match" name="rule[new_match]" onclick="newMatch() "/> |
| 127 | <input type="submit" value="New Action" name="rule[new_action]" onclick="newAction()" /> |
| 128 | <input type="submit" value="Submit" name="rule[submit]" onclick="this.form.submit()" /> |
| 129 | </td></tr> |
| 130 | </table> |
| 131 | </form> |
| 132 | </td> |
| 133 | </tr> |
| 134 | </table> |
| 135 | |
| 136 | <script type="text/javascript"> |
| 137 | createRuleForm(); |
| 138 | </script> |
| 139 | |
| 140 | <?php |
| 141 | /********** footer **********/ |
| 142 | |
| 143 | require("include/footer.inc.php"); |
| 144 | |
| 145 | /******************************************************************************** |
| 146 | * $id: header.inc.php,v 1.2 2003/08/03 16:02:41 madcoder exp $ |
| 147 | * vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 textwidth=100: |
| 148 | ********************************************************************************/ |
| 149 | ?> |