function love_Fetch(&$user = 0, &$ip = '0.0.0.0', $offset = null, $limit = null) { db_Connect(); return db_FetchSingle("SELECT `node` FROM `" . CMW_TABLE_NODE_LOVE . "` WHERE " . "`user`=" . $user . " AND " . "`ip`=INET_ATON('" . $ip . "')" . (is_null($limit) ? "" : " LIMIT " . $limit) . (is_null($offset) ? "" : " OFFSET " . $offset) . ";"); }
function user_GetHashByMail($mail) { db_Connect(); // TODO: Use time-attack safe fetch function $hash = db_FetchSingle("SELECT `hash` FROM `" . CMW_TABLE_USER . "` WHERE " . "`mail`=\"" . $mail . "\"" . " LIMIT 1" . ";"); if (count($hash)) { return $hash[0]; } return null; }
function node_GetPublishedNodeIdsByTypes($types, $limit = 50, $offset = 0) { // Sort the types, to make sure we get a consistent key name // if (is_array($types)) { sort($types, SORT_STRING); } else { $types = [$types]; } $cache_key = "published-ids\$" . $offset . "\$" . $limit . "\$" . implode("\$", $types); // Fetch from cache // $cached = cache_Fetch($cache_key); if ($cached) { return $cached; } // Fetch from database // global $NODE_SCHEMA; db_Connect(); $items = db_FetchSingle("SELECT `id` FROM `" . CMW_TABLE_NODE . "` WHERE " . ("`time_published` != " . "'0000-00-00 00:00:00'" . " AND ") . (is_array($types) ? "`type` in (\"" . implode("\",\"", $types) . "\")" : "`type`=" . "\"post\"") . " ORDER BY `time_published` DESC" . (" LIMIT " . $limit . " OFFSET " . $offset) . ";", $NODE_SCHEMA); // Cache it // cache_Store($cache_key, $items, CACHE_TTL_PUBLISHED_IDS); return $items; }
function star_Fetch(&$user = 0, $offset = null, $limit = null) { db_Connect(); return db_FetchSingle("SELECT `node` FROM `" . CMW_TABLE_NODE_STAR . "` WHERE " . "`user`=" . $user . (is_null($limit) ? "" : " LIMIT " . $limit) . (is_null($offset) ? "" : " OFFSET " . $offset) . ";"); }