Changeset 1257
- Timestamp:
- 04/20/05 23:21:09 (4 years ago)
- Files:
-
- trunk/bureau/admin/cron_execute.php (modified) (1 diff)
- trunk/bureau/admin/phpcron_add.php (modified) (5 diffs)
- trunk/bureau/admin/phpcron_doadd.php (modified) (4 diffs)
- trunk/bureau/admin/phpcron_list.php (modified) (3 diffs)
- trunk/bureau/class/m_phpcron.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/bureau/admin/cron_execute.php
r1253 r1257 44 44 } 45 45 46 // Many times a day between 2 hours : Yeah Man, noso hard :)46 // Many times a day between 2 hours : Man, not so hard :) 47 47 $r=mysql_query("SELECT id, uid, action, url, mail, acmode, corpus FROM crontasks WHERE 48 48 `period`='1' AND ( ((p2*60+p3)-$minsince )%p1)=0 AND ($ch>=p2 AND $ci>=p3 AND $ch<=p4 AND $ci<=p5)"); trunk/bureau/admin/phpcron_add.php
r1253 r1257 100 100 } 101 101 ?> 102 <h2> Nouvelle tache planifiee</h2>102 <h2><?php __("New timed task"); ?>Nouvelle tache planifiee</h2> 103 103 <form method="post" action="phpcron_doadd.php" name="main"> 104 104 <p> 105 Periodicite de l'evenement : 105 <?php __("Event periodicity: "); ?> 106 106 <select id="t" name="t" onchange="upd(this.selectedIndex);"> 107 107 <?php … … 110 110 </select> 111 111 </p> 112 113 <!-- HERE There should be specific code for each language ... --> 114 112 115 <p> 113 116 <div id="u1"> … … 272 275 </p> 273 276 277 <!-- END OF 'HERE There should be specific code for each language ...' --> 278 279 280 281 282 274 283 <p> 275 Quel evenement declencher : 284 <?php __("Which event shall I trigger: "); ?> 276 285 <select id="w" name="w" onchange="upd2(this.selectedIndex);"> 277 286 <?php … … 281 290 282 291 <div id="w1"> 283 <label for="url"> Url :</label><input type="text" size="40" id="url" name="url" value="<?php echo htmlentities($url); ?>"/>292 <label for="url"><?php __("Url: "); ?></label><input type="text" size="40" id="url" name="url" value="<?php echo htmlentities($url); ?>"/> 284 293 </div> 285 294 <div id="w2"> 286 <label for="mail2"> Adresse Email :</label><input type="text" size="30" id="mail2" name="mail2" value="<?php echo htmlentities($mail2); ?>"/>295 <label for="mail2"><?php __("Email Address: "); ?></label><input type="text" size="30" id="mail2" name="mail2" value="<?php echo htmlentities($mail2); ?>"/> 287 296 </div> 288 297 <div id="w4"> 289 <label for="mode2"> Comment envoyer la page</label><select name="mode2" id="mode2">290 <?php 291 $mm=array(0=> "En piece jointe",1=>"Dans le corps du mail");298 <label for="mode2"><?php __("How shall I send the page ?"); ?></label><select name="mode2" id="mode2"> 299 <?php 300 $mm=array(0=>)_("As an attachment"),1=>_("In the mail body")); 292 301 do_list($mm,$mode2); 293 302 ?> … … 295 304 </div> 296 305 <div id="w3"> 297 <label for="sujet"> Sujet du mail :</label><input type="text" size="40" id="sujet" name="sujet" value="<?php echo htmlentities($sujet); ?>"/><br />298 <label for="texte"> Texte du mail :</label><textarea name="texte" id="texte" cols="30" rows="6"><?php echo htmlentities($texte); ?></textarea>306 <label for="sujet"><?php __("Email Subject: "); ?></label><input type="text" size="40" id="sujet" name="sujet" value="<?php echo htmlentities($sujet); ?>"/><br /> 307 <label for="texte"><?php __("Email Body: "); ?></label><textarea name="texte" id="texte" cols="30" rows="6"><?php echo htmlentities($texte); ?></textarea> 299 308 </div> 300 309 301 310 302 311 <br /> 303 <input type="submit" value=" Creer cet evenement" />312 <input type="submit" value="<?php __("Create this task"); ?>" /> 304 313 305 314 </form> trunk/bureau/admin/phpcron_doadd.php
r1253 r1257 25 25 ---------------------------------------------------------------------- 26 26 Original Author of file: Benjamin Sonntag 27 Purpose of file: List ftp accounts of the user.27 Purpose of file: Do add a cron task to the user account 28 28 ---------------------------------------------------------------------- 29 29 */ … … 106 106 107 107 if ($error) { 108 $error=_(" $t Erreur dans le choix de la periode, merci de preciser une periode correcte.");108 $error=_("Error in the period choice, please ask for a correct period."); 109 109 include("phpcron_add.php"); 110 110 exit(); … … 140 140 141 141 if ($error) { 142 $error= "Erreur dans le choix de la tache a effectuer, merci de preciser une tache correct.";142 $error=_("Error in the task choice. Please set a correct task parameter."; 143 143 include("cron_add".$r.".php"); 144 144 exit(); 145 145 } 146 146 147 $phpcron->add_task(147 //$phpcron->add_task( 148 148 // ok, let's use $t $w $p1-4 $f* to insert into mysql : 149 mysql_query("INSERT INTO crontasks SET149 $db->query("INSERT INTO crontasks SET 150 150 uid='".$uid."', 151 151 `period`='$t', p1='$p1', p2='$p2', p3='$p3', p4='$p4', p5='$p5', … … 153 153 "); 154 154 155 if (mysql_errno()) { 156 $error="Impossible de creer l'entree crontab, reessayez plus tard (".mysql_error().")."; 157 include("cron_add".$r.".php"); 158 exit(); 159 } 160 161 $error="L'entree a ete cree avec succes."; 155 $error=_("Task successfully created."); 162 156 include("index.php"); 163 157 trunk/bureau/admin/phpcron_list.php
r1253 r1257 25 25 ---------------------------------------------------------------------- 26 26 Original Author of file: Benjamin Sonntag 27 Purpose of file: List ftp accounts of the user.27 Purpose of file: List cron tasks of the user. 28 28 ---------------------------------------------------------------------- 29 29 */ … … 40 40 </head> 41 41 <body> 42 <h3><?php __("T asks list"); ?></h3>42 <h3><?php __("Timed tasks list"); ?></h3> 43 43 <?php 44 44 if ($notask) { … … 83 83 <?php } 84 84 85 $mem->show_help("ftp_list");86 85 ?> 87 86 </body> 88 87 </html> 89 88 90 91 92 93 94 95 96 97 <?php98 99 require_once("config.php");100 101 ?>102 <html>103 <head>104 <title>Cron</title>105 </head>106 <body>107 <?php108 109 if ($error) {110 echo "<p class=\"error\">$error</p>";111 }112 113 ?>114 <p>115 <a href="cron_add.php">Ajouter une nouvelle planification.</a>116 <br />117 <a href="cron_add2.php">Ajouter une nouvelle planification.</a>118 </p>119 <h2>Liste des taches planifiees</h2>120 <?php121 122 $r=mysql_query("SELECT * FROM crontasks WHERE uid='1';");123 if (!mysql_num_rows($r)) {124 echo "<p class=\"error\">Aucune tache planifiee</p>";125 } else {126 127 ?>128 <form method="post" action="cron_dodel.php" />129 <table>130 <tr><th></th><th>Periodicite</th><th>Action</th></tr>131 <?php132 133 $i=0;134 while($c=mysql_fetch_array($r)) {135 $d=task2str($c);136 echo "<tr>";137 echo "<td><input type=\"checkbox\" name=\"del_$i\" value=\"".$c["id"]."\" /> ";138 echo "<a href=\"cron_edit.php?id=".$c["id"]."\">Modifier</a></td>";139 echo "<td>".$d[0]."</td>";140 echo "<td>".$d[1]."</td>";141 echo "</tr>";142 $i++;143 }144 145 ?>146 </table>147 <input type="submit" value="Effacer les taches cochees" />148 </form>149 <?php150 }151 152 ?>153 154 155 </body>156 </html>trunk/bureau/class/m_phpcron.php
r1253 r1257 30 30 class m_phpcron { 31 31 32 // The fqdn of the server so that mail sent to anybody will by marked by X-PHP-CRON uniq instance id. 33 $SITE_SIGNATURE="alternc.info"; 34 35 var $jobtype_str=array( 36 0 => _("Send an email"), 37 1 => _("Send a page by email"), 38 2 => _("Call a web page"), 39 3 => _("Call a web page and keep it"), 40 ); 41 42 43 var $period_str=array( 44 0 => _("Once"), 45 1 => _("Many times a day"), 46 2 => _("Daily"), 47 3 => _("Weekly"), 48 4 => _("Monthly (by day number)"), 49 5 => _("Monthly (by day name)"), 50 6 => _("Yearly"), 51 ); 52 53 var $hourly_str=array( 54 0 => _("15 minutes"), 55 1 => _("30 minutes"), 56 2 => _("45 minutes"), 57 3 => _("Hours"), 58 4 => _("2 Hours"), 59 5 => _("3 Hours"), 60 6 => _("4 Hours"), 61 7 => _("6 Hours"), 62 8 => _("8 Hours"), 63 9 => _("12 Hours"), 64 ); 65 66 var $mhourly_str=array( 67 "m15" => _("15 minutes"), 68 "m30" => _("30 minutes"), 69 "m45" => _("45 minutes"), 70 "m60" => _("Hours"), 71 "m120" => _("2 Hours"), 72 "m180" => _("3 Hours"), 73 "m240" => _("4 Hours"), 74 "m360" => _("6 Hours"), 75 "m480" => _("8 Hours"), 76 "m720" => _("12 Hours"), 77 ); 78 79 var $weekly_str=array( 80 0 => _("Sunday"), 81 1 => _("Monday"), 82 2 => _("Thirsday"), 83 3 => _("Wednesday"), 84 4 => _("Tuesday"), 85 5 => _("Friday"), 86 6 => _("Saturday"), 87 ); 88 89 var $monthly_str=array( 90 0 => _("First"), 91 1 => _("Second"), 92 2 => _("Third"), 93 3 => _("Before the last"), 94 4 => _("Last"), 95 ); 96 97 var $yearly_str=array( 98 0 => _("January"), 99 1 => _("February"), 100 2 => _("March"), 101 3 => _("April"), 102 4 => _("May"), 103 5 => _("June"), 104 6 => _("July"), 105 7 => _("August"), 106 8 => _("September"), 107 9 => _("October"), 108 10=> _("November"), 109 11=> _("December"), 110 ); 111 112 113 var $action_texts=array( 114 0 => _("Send a mail to %1\$s with subject '%2\$s' and content : \n%3\$s"), 115 1 => _("Send the content of page %1\$s by mail to %2\$s."), 116 2 => _("Call the web page %1\$s"), 117 3 => _("Call the web page %1\$s and keep it in a document manager."), 118 ); 119 var $period_texts=array( 120 0 => _("On %2\$s, %1\$d %3\$d at %4\$d:%5\$d"), // Le 1 Janvier 2004 a 23H30 121 1 => _("Every %1\$s from %2\$d:%3\$d to %4\$d:%5\$d"), // Toutes les 15 minutes de 0H00 a 23H45 122 2 => _("Every day at %1\$d:%2\$d"), // Tous les jours a 12H10 123 3 => _("Every %1\$s at %2\$d:%3\$d"), // Tous les dimanches a 12H10 124 4 => _("Every %1\$s of the month at %2\$d:%3\$d"), // Tous les 4 du mois a 12H10 125 5 => _("Every %1\$s %2\$s of the month at %3\$d:%4\$d"), // Tous les premier lundi du mois a 12H10 126 6 => _("Every %2\$s, %1\$d at %3\$d:%4\$d"), // Tous les 1 Janvier a 23H30 127 ); 128 32 129 var $clsid="phpcron"; /* Numero de la classe php (pour les logs) */ 33 130 34 131 /*****************************************************************************/ 35 function m_phpcron() { } 132 function m_phpcron() { 133 global $FQDN; 134 $this->SITE_SIGNATURE=$FQDN; 135 } 36 136 37 137 /*****************************************************************************/ … … 39 139 function get_list() { 40 140 global $err,$db,$cuid; 41 $err->log( "phpcron","enum_tasks");141 $err->log($this->clsid,"get_list"); 42 142 $db->query("SELECT * FROM crontasks WHERE uid='$cuid';"); 43 143 if (!$db->next_record()) { … … 55 155 /*****************************************************************************/ 56 156 function exec_cron_job($c,$dry_run=0) { 57 global $SITE_SIGNATURE;58 157 echo "Executing Cron job #".$c["id"]."<br />\n"; 59 158 if (!$dry_run) { … … 61 160 switch ($c[action]) { 62 161 case 0: // Send a mail 63 mail($c["mail"],$c["url"],$c["corpus"],"X-PHP-CRON: ".$ SITE_SIGNATURE."#".$c["id"]);162 mail($c["mail"],$c["url"],$c["corpus"],"X-PHP-CRON: ".$this->SITE_SIGNATURE."#".$c["id"]); 64 163 break; 65 164 case 1: // Send a page by mail 66 165 $res=retrieve_url($c["url"]); 67 mail($c["mail"], "Tache planifiee ".$c["id"]," Page web jointe",$res,"X-PHP-CRON: ".$SITE_SIGNATURE."#".$c["id"]);166 mail($c["mail"],_("Timed task number ").$c["id"],_(" Web page attached"),$res,"X-PHP-CRON: ".$SITE_SIGNATURE."#".$c["id"]); 68 167 break; 69 168 case 2: // Call a web page … … 74 173 mysql_query("INSERT INTO cronpages SET url='".addslashes($c["url"])."', taskid='".$c["uid"]."', size='".strlen($res)."', content='".addslashes($res)."';"); 75 174 default: 76 echo "Error executing job #".$c["id"]."<br />\n";175 echo _("Error executing job #").$c["id"]."<br />\n"; 77 176 break; 78 177 } … … 92 191 /*****************************************************************************/ 93 192 function retrieve_url($url) { 94 return "nothing here, sorry ... ";193 return "nothing here, sorry ... (To be coded, benjamin has a http_fetch power tool)"; 95 194 } 96 195 97 196 /*****************************************************************************/ 98 197 function task2str($c) { 99 global $mhourly_str,$weekly_str,$monthly_str,$yearly_str;198 // global $mhourly_str,$weekly_str,$monthly_str,$yearly_str; 100 199 // Return a language-dependant formatted string from a task entry (from mysql) 101 $period_texts=array(102 0 => "Le %1\$d %2\$s %3\$d a %4\$dH%5\$d", // Le 1 Janvier 2004 a 23H30103 1 => "Toutes les %1\$s de %2\$dH%3\$d a %4\$dH%5\$d", // Toutes les 15 minutes de 0H00 a 23H45104 2 => "Tous les jours a %1\$dH%2\$d", // Tous les jours a 12H10105 3 => "Tous les %1\$s de %2\$dH%3\$d", // Tous les dimanches a 12H10106 4 => "Tous les %1\$s du mois a %2\$dH%3\$d", // Tous les 4 du mois a 12H10107 5 => "Tous les %1\$s %2\$s du mois a %3\$dH%4\$d", // Tous les premier lundi du mois a 12H10108 6 => "Tous les %1\$d %2\$s a %3\$dH%4\$d", // Tous les 1 Janvier a 23H30109 );110 200 switch ($c["period"]) { 111 201 case 0: 112 $str=sprintf($ period_texts[0],$c["p1"],$yearly_str[$c["p2"]],$c["p3"],$c["p4"],$c["p5"]);202 $str=sprintf($this->period_texts[0],$c["p1"],$this->yearly_str[$c["p2"]],$c["p3"],$c["p4"],$c["p5"]); 113 203 break; 114 204 case 1: 115 $str=sprintf($ period_texts[1],$mhourly_str["m".$c["p1"]],$c["p2"],$c["p3"],$c["p4"],$c["p5"]);205 $str=sprintf($this->period_texts[1],$this->mhourly_str["m".$c["p1"]],$c["p2"],$c["p3"],$c["p4"],$c["p5"]); 116 206 break; 117 207 case 2: 118 $str=sprintf($ period_texts[2],$c["p1"],$c["p2"]);208 $str=sprintf($this->period_texts[2],$c["p1"],$c["p2"]); 119 209 break; 120 210 case 3: 121 $str=sprintf($ period_texts[3],$weekly_str[$c["p1"]],$c["p2"],$c["p3"]);211 $str=sprintf($this->period_texts[3],$this->weekly_str[$c["p1"]],$c["p2"],$c["p3"]); 122 212 break; 123 213 case 4: 124 $str=sprintf($ period_texts[4],$c["p1"],$c["p2"],$c["p3"]);214 $str=sprintf($this->period_texts[4],$c["p1"],$c["p2"],$c["p3"]); 125 215 break; 126 216 case 5: 127 $str=sprintf($ period_texts[5],$monthly_str[$c["p1"]],$weekly_str[$c["p2"]],$c["p3"],$c["p4"]);217 $str=sprintf($this->period_texts[5],$this->monthly_str[$c["p1"]],$this->weekly_str[$c["p2"]],$c["p3"],$c["p4"]); 128 218 break; 129 219 case 6: 130 $str=sprintf($ period_texts[6],$c["p1"],$yearly_str[$c["p2"]],$c["p3"],$c["p4"],$c["p5"]);220 $str=sprintf($this->period_texts[6],$c["p1"],$this->yearly_str[$c["p2"]],$c["p3"],$c["p4"],$c["p5"]); 131 221 break; 132 222 default: 133 $str="Tache mal formattee !"; 134 break; 135 } 136 137 $action_texts=array( 138 0 => "Envoyer un mail a %1\$s ayant pour sujet '%2\$s' et pour contenu : \n%3\$s", 139 1 => "Envoyer le contenu de la page web %1\$s par mail a %2\$s.", 140 2 => "Appeler la page web %1\$s", 141 3 => "Appeler la page web %1\$s et la conserver dans un porte document.", 142 ); 223 $str=_("Task is badly formatted!"); 224 break; 225 } 226 143 227 // Now the task itself :) 144 228 switch ($c["action"]) { 145 229 case 0: 146 $str2=sprintf($ action_texts[0],$c["mail"],$c["url"],$c["corpus"]);230 $str2=sprintf($this->action_texts[0],$c["mail"],$c["url"],$c["corpus"]); 147 231 break; 148 232 case 1: 149 $str2=sprintf($ action_texts[1],$c["url"],$c["mail"]);233 $str2=sprintf($this->action_texts[1],$c["url"],$c["mail"]); 150 234 break; 151 235 case 2: 152 $str2=sprintf($ action_texts[2],$c["url"]);236 $str2=sprintf($this->action_texts[2],$c["url"]); 153 237 break; 154 238 case 3: 155 $str2=sprintf($ action_texts[3],$c["url"]);239 $str2=sprintf($this->action_texts[3],$c["url"]); 156 240 break; 157 241 default: 158 $str2= "Tache mal formattee !";242 $str2=_("Task is badly formatted!"); 159 243 break; 160 244 }
