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
|
|
|
|
2018-12-19 15:57:03 +00:00
|
|
|
use Froxlor\Database\Database;
|
2018-12-18 12:45:05 +00:00
|
|
|
use Froxlor\Api\Commands\Cronjobs as Cronjobs;
|
|
|
|
|
2013-04-27 07:22:23 +00:00
|
|
|
if (isset($_POST['id'])) {
|
2010-01-25 15:32:36 +00:00
|
|
|
$id = intval($_POST['id']);
|
2018-12-19 15:57:03 +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 == '') {
|
2018-12-26 14:51:26 +00:00
|
|
|
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'viewed admin_cronjobs');
|
2010-01-27 09:19:19 +00:00
|
|
|
|
|
|
|
$fields = array(
|
2018-12-22 07:15:31 +00:00
|
|
|
'c.lastrun' => $lng['cron']['lastrun'],
|
|
|
|
'c.interval' => $lng['cron']['interval'],
|
|
|
|
'c.isactive' => $lng['cron']['isactive']
|
2010-01-27 09:19:19 +00:00
|
|
|
);
|
2018-12-22 07:15:31 +00:00
|
|
|
$paging = new \Froxlor\UI\Paging($userinfo, TABLE_PANEL_CRONRUNS, $fields);
|
2010-01-27 09:19:19 +00:00
|
|
|
|
|
|
|
$crons = '';
|
2013-12-17 08:59:11 +00:00
|
|
|
$result_stmt = Database::prepare("SELECT `c`.* FROM `" . TABLE_PANEL_CRONRUNS . "` `c` ORDER BY `module` ASC, `cronfile` ASC");
|
2013-10-29 08:02:49 +00:00
|
|
|
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-12-17 08:59:11 +00:00
|
|
|
$cmod = '';
|
2010-01-27 09:19:19 +00:00
|
|
|
|
2013-10-29 08:02:49 +00:00
|
|
|
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2013-12-17 08:59:11 +00:00
|
|
|
if ($cmod != $row['module']) {
|
2013-12-19 11:17:56 +00:00
|
|
|
$_mod = explode("/", $row['module']);
|
|
|
|
$module = ucfirst($_mod[1]);
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("\$crons.=\"" . \Froxlor\UI\Template::getTemplate('cronjobs/cronjobs_cronjobmodule') . "\";");
|
2013-12-17 08:59:11 +00:00
|
|
|
$cmod = $row['module'];
|
|
|
|
}
|
2013-04-27 07:22:23 +00:00
|
|
|
if ($paging->checkDisplay($i)) {
|
2018-12-24 12:50:45 +00:00
|
|
|
$row = \Froxlor\PhpHelper::htmlentitiesArray($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']);
|
2018-12-22 07:15:31 +00:00
|
|
|
$row['isactive'] = ((int) $row['isactive'] == 1) ? $lng['panel']['yes'] : $lng['panel']['no'];
|
2013-04-27 07:22:23 +00:00
|
|
|
|
2018-12-22 07:15:31 +00:00
|
|
|
$description = $lng['crondesc'][$row['desc_lng_key']];
|
2013-04-27 07:22:23 +00:00
|
|
|
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("\$crons.=\"" . \Froxlor\UI\Template::getTemplate('cronjobs/cronjobs_cronjob') . "\";");
|
2018-12-19 15:57:03 +00:00
|
|
|
$count ++;
|
2010-01-27 09:19:19 +00:00
|
|
|
}
|
|
|
|
|
2018-12-19 15:57:03 +00:00
|
|
|
$i ++;
|
2010-01-27 09:19:19 +00:00
|
|
|
}
|
|
|
|
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("echo \"" . \Froxlor\UI\Template::getTemplate('cronjobs/cronjobs') . "\";");
|
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) {
|
2018-10-28 07:53:25 +00:00
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
$json_result = Cronjobs::getLocal($userinfo, array(
|
2018-10-28 07:53:25 +00:00
|
|
|
'id' => $id
|
|
|
|
))->get();
|
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2018-10-28 07:53:25 +00:00
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
2013-04-27 07:22:23 +00:00
|
|
|
if ($result['cronfile'] != '') {
|
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
2018-10-28 07:53:25 +00:00
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
Cronjobs::getLocal($userinfo, $_POST)->update();
|
2018-10-28 07:53:25 +00:00
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2010-03-26 08:42:13 +00:00
|
|
|
}
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::redirectTo($filename, array(
|
2018-12-19 15:57:03 +00:00
|
|
|
'page' => $page,
|
|
|
|
's' => $s
|
|
|
|
));
|
2013-04-27 07:22:23 +00:00
|
|
|
} else {
|
2014-01-13 07:55:39 +00:00
|
|
|
|
2010-03-26 08:42:13 +00:00
|
|
|
// interval
|
|
|
|
$interval_nfo = explode(' ', $result['interval']);
|
2015-06-10 12:59:38 +00:00
|
|
|
$interval_value = $interval_nfo[0];
|
2010-03-26 08:42:13 +00:00
|
|
|
|
|
|
|
$interval_interval = '';
|
2018-12-22 07:15:31 +00:00
|
|
|
$interval_interval .= \Froxlor\UI\HTML::makeoption($lng['cronmgmt']['minutes'], 'MINUTE', $interval_nfo[1]);
|
|
|
|
$interval_interval .= \Froxlor\UI\HTML::makeoption($lng['cronmgmt']['hours'], 'HOUR', $interval_nfo[1]);
|
|
|
|
$interval_interval .= \Froxlor\UI\HTML::makeoption($lng['cronmgmt']['days'], 'DAY', $interval_nfo[1]);
|
|
|
|
$interval_interval .= \Froxlor\UI\HTML::makeoption($lng['cronmgmt']['weeks'], 'WEEK', $interval_nfo[1]);
|
|
|
|
$interval_interval .= \Froxlor\UI\HTML::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
|
|
|
|
2018-12-19 15:57:03 +00:00
|
|
|
$cronjobs_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/cronjobs/formfield.cronjobs_edit.php';
|
2018-12-21 10:22:03 +00:00
|
|
|
$cronjobs_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($cronjobs_edit_data);
|
2015-06-10 12:59:38 +00:00
|
|
|
|
|
|
|
$title = $cronjobs_edit_data['cronjobs_edit']['title'];
|
|
|
|
$image = $cronjobs_edit_data['cronjobs_edit']['image'];
|
2011-02-08 11:53:24 +00:00
|
|
|
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("echo \"" . \Froxlor\UI\Template::getTemplate('cronjobs/cronjob_edit') . "\";");
|
2010-03-26 08:42:13 +00:00
|
|
|
}
|
|
|
|
}
|
2018-12-19 15:57:03 +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
|
|
|
}
|
|
|
|
}
|