2010-01-25 13:40:17 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This file is part of the Froxlor project.
|
|
|
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the COPYING
|
|
|
|
* file that was distributed with this source code. You can also view the
|
|
|
|
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
|
|
|
*
|
|
|
|
* @copyright (c) the authors
|
|
|
|
* @author Froxlor team <team@froxlor.org> (2010-)
|
|
|
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
2010-01-25 15:32:36 +00:00
|
|
|
* @package Panel
|
2011-05-04 09:59:20 +00:00
|
|
|
*
|
2010-01-25 13:40:17 +00:00
|
|
|
*/
|
|
|
|
|
2010-01-25 15:32:36 +00:00
|
|
|
define('AREA', 'admin');
|
2013-11-18 11:53:33 +00:00
|
|
|
require './lib/init.php';
|
2010-01-25 15:32:36 +00:00
|
|
|
|
2013-04-27 07:22:23 +00:00
|
|
|
if (isset($_POST['id'])) {
|
2010-01-25 15:32:36 +00:00
|
|
|
$id = intval($_POST['id']);
|
2013-04-27 07:22:23 +00:00
|
|
|
} elseif(isset($_GET['id'])) {
|
2010-01-25 15:32:36 +00:00
|
|
|
$id = intval($_GET['id']);
|
2010-01-25 13:40:17 +00:00
|
|
|
}
|
2010-01-25 15:32:36 +00:00
|
|
|
|
2013-04-27 07:22:23 +00:00
|
|
|
if ($page == 'cronjobs' || $page == 'overview') {
|
|
|
|
if ($action == '') {
|
|
|
|
$log->logAction(ADM_ACTION, LOG_NOTICE, 'viewed admin_cronjobs');
|
2010-01-27 09:19:19 +00:00
|
|
|
|
|
|
|
$fields = array(
|
|
|
|
'c.lastrun' => $lng['cron']['lastrun'],
|
|
|
|
'c.interval' => $lng['cron']['interval'],
|
|
|
|
'c.isactive' => $lng['cron']['isactive']
|
|
|
|
);
|
2013-11-18 08:09:06 +00:00
|
|
|
$paging = new paging($userinfo, TABLE_PANEL_CRONRUNS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
|
2010-01-27 09:19:19 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @TODO Fix sorting
|
|
|
|
*/
|
|
|
|
$crons = '';
|
2013-10-29 08:02:49 +00:00
|
|
|
$result_stmt = Database::prepare("SELECT `c`.* FROM `" . TABLE_PANEL_CRONRUNS . "` `c` ORDER BY `cronfile` ASC");
|
|
|
|
Database::pexecute($result_stmt);
|
|
|
|
$paging->setEntries(Database::num_rows());
|
2010-01-27 09:19:19 +00:00
|
|
|
$sortcode = $paging->getHtmlSortCode($lng);
|
|
|
|
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
|
|
|
$searchcode = $paging->getHtmlSearchCode($lng);
|
|
|
|
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
|
|
|
|
|
|
|
$i = 0;
|
|
|
|
$count = 0;
|
|
|
|
|
2013-10-29 08:02:49 +00:00
|
|
|
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2013-04-27 07:22:23 +00:00
|
|
|
if ($paging->checkDisplay($i)) {
|
2010-01-27 09:19:19 +00:00
|
|
|
$row = htmlentities_array($row);
|
2013-04-27 07:22:23 +00:00
|
|
|
|
2010-01-27 09:19:19 +00:00
|
|
|
$row['lastrun'] = date('d.m.Y H:i', $row['lastrun']);
|
2013-04-27 07:22:23 +00:00
|
|
|
$row['isactive'] = ((int)$row['isactive'] == 1) ? $lng['panel']['yes'] : $lng['panel']['no'];
|
|
|
|
|
2010-01-28 11:17:55 +00:00
|
|
|
$description = $lng['crondesc'][$row['desc_lng_key']];
|
2013-04-27 07:22:23 +00:00
|
|
|
|
|
|
|
eval("\$crons.=\"" . getTemplate('cronjobs/cronjobs_cronjob') . "\";");
|
2010-01-27 09:19:19 +00:00
|
|
|
$count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
|
2013-04-27 07:22:23 +00:00
|
|
|
eval("echo \"" . getTemplate('cronjobs/cronjobs') . "\";");
|
2010-01-27 09:19:19 +00:00
|
|
|
|
2013-04-27 07:22:23 +00:00
|
|
|
} elseif ($action == 'new') {
|
2010-01-27 09:19:19 +00:00
|
|
|
/*
|
2010-03-26 08:42:13 +00:00
|
|
|
* @TODO later
|
2010-01-27 09:19:19 +00:00
|
|
|
*/
|
2013-04-27 07:22:23 +00:00
|
|
|
} elseif ($action == 'edit' && $id != 0) {
|
2013-10-29 08:02:49 +00:00
|
|
|
$result_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_CRONRUNS . "` WHERE `id`= :id");
|
|
|
|
Database::pexecute($result_stmt, array('id' => $id));
|
|
|
|
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
|
2013-04-27 07:22:23 +00:00
|
|
|
if ($result['cronfile'] != '') {
|
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
2012-06-25 07:27:39 +00:00
|
|
|
$isactive = isset($_POST['isactive']) ? 1 : 0;
|
2010-03-26 08:42:13 +00:00
|
|
|
$interval_value = validate($_POST['interval_value'], 'interval_value', '/^([0-9]+)$/Di', 'stringisempty');
|
|
|
|
$interval_interval = validate($_POST['interval_interval'], 'interval_interval');
|
2013-04-27 07:22:23 +00:00
|
|
|
|
|
|
|
if ($isactive != 1) {
|
2010-03-26 08:42:13 +00:00
|
|
|
$isactive = 0;
|
|
|
|
}
|
2013-04-27 07:22:23 +00:00
|
|
|
|
|
|
|
$interval = $interval_value . ' ' . strtoupper($interval_interval);
|
|
|
|
|
2013-10-29 08:02:49 +00:00
|
|
|
$upd = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_CRONRUNS . "`
|
|
|
|
SET `isactive` = :isactive, `interval` = :int
|
|
|
|
WHERE `id` = :id"
|
|
|
|
);
|
|
|
|
Database::pexecute($upd, array('isactive' => $isactive, 'int' => $interval, 'id' => $id));
|
2010-03-26 08:42:13 +00:00
|
|
|
|
|
|
|
redirectTo($filename, Array('page' => $page, 's' => $s));
|
2013-04-27 07:22:23 +00:00
|
|
|
} else {
|
2012-06-25 07:27:39 +00:00
|
|
|
//$isactive = makeyesno('isactive', '1', '0', $result['isactive']);
|
2010-03-26 08:42:13 +00:00
|
|
|
// interval
|
|
|
|
$interval_nfo = explode(' ', $result['interval']);
|
|
|
|
$interval_value = $interval_nfo[0];
|
|
|
|
|
|
|
|
$interval_interval = '';
|
2013-04-27 07:22:23 +00:00
|
|
|
$interval_interval .= makeoption($lng['cronmgmt']['seconds'], 'SECOND', $interval_nfo[1]);
|
|
|
|
$interval_interval .= makeoption($lng['cronmgmt']['minutes'], 'MINUTE', $interval_nfo[1]);
|
|
|
|
$interval_interval .= makeoption($lng['cronmgmt']['hours'], 'HOUR', $interval_nfo[1]);
|
|
|
|
$interval_interval .= makeoption($lng['cronmgmt']['days'], 'DAY', $interval_nfo[1]);
|
|
|
|
$interval_interval .= makeoption($lng['cronmgmt']['weeks'], 'WEEK', $interval_nfo[1]);
|
|
|
|
$interval_interval .= makeoption($lng['cronmgmt']['months'], 'MONTH', $interval_nfo[1]);
|
2010-03-26 08:42:13 +00:00
|
|
|
// end of interval
|
2013-04-27 07:22:23 +00:00
|
|
|
|
2010-03-26 08:42:13 +00:00
|
|
|
$change_cronfile = false;
|
2013-04-27 07:22:23 +00:00
|
|
|
if (substr($result['module'], 0, strpos($result['module'], '/')) != 'froxlor') {
|
2010-03-26 08:42:13 +00:00
|
|
|
$change_cronfile = true;
|
|
|
|
}
|
2011-02-08 11:53:24 +00:00
|
|
|
|
|
|
|
$cronjobs_edit_data = include_once dirname(__FILE__).'/lib/formfields/admin/cronjobs/formfield.cronjobs_edit.php';
|
|
|
|
$cronjobs_edit_form = htmlform::genHTMLForm($cronjobs_edit_data);
|
|
|
|
|
|
|
|
$title = $cronjobs_edit_data['cronjobs_edit']['title'];
|
|
|
|
$image = $cronjobs_edit_data['cronjobs_edit']['image'];
|
|
|
|
|
2013-04-27 07:22:23 +00:00
|
|
|
eval("echo \"" . getTemplate('cronjobs/cronjob_edit') . "\";");
|
2010-03-26 08:42:13 +00:00
|
|
|
}
|
|
|
|
}
|
2010-01-25 15:32:36 +00:00
|
|
|
}
|
2013-04-27 07:22:23 +00:00
|
|
|
elseif ($action == 'delete' && $id != 0) {
|
2010-01-27 09:19:19 +00:00
|
|
|
/*
|
2010-03-26 08:42:13 +00:00
|
|
|
* @TODO later
|
2010-01-27 09:19:19 +00:00
|
|
|
*/
|
2010-01-25 15:32:36 +00:00
|
|
|
}
|
|
|
|
}
|