Auteur Topic: Nieuwe luxere Cronjob editor  (gelezen 7199 keer)

Offline wizjos

  • Administrator
  • MVP
  • *
  • Bedankjes
  • -Gegeven: 123
  • -Ontvangen: 181
  • Berichten: 1.999
Nieuwe luxere Cronjob editor
« Gepost op: 14 maart 2009, 18:34:07 »
De oude versie van de cronjob was best leuk, maar deze vind ik mooier... Hij staat al in principe ook al op die pagina, maar valt daar een beetje weg. In deze post is ook de beveiliging een tikje aangescherpt(op de hulppagina's)...



Zoals je ziet een wat andere lay-out en een paar extra schermen voor bewerken en een nieuwe job



De code:

Appication.cfg:
text = NewCron
description = NewCron
icon_16 = cron16.png
icon_32 = cron32.png
type = embedded
path = /phpsrc/newcron/cronjob.php

cronjob.php:
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Cronjobs</title>
<style>body,input,select,option,td{font:11px Arial}body{background-color:#EEEEEE}legend{font-weight:bold;color:#15428b}fieldset{border:1px solid #bbb; padding:5px}a:hover,a:link,a:visited{color: #000;text-decoration:none}</style>

<script type="text/javascript" language="JavaScript">

function markCheckbox(state){
var checkboxes=document.getElementsByName('choicecron[]');
for(var n=0;n<checkboxes.length;n++){
checkboxes[n].checked=state;
}
}
function disp_confirm(){
var r=confirm("Are you sure you want to delete the selected job(s)?");
if (r==true){
document.cronindex.submit();
} else {
alert("Deletion aborted...");
}
}
function emptytest() {
message = 0;
nmbr = 0;
var checkboxes=document.getElementsByName('choicecron[]');
for(var n=0;n<checkboxes.length;n++){
if (checkboxes[n].checked == 1){
message=1;
nmbr++;
}
}
if (message == 0) {
switch(document.getElementById('action').value)
{
case 'delete':
alert("Please choose one or more jobs you want to delete");
break;
case 'enabledisable':
alert("Please choose one or more jobs you want to enable/disable");
break;
case 'changejob':
alert("Please choose a job you want to change");
break;
}
} else {
if (document.getElementById('action').value == 'delete') {
disp_confirm();
} else if (document.getElementById('action').value == 'changejob' && nmbr > 1) {
alert("You can change only one job at a time!");
} else {
document.cronindex.submit();
}
}
}
</script></head>

<?php
putenv('HTTP_COOKIE='&#46;$_SERVER['HTTP_COOKIE'&#93;);
putenv('REMOTE_ADDR='&#46;$_SERVER['REMOTE_ADDR'&#93;);
$user=exec('/usr/syno/synoman/webman/modules/authenticate&#46;cgi');
if($user != 'admin'){
   header("HTTP/1&#46;0 403 Forbidden");
   exit;
}
$lines=10;
if ($_REQUEST['action2'&#93; == 'deletelog')
file_put_contents('/var/log/cron&#46;log''');
if ($_REQUEST['action2'&#93; == 'refreshlog')
$lines=$_REQUEST['customlines'&#93;;
$crontabfile=file('/etc/crontab');
$t=count($crontabfile);
echo '<form name="cronindex" action="editcron&#46;php" method="post">';
echo '<input type="hidden" id="action" name="action" value="">';

echo '<fieldset><legend>etc/crontab</legend>
<table width=100%" cellspacing=1" cellpadding="2" bgcolor="#eeeeee"><tr bgcolor="#cdcdcd">
<td width="30px" align="center"><input type="checkbox" title="Select/Deselect all" name="checkall" value="" onclick="markCheckbox(this&#46;checked)" /></td><td width="60px"><b>Status</b></td><td><b>Who</b></td><td><b>Command</b></td><td><b>Description</b></td></tr>'
;
$z=0;
while ($z $t){
foreach($crontabfile as $last) {
$command=explode(chr(9),$last);
$delete_change=implode(chr(9),$command);
if ($command[0&#93;{0}=='#'){
$active='Stopped'$cellcol="CC0000";}
else{$active='Running'$cellcol="#006600";}
echo '<tr bgcolor="#e1e1e1">';
if ($command[0&#93;=='#minute'){
echo '<td align="center" height=22">&#46;&#46;&#46;</td><td>&#46;&#46;&#46;</td><td>&#46;&#46;&#46;</td><td>#minute hour mday month wday who command</td><td>Default header</td></tr>';
}
else{
$description substr_replace($command[7&#93;, '', 0, 1);
echo '<td align="center" ><input type="checkbox" name="choicecron[&#93;" value="'&#46;$delete_change&#46;'"></td><td><font color='&#46;$cellcol&#46;'>'&#46;$active&#46;'</font></td><td title="'&#46;$delete_change&#46;'">'&#46;$command[5&#93;&#46;'</td><td title="'&#46;$delete_change&#46;'">'&#46;$command[6&#93;&#46;'</td><td>'&#46;$description&#46;'</td></tr>';
}
$z++;
}
}
echo 
'</table></fieldset>';
//echo '<fieldset><legend>Actions</legend>';
echo '<input type="button" title="Delete selected job(s) and restart crond" value=" Delete job & Restart " onclick="document&#46;getElementById('action')&#46;value='delete';emptytest()"/>';
echo 
'<input type="button" title="Enable or Disable selected job(s) and restart crond" value=" Enable/Disable & Restart " style="margin-left:3px" onclick="document&#46;getElementById('action')&#46;value='enabledisable';emptytest()"/>';
echo 
'<input type="button" title="Edit selected job" value=" Edit selected job " style="margin-left:3px" onclick="document&#46;getElementById('action')&#46;value='changejob';emptytest()"/>';
echo 
'<input type="button" title="Create a new cronjob" value=" Set new job " style="margin-left:3px" onclick="window&#46;location='newcron&#46;php'">';
echo '</fieldset></form>';

echo 
'<fieldset><legend>/var/log/cron&#46;log</legend>';

$logread=exec('tail -'&#46;$lines&#46;' /var/log/cron&#46;log', $cronlog);
$cl=count($cronlog);

echo 
'<table width=100%" cellspacing=0" cellpadding="1" bgcolor="#e1e1e1">';
for (
$i=0;$i<$cl;$i++){
echo '<tr><td>'&#46;$cronlog[$i&#93;&#46;'</td></tr><tr>';
}
echo 
'</tr></table></fieldset>';

echo 
'<form name="cronlog" action="cronjob&#46;php" method="post">';
echo 
'<input type="hidden" id="log" name="action2" value="">';
echo 
'<fieldset><legend>Actions</legend>';
echo 
'<input type="button" title="Delete cron&#46;log file" value=" Delete Log " onclick="document&#46;getElementById('log')&#46;value='deletelog';submit()"/>';
echo 
'<input type="button" title="Refresh cron&#46;log" value=" Refresh Log " style="margin-left:3px" onclick="document&#46;getElementById('log')&#46;value='refreshlog';submit()"/>';
echo 
'<input type="text" name="customlines" size="1" value="'&#46;$lines&#46;'" style="margin-left:5px"> Lines</input>';
echo '</input>';
echo 
'</fieldset></form>';

if (
$empty==1){
echo '<font color="#ff0000"><b> Please select a job to edit (Multiple choice is impossible)&#46;</b></font>';
}
?>


newcron.php:
<?php
putenv
('HTTP_COOKIE='&#46;$_SERVER['HTTP_COOKIE'&#93;);
putenv('REMOTE_ADDR='&#46;$_SERVER['REMOTE_ADDR'&#93;);
$user=exec('/usr/syno/synoman/webman/modules/authenticate&#46;cgi');
if(
$user != 'admin'){
   
header("HTTP/1&#46;0 403 Forbidden");
   exit;
}
?>

<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Cronjobs</title>
<style>body,input,select,option,td{font:11px Arial}body{background-color:#EEEEEE}legend{font-weight:bold;color:#15428b}fieldset{border:1px solid #bbb; padding:5px}a:hover,a:link,a:visited{color: #000;text-decoration:none}</style>

<script language="JavaScript" type="text/javascript">

function makeminDisable()
{
for( var i=1; i<6; i++ ){
document.getElementById('min' +i).disabled=true;
}
}
function makeminEnable()
{
for( var i=1; i<6; i++ ){
document.getElementById('min' +i).disabled=false;
}
}
function makehourDisable()
{
for( var i=1; i<3; i++ ){
document.getElementById('hour' +i).disabled=true;
}
}
function makehourEnable()
{
for( var i=1; i<3; i++ ){
document.getElementById('hour' +i).disabled=false;
}
}
function makedayDisable()
{
for( var i=1; i<4; i++ ){
document.getElementById('day' +i).disabled=true;
}
}
function makedayEnable()
{
for( var i=1; i<4; i++ ){
document.getElementById('day' +i).disabled=false;
}
}
function makemonDisable()
{
document.getElementById('mon').disabled=true;
}
function makemonEnable()
{
document.getElementById('mon').disabled=false;
}
function makeweekdayDisable()
{
document.getElementById('wday').disabled=true;
}
function makeweekdayEnable()
{
document.getElementById('wday').disabled=false;
}
function pushUser()
{
document.cron.user.value=document.cron.user_select.value;
}
</script></head>

<?php

$error 
$_POST['empty'&#93;;
echo '<fieldset><legend>Details</legend><form name="cron" action="setcron&#46;php" method="post">';
echo 
'<table><tr height="25">';
echo 
'<td width="150"><b>User</b></td><td><input title="Enter user for running this cronjob" type=text id="user" name="user" size="12"</input>';
echo 
'<select name="user_select" size="1" style="margin-left:10px" value="" selected onChange="javascript&#058;pushUser();">';
echo 
'echo <option value="">Choose user</option>';
$user_shadow=file('/etc/shadow');
foreach(
$user_shadow as $each_user) {
$count_string=strlen($each_user);
$pos strpos($each_user":");
$select_user=substr_replace($each_user''$pos, -1);
echo '<option value="'&#46;$select_user&#46;'">'&#46;$select_user&#46;'</option>';
}
echo 
'</select></td>';
echo 
'<tr height="25"><td><b>Active</b></td><td><input type="radio" name="active" value="" checked="checked"> Yes</input><input type="radio" name="active" value="#"> No</input></td>';
echo 
'<tr height="25"><td><b>Command</b></td><td><input title="Enter cron command here" type=text name="command" size="50"</input></td>';
echo 
'<tr height="25"><td><b>Description</b></td><td><input title="Enter jobdescription here" type=text name="description" size="50"</input></td>';
echo 
'</tr></table></fieldset>';
echo 
'<table cellspacing="0"><tr>';
echo 
'<td valign="top"><fieldset style="height:240px;"><legend>Minute</legend>
<input name="radiomin" type="radio" value="minall" onClick="makeminDisable();" checked="true"> All</input><br />
<input name="radiomin" type="radio" value="minchoice" onClick="makeminEnable(this);" > Selection</input><br /><br />

<select name="min1[&#93;" id="min1" size="12" multiple="true" disabled="true">'
;
$x=0$y=12;
while (
$x<$y){
echo '<option value="'&#46;$x&#46;'">'&#46;$x&#46;'</option>';
$x++;
}
echo 
'</select>';
echo 
'<select name="min2[&#93;" id="min2" size="12" multiple="true" disabled="true" style="margin-left:5px">';
$x=12$y=24;
while (
$x<$y){
echo '<option value="'&#46;$x&#46;'">'&#46;$x&#46;'</option>';
$x++;
}
echo 
'</select>';
echo 
'<select name="min3[&#93;"  id="min3" size="12" multiple="true" disabled="true" style="margin-left:5px">';
$x=24$y=36;
while (
$x<$y){
echo '<option value="'&#46;$x&#46;'">'&#46;$x&#46;'</option>';
$x++;
}
echo 
'</select>';
echo 
'<select name="min4[&#93;"  id="min4" size="12" multiple="true" disabled="true" style="margin-left:5px">';
$x=36$y=48;
while (
$x<$y){
echo '<option value="'&#46;$x&#46;'">'&#46;$x&#46;'</option>';
$x++;
}
echo 
'</select>';
echo 
'<select name="min5[&#93;"  id="min5" size="12" multiple="true" disabled="true" style="margin-left:5px">';
$x=48$y=60;
while (
$x<$y){
echo '<option value="'&#46;$x&#46;'">'&#46;$x&#46;'</option>';
$x++;
}
echo 
'</select></fieldset></td>';

echo 
'<td valign="top"><fieldset style="height:240px;"><legend>Hour</legend>
<input name="radiohour" type="radio" value="hourall" onClick="makehourDisable(this)" checked="checked"> All</input><br />
<input name="radiohour" type="radio" value="hourchoice" onClick="makehourEnable(this)"> Selection</input><br /><br />
<select name="hour1[&#93;" id="hour1" size="12" multiple="true" disabled="true">'
;
$x=0$y=12;
while (
$x<$y){
echo '<option value="'&#46;$x&#46;'">'&#46;$x&#46;'</option>';
$x++;
}
echo 
'</select>';
echo 
'<select name="hour2[&#93;" id="hour2" size="12" multiple="true" disabled="true" style="margin-left:5px">';
$x=12$y=24;
while (
$x<$y){
echo '<option value="'&#46;$x&#46;'">'&#46;$x&#46;'</option>';
$x++;
}
echo 
'</select></fieldset></td>';

echo 
'<td valign="top"><fieldset style="height:240px;"><legend>Day</legend>
<input name="radioday" type="radio" value="dayall" onClick="makedayDisable(this)" checked="checked"> All</input><br />
<input name="radioday" type="radio" value="daychoice" onClick="makedayEnable(this)"> Selection</input><br /><br />
<select name="day1[&#93;" id="day1" size="12" multiple="true" disabled="true">'
;
$x=1$y=13;
while (
$x<$y){
echo '<option value="'&#46;$x&#46;'">'&#46;$x&#46;'</option>';
$x++;
}
echo 
'</select>';
echo 
'<select name="day2[&#93;" id="day2" size="12" multiple="true" disabled="true" style="margin-left:5px">';
$x=13$y=25;
while (
$x<$y){
echo '<option value="'&#46;$x&#46;'">'&#46;$x&#46;'</option>';
$x++;
}
echo 
'</select>';
echo 
'<select name="day3[&#93;" id="day3" size="12" multiple="true" disabled="true" style="margin-left:5px">';
$x=25$y=32;
while (
$x<$y){
echo '<option value="'&#46;$x&#46;'">'&#46;$x&#46;'</option>';
$x++;
}
echo 
'</select></fieldset></td>';

echo 
'<td valign="top"><fieldset style="height:240px;"><legend>Month</legend>
<input name="radiomon" type="radio" value="monall" onClick="makemonDisable(this)" checked="checked"> All</input><br />
<input name="radiomon" type="radio" value="monchoice" onClick="makemonEnable(this)"> Selection</input><br /><br />
<select name="mon[&#93;" id="mon" size="12" multiple="true" disabled="true">'
;
$x=1$y=13;
while (
$x<$y){
echo '<option value="'&#46;$x&#46;'">'&#46;$x&#46;'</option>';
$x++;
}
echo 
'</select></fieldset></td>';

echo 
'<td valign="top"><fieldset style="height:240px;"><legend>Weekday</legend>
<input name="radioweekday" type="radio" value="weekdayall" onClick="makeweekdayDisable(this)" checked="checked"> All</input><br />
<input name="radioweekday" type="radio" value="weekdaychoice" onClick="makeweekdayEnable(this)"> Selection</input><br /><br />
<select name="weekday[&#93;" id="wday" size="12" multiple="true" disabled="true">'
;
$wday=array("Monday""Tuesday""Wednesday""Thursday""Friday""Saturday""Sunday");
$x=1$y=8; $z=0;
while (
$x<$y){
echo '<option value="'&#46;$x&#46;'">'&#46;$wday[$z&#93;&#46;'</option>';
$x++; $z++;
}
echo 
'</select></fieldset></td>';

echo 
'</tr></table>';
echo 
'<fieldset><legend>Actions</legend>';
echo 
'<input type="button" title="Abort new job and go back to index" value=" Cancel " onclick="window&#46;location='cronjob&#46;php'">';
echo '<input type="submit" title="Save cronjob and restart crond" style="margin-left:3px" value=" Save job & Restart ">';
echo 
'</fieldset></form>';
echo 
'<br />* Hold "CTRL" for multiple selection and deselection';
if (
$empty==1){
echo '<br /><br /><font color="#ff0000"><b>Value for User and Command is required!</b></font>';
}
?>

editcron.php:<?php
putenv
('HTTP_COOKIE='&#46;$_SERVER['HTTP_COOKIE'&#93;);
putenv('REMOTE_ADDR='&#46;$_SERVER['REMOTE_ADDR'&#93;);
$user=exec('/usr/syno/synoman/webman/modules/authenticate&#46;cgi');
if(
$user != 'admin'){
   
header("HTTP/1&#46;0 403 Forbidden");
   exit;
}
$deletechange $_POST['choicecron'&#93;;
$button $_POST['action'&#93;;

$crontabfile=file('/etc/crontab');
$x=count($crontabfile);
$c=count($deletechange);

if (
$button == 'enabledisable'){
for ($i=0$i<$c$i++){
$search=$deletechange[$i&#93;;
for ($y=0;$y<$x;$y++){
if(array_key_exists($y,$crontabfile)){
if(substr_count($crontabfile[$y&#93;, $search) > 0){
if ($crontabfile[$y&#93;{0}=='#'){
$crontabfile[$y&#93;{0}='';
$crontabfile_mod $crontabfile[$y&#93;;
$crontabfile[$y&#93; = ltrim($crontabfile_mod);
}
else{
$crontabfile_mod $crontabfile[$y&#93;;
$crontabfile[$y&#93; = '#'&#46;$crontabfile_mod;
}
}
}
}
}
file_put_contents('/etc/crontab'$crontabfile);
exec('killall crond;crond -l 8 -L /var/log/cron&#46;log');
header("Location: cronjob&#46;php");
exit();
}

If (
$button == 'delete'){
for ($i=0$i<$c$i++){
$search=$deletechange[$i&#93;;
for ($y=0;$y<$x;$y++){
if(array_key_exists($y,$crontabfile)){
if(substr_count($crontabfile[$y&#93;, $search) > 0)
unset($crontabfile[$y&#93;);
}
}
}
file_put_contents('/etc/crontab'$crontabfile);
exec('killall crond;crond -l 8 -L /var/log/cron&#46;log');
header("Location: cronjob&#46;php");
exit();
}

if (
$button == 'changejob'){
if ($deletechange =='' or $c 1){
header("Location: cronjob&#46;php?empty=1");
exit();
}
?>


<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Cronjobs</title>
<style>body,input,select,option,td{font:11px Arial}body{background-color:#EEEEEE}legend{font-weight:bold;color:#15428b}fieldset{border:1px solid #bbb; padding:5px}a:hover,a:link,a:visited{color: #000;text-decoration:none}</style>

<script language="JavaScript" type="text/javascript">

function makeminDisable()
{
for( var i=1; i<6; i++ ){
document.getElementById('min' +i).disabled=true;
}
}
function makeminEnable()
{
for( var i=1; i<6; i++ ){
document.getElementById('min' +i).disabled=false;
}
}
function makestdDisable()
{
for( var i=1; i<3; i++ ){
document.getElementById('std' +i).disabled=true;
}
}
function makestdEnable()
{
for( var i=1; i<3; i++ ){
document.getElementById('std' +i).disabled=false;
}
}
function makedayDisable()
{
for( var i=1; i<4; i++ ){
document.getElementById('day' +i).disabled=true;
}
}
function makedayEnable()
{
for( var i=1; i<4; i++ ){
document.getElementById('day' +i).disabled=false;
}
}
function makemonDisable()
{
document.getElementById('mon').disabled=true;
}
function makemonEnable()
{
document.getElementById('mon').disabled=false;
}
function makeweekdayDisable()
{
document.getElementById('wday').disabled=true;
}
function makeweekdayEnable()
{
document.getElementById('wday').disabled=false;
}
function pushUser()
{
document.cron.user.value=document.cron.user_select.value;
}
</script></head>

<?php
function decrypt($decrypt){
$text explode(",",$decrypt);
foreach ($text as $value) {
$count++;
$begin "";
$end "";
$temp "";
if (strpos($value,"-") > 0) {
$begin substr($value,0,strpos($value,"-"));
$end substr($value,strpos($value,"-")+1);
for ($begin$begin<=$end$begin++) {
$temp $temp&#46;","&#46;$begin;
}
$text[$count-1&#93; = $temp;
}
}
$decrypt implode(",",$text);
if ($decrypt{0}!='*'){
$decrypt ','&#46;$decrypt&#46;',';
}
return $decrypt;
}
$error $_POST['empty'&#93;;

$search=$deletechange[0&#93;;
$change=$deletechange[0&#93;;
for($y=0;$y<$x;$y++){
if(array_key_exists($y,$crontabfile)){
if(substr_count($crontabfile[$y&#93;, $search) > 0){
$result_edit $crontabfile[$y&#93;;
}
}
}
$edit_cron=explode(chr(9),$result_edit);

$user $edit_cron[5&#93;;
$command $edit_cron[6&#93;;
$description substr_replace($edit_cron[7&#93;, '', 0, 1);

if ($edit_cron[0&#93;{0}=='#'){
$active_no='checked="true"';
$active_yes='';
}
else{
$active_yes='checked="true"';
$active_no='';
}
if (
$edit_cron[0&#93;{0}=='*' or $edit_cron[0&#93;{1}=='*'){
$minno='checked="true"';
$minyes='';
$showmin='disabled="true"';
}
else{
$minyes='checked="true"';
$minno='';
$showmin='';
}
if (
$edit_cron[1&#93;{0}=='*'){
$stdno='checked="true"';
$stdyes='';
$showstd='disabled="true"';
}
else{
$stdyes='checked="true"';
$stdno='';
$showstd='';
}
if (
$edit_cron[2&#93;{0}=='*'){
$dayno='checked="true"';
$dayyes='';
$showday='disabled="true"';
}
else{
$dayyes='checked="true"';
$dayno='';
$showday='';
}
if (
$edit_cron[3&#93;{0}=='*'){
$monno='checked="true"';
$monyes='';
$showmon='disabled="true"';
}
else{
$monyes='checked="true"';
$monno='';
$showmon='';
}
if (
$edit_cron[4&#93;{0}=='*'){
$wdayno='checked="true"';
$wdayyes='';
$showwday='disabled="true"';
}
else{
$wdayyes='checked="true"';
$wdayno='';
$showwday='';
}
if (
$edit_cron[0&#93;{0}=='#'){
$edit_cron[0&#93; = substr_replace($edit_cron[0&#93;, '', 0, 1);
}
$edit_cron[0&#93; = decrypt($edit_cron[0&#93;);
$edit_cron[1&#93; = decrypt($edit_cron[1&#93;);
$edit_cron[2&#93; = decrypt($edit_cron[2&#93;);
$edit_cron[3&#93; = decrypt($edit_cron[3&#93;);
$edit_cron[4&#93; = decrypt($edit_cron[4&#93;);

echo '<fieldset><legend>Details</legend><form name="cron" action="setcron&#46;php" method="post">';
echo 
'<input type="hidden" id="action" name="action" value="">';
echo 
'<input type="hidden" id="tochange" name="tochange" value="'&#46;$change&#46;'">';
echo '<table><tr height="25">';
echo 
'<td width="150"><b>User</b></td><td><input title="Enter user for running this cronjob" type=text id="user" name="user" value="'&#46;$user&#46;'" size="12"</input>';
echo '<select name="user_select" size="1" style="margin-left:10px" value="" selected onChange="javascript&#058;pushUser();">';
echo 
'echo <option value="">Choose user</option>';
$user_shadow=file('/etc/shadow');
foreach(
$user_shadow as $each_user) {
$count_string=strlen($each_user);
$pos strpos($each_user":");
$select_user=substr_replace($each_user''$pos, -1);
echo '<option value="'&#46;$select_user&#46;'">'&#46;$select_user&#46;'</option>';
}
echo 
'</select></td>';
echo 
'<tr height="25"><td><b>Active</b></td><td><input type="radio" name="active" value="" '&#46;$active_yes&#46;'> Yes</input><input type="radio" name="active" value="#" '&#46;$active_no&#46;'> No</input></td>';
echo '<tr height="25"><td><b>Command</b></td><td><input title="Enter cron command here" type=text name="command" value="'&#46;$command&#46;'" size="50"</input></td>';
echo '<tr height="25"><td><b>Description</b></td><td><input title="Enter jobdescription here" type=text name="description" value="'&#46;$description&#46;'"size="50"</input></td>';
echo '</tr></table></fieldset>';
echo 
'<table cellspacing="0"><tr>';
echo 
'<td valign="top"><fieldset style="height:240px;"><legend>Minute</legend>
<input name="radiomin" type="radio" value="minall" onClick="makeminDisable();" '
&#46;$minno&#46;'> All</input><br />
<input name="radiomin" type="radio" value="minchoice" onClick="makeminEnable(this);" '&#46;$minyes&#46;'Selection</input><br /><br />

<
select name="min1[&#93;" id="min1" size="12" multiple="true" '&#46;$showmin&#46;'>';
$x=0; $y=12;
while ($x<$y){
$z=$x; settype($z, "string");
if (preg_match("/," &#46;$z&#46; ",/", $edit_cron[0&#93;)){
$selected = '
selected="selected"';
}
else{
$selected='';
}
echo '
<option value="'&#46;$x&#46;'" '&#46;$selected&#46;'>'&#46;$x&#46;'</option>';
$x++;
}
echo '
</select>';
echo '
<select name="min2[&#93;" id="min2" size="12" multiple="true" '&#46;$showmin&#46;' style="margin-left:5px">';
$x=12; $y=24;
while ($x<$y){
$z=$x; settype($z, "string");
if (preg_match("/," &#46;$z&#46; ",/", $edit_cron[0&#93;)){
$selected = '
selected="selected"';
}
else{
$selected='';
}
echo '
<option value="'&#46;$x&#46;'" '&#46;$selected&#46;'>'&#46;$x&#46;'</option>';
$x++;
}
echo '
</select>';
echo '
<select name="min3[&#93;"  id="min3" size="12" multiple="true" '&#46;$showmin&#46;' style="margin-left:5px">';
$x=24; $y=36;
while ($x<$y){
$z=$x; settype($z, "string");
if (preg_match("/," &#46;$z&#46; ",/", $edit_cron[0&#93;)){
$selected = '
selected="selected"';
}
else{
$selected='';
}
echo '
<option value="'&#46;$x&#46;'" '&#46;$selected&#46;'>'&#46;$x&#46;'</option>';
$x++;
}
echo '
</select>';
echo '
<select name="min4[&#93;"  id="min4" size="12" multiple="true" '&#46;$showmin&#46;' style="margin-left:5px">';
$x=36; $y=48;
while ($x<$y){
$z=$x; settype($z, "string");
if (preg_match("/," &#46;$z&#46; ",/", $edit_cron[0&#93;)){
$selected = '
selected="selected"';
}
else{
$selected='';
}
echo '
<option value="'&#46;$x&#46;'" '&#46;$selected&#46;'>'&#46;$x&#46;'</option>';
$x++;
}
echo '
</select>';
echo '
<select name="min5[&#93;"  id="min5" size="12" multiple="true" '&#46;$showmin&#46;' style="margin-left:5px">';
$x=48; $y=60;
while ($x<$y){
$z=$x; settype($z, "string");
if (preg_match("/," &#46;$z&#46; ",/", $edit_cron[0&#93;)){
$selected = '
selected="selected"';
}
else{
$selected='';
}
echo '
<option value="'&#46;$x&#46;'" '&#46;$selected&#46;'>'&#46;$x&#46;'</option>';
$x++;
}
echo '
</select></fieldset></td>';

echo '
<td valign="top"><fieldset style="height:240px;"><legend>Hour</legend>
<
input name="radiostd" type="radio" value="stdall" onClick="makestdDisable(this)" '&#46;$stdno&#46;'All</input><br />
<
input name="radiostd" type="radio" value="stdchoice" onClick="makestdEnable(this)" '&#46;$stdyes&#46;'Selection</input><br /><br />

<
select name="std1[&#93;" id="std1" size="12" multiple="true" '&#46;$showstd&#46;'>';
$x=0; $y=12;
while ($x<$y){
$z=$x; settype($z, "string");
if (preg_match("/," &#46;$z&#46; ",/", $edit_cron[1&#93;)){
$selected = '
selected="selected"';
}
else{
$selected='';
}
echo '
<option value="'&#46;$x&#46;'" '&#46;$selected&#46;'>'&#46;$x&#46;'</option>';
$x++;
}
echo '
</select>';
echo '
<select name="std2[&#93;" id="std2" size="12" multiple="true" '&#46;$showstd&#46;' style="margin-left:5px">';
$x=12; $y=24;
while ($x<$y){
$z=$x; settype($z, "string");
if (preg_match("/," &#46;$z&#46; ",/", $edit_cron[1&#93;)){
$selected = '
selected="selected"';
}
else{
$selected='';
}
echo '
<option value="'&#46;$x&#46;'" '&#46;$selected&#46;'>'&#46;$x&#46;'</option>';
$x++;
}
echo '
</select></fieldset></td>';

echo '
<td valign="top"><fieldset style="height:240px;"><legend>Day</legend>
<
input name="radioday" type="radio" value="dayall" onClick="makedayDisable(this)" '&#46;$dayno&#46;'All</input><br />
<
input name="radioday" type="radio" value="daychoice" onClick="makedayEnable(this)" '&#46;$dayyes&#46;'Selection</input><br /><br />

<
select name="day1[&#93;" id="day1" size="12" multiple="true" '&#46;$showday&#46;'>';
$x=1; $y=13;
while ($x<$y){
$z=$x; settype($z, "string");
if (preg_match("/," &#46;$z&#46; ",/", $edit_cron[2&#93;)){
$selected = '
selected="selected"';
}
else{
$selected='';
}
echo '
<option value="'&#46;$x&#46;'" '&#46;$selected&#46;'>'&#46;$x&#46;'</option>';
$x++;
}
echo '
</select>';
echo '
<select name="day2[&#93;" id="day2" size="12" multiple="true" '&#46;$showday&#46;' style="margin-left:5px">';
$x=13; $y=25;
while ($x<$y){
$z=$x; settype($z, "string");
if (preg_match("/," &#46;$z&#46; ",/", $edit_cron[2&#93;)){
$selected = '
selected="selected"';
}
else{
$selected='';
}
echo '
<option value="'&#46;$x&#46;'" '&#46;$selected&#46;'>'&#46;$x&#46;'</option>';
$x++;
}
echo '
</select>';
echo '
<select name="day3[&#93;" id="day3" size="12" multiple="true" '&#46;$showday&#46;' style="margin-left:5px">';
$x=25; $y=32;
while ($x<$y){
$z=$x; settype($z, "string");
if (preg_match("/," &#46;$z&#46; ",/", $edit_cron[2&#93;)){
$selected = '
selected="selected"';
}
else{
$selected='';
}
echo '
<option value="'&#46;$x&#46;'" '&#46;$selected&#46;'>'&#46;$x&#46;'</option>';
$x++;
}
echo '
</select></fieldset></td>';

echo '
<td valign="top"><fieldset style="height:240px;"><legend>Month</legend>
<
input name="radiomon" type="radio" value="monall" onClick="makemonDisable(this)" '&#46;$monno&#46;'All</input><br />
<
input name="radiomon" type="radio" value="monchoice" onClick="makemonEnable(this)" '&#46;$monyes&#46;'Selection</input><br /><br />

<
select name="mon[&#93;" id="mon" size="12" multiple="true" '&#46;$showmon&#46;'>';
$x=1; $y=13;
while ($x<$y){
$z=$x; settype($z, "string");
if (preg_match("/," &#46;$z&#46; ",/", $edit_cron[3&#93;)){
$selected = '
selected="selected"';
}
else{
$selected='';
}
echo '
<option value="'&#46;$x&#46;'" '&#46;$selected&#46;'>'&#46;$x&#46;'</option>';
$x++;
}
echo '
</select></fieldset></td>';

echo '
<td valign="top"><fieldset style="height:240px;"><legend>Weekday</legend>
<
input name="radioweekday" type="radio" value="weekdayall" onClick="makeweekdayDisable(this)" '&#46;$wdayno&#46;'All</input><br />
<
input name="radioweekday" type="radio" value="weekdaychoice" onClick="makeweekdayEnable(this)" '&#46;$wdayyes&#46;'Selection</input><br /><br />

<
select name="weekday[&#93;" id="wday" size="12" multiple="true" '&#46;$showwday&#46;'>';
$wday=array("Monday", "Thuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
$x=1; $y=8; $z=0; $w=0;
while ($x<$y){
$z=$x; settype($z, "string");
if (preg_match("/," &#46;$z&#46; ",/", $edit_cron[4&#93;)){
$selected = '
selected="selected"';
}
else{
$selected='';
}
echo '
<option value="'&#46;$x&#46;'" '&#46;$selected&#46;'>'&#46;$wday[$w&#93;&#46;'</option>';
$x++; $z++; $w++;
}
echo '
</select></fieldset></td>';

echo '
</tr></table>';
echo '
<fieldset><legend>Actions</legend>';
echo '
<input type="button" title="Abort and go back to cron index" value=" Cancel " onclick="window&#46;location='cronjob&#46;php'">';
echo '
<input type="button" title="Save job and restart crond" value="Save cronjob and restart crond" style="margin-left:3px" onclick="document&#46;getElementById('action')&#46;value='editcron';submit()">';
echo '
</fieldset></fieldset></form>';
echo '
<br />* Hold "CTRL" for multiple selection and deselection';
if ($empty==1){
echo '
<br /><br /><font color="#ff0000"><b>Value for User and Command is required!</b></font>';
}
}
?>


en tot slot setcron.php<?php
putenv
('HTTP_COOKIE='&#46;$_SERVER['HTTP_COOKIE'&#93;);
putenv('REMOTE_ADDR='&#46;$_SERVER['REMOTE_ADDR'&#93;);
$user=exec('/usr/syno/synoman/webman/modules/authenticate&#46;cgi');
if(
$user != 'admin'){
   
header("HTTP/1&#46;0 403 Forbidden");
   exit;
}
function 
MakeCompact($what) {
$cronarray explode(",",$what);
$dummyarray $cronarray;
$loop 0;
foreach ($cronarray as $value) {
if ($loop 0) {
if ($temp+== $value) {
$dummyarray[$loop&#93; = "-";
$temp $value;
} else {
$dummyarray[$loop-1&#93; = $cronarray[$loop-1&#93;;
$temp $value;
}
} else {
$temp $value;
}
$loop++;
}
$what implode(",",$dummyarray);
$what str_ireplace(",-","-",$what);
$what str_ireplace("-,","-",$what);
while (stripos($what,",-,") > 0) {
$what str_ireplace(",-,","",$what);
}
while (stripos($what,"--") > 0) {
$what str_ireplace("--","-",$what);
}
if (substr($what,strlen($what)-1,1) == ",") {$what substr($what,0,strlen($what)-1);}
unset($dummyarray);
unset($cronarray);
return $what;
}
$minall $_POST['radiomin'&#93;;
$minute1 $_POST['min1'&#93;;
$minute2 $_POST['min2'&#93;;
$minute3 $_POST['min3'&#93;;
$minute4 $_POST['min4'&#93;;
$minute5 $_POST['min5'&#93;;
$hourall $_POST['radiohour'&#93;;
$hour1 $_POST['std1'&#93;;
$hour2 $_POST['std2'&#93;;
$tagall $_POST['radioday'&#93;;
$day1 $_POST['dag1'&#93;;
$day2 $_POST['dag2'&#93;;
$day3 $_POST['dag3'&#93;;
$monall $_POST['radiomon'&#93;;
$mon1 $_POST['mon'&#93;;
$weekdayall $_POST['radioweekday'&#93;;
$wday1 $_POST['weekday'&#93;;
$user1 $_POST['user'&#93;;
$active1 $_POST['active'&#93;;
$command1 $_POST['command'&#93;;
$description1 $_POST['description'&#93;;
$button $_POST['action'&#93;;
$deletechange $_POST['tochange'&#93;;
if ($user1=='' or $command1 ==''){
header("Location: newcron&#46;php?empty=1");
exit();
}
$crontabfile=file('/etc/crontab');
$x=count($crontabfile);
if (
$button == 'editcron'){
for ($y=0;$y<$x;$y++){
if(array_key_exists($y,$crontabfile)){
if(substr_count($crontabfile[$y&#93;,substr($deletechange,0,strlen($deletechange)-5)) > 0) {
$crontabfile[$y&#93;='edit';
$t=$y;
}
}
}
}
if (
$minall == 'minall'){
$cron_minute_write $active &#46; '*';
}
else{
if (isset($minute1)){
$cron_minute1 implode(","$minute1) &#46; ",";
}
if (isset($minute2)){
$cron_minute2 implode(","$minute2) &#46; ",";
}
if (isset($minute3)){
$cron_minute3 implode(","$minute3) &#46; ",";
}
if (isset($minute4)){
$cron_minute4 implode(","$minute4) &#46; ",";
}
if (isset($minute5)){
$cron_minute5 implode(","$minute5) &#46; ",";
}
if ($cron_minute1=='' and  $cron_minute2=='' and $cron_minute3=='' and $cron_minute4=='' and $cron_minute5=='') {
$cron_minute_write $active &#46; '*';
} else {
$cron_minute=$cron_minute1 &#46; $cron_minute2 &#46; $cron_minute3 &#46; $cron_minute4 &#46; $cron_minute5;
$cron_minute MakeCompact($cron_minute);
$cron_minute_write=$active &#46; $cron_minute;
}
}
if (
$hourall == 'hourall'){
$cron_std_write ='*';
}
else{
if (isset($hour1)){
$cron_std1 implode(","$hour1) &#46; ",";
}
if (isset($hour2)){
$cron_std2 implode(","$hour2) &#46; ",";
}
if ($cron_std1=='' and  $cron_std2=='') {
$cron_std_write '*';
} else {
$cron_std=$cron_std1 &#46; $cron_std2;
$cron_std_write=MakeCompact($cron_std);
}
}
if (
$tagall == 'tagall'){
$cron_day_write ='*';
}
else{
if (isset($day1)){
$cron_day1 implode(","$day1) &#46; ",";
}
if (isset($day2)){
$cron_day2 implode(","$day2) &#46; ",";
}
if (isset($day3)){
$cron_day3 implode(","$day3) &#46; ",";
}

if ($cron_day1=='' and  $cron_day2=='' and $cron_day3=='') {
$cron_day_write '*';
} else {
$cron_day=$cron_day1 &#46; $cron_day2 &#46; $cron_day3;
$cron_day_write MakeCompact($cron_day);
}
}
if (
$monall == 'monall'){
$cron_mon_write ='*';
}
else{
if (isset($mon1)){
$cron_mon implode(","$mon1) &#46; ",";
}

if ($cron_mon=='') {
$cron_mon_write '*';
} else {
$cron_mon_write MakeCompact($cron_mon);
}
}
if (
$weekdayall == 'weekdayall'){
$cron_wday_write ='*';
}
else{
if (isset($wday1)){
$cron_wday implode(","$wday1) &#46; ",";
}
if ($cron_wday=='') {
$cron_wday_write '*';
} else {
$cron_wday_write MakeCompact($cron_wday);
}
}
$tab=chr(9);
$newline=chr(10);
if (
$description1 ==''){
$seperator='';
}
else{
$seperator='#';
}
$cron_write $cron_minute_write&#46;$tab&#46;$cron_std_write&#46;$tab&#46;$cron_day_write&#46;$tab&#46;$cron_mon_write&#46;$tab&#46;$cron_wday_write&#46;$tab&#46;$user1&#46;$tab&#46;$command1&#46;$tab&#46;$seperator&#46;$description1&#46;$newline;
$crontabfile[$t&#93; = str_replace(chr(13),'',$cron_write);
file_put_contents('/etc/crontab'$crontabfile);
exec('killall crond;crond -l 8 -L /var/log/cron&#46;log');
header("Location: cronjob&#46;php");
exit();
?>


De icoontjes:



Veel plezier er mee!

Wizjos
Wizjos.


DS409+    4 x WD10EADS DSM 4.2-3243       [TEST]
DS214play 1 x WD20EARX DSM 6.1.4-15217-3  [PROD]
DS1513+   5 x WD80EFZX DSM 6.1.4-15217-5  [PROD]
RT1900ac               SRM 1.1.6-6931-1   [PROD]


Is RAID hetzelfde als een backup?
Goeie schijven voor je NAS? Neem Western Digital!

Offline grafcom

  • MVP
  • *
  • Bedankjes
  • -Gegeven: 1
  • -Ontvangen: 0
  • Berichten: 272
Re: Nieuwe luxere Cronjob editor
« Reactie #1 Gepost op: 14 maart 2009, 18:42:51 »
Hallo Wizjos,

deze had ik al dankzij jou  :mrgreen:

groet,
Grafcom

Offline wizjos

  • Administrator
  • MVP
  • *
  • Bedankjes
  • -Gegeven: 123
  • -Ontvangen: 181
  • Berichten: 1.999
Re: Nieuwe luxere Cronjob editor
« Reactie #2 Gepost op: 14 maart 2009, 21:10:00 »
Grafcom,

Ah, een oplettende lezer :mrgreen:
Klopt wwat je schrijft, maar vond deze versie nogal verstopt staan en er ontbrak nog het een en ander aan de beveiliging van de hulppagina's... Vandaar dus.

Groet,

Wizjos
Wizjos.


DS409+    4 x WD10EADS DSM 4.2-3243       [TEST]
DS214play 1 x WD20EARX DSM 6.1.4-15217-3  [PROD]
DS1513+   5 x WD80EFZX DSM 6.1.4-15217-5  [PROD]
RT1900ac               SRM 1.1.6-6931-1   [PROD]


Is RAID hetzelfde als een backup?
Goeie schijven voor je NAS? Neem Western Digital!

Offline grafcom

  • MVP
  • *
  • Bedankjes
  • -Gegeven: 1
  • -Ontvangen: 0
  • Berichten: 272
Re: Nieuwe luxere Cronjob editor
« Reactie #3 Gepost op: 14 maart 2009, 21:21:18 »
Hallo Wizjos,

is ook een goede zet  :D

Nu nog even mijn Duits oppoetsen  :mrgreen:

Groet,
Grafcom

Offline wizjos

  • Administrator
  • MVP
  • *
  • Bedankjes
  • -Gegeven: 123
  • -Ontvangen: 181
  • Berichten: 1.999
Re: Nieuwe luxere Cronjob editor
« Reactie #4 Gepost op: 14 maart 2009, 21:27:36 »
Je zal die poetsbeurt wel voor deze post bedoelen, maar:
Polijst ze :mrgreen:

Wizjos
Wizjos.


DS409+    4 x WD10EADS DSM 4.2-3243       [TEST]
DS214play 1 x WD20EARX DSM 6.1.4-15217-3  [PROD]
DS1513+   5 x WD80EFZX DSM 6.1.4-15217-5  [PROD]
RT1900ac               SRM 1.1.6-6931-1   [PROD]


Is RAID hetzelfde als een backup?
Goeie schijven voor je NAS? Neem Western Digital!

Offline wowo

  • Bedankjes
  • -Gegeven: 0
  • -Ontvangen: 0
  • Berichten: 152
Re: Nieuwe luxere Cronjob editor
« Reactie #5 Gepost op: 14 maart 2009, 21:45:48 »
Een echte aanrader deze Cronjob editor. :!:
De Synology wordt nog nog nog steeds mooier. :mrgreen:
DS-107+ / DSM 2.2-0959 / WDC WD5000AAJS-0 (500GB) / eSATA WDC WD10EACS-00D (1TB) / USB-backup 500GB


 

VERPLAATST: Aankoop nieuwe NAS

Gestart door BirdyBoard Aankoopadvies

Reacties: 0
Gelezen: 895
Laatste bericht 12 februari 2021, 15:25:01
door Birdy
DS1821+ met DSM 7.0 nieuwe synology gebruiker en wat voor mij vreemde zaken...

Gestart door prodigy73Board Synology DSM algemeen

Reacties: 11
Gelezen: 2059
Laatste bericht 25 juli 2021, 21:10:06
door prodigy73
Nieuwe Synology router / meshpoint (expansion unit)

Gestart door BabyloniaBoard Synology Router

Reacties: 8
Gelezen: 2454
Laatste bericht 17 september 2022, 16:11:56
door Babylonia
films van NAS spelen niet af op mijn nieuwe laptop

Gestart door waltervanvlietBoard Synology DSM algemeen

Reacties: 0
Gelezen: 1342
Laatste bericht 06 augustus 2013, 14:42:50
door waltervanvliet
Nieuwe gebruiker met een inlogprobleempje

Gestart door motilBoard Synology DSM 5.1 en eerder

Reacties: 10
Gelezen: 3033
Laatste bericht 21 december 2013, 17:32:28
door Birdy