本文整理汇总了PHP中App::set_baseurl方法的典型用法代码示例。如果您正苦于以下问题:PHP App::set_baseurl方法的具体用法?PHP App::set_baseurl怎么用?PHP App::set_baseurl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App
的用法示例。
在下文中一共展示了App::set_baseurl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gprobe_run
function gprobe_run($argv, $argc)
{
global $a, $db;
if (is_null($a)) {
$a = new App();
}
if (is_null($db)) {
@(include ".htconfig.php");
require_once "dba.php";
$db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
}
require_once 'include/session.php';
require_once 'include/datetime.php';
load_config('config');
load_config('system');
$a->set_baseurl(get_config('system', 'url'));
load_hooks();
if ($argc != 2) {
return;
}
$url = hex2bin($argv[1]);
$r = q("select * from gcontact where nurl = '%s' limit 1", dbesc(normalise_link($url)));
if (!count($r)) {
$arr = probe_url($url);
if (count($arr) && x($arr, 'network') && $arr['network'] === NETWORK_DFRN) {
q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`)\n\t\t\t\tvalues ( '%s', '%s', '%s', '%s') ", dbesc($arr['name']), dbesc($arr['url']), dbesc(normalise_link($arr['url'])), dbesc($arr['photo']));
}
$r = q("select * from gcontact where nurl = '%s' limit 1", dbesc(normalise_link($url)));
}
if (count($r)) {
poco_load(0, 0, $r[0]['id'], str_replace('/profile/', '/poco/', $r[0]['url']));
}
return;
}
示例2: directory_run
function directory_run(&$argv, &$argc)
{
global $a, $db;
if (is_null($a)) {
$a = new App();
}
if (is_null($db)) {
@(include ".htconfig.php");
require_once "include/dba.php";
$db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
}
load_config('config');
load_config('system');
if ($argc != 2) {
return;
}
load_config('system');
load_hooks();
$a->set_baseurl(get_config('system', 'url'));
$dir = get_config('system', 'directory_submit_url');
if (!strlen($dir)) {
return;
}
$arr = array('url' => $argv[1]);
call_hooks('globaldir_update', $arr);
logger('Updating directory: ' . $arr['url'], LOGGER_DEBUG);
if (strlen($arr['url'])) {
fetch_url($dir . '?url=' . bin2hex($arr['url']));
}
return;
}
示例3: expire_run
function expire_run($argv, $argc)
{
global $a, $db;
if (is_null($a)) {
$a = new App();
}
if (is_null($db)) {
@(include ".htconfig.php");
require_once "dba.php";
$db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
}
require_once 'include/session.php';
require_once 'include/datetime.php';
require_once 'library/simplepie/simplepie.inc';
require_once 'include/items.php';
require_once 'include/Contact.php';
load_config('config');
load_config('system');
$a->set_baseurl(get_config('system', 'url'));
logger('expire: start');
$r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0");
if (count($r)) {
foreach ($r as $rr) {
logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG);
item_expire($rr['uid'], $rr['expire']);
}
}
return;
}
示例4: expire_run
function expire_run($argv, $argc)
{
global $a, $db;
if (is_null($a)) {
$a = new App();
}
if (is_null($db)) {
@(include ".htconfig.php");
require_once "dba.php";
$db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
}
require_once 'include/session.php';
require_once 'include/datetime.php';
require_once 'library/simplepie/simplepie.inc';
require_once 'include/items.php';
require_once 'include/Contact.php';
load_config('config');
load_config('system');
$a->set_baseurl(get_config('system', 'url'));
// physically remove anything that has been deleted for more than two months
$r = q("delete from item where deleted = 1 and changed < UTC_TIMESTAMP() - INTERVAL 60 DAY");
q("optimize table item");
logger('expire: start');
$r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0");
if (count($r)) {
foreach ($r as $rr) {
logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG);
item_expire($rr['uid'], $rr['expire']);
}
}
return;
}
示例5: directory_run
function directory_run($argv, $argc)
{
global $a, $db;
if (is_null($a)) {
$a = new App();
}
if (is_null($db)) {
@(include ".htconfig.php");
require_once "dba.php";
$db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
}
load_config('config');
load_config('system');
if ($argc != 2) {
return;
}
load_config('system');
$a->set_baseurl(get_config('system', 'url'));
$dir = get_config('system', 'directory_submit_url');
if (!strlen($dir)) {
return;
}
fetch_url($dir . '?url=' . bin2hex($argv[1]));
return;
}
示例6: gprobe_run
function gprobe_run(&$argv, &$argc)
{
global $a, $db;
if (is_null($a)) {
$a = new App();
}
if (is_null($db)) {
@(include ".htconfig.php");
require_once "include/dba.php";
$db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
}
require_once 'include/session.php';
require_once 'include/datetime.php';
load_config('config');
load_config('system');
$a->set_baseurl(get_config('system', 'url'));
load_hooks();
if ($argc != 2) {
return;
}
$url = hex2bin($argv[1]);
$r = q("select * from gcontact where nurl = '%s' limit 1", dbesc(normalise_link($url)));
logger("gprobe start for " . normalise_link($url), LOGGER_DEBUG);
if (!count($r)) {
// Is it a DDoS attempt?
$urlparts = parse_url($url);
$result = Cache::get("gprobe:" . $urlparts["host"]);
if (!is_null($result)) {
$result = unserialize($result);
if ($result["network"] == NETWORK_FEED) {
logger("DDoS attempt detected for " . $urlparts["host"] . " by " . $_SERVER["REMOTE_ADDR"] . ". server data: " . print_r($_SERVER, true), LOGGER_DEBUG);
return;
}
}
$arr = probe_url($url);
if (is_null($result)) {
Cache::set("gprobe:" . $urlparts["host"], serialize($arr));
}
if (count($arr) && x($arr, 'network') && $arr['network'] === NETWORK_DFRN) {
q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`)\n\t\t\t\tvalues ( '%s', '%s', '%s', '%s') ", dbesc($arr['name']), dbesc($arr['url']), dbesc(normalise_link($arr['url'])), dbesc($arr['photo']));
}
$r = q("select * from gcontact where nurl = '%s' limit 1", dbesc(normalise_link($url)));
}
if (count($r)) {
poco_load(0, 0, $r[0]['id'], str_replace('/profile/', '/poco/', $r[0]['url']));
}
logger("gprobe end for " . normalise_link($url), LOGGER_DEBUG);
return;
}
示例7: cronhooks_run
function cronhooks_run(&$argv, &$argc)
{
global $a, $db;
if (is_null($a)) {
$a = new App();
}
if (is_null($db)) {
@(include ".htconfig.php");
require_once "include/dba.php";
$db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
}
require_once 'include/session.php';
require_once 'include/datetime.php';
require_once 'include/pidfile.php';
load_config('config');
load_config('system');
$maxsysload = intval(get_config('system', 'maxloadavg'));
if ($maxsysload < 1) {
$maxsysload = 50;
}
if (function_exists('sys_getloadavg')) {
$load = sys_getloadavg();
if (intval($load[0]) > $maxsysload) {
logger('system: load ' . $load . ' too high. Poller deferred to next scheduled run.');
return;
}
}
$lockpath = get_lockpath();
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'cronhooks');
if ($pidfile->is_already_running()) {
logger("cronhooks: Already running");
if ($pidfile->running_time() > 19 * 60) {
$pidfile->kill();
logger("cronhooks: killed stale process");
// Calling a new instance
proc_run('php', 'include/cronhooks.php');
}
exit;
}
}
$a->set_baseurl(get_config('system', 'url'));
load_hooks();
logger('cronhooks: start');
$d = datetime_convert();
call_hooks('cron', $d);
logger('cronhooks: end');
return;
}
示例8: cli_startup
function cli_startup()
{
global $a, $db;
if (is_null($a)) {
$a = new App();
}
if (is_null($db)) {
@(include ".htconfig.php");
require_once 'include/dba/dba_driver.php';
$db = dba_factory($db_host, $db_port, $db_user, $db_pass, $db_data);
unset($db_host, $db_port, $db_user, $db_pass, $db_data);
}
require_once 'include/session.php';
load_config('system');
$a->set_baseurl(get_config('system', 'baseurl'));
load_hooks();
}
示例9: pubsubpublish_run
function pubsubpublish_run(&$argv, &$argc)
{
global $a, $db;
if (is_null($a)) {
$a = new App();
}
if (is_null($db)) {
@(include ".htconfig.php");
require_once "include/dba.php";
$db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
}
require_once 'include/items.php';
require_once 'include/pidfile.php';
load_config('config');
load_config('system');
$lockpath = get_lockpath();
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'pubsubpublish');
if ($pidfile->is_already_running()) {
logger("Already running");
if ($pidfile->running_time() > 9 * 60) {
$pidfile->kill();
logger("killed stale process");
// Calling a new instance
proc_run('php', "include/pubsubpublish.php");
}
return;
}
}
$a->set_baseurl(get_config('system', 'url'));
load_hooks();
if ($argc > 1) {
$pubsubpublish_id = intval($argv[1]);
} else {
$pubsubpublish_id = 0;
}
handle_pubsubhubbub();
return;
}
示例10: cli_startup
function cli_startup()
{
global $a, $db, $default_timezone;
if (is_null($a)) {
$a = new App();
}
if (is_null($db)) {
@(include ".htconfig.php");
if (!defined('UNO')) {
define('UNO', 0);
}
$a->timezone = x($default_timezone) ? $default_timezone : 'UTC';
date_default_timezone_set($a->timezone);
require_once 'include/dba/dba_driver.php';
$db = dba_factory($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type);
unset($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type);
}
require_once 'include/session.php';
load_config('system');
$a->set_baseurl(get_config('system', 'baseurl'));
load_hooks();
}
示例11: cronhooks_run
function cronhooks_run(&$argv, &$argc)
{
global $a, $db;
if (is_null($a)) {
$a = new App();
}
if (is_null($db)) {
@(include ".htconfig.php");
require_once "include/dba.php";
$db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
}
require_once 'include/session.php';
require_once 'include/datetime.php';
load_config('config');
load_config('system');
$a->set_baseurl(get_config('system', 'url'));
load_hooks();
logger('cronhooks: start');
$d = datetime_convert();
call_hooks('cron', $d);
return;
}
示例12: delivery_run
function delivery_run(&$argv, &$argc)
{
global $a, $db;
if (is_null($a)) {
$a = new App();
}
if (is_null($db)) {
@(include ".htconfig.php");
require_once "include/dba.php";
$db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
}
require_once "include/session.php";
require_once "include/datetime.php";
require_once 'include/items.php';
require_once 'include/bbcode.php';
require_once 'include/diaspora.php';
require_once 'include/email.php';
load_config('config');
load_config('system');
load_hooks();
if ($argc < 3) {
return;
}
$a->set_baseurl(get_config('system', 'url'));
logger('delivery: invoked: ' . print_r($argv, true), LOGGER_DEBUG);
$cmd = $argv[1];
$item_id = intval($argv[2]);
for ($x = 3; $x < $argc; $x++) {
$contact_id = intval($argv[$x]);
// Some other process may have delivered this item already.
$r = q("select * from deliverq where cmd = '%s' and item = %d and contact = %d limit 1", dbesc($cmd), dbesc($item_id), dbesc($contact_id));
if (!count($r)) {
continue;
}
$maxsysload = intval(get_config('system', 'maxloadavg'));
if ($maxsysload < 1) {
$maxsysload = 50;
}
if (function_exists('sys_getloadavg')) {
$load = sys_getloadavg();
if (intval($load[0]) > $maxsysload) {
logger('system: load ' . $load . ' too high. Delivery deferred to next queue run.');
return;
}
}
// It's ours to deliver. Remove it from the queue.
q("delete from deliverq where cmd = '%s' and item = %d and contact = %d", dbesc($cmd), dbesc($item_id), dbesc($contact_id));
if (!$item_id || !$contact_id) {
continue;
}
$expire = false;
$top_level = false;
$recipients = array();
$url_recipients = array();
$normal_mode = true;
$recipients[] = $contact_id;
if ($cmd === 'expire') {
$normal_mode = false;
$expire = true;
$items = q("SELECT * FROM `item` WHERE `uid` = %d AND `wall` = 1 \n\t\t\t\tAND `deleted` = 1 AND `changed` > UTC_TIMESTAMP() - INTERVAL 30 MINUTE", intval($item_id));
$uid = $item_id;
$item_id = 0;
if (!count($items)) {
continue;
}
} else {
// find ancestors
$r = q("SELECT * FROM `item` WHERE `id` = %d and visible = 1 and moderated = 0 LIMIT 1", intval($item_id));
if (!count($r) || !intval($r[0]['parent'])) {
continue;
}
$target_item = $r[0];
$parent_id = intval($r[0]['parent']);
$uid = $r[0]['uid'];
$updated = $r[0]['edited'];
// POSSIBLE CLEANUP --> The following seems superfluous. We've already checked for "if (! intval($r[0]['parent']))" a few lines up
if (!$parent_id) {
continue;
}
$items = q("SELECT `item`.*, `sign`.`signed_text`,`sign`.`signature`,`sign`.`signer` \n\t\t\t\tFROM `item` LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id` WHERE `parent` = %d and visible = 1 and moderated = 0 ORDER BY `id` ASC", intval($parent_id));
if (!count($items)) {
continue;
}
$icontacts = null;
$contacts_arr = array();
foreach ($items as $item) {
if (!in_array($item['contact-id'], $contacts_arr)) {
$contacts_arr[] = intval($item['contact-id']);
}
}
if (count($contacts_arr)) {
$str_contacts = implode(',', $contacts_arr);
$icontacts = q("SELECT * FROM `contact` \n\t\t\t\t\tWHERE `id` IN ( {$str_contacts} ) ");
}
if (!($icontacts && count($icontacts))) {
continue;
}
// avoid race condition with deleting entries
if ($items[0]['deleted']) {
//.........这里部分代码省略.........
示例13: poller_run
function poller_run(&$argv, &$argc)
{
global $a, $db;
if (is_null($a)) {
$a = new App();
}
if (is_null($db)) {
@(include ".htconfig.php");
require_once "include/dba.php";
$db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
}
require_once 'include/session.php';
require_once 'include/datetime.php';
require_once 'library/simplepie/simplepie.inc';
require_once 'include/items.php';
require_once 'include/Contact.php';
require_once 'include/email.php';
require_once 'include/socgraph.php';
require_once 'include/pidfile.php';
load_config('config');
load_config('system');
$maxsysload = intval(get_config('system', 'maxloadavg'));
if ($maxsysload < 1) {
$maxsysload = 50;
}
if (function_exists('sys_getloadavg')) {
$load = sys_getloadavg();
if (intval($load[0]) > $maxsysload) {
logger('system: load ' . $load . ' too high. Poller deferred to next scheduled run.');
return;
}
}
$lockpath = get_lockpath();
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'poller');
if ($pidfile->is_already_running()) {
logger("poller: Already running");
if ($pidfile->running_time() > 9 * 60) {
$pidfile->kill();
logger("poller: killed stale process");
// Calling a new instance
proc_run('php', 'include/poller.php');
}
exit;
}
}
$a->set_baseurl(get_config('system', 'url'));
load_hooks();
logger('poller: start');
// run queue delivery process in the background
proc_run('php', "include/queue.php");
// run diaspora photo queue process in the background
proc_run('php', "include/dsprphotoq.php");
// expire any expired accounts
q("UPDATE user SET `account_expired` = 1 where `account_expired` = 0 \n\t\tAND `account_expires_on` != '0000-00-00 00:00:00' \n\t\tAND `account_expires_on` < UTC_TIMESTAMP() ");
// delete user and contact records for recently removed accounts
$r = q("SELECT * FROM `user` WHERE `account_removed` = 1 AND `account_expires_on` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
if ($r) {
foreach ($r as $user) {
q("DELETE FROM `contact` WHERE `uid` = %d", intval($user['uid']));
q("DELETE FROM `user` WHERE `uid` = %d", intval($user['uid']));
}
}
$abandon_days = intval(get_config('system', 'account_abandon_days'));
if ($abandon_days < 1) {
$abandon_days = 0;
}
// Check OStatus conversations
check_conversations();
// To-Do: Regenerate usage statistics
// q("ANALYZE TABLE `item`");
// once daily run birthday_updates and then expire in background
$d1 = get_config('system', 'last_expire_day');
$d2 = intval(datetime_convert('UTC', 'UTC', 'now', 'd'));
if ($d2 != intval($d1)) {
update_contact_birthdays();
update_suggestions();
set_config('system', 'last_expire_day', $d2);
proc_run('php', 'include/expire.php');
}
$last = get_config('system', 'cache_last_cleared');
if ($last) {
$next = $last + 3600;
// Once per hour
$clear_cache = $next <= time();
} else {
$clear_cache = true;
}
if ($clear_cache) {
// clear old cache
Cache::clear();
// clear old item cache files
clear_cache();
// clear cache for photos
clear_cache($a->get_basepath(), $a->get_basepath() . "/photo");
// clear smarty cache
clear_cache($a->get_basepath() . "/view/smarty3/compiled", $a->get_basepath() . "/view/smarty3/compiled");
// clear cache for image proxy
if (!get_config("system", "proxy_disabled")) {
//.........这里部分代码省略.........
示例14: check_config
function check_config(&$a)
{
$build = get_config('system', 'db_version');
if (!intval($build)) {
$build = set_config('system', 'db_version', DB_UPDATE_VERSION);
}
$saved = get_config('system', 'urlverify');
if (!$saved) {
set_config('system', 'urlverify', bin2hex(z_root()));
}
if ($saved && $saved != bin2hex(z_root())) {
// our URL changed. Do something.
$oldurl = hex2bin($saved);
logger('Baseurl changed!');
$oldhost = substr($oldurl, strpos($oldurl, '//') + 2);
$host = substr(z_root(), strpos(z_root(), '//') + 2);
$is_ip_addr = preg_match("/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\$/", $host) ? true : false;
$was_ip_addr = preg_match("/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\$/", $oldhost) ? true : false;
// only change the url to an ip address if it was already an ip and not a dns name
if (!$is_ip_addr || $is_ip_addr && $was_ip_addr) {
fix_system_urls($oldurl, z_root());
set_config('system', 'urlverify', bin2hex(z_root()));
} else {
logger('Attempt to change baseurl from a DNS name to an IP address was refused.');
}
}
// This will actually set the url to the one stored in .htconfig, and ignore what
// we're passing - unless we are installing and it has never been set.
App::set_baseurl(z_root());
// Make sure each site has a system channel. This is now created on install
// so we just need to keep this around a couple of weeks until the hubs that
// already exist have one
$syschan_exists = get_sys_channel();
if (!$syschan_exists) {
create_sys_channel();
}
if ($build != DB_UPDATE_VERSION) {
$stored = intval($build);
if (!$stored) {
logger('Critical: check_config unable to determine database schema version');
return;
}
$current = intval(DB_UPDATE_VERSION);
if ($stored < $current && file_exists('install/update.php')) {
load_config('database');
// We're reporting a different version than what is currently installed.
// Run any existing update scripts to bring the database up to current.
require_once 'install/update.php';
// make sure that boot.php and update.php are the same release, we might be
// updating right this very second and the correct version of the update.php
// file may not be here yet. This can happen on a very busy site.
if (DB_UPDATE_VERSION == UPDATE_VERSION) {
for ($x = $stored; $x < $current; $x++) {
if (function_exists('update_r' . $x)) {
// There could be a lot of processes running or about to run.
// We want exactly one process to run the update command.
// So store the fact that we're taking responsibility
// after first checking to see if somebody else already has.
// If the update fails or times-out completely you may need to
// delete the config entry to try again.
if (get_config('database', 'update_r' . $x)) {
break;
}
set_config('database', 'update_r' . $x, '1');
// call the specific update
$func = 'update_r' . $x;
$retval = $func();
if ($retval) {
// Prevent sending hundreds of thousands of emails by creating
// a lockfile.
$lockfile = 'store/[data]/mailsent';
if (file_exists($lockfile) && filemtime($lockfile) > time() - 86400) {
return;
}
@unlink($lockfile);
//send the administrator an e-mail
file_put_contents($lockfile, $x);
$r = q("select account_language from account where account_email = '%s' limit 1", dbesc(App::$config['system']['admin_email']));
push_lang($r ? $r[0]['account_language'] : 'en');
$email_tpl = get_intltext_template("update_fail_eml.tpl");
$email_msg = replace_macros($email_tpl, array('$sitename' => App::$config['system']['sitename'], '$siteurl' => z_root(), '$update' => $x, '$error' => sprintf(t('Update %s failed. See error logs.'), $x)));
$subject = email_header_encode(sprintf(t('Update Error at %s'), z_root()));
mail(App::$config['system']['admin_email'], $subject, $email_msg, 'From: Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit');
//try the logger
logger('CRITICAL: Update Failed: ' . $x);
pop_lang();
} else {
set_config('database', 'update_r' . $x, 'success');
}
}
}
set_config('system', 'db_version', DB_UPDATE_VERSION);
}
}
}
/**
*
* Synchronise plugins:
*
* App::$config['system']['addon'] contains a comma-separated list of names
//.........这里部分代码省略.........
示例15: poller_run
function poller_run($argv, $argc)
{
global $a, $db;
if (is_null($a)) {
$a = new App();
}
if (is_null($db)) {
@(include ".htconfig.php");
require_once "dba.php";
$db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
}
require_once 'include/session.php';
require_once 'include/datetime.php';
require_once 'library/simplepie/simplepie.inc';
require_once 'include/items.php';
require_once 'include/Contact.php';
require_once 'include/email.php';
require_once 'include/socgraph.php';
require_once 'include/pidfile.php';
load_config('config');
load_config('system');
$maxsysload = intval(get_config('system', 'maxloadavg'));
if ($maxsysload < 1) {
$maxsysload = 50;
}
if (function_exists('sys_getloadavg')) {
$load = sys_getloadavg();
if (intval($load[0]) > $maxsysload) {
logger('system: load ' . $load . ' too high. Poller deferred to next scheduled run.');
return;
}
}
$lockpath = get_config('system', 'lockpath');
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'poller.lck');
if ($pidfile->is_already_running()) {
logger("poller: Already running");
exit;
}
}
$a->set_baseurl(get_config('system', 'url'));
load_hooks();
logger('poller: start');
// run queue delivery process in the background
proc_run('php', "include/queue.php");
// expire any expired accounts
q("UPDATE user SET `account_expired` = 1 where `account_expired` = 0 \n\t\tAND `account_expires_on` != '0000-00-00 00:00:00' \n\t\tAND `account_expires_on` < UTC_TIMESTAMP() ");
$abandon_days = intval(get_config('system', 'account_abandon_days'));
if ($abandon_days < 1) {
$abandon_days = 0;
}
// once daily run birthday_updates and then expire in background
$d1 = get_config('system', 'last_expire_day');
$d2 = intval(datetime_convert('UTC', 'UTC', 'now', 'd'));
if ($d2 != intval($d1)) {
update_contact_birthdays();
update_suggestions();
set_config('system', 'last_expire_day', $d2);
proc_run('php', 'include/expire.php');
}
// clear old cache
Cache::clear();
// clear item cache files if they are older than one day
$cache = get_config('system', 'itemcache');
if ($cache != '' and is_dir($cache)) {
if ($dh = opendir($cache)) {
while (($file = readdir($dh)) !== false) {
$fullpath = $cache . "/" . $file;
if (filetype($fullpath) == "file" and filectime($fullpath) < time() - 86400) {
unlink($fullpath);
}
}
closedir($dh);
}
}
$manual_id = 0;
$generation = 0;
$hub_update = false;
$force = false;
$restart = false;
if ($argc > 1 && $argv[1] == 'force') {
$force = true;
}
if ($argc > 1 && $argv[1] == 'restart') {
$restart = true;
$generation = intval($argv[2]);
if (!$generation) {
killme();
}
}
if ($argc > 1 && intval($argv[1])) {
$manual_id = intval($argv[1]);
$force = true;
}
$interval = intval(get_config('system', 'poll_interval'));
if (!$interval) {
$interval = get_config('system', 'delivery_interval') === false ? 3 : intval(get_config('system', 'delivery_interval'));
}
$sql_extra = $manual_id ? " AND `id` = {$manual_id} " : "";
//.........这里部分代码省略.........