Esempio n. 1
0
function DbGetTop($limit)
{
    global $min_votes;
    //gemiddelde van ALLE movies bijelkaar
    $total_avg = db_QueryFetchRow("\n\t    SELECT \n\t\tAVG(vote_value) as avg\n\t    FROM votes\n\t");
    // movies met hoogstge bayesian ratings
    $tops = db_QueryFetch("\n\t    SELECT\n\t\tmovies.*,\n\t\t(( ({$min_votes} * {$total_avg['avg']}) + COUNT(vote_value) * AVG(vote_value) ) / ({$min_votes} + COUNT(vote_value))) as avg\n\t    FROM votes,movies\n\t    WHERE movies.movie_id=votes.movie_id\n\t    GROUP by movie_id\n\t    ORDER by avg DESC\n\t    LIMIT {$limit}\n\t");
    // rearrange to this form:
    // $ret[movie_name]=array($thumbs);
    foreach ($tops as $top) {
        $ret[$top[movie_name]] = GetThumbs($top[movie_name]);
    }
    return $ret;
}
Esempio n. 2
0
function theme_GetStrikes($user)
{
    return db_QueryFetch("SELECT id,node,reason,`timestamp` FROM " . CMW_TABLE_USER_STRIKE . " \n\t\tWHERE user=?", $user);
}
Esempio n. 3
0
function themeIdea_GetDetail($event_id, $user_id = 0, $threshold = null, $query_suffix = ";")
{
    if ($user_id) {
        return db_QueryFetch("SELECT id,theme,parent,user,score," . DB_FIELD_DATE('timestamp') . "\n\t\t\tFROM " . SH_TABLE_PREFIX . SH_TABLE_THEME_IDEA . " \n\t\t\tWHERE node=? AND user=?" . $query_suffix, $event_id, $user_id);
    } else {
        if (isset($threshold)) {
            return db_QueryFetch("SELECT id,theme,parent,user,score," . DB_FIELD_DATE('timestamp') . "\n\t\t\t\tFROM " . SH_TABLE_PREFIX . SH_TABLE_THEME_IDEA . " \n\t\t\t\tWHERE node=? AND score>=?" . $query_suffix, $event_id, $threshold);
        } else {
            return db_QueryFetch("SELECT id,theme,parent,user,score," . DB_FIELD_DATE('timestamp') . "\n\t\t\t\tFROM " . SH_TABLE_PREFIX . SH_TABLE_THEME_IDEA . " \n\t\t\t\tWHERE node=?" . $query_suffix, $event_id);
        }
    }
}
Esempio n. 4
0
function db_QueryFetchFirst($query, ...$args)
{
    $ret = db_QueryFetch($query, ...$args);
    if (isset($ret[0])) {
        return $ret[0];
    }
    return null;
}
Esempio n. 5
0
function db_QueryFetchFirst($query, ...$args)
{
    $ret = db_QueryFetch($query, ...$args);
    // Calling non-internal function, so ...
    if (isset($ret[0])) {
        return $ret[0];
    }
    return null;
}
Esempio n. 6
0
function access_GetIP($ip)
{
    return db_QueryFetch("SELECT id,user," . (defined('CMW_USING_MARIADB') ? "INET6_NTOA(ip)" : "INET_NTOA(ip)") . " AS ip,first_timestamp,last_timestamp,total FROM " . CMW_TABLE_USER_ACCESS . " \n\t\tWHERE ip=" . (defined('CMW_USING_MARIADB') ? "INET6_ATON(?)" : "INET_ATON(?)"), $ip);
}
Esempio n. 7
0
function user_GetByNode($node, $query_suffix = ";")
{
    $ret = db_QueryFetch("SELECT id,node,mail," . DB_FIELD_DATE('created') . ",hash,HEX(secret) AS secret,auth_key," . DB_FIELD_DATE('last_auth') . "\n\t\tFROM " . SH_TABLE_PREFIX . SH_TABLE_USER . " \n\t\tWHERE node=?" . $query_suffix, $node);
    return db_ParseRows($ret, _SH_USER_ROW_MAP);
}
Esempio n. 8
0
function theme_GetHistory()
{
    $ret = cache_Fetch(_THEME_CACHE_KEY . "THEME_HISTORY");
    if ($ret === null) {
        $ret = db_QueryFetch("SELECT node,shorthand,name,theme FROM " . CMW_TABLE_THEME_HISTORY);
        if (is_array($ret)) {
            cache_Store(_THEME_CACHE_KEY . "THEME_HISTORY", $ret, _THEME_CACHE_TTL);
        } else {
            return null;
        }
    }
    return $ret;
}