function getUserById($uid, $hash, $userId) { if (!($uid > 0)) { return -1; } if (!($userId > 0)) { return -1; } if (!checkCookies($uid, $hash)) { return -1; } $colsArray = array("users" => array(1, 2, 4, 5, 6, 7, 8)); $colStr = getSqlColumns($colsArray); $query = "SELECT {$colStr} FROM `users` WHERE `uid`={$userId};"; $data = array(); if ($result = mysql_query($query)) { while ($res = mysql_fetch_array($result)) { $data["user"] = getSqlData($colsArray, $res); } } $colsArray = array("item" => array(1, 3, 4, 11)); $colStr = getSqlColumns($colsArray); $query = "SELECT {$colStr} FROM `item` WHERE `item`.`uid`={$userId};"; if ($result = mysql_query($query)) { $inndata = array(); while ($res = mysql_fetch_array($result)) { array_push($inndata, getSqlData($colsArray, $res)); } $data["items"] = $inndata; } return $data; }
function getNotification($uid, $hash) { if (!($uid > 0)) { return -1; } if (!checkCookies($uid, $hash)) { return false; } $colsArray = array("borrow" => array(1, 2, 3, 4, 5, 6, 7), "item" => array(1, 3, 4)); $colStr = getSqlColumns($colsArray); $query = "SELECT {$colStr} FROM `item`, `borrow` WHERE `borrow`.`iid`=`item`.`iid` AND `item`.`uid`={$uid} AND `item`.`status`=1;"; $data = array(); if ($result = mysql_query($query)) { while ($res = mysql_fetch_array($result)) { $data[$res["bid"]] = getSqlData($colsArray, $res); } } return $data; }
function getReply($iid) { // $colsArray = array("replycomment" => array(1, 3, 4, 5, 6)); $colStr = getSqlColumns($colsArray); $query = "SELECT {$colStr} FROM `replycomment` WHERE `iid`={$iid};"; if ($result = mysql_query($query)) { $comments = array(); while ($res = mysql_fetch_array($result)) { if (!isset($comments[$res["cid"]])) { $comments[$res["cid"]] = array(); } $comments[$res["cid"]][$res["rcid"]] = getSqlData($colsArray, $res); } return $comments; } }
function getUsersBySearch($q) { $q = mysql_real_escape_string($q); $colsArray = array("users" => array(1, 2, 4, 5, 6)); $colStr = getSqlColumns($colsArray); $query = "SELECT {$colStr} FROM `users` WHERE (`users`.`email` LIKE '%{$q}%') OR (`users`.`uname` LIKE '%{$q}%') OR (`users`.`fname` LIKE '%{$q}%') OR (`users`.`contact` LIKE '%{$q}%');"; $items = array(); if ($result = mysql_query($query)) { while ($res = mysql_fetch_assoc($result)) { $item = getSqlData($colsArray, $res); $items[] = $item; } } return $items; }