root/alternc-procmail/tags/REL_0_9_3/procmail_add.php

Revision 1270, 6.4 kB (checked in by benjamin, 4 years ago)

correctifs en tout genre pour que procmail-builder marche sur squirrelmail 1.4 alternc 0.9.3/4 et sarge

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