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; }
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 node_GetPublishedIdModifiedByParent($parent, $limit = 20, $offset = 0) { if (is_integer($parent)) { return db_QueryFetchPair("SELECT id, modified \n\t\t\tFROM " . SH_TABLE_PREFIX . SH_TABLE_NODE . " \n\t\t\tWHERE published > CONVERT(0,DATETIME) AND parent=?\n\t\t\tORDER BY published DESC,\n\t\t\tLIMIT ? OFFSET ?\n\t\t\t" . $query_suffix, $parent, $limit, $offset); } else { if (is_array($parent)) { // Confirm that all IDs are not zero foreach ($parent as $id) { if (intval($id) == 0) { return null; } } $ids = implode(',', $parent); return db_QueryFetchPair("SELECT id, modified \n\t\t\tFROM " . SH_TABLE_PREFIX . SH_TABLE_NODE . " \n\t\t\tWHERE published > CONVERT(0,DATETIME) AND parent IN ({$ids})\n\t\t\tORDER BY published DESC,\n\t\t\tLIMIT ? OFFSET ?\n\t\t\t" . $query_suffix, $limit, $offset); } } return null; }
function _themeIdea_GetRandom($event_id, $threshold = null, $query_suffix = ";") { if (isset($threshold)) { return db_QueryFetchPair("SELECT id,theme \n\t\t\tFROM " . SH_TABLE_PREFIX . SH_TABLE_THEME_IDEA . " \n\t\t\tWHERE node=? AND parent=0 AND score>=?\n\t\t\tORDER BY rand() LIMIT 1" . $query_suffix, $event_id, $threshold); } else { return db_QueryFetchPair("SELECT id,theme \n\t\t\tFROM " . SH_TABLE_PREFIX . SH_TABLE_THEME_IDEA . " \n\t\t\tWHERE node=? AND parent=0\n\t\t\tORDER BY rand() LIMIT 1" . $query_suffix, $event_id); } }
} // APCu // if (defined('CMW_USING_APCU') && !$show_specific) { $response['apcu_api_version'] = phpversion('apcu'); if (function_exists('apcu_cache_info')) { $response['apcu_uptime'] = time() - intval(apcu_cache_info(true)['start_time']); } } // Database // if (defined('CMW_USING_DB') && $show_db) { $response['db_api_version'] = phpversion('mysqli'); if ($is_admin) { require_once __DIR__ . "/../../db.php"; $db_data = db_QueryFetchPair("show VARIABLES like \"%version%\""); $response['db_version'] = $db_data['version']; $db_data = db_QueryFetchPair("show global status where Variable_Name = 'Uptime';"); $response['db_uptime'] = time_offset() + intval($db_data['Uptime']); } } // Redis // if (defined('CMW_USING_REDIS') && $show_redis) { $response['redis_api_version'] = phpversion('redis'); if ($is_admin) { $redis = new Redis(); $redis->connect(CMW_REDIS_HOST); $info = $redis->info('default'); $response['redis_version'] = $info['redis_version']; $response['redis_uptime'] = time_offset() + intval($info['uptime_in_seconds']); $redis->close(); } }
function theme_GetUserKillCounts() { $ret = cache_Fetch(_THEME_CACHE_KEY . "IDEA_KILL_COUNTS"); if ($ret === null) { $ret = db_QueryFetchPair("SELECT user,COUNT(id) FROM " . CMW_TABLE_THEME_IDEA_VOTE . "\n\t\t\t\tGROUP BY user\n\t\t\t"); cache_Store(_THEME_CACHE_KEY . "IDEA_KILL_COUNTS", $ret, _THEME_CACHE_TTL); } return $ret; }