Exemple #1
0
function _global_Load()
{
    $ret = cache_Fetch(_SH_GLOBAL_CACHE_KEY);
    if ($ret === null) {
        // Fetch the newest version of every key //
        $ret = db_QueryFetchPair("SELECT `key`,`value` FROM " . SH_TABLE_PREFIX . SH_TABLE_GLOBAL . "\n\t\t\tWHERE id IN (\n\t\t\t\tSELECT MAX(id) FROM " . SH_TABLE_PREFIX . SH_TABLE_GLOBAL . " GROUP BY `key`\n\t\t\t);");
        if (!is_array($ret)) {
            return [];
        }
        // Convert types of the values of certain keys found in globals //
        foreach ($ret as $key => &$value) {
            if (strcmp($key, "active") === 0) {
                $value = intval($value);
                continue;
            } else {
                if (strpos($key, "-active") !== false) {
                    $value = intval($value);
                    continue;
                } else {
                    if (strpos($key, "SH_TABLE_") === 0) {
                        $value = intval($value);
                        continue;
                    }
                }
            }
        }
        if ($ret) {
            cache_Store(_SH_GLOBAL_CACHE_KEY, $ret, _SH_GLOBAL_CACHE_TTL);
        } else {
            $ret = [];
        }
    }
    return $ret;
}
Exemple #2
0
function _config_Load()
{
    $ret = cache_Fetch(_CONFIG_CACHE_KEY);
    if ($ret === null) {
        $ret = db_QueryFetchPair("SELECT `key`,`value` FROM " . CMW_TABLE_CONFIG . "\n\t\t\tWHERE id IN (\n\t\t\t\tSELECT MAX(id) FROM " . CMW_TABLE_CONFIG . " GROUP BY `key`\n\t\t\t);");
        cache_Store(_CONFIG_CACHE_KEY, $ret, _CONFIG_CACHE_TTL);
    }
    return $ret;
}
function legacy_GetUser($id)
{
    $ret = cache_Fetch(_LEGACY_USER_CACHE_KEY . $id);
    if ($ret === null) {
        $ret = db_QueryFetchFirst("SELECT id," . MYSQL_ISO_FORMAT('timestamp') . ",hash\n\t\t\tFROM " . CMW_TABLE_LEGACY_USER . " WHERE id=? LIMIT 1;", $id);
        cache_Store(_LEGACY_USER_CACHE_KEY . $id, $ret, _LEGACY_USER_CACHE_TTL);
    }
    return $ret;
}
Exemple #4
0
function GetEventNodes()
{
    $cache_key = CACHE_KEY_PREFIX . "GetEventNodes";
    $ret = cache_Fetch($cache_key);
    if (!isset($ret)) {
        $ret = node_GetIdByType(SH_NODE_TYPE_EVENT);
        cache_Store($cache_key, $ret, CACHE_TTL);
    }
    return $ret;
}
Exemple #5
0
            // We're done with the original, so destroy it (to save memory) //
            imagedestroy($data);
            // Begin Output Buffering //
            ob_start();
            $content_type = "";
            // Output the data //
            if ($jpeg || $info['mime'] === "image/jpeg") {
                $content_type = 'Content-type: image/jpeg';
                header($content_type);
                imagejpeg($out_data);
            } else {
                $content_type = 'Content-type: image/png';
                header($content_type);
                imagepng($out_data);
            }
            cache_Store($cache_key, ['header' => $content_type, 'data' => ob_get_flush()], CACHE_TTL_IMAGE);
            // Finished //
            imagedestroy($out_data);
            die;
        } else {
            header('X-Status-Reason: Bad source image');
            http_response_code(403);
            die;
        }
    } else {
        http_response_code(404);
        die;
    }
} else {
    if (empty($image)) {
        // Debug: Report how many redirects //
Exemple #6
0
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;
}
Exemple #7
0
function theme_GetFinalVotingList($node)
{
    $ret = cache_Fetch(_THEME_CACHE_KEY . "FINAL_VOTE_LIST");
    if ($ret === null) {
        $ret = db_DoFetch("SELECT id,theme FROM " . CMW_TABLE_THEME_FINAL . " \n\t\t\tWHERE node=?\n\t\t\tORDER BY score DESC,id ASC", $node);
        cache_Store(_THEME_CACHE_KEY . "FINAL_VOTE_LIST", $ret, _THEME_CACHE_TTL);
    }
    return $ret;
}
Exemple #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;
}