enhance new PDO Database class; converted admin_cronjobs
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -39,8 +39,9 @@ if ($page == 'cronjobs' || $page == 'overview') {
|
||||
* @TODO Fix sorting
|
||||
*/
|
||||
$crons = '';
|
||||
$result = $db->query("SELECT `c`.* FROM `" . TABLE_PANEL_CRONRUNS . "` `c` ORDER BY `cronfile` ASC");
|
||||
$paging->setEntries($db->num_rows($result));
|
||||
$result_stmt = Database::prepare("SELECT `c`.* FROM `" . TABLE_PANEL_CRONRUNS . "` `c` ORDER BY `cronfile` ASC");
|
||||
Database::pexecute($result_stmt);
|
||||
$paging->setEntries(Database::num_rows());
|
||||
$sortcode = $paging->getHtmlSortCode($lng);
|
||||
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$searchcode = $paging->getHtmlSearchCode($lng);
|
||||
@@ -49,7 +50,7 @@ if ($page == 'cronjobs' || $page == 'overview') {
|
||||
$i = 0;
|
||||
$count = 0;
|
||||
|
||||
while ($row = $db->fetch_array($result)) {
|
||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
if ($paging->checkDisplay($i)) {
|
||||
$row = htmlentities_array($row);
|
||||
|
||||
@@ -72,7 +73,9 @@ if ($page == 'cronjobs' || $page == 'overview') {
|
||||
* @TODO later
|
||||
*/
|
||||
} elseif ($action == 'edit' && $id != 0) {
|
||||
$result = $db->query_first("SELECT * FROM `" . TABLE_PANEL_CRONRUNS . "` WHERE `id`='" . (int)$id . "'");
|
||||
$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);
|
||||
if ($result['cronfile'] != '') {
|
||||
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||
$isactive = isset($_POST['isactive']) ? 1 : 0;
|
||||
@@ -85,10 +88,12 @@ if ($page == 'cronjobs' || $page == 'overview') {
|
||||
|
||||
$interval = $interval_value . ' ' . strtoupper($interval_interval);
|
||||
|
||||
$db->query("UPDATE `" . TABLE_PANEL_CRONRUNS . "`
|
||||
SET `isactive` = '".(int)$isactive."',
|
||||
`interval` = '".$interval."'
|
||||
WHERE `id` = '" . (int)$id . "'");
|
||||
$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));
|
||||
|
||||
redirectTo($filename, Array('page' => $page, 's' => $s));
|
||||
} else {
|
||||
|
||||
@@ -53,6 +53,15 @@ class Database {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the number of found rows of the last select query
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function num_rows($stmt) {
|
||||
return Database::query("SELECT FOUND_ROWS()")->fetchColumn();
|
||||
}
|
||||
|
||||
/**
|
||||
* let's us interact with the PDO-Object by using static
|
||||
* call like "Database::function()"
|
||||
@@ -165,7 +174,7 @@ class Database {
|
||||
* log to a file, so we can actually ask people for the error
|
||||
* (no one seems to find the stuff in the syslog)
|
||||
*/
|
||||
$sl_dir = makeCorrectDir(dirname(dirname(dirname(dirname(__FILE__))))."/logs/");
|
||||
$sl_dir = makeCorrectDir(FROXLOR_INSTALL_DIR."/logs/");
|
||||
if (!file_exists($sl_dir)) {
|
||||
@mkdir($sl_dir, 0755);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user