updating cron module

This commit is contained in:
Steven Mondji-Lerider 2012-09-13 14:23:18 +00:00
parent 114c1eb999
commit 9d5794a83f
2 changed files with 15 additions and 6 deletions

View File

@ -9,7 +9,7 @@ getFields($fields);
if (!empty($cronupdate)) {
if (! $cron->update($cronupdate)) {
$error=_("There was an error during the record.");
$error=$err->errstr();
} else {
$error=_("Save done.");
}
@ -75,7 +75,7 @@ foreach ($cron->schedule() as $cs) {
<tr>
<td/>
<td>
<input type="submit" name="submit" class="inb" value="<?php __("Save"); ?>" />
<input type="submit" name="submit" class="inb" value="<?php __("Apply the modifications"); ?>" />
</td>
</table>

View File

@ -34,7 +34,7 @@ class m_cron {
*/
function m_cron() {
}
//FIXME add a NOT NULL constraint on uid in the DB
function schedule() {
return Array(
Array('unit'=>1440, 'name'=>_("Daily")),
@ -109,12 +109,19 @@ class m_cron {
return $this->delete_one($id);
}
// FIXME check the url property
if(filter_var($url,FILTER_VALIDATE_URL)===false){
$err->raise("cron",_("URL not valid"));
return false;
}
$url=mysql_real_escape_string(urlencode($url));
$user=mysql_real_escape_string(urlencode($user));
if (empty($user)) $password='';
$password=mysql_real_escape_string(urlencode($password));
if (! checkmail($email) == 0 ) return false;
if (! checkmail($email) == 0 ){
$err->raise("cron",_("Email address is not valid"));
return false;
}
$email=mysql_real_escape_string(urlencode($email));
if (! $this->valid_schedule($schedule)) return false;
@ -126,7 +133,9 @@ class m_cron {
}
} else { // if not a new insert, check the $cuid
$db->query("SELECT uid FROM cron WHERE id = $id;");
if (! $db->next_record()) { return "false"; } // return false if pb
if (! $db->next_record()) {
return "false";
} // return false if pb
if ( $db->f('uid') != $cuid ) {
$err->raise("cron",_("Identity problem"));
return false;