mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-10 17:14:26 +02:00
Merge remote-tracking branch 'upstream/develop' into 1701-poco
Conflicts: include/socgraph.php
This commit is contained in:
commit
7f61b2ee15
52 changed files with 1573 additions and 1763 deletions
|
@ -127,7 +127,7 @@ function mark_for_death($contact) {
|
|||
if($contact['archive'])
|
||||
return;
|
||||
|
||||
if($contact['term-date'] == '0000-00-00 00:00:00') {
|
||||
if ($contact['term-date'] <= NULL_DATE) {
|
||||
q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d",
|
||||
dbesc(datetime_convert()),
|
||||
intval($contact['id'])
|
||||
|
@ -185,13 +185,13 @@ function unmark_for_death($contact) {
|
|||
|
||||
// It's a miracle. Our dead contact has inexplicably come back to life.
|
||||
q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d",
|
||||
dbesc('0000-00-00 00:00:00'),
|
||||
dbesc(NULL_DATE),
|
||||
intval($contact['id'])
|
||||
);
|
||||
|
||||
if ($contact['url'] != '') {
|
||||
q("UPDATE `contact` SET `term-date` = '%s' WHERE `nurl` = '%s'",
|
||||
dbesc('0000-00-00 00:00:00'),
|
||||
dbesc(NULL_DATE),
|
||||
dbesc(normalise_link($contact['url']))
|
||||
);
|
||||
}
|
||||
|
|
|
@ -6,26 +6,9 @@
|
|||
* This script is started from mod/item.php to save some time when doing a post.
|
||||
*/
|
||||
|
||||
use \Friendica\Core\Config;
|
||||
|
||||
require_once("boot.php");
|
||||
require_once("include/threads.php");
|
||||
|
||||
function create_shadowentry_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);
|
||||
}
|
||||
|
||||
Config::load();
|
||||
|
||||
if ($argc != 2) {
|
||||
return;
|
||||
}
|
||||
|
@ -34,9 +17,4 @@ function create_shadowentry_run($argv, $argc) {
|
|||
|
||||
add_shadow_entry($message_id);
|
||||
}
|
||||
|
||||
if (array_search(__file__,get_included_files())===0){
|
||||
create_shadowentry_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||
killme();
|
||||
}
|
||||
?>
|
||||
|
|
109
include/cron.php
109
include/cron.php
|
@ -1,35 +1,11 @@
|
|||
<?php
|
||||
if (!file_exists("boot.php") AND (sizeof($_SERVER["argv"]) != 0)) {
|
||||
$directory = dirname($_SERVER["argv"][0]);
|
||||
|
||||
if (substr($directory, 0, 1) != "/")
|
||||
$directory = $_SERVER["PWD"]."/".$directory;
|
||||
|
||||
$directory = realpath($directory."/..");
|
||||
|
||||
chdir($directory);
|
||||
}
|
||||
|
||||
use \Friendica\Core\Config;
|
||||
|
||||
require_once("boot.php");
|
||||
require_once("include/photos.php");
|
||||
require_once("include/user.php");
|
||||
|
||||
require_once('include/photos.php');
|
||||
require_once('include/user.php');
|
||||
|
||||
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);
|
||||
};
|
||||
global $a;
|
||||
|
||||
require_once('include/session.php');
|
||||
require_once('include/datetime.php');
|
||||
|
@ -40,16 +16,6 @@ function cron_run(&$argv, &$argc){
|
|||
require_once('mod/nodeinfo.php');
|
||||
require_once('include/post_update.php');
|
||||
|
||||
Config::load();
|
||||
|
||||
// Don't check this stuff if the function is called by the poller
|
||||
if (App::callstack() != "poller_run") {
|
||||
if ($a->maxload_reached())
|
||||
return;
|
||||
if (App::is_already_running('cron', 'include/cron.php', 540))
|
||||
return;
|
||||
}
|
||||
|
||||
$last = get_config('system','last_cron');
|
||||
|
||||
$poll_interval = intval(get_config('system','cron_interval'));
|
||||
|
@ -64,10 +30,6 @@ function cron_run(&$argv, &$argc){
|
|||
}
|
||||
}
|
||||
|
||||
$a->set_baseurl(get_config('system','url'));
|
||||
|
||||
load_hooks();
|
||||
|
||||
logger('cron: start');
|
||||
|
||||
// run queue delivery process in the background
|
||||
|
@ -85,34 +47,17 @@ function cron_run(&$argv, &$argc){
|
|||
// Expire and remove user entries
|
||||
cron_expire_and_remove_users();
|
||||
|
||||
// If the worker is active, split the jobs in several sub processes
|
||||
if (get_config("system", "worker")) {
|
||||
// Check OStatus conversations
|
||||
proc_run(PRIORITY_MEDIUM, "include/cronjobs.php", "ostatus_mentions");
|
||||
// Check OStatus conversations
|
||||
proc_run(PRIORITY_MEDIUM, "include/cronjobs.php", "ostatus_mentions");
|
||||
|
||||
// Check every conversation
|
||||
proc_run(PRIORITY_MEDIUM, "include/cronjobs.php", "ostatus_conversations");
|
||||
// Check every conversation
|
||||
proc_run(PRIORITY_MEDIUM, "include/cronjobs.php", "ostatus_conversations");
|
||||
|
||||
// Call possible post update functions
|
||||
proc_run(PRIORITY_LOW, "include/cronjobs.php", "post_update");
|
||||
// Call possible post update functions
|
||||
proc_run(PRIORITY_LOW, "include/cronjobs.php", "post_update");
|
||||
|
||||
// update nodeinfo data
|
||||
proc_run(PRIORITY_LOW, "include/cronjobs.php", "nodeinfo");
|
||||
} else {
|
||||
// Check OStatus conversations
|
||||
// Check only conversations with mentions (for a longer time)
|
||||
ostatus::check_conversations(true);
|
||||
|
||||
// Check every conversation
|
||||
ostatus::check_conversations(false);
|
||||
|
||||
// Call possible post update functions
|
||||
// see include/post_update.php for more details
|
||||
post_update();
|
||||
|
||||
// update nodeinfo data
|
||||
nodeinfo_cron();
|
||||
}
|
||||
// update nodeinfo data
|
||||
proc_run(PRIORITY_LOW, "include/cronjobs.php", "nodeinfo");
|
||||
|
||||
// once daily run birthday_updates and then expire in background
|
||||
|
||||
|
@ -123,6 +68,8 @@ function cron_run(&$argv, &$argc){
|
|||
|
||||
update_contact_birthdays();
|
||||
|
||||
proc_run(PRIORITY_LOW, "include/discover_poco.php", "update_server");
|
||||
|
||||
proc_run(PRIORITY_LOW, "include/discover_poco.php", "suggestions");
|
||||
|
||||
set_config('system','last_expire_day',$d2);
|
||||
|
@ -173,8 +120,8 @@ function cron_update_photo_albums() {
|
|||
function cron_expire_and_remove_users() {
|
||||
// expire any expired accounts
|
||||
q("UPDATE user SET `account_expired` = 1 where `account_expired` = 0
|
||||
AND `account_expires_on` != '0000-00-00 00:00:00'
|
||||
AND `account_expires_on` < UTC_TIMESTAMP() ");
|
||||
AND `account_expires_on` > '%s'
|
||||
AND `account_expires_on` < UTC_TIMESTAMP()", dbesc(NULL_DATE));
|
||||
|
||||
// delete user and contact records for recently removed accounts
|
||||
$r = q("SELECT * FROM `user` WHERE `account_removed` AND `account_expires_on` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
|
||||
|
@ -213,14 +160,6 @@ function cron_poll_contacts($argc, $argv) {
|
|||
$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')));
|
||||
|
||||
// If we are using the worker we don't need a delivery interval
|
||||
if (get_config("system", "worker"))
|
||||
$interval = false;
|
||||
|
||||
$sql_extra = (($manual_id) ? " AND `id` = $manual_id " : "");
|
||||
|
||||
reload_plugins();
|
||||
|
@ -275,13 +214,15 @@ function cron_poll_contacts($argc, $argv) {
|
|||
|
||||
$xml = false;
|
||||
|
||||
if($manual_id)
|
||||
$contact['last-update'] = '0000-00-00 00:00:00';
|
||||
if ($manual_id) {
|
||||
$contact['last-update'] = NULL_DATE;
|
||||
}
|
||||
|
||||
if(in_array($contact['network'], array(NETWORK_DFRN, NETWORK_ZOT, NETWORK_OSTATUS)))
|
||||
if (in_array($contact['network'], array(NETWORK_DFRN, NETWORK_ZOT, NETWORK_OSTATUS))) {
|
||||
$contact['priority'] = 2;
|
||||
}
|
||||
|
||||
if($contact['subhub'] AND in_array($contact['network'], array(NETWORK_DFRN, NETWORK_ZOT, NETWORK_OSTATUS))) {
|
||||
if ($contact['subhub'] AND in_array($contact['network'], array(NETWORK_DFRN, NETWORK_ZOT, NETWORK_OSTATUS))) {
|
||||
// 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
|
||||
|
@ -335,9 +276,6 @@ function cron_poll_contacts($argc, $argv) {
|
|||
} else {
|
||||
proc_run(PRIORITY_LOW, 'include/onepoll.php', $contact['id']);
|
||||
}
|
||||
|
||||
if($interval)
|
||||
@time_sleep_until(microtime(true) + (float) $interval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -488,8 +426,3 @@ function cron_repair_database() {
|
|||
/// - remove children when parent got lost
|
||||
/// - set contact-id in item when not present
|
||||
}
|
||||
|
||||
if (array_search(__file__,get_included_files())===0){
|
||||
cron_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||
killme();
|
||||
}
|
||||
|
|
|
@ -2,37 +2,11 @@
|
|||
|
||||
use \Friendica\Core\Config;
|
||||
|
||||
require_once("boot.php");
|
||||
|
||||
function cronhooks_run(&$argv, &$argc){
|
||||
global $a, $db;
|
||||
global $a;
|
||||
|
||||
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');
|
||||
|
||||
Config::load();
|
||||
|
||||
// Don't check this stuff if the function is called by the poller
|
||||
if (App::callstack() != "poller_run") {
|
||||
if ($a->maxload_reached())
|
||||
return;
|
||||
if (App::is_already_running('cronhooks', 'include/cronhooks.php', 1140))
|
||||
return;
|
||||
}
|
||||
|
||||
load_hooks();
|
||||
|
||||
if (($argc == 2) AND is_array($a->hooks) AND array_key_exists("cron", $a->hooks)) {
|
||||
foreach ($a->hooks["cron"] as $hook)
|
||||
if ($hook[1] == $argv[1]) {
|
||||
|
@ -42,7 +16,7 @@ function cronhooks_run(&$argv, &$argc){
|
|||
return;
|
||||
}
|
||||
|
||||
$last = get_config('system','last_cronhook');
|
||||
$last = get_config('system', 'last_cronhook');
|
||||
|
||||
$poll_interval = intval(get_config('system','cronhook_interval'));
|
||||
if(! $poll_interval)
|
||||
|
@ -62,22 +36,16 @@ function cronhooks_run(&$argv, &$argc){
|
|||
|
||||
$d = datetime_convert();
|
||||
|
||||
if (get_config("system", "worker") AND is_array($a->hooks) AND array_key_exists("cron", $a->hooks)) {
|
||||
if (is_array($a->hooks) AND array_key_exists("cron", $a->hooks)) {
|
||||
foreach ($a->hooks["cron"] as $hook) {
|
||||
logger("Calling cronhooks for '".$hook[1]."'", LOGGER_DEBUG);
|
||||
proc_run(PRIORITY_MEDIUM, "include/cronhooks.php", $hook[1]);
|
||||
}
|
||||
} else
|
||||
call_hooks('cron', $d);
|
||||
}
|
||||
|
||||
logger('cronhooks: end');
|
||||
|
||||
set_config('system','last_cronhook', time());
|
||||
set_config('system', 'last_cronhook', time());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (array_search(__file__,get_included_files())===0){
|
||||
cronhooks_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||
killme();
|
||||
}
|
||||
|
|
|
@ -1,44 +1,14 @@
|
|||
<?php
|
||||
use \Friendica\Core\Config;
|
||||
|
||||
if (!file_exists("boot.php") AND (sizeof($_SERVER["argv"]) != 0)) {
|
||||
$directory = dirname($_SERVER["argv"][0]);
|
||||
|
||||
if (substr($directory, 0, 1) != "/")
|
||||
$directory = $_SERVER["PWD"]."/".$directory;
|
||||
|
||||
$directory = realpath($directory."/..");
|
||||
|
||||
chdir($directory);
|
||||
}
|
||||
|
||||
require_once("boot.php");
|
||||
|
||||
|
||||
function cronjobs_run(&$argv, &$argc){
|
||||
global $a, $db;
|
||||
global $a;
|
||||
|
||||
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/ostatus.php');
|
||||
require_once('include/post_update.php');
|
||||
require_once('mod/nodeinfo.php');
|
||||
|
||||
Config::load();
|
||||
|
||||
$a->set_baseurl(get_config('system','url'));
|
||||
|
||||
// No parameter set? So return
|
||||
if ($argc <= 1)
|
||||
return;
|
||||
|
@ -71,8 +41,3 @@ function cronjobs_run(&$argv, &$argc){
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
if (array_search(__file__,get_included_files())===0){
|
||||
cronjobs_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||
killme();
|
||||
}
|
||||
|
|
|
@ -339,7 +339,7 @@ function relative_date($posted_date, $format = null) {
|
|||
|
||||
$abs = strtotime($localtime);
|
||||
|
||||
if (is_null($posted_date) || $posted_date === '0000-00-00 00:00:00' || $abs === False) {
|
||||
if (is_null($posted_date) || $posted_date <= NULL_DATE || $abs === False) {
|
||||
return t('never');
|
||||
}
|
||||
|
||||
|
|
320
include/dba.php
320
include/dba.php
|
@ -1,17 +1,5 @@
|
|||
<?php
|
||||
require_once("dbm.php");
|
||||
|
||||
# if PDO is avaible for mysql, use the new database abstraction
|
||||
# TODO: PDO is disabled for release 3.3. We need to investigate why
|
||||
# the update from 3.2 fails with pdo
|
||||
/*
|
||||
if (class_exists('\PDO') && in_array('mysql', PDO::getAvailableDrivers())) {
|
||||
require_once("library/dddbl2/dddbl.php");
|
||||
require_once("include/dba_pdo.php");
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
require_once('include/datetime.php');
|
||||
|
||||
/**
|
||||
|
@ -24,13 +12,12 @@ require_once('include/datetime.php');
|
|||
*
|
||||
*/
|
||||
|
||||
if (! class_exists('dba')) {
|
||||
class dba {
|
||||
|
||||
private $debug = 0;
|
||||
private $db;
|
||||
private $result;
|
||||
public $mysqli = true;
|
||||
private $driver;
|
||||
public $connected = false;
|
||||
public $error = false;
|
||||
|
||||
|
@ -53,7 +40,7 @@ class dba {
|
|||
if ($install) {
|
||||
if (strlen($server) && ($server !== 'localhost') && ($server !== '127.0.0.1')) {
|
||||
if (! dns_get_record($server, DNS_A + DNS_CNAME + DNS_PTR)) {
|
||||
$this->error = sprintf( t('Cannot locate DNS info for database server \'%s\''), $server);
|
||||
$this->error = sprintf(t('Cannot locate DNS info for database server \'%s\''), $server);
|
||||
$this->connected = false;
|
||||
$this->db = null;
|
||||
return;
|
||||
|
@ -61,37 +48,52 @@ class dba {
|
|||
}
|
||||
}
|
||||
|
||||
if (class_exists('mysqli')) {
|
||||
$this->db = @new mysqli($server,$user,$pass,$db);
|
||||
if (! mysqli_connect_errno()) {
|
||||
if (class_exists('\PDO') && in_array('mysql', PDO::getAvailableDrivers())) {
|
||||
$this->driver = 'pdo';
|
||||
$connect = "mysql:host=".$server.";dbname=".$db;
|
||||
if (isset($a->config["system"]["db_charset"])) {
|
||||
$connect .= ";charset=".$a->config["system"]["db_charset"];
|
||||
}
|
||||
$this->db = @new PDO($connect, $user, $pass);
|
||||
if (!$this->db->errorCode()) {
|
||||
$this->connected = true;
|
||||
}
|
||||
if (isset($a->config["system"]["db_charset"])) {
|
||||
$this->db->set_charset($a->config["system"]["db_charset"]);
|
||||
} elseif (class_exists('mysqli')) {
|
||||
$this->driver = 'mysqli';
|
||||
$this->db = @new mysqli($server,$user,$pass,$db);
|
||||
if (!mysqli_connect_errno()) {
|
||||
$this->connected = true;
|
||||
|
||||
if (isset($a->config["system"]["db_charset"])) {
|
||||
$this->db->set_charset($a->config["system"]["db_charset"]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->mysqli = false;
|
||||
} elseif (function_exists('mysql_connect')) {
|
||||
$this->driver = 'mysql';
|
||||
$this->db = mysql_connect($server,$user,$pass);
|
||||
if ($this->db && mysql_select_db($db,$this->db)) {
|
||||
$this->connected = true;
|
||||
|
||||
if (isset($a->config["system"]["db_charset"])) {
|
||||
mysql_set_charset($a->config["system"]["db_charset"], $this->db);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// No suitable SQL driver was found.
|
||||
if (!$install) {
|
||||
system_unavailable();
|
||||
}
|
||||
if (isset($a->config["system"]["db_charset"]))
|
||||
mysql_set_charset($a->config["system"]["db_charset"], $this->db);
|
||||
}
|
||||
|
||||
if (!$this->connected) {
|
||||
$this->db = null;
|
||||
if (!$install) {
|
||||
system_unavailable();
|
||||
}
|
||||
}
|
||||
|
||||
$a->save_timestamp($stamp1, "network");
|
||||
}
|
||||
|
||||
public function getdb() {
|
||||
return $this->db;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the MySQL server version string
|
||||
*
|
||||
|
@ -101,12 +103,18 @@ class dba {
|
|||
* @return string
|
||||
*/
|
||||
public function server_info() {
|
||||
if ($this->mysqli) {
|
||||
$return = $this->db->server_info;
|
||||
} else {
|
||||
$return = mysql_get_server_info($this->db);
|
||||
switch ($this->driver) {
|
||||
case 'pdo':
|
||||
$version = $this->db->getAttribute(PDO::ATTR_SERVER_VERSION);
|
||||
break;
|
||||
case 'mysqli':
|
||||
$version = $this->db->server_info;
|
||||
break;
|
||||
case 'mysql':
|
||||
$version = mysql_get_server_info($this->db);
|
||||
break;
|
||||
}
|
||||
return $return;
|
||||
return $version;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -130,12 +138,18 @@ class dba {
|
|||
return 0;
|
||||
}
|
||||
|
||||
if ($this->mysqli) {
|
||||
$return = $this->result->num_rows;
|
||||
} else {
|
||||
$return = mysql_num_rows($this->result);
|
||||
switch ($this->driver) {
|
||||
case 'pdo':
|
||||
$rows = $this->result->rowCount();
|
||||
break;
|
||||
case 'mysqli':
|
||||
$rows = $this->result->num_rows;
|
||||
break;
|
||||
case 'mysql':
|
||||
$rows = mysql_num_rows($this->result);
|
||||
break;
|
||||
}
|
||||
return $return;
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -172,8 +186,9 @@ class dba {
|
|||
if ((intval($a->config["system"]["db_loglimit_index"]) > 0)) {
|
||||
$log = (in_array($row['key'], $watchlist) AND
|
||||
($row['rows'] >= intval($a->config["system"]["db_loglimit_index"])));
|
||||
} else
|
||||
} else {
|
||||
$log = false;
|
||||
}
|
||||
|
||||
if ((intval($a->config["system"]["db_loglimit_index_high"]) > 0) AND ($row['rows'] >= intval($a->config["system"]["db_loglimit_index_high"]))) {
|
||||
$log = true;
|
||||
|
@ -203,13 +218,7 @@ class dba {
|
|||
|
||||
$this->error = '';
|
||||
|
||||
// Check the connection (This can reconnect the connection - if configured)
|
||||
if ($this->mysqli) {
|
||||
$connected = $this->db->ping();
|
||||
} else {
|
||||
$connected = mysql_ping($this->db);
|
||||
}
|
||||
$connstr = ($connected ? "Connected" : "Disonnected");
|
||||
$connstr = ($this->connected() ? "Connected" : "Disonnected");
|
||||
|
||||
$stamp1 = microtime(true);
|
||||
|
||||
|
@ -219,10 +228,22 @@ class dba {
|
|||
$sql = "/*".$a->callstack()." */ ".$sql;
|
||||
}
|
||||
|
||||
if ($this->mysqli) {
|
||||
$result = @$this->db->query($sql);
|
||||
} else {
|
||||
$result = @mysql_query($sql,$this->db);
|
||||
$columns = 0;
|
||||
|
||||
switch ($this->driver) {
|
||||
case 'pdo':
|
||||
$result = @$this->db->query($sql);
|
||||
// Is used to separate between queries that returning data - or not
|
||||
if (!is_bool($result)) {
|
||||
$columns = $result->columnCount();
|
||||
}
|
||||
break;
|
||||
case 'mysqli':
|
||||
$result = @$this->db->query($sql);
|
||||
break;
|
||||
case 'mysql':
|
||||
$result = @mysql_query($sql,$this->db);
|
||||
break;
|
||||
}
|
||||
$stamp2 = microtime(true);
|
||||
$duration = (float)($stamp2-$stamp1);
|
||||
|
@ -243,16 +264,27 @@ class dba {
|
|||
}
|
||||
}
|
||||
|
||||
if ($this->mysqli) {
|
||||
if ($this->db->errno) {
|
||||
$this->error = $this->db->error;
|
||||
$this->errorno = $this->db->errno;
|
||||
}
|
||||
} elseif (mysql_errno($this->db)) {
|
||||
$this->error = mysql_error($this->db);
|
||||
$this->errorno = mysql_errno($this->db);
|
||||
switch ($this->driver) {
|
||||
case 'pdo':
|
||||
$errorInfo = $this->db->errorInfo();
|
||||
if ($errorInfo) {
|
||||
$this->error = $errorInfo[2];
|
||||
$this->errorno = $errorInfo[1];
|
||||
}
|
||||
break;
|
||||
case 'mysqli':
|
||||
if ($this->db->errno) {
|
||||
$this->error = $this->db->error;
|
||||
$this->errorno = $this->db->errno;
|
||||
}
|
||||
break;
|
||||
case 'mysql':
|
||||
if (mysql_errno($this->db)) {
|
||||
$this->error = mysql_error($this->db);
|
||||
$this->errorno = mysql_errno($this->db);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (strlen($this->error)) {
|
||||
logger('DB Error ('.$connstr.') '.$this->errorno.': '.$this->error);
|
||||
}
|
||||
|
@ -266,10 +298,16 @@ class dba {
|
|||
} elseif ($result === true) {
|
||||
$mesg = 'true';
|
||||
} else {
|
||||
if ($this->mysqli) {
|
||||
$mesg = $result->num_rows . ' results' . EOL;
|
||||
} else {
|
||||
$mesg = mysql_num_rows($result) . ' results' . EOL;
|
||||
switch ($this->driver) {
|
||||
case 'pdo':
|
||||
$mesg = $result->rowCount().' results'.EOL;
|
||||
break;
|
||||
case 'mysqli':
|
||||
$mesg = $result->num_rows.' results'.EOL;
|
||||
break;
|
||||
case 'mysql':
|
||||
$mesg = mysql_num_rows($result).' results'.EOL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -293,7 +331,7 @@ class dba {
|
|||
}
|
||||
}
|
||||
|
||||
if (($result === true) || ($result === false)) {
|
||||
if (is_bool($result)) {
|
||||
return $result;
|
||||
}
|
||||
if ($onlyquery) {
|
||||
|
@ -302,18 +340,32 @@ class dba {
|
|||
}
|
||||
|
||||
$r = array();
|
||||
if ($this->mysqli) {
|
||||
if ($result->num_rows) {
|
||||
while($x = $result->fetch_array(MYSQLI_ASSOC))
|
||||
switch ($this->driver) {
|
||||
case 'pdo':
|
||||
while ($x = $result->fetch(PDO::FETCH_ASSOC)) {
|
||||
$r[] = $x;
|
||||
}
|
||||
$result->closeCursor();
|
||||
break;
|
||||
case 'mysqli':
|
||||
while ($x = $result->fetch_array(MYSQLI_ASSOC)) {
|
||||
$r[] = $x;
|
||||
}
|
||||
$result->free_result();
|
||||
}
|
||||
} else {
|
||||
if (mysql_num_rows($result)) {
|
||||
while($x = mysql_fetch_array($result, MYSQL_ASSOC))
|
||||
break;
|
||||
case 'mysql':
|
||||
while ($x = mysql_fetch_array($result, MYSQL_ASSOC)) {
|
||||
$r[] = $x;
|
||||
}
|
||||
mysql_free_result($result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// PDO doesn't return "true" on successful operations - like mysqli does
|
||||
// Emulate this behaviour by checking if the query returned data and had columns
|
||||
// This should be reliable enough
|
||||
if (($this->driver == 'pdo') AND (count($r) == 0) AND ($columns == 0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//$a->save_timestamp($stamp1, "database");
|
||||
|
@ -328,12 +380,16 @@ class dba {
|
|||
$x = false;
|
||||
|
||||
if ($this->result) {
|
||||
if ($this->mysqli) {
|
||||
if ($this->result->num_rows)
|
||||
switch ($this->driver) {
|
||||
case 'pdo':
|
||||
$x = $this->result->fetch(PDO::FETCH_ASSOC);
|
||||
break;
|
||||
case 'mysqli':
|
||||
$x = $this->result->fetch_array(MYSQLI_ASSOC);
|
||||
} else {
|
||||
if (mysql_num_rows($this->result))
|
||||
break;
|
||||
case 'mysql':
|
||||
$x = mysql_fetch_array($this->result, MYSQL_ASSOC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return($x);
|
||||
|
@ -341,10 +397,16 @@ class dba {
|
|||
|
||||
public function qclose() {
|
||||
if ($this->result) {
|
||||
if ($this->mysqli) {
|
||||
$this->result->free_result();
|
||||
} else {
|
||||
mysql_free_result($this->result);
|
||||
switch ($this->driver) {
|
||||
case 'pdo':
|
||||
$this->result->closeCursor();
|
||||
break;
|
||||
case 'mysqli':
|
||||
$this->result->free_result();
|
||||
break;
|
||||
case 'mysql':
|
||||
mysql_free_result($this->result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -355,35 +417,65 @@ class dba {
|
|||
|
||||
public function escape($str) {
|
||||
if ($this->db && $this->connected) {
|
||||
if ($this->mysqli) {
|
||||
return @$this->db->real_escape_string($str);
|
||||
} else {
|
||||
return @mysql_real_escape_string($str,$this->db);
|
||||
switch ($this->driver) {
|
||||
case 'pdo':
|
||||
return substr(@$this->db->quote($str, PDO::PARAM_STR), 1, -1);
|
||||
case 'mysqli':
|
||||
return @$this->db->real_escape_string($str);
|
||||
case 'mysql':
|
||||
return @mysql_real_escape_string($str,$this->db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function connected() {
|
||||
if ($this->mysqli) {
|
||||
$connected = $this->db->ping();
|
||||
} else {
|
||||
$connected = mysql_ping($this->db);
|
||||
switch ($this->driver) {
|
||||
case 'pdo':
|
||||
// Not sure if this really is working like expected
|
||||
$connected = ($this->db->getAttribute(PDO::ATTR_CONNECTION_STATUS) != "");
|
||||
break;
|
||||
case 'mysqli':
|
||||
$connected = $this->db->ping();
|
||||
break;
|
||||
case 'mysql':
|
||||
$connected = mysql_ping($this->db);
|
||||
break;
|
||||
}
|
||||
return $connected;
|
||||
}
|
||||
|
||||
function insert_id() {
|
||||
switch ($this->driver) {
|
||||
case 'pdo':
|
||||
$id = $this->db->lastInsertId();
|
||||
break;
|
||||
case 'mysqli':
|
||||
$id = $this->db->insert_id;
|
||||
break;
|
||||
case 'mysql':
|
||||
$id = mysql_insert_id($this->db);
|
||||
break;
|
||||
}
|
||||
return $id;
|
||||
}
|
||||
|
||||
function __destruct() {
|
||||
if ($this->db) {
|
||||
if ($this->mysqli) {
|
||||
$this->db->close();
|
||||
} else {
|
||||
mysql_close($this->db);
|
||||
switch ($this->driver) {
|
||||
case 'pdo':
|
||||
$this->db = null;
|
||||
break;
|
||||
case 'mysqli':
|
||||
$this->db->close();
|
||||
break;
|
||||
case 'mysql':
|
||||
mysql_close($this->db);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
if (! function_exists('printable')) {
|
||||
function printable($s) {
|
||||
$s = preg_replace("~([\x01-\x08\x0E-\x0F\x10-\x1F\x7F-\xFF])~",".", $s);
|
||||
$s = str_replace("\x00",'.',$s);
|
||||
|
@ -391,37 +483,32 @@ function printable($s) {
|
|||
$s = escape_tags($s);
|
||||
}
|
||||
return $s;
|
||||
}}
|
||||
}
|
||||
|
||||
// Procedural functions
|
||||
if (! function_exists('dbg')) {
|
||||
function dbg($state) {
|
||||
global $db;
|
||||
|
||||
if ($db) {
|
||||
$db->dbg($state);
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
if (! function_exists('dbesc')) {
|
||||
function dbesc($str) {
|
||||
global $db;
|
||||
|
||||
if ($db && $db->connected) {
|
||||
return($db->escape($str));
|
||||
} else {
|
||||
return(str_replace("'","\\'",$str));
|
||||
}
|
||||
}}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Function: q($sql,$args);
|
||||
// Description: execute SQL query with printf style args.
|
||||
// Example: $r = q("SELECT * FROM `%s` WHERE `uid` = %d",
|
||||
// 'user', 1);
|
||||
|
||||
if (! function_exists('q')) {
|
||||
function q($sql) {
|
||||
|
||||
global $db;
|
||||
$args = func_get_args();
|
||||
unset($args[0]);
|
||||
|
@ -445,8 +532,7 @@ function q($sql) {
|
|||
*/
|
||||
logger('dba: no database: ' . print_r($args,true));
|
||||
return false;
|
||||
|
||||
}}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Performs a query with "dirty reads"
|
||||
|
@ -458,8 +544,8 @@ function q($sql) {
|
|||
* @return array Query array
|
||||
*/
|
||||
function qu($sql) {
|
||||
|
||||
global $db;
|
||||
|
||||
$args = func_get_args();
|
||||
unset($args[0]);
|
||||
|
||||
|
@ -484,7 +570,6 @@ function qu($sql) {
|
|||
*/
|
||||
logger('dba: no database: ' . print_r($args,true));
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -492,40 +577,31 @@ function qu($sql) {
|
|||
* Raw db query, no arguments
|
||||
*
|
||||
*/
|
||||
|
||||
if (! function_exists('dbq')) {
|
||||
function dbq($sql) {
|
||||
|
||||
global $db;
|
||||
|
||||
if ($db && $db->connected) {
|
||||
$ret = $db->q($sql);
|
||||
} else {
|
||||
$ret = false;
|
||||
}
|
||||
return $ret;
|
||||
}}
|
||||
|
||||
}
|
||||
|
||||
// Caller is responsible for ensuring that any integer arguments to
|
||||
// dbesc_array are actually integers and not malformed strings containing
|
||||
// SQL injection vectors. All integer array elements should be specifically
|
||||
// cast to int to avoid trouble.
|
||||
|
||||
|
||||
if (! function_exists('dbesc_array_cb')) {
|
||||
function dbesc_array_cb(&$item, $key) {
|
||||
if (is_string($item))
|
||||
$item = dbesc($item);
|
||||
}}
|
||||
}
|
||||
|
||||
|
||||
if (! function_exists('dbesc_array')) {
|
||||
function dbesc_array(&$arr) {
|
||||
if (is_array($arr) && count($arr)) {
|
||||
array_walk($arr,'dbesc_array_cb');
|
||||
}
|
||||
}}
|
||||
|
||||
}
|
||||
|
||||
function dba_timer() {
|
||||
return microtime(true);
|
||||
|
|
|
@ -5,26 +5,8 @@
|
|||
*/
|
||||
|
||||
use \Friendica\Core\Config;
|
||||
use \Friendica\Core\PConfig;
|
||||
|
||||
require_once("boot.php");
|
||||
|
||||
function dbclean_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);
|
||||
}
|
||||
|
||||
Config::load();
|
||||
|
||||
if (!Config::get('system', 'dbclean', false)) {
|
||||
return;
|
||||
}
|
||||
|
@ -35,7 +17,7 @@ function dbclean_run(&$argv, &$argc) {
|
|||
$stage = 0;
|
||||
}
|
||||
|
||||
if (Config::get("system", "worker") AND ($stage == 0)) {
|
||||
if ($stage == 0) {
|
||||
proc_run(PRIORITY_LOW, 'include/dbclean.php', 1);
|
||||
proc_run(PRIORITY_LOW, 'include/dbclean.php', 2);
|
||||
proc_run(PRIORITY_LOW, 'include/dbclean.php', 3);
|
||||
|
@ -56,12 +38,8 @@ function remove_orphans($stage = 0) {
|
|||
|
||||
$count = 0;
|
||||
|
||||
// With activated worker we split the deletion in many small tasks
|
||||
if (Config::get("system", "worker")) {
|
||||
$limit = 1000;
|
||||
} else {
|
||||
$limit = 10000;
|
||||
}
|
||||
// We split the deletion in many small tasks
|
||||
$limit = 1000;
|
||||
|
||||
if (($stage == 1) OR ($stage == 0)) {
|
||||
logger("Deleting old global item entries from item table without user copy");
|
||||
|
@ -159,14 +137,9 @@ function remove_orphans($stage = 0) {
|
|||
}
|
||||
|
||||
// Call it again if not all entries were purged
|
||||
if (($stage != 0) AND ($count > 0) AND Config::get("system", "worker")) {
|
||||
if (($stage != 0) AND ($count > 0)) {
|
||||
proc_run(PRIORITY_MEDIUM, 'include/dbclean.php');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (array_search(__file__,get_included_files())===0){
|
||||
dbclean_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||
killme();
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -96,17 +96,10 @@ class dbm {
|
|||
public static function date($date = 'now') {
|
||||
$timestamp = strtotime($date);
|
||||
|
||||
// Workaround for 3.5.1
|
||||
if ($timestamp < -62135596800) {
|
||||
return '0000-00-00 00:00:00';
|
||||
}
|
||||
|
||||
// The above will be removed in 3.5.2
|
||||
// The following will then be enabled
|
||||
// Don't allow lower date strings as '0001-01-01 00:00:00'
|
||||
//if ($timestamp < -62135596800) {
|
||||
// $timestamp = -62135596800;
|
||||
//}
|
||||
if ($timestamp < -62135596800) {
|
||||
$timestamp = -62135596800;
|
||||
}
|
||||
|
||||
return date('Y-m-d H:i:s', $timestamp);
|
||||
}
|
||||
|
|
|
@ -144,7 +144,8 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
|
|||
global $a, $db;
|
||||
|
||||
if ($action) {
|
||||
set_config('system', 'maintenance', 1);
|
||||
Config::set('system', 'maintenance', 1);
|
||||
Config::set('system', 'maintenance_reason', 'Database update');
|
||||
}
|
||||
|
||||
if (isset($a->config["system"]["db_charset"])) {
|
||||
|
@ -361,8 +362,10 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
|
|||
}
|
||||
}
|
||||
|
||||
if ($action)
|
||||
set_config('system', 'maintenance', 0);
|
||||
if ($action) {
|
||||
Config::set('system', 'maintenance', 0);
|
||||
Config::set('system', 'maintenance_reason', '');
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
@ -536,8 +539,8 @@ function db_definition($charset) {
|
|||
"filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
|
||||
"filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
"data" => array("type" => "longblob", "not null" => "1"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"allow_cid" => array("type" => "mediumtext"),
|
||||
"allow_gid" => array("type" => "mediumtext"),
|
||||
"deny_cid" => array("type" => "mediumtext"),
|
||||
|
@ -564,7 +567,7 @@ function db_definition($charset) {
|
|||
"k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
|
||||
"v" => array("type" => "mediumtext"),
|
||||
"expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
"updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
),
|
||||
"indexes" => array(
|
||||
"PRIMARY" => array("k"),
|
||||
|
@ -613,7 +616,7 @@ function db_definition($charset) {
|
|||
"fields" => array(
|
||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
"remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
"rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
|
@ -651,14 +654,14 @@ function db_definition($charset) {
|
|||
"usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
"subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
"hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"last-update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"success_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"failure_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"name-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"last-item" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"last-update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"success_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"failure_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"name-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"uri-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"avatar-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"term-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"last-item" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
|
||||
"blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
|
||||
"readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
|
@ -703,8 +706,8 @@ function db_definition($charset) {
|
|||
"recips" => array("type" => "text"),
|
||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
"creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"subject" => array("type" => "text"),
|
||||
),
|
||||
"indexes" => array(
|
||||
|
@ -712,18 +715,6 @@ function db_definition($charset) {
|
|||
"uid" => array("uid"),
|
||||
)
|
||||
);
|
||||
$database["deliverq"] = array(
|
||||
"fields" => array(
|
||||
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||
"cmd" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
|
||||
"item" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
"contact" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
),
|
||||
"indexes" => array(
|
||||
"PRIMARY" => array("id"),
|
||||
"cmd_item_contact" => array("UNIQUE", "cmd", "item", "contact"),
|
||||
)
|
||||
);
|
||||
$database["event"] = array(
|
||||
"fields" => array(
|
||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||
|
@ -731,10 +722,10 @@ function db_definition($charset) {
|
|||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
"cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
"uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"start" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"finish" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"start" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"finish" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"summary" => array("type" => "text"),
|
||||
"desc" => array("type" => "text"),
|
||||
"location" => array("type" => "text"),
|
||||
|
@ -770,7 +761,7 @@ function db_definition($charset) {
|
|||
"network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
|
||||
"alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"pubkey" => array("type" => "text"),
|
||||
"updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
),
|
||||
"indexes" => array(
|
||||
"PRIMARY" => array("id"),
|
||||
|
@ -811,7 +802,7 @@ function db_definition($charset) {
|
|||
"request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"note" => array("type" => "text"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
),
|
||||
"indexes" => array(
|
||||
"PRIMARY" => array("id"),
|
||||
|
@ -838,10 +829,10 @@ function db_definition($charset) {
|
|||
"nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
|
||||
"last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
|
||||
"last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"updated" => array("type" => "datetime", "default" => NULL_DATE),
|
||||
"last_contact" => array("type" => "datetime", "default" => NULL_DATE),
|
||||
"last_failure" => array("type" => "datetime", "default" => NULL_DATE),
|
||||
"location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"about" => array("type" => "text"),
|
||||
"keywords" => array("type" => "text"),
|
||||
|
@ -875,7 +866,7 @@ function db_definition($charset) {
|
|||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
"gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
"zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
"updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
),
|
||||
"indexes" => array(
|
||||
"PRIMARY" => array("id"),
|
||||
|
@ -923,10 +914,10 @@ function db_definition($charset) {
|
|||
"noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
|
||||
"platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"last_poco_query" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
|
||||
"last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
|
||||
"last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"last_poco_query" => array("type" => "datetime", "default" => NULL_DATE),
|
||||
"last_contact" => array("type" => "datetime", "default" => NULL_DATE),
|
||||
"last_failure" => array("type" => "datetime", "default" => NULL_DATE),
|
||||
),
|
||||
"indexes" => array(
|
||||
"PRIMARY" => array("id"),
|
||||
|
@ -956,7 +947,7 @@ function db_definition($charset) {
|
|||
"duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
"note" => array("type" => "text"),
|
||||
"hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"datetime" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
|
||||
"ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
),
|
||||
|
@ -979,11 +970,11 @@ function db_definition($charset) {
|
|||
"parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
"owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
|
@ -1082,7 +1073,7 @@ function db_definition($charset) {
|
|||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||
"name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
|
||||
"locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
"created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
|
||||
"created" => array("type" => "datetime", "default" => NULL_DATE),
|
||||
),
|
||||
"indexes" => array(
|
||||
"PRIMARY" => array("id"),
|
||||
|
@ -1106,7 +1097,7 @@ function db_definition($charset) {
|
|||
"unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
"uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
),
|
||||
"indexes" => array(
|
||||
"PRIMARY" => array("id"),
|
||||
|
@ -1130,7 +1121,7 @@ function db_definition($charset) {
|
|||
"action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
"movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
"last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"last_check" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
),
|
||||
"indexes" => array(
|
||||
"PRIMARY" => array("id"),
|
||||
|
@ -1155,7 +1146,7 @@ function db_definition($charset) {
|
|||
"name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"msg" => array("type" => "mediumtext"),
|
||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
"link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
|
@ -1191,7 +1182,7 @@ function db_definition($charset) {
|
|||
"fields" => array(
|
||||
"url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
|
||||
"content" => array("type" => "mediumtext"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
),
|
||||
"indexes" => array(
|
||||
"PRIMARY" => array("url"),
|
||||
|
@ -1204,7 +1195,7 @@ function db_definition($charset) {
|
|||
"guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
|
||||
"oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
|
||||
"content" => array("type" => "mediumtext"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
),
|
||||
"indexes" => array(
|
||||
"PRIMARY" => array("url", "guessing", "oembed"),
|
||||
|
@ -1231,8 +1222,8 @@ function db_definition($charset) {
|
|||
"contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
||||
"guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
|
||||
"resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"desc" => array("type" => "text"),
|
||||
"album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
|
@ -1294,7 +1285,7 @@ function db_definition($charset) {
|
|||
"fields" => array(
|
||||
"pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
|
||||
"command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
),
|
||||
"indexes" => array(
|
||||
"PRIMARY" => array("pid"),
|
||||
|
@ -1320,7 +1311,7 @@ function db_definition($charset) {
|
|||
"gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
|
||||
"marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"with" => array("type" => "text"),
|
||||
"howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"howlong" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
|
@ -1372,7 +1363,7 @@ function db_definition($charset) {
|
|||
"topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
"last_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"last_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
),
|
||||
"indexes" => array(
|
||||
|
@ -1384,8 +1375,8 @@ function db_definition($charset) {
|
|||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||
"cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
"network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"last" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"last" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"content" => array("type" => "mediumtext"),
|
||||
"batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
),
|
||||
|
@ -1402,7 +1393,7 @@ function db_definition($charset) {
|
|||
"fields" => array(
|
||||
"id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||
"hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
|
||||
"password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
|
||||
|
@ -1456,7 +1447,7 @@ function db_definition($charset) {
|
|||
"spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
"ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
"term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
),
|
||||
"indexes" => array(
|
||||
"PRIMARY" => array("id"),
|
||||
|
@ -1475,8 +1466,8 @@ function db_definition($charset) {
|
|||
"term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
"aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
||||
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
||||
|
@ -1497,11 +1488,11 @@ function db_definition($charset) {
|
|||
"gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
|
||||
"owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
|
||||
"author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
"private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
"pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
|
@ -1553,8 +1544,8 @@ function db_definition($charset) {
|
|||
"openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
|
||||
"language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
|
||||
"register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"register_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"login_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
"theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
|
@ -1578,8 +1569,8 @@ function db_definition($charset) {
|
|||
"expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
|
||||
"account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
"account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
"account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
|
||||
"def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
"allow_cid" => array("type" => "mediumtext"),
|
||||
|
@ -1608,9 +1599,9 @@ function db_definition($charset) {
|
|||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||
"parameter" => array("type" => "text"),
|
||||
"priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
"pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
"executed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||
"executed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
),
|
||||
"indexes" => array(
|
||||
"PRIMARY" => array("id"),
|
||||
|
|
|
@ -2,32 +2,12 @@
|
|||
|
||||
use \Friendica\Core\Config;
|
||||
|
||||
require_once("boot.php");
|
||||
|
||||
function dbupdate_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);
|
||||
}
|
||||
|
||||
Config::load();
|
||||
global $a;
|
||||
|
||||
// We are deleting the latest dbupdate entry.
|
||||
// This is done to avoid endless loops because the update was interupted.
|
||||
Config::delete('database','dbupdate_'.DB_UPDATE_VERSION);
|
||||
Config::delete('database', 'dbupdate_'.DB_UPDATE_VERSION);
|
||||
|
||||
update_db($a);
|
||||
}
|
||||
|
||||
if (array_search(__file__,get_included_files())===0){
|
||||
dbupdate_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||
killme();
|
||||
}
|
||||
|
|
|
@ -2,44 +2,25 @@
|
|||
|
||||
use \Friendica\Core\Config;
|
||||
|
||||
require_once("boot.php");
|
||||
require_once('include/queue_fn.php');
|
||||
require_once('include/html2plain.php');
|
||||
require_once("include/Scrape.php");
|
||||
require_once('include/Scrape.php');
|
||||
require_once('include/diaspora.php');
|
||||
require_once("include/ostatus.php");
|
||||
require_once("include/dfrn.php");
|
||||
require_once('include/ostatus.php');
|
||||
require_once('include/dfrn.php');
|
||||
|
||||
function delivery_run(&$argv, &$argc){
|
||||
global $a, $db;
|
||||
global $a;
|
||||
|
||||
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/datetime.php');
|
||||
require_once('include/items.php');
|
||||
require_once('include/bbcode.php');
|
||||
require_once('include/email.php');
|
||||
|
||||
Config::load();
|
||||
|
||||
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];
|
||||
|
@ -49,30 +30,6 @@ function delivery_run(&$argv, &$argc){
|
|||
|
||||
$contact_id = intval($argv[$x]);
|
||||
|
||||
/// @todo When switching completely to the worker we won't need this anymore
|
||||
// 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 (!dbm::is_result($r)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($a->maxload_reached()) {
|
||||
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;
|
||||
}
|
||||
|
@ -577,8 +534,3 @@ function delivery_run(&$argv, &$argc){
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
if (array_search(__file__,get_included_files())===0){
|
||||
delivery_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||
killme();
|
||||
}
|
||||
|
|
|
@ -1094,7 +1094,7 @@ class dfrn {
|
|||
return 3;
|
||||
}
|
||||
|
||||
if($contact['term-date'] != '0000-00-00 00:00:00') {
|
||||
if ($contact['term-date'] > NULL_DATE) {
|
||||
logger("dfrn_deliver: $url back from the dead - removing mark for death");
|
||||
require_once('include/Contact.php');
|
||||
unmark_for_death($contact);
|
||||
|
|
|
@ -1,36 +1,16 @@
|
|||
<?php
|
||||
require_once("boot.php");
|
||||
|
||||
use \Friendica\Core\Config;
|
||||
|
||||
function directory_run(&$argv, &$argc){
|
||||
global $a, $db;
|
||||
|
||||
if(is_null($a)) {
|
||||
$a = new App;
|
||||
if ($argc != 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
};
|
||||
$dir = get_config('system', 'directory');
|
||||
|
||||
Config::load();
|
||||
|
||||
if($argc != 2)
|
||||
return;
|
||||
|
||||
load_hooks();
|
||||
|
||||
|
||||
$a->set_baseurl(get_config('system','url'));
|
||||
|
||||
$dir = get_config('system','directory');
|
||||
|
||||
if(! strlen($dir))
|
||||
if (!strlen($dir)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$dir .= "/submit";
|
||||
|
||||
|
@ -39,13 +19,8 @@ function directory_run(&$argv, &$argc){
|
|||
call_hooks('globaldir_update', $arr);
|
||||
|
||||
logger('Updating directory: ' . $arr['url'], LOGGER_DEBUG);
|
||||
if(strlen($arr['url']))
|
||||
if (strlen($arr['url'])) {
|
||||
fetch_url($dir . '?url=' . bin2hex($arr['url']));
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (array_search(__file__,get_included_files())===0){
|
||||
directory_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||
killme();
|
||||
}
|
||||
|
|
|
@ -2,62 +2,64 @@
|
|||
|
||||
use \Friendica\Core\Config;
|
||||
|
||||
require_once("boot.php");
|
||||
require_once("include/socgraph.php");
|
||||
require_once('include/socgraph.php');
|
||||
require_once('include/datetime.php');
|
||||
|
||||
function discover_poco_run(&$argv, &$argc){
|
||||
global $a, $db;
|
||||
function discover_poco_run(&$argv, &$argc) {
|
||||
|
||||
if(is_null($a)) {
|
||||
$a = new App;
|
||||
}
|
||||
/*
|
||||
This function can be called in these ways:
|
||||
- dirsearch <search pattern>: Searches for "search pattern" in the directory. "search pattern" is url encoded.
|
||||
- checkcontact: Updates gcontact entries
|
||||
- suggestions: Discover other servers for their contacts.
|
||||
- server <poco url>: Searches for the poco server list. "poco url" is base64 encoded.
|
||||
- update_server: Frequently check the first 250 servers for vitality.
|
||||
*/
|
||||
|
||||
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');
|
||||
|
||||
Config::load();
|
||||
|
||||
// Don't check this stuff if the function is called by the poller
|
||||
if (App::callstack() != "poller_run")
|
||||
if ($a->maxload_reached())
|
||||
return;
|
||||
|
||||
if(($argc > 2) && ($argv[1] == "dirsearch")) {
|
||||
if (($argc > 2) && ($argv[1] == "dirsearch")) {
|
||||
$search = urldecode($argv[2]);
|
||||
$mode = 1;
|
||||
} elseif(($argc == 2) && ($argv[1] == "checkcontact")) {
|
||||
} elseif (($argc == 2) && ($argv[1] == "checkcontact")) {
|
||||
$mode = 2;
|
||||
} elseif(($argc == 2) && ($argv[1] == "suggestions")) {
|
||||
} elseif (($argc == 2) && ($argv[1] == "suggestions")) {
|
||||
$mode = 3;
|
||||
} elseif (($argc == 3) && ($argv[1] == "server")) {
|
||||
$mode = 4;
|
||||
} elseif (($argc == 2) && ($argv[1] == "update_server")) {
|
||||
$mode = 5;
|
||||
} elseif ($argc == 1) {
|
||||
$search = "";
|
||||
$mode = 0;
|
||||
} else
|
||||
} else {
|
||||
die("Unknown or missing parameter ".$argv[1]."\n");
|
||||
|
||||
// Don't check this stuff if the function is called by the poller
|
||||
if (App::callstack() != "poller_run")
|
||||
if (App::is_already_running('discover_poco'.$mode.urlencode($search), 'include/discover_poco.php', 1140))
|
||||
return;
|
||||
|
||||
$a->set_baseurl(get_config('system','url'));
|
||||
|
||||
load_hooks();
|
||||
}
|
||||
|
||||
logger('start '.$search);
|
||||
|
||||
if ($mode==3)
|
||||
if ($mode == 5) {
|
||||
update_server();
|
||||
} elseif ($mode == 4) {
|
||||
$server_url = base64_decode($argv[2]);
|
||||
if ($server_url == "") {
|
||||
return;
|
||||
}
|
||||
$server_url = filter_var($server_url, FILTER_SANITIZE_URL);
|
||||
if (substr(normalise_link($server_url), 0, 7) != "http://") {
|
||||
return;
|
||||
}
|
||||
$result = "Checking server ".$server_url." - ";
|
||||
$ret = poco_check_server($server_url);
|
||||
if ($ret) {
|
||||
$result .= "success";
|
||||
} else {
|
||||
$result .= "failed";
|
||||
}
|
||||
logger($result, LOGGER_DEBUG);
|
||||
} elseif ($mode == 3) {
|
||||
update_suggestions();
|
||||
elseif (($mode == 2) AND get_config('system','poco_completion'))
|
||||
} elseif (($mode == 2) AND get_config('system','poco_completion')) {
|
||||
discover_users();
|
||||
elseif (($mode == 1) AND ($search != "") and get_config('system','poco_local_search')) {
|
||||
} elseif (($mode == 1) AND ($search != "") and get_config('system','poco_local_search')) {
|
||||
discover_directory($search);
|
||||
gs_search_user($search);
|
||||
} elseif (($mode == 0) AND ($search == "") and (get_config('system','poco_discovery') > 0)) {
|
||||
|
@ -74,6 +76,33 @@ function discover_poco_run(&$argv, &$argc){
|
|||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Updates the first 250 servers
|
||||
*
|
||||
*/
|
||||
function update_server() {
|
||||
$r = q("SELECT `url`, `created`, `last_failure`, `last_contact` FROM `gserver` ORDER BY rand()");
|
||||
|
||||
if (!dbm::is_result($r)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$updated = 0;
|
||||
|
||||
foreach ($r AS $server) {
|
||||
if (!poco_do_update($server["created"], "", $server["last_failure"], $server["last_contact"])) {
|
||||
continue;
|
||||
}
|
||||
logger('Update server status for server '.$server["url"], LOGGER_DEBUG);
|
||||
|
||||
proc_run(PRIORITY_LOW, "include/discover_poco.php", "server", base64_encode($server["url"]));
|
||||
|
||||
if (++$updated > 250) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function discover_users() {
|
||||
logger("Discover users", LOGGER_DEBUG);
|
||||
|
||||
|
@ -84,9 +113,9 @@ function discover_users() {
|
|||
dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA),
|
||||
dbesc(NETWORK_OSTATUS), dbesc(NETWORK_FEED));
|
||||
|
||||
if (!$users)
|
||||
if (!$users) {
|
||||
return;
|
||||
|
||||
}
|
||||
$checked = 0;
|
||||
|
||||
foreach ($users AS $user) {
|
||||
|
@ -111,27 +140,29 @@ function discover_users() {
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($user["server_url"] != "")
|
||||
if ($user["server_url"] != "") {
|
||||
$server_url = $user["server_url"];
|
||||
else
|
||||
} else {
|
||||
$server_url = poco_detect_server($user["url"]);
|
||||
|
||||
}
|
||||
if (($server_url == "") OR poco_check_server($server_url, $gcontacts[0]["network"])) {
|
||||
logger('Check user '.$user["url"]);
|
||||
poco_last_updated($user["url"], true);
|
||||
|
||||
if (++$checked > 100)
|
||||
if (++$checked > 100) {
|
||||
return;
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `nurl` = '%s'",
|
||||
dbesc(datetime_convert()), dbesc(normalise_link($user["url"])));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function discover_directory($search) {
|
||||
|
||||
$data = Cache::get("dirsearch:".$search);
|
||||
if (!is_null($data)){
|
||||
if (!is_null($data)) {
|
||||
// Only search for the same item every 24 hours
|
||||
if (time() < $data + (60 * 60 * 24)) {
|
||||
logger("Already searched for ".$search." in the last 24 hours", LOGGER_DEBUG);
|
||||
|
@ -142,7 +173,7 @@ function discover_directory($search) {
|
|||
$x = fetch_url(get_server()."/lsearch?p=1&n=500&search=".urlencode($search));
|
||||
$j = json_decode($x);
|
||||
|
||||
if(count($j->results))
|
||||
if (count($j->results)) {
|
||||
foreach($j->results as $jj) {
|
||||
// Check if the contact already exists
|
||||
$exists = q("SELECT `id`, `last_contact`, `last_failure`, `updated` FROM `gcontact` WHERE `nurl` = '%s'", normalise_link($jj->url));
|
||||
|
@ -150,32 +181,33 @@ function discover_directory($search) {
|
|||
logger("Profile ".$jj->url." already exists (".$search.")", LOGGER_DEBUG);
|
||||
|
||||
if (($exists[0]["last_contact"] < $exists[0]["last_failure"]) AND
|
||||
($exists[0]["updated"] < $exists[0]["last_failure"]))
|
||||
($exists[0]["updated"] < $exists[0]["last_failure"])) {
|
||||
continue;
|
||||
|
||||
}
|
||||
// Update the contact
|
||||
poco_last_updated($jj->url);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Harcoded paths aren't so good. But in this case it is okay.
|
||||
// First: We only will get Friendica contacts (which always are using this url schema)
|
||||
// Second: There will be no further problems if we are doing a mistake
|
||||
$server_url = preg_replace("=(https?://)(.*)/profile/(.*)=ism", "$1$2", $jj->url);
|
||||
if ($server_url != $jj->url)
|
||||
$server_url = poco_detect_server($jj->url);
|
||||
if ($server_url != '') {
|
||||
if (!poco_check_server($server_url)) {
|
||||
logger("Friendica server ".$server_url." doesn't answer.", LOGGER_DEBUG);
|
||||
continue;
|
||||
}
|
||||
logger("Friendica server ".$server_url." seems to be okay.", LOGGER_DEBUG);
|
||||
logger("Friendica server ".$server_url." seems to be okay.", LOGGER_DEBUG);
|
||||
}
|
||||
|
||||
logger("Check if profile ".$jj->url." is reachable (".$search.")", LOGGER_DEBUG);
|
||||
$data = probe_url($jj->url);
|
||||
if ($data["network"] == NETWORK_DFRN) {
|
||||
logger("Profile ".$jj->url." is reachable (".$search.")", LOGGER_DEBUG);
|
||||
logger("Add profile ".$jj->url." to local directory (".$search.")", LOGGER_DEBUG);
|
||||
poco_check($data["url"], $data["name"], $data["network"], $data["photo"], "", "", "", $jj->tags, $data["addr"], "", 0);
|
||||
} else {
|
||||
logger("Profile ".$jj->url." is not responding or no Friendica contact - but network ".$data["network"], LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
}
|
||||
Cache::set("dirsearch:".$search, time(), CACHE_DAY);
|
||||
}
|
||||
|
||||
|
@ -195,14 +227,14 @@ function gs_search_user($search) {
|
|||
$url = "http://gstools.org/api/users_search/".urlencode($search);
|
||||
|
||||
$result = z_fetch_url($url);
|
||||
if (!$result["success"])
|
||||
if (!$result["success"]) {
|
||||
return false;
|
||||
|
||||
}
|
||||
$contacts = json_decode($result["body"]);
|
||||
|
||||
if ($contacts->status == 'ERROR')
|
||||
if ($contacts->status == 'ERROR') {
|
||||
return false;
|
||||
|
||||
}
|
||||
foreach($contacts->data AS $user) {
|
||||
$contact = probe_url($user->site_address."/".$user->name);
|
||||
if ($contact["network"] != NETWORK_PHANTOM) {
|
||||
|
@ -211,9 +243,3 @@ function gs_search_user($search) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (array_search(__file__,get_included_files())===0){
|
||||
discover_poco_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||
killme();
|
||||
}
|
||||
|
|
|
@ -2,32 +2,13 @@
|
|||
|
||||
use \Friendica\Core\Config;
|
||||
|
||||
require_once("boot.php");
|
||||
|
||||
function expire_run(&$argv, &$argc){
|
||||
global $a, $db;
|
||||
global $a;
|
||||
|
||||
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/Contact.php');
|
||||
|
||||
Config::load();
|
||||
|
||||
$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");
|
||||
|
@ -53,8 +34,3 @@ function expire_run(&$argv, &$argc){
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
if (array_search(__file__,get_included_files())===0){
|
||||
expire_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||
killme();
|
||||
}
|
||||
|
|
|
@ -2,36 +2,14 @@
|
|||
|
||||
use \Friendica\Core\Config;
|
||||
|
||||
require_once("boot.php");
|
||||
require_once('include/Scrape.php');
|
||||
require_once('include/socgraph.php');
|
||||
require_once('include/datetime.php');
|
||||
|
||||
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');
|
||||
|
||||
Config::load();
|
||||
|
||||
$a->set_baseurl(get_config('system','url'));
|
||||
|
||||
load_hooks();
|
||||
|
||||
if($argc != 2)
|
||||
if ($argc != 2) {
|
||||
return;
|
||||
|
||||
}
|
||||
$url = hex2bin($argv[1]);
|
||||
|
||||
$r = q("SELECT `id`, `url`, `network` FROM `gcontact` WHERE `nurl` = '%s' ORDER BY `id` LIMIT 1",
|
||||
|
@ -74,8 +52,3 @@ function gprobe_run(&$argv, &$argc){
|
|||
logger("gprobe end for ".normalise_link($url), LOGGER_DEBUG);
|
||||
return;
|
||||
}
|
||||
|
||||
if (array_search(__file__,get_included_files())===0){
|
||||
gprobe_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||
killme();
|
||||
}
|
||||
|
|
|
@ -652,7 +652,7 @@ function advanced_profile(App $a) {
|
|||
$profile['marital']['with'] = $a->profile['with'];
|
||||
}
|
||||
|
||||
if (strlen($a->profile['howlong']) && $a->profile['howlong'] !== '0000-00-00 00:00:00') {
|
||||
if (strlen($a->profile['howlong']) && $a->profile['howlong'] >= NULL_DATE) {
|
||||
$profile['howlong'] = relative_date($a->profile['howlong'], t('for %1$d %2$s'));
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,8 @@ function block_on_function_lock($fn_name, $wait_sec = 2, $timeout = 30) {
|
|||
|
||||
if(! function_exists('unlock_function')) {
|
||||
function unlock_function($fn_name) {
|
||||
$r = q("UPDATE `locks` SET `locked` = 0, `created` = '0000-00-00 00:00:00' WHERE `name` = '%s'",
|
||||
$r = q("UPDATE `locks` SET `locked` = 0, `created` = '%s' WHERE `name` = '%s'",
|
||||
dbesc(NULL_DATE),
|
||||
dbesc($fn_name)
|
||||
);
|
||||
|
||||
|
|
|
@ -72,8 +72,9 @@ function z_fetch_url($url,$binary = false, &$redirects = 0, $opts=array()) {
|
|||
$a = get_app();
|
||||
|
||||
$ch = @curl_init($url);
|
||||
if(($redirects > 8) || (! $ch))
|
||||
return false;
|
||||
if(($redirects > 8) || (! $ch)) {
|
||||
return $ret;
|
||||
}
|
||||
|
||||
@curl_setopt($ch, CURLOPT_HEADER, true);
|
||||
|
||||
|
|
|
@ -2,12 +2,11 @@
|
|||
|
||||
use \Friendica\Core\Config;
|
||||
|
||||
require_once("boot.php");
|
||||
require_once('include/queue_fn.php');
|
||||
require_once('include/html2plain.php');
|
||||
require_once("include/Scrape.php");
|
||||
require_once('include/Scrape.php');
|
||||
require_once('include/diaspora.php');
|
||||
require_once("include/ostatus.php");
|
||||
require_once('include/ostatus.php');
|
||||
require_once('include/salmon.php');
|
||||
|
||||
/*
|
||||
|
@ -44,35 +43,17 @@ require_once('include/salmon.php');
|
|||
|
||||
|
||||
function notifier_run(&$argv, &$argc){
|
||||
global $a, $db;
|
||||
global $a;
|
||||
|
||||
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/datetime.php');
|
||||
require_once('include/items.php');
|
||||
require_once('include/bbcode.php');
|
||||
require_once('include/email.php');
|
||||
|
||||
Config::load();
|
||||
|
||||
load_hooks();
|
||||
|
||||
if ($argc < 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
$a->set_baseurl(get_config('system','url'));
|
||||
|
||||
logger('notifier: invoked: ' . print_r($argv,true), LOGGER_DEBUG);
|
||||
|
||||
$cmd = $argv[1];
|
||||
|
@ -490,79 +471,22 @@ function notifier_run(&$argv, &$argc){
|
|||
if ($relocate) {
|
||||
$r = $recipients_relocate;
|
||||
} else {
|
||||
$r = q("SELECT * FROM `contact` WHERE `id` IN (%s) AND NOT `blocked` AND NOT `pending` AND NOT `archive`".$sql_extra,
|
||||
$r = q("SELECT `id`, `url`, `network`, `self` FROM `contact`
|
||||
WHERE `id` IN (%s) AND NOT `blocked` AND NOT `pending` AND NOT `archive`".$sql_extra,
|
||||
dbesc($recip_str)
|
||||
);
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
// delivery loop
|
||||
|
||||
if (dbm::is_result($r)) {
|
||||
foreach ($r as $contact) {
|
||||
if (!$contact['self']) {
|
||||
if (($contact['network'] === NETWORK_DIASPORA) && ($public_message)) {
|
||||
continue;
|
||||
}
|
||||
q("INSERT INTO `deliverq` (`cmd`,`item`,`contact`) VALUES ('%s', %d, %d)",
|
||||
dbesc($cmd),
|
||||
intval($item_id),
|
||||
intval($contact['id'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// This controls the number of deliveries to execute with each separate delivery process.
|
||||
// By default we'll perform one delivery per process. Assuming a hostile shared hosting
|
||||
// provider, this provides the greatest chance of deliveries if processes start getting
|
||||
// killed. We can also space them out with the delivery_interval to also help avoid them
|
||||
// getting whacked.
|
||||
|
||||
// If $deliveries_per_process > 1, we will chain this number of multiple deliveries
|
||||
// together into a single process. This will reduce the overall number of processes
|
||||
// spawned for each delivery, but they will run longer.
|
||||
|
||||
// When using the workerqueue, we don't need this functionality.
|
||||
|
||||
$deliveries_per_process = intval(get_config('system','delivery_batch_count'));
|
||||
if (($deliveries_per_process <= 0) OR get_config("system", "worker")) {
|
||||
$deliveries_per_process = 1;
|
||||
}
|
||||
|
||||
$this_batch = array();
|
||||
|
||||
for ($x = 0; $x < count($r); $x ++) {
|
||||
$contact = $r[$x];
|
||||
|
||||
if ($contact['self']) {
|
||||
continue;
|
||||
}
|
||||
logger("Deliver ".$target_item["guid"]." to ".$contact['url']." via network ".$contact['network'], LOGGER_DEBUG);
|
||||
|
||||
// potentially more than one recipient. Start a new process and space them out a bit.
|
||||
// we will deliver single recipient types of message and email recipients here.
|
||||
|
||||
$this_batch[] = $contact['id'];
|
||||
|
||||
if (count($this_batch) >= $deliveries_per_process) {
|
||||
proc_run(PRIORITY_HIGH,'include/delivery.php',$cmd,$item_id,$this_batch);
|
||||
$this_batch = array();
|
||||
if ($interval) {
|
||||
@time_sleep_until(microtime(true) + (float) $interval);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// be sure to pick up any stragglers
|
||||
if (count($this_batch)) {
|
||||
proc_run(PRIORITY_HIGH,'include/delivery.php',$cmd,$item_id,$this_batch);
|
||||
proc_run(PRIORITY_HIGH,'include/delivery.php', $cmd, $item_id, $contact['id']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -614,18 +538,6 @@ function notifier_run(&$argv, &$argc){
|
|||
if (dbm::is_result($r)) {
|
||||
logger('pubdeliver '.$target_item["guid"].': '.print_r($r,true), LOGGER_DEBUG);
|
||||
|
||||
// throw everything into the queue in case we get killed
|
||||
|
||||
foreach ($r as $rr) {
|
||||
if ((! $mail) && (! $fsuggest) && (! $followup)) {
|
||||
q("INSERT INTO `deliverq` (`cmd`,`item`,`contact`) VALUES ('%s', %d, %d)
|
||||
ON DUPLICATE KEY UPDATE `cmd` = '%s', `item` = %d, `contact` = %d",
|
||||
dbesc($cmd), intval($item_id), intval($rr['id']),
|
||||
dbesc($cmd), intval($item_id), intval($rr['id'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($r as $rr) {
|
||||
|
||||
// except for Diaspora batch jobs
|
||||
|
@ -639,9 +551,6 @@ function notifier_run(&$argv, &$argc){
|
|||
if ((! $mail) && (! $fsuggest) && (! $followup)) {
|
||||
logger('notifier: delivery agent: '.$rr['name'].' '.$rr['id'].' '.$rr['network'].' '.$target_item["guid"]);
|
||||
proc_run(PRIORITY_HIGH,'include/delivery.php',$cmd,$item_id,$rr['id']);
|
||||
if ($interval) {
|
||||
@time_sleep_until(microtime(true) + (float) $interval);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -694,9 +603,3 @@ function notifier_run(&$argv, &$argc){
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (array_search(__file__,get_included_files())===0){
|
||||
notifier_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||
killme();
|
||||
}
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
use \Friendica\Core\Config;
|
||||
|
||||
require_once("boot.php");
|
||||
require_once("include/follow.php");
|
||||
require_once('include/follow.php');
|
||||
|
||||
function RemoveReply($subject) {
|
||||
while (in_array(strtolower(substr($subject, 0, 3)), array("re:", "aw:")))
|
||||
|
@ -13,20 +12,8 @@ function RemoveReply($subject) {
|
|||
}
|
||||
|
||||
function onepoll_run(&$argv, &$argc){
|
||||
global $a, $db;
|
||||
global $a;
|
||||
|
||||
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/Contact.php');
|
||||
|
@ -34,12 +21,6 @@ function onepoll_run(&$argv, &$argc){
|
|||
require_once('include/socgraph.php');
|
||||
require_once('include/queue_fn.php');
|
||||
|
||||
Config::load();
|
||||
|
||||
$a->set_baseurl(get_config('system','url'));
|
||||
|
||||
load_hooks();
|
||||
|
||||
logger('onepoll: start');
|
||||
|
||||
$manual_id = 0;
|
||||
|
@ -61,13 +42,6 @@ function onepoll_run(&$argv, &$argc){
|
|||
return;
|
||||
}
|
||||
|
||||
// Don't check this stuff if the function is called by the poller
|
||||
if (App::callstack() != "poller_run") {
|
||||
if (App::is_already_running('onepoll'.$contact_id, '', 540)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$d = datetime_convert();
|
||||
|
||||
// Only poll from those with suitable relationships,
|
||||
|
@ -159,7 +133,7 @@ function onepoll_run(&$argv, &$argc){
|
|||
|
||||
logger("onepoll: poll: ({$contact['id']}) IMPORTER: {$importer['name']}, CONTACT: {$contact['name']}");
|
||||
|
||||
$last_update = (($contact['last-update'] === '0000-00-00 00:00:00')
|
||||
$last_update = (($contact['last-update'] <= NULL_DATE)
|
||||
? datetime_convert('UTC','UTC','now - 7 days', ATOM_TIME)
|
||||
: datetime_convert('UTC','UTC',$contact['last-update'], ATOM_TIME)
|
||||
);
|
||||
|
@ -265,7 +239,7 @@ function onepoll_run(&$argv, &$argc){
|
|||
intval($contact['id'])
|
||||
);
|
||||
mark_for_death($contact);
|
||||
} elseif ($contact['term-date'] != '0000-00-00 00:00:00') {
|
||||
} elseif ($contact['term-date'] > NULL_DATE) {
|
||||
logger("poller: $url back from the dead - removing mark for death");
|
||||
unmark_for_death($contact);
|
||||
}
|
||||
|
@ -697,8 +671,3 @@ function onepoll_run(&$argv, &$argc){
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
if (array_search(__file__,get_included_files())===0) {
|
||||
onepoll_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||
killme();
|
||||
}
|
||||
|
|
|
@ -35,6 +35,10 @@ function poller_run($argv, $argc){
|
|||
return;
|
||||
}
|
||||
|
||||
$a->set_baseurl(Config::get('system', 'url'));
|
||||
|
||||
load_hooks();
|
||||
|
||||
$a->start_process();
|
||||
|
||||
if (poller_max_connections_reached()) {
|
||||
|
@ -353,18 +357,18 @@ function poller_max_connections_reached() {
|
|||
*
|
||||
*/
|
||||
function poller_kill_stale_workers() {
|
||||
$r = q("SELECT `pid`, `executed`, `priority`, `parameter` FROM `workerqueue` WHERE `executed` != '0000-00-00 00:00:00'");
|
||||
$r = q("SELECT `pid`, `executed`, `priority`, `parameter` FROM `workerqueue` WHERE `executed` > '%s'", dbesc(NULL_DATE));
|
||||
|
||||
if (!dbm::is_result($r)) {
|
||||
// No processing here needed
|
||||
return;
|
||||
}
|
||||
|
||||
foreach($r AS $pid)
|
||||
if (!posix_kill($pid["pid"], 0))
|
||||
q("UPDATE `workerqueue` SET `executed` = '0000-00-00 00:00:00', `pid` = 0 WHERE `pid` = %d",
|
||||
intval($pid["pid"]));
|
||||
else {
|
||||
foreach ($r AS $pid) {
|
||||
if (!posix_kill($pid["pid"], 0)) {
|
||||
q("UPDATE `workerqueue` SET `executed` = '%s', `pid` = 0 WHERE `pid` = %d",
|
||||
dbesc(NULL_DATE), intval($pid["pid"]));
|
||||
} else {
|
||||
// Kill long running processes
|
||||
|
||||
// Check if the priority is in a valid range
|
||||
|
@ -387,14 +391,17 @@ function poller_kill_stale_workers() {
|
|||
// We killed the stale process.
|
||||
// To avoid a blocking situation we reschedule the process at the beginning of the queue.
|
||||
// Additionally we are lowering the priority.
|
||||
q("UPDATE `workerqueue` SET `executed` = '0000-00-00 00:00:00', `created` = '%s',
|
||||
q("UPDATE `workerqueue` SET `executed` = '%s', `created` = '%s',
|
||||
`priority` = %d, `pid` = 0 WHERE `pid` = %d",
|
||||
dbesc(NULL_DATE),
|
||||
dbesc(datetime_convert()),
|
||||
intval(PRIORITY_NEGLIGIBLE),
|
||||
intval($pid["pid"]));
|
||||
} else
|
||||
} else {
|
||||
logger("Worker process ".$pid["pid"]." (".implode(" ", $argv).") now runs for ".round($duration)." of ".$max_duration." allowed minutes. That's okay.", LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -421,15 +428,15 @@ function poller_too_much_workers() {
|
|||
$slope = $maxworkers / pow($maxsysload, $exponent);
|
||||
$queues = ceil($slope * pow(max(0, $maxsysload - $load), $exponent));
|
||||
|
||||
$s = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00'");
|
||||
$s = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE `executed` <= '%s'", dbesc(NULL_DATE));
|
||||
$entries = $s[0]["total"];
|
||||
|
||||
if (Config::get("system", "worker_fastlane", false) AND ($queues > 0) AND ($entries > 0) AND ($active >= $queues)) {
|
||||
$s = q("SELECT `priority` FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00' ORDER BY `priority` LIMIT 1");
|
||||
$s = q("SELECT `priority` FROM `workerqueue` WHERE `executed` <= '%s' ORDER BY `priority` LIMIT 1", dbesc(NULL_DATE));
|
||||
$top_priority = $s[0]["priority"];
|
||||
|
||||
$s = q("SELECT `id` FROM `workerqueue` WHERE `priority` <= %d AND `executed` != '0000-00-00 00:00:00' LIMIT 1",
|
||||
intval($top_priority));
|
||||
$s = q("SELECT `id` FROM `workerqueue` WHERE `priority` <= %d AND `executed` > '%s' LIMIT 1",
|
||||
intval($top_priority), dbesc(NULL_DATE));
|
||||
$high_running = dbm::is_result($s);
|
||||
|
||||
if (!$high_running AND ($top_priority > PRIORITY_UNDEFINED) AND ($top_priority < PRIORITY_NEGLIGIBLE)) {
|
||||
|
@ -464,7 +471,7 @@ function poller_too_much_workers() {
|
|||
// Are there fewer workers running as possible? Then fork a new one.
|
||||
if (!Config::get("system", "worker_dont_fork") AND ($queues > ($active + 1)) AND ($entries > 1)) {
|
||||
logger("Active workers: ".$active."/".$queues." Fork a new worker.", LOGGER_DEBUG);
|
||||
$args = array("php", "include/poller.php", "no_cron");
|
||||
$args = array("include/poller.php", "no_cron");
|
||||
$a = get_app();
|
||||
$a->proc_run($args);
|
||||
}
|
||||
|
@ -549,21 +556,25 @@ function poller_worker_process() {
|
|||
if (poller_passing_slow($highest_priority)) {
|
||||
// Are there waiting processes with a higher priority than the currently highest?
|
||||
$r = q("SELECT * FROM `workerqueue`
|
||||
WHERE `executed` = '0000-00-00 00:00:00' AND `priority` < %d
|
||||
ORDER BY `priority`, `created` LIMIT 1", dbesc($highest_priority));
|
||||
if (dbm::is_result($r))
|
||||
WHERE `executed` <= '%s' AND `priority` < %d
|
||||
ORDER BY `priority`, `created` LIMIT 1",
|
||||
dbesc(NULL_DATE),
|
||||
intval($highest_priority));
|
||||
if (dbm::is_result($r)) {
|
||||
return $r;
|
||||
|
||||
}
|
||||
// Give slower processes some processing time
|
||||
$r = q("SELECT * FROM `workerqueue`
|
||||
WHERE `executed` = '0000-00-00 00:00:00' AND `priority` > %d
|
||||
ORDER BY `priority`, `created` LIMIT 1", dbesc($highest_priority));
|
||||
WHERE `executed` <= '%s' AND `priority` > %d
|
||||
ORDER BY `priority`, `created` LIMIT 1",
|
||||
dbesc(NULL_DATE),
|
||||
intval($highest_priority));
|
||||
}
|
||||
|
||||
// If there is no result (or we shouldn't pass lower processes) we check without priority limit
|
||||
if (($highest_priority == 0) OR !dbm::is_result($r))
|
||||
$r = q("SELECT * FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00' ORDER BY `priority`, `created` LIMIT 1");
|
||||
|
||||
if (($highest_priority == 0) OR !dbm::is_result($r)) {
|
||||
$r = q("SELECT * FROM `workerqueue` WHERE `executed` <= '%s' ORDER BY `priority`, `created` LIMIT 1", dbesc(NULL_DATE));
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
|
@ -571,7 +582,7 @@ function poller_worker_process() {
|
|||
* @brief Call the front end worker
|
||||
*/
|
||||
function call_worker() {
|
||||
if (!Config::get("system", "frontend_worker") OR !Config::get("system", "worker")) {
|
||||
if (!Config::get("system", "frontend_worker")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -583,7 +594,7 @@ function call_worker() {
|
|||
* @brief Call the front end worker if there aren't any active
|
||||
*/
|
||||
function call_worker_if_idle() {
|
||||
if (!Config::get("system", "frontend_worker") OR !Config::get("system", "worker")) {
|
||||
if (!Config::get("system", "frontend_worker")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -610,7 +621,7 @@ function call_worker_if_idle() {
|
|||
|
||||
logger('Call poller', LOGGER_DEBUG);
|
||||
|
||||
$args = array("php", "include/poller.php", "no_cron");
|
||||
$args = array("include/poller.php", "no_cron");
|
||||
$a = get_app();
|
||||
$a->proc_run($args);
|
||||
return;
|
||||
|
|
|
@ -1,12 +1,31 @@
|
|||
<?php
|
||||
require_once("boot.php");
|
||||
require_once("include/ostatus.php");
|
||||
|
||||
use \Friendica\Core\Config;
|
||||
use \Friendica\Core\PConfig;
|
||||
|
||||
require_once('include/items.php');
|
||||
require_once('include/ostatus.php');
|
||||
|
||||
function pubsubpublish_run(&$argv, &$argc){
|
||||
|
||||
if ($argc > 1) {
|
||||
$pubsubpublish_id = intval($argv[1]);
|
||||
} else {
|
||||
// We'll push to each subscriber that has push > 0,
|
||||
// i.e. there has been an update (set in notifier.php).
|
||||
$r = q("SELECT `id`, `callback_url` FROM `push_subscriber` WHERE `push` > 0");
|
||||
|
||||
foreach ($r as $rr) {
|
||||
logger("Publish feed to ".$rr["callback_url"], LOGGER_DEBUG);
|
||||
proc_run(PRIORITY_HIGH, 'include/pubsubpublish.php', $rr["id"]);
|
||||
}
|
||||
}
|
||||
|
||||
handle_pubsubhubbub($pubsubpublish_id);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
function handle_pubsubhubbub($id) {
|
||||
global $a, $db;
|
||||
global $a;
|
||||
|
||||
$r = q("SELECT * FROM `push_subscriber` WHERE `id` = %d", intval($id));
|
||||
if (!$r)
|
||||
|
@ -54,70 +73,3 @@ function handle_pubsubhubbub($id) {
|
|||
intval($rr['id']));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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');
|
||||
|
||||
Config::load();
|
||||
|
||||
// Don't check this stuff if the function is called by the poller
|
||||
if (App::callstack() != "poller_run") {
|
||||
if (App::is_already_running("pubsubpublish", "include/pubsubpublish.php", 540)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$a->set_baseurl(get_config('system','url'));
|
||||
|
||||
load_hooks();
|
||||
|
||||
if ($argc > 1) {
|
||||
$pubsubpublish_id = intval($argv[1]);
|
||||
}
|
||||
else {
|
||||
// We'll push to each subscriber that has push > 0,
|
||||
// i.e. there has been an update (set in notifier.php).
|
||||
$r = q("SELECT `id`, `callback_url` FROM `push_subscriber` WHERE `push` > 0");
|
||||
|
||||
// Use the delivery interval that is also used for the notifier
|
||||
$interval = Config::get("system", "delivery_interval", 2);
|
||||
|
||||
// If we are using the worker we don't need a delivery interval
|
||||
if (get_config("system", "worker")) {
|
||||
$interval = false;
|
||||
}
|
||||
|
||||
foreach ($r as $rr) {
|
||||
logger("Publish feed to ".$rr["callback_url"], LOGGER_DEBUG);
|
||||
proc_run(PRIORITY_HIGH, 'include/pubsubpublish.php', $rr["id"]);
|
||||
|
||||
if($interval)
|
||||
@time_sleep_until(microtime(true) + (float) $interval);
|
||||
}
|
||||
}
|
||||
|
||||
handle_pubsubhubbub($pubsubpublish_id);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (array_search(__file__,get_included_files())===0){
|
||||
pubsubpublish_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||
killme();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,41 +2,16 @@
|
|||
|
||||
use \Friendica\Core\Config;
|
||||
|
||||
require_once("boot.php");
|
||||
require_once('include/queue_fn.php');
|
||||
require_once('include/dfrn.php');
|
||||
require_once("include/datetime.php");
|
||||
require_once('include/items.php');
|
||||
require_once('include/bbcode.php');
|
||||
require_once('include/socgraph.php');
|
||||
require_once('include/cache.php');
|
||||
|
||||
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/socgraph.php');
|
||||
|
||||
Config::load();
|
||||
|
||||
// Don't check this stuff if the function is called by the poller
|
||||
if (App::callstack() != "poller_run")
|
||||
if (App::is_already_running('queue', 'include/queue.php', 540))
|
||||
return;
|
||||
|
||||
$a->set_baseurl(get_config('system','url'));
|
||||
|
||||
load_hooks();
|
||||
global $a;
|
||||
|
||||
if ($argc > 1) {
|
||||
$queue_id = intval($argv[1]);
|
||||
|
@ -54,30 +29,13 @@ function queue_run(&$argv, &$argc){
|
|||
// Handling the pubsubhubbub requests
|
||||
proc_run(PRIORITY_HIGH,'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(PRIORITY_HIGH,'include/delivery.php',$rr['cmd'],$rr['item'],$rr['contact']);
|
||||
if ($interval) {
|
||||
time_sleep_until(microtime(true) + (float) $interval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$r = q("SELECT `queue`.*, `contact`.`name`, `contact`.`uid` FROM `queue`
|
||||
INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`
|
||||
WHERE `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);
|
||||
logger('Expired queue data: ' . $rr['content'], LOGGER_DATA);
|
||||
}
|
||||
q("DELETE FROM `queue` WHERE `created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
|
||||
}
|
||||
|
@ -86,158 +44,137 @@ function queue_run(&$argv, &$argc){
|
|||
// 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)) ORDER BY `cid`, `created`");
|
||||
} else {
|
||||
logger('queue: start for id '.$queue_id);
|
||||
|
||||
$r = q("SELECT `id` FROM `queue` WHERE `id` = %d LIMIT 1",
|
||||
intval($queue_id)
|
||||
);
|
||||
}
|
||||
call_hooks('queue_predeliver', $a, $r);
|
||||
|
||||
if (!$r){
|
||||
if (dbm::is_result($r)) {
|
||||
foreach ($r as $q_item) {
|
||||
logger('Call queue for id '.$q_item['id']);
|
||||
proc_run(PRIORITY_LOW, "include/queue.php", $q_item['id']);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$queue_id)
|
||||
call_hooks('queue_predeliver', $a, $r);
|
||||
|
||||
|
||||
// delivery loop
|
||||
// delivering
|
||||
|
||||
require_once('include/salmon.php');
|
||||
require_once('include/diaspora.php');
|
||||
|
||||
foreach($r as $q_item) {
|
||||
$r = q("SELECT * FROM `queue` WHERE `id` = %d LIMIT 1",
|
||||
intval($queue_id));
|
||||
|
||||
// queue_predeliver hooks may have changed the queue db details,
|
||||
// so check again if this entry still needs processing
|
||||
if (!dbm::is_result($r)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($queue_id) {
|
||||
$qi = q("SELECT * FROM `queue` WHERE `id` = %d LIMIT 1",
|
||||
intval($queue_id));
|
||||
} elseif (get_config("system", "worker")) {
|
||||
logger('Call queue for id '.$q_item['id']);
|
||||
proc_run(PRIORITY_LOW, "include/queue.php", $q_item['id']);
|
||||
continue;
|
||||
} else
|
||||
$qi = q("SELECT * FROM `queue` WHERE `id` = %d AND `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ",
|
||||
intval($q_item['id']));
|
||||
$q_item = $r[0];
|
||||
|
||||
if (!dbm::is_result($qi)) {
|
||||
continue;
|
||||
$c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
|
||||
intval($q_item['cid'])
|
||||
);
|
||||
|
||||
if (!dbm::is_result($c)) {
|
||||
remove_queue_item($q_item['id']);
|
||||
return;
|
||||
}
|
||||
|
||||
$dead = Cache::get($cachekey_deadguy.$c[0]['notify']);
|
||||
|
||||
if (!is_null($dead) AND $dead) {
|
||||
logger('queue: skipping known dead url: '.$c[0]['notify']);
|
||||
update_queue_time($q_item['id']);
|
||||
return;
|
||||
}
|
||||
|
||||
$server = poco_detect_server($c[0]['url']);
|
||||
|
||||
if ($server != "") {
|
||||
$vital = Cache::get($cachekey_server.$server);
|
||||
|
||||
if (is_null($vital)) {
|
||||
logger("Check server ".$server." (".$c[0]["network"].")");
|
||||
|
||||
$vital = poco_check_server($server, $c[0]["network"], true);
|
||||
Cache::set($cachekey_server.$server, $vital, CACHE_QUARTER_HOUR);
|
||||
}
|
||||
|
||||
|
||||
$c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
|
||||
intval($qi[0]['cid'])
|
||||
);
|
||||
if (! dbm::is_result($c)) {
|
||||
remove_queue_item($q_item['id']);
|
||||
continue;
|
||||
}
|
||||
|
||||
$dead = Cache::get($cachekey_deadguy.$c[0]['notify']);
|
||||
|
||||
if (!is_null($dead) AND $dead) {
|
||||
logger('queue: skipping known dead url: '.$c[0]['notify']);
|
||||
if (!is_null($vital) AND !$vital) {
|
||||
logger('queue: skipping dead server: '.$server);
|
||||
update_queue_time($q_item['id']);
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$server = poco_detect_server($c[0]['url']);
|
||||
$u = q("SELECT `user`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`
|
||||
FROM `user` WHERE `uid` = %d LIMIT 1",
|
||||
intval($c[0]['uid'])
|
||||
);
|
||||
if (!dbm::is_result($u)) {
|
||||
remove_queue_item($q_item['id']);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($server != "") {
|
||||
$vital = Cache::get($cachekey_server.$server);
|
||||
$data = $q_item['content'];
|
||||
$public = $q_item['batch'];
|
||||
$contact = $c[0];
|
||||
$owner = $u[0];
|
||||
|
||||
if (is_null($vital)) {
|
||||
logger("Check server ".$server." (".$c[0]["network"].")");
|
||||
$deliver_status = 0;
|
||||
|
||||
$vital = poco_check_server($server, $c[0]["network"], true);
|
||||
Cache::set($cachekey_server.$server, $vital, CACHE_QUARTER_HOUR);
|
||||
}
|
||||
switch ($contact['network']) {
|
||||
case NETWORK_DFRN:
|
||||
logger('queue: dfrndelivery: item '.$q_item['id'].' for '.$contact['name'].' <'.$contact['url'].'>');
|
||||
$deliver_status = dfrn::deliver($owner, $contact, $data);
|
||||
|
||||
if (!is_null($vital) AND !$vital) {
|
||||
logger('queue: skipping dead server: '.$server);
|
||||
if ($deliver_status == (-1)) {
|
||||
update_queue_time($q_item['id']);
|
||||
continue;
|
||||
Cache::set($cachekey_deadguy.$contact['notify'], true, CACHE_QUARTER_HOUR);
|
||||
} else {
|
||||
remove_queue_item($q_item['id']);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NETWORK_OSTATUS:
|
||||
if ($contact['notify']) {
|
||||
logger('queue: slapdelivery: item '.$q_item['id'].' for '.$contact['name'].' <'.$contact['url'].'>');
|
||||
$deliver_status = slapper($owner, $contact['notify'], $data);
|
||||
|
||||
$u = q("SELECT `user`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`
|
||||
FROM `user` WHERE `uid` = %d LIMIT 1",
|
||||
intval($c[0]['uid'])
|
||||
);
|
||||
if (! dbm::is_result($u)) {
|
||||
remove_queue_item($q_item['id']);
|
||||
continue;
|
||||
}
|
||||
|
||||
$data = $qi[0]['content'];
|
||||
$public = $qi[0]['batch'];
|
||||
$contact = $c[0];
|
||||
$owner = $u[0];
|
||||
|
||||
$deliver_status = 0;
|
||||
|
||||
switch($contact['network']) {
|
||||
case NETWORK_DFRN:
|
||||
logger('queue: dfrndelivery: item '.$q_item['id'].' for '.$contact['name'].' <'.$contact['url'].'>');
|
||||
$deliver_status = dfrn::deliver($owner,$contact,$data);
|
||||
|
||||
if ($deliver_status < 0) {
|
||||
if ($deliver_status == (-1)) {
|
||||
update_queue_time($q_item['id']);
|
||||
Cache::set($cachekey_deadguy.$contact['notify'], true, CACHE_QUARTER_HOUR);
|
||||
} else {
|
||||
remove_queue_item($q_item['id']);
|
||||
}
|
||||
break;
|
||||
case NETWORK_OSTATUS:
|
||||
if ($contact['notify']) {
|
||||
logger('queue: slapdelivery: item '.$q_item['id'].' for '.$contact['name'].' <'.$contact['url'].'>');
|
||||
$deliver_status = slapper($owner,$contact['notify'],$data);
|
||||
}
|
||||
break;
|
||||
case NETWORK_DIASPORA:
|
||||
if ($contact['notify']) {
|
||||
logger('queue: diaspora_delivery: item '.$q_item['id'].' for '.$contact['name'].' <'.$contact['url'].'>');
|
||||
$deliver_status = Diaspora::transmit($owner, $contact, $data, $public, true);
|
||||
|
||||
if ($deliver_status == (-1)) {
|
||||
update_queue_time($q_item['id']);
|
||||
Cache::set($cachekey_deadguy.$contact['notify'], true, CACHE_QUARTER_HOUR);
|
||||
} else {
|
||||
remove_queue_item($q_item['id']);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NETWORK_DIASPORA:
|
||||
if ($contact['notify']) {
|
||||
logger('queue: diaspora_delivery: item '.$q_item['id'].' for '.$contact['name'].' <'.$contact['url'].'>');
|
||||
$deliver_status = Diaspora::transmit($owner,$contact,$data,$public,true);
|
||||
|
||||
if ($deliver_status == (-1)) {
|
||||
update_queue_time($q_item['id']);
|
||||
Cache::set($cachekey_deadguy.$contact['notify'], true, CACHE_QUARTER_HOUR);
|
||||
} else {
|
||||
remove_queue_item($q_item['id']);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$params = array('owner' => $owner, 'contact' => $contact, 'queue' => $q_item, 'result' => false);
|
||||
call_hooks('queue_deliver', $a, $params);
|
||||
|
||||
if ($params['result']) {
|
||||
remove_queue_item($q_item['id']);
|
||||
} else {
|
||||
if ($deliver_status == (-1)) {
|
||||
update_queue_time($q_item['id']);
|
||||
Cache::set($cachekey_deadguy.$contact['notify'], true, CACHE_QUARTER_HOUR);
|
||||
} else {
|
||||
remove_queue_item($q_item['id']);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$params = array('owner' => $owner, 'contact' => $contact, 'queue' => $q_item, 'result' => false);
|
||||
call_hooks('queue_deliver', $a, $params);
|
||||
|
||||
if ($params['result']) {
|
||||
remove_queue_item($q_item['id']);
|
||||
} else {
|
||||
update_queue_time($q_item['id']);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
logger('Deliver status '.(int)$deliver_status.' for item '.$q_item['id'].' to '.$contact['name'].' <'.$contact['url'].'>');
|
||||
}
|
||||
logger('Deliver status '.(int)$deliver_status.' for item '.$q_item['id'].' to '.$contact['name'].' <'.$contact['url'].'>');
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (array_search(__file__,get_included_files())===0){
|
||||
queue_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||
killme();
|
||||
}
|
||||
|
|
|
@ -6,24 +6,7 @@
|
|||
|
||||
use \Friendica\Core\Config;
|
||||
|
||||
require_once("boot.php");
|
||||
|
||||
function remove_contact_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);
|
||||
}
|
||||
|
||||
Config::load();
|
||||
|
||||
if ($argc != 2) {
|
||||
return;
|
||||
}
|
||||
|
@ -46,9 +29,4 @@ function remove_contact_run($argv, $argc) {
|
|||
|
||||
q("DELETE FROM `queue` WHERE `cid` = %d", intval($id));
|
||||
}
|
||||
|
||||
if (array_search(__file__, get_included_files()) === 0) {
|
||||
remove_contact_run($_SERVER["argv"], $_SERVER["argc"]);
|
||||
killme();
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -55,7 +55,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
|
|||
$a->user = $user_record;
|
||||
|
||||
if($interactive) {
|
||||
if($a->user['login_date'] === '0000-00-00 00:00:00') {
|
||||
if ($a->user['login_date'] <= NULL_DATE) {
|
||||
$_SESSION['return_url'] = 'profile_photo/new';
|
||||
$a->module = 'profile_photo';
|
||||
info( t("Welcome ") . $a->user['username'] . EOL);
|
||||
|
|
|
@ -5,20 +5,26 @@ use \Friendica\Core\Config;
|
|||
require_once("boot.php");
|
||||
require_once("include/threads.php");
|
||||
|
||||
global $a, $db;
|
||||
function shadowupdate_run(&$argv, &$argc){
|
||||
global $a, $db;
|
||||
|
||||
if(is_null($a))
|
||||
$a = new App;
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
Config::load();
|
||||
|
||||
update_shadow_copy();
|
||||
}
|
||||
|
||||
Config::load();
|
||||
|
||||
update_shadow_copy();
|
||||
killme();
|
||||
?>
|
||||
if (array_search(__file__,get_included_files())===0){
|
||||
shadowupdate_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||
killme();
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
|
|||
$connect_url = '';
|
||||
$name = '';
|
||||
$network = '';
|
||||
$updated = '0000-00-00 00:00:00';
|
||||
$updated = NULL_DATE;
|
||||
$location = '';
|
||||
$about = '';
|
||||
$keywords = '';
|
||||
|
@ -239,12 +239,12 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca
|
|||
);
|
||||
|
||||
if (count($x)) {
|
||||
if (($network == "") AND ($x[0]["network"] != NETWORK_STATUSNET))
|
||||
if (($network == "") AND ($x[0]["network"] != NETWORK_STATUSNET)) {
|
||||
$network = $x[0]["network"];
|
||||
|
||||
if ($updated == "0000-00-00 00:00:00")
|
||||
}
|
||||
if ($updated <= NULL_DATE) {
|
||||
$updated = $x[0]["updated"];
|
||||
|
||||
}
|
||||
$created = $x[0]["created"];
|
||||
$server_url = $x[0]["server_url"];
|
||||
$nick = $x[0]["nick"];
|
||||
|
@ -252,7 +252,7 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca
|
|||
$alias = $x[0]["alias"];
|
||||
$notify = $x[0]["notify"];
|
||||
} else {
|
||||
$created = "0000-00-00 00:00:00";
|
||||
$created = NULL_DATE;
|
||||
$server_url = "";
|
||||
|
||||
$urlparts = parse_url($profile_url);
|
||||
|
@ -309,7 +309,18 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca
|
|||
|
||||
logger("profile-check generation: ".$generation." Network: ".$network." URL: ".$profile_url." name: ".$name." avatar: ".$profile_photo, LOGGER_DEBUG);
|
||||
|
||||
poco_check_server($server_url, $network);
|
||||
// We check the server url to be sure that it is a real one
|
||||
$server_url2 = poco_detect_server($profile_url);
|
||||
|
||||
// We are no sure that it is a correct URL. So we use it in the future
|
||||
if ($server_url2 != "") {
|
||||
$server_url = $server_url2;
|
||||
}
|
||||
|
||||
// The server URL doesn't seem to be valid, so we don't store it.
|
||||
if (!poco_check_server($server_url, $network)) {
|
||||
$server_url = "";
|
||||
}
|
||||
|
||||
$gcontact = array("url" => $profile_url,
|
||||
"addr" => $addr,
|
||||
|
@ -401,13 +412,47 @@ function poco_detect_server($profile) {
|
|||
|
||||
// Mastodon
|
||||
if ($server_url == "") {
|
||||
$red = preg_replace("=(https?://)(.*)/users/(.*)=ism", "$1$2", $profile);
|
||||
if ($red != $profile) {
|
||||
$server_url = $red;
|
||||
$mastodon = preg_replace("=(https?://)(.*)/users/(.*)=ism", "$1$2", $profile);
|
||||
if ($mastodon != $profile) {
|
||||
$server_url = $mastodon;
|
||||
$network = NETWORK_OSTATUS;
|
||||
}
|
||||
}
|
||||
|
||||
// Numeric OStatus variant
|
||||
if ($server_url == "") {
|
||||
$ostatus = preg_replace("=(https?://)(.*)/user/(.*)=ism", "$1$2", $profile);
|
||||
if ($ostatus != $profile) {
|
||||
$server_url = $ostatus;
|
||||
$network = NETWORK_OSTATUS;
|
||||
}
|
||||
}
|
||||
|
||||
// Wild guess
|
||||
if ($server_url == "") {
|
||||
$base = preg_replace("=(https?://)(.*?)/(.*)=ism", "$1$2", $profile);
|
||||
if ($base != $profile) {
|
||||
$server_url = $base;
|
||||
$network = NETWORK_PHANTOM;
|
||||
}
|
||||
}
|
||||
|
||||
if ($server_url == "") {
|
||||
return "";
|
||||
}
|
||||
|
||||
$r = q("SELECT `id` FROM `gserver` WHERE `nurl` = '%s' AND `last_contact` > `last_failure`",
|
||||
dbesc(normalise_link($server_url)));
|
||||
if (dbm::is_result($r)) {
|
||||
return $server_url;
|
||||
}
|
||||
|
||||
// Fetch the host-meta to check if this really is a server
|
||||
$serverret = z_fetch_url($server_url."/.well-known/host-meta");
|
||||
if (!$serverret["success"]) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return $server_url;
|
||||
}
|
||||
|
||||
|
@ -420,14 +465,16 @@ function poco_last_updated($profile, $force = false) {
|
|||
$gcontacts = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s'",
|
||||
dbesc(normalise_link($profile)));
|
||||
|
||||
if ($gcontacts[0]["created"] == "0000-00-00 00:00:00")
|
||||
if ($gcontacts[0]["created"] <= NULL_DATE) {
|
||||
q("UPDATE `gcontact` SET `created` = '%s' WHERE `nurl` = '%s'",
|
||||
dbesc(datetime_convert()), dbesc(normalise_link($profile)));
|
||||
|
||||
if ($gcontacts[0]["server_url"] != "")
|
||||
}
|
||||
if ($gcontacts[0]["server_url"] != "") {
|
||||
$server_url = $gcontacts[0]["server_url"];
|
||||
else
|
||||
}
|
||||
if (($server_url == '') OR ($gcontacts[0]["server_url"] == $gcontacts[0]["nurl"])) {
|
||||
$server_url = poco_detect_server($profile);
|
||||
}
|
||||
|
||||
if (!in_array($gcontacts[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_FEED, NETWORK_OSTATUS, ""))) {
|
||||
logger("Profile ".$profile.": Network type ".$gcontacts[0]["network"]." can't be checked", LOGGER_DEBUG);
|
||||
|
@ -617,10 +664,11 @@ function poco_last_updated($profile, $force = false) {
|
|||
}
|
||||
|
||||
// Maybe there aren't any entries. Then check if it is a valid feed
|
||||
if ($last_updated == "")
|
||||
if ($xpath->query('/atom:feed')->length > 0)
|
||||
$last_updated = "0000-00-00 00:00:00";
|
||||
|
||||
if ($last_updated == "") {
|
||||
if ($xpath->query('/atom:feed')->length > 0) {
|
||||
$last_updated = NULL_DATE;
|
||||
}
|
||||
}
|
||||
q("UPDATE `gcontact` SET `updated` = '%s', `last_contact` = '%s' WHERE `nurl` = '%s'",
|
||||
dbesc(dbm::date($last_updated)), dbesc(dbm::date()), dbesc(normalise_link($profile)));
|
||||
|
||||
|
@ -680,6 +728,213 @@ function poco_to_boolean($val) {
|
|||
return ($val);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Detect server type (Hubzilla or Friendica) via the poco data
|
||||
*
|
||||
* @param object $data POCO data
|
||||
* @return array Server data
|
||||
*/
|
||||
function poco_detect_poco_data($data) {
|
||||
$server = false;
|
||||
|
||||
if (!isset($data->entry)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (count($data->entry) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isset($data->entry[0]->urls)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (count($data->entry[0]->urls) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($data->entry[0]->urls AS $url) {
|
||||
if ($url->type == 'zot') {
|
||||
$server = array();
|
||||
$server["platform"] = 'Hubzilla';
|
||||
$server["network"] = NETWORK_DIASPORA;
|
||||
return $server;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Detect server type by using the nodeinfo data
|
||||
*
|
||||
* @param string $server_url address of the server
|
||||
* @return array Server data
|
||||
*/
|
||||
function poco_fetch_nodeinfo($server_url) {
|
||||
$serverret = z_fetch_url($server_url."/.well-known/nodeinfo");
|
||||
if (!$serverret["success"]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$nodeinfo = json_decode($serverret['body']);
|
||||
|
||||
if (!is_object($nodeinfo)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!is_array($nodeinfo->links)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$nodeinfo_url = '';
|
||||
|
||||
foreach ($nodeinfo->links AS $link) {
|
||||
if ($link->rel == 'http://nodeinfo.diaspora.software/ns/schema/1.0') {
|
||||
$nodeinfo_url = $link->href;
|
||||
}
|
||||
}
|
||||
|
||||
if ($nodeinfo_url == '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$serverret = z_fetch_url($nodeinfo_url);
|
||||
if (!$serverret["success"]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$nodeinfo = json_decode($serverret['body']);
|
||||
|
||||
if (!is_object($nodeinfo)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$server = array();
|
||||
|
||||
$server['register_policy'] = REGISTER_CLOSED;
|
||||
|
||||
if (is_bool($nodeinfo->openRegistrations) AND $nodeinfo->openRegistrations) {
|
||||
$server['register_policy'] = REGISTER_OPEN;
|
||||
}
|
||||
|
||||
if (is_object($nodeinfo->software)) {
|
||||
if (isset($nodeinfo->software->name)) {
|
||||
$server['platform'] = $nodeinfo->software->name;
|
||||
}
|
||||
|
||||
if (isset($nodeinfo->software->version)) {
|
||||
$server['version'] = $nodeinfo->software->version;
|
||||
// Version numbers on Nodeinfo are presented with additional info, e.g.:
|
||||
// 0.6.3.0-p1702cc1c, 0.6.99.0-p1b9ab160 or 3.4.3-2-1191.
|
||||
$server['version'] = preg_replace("=(.+)-(.{4,})=ism", "$1", $server['version']);
|
||||
}
|
||||
}
|
||||
|
||||
if (is_object($nodeinfo->metadata)) {
|
||||
if (isset($nodeinfo->metadata->nodeName)) {
|
||||
$server['site_name'] = $nodeinfo->metadata->nodeName;
|
||||
}
|
||||
}
|
||||
|
||||
$diaspora = false;
|
||||
$friendica = false;
|
||||
$gnusocial = false;
|
||||
|
||||
if (is_array($nodeinfo->protocols->inbound)) {
|
||||
foreach ($nodeinfo->protocols->inbound AS $inbound) {
|
||||
if ($inbound == 'diaspora') {
|
||||
$diaspora = true;
|
||||
}
|
||||
if ($inbound == 'friendica') {
|
||||
$friendica = true;
|
||||
}
|
||||
if ($inbound == 'gnusocial') {
|
||||
$gnusocial = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($gnusocial) {
|
||||
$server['network'] = NETWORK_OSTATUS;
|
||||
}
|
||||
if ($diaspora) {
|
||||
$server['network'] = NETWORK_DIASPORA;
|
||||
}
|
||||
if ($friendica) {
|
||||
$server['network'] = NETWORK_DFRN;
|
||||
}
|
||||
|
||||
if (!$server) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $server;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Detect server type (Hubzilla or Friendica) via the front page body
|
||||
*
|
||||
* @param string $body Front page of the server
|
||||
* @return array Server data
|
||||
*/
|
||||
function poco_detect_server_type($body) {
|
||||
$server = false;
|
||||
|
||||
$doc = new \DOMDocument();
|
||||
@$doc->loadHTML($body);
|
||||
$xpath = new \DomXPath($doc);
|
||||
|
||||
$list = $xpath->query("//meta[@name]");
|
||||
|
||||
foreach ($list as $node) {
|
||||
$attr = array();
|
||||
if ($node->attributes->length) {
|
||||
foreach ($node->attributes as $attribute) {
|
||||
$attr[$attribute->name] = $attribute->value;
|
||||
}
|
||||
}
|
||||
if ($attr['name'] == 'generator') {
|
||||
$version_part = explode(" ", $attr['content']);
|
||||
if (count($version_part) == 2) {
|
||||
if (in_array($version_part[0], array("Friendika", "Friendica"))) {
|
||||
$server = array();
|
||||
$server["platform"] = $version_part[0];
|
||||
$server["version"] = $version_part[1];
|
||||
$server["network"] = NETWORK_DFRN;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$server) {
|
||||
$list = $xpath->query("//meta[@property]");
|
||||
|
||||
foreach ($list as $node) {
|
||||
$attr = array();
|
||||
if ($node->attributes->length) {
|
||||
foreach ($node->attributes as $attribute) {
|
||||
$attr[$attribute->name] = $attribute->value;
|
||||
}
|
||||
}
|
||||
if ($attr['property'] == 'generator') {
|
||||
if (in_array($attr['content'], array("hubzilla", "BlaBlaNet"))) {
|
||||
$server = array();
|
||||
$server["platform"] = $attr['content'];
|
||||
$server["version"] = "";
|
||||
$server["network"] = NETWORK_DIASPORA;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$server) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$server["site_name"] = $xpath->evaluate($element."//head/title/text()", $context)->item(0)->nodeValue;
|
||||
return $server;
|
||||
}
|
||||
|
||||
function poco_check_server($server_url, $network = "", $force = false) {
|
||||
|
||||
// Unify the server address
|
||||
|
@ -692,10 +947,10 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
|||
$servers = q("SELECT * FROM `gserver` WHERE `nurl` = '%s'", dbesc(normalise_link($server_url)));
|
||||
if (dbm::is_result($servers)) {
|
||||
|
||||
if ($servers[0]["created"] == "0000-00-00 00:00:00")
|
||||
if ($servers[0]["created"] <= NULL_DATE) {
|
||||
q("UPDATE `gserver` SET `created` = '%s' WHERE `nurl` = '%s'",
|
||||
dbesc(datetime_convert()), dbesc(normalise_link($server_url)));
|
||||
|
||||
}
|
||||
$poco = $servers[0]["poco"];
|
||||
$noscrape = $servers[0]["noscrape"];
|
||||
|
||||
|
@ -723,13 +978,15 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
|||
$info = "";
|
||||
$register_policy = -1;
|
||||
|
||||
$last_contact = "0000-00-00 00:00:00";
|
||||
$last_failure = "0000-00-00 00:00:00";
|
||||
$last_contact = NULL_DATE;
|
||||
$last_failure = NULL_DATE;
|
||||
}
|
||||
logger("Server ".$server_url." is outdated or unknown. Start discovery. Force: ".$force." Created: ".$servers[0]["created"]." Failure: ".$last_failure." Contact: ".$last_contact, LOGGER_DEBUG);
|
||||
|
||||
$failure = false;
|
||||
$possible_failure = false;
|
||||
$orig_last_failure = $last_failure;
|
||||
$orig_last_contact = $last_contact;
|
||||
|
||||
// Check if the page is accessible via SSL.
|
||||
$orig_server_url = $server_url;
|
||||
|
@ -769,18 +1026,58 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
|||
$last_failure = datetime_convert();
|
||||
$failure = true;
|
||||
}
|
||||
$possible_failure = true;
|
||||
} elseif ($network == NETWORK_DIASPORA)
|
||||
$last_contact = datetime_convert();
|
||||
|
||||
// If the server has no possible failure we reset the cached data
|
||||
if (!$possible_failure) {
|
||||
$version = "";
|
||||
$platform = "";
|
||||
$site_name = "";
|
||||
$info = "";
|
||||
$register_policy = -1;
|
||||
}
|
||||
|
||||
// Look for poco
|
||||
if (!$failure) {
|
||||
// Test for Diaspora
|
||||
$serverret = z_fetch_url($server_url."/poco");
|
||||
if ($serverret["success"]) {
|
||||
$data = json_decode($serverret["body"]);
|
||||
if (isset($data->totalResults)) {
|
||||
$poco = $server_url."/poco";
|
||||
$last_contact = datetime_convert();
|
||||
|
||||
$server = poco_detect_poco_data($data);
|
||||
if ($server) {
|
||||
$platform = $server['platform'];
|
||||
$network = $server['network'];
|
||||
$version = '';
|
||||
$site_name = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$failure) {
|
||||
// Test for Diaspora, Hubzilla, Mastodon or older Friendica servers
|
||||
$serverret = z_fetch_url($server_url);
|
||||
|
||||
if (!$serverret["success"] OR ($serverret["body"] == ""))
|
||||
if (!$serverret["success"] OR ($serverret["body"] == "")) {
|
||||
$last_failure = datetime_convert();
|
||||
$failure = true;
|
||||
else {
|
||||
} else {
|
||||
$server = poco_detect_server_type($serverret["body"]);
|
||||
if ($server) {
|
||||
$platform = $server['platform'];
|
||||
$network = $server['network'];
|
||||
$version = $server['version'];
|
||||
$site_name = $server['site_name'];
|
||||
$last_contact = datetime_convert();
|
||||
}
|
||||
|
||||
$lines = explode("\n",$serverret["header"]);
|
||||
if(count($lines))
|
||||
if(count($lines)) {
|
||||
foreach($lines as $line) {
|
||||
$line = trim($line);
|
||||
if(stristr($line,'X-Diaspora-Version:')) {
|
||||
|
@ -790,6 +1087,7 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
|||
$network = NETWORK_DIASPORA;
|
||||
$versionparts = explode("-", $version);
|
||||
$version = $versionparts[0];
|
||||
$last_contact = datetime_convert();
|
||||
}
|
||||
|
||||
if(stristr($line,'Server: Mastodon')) {
|
||||
|
@ -797,12 +1095,14 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
|||
$network = NETWORK_OSTATUS;
|
||||
// Mastodon doesn't reveal version numbers
|
||||
$version = "";
|
||||
$last_contact = datetime_convert();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$failure) {
|
||||
if (!$failure AND ($poco == "")) {
|
||||
// Test for Statusnet
|
||||
// Will also return data for Friendica and GNU Social - but it will be overwritten later
|
||||
// The "not implemented" is a special treatment for really, really old Friendica versions
|
||||
|
@ -810,8 +1110,11 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
|||
if ($serverret["success"] AND ($serverret["body"] != '{"error":"not implemented"}') AND
|
||||
($serverret["body"] != '') AND (strlen($serverret["body"]) < 30)) {
|
||||
$platform = "StatusNet";
|
||||
$version = trim($serverret["body"], '"');
|
||||
// Remove junk that some GNU Social servers return
|
||||
$version = str_replace(chr(239).chr(187).chr(191), "", $serverret["body"]);
|
||||
$version = trim($version, '"');
|
||||
$network = NETWORK_OSTATUS;
|
||||
$last_contact = datetime_convert();
|
||||
}
|
||||
|
||||
// Test for GNU Social
|
||||
|
@ -819,17 +1122,32 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
|||
if ($serverret["success"] AND ($serverret["body"] != '{"error":"not implemented"}') AND
|
||||
($serverret["body"] != '') AND (strlen($serverret["body"]) < 30)) {
|
||||
$platform = "GNU Social";
|
||||
$version = trim($serverret["body"], '"');
|
||||
// Remove junk that some GNU Social servers return
|
||||
$version = str_replace(chr(239).chr(187).chr(191), "", $serverret["body"]);
|
||||
$version = trim($version, '"');
|
||||
$network = NETWORK_OSTATUS;
|
||||
$last_contact = datetime_convert();
|
||||
}
|
||||
}
|
||||
|
||||
if (!$failure) {
|
||||
// Test for Hubzilla, Redmatrix or Friendica
|
||||
$serverret = z_fetch_url($server_url."/api/statusnet/config.json");
|
||||
if ($serverret["success"]) {
|
||||
$data = json_decode($serverret["body"]);
|
||||
|
||||
if (isset($data->site->server)) {
|
||||
$last_contact = datetime_convert();
|
||||
|
||||
if (isset($data->site->platform)) {
|
||||
$platform = $data->site->platform->PLATFORM_NAME;
|
||||
$version = $data->site->platform->STD_VERSION;
|
||||
$network = NETWORK_DIASPORA;
|
||||
}
|
||||
if (isset($data->site->BlaBlaNet)) {
|
||||
$platform = $data->site->BlaBlaNet->PLATFORM_NAME;
|
||||
$version = $data->site->BlaBlaNet->STD_VERSION;
|
||||
$network = NETWORK_DIASPORA;
|
||||
}
|
||||
if (isset($data->site->hubzilla)) {
|
||||
$platform = $data->site->hubzilla->PLATFORM_NAME;
|
||||
$version = $data->site->hubzilla->RED_VERSION;
|
||||
|
@ -866,32 +1184,66 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Query statistics.json. Optional package for Diaspora, Friendica and Redmatrix
|
||||
if (!$failure) {
|
||||
$serverret = z_fetch_url($server_url."/statistics.json");
|
||||
if ($serverret["success"]) {
|
||||
$data = json_decode($serverret["body"]);
|
||||
if ($version == "")
|
||||
if (isset($data->version)) {
|
||||
$version = $data->version;
|
||||
// Version numbers on statistics.json are presented with additional info, e.g.:
|
||||
// 0.6.3.0-p1702cc1c, 0.6.99.0-p1b9ab160 or 3.4.3-2-1191.
|
||||
$version = preg_replace("=(.+)-(.{4,})=ism", "$1", $version);
|
||||
}
|
||||
|
||||
$site_name = $data->name;
|
||||
|
||||
if (isset($data->network) AND ($platform == ""))
|
||||
if (isset($data->network)) {
|
||||
$platform = $data->network;
|
||||
}
|
||||
|
||||
if ($platform == "Diaspora")
|
||||
if ($platform == "Diaspora") {
|
||||
$network = NETWORK_DIASPORA;
|
||||
}
|
||||
|
||||
if ($data->registrations_open)
|
||||
if ($data->registrations_open) {
|
||||
$register_policy = REGISTER_OPEN;
|
||||
else
|
||||
} else {
|
||||
$register_policy = REGISTER_CLOSED;
|
||||
}
|
||||
|
||||
if (isset($data->version))
|
||||
$last_contact = datetime_convert();
|
||||
}
|
||||
}
|
||||
|
||||
// Query nodeinfo. Working for (at least) Diaspora and Friendica.
|
||||
if (!$failure) {
|
||||
$server = poco_fetch_nodeinfo($server_url);
|
||||
if ($server) {
|
||||
$register_policy = $server['register_policy'];
|
||||
|
||||
if (isset($server['platform'])) {
|
||||
$platform = $server['platform'];
|
||||
}
|
||||
|
||||
if (isset($server['network'])) {
|
||||
$network = $server['network'];
|
||||
}
|
||||
|
||||
if (isset($server['version'])) {
|
||||
$version = $server['version'];
|
||||
}
|
||||
|
||||
if (isset($server['site_name'])) {
|
||||
$site_name = $server['site_name'];
|
||||
}
|
||||
|
||||
$last_contact = datetime_convert();
|
||||
}
|
||||
}
|
||||
|
||||
// Check for noscrape
|
||||
// Friendica servers could be detected as OStatus servers
|
||||
if (!$failure AND in_array($network, array(NETWORK_DFRN, NETWORK_OSTATUS))) {
|
||||
|
@ -929,16 +1281,21 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
|||
}
|
||||
}
|
||||
|
||||
// Look for poco
|
||||
if (!$failure) {
|
||||
$serverret = z_fetch_url($server_url."/poco");
|
||||
if ($serverret["success"]) {
|
||||
$data = json_decode($serverret["body"]);
|
||||
if (isset($data->totalResults)) {
|
||||
$poco = $server_url."/poco";
|
||||
$last_contact = datetime_convert();
|
||||
}
|
||||
}
|
||||
if ($possible_failure AND !$failure) {
|
||||
$last_failure = datetime_convert();
|
||||
$failure = true;
|
||||
}
|
||||
|
||||
if ($failure) {
|
||||
$last_contact = $orig_last_contact;
|
||||
} else {
|
||||
$last_failure = $orig_last_failure;
|
||||
}
|
||||
|
||||
if (($last_contact <= $last_failure) AND !$failure) {
|
||||
logger("Server ".$server_url." seems to be alive, but last contact wasn't set - could be a bug", LOGGER_DEBUG);
|
||||
} else if (($last_contact >= $last_failure) AND $failure) {
|
||||
logger("Server ".$server_url." seems to be dead, but last failure wasn't set - could be a bug", LOGGER_DEBUG);
|
||||
}
|
||||
|
||||
// Check again if the server exists
|
||||
|
@ -949,7 +1306,7 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
|||
$info = strip_tags($info);
|
||||
$platform = strip_tags($platform);
|
||||
|
||||
if ($servers)
|
||||
if ($servers) {
|
||||
q("UPDATE `gserver` SET `url` = '%s', `version` = '%s', `site_name` = '%s', `info` = '%s', `register_policy` = %d, `poco` = '%s', `noscrape` = '%s',
|
||||
`network` = '%s', `platform` = '%s', `last_contact` = '%s', `last_failure` = '%s' WHERE `nurl` = '%s'",
|
||||
dbesc($server_url),
|
||||
|
@ -965,7 +1322,7 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
|||
dbesc($last_failure),
|
||||
dbesc(normalise_link($server_url))
|
||||
);
|
||||
else
|
||||
} elseif (!$failure) {
|
||||
q("INSERT INTO `gserver` (`url`, `nurl`, `version`, `site_name`, `info`, `register_policy`, `poco`, `noscrape`, `network`, `platform`, `created`, `last_contact`, `last_failure`)
|
||||
VALUES ('%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
|
||||
dbesc($server_url),
|
||||
|
@ -983,7 +1340,7 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
|||
dbesc($last_failure),
|
||||
dbesc(datetime_convert())
|
||||
);
|
||||
|
||||
}
|
||||
logger("End discovery for server ".$server_url, LOGGER_DEBUG);
|
||||
|
||||
return !$failure;
|
||||
|
@ -1147,7 +1504,7 @@ function suggestion_query($uid, $start = 0, $limit = 80) {
|
|||
where uid = %d and not gcontact.nurl in ( select nurl from contact where uid = %d )
|
||||
AND NOT `gcontact`.`name` IN (SELECT `name` FROM `contact` WHERE `uid` = %d)
|
||||
AND NOT `gcontact`.`id` IN (SELECT `gcid` FROM `gcign` WHERE `uid` = %d)
|
||||
AND `gcontact`.`updated` != '0000-00-00 00:00:00'
|
||||
AND `gcontact`.`updated` >= '%s'
|
||||
AND `gcontact`.`last_contact` >= `gcontact`.`last_failure`
|
||||
AND `gcontact`.`network` IN (%s)
|
||||
GROUP BY `glink`.`gcid` ORDER BY `gcontact`.`updated` DESC,`total` DESC LIMIT %d, %d",
|
||||
|
@ -1155,6 +1512,7 @@ function suggestion_query($uid, $start = 0, $limit = 80) {
|
|||
intval($uid),
|
||||
intval($uid),
|
||||
intval($uid),
|
||||
dbesc(NULL_DATE),
|
||||
$sql_network,
|
||||
intval($start),
|
||||
intval($limit)
|
||||
|
@ -1173,13 +1531,14 @@ function suggestion_query($uid, $start = 0, $limit = 80) {
|
|||
WHERE `glink`.`uid` = 0 AND `glink`.`cid` = 0 AND `glink`.`zcid` = 0 AND NOT `gcontact`.`nurl` IN (SELECT `nurl` FROM `contact` WHERE `uid` = %d)
|
||||
AND NOT `gcontact`.`name` IN (SELECT `name` FROM `contact` WHERE `uid` = %d)
|
||||
AND NOT `gcontact`.`id` IN (SELECT `gcid` FROM `gcign` WHERE `uid` = %d)
|
||||
AND `gcontact`.`updated` != '0000-00-00 00:00:00'
|
||||
AND `gcontact`.`updated` >= '%s'
|
||||
AND `gcontact`.`last_contact` >= `gcontact`.`last_failure`
|
||||
AND `gcontact`.`network` IN (%s)
|
||||
ORDER BY rand() LIMIT %d, %d",
|
||||
intval($uid),
|
||||
intval($uid),
|
||||
intval($uid),
|
||||
dbesc(NULL_DATE),
|
||||
$sql_network,
|
||||
intval($start),
|
||||
intval($limit)
|
||||
|
@ -1244,6 +1603,33 @@ function update_suggestions() {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Fetch server list from remote servers and adds them when they are new.
|
||||
*
|
||||
* @param string $poco URL to the POCO endpoint
|
||||
*/
|
||||
function poco_fetch_serverlist($poco) {
|
||||
$serverret = z_fetch_url($poco."/@server");
|
||||
if (!$serverret["success"]) {
|
||||
return;
|
||||
}
|
||||
$serverlist = json_decode($serverret['body']);
|
||||
|
||||
if (!is_array($serverlist)) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($serverlist AS $server) {
|
||||
$server_url = str_replace("/index.php", "", $server->url);
|
||||
|
||||
$r = q("SELECT `nurl` FROM `gserver` WHERE `nurl` = '%s'", dbesc(normalise_link($server_url)));
|
||||
if (!dbm::is_result($r)) {
|
||||
logger("Call server check for server ".$server_url, LOGGER_DEBUG);
|
||||
proc_run(PRIORITY_LOW, "include/discover_poco.php", "server", base64_encode($server_url));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function poco_discover_federation() {
|
||||
$last = get_config('poco','last_federation_discovery');
|
||||
|
||||
|
@ -1259,8 +1645,9 @@ function poco_discover_federation() {
|
|||
if ($serverdata) {
|
||||
$servers = json_decode($serverdata);
|
||||
|
||||
foreach($servers->pods AS $server)
|
||||
poco_check_server("https://".$server->host);
|
||||
foreach ($servers->pods AS $server) {
|
||||
proc_run(PRIORITY_LOW, "include/discover_poco.php", "server", base64_encode("https://".$server->host));
|
||||
}
|
||||
}
|
||||
|
||||
// Currently disabled, since the service isn't available anymore.
|
||||
|
@ -1295,6 +1682,9 @@ function poco_discover_single_server($id) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Discover new servers out there
|
||||
poco_fetch_serverlist($server["poco"]);
|
||||
|
||||
// Fetch all users from the other server
|
||||
$url = $server["poco"]."/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation";
|
||||
|
||||
|
@ -1411,7 +1801,7 @@ function poco_discover_server($data, $default_generation = 0) {
|
|||
$connect_url = '';
|
||||
$name = '';
|
||||
$network = '';
|
||||
$updated = '0000-00-00 00:00:00';
|
||||
$updated = NULL_DATE;
|
||||
$location = '';
|
||||
$about = '';
|
||||
$keywords = '';
|
||||
|
@ -1895,4 +2285,20 @@ function gs_discover() {
|
|||
q("UPDATE `gserver` SET `last_poco_query` = '%s' WHERE `nurl` = '%s'", dbesc(datetime_convert()), dbesc($server["nurl"]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns a list of all known servers
|
||||
* @return array List of server urls
|
||||
*/
|
||||
function poco_serverlist() {
|
||||
$r = q("SELECT `url`, `site_name` AS `displayName`, `network`, `platform`, `version` FROM `gserver`
|
||||
WHERE `network` IN ('%s', '%s', '%s') AND `last_contact` > `last_failure`
|
||||
ORDER BY `last_contact`
|
||||
LIMIT 1000",
|
||||
dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS));
|
||||
if (!dbm::is_result($r)) {
|
||||
return false;
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -6,24 +6,10 @@
|
|||
|
||||
use \Friendica\Core\Config;
|
||||
|
||||
require_once("boot.php");
|
||||
require_once("include/items.php");
|
||||
|
||||
function spool_post_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);
|
||||
}
|
||||
|
||||
Config::load();
|
||||
global $a;
|
||||
|
||||
$path = get_spoolpath();
|
||||
|
||||
|
@ -69,9 +55,4 @@ function spool_post_run($argv, $argc) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (array_search(__file__, get_included_files()) === 0) {
|
||||
spool_post_run($_SERVER["argv"], $_SERVER["argc"]);
|
||||
killme();
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,24 +1,6 @@
|
|||
<?php
|
||||
|
||||
use \Friendica\Core\Config;
|
||||
|
||||
require_once("boot.php");
|
||||
require_once("include/tags.php");
|
||||
|
||||
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);
|
||||
function tagupdate_run(&$argv, &$argc){
|
||||
update_items();
|
||||
}
|
||||
|
||||
Config::load();
|
||||
|
||||
update_items();
|
||||
killme();
|
||||
?>
|
||||
|
|
|
@ -903,10 +903,10 @@ function contact_block() {
|
|||
intval($shown)
|
||||
);
|
||||
if (dbm::is_result($r)) {
|
||||
$contacts = "";
|
||||
foreach ($r AS $contact)
|
||||
$contacts = array();
|
||||
foreach ($r AS $contact) {
|
||||
$contacts[] = $contact["id"];
|
||||
|
||||
}
|
||||
$r = q("SELECT `id`, `uid`, `addr`, `url`, `name`, `thumb`, `network` FROM `contact` WHERE `id` IN (%s)",
|
||||
dbesc(implode(",", $contacts)));
|
||||
|
||||
|
|
|
@ -1,25 +1,7 @@
|
|||
<?php
|
||||
|
||||
use \Friendica\Core\Config;
|
||||
|
||||
require_once("boot.php");
|
||||
require_once("include/threads.php");
|
||||
|
||||
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);
|
||||
function threadupdate_run(&$argv, &$argc){
|
||||
update_threads();
|
||||
update_threads_mention();
|
||||
}
|
||||
|
||||
Config::load();
|
||||
|
||||
update_threads();
|
||||
update_threads_mention();
|
||||
killme();
|
||||
?>
|
||||
|
|
|
@ -11,14 +11,11 @@ define("IMPORT_DEBUG", False);
|
|||
|
||||
function last_insert_id() {
|
||||
global $db;
|
||||
|
||||
if (IMPORT_DEBUG)
|
||||
return 1;
|
||||
if ($db->mysqli) {
|
||||
$thedb = $db->getdb();
|
||||
return $thedb->insert_id;
|
||||
} else {
|
||||
return mysql_insert_id();
|
||||
}
|
||||
|
||||
return $db->insert_id();
|
||||
}
|
||||
|
||||
function last_error() {
|
||||
|
@ -186,8 +183,8 @@ function import_account(App $a, $file) {
|
|||
}
|
||||
}
|
||||
if ($contact['uid'] == $olduid && $contact['self'] == '0') {
|
||||
// set contacts 'avatar-date' to "0000-00-00 00:00:00" to let poller to update urls
|
||||
$contact["avatar-date"] = "0000-00-00 00:00:00" ;
|
||||
// set contacts 'avatar-date' to NULL_DATE to let poller to update urls
|
||||
$contact["avatar-date"] = NULL_DATE;
|
||||
|
||||
|
||||
switch ($contact['network']) {
|
||||
|
|
|
@ -2,46 +2,23 @@
|
|||
|
||||
use \Friendica\Core\Config;
|
||||
|
||||
require_once("boot.php");
|
||||
|
||||
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);
|
||||
};
|
||||
global $a;
|
||||
|
||||
require_once('include/Scrape.php');
|
||||
require_once("include/socgraph.php");
|
||||
|
||||
Config::load();
|
||||
|
||||
$a->set_baseurl(get_config('system','url'));
|
||||
|
||||
load_hooks();
|
||||
require_once('include/socgraph.php');
|
||||
|
||||
logger('update_gcontact: start');
|
||||
|
||||
if(($argc > 1) && (intval($argv[1])))
|
||||
if (($argc > 1) && (intval($argv[1]))) {
|
||||
$contact_id = intval($argv[1]);
|
||||
}
|
||||
|
||||
if(!$contact_id) {
|
||||
if (!$contact_id) {
|
||||
logger('update_gcontact: no contact');
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't check this stuff if the function is called by the poller
|
||||
if (App::callstack() != "poller_run")
|
||||
if (App::is_already_running('update_gcontact'.$contact_id, '', 540))
|
||||
return;
|
||||
|
||||
$r = q("SELECT * FROM `gcontact` WHERE `id` = %d", intval($contact_id));
|
||||
|
||||
if (!$r)
|
||||
|
@ -98,8 +75,3 @@ function update_gcontact_run(&$argv, &$argc){
|
|||
dbesc(normalise_link($data["url"]))
|
||||
);
|
||||
}
|
||||
|
||||
if (array_search(__file__,get_included_files())===0){
|
||||
update_gcontact_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||
killme();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue