本文整理汇总了PHP中file_is_locked函数的典型用法代码示例。如果您正苦于以下问题:PHP file_is_locked函数的具体用法?PHP file_is_locked怎么用?PHP file_is_locked使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了file_is_locked函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reap_children
function reap_children()
{
global $children;
global $ctimes;
$tmp = array();
foreach ($children as $pid) {
if (pcntl_waitpid($pid, $status, WNOHANG) != $pid) {
if (file_is_locked("update_daemon-{$pid}.lock")) {
array_push($tmp, $pid);
} else {
_debug("[reap_children] child {$pid} seems active but lockfile is unlocked.");
}
} else {
_debug("[reap_children] child {$pid} reaped.");
unset($ctimes[$pid]);
}
}
$children = $tmp;
return count($tmp);
}
示例2: make_runtime_info
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;
}
示例3: getConfig
function getConfig()
{
$config = array("icons_dir" => ICONS_DIR, "icons_url" => ICONS_URL);
$config["daemon_is_running"] = file_is_locked("update_daemon.lock");
$result = $this->dbh->query("SELECT COUNT(*) AS cf FROM\n\t\t\tttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]);
$num_feeds = $this->dbh->fetch_result($result, 0, "cf");
$config["num_feeds"] = (int) $num_feeds;
$this->wrap(self::STATUS_OK, $config);
}
示例4: expire_lock_files
function expire_lock_files($debug)
{
//if ($debug) _debug("Removing old lock files...");
$num_deleted = 0;
if (is_writable(LOCK_DIRECTORY)) {
$files = glob(LOCK_DIRECTORY . "/*.lock");
if ($files) {
foreach ($files as $file) {
if (!file_is_locked(basename($file)) && time() - filemtime($file) > 86400 * 2) {
unlink($file);
++$num_deleted;
}
}
}
}
if ($debug) {
_debug("Removed {$num_deleted} old lock files.");
}
}
示例5: print_runtime_info
function print_runtime_info($link)
{
print "<runtime-info>";
$result = db_query($link, "SELECT COUNT(*) AS cf FROM\n\t\t\tttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]);
$num_feeds = db_fetch_result($result, 0, "cf");
print "<param key=\"num_feeds\" value=\"" . (int) $num_feeds . "\"/>";
if (ENABLE_UPDATE_DAEMON) {
print "<param key=\"daemon_is_running\" value=\"" . (int) file_is_locked("update_daemon.lock") . "\"/>";
if (time() - $_SESSION["daemon_stamp_check"] > 30) {
$stamp = (int) read_stampfile("update_daemon.stamp");
// print "<param key=\"daemon_stamp_delta\" value=\"$stamp_delta\"/>";
if ($stamp) {
$stamp_delta = time() - $stamp;
if ($stamp_delta > 1800) {
$stamp_check = 0;
} else {
$stamp_check = 1;
$_SESSION["daemon_stamp_check"] = time();
}
print "<param key=\"daemon_stamp_ok\" value=\"{$stamp_check}\"/>";
$stamp_fmt = date("Y.m.d, G:i", $stamp);
print "<param key=\"daemon_stamp\" value=\"{$stamp_fmt}\"/>";
}
}
}
if (CHECK_FOR_NEW_VERSION && $_SESSION["access_level"] >= 10) {
if ($_SESSION["last_version_check"] + 86400 + rand(-1000, 1000) < time()) {
$new_version_details = check_for_update($link);
print "<param key=\"new_version_available\" value=\"" . sprintf("%d", $new_version_details != "") . "\"/>";
$_SESSION["last_version_check"] = time();
}
}
// print "<param key=\"new_version_available\" value=\"1\"/>";
print "</runtime-info>";
}
示例6: join
$article_id = join(",", array_filter(explode(",", db_escape_string($_REQUEST["article_id"])), is_numeric));
$query = "SELECT id,title,link,content,feed_id,comments,int_id,\n\t\t\t\tmarked,unread,published,\n\t\t\t\t" . SUBSTRING_FOR_DATE . "(updated,1,16) as updated,\n\t\t\t\tauthor\n\t\t\t\tFROM ttrss_entries,ttrss_user_entries\n\t\t\t\tWHERE\tid IN ({$article_id}) AND ref_id = id AND owner_uid = " . $_SESSION["uid"];
$result = db_query($link, $query);
$articles = array();
if (db_num_rows($result) != 0) {
while ($line = db_fetch_assoc($result)) {
$attachments = get_article_enclosures($link, $line['id']);
$article = array("id" => $line["id"], "title" => $line["title"], "link" => $line["link"], "labels" => get_article_labels($link, $line['id']), "unread" => sql_bool_to_bool($line["unread"]), "marked" => sql_bool_to_bool($line["marked"]), "published" => sql_bool_to_bool($line["published"]), "comments" => $line["comments"], "author" => $line["author"], "updated" => strtotime($line["updated"]), "content" => $line["content"], "feed_id" => $line["feed_id"], "attachments" => $attachments);
array_push($articles, $article);
}
}
print api_wrap_reply(API_STATUS_OK, $seq, $articles);
break;
case "getConfig":
$config = array("icons_dir" => ICONS_DIR, "icons_url" => ICONS_URL);
$config["daemon_is_running"] = file_is_locked("update_daemon.lock");
$result = db_query($link, "SELECT COUNT(*) AS cf FROM\n\t\t\t\tttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]);
$num_feeds = db_fetch_result($result, 0, "cf");
$config["num_feeds"] = (int) $num_feeds;
print api_wrap_reply(API_STATUS_OK, $seq, $config);
break;
case "updateFeed":
$feed_id = db_escape_string($_REQUEST["feed_id"]);
update_rss_feed($link, $feed_id, true);
print api_wrap_reply(API_STATUS_OK, $seq, array("status" => "OK"));
break;
case "catchupFeed":
$feed_id = db_escape_string($_REQUEST["feed_id"]);
$is_cat = db_escape_string($_REQUEST["is_cat"]);
catchup_feed($link, $feed_id, $is_cat);
print api_wrap_reply(API_STATUS_OK, $seq, array("status" => "OK"));