Qques modifs sur les crons
This commit is contained in:
parent
52072b919b
commit
97fd2dfdf6
|
@ -30,6 +30,7 @@ $lst_cron = $cron->lst_cron();
|
||||||
|
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
|
<!--
|
||||||
<tr>
|
<tr>
|
||||||
<th/>
|
<th/>
|
||||||
<th><?php __("URL"); ?></th>
|
<th><?php __("URL"); ?></th>
|
||||||
|
@ -38,6 +39,7 @@ $lst_cron = $cron->lst_cron();
|
||||||
<th><?php __("Password"); ?></th>
|
<th><?php __("Password"); ?></th>
|
||||||
<th><?php __("Email report"); ?></th>
|
<th><?php __("Email report"); ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
-->
|
||||||
<?php
|
<?php
|
||||||
$max_cron = $quota->getquota("cron");
|
$max_cron = $quota->getquota("cron");
|
||||||
$max_cron = $max_cron['t'];
|
$max_cron = $max_cron['t'];
|
||||||
|
@ -47,14 +49,15 @@ for ($i=0; $i < $max_cron ; $i++) {
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<?php if (isset($lst_cron[$i])) echo "<input type='hidden' name='cronupdate[$i][id]' value='".$lst_cron[$i]['id']."' />"; ?>
|
<?php if (isset($lst_cron[$i])) echo "<input type='hidden' name='cronupdate[$i][id]' value='".$lst_cron[$i]['id']."' />"; ?>
|
||||||
<td>
|
<td rowspan=2>
|
||||||
|
#<?php echo $lst_cron[$i]['id']; ?><br/>
|
||||||
<a href="javascript:cleancron('<?php echo $i ?>');"><img src="images/delete.png" alt="<?php __("Delete");?>" title="<?php __("Delete");?>"/></a>
|
<a href="javascript:cleancron('<?php echo $i ?>');"><img src="images/delete.png" alt="<?php __("Delete");?>" title="<?php __("Delete");?>"/></a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td colspan=2>
|
||||||
<input type="text" id="crup_url_<?php echo $i?>" name="<?php echo "cronupdate[$i][url]";?>" size="30" maxlength="255" value="<?php if (isset($lst_cron[$i]['url'])) { echo htmlentities($lst_cron[$i]['url']);} ?>"/>
|
<input type="text" placeholder="<?php __("Called URL"); ?>" id="crup_url_<?php echo $i?>" name="<?php echo "cronupdate[$i][url]";?>" size="40" maxlength="255" value="<?php if (isset($lst_cron[$i]['url'])) { echo htmlentities($lst_cron[$i]['url']);} ?>"/>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select name='cronupdate[<?php echo $i; ?>][schedule]'>
|
<?php __("Period:");?> <select name='cronupdate[<?php echo $i; ?>][schedule]'>
|
||||||
<?php
|
<?php
|
||||||
foreach ($cron->schedule() as $cs) {
|
foreach ($cron->schedule() as $cs) {
|
||||||
echo "<option value='".$cs['unit']."'";
|
echo "<option value='".$cs['unit']."'";
|
||||||
|
@ -66,11 +69,14 @@ foreach ($cron->schedule() as $cs) {
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
|
<?php __("Next execution: "); echo $lst_cron[$i]['next_execution'];?>
|
||||||
</td>
|
</td>
|
||||||
<td><input type="text" id="crup_user_<?php echo $i?>" name="<?php echo "cronupdate[$i][user]";?>" size="10" maxlength="64" value="<?php if (isset($lst_cron[$i]['user'])) { echo htmlentities($lst_cron[$i]['user']);} ?>"/></td>
|
</tr><tr>
|
||||||
<td><input type="text" id="crup_pass_<?php echo $i?>" name="<?php echo "cronupdate[$i][password]";?>" size="10" maxlength="64" value="<?php if (isset($lst_cron[$i]['password'])) { echo htmlentities($lst_cron[$i]['password']);} ?>"/></td>
|
<td><input type="text" placeholder="<?php __("HTTP user (optionnal)"); ?>" id="crup_user_<?php echo $i?>" name="<?php echo "cronupdate[$i][user]";?>" size="20" maxlength="64" value="<?php if (isset($lst_cron[$i]['user'])) { echo htmlentities($lst_cron[$i]['user']);} ?>"/></td>
|
||||||
<td><input type="text" id="crup_mail_<?php echo $i?>" name="<?php echo "cronupdate[$i][email]";?>" size="10" maxlength="64" value="<?php if (isset($lst_cron[$i]['email'])) { echo htmlentities($lst_cron[$i]['email']);} ?>"/></td>
|
<td><input type="text" placeholder="<?php __("HTTP password (optionnal)"); ?>" id="crup_pass_<?php echo $i?>" name="<?php echo "cronupdate[$i][password]";?>" size="20" maxlength="64" value="<?php if (isset($lst_cron[$i]['password'])) { echo htmlentities($lst_cron[$i]['password']);} ?>"/></td>
|
||||||
|
<td><input type="text" placeholder="<?php __("Mail address (for reports)"); ?>" id="crup_mail_<?php echo $i?>" name="<?php echo "cronupdate[$i][email]";?>" size="25" maxlength="64" value="<?php if (isset($lst_cron[$i]['email'])) { echo htmlentities($lst_cron[$i]['email']);} ?>"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr><td colspan=4><hr/></td></tr>
|
||||||
<?php } //foreach ?>
|
<?php } //foreach ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td/>
|
<td/>
|
||||||
|
|
|
@ -61,6 +61,7 @@ class m_cron {
|
||||||
$tmp['password']=urldecode($db->f('password'));
|
$tmp['password']=urldecode($db->f('password'));
|
||||||
$tmp['schedule']=$db->f('schedule');
|
$tmp['schedule']=$db->f('schedule');
|
||||||
$tmp['email']=urldecode($db->f('email'));
|
$tmp['email']=urldecode($db->f('email'));
|
||||||
|
$tmp['next_execution']=$db->f('next_execution');
|
||||||
$r[]=$tmp;
|
$r[]=$tmp;
|
||||||
}
|
}
|
||||||
return $r;
|
return $r;
|
||||||
|
@ -114,15 +115,15 @@ class m_cron {
|
||||||
$err->raise("cron",_("URL not valid"));
|
$err->raise("cron",_("URL not valid"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$url=mysql_real_escape_string(urlencode($url));
|
$url=urlencode($url);
|
||||||
$user=mysql_real_escape_string(urlencode($user));
|
$user=urlencode($user);
|
||||||
if (empty($user)) $password='';
|
if (empty($user)) $password='';
|
||||||
$password=mysql_real_escape_string(urlencode($password));
|
$password=urlencode($password);
|
||||||
if (! checkmail($email) == 0 ){
|
if (! checkmail($email) == 0 ){
|
||||||
$err->raise("cron",_("Email address is not valid"));
|
$err->raise("cron",_("Email address is not valid"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$email=mysql_real_escape_string(urlencode($email));
|
$email=urlencode($email);
|
||||||
if (! $this->valid_schedule($schedule)) return false;
|
if (! $this->valid_schedule($schedule)) return false;
|
||||||
|
|
||||||
if (is_null($id)) { // if a new insert, quotacheck
|
if (is_null($id)) { // if a new insert, quotacheck
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# FIXME relecture + commentaires
|
# FIXME relecture + commentaires
|
||||||
|
|
||||||
id=$1
|
id=$1
|
||||||
url=$2
|
url=$2
|
||||||
|
@ -46,15 +46,14 @@ urldecode() {
|
||||||
i=$((i+1))
|
i=$((i+1))
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
) | sed -e 's/"/\\"/g' -e 's/\!/\\\!/g'
|
) | sed -e 's/"/\\"/g' -e 's/\!/\\\!/g' -e 's/\ /\\\ /g' -e "s/'/\\'/g"
|
||||||
}
|
}
|
||||||
|
|
||||||
params=""
|
|
||||||
if [ ! "x$user" == "x" -a ! "x$password" == "x" ]; then
|
|
||||||
params="--http-user=\"$(urldecode $user)\" --http-password=\"$(urldecode $password)\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
wget -O - $params "$(urldecode $url)" --timeout=$timeout | mailx -s "AlternC Cron $id - Report $date" -r "$from" "$email"
|
date=$(date +%x\ %X)
|
||||||
|
|
||||||
|
# Don't really understand why it must be called this way...
|
||||||
|
bash -c "( echo -e 'Here the report for the scheduled task for the cron #$id in your AlternC configuration (from http://$FQDN)\n\n\n------------\n\n'; wget -O - --no-check-certificate --http-user=$(urldecode $user) --http-password=$(urldecode $password) \"$(urldecode $url)\" --timeout=$timeout 2>&1 )| mailx -s \"AlternC Cron #$id - Report $date\" -r \"$from\" \"$(urldecode $email)\""
|
||||||
|
|
||||||
# On calcule l'heure de la prochaine execution idéale
|
# On calcule l'heure de la prochaine execution idéale
|
||||||
((interval=$schedule * 60))
|
((interval=$schedule * 60))
|
||||||
|
|
Loading…
Reference in New Issue