function get_content_from_sql($sql_where_clause) { // Returns an Array of the requested fields of the pictures that are returned by the sql where clause $sql_where_clause global $db; global $config_vars; $sql = "SELECT * FROM " . $config_vars['table_prefix'] . "pics\n\t\tWHERE {$sql_where_clause}"; if (!($result = $db->query($sql))) { error_report(SQL_ERROR, 'get_content_from_sql', __LINE__, __FILE__, $sql); } while ($row = $db->sql_fetchrow($result)) { $objarray[] = get_content_from_row($row); } return $objarray; }
function get_content_ordered_by($by, $filter = true, $order = 'DESC', $limit_start = 0, $limit_end = -1) { // returns a assoc array containing 'object' = content objects and 'length' = how long they have been viewed ordered by the length they have been viewed. global $db, $config_vars; if ($filter) { $filter = 'and (view_table.end!=0)'; } $sql = 'SELECT SUM(UNIX_TIMESTAMP(view_table.end) - UNIX_TIMESTAMP(view_table.start)) as length,COUNT(*) as amount,content.* FROM ' . $config_vars['table_prefix'] . 'views AS view_table, ' . $config_vars['table_prefix'] . 'content AS content WHERE (view_table.content_id=content.id) ' . $filter . ' GROUP BY view_table.content_id ORDER BY ' . $by . " {$order} \n\t\tLIMIT {$limit_start},{$limit_end}"; if (!($result = $db->sql_query($sql))) { error_report(SQL_ERROR, 'get_content_ordered_by', __LINE__, __FILE__, $sql); } while ($row = $db->sql_fetchrow($result)) { $a['object'] = get_content_from_row($row); $a['length'] = $row['length']; $a['amount'] = $row['amount']; $objarray[] = $a; } return $objarray; }
function get_surrounding_content($cat_id) { // Returns an Array of album_content objects of all content which is in the categorie with id $cat_id global $db, $config_vars, $userdata, $filetypes; // get auth where $auth_where = get_allowed_contentgroups_where($userdata['user_id'], "view", 'content.contentgroup_id'); // get all content $sql = 'SELECT content.id,content.file,content_in_cat.place_in_cat FROM ' . $config_vars['table_prefix'] . "content as content," . $config_vars['table_prefix'] . "content_in_cat as content_in_cat\n\t\t\tWHERE ({$auth_where}) and \n\t\t\t\t(content.id = content_in_cat.content_id) and (content_in_cat.cat_id = {$cat_id})\n\t\t\tORDER BY content_in_cat.place_in_cat"; if (!($result = $db->sql_query($sql))) { $error = new phreak_error(E_WARNING, SQL_ERROR, __LINE__, __FILE__, 'get_surrounding_content', $this->id, 0, 0, $sql); $error->commit(); //error_report(SQL_ERROR, 'get_surrounding_content' , __LINE__, __FILE__,$sql); } $objarray['place'] = 1; $objarray['amount'] = $db->sql_affectedrows(); while ($row = $db->sql_fetchrow($result)) { if ($row['id'] == $this->id) { $objarray['prev'] = get_content_from_row($lastrow); $objarray['next'] = get_content_from_row($db->sql_fetchrow($result)); return $objarray; } $objarray['place']++; $lastrow = $row; } }