Fixes #1328
This commit is contained in:
		
							parent
							
								
									cf4a276e81
								
							
						
					
					
						commit
						70b74ee19f
					
				|  | @ -50,7 +50,7 @@ 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 rowspan=2> |     <td rowspan=2> | ||||||
|       #<?php echo $lst_cron[$i]['id']; ?><br/>
 |       <?php if (isset($lst_cron[$i])) { 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 colspan=2> |     <td colspan=2> | ||||||
|  | @ -69,12 +69,12 @@ foreach ($cron->schedule() as $cs) { | ||||||
| } | } | ||||||
| ?>
 | ?>
 | ||||||
|       </select> |       </select> | ||||||
|       <?php __("Next execution: "); echo $lst_cron[$i]['next_execution'];?>
 |       <?php if (isset($lst_cron[$i])) {__("Next execution: "); echo $lst_cron[$i]['next_execution'];}?>
 | ||||||
|     </td> |     </td> | ||||||
|   </tr><tr> |   </tr><tr> | ||||||
|     <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" 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" 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 __("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> |     <td><input type="text" placeholder="<?php __("Mail address (optionnal)"); ?>" 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> |   <tr><td colspan=4><hr/></td></tr> | ||||||
| <?php } //foreach ?>
 | <?php } //foreach ?>
 | ||||||
|  |  | ||||||
|  | @ -119,7 +119,7 @@ class m_cron { | ||||||
|     $user=urlencode($user); |     $user=urlencode($user); | ||||||
|     if (empty($user)) $password=''; |     if (empty($user)) $password=''; | ||||||
|     $password=urlencode($password); |     $password=urlencode($password); | ||||||
|     if (! checkmail($email) == 0 ){  |     if (!empty($email) && ! checkmail($email) == 0 ){  | ||||||
|         $err->raise("cron",_("Email address is not valid")); |         $err->raise("cron",_("Email address is not valid")); | ||||||
|       return false; |       return false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -16,8 +16,8 @@ done | ||||||
| max_process=2 | max_process=2 | ||||||
| 
 | 
 | ||||||
| tasks () { | tasks () { | ||||||
| $MYSQL_DO "select id, url, email, schedule, UNIX_TIMESTAMP(), user, password as now from cron c where next_execution <= now();" | while read id url email schedule now user password ; do | $MYSQL_DO "select id, url, if(length(email)>0,email,'null'), schedule, UNIX_TIMESTAMP(), user, password as now from cron c where next_execution <= now();" | while read id url email schedule now user password ; do | ||||||
|   echo $id $url $email $schedule $now \"$user\" \"$password\"  |   echo $id $url \"$email\" $schedule $now \"$user\" \"$password\"  | ||||||
| done | done | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -49,11 +49,23 @@ urldecode() { | ||||||
| ) | sed -e 's/"/\\"/g' -e 's/\!/\\\!/g' -e 's/\ /\\\ /g' -e "s/'/\\'/g" | ) | sed -e 's/"/\\"/g' -e 's/\!/\\\!/g' -e 's/\ /\\\ /g' -e "s/'/\\'/g" | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | tmpfile=$(mktemp /tmp/altern-cron-id$id-$$.XXX) | ||||||
| date=$(date +%x\ %X) |  | ||||||
| 
 | 
 | ||||||
| # Don't really understand why it must be called this way... | # 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)\"" | ( | ||||||
|  | echo -e "Here the report for the scheduled task for the cron #$id in your AlternC configuration (from http://$FQDN)\n\n" | ||||||
|  | echo -e "\n---------- BEGIN ----------" | ||||||
|  | bash -c "wget -O - --no-check-certificate --http-user=$(urldecode $user) --http-password=$(urldecode $password) \"$(urldecode $url)\" --timeout=$timeout 2>&1" | ||||||
|  | echo -e "\n----------  END  ----------" | ||||||
|  | ) > "$tmpfile" | ||||||
|  | 
 | ||||||
|  | # If there is an email specified, mail it | ||||||
|  | if [ ! "x$email" == "x" -a ! "$email" == "null" ] ; then | ||||||
|  |   date=$(date +%x\ %X) | ||||||
|  |   cat "$tmpfile" | mailx -s "AlternC Cron #$id - Report $date" -r "$from" "$(urldecode $email)" | ||||||
|  | fi | ||||||
|  | 
 | ||||||
|  | rm -f "$tmpfile" | ||||||
| 
 | 
 | ||||||
| # 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
	
	 Alan Garcia
						Alan Garcia