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 TagLineLib extends TikiLib 18{ 19 20 /** 21 * @param $offset 22 * @param $maxRecords 23 * @param $sort_mode 24 * @param $find 25 * @return array 26 */ 27 public function list_cookies($offset, $maxRecords, $sort_mode, $find) 28 { 29 if ($find) { 30 $mid = " where (`cookie` like ?)"; 31 $bindvars = ['%' . $find . '%']; 32 } else { 33 $mid = ""; 34 $bindvars = []; 35 } 36 $query = "select * from `tiki_cookies` $mid order by " . $this->convertSortMode($sort_mode); 37 $query_cant = "select count(*) from `tiki_cookies` $mid"; 38 $result = $this->query($query, $bindvars, $maxRecords, $offset); 39 $cant = $this->getOne($query_cant, $bindvars); 40 $ret = []; 41 while ($res = $result->fetchRow()) { 42 $ret[] = $res; 43 } 44 $retval = []; 45 $retval["data"] = $ret; 46 $retval["cant"] = $cant; 47 return $retval; 48 } 49 50 /** 51 * @param $cookieId 52 * @param $cookie 53 * 54 * @return TikiDb_Pdo_Result|TikiDb_Adodb_Result 55 */ 56 public function replace_cookie($cookieId, $cookie) 57 { 58 //$cookie = addslashes($cookie); 59 // Check the name 60 if ($cookieId) { 61 $query = "update `tiki_cookies` set `cookie`=? where `cookieId`=?"; 62 $bindvars = [$cookie,(int) $cookieId]; 63 } else { 64 $bindvars = [$cookie]; 65 $query = "delete from `tiki_cookies` where `cookie`=?"; 66 $result = $this->query($query, $bindvars); 67 $query = "insert into `tiki_cookies`(`cookie`) values(?)"; 68 } 69 return $this->query($query, $bindvars); 70 } 71 72 /** 73 * @param $cookieId 74 * 75 * @return TikiDb_Pdo_Result|TikiDb_Adodb_Result 76 */ 77 public function remove_cookie($cookieId) 78 { 79 $query = "delete from `tiki_cookies` where `cookieId`=?"; 80 return $this->query($query, [(int) $cookieId]); 81 } 82 83 /** 84 * @param $cookieId 85 * 86 * @return array|bool 87 */ 88 public function get_cookie($cookieId) 89 { 90 $query = "select * from `tiki_cookies` where `cookieId`=?"; 91 $result = $this->query($query, [(int) $cookieId]); 92 if (! $result->numRows()) { 93 return false; 94 } 95 96 return $result->fetchRow(); 97 } 98 99 /** 100 * @return TikiDb_Pdo_Result|TikiDb_Adodb_Result 101 */ 102 public function remove_all_cookies() 103 { 104 $query = "delete from `tiki_cookies`"; 105 return $this->query($query, []); 106 } 107} 108$taglinelib = new TagLineLib; 109