1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8//this script may only be included - so its better to die if called directly. 9if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) { 10 header("location: index.php"); 11 exit; 12} 13 14/** 15 * 16 */ 17class RefererLib extends TikiLib 18{ 19 20 function clear_referer_stats() 21 { 22 $query = "delete from tiki_referer_stats"; 23 24 $result = $this->query($query); 25 } 26 27 /** 28 * @param $offset 29 * @param $maxRecords 30 * @param $sort_mode 31 * @param $find 32 * @return array 33 */ 34 function list_referer_stats($offset, $maxRecords, $sort_mode, $find) 35 { 36 $bindvars = []; 37 if ($find) { 38 $mid = " where (`referer` like ?)"; 39 $bindvars[] = '%' . $find . '%'; 40 } else { 41 $mid = ""; 42 } 43 44 $query = "select * from `tiki_referer_stats` $mid order by " . $this->convertSortMode($sort_mode); 45 ; 46 $query_cant = "select count(*) from `tiki_referer_stats` $mid"; 47 $result = $this->query($query, $bindvars, $maxRecords, $offset); 48 $cant = $this->getOne($query_cant, $bindvars); 49 $ret = []; 50 51 while ($res = $result->fetchRow()) { 52 $ret[] = $res; 53 } 54 55 $retval = []; 56 $retval["data"] = $ret; 57 $retval["cant"] = $cant; 58 return $retval; 59 } 60} 61$refererlib = new RefererLib; 62