root/alternc-procmail/branches/v0/procmail_add.php

Revision 1262, 6.0 kB (checked in by anonymous, 4 years ago)

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php /* Modified at 2 places by ri_once */ ?>
2 <?php
3
4    chdir ("..");
5    session_start();
6
7    include_once ("procmail_builder/config.php");
8    include_once ("../config/config.php");
9    include_once ("../functions/strings.php");
10    include_once ("../functions/page_header.php");
11    include_once ("../functions/imap.php");
12
13    if (isset($plugin_change_ldappass))
14        $Messages = change_ldappass_check();
15
16    include_once ("../src/load_prefs.php");
17    displayPageHeader($color, "None");
18
19   textdomain("procmail_builder");
20
21 $raction=intval($raction);
22 if (!$raction) {
23     $raction=1;
24 }
25
26 $crittypecount=7;
27 if (!is_array($crit)) {
28     $crit=array();
29 }
30 if (!is_array($crittext)) {
31     $crittext=array();
32 }
33 if ($createit && $accook=2) {
34     $newcrit=intval($newcrit);
35     $crit[]=$newcrit;
36     $a=_("procmail_crit_$newcrit");   
37     if (substr($a,strlen($a)-3)=="...")
38         $crittext[]=$newcrittxt;
39     else
40         $crittext[]="";
41 }
42 if ($dropit && $accook==2 && is_array($del)) {
43     $nc=$crit;
44     $nct=$crittext;
45     $crit=array();
46     $crittext=array();
47     for ($i=0;$i<count($nc);$i++) {
48         if (!in_array($i+1,$del)) {
49             $crit[]=$nc[$i];
50             $crittext[]=$nct[$i];
51         }
52     }
53 }
54
55 if ($rcreateit && $accook==2) {
56     if (!$r=$pr->buildrule($rulename,$crit,$crittext,$raction,$foldertogo,$emailto,$autoreplytxt)) {
57         $error=$er->errstr();
58     } else {
59         if ($pr->addrule($r)) {
60             $error="La règle a été ajoutée avec succès";
61             $already=1;
62             include_once("procmail_opt.php");
63             exit();
64         } else {
65             $error=$er->errstr();
66         }
67     }
68 }
69
70 if ($rdropit && $accook==2) {
71     $already=1;
72     include_once("procmail_opt.php");
73     exit();
74 }
75
76 ?>
77 <br>
78 <form method=post action="procmail_add.php">
79 <input type="hidden" name="accook" value="2">
80 <table width=95% align=center cellpadding=2 cellspacing=2 border=0>
81 <tr><td bgcolor="<?php echo $color[0] ?>">
82    <center><b><?php __("Create a new rule"); ?></b></center>
83 </td>
84 </tr>
85 <?php
86
87 if ($error) echo "<tr><td><b>$error</b></td></tr>";
88
89 ?>
90 <tr><td>
91 <?php __("Name of this rule"); ?> : <input type="text" name="rulename" size="20" maxlength="128" value="<?php echo str_replace("\"","&quote;",$rulename); ?>">
92 </td></tr>
93 <tr><td bgcolor="<?php echo $color[0] ?>">
94    <?php __("CRITERIA"); ?>
95 </td></tr>
96 <tr><td>
97 <?php if (count($crit)==0) {
98      __("No Criteria defined yet, all messages selected");
99 } else {
100     // Liste des critères
101     echo "<table cellpadding=\"4\" cellspacing=\"0\">";
102     for($i=0;$i<count($crit);$i++) {
103         echo "<tr>";
104         echo "<td><input type=\"checkbox\" name=\"del[]\" value=\"".($i+1)."\"></td>";
105         echo "<td><select name=\"crit[$i]\">";
106         for($j=0;$j<$crittypecount;$j++)  {
107             echo "<option value=\"$j\"";
108             if ($crit[$i]==$j) echo " selected";
109             echo ">"._("procmail_crit_$j")."</option>\n";
110         }
111         echo "</select></td>";
112         echo "<td><input type=\"text\" name=\"crittext[$i]\" size=\"20\" value=\"".str_replace("\"","&quote;",$crittext[$i])."\" maxlength=\"255\"></td>";
113         echo "</tr>";
114     }
115     echo "</table>";
116 }
117 ?>
118 </td></tr>
119 <tr><td>
120 <hr>
121 <select name="newcrit">
122 <?php
123 for($i=0;$i<$crittypecount;$i++)  {
124     echo "<option value=\"$i\">"._("procmail_crit_$i")."</option>\n";
125 }
126 ?>
127 </select>
128 &nbsp;&nbsp;
129 <input type="text" name="newcrittxt" size="20" value="" maxlength="255">&nbsp;&nbsp;
130 <input type="submit" name="createit" value="<?php __("Add this new criterium"); ?>">&nbsp;
131 <input type="submit" name="dropit" value="<?php __("Drop checked criteria"); ?>">&nbsp;
132 </td></tr>
133 <tr><td><p>&nbsp;</p></td></tr>
134 <tr><td bgcolor="<?php echo $color[0] ?>">
135    <?php __("PROCESS"); ?>
136 </td></tr>
137
138 <tr><td>
139 <table cellpadding="4" cellspacing="0">
140     <tr><td><input type="radio" name="raction" id="moveit" value="1"<?php if ($raction==1) echo " checked"; ?>></td>
141         <td><label for="moveit"><?php __("Move the message to this folder"); ?></label></td>
142         <td><select name="foldertogo"><?php
143 $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
144 $boxes = sqimap_mailbox_list($imapConnection);
145
146 for ($i = 0; $i < count($boxes); $i++) {
147     if (!in_array('noinferiors', $boxes[$i]['flags'])) {
148         if ((strtolower($boxes[$i]['unformatted']) == 'inbox') &&
149             $default_sub_of_inbox) {
150             $box = $boxes[$i]['unformatted'];
151             $box2 = str_replace(' ', '&nbsp;', $boxes[$i]['unformatted-disp']);
152             echo "<OPTION SELECTED VALUE=\"$box\">$box2</option>\n";
153         } else {
154             $box = $boxes[$i]['unformatted'];
155             $box2 = str_replace(' ', '&nbsp;', $boxes[$i]['unformatted-disp']);
156             if (strtolower($imap_server_type) != 'courier' ||
157                   strtolower($box) != "inbox.trash")
158                 echo "<OPTION VALUE=\"$box\">$box2</option>\n";
159         }
160     }
161 }
162
163 ?></select></td></tr>
164     <tr><td><input type="radio" name="raction" id="r2" value="2"<?php if ($raction==2) echo " checked"; ?>></td>
165         <td colspan="2"><label for="r2"><?php __("Filter the message through SpamAssassin"); ?></label></td></tr>
166     <tr><td><input type="radio" name="raction" id="r3" value="3"<?php if ($raction==3) echo " checked"; ?>></td>
167         <td colspan="2"><label for="r3"><?php __("Discard the message (for good !)"); ?></label></td></tr>
168     <tr><td><input type="radio" name="raction" id="r4" value="4"<?php if ($raction==4) echo " checked"; ?>></td>
169         <td><label for="r4"><?php __("Forward the mail to"); ?></label></td><td><input type="text" name="emailto" value="<?php echo str_replace("\"","&quote;",$emailto); ?>" size="30" maxlength="255"></td></tr>
170     <tr><td valign="top"><input type="radio" name="raction" id="r5" value="5"<?php if ($raction==5) echo " checked"; ?>></td>   
171         <td valign="top"><label for="r5"><?php __("Auto-reply"); ?><br><?php __("Enter auto-reply text below"); ?></label></td><td><textarea cols="32" rows="10" name="autoreplytxt"><?php echo str_replace("<","&lt;",$autoreplytxt); ?></textarea></td></tr>
172 </table>
173 </td></tr>
174 <tr><td>
175     <input type="submit" name="rcreateit" value="<?php __("Create this rule"); ?>">&nbsp;
176     <input type="submit" name="rdropit" value="<?php __("Go back to the rule list"); ?>">&nbsp;
177 </td></tr>
178
179 <tr><td><p>&nbsp;</p></td></tr>
180 <tr><td>
181 <small><?php __("help_procmail_2"); ?></small>
182 </td></tr>
183 </body>
184 </html>
185 <?php
186 textdomain("squirrelmail");
187 ?>
188
Note: See TracBrowser for help on using the browser.