5. rewrite cronjobs_add.php whith
Code:
<?php
/**
* ispCP П‰ (OMEGA) a Virtual Hosting Control System
*
* @copyright 2001-2006 by moleSoftware GmbH
* @copyright 2006-2008 by ispCP | http://isp-control.net
* @version SVN: $Id$
* @link http://isp-control.net
* @author ispCP Team
*
* @license
* This program is free software; you can redistribute it and/or modify it under
* the terms of the MPL General Public License as published by the Free Software
* Foundation; either version 1.1 of the License, or (at your option) any later
* version.
* You should have received a copy of the MPL Mozilla Public License along with
* this program; if not, write to the Open Source Initiative (OSI)
* http://opensource.org | osi@opensource.org
*/
require '../include/ispcp-lib.php';
check_login(__FILE__);
$tpl = new pTemplate();
$tpl->define_dynamic('page', Config::get('CLIENT_TEMPLATE_PATH') . '/cronjobs_add.tpl');
$tpl->define_dynamic('page_message', 'page');
$tpl->define_dynamic('logged_from', 'page');
$theme_color = Config::get('USER_INITIAL_THEME');
$tpl->assign(
array('TR_CLIENT_CRONJOBS_TITLE' => tr('ispCP - Client/Cronjob Manager'),
'THEME_COLOR_PATH' => "../themes/$theme_color",
'THEME_CHARSET' => tr('encoding'),
'ISP_LOGO' => get_logo($_SESSION['user_id'])
)
);
function add_cron_job(&$tpl, &$sql, $user_id) {
/*
(с) Sergey Obookhoff, www.data-stream.ru
Russia, Moscow
*/
if (!isset($_POST['Submit'])) {
return;
}
if ((empty($_POST['name']) | empty($_POST['description']) | empty($_POST['command_line']) | empty($_POST['min']) | empty($_POST['hour']) | empty($_POST['day_of_month']) | empty($_POST['month']) | empty($_POST['day_of_week'])) && isset($_POST['Submit'])) {
set_page_message(tr('Please type All Fields and Values!'));
return;
}
foreach($_POST as $key => $value)
{
$a = $key;
$$a = $value;
}
if ($activ == 0) {$cron_status = "ok";}
else {$cron_status = Config::get('ITEM_ADD_STATUS');}
// add cron_job in the ispcp DB;
$query = "
INSERT INTO `cron_jobs`
(`admin_id`, `cron_name`, `cron_desc`, `min`, `hour`, `day`, `month`, `week`, `command`, `cron_activ`, `cron_status`)
VALUES
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
";
$rs = exec_query($sql, $query, array($user_id, $name, $description, $min, $hour, $day_of_month, $month, $day_of_week, $command_line, $activ, $cron_status));
$query = "
SELECT
`cron_id`
`cron_name`
FROM
`cron_jobs`
WHERE
`cron_name` = ?
";
$rs = exec_query($sql, $query, array($name));
$cron_name = $rs->fields['cron_name'];
send_request();
write_log($_SESSION['user_logged'] . ": add Cron Job: " . $cron_name);
set_page_message(tr('Cron Job successfully added!'));
user_goto('cronjobs_overview.php');
} // End of add_cron_job();
function get_cron_domain(&$tpl, &$sql, $user_id) {
$query = "
SELECT
`admin_name`
FROM
`admin`
WHERE
admin_id = ?
";
$rs = exec_query($sql, $query, array($user_id));
return $rs->fields['admin_name'];
}
/*
*
* static page messages.
*
*/
gen_client_mainmenu($tpl, Config::get('CLIENT_TEMPLATE_PATH') . '/main_menu_webtools.tpl');
gen_client_menu($tpl, Config::get('CLIENT_TEMPLATE_PATH') . '/menu_webtools.tpl');
gen_logged_from($tpl);
check_permissions($tpl);
add_cron_job($tpl, $sql, $_SESSION['user_id']);
$example = Config::get('APACHE_WWW_DIR') . '/' . get_cron_domain($tpl, $sql, $_SESSION['user_id']) . '/htdocs/test.php' ;
$tpl->assign(
array('TR_CRON_MANAGER' => tr('Cronjob Manager'),
'TR_ADD_CRONJOB' => tr('Add Cronjob'),
'TR_NAME' => tr('Name'),
'TR_DESCRIPTION' => tr('Description'),
'TR_ACTIVE' => tr('Active'),
'YES' => tr('Yes'),
'NO' => tr('No'),
'TR_CRONJOB' => tr('Cronjob'),
'TR_COMMAND' => tr('Command to run:'),
'TR_MIN' => tr('Minute(s):'),
'TR_HOUR' => tr('Hour(s):'),
'TR_DAY' => tr('Day(s):'),
'TR_MONTHS' => tr('Month(s):'),
'TR_WEEKDAYS' => tr('Weekday(s):'),
'TR_ADD' => tr('Add'),
'TR_RESET' => tr('Reset'),
'TR_CANCEL' => tr('Cancel'),
'EXAMPLE' => $example,
)
);
gen_page_message($tpl);
$tpl->parse('PAGE', 'page');
$tpl->prnt();
if (Config::get('DUMP_GUI_DEBUG'))
dump_gui_debug();
unset_messages();
6. Do same help for users
open cronjobs_add.tpl
replace
Code:
<td width="25"> </td>
<td colspan="5" class="content2">{TR_COMMAND}</td>
</tr>
<tr>
<td width="25"> </td>
<td colspan="5" class="content"><input name="command_line" type="text" class="textinput" id="command_line" style="width:370px"></td>
</tr>
with new code
Code:
<tr>
<td width="25"> </td>
<td colspan="5" class="content2">Enter full SERVER PATH to executed script! {TR_COMMAND}</td>
</tr>
<tr>
<td width="25"> </td>
<td colspan="5" class="content"><input name="command_line" type="text" class="textinput" id="command_line" value={EXAMPLE} style="width:370px"></td>
</tr>
7. fixing format bug in tpl.
Open cronjobs_overview.tpl and replace
Code:
<tr>
<!-- BDP: cronjobs -->
<td nowrap="nowrap"> </td>
<td nowrap="nowrap" class="{ITEM_CLASS}"><strong>{NAME}</strong><br>
{DESCRIPTION}</td>
<td width="100" align="center" nowrap="nowrap" class="{ITEM_CLASS}">{ACTIVE}</td>
<td width="100" nowrap="nowrap" class="{ITEM_CLASS}"><img src="{THEME_COLOR_PATH}/images/icons/edit.png" width="16" height="16" align="absmiddle"> <a href="cronjobs_edit.php?cron_id={ID}" class="link">{TR_EDIT}</a></td>
<td width="100" nowrap="nowrap" class="{ITEM_CLASS}"><img src="{THEME_COLOR_PATH}/images/icons/delete.png" width="16" height="16" border="0" align="absmiddle"> <a href="#" class="link" onclick="action_delete('cronjobs_delete.php?cron_id={ID}', '{NAME}')">{TR_DELETE}</a></td>
<!-- EDP: cronjobs -->
</tr>
whith
Code:
<!-- BDP: cronjobs -->
<tr>
<td nowrap="nowrap"> </td>
<td nowrap="nowrap" class="{ITEM_CLASS}"><strong>{NAME}</strong><br>
{DESCRIPTION}</td>
<td width="100" align="center" nowrap="nowrap" class="{ITEM_CLASS}">{ACTIVE}</td>
<td width="100" nowrap="nowrap" class="{ITEM_CLASS}"><img src="{THEME_COLOR_PATH}/images/icons/edit.png" width="16" height="16" align="absmiddle"> <a href="cronjobs_edit.php?cron_id={ID}" class="link">{TR_EDIT}</a></td>
<td width="100" nowrap="nowrap" class="{ITEM_CLASS}"><img src="{THEME_COLOR_PATH}/images/icons/delete.png" width="16" height="16" border="0" align="absmiddle"> <a href="#" class="link" onclick="action_delete('cronjobs_delete.php?cron_id={ID}', '{NAME}')">{TR_DELETE}</a></td>
</tr>
<!-- EDP: cronjobs -->
8. rewrite cronjobs_edit.php
Ooops! Vodka is over
I must go to the night shop...