Merge branch 'master' of git://github.com/Froxlor/Froxlor

This commit is contained in:
BNoiZe
2013-11-06 18:05:57 +01:00
21 changed files with 1509 additions and 1442 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -18,10 +18,6 @@
*/
define('AREA', 'admin');
/**
* Include our init.php, which manages Sessions, Language etc.
*/
require ("./lib/init.php");
if ($action == 'logout') {
@@ -71,8 +67,7 @@ if ($page == 'overview') {
SUM(`traffic_used`) AS `traffic_used`,
SUM(`aps_packages_used`) AS `aps_packages_used`
FROM `" . TABLE_PANEL_CUSTOMERS . "`" . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = :adminid "));
Database::pexecute($overview_stmt, array('adminid' => $userinfo['adminid']));
$overview = $overview_stmt->fetch(PDO::FETCH_ASSOC);
$overview = Database::pexecute_first($overview_stmt, array('adminid' => $userinfo['adminid']));
$overview['traffic_used'] = round($overview['traffic_used'] / (1024 * 1024), $settings['panel']['decimal_places']);
$overview['diskspace_used'] = round($overview['diskspace_used'] / 1024, $settings['panel']['decimal_places']);
@@ -81,8 +76,8 @@ if ($page == 'overview') {
SELECT COUNT(*) AS `number_domains` FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `parentdomainid`='0'" . ($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid")
);
Database::pexecute($number_domains_stmt, array('adminid' => $userinfo['adminid']));
$number_domains = $number_domains_stmt->fetch(PDO::FETCH_ASSOC);
$number_domains = Database::pexecute_first($number_domains_stmt, array('adminid' => $userinfo['adminid']));
$overview['number_domains'] = $number_domains['number_domains'];
$phpversion = phpversion();

View File

@@ -148,8 +148,7 @@ if ($page == 'overview') {
$result_stmt = Database::prepare("
SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "` WHERE `id` = :id"
);
Database::pexecute($result_stmt, array('id' => $id));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
$result = Database::pexecute_first($result_stmt, array('id' => $id));
if ($result['id'] != 0
&& $result['id'] == $id
@@ -190,8 +189,7 @@ if ($page == 'overview') {
$result_stmt = Database::prepare("
SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "` WHERE `id` = :id"
);
Database::pexecute($result_stmt, array('id' => $id));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
$result = Database::pexecute_first($result_stmt, array('id' => $id));
if ($result['id'] != 0
&& $result['id'] == $id

View File

@@ -18,11 +18,6 @@
*/
define('AREA', 'admin');
/**
* Include our init.php, which manages Sessions, Language etc.
*/
require ("./lib/init.php");
if (isset($_POST['id'])) {
@@ -42,8 +37,7 @@ if (isset($_POST['id'])) {
SELECT `id` FROM `panel_tickets`
WHERE `id` = :id AND `adminid` = :adminid
");
Database::pexecute($stmt, array('id' => $id, 'adminid' => $userinfo['adminid']));
$result = $stmt->fetch(PDO::FETCH_ASSOC);
$result = Database::pexecute_first($stmt, array('id' => $id, 'adminid' => $userinfo['adminid']));
if ($result == null) {
// no rights to see the requested ticket
@@ -62,8 +56,7 @@ if ($page == 'tickets'
FROM `" . TABLE_PANEL_CUSTOMERS . "` " .
($userinfo['customers_see_all'] ? '' : "WHERE `adminid` = :adminid")
);
Database::pexecute($countcustomers_stmt, array('adminid' => $userinfo['adminid']));
$countcustomers = $countcustomers_stmt->fetch(PDO::FETCH_ASSOC);
$countcustomers = Database::pexecute_first($countcustomers_stmt, array('adminid' => $userinfo['adminid']));
$countcustomers = (int)$countcustomers['countcustomers'];
if ($action == '') {
@@ -135,8 +128,7 @@ if ($page == 'tickets'
FROM `' . TABLE_PANEL_CUSTOMERS . '`
WHERE `customerid` = :cid'
);
Database::pexecute($usr_stmt, array('cid' => $cid));
$usr = $usr_stmt->fetch(PDO::FETCH_ASSOC);
$usr = Database::pexecute_first($usr_stmt, array('cid' => $cid));
if (isset($usr['loginname'])) {
$customer = getCorrectFullUserDetails($usr);
@@ -191,7 +183,7 @@ if ($page == 'tickets'
if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
$newticket = ticket::getInstanceOf($userinfo, $db, $settings, -1);
$newticket = ticket::getInstanceOf($userinfo, $settings, -1);
$newticket->Set('subject', validate($_POST['subject'], 'subject'), true, false);
$newticket->Set('priority', validate($_POST['priority'], 'priority'), true, false);
$newticket->Set('category', validate($_POST['category'], 'category'), true, false);
@@ -226,8 +218,7 @@ if ($page == 'tickets'
SELECT `id`, `name` FROM `' . TABLE_PANEL_TICKET_CATS . '`
'.$where.' ORDER BY `logicalorder`, `name` ASC'
);
Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid']));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
$result = Database::pexecute_first($result_stmt, array('adminid' => $userinfo['adminid']));
if (isset($result['name'])
&& $result['name'] != ''
@@ -283,7 +274,7 @@ if ($page == 'tickets'
&& $_POST['send'] == 'send'
) {
$replyticket = ticket::getInstanceOf($userinfo, $db, $settings, -1);
$replyticket = ticket::getInstanceOf($userinfo, $settings, -1);
$replyticket->Set('subject', validate($_POST['subject'], 'subject'), true, false);
$replyticket->Set('priority', validate($_POST['priority'], 'priority'), true, false);
$replyticket->Set('message', validate(htmlentities(str_replace("\r\n", "\n", $_POST['message'])), 'message', '/^[^\0]*$/'), true, false);
@@ -292,7 +283,7 @@ if ($page == 'tickets'
standard_error(array('stringisempty', 'mymessage'));
} else {
$now = time();
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$replyticket->Set('customerid', $mainticket->Get('customer'), true, true);
$replyticket->Set('lastchange', $now, true, true);
$replyticket->Set('ip', $_SERVER['REMOTE_ADDR'], true, true);
@@ -318,7 +309,7 @@ if ($page == 'tickets'
} else {
$ticket_replies = '';
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$dt = date("d.m.Y H:i\h", $mainticket->Get('dt'));
$status = ticket::getStatusText($lng, $mainticket->Get('status'));
@@ -339,8 +330,7 @@ if ($page == 'tickets'
FROM `' . TABLE_PANEL_CUSTOMERS . '`
WHERE `customerid` = :cid'
);
Database::pexecute($usr_stmt, array('cid' => $cid));
$usr = $usr_stmt->fetch(PDO::FETCH_ASSOC);
$usr = Database::pexecute_first($usr_stmt, array('cid' => $cid));
$by = '<a href="'.$linker->getLink(array('section' => 'customers', 'page' => 'customers', 'action' => 'su', 'id' => $cid)).'" rel="external">';
$by .= getCorrectFullUserDetails($usr).'</a>';
}
@@ -352,8 +342,7 @@ if ($page == 'tickets'
$result_stmt = Database::prepare('
SELECT `name` FROM `' . TABLE_PANEL_TICKET_CATS . '` WHERE `id` = :cid'
);
Database::pexecute($result_stmt, array('cid' => $mainticket->Get('category')));
$row = $result_stmt->fetch(PDO::FETCH_ASSOC);
$row = Database::pexecute_first($result_stmt, array('cid' => $mainticket->Get('category')));
$andere_stmt = Database::prepare('
SELECT * FROM `' . TABLE_PANEL_TICKETS . '`
@@ -364,7 +353,7 @@ if ($page == 'tickets'
while ($row2 = $andere_stmt->fetch(PDO::FETCH_ASSOC)) {
$subticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$row2['id']);
$subticket = ticket::getInstanceOf($userinfo, $settings, (int)$row2['id']);
$lastchange = date("d.m.Y H:i\h", $subticket->Get('lastchange'));
if ($subticket->Get('by') == '1') {
@@ -376,8 +365,7 @@ if ($page == 'tickets'
FROM `' . TABLE_PANEL_CUSTOMERS . '`
WHERE `customerid` = :cid'
);
Database::pexecute($usr_stmt, array('cid' => $cid));
$usr = $usr_stmt->fetch(PDO::FETCH_ASSOC);
$usr = Database::pexecute_first($usr_stmt, array('cid' => $cid));
$by = '<a href="'.$linker->getLink(array('section' => 'customers', 'page' => 'customers', 'action' => 'su', 'id' => $cid)).'" rel="external">';
$by .= getCorrectFullUserDetails($usr).'</a>';
}
@@ -410,15 +398,15 @@ if ($page == 'tickets'
&& $_POST['send'] == 'send'
) {
$now = time();
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$mainticket->Set('lastchange', $now, true, true);
$mainticket->Set('lastreplier', '1', true, true);
$mainticket->Set('status', '3', true, true);
$mainticket->Update();
$log->logAction(ADM_ACTION, LOG_NOTICE, "closed ticket '" . $mainticket->Get('subject') . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
redirectTo($filename, array('page' => $page, 's' => $s));
} else {
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
ask_yesno('ticket_reallyclose', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $mainticket->Get('subject'));
}
@@ -426,13 +414,13 @@ if ($page == 'tickets'
&& $id != 0
) {
$now = time();
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$mainticket->Set('lastchange', $now, true, true);
$mainticket->Set('lastreplier', '1', true, true);
$mainticket->Set('status', '0', true, true);
$mainticket->Update();
$log->logAction(ADM_ACTION, LOG_NOTICE, "reopened ticket '" . $mainticket->Get('subject') . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
redirectTo($filename, array('page' => $page, 's' => $s));
} elseif($action == 'archive'
&& $id != 0
@@ -441,16 +429,16 @@ if ($page == 'tickets'
&& $_POST['send'] == 'send'
) {
$now = time();
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$mainticket->Set('lastchange', $now, true, true);
$mainticket->Set('lastreplier', '1', true, true);
$mainticket->Set('status', '3', true, true);
$mainticket->Update();
$mainticket->Archive();
$log->logAction(ADM_ACTION, LOG_NOTICE, "archived ticket '" . $mainticket->Get('subject') . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
redirectTo($filename, array('page' => $page, 's' => $s));
} else {
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
ask_yesno('ticket_reallyarchive', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $mainticket->Get('subject'));
}
@@ -460,12 +448,12 @@ if ($page == 'tickets'
if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$log->logAction(ADM_ACTION, LOG_INFO, "deleted ticket '" . $mainticket->Get('subject') . "'");
$mainticket->Delete();
redirectTo($filename, Array('page' => $page, 's' => $s));
redirectTo($filename, array('page' => $page, 's' => $s));
} else {
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
ask_yesno('ticket_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $mainticket->Get('subject'));
}
}
@@ -538,18 +526,18 @@ if ($page == 'tickets'
if ($order < 1 || $order >= 1000) {
// use the latest available
$order = ticket::getHighestOrderNumber($db, $userinfo['adminid']) + 1;
$order = ticket::getHighestOrderNumber($userinfo['adminid']) + 1;
}
if ($category == '') {
standard_error(array('stringisempty', 'mycategory'));
} else {
ticket::addCategory($db, $category, $userinfo['adminid'], $order);
ticket::addCategory($category, $userinfo['adminid'], $order);
$log->logAction(ADM_ACTION, LOG_INFO, "added ticket-category '" . $category . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
redirectTo($filename, array('page' => $page, 's' => $s));
}
} else {
$order = ticket::getHighestOrderNumber($db, $userinfo['adminid']) + 1;
$order = ticket::getHighestOrderNumber($userinfo['adminid']) + 1;
$category_new_data = include_once dirname(__FILE__).'/lib/formfields/admin/tickets/formfield.category_new.php';
$category_new_form = htmlform::genHTMLForm($category_new_data);
@@ -577,16 +565,15 @@ if ($page == 'tickets'
if ($category == '') {
standard_error(array('stringisempty', 'mycategory'));
} else {
ticket::editCategory($db, $category, $id, $order);
ticket::editCategory($category, $id, $order);
$log->logAction(ADM_ACTION, LOG_INFO, "edited ticket-category '" . $category . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
redirectTo($filename, array('page' => $page, 's' => $s));
}
} else {
$row_stmt = Database::prepare('
SELECT * FROM `' . TABLE_PANEL_TICKET_CATS . '` WHERE `id` = :id'
);
Database::pexecute($row_stmt, array('id' => $id));
$row = $row_stmt->fetch(PDO::FETCH_ASSOC);
$row = Database::pexecute_first($row_stmt, array('id' => $id));
$category_edit_data = include_once dirname(__FILE__).'/lib/formfields/admin/tickets/formfield.category_edit.php';
$category_edit_form = htmlform::genHTMLForm($category_edit_data);
@@ -602,15 +589,15 @@ if ($page == 'tickets'
if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
if (ticket::deleteCategory($db, $id) == false) {
if (ticket::deleteCategory($id) == false) {
standard_error('categoryhastickets');
}
$log->logAction(ADM_ACTION, LOG_INFO, "deleted ticket-category #" . $id);
redirectTo($filename, Array('page' => $page, 's' => $s));
redirectTo($filename, array('page' => $page, 's' => $s));
} else {
$name = ticket::getCategoryName($db, $id);
$name = ticket::getCategoryName($id);
ask_yesno('ticket_reallydeletecat', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $name);
}
}
@@ -643,8 +630,11 @@ if ($page == 'tickets'
$categories[$x] = isset($_POST['category' . $x]) ? $_POST['category' . $x] : '';
}
// FIXME migrate to PDO
$query = ticket::getArchiveSearchStatement($db, $subject, $priority, $fromdate, $todate, $message, $customer, $userinfo['adminid'], $categories);
$archive_search = ticket::getArchiveSearchStatement($subject, $priority, $fromdate, $todate, $message, $customer, $userinfo['adminid'], $categories);
$query = $archive_search[0];
$archive_params = $archive_search[1];
$fields = array(
'lastchange' => $lng['ticket']['lastchange'],
'ticket_answers' => $lng['ticket']['ticket_answers'],
@@ -653,15 +643,15 @@ if ($page == 'tickets'
'priority' => $lng['ticket']['priority']
);
$paging = new paging($userinfo, $db, TABLE_PANEL_TICKETS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
// FIXME migrate (the above) to PDO
$result = $db->query($query . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
$result_stmt = Database::prepare($query . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
Database::pexecute($result_stmt, $archive_params);
$sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$ctickets = array();
while ($row = $db->fetch_array($result)) {
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if (!isset($ctickets[$row['customerid']])
|| !is_array($ctickets[$row['customerid']])
) {
@@ -691,7 +681,7 @@ if ($page == 'tickets'
ksort($ticketrows);
}
$_cid = 0;
$_cid = -1;
foreach ($ticketrows as $ticket) {
if ($paging->checkDisplay($i)) {
$ticket['lastchange'] = date("d.m.y H:i", $ticket['lastchange']);
@@ -702,8 +692,7 @@ if ($page == 'tickets'
FROM `' . TABLE_PANEL_CUSTOMERS . '`
WHERE `customerid` = :cid'
);
Database::pexecute($usr_stmt, array('cid' => $cid));
$usr = $usr_stmt->fetch(PDO::FETCH_ASSOC);
$usr = Database::pexecute_first($usr_stmt, array('cid' => $cid));
if (isset($usr['loginname'])) {
$customer = getCorrectFullUserDetails($usr);
@@ -711,6 +700,8 @@ if ($page == 'tickets'
$customerid = $usr['customerid'];
} else {
$customer = $lng['ticket']['nonexistingcustomer'];
$customerid = 0;
$customerloginname = '';
}
eval("\$tickets.=\"" . getTemplate("tickets/tickets_customer") . "\";");
}
@@ -750,7 +741,7 @@ if ($page == 'tickets'
} else {
$archived = array();
$archived = ticket::getLastArchived($db, 6, $userinfo['adminid']);
$archived = ticket::getLastArchived(6, $userinfo['adminid']);
$tickets = '';
if ($archived !== false) {
@@ -805,27 +796,22 @@ if ($page == 'tickets'
) {
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed archived-ticket #" . $id);
$ticket_replies = '';
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$lastchange = date("d.m.Y H:i\h", $mainticket->Get('lastchange'));
$dt = date("d.m.Y H:i\h", $mainticket->Get('dt'));
$status = ticket::getStatusText($lng, $mainticket->Get('status'));
$isclosed = 1;
if($mainticket->Get('by') == '1')
{
if ($mainticket->Get('by') == '1') {
$by = $lng['ticket']['staff'];
}
else
{
} else {
$cid = $mainticket->Get('customer');
$usr_stmt = Database::prepare('
SELECT `customerid`, `firstname`, `name`, `company`, `loginname`
FROM `' . TABLE_PANEL_CUSTOMERS . '`
WHERE `customerid` = :cid'
);
Database::pexecute($usr_stmt, array('cid' => $cid));
$usr = $usr_stmt->fetch(PDO::FETCH_ASSOC);
$usr = Database::pexecute_first($usr_stmt, array('cid' => $cid));
$by = '<a href="'.$linker->getLink(array('section' => 'customers', 'page' => 'customers', 'action' => 'su', 'id' => $cid)).'" rel="external">';
$by .= getCorrectFullUserDetails($usr).'</a>';
}
@@ -837,8 +823,7 @@ if ($page == 'tickets'
$result_stmt = Database::prepare('
SELECT `name` FROM `' . TABLE_PANEL_TICKET_CATS . '` WHERE `id` = :cid'
);
Database::pexecute($result_stmt, array('cid' => $mainticket->Get('category')));
$row = $result_stmt->fetch(PDO::FETCH_ASSOC);
$row = Database::pexecute_first($result_stmt, array('cid' => $mainticket->Get('category')));
$andere_stmt = Database::prepare('
SELECT * FROM `' . TABLE_PANEL_TICKETS . '` WHERE `answerto` = :id'
@@ -848,7 +833,7 @@ if ($page == 'tickets'
while ($row2 = $andere_stmt->fetch(PDO::FETCH_ASSOC)) {
$subticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$row2['id']);
$subticket = ticket::getInstanceOf($userinfo, $settings, (int)$row2['id']);
$lastchange = date("d.m.Y H:i\h", $subticket->Get('lastchange'));
if ($subticket->Get('by') == '1') {
@@ -860,9 +845,7 @@ if ($page == 'tickets'
FROM `' . TABLE_PANEL_CUSTOMERS . '`
WHERE `customerid` = :cid'
);
Database::pexecute($usr_stmt, array('cid' => $cid));
$usr = $usr_stmt->fetch(PDO::FETCH_ASSOC);
$usr = Database::pexecute_first($usr_stmt, array('cid' => $cid));
$by = '<a href="'.$linker->getLink(array('section' => 'customers', 'page' => 'customers', 'action' => 'su', 'id' => $cid)).'" rel="external">';
$by .= getCorrectFullUserDetails($usr).'</a>';
}
@@ -887,12 +870,12 @@ if ($page == 'tickets'
if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$log->logAction(ADM_ACTION, LOG_INFO, "deleted archived ticket '" . $mainticket->Get('subject') . "'");
$mainticket->Delete();
redirectTo($filename, Array('page' => $page, 's' => $s));
redirectTo($filename, array('page' => $page, 's' => $s));
} else {
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
ask_yesno('ticket_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $mainticket->Get('subject'));
}
}

View File

@@ -211,7 +211,7 @@ if ($page == 'overview') {
);
$params = array(
"customerid" => $userinfo['customerid'],
"username" => $username,
"databasename" => $username,
"description" => $databasedescription,
"dbserver" => $dbserver
);

View File

@@ -18,22 +18,18 @@
*/
define('AREA', 'customer');
/**
* Include our init.php, which manages Sessions, Language etc.
*/
require ("./lib/init.php");
if(isset($_POST['id'])) {
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
/*
* Check if the current user is allowed to see the current ticket.
*/
$stmt = Database::prepare("SELECT `id` FROM `panel_tickets` WHERE `id` = :id AND `customerid` = :customerid");
Database::pexecute($stmt, array("id" => $id, "customerid" => $userinfo['customerid']));
$result = $stmt->fetch(PDO::FETCH_ASSOC);
$result = Database::pexecute_first($stmt, array("id" => $id, "customerid" => $userinfo['customerid']));
if ($result == null) {
// no rights to see the requested ticket
standard_error(array('ticketnotaccessible'));
@@ -141,8 +137,7 @@ if($page == 'overview') {
AND `answerto` = "0"
AND (`status` = "0" OR `status` = "1" OR `status` = "2")'
);
Database::pexecute($stmt, array("customerid" => $userinfo['customerid']));
$opentickets = $stmt->fetch(PDO::FETCH_ASSOC);
$opentickets = Database::pexecute_first($stmt, array("customerid" => $userinfo['customerid']));
if($settings['ticket']['concurrently_open'] != - 1 && $settings['ticket']['concurrently_open'] != '') {
$notmorethanxopentickets = strtr($lng['ticket']['notmorethanxopentickets'], array('%s' => $settings['ticket']['concurrently_open']));
@@ -152,10 +147,11 @@ if($page == 'overview') {
$ticketsopen = (int)$opentickets['count'];
eval("echo \"" . getTemplate("tickets/tickets") . "\";");
} elseif($action == 'new') {
if($userinfo['tickets_used'] < $userinfo['tickets'] || $userinfo['tickets'] == '-1') {
if(isset($_POST['send']) && $_POST['send'] == 'send') {
$newticket = ticket::getInstanceOf($userinfo, $db, $settings, -1);
$newticket = ticket::getInstanceOf($userinfo, $settings, -1);
$newticket->Set('subject', validate($_POST['subject'], 'subject'), true, false);
$newticket->Set('priority', validate($_POST['priority'], 'priority'), true, false);
$newticket->Set('category', validate($_POST['category'], 'category'), true, false);
@@ -185,11 +181,9 @@ if($page == 'overview') {
Database::pexecute($stmt, array("customerid" => $userinfo['customerid']));
// Customer mail
$newticket->sendMail((int)$userinfo['customerid'], 'new_ticket_for_customer_subject', $lng['mails']['new_ticket_for_customer']['subject'], 'new_ticket_for_customer_mailbody', $lng['mails']['new_ticket_for_customer']['mailbody']);
// Admin mail
$newticket->sendMail(-1, 'new_ticket_by_customer_subject', $lng['mails']['new_ticket_by_customer']['subject'], 'new_ticket_by_customer_mailbody', $lng['mails']['new_ticket_by_customer']['mailbody']);
redirectTo($filename, Array('page' => $page, 's' => $s));
}
@@ -199,10 +193,9 @@ if($page == 'overview') {
WHERE `adminid` = :adminid
ORDER BY `logicalorder`, `name` ASC'
);
Database::pexecute($result_stmt, array("adminid" => $userinfo['adminid']));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
$result = Database::pexecute_first($result_stmt, array("adminid" => $userinfo['adminid']));
if(isset($result['name']) && $result['name'] != '') {
if (isset($result['name']) && $result['name'] != '') {
$result2_stmt = Database::prepare('SELECT `id`, `name` FROM `' . TABLE_PANEL_TICKET_CATS . '`
WHERE `adminid` = :adminid
ORDER BY `logicalorder`, `name` ASC'
@@ -225,10 +218,11 @@ if($page == 'overview') {
AND `answerto` = "0"
AND (`status` = "0" OR `status` = "1" OR `status` = "2")'
);
Database::pexecute($opentickets_stmt, array("customerid" => $userinfo['customerid']));
$opentickets = $opentickets_stmt->fetch(PDO::FETCH_ASSOC);
$opentickets = Database::pexecute_first($opentickets_stmt, array("customerid" => $userinfo['customerid']));
if($settings['ticket']['concurrently_open'] != - 1 && $settings['ticket']['concurrently_open'] != '') {
if ($settings['ticket']['concurrently_open'] != - 1
&& $settings['ticket']['concurrently_open'] != ''
) {
$notmorethanxopentickets = strtr($lng['ticket']['notmorethanxopentickets'], array('%s' => $settings['ticket']['concurrently_open']));
} else {
$notmorethanxopentickets = '';
@@ -249,7 +243,7 @@ if($page == 'overview') {
}
} elseif($action == 'answer' && $id != 0) {
if(isset($_POST['send']) && $_POST['send'] == 'send') {
$replyticket = ticket::getInstanceOf($userinfo, $db, $settings, -1);
$replyticket = ticket::getInstanceOf($userinfo, $settings, -1);
$replyticket->Set('subject', validate($_POST['subject'], 'subject'), true, false);
$replyticket->Set('priority', validate($_POST['priority'], 'priority'), true, false);
$replyticket->Set('message', validate(str_replace("\r\n", "\n", $_POST['message']), 'message', '/^[^\0]*$/'), true, false);
@@ -267,8 +261,7 @@ if($page == 'overview') {
$replyticket->Insert();
// Update priority if changed
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
if($replyticket->Get('priority') != $mainticket->Get('priority')) {
$mainticket->Set('priority', $replyticket->Get('priority'), true);
@@ -284,7 +277,7 @@ if($page == 'overview') {
}
} else {
$ticket_replies = '';
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$dt = date("d.m.Y H:i\h", $mainticket->Get('dt'));
$status = ticket::getStatusText($lng, $mainticket->Get('status'));
@@ -302,10 +295,8 @@ if($page == 'overview') {
FROM `' . TABLE_PANEL_CUSTOMERS . '`
WHERE `customerid` = :customerid '
);
Database::pexecute($usr_stmt, array("customerid" => $cid));
$usr = $usr_stmt->fetch(PDO::FETCH_ASSOC);
$usr = Database::pexecute_first($usr_stmt, array("customerid" => $cid));
$by = getCorrectFullUserDetails($usr);
//$by = $lng['ticket']['customer'];
}
$subject = $mainticket->Get('subject');
@@ -314,24 +305,23 @@ if($page == 'overview') {
$result_stmt = Database::prepare('SELECT `name` FROM `' . TABLE_PANEL_TICKET_CATS . '`
WHERE `id`= :id '
);
Database::pexecute($result_stmt, array("id" => $mainticket->Get('category')));
$row = $result_stmt->fetch(PDO::FETCH_ASSOC);
$row = Database::pexecute_first($result_stmt, array("id" => $mainticket->Get('category')));
$andere_stmt = Database::prepare('SELECT * FROM `' . TABLE_PANEL_TICKETS . '`
WHERE `answerto`= :answerto
ORDER BY `lastchange` ASC'
);
Database::pexecute($andere_stmt, array("answerto" => $id));
$numrows_andere = Database::num_rows();
while($row2 = $andere_stmt->fetch(PDO::FETCH_ASSOC)) {
$subticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$row2['id']);
$subticket = ticket::getInstanceOf($userinfo, $settings, (int)$row2['id']);
$lastchange = date("d.m.Y H:i\h", $subticket->Get('lastchange'));
if($subticket->Get('by') == '1') {
$by = $lng['ticket']['staff'];
} else {
$by = getCorrectFullUserDetails($usr);
//$by = $lng['ticket']['customer'];
}
$subject = $subticket->Get('subject');
@@ -343,10 +333,9 @@ if($page == 'overview') {
$priorities.= makeoption($lng['ticket']['normal'], '2', $mainticket->Get('priority'), true, true);
$priorities.= makeoption($lng['ticket']['low'], '3', $mainticket->Get('priority'), true, true);
$subject = $mainticket->Get('subject');
$ticket_replies_count = $db->num_rows($andere) + 1;
$ticket_replies_count = $numrows_andere + 1;
// don't forget the main-ticket!
$ticket_reply_data = include_once dirname(__FILE__).'/lib/formfields/customer/tickets/formfield.ticket_reply.php';
$ticket_reply_form = htmlform::genHTMLForm($ticket_reply_data);
@@ -358,7 +347,7 @@ if($page == 'overview') {
} elseif($action == 'close' && $id != 0) {
if(isset($_POST['send']) && $_POST['send'] == 'send') {
$now = time();
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$mainticket->Set('lastchange', $now, true, true);
$mainticket->Set('lastreplier', '0', true, true);
$mainticket->Set('status', '3', true, true);
@@ -366,7 +355,7 @@ if($page == 'overview') {
$log->logAction(USR_ACTION, LOG_NOTICE, "closed support-ticket '" . $mainticket->Get('subject') . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
} else {
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
ask_yesno('ticket_reallyclose', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $mainticket->Get('subject'));
}
} elseif($action == 'reopen' && $id != 0) {
@@ -376,8 +365,7 @@ if($page == 'overview') {
AND `answerto` = "0"
AND (`status` = "0" OR `status` = "1" OR `status` = "2")'
);
Database::pexecute($opentickets_stmt, array("customerid" => $userinfo['customerid']));
$opentickets = $opentickets_stmt->fetch(PDO::FETCH_ASSOC);
$opentickets = Database::pexecute_first($opentickets_stmt, array("customerid" => $userinfo['customerid']));
$ticketsopen = (int)$opentickets['count'];
if($ticketsopen > $settings['ticket']['concurrently_open'] && $settings['ticket']['concurrently_open'] != - 1 && $settings['ticket']['concurrently_open'] != '') {
@@ -385,14 +373,12 @@ if($page == 'overview') {
}
$now = time();
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$id);
$mainticket->Set('lastchange', $now, true, true);
$mainticket->Set('lastreplier', '0', true, true);
$mainticket->Set('status', '0', true, true);
$mainticket->Update();
$log->logAction(USR_ACTION, LOG_NOTICE, "reopened support-ticket '" . $mainticket->Get('subject') . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
redirectTo($filename, array('page' => $page, 's' => $s));
}
}
?>

View File

@@ -69,6 +69,22 @@ class Database {
}
}
/**
* Wrapper for PDOStatement::execute so we can catch the PDOException
* and display the error nicely on the panel - also fetches the
* result from the statement and returns the resulting array
*
* @param PDOStatement $stmt
* @param array $params (optional)
* @param bool $showerror suppress errordisplay (default true)
*
* @return array
*/
public static function pexecute_first(&$stmt, $params = null, $showerror = true) {
self::pexecute($stmt, $params, $showerror);
return $stmt->fetch(PDO::FETCH_ASSOC);
}
/**
* returns the number of found rows of the last select query
*
@@ -250,4 +266,4 @@ class Database {
die("We are sorry, but a MySQL - error occurred. The administrator may find more information in in the sql-error.log in the logs/ directory");
}
}
}
}

View File

@@ -19,13 +19,7 @@
*
*/
class phpinterface
{
/**
* Database handler
* @var object
*/
private $_db = false;
class phpinterface {
/**
* Settings array
@@ -54,9 +48,7 @@ class phpinterface
/**
* main constructor
*/
public function __construct($db, $settings, $domain)
{
$this->_db = $db;
public function __construct($settings, $domain) {
$this->_settings = $settings;
$this->_domain = $domain;
$this->_setInterface();
@@ -66,8 +58,7 @@ class phpinterface
* returns the interface-object
* from where we can control it
*/
public function getInterface()
{
public function getInterface() {
return $this->_interface;
}
@@ -76,16 +67,13 @@ class phpinterface
* php-interface: fcgid or php-fpm
* sets private $_interface variable
*/
private function _setInterface()
{
private function _setInterface() {
// php-fpm
if((int)$this->_settings['phpfpm']['enabled'] == 1)
{
$this->_interface = new phpinterface_fpm($this->_db, $this->_settings, $this->_domain);
}
elseif((int)$this->_settings['system']['mod_fcgid'] == 1)
{
$this->_interface = new phpinterface_fcgid($this->_db, $this->_settings, $this->_domain);
if ((int)$this->_settings['phpfpm']['enabled'] == 1) {
$this->_interface = new phpinterface_fpm($this->_settings, $this->_domain);
} elseif ((int)$this->_settings['system']['mod_fcgid'] == 1) {
$this->_interface = new phpinterface_fcgid($this->_settings, $this->_domain);
}
}
@@ -96,23 +84,20 @@ class phpinterface
*
* @return array
*/
public function getPhpConfig($php_config_id)
{
public function getPhpConfig($php_config_id) {
$php_config_id = intval($php_config_id);
// If domain has no config, we will use the default one.
if($php_config_id == 0)
{
if ($php_config_id == 0) {
$php_config_id = 1;
}
if(!isset($this->php_configs_cache[$php_config_id]))
{
$this->_php_configs_cache[$php_config_id] = $this->_db->query_first(
"SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "`
WHERE `id` = " . (int)$php_config_id
if (!isset($this->php_configs_cache[$php_config_id])) {
$stmt = Database::prepare("
SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "` WHERE `id` = :id"
);
$this->_php_configs_cache[$php_config_id] = Database::pexecute_first($stmt, array('id' => $php_config_id));
}
return $this->_php_configs_cache[$php_config_id];

View File

@@ -19,13 +19,7 @@
*
*/
class phpinterface_fcgid
{
/**
* Database handler
* @var object
*/
private $_db = false;
class phpinterface_fcgid {
/**
* Settings array
@@ -36,27 +30,25 @@ class phpinterface_fcgid
/**
* Domain-Data array
* @var array
*/
*/
private $_domain = array();
/**
* Admin-Date cache array
* @var array
*/
*/
private $_admin_cache = array();
/**
* main constructor
*/
public function __construct($db, $settings, $domain)
{
$this->_db = $db;
*/
public function __construct($settings, $domain) {
$this->_settings = $settings;
$this->_domain = $domain;
}
public function createConfig($phpconfig)
{
public function createConfig($phpconfig) {
// create starter
$starter_file = "#!/bin/sh\n\n";
$starter_file.= "#\n";
@@ -68,18 +60,13 @@ class phpinterface_fcgid
$starter_file.= "export PHPRC\n";
// set number of processes for one domain
if((int)$this->_domain['mod_fcgid_starter'] != - 1)
{
if ((int)$this->_domain['mod_fcgid_starter'] != - 1) {
$starter_file.= "PHP_FCGI_CHILDREN=" . (int)$this->_domain['mod_fcgid_starter'] . "\n";
}
else
{
if((int)$phpconfig['mod_fcgid_starter'] != - 1)
{
} else {
if ((int)$phpconfig['mod_fcgid_starter'] != - 1) {
$starter_file.= "PHP_FCGI_CHILDREN=" . (int)$phpconfig['mod_fcgid_starter'] . "\n";
}
else
{
} else {
$starter_file.= "PHP_FCGI_CHILDREN=" . (int)$this->_settings['system']['mod_fcgid_starter'] . "\n";
}
}
@@ -87,18 +74,12 @@ class phpinterface_fcgid
$starter_file.= "export PHP_FCGI_CHILDREN\n";
// set number of maximum requests for one domain
if((int)$this->_domain['mod_fcgid_maxrequests'] != - 1)
{
if ((int)$this->_domain['mod_fcgid_maxrequests'] != - 1) {
$starter_file.= "PHP_FCGI_MAX_REQUESTS=" . (int)$this->_domain['mod_fcgid_maxrequests'] . "\n";
}
else
{
if((int)$phpconfig['mod_fcgid_maxrequests'] != - 1)
{
} else {
if ((int)$phpconfig['mod_fcgid_maxrequests'] != - 1) {
$starter_file.= "PHP_FCGI_MAX_REQUESTS=" . (int)$phpconfig['mod_fcgid_maxrequests'] . "\n";
}
else
{
} else {
$starter_file.= "PHP_FCGI_MAX_REQUESTS=" . (int)$this->_settings['system']['mod_fcgid_maxrequests'] . "\n";
}
}
@@ -109,8 +90,7 @@ class phpinterface_fcgid
$starter_file.= "exec " . $phpconfig['binary'] . " -c " . escapeshellarg($this->getConfigDir()) . "\n";
//remove +i attibute, so starter can be overwritten
if(file_exists($this->getStarterFile()))
{
if (file_exists($this->getStarterFile())) {
removeImmutable($this->getStarterFile());
}
@@ -122,34 +102,36 @@ class phpinterface_fcgid
setImmutable($this->getStarterFile());
}
public function createIniFile($phpconfig)
{
/**
* create customized php.ini
*
* @param array $phpconfig
*/
public function createIniFile($phpconfig) {
$openbasedir = '';
$openbasedirc = ';';
if($this->_domain['openbasedir'] == '1')
{
if ($this->_domain['openbasedir'] == '1') {
$openbasedirc = '';
$_phpappendopenbasedir = '';
$_custom_openbasedir = explode(':', $this->_settings['system']['mod_fcgid_peardir']);
foreach($_custom_openbasedir as $cobd)
{
foreach ($_custom_openbasedir as $cobd) {
$_phpappendopenbasedir .= appendOpenBasedirPath($cobd);
}
$_custom_openbasedir = explode(':', $this->_settings['system']['phpappendopenbasedir']);
foreach($_custom_openbasedir as $cobd)
{
foreach ($_custom_openbasedir as $cobd) {
$_phpappendopenbasedir .= appendOpenBasedirPath($cobd);
}
if($this->_domain['openbasedir_path'] == '0' && strstr($this->_domain['documentroot'], ":") === false)
{
if ($this->_domain['openbasedir_path'] == '0'
&& strstr($this->_domain['documentroot'], ":") === false
) {
$openbasedir = appendOpenBasedirPath($this->_domain['documentroot'], true);
}
else
{
} else {
$openbasedir = appendOpenBasedirPath($this->_domain['customerroot'], true);
}
@@ -158,34 +140,31 @@ class phpinterface_fcgid
$openbasedir = explode(':', $openbasedir);
$clean_openbasedir = array();
foreach($openbasedir as $number => $path)
{
if(trim($path) != '/')
{
foreach ($openbasedir as $number => $path) {
if (trim($path) != '/') {
$clean_openbasedir[] = makeCorrectDir($path);
}
}
$openbasedir = implode(':', $clean_openbasedir);
}
else
{
} else {
$openbasedir = 'none';
$openbasedirc = ';';
}
$admin = $this->_getAdminData($this->_domain['adminid']);
$php_ini_variables = array(
'SAFE_MODE' => 'Off', // keep this for compatibility, just in case
'PEAR_DIR' => $this->_settings['system']['mod_fcgid_peardir'],
'OPEN_BASEDIR' => $openbasedir,
'OPEN_BASEDIR_C' => $openbasedirc,
'OPEN_BASEDIR_GLOBAL' => $this->_settings['system']['phpappendopenbasedir'],
'TMP_DIR' => $this->getTempDir(),
'CUSTOMER_EMAIL' => $this->_domain['email'],
'ADMIN_EMAIL' => $admin['email'],
'DOMAIN' => $this->_domain['domain'],
'CUSTOMER' => $this->_domain['loginname'],
'ADMIN' => $admin['loginname']
'SAFE_MODE' => 'Off', // keep this for compatibility, just in case
'PEAR_DIR' => $this->_settings['system']['mod_fcgid_peardir'],
'OPEN_BASEDIR' => $openbasedir,
'OPEN_BASEDIR_C' => $openbasedirc,
'OPEN_BASEDIR_GLOBAL' => $this->_settings['system']['phpappendopenbasedir'],
'TMP_DIR' => $this->getTempDir(),
'CUSTOMER_EMAIL' => $this->_domain['email'],
'ADMIN_EMAIL' => $admin['email'],
'DOMAIN' => $this->_domain['domain'],
'CUSTOMER' => $this->_domain['loginname'],
'ADMIN' => $admin['loginname']
);
//insert a small header for the file
@@ -206,17 +185,16 @@ class phpinterface_fcgid
/**
* fcgid-config directory
*
*
* @param boolean $createifnotexists create the directory if it does not exist
*
*
* @return string the directory
*/
public function getConfigDir($createifnotexists = true)
{
public function getConfigDir($createifnotexists = true) {
$configdir = makeCorrectDir($this->_settings['system']['mod_fcgid_configdir'] . '/' . $this->_domain['loginname'] . '/' . $this->_domain['domain'] . '/');
if(!is_dir($configdir) && $createifnotexists)
{
if (!is_dir($configdir) && $createifnotexists) {
safe_exec('mkdir -p ' . escapeshellarg($configdir));
safe_exec('chown ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($configdir));
}
@@ -226,66 +204,61 @@ class phpinterface_fcgid
/**
* fcgid-temp directory
*
*
* @param boolean $createifnotexists create the directory if it does not exist
*
*
* @return string the directory
*/
public function getTempDir($createifnotexists = true)
{
public function getTempDir($createifnotexists = true) {
$tmpdir = makeCorrectDir($this->_settings['system']['mod_fcgid_tmpdir'] . '/' . $this->_domain['loginname'] . '/');
if(!is_dir($tmpdir) && $createifnotexists)
{
if (!is_dir($tmpdir) && $createifnotexists) {
safe_exec('mkdir -p ' . escapeshellarg($tmpdir));
safe_exec('chown -R ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($tmpdir));
safe_exec('chmod 0750 ' . escapeshellarg($tmpdir));
}
return $tmpdir;
}
/**
* return path of php-starter file
*
*
* @return string the directory
*/
public function getStarterFile()
{
public function getStarterFile() {
$starter_filename = makeCorrectFile($this->getConfigDir() . '/php-fcgi-starter');
return $starter_filename;
}
/**
* return path of php.ini file
*
*
* @return string full with path file-name
*/
public function getIniFile()
{
public function getIniFile() {
$phpini_filename = makeCorrectFile($this->getConfigDir() . '/php.ini');
return $phpini_filename;
}
/**
* return the admin-data of a specific admin
*
*
* @param int $adminid id of the admin-user
*
*
* @return array
*/
private function _getAdminData($adminid)
{
private function _getAdminData($adminid) {
$adminid = intval($adminid);
if(!isset($this->_admin_cache[$adminid]))
{
$this->_admin_cache[$adminid] = $this->_db->query_first(
"SELECT `email`, `loginname` FROM `" . TABLE_PANEL_ADMINS . "`
WHERE `adminid` = " . (int)$adminid
if (!isset($this->_admin_cache[$adminid])) {
$stmt = Database::prepare("TABLE_PANEL_ADMINS
SELECT `email`, `loginname` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid` = :id"
);
$this->_admin_cache[$adminid] = Database::pexecute_first($stmt, array('id' => $adminid));
}
return $this->_admin_cache[$adminid];
}
}

View File

@@ -19,13 +19,7 @@
*
*/
class phpinterface_fpm
{
/**
* Database handler
* @var object
*/
private $_db = false;
class phpinterface_fpm {
/**
* Settings array
@@ -36,80 +30,83 @@ class phpinterface_fpm
/**
* Domain-Data array
* @var array
*/
*/
private $_domain = array();
/**
* Admin-Date cache array
* @var array
*/
*/
private $_admin_cache = array();
/**
* defines what can be used for pool-config from php.ini
* @var array
*/
*/
private $_ini = array(
'php_value' => array(
'error_reporting',
'max_execution_time',
'include_path',
'upload_max_filesize',
'log_errors_max_len'
),
'php_flag' => array(
'short_open_tag',
'asp_tags',
'display_errors',
'display_startup_errors',
'log_errors',
'track_errors',
'html_errors',
'magic_quotes_gpc',
'magic_quotes_runtime',
'magic_quotes_sybase'
),
'php_admin_value' => array(
'precision',
'output_buffering',
'disable_functions',
'max_input_time',
'memory_limit',
'post_max_size',
'variables_order',
'gpc_order',
'date.timezone'
),
'php_admin_flag' => array(
'allow_call_time_pass_reference',
'allow_url_fopen',
'cgi.force_redirect',
'enable_dl',
'expose_php',
'ignore_repeated_errors',
'ignore_repeated_source',
'report_memleaks',
'register_argc_argv',
'file_uploads',
'allow_url_fopen'
)
'php_value' => array(
'error_reporting',
'max_execution_time',
'include_path',
'upload_max_filesize',
'log_errors_max_len'
),
'php_flag' => array(
'short_open_tag',
'asp_tags',
'display_errors',
'display_startup_errors',
'log_errors',
'track_errors',
'html_errors',
'magic_quotes_gpc',
'magic_quotes_runtime',
'magic_quotes_sybase'
),
'php_admin_value' => array(
'precision',
'output_buffering',
'disable_functions',
'max_input_time',
'memory_limit',
'post_max_size',
'variables_order',
'gpc_order',
'date.timezone'
),
'php_admin_flag' => array(
'allow_call_time_pass_reference',
'allow_url_fopen',
'cgi.force_redirect',
'enable_dl',
'expose_php',
'ignore_repeated_errors',
'ignore_repeated_source',
'report_memleaks',
'register_argc_argv',
'file_uploads',
'allow_url_fopen'
)
);
/**
* main constructor
*/
public function __construct($db, $settings, $domain)
{
$this->_db = $db;
*/
public function __construct($settings, $domain) {
$this->_settings = $settings;
$this->_domain = $domain;
}
public function createConfig($phpconfig)
{
/**
* create fpm-pool config
*
* @param array $phpconfig
*/
public function createConfig($phpconfig) {
$fh = @fopen($this->getConfigFile(), 'w');
if($fh)
{
if ($fh) {
$fpm_pm = $this->_settings['phpfpm']['pm'];
$fpm_children = (int)$this->_settings['phpfpm']['max_children'];
$fpm_start_servers = (int)$this->_settings['phpfpm']['start_servers'];
@@ -118,39 +115,34 @@ class phpinterface_fpm
$fpm_requests = (int)$this->_settings['phpfpm']['max_requests'];
$fpm_process_idle_timeout = (int)$this->_settings['phpfpm']['idle_timeout'];
if($fpm_children == 0) {
if ($fpm_children == 0) {
$fpm_children = 1;
}
$fpm_config = ';PHP-FPM configuration for "'.$this->_domain['domain'].'" created on ' . date("Y.m.d H:i:s") . "\n";
$fpm_config.= '['.$this->_domain['domain'].']'."\n";
$fpm_config.= 'listen = '.$this->getSocketFile()."\n";
if($this->_domain['loginname'] == 'froxlor.panel')
{
if ($this->_domain['loginname'] == 'froxlor.panel') {
$fpm_config.= 'listen.owner = '.$this->_domain['guid']."\n";
$fpm_config.= 'listen.group = '.$this->_domain['guid']."\n";
}
else
{
} else {
$fpm_config.= 'listen.owner = '.$this->_domain['loginname']."\n";
$fpm_config.= 'listen.group = '.$this->_domain['loginname']."\n";
}
$fpm_config.= 'listen.mode = 0666'."\n";
if($this->_domain['loginname'] == 'froxlor.panel')
{
if ($this->_domain['loginname'] == 'froxlor.panel') {
$fpm_config.= 'user = '.$this->_domain['guid']."\n";
$fpm_config.= 'group = '.$this->_domain['guid']."\n";
}
else
{
} else {
$fpm_config.= 'user = '.$this->_domain['loginname']."\n";
$fpm_config.= 'group = '.$this->_domain['loginname']."\n";
}
$fpm_config.= 'pm = '.$fpm_pm."\n";
$fpm_config.= 'pm.max_children = '.$fpm_children."\n";
if($fpm_pm == 'dynamic') {
if ($fpm_pm == 'dynamic') {
// failsafe, refs #955
if ($fpm_start_servers < $fpm_min_spare_servers) {
$fpm_start_servers = $fpm_min_spare_servers;
@@ -167,12 +159,10 @@ class phpinterface_fpm
}
$fpm_config.= 'pm.max_requests = '.$fpm_requests."\n";
$fpm_config.= ';chroot = '.makeCorrectDir($this->_domain['documentroot'])."\n";
$tmpdir = makeCorrectDir($this->_settings['phpfpm']['tmpdir'] . '/' . $this->_domain['loginname'] . '/');
if(!is_dir($tmpdir))
{
if (!is_dir($tmpdir)) {
$this->getTempDir();
}
//$slowlog = makeCorrectFile($this->_settings['system']['logfiles_directory'] . $this->_domain['loginname'] . '/php-fpm_slow.log');
@@ -182,30 +172,26 @@ class phpinterface_fpm
$fpm_config.= 'env[TEMP] = '.$tmpdir."\n";
$fpm_config.= 'php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f '.$this->_domain['email']."\n";
if($this->_domain['loginname'] != 'froxlor.panel')
{
if($this->_domain['openbasedir'] == '1')
{
if ($this->_domain['loginname'] != 'froxlor.panel') {
if ($this->_domain['openbasedir'] == '1') {
$openbasedir = '';
$_phpappendopenbasedir = '';
$_custom_openbasedir = explode(':', $this->_settings['phpfpm']['peardir']);
foreach($_custom_openbasedir as $cobd)
{
foreach ($_custom_openbasedir as $cobd) {
$_phpappendopenbasedir .= appendOpenBasedirPath($cobd);
}
$_custom_openbasedir = explode(':', $this->_settings['system']['phpappendopenbasedir']);
foreach($_custom_openbasedir as $cobd)
{
foreach ($_custom_openbasedir as $cobd) {
$_phpappendopenbasedir .= appendOpenBasedirPath($cobd);
}
if($this->_domain['openbasedir_path'] == '0' && strstr($this->_domain['documentroot'], ":") === false)
{
if ($this->_domain['openbasedir_path'] == '0'
&& strstr($this->_domain['documentroot'], ":") === false
) {
$openbasedir = appendOpenBasedirPath($this->_domain['documentroot'], true);
}
else
{
} else {
$openbasedir = appendOpenBasedirPath($this->_domain['customerroot'], true);
}
@@ -214,10 +200,8 @@ class phpinterface_fpm
$openbasedir = explode(':', $openbasedir);
$clean_openbasedir = array();
foreach($openbasedir as $number => $path)
{
if(trim($path) != '/')
{
foreach ($openbasedir as $number => $path) {
if (trim($path) != '/') {
$clean_openbasedir[] = makeCorrectDir($path);
}
}
@@ -230,6 +214,7 @@ class phpinterface_fpm
$fpm_config.= 'php_admin_value[upload_tmp_dir] = ' . makeCorrectDir($this->_settings['phpfpm']['tmpdir'] . '/' . $this->_domain['loginname'] . '/') . "\n";
$admin = $this->_getAdminData($this->_domain['adminid']);
$php_ini_variables = array(
'SAFE_MODE' => 'Off', // keep this for compatibility, just in case
'PEAR_DIR' => $this->_settings['system']['mod_fcgid_peardir'],
@@ -265,8 +250,7 @@ class phpinterface_fpm
*
* @param string $phpconfig
*/
public function createIniFile($phpconfig)
{
public function createIniFile($phpconfig) {
return;
}
@@ -277,13 +261,12 @@ class phpinterface_fpm
*
* @return string the full path to the file
*/
public function getConfigFile($createifnotexists = true)
{
public function getConfigFile($createifnotexists = true) {
$configdir = makeCorrectDir($this->_settings['phpfpm']['configdir']);
$config = makeCorrectFile($configdir.'/'.$this->_domain['domain'].'.conf');
if(!is_dir($configdir) && $createifnotexists)
{
if (!is_dir($configdir) && $createifnotexists) {
safe_exec('mkdir -p ' . escapeshellarg($configdir));
}
@@ -297,13 +280,12 @@ class phpinterface_fpm
*
* @return string the full path to the socket
*/
public function getSocketFile($createifnotexists = true)
{
public function getSocketFile($createifnotexists = true) {
$socketdir = makeCorrectDir('/var/run/'.$this->_settings['system']['webserver'].'/');
$socket = makeCorrectFile($socketdir.'/'.$this->_domain['loginname'].'-'.$this->_domain['domain'].'-php-fpm.socket');
if(!is_dir($socketdir) && $createifnotexists)
{
if (!is_dir($socketdir) && $createifnotexists) {
safe_exec('mkdir -p '.escapeshellarg($socketdir));
safe_exec('chown -R '.$this->_settings['system']['httpuser'].':'.$this->_settings['system']['httpgroup'].' '.escapeshellarg($socketdir));
}
@@ -318,12 +300,11 @@ class phpinterface_fpm
*
* @return string the directory
*/
public function getTempDir($createifnotexists = true)
{
public function getTempDir($createifnotexists = true) {
$tmpdir = makeCorrectDir($this->_settings['phpfpm']['tmpdir'] . '/' . $this->_domain['loginname'] . '/');
if(!is_dir($tmpdir) && $createifnotexists)
{
if (!is_dir($tmpdir) && $createifnotexists) {
safe_exec('mkdir -p ' . escapeshellarg($tmpdir));
safe_exec('chown -R ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($tmpdir));
safe_exec('chmod 0750 ' . escapeshellarg($tmpdir));
@@ -333,28 +314,27 @@ class phpinterface_fpm
}
/**
* fastcgi-fakedirectory directory
*
* @param boolean $createifnotexists create the directory if it does not exist
*
* @return string the directory
*/
public function getAliasConfigDir($createifnotexists = true)
{
// ensure default...
if (!isset($this->_settings['phpfpm']['aliasconfigdir'])) {
$this->_settings['phpfpm']['aliasconfigdir'] = '/var/www/php-fpm';
}
* fastcgi-fakedirectory directory
*
* @param boolean $createifnotexists create the directory if it does not exist
*
* @return string the directory
*/
public function getAliasConfigDir($createifnotexists = true) {
$configdir = makeCorrectDir($this->_settings['phpfpm']['aliasconfigdir'] . '/' . $this->_domain['loginname'] . '/' . $this->_domain['domain'] . '/');
if(!is_dir($configdir) && $createifnotexists)
{
safe_exec('mkdir -p ' . escapeshellarg($configdir));
safe_exec('chown ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($configdir));
}
// ensure default...
if (!isset($this->_settings['phpfpm']['aliasconfigdir'])) {
$this->_settings['phpfpm']['aliasconfigdir'] = '/var/www/php-fpm';
}
return $configdir;
}
$configdir = makeCorrectDir($this->_settings['phpfpm']['aliasconfigdir'] . '/' . $this->_domain['loginname'] . '/' . $this->_domain['domain'] . '/');
if (!is_dir($configdir) && $createifnotexists) {
safe_exec('mkdir -p ' . escapeshellarg($configdir));
safe_exec('chown ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($configdir));
}
return $configdir;
}
/**
* return the admin-data of a specific admin
@@ -364,15 +344,15 @@ class phpinterface_fpm
* @return array
*/
private function _getAdminData($adminid) {
$adminid = intval($adminid);
if (!isset($this->_admin_cache[$adminid])) {
$this->_admin_cache[$adminid] = $this->_db->query_first(
"SELECT `email`, `loginname` FROM `" . TABLE_PANEL_ADMINS . "`
WHERE `adminid` = " . (int)$adminid
$stmt = Database::prepare("TABLE_PANEL_ADMINS
SELECT `email`, `loginname` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid` = :id"
);
$this->_admin_cache[$adminid] = Database::pexecute_first($stmt, array('id' => $adminid));
}
return $this->_admin_cache[$adminid];
}
}

View File

@@ -20,20 +20,14 @@
* Support Tickets - Tickets-Class
*/
class ticket
{
class ticket {
/**
* Userinfo
* @var array
*/
private $userinfo = array();
/**
* Database handler
* @var db
*/
private $db = false;
/**
* Settings array
* @var settings
@@ -68,14 +62,11 @@ class ticket
* Class constructor.
*
* @param array userinfo
* @param resource database
* @param array settings
* @param int ticket id
*/
private function __construct($userinfo, $db, $settings, $tid = - 1)
{
private function __construct($userinfo, $settings, $tid = - 1) {
$this->userinfo = $userinfo;
$this->db = $db;
$this->settings = $settings;
$this->tid = $tid;
@@ -96,23 +87,22 @@ class ticket
/**
* Singleton ftw ;-)
*
* @param array userinfo
* @param array settings
* @param int ticket id
*/
static public function getInstanceOf($_usernfo, $_db, $_settings, $_tid)
{
if(!isset(self::$tickets[$_tid]))
{
self::$tickets[$_tid] = new ticket($_usernfo, $_db, $_settings, $_tid);
static public function getInstanceOf($_usernfo, $_settings, $_tid) {
if (!isset(self::$tickets[$_tid])) {
self::$tickets[$_tid] = new ticket($_usernfo, $_settings, $_tid);
}
return self::$tickets[$_tid];
}
/**
* Initialize data-array
*/
private function initData()
{
private function initData() {
$this->Set('customer', 0, true, true);
$this->Set('admin', 1, true, true);
$this->Set('subject', '', true, true);
@@ -132,12 +122,16 @@ class ticket
/**
* Read ticket data from database.
*/
private function readData()
{
if(isset($this->tid)
&& $this->tid != - 1)
{
$_ticket = $this->db->query_first('SELECT * FROM `' . TABLE_PANEL_TICKETS . '` WHERE `id` = "' . $this->tid . '"');
private function readData() {
if (isset($this->tid)
&& $this->tid != - 1
) {
$_ticket_stmt = Database::prepare('
SELECT * FROM `' . TABLE_PANEL_TICKETS . '` WHERE `id` = :tid'
);
$_ticket = Database::pexecute_first($_ticket_stmt, array('tid' => $this->tid));
$this->Set('customer', $_ticket['customerid'], true, false);
$this->Set('admin', $_ticket['adminid'], true, false);
$this->Set('subject', $_ticket['subject'], true, false);
@@ -158,79 +152,104 @@ class ticket
/**
* Insert data to database
*/
public function Insert()
{
$this->db->query("INSERT INTO `" . TABLE_PANEL_TICKETS . "`
(`customerid`,
`adminid`,
`category`,
`priority`,
`subject`,
`message`,
`dt`,
`lastchange`,
`ip`,
`status`,
`lastreplier`,
`by`,
`answerto`)
VALUES
('" . (int)$this->Get('customer') . "',
'" . (int)$this->Get('admin') . "',
'" . (int)$this->Get('category') . "',
'" . (int)$this->Get('priority') . "',
'" . $this->db->escape($this->Get('subject')) . "',
'" . $this->db->escape($this->Get('message')) . "',
'" . (int)$this->Get('dt') . "',
'" . (int)$this->Get('lastchange') . "',
'" . $this->db->escape($this->Get('ip')) . "',
'" . (int)$this->Get('status') . "',
'" . (int)$this->Get('lastreplier') . "',
'" . (int)$this->Get('by') . "',
'" . (int)$this->Get('answerto') . "');");
$this->tid = $this->db->insert_id();
public function Insert() {
$ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_TICKETS . "` SET
`customerid` = :customerid,
`adminid` = :adminid,
`category` = :category,
`priority` = :priority,
`subject` = :subject,
`message` = :message,
`dt` = :dt,
`lastchange` = :lastchange,
`ip` = :ip,
`status` = :status,
`lastreplier` = :lastreplier,
`by` = :by,
`answerto` = :answerto"
);
$ins_data = array(
'customerid' => $this->Get('customer'),
'adminid' => $this->Get('admin'),
'category' => $this->Get('category'),
'priority' => $this->Get('priority'),
'subject' => $this->Get('subject'),
'message' => $this->Get('message'),
'dt' => $this->Get('dt'),
'lastchange' => $this->Get('lastchange'),
'ip' => $this->Get('ip'),
'status' => $this->Get('status'),
'lastreplier' => $this->Get('lastreplier'),
'by' => $this->Get('by'),
'answerto' => $this->Get('answerto')
);
Database::pexecute($ins_stmt, $ins_data);
$this->tid = Database::lastInsertId();
return true;
}
/**
* Update data in database
*/
public function Update()
{
// Update "main" ticket
public function Update() {
$this->db->query('UPDATE `' . TABLE_PANEL_TICKETS . '` SET
`priority` = "' . (int)$this->Get('priority') . '",
`lastchange` = "' . (int)$this->Get('lastchange') . '",
`status` = "' . (int)$this->Get('status') . '",
`lastreplier` = "' . (int)$this->Get('lastreplier') . '"
WHERE `id` = "' . (int)$this->tid . '";');
// Update "main" ticket
$upd_stmt = Database::prepare('
UPDATE `' . TABLE_PANEL_TICKETS . '` SET
`priority` = :priority,
`lastchange` = :lastchange,
`status` = :status,
`lastreplier` = :lastreplier
WHERE `id` = :tid'
);
$upd_data = array(
'priority' => $this->Get('priority'),
'lastchange' => $this->Get('lastchange'),
'status' => $this->Get('status'),
'lastreplier' => $this->Get('lastreplier'),
'tid' => $this->tid
);
Database::pexecute($upd_stmt, $upd_data);
return true;
}
/**
* Moves a ticket to the archive
*/
public function Archive()
{
public function Archive() {
// Update "main" ticket
$this->db->query('UPDATE `' . TABLE_PANEL_TICKETS . '` SET `archived` = "1" WHERE `id` = "' . (int)$this->tid . '";');
$upd_stmt = Database::prepare('
UPDATE `' . TABLE_PANEL_TICKETS . '` SET `archived` = "1" WHERE `id` = :tid'
);
Database::pexecute($upd_stmt, array('tid' => $this->tid));
// Update "answers" to ticket
$this->db->query('UPDATE `' . TABLE_PANEL_TICKETS . '` SET `archived` = "1" WHERE `answerto` = "' . (int)$this->tid . '";');
$upd_stmt = Database::prepare('
UPDATE `' . TABLE_PANEL_TICKETS . '` SET `archived` = "1" WHERE `answerto` = :tid'
);
Database::pexecute($upd_stmt, array('tid' => $this->tid));
return true;
}
/**
* Remove ticket from database
*/
public function Delete()
{
public function Delete() {
// Delete "main" ticket
$this->db->query('DELETE FROM `' . TABLE_PANEL_TICKETS . '` WHERE `id` = "' . (int)$this->tid . '";');
$del_stmt = Database::prepare('
DELETE FROM `' . TABLE_PANEL_TICKETS . '` WHERE `id` = :tid'
);
Database::pexecute($del_stmt, array('tid' => $this->tid));
// Delete "answers" to ticket"
$this->db->query('DELETE FROM `' . TABLE_PANEL_TICKETS . '` WHERE `answerto` = "' . (int)$this->tid . '";');
$del_stmt = Database::prepare('
DELETE FROM `' . TABLE_PANEL_TICKETS . '` WHERE `answerto` = :tid'
);
Database::pexecute($del_stmt, array('tid' => $this->tid));
return true;
}
@@ -242,12 +261,14 @@ class ticket
global $mail, $theme;
// Some checks are to be made here in the future
if($customerid != - 1)
{
if ($customerid != - 1) {
// Get e-mail message for customer
$usr = $this->db->query_first('SELECT `name`, `firstname`, `company`, `email`
FROM `' . TABLE_PANEL_CUSTOMERS . '`
WHERE `customerid` = "' . (int)$customerid . '"');
$usr_stmt = Database::prepare('
SELECT `name`, `firstname`, `company`, `email`
FROM `' . TABLE_PANEL_CUSTOMERS . '` WHERE `customerid` = :customerid'
);
$usr = Database::pexecute_first($usr_stmt, array('customerid' => $customerid));
$replace_arr = array(
'FIRSTNAME' => $usr['firstname'],
'NAME' => $usr['name'],
@@ -255,29 +276,38 @@ class ticket
'SALUTATION' => getCorrectUserSalutation($usr),
'SUBJECT' => $this->Get('subject', true)
);
}
else
{
} else {
$replace_arr = array(
'SUBJECT' => $this->Get('subject', true)
);
}
$result = $this->db->query_first('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '`
WHERE `adminid`=\'' . (int)$this->userinfo['adminid'] . '\'
AND `language`=\'' . $this->db->escape($this->userinfo['def_language']) . '\'
AND `templategroup`=\'mails\'
AND `varname`=\'' . $template_subject . '\'');
$tpl_seldata = array(
'adminid' => $this->userinfo['adminid'],
'lang' => $this->userinfo['def_language'],
'tplsubject' => $template_subject
);
$result_stmt = Database::prepare("
SELECT `value` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid`= :adminid
AND `language`= :lang
AND `templategroup`= 'mails' AND `varname`= :tplsubject"
);
$result = Database::pexecute_first($result_stmt, $tpl_seldata);
$mail_subject = html_entity_decode(replace_variables((($result['value'] != '') ? $result['value'] : $default_subject), $replace_arr));
$result = $this->db->query_first('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '`
WHERE `adminid`=\'' . (int)$this->userinfo['adminid'] . '\'
AND `language`=\'' . $this->db->escape($this->userinfo['def_language']) . '\'
AND `templategroup`=\'mails\'
AND `varname`=\'' . $template_body . '\'');
unset($tpl_seldata['tplsubject']);
$tpl_seldata['tplbody'] = $template_body;
$result_stmt = Database::prepare("
SELECT `value` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid`= :adminid
AND `language`= :lang
AND `templategroup`= 'mails' AND `varname`= :tplmailbody"
);
$result = Database::pexecute_first($result_stmt, $tpl_seldata);
$mail_body = html_entity_decode(replace_variables((($result['value'] != '') ? $result['value'] : $default_body), $replace_arr));
if($customerid != - 1)
{
if ($customerid != - 1) {
$_mailerror = false;
try {
$mail->SetFrom($this->settings['ticket']['noreply_email'], $this->settings['ticket']['noreply_name']);
@@ -299,13 +329,15 @@ class ticket
$rstlog->logAction(ADM_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
standard_error('errorsendingmail', $usr['email']);
}
$mail->ClearAddresses();
}
else
{
$admin = $this->db->query_first("SELECT `name`, `email` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid`='" . (int)$this->userinfo['adminid'] . "'");
} else {
$admin_stmt = Database::prepare("
SELECT `name`, `email` FROM `" . TABLE_PANEL_ADMINS . "`
WHERE `adminid` = :adminid"
);
$admin = Database::pexecute_first($admin_stmt, array('adminid' => $userinfo['adminid']));
$_mailerror = false;
try {
$mail->SetFrom($this->settings['ticket']['noreply_email'], $this->settings['ticket']['noreply_name']);
@@ -335,65 +367,77 @@ class ticket
/**
* Add a support-categories
*/
static public function addCategory($_db, $_category = null, $_admin = 1, $_order = 1)
{
if($_category != null
&& $_category != '')
{
if($_order < 1) {
static public function addCategory($_category = null, $_admin = 1, $_order = 1) {
if ($_category != null
&& $_category != ''
) {
if ($_order < 1) {
$_order = 1;
}
$_db->query('INSERT INTO `' . TABLE_PANEL_TICKET_CATS . '` SET
`name` = "' . $_db->escape($_category) . '",
`adminid` = "' . (int)$_admin . '",
`logicalorder` = "' . (int)$_order . '"');
$ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_TICKET_CATS . "` SET
`name` = :name,
`adminid` = :adminid,
`logicalorder` = :lo"
);
$ins_data = array(
'name' => $_category,
'adminid' => $_admin,
'lo' => $_order
);
Database::pexecute($ins_stmt, $ins_data);
return true;
}
return false;
}
/**
* Edit a support-categories
*/
static public function editCategory($_db, $_category = null, $_id = 0, $_order = 1)
{
if($_category != null
&& $_category != ''
&& $_id != 0)
{
if($_order < 1) {
static public function editCategory($_category = null, $_id = 0, $_order = 1) {
if ($_category != null
&& $_category != ''
&& $_id != 0
) {
if ($_order < 1) {
$_order = 1;
}
$_db->query('UPDATE `' . TABLE_PANEL_TICKET_CATS . '` SET
`name` = "' . $_db->escape($_category) . '",
`logicalorder` = "' . (int)$_order . '"
WHERE `id` = "' . (int)$_id . '"');
$upd_stmt = Database::prepare("
UPDATE `' . TABLE_PANEL_TICKET_CATS . '` SET
`name` = :name,
`logicalorder` = :lo
WHERE `id` = :id"
);
Database::pexecute($upd_stmt, array('name' => $_category, 'lo' => $_order, 'id' => $_id));
return true;
}
return false;
}
/**
* Delete a support-categories
*/
static public function deleteCategory($_db, $_id = 0)
{
if($_id != 0)
{
$result = $_db->query_first('SELECT COUNT(`id`) as `numtickets` FROM `' . TABLE_PANEL_TICKETS . '`
WHERE `category` = "' . (int)$_id . '"');
static public function deleteCategory($_id = 0) {
if($result['numtickets'] == "0")
{
$_db->query('DELETE FROM `' . TABLE_PANEL_TICKET_CATS . '` WHERE `id` = "' . (int)$_id . '"');
if ($_id != 0) {
$result_stmt = Database::prepare("
SELECT COUNT(`id`) as `numtickets` FROM `" . TABLE_PANEL_TICKETS . "`
WHERE `category` = :cat"
);
$result = Database::pexecute_first($result_stmt, array('cat' => $_id));
if ($result['numtickets'] == "0") {
$del_stmt = Database::prepare("
DELETE FROM `" . TABLE_PANEL_TICKET_CATS . "` WHERE `id` = :id"
);
Database::pexecute($del_stmt, array('id' => $_id));
return true;
}
else
{
} else {
return false;
}
}
@@ -404,55 +448,63 @@ class ticket
/**
* Return a support-category-name
*/
static public function getCategoryName($_db, $_id = 0)
{
if($_id != 0)
{
$category = $_db->query_first('SELECT `name` FROM `' . TABLE_PANEL_TICKET_CATS . '` WHERE `id` = "' . (int)$_id . '"');
static public function getCategoryName($_id = 0) {
if ($_id != 0) {
$stmt = Database::prepare("
SELECT `name` FROM `" . TABLE_PANEL_TICKET_CATS . "` WHERE `id` = :id"
);
$category = Database::pexecute_first($stmt, array('id' => $_id));
return $category['name'];
}
return null;
}
/**
* get the highest order number
*
* @param object $_db database-object
* @param object $_uid admin-id (optional)
*
* @return int highest order number
*/
static public function getHighestOrderNumber($_db = null, $_uid = 0)
{
static public function getHighestOrderNumber($_uid = 0) {
$where = '';
$sel_data = array();
if ($_uid > 0) {
$where = ' WHERE `adminid` = "'.(int)$_uid.'"';
$where = " WHERE `adminid` = :adminid";
$sel_data['adminid'] = $_uid;
}
$sql = "SELECT MAX(`logicalorder`) as `highestorder` FROM `" . TABLE_PANEL_TICKET_CATS . "`".$where.";";
$result = $_db->query_first($sql);
$result_stmt = Database::prepare($sql);
$result = Database::pexecute_first($result_stmt, $sel_data);
return (isset($result['highestorder']) ? (int)$result['highestorder'] : 0);
}
/**
* returns the last x archived tickets
*/
static public function getLastArchived($_db, $_num = 10, $_admin = 1)
{
if($_num > 0)
{
static public function getLastArchived($_num = 10, $_admin = 1) {
if ($_num > 0) {
$archived = array();
$counter = 0;
$result = $_db->query('SELECT *,
(SELECT COUNT(`sub`.`id`)
FROM `' . TABLE_PANEL_TICKETS . '` `sub`
WHERE `sub`.`answerto` = `main`.`id`) as `ticket_answers`
FROM `' . TABLE_PANEL_TICKETS . '` `main`
WHERE `main`.`answerto` = "0"
AND `main`.`archived` = "1" AND `main`.`adminid` = "' . (int)$_admin . '"
ORDER BY `main`.`lastchange` DESC LIMIT 0, ' . (int)$_num);
$result_stmt = Database::prepare("
SELECT *, (
SELECT COUNT(`sub`.`id`)
FROM `" . TABLE_PANEL_TICKETS . "` `sub`
WHERE `sub`.`answerto` = `main`.`id`
) as `ticket_answers`
FROM `" . TABLE_PANEL_TICKETS . "` `main`
WHERE `main`.`answerto` = '0' AND `main`.`archived` = '1'
AND `main`.`adminid` = :adminid
ORDER BY `main`.`lastchange` DESC LIMIT 0, ".(int)$_num
);
Database::pexecute($result_stmt, array('adminid' => $_admin));
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
while($row = $_db->fetch_array($result))
{
$archived[$counter]['id'] = $row['id'];
$archived[$counter]['customerid'] = $row['customerid'];
$archived[$counter]['adminid'] = $row['adminid'];
@@ -469,12 +521,9 @@ class ticket
$counter++;
}
if(isset($archived[0]['id']))
{
if (isset($archived[0]['id'])) {
return $archived;
}
else
{
} else {
return false;
}
}
@@ -482,131 +531,136 @@ class ticket
/**
* Returns a sql-statement to search the archive
* including necessary parameter-array for PDO
*
* @return array 0 = query, 1 = params-array
*/
static public function getArchiveSearchStatement($db, $subject = NULL, $priority = NULL, $fromdate = NULL, $todate = NULL, $message = NULL, $customer = - 1, $admin = 1, $categories = NULL)
static public function getArchiveSearchStatement($subject = null, $priority = null, $fromdate = null, $todate = null, $message = null, $customer = - 1, $admin = 1, $categories = null)
{
$query = 'SELECT `main`.*,
(SELECT COUNT(`sub`.`id`) FROM `' . TABLE_PANEL_TICKETS . '` `sub`
WHERE `sub`.`answerto` = `main`.`id`) as `ticket_answers`
FROM `' . TABLE_PANEL_TICKETS . '` `main`
WHERE `main`.`archived` = "1" AND `main`.`adminid` = "' . (int)$admin . '" ';
$search_params = array();
if($subject != NULL
&& $subject != '')
{
$query.= 'AND `main`.`subject` LIKE "' . $db->escape("%$subject%") . '" ';
$query = "
SELECT `main`.*, (
SELECT COUNT(`sub`.`id`) FROM `" . TABLE_PANEL_TICKETS . "` `sub`
WHERE `sub`.`answerto` = `main`.`id`
) as `ticket_answers`
FROM `" . TABLE_PANEL_TICKETS . "` `main`
WHERE `main`.`archived` = '1' AND `main`.`adminid` = :admin"
;
$search_params['admin'] = $admin;
if ($subject != NULL
&& $subject != ''
) {
$query .= " AND `main`.`subject` LIKE :subject";
$search_params['subject'] = "%".$subject."%";
}
if($priority != NULL
&& isset($priority[0])
&& $priority[0] != '')
{
if(isset($priority[1])
&& $priority[1] != '')
{
if(isset($priority[2])
&& $priority[2] != '')
{
$query.= 'AND (`main`.`priority` = "1"
OR `main`.`priority` = "2"
OR `main`.`priority` = "3") ';
}
else
{
$query.= 'AND (`main`.`priority` = "1"
OR `main`.`priority` = "2") ';
if ($priority != null
&& isset($priority[0])
&& $priority[0] != ''
) {
if (isset($priority[1])
&& $priority[1] != ''
) {
if (isset($priority[2])
&& $priority[2] != ''
) {
$query .= " AND (`main`.`priority` = '1' OR `main`.`priority` = '2' OR `main`.`priority` = '3')";
} else {
$query .= " AND (`main`.`priority` = '1' OR `main`.`priority` = '1')";
}
} elseif (isset($priority[2])
&& $priority[2] != ''
) {
$query .= " AND (`main`.`priority` = '1' OR `main`.`priority` = '3')";
} else {
$query .= " AND `main`.`priority` = '1'";
}
elseif(isset($priority[2])
&& $priority[2] != '')
{
$query.= 'AND (`main`.`priority` = "1"
OR `main`.`priority` = "3") ';
} elseif($priority != null
&& isset($priority[1])
&& $priority[1] != ''
) {
if (isset($priority[2])
&& $priority[2] != ''
) {
$query .= " AND (`main`.`priority` = '2' OR `main`.`priority` = '3')";
} else {
$query .= " AND `main`.`priority` = '2'";
}
else
{
$query.= 'AND `main`.`priority` = "1" ';
}
}
elseif($priority != NULL
&& isset($priority[1])
&& $priority[1] != '')
{
if(isset($priority[2])
&& $priority[2] != '')
{
$query.= 'AND (`main`.`priority` = "2" OR `main`.`priority` = "3") ';
}
else
{
$query.= 'AND `main`.`priority` = "2" ';
}
}
elseif($priority != NULL)
{
if(isset($priority[3])
&& $priority[3] != '')
{
$query.= 'AND `main`.`priority` = "3" ';
} elseif($priority != null) {
if (isset($priority[3])
&& $priority[3] != ''
) {
$query .= " AND `main`.`priority` = '3'";
}
}
if($fromdate != NULL
&& $fromdate > 0)
{
$query.= 'AND `main`.`lastchange` > "' . $db->escape(strtotime($fromdate)) . '" ';
if ($fromdate != null
&& $fromdate > 0
) {
$query .= " AND `main`.`lastchange` > :fromdate";
$search_params['fromdate'] = strtotime($fromdate);
}
if($todate != NULL
&& $todate > 0)
{
$query.= 'AND `main`.`lastchange` < "' . $db->escape(strtotime($todate)) . '" ';
if ($todate != null
&& $todate > 0
) {
$query .= " AND `main`.`lastchange` < :todate";
$search_params['todate'] = strtotime($todate);
}
if($message != NULL
&& $message != '')
{
$query.= 'AND `main`.`message` LIKE "' . $db->escape("%$message%") . '" ';
if ($message != null
&& $message != ''
) {
$query .= " AND `main`.`message` LIKE :message";
$search_params['message'] = "%".$message."%";
}
if($customer != - 1)
{
$query.= 'AND `main`.`customerid` = "' . (int)$customer . '" ';
if ($customer != - 1) {
$query .= " AND `main`.`customerid` = :customer";
$search_params['customer'] = $customer;
}
if($categories != NULL)
{
if ($categories != null) {
$cats = array();
foreach($categories as $index => $catid)
{
if ($catid != "")
{
foreach ($categories as $index => $catid) {
if ($catid != "") {
$cats[] = $catid;
}
}
if (count($cats) > 0)
{
$query.= 'AND (';
if (count($cats) > 0) {
$query .= " AND (";
}
foreach($cats as $catid)
{
if(isset($catid)
&& $catid > 0)
{
$query.= '`main`.`category` = "' . (int)$catid . '" OR ';
foreach ($cats as $catid) {
if (isset($catid) && $catid > 0) {
$query .= "`main`.`category` = :catid_".$catid." OR ";
$search_params['catid_'.$catid] = $catid;
}
}
if (count($cats) > 0)
{
if (count($cats) > 0) {
$query = substr($query, 0, strlen($query) - 3);
$query.= ') ';
$query .= ") ";
}
}
return $query;
return array('0' => $query, '1' => $search_params);
}
/**
@@ -674,20 +728,20 @@ class ticket
/**
* function customerHasTickets
*
* @param object mysql-db-object
* @param int customer-id
*
* @return array/bool array of ticket-ids if customer has any, else false
*/
static public function customerHasTickets($_db = null, $_cid = 0)
{
if($_cid != 0)
{
$result = $_db->query('SELECT `id` FROM `' . TABLE_PANEL_TICKETS . '` WHERE `customerid` ="'.(int)$_cid.'"');
static public function customerHasTickets($_cid = 0) {
if ($_cid != 0) {
$result_stmt = Database::prepare("
SELECT `id` FROM `" . TABLE_PANEL_TICKETS . "` WHERE `customerid` = :cid"
);
Database::pexecute($result_stmt, array('cid' => $_cid));
$tickets = array();
while($row = $_db->fetch_array($result))
{
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$tickets[] = $row['id'];
}
@@ -700,32 +754,22 @@ class ticket
/**
* Get a data-var
*/
public function Get($_var = '', $_vartrusted = false)
{
if($_var != '')
{
if(!$_vartrusted)
{
public function Get($_var = '', $_vartrusted = false) {
if ($_var != '') {
if (!$_vartrusted) {
$_var = htmlspecialchars($_var);
}
if(isset($this->t_data[$_var]))
{
if(strtolower($_var) == 'message')
{
if (isset($this->t_data[$_var])) {
if (strtolower($_var) == 'message') {
return nl2br($this->t_data[$_var]);
}
elseif(strtolower($_var) == 'subject')
{
} elseif(strtolower($_var) == 'subject') {
return nl2br($this->t_data[$_var]);
}
else
{
} else {
return $this->t_data[$_var];
}
}
else
{
} else {
return null;
}
}
@@ -734,23 +778,22 @@ class ticket
/**
* Set a data-var
*/
public function Set($_var = '', $_value = '', $_vartrusted = false, $_valuetrusted = false)
{
if($_var != ''
&& $_value != '')
{
if(!$_vartrusted)
{
public function Set($_var = '', $_value = '', $_vartrusted = false, $_valuetrusted = false) {
if ($_var != ''
&& $_value != ''
) {
if (!$_vartrusted) {
$_var = $this->_purifier->purify($_var);
}
if(!$_valuetrusted)
{
if (!$_valuetrusted) {
$_value = $this->_purifier->purify($_value);
}
if(strtolower($_var) == 'message' || strtolower($_var) == 'subject')
{
if (strtolower($_var) == 'message'
|| strtolower($_var) == 'subject'
) {
$_value = $this->convertLatin1ToHtml($_value);
}

View File

@@ -26,17 +26,19 @@
*
* @return boolean
*/
function domainHasApsInstances($domainid = 0)
{
global $db, $settings, $theme;
function domainHasApsInstances($domainid = 0) {
global $settings, $theme;
if($settings['aps']['aps_active'] == '1')
{
if($domainid > 0)
{
$instances = $db->query_first("SELECT COUNT(`ID`) AS `count` FROM `" . TABLE_APS_SETTINGS . "` WHERE `Name`='main_domain' AND `Value`='" . (int)$domainid . "'");
if((int)$instances['count'] != 0)
{
if ($settings['aps']['aps_active'] == '1') {
if ($domainid > 0) {
$instances_stmt = Database::prepare("
SELECT COUNT(`ID`) AS `count` FROM `" . TABLE_APS_SETTINGS . "`
WHERE `Name` = 'main_domain' AND `Value` = :domainid"
);
$instances = Database::pexecute_first($instances_stmt, array('domainid' => $domainid));
if ((int)$instances['count'] != 0) {
return true;
}
}

View File

@@ -29,8 +29,7 @@ function domainHasMainSubDomains($id = 0) {
SELECT COUNT(`id`) as `mainsubs` FROM `".TABLE_PANEL_DOMAINS."`
WHERE `ismainbutsubto` = :id"
);
Database::pexecute($result_stmt, array('id' => $id));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
$result = Database::pexecute_first($result_stmt, array('id' => $id));
if (isset($result['mainsubs'])
&& $result['mainsubs'] > 0

View File

@@ -234,7 +234,7 @@ class apache
'loginname' => 'froxlor.panel',
'documentroot' => $mypath
);
$php = new phpinterface($this->getDB(), $this->settings, $domain);
$php = new phpinterface($this->settings, $domain);
$phpconfig = $php->getPhpConfig($this->settings['system']['mod_fcgid_defaultini_ownvhost']);
$starter_filename = makeCorrectFile($configdir . '/php-fcgi-starter');
@@ -273,7 +273,7 @@ class apache
'documentroot' => $mypath,
);
$php = new phpinterface($this->getDB(), $this->settings, $domain);
$php = new phpinterface($this->settings, $domain);
$phpconfig = $php->getPhpConfig($this->settings['phpfpm']['vhost_defaultini']);
$srvName = substr(md5($ipport),0,4).'.fpm.external';
if ($row_ipsandports['ssl']) {
@@ -809,7 +809,7 @@ class apache
GROUP BY `id_domain`
) AS p ON p.`id_domain` = `d`.`id`
WHERE `d`.`aliasdomain` IS NULL
WHERE `d`.`aliasdomain` IS NULL AND `d`.`email_only` = '0'
ORDER BY `d`.`parentdomainid` DESC, `d`.`iswildcarddomain`, `d`.`domain` ASC;";
$result_domains = $this->db->query($query);

View File

@@ -32,7 +32,7 @@ class apache_fcgid extends apache
if($domain['phpenabled'] == '1')
{
$php = new phpinterface($this->getDB(), $this->settings, $domain);
$php = new phpinterface($this->settings, $domain);
$phpconfig = $php->getPhpConfig((int)$domain['phpsettingid']);
if((int)$this->settings['phpfpm']['enabled'] == 1)
@@ -93,8 +93,8 @@ class apache_fcgid extends apache
// create starter-file | config-file
$php->getInterface()->createConfig($phpconfig);
// create php.ini
// @TODO make php-fpm support this
// create php.ini (fpm does nothing here, as it
// defines ini-settings in its pool config)
$php->getInterface()->createIniFile($phpconfig);
}
else
@@ -143,7 +143,7 @@ class apache_fcgid extends apache
safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($mypath));
// get php.ini for our own vhost
$php = new phpinterface($this->getDB(), $this->settings, $domain);
$php = new phpinterface($this->settings, $domain);
// get php-config
if ($this->settings['phpfpm']['enabled'] == '1') {
@@ -157,8 +157,8 @@ class apache_fcgid extends apache
// create starter-file | config-file
$php->getInterface()->createConfig($phpconfig);
// create php.ini
// @TODO make php-fpm support this
// create php.ini (fpm does nothing here, as it
// defines ini-settings in its pool config)
$php->getInterface()->createIniFile($phpconfig);
}
}

View File

@@ -151,7 +151,7 @@ class lighttpd
'documentroot' => $mypath
);
$php = new phpinterface($this->getDB(), $this->settings, $domain);
$php = new phpinterface($this->settings, $domain);
$this->lighttpd_data[$vhost_filename].= ' fastcgi.server = ( '."\n";
$this->lighttpd_data[$vhost_filename].= "\t".'".php" => ('."\n";
@@ -324,7 +324,7 @@ class lighttpd
GROUP BY `id_domain`
) AS p ON p.`id_domain` = `d`.`id`
WHERE `d`.`aliasdomain` IS NULL
WHERE `d`.`aliasdomain` IS NULL AND `d`.`email_only` = '0'
ORDER BY `d`.`parentdomainid` DESC, `d`.`iswildcarddomain`, `d`.`domain` ASC;";
$included_vhosts = array();

View File

@@ -15,10 +15,6 @@
*
*/
/*
* This script creates the php.ini's used by mod_suPHP+php-cgi
*/
if(@php_sapi_name() != 'cli'
&& @php_sapi_name() != 'cgi'
&& @php_sapi_name() != 'cgi-fcgi')
@@ -34,7 +30,7 @@ class lighttpd_fcgid extends lighttpd
if($domain['phpenabled'] == '1')
{
$php = new phpinterface($this->getDB(), $this->settings, $domain);
$php = new phpinterface($this->settings, $domain);
$phpconfig = $php->getPhpConfig((int)$domain['phpsettingid']);
// vhost data for php-fpm
@@ -105,8 +101,8 @@ class lighttpd_fcgid extends lighttpd
// create starter-file | config-file
$php->getInterface()->createConfig($phpconfig);
// create php.ini
// @TODO make php-fpm support this
// create php.ini (fpm does nothing here, as it
// defines ini-settings in its pool config)
$php->getInterface()->createIniFile($phpconfig);
}
else
@@ -145,7 +141,7 @@ class lighttpd_fcgid extends lighttpd
safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($mypath));
// get php.ini for our own vhost
$php = new phpinterface($this->getDB(), $this->settings, $domain);
$php = new phpinterface($this->settings, $domain);
// get php-config
if ($this->settings['phpfpm']['enabled'] == '1') {
@@ -159,8 +155,8 @@ class lighttpd_fcgid extends lighttpd
// create starter-file | config-file
$php->getInterface()->createConfig($phpconfig);
// create php.ini
// @TODO make php-fpm support this
// create php.ini (fpm does nothing here, as it
// defines ini-settings in its pool config)
$php->getInterface()->createIniFile($phpconfig);
}
}

View File

@@ -242,7 +242,7 @@ class nginx
'documentroot' => $mypath,
);
$php = new phpinterface($this->getDB(), $this->settings, $domain);
$php = new phpinterface($this->settings, $domain);
$this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_pass unix:' . $php->getInterface()->getSocketFile() . ';' . "\n";
} else {
$this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_pass ' . $this->settings['system']['nginx_php_backend'] . ';' . "\n";
@@ -284,7 +284,7 @@ class nginx
GROUP BY `id_domain`
) AS p ON p.`id_domain` = `d`.`id`
WHERE `d`.`aliasdomain` IS NULL
WHERE `d`.`aliasdomain` IS NULL AND `d`.`email_only` = '0'
ORDER BY `d`.`parentdomainid` DESC, `d`.`iswildcarddomain`, `d`.`domain` ASC;";
$result_domains = $this->db->query($query);

View File

@@ -15,10 +15,6 @@
*
*/
/*
* This script creates the php.ini's used by mod_suPHP+php-cgi
*/
if(@php_sapi_name() != 'cli'
&& @php_sapi_name() != 'cgi'
&& @php_sapi_name() != 'cgi-fcgi')
@@ -34,7 +30,7 @@ class nginx_phpfpm extends nginx
if($domain['phpenabled'] == '1')
{
$php = new phpinterface($this->getDB(), $this->settings, $domain);
$php = new phpinterface($this->settings, $domain);
$phpconfig = $php->getPhpConfig((int)$domain['phpsettingid']);
$php_options_text = "\t".'location ~ \.php$ {'."\n";
@@ -52,8 +48,8 @@ class nginx_phpfpm extends nginx
// create starter-file | config-file
$php->getInterface()->createConfig($phpconfig);
// create php.ini
// @TODO make php-fpm support this
// create php.ini (fpm does nothing here, as it
// defines ini-settings in its pool config)
$php->getInterface()->createIniFile($phpconfig);
}
else
@@ -92,7 +88,7 @@ class nginx_phpfpm extends nginx
safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($mypath));
// get php.ini for our own vhost
$php = new phpinterface($this->getDB(), $this->settings, $domain);
$php = new phpinterface($this->settings, $domain);
// get php-config
if ($this->settings['phpfpm']['enabled'] == '1') {
@@ -106,8 +102,8 @@ class nginx_phpfpm extends nginx
// create starter-file | config-file
$php->getInterface()->createConfig($phpconfig);
// create php.ini
// @TODO make php-fpm support this
// create php.ini (fpm does nothing here, as it
// defines ini-settings in its pool config)
$php->getInterface()->createIniFile($phpconfig);
}
}

View File

@@ -20,22 +20,23 @@
/**
* ARCHIVING CLOSED TICKETS
*/
fwrite($debugHandler, 'Ticket-archiving run started...' . "\n");
$result_tickets = $db->query("SELECT `id`, `lastchange`, `subject` FROM `" . TABLE_PANEL_TICKETS . "`
WHERE `status` = '3' AND `answerto` = '0';");
$result_tickets_stmt = Database::query("
SELECT `id`, `lastchange`, `subject` FROM `" . TABLE_PANEL_TICKETS . "`
WHERE `status` = '3' AND `answerto` = '0';"
);
$archiving_count = 0;
while($row_ticket = $db->fetch_array($result_tickets))
{
while($row_ticket = $result_tickets_stmt->fetch(PDO::FETCH_ASSOC)) {
$lastchange = $row_ticket['lastchange'];
$now = time();
$days = (int)(($now - $lastchange) / 86400);
if($days >= $settings['ticket']['archiving_days'])
{
if ($days >= $settings['ticket']['archiving_days']) {
fwrite($debugHandler, 'archiving ticket "' . $row_ticket['subject'] . '" (ID #' . $row_ticket['id'] . ')' . "\n");
$mainticket = ticket::getInstanceOf(null, $db, $settings, (int)$row_ticket['id']);
$mainticket = ticket::getInstanceOf(null, $settings, (int)$row_ticket['id']);
$mainticket->Set('lastchange', $now, true, true);
$mainticket->Set('lastreplier', '1', true, true);
$mainticket->Set('status', '3', true, true);
@@ -46,6 +47,7 @@ while($row_ticket = $db->fetch_array($result_tickets))
}
fwrite($debugHandler, 'Archived ' . $archiving_count . ' tickets' . "\n");
$db->query('UPDATE `' . TABLE_PANEL_SETTINGS . '` SET `value` = UNIX_TIMESTAMP() WHERE `settinggroup` = \'system\' AND `varname` = \'last_archive_run\' ');
?>
Database::query("
UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = UNIX_TIMESTAMP()
WHERE `settinggroup` = 'system' AND `varname` = 'last_archive_run'"
);

View File

@@ -20,7 +20,6 @@
/**
* RESET USED TICKETS COUNTER
*/
fwrite($debugHandler, 'Resetting customers used ticket counter' . "\n");
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Resetting customers used ticket counter");
$db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `tickets_used` = '0'");
Database::query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `tickets_used` = '0'");