Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/hopeinstoughton_books/core/models/ |
Upload File : |
<?php
class Statistics_Model extends Model {
function __construct() {
global $DATABASE;
parent::__construct();
if (!is_object($DATABASE->db)) {
$DATABASE->Open();
DbErr($DATABASE);
}
}
public function CountByCategory() {
global $DATABASE;
$list = self::retrieveStockGroups(0, 1);
$sql = <<<BLOCK
select count(ds_title) as count,ds_group
from dt_stock
where ds_out < '1991-01-01'
group by ds_group,ds_title
BLOCK;
$list = $DATABASE->Query($sql, NULL, array($this, '__list'), $list);
return $list;
}
function __list(&$ITEM, &$param) {
$g = intval($ITEM['ds_group']);
if (!isset($param[$g]['count'])) $param[$g]['count'] = 0;
$param[$g]['count']++;
return 0;
}
function __groups(&$ITEM, &$param) {
if ($this->x_full) {
$param[$ITEM['dg_id']]['desc'] = $ITEM['dg_desc'];
} else {
$param[$ITEM['dg_id']] = $ITEM['dg_desc'];
}
}
public function retrieveStockGroups($all = 1, $full = 0) {
global $DATABASE;
$this->x_full = $full;
$sql = 'select dg_id,dg_desc from dt_group';
if (!$all) $sql .= ' where dg_view="1"';
$result = $DATABASE->Query($sql, NULL, array($this, '__groups'), array());
DbErr($DATABASE);
return $result;
}
public function BooksByGroup($group) {
global $DATABASE;
$groupname = $DATABASE->Lookup("select dg_desc from dt_group where dg_id=%d", array($group));
$sql = <<<BLOCK
select a1.ba_name as ba_name1,a2.ba_name as ba_name2,bt_id,bt_title,bt_private,
bt_nonch,bt_dim
from dt_stock
left outer join dt_title on ds_title=bt_id
left outer join dt_author as a1 on a1.ba_id=bt_author1
left outer join dt_author as a2 on a2.ba_id=bt_author2
where ds_group=%d
group by ds_title
BLOCK;
$res = $DATABASE->Query($sql, array($group), array($this, '__titlesbygroup'), array());
DbErr($DATABASE);
uasort($res, array($this, '__sorting'));
$groupname = empty($groupname['dg_desc']) ? '(unknown category)' : $groupname['dg_desc'];
return array('desc' => $groupname, 'data' => $res);
}
function __titlesbygroup(&$ITEM, &$param) {
$param[$ITEM['bt_id']] = array(ip_AsTitle($ITEM, 2), $ITEM['bt_nonch'], $ITEM['bt_dim']);
return 0;
}
function __sorting($a, $b) {
$a = strtolower($a[0]);
$b = strtolower($b[0]);
if ($a == $b) return 0;
return ($a < $b) ? -1 : 1;
}
}