Alternc  latest
Alternc logiel libre pour l'hébergement
cron.php
Go to the documentation of this file.
1 <?php
2 /*
3  ----------------------------------------------------------------------
4  LICENSE
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License (GPL)
8  as published by the Free Software Foundation; either version 2
9  of the License, or (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  To read the license please visit http://www.gnu.org/copyleft/gpl.html
17  ----------------------------------------------------------------------
18 */
19 
20 /**
21  * Launch the AlternC's panel crontab for users.
22  *
23  * @copyright AlternC-Team 2000-2017 https://alternc.com/
24  */
25 
26 require_once("../class/config.php");
27 include_once("head.php");
28 
29 $fields = array (
30  "cronupdate" => array ("post", "array", ""),
31 );
33 
34 if (!empty($cronupdate)) {
35  if ($cron->update($cronupdate)) {
36  $msg->raise("INFO", "mysql", _("Save done."));
37  }
38 }
39 
40 $lst_cron = $cron->lst_cron();
41 ?>
42 
43 <h3><?php __("Scheduled tasks"); ?></h3>
44 <hr id="topbar"/>
45 <br />
46 
47 <?php
48 echo $msg->msg_html_all()
49 ?>
50 
51 <form method="post" action="cron.php" id="main" name="cron" >
52  <?php csrf_get(); ?>
53 
54 <table class="tlist">
55 <!--
56  <tr>
57  <th/>
58  <th><?php __("URL"); ?></th>
59  <th><?php __("Schedule"); ?></th>
60  <th><?php __("User"); ?></th>
61  <th><?php __("Password"); ?></th>
62  <th><?php __("Email report"); ?></th>
63  </tr>
64 -->
65 <?php
66 $max_cron = $quota->getquota("cron");
67 $max_cron = $max_cron['t'];
68 if ( sizeof($lst_cron) > $max_cron ) $max_cron=sizeof($lst_cron);
69 
70 for ($i=0; $i < $max_cron ; $i++) {
71 ?>
72  <tr class="<?php echo ($i%2)?"lst1":"lst2"; ?>">
73  <td rowspan='2'>
74  <?php if (isset($lst_cron[$i])) echo "<input type='hidden' name='cronupdate[$i][id]' value='".$lst_cron[$i]['id']."' />"; ?>
75  <?php if (isset($lst_cron[$i])) { echo '#'.$lst_cron[$i]['id']; } ?><br/>
76  <a href="javascript:cleancron('<?php echo $i ?>');"><img src="images/delete.png" alt="<?php __("Delete");?>" title="<?php __("Delete");?>"/></a>
77  </td>
78  <td colspan='2'>
79  <label for="crup_url_<?php echo $i?>"><?php __("Called URL"); ?> :</label><br/><input type="text" id="crup_url_<?php echo $i; ?>" name="<?php echo "cronupdate[$i][url]";?>" size="40" maxlength="255" value="<?php if (isset($lst_cron[$i]['url'])) { ehe($lst_cron[$i]['url']); } ?>"/>
80  </td>
81  <td>
82  <?php __("Period:");?> <select name='cronupdate[<?php echo $i; ?>][schedule]'>
83 <?php
84 foreach ($cron->schedule() as $cs) {
85  echo "<option value='".$cs['unit']."'";
86  if (isset($lst_cron[$i]['schedule']) && ($lst_cron[$i]['schedule'] == $cs['unit'])){
87  echo " selected='selected' ";
88  }
89  echo " >".$cs['name'];
90  echo "</option>";
91 }
92 ?>
93  </select>
94  <br/><?php if (isset($lst_cron[$i])) {__("Next execution: "); echo $lst_cron[$i]['next_execution'];}?>
95  </td>
96  </tr><tr class="<?php echo ($i%2)?"lst1":"lst2"; ?>">
97  <td><label for="crup_user_<?php echo $i?>"><?php __("HTTP user (optional)"); ?> :</label><br/><input type="text" id="crup_user_<?php echo $i?>" name="<?php echo "cronupdate[$i][user]";?>" size="20" maxlength="64" value="<?php if (isset($lst_cron[$i]['user'])) { ehe($lst_cron[$i]['user']);} ?>"/></td>
98  <td><label for="crup_pass_<?php echo $i?>"><?php __("HTTP password (optional)"); ?> :</label><br/><input type="text" id="crup_pass_<?php echo $i?>" name="<?php echo "cronupdate[$i][password]";?>" size="20" maxlength="64" value="<?php if (isset($lst_cron[$i]['password'])) { ehe($lst_cron[$i]['password']);} ?>"/></td>
99  <td><label for="crup_mail_<?php echo $i?>"><?php __("Mail address (optional)"); ?> :</label><br/><input type="text" id="crup_mail_<?php echo $i?>" name="<?php echo "cronupdate[$i][email]";?>" size="25" maxlength="64" value="<?php if (isset($lst_cron[$i]['email'])) { ehe($lst_cron[$i]['email']);} ?>"/></td>
100  </tr>
101 <?php } //foreach ?>
102 </table>
103 <p><input type="submit" name="submit" class="inb ok" value="<?php __("Apply the modifications"); ?>" /></p>
104 
105 </form>
106 
107 <script type="text/javascript">
108 function cleancron(i) {
109  document.getElementById('crup_url_'+i).value = '';
110  document.getElementById('crup_user_'+i).value = '';
111  document.getElementById('crup_pass_'+i).value = '';
112  document.getElementById('crup_mail_'+i).value = '';
113 }
114 
115 </script>
116 
117 <?php include_once("foot.php"); ?>
$msg
Definition: bootstrap.php:75
for($i=0; $i< $max_cron ; $i++)</table >< p >< input type="submit" name="submit" class="inb ok" value="<?php __("Apply the modifications"); ?></p></form><script type="text/javascript"> cleancron(i)
Definition: cron.php:108
$max_cron
Definition: cron.php:66
if(!empty($cronupdate)) $lst_cron
Definition: cron.php:40
$fields
Launch the AlternC's panel crontab for users.
Definition: cron.php:29
__($str)
Definition: functions.php:404
getFields($fields, $requestOnly=false)
Get the Fields of the posted form from $_REQUEST or POST or GET and check their type.
Definition: functions.php:688
csrf_get($return=false)
Give a new CSRF uniq token for a form the session must be up since the CSRF is linked to the session ...
Definition: functions.php:1159
$i