本文整理汇总了PHP中load_hooks函数的典型用法代码示例。如果您正苦于以下问题:PHP load_hooks函数的具体用法?PHP load_hooks怎么用?PHP load_hooks使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load_hooks函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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();
}
示例6: 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;
}
示例7: 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();
}
示例8: 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 "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';
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");
// make this optional as it could have a performance impact on large sites
if (intval(get_config('system', 'optimize_items'))) {
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']);
}
}
load_hooks();
call_hooks('expire');
return;
}
示例9: 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;
}
示例10: update_gcontact_run
function update_gcontact_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/pidfile.php';
require_once 'include/Scrape.php';
require_once "include/socgraph.php";
load_config('config');
load_config('system');
$a->set_baseurl(get_config('system', 'url'));
load_hooks();
logger('update_gcontact: start');
if ($argc > 1 && intval($argv[1])) {
$contact_id = intval($argv[1]);
}
if (!$contact_id) {
logger('update_gcontact: no contact');
return;
}
$lockpath = get_lockpath();
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'update_gcontact' . $contact_id);
if ($pidfile->is_already_running()) {
logger("update_gcontact: Already running for contact " . $contact_id);
if ($pidfile->running_time() > 9 * 60) {
$pidfile->kill();
logger("killed stale process");
}
exit;
}
}
$r = q("SELECT * FROM `gcontact` WHERE `id` = %d", intval($contact_id));
if (!$r) {
return;
}
if (!in_array($r[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
return;
}
$data = probe_url($r[0]["url"]);
if (!in_array($data["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
if ($r[0]["server_url"] != "") {
poco_check_server($r[0]["server_url"], $r[0]["network"]);
}
q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `id` = %d", dbesc(datetime_convert()), intval($contact_id));
return;
}
if ($data["name"] == "" and $r[0]['name'] != "") {
$data["name"] = $r[0]['name'];
}
if ($data["nick"] == "" and $r[0]['nick'] != "") {
$data["nick"] = $r[0]['nick'];
}
if ($data["addr"] == "" and $r[0]['addr'] != "") {
$data["addr"] = $r[0]['addr'];
}
if ($data["photo"] == "" and $r[0]['photo'] != "") {
$data["photo"] = $r[0]['photo'];
}
q("UPDATE `gcontact` SET `name` = '%s', `nick` = '%s', `addr` = '%s', `photo` = '%s'\n\t\t\t\tWHERE `id` = %d", dbesc($data["name"]), dbesc($data["nick"]), dbesc($data["addr"]), dbesc($data["photo"]), intval($contact_id));
q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `addr` = '%s', `photo` = '%s'\n\t\t\t\tWHERE `uid` = 0 AND `addr` = '' AND `nurl` = '%s'", dbesc($data["name"]), dbesc($data["nick"]), dbesc($data["addr"]), dbesc($data["photo"]), dbesc(normalise_link($data["url"])));
q("UPDATE `contact` SET `addr` = '%s'\n\t\t\t\tWHERE `uid` != 0 AND `addr` = '' AND `nurl` = '%s'", dbesc($data["addr"]), dbesc(normalise_link($data["url"])));
}
示例11: check_config
//.........这里部分代码省略.........
if (!x($build)) {
$build = set_config('system', 'build', DB_UPDATE_VERSION);
}
$url = get_config('system', 'url');
// if the url isn't set or the stored url is radically different
// than the currently visited url, store the current value accordingly.
// "Radically different" ignores common variations such as http vs https
// and www.example.com vs example.com.
if (!x($url) || !link_compare($url, $a->get_baseurl())) {
$url = set_config('system', 'url', $a->get_baseurl());
}
if ($build != DB_UPDATE_VERSION) {
$stored = intval($build);
$current = intval(DB_UPDATE_VERSION);
if ($stored < $current && file_exists('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 '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_' . $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_' . $x)) {
break;
}
set_config('database', 'update_' . $x, '1');
// call the specific update
$func = 'update_' . $x;
$retval = $func();
if ($retval) {
//send the administrator an e-mail
$email_tpl = get_intltext_template("update_fail_eml.tpl");
$email_msg = replace_macros($email_tpl, array('$sitename' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$update' => $x, '$error' => sprintf(t('Update %s failed. See error logs.'), $x)));
$subject = sprintf(t('Update Error at %s'), $a->get_baseurl());
mail($a->config['admin_email'], $subject, $email_msg, 'From: ' . t('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);
} else {
set_config('database', 'update_' . $x, 'success');
}
}
}
set_config('system', 'build', DB_UPDATE_VERSION);
}
}
}
/**
*
* Synchronise plugins:
*
* $a->config['system']['addon'] contains a comma-separated list of names
* of plugins/addons which are used on this system.
* Go through the database list of already installed addons, and if we have
* an entry, but it isn't in the config list, call the uninstall procedure
* and mark it uninstalled in the database (for now we'll remove it).
* Then go through the config list and if we have a plugin that isn't installed,
* call the install procedure and add it to the database.
*
*/
$r = q("SELECT * FROM `addon` WHERE `installed` = 1");
if (count($r)) {
$installed = $r;
} else {
$installed = array();
}
$plugins = get_config('system', 'addon');
$plugins_arr = array();
if ($plugins) {
$plugins_arr = explode(',', str_replace(' ', '', $plugins));
}
$a->plugins = $plugins_arr;
$installed_arr = array();
if (count($installed)) {
foreach ($installed as $i) {
if (!in_array($i['name'], $plugins_arr)) {
uninstall_plugin($i['name']);
} else {
$installed_arr[] = $i['name'];
}
}
}
if (count($plugins_arr)) {
foreach ($plugins_arr as $p) {
if (!in_array($p, $installed_arr)) {
install_plugin($p);
}
}
}
load_hooks();
return;
}
示例12: queue_run
function queue_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/pidfile.php';
require_once 'include/socgraph.php';
load_config('config');
load_config('system');
$lockpath = get_lockpath();
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'queue');
if ($pidfile->is_already_running()) {
logger("queue: Already running");
if ($pidfile->running_time() > 9 * 60) {
$pidfile->kill();
logger("queue: killed stale process");
// Calling a new instance
proc_run('php', "include/queue.php");
}
return;
}
}
$a->set_baseurl(get_config('system', 'url'));
load_hooks();
if ($argc > 1) {
$queue_id = intval($argv[1]);
} else {
$queue_id = 0;
}
$deadguys = array();
logger('queue: start');
// Handling the pubsubhubbub requests
proc_run('php', 'include/pubsubpublish.php');
$interval = get_config('system', 'delivery_interval') === false ? 2 : intval(get_config('system', 'delivery_interval'));
// If we are using the worker we don't need a delivery interval
if (get_config("system", "worker")) {
$interval = false;
}
$r = q("select * from deliverq where 1");
if ($r) {
foreach ($r as $rr) {
logger('queue: deliverq');
proc_run('php', 'include/delivery.php', $rr['cmd'], $rr['item'], $rr['contact']);
if ($interval) {
@time_sleep_until(microtime(true) + (double) $interval);
}
}
}
$r = q("SELECT `queue`.*, `contact`.`name`, `contact`.`uid` FROM `queue`\n\t\tINNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`\n\t\tWHERE `queue`.`created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
if ($r) {
foreach ($r as $rr) {
logger('Removing expired queue item for ' . $rr['name'] . ', uid=' . $rr['uid']);
logger('Expired queue data :' . $rr['content'], LOGGER_DATA);
}
q("DELETE FROM `queue` WHERE `created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
}
if ($queue_id) {
$r = q("SELECT `id` FROM `queue` WHERE `id` = %d LIMIT 1", intval($queue_id));
} else {
// For the first 12 hours we'll try to deliver every 15 minutes
// After that, we'll only attempt delivery once per hour.
$r = q("SELECT `id` FROM `queue` WHERE (( `created` > UTC_TIMESTAMP() - INTERVAL 12 HOUR && `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ) OR ( `last` < UTC_TIMESTAMP() - INTERVAL 1 HOUR ))");
}
if (!$r) {
return;
}
if (!$queue_id) {
call_hooks('queue_predeliver', $a, $r);
}
// delivery loop
require_once 'include/salmon.php';
require_once 'include/diaspora.php';
foreach ($r as $q_item) {
// queue_predeliver hooks may have changed the queue db details,
// so check again if this entry still needs processing
if ($queue_id) {
$qi = q("select * from queue where `id` = %d limit 1", intval($queue_id));
} else {
$qi = q("SELECT * FROM `queue` WHERE `id` = %d AND `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ", intval($q_item['id']));
}
if (!count($qi)) {
continue;
}
$c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", intval($qi[0]['cid']));
if (!count($c)) {
remove_queue_item($q_item['id']);
continue;
}
//.........这里部分代码省略.........
示例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 "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';
load_config('config');
load_config('system');
$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();
$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;
}
$sql_extra = $manual_id ? " AND `id` = {$manual_id} " : "";
reload_plugins();
$d = datetime_convert();
if (!$restart) {
proc_run('php', 'include/cronhooks.php');
}
// Only poll from those with suitable relationships,
// and which have a polling address and ignore Diaspora since
// we are unable to match those posts with a Diaspora GUID and prevent duplicates.
$abandon_sql = $abandon_days ? sprintf(" AND `user`.`login_date` > UTC_TIMESTAMP() - INTERVAL %d DAY ", intval($abandon_days)) : '';
$contacts = q("SELECT `contact`.`id` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid` \n\t\tWHERE ( `rel` = %d OR `rel` = %d ) AND `poll` != ''\n\t\tAND NOT `network` IN ( '%s', '%s' )\n\t\t{$sql_extra} \n\t\tAND `self` = 0 AND `contact`.`blocked` = 0 AND `contact`.`readonly` = 0 \n\t\tAND `user`.`account_expired` = 0 {$abandon_sql} ORDER BY RAND()", intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_FACEBOOK));
if (!count($contacts)) {
return;
}
foreach ($contacts as $c) {
$res = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", intval($c['id']));
if (!$res || !count($res)) {
continue;
}
foreach ($res as $contact) {
$xml = false;
if ($manual_id) {
$contact['last-update'] = '0000-00-00 00:00:00';
}
if ($contact['network'] === NETWORK_DFRN || $contact['network'] === NETWORK_OSTATUS) {
$contact['priority'] = 2;
}
if ($contact['priority'] || $contact['subhub']) {
$hub_update = true;
$update = false;
$t = $contact['last-update'];
// We should be getting everything via a hub. But just to be sure, let's check once a day.
// (You can make this more or less frequent if desired by setting 'pushpoll_frequency' appropriately)
// This also lets us update our subscription to the hub, and add or replace hubs in case it
// changed. We will only update hubs once a day, regardless of 'pushpoll_frequency'.
if ($contact['subhub']) {
$interval = get_config('system', 'pushpoll_frequency');
$contact['priority'] = $interval !== false ? intval($interval) : 3;
//.........这里部分代码省略.........
示例14: cron_run
function cron_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';
require_once 'mod/nodeinfo.php';
load_config('config');
load_config('system');
$maxsysload = intval(get_config('system', 'maxloadavg'));
if ($maxsysload < 1) {
$maxsysload = 50;
}
$load = current_load();
if ($load) {
if (intval($load) > $maxsysload) {
logger('system: load ' . $load . ' too high. cron deferred to next scheduled run.');
return;
}
}
$last = get_config('system', 'last_cron');
$poll_interval = intval(get_config('system', 'cron_interval'));
if (!$poll_interval) {
$poll_interval = 10;
}
if ($last) {
$next = $last + $poll_interval * 60;
if ($next > time()) {
logger('cron intervall not reached');
return;
}
}
$lockpath = get_lockpath();
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'cron');
if ($pidfile->is_already_running()) {
logger("cron: Already running");
if ($pidfile->running_time() > 9 * 60) {
$pidfile->kill();
logger("cron: killed stale process");
// Calling a new instance
proc_run('php', 'include/cron.php');
}
exit;
}
}
$a->set_baseurl(get_config('system', 'url'));
load_hooks();
logger('cron: 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");
// run the process to discover global contacts in the background
proc_run('php', "include/discover_poco.php");
// run the process to update locally stored global contacts in the background
proc_run('php', "include/discover_poco.php", "checkcontact");
// 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 only conversations with mentions (for a longer time)
check_conversations(true);
// Check every conversation
check_conversations(false);
// Follow your friends from your legacy OStatus account
// Doesn't work
// ostatus_check_follow_friends();
// update nodeinfo data
nodeinfo_cron();
// 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'));
//.........这里部分代码省略.........
示例15: notifier_run
function notifier_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 "session.php";
require_once "datetime.php";
require_once 'include/items.php';
require_once 'include/bbcode.php';
load_config('config');
load_config('system');
load_hooks();
if ($argc < 3) {
return;
}
$a->set_baseurl(get_config('system', 'url'));
logger('notifier: invoked: ' . print_r($argv, true));
$cmd = $argv[1];
switch ($cmd) {
case 'mail':
default:
$item_id = intval($argv[2]);
if (!$item_id) {
return;
}
break;
}
$expire = false;
$mail = false;
$fsuggest = false;
$top_level = false;
$recipients = array();
$url_recipients = array();
$normal_mode = true;
if ($cmd === 'mail') {
$normal_mode = false;
$mail = true;
$message = q("SELECT * FROM `mail` WHERE `id` = %d LIMIT 1", intval($item_id));
if (!count($message)) {
return;
}
$uid = $message[0]['uid'];
$recipients[] = $message[0]['contact-id'];
$item = $message[0];
} elseif ($cmd === 'expire') {
$normal_mode = false;
$expire = true;
$items = q("SELECT * FROM `item` WHERE `uid` = %d AND `wall` = 1 \n\t\t\tAND `deleted` = 1 AND `changed` > UTC_TIMESTAMP() - INTERVAL 10 MINUTE", intval($item_id));
$uid = $item_id;
$item_id = 0;
if (!count($items)) {
return;
}
} elseif ($cmd === 'suggest') {
$normal_mode = false;
$fsuggest = true;
$suggest = q("SELECT * FROM `fsuggest` WHERE `id` = %d LIMIT 1", intval($item_id));
if (!count($suggest)) {
return;
}
$uid = $suggest[0]['uid'];
$recipients[] = $suggest[0]['cid'];
$item = $suggest[0];
} else {
// find ancestors
$r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", intval($item_id));
if (!count($r) || !intval($r[0]['parent'])) {
return;
}
$target_item = $r[0];
$parent_id = intval($r[0]['parent']);
$uid = $r[0]['uid'];
$updated = $r[0]['edited'];
if (!$parent_id) {
return;
}
$items = q("SELECT `item`.*, `sign`.`signed_text`,`sign`.`signature`,`sign`.`signer` \n\t\t\tFROM `item` LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id` WHERE `parent` = %d ORDER BY `id` ASC", intval($parent_id));
if (!count($items)) {
return;
}
// avoid race condition with deleting entries
if ($items[0]['deleted']) {
foreach ($items as $item) {
$item['deleted'] = 1;
}
}
if (count($items) == 1 && $items[0]['id'] === $target_item['id'] && $items[0]['uri'] === $items[0]['parent-uri']) {
logger('notifier: top level post');
$top_level = true;
}
}
$r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`, \n\t\t`user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`, \n\t\t`user`.`page-flags`, `user`.`prvnets`\n\t\tFROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid` \n\t\tWHERE `contact`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1", intval($uid));
if (!count($r)) {
//.........这里部分代码省略.........