function make_runtime_info() { $data = array(); $result = db_query("SELECT MAX(id) AS mid, COUNT(*) AS nf FROM\n\t\t\tttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]); $max_feed_id = db_fetch_result($result, 0, "mid"); $num_feeds = db_fetch_result($result, 0, "nf"); $data["max_feed_id"] = (int) $max_feed_id; $data["num_feeds"] = (int) $num_feeds; $data['last_article_id'] = getLastArticleId(); $data['cdm_expanded'] = get_pref('CDM_EXPANDED'); $data['dep_ts'] = calculate_dep_timestamp(); $data['reload_on_ts_change'] = !defined('_NO_RELOAD_ON_TS_CHANGE'); if (file_exists(LOCK_DIRECTORY . "/update_daemon.lock")) { $data['daemon_is_running'] = (int) file_is_locked("update_daemon.lock"); if (time() - $_SESSION["daemon_stamp_check"] > 30) { $stamp = (int) @file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp"); if ($stamp) { $stamp_delta = time() - $stamp; if ($stamp_delta > 1800) { $stamp_check = 0; } else { $stamp_check = 1; $_SESSION["daemon_stamp_check"] = time(); } $data['daemon_stamp_ok'] = $stamp_check; $stamp_fmt = date("Y.m.d, G:i", $stamp); $data['daemon_stamp'] = $stamp_fmt; } } } if ($_SESSION["last_version_check"] + 86400 + rand(-1000, 1000) < time()) { $new_version_details = @check_for_update(); $data['new_version_available'] = (int) ($new_version_details != false); $_SESSION["last_version_check"] = time(); $_SESSION["version_data"] = $new_version_details; } return $data; }
function getAllCounters() { $last_article_id = (int) $_REQUEST["last_article_id"]; $reply = array(); if ($seq) { $reply['seq'] = $seq; } if ($last_article_id != getLastArticleId($this->link)) { $omode = $_REQUEST["omode"]; if ($omode != "T") { $reply['counters'] = getAllCounters($this->link, $omode); } else { $reply['counters'] = getGlobalCounters($this->link); } } $reply['runtime-info'] = make_runtime_info($this->link); print json_encode($reply); }
function getAllCounters() { $last_article_id = (int) $_REQUEST["last_article_id"]; $reply = array(); if (!empty($_REQUEST['seq'])) { $reply['seq'] = (int) $_REQUEST['seq']; } if ($last_article_id != getLastArticleId()) { $reply['counters'] = getAllCounters(); } $reply['runtime-info'] = make_runtime_info(); print json_encode($reply); }