migrate paging class to new PDO database class, refs #1287
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -42,7 +42,7 @@ if ($page == 'admins'
|
|||||||
'traffic_used' => $lng['customer']['traffic'] . ' (' . $lng['panel']['used'] . ')',
|
'traffic_used' => $lng['customer']['traffic'] . ' (' . $lng['panel']['used'] . ')',
|
||||||
'deactivated' => $lng['admin']['deactivated']
|
'deactivated' => $lng['admin']['deactivated']
|
||||||
);
|
);
|
||||||
$paging = new paging($userinfo, $db, TABLE_PANEL_ADMINS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
|
$paging = new paging($userinfo, TABLE_PANEL_ADMINS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
|
||||||
$admins = '';
|
$admins = '';
|
||||||
$result_stmt = Database::query("SELECT * FROM `" . TABLE_PANEL_ADMINS . "` " . $paging->getSqlWhere(false) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
|
$result_stmt = Database::query("SELECT * FROM `" . TABLE_PANEL_ADMINS . "` " . $paging->getSqlWhere(false) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
|
||||||
$numrows_admins = Database::num_rows();
|
$numrows_admins = Database::num_rows();
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ if ($page == 'cronjobs' || $page == 'overview') {
|
|||||||
'c.interval' => $lng['cron']['interval'],
|
'c.interval' => $lng['cron']['interval'],
|
||||||
'c.isactive' => $lng['cron']['isactive']
|
'c.isactive' => $lng['cron']['isactive']
|
||||||
);
|
);
|
||||||
$paging = new paging($userinfo, $db, TABLE_PANEL_CRONRUNS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
|
$paging = new paging($userinfo, TABLE_PANEL_CRONRUNS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @TODO Fix sorting
|
* @TODO Fix sorting
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ if ($page == 'customers'
|
|||||||
$field['c.backup_allowed'] = $lng['backup_allowed'];
|
$field['c.backup_allowed'] = $lng['backup_allowed'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$paging = new paging($userinfo, $db, TABLE_PANEL_CUSTOMERS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
|
$paging = new paging($userinfo, TABLE_PANEL_CUSTOMERS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
|
||||||
$customers = '';
|
$customers = '';
|
||||||
$result_stmt = Database::prepare("
|
$result_stmt = Database::prepare("
|
||||||
SELECT `c`.*, `a`.`loginname` AS `adminname`
|
SELECT `c`.*, `a`.`loginname` AS `adminname`
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ if ($page == 'domains'
|
|||||||
'c.loginname' => $lng['login']['username'],
|
'c.loginname' => $lng['login']['username'],
|
||||||
'd.aliasdomain' => $lng['domains']['aliasdomain']
|
'd.aliasdomain' => $lng['domains']['aliasdomain']
|
||||||
);
|
);
|
||||||
$paging = new paging($userinfo, $db, TABLE_PANEL_DOMAINS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
|
$paging = new paging($userinfo, TABLE_PANEL_DOMAINS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
|
||||||
$domains = '';
|
$domains = '';
|
||||||
$result_stmt = Database::prepare("
|
$result_stmt = Database::prepare("
|
||||||
SELECT `d`.*, `c`.`loginname`, `c`.`name`, `c`.`firstname`, `c`.`company`, `c`.`standardsubdomain`, `ad`.`id` AS `aliasdomainid`, `ad`.`domain` AS `aliasdomain`
|
SELECT `d`.*, `c`.`loginname`, `c`.`name`, `c`.`firstname`, `c`.`company`, `c`.`standardsubdomain`, `ad`.`id` AS `aliasdomainid`, `ad`.`domain` AS `aliasdomain`
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ if ($page == 'ipsandports'
|
|||||||
'ip' => $lng['admin']['ipsandports']['ip'],
|
'ip' => $lng['admin']['ipsandports']['ip'],
|
||||||
'port' => $lng['admin']['ipsandports']['port']
|
'port' => $lng['admin']['ipsandports']['port']
|
||||||
);
|
);
|
||||||
$paging = new paging($userinfo, $db, TABLE_PANEL_IPSANDPORTS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
|
$paging = new paging($userinfo, TABLE_PANEL_IPSANDPORTS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
|
||||||
$ipsandports = '';
|
$ipsandports = '';
|
||||||
$result_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` " . $paging->getSqlWhere(false) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
|
$result_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` " . $paging->getSqlWhere(false) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
|
||||||
Database::pexecute($result_stmt);
|
Database::pexecute($result_stmt);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ if ($page == 'log'
|
|||||||
'user' => $lng['logger']['user'],
|
'user' => $lng['logger']['user'],
|
||||||
'text' => $lng['logger']['action']
|
'text' => $lng['logger']['action']
|
||||||
);
|
);
|
||||||
$paging = new paging($userinfo, $db, TABLE_PANEL_LOG, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
|
$paging = new paging($userinfo, TABLE_PANEL_LOG, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
|
||||||
$paging->sortfield = 'date';
|
$paging->sortfield = 'date';
|
||||||
$paging->sortorder = 'desc';
|
$paging->sortorder = 'desc';
|
||||||
$result_stmt = Database::query('
|
$result_stmt = Database::query('
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ if ($page == 'tickets'
|
|||||||
'subject' => $lng['ticket']['subject'],
|
'subject' => $lng['ticket']['subject'],
|
||||||
'lastreplier' => $lng['ticket']['lastreplier']
|
'lastreplier' => $lng['ticket']['lastreplier']
|
||||||
);
|
);
|
||||||
$paging = new paging($userinfo, $db, TABLE_PANEL_TICKETS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
|
$paging = new paging($userinfo, TABLE_PANEL_TICKETS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
|
||||||
$paging->sortfield = 'lastchange';
|
$paging->sortfield = 'lastchange';
|
||||||
$paging->sortorder = 'desc';
|
$paging->sortorder = 'desc';
|
||||||
$result_stmt = Database::prepare("
|
$result_stmt = Database::prepare("
|
||||||
@@ -475,7 +475,7 @@ if ($page == 'tickets'
|
|||||||
if ($userinfo['tickets_see_all'] != '1') {
|
if ($userinfo['tickets_see_all'] != '1') {
|
||||||
$where = " `main`.`adminid` = :adminid";
|
$where = " `main`.`adminid` = :adminid";
|
||||||
}
|
}
|
||||||
$paging = new paging($userinfo, $db, TABLE_PANEL_TICKET_CATS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
|
$paging = new paging($userinfo, TABLE_PANEL_TICKET_CATS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
|
||||||
$result_stmt = Database::prepare("
|
$result_stmt = Database::prepare("
|
||||||
SELECT `main`.`id`, `main`.`name`, `main`.`logicalorder`, (
|
SELECT `main`.`id`, `main`.`name`, `main`.`logicalorder`, (
|
||||||
SELECT COUNT(`sub`.`id`) FROM `" . TABLE_PANEL_TICKETS . "` `sub`
|
SELECT COUNT(`sub`.`id`) FROM `" . TABLE_PANEL_TICKETS . "` `sub`
|
||||||
@@ -645,7 +645,7 @@ if ($page == 'tickets'
|
|||||||
'lastreplier' => $lng['ticket']['lastreplier'],
|
'lastreplier' => $lng['ticket']['lastreplier'],
|
||||||
'priority' => $lng['ticket']['priority']
|
'priority' => $lng['ticket']['priority']
|
||||||
);
|
);
|
||||||
$paging = new paging($userinfo, $db, TABLE_PANEL_TICKETS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
|
$paging = new paging($userinfo, TABLE_PANEL_TICKETS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
|
||||||
$result_stmt = Database::prepare($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);
|
Database::pexecute($result_stmt, $archive_params);
|
||||||
$sortcode = $paging->getHtmlSortCode($lng);
|
$sortcode = $paging->getHtmlSortCode($lng);
|
||||||
|
|||||||
@@ -21,91 +21,72 @@
|
|||||||
* Class to manage paging system
|
* Class to manage paging system
|
||||||
* @package Functions
|
* @package Functions
|
||||||
*/
|
*/
|
||||||
|
class paging {
|
||||||
|
|
||||||
class paging
|
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Userinfo
|
* Userinfo
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var $userinfo = array();
|
var $userinfo = array();
|
||||||
|
|
||||||
/**
|
|
||||||
* Database handler
|
|
||||||
* @var db
|
|
||||||
*/
|
|
||||||
|
|
||||||
var $db = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MySQL-Table
|
* MySQL-Table
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var $table = '';
|
var $table = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fields with description which should be selectable
|
* Fields with description which should be selectable
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var $fields = array();
|
var $fields = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entries per page
|
* Entries per page
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var $entriesperpage = 0;
|
var $entriesperpage = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of entries of table
|
* Number of entries of table
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var $entries = 0;
|
var $entries = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sortorder, asc or desc
|
* Sortorder, asc or desc
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var $sortorder = 'asc';
|
var $sortorder = 'asc';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sortfield
|
* Sortfield
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var $sortfield = '';
|
var $sortfield = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searchfield
|
* Searchfield
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var $searchfield = '';
|
var $searchfield = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searchtext
|
* Searchtext
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var $searchtext = '';
|
var $searchtext = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pagenumber
|
* Pagenumber
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var $pageno = 0;
|
var $pageno = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switch natsorting on/off
|
* Switch natsorting on/off
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var $natSorting = false;
|
var $natSorting = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,17 +98,14 @@ class paging
|
|||||||
* @param int entries per page
|
* @param int entries per page
|
||||||
* @param bool Switch natsorting on/off (global, affects all calls of sort)
|
* @param bool Switch natsorting on/off (global, affects all calls of sort)
|
||||||
*/
|
*/
|
||||||
|
function paging($userinfo, $table, $fields, $entriesperpage, $natSorting = false) {
|
||||||
|
|
||||||
function paging($userinfo, $db, $table, $fields, $entriesperpage, $natSorting = false)
|
|
||||||
{
|
|
||||||
$this->userinfo = $userinfo;
|
$this->userinfo = $userinfo;
|
||||||
|
|
||||||
if(!is_array($this->userinfo['lastpaging']))
|
if (!is_array($this->userinfo['lastpaging'])) {
|
||||||
{
|
|
||||||
$this->userinfo['lastpaging'] = unserialize($this->userinfo['lastpaging']);
|
$this->userinfo['lastpaging'] = unserialize($this->userinfo['lastpaging']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db = $db;
|
|
||||||
$this->table = $table;
|
$this->table = $table;
|
||||||
$this->fields = $fields;
|
$this->fields = $fields;
|
||||||
$this->entriesperpage = $entriesperpage;
|
$this->entriesperpage = $entriesperpage;
|
||||||
@@ -135,42 +113,39 @@ class paging
|
|||||||
$checklastpaging = (isset($this->userinfo['lastpaging']['table']) && $this->userinfo['lastpaging']['table'] == $this->table);
|
$checklastpaging = (isset($this->userinfo['lastpaging']['table']) && $this->userinfo['lastpaging']['table'] == $this->table);
|
||||||
$this->userinfo['lastpaging']['table'] = $this->table;
|
$this->userinfo['lastpaging']['table'] = $this->table;
|
||||||
|
|
||||||
if(isset($_REQUEST['sortorder'])
|
if (isset($_REQUEST['sortorder'])
|
||||||
&& (strtolower($_REQUEST['sortorder']) == 'desc' || strtolower($_REQUEST['sortorder']) == 'asc'))
|
&& (strtolower($_REQUEST['sortorder']) == 'desc'
|
||||||
{
|
|| strtolower($_REQUEST['sortorder']) == 'asc')
|
||||||
|
) {
|
||||||
$this->sortorder = strtolower($_REQUEST['sortorder']);
|
$this->sortorder = strtolower($_REQUEST['sortorder']);
|
||||||
}
|
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
if($checklastpaging
|
if ($checklastpaging
|
||||||
&& isset($this->userinfo['lastpaging']['sortorder'])
|
&& isset($this->userinfo['lastpaging']['sortorder'])
|
||||||
&& (strtolower($this->userinfo['lastpaging']['sortorder']) == 'desc' || strtolower($this->userinfo['lastpaging']['sortorder']) == 'asc'))
|
&& (strtolower($this->userinfo['lastpaging']['sortorder']) == 'desc'
|
||||||
{
|
|| strtolower($this->userinfo['lastpaging']['sortorder']) == 'asc')
|
||||||
|
) {
|
||||||
$this->sortorder = strtolower($this->userinfo['lastpaging']['sortorder']);
|
$this->sortorder = strtolower($this->userinfo['lastpaging']['sortorder']);
|
||||||
}
|
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
$this->sortorder = 'asc';
|
$this->sortorder = 'asc';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->userinfo['lastpaging']['sortorder'] = $this->sortorder;
|
$this->userinfo['lastpaging']['sortorder'] = $this->sortorder;
|
||||||
|
|
||||||
if(isset($_REQUEST['sortfield'])
|
if (isset($_REQUEST['sortfield'])
|
||||||
&& isset($fields[$_REQUEST['sortfield']]))
|
&& isset($fields[$_REQUEST['sortfield']])
|
||||||
{
|
) {
|
||||||
$this->sortfield = $_REQUEST['sortfield'];
|
$this->sortfield = $_REQUEST['sortfield'];
|
||||||
}
|
} else {
|
||||||
else
|
if ($checklastpaging
|
||||||
{
|
|
||||||
if($checklastpaging
|
|
||||||
&& isset($this->userinfo['lastpaging']['sortfield'])
|
&& isset($this->userinfo['lastpaging']['sortfield'])
|
||||||
&& isset($fields[$this->userinfo['lastpaging']['sortfield']]))
|
&& isset($fields[$this->userinfo['lastpaging']['sortfield']])
|
||||||
{
|
) {
|
||||||
$this->sortfield = $this->userinfo['lastpaging']['sortfield'];
|
$this->sortfield = $this->userinfo['lastpaging']['sortfield'];
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$fieldnames = array_keys($fields);
|
$fieldnames = array_keys($fields);
|
||||||
$this->sortfield = $fieldnames[0];
|
$this->sortfield = $fieldnames[0];
|
||||||
}
|
}
|
||||||
@@ -178,21 +153,17 @@ class paging
|
|||||||
|
|
||||||
$this->userinfo['lastpaging']['sortfield'] = $this->sortfield;
|
$this->userinfo['lastpaging']['sortfield'] = $this->sortfield;
|
||||||
|
|
||||||
if(isset($_REQUEST['searchfield'])
|
if (isset($_REQUEST['searchfield'])
|
||||||
&& isset($fields[$_REQUEST['searchfield']]))
|
&& isset($fields[$_REQUEST['searchfield']])
|
||||||
{
|
) {
|
||||||
$this->searchfield = $_REQUEST['searchfield'];
|
$this->searchfield = $_REQUEST['searchfield'];
|
||||||
}
|
} else {
|
||||||
else
|
if ($checklastpaging
|
||||||
{
|
|
||||||
if($checklastpaging
|
|
||||||
&& isset($this->userinfo['lastpaging']['searchfield'])
|
&& isset($this->userinfo['lastpaging']['searchfield'])
|
||||||
&& isset($fields[$this->userinfo['lastpaging']['searchfield']]))
|
&& isset($fields[$this->userinfo['lastpaging']['searchfield']])
|
||||||
{
|
) {
|
||||||
$this->searchfield = $this->userinfo['lastpaging']['searchfield'];
|
$this->searchfield = $this->userinfo['lastpaging']['searchfield'];
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$fieldnames = array_keys($fields);
|
$fieldnames = array_keys($fields);
|
||||||
$this->searchfield = $fieldnames[0];
|
$this->searchfield = $fieldnames[0];
|
||||||
}
|
}
|
||||||
@@ -200,49 +171,56 @@ class paging
|
|||||||
|
|
||||||
$this->userinfo['lastpaging']['searchfield'] = $this->searchfield;
|
$this->userinfo['lastpaging']['searchfield'] = $this->searchfield;
|
||||||
|
|
||||||
if(isset($_REQUEST['searchtext'])
|
if (isset($_REQUEST['searchtext'])
|
||||||
&& (preg_match('/[-_@\p{L}\p{N}*.]+$/u', $_REQUEST['searchtext']) || $_REQUEST['searchtext'] === ''))
|
&& (preg_match('/[-_@\p{L}\p{N}*.]+$/u', $_REQUEST['searchtext'])
|
||||||
{
|
|| $_REQUEST['searchtext'] === '')
|
||||||
|
) {
|
||||||
$this->searchtext = $_REQUEST['searchtext'];
|
$this->searchtext = $_REQUEST['searchtext'];
|
||||||
}
|
} else {
|
||||||
else
|
if ($checklastpaging
|
||||||
{
|
|
||||||
if($checklastpaging
|
|
||||||
&& isset($this->userinfo['lastpaging']['searchtext'])
|
&& isset($this->userinfo['lastpaging']['searchtext'])
|
||||||
&& preg_match('/[-_@\p{L}\p{N}*.]+$/u', $this->userinfo['lastpaging']['searchtext']))
|
&& preg_match('/[-_@\p{L}\p{N}*.]+$/u', $this->userinfo['lastpaging']['searchtext'])
|
||||||
{
|
) {
|
||||||
$this->searchtext = $this->userinfo['lastpaging']['searchtext'];
|
$this->searchtext = $this->userinfo['lastpaging']['searchtext'];
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->searchtext = '';
|
$this->searchtext = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->userinfo['lastpaging']['searchtext'] = $this->searchtext;
|
$this->userinfo['lastpaging']['searchtext'] = $this->searchtext;
|
||||||
|
|
||||||
if(isset($_REQUEST['pageno'])
|
if (isset($_REQUEST['pageno'])
|
||||||
&& intval($_REQUEST['pageno']) != 0)
|
&& intval($_REQUEST['pageno']) != 0
|
||||||
{
|
) {
|
||||||
$this->pageno = intval($_REQUEST['pageno']);
|
$this->pageno = intval($_REQUEST['pageno']);
|
||||||
}
|
} else {
|
||||||
else
|
if ($checklastpaging
|
||||||
{
|
|
||||||
if($checklastpaging
|
|
||||||
&& isset($this->userinfo['lastpaging']['pageno'])
|
&& isset($this->userinfo['lastpaging']['pageno'])
|
||||||
&& intval($this->userinfo['lastpaging']['pageno']) != 0)
|
&& intval($this->userinfo['lastpaging']['pageno']) != 0
|
||||||
{
|
) {
|
||||||
$this->pageno = intval($this->userinfo['lastpaging']['pageno']);
|
$this->pageno = intval($this->userinfo['lastpaging']['pageno']);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->pageno = 1;
|
$this->pageno = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->userinfo['lastpaging']['pageno'] = $this->pageno;
|
$this->userinfo['lastpaging']['pageno'] = $this->pageno;
|
||||||
$query = 'UPDATE `' . TABLE_PANEL_SESSIONS . '` SET `lastpaging`="' . $this->db->escape(serialize($this->userinfo['lastpaging'])) . '" WHERE `hash`="' . $this->db->escape($userinfo['hash']) . '" AND `userid` = "' . $this->db->escape($userinfo['userid']) . '" AND `ipaddress` = "' . $this->db->escape($userinfo['ipaddress']) . '" AND `useragent` = "' . $this->db->escape($userinfo['useragent']) . '" AND `adminsession` = "' . $this->db->escape($userinfo['adminsession']) . '" ';
|
$upd_stmt = Database::prepare("
|
||||||
$this->db->query($query);
|
UPDATE `" . TABLE_PANEL_SESSIONS . "` SET
|
||||||
|
`lastpaging` = :lastpaging
|
||||||
|
WHERE `hash` = :hash AND `userid` = :userid
|
||||||
|
AND `ipaddress` = :ipaddr AND `useragent` = :ua
|
||||||
|
AND `adminsession` = :adminsession
|
||||||
|
");
|
||||||
|
$upd_data = array(
|
||||||
|
'lastpaging' => serialize($this->userinfo['lastpaging']),
|
||||||
|
'hash' => $userinfo['hash'],
|
||||||
|
'userid' => $userinfo['userid'],
|
||||||
|
'ipaddr' => $userinfo['ipaddress'],
|
||||||
|
'ua' => $userinfo['useragent'],
|
||||||
|
'adminsession' => $userinfo['adminsession']
|
||||||
|
);
|
||||||
|
Database::pexecute($upd_stmt, $upd_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -250,13 +228,11 @@ class paging
|
|||||||
*
|
*
|
||||||
* @param int entries
|
* @param int entries
|
||||||
*/
|
*/
|
||||||
|
function setEntries($entries) {
|
||||||
|
|
||||||
function setEntries($entries)
|
|
||||||
{
|
|
||||||
$this->entries = $entries;
|
$this->entries = $entries;
|
||||||
|
|
||||||
if(($this->pageno - 1) * $this->entriesperpage > $this->entries)
|
if (($this->pageno - 1) * $this->entriesperpage > $this->entries) {
|
||||||
{
|
|
||||||
$this->pageno = 1;
|
$this->pageno = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,9 +245,7 @@ class paging
|
|||||||
* @param int number of row
|
* @param int number of row
|
||||||
* @return bool to display or not to display, that's the question
|
* @return bool to display or not to display, that's the question
|
||||||
*/
|
*/
|
||||||
|
function checkDisplay($count) {
|
||||||
function checkDisplay($count)
|
|
||||||
{
|
|
||||||
$begin = (intval($this->pageno) - 1) * intval($this->entriesperpage);
|
$begin = (intval($this->pageno) - 1) * intval($this->entriesperpage);
|
||||||
$end = (intval($this->pageno) * intval($this->entriesperpage));
|
$end = (intval($this->pageno) * intval($this->entriesperpage));
|
||||||
return (($count >= $begin && $count < $end) || $this->entriesperpage == 0);
|
return (($count >= $begin && $count < $end) || $this->entriesperpage == 0);
|
||||||
@@ -283,30 +257,21 @@ class paging
|
|||||||
* @param bool should returned condition code start with WHERE (false) or AND (true)?
|
* @param bool should returned condition code start with WHERE (false) or AND (true)?
|
||||||
* @return string the condition code
|
* @return string the condition code
|
||||||
*/
|
*/
|
||||||
|
function getSqlWhere($append = false) {
|
||||||
function getSqlWhere($append = false)
|
if ($this->searchtext != '') {
|
||||||
{
|
if ($append == true) {
|
||||||
if($this->searchtext != '')
|
|
||||||
{
|
|
||||||
if($append == true)
|
|
||||||
{
|
|
||||||
$condition = ' AND ';
|
$condition = ' AND ';
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$condition = ' WHERE ';
|
$condition = ' WHERE ';
|
||||||
}
|
}
|
||||||
|
|
||||||
$searchfield = explode('.', $this->searchfield);
|
$searchfield = explode('.', $this->searchfield);
|
||||||
foreach($searchfield as $id => $field)
|
foreach ($searchfield as $id => $field) {
|
||||||
{
|
if (substr($field, -1, 1) != '`') {
|
||||||
if(substr($field, -1, 1) != '`')
|
|
||||||
{
|
|
||||||
$field.= '`';
|
$field.= '`';
|
||||||
}
|
}
|
||||||
|
|
||||||
if($field{0} != '`')
|
if ($field{0} != '`') {
|
||||||
{
|
|
||||||
$field = '`' . $field;
|
$field = '`' . $field;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,10 +280,8 @@ class paging
|
|||||||
|
|
||||||
$searchfield = implode('.', $searchfield);
|
$searchfield = implode('.', $searchfield);
|
||||||
$searchtext = str_replace('*', '%', $this->searchtext);
|
$searchtext = str_replace('*', '%', $this->searchtext);
|
||||||
$condition.= $searchfield . ' LIKE "' . $this->db->escape($searchtext) . '" ';
|
$condition.= $searchfield . " LIKE " . Database::quote($searchtext);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$condition = '';
|
$condition = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,19 +294,15 @@ class paging
|
|||||||
* @param bool Switch natsorting on/off (local, affects just this call)
|
* @param bool Switch natsorting on/off (local, affects just this call)
|
||||||
* @return string the "order by"-code
|
* @return string the "order by"-code
|
||||||
*/
|
*/
|
||||||
|
function getSqlOrderBy($natSorting = null) {
|
||||||
|
|
||||||
function getSqlOrderBy($natSorting = null)
|
|
||||||
{
|
|
||||||
$sortfield = explode('.', $this->sortfield);
|
$sortfield = explode('.', $this->sortfield);
|
||||||
foreach($sortfield as $id => $field)
|
foreach ($sortfield as $id => $field) {
|
||||||
{
|
if (substr($field, -1, 1) != '`') {
|
||||||
if(substr($field, -1, 1) != '`')
|
|
||||||
{
|
|
||||||
$field.= '`';
|
$field.= '`';
|
||||||
}
|
}
|
||||||
|
|
||||||
if($field{0} != '`')
|
if ($field{0} != '`') {
|
||||||
{
|
|
||||||
$field = '`' . $field;
|
$field = '`' . $field;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,15 +312,12 @@ class paging
|
|||||||
$sortfield = implode('.', $sortfield);
|
$sortfield = implode('.', $sortfield);
|
||||||
$sortorder = strtoupper($this->sortorder);
|
$sortorder = strtoupper($this->sortorder);
|
||||||
|
|
||||||
if($natSorting == true
|
if ($natSorting == true
|
||||||
|| ($natSorting === null && $this->natSorting == true))
|
|| ($natSorting === null && $this->natSorting == true)
|
||||||
{
|
) {
|
||||||
// Acts similar to php's natsort(), found in one comment at http://my.opera.com/cpr/blog/show.dml/160556
|
// Acts similar to php's natsort(), found in one comment at http://my.opera.com/cpr/blog/show.dml/160556
|
||||||
|
|
||||||
$sortcode = 'ORDER BY CONCAT( IF( ASCII( LEFT( ' . $sortfield . ', 5 ) ) > 57, LEFT( ' . $sortfield . ', 1 ), \'0\' ), IF( ASCII( RIGHT( ' . $sortfield . ', 1 ) ) > 57, LPAD( ' . $sortfield . ', 255, \'0\' ), LPAD( CONCAT( ' . $sortfield . ', \'-\' ), 255, \'0\' ) ) ) ' . $sortorder;
|
$sortcode = 'ORDER BY CONCAT( IF( ASCII( LEFT( ' . $sortfield . ', 5 ) ) > 57, LEFT( ' . $sortfield . ', 1 ), \'0\' ), IF( ASCII( RIGHT( ' . $sortfield . ', 1 ) ) > 57, LPAD( ' . $sortfield . ', 255, \'0\' ), LPAD( CONCAT( ' . $sortfield . ', \'-\' ), 255, \'0\' ) ) ) ' . $sortorder;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$sortcode = 'ORDER BY ' . $sortfield . ' ' . $sortorder;
|
$sortcode = 'ORDER BY ' . $sortfield . ' ' . $sortorder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,13 +329,10 @@ class paging
|
|||||||
*
|
*
|
||||||
* @return string always empty
|
* @return string always empty
|
||||||
*/
|
*/
|
||||||
|
function getSqlLimit() {
|
||||||
function getSqlLimit()
|
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* currently not in use
|
* currently not in use
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,21 +342,18 @@ class paging
|
|||||||
* @param array Language array
|
* @param array Language array
|
||||||
* @return string the html sortcode
|
* @return string the html sortcode
|
||||||
*/
|
*/
|
||||||
|
function getHtmlSortCode($lng, $break = false) {
|
||||||
|
|
||||||
function getHtmlSortCode($lng, $break = false)
|
|
||||||
{
|
|
||||||
$sortcode = '';
|
$sortcode = '';
|
||||||
$fieldoptions = '';
|
$fieldoptions = '';
|
||||||
$orderoptions = '';
|
$orderoptions = '';
|
||||||
|
|
||||||
foreach($this->fields as $fieldname => $fieldcaption)
|
foreach ($this->fields as $fieldname => $fieldcaption) {
|
||||||
{
|
|
||||||
$fieldoptions.= makeoption($fieldcaption, $fieldname, $this->sortfield, true, true);
|
$fieldoptions.= makeoption($fieldcaption, $fieldname, $this->sortfield, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$breakorws = ($break ? '<br />' : ' ');
|
$breakorws = ($break ? '<br />' : ' ');
|
||||||
foreach(array('asc' => $lng['panel']['ascending'], 'desc' => $lng['panel']['decending']) as $sortordertype => $sortorderdescription)
|
foreach (array('asc' => $lng['panel']['ascending'], 'desc' => $lng['panel']['decending']) as $sortordertype => $sortorderdescription) {
|
||||||
{
|
|
||||||
$orderoptions.= makeoption($sortorderdescription, $sortordertype, $this->sortorder, true, true);
|
$orderoptions.= makeoption($sortorderdescription, $sortordertype, $this->sortorder, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,24 +368,20 @@ class paging
|
|||||||
* @param string If set, only this field will be returned
|
* @param string If set, only this field will be returned
|
||||||
* @return mixed An array or a string (if field is set) of html code of arrows
|
* @return mixed An array or a string (if field is set) of html code of arrows
|
||||||
*/
|
*/
|
||||||
|
function getHtmlArrowCode($baseurl, $field = '') {
|
||||||
|
|
||||||
function getHtmlArrowCode($baseurl, $field = '')
|
|
||||||
{
|
|
||||||
global $theme;
|
global $theme;
|
||||||
|
|
||||||
if($field != ''
|
if ($field != ''
|
||||||
&& isset($this->fields[$field]))
|
&& isset($this->fields[$field])
|
||||||
{
|
) {
|
||||||
$baseurl = htmlspecialchars($baseurl);
|
$baseurl = htmlspecialchars($baseurl);
|
||||||
$fieldname = htmlspecialchars($field);
|
$fieldname = htmlspecialchars($field);
|
||||||
eval("\$arrowcode =\"" . getTemplate("misc/htmlarrowcode", '1') . "\";");
|
eval("\$arrowcode =\"" . getTemplate("misc/htmlarrowcode", '1') . "\";");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$baseurl = htmlspecialchars($baseurl);
|
$baseurl = htmlspecialchars($baseurl);
|
||||||
$arrowcode = array();
|
$arrowcode = array();
|
||||||
foreach($this->fields as $fieldname => $fieldcaption)
|
foreach ($this->fields as $fieldname => $fieldcaption) {
|
||||||
{
|
|
||||||
$fieldname = htmlspecialchars($fieldname);
|
$fieldname = htmlspecialchars($fieldname);
|
||||||
eval("\$arrowcode[\$fieldname] =\"" . getTemplate("misc/htmlarrowcode", '1') . "\";");
|
eval("\$arrowcode[\$fieldname] =\"" . getTemplate("misc/htmlarrowcode", '1') . "\";");
|
||||||
}
|
}
|
||||||
@@ -450,14 +396,12 @@ class paging
|
|||||||
* @param array Language array
|
* @param array Language array
|
||||||
* @return string the html searchcode
|
* @return string the html searchcode
|
||||||
*/
|
*/
|
||||||
|
function getHtmlSearchCode($lng) {
|
||||||
|
|
||||||
function getHtmlSearchCode($lng)
|
|
||||||
{
|
|
||||||
$searchcode = '';
|
$searchcode = '';
|
||||||
$fieldoptions = '';
|
$fieldoptions = '';
|
||||||
$searchtext = htmlspecialchars($this->searchtext);
|
$searchtext = htmlspecialchars($this->searchtext);
|
||||||
foreach($this->fields as $fieldname => $fieldcaption)
|
foreach ($this->fields as $fieldname => $fieldcaption) {
|
||||||
{
|
|
||||||
$fieldoptions.= makeoption($fieldcaption, $fieldname, $this->searchfield, true, true);
|
$fieldoptions.= makeoption($fieldcaption, $fieldname, $this->searchfield, true, true);
|
||||||
}
|
}
|
||||||
eval("\$searchcode =\"" . getTemplate("misc/htmlsearchcode", '1') . "\";");
|
eval("\$searchcode =\"" . getTemplate("misc/htmlsearchcode", '1') . "\";");
|
||||||
@@ -470,61 +414,42 @@ class paging
|
|||||||
* @param string URL to use as base for links
|
* @param string URL to use as base for links
|
||||||
* @return string the html pagingcode
|
* @return string the html pagingcode
|
||||||
*/
|
*/
|
||||||
|
function getHtmlPagingCode($baseurl) {
|
||||||
function getHtmlPagingCode($baseurl)
|
if ($this->entriesperpage == 0) {
|
||||||
{
|
|
||||||
if($this->entriesperpage == 0)
|
|
||||||
{
|
|
||||||
return '';
|
return '';
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$pages = intval($this->entries / $this->entriesperpage);
|
$pages = intval($this->entries / $this->entriesperpage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->entries % $this->entriesperpage != 0)
|
if ($this->entries % $this->entriesperpage != 0) {
|
||||||
{
|
|
||||||
$pages++;
|
$pages++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($pages > 1)
|
if ($pages > 1) {
|
||||||
{
|
|
||||||
$start = $this->pageno - 4;
|
|
||||||
|
|
||||||
if($start < 1)
|
$start = $this->pageno - 4;
|
||||||
{
|
if ($start < 1) {
|
||||||
$start = 1;
|
$start = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$stop = $this->pageno + 4;
|
$stop = $this->pageno + 4;
|
||||||
|
if ($stop > $pages) {
|
||||||
if($stop > $pages)
|
|
||||||
{
|
|
||||||
$stop = $pages;
|
$stop = $pages;
|
||||||
}
|
}
|
||||||
|
|
||||||
$pagingcode = '<a href="' . htmlspecialchars($baseurl) . '&pageno=1">«</a> <a href="' . htmlspecialchars($baseurl) . '&pageno=' . ((intval($this->pageno) - 1) == 0 ? '1' : intval($this->pageno) - 1) . '"><</a> ';
|
$pagingcode = '<a href="' . htmlspecialchars($baseurl) . '&pageno=1">«</a> <a href="' . htmlspecialchars($baseurl) . '&pageno=' . ((intval($this->pageno) - 1) == 0 ? '1' : intval($this->pageno) - 1) . '"><</a> ';
|
||||||
for ($i = $start;$i <= $stop;$i++)
|
for ($i = $start;$i <= $stop;$i++) {
|
||||||
{
|
if ($i != $this->pageno) {
|
||||||
if($i != $this->pageno)
|
|
||||||
{
|
|
||||||
$pagingcode.= ' <a href="' . htmlspecialchars($baseurl) . '&pageno=' . $i . '">' . $i . '</a> ';
|
$pagingcode.= ' <a href="' . htmlspecialchars($baseurl) . '&pageno=' . $i . '">' . $i . '</a> ';
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$pagingcode.= ' <strong>' . $i . '</strong> ';
|
$pagingcode.= ' <strong>' . $i . '</strong> ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$pagingcode.= ' <a href="' . htmlspecialchars($baseurl) . '&pageno=' . ((intval($this->pageno) + 1) > $pages ? $pages : intval($this->pageno) + 1) . '">></a> <a href="' . $baseurl . '&pageno=' . $pages . '">»</a>';
|
$pagingcode.= ' <a href="' . htmlspecialchars($baseurl) . '&pageno=' . ((intval($this->pageno) + 1) > $pages ? $pages : intval($this->pageno) + 1) . '">></a> <a href="' . $baseurl . '&pageno=' . $pages . '">»</a>';
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$pagingcode = '';
|
$pagingcode = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $pagingcode;
|
return $pagingcode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user