Merge remote-tracking branch 'upstream/develop' into 1702-null-date
This commit is contained in:
commit
e301fa0832
126
boot.php
126
boot.php
|
@ -32,7 +32,6 @@ require_once('include/cache.php');
|
||||||
require_once('library/Mobile_Detect/Mobile_Detect.php');
|
require_once('library/Mobile_Detect/Mobile_Detect.php');
|
||||||
require_once('include/features.php');
|
require_once('include/features.php');
|
||||||
require_once('include/identity.php');
|
require_once('include/identity.php');
|
||||||
require_once('include/pidfile.php');
|
|
||||||
require_once('update.php');
|
require_once('update.php');
|
||||||
require_once('include/dbstructure.php');
|
require_once('include/dbstructure.php');
|
||||||
|
|
||||||
|
@ -1354,60 +1353,25 @@ class App {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Checks if the process is already running
|
|
||||||
*
|
|
||||||
* @param string $taskname The name of the task that will be used for the name of the lockfile
|
|
||||||
* @param string $task The path and name of the php script
|
|
||||||
* @param int $timeout The timeout after which a task should be killed
|
|
||||||
*
|
|
||||||
* @return bool Is the process running?
|
|
||||||
*/
|
|
||||||
function is_already_running($taskname, $task = "", $timeout = 540) {
|
|
||||||
|
|
||||||
$lockpath = get_lockpath();
|
|
||||||
if ($lockpath != '') {
|
|
||||||
$pidfile = new pidfile($lockpath, $taskname);
|
|
||||||
if ($pidfile->is_already_running()) {
|
|
||||||
logger("Already running");
|
|
||||||
if ($pidfile->running_time() > $timeout) {
|
|
||||||
$pidfile->kill();
|
|
||||||
logger("killed stale process");
|
|
||||||
// Calling a new instance
|
|
||||||
if ($task != "")
|
|
||||||
proc_run(PRIORITY_MEDIUM, $task);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function proc_run($args) {
|
function proc_run($args) {
|
||||||
|
|
||||||
if (!function_exists("proc_open")) {
|
if (!function_exists("proc_open")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the php path if it is a php call
|
// If the last worker fork was less than 10 seconds before then don't fork another one.
|
||||||
if (count($args) && ($args[0] === 'php' OR !is_string($args[0]))) {
|
// This should prevent the forking of masses of workers.
|
||||||
|
$cachekey = "app:proc_run:started";
|
||||||
// If the last worker fork was less than 10 seconds before then don't fork another one.
|
$result = Cache::get($cachekey);
|
||||||
// This should prevent the forking of masses of workers.
|
if (!is_null($result)) {
|
||||||
if (get_config("system", "worker")) {
|
if ((time() - $result) < 10) {
|
||||||
$cachekey = "app:proc_run:started";
|
return;
|
||||||
$result = Cache::get($cachekey);
|
|
||||||
if (!is_null($result)) {
|
|
||||||
if ((time() - $result) < 10) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Set the timestamp of the last proc_run
|
|
||||||
Cache::set($cachekey, time(), CACHE_MINUTE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$args[0] = ((x($this->config,'php_path')) && (strlen($this->config['php_path'])) ? $this->config['php_path'] : 'php');
|
|
||||||
}
|
}
|
||||||
|
// Set the timestamp of the last proc_run
|
||||||
|
Cache::set($cachekey, time(), CACHE_MINUTE);
|
||||||
|
|
||||||
|
array_unshift($args, ((x($this->config,'php_path')) && (strlen($this->config['php_path'])) ? $this->config['php_path'] : 'php'));
|
||||||
|
|
||||||
// add baseurl to args. cli scripts can't construct it
|
// add baseurl to args. cli scripts can't construct it
|
||||||
$args[] = $this->get_baseurl();
|
$args[] = $this->get_baseurl();
|
||||||
|
@ -1897,11 +1861,35 @@ function goaway($s) {
|
||||||
* @return int|bool user id or false
|
* @return int|bool user id or false
|
||||||
*/
|
*/
|
||||||
function local_user() {
|
function local_user() {
|
||||||
if((x($_SESSION,'authenticated')) && (x($_SESSION,'uid')))
|
if (x($_SESSION, 'authenticated') && x($_SESSION, 'uid')) {
|
||||||
return intval($_SESSION['uid']);
|
return intval($_SESSION['uid']);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the public contact id of logged in user or false.
|
||||||
|
*
|
||||||
|
* @return int|bool public contact id or false
|
||||||
|
*/
|
||||||
|
function public_contact() {
|
||||||
|
static $public_contact_id = false;
|
||||||
|
|
||||||
|
if (!$public_contact_id && x($_SESSION, 'authenticated')) {
|
||||||
|
if (x($_SESSION, 'my_address')) {
|
||||||
|
// Local user
|
||||||
|
$public_contact_id = intval(get_contact($_SESSION['my_address'], 0));
|
||||||
|
} else if (x($_SESSION, 'visitor_home')) {
|
||||||
|
// Remote user
|
||||||
|
$public_contact_id = intval(get_contact($_SESSION['visitor_home'], 0));
|
||||||
|
}
|
||||||
|
} else if (!x($_SESSION, 'authenticated')) {
|
||||||
|
$public_contact_id = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $public_contact_id;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns contact id of authenticated site visitor or false
|
* @brief Returns contact id of authenticated site visitor or false
|
||||||
*
|
*
|
||||||
|
@ -1960,10 +1948,9 @@ function get_max_import_size() {
|
||||||
* @brief Wrap calls to proc_close(proc_open()) and call hook
|
* @brief Wrap calls to proc_close(proc_open()) and call hook
|
||||||
* so plugins can take part in process :)
|
* so plugins can take part in process :)
|
||||||
*
|
*
|
||||||
* @param (string|integer|array) $cmd program to run, priority or parameter array
|
* @param (integer|array) priority or parameter array, $cmd atrings are deprecated and are ignored
|
||||||
*
|
*
|
||||||
* next args are passed as $cmd command line
|
* next args are passed as $cmd command line
|
||||||
* e.g.: proc_run("ls","-la","/tmp");
|
|
||||||
* or: proc_run(PRIORITY_HIGH, "include/notifier.php", "drop", $drop_id);
|
* or: proc_run(PRIORITY_HIGH, "include/notifier.php", "drop", $drop_id);
|
||||||
* or: proc_run(array('priority' => PRIORITY_HIGH, 'dont_fork' => true), "include/create_shadowentry.php", $post_id);
|
* or: proc_run(array('priority' => PRIORITY_HIGH, 'dont_fork' => true), "include/create_shadowentry.php", $post_id);
|
||||||
*
|
*
|
||||||
|
@ -2008,11 +1995,6 @@ function proc_run($cmd){
|
||||||
if (!$arr['run_cmd'] OR !count($args))
|
if (!$arr['run_cmd'] OR !count($args))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!get_config("system", "worker") OR (is_string($run_parameter) AND ($run_parameter != 'php'))) {
|
|
||||||
$a->proc_run($args);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$priority = PRIORITY_MEDIUM;
|
$priority = PRIORITY_MEDIUM;
|
||||||
$dont_fork = get_config("system", "worker_dont_fork");
|
$dont_fork = get_config("system", "worker_dont_fork");
|
||||||
|
|
||||||
|
@ -2060,7 +2042,7 @@ function proc_run($cmd){
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Now call the poller to execute the jobs that we just added to the queue
|
// Now call the poller to execute the jobs that we just added to the queue
|
||||||
$args = array("php", "include/poller.php", "no_cron");
|
$args = array("include/poller.php", "no_cron");
|
||||||
|
|
||||||
$a->proc_run($args);
|
$a->proc_run($args);
|
||||||
}
|
}
|
||||||
|
@ -2394,38 +2376,6 @@ function get_itemcachepath() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_lockpath() {
|
|
||||||
$lockpath = get_config('system','lockpath');
|
|
||||||
if (($lockpath != "") AND App::directory_usable($lockpath)) {
|
|
||||||
// We have a lock path and it is usable
|
|
||||||
return $lockpath;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We don't have a working preconfigured lock path, so we take the temp path.
|
|
||||||
$temppath = get_temppath();
|
|
||||||
|
|
||||||
if ($temppath != "") {
|
|
||||||
// To avoid any interferences with other systems we create our own directory
|
|
||||||
$lockpath = $temppath."/lock";
|
|
||||||
if (!is_dir($lockpath)) {
|
|
||||||
mkdir($lockpath);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (App::directory_usable($lockpath)) {
|
|
||||||
// The new path is usable, we are happy
|
|
||||||
set_config("system", "lockpath", $lockpath);
|
|
||||||
return $lockpath;
|
|
||||||
} else {
|
|
||||||
// We can't create a subdirectory, strange.
|
|
||||||
// But the directory seems to work, so we use it but don't store it.
|
|
||||||
return $temppath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reaching this point means that the operating system is configured badly.
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns the path where spool files are stored
|
* @brief Returns the path where spool files are stored
|
||||||
*
|
*
|
||||||
|
|
14
database.sql
14
database.sql
|
@ -1,5 +1,5 @@
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
-- Friendica 3.5.1-rc (Asparagus)
|
-- Friendica 3.5.2-dev (Asparagus)
|
||||||
-- DB_UPDATE_VERSION 1215
|
-- DB_UPDATE_VERSION 1215
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
|
|
||||||
|
@ -204,18 +204,6 @@ CREATE TABLE IF NOT EXISTS `conv` (
|
||||||
INDEX `uid` (`uid`)
|
INDEX `uid` (`uid`)
|
||||||
) DEFAULT CHARSET=utf8mb4;
|
) DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
--
|
|
||||||
-- TABLE deliverq
|
|
||||||
--
|
|
||||||
CREATE TABLE IF NOT EXISTS `deliverq` (
|
|
||||||
`id` int(10) unsigned NOT NULL auto_increment,
|
|
||||||
`cmd` varbinary(32) NOT NULL DEFAULT '',
|
|
||||||
`item` int(11) NOT NULL DEFAULT 0,
|
|
||||||
`contact` int(11) NOT NULL DEFAULT 0,
|
|
||||||
PRIMARY KEY(`id`),
|
|
||||||
UNIQUE INDEX `cmd_item_contact` (`cmd`,`item`,`contact`)
|
|
||||||
) DEFAULT CHARSET=utf8mb4;
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- TABLE event
|
-- TABLE event
|
||||||
--
|
--
|
||||||
|
|
|
@ -702,15 +702,6 @@ function posts_from_gcontact(App $a, $gcontact_id) {
|
||||||
else
|
else
|
||||||
$sql = "`item`.`uid` = %d";
|
$sql = "`item`.`uid` = %d";
|
||||||
|
|
||||||
if(get_config('system', 'old_pager')) {
|
|
||||||
$r = q("SELECT COUNT(*) AS `total` FROM `item`
|
|
||||||
WHERE `gcontact-id` = %d and $sql",
|
|
||||||
intval($gcontact_id),
|
|
||||||
intval(local_user()));
|
|
||||||
|
|
||||||
$a->set_pager_total($r[0]['total']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
|
$r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
|
||||||
`author-name` AS `name`, `owner-avatar` AS `photo`,
|
`author-name` AS `name`, `owner-avatar` AS `photo`,
|
||||||
`owner-link` AS `url`, `owner-avatar` AS `thumb`
|
`owner-link` AS `url`, `owner-avatar` AS `thumb`
|
||||||
|
@ -724,13 +715,9 @@ function posts_from_gcontact(App $a, $gcontact_id) {
|
||||||
intval($a->pager['itemspage'])
|
intval($a->pager['itemspage'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$o = conversation($a,$r,'community',false);
|
$o = conversation($a, $r, 'community', false);
|
||||||
|
|
||||||
if(!get_config('system', 'old_pager')) {
|
$o .= alt_pager($a, count($r));
|
||||||
$o .= alt_pager($a,count($r));
|
|
||||||
} else {
|
|
||||||
$o .= paginate($a);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
@ -763,15 +750,6 @@ function posts_from_contact_url(App $a, $contact_url) {
|
||||||
|
|
||||||
$author_id = intval($r[0]["author-id"]);
|
$author_id = intval($r[0]["author-id"]);
|
||||||
|
|
||||||
if (get_config('system', 'old_pager')) {
|
|
||||||
$r = q("SELECT COUNT(*) AS `total` FROM `item`
|
|
||||||
WHERE `author-id` = %d and $sql",
|
|
||||||
intval($author_id),
|
|
||||||
intval(local_user()));
|
|
||||||
|
|
||||||
$a->set_pager_total($r[0]['total']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$r = q(item_query()." AND `item`.`author-id` = %d AND ".$sql.
|
$r = q(item_query()." AND `item`.`author-id` = %d AND ".$sql.
|
||||||
" ORDER BY `item`.`created` DESC LIMIT %d, %d",
|
" ORDER BY `item`.`created` DESC LIMIT %d, %d",
|
||||||
intval($author_id),
|
intval($author_id),
|
||||||
|
@ -780,13 +758,9 @@ function posts_from_contact_url(App $a, $contact_url) {
|
||||||
intval($a->pager['itemspage'])
|
intval($a->pager['itemspage'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$o = conversation($a,$r,'community',false);
|
$o = conversation($a, $r, 'community', false);
|
||||||
|
|
||||||
if (!get_config('system', 'old_pager')) {
|
$o .= alt_pager($a, count($r));
|
||||||
$o .= alt_pager($a,count($r));
|
|
||||||
} else {
|
|
||||||
$o .= paginate($a);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1686,20 +1686,16 @@ use \Friendica\Core\Config;
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($r[0]['body'] != "") {
|
if ($r[0]['body'] != "") {
|
||||||
if (!intval(get_config('system','old_share'))) {
|
if (strpos($r[0]['body'], "[/share]") !== false) {
|
||||||
if (strpos($r[0]['body'], "[/share]") !== false) {
|
$pos = strpos($r[0]['body'], "[share");
|
||||||
$pos = strpos($r[0]['body'], "[share");
|
$post = substr($r[0]['body'], $pos);
|
||||||
$post = substr($r[0]['body'], $pos);
|
} else {
|
||||||
} else {
|
$post = share_header($r[0]['author-name'], $r[0]['author-link'], $r[0]['author-avatar'], $r[0]['guid'], $r[0]['created'], $r[0]['plink']);
|
||||||
$post = share_header($r[0]['author-name'], $r[0]['author-link'], $r[0]['author-avatar'], $r[0]['guid'], $r[0]['created'], $r[0]['plink']);
|
|
||||||
|
|
||||||
$post .= $r[0]['body'];
|
|
||||||
$post .= "[/share]";
|
|
||||||
}
|
|
||||||
$_REQUEST['body'] = $post;
|
|
||||||
} else
|
|
||||||
$_REQUEST['body'] = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8')."[url=".$r[0]['reply_url']."]".$r[0]['reply_author']."[/url] \n".$r[0]['body'];
|
|
||||||
|
|
||||||
|
$post .= $r[0]['body'];
|
||||||
|
$post .= "[/share]";
|
||||||
|
}
|
||||||
|
$_REQUEST['body'] = $post;
|
||||||
$_REQUEST['profile_uid'] = api_user();
|
$_REQUEST['profile_uid'] = api_user();
|
||||||
$_REQUEST['type'] = 'wall';
|
$_REQUEST['type'] = 'wall';
|
||||||
$_REQUEST['api_source'] = true;
|
$_REQUEST['api_source'] = true;
|
||||||
|
|
|
@ -125,6 +125,7 @@ if (isset($_SESSION) && x($_SESSION,'authenticated') && (!x($_POST,'auth-params'
|
||||||
$openid = new LightOpenID;
|
$openid = new LightOpenID;
|
||||||
$openid->identity = $openid_url;
|
$openid->identity = $openid_url;
|
||||||
$_SESSION['openid'] = $openid_url;
|
$_SESSION['openid'] = $openid_url;
|
||||||
|
$_SESSION['remember'] = $_POST['remember'];
|
||||||
$openid->returnUrl = App::get_baseurl(true).'/openid';
|
$openid->returnUrl = App::get_baseurl(true).'/openid';
|
||||||
goaway($openid->authUrl());
|
goaway($openid->authUrl());
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
@ -178,17 +179,12 @@ if (isset($_SESSION) && x($_SESSION,'authenticated') && (!x($_POST,'auth-params'
|
||||||
goaway(z_root());
|
goaway(z_root());
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the user specified to remember the authentication, then set a cookie
|
if (! $_POST['remember']) {
|
||||||
// that expires after one week (the default is when the browser is closed).
|
|
||||||
// The cookie will be renewed automatically.
|
|
||||||
// The week ensures that sessions will expire after some inactivity.
|
|
||||||
if ($_POST['remember'])
|
|
||||||
new_cookie(604800, $r[0]);
|
|
||||||
else
|
|
||||||
new_cookie(0); // 0 means delete on browser exit
|
new_cookie(0); // 0 means delete on browser exit
|
||||||
|
}
|
||||||
|
|
||||||
// if we haven't failed up this point, log them in.
|
// if we haven't failed up this point, log them in.
|
||||||
|
$_SESSION['remember'] = $_POST['remember'];
|
||||||
$_SESSION['last_login_date'] = datetime_convert('UTC','UTC');
|
$_SESSION['last_login_date'] = datetime_convert('UTC','UTC');
|
||||||
authenticate_success($record, true, true);
|
authenticate_success($record, true, true);
|
||||||
}
|
}
|
||||||
|
@ -203,39 +199,3 @@ function nuke_session() {
|
||||||
session_unset();
|
session_unset();
|
||||||
session_destroy();
|
session_destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Calculate the hash that is needed for the "Friendica" cookie
|
|
||||||
*
|
|
||||||
* @param array $user Record from "user" table
|
|
||||||
*
|
|
||||||
* @return string Hashed data
|
|
||||||
*/
|
|
||||||
function cookie_hash($user) {
|
|
||||||
return(hash("sha256", get_config("system", "site_prvkey").
|
|
||||||
$user["uprvkey"].
|
|
||||||
$user["password"]));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the "Friendica" cookie
|
|
||||||
*
|
|
||||||
* @param int $time
|
|
||||||
* @param array $user Record from "user" table
|
|
||||||
*/
|
|
||||||
function new_cookie($time, $user = array()) {
|
|
||||||
|
|
||||||
if ($time != 0)
|
|
||||||
$time = $time + time();
|
|
||||||
|
|
||||||
if ($user)
|
|
||||||
$value = json_encode(array("uid" => $user["uid"],
|
|
||||||
"hash" => cookie_hash($user),
|
|
||||||
"ip" => $_SERVER['REMOTE_ADDR']));
|
|
||||||
else
|
|
||||||
$value = "";
|
|
||||||
|
|
||||||
setcookie("Friendica", $value, $time, "/", "",
|
|
||||||
(get_config('system', 'ssl_policy') == SSL_POLICY_FULL), true);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -416,8 +416,8 @@ These Fields are not added below (yet). They are here to for bug search.
|
||||||
`item`.`shadow`,
|
`item`.`shadow`,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return "`item`.`author-link`, `item`.`author-name`, `item`.`author-avatar`,
|
return "`item`.`author-id`, `item`.`author-link`, `item`.`author-name`, `item`.`author-avatar`,
|
||||||
`item`.`owner-link`, `item`.`owner-name`, `item`.`owner-avatar`,
|
`item`.`owner-id`, `item`.`owner-link`, `item`.`owner-name`, `item`.`owner-avatar`,
|
||||||
`item`.`contact-id`, `item`.`uid`, `item`.`id`, `item`.`parent`,
|
`item`.`contact-id`, `item`.`uid`, `item`.`id`, `item`.`parent`,
|
||||||
`item`.`uri`, `item`.`thr-parent`, `item`.`parent-uri`,
|
`item`.`uri`, `item`.`thr-parent`, `item`.`parent-uri`,
|
||||||
`item`.`commented`, `item`.`created`, `item`.`edited`,
|
`item`.`commented`, `item`.`created`, `item`.`edited`,
|
||||||
|
@ -1066,8 +1066,9 @@ function builtin_activity_puller($item, &$conv_responses) {
|
||||||
else
|
else
|
||||||
$conv_responses[$mode][$item['thr-parent']] ++;
|
$conv_responses[$mode][$item['thr-parent']] ++;
|
||||||
|
|
||||||
if((local_user()) && (local_user() == $item['uid']) && ($item['self']))
|
if (public_contact() == $item['author-id']) {
|
||||||
$conv_responses[$mode][$item['thr-parent'] . '-self'] = 1;
|
$conv_responses[$mode][$item['thr-parent'] . '-self'] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
$conv_responses[$mode][$item['thr-parent'] . '-l'][] = $url;
|
$conv_responses[$mode][$item['thr-parent'] . '-l'][] = $url;
|
||||||
|
|
||||||
|
|
|
@ -6,26 +6,9 @@
|
||||||
* This script is started from mod/item.php to save some time when doing a post.
|
* 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");
|
require_once("include/threads.php");
|
||||||
|
|
||||||
function create_shadowentry_run($argv, $argc) {
|
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) {
|
if ($argc != 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -34,9 +17,4 @@ function create_shadowentry_run($argv, $argc) {
|
||||||
|
|
||||||
add_shadow_entry($message_id);
|
add_shadow_entry($message_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
|
||||||
create_shadowentry_run($_SERVER["argv"],$_SERVER["argc"]);
|
|
||||||
killme();
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,35 +1,11 @@
|
||||||
<?php
|
<?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;
|
use \Friendica\Core\Config;
|
||||||
|
|
||||||
require_once("boot.php");
|
require_once('include/photos.php');
|
||||||
require_once("include/photos.php");
|
require_once('include/user.php');
|
||||||
require_once("include/user.php");
|
|
||||||
|
|
||||||
|
|
||||||
function cron_run(&$argv, &$argc){
|
function cron_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/session.php');
|
||||||
require_once('include/datetime.php');
|
require_once('include/datetime.php');
|
||||||
|
@ -40,16 +16,6 @@ function cron_run(&$argv, &$argc){
|
||||||
require_once('mod/nodeinfo.php');
|
require_once('mod/nodeinfo.php');
|
||||||
require_once('include/post_update.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');
|
$last = get_config('system','last_cron');
|
||||||
|
|
||||||
$poll_interval = intval(get_config('system','cron_interval'));
|
$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');
|
logger('cron: start');
|
||||||
|
|
||||||
// run queue delivery process in the background
|
// run queue delivery process in the background
|
||||||
|
@ -85,34 +47,17 @@ function cron_run(&$argv, &$argc){
|
||||||
// Expire and remove user entries
|
// Expire and remove user entries
|
||||||
cron_expire_and_remove_users();
|
cron_expire_and_remove_users();
|
||||||
|
|
||||||
// If the worker is active, split the jobs in several sub processes
|
// Check OStatus conversations
|
||||||
if (get_config("system", "worker")) {
|
proc_run(PRIORITY_MEDIUM, "include/cronjobs.php", "ostatus_mentions");
|
||||||
// Check OStatus conversations
|
|
||||||
proc_run(PRIORITY_MEDIUM, "include/cronjobs.php", "ostatus_mentions");
|
|
||||||
|
|
||||||
// Check every conversation
|
// Check every conversation
|
||||||
proc_run(PRIORITY_MEDIUM, "include/cronjobs.php", "ostatus_conversations");
|
proc_run(PRIORITY_MEDIUM, "include/cronjobs.php", "ostatus_conversations");
|
||||||
|
|
||||||
// Call possible post update functions
|
// Call possible post update functions
|
||||||
proc_run(PRIORITY_LOW, "include/cronjobs.php", "post_update");
|
proc_run(PRIORITY_LOW, "include/cronjobs.php", "post_update");
|
||||||
|
|
||||||
// update nodeinfo data
|
// update nodeinfo data
|
||||||
proc_run(PRIORITY_LOW, "include/cronjobs.php", "nodeinfo");
|
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
// once daily run birthday_updates and then expire in background
|
// once daily run birthday_updates and then expire in background
|
||||||
|
|
||||||
|
@ -123,6 +68,8 @@ function cron_run(&$argv, &$argc){
|
||||||
|
|
||||||
update_contact_birthdays();
|
update_contact_birthdays();
|
||||||
|
|
||||||
|
proc_run(PRIORITY_LOW, "include/discover_poco.php", "update_server");
|
||||||
|
|
||||||
proc_run(PRIORITY_LOW, "include/discover_poco.php", "suggestions");
|
proc_run(PRIORITY_LOW, "include/discover_poco.php", "suggestions");
|
||||||
|
|
||||||
set_config('system','last_expire_day',$d2);
|
set_config('system','last_expire_day',$d2);
|
||||||
|
@ -213,14 +160,6 @@ function cron_poll_contacts($argc, $argv) {
|
||||||
$force = true;
|
$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 " : "");
|
$sql_extra = (($manual_id) ? " AND `id` = $manual_id " : "");
|
||||||
|
|
||||||
reload_plugins();
|
reload_plugins();
|
||||||
|
@ -335,9 +274,6 @@ function cron_poll_contacts($argc, $argv) {
|
||||||
} else {
|
} else {
|
||||||
proc_run(PRIORITY_LOW, 'include/onepoll.php', $contact['id']);
|
proc_run(PRIORITY_LOW, 'include/onepoll.php', $contact['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($interval)
|
|
||||||
@time_sleep_until(microtime(true) + (float) $interval);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -488,8 +424,3 @@ function cron_repair_database() {
|
||||||
/// - remove children when parent got lost
|
/// - remove children when parent got lost
|
||||||
/// - set contact-id in item when not present
|
/// - 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;
|
use \Friendica\Core\Config;
|
||||||
|
|
||||||
require_once("boot.php");
|
|
||||||
|
|
||||||
function cronhooks_run(&$argv, &$argc){
|
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');
|
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)) {
|
if (($argc == 2) AND is_array($a->hooks) AND array_key_exists("cron", $a->hooks)) {
|
||||||
foreach ($a->hooks["cron"] as $hook)
|
foreach ($a->hooks["cron"] as $hook)
|
||||||
if ($hook[1] == $argv[1]) {
|
if ($hook[1] == $argv[1]) {
|
||||||
|
@ -42,7 +16,7 @@ function cronhooks_run(&$argv, &$argc){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$last = get_config('system','last_cronhook');
|
$last = get_config('system', 'last_cronhook');
|
||||||
|
|
||||||
$poll_interval = intval(get_config('system','cronhook_interval'));
|
$poll_interval = intval(get_config('system','cronhook_interval'));
|
||||||
if(! $poll_interval)
|
if(! $poll_interval)
|
||||||
|
@ -62,22 +36,16 @@ function cronhooks_run(&$argv, &$argc){
|
||||||
|
|
||||||
$d = datetime_convert();
|
$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) {
|
foreach ($a->hooks["cron"] as $hook) {
|
||||||
logger("Calling cronhooks for '".$hook[1]."'", LOGGER_DEBUG);
|
logger("Calling cronhooks for '".$hook[1]."'", LOGGER_DEBUG);
|
||||||
proc_run(PRIORITY_MEDIUM, "include/cronhooks.php", $hook[1]);
|
proc_run(PRIORITY_MEDIUM, "include/cronhooks.php", $hook[1]);
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
call_hooks('cron', $d);
|
|
||||||
|
|
||||||
logger('cronhooks: end');
|
logger('cronhooks: end');
|
||||||
|
|
||||||
set_config('system','last_cronhook', time());
|
set_config('system', 'last_cronhook', time());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
|
||||||
cronhooks_run($_SERVER["argv"],$_SERVER["argc"]);
|
|
||||||
killme();
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,44 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
use \Friendica\Core\Config;
|
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){
|
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/datetime.php');
|
||||||
require_once('include/ostatus.php');
|
require_once('include/ostatus.php');
|
||||||
require_once('include/post_update.php');
|
require_once('include/post_update.php');
|
||||||
require_once('mod/nodeinfo.php');
|
require_once('mod/nodeinfo.php');
|
||||||
|
|
||||||
Config::load();
|
|
||||||
|
|
||||||
$a->set_baseurl(get_config('system','url'));
|
|
||||||
|
|
||||||
// No parameter set? So return
|
// No parameter set? So return
|
||||||
if ($argc <= 1)
|
if ($argc <= 1)
|
||||||
return;
|
return;
|
||||||
|
@ -71,8 +41,3 @@ function cronjobs_run(&$argv, &$argc){
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
|
||||||
cronjobs_run($_SERVER["argv"],$_SERVER["argc"]);
|
|
||||||
killme();
|
|
||||||
}
|
|
||||||
|
|
320
include/dba.php
320
include/dba.php
|
@ -1,17 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
require_once("dbm.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');
|
require_once('include/datetime.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,13 +12,12 @@ require_once('include/datetime.php');
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (! class_exists('dba')) {
|
|
||||||
class dba {
|
class dba {
|
||||||
|
|
||||||
private $debug = 0;
|
private $debug = 0;
|
||||||
private $db;
|
private $db;
|
||||||
private $result;
|
private $result;
|
||||||
public $mysqli = true;
|
private $driver;
|
||||||
public $connected = false;
|
public $connected = false;
|
||||||
public $error = false;
|
public $error = false;
|
||||||
|
|
||||||
|
@ -53,7 +40,7 @@ class dba {
|
||||||
if ($install) {
|
if ($install) {
|
||||||
if (strlen($server) && ($server !== 'localhost') && ($server !== '127.0.0.1')) {
|
if (strlen($server) && ($server !== 'localhost') && ($server !== '127.0.0.1')) {
|
||||||
if (! dns_get_record($server, DNS_A + DNS_CNAME + DNS_PTR)) {
|
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->connected = false;
|
||||||
$this->db = null;
|
$this->db = null;
|
||||||
return;
|
return;
|
||||||
|
@ -61,37 +48,52 @@ class dba {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (class_exists('mysqli')) {
|
if (class_exists('\PDO') && in_array('mysql', PDO::getAvailableDrivers())) {
|
||||||
$this->db = @new mysqli($server,$user,$pass,$db);
|
$this->driver = 'pdo';
|
||||||
if (! mysqli_connect_errno()) {
|
$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;
|
$this->connected = true;
|
||||||
}
|
}
|
||||||
if (isset($a->config["system"]["db_charset"])) {
|
} elseif (class_exists('mysqli')) {
|
||||||
$this->db->set_charset($a->config["system"]["db_charset"]);
|
$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 {
|
} elseif (function_exists('mysql_connect')) {
|
||||||
$this->mysqli = false;
|
$this->driver = 'mysql';
|
||||||
$this->db = mysql_connect($server,$user,$pass);
|
$this->db = mysql_connect($server,$user,$pass);
|
||||||
if ($this->db && mysql_select_db($db,$this->db)) {
|
if ($this->db && mysql_select_db($db,$this->db)) {
|
||||||
$this->connected = true;
|
$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) {
|
if (!$this->connected) {
|
||||||
$this->db = null;
|
$this->db = null;
|
||||||
if (!$install) {
|
if (!$install) {
|
||||||
system_unavailable();
|
system_unavailable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$a->save_timestamp($stamp1, "network");
|
$a->save_timestamp($stamp1, "network");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getdb() {
|
|
||||||
return $this->db;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns the MySQL server version string
|
* @brief Returns the MySQL server version string
|
||||||
*
|
*
|
||||||
|
@ -101,12 +103,18 @@ class dba {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function server_info() {
|
public function server_info() {
|
||||||
if ($this->mysqli) {
|
switch ($this->driver) {
|
||||||
$return = $this->db->server_info;
|
case 'pdo':
|
||||||
} else {
|
$version = $this->db->getAttribute(PDO::ATTR_SERVER_VERSION);
|
||||||
$return = mysql_get_server_info($this->db);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->mysqli) {
|
switch ($this->driver) {
|
||||||
$return = $this->result->num_rows;
|
case 'pdo':
|
||||||
} else {
|
$rows = $this->result->rowCount();
|
||||||
$return = mysql_num_rows($this->result);
|
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)) {
|
if ((intval($a->config["system"]["db_loglimit_index"]) > 0)) {
|
||||||
$log = (in_array($row['key'], $watchlist) AND
|
$log = (in_array($row['key'], $watchlist) AND
|
||||||
($row['rows'] >= intval($a->config["system"]["db_loglimit_index"])));
|
($row['rows'] >= intval($a->config["system"]["db_loglimit_index"])));
|
||||||
} else
|
} else {
|
||||||
$log = false;
|
$log = false;
|
||||||
|
}
|
||||||
|
|
||||||
if ((intval($a->config["system"]["db_loglimit_index_high"]) > 0) AND ($row['rows'] >= intval($a->config["system"]["db_loglimit_index_high"]))) {
|
if ((intval($a->config["system"]["db_loglimit_index_high"]) > 0) AND ($row['rows'] >= intval($a->config["system"]["db_loglimit_index_high"]))) {
|
||||||
$log = true;
|
$log = true;
|
||||||
|
@ -203,13 +218,7 @@ class dba {
|
||||||
|
|
||||||
$this->error = '';
|
$this->error = '';
|
||||||
|
|
||||||
// Check the connection (This can reconnect the connection - if configured)
|
$connstr = ($this->connected() ? "Connected" : "Disonnected");
|
||||||
if ($this->mysqli) {
|
|
||||||
$connected = $this->db->ping();
|
|
||||||
} else {
|
|
||||||
$connected = mysql_ping($this->db);
|
|
||||||
}
|
|
||||||
$connstr = ($connected ? "Connected" : "Disonnected");
|
|
||||||
|
|
||||||
$stamp1 = microtime(true);
|
$stamp1 = microtime(true);
|
||||||
|
|
||||||
|
@ -219,10 +228,22 @@ class dba {
|
||||||
$sql = "/*".$a->callstack()." */ ".$sql;
|
$sql = "/*".$a->callstack()." */ ".$sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->mysqli) {
|
$columns = 0;
|
||||||
$result = @$this->db->query($sql);
|
|
||||||
} else {
|
switch ($this->driver) {
|
||||||
$result = @mysql_query($sql,$this->db);
|
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);
|
$stamp2 = microtime(true);
|
||||||
$duration = (float)($stamp2-$stamp1);
|
$duration = (float)($stamp2-$stamp1);
|
||||||
|
@ -243,16 +264,27 @@ class dba {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->mysqli) {
|
switch ($this->driver) {
|
||||||
if ($this->db->errno) {
|
case 'pdo':
|
||||||
$this->error = $this->db->error;
|
$errorInfo = $this->db->errorInfo();
|
||||||
$this->errorno = $this->db->errno;
|
if ($errorInfo) {
|
||||||
}
|
$this->error = $errorInfo[2];
|
||||||
} elseif (mysql_errno($this->db)) {
|
$this->errorno = $errorInfo[1];
|
||||||
$this->error = mysql_error($this->db);
|
}
|
||||||
$this->errorno = mysql_errno($this->db);
|
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)) {
|
if (strlen($this->error)) {
|
||||||
logger('DB Error ('.$connstr.') '.$this->errorno.': '.$this->error);
|
logger('DB Error ('.$connstr.') '.$this->errorno.': '.$this->error);
|
||||||
}
|
}
|
||||||
|
@ -266,10 +298,16 @@ class dba {
|
||||||
} elseif ($result === true) {
|
} elseif ($result === true) {
|
||||||
$mesg = 'true';
|
$mesg = 'true';
|
||||||
} else {
|
} else {
|
||||||
if ($this->mysqli) {
|
switch ($this->driver) {
|
||||||
$mesg = $result->num_rows . ' results' . EOL;
|
case 'pdo':
|
||||||
} else {
|
$mesg = $result->rowCount().' results'.EOL;
|
||||||
$mesg = mysql_num_rows($result) . ' 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;
|
return $result;
|
||||||
}
|
}
|
||||||
if ($onlyquery) {
|
if ($onlyquery) {
|
||||||
|
@ -302,18 +340,32 @@ class dba {
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = array();
|
$r = array();
|
||||||
if ($this->mysqli) {
|
switch ($this->driver) {
|
||||||
if ($result->num_rows) {
|
case 'pdo':
|
||||||
while($x = $result->fetch_array(MYSQLI_ASSOC))
|
while ($x = $result->fetch(PDO::FETCH_ASSOC)) {
|
||||||
$r[] = $x;
|
$r[] = $x;
|
||||||
|
}
|
||||||
|
$result->closeCursor();
|
||||||
|
break;
|
||||||
|
case 'mysqli':
|
||||||
|
while ($x = $result->fetch_array(MYSQLI_ASSOC)) {
|
||||||
|
$r[] = $x;
|
||||||
|
}
|
||||||
$result->free_result();
|
$result->free_result();
|
||||||
}
|
break;
|
||||||
} else {
|
case 'mysql':
|
||||||
if (mysql_num_rows($result)) {
|
while ($x = mysql_fetch_array($result, MYSQL_ASSOC)) {
|
||||||
while($x = mysql_fetch_array($result, MYSQL_ASSOC))
|
|
||||||
$r[] = $x;
|
$r[] = $x;
|
||||||
|
}
|
||||||
mysql_free_result($result);
|
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");
|
//$a->save_timestamp($stamp1, "database");
|
||||||
|
@ -328,12 +380,16 @@ class dba {
|
||||||
$x = false;
|
$x = false;
|
||||||
|
|
||||||
if ($this->result) {
|
if ($this->result) {
|
||||||
if ($this->mysqli) {
|
switch ($this->driver) {
|
||||||
if ($this->result->num_rows)
|
case 'pdo':
|
||||||
|
$x = $this->result->fetch(PDO::FETCH_ASSOC);
|
||||||
|
break;
|
||||||
|
case 'mysqli':
|
||||||
$x = $this->result->fetch_array(MYSQLI_ASSOC);
|
$x = $this->result->fetch_array(MYSQLI_ASSOC);
|
||||||
} else {
|
break;
|
||||||
if (mysql_num_rows($this->result))
|
case 'mysql':
|
||||||
$x = mysql_fetch_array($this->result, MYSQL_ASSOC);
|
$x = mysql_fetch_array($this->result, MYSQL_ASSOC);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return($x);
|
return($x);
|
||||||
|
@ -341,10 +397,16 @@ class dba {
|
||||||
|
|
||||||
public function qclose() {
|
public function qclose() {
|
||||||
if ($this->result) {
|
if ($this->result) {
|
||||||
if ($this->mysqli) {
|
switch ($this->driver) {
|
||||||
$this->result->free_result();
|
case 'pdo':
|
||||||
} else {
|
$this->result->closeCursor();
|
||||||
mysql_free_result($this->result);
|
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) {
|
public function escape($str) {
|
||||||
if ($this->db && $this->connected) {
|
if ($this->db && $this->connected) {
|
||||||
if ($this->mysqli) {
|
switch ($this->driver) {
|
||||||
return @$this->db->real_escape_string($str);
|
case 'pdo':
|
||||||
} else {
|
return substr(@$this->db->quote($str, PDO::PARAM_STR), 1, -1);
|
||||||
return @mysql_real_escape_string($str,$this->db);
|
case 'mysqli':
|
||||||
|
return @$this->db->real_escape_string($str);
|
||||||
|
case 'mysql':
|
||||||
|
return @mysql_real_escape_string($str,$this->db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function connected() {
|
function connected() {
|
||||||
if ($this->mysqli) {
|
switch ($this->driver) {
|
||||||
$connected = $this->db->ping();
|
case 'pdo':
|
||||||
} else {
|
// Not sure if this really is working like expected
|
||||||
$connected = mysql_ping($this->db);
|
$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;
|
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() {
|
function __destruct() {
|
||||||
if ($this->db) {
|
if ($this->db) {
|
||||||
if ($this->mysqli) {
|
switch ($this->driver) {
|
||||||
$this->db->close();
|
case 'pdo':
|
||||||
} else {
|
$this->db = null;
|
||||||
mysql_close($this->db);
|
break;
|
||||||
|
case 'mysqli':
|
||||||
|
$this->db->close();
|
||||||
|
break;
|
||||||
|
case 'mysql':
|
||||||
|
mysql_close($this->db);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}
|
}
|
||||||
|
|
||||||
if (! function_exists('printable')) {
|
|
||||||
function printable($s) {
|
function printable($s) {
|
||||||
$s = preg_replace("~([\x01-\x08\x0E-\x0F\x10-\x1F\x7F-\xFF])~",".", $s);
|
$s = preg_replace("~([\x01-\x08\x0E-\x0F\x10-\x1F\x7F-\xFF])~",".", $s);
|
||||||
$s = str_replace("\x00",'.',$s);
|
$s = str_replace("\x00",'.',$s);
|
||||||
|
@ -391,37 +483,32 @@ function printable($s) {
|
||||||
$s = escape_tags($s);
|
$s = escape_tags($s);
|
||||||
}
|
}
|
||||||
return $s;
|
return $s;
|
||||||
}}
|
}
|
||||||
|
|
||||||
// Procedural functions
|
// Procedural functions
|
||||||
if (! function_exists('dbg')) {
|
|
||||||
function dbg($state) {
|
function dbg($state) {
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
if ($db) {
|
if ($db) {
|
||||||
$db->dbg($state);
|
$db->dbg($state);
|
||||||
}
|
}
|
||||||
}}
|
}
|
||||||
|
|
||||||
if (! function_exists('dbesc')) {
|
|
||||||
function dbesc($str) {
|
function dbesc($str) {
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
if ($db && $db->connected) {
|
if ($db && $db->connected) {
|
||||||
return($db->escape($str));
|
return($db->escape($str));
|
||||||
} else {
|
} else {
|
||||||
return(str_replace("'","\\'",$str));
|
return(str_replace("'","\\'",$str));
|
||||||
}
|
}
|
||||||
}}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Function: q($sql,$args);
|
// Function: q($sql,$args);
|
||||||
// Description: execute SQL query with printf style args.
|
// Description: execute SQL query with printf style args.
|
||||||
// Example: $r = q("SELECT * FROM `%s` WHERE `uid` = %d",
|
// Example: $r = q("SELECT * FROM `%s` WHERE `uid` = %d",
|
||||||
// 'user', 1);
|
// 'user', 1);
|
||||||
|
|
||||||
if (! function_exists('q')) {
|
|
||||||
function q($sql) {
|
function q($sql) {
|
||||||
|
|
||||||
global $db;
|
global $db;
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
unset($args[0]);
|
unset($args[0]);
|
||||||
|
@ -445,8 +532,7 @@ function q($sql) {
|
||||||
*/
|
*/
|
||||||
logger('dba: no database: ' . print_r($args,true));
|
logger('dba: no database: ' . print_r($args,true));
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Performs a query with "dirty reads"
|
* @brief Performs a query with "dirty reads"
|
||||||
|
@ -458,8 +544,8 @@ function q($sql) {
|
||||||
* @return array Query array
|
* @return array Query array
|
||||||
*/
|
*/
|
||||||
function qu($sql) {
|
function qu($sql) {
|
||||||
|
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
unset($args[0]);
|
unset($args[0]);
|
||||||
|
|
||||||
|
@ -484,7 +570,6 @@ function qu($sql) {
|
||||||
*/
|
*/
|
||||||
logger('dba: no database: ' . print_r($args,true));
|
logger('dba: no database: ' . print_r($args,true));
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -492,40 +577,31 @@ function qu($sql) {
|
||||||
* Raw db query, no arguments
|
* Raw db query, no arguments
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (! function_exists('dbq')) {
|
|
||||||
function dbq($sql) {
|
function dbq($sql) {
|
||||||
|
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
if ($db && $db->connected) {
|
if ($db && $db->connected) {
|
||||||
$ret = $db->q($sql);
|
$ret = $db->q($sql);
|
||||||
} else {
|
} else {
|
||||||
$ret = false;
|
$ret = false;
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Caller is responsible for ensuring that any integer arguments to
|
// Caller is responsible for ensuring that any integer arguments to
|
||||||
// dbesc_array are actually integers and not malformed strings containing
|
// dbesc_array are actually integers and not malformed strings containing
|
||||||
// SQL injection vectors. All integer array elements should be specifically
|
// SQL injection vectors. All integer array elements should be specifically
|
||||||
// cast to int to avoid trouble.
|
// cast to int to avoid trouble.
|
||||||
|
|
||||||
|
|
||||||
if (! function_exists('dbesc_array_cb')) {
|
|
||||||
function dbesc_array_cb(&$item, $key) {
|
function dbesc_array_cb(&$item, $key) {
|
||||||
if (is_string($item))
|
if (is_string($item))
|
||||||
$item = dbesc($item);
|
$item = dbesc($item);
|
||||||
}}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (! function_exists('dbesc_array')) {
|
|
||||||
function dbesc_array(&$arr) {
|
function dbesc_array(&$arr) {
|
||||||
if (is_array($arr) && count($arr)) {
|
if (is_array($arr) && count($arr)) {
|
||||||
array_walk($arr,'dbesc_array_cb');
|
array_walk($arr,'dbesc_array_cb');
|
||||||
}
|
}
|
||||||
}}
|
}
|
||||||
|
|
||||||
|
|
||||||
function dba_timer() {
|
function dba_timer() {
|
||||||
return microtime(true);
|
return microtime(true);
|
||||||
|
|
|
@ -5,26 +5,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use \Friendica\Core\Config;
|
||||||
use \Friendica\Core\PConfig;
|
|
||||||
|
|
||||||
require_once("boot.php");
|
|
||||||
|
|
||||||
function dbclean_run(&$argv, &$argc) {
|
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)) {
|
if (!Config::get('system', 'dbclean', false)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +17,7 @@ function dbclean_run(&$argv, &$argc) {
|
||||||
$stage = 0;
|
$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', 1);
|
||||||
proc_run(PRIORITY_LOW, 'include/dbclean.php', 2);
|
proc_run(PRIORITY_LOW, 'include/dbclean.php', 2);
|
||||||
proc_run(PRIORITY_LOW, 'include/dbclean.php', 3);
|
proc_run(PRIORITY_LOW, 'include/dbclean.php', 3);
|
||||||
|
@ -56,12 +38,8 @@ function remove_orphans($stage = 0) {
|
||||||
|
|
||||||
$count = 0;
|
$count = 0;
|
||||||
|
|
||||||
// With activated worker we split the deletion in many small tasks
|
// We split the deletion in many small tasks
|
||||||
if (Config::get("system", "worker")) {
|
$limit = 1000;
|
||||||
$limit = 1000;
|
|
||||||
} else {
|
|
||||||
$limit = 10000;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($stage == 1) OR ($stage == 0)) {
|
if (($stage == 1) OR ($stage == 0)) {
|
||||||
logger("Deleting old global item entries from item table without user copy");
|
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
|
// 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');
|
proc_run(PRIORITY_MEDIUM, 'include/dbclean.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
|
||||||
dbclean_run($_SERVER["argv"],$_SERVER["argc"]);
|
|
||||||
killme();
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -712,18 +712,6 @@ function db_definition($charset) {
|
||||||
"uid" => array("uid"),
|
"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(
|
$database["event"] = array(
|
||||||
"fields" => array(
|
"fields" => array(
|
||||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||||
|
|
|
@ -2,32 +2,12 @@
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use \Friendica\Core\Config;
|
||||||
|
|
||||||
require_once("boot.php");
|
|
||||||
|
|
||||||
function dbupdate_run(&$argv, &$argc) {
|
function dbupdate_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);
|
|
||||||
}
|
|
||||||
|
|
||||||
Config::load();
|
|
||||||
|
|
||||||
// We are deleting the latest dbupdate entry.
|
// We are deleting the latest dbupdate entry.
|
||||||
// This is done to avoid endless loops because the update was interupted.
|
// 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);
|
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;
|
use \Friendica\Core\Config;
|
||||||
|
|
||||||
require_once("boot.php");
|
|
||||||
require_once('include/queue_fn.php');
|
require_once('include/queue_fn.php');
|
||||||
require_once('include/html2plain.php');
|
require_once('include/html2plain.php');
|
||||||
require_once("include/Scrape.php");
|
require_once('include/Scrape.php');
|
||||||
require_once('include/diaspora.php');
|
require_once('include/diaspora.php');
|
||||||
require_once("include/ostatus.php");
|
require_once('include/ostatus.php');
|
||||||
require_once("include/dfrn.php");
|
require_once('include/dfrn.php');
|
||||||
|
|
||||||
function delivery_run(&$argv, &$argc){
|
function delivery_run(&$argv, &$argc){
|
||||||
global $a, $db;
|
global $a;
|
||||||
|
|
||||||
if (is_null($a)) {
|
require_once('include/datetime.php');
|
||||||
$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/items.php');
|
||||||
require_once('include/bbcode.php');
|
require_once('include/bbcode.php');
|
||||||
require_once('include/email.php');
|
require_once('include/email.php');
|
||||||
|
|
||||||
Config::load();
|
|
||||||
|
|
||||||
load_hooks();
|
|
||||||
|
|
||||||
if ($argc < 3) {
|
if ($argc < 3) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$a->set_baseurl(get_config('system','url'));
|
|
||||||
|
|
||||||
logger('delivery: invoked: '. print_r($argv,true), LOGGER_DEBUG);
|
logger('delivery: invoked: '. print_r($argv,true), LOGGER_DEBUG);
|
||||||
|
|
||||||
$cmd = $argv[1];
|
$cmd = $argv[1];
|
||||||
|
@ -49,30 +30,6 @@ function delivery_run(&$argv, &$argc){
|
||||||
|
|
||||||
$contact_id = intval($argv[$x]);
|
$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) {
|
if (!$item_id || !$contact_id) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -577,8 +534,3 @@ function delivery_run(&$argv, &$argc){
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
|
||||||
delivery_run($_SERVER["argv"],$_SERVER["argc"]);
|
|
||||||
killme();
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,36 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
require_once("boot.php");
|
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use \Friendica\Core\Config;
|
||||||
|
|
||||||
function directory_run(&$argv, &$argc){
|
function directory_run(&$argv, &$argc){
|
||||||
global $a, $db;
|
if ($argc != 2) {
|
||||||
|
return;
|
||||||
if(is_null($a)) {
|
|
||||||
$a = new App;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_null($db)) {
|
$dir = get_config('system', 'directory');
|
||||||
@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 (!strlen($dir)) {
|
||||||
|
|
||||||
if($argc != 2)
|
|
||||||
return;
|
|
||||||
|
|
||||||
load_hooks();
|
|
||||||
|
|
||||||
|
|
||||||
$a->set_baseurl(get_config('system','url'));
|
|
||||||
|
|
||||||
$dir = get_config('system','directory');
|
|
||||||
|
|
||||||
if(! strlen($dir))
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$dir .= "/submit";
|
$dir .= "/submit";
|
||||||
|
|
||||||
|
@ -39,13 +19,8 @@ function directory_run(&$argv, &$argc){
|
||||||
call_hooks('globaldir_update', $arr);
|
call_hooks('globaldir_update', $arr);
|
||||||
|
|
||||||
logger('Updating directory: ' . $arr['url'], LOGGER_DEBUG);
|
logger('Updating directory: ' . $arr['url'], LOGGER_DEBUG);
|
||||||
if(strlen($arr['url']))
|
if (strlen($arr['url'])) {
|
||||||
fetch_url($dir . '?url=' . bin2hex($arr['url']));
|
fetch_url($dir . '?url=' . bin2hex($arr['url']));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
|
||||||
directory_run($_SERVER["argv"],$_SERVER["argc"]);
|
|
||||||
killme();
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,62 +2,64 @@
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
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){
|
function discover_poco_run(&$argv, &$argc) {
|
||||||
global $a, $db;
|
|
||||||
|
|
||||||
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)) {
|
if (($argc > 2) && ($argv[1] == "dirsearch")) {
|
||||||
@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")) {
|
|
||||||
$search = urldecode($argv[2]);
|
$search = urldecode($argv[2]);
|
||||||
$mode = 1;
|
$mode = 1;
|
||||||
} elseif(($argc == 2) && ($argv[1] == "checkcontact")) {
|
} elseif (($argc == 2) && ($argv[1] == "checkcontact")) {
|
||||||
$mode = 2;
|
$mode = 2;
|
||||||
} elseif(($argc == 2) && ($argv[1] == "suggestions")) {
|
} elseif (($argc == 2) && ($argv[1] == "suggestions")) {
|
||||||
$mode = 3;
|
$mode = 3;
|
||||||
|
} elseif (($argc == 3) && ($argv[1] == "server")) {
|
||||||
|
$mode = 4;
|
||||||
|
} elseif (($argc == 2) && ($argv[1] == "update_server")) {
|
||||||
|
$mode = 5;
|
||||||
} elseif ($argc == 1) {
|
} elseif ($argc == 1) {
|
||||||
$search = "";
|
$search = "";
|
||||||
$mode = 0;
|
$mode = 0;
|
||||||
} else
|
} else {
|
||||||
die("Unknown or missing parameter ".$argv[1]."\n");
|
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);
|
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();
|
update_suggestions();
|
||||||
elseif (($mode == 2) AND get_config('system','poco_completion'))
|
} elseif (($mode == 2) AND get_config('system','poco_completion')) {
|
||||||
discover_users();
|
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);
|
discover_directory($search);
|
||||||
gs_search_user($search);
|
gs_search_user($search);
|
||||||
} elseif (($mode == 0) AND ($search == "") and (get_config('system','poco_discovery') > 0)) {
|
} elseif (($mode == 0) AND ($search == "") and (get_config('system','poco_discovery') > 0)) {
|
||||||
|
@ -74,6 +76,33 @@ function discover_poco_run(&$argv, &$argc){
|
||||||
return;
|
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() {
|
function discover_users() {
|
||||||
logger("Discover users", LOGGER_DEBUG);
|
logger("Discover users", LOGGER_DEBUG);
|
||||||
|
|
||||||
|
@ -84,9 +113,9 @@ function discover_users() {
|
||||||
dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA),
|
dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA),
|
||||||
dbesc(NETWORK_OSTATUS), dbesc(NETWORK_FEED));
|
dbesc(NETWORK_OSTATUS), dbesc(NETWORK_FEED));
|
||||||
|
|
||||||
if (!$users)
|
if (!$users) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
$checked = 0;
|
$checked = 0;
|
||||||
|
|
||||||
foreach ($users AS $user) {
|
foreach ($users AS $user) {
|
||||||
|
@ -111,27 +140,29 @@ function discover_users() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user["server_url"] != "")
|
if ($user["server_url"] != "") {
|
||||||
$server_url = $user["server_url"];
|
$server_url = $user["server_url"];
|
||||||
else
|
} else {
|
||||||
$server_url = poco_detect_server($user["url"]);
|
$server_url = poco_detect_server($user["url"]);
|
||||||
|
}
|
||||||
if (($server_url == "") OR poco_check_server($server_url, $gcontacts[0]["network"])) {
|
if (($server_url == "") OR poco_check_server($server_url, $gcontacts[0]["network"])) {
|
||||||
logger('Check user '.$user["url"]);
|
logger('Check user '.$user["url"]);
|
||||||
poco_last_updated($user["url"], true);
|
poco_last_updated($user["url"], true);
|
||||||
|
|
||||||
if (++$checked > 100)
|
if (++$checked > 100) {
|
||||||
return;
|
return;
|
||||||
} else
|
}
|
||||||
|
} else {
|
||||||
q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `nurl` = '%s'",
|
q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `nurl` = '%s'",
|
||||||
dbesc(datetime_convert()), dbesc(normalise_link($user["url"])));
|
dbesc(datetime_convert()), dbesc(normalise_link($user["url"])));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function discover_directory($search) {
|
function discover_directory($search) {
|
||||||
|
|
||||||
$data = Cache::get("dirsearch:".$search);
|
$data = Cache::get("dirsearch:".$search);
|
||||||
if (!is_null($data)){
|
if (!is_null($data)) {
|
||||||
// Only search for the same item every 24 hours
|
// Only search for the same item every 24 hours
|
||||||
if (time() < $data + (60 * 60 * 24)) {
|
if (time() < $data + (60 * 60 * 24)) {
|
||||||
logger("Already searched for ".$search." in the last 24 hours", LOGGER_DEBUG);
|
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));
|
$x = fetch_url(get_server()."/lsearch?p=1&n=500&search=".urlencode($search));
|
||||||
$j = json_decode($x);
|
$j = json_decode($x);
|
||||||
|
|
||||||
if(count($j->results))
|
if (count($j->results)) {
|
||||||
foreach($j->results as $jj) {
|
foreach($j->results as $jj) {
|
||||||
// Check if the contact already exists
|
// Check if the contact already exists
|
||||||
$exists = q("SELECT `id`, `last_contact`, `last_failure`, `updated` FROM `gcontact` WHERE `nurl` = '%s'", normalise_link($jj->url));
|
$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);
|
logger("Profile ".$jj->url." already exists (".$search.")", LOGGER_DEBUG);
|
||||||
|
|
||||||
if (($exists[0]["last_contact"] < $exists[0]["last_failure"]) AND
|
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;
|
continue;
|
||||||
|
}
|
||||||
// Update the contact
|
// Update the contact
|
||||||
poco_last_updated($jj->url);
|
poco_last_updated($jj->url);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Harcoded paths aren't so good. But in this case it is okay.
|
$server_url = poco_detect_server($jj->url);
|
||||||
// First: We only will get Friendica contacts (which always are using this url schema)
|
if ($server_url != '') {
|
||||||
// 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)
|
|
||||||
if (!poco_check_server($server_url)) {
|
if (!poco_check_server($server_url)) {
|
||||||
logger("Friendica server ".$server_url." doesn't answer.", LOGGER_DEBUG);
|
logger("Friendica server ".$server_url." doesn't answer.", LOGGER_DEBUG);
|
||||||
continue;
|
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);
|
$data = probe_url($jj->url);
|
||||||
if ($data["network"] == NETWORK_DFRN) {
|
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);
|
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);
|
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);
|
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);
|
$url = "http://gstools.org/api/users_search/".urlencode($search);
|
||||||
|
|
||||||
$result = z_fetch_url($url);
|
$result = z_fetch_url($url);
|
||||||
if (!$result["success"])
|
if (!$result["success"]) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
$contacts = json_decode($result["body"]);
|
$contacts = json_decode($result["body"]);
|
||||||
|
|
||||||
if ($contacts->status == 'ERROR')
|
if ($contacts->status == 'ERROR') {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
foreach($contacts->data AS $user) {
|
foreach($contacts->data AS $user) {
|
||||||
$contact = probe_url($user->site_address."/".$user->name);
|
$contact = probe_url($user->site_address."/".$user->name);
|
||||||
if ($contact["network"] != NETWORK_PHANTOM) {
|
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;
|
use \Friendica\Core\Config;
|
||||||
|
|
||||||
require_once("boot.php");
|
|
||||||
|
|
||||||
function expire_run(&$argv, &$argc){
|
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/datetime.php');
|
||||||
require_once('include/items.php');
|
require_once('include/items.php');
|
||||||
require_once('include/Contact.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
|
// 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");
|
$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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
|
||||||
expire_run($_SERVER["argv"],$_SERVER["argc"]);
|
|
||||||
killme();
|
|
||||||
}
|
|
||||||
|
|
207
include/feed.php
207
include/feed.php
|
@ -17,11 +17,11 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
if (!$simulate)
|
if (!$simulate) {
|
||||||
logger("Import Atom/RSS feed '".$contact["name"]."' (Contact ".$contact["id"].") for user ".$importer["uid"], LOGGER_DEBUG);
|
logger("Import Atom/RSS feed '".$contact["name"]."' (Contact ".$contact["id"].") for user ".$importer["uid"], LOGGER_DEBUG);
|
||||||
else
|
} else {
|
||||||
logger("Test Atom/RSS feed", LOGGER_DEBUG);
|
logger("Test Atom/RSS feed", LOGGER_DEBUG);
|
||||||
|
}
|
||||||
if ($xml == "") {
|
if ($xml == "") {
|
||||||
logger('XML is empty.', LOGGER_DEBUG);
|
logger('XML is empty.', LOGGER_DEBUG);
|
||||||
return;
|
return;
|
||||||
|
@ -45,63 +45,69 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
|
||||||
$author["author-link"] = $xpath->evaluate('/rdf:RDF/rss:channel/rss:link/text()')->item(0)->nodeValue;
|
$author["author-link"] = $xpath->evaluate('/rdf:RDF/rss:channel/rss:link/text()')->item(0)->nodeValue;
|
||||||
$author["author-name"] = $xpath->evaluate('/rdf:RDF/rss:channel/rss:title/text()')->item(0)->nodeValue;
|
$author["author-name"] = $xpath->evaluate('/rdf:RDF/rss:channel/rss:title/text()')->item(0)->nodeValue;
|
||||||
|
|
||||||
if ($author["author-name"] == "")
|
if ($author["author-name"] == "") {
|
||||||
$author["author-name"] = $xpath->evaluate('/rdf:RDF/rss:channel/rss:description/text()')->item(0)->nodeValue;
|
$author["author-name"] = $xpath->evaluate('/rdf:RDF/rss:channel/rss:description/text()')->item(0)->nodeValue;
|
||||||
|
}
|
||||||
$entries = $xpath->query('/rdf:RDF/rss:item');
|
$entries = $xpath->query('/rdf:RDF/rss:item');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is it Atom?
|
// Is it Atom?
|
||||||
if ($xpath->query('/atom:feed')->length > 0) {
|
if ($xpath->query('/atom:feed')->length > 0) {
|
||||||
$alternate = $xpath->query("atom:link[@rel='alternate']")->item(0)->attributes;
|
$alternate = $xpath->query("atom:link[@rel='alternate']")->item(0)->attributes;
|
||||||
if (is_object($alternate))
|
if (is_object($alternate)) {
|
||||||
foreach($alternate AS $attributes)
|
foreach($alternate AS $attributes) {
|
||||||
if ($attributes->name == "href")
|
if ($attributes->name == "href") {
|
||||||
$author["author-link"] = $attributes->textContent;
|
$author["author-link"] = $attributes->textContent;
|
||||||
|
}
|
||||||
if ($author["author-link"] == "")
|
}
|
||||||
$author["author-link"] = $author["author-id"];
|
|
||||||
|
|
||||||
if ($author["author-link"] == "") {
|
|
||||||
$self = $xpath->query("atom:link[@rel='self']")->item(0)->attributes;
|
|
||||||
if (is_object($self))
|
|
||||||
foreach($self AS $attributes)
|
|
||||||
if ($attributes->name == "href")
|
|
||||||
$author["author-link"] = $attributes->textContent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($author["author-link"] == "")
|
if ($author["author-link"] == "") {
|
||||||
$author["author-link"] = $xpath->evaluate('/atom:feed/atom:id/text()')->item(0)->nodeValue;
|
$author["author-link"] = $author["author-id"];
|
||||||
|
}
|
||||||
|
if ($author["author-link"] == "") {
|
||||||
|
$self = $xpath->query("atom:link[@rel='self']")->item(0)->attributes;
|
||||||
|
if (is_object($self)) {
|
||||||
|
foreach($self AS $attributes) {
|
||||||
|
if ($attributes->name == "href") {
|
||||||
|
$author["author-link"] = $attributes->textContent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($author["author-link"] == "") {
|
||||||
|
$author["author-link"] = $xpath->evaluate('/atom:feed/atom:id/text()')->item(0)->nodeValue;
|
||||||
|
}
|
||||||
$author["author-avatar"] = $xpath->evaluate('/atom:feed/atom:logo/text()')->item(0)->nodeValue;
|
$author["author-avatar"] = $xpath->evaluate('/atom:feed/atom:logo/text()')->item(0)->nodeValue;
|
||||||
|
|
||||||
$author["author-name"] = $xpath->evaluate('/atom:feed/atom:title/text()')->item(0)->nodeValue;
|
$author["author-name"] = $xpath->evaluate('/atom:feed/atom:title/text()')->item(0)->nodeValue;
|
||||||
|
|
||||||
if ($author["author-name"] == "")
|
if ($author["author-name"] == "") {
|
||||||
$author["author-name"] = $xpath->evaluate('/atom:feed/atom:subtitle/text()')->item(0)->nodeValue;
|
$author["author-name"] = $xpath->evaluate('/atom:feed/atom:subtitle/text()')->item(0)->nodeValue;
|
||||||
|
}
|
||||||
if ($author["author-name"] == "")
|
if ($author["author-name"] == "") {
|
||||||
$author["author-name"] = $xpath->evaluate('/atom:feed/atom:author/atom:name/text()')->item(0)->nodeValue;
|
$author["author-name"] = $xpath->evaluate('/atom:feed/atom:author/atom:name/text()')->item(0)->nodeValue;
|
||||||
|
}
|
||||||
$value = $xpath->evaluate('atom:author/poco:displayName/text()')->item(0)->nodeValue;
|
$value = $xpath->evaluate('atom:author/poco:displayName/text()')->item(0)->nodeValue;
|
||||||
if ($value != "")
|
if ($value != "") {
|
||||||
$author["author-name"] = $value;
|
$author["author-name"] = $value;
|
||||||
|
}
|
||||||
if ($simulate) {
|
if ($simulate) {
|
||||||
$author["author-id"] = $xpath->evaluate('/atom:feed/atom:author/atom:uri/text()')->item(0)->nodeValue;
|
$author["author-id"] = $xpath->evaluate('/atom:feed/atom:author/atom:uri/text()')->item(0)->nodeValue;
|
||||||
|
|
||||||
$value = $xpath->evaluate('atom:author/poco:preferredUsername/text()')->item(0)->nodeValue;
|
$value = $xpath->evaluate('atom:author/poco:preferredUsername/text()')->item(0)->nodeValue;
|
||||||
if ($value != "")
|
if ($value != "") {
|
||||||
$author["author-nick"] = $value;
|
$author["author-nick"] = $value;
|
||||||
|
}
|
||||||
$value = $xpath->evaluate('atom:author/poco:address/poco:formatted/text()', $context)->item(0)->nodeValue;
|
$value = $xpath->evaluate('atom:author/poco:address/poco:formatted/text()', $context)->item(0)->nodeValue;
|
||||||
if ($value != "")
|
if ($value != "") {
|
||||||
$author["author-location"] = $value;
|
$author["author-location"] = $value;
|
||||||
|
}
|
||||||
$value = $xpath->evaluate('atom:author/poco:note/text()')->item(0)->nodeValue;
|
$value = $xpath->evaluate('atom:author/poco:note/text()')->item(0)->nodeValue;
|
||||||
if ($value != "")
|
if ($value != "") {
|
||||||
$author["author-about"] = $value;
|
$author["author-about"] = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$author["edited"] = $author["created"] = $xpath->query('/atom:feed/atom:updated/text()')->item(0)->nodeValue;
|
$author["edited"] = $author["created"] = $xpath->query('/atom:feed/atom:updated/text()')->item(0)->nodeValue;
|
||||||
|
@ -118,12 +124,12 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
|
||||||
$author["author-name"] = $xpath->evaluate('/rss/channel/title/text()')->item(0)->nodeValue;
|
$author["author-name"] = $xpath->evaluate('/rss/channel/title/text()')->item(0)->nodeValue;
|
||||||
$author["author-avatar"] = $xpath->evaluate('/rss/channel/image/url/text()')->item(0)->nodeValue;
|
$author["author-avatar"] = $xpath->evaluate('/rss/channel/image/url/text()')->item(0)->nodeValue;
|
||||||
|
|
||||||
if ($author["author-name"] == "")
|
if ($author["author-name"] == "") {
|
||||||
$author["author-name"] = $xpath->evaluate('/rss/channel/copyright/text()')->item(0)->nodeValue;
|
$author["author-name"] = $xpath->evaluate('/rss/channel/copyright/text()')->item(0)->nodeValue;
|
||||||
|
}
|
||||||
if ($author["author-name"] == "")
|
if ($author["author-name"] == "") {
|
||||||
$author["author-name"] = $xpath->evaluate('/rss/channel/description/text()')->item(0)->nodeValue;
|
$author["author-name"] = $xpath->evaluate('/rss/channel/description/text()')->item(0)->nodeValue;
|
||||||
|
}
|
||||||
$author["edited"] = $author["created"] = $xpath->query('/rss/channel/pubDate/text()')->item(0)->nodeValue;
|
$author["edited"] = $author["created"] = $xpath->query('/rss/channel/pubDate/text()')->item(0)->nodeValue;
|
||||||
|
|
||||||
$author["app"] = $xpath->evaluate('/rss/channel/generator/text()')->item(0)->nodeValue;
|
$author["app"] = $xpath->evaluate('/rss/channel/generator/text()')->item(0)->nodeValue;
|
||||||
|
@ -134,9 +140,9 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
|
||||||
if (!$simulate) {
|
if (!$simulate) {
|
||||||
$author["author-link"] = $contact["url"];
|
$author["author-link"] = $contact["url"];
|
||||||
|
|
||||||
if ($author["author-name"] == "")
|
if ($author["author-name"] == "") {
|
||||||
$author["author-name"] = $contact["name"];
|
$author["author-name"] = $contact["name"];
|
||||||
|
}
|
||||||
$author["author-avatar"] = $contact["thumb"];
|
$author["author-avatar"] = $contact["thumb"];
|
||||||
|
|
||||||
$author["owner-link"] = $contact["url"];
|
$author["owner-link"] = $contact["url"];
|
||||||
|
@ -171,33 +177,39 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
|
||||||
|
|
||||||
$entrylist = array();
|
$entrylist = array();
|
||||||
|
|
||||||
foreach ($entries AS $entry)
|
foreach ($entries AS $entry) {
|
||||||
$entrylist[] = $entry;
|
$entrylist[] = $entry;
|
||||||
|
}
|
||||||
foreach (array_reverse($entrylist) AS $entry) {
|
foreach (array_reverse($entrylist) AS $entry) {
|
||||||
$item = array_merge($header, $author);
|
$item = array_merge($header, $author);
|
||||||
|
|
||||||
if (is_object($alternate))
|
$alternate = $xpath->query("atom:link[@rel='alternate']", $entry)->item(0)->attributes;
|
||||||
foreach($alternate AS $attributes)
|
if (!is_object($alternate)) {
|
||||||
if ($attributes->name == "href")
|
$alternate = $xpath->query("atom:link", $entry)->item(0)->attributes;
|
||||||
|
}
|
||||||
|
if (is_object($alternate)) {
|
||||||
|
foreach($alternate AS $attributes) {
|
||||||
|
if ($attributes->name == "href") {
|
||||||
$item["plink"] = $attributes->textContent;
|
$item["plink"] = $attributes->textContent;
|
||||||
|
}
|
||||||
if ($item["plink"] == "")
|
}
|
||||||
|
}
|
||||||
|
if ($item["plink"] == "") {
|
||||||
$item["plink"] = $xpath->evaluate('link/text()', $entry)->item(0)->nodeValue;
|
$item["plink"] = $xpath->evaluate('link/text()', $entry)->item(0)->nodeValue;
|
||||||
|
}
|
||||||
if ($item["plink"] == "")
|
if ($item["plink"] == "") {
|
||||||
$item["plink"] = $xpath->evaluate('rss:link/text()', $entry)->item(0)->nodeValue;
|
$item["plink"] = $xpath->evaluate('rss:link/text()', $entry)->item(0)->nodeValue;
|
||||||
|
}
|
||||||
$item["plink"] = original_url($item["plink"]);
|
$item["plink"] = original_url($item["plink"]);
|
||||||
|
|
||||||
$item["uri"] = $xpath->evaluate('atom:id/text()', $entry)->item(0)->nodeValue;
|
$item["uri"] = $xpath->evaluate('atom:id/text()', $entry)->item(0)->nodeValue;
|
||||||
|
|
||||||
if ($item["uri"] == "")
|
if ($item["uri"] == "") {
|
||||||
$item["uri"] = $xpath->evaluate('guid/text()', $entry)->item(0)->nodeValue;
|
$item["uri"] = $xpath->evaluate('guid/text()', $entry)->item(0)->nodeValue;
|
||||||
|
}
|
||||||
if ($item["uri"] == "")
|
if ($item["uri"] == "") {
|
||||||
$item["uri"] = $item["plink"];
|
$item["uri"] = $item["plink"];
|
||||||
|
}
|
||||||
$item["parent-uri"] = $item["uri"];
|
$item["parent-uri"] = $item["uri"];
|
||||||
|
|
||||||
if (!$simulate) {
|
if (!$simulate) {
|
||||||
|
@ -211,54 +223,50 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
|
||||||
|
|
||||||
$item["title"] = $xpath->evaluate('atom:title/text()', $entry)->item(0)->nodeValue;
|
$item["title"] = $xpath->evaluate('atom:title/text()', $entry)->item(0)->nodeValue;
|
||||||
|
|
||||||
if ($item["title"] == "")
|
if ($item["title"] == "") {
|
||||||
$item["title"] = $xpath->evaluate('title/text()', $entry)->item(0)->nodeValue;
|
$item["title"] = $xpath->evaluate('title/text()', $entry)->item(0)->nodeValue;
|
||||||
|
}
|
||||||
if ($item["title"] == "")
|
if ($item["title"] == "") {
|
||||||
$item["title"] = $xpath->evaluate('rss:title/text()', $entry)->item(0)->nodeValue;
|
$item["title"] = $xpath->evaluate('rss:title/text()', $entry)->item(0)->nodeValue;
|
||||||
|
}
|
||||||
$alternate = $xpath->query("atom:link[@rel='alternate']", $entry)->item(0)->attributes;
|
|
||||||
if (!is_object($alternate))
|
|
||||||
$alternate = $xpath->query("atom:link", $entry)->item(0)->attributes;
|
|
||||||
|
|
||||||
$published = $xpath->query('atom:published/text()', $entry)->item(0)->nodeValue;
|
$published = $xpath->query('atom:published/text()', $entry)->item(0)->nodeValue;
|
||||||
|
|
||||||
if ($published == "")
|
if ($published == "") {
|
||||||
$published = $xpath->query('pubDate/text()', $entry)->item(0)->nodeValue;
|
$published = $xpath->query('pubDate/text()', $entry)->item(0)->nodeValue;
|
||||||
|
}
|
||||||
if ($published == "")
|
if ($published == "") {
|
||||||
$published = $xpath->query('dc:date/text()', $entry)->item(0)->nodeValue;
|
$published = $xpath->query('dc:date/text()', $entry)->item(0)->nodeValue;
|
||||||
|
}
|
||||||
$updated = $xpath->query('atom:updated/text()', $entry)->item(0)->nodeValue;
|
$updated = $xpath->query('atom:updated/text()', $entry)->item(0)->nodeValue;
|
||||||
|
|
||||||
if ($updated == "")
|
if ($updated == "") {
|
||||||
$updated = $published;
|
$updated = $published;
|
||||||
|
}
|
||||||
if ($published != "")
|
if ($published != "") {
|
||||||
$item["created"] = $published;
|
$item["created"] = $published;
|
||||||
|
}
|
||||||
if ($updated != "")
|
if ($updated != "") {
|
||||||
$item["edited"] = $updated;
|
$item["edited"] = $updated;
|
||||||
|
}
|
||||||
$creator = $xpath->query('author/text()', $entry)->item(0)->nodeValue;
|
$creator = $xpath->query('author/text()', $entry)->item(0)->nodeValue;
|
||||||
|
|
||||||
if ($creator == "")
|
if ($creator == "") {
|
||||||
$creator = $xpath->query('atom:author/atom:name/text()', $entry)->item(0)->nodeValue;
|
$creator = $xpath->query('atom:author/atom:name/text()', $entry)->item(0)->nodeValue;
|
||||||
|
}
|
||||||
if ($creator == "")
|
if ($creator == "") {
|
||||||
$creator = $xpath->query('dc:creator/text()', $entry)->item(0)->nodeValue;
|
$creator = $xpath->query('dc:creator/text()', $entry)->item(0)->nodeValue;
|
||||||
|
}
|
||||||
if ($creator != "")
|
if ($creator != "") {
|
||||||
$item["author-name"] = $creator;
|
$item["author-name"] = $creator;
|
||||||
|
}
|
||||||
if ($pubDate != "")
|
if ($pubDate != "") {
|
||||||
$item["edited"] = $item["created"] = $pubDate;
|
$item["edited"] = $item["created"] = $pubDate;
|
||||||
|
}
|
||||||
$creator = $xpath->query('dc:creator/text()', $entry)->item(0)->nodeValue;
|
$creator = $xpath->query('dc:creator/text()', $entry)->item(0)->nodeValue;
|
||||||
|
|
||||||
if ($creator != "")
|
if ($creator != "") {
|
||||||
$item["author-name"] = $creator;
|
$item["author-name"] = $creator;
|
||||||
|
}
|
||||||
/// @TODO ?
|
/// @TODO ?
|
||||||
// <category>Ausland</category>
|
// <category>Ausland</category>
|
||||||
// <media:thumbnail width="152" height="76" url="http://www.taz.de/picture/667875/192/14388767.jpg"/>
|
// <media:thumbnail width="152" height="76" url="http://www.taz.de/picture/667875/192/14388767.jpg"/>
|
||||||
|
@ -273,12 +281,13 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
|
||||||
$title = "";
|
$title = "";
|
||||||
|
|
||||||
foreach($enclosure->attributes AS $attributes) {
|
foreach($enclosure->attributes AS $attributes) {
|
||||||
if ($attributes->name == "url")
|
if ($attributes->name == "url") {
|
||||||
$href = $attributes->textContent;
|
$href = $attributes->textContent;
|
||||||
elseif ($attributes->name == "length")
|
} elseif ($attributes->name == "length") {
|
||||||
$length = $attributes->textContent;
|
$length = $attributes->textContent;
|
||||||
elseif ($attributes->name == "type")
|
} elseif ($attributes->name == "type") {
|
||||||
$type = $attributes->textContent;
|
$type = $attributes->textContent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(strlen($item["attach"]))
|
if(strlen($item["attach"]))
|
||||||
$item["attach"] .= ',';
|
$item["attach"] .= ',';
|
||||||
|
@ -292,9 +301,11 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
|
||||||
$preview = "";
|
$preview = "";
|
||||||
|
|
||||||
// Handle enclosures and treat them as preview picture
|
// Handle enclosures and treat them as preview picture
|
||||||
foreach ($attachments AS $attachment)
|
foreach ($attachments AS $attachment) {
|
||||||
if ($attachment["type"] == "image/jpeg")
|
if ($attachment["type"] == "image/jpeg") {
|
||||||
$preview = $attachment["link"];
|
$preview = $attachment["link"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$item["body"] = $item["title"].add_page_info($item["plink"], false, $preview, ($contact["fetch_further_information"] == 2), $contact["ffi_keyword_blacklist"]);
|
$item["body"] = $item["title"].add_page_info($item["plink"], false, $preview, ($contact["fetch_further_information"] == 2), $contact["ffi_keyword_blacklist"]);
|
||||||
$item["tag"] = add_page_keywords($item["plink"], false, $preview, ($contact["fetch_further_information"] == 2), $contact["ffi_keyword_blacklist"]);
|
$item["tag"] = add_page_keywords($item["plink"], false, $preview, ($contact["fetch_further_information"] == 2), $contact["ffi_keyword_blacklist"]);
|
||||||
|
@ -304,20 +315,20 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
|
||||||
} else {
|
} else {
|
||||||
$body = trim($xpath->evaluate('atom:content/text()', $entry)->item(0)->nodeValue);
|
$body = trim($xpath->evaluate('atom:content/text()', $entry)->item(0)->nodeValue);
|
||||||
|
|
||||||
if ($body == "")
|
if ($body == "") {
|
||||||
$body = trim($xpath->evaluate('content:encoded/text()', $entry)->item(0)->nodeValue);
|
$body = trim($xpath->evaluate('content:encoded/text()', $entry)->item(0)->nodeValue);
|
||||||
|
}
|
||||||
if ($body == "")
|
if ($body == "") {
|
||||||
$body = trim($xpath->evaluate('description/text()', $entry)->item(0)->nodeValue);
|
$body = trim($xpath->evaluate('description/text()', $entry)->item(0)->nodeValue);
|
||||||
|
}
|
||||||
if ($body == "")
|
if ($body == "") {
|
||||||
$body = trim($xpath->evaluate('atom:summary/text()', $entry)->item(0)->nodeValue);
|
$body = trim($xpath->evaluate('atom:summary/text()', $entry)->item(0)->nodeValue);
|
||||||
|
}
|
||||||
// remove the content of the title if it is identically to the body
|
// remove the content of the title if it is identically to the body
|
||||||
// This helps with auto generated titles e.g. from tumblr
|
// This helps with auto generated titles e.g. from tumblr
|
||||||
if (title_is_body($item["title"], $body))
|
if (title_is_body($item["title"], $body)) {
|
||||||
$item["title"] = "";
|
$item["title"] = "";
|
||||||
|
}
|
||||||
$item["body"] = html2bbcode($body);
|
$item["body"] = html2bbcode($body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,14 +347,16 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
|
||||||
$id = item_store($item, false, $notify);
|
$id = item_store($item, false, $notify);
|
||||||
|
|
||||||
logger("Feed for contact ".$contact["url"]." stored under id ".$id);
|
logger("Feed for contact ".$contact["url"]." stored under id ".$id);
|
||||||
} else
|
} else {
|
||||||
$items[] = $item;
|
$items[] = $item;
|
||||||
|
}
|
||||||
if ($simulate)
|
if ($simulate) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($simulate)
|
if ($simulate) {
|
||||||
return array("header" => $author, "items" => $items);
|
return array("header" => $author, "items" => $items);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -2,36 +2,14 @@
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use \Friendica\Core\Config;
|
||||||
|
|
||||||
require_once("boot.php");
|
|
||||||
require_once('include/Scrape.php');
|
require_once('include/Scrape.php');
|
||||||
require_once('include/socgraph.php');
|
require_once('include/socgraph.php');
|
||||||
|
require_once('include/datetime.php');
|
||||||
|
|
||||||
function gprobe_run(&$argv, &$argc){
|
function gprobe_run(&$argv, &$argc){
|
||||||
global $a, $db;
|
if ($argc != 2) {
|
||||||
|
|
||||||
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)
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
$url = hex2bin($argv[1]);
|
$url = hex2bin($argv[1]);
|
||||||
|
|
||||||
$r = q("SELECT `id`, `url`, `network` FROM `gcontact` WHERE `nurl` = '%s' ORDER BY `id` LIMIT 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);
|
logger("gprobe end for ".normalise_link($url), LOGGER_DEBUG);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
|
||||||
gprobe_run($_SERVER["argv"],$_SERVER["argc"]);
|
|
||||||
killme();
|
|
||||||
}
|
|
||||||
|
|
264
include/like.php
264
include/like.php
|
@ -18,155 +18,169 @@ require_once("include/diaspora.php");
|
||||||
function do_like($item_id, $verb) {
|
function do_like($item_id, $verb) {
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
if(! local_user() && ! remote_user()) {
|
if (! local_user() && ! remote_user()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($verb) {
|
switch ($verb) {
|
||||||
case 'like':
|
case 'like':
|
||||||
|
$bodyverb = t('%1$s likes %2$s\'s %3$s');
|
||||||
|
$activity = ACTIVITY_LIKE;
|
||||||
|
break;
|
||||||
case 'unlike':
|
case 'unlike':
|
||||||
|
$bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
|
||||||
$activity = ACTIVITY_LIKE;
|
$activity = ACTIVITY_LIKE;
|
||||||
break;
|
break;
|
||||||
case 'dislike':
|
case 'dislike':
|
||||||
case 'undislike':
|
case 'undislike':
|
||||||
|
$bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
|
||||||
$activity = ACTIVITY_DISLIKE;
|
$activity = ACTIVITY_DISLIKE;
|
||||||
break;
|
break;
|
||||||
case 'attendyes':
|
case 'attendyes':
|
||||||
case 'unattendyes':
|
case 'unattendyes':
|
||||||
|
$bodyverb = t('%1$s is attending %2$s\'s %3$s');
|
||||||
$activity = ACTIVITY_ATTEND;
|
$activity = ACTIVITY_ATTEND;
|
||||||
break;
|
break;
|
||||||
case 'attendno':
|
case 'attendno':
|
||||||
case 'unattendno':
|
case 'unattendno':
|
||||||
|
$bodyverb = t('%1$s is not attending %2$s\'s %3$s');
|
||||||
$activity = ACTIVITY_ATTENDNO;
|
$activity = ACTIVITY_ATTENDNO;
|
||||||
break;
|
break;
|
||||||
case 'attendmaybe':
|
case 'attendmaybe':
|
||||||
case 'unattendmaybe':
|
case 'unattendmaybe':
|
||||||
|
$bodyverb = t('%1$s may attend %2$s\'s %3$s');
|
||||||
$activity = ACTIVITY_ATTENDMAYBE;
|
$activity = ACTIVITY_ATTENDMAYBE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
logger('like: unknown verb ' . $verb . ' for item ' . $item_id);
|
||||||
return false;
|
return false;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enable activity toggling instead of on/off
|
||||||
|
$event_verb_flag = $activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE;
|
||||||
|
|
||||||
logger('like: verb ' . $verb . ' item ' . $item_id);
|
logger('like: verb ' . $verb . ' item ' . $item_id);
|
||||||
|
|
||||||
$r = q("SELECT * FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
|
// Retrieve item
|
||||||
|
$items = q("SELECT * FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
|
||||||
dbesc($item_id),
|
dbesc($item_id),
|
||||||
dbesc($item_id)
|
dbesc($item_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
if(! $item_id || (! dbm::is_result($r))) {
|
if (! $item_id || ! dbm::is_result($items)) {
|
||||||
logger('like: no item ' . $item_id);
|
logger('like: unknown item ' . $item_id);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$item = $r[0];
|
$item = $items[0];
|
||||||
|
|
||||||
$owner_uid = $item['uid'];
|
if (! can_write_wall($a, $item['uid'])) {
|
||||||
|
logger('like: unable to write on wall ' . $item['uid']);
|
||||||
if (! can_write_wall($a,$owner_uid)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$remote_owner = null;
|
// Retrieves the local post owner
|
||||||
|
$owners = q("SELECT `contact`.* FROM `contact`
|
||||||
|
WHERE `contact`.`self` = 1
|
||||||
|
AND `contact`.`uid` = %d",
|
||||||
|
intval($item['uid'])
|
||||||
|
);
|
||||||
|
if (dbm::is_result($owners)) {
|
||||||
|
$owner_self_contact = $owners[0];
|
||||||
|
} else {
|
||||||
|
logger('like: unknown owner ' . $item['uid']);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(! $item['wall']) {
|
// Retrieve the current logged in user's public contact
|
||||||
// The top level post may have been written by somebody on another system
|
$author_id = public_contact();
|
||||||
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
|
||||||
intval($item['contact-id']),
|
$contacts = q("SELECT * FROM `contact` WHERE `id` = %d",
|
||||||
intval($item['uid'])
|
intval($author_id)
|
||||||
|
);
|
||||||
|
if (dbm::is_result($contacts)) {
|
||||||
|
$author_contact = $contacts[0];
|
||||||
|
} else {
|
||||||
|
logger('like: unknown author ' . $author_id);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Contact-id is the uid-dependant author contact
|
||||||
|
if (local_user() == $item['uid']) {
|
||||||
|
$item_contact_id = $owner_self_contact['id'];
|
||||||
|
$item_contact = $owner_self_contact;
|
||||||
|
} else {
|
||||||
|
$item_contact_id = get_contact($author_contact['url'], $item['uid']);
|
||||||
|
|
||||||
|
$contacts = q("SELECT * FROM `contact` WHERE `id` = %d",
|
||||||
|
intval($item_contact_id)
|
||||||
);
|
);
|
||||||
if (! dbm::is_result($r)) {
|
if (dbm::is_result($contacts)) {
|
||||||
|
$item_contact = $contacts[0];
|
||||||
|
} else {
|
||||||
|
logger('like: unknown item contact ' . $item_contact_id);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (! $r[0]['self']) {
|
|
||||||
$remote_owner = $r[0];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this represents the post owner on this system.
|
// Look for an existing verb row
|
||||||
|
|
||||||
$r = q("SELECT `contact`.*, `user`.`nickname` FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
|
|
||||||
WHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1",
|
|
||||||
intval($owner_uid)
|
|
||||||
);
|
|
||||||
if (dbm::is_result($r)) {
|
|
||||||
$owner = $r[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $owner) {
|
|
||||||
logger('like: no owner');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $remote_owner) {
|
|
||||||
$remote_owner = $owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This represents the person posting
|
|
||||||
|
|
||||||
if ((local_user()) && (local_user() == $owner_uid)) {
|
|
||||||
$contact = $owner;
|
|
||||||
} else {
|
|
||||||
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
|
||||||
intval($_SESSION['visitor_id']),
|
|
||||||
intval($owner_uid)
|
|
||||||
);
|
|
||||||
if (dbm::is_result($r)) {
|
|
||||||
$contact = $r[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (! $contact) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$verbs = " '".dbesc($activity)."' ";
|
|
||||||
|
|
||||||
// event participation are essentially radio toggles. If you make a subsequent choice,
|
// event participation are essentially radio toggles. If you make a subsequent choice,
|
||||||
// we need to eradicate your first choice.
|
// we need to eradicate your first choice.
|
||||||
if ($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) {
|
if ($event_verb_flag) {
|
||||||
$verbs = " '" . dbesc(ACTIVITY_ATTEND) . "','" . dbesc(ACTIVITY_ATTENDNO) . "','" . dbesc(ACTIVITY_ATTENDMAYBE) . "' ";
|
$verbs = "'" . dbesc(ACTIVITY_ATTEND) . "', '" . dbesc(ACTIVITY_ATTENDNO) . "', '" . dbesc(ACTIVITY_ATTENDMAYBE) . "'";
|
||||||
|
} else {
|
||||||
|
$verbs = "'".dbesc($activity)."'";
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("SELECT `id`, `guid` FROM `item` WHERE `verb` IN ( $verbs ) AND `deleted` = 0
|
$existing_like = q("SELECT `id`, `guid`, `verb` FROM `item`
|
||||||
AND `contact-id` = %d AND `uid` = %d
|
WHERE `verb` IN ($verbs)
|
||||||
AND (`parent` = '%s' OR `parent-uri` = '%s' OR `thr-parent` = '%s') LIMIT 1",
|
AND `deleted` = 0
|
||||||
intval($contact['id']), intval($owner_uid),
|
AND `author-id` = %d
|
||||||
|
AND `uid` = %d
|
||||||
|
AND (`parent` = '%s' OR `parent-uri` = '%s' OR `thr-parent` = '%s')
|
||||||
|
LIMIT 1",
|
||||||
|
intval($author_contact['id']),
|
||||||
|
intval($item['uid']),
|
||||||
dbesc($item_id), dbesc($item_id), dbesc($item['uri'])
|
dbesc($item_id), dbesc($item_id), dbesc($item['uri'])
|
||||||
);
|
);
|
||||||
|
|
||||||
if (dbm::is_result($r)) {
|
// If it exists, mark it as deleted
|
||||||
$like_item = $r[0];
|
if (dbm::is_result($existing_like)) {
|
||||||
|
$like_item = $existing_like[0];
|
||||||
|
|
||||||
// Already voted, undo it
|
// Already voted, undo it
|
||||||
$r = q("UPDATE `item` SET `deleted` = 1, `unseen` = 1, `changed` = '%s' WHERE `id` = %d",
|
q("UPDATE `item` SET `deleted` = 1, `unseen` = 1, `changed` = '%s' WHERE `id` = %d",
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
intval($like_item['id'])
|
intval($like_item['id'])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// Clean up the Diaspora signatures for this like
|
// Clean up the Diaspora signatures for this like
|
||||||
// Go ahead and do it even if Diaspora support is disabled. We still want to clean up
|
// Go ahead and do it even if Diaspora support is disabled. We still want to clean up
|
||||||
// if it had been enabled in the past
|
// if it had been enabled in the past
|
||||||
$r = q("DELETE FROM `sign` WHERE `iid` = %d",
|
q("DELETE FROM `sign` WHERE `iid` = %d",
|
||||||
intval($like_item['id'])
|
intval($like_item['id'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$like_item_id = $like_item['id'];
|
$like_item_id = $like_item['id'];
|
||||||
proc_run(PRIORITY_HIGH, "include/notifier.php", "like", $like_item_id);
|
proc_run(PRIORITY_HIGH, "include/notifier.php", "like", $like_item_id);
|
||||||
|
|
||||||
|
if (!$event_verb_flag || $like_item['verb'] == $activity) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verb is "un-something", just trying to delete existing entries
|
||||||
|
if (strpos($verb, 'un') === 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$uri = item_new_uri($a->get_hostname(),$owner_uid);
|
// Else or if event verb different from existing row, create a new item row
|
||||||
|
|
||||||
$post_type = (($item['resource-id']) ? t('photo') : t('status'));
|
$post_type = (($item['resource-id']) ? t('photo') : t('status'));
|
||||||
if ($item['object-type'] === ACTIVITY_OBJ_EVENT) {
|
if ($item['object-type'] === ACTIVITY_OBJ_EVENT) {
|
||||||
$post_type = t('event');
|
$post_type = t('event');
|
||||||
}
|
}
|
||||||
$objtype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE );
|
$objtype = $item['resource-id'] ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE ;
|
||||||
$link = xmlify('<link rel="alternate" type="text/html" href="' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
|
$link = xmlify('<link rel="alternate" type="text/html" href="' . App::get_baseurl() . '/display/' . $owner_self_contact['nick'] . '/' . $item['id'] . '" />' . "\n") ;
|
||||||
$body = $item['body'];
|
$body = $item['body'];
|
||||||
|
|
||||||
$obj = <<< EOT
|
$obj = <<< EOT
|
||||||
|
@ -180,80 +194,62 @@ function do_like($item_id, $verb) {
|
||||||
<content>$body</content>
|
<content>$body</content>
|
||||||
</object>
|
</object>
|
||||||
EOT;
|
EOT;
|
||||||
if ($verb === 'like') {
|
|
||||||
$bodyverb = t('%1$s likes %2$s\'s %3$s');
|
|
||||||
}
|
|
||||||
if ($verb === 'dislike') {
|
|
||||||
$bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
|
|
||||||
}
|
|
||||||
if ($verb === 'attendyes') {
|
|
||||||
$bodyverb = t('%1$s is attending %2$s\'s %3$s');
|
|
||||||
}
|
|
||||||
if ($verb === 'attendno') {
|
|
||||||
$bodyverb = t('%1$s is not attending %2$s\'s %3$s');
|
|
||||||
}
|
|
||||||
if ($verb === 'attendmaybe') {
|
|
||||||
$bodyverb = t('%1$s may attend %2$s\'s %3$s');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! isset($bodyverb)) {
|
$ulink = '[url=' . $author_contact['url'] . ']' . $author_contact['name'] . '[/url]';
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
|
|
||||||
$alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
|
$alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
|
||||||
$plink = '[url=' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
|
$plink = '[url=' . App::get_baseurl() . '/display/' . $owner_self_contact['nick'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
|
||||||
|
|
||||||
/// @TODO Or rewrite this to multi-line initialization of the array?
|
$new_item = array(
|
||||||
$arr = array();
|
'guid' => get_guid(32),
|
||||||
|
'uri' => item_new_uri($a->get_hostname(), $item['uid']),
|
||||||
|
'uid' => $item['uid'],
|
||||||
|
'contact-id' => $item_contact_id,
|
||||||
|
'type' => 'activity',
|
||||||
|
'wall' => $item['wall'],
|
||||||
|
'origin' => 1,
|
||||||
|
'gravity' => GRAVITY_LIKE,
|
||||||
|
'parent' => $item['id'],
|
||||||
|
'parent-uri' => $item['uri'],
|
||||||
|
'thr-parent' => $item['uri'],
|
||||||
|
'owner-id' => $item['owner-id'],
|
||||||
|
'owner-name' => $item['owner-name'],
|
||||||
|
'owner-link' => $item['owner-link'],
|
||||||
|
'owner-avatar' => $item['owner-avatar'],
|
||||||
|
'author-id' => $author_contact['id'],
|
||||||
|
'author-name' => $author_contact['name'],
|
||||||
|
'author-link' => $author_contact['url'],
|
||||||
|
'author-avatar' => $author_contact['thumb'],
|
||||||
|
'body' => sprintf($bodyverb, $ulink, $alink, $plink),
|
||||||
|
'verb' => $activity,
|
||||||
|
'object-type' => $objtype,
|
||||||
|
'object' => $obj,
|
||||||
|
'allow_cid' => $item['allow_cid'],
|
||||||
|
'allow_gid' => $item['allow_gid'],
|
||||||
|
'deny_cid' => $item['deny_cid'],
|
||||||
|
'deny_gid' => $item['deny_gid'],
|
||||||
|
'visible' => 1,
|
||||||
|
'unseen' => 1,
|
||||||
|
'last-child' => 0
|
||||||
|
);
|
||||||
|
|
||||||
$arr['guid'] = get_guid(32);
|
$new_item_id = item_store($new_item);
|
||||||
$arr['uri'] = $uri;
|
|
||||||
$arr['uid'] = $owner_uid;
|
|
||||||
$arr['contact-id'] = $contact['id'];
|
|
||||||
$arr['type'] = 'activity';
|
|
||||||
$arr['wall'] = $item['wall'];
|
|
||||||
$arr['origin'] = 1;
|
|
||||||
$arr['gravity'] = GRAVITY_LIKE;
|
|
||||||
$arr['parent'] = $item['id'];
|
|
||||||
$arr['parent-uri'] = $item['uri'];
|
|
||||||
$arr['thr-parent'] = $item['uri'];
|
|
||||||
$arr['owner-name'] = $remote_owner['name'];
|
|
||||||
$arr['owner-link'] = $remote_owner['url'];
|
|
||||||
$arr['owner-avatar'] = $remote_owner['thumb'];
|
|
||||||
$arr['author-name'] = $contact['name'];
|
|
||||||
$arr['author-link'] = $contact['url'];
|
|
||||||
$arr['author-avatar'] = $contact['thumb'];
|
|
||||||
$arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink );
|
|
||||||
$arr['verb'] = $activity;
|
|
||||||
$arr['object-type'] = $objtype;
|
|
||||||
$arr['object'] = $obj;
|
|
||||||
$arr['allow_cid'] = $item['allow_cid'];
|
|
||||||
$arr['allow_gid'] = $item['allow_gid'];
|
|
||||||
$arr['deny_cid'] = $item['deny_cid'];
|
|
||||||
$arr['deny_gid'] = $item['deny_gid'];
|
|
||||||
$arr['visible'] = 1;
|
|
||||||
$arr['unseen'] = 1;
|
|
||||||
$arr['last-child'] = 0;
|
|
||||||
|
|
||||||
$post_id = item_store($arr);
|
|
||||||
|
|
||||||
|
// @todo: Explain this block
|
||||||
if (! $item['visible']) {
|
if (! $item['visible']) {
|
||||||
$r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d",
|
q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d",
|
||||||
intval($item['id']),
|
intval($item['id']),
|
||||||
intval($owner_uid)
|
intval($item['uid'])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Save the author information for the like in case we need to relay to Diaspora
|
// Save the author information for the like in case we need to relay to Diaspora
|
||||||
Diaspora::store_like_signature($contact, $post_id);
|
Diaspora::store_like_signature($item_contact, $new_item_id);
|
||||||
|
|
||||||
$arr['id'] = $post_id;
|
$new_item['id'] = $new_item_id;
|
||||||
|
|
||||||
call_hooks('post_local_end', $arr);
|
call_hooks('post_local_end', $new_item);
|
||||||
|
|
||||||
proc_run(PRIORITY_HIGH, "include/notifier.php", "like", $post_id);
|
proc_run(PRIORITY_HIGH, "include/notifier.php", "like", $new_item_id);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,8 +72,9 @@ function z_fetch_url($url,$binary = false, &$redirects = 0, $opts=array()) {
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
$ch = @curl_init($url);
|
$ch = @curl_init($url);
|
||||||
if(($redirects > 8) || (! $ch))
|
if(($redirects > 8) || (! $ch)) {
|
||||||
return false;
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
@curl_setopt($ch, CURLOPT_HEADER, true);
|
@curl_setopt($ch, CURLOPT_HEADER, true);
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,11 @@
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use \Friendica\Core\Config;
|
||||||
|
|
||||||
require_once("boot.php");
|
|
||||||
require_once('include/queue_fn.php');
|
require_once('include/queue_fn.php');
|
||||||
require_once('include/html2plain.php');
|
require_once('include/html2plain.php');
|
||||||
require_once("include/Scrape.php");
|
require_once('include/Scrape.php');
|
||||||
require_once('include/diaspora.php');
|
require_once('include/diaspora.php');
|
||||||
require_once("include/ostatus.php");
|
require_once('include/ostatus.php');
|
||||||
require_once('include/salmon.php');
|
require_once('include/salmon.php');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -44,35 +43,17 @@ require_once('include/salmon.php');
|
||||||
|
|
||||||
|
|
||||||
function notifier_run(&$argv, &$argc){
|
function notifier_run(&$argv, &$argc){
|
||||||
global $a, $db;
|
global $a;
|
||||||
|
|
||||||
if (is_null($a)) {
|
require_once('include/datetime.php');
|
||||||
$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/items.php');
|
||||||
require_once('include/bbcode.php');
|
require_once('include/bbcode.php');
|
||||||
require_once('include/email.php');
|
require_once('include/email.php');
|
||||||
|
|
||||||
Config::load();
|
|
||||||
|
|
||||||
load_hooks();
|
|
||||||
|
|
||||||
if ($argc < 3) {
|
if ($argc < 3) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$a->set_baseurl(get_config('system','url'));
|
|
||||||
|
|
||||||
logger('notifier: invoked: ' . print_r($argv,true), LOGGER_DEBUG);
|
logger('notifier: invoked: ' . print_r($argv,true), LOGGER_DEBUG);
|
||||||
|
|
||||||
$cmd = $argv[1];
|
$cmd = $argv[1];
|
||||||
|
@ -490,79 +471,22 @@ function notifier_run(&$argv, &$argc){
|
||||||
if ($relocate) {
|
if ($relocate) {
|
||||||
$r = $recipients_relocate;
|
$r = $recipients_relocate;
|
||||||
} else {
|
} 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)
|
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
|
// delivery loop
|
||||||
|
|
||||||
if (dbm::is_result($r)) {
|
if (dbm::is_result($r)) {
|
||||||
foreach ($r as $contact) {
|
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']) {
|
if ($contact['self']) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
logger("Deliver ".$target_item["guid"]." to ".$contact['url']." via network ".$contact['network'], LOGGER_DEBUG);
|
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.
|
proc_run(PRIORITY_HIGH,'include/delivery.php', $cmd, $item_id, $contact['id']);
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -614,18 +538,6 @@ function notifier_run(&$argv, &$argc){
|
||||||
if (dbm::is_result($r)) {
|
if (dbm::is_result($r)) {
|
||||||
logger('pubdeliver '.$target_item["guid"].': '.print_r($r,true), LOGGER_DEBUG);
|
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) {
|
foreach ($r as $rr) {
|
||||||
|
|
||||||
// except for Diaspora batch jobs
|
// except for Diaspora batch jobs
|
||||||
|
@ -639,9 +551,6 @@ function notifier_run(&$argv, &$argc){
|
||||||
if ((! $mail) && (! $fsuggest) && (! $followup)) {
|
if ((! $mail) && (! $fsuggest) && (! $followup)) {
|
||||||
logger('notifier: delivery agent: '.$rr['name'].' '.$rr['id'].' '.$rr['network'].' '.$target_item["guid"]);
|
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']);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
|
||||||
notifier_run($_SERVER["argv"],$_SERVER["argc"]);
|
|
||||||
killme();
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use \Friendica\Core\Config;
|
||||||
|
|
||||||
require_once("boot.php");
|
require_once('include/follow.php');
|
||||||
require_once("include/follow.php");
|
|
||||||
|
|
||||||
function RemoveReply($subject) {
|
function RemoveReply($subject) {
|
||||||
while (in_array(strtolower(substr($subject, 0, 3)), array("re:", "aw:")))
|
while (in_array(strtolower(substr($subject, 0, 3)), array("re:", "aw:")))
|
||||||
|
@ -13,20 +12,8 @@ function RemoveReply($subject) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onepoll_run(&$argv, &$argc){
|
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/datetime.php');
|
||||||
require_once('include/items.php');
|
require_once('include/items.php');
|
||||||
require_once('include/Contact.php');
|
require_once('include/Contact.php');
|
||||||
|
@ -34,12 +21,6 @@ function onepoll_run(&$argv, &$argc){
|
||||||
require_once('include/socgraph.php');
|
require_once('include/socgraph.php');
|
||||||
require_once('include/queue_fn.php');
|
require_once('include/queue_fn.php');
|
||||||
|
|
||||||
Config::load();
|
|
||||||
|
|
||||||
$a->set_baseurl(get_config('system','url'));
|
|
||||||
|
|
||||||
load_hooks();
|
|
||||||
|
|
||||||
logger('onepoll: start');
|
logger('onepoll: start');
|
||||||
|
|
||||||
$manual_id = 0;
|
$manual_id = 0;
|
||||||
|
@ -61,13 +42,6 @@ function onepoll_run(&$argv, &$argc){
|
||||||
return;
|
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();
|
$d = datetime_convert();
|
||||||
|
|
||||||
// Only poll from those with suitable relationships,
|
// Only poll from those with suitable relationships,
|
||||||
|
@ -697,8 +671,3 @@ function onepoll_run(&$argv, &$argc){
|
||||||
|
|
||||||
return;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$a->set_baseurl(Config::get('system', 'url'));
|
||||||
|
|
||||||
|
load_hooks();
|
||||||
|
|
||||||
$a->start_process();
|
$a->start_process();
|
||||||
|
|
||||||
if (poller_max_connections_reached()) {
|
if (poller_max_connections_reached()) {
|
||||||
|
@ -465,7 +469,7 @@ function poller_too_much_workers() {
|
||||||
// Are there fewer workers running as possible? Then fork a new one.
|
// 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)) {
|
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);
|
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 = get_app();
|
||||||
$a->proc_run($args);
|
$a->proc_run($args);
|
||||||
}
|
}
|
||||||
|
@ -576,7 +580,7 @@ function poller_worker_process() {
|
||||||
* @brief Call the front end worker
|
* @brief Call the front end worker
|
||||||
*/
|
*/
|
||||||
function call_worker() {
|
function call_worker() {
|
||||||
if (!Config::get("system", "frontend_worker") OR !Config::get("system", "worker")) {
|
if (!Config::get("system", "frontend_worker")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -588,7 +592,7 @@ function call_worker() {
|
||||||
* @brief Call the front end worker if there aren't any active
|
* @brief Call the front end worker if there aren't any active
|
||||||
*/
|
*/
|
||||||
function call_worker_if_idle() {
|
function call_worker_if_idle() {
|
||||||
if (!Config::get("system", "frontend_worker") OR !Config::get("system", "worker")) {
|
if (!Config::get("system", "frontend_worker")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -615,7 +619,7 @@ function call_worker_if_idle() {
|
||||||
|
|
||||||
logger('Call poller', LOGGER_DEBUG);
|
logger('Call poller', LOGGER_DEBUG);
|
||||||
|
|
||||||
$args = array("php", "include/poller.php", "no_cron");
|
$args = array("include/poller.php", "no_cron");
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
$a->proc_run($args);
|
$a->proc_run($args);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,12 +1,31 @@
|
||||||
<?php
|
<?php
|
||||||
require_once("boot.php");
|
|
||||||
require_once("include/ostatus.php");
|
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
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) {
|
function handle_pubsubhubbub($id) {
|
||||||
global $a, $db;
|
global $a;
|
||||||
|
|
||||||
$r = q("SELECT * FROM `push_subscriber` WHERE `id` = %d", intval($id));
|
$r = q("SELECT * FROM `push_subscriber` WHERE `id` = %d", intval($id));
|
||||||
if (!$r)
|
if (!$r)
|
||||||
|
@ -54,70 +73,3 @@ function handle_pubsubhubbub($id) {
|
||||||
intval($rr['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;
|
use \Friendica\Core\Config;
|
||||||
|
|
||||||
require_once("boot.php");
|
|
||||||
require_once('include/queue_fn.php');
|
require_once('include/queue_fn.php');
|
||||||
require_once('include/dfrn.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');
|
require_once('include/cache.php');
|
||||||
|
|
||||||
function queue_run(&$argv, &$argc){
|
function queue_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/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();
|
|
||||||
|
|
||||||
if ($argc > 1) {
|
if ($argc > 1) {
|
||||||
$queue_id = intval($argv[1]);
|
$queue_id = intval($argv[1]);
|
||||||
|
@ -54,30 +29,13 @@ function queue_run(&$argv, &$argc){
|
||||||
// Handling the pubsubhubbub requests
|
// Handling the pubsubhubbub requests
|
||||||
proc_run(PRIORITY_HIGH,'include/pubsubpublish.php');
|
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`
|
$r = q("SELECT `queue`.*, `contact`.`name`, `contact`.`uid` FROM `queue`
|
||||||
INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`
|
INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`
|
||||||
WHERE `queue`.`created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
|
WHERE `queue`.`created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
|
||||||
if ($r) {
|
if ($r) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
logger('Removing expired queue item for ' . $rr['name'] . ', uid=' . $rr['uid']);
|
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");
|
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.
|
// 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`");
|
$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",
|
call_hooks('queue_predeliver', $a, $r);
|
||||||
intval($queue_id)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$queue_id)
|
|
||||||
call_hooks('queue_predeliver', $a, $r);
|
|
||||||
|
|
||||||
|
// delivering
|
||||||
// delivery loop
|
|
||||||
|
|
||||||
require_once('include/salmon.php');
|
require_once('include/salmon.php');
|
||||||
require_once('include/diaspora.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,
|
if (!dbm::is_result($r)) {
|
||||||
// so check again if this entry still needs processing
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($queue_id) {
|
$q_item = $r[0];
|
||||||
$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']));
|
|
||||||
|
|
||||||
if (!dbm::is_result($qi)) {
|
$c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
|
||||||
continue;
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_null($vital) AND !$vital) {
|
||||||
$c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
|
logger('queue: skipping dead server: '.$server);
|
||||||
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']);
|
|
||||||
update_queue_time($q_item['id']);
|
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 != "") {
|
$data = $q_item['content'];
|
||||||
$vital = Cache::get($cachekey_server.$server);
|
$public = $q_item['batch'];
|
||||||
|
$contact = $c[0];
|
||||||
|
$owner = $u[0];
|
||||||
|
|
||||||
if (is_null($vital)) {
|
$deliver_status = 0;
|
||||||
logger("Check server ".$server." (".$c[0]["network"].")");
|
|
||||||
|
|
||||||
$vital = poco_check_server($server, $c[0]["network"], true);
|
switch ($contact['network']) {
|
||||||
Cache::set($cachekey_server.$server, $vital, CACHE_QUARTER_HOUR);
|
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) {
|
if ($deliver_status == (-1)) {
|
||||||
logger('queue: skipping dead server: '.$server);
|
|
||||||
update_queue_time($q_item['id']);
|
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`
|
if ($deliver_status == (-1)) {
|
||||||
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) {
|
|
||||||
update_queue_time($q_item['id']);
|
update_queue_time($q_item['id']);
|
||||||
Cache::set($cachekey_deadguy.$contact['notify'], true, CACHE_QUARTER_HOUR);
|
Cache::set($cachekey_deadguy.$contact['notify'], true, CACHE_QUARTER_HOUR);
|
||||||
} else {
|
} else {
|
||||||
remove_queue_item($q_item['id']);
|
remove_queue_item($q_item['id']);
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case NETWORK_OSTATUS:
|
break;
|
||||||
if ($contact['notify']) {
|
case NETWORK_DIASPORA:
|
||||||
logger('queue: slapdelivery: item '.$q_item['id'].' for '.$contact['name'].' <'.$contact['url'].'>');
|
if ($contact['notify']) {
|
||||||
$deliver_status = slapper($owner,$contact['notify'],$data);
|
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)) {
|
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 {
|
|
||||||
update_queue_time($q_item['id']);
|
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;
|
return;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
|
||||||
queue_run($_SERVER["argv"],$_SERVER["argc"]);
|
|
||||||
killme();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,24 +6,7 @@
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use \Friendica\Core\Config;
|
||||||
|
|
||||||
require_once("boot.php");
|
|
||||||
|
|
||||||
function remove_contact_run($argv, $argc) {
|
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) {
|
if ($argc != 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -46,9 +29,4 @@ function remove_contact_run($argv, $argc) {
|
||||||
|
|
||||||
q("DELETE FROM `queue` WHERE `cid` = %d", intval($id));
|
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();
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,5 +1,44 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Calculate the hash that is needed for the "Friendica" cookie
|
||||||
|
*
|
||||||
|
* @param array $user Record from "user" table
|
||||||
|
*
|
||||||
|
* @return string Hashed data
|
||||||
|
*/
|
||||||
|
function cookie_hash($user) {
|
||||||
|
return(hash("sha256", get_config("system", "site_prvkey").
|
||||||
|
$user["uprvkey"].
|
||||||
|
$user["password"]));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the "Friendica" cookie
|
||||||
|
*
|
||||||
|
* @param int $time
|
||||||
|
* @param array $user Record from "user" table
|
||||||
|
*/
|
||||||
|
function new_cookie($time, $user = array()) {
|
||||||
|
|
||||||
|
if ($time != 0) {
|
||||||
|
$time = $time + time();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user) {
|
||||||
|
$value = json_encode(array("uid" => $user["uid"],
|
||||||
|
"hash" => cookie_hash($user),
|
||||||
|
"ip" => $_SERVER['REMOTE_ADDR']));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$value = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
setcookie("Friendica", $value, $time, "/", "",
|
||||||
|
(get_config('system', 'ssl_policy') == SSL_POLICY_FULL), true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function authenticate_success($user_record, $login_initial = false, $interactive = false, $login_refresh = false) {
|
function authenticate_success($user_record, $login_initial = false, $interactive = false, $login_refresh = false) {
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
@ -94,6 +133,21 @@ function authenticate_success($user_record, $login_initial = false, $interactive
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($login_initial) {
|
||||||
|
// If the user specified to remember the authentication, then set a cookie
|
||||||
|
// that expires after one week (the default is when the browser is closed).
|
||||||
|
// The cookie will be renewed automatically.
|
||||||
|
// The week ensures that sessions will expire after some inactivity.
|
||||||
|
if ($_SESSION['remember']) {
|
||||||
|
logger('Injecting cookie for remembered user '. $_SESSION['remember_user']['nickname']);
|
||||||
|
new_cookie(604800, $user_record);
|
||||||
|
unset($_SESSION['remember']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($login_initial) {
|
if ($login_initial) {
|
||||||
call_hooks('logged_in', $a->user);
|
call_hooks('logged_in', $a->user);
|
||||||
|
|
||||||
|
|
|
@ -5,20 +5,26 @@ use \Friendica\Core\Config;
|
||||||
require_once("boot.php");
|
require_once("boot.php");
|
||||||
require_once("include/threads.php");
|
require_once("include/threads.php");
|
||||||
|
|
||||||
global $a, $db;
|
function shadowupdate_run(&$argv, &$argc){
|
||||||
|
global $a, $db;
|
||||||
|
|
||||||
if(is_null($a))
|
if (is_null($a)) {
|
||||||
$a = new App;
|
$a = new App;
|
||||||
|
}
|
||||||
|
|
||||||
if(is_null($db)) {
|
if (is_null($db)) {
|
||||||
@include(".htconfig.php");
|
@include(".htconfig.php");
|
||||||
require_once("include/dba.php");
|
require_once("include/dba.php");
|
||||||
$db = new dba($db_host, $db_user, $db_pass, $db_data);
|
$db = new dba($db_host, $db_user, $db_pass, $db_data);
|
||||||
unset($db_host, $db_user, $db_pass, $db_data);
|
unset($db_host, $db_user, $db_pass, $db_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
Config::load();
|
||||||
|
|
||||||
|
update_shadow_copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
Config::load();
|
if (array_search(__file__,get_included_files())===0){
|
||||||
|
shadowupdate_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||||
update_shadow_copy();
|
killme();
|
||||||
killme();
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -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);
|
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,
|
$gcontact = array("url" => $profile_url,
|
||||||
"addr" => $addr,
|
"addr" => $addr,
|
||||||
|
@ -401,13 +412,47 @@ function poco_detect_server($profile) {
|
||||||
|
|
||||||
// Mastodon
|
// Mastodon
|
||||||
if ($server_url == "") {
|
if ($server_url == "") {
|
||||||
$red = preg_replace("=(https?://)(.*)/users/(.*)=ism", "$1$2", $profile);
|
$mastodon = preg_replace("=(https?://)(.*)/users/(.*)=ism", "$1$2", $profile);
|
||||||
if ($red != $profile) {
|
if ($mastodon != $profile) {
|
||||||
$server_url = $red;
|
$server_url = $mastodon;
|
||||||
$network = NETWORK_OSTATUS;
|
$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;
|
return $server_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,10 +469,12 @@ function poco_last_updated($profile, $force = false) {
|
||||||
q("UPDATE `gcontact` SET `created` = '%s' WHERE `nurl` = '%s'",
|
q("UPDATE `gcontact` SET `created` = '%s' WHERE `nurl` = '%s'",
|
||||||
dbesc(datetime_convert()), dbesc(normalise_link($profile)));
|
dbesc(datetime_convert()), dbesc(normalise_link($profile)));
|
||||||
|
|
||||||
if ($gcontacts[0]["server_url"] != "")
|
if ($gcontacts[0]["server_url"] != "") {
|
||||||
$server_url = $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);
|
$server_url = poco_detect_server($profile);
|
||||||
|
}
|
||||||
|
|
||||||
if (!in_array($gcontacts[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_FEED, NETWORK_OSTATUS, ""))) {
|
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);
|
logger("Profile ".$profile.": Network type ".$gcontacts[0]["network"]." can't be checked", LOGGER_DEBUG);
|
||||||
|
@ -680,6 +727,213 @@ function poco_to_boolean($val) {
|
||||||
return ($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) {
|
function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
|
|
||||||
// Unify the server address
|
// Unify the server address
|
||||||
|
@ -729,7 +983,9 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
logger("Server ".$server_url." is outdated or unknown. Start discovery. Force: ".$force." Created: ".$servers[0]["created"]." Failure: ".$last_failure." Contact: ".$last_contact, LOGGER_DEBUG);
|
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;
|
$failure = false;
|
||||||
|
$possible_failure = false;
|
||||||
$orig_last_failure = $last_failure;
|
$orig_last_failure = $last_failure;
|
||||||
|
$orig_last_contact = $last_contact;
|
||||||
|
|
||||||
// Check if the page is accessible via SSL.
|
// Check if the page is accessible via SSL.
|
||||||
$orig_server_url = $server_url;
|
$orig_server_url = $server_url;
|
||||||
|
@ -769,18 +1025,58 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
$last_failure = datetime_convert();
|
$last_failure = datetime_convert();
|
||||||
$failure = true;
|
$failure = true;
|
||||||
}
|
}
|
||||||
|
$possible_failure = true;
|
||||||
} elseif ($network == NETWORK_DIASPORA)
|
} elseif ($network == NETWORK_DIASPORA)
|
||||||
$last_contact = datetime_convert();
|
$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) {
|
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);
|
$serverret = z_fetch_url($server_url);
|
||||||
|
|
||||||
if (!$serverret["success"] OR ($serverret["body"] == ""))
|
if (!$serverret["success"] OR ($serverret["body"] == "")) {
|
||||||
|
$last_failure = datetime_convert();
|
||||||
$failure = true;
|
$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"]);
|
$lines = explode("\n",$serverret["header"]);
|
||||||
if(count($lines))
|
if(count($lines)) {
|
||||||
foreach($lines as $line) {
|
foreach($lines as $line) {
|
||||||
$line = trim($line);
|
$line = trim($line);
|
||||||
if(stristr($line,'X-Diaspora-Version:')) {
|
if(stristr($line,'X-Diaspora-Version:')) {
|
||||||
|
@ -790,6 +1086,7 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
$network = NETWORK_DIASPORA;
|
$network = NETWORK_DIASPORA;
|
||||||
$versionparts = explode("-", $version);
|
$versionparts = explode("-", $version);
|
||||||
$version = $versionparts[0];
|
$version = $versionparts[0];
|
||||||
|
$last_contact = datetime_convert();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(stristr($line,'Server: Mastodon')) {
|
if(stristr($line,'Server: Mastodon')) {
|
||||||
|
@ -797,12 +1094,14 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
$network = NETWORK_OSTATUS;
|
$network = NETWORK_OSTATUS;
|
||||||
// Mastodon doesn't reveal version numbers
|
// Mastodon doesn't reveal version numbers
|
||||||
$version = "";
|
$version = "";
|
||||||
|
$last_contact = datetime_convert();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$failure) {
|
if (!$failure AND ($poco == "")) {
|
||||||
// Test for Statusnet
|
// Test for Statusnet
|
||||||
// Will also return data for Friendica and GNU Social - but it will be overwritten later
|
// 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
|
// The "not implemented" is a special treatment for really, really old Friendica versions
|
||||||
|
@ -810,8 +1109,11 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
if ($serverret["success"] AND ($serverret["body"] != '{"error":"not implemented"}') AND
|
if ($serverret["success"] AND ($serverret["body"] != '{"error":"not implemented"}') AND
|
||||||
($serverret["body"] != '') AND (strlen($serverret["body"]) < 30)) {
|
($serverret["body"] != '') AND (strlen($serverret["body"]) < 30)) {
|
||||||
$platform = "StatusNet";
|
$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;
|
$network = NETWORK_OSTATUS;
|
||||||
|
$last_contact = datetime_convert();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test for GNU Social
|
// Test for GNU Social
|
||||||
|
@ -819,17 +1121,32 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
if ($serverret["success"] AND ($serverret["body"] != '{"error":"not implemented"}') AND
|
if ($serverret["success"] AND ($serverret["body"] != '{"error":"not implemented"}') AND
|
||||||
($serverret["body"] != '') AND (strlen($serverret["body"]) < 30)) {
|
($serverret["body"] != '') AND (strlen($serverret["body"]) < 30)) {
|
||||||
$platform = "GNU Social";
|
$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;
|
$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");
|
$serverret = z_fetch_url($server_url."/api/statusnet/config.json");
|
||||||
if ($serverret["success"]) {
|
if ($serverret["success"]) {
|
||||||
$data = json_decode($serverret["body"]);
|
$data = json_decode($serverret["body"]);
|
||||||
|
|
||||||
if (isset($data->site->server)) {
|
if (isset($data->site->server)) {
|
||||||
$last_contact = datetime_convert();
|
$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)) {
|
if (isset($data->site->hubzilla)) {
|
||||||
$platform = $data->site->hubzilla->PLATFORM_NAME;
|
$platform = $data->site->hubzilla->PLATFORM_NAME;
|
||||||
$version = $data->site->hubzilla->RED_VERSION;
|
$version = $data->site->hubzilla->RED_VERSION;
|
||||||
|
@ -866,32 +1183,66 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Query statistics.json. Optional package for Diaspora, Friendica and Redmatrix
|
// Query statistics.json. Optional package for Diaspora, Friendica and Redmatrix
|
||||||
if (!$failure) {
|
if (!$failure) {
|
||||||
$serverret = z_fetch_url($server_url."/statistics.json");
|
$serverret = z_fetch_url($server_url."/statistics.json");
|
||||||
if ($serverret["success"]) {
|
if ($serverret["success"]) {
|
||||||
$data = json_decode($serverret["body"]);
|
$data = json_decode($serverret["body"]);
|
||||||
if ($version == "")
|
if (isset($data->version)) {
|
||||||
$version = $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;
|
$site_name = $data->name;
|
||||||
|
|
||||||
if (isset($data->network) AND ($platform == ""))
|
if (isset($data->network)) {
|
||||||
$platform = $data->network;
|
$platform = $data->network;
|
||||||
|
}
|
||||||
|
|
||||||
if ($platform == "Diaspora")
|
if ($platform == "Diaspora") {
|
||||||
$network = NETWORK_DIASPORA;
|
$network = NETWORK_DIASPORA;
|
||||||
|
}
|
||||||
|
|
||||||
if ($data->registrations_open)
|
if ($data->registrations_open) {
|
||||||
$register_policy = REGISTER_OPEN;
|
$register_policy = REGISTER_OPEN;
|
||||||
else
|
} else {
|
||||||
$register_policy = REGISTER_CLOSED;
|
$register_policy = REGISTER_CLOSED;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($data->version))
|
if (isset($data->version))
|
||||||
$last_contact = datetime_convert();
|
$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
|
// Check for noscrape
|
||||||
// Friendica servers could be detected as OStatus servers
|
// Friendica servers could be detected as OStatus servers
|
||||||
if (!$failure AND in_array($network, array(NETWORK_DFRN, NETWORK_OSTATUS))) {
|
if (!$failure AND in_array($network, array(NETWORK_DFRN, NETWORK_OSTATUS))) {
|
||||||
|
@ -929,16 +1280,21 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look for poco
|
if ($possible_failure AND !$failure) {
|
||||||
if (!$failure) {
|
$last_failure = datetime_convert();
|
||||||
$serverret = z_fetch_url($server_url."/poco");
|
$failure = true;
|
||||||
if ($serverret["success"]) {
|
}
|
||||||
$data = json_decode($serverret["body"]);
|
|
||||||
if (isset($data->totalResults)) {
|
if ($failure) {
|
||||||
$poco = $server_url."/poco";
|
$last_contact = $orig_last_contact;
|
||||||
$last_contact = datetime_convert();
|
} 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
|
// Check again if the server exists
|
||||||
|
@ -949,7 +1305,7 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
$info = strip_tags($info);
|
$info = strip_tags($info);
|
||||||
$platform = strip_tags($platform);
|
$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',
|
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'",
|
`network` = '%s', `platform` = '%s', `last_contact` = '%s', `last_failure` = '%s' WHERE `nurl` = '%s'",
|
||||||
dbesc($server_url),
|
dbesc($server_url),
|
||||||
|
@ -965,7 +1321,7 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
dbesc($last_failure),
|
dbesc($last_failure),
|
||||||
dbesc(normalise_link($server_url))
|
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`)
|
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')",
|
VALUES ('%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
|
||||||
dbesc($server_url),
|
dbesc($server_url),
|
||||||
|
@ -983,7 +1339,7 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
||||||
dbesc($last_failure),
|
dbesc($last_failure),
|
||||||
dbesc(datetime_convert())
|
dbesc(datetime_convert())
|
||||||
);
|
);
|
||||||
|
}
|
||||||
logger("End discovery for server ".$server_url, LOGGER_DEBUG);
|
logger("End discovery for server ".$server_url, LOGGER_DEBUG);
|
||||||
|
|
||||||
return !$failure;
|
return !$failure;
|
||||||
|
@ -1246,6 +1602,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() {
|
function poco_discover_federation() {
|
||||||
$last = get_config('poco','last_federation_discovery');
|
$last = get_config('poco','last_federation_discovery');
|
||||||
|
|
||||||
|
@ -1261,8 +1644,9 @@ function poco_discover_federation() {
|
||||||
if ($serverdata) {
|
if ($serverdata) {
|
||||||
$servers = json_decode($serverdata);
|
$servers = json_decode($serverdata);
|
||||||
|
|
||||||
foreach($servers->pods AS $server)
|
foreach ($servers->pods AS $server) {
|
||||||
poco_check_server("https://".$server->host);
|
proc_run(PRIORITY_LOW, "include/discover_poco.php", "server", base64_encode("https://".$server->host));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Currently disabled, since the service isn't available anymore.
|
// Currently disabled, since the service isn't available anymore.
|
||||||
|
@ -1307,6 +1691,9 @@ function poco_discover($complete = false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Discover new servers out there
|
||||||
|
poco_fetch_serverlist($server["poco"]);
|
||||||
|
|
||||||
// Fetch all users from the other server
|
// Fetch all users from the other server
|
||||||
$url = $server["poco"]."/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation";
|
$url = $server["poco"]."/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation";
|
||||||
|
|
||||||
|
@ -1881,4 +2268,20 @@ function gs_discover() {
|
||||||
q("UPDATE `gserver` SET `last_poco_query` = '%s' WHERE `nurl` = '%s'", dbesc(datetime_convert()), dbesc($server["nurl"]));
|
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;
|
use \Friendica\Core\Config;
|
||||||
|
|
||||||
require_once("boot.php");
|
|
||||||
require_once("include/items.php");
|
require_once("include/items.php");
|
||||||
|
|
||||||
function spool_post_run($argv, $argc) {
|
function spool_post_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);
|
|
||||||
}
|
|
||||||
|
|
||||||
Config::load();
|
|
||||||
|
|
||||||
$path = get_spoolpath();
|
$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
|
<?php
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
|
||||||
|
|
||||||
require_once("boot.php");
|
|
||||||
require_once("include/tags.php");
|
require_once("include/tags.php");
|
||||||
|
|
||||||
global $a, $db;
|
function tagupdate_run(&$argv, &$argc){
|
||||||
|
update_items();
|
||||||
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();
|
|
||||||
|
|
||||||
update_items();
|
|
||||||
killme();
|
|
||||||
?>
|
|
||||||
|
|
106
include/text.php
106
include/text.php
|
@ -268,90 +268,90 @@ function hex2bin($s) {
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
||||||
if(! function_exists('paginate_data')) {
|
|
||||||
/**
|
/**
|
||||||
* Automatica pagination data.
|
* @brief Paginator function. Pushes relevant links in a pager array structure.
|
||||||
|
*
|
||||||
|
* Links are generated depending on the current page and the total number of items.
|
||||||
|
* Inactive links (like "first" and "prev" on page 1) are given the "disabled" class.
|
||||||
|
* Current page link is given the "active" CSS class
|
||||||
*
|
*
|
||||||
* @param App $a App instance
|
* @param App $a App instance
|
||||||
* @param int $count [optional] item count (used with alt pager)
|
* @param int $count [optional] item count (used with minimal pager)
|
||||||
* @return Array data for pagination template
|
* @return Array data for pagination template
|
||||||
*/
|
*/
|
||||||
function paginate_data(App $a, $count=null) {
|
function paginate_data(App $a, $count = null) {
|
||||||
$stripped = preg_replace('/([&?]page=[0-9]*)/','',$a->query_string);
|
$stripped = preg_replace('/([&?]page=[0-9]*)/', '', $a->query_string);
|
||||||
|
|
||||||
$stripped = str_replace('q=','',$stripped);
|
$stripped = str_replace('q=', '', $stripped);
|
||||||
$stripped = trim($stripped,'/');
|
$stripped = trim($stripped, '/');
|
||||||
$pagenum = $a->pager['page'];
|
$pagenum = $a->pager['page'];
|
||||||
|
|
||||||
if (($a->page_offset != "") AND !preg_match('/[?&].offset=/', $stripped))
|
if (($a->page_offset != '') AND !preg_match('/[?&].offset=/', $stripped)) {
|
||||||
$stripped .= "&offset=".urlencode($a->page_offset);
|
$stripped .= '&offset=' . urlencode($a->page_offset);
|
||||||
|
|
||||||
$url = $stripped;
|
|
||||||
|
|
||||||
$data = array();
|
|
||||||
function _l(&$d, $name, $url, $text, $class="") {
|
|
||||||
if (!strpos($url, "?")) {
|
|
||||||
if ($pos = strpos($url, "&"))
|
|
||||||
$url = substr($url, 0, $pos)."?".substr($url, $pos + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$d[$name] = array('url'=>$url, 'text'=>$text, 'class'=>$class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_null($count)){
|
$url = $stripped;
|
||||||
// alt pager
|
$data = array();
|
||||||
if($a->pager['page']>1)
|
|
||||||
_l($data, "prev", $url.'&page='.($a->pager['page'] - 1), t('newer'));
|
function _l(&$d, $name, $url, $text, $class = '') {
|
||||||
if($count>0)
|
if (strpos($url, '?') === false && ($pos = strpos($url, '&')) !== false) {
|
||||||
_l($data, "next", $url.'&page='.($a->pager['page'] + 1), t('older'));
|
$url = substr($url, 0, $pos) . '?' . substr($url, $pos + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$d[$name] = array('url' => $url, 'text' => $text, 'class' => $class);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_null($count)) {
|
||||||
|
// minimal pager (newer / older)
|
||||||
|
$data['class'] = 'pager';
|
||||||
|
_l($data, 'prev', $url . '&page=' . ($a->pager['page'] - 1), t('newer'), 'previous' . ($a->pager['page'] == 1 ? ' disabled' : ''));
|
||||||
|
_l($data, 'next', $url . '&page=' . ($a->pager['page'] + 1), t('older'), 'next' . ($count <= 0 ? ' disabled' : ''));
|
||||||
} else {
|
} else {
|
||||||
// full pager
|
// full pager (first / prev / 1 / 2 / ... / 14 / 15 / next / last)
|
||||||
if($a->pager['total'] > $a->pager['itemspage']) {
|
$data['class'] = 'pagination';
|
||||||
if($a->pager['page'] != 1)
|
if ($a->pager['total'] > $a->pager['itemspage']) {
|
||||||
_l($data, "prev", $url.'&page='.($a->pager['page'] - 1), t('prev'));
|
_l($data, 'first', $url . '&page=1', t('first'), $a->pager['page'] == 1 ? 'disabled' : '');
|
||||||
|
_l($data, 'prev', $url . '&page=' . ($a->pager['page'] - 1), t('prev'), $a->pager['page'] == 1 ? 'disabled' : '');
|
||||||
_l($data, "first", $url."&page=1", t('first'));
|
|
||||||
|
|
||||||
|
|
||||||
$numpages = $a->pager['total'] / $a->pager['itemspage'];
|
$numpages = $a->pager['total'] / $a->pager['itemspage'];
|
||||||
|
|
||||||
$numstart = 1;
|
$numstart = 1;
|
||||||
$numstop = $numpages;
|
$numstop = $numpages;
|
||||||
|
|
||||||
if($numpages > 14) {
|
// Limit the number of displayed page number buttons.
|
||||||
$numstart = (($pagenum > 7) ? ($pagenum - 7) : 1);
|
if ($numpages > 8) {
|
||||||
$numstop = (($pagenum > ($numpages - 7)) ? $numpages : ($numstart + 14));
|
$numstart = (($pagenum > 4) ? ($pagenum - 4) : 1);
|
||||||
|
$numstop = (($pagenum > ($numpages - 7)) ? $numpages : ($numstart + 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
$pages = array();
|
$pages = array();
|
||||||
|
|
||||||
for($i = $numstart; $i <= $numstop; $i++){
|
for ($i = $numstart; $i <= $numstop; $i++) {
|
||||||
if($i == $a->pager['page'])
|
if ($i == $a->pager['page']) {
|
||||||
_l($pages, $i, "#", $i, "current");
|
_l($pages, $i, '#', $i, 'current active');
|
||||||
else
|
} else {
|
||||||
_l($pages, $i, $url."&page=$i", $i, "n");
|
_l($pages, $i, $url . '&page='. $i, $i, 'n');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($a->pager['total'] % $a->pager['itemspage']) != 0) {
|
if (($a->pager['total'] % $a->pager['itemspage']) != 0) {
|
||||||
if($i == $a->pager['page'])
|
if ($i == $a->pager['page']) {
|
||||||
_l($pages, $i, "#", $i, "current");
|
_l($pages, $i, '#', $i, 'current active');
|
||||||
else
|
} else {
|
||||||
_l($pages, $i, $url."&page=$i", $i, "n");
|
_l($pages, $i, $url . '&page=' . $i, $i, 'n');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['pages'] = $pages;
|
$data['pages'] = $pages;
|
||||||
|
|
||||||
$lastpage = (($numpages > intval($numpages)) ? intval($numpages)+1 : $numpages);
|
$lastpage = (($numpages > intval($numpages)) ? intval($numpages)+1 : $numpages);
|
||||||
_l($data, "last", $url."&page=$lastpage", t('last'));
|
_l($data, 'next', $url . '&page=' . ($a->pager['page'] + 1), t('next'), $a->pager['page'] == $lastpage ? 'disabled' : '');
|
||||||
|
_l($data, 'last', $url . '&page=' . $lastpage, t('last'), $a->pager['page'] == $lastpage ? 'disabled' : '');
|
||||||
if(($a->pager['total'] - ($a->pager['itemspage'] * $a->pager['page'])) > 0)
|
|
||||||
_l($data, "next", $url."&page=".($a->pager['page'] + 1), t('next'));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $data;
|
|
||||||
|
|
||||||
}}
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
if(! function_exists('paginate')) {
|
if(! function_exists('paginate')) {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,25 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
|
||||||
|
|
||||||
require_once("boot.php");
|
|
||||||
require_once("include/threads.php");
|
require_once("include/threads.php");
|
||||||
|
|
||||||
global $a, $db;
|
function threadupdate_run(&$argv, &$argc){
|
||||||
|
update_threads();
|
||||||
if(is_null($a))
|
update_threads_mention();
|
||||||
$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();
|
|
||||||
|
|
||||||
update_threads();
|
|
||||||
update_threads_mention();
|
|
||||||
killme();
|
|
||||||
?>
|
|
||||||
|
|
|
@ -11,14 +11,11 @@ define("IMPORT_DEBUG", False);
|
||||||
|
|
||||||
function last_insert_id() {
|
function last_insert_id() {
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
if (IMPORT_DEBUG)
|
if (IMPORT_DEBUG)
|
||||||
return 1;
|
return 1;
|
||||||
if ($db->mysqli) {
|
|
||||||
$thedb = $db->getdb();
|
return $db->insert_id();
|
||||||
return $thedb->insert_id;
|
|
||||||
} else {
|
|
||||||
return mysql_insert_id();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function last_error() {
|
function last_error() {
|
||||||
|
|
|
@ -2,46 +2,23 @@
|
||||||
|
|
||||||
use \Friendica\Core\Config;
|
use \Friendica\Core\Config;
|
||||||
|
|
||||||
require_once("boot.php");
|
|
||||||
|
|
||||||
function update_gcontact_run(&$argv, &$argc){
|
function update_gcontact_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/Scrape.php');
|
require_once('include/Scrape.php');
|
||||||
require_once("include/socgraph.php");
|
require_once('include/socgraph.php');
|
||||||
|
|
||||||
Config::load();
|
|
||||||
|
|
||||||
$a->set_baseurl(get_config('system','url'));
|
|
||||||
|
|
||||||
load_hooks();
|
|
||||||
|
|
||||||
logger('update_gcontact: start');
|
logger('update_gcontact: start');
|
||||||
|
|
||||||
if(($argc > 1) && (intval($argv[1])))
|
if (($argc > 1) && (intval($argv[1]))) {
|
||||||
$contact_id = intval($argv[1]);
|
$contact_id = intval($argv[1]);
|
||||||
|
}
|
||||||
|
|
||||||
if(!$contact_id) {
|
if (!$contact_id) {
|
||||||
logger('update_gcontact: no contact');
|
logger('update_gcontact: no contact');
|
||||||
return;
|
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));
|
$r = q("SELECT * FROM `gcontact` WHERE `id` = %d", intval($contact_id));
|
||||||
|
|
||||||
if (!$r)
|
if (!$r)
|
||||||
|
@ -98,8 +75,3 @@ function update_gcontact_run(&$argv, &$argc){
|
||||||
dbesc(normalise_link($data["url"]))
|
dbesc(normalise_link($data["url"]))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
|
||||||
update_gcontact_run($_SERVER["argv"],$_SERVER["argc"]);
|
|
||||||
killme();
|
|
||||||
}
|
|
||||||
|
|
365
mod/admin.php
365
mod/admin.php
|
@ -27,7 +27,7 @@ require_once("include/text.php");
|
||||||
function admin_post(App $a) {
|
function admin_post(App $a) {
|
||||||
|
|
||||||
|
|
||||||
if(!is_site_admin()) {
|
if (!is_site_admin()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ function admin_post(App $a) {
|
||||||
|
|
||||||
// urls
|
// urls
|
||||||
if ($a->argc > 1) {
|
if ($a->argc > 1) {
|
||||||
switch ($a->argv[1]){
|
switch ($a->argv[1]) {
|
||||||
case 'site':
|
case 'site':
|
||||||
admin_page_site_post($a);
|
admin_page_site_post($a);
|
||||||
break;
|
break;
|
||||||
|
@ -47,10 +47,10 @@ function admin_post(App $a) {
|
||||||
admin_page_users_post($a);
|
admin_page_users_post($a);
|
||||||
break;
|
break;
|
||||||
case 'plugins':
|
case 'plugins':
|
||||||
if($a->argc > 2 &&
|
if ($a->argc > 2 &&
|
||||||
is_file("addon/".$a->argv[2]."/".$a->argv[2].".php")) {
|
is_file("addon/".$a->argv[2]."/".$a->argv[2].".php")) {
|
||||||
@include_once("addon/".$a->argv[2]."/".$a->argv[2].".php");
|
@include_once("addon/".$a->argv[2]."/".$a->argv[2].".php");
|
||||||
if(function_exists($a->argv[2].'_plugin_admin_post')) {
|
if (function_exists($a->argv[2].'_plugin_admin_post')) {
|
||||||
$func = $a->argv[2].'_plugin_admin_post';
|
$func = $a->argv[2].'_plugin_admin_post';
|
||||||
$func($a);
|
$func($a);
|
||||||
}
|
}
|
||||||
|
@ -59,14 +59,16 @@ function admin_post(App $a) {
|
||||||
return; // NOTREACHED
|
return; // NOTREACHED
|
||||||
break;
|
break;
|
||||||
case 'themes':
|
case 'themes':
|
||||||
if($a->argc < 2) {
|
if ($a->argc < 2) {
|
||||||
if(is_ajax()) return;
|
if (is_ajax()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
goaway('admin/');
|
goaway('admin/');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$theme = $a->argv[2];
|
$theme = $a->argv[2];
|
||||||
if(is_file("view/theme/$theme/config.php")){
|
if (is_file("view/theme/$theme/config.php")) {
|
||||||
function __call_theme_admin_post(App $a, $theme) {
|
function __call_theme_admin_post(App $a, $theme) {
|
||||||
$orig_theme = $a->theme;
|
$orig_theme = $a->theme;
|
||||||
$orig_page = $a->page;
|
$orig_page = $a->page;
|
||||||
|
@ -77,8 +79,10 @@ function admin_post(App $a) {
|
||||||
|
|
||||||
|
|
||||||
$init = $theme."_init";
|
$init = $theme."_init";
|
||||||
if(function_exists($init)) $init($a);
|
if (function_exists($init)) {
|
||||||
if(function_exists("theme_admin_post")) {
|
$init($a);
|
||||||
|
}
|
||||||
|
if (function_exists("theme_admin_post")) {
|
||||||
$admin_form = theme_admin_post($a);
|
$admin_form = theme_admin_post($a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,8 +94,9 @@ function admin_post(App $a) {
|
||||||
__call_theme_admin_post($a, $theme);
|
__call_theme_admin_post($a, $theme);
|
||||||
}
|
}
|
||||||
info(t('Theme settings updated.'));
|
info(t('Theme settings updated.'));
|
||||||
if(is_ajax()) return;
|
if (is_ajax()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
goaway('admin/themes/'.$theme);
|
goaway('admin/themes/'.$theme);
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
|
@ -130,7 +135,7 @@ function admin_post(App $a) {
|
||||||
*/
|
*/
|
||||||
function admin_content(App $a) {
|
function admin_content(App $a) {
|
||||||
|
|
||||||
if(!is_site_admin()) {
|
if (!is_site_admin()) {
|
||||||
return login(false);
|
return login(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +173,7 @@ function admin_content(App $a) {
|
||||||
|
|
||||||
$r = q("SELECT `name` FROM `addon` WHERE `plugin_admin` = 1 ORDER BY `name`");
|
$r = q("SELECT `name` FROM `addon` WHERE `plugin_admin` = 1 ORDER BY `name`");
|
||||||
$aside_tools['plugins_admin']=array();
|
$aside_tools['plugins_admin']=array();
|
||||||
foreach ($r as $h){
|
foreach ($r as $h) {
|
||||||
$plugin =$h['name'];
|
$plugin =$h['name'];
|
||||||
$aside_tools['plugins_admin'][] = array("admin/plugins/".$plugin, $plugin, "plugin");
|
$aside_tools['plugins_admin'][] = array("admin/plugins/".$plugin, $plugin, "plugin");
|
||||||
// temp plugins with admin
|
// temp plugins with admin
|
||||||
|
@ -199,8 +204,8 @@ function admin_content(App $a) {
|
||||||
*/
|
*/
|
||||||
$o = '';
|
$o = '';
|
||||||
// urls
|
// urls
|
||||||
if($a->argc > 1) {
|
if ($a->argc > 1) {
|
||||||
switch ($a->argv[1]){
|
switch ($a->argv[1]) {
|
||||||
case 'site':
|
case 'site':
|
||||||
$o = admin_page_site($a);
|
$o = admin_page_site($a);
|
||||||
break;
|
break;
|
||||||
|
@ -238,7 +243,7 @@ function admin_content(App $a) {
|
||||||
$o = admin_page_summary($a);
|
$o = admin_page_summary($a);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_ajax()) {
|
if (is_ajax()) {
|
||||||
echo $o;
|
echo $o;
|
||||||
killme();
|
killme();
|
||||||
return '';
|
return '';
|
||||||
|
@ -270,8 +275,8 @@ function admin_page_federation(App $a) {
|
||||||
// off one % two of them are needed in the query
|
// off one % two of them are needed in the query
|
||||||
// Add more platforms if you like, when one returns 0 known nodes it is not
|
// Add more platforms if you like, when one returns 0 known nodes it is not
|
||||||
// displayed on the stats page.
|
// displayed on the stats page.
|
||||||
$platforms = array('Friendica', 'Diaspora', '%%red%%', 'Hubzilla', 'BlaBlaNet', 'GNU Social', 'StatusNet', 'Mastodon');
|
$platforms = array('Friendi%%a', 'Diaspora', '%%red%%', 'Hubzilla', 'BlaBlaNet', 'GNU Social', 'StatusNet', 'Mastodon');
|
||||||
$colors = array('Friendica' => '#ffc018', // orange from the logo
|
$colors = array('Friendi%%a' => '#ffc018', // orange from the logo
|
||||||
'Diaspora' => '#a1a1a1', // logo is black and white, makes a gray
|
'Diaspora' => '#a1a1a1', // logo is black and white, makes a gray
|
||||||
'%%red%%' => '#c50001', // fire red from the logo
|
'%%red%%' => '#c50001', // fire red from the logo
|
||||||
'Hubzilla' => '#43488a', // blue from the logo
|
'Hubzilla' => '#43488a', // blue from the logo
|
||||||
|
@ -310,19 +315,21 @@ function admin_page_federation(App $a) {
|
||||||
// in the DB the Diaspora versions have the format x.x.x.x-xx the last
|
// in the DB the Diaspora versions have the format x.x.x.x-xx the last
|
||||||
// part (-xx) should be removed to clean up the versions from the "head
|
// part (-xx) should be removed to clean up the versions from the "head
|
||||||
// commit" information and combined into a single entry for x.x.x.x
|
// commit" information and combined into a single entry for x.x.x.x
|
||||||
if($p=='Diaspora') {
|
if ($p == 'Diaspora') {
|
||||||
$newV = array();
|
$newV = array();
|
||||||
$newVv = array();
|
$newVv = array();
|
||||||
foreach($v as $vv) {
|
foreach ($v as $vv) {
|
||||||
$newVC = $vv['total'];
|
$newVC = $vv['total'];
|
||||||
$newVV = $vv['version'];
|
$newVV = $vv['version'];
|
||||||
$posDash = strpos($newVV, '-');
|
$posDash = strpos($newVV, '-');
|
||||||
if($posDash)
|
if ($posDash) {
|
||||||
$newVV = substr($newVV, 0, $posDash);
|
$newVV = substr($newVV, 0, $posDash);
|
||||||
if(isset($newV[$newVV]))
|
}
|
||||||
|
if (isset($newV[$newVV])) {
|
||||||
$newV[$newVV] += $newVC;
|
$newV[$newVV] += $newVC;
|
||||||
else
|
} else {
|
||||||
$newV[$newVV] = $newVC;
|
$newV[$newVV] = $newVC;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
foreach ($newV as $key => $value) {
|
foreach ($newV as $key => $value) {
|
||||||
array_push($newVv, array('total'=>$value, 'version'=>$key));
|
array_push($newVv, array('total'=>$value, 'version'=>$key));
|
||||||
|
@ -333,7 +340,7 @@ function admin_page_federation(App $a) {
|
||||||
// early friendica versions have the format x.x.xxxx where xxxx is the
|
// early friendica versions have the format x.x.xxxx where xxxx is the
|
||||||
// DB version stamp; those should be operated out and versions be
|
// DB version stamp; those should be operated out and versions be
|
||||||
// conbined
|
// conbined
|
||||||
if($p=='Friendica') {
|
if ($p == 'Friendi%%a') {
|
||||||
$newV = array();
|
$newV = array();
|
||||||
$newVv = array();
|
$newVv = array();
|
||||||
foreach ($v as $vv) {
|
foreach ($v as $vv) {
|
||||||
|
@ -341,12 +348,14 @@ function admin_page_federation(App $a) {
|
||||||
$newVV = $vv['version'];
|
$newVV = $vv['version'];
|
||||||
$lastDot = strrpos($newVV,'.');
|
$lastDot = strrpos($newVV,'.');
|
||||||
$len = strlen($newVV)-1;
|
$len = strlen($newVV)-1;
|
||||||
if(($lastDot == $len-4) && (!strrpos($newVV,'-rc')==$len-3))
|
if (($lastDot == $len-4) && (!strrpos($newVV,'-rc') == $len-3)) {
|
||||||
$newVV = substr($newVV, 0, $lastDot);
|
$newVV = substr($newVV, 0, $lastDot);
|
||||||
if(isset($newV[$newVV]))
|
}
|
||||||
|
if (isset($newV[$newVV])) {
|
||||||
$newV[$newVV] += $newVC;
|
$newV[$newVV] += $newVC;
|
||||||
else
|
} else {
|
||||||
$newV[$newVV] = $newVC;
|
$newV[$newVV] = $newVC;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
foreach ($newV as $key => $value) {
|
foreach ($newV as $key => $value) {
|
||||||
array_push($newVv, array('total'=>$value, 'version'=>$key));
|
array_push($newVv, array('total'=>$value, 'version'=>$key));
|
||||||
|
@ -455,7 +464,10 @@ function admin_page_summary(App $a) {
|
||||||
);
|
);
|
||||||
|
|
||||||
$users=0;
|
$users=0;
|
||||||
foreach ($r as $u){ $accounts[$u['page-flags']][1] = $u['count']; $users+= $u['count']; }
|
foreach ($r as $u) {
|
||||||
|
$accounts[$u['page-flags']][1] = $u['count'];
|
||||||
|
$users+= $u['count'];
|
||||||
|
}
|
||||||
|
|
||||||
logger('accounts: '.print_r($accounts,true),LOGGER_DATA);
|
logger('accounts: '.print_r($accounts,true),LOGGER_DATA);
|
||||||
|
|
||||||
|
@ -468,12 +480,8 @@ function admin_page_summary(App $a) {
|
||||||
$r = qu("SELECT COUNT(*) AS `total` FROM `queue` WHERE 1");
|
$r = qu("SELECT COUNT(*) AS `total` FROM `queue` WHERE 1");
|
||||||
$queue = (($r) ? $r[0]['total'] : 0);
|
$queue = (($r) ? $r[0]['total'] : 0);
|
||||||
|
|
||||||
if (get_config('system','worker')) {
|
$r = qu("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE 1");
|
||||||
$r = qu("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE 1");
|
$workerqueue = (($r) ? $r[0]['total'] : 0);
|
||||||
$workerqueue = (($r) ? $r[0]['total'] : 0);
|
|
||||||
} else {
|
|
||||||
$workerqueue = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We can do better, but this is a quick queue status
|
// We can do better, but this is a quick queue status
|
||||||
|
|
||||||
|
@ -485,7 +493,6 @@ function admin_page_summary(App $a) {
|
||||||
'$title' => t('Administration'),
|
'$title' => t('Administration'),
|
||||||
'$page' => t('Summary'),
|
'$page' => t('Summary'),
|
||||||
'$queues' => $queues,
|
'$queues' => $queues,
|
||||||
'$workeractive' => get_config('system','worker'),
|
|
||||||
'$users' => array(t('Registered users'), $users),
|
'$users' => array(t('Registered users'), $users),
|
||||||
'$accounts' => $accounts,
|
'$accounts' => $accounts,
|
||||||
'$pending' => array(t('Pending registrations'), $pending),
|
'$pending' => array(t('Pending registrations'), $pending),
|
||||||
|
@ -506,19 +513,19 @@ function admin_page_summary(App $a) {
|
||||||
* @param App $a
|
* @param App $a
|
||||||
*/
|
*/
|
||||||
function admin_page_site_post(App $a) {
|
function admin_page_site_post(App $a) {
|
||||||
if(!x($_POST,"page_site")) {
|
if (!x($_POST,"page_site")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
check_form_security_token_redirectOnErr('/admin/site', 'admin_site');
|
check_form_security_token_redirectOnErr('/admin/site', 'admin_site');
|
||||||
|
|
||||||
// relocate
|
// relocate
|
||||||
if(x($_POST,'relocate') && x($_POST,'relocate_url') && $_POST['relocate_url']!="") {
|
if (x($_POST,'relocate') && x($_POST,'relocate_url') && $_POST['relocate_url'] != "") {
|
||||||
$new_url = $_POST['relocate_url'];
|
$new_url = $_POST['relocate_url'];
|
||||||
$new_url = rtrim($new_url,"/");
|
$new_url = rtrim($new_url,"/");
|
||||||
|
|
||||||
$parsed = @parse_url($new_url);
|
$parsed = @parse_url($new_url);
|
||||||
if(!$parsed || (!x($parsed,'host') || !x($parsed,'scheme'))) {
|
if (!$parsed || (!x($parsed,'host') || !x($parsed,'scheme'))) {
|
||||||
notice(t("Can not parse base url. Must have at least <scheme>://<domain>"));
|
notice(t("Can not parse base url. Must have at least <scheme>://<domain>"));
|
||||||
goaway('admin/site');
|
goaway('admin/site');
|
||||||
}
|
}
|
||||||
|
@ -551,7 +558,7 @@ function admin_page_site_post(App $a) {
|
||||||
|
|
||||||
$q = sprintf("UPDATE %s SET %s;", $table_name, $upds);
|
$q = sprintf("UPDATE %s SET %s;", $table_name, $upds);
|
||||||
$r = q($q);
|
$r = q($q);
|
||||||
if(!$r) {
|
if (!$r) {
|
||||||
notice("Failed updating '$table_name': ".$db->error);
|
notice("Failed updating '$table_name': ".$db->error);
|
||||||
goaway('admin/site');
|
goaway('admin/site');
|
||||||
}
|
}
|
||||||
|
@ -630,8 +637,6 @@ function admin_page_site_post(App $a) {
|
||||||
$proxyuser = ((x($_POST,'proxyuser')) ? notags(trim($_POST['proxyuser'])) : '');
|
$proxyuser = ((x($_POST,'proxyuser')) ? notags(trim($_POST['proxyuser'])) : '');
|
||||||
$proxy = ((x($_POST,'proxy')) ? notags(trim($_POST['proxy'])) : '');
|
$proxy = ((x($_POST,'proxy')) ? notags(trim($_POST['proxy'])) : '');
|
||||||
$timeout = ((x($_POST,'timeout')) ? intval(trim($_POST['timeout'])) : 60);
|
$timeout = ((x($_POST,'timeout')) ? intval(trim($_POST['timeout'])) : 60);
|
||||||
$delivery_interval = ((x($_POST,'delivery_interval')) ? intval(trim($_POST['delivery_interval'])) : 0);
|
|
||||||
$poll_interval = ((x($_POST,'poll_interval')) ? intval(trim($_POST['poll_interval'])) : 0);
|
|
||||||
$maxloadavg = ((x($_POST,'maxloadavg')) ? intval(trim($_POST['maxloadavg'])) : 50);
|
$maxloadavg = ((x($_POST,'maxloadavg')) ? intval(trim($_POST['maxloadavg'])) : 50);
|
||||||
$maxloadavg_frontend = ((x($_POST,'maxloadavg_frontend')) ? intval(trim($_POST['maxloadavg_frontend'])) : 50);
|
$maxloadavg_frontend = ((x($_POST,'maxloadavg_frontend')) ? intval(trim($_POST['maxloadavg_frontend'])) : 50);
|
||||||
$optimize_max_tablesize = ((x($_POST,'optimize_max_tablesize')) ? intval(trim($_POST['optimize_max_tablesize'])): 100);
|
$optimize_max_tablesize = ((x($_POST,'optimize_max_tablesize')) ? intval(trim($_POST['optimize_max_tablesize'])): 100);
|
||||||
|
@ -649,37 +654,32 @@ function admin_page_site_post(App $a) {
|
||||||
$diaspora_enabled = ((x($_POST,'diaspora_enabled')) ? True : False);
|
$diaspora_enabled = ((x($_POST,'diaspora_enabled')) ? True : False);
|
||||||
$ssl_policy = ((x($_POST,'ssl_policy')) ? intval($_POST['ssl_policy']) : 0);
|
$ssl_policy = ((x($_POST,'ssl_policy')) ? intval($_POST['ssl_policy']) : 0);
|
||||||
$force_ssl = ((x($_POST,'force_ssl')) ? True : False);
|
$force_ssl = ((x($_POST,'force_ssl')) ? True : False);
|
||||||
$old_share = ((x($_POST,'old_share')) ? True : False);
|
|
||||||
$hide_help = ((x($_POST,'hide_help')) ? True : False);
|
$hide_help = ((x($_POST,'hide_help')) ? True : False);
|
||||||
$suppress_language = ((x($_POST,'suppress_language')) ? True : False);
|
|
||||||
$suppress_tags = ((x($_POST,'suppress_tags')) ? True : False);
|
$suppress_tags = ((x($_POST,'suppress_tags')) ? True : False);
|
||||||
$use_fulltext_engine = ((x($_POST,'use_fulltext_engine')) ? True : False);
|
$use_fulltext_engine = ((x($_POST,'use_fulltext_engine')) ? True : False);
|
||||||
$itemcache = ((x($_POST,'itemcache')) ? notags(trim($_POST['itemcache'])) : '');
|
$itemcache = ((x($_POST,'itemcache')) ? notags(trim($_POST['itemcache'])) : '');
|
||||||
$itemcache_duration = ((x($_POST,'itemcache_duration')) ? intval($_POST['itemcache_duration']) : 0);
|
$itemcache_duration = ((x($_POST,'itemcache_duration')) ? intval($_POST['itemcache_duration']) : 0);
|
||||||
$max_comments = ((x($_POST,'max_comments')) ? intval($_POST['max_comments']) : 0);
|
$max_comments = ((x($_POST,'max_comments')) ? intval($_POST['max_comments']) : 0);
|
||||||
$lockpath = ((x($_POST,'lockpath')) ? notags(trim($_POST['lockpath'])) : '');
|
|
||||||
$temppath = ((x($_POST,'temppath')) ? notags(trim($_POST['temppath'])) : '');
|
$temppath = ((x($_POST,'temppath')) ? notags(trim($_POST['temppath'])) : '');
|
||||||
$basepath = ((x($_POST,'basepath')) ? notags(trim($_POST['basepath'])) : '');
|
$basepath = ((x($_POST,'basepath')) ? notags(trim($_POST['basepath'])) : '');
|
||||||
$singleuser = ((x($_POST,'singleuser')) ? notags(trim($_POST['singleuser'])) : '');
|
$singleuser = ((x($_POST,'singleuser')) ? notags(trim($_POST['singleuser'])) : '');
|
||||||
$proxy_disabled = ((x($_POST,'proxy_disabled')) ? True : False);
|
$proxy_disabled = ((x($_POST,'proxy_disabled')) ? True : False);
|
||||||
$old_pager = ((x($_POST,'old_pager')) ? True : False);
|
|
||||||
$only_tag_search = ((x($_POST,'only_tag_search')) ? True : False);
|
$only_tag_search = ((x($_POST,'only_tag_search')) ? True : False);
|
||||||
$rino = ((x($_POST,'rino')) ? intval($_POST['rino']) : 0);
|
$rino = ((x($_POST,'rino')) ? intval($_POST['rino']) : 0);
|
||||||
$embedly = ((x($_POST,'embedly')) ? notags(trim($_POST['embedly'])) : '');
|
$embedly = ((x($_POST,'embedly')) ? notags(trim($_POST['embedly'])) : '');
|
||||||
$worker = ((x($_POST,'worker')) ? True : False);
|
|
||||||
$worker_queues = ((x($_POST,'worker_queues')) ? intval($_POST['worker_queues']) : 4);
|
$worker_queues = ((x($_POST,'worker_queues')) ? intval($_POST['worker_queues']) : 4);
|
||||||
$worker_dont_fork = ((x($_POST,'worker_dont_fork')) ? True : False);
|
$worker_dont_fork = ((x($_POST,'worker_dont_fork')) ? True : False);
|
||||||
$worker_fastlane = ((x($_POST,'worker_fastlane')) ? True : False);
|
$worker_fastlane = ((x($_POST,'worker_fastlane')) ? True : False);
|
||||||
$worker_frontend = ((x($_POST,'worker_frontend')) ? True : False);
|
$worker_frontend = ((x($_POST,'worker_frontend')) ? True : False);
|
||||||
|
|
||||||
if($a->get_path() != "")
|
if ($a->get_path() != "") {
|
||||||
$diaspora_enabled = false;
|
$diaspora_enabled = false;
|
||||||
|
}
|
||||||
if(!$thread_allow)
|
if (!$thread_allow) {
|
||||||
$ostatus_disabled = true;
|
$ostatus_disabled = true;
|
||||||
|
}
|
||||||
if($ssl_policy != intval(get_config('system','ssl_policy'))) {
|
if ($ssl_policy != intval(get_config('system','ssl_policy'))) {
|
||||||
if($ssl_policy == SSL_POLICY_FULL) {
|
if ($ssl_policy == SSL_POLICY_FULL) {
|
||||||
q("UPDATE `contact` SET
|
q("UPDATE `contact` SET
|
||||||
`url` = REPLACE(`url` , 'http:' , 'https:'),
|
`url` = REPLACE(`url` , 'http:' , 'https:'),
|
||||||
`photo` = REPLACE(`photo` , 'http:' , 'https:'),
|
`photo` = REPLACE(`photo` , 'http:' , 'https:'),
|
||||||
|
@ -697,8 +697,7 @@ function admin_page_site_post(App $a) {
|
||||||
`thumb` = REPLACE(`thumb` , 'http:' , 'https:')
|
`thumb` = REPLACE(`thumb` , 'http:' , 'https:')
|
||||||
WHERE 1 "
|
WHERE 1 "
|
||||||
);
|
);
|
||||||
}
|
} elseif ($ssl_policy == SSL_POLICY_SELFSIGN) {
|
||||||
elseif($ssl_policy == SSL_POLICY_SELFSIGN) {
|
|
||||||
q("UPDATE `contact` SET
|
q("UPDATE `contact` SET
|
||||||
`url` = REPLACE(`url` , 'https:' , 'http:'),
|
`url` = REPLACE(`url` , 'https:' , 'http:'),
|
||||||
`photo` = REPLACE(`photo` , 'https:' , 'http:'),
|
`photo` = REPLACE(`photo` , 'https:' , 'http:'),
|
||||||
|
@ -719,8 +718,6 @@ function admin_page_site_post(App $a) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set_config('system','ssl_policy',$ssl_policy);
|
set_config('system','ssl_policy',$ssl_policy);
|
||||||
set_config('system','delivery_interval',$delivery_interval);
|
|
||||||
set_config('system','poll_interval',$poll_interval);
|
|
||||||
set_config('system','maxloadavg',$maxloadavg);
|
set_config('system','maxloadavg',$maxloadavg);
|
||||||
set_config('system','maxloadavg_frontend',$maxloadavg_frontend);
|
set_config('system','maxloadavg_frontend',$maxloadavg_frontend);
|
||||||
set_config('system','optimize_max_tablesize',$optimize_max_tablesize);
|
set_config('system','optimize_max_tablesize',$optimize_max_tablesize);
|
||||||
|
@ -734,12 +731,11 @@ function admin_page_site_post(App $a) {
|
||||||
set_config('config','sitename',$sitename);
|
set_config('config','sitename',$sitename);
|
||||||
set_config('config','hostname',$hostname);
|
set_config('config','hostname',$hostname);
|
||||||
set_config('config','sender_email', $sender_email);
|
set_config('config','sender_email', $sender_email);
|
||||||
set_config('system','suppress_language',$suppress_language);
|
|
||||||
set_config('system','suppress_tags',$suppress_tags);
|
set_config('system','suppress_tags',$suppress_tags);
|
||||||
set_config('system','shortcut_icon',$shortcut_icon);
|
set_config('system','shortcut_icon',$shortcut_icon);
|
||||||
set_config('system','touch_icon',$touch_icon);
|
set_config('system','touch_icon',$touch_icon);
|
||||||
|
|
||||||
if($banner=="") {
|
if ($banner == "") {
|
||||||
// don't know why, but del_config doesn't work...
|
// don't know why, but del_config doesn't work...
|
||||||
q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
|
q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
|
||||||
dbesc("system"),
|
dbesc("system"),
|
||||||
|
@ -749,7 +745,7 @@ function admin_page_site_post(App $a) {
|
||||||
set_config('system','banner', $banner);
|
set_config('system','banner', $banner);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($info=="") {
|
if ($info == "") {
|
||||||
del_config('config','info');
|
del_config('config','info');
|
||||||
} else {
|
} else {
|
||||||
set_config('config','info',$info);
|
set_config('config','info',$info);
|
||||||
|
@ -757,12 +753,12 @@ function admin_page_site_post(App $a) {
|
||||||
set_config('system','language', $language);
|
set_config('system','language', $language);
|
||||||
set_config('system','theme', $theme);
|
set_config('system','theme', $theme);
|
||||||
|
|
||||||
if($theme_mobile === '---') {
|
if ($theme_mobile === '---') {
|
||||||
del_config('system','mobile-theme');
|
del_config('system','mobile-theme');
|
||||||
} else {
|
} else {
|
||||||
set_config('system','mobile-theme', $theme_mobile);
|
set_config('system','mobile-theme', $theme_mobile);
|
||||||
}
|
}
|
||||||
if($singleuser === '---') {
|
if ($singleuser === '---') {
|
||||||
del_config('system','singleuser');
|
del_config('system','singleuser');
|
||||||
} else {
|
} else {
|
||||||
set_config('system','singleuser', $singleuser);
|
set_config('system','singleuser', $singleuser);
|
||||||
|
@ -805,25 +801,21 @@ function admin_page_site_post(App $a) {
|
||||||
set_config('config','private_addons', $private_addons);
|
set_config('config','private_addons', $private_addons);
|
||||||
|
|
||||||
set_config('system','force_ssl', $force_ssl);
|
set_config('system','force_ssl', $force_ssl);
|
||||||
set_config('system','old_share', $old_share);
|
|
||||||
set_config('system','hide_help', $hide_help);
|
set_config('system','hide_help', $hide_help);
|
||||||
set_config('system','use_fulltext_engine', $use_fulltext_engine);
|
set_config('system','use_fulltext_engine', $use_fulltext_engine);
|
||||||
set_config('system','itemcache', $itemcache);
|
set_config('system','itemcache', $itemcache);
|
||||||
set_config('system','itemcache_duration', $itemcache_duration);
|
set_config('system','itemcache_duration', $itemcache_duration);
|
||||||
set_config('system','max_comments', $max_comments);
|
set_config('system','max_comments', $max_comments);
|
||||||
set_config('system','lockpath', $lockpath);
|
|
||||||
set_config('system','temppath', $temppath);
|
set_config('system','temppath', $temppath);
|
||||||
set_config('system','basepath', $basepath);
|
set_config('system','basepath', $basepath);
|
||||||
set_config('system','proxy_disabled', $proxy_disabled);
|
set_config('system','proxy_disabled', $proxy_disabled);
|
||||||
set_config('system','old_pager', $old_pager);
|
|
||||||
set_config('system','only_tag_search', $only_tag_search);
|
set_config('system','only_tag_search', $only_tag_search);
|
||||||
set_config('system','worker', $worker);
|
|
||||||
set_config('system','worker_queues', $worker_queues);
|
set_config('system','worker_queues', $worker_queues);
|
||||||
set_config('system','worker_dont_fork', $worker_dont_fork);
|
set_config('system','worker_dont_fork', $worker_dont_fork);
|
||||||
set_config('system','worker_fastlane', $worker_fastlane);
|
set_config('system','worker_fastlane', $worker_fastlane);
|
||||||
set_config('system','frontend_worker', $worker_frontend);
|
set_config('system','frontend_worker', $worker_frontend);
|
||||||
|
|
||||||
if($rino==2 and !function_exists('mcrypt_create_iv')) {
|
if (($rino == 2) and !function_exists('mcrypt_create_iv')) {
|
||||||
notice(t("RINO2 needs mcrypt php extension to work."));
|
notice(t("RINO2 needs mcrypt php extension to work."));
|
||||||
} else {
|
} else {
|
||||||
set_config('system','rino_encrypt', $rino);
|
set_config('system','rino_encrypt', $rino);
|
||||||
|
@ -851,7 +843,7 @@ function admin_page_site(App $a) {
|
||||||
/* Installed langs */
|
/* Installed langs */
|
||||||
$lang_choices = get_available_languages();
|
$lang_choices = get_available_languages();
|
||||||
|
|
||||||
if(strlen(get_config('system','directory_submit_url')) AND
|
if (strlen(get_config('system','directory_submit_url')) AND
|
||||||
!strlen(get_config('system','directory'))) {
|
!strlen(get_config('system','directory'))) {
|
||||||
set_config('system','directory', dirname(get_config('system','directory_submit_url')));
|
set_config('system','directory', dirname(get_config('system','directory_submit_url')));
|
||||||
del_config('system','directory_submit_url');
|
del_config('system','directory_submit_url');
|
||||||
|
@ -862,12 +854,12 @@ function admin_page_site(App $a) {
|
||||||
$theme_choices_mobile = array();
|
$theme_choices_mobile = array();
|
||||||
$theme_choices_mobile["---"] = t("No special theme for mobile devices");
|
$theme_choices_mobile["---"] = t("No special theme for mobile devices");
|
||||||
$files = glob('view/theme/*');
|
$files = glob('view/theme/*');
|
||||||
if($files) {
|
if ($files) {
|
||||||
|
|
||||||
$allowed_theme_list = Config::get('system', 'allowed_themes');
|
$allowed_theme_list = Config::get('system', 'allowed_themes');
|
||||||
|
|
||||||
foreach($files as $file) {
|
foreach ($files as $file) {
|
||||||
if(intval(file_exists($file.'/unsupported')))
|
if (intval(file_exists($file.'/unsupported')))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$f = basename($file);
|
$f = basename($file);
|
||||||
|
@ -879,7 +871,7 @@ function admin_page_site(App $a) {
|
||||||
|
|
||||||
$theme_name = ((file_exists($file.'/experimental')) ? sprintf("%s - \x28Experimental\x29", $f) : $f);
|
$theme_name = ((file_exists($file.'/experimental')) ? sprintf("%s - \x28Experimental\x29", $f) : $f);
|
||||||
|
|
||||||
if(file_exists($file.'/mobile')) {
|
if (file_exists($file.'/mobile')) {
|
||||||
$theme_choices_mobile[$f] = $theme_name;
|
$theme_choices_mobile[$f] = $theme_name;
|
||||||
} else {
|
} else {
|
||||||
$theme_choices[$f] = $theme_name;
|
$theme_choices[$f] = $theme_name;
|
||||||
|
@ -928,15 +920,15 @@ function admin_page_site(App $a) {
|
||||||
|
|
||||||
/* Banner */
|
/* Banner */
|
||||||
$banner = get_config('system','banner');
|
$banner = get_config('system','banner');
|
||||||
if($banner == false)
|
if ($banner == false) {
|
||||||
$banner = '<a href="http://friendica.com"><img id="logo-img" src="images/friendica-32.png" alt="logo" /></a><span id="logo-text"><a href="http://friendica.com">Friendica</a></span>';
|
$banner = '<a href="http://friendica.com"><img id="logo-img" src="images/friendica-32.png" alt="logo" /></a><span id="logo-text"><a href="http://friendica.com">Friendica</a></span>';
|
||||||
|
}
|
||||||
$banner = htmlspecialchars($banner);
|
$banner = htmlspecialchars($banner);
|
||||||
$info = get_config('config','info');
|
$info = get_config('config','info');
|
||||||
$info = htmlspecialchars($info);
|
$info = htmlspecialchars($info);
|
||||||
|
|
||||||
// Automatically create temporary paths
|
// Automatically create temporary paths
|
||||||
get_temppath();
|
get_temppath();
|
||||||
get_lockpath();
|
|
||||||
get_itemcachepath();
|
get_itemcachepath();
|
||||||
|
|
||||||
//echo "<pre>"; var_dump($lang_choices); die("</pre>");
|
//echo "<pre>"; var_dump($lang_choices); die("</pre>");
|
||||||
|
@ -954,9 +946,9 @@ function admin_page_site(App $a) {
|
||||||
SSL_POLICY_SELFSIGN => t("Self-signed certificate, use SSL for local links only (discouraged)")
|
SSL_POLICY_SELFSIGN => t("Self-signed certificate, use SSL for local links only (discouraged)")
|
||||||
);
|
);
|
||||||
|
|
||||||
if($a->config['hostname'] == "")
|
if ($a->config['hostname'] == "") {
|
||||||
$a->config['hostname'] = $a->get_hostname();
|
$a->config['hostname'] = $a->get_hostname();
|
||||||
|
}
|
||||||
$diaspora_able = ($a->get_path() == "");
|
$diaspora_able = ($a->get_path() == "");
|
||||||
|
|
||||||
$optimize_max_tablesize = Config::get('system','optimize_max_tablesize', 100);
|
$optimize_max_tablesize = Config::get('system','optimize_max_tablesize', 100);
|
||||||
|
@ -996,7 +988,6 @@ function admin_page_site(App $a) {
|
||||||
'$theme_mobile' => array('theme_mobile', t("Mobile system theme"), get_config('system','mobile-theme'), t("Theme for mobile devices"), $theme_choices_mobile),
|
'$theme_mobile' => array('theme_mobile', t("Mobile system theme"), get_config('system','mobile-theme'), t("Theme for mobile devices"), $theme_choices_mobile),
|
||||||
'$ssl_policy' => array('ssl_policy', t("SSL link policy"), (string) intval(get_config('system','ssl_policy')), t("Determines whether generated links should be forced to use SSL"), $ssl_choices),
|
'$ssl_policy' => array('ssl_policy', t("SSL link policy"), (string) intval(get_config('system','ssl_policy')), t("Determines whether generated links should be forced to use SSL"), $ssl_choices),
|
||||||
'$force_ssl' => array('force_ssl', t("Force SSL"), get_config('system','force_ssl'), t("Force all Non-SSL requests to SSL - Attention: on some systems it could lead to endless loops.")),
|
'$force_ssl' => array('force_ssl', t("Force SSL"), get_config('system','force_ssl'), t("Force all Non-SSL requests to SSL - Attention: on some systems it could lead to endless loops.")),
|
||||||
'$old_share' => array('old_share', t("Old style 'Share'"), get_config('system','old_share'), t("Deactivates the bbcode element 'share' for repeating items.")),
|
|
||||||
'$hide_help' => array('hide_help', t("Hide help entry from navigation menu"), get_config('system','hide_help'), t("Hides the menu entry for the Help pages from the navigation menu. You can still access it calling /help directly.")),
|
'$hide_help' => array('hide_help', t("Hide help entry from navigation menu"), get_config('system','hide_help'), t("Hides the menu entry for the Help pages from the navigation menu. You can still access it calling /help directly.")),
|
||||||
'$singleuser' => array('singleuser', t("Single user instance"), get_config('system','singleuser'), t("Make this instance multi-user or single-user for the named user"), $user_names),
|
'$singleuser' => array('singleuser', t("Single user instance"), get_config('system','singleuser'), t("Make this instance multi-user or single-user for the named user"), $user_names),
|
||||||
'$maximagesize' => array('maximagesize', t("Maximum image size"), get_config('system','maximagesize'), t("Maximum size in bytes of uploaded images. Default is 0, which means no limits.")),
|
'$maximagesize' => array('maximagesize', t("Maximum image size"), get_config('system','maximagesize'), t("Maximum size in bytes of uploaded images. Default is 0, which means no limits.")),
|
||||||
|
@ -1036,8 +1027,6 @@ function admin_page_site(App $a) {
|
||||||
'$proxyuser' => array('proxyuser', t("Proxy user"), get_config('system','proxyuser'), ""),
|
'$proxyuser' => array('proxyuser', t("Proxy user"), get_config('system','proxyuser'), ""),
|
||||||
'$proxy' => array('proxy', t("Proxy URL"), get_config('system','proxy'), ""),
|
'$proxy' => array('proxy', t("Proxy URL"), get_config('system','proxy'), ""),
|
||||||
'$timeout' => array('timeout', t("Network timeout"), (x(get_config('system','curl_timeout'))?get_config('system','curl_timeout'):60), t("Value is in seconds. Set to 0 for unlimited (not recommended).")),
|
'$timeout' => array('timeout', t("Network timeout"), (x(get_config('system','curl_timeout'))?get_config('system','curl_timeout'):60), t("Value is in seconds. Set to 0 for unlimited (not recommended).")),
|
||||||
'$delivery_interval' => array('delivery_interval', t("Delivery interval"), (x(get_config('system','delivery_interval'))?get_config('system','delivery_interval'):2), t("Delay background delivery processes by this many seconds to reduce system load. Recommend: 4-5 for shared hosts, 2-3 for virtual private servers. 0-1 for large dedicated servers.")),
|
|
||||||
'$poll_interval' => array('poll_interval', t("Poll interval"), (x(get_config('system','poll_interval'))?get_config('system','poll_interval'):2), t("Delay background polling processes by this many seconds to reduce system load. If 0, use delivery interval.")),
|
|
||||||
'$maxloadavg' => array('maxloadavg', t("Maximum Load Average"), ((intval(get_config('system','maxloadavg')) > 0)?get_config('system','maxloadavg'):50), t("Maximum system load before delivery and poll processes are deferred - default 50.")),
|
'$maxloadavg' => array('maxloadavg', t("Maximum Load Average"), ((intval(get_config('system','maxloadavg')) > 0)?get_config('system','maxloadavg'):50), t("Maximum system load before delivery and poll processes are deferred - default 50.")),
|
||||||
'$maxloadavg_frontend' => array('maxloadavg_frontend', t("Maximum Load Average (Frontend)"), ((intval(get_config('system','maxloadavg_frontend')) > 0)?get_config('system','maxloadavg_frontend'):50), t("Maximum system load before the frontend quits service - default 50.")),
|
'$maxloadavg_frontend' => array('maxloadavg_frontend', t("Maximum Load Average (Frontend)"), ((intval(get_config('system','maxloadavg_frontend')) > 0)?get_config('system','maxloadavg_frontend'):50), t("Maximum system load before the frontend quits service - default 50.")),
|
||||||
'$optimize_max_tablesize'=> array('optimize_max_tablesize', t("Maximum table size for optimization"), $optimize_max_tablesize, t("Maximum table size (in MB) for the automatic optimization - default 100 MB. Enter -1 to disable it.")),
|
'$optimize_max_tablesize'=> array('optimize_max_tablesize', t("Maximum table size for optimization"), $optimize_max_tablesize, t("Maximum table size (in MB) for the automatic optimization - default 100 MB. Enter -1 to disable it.")),
|
||||||
|
@ -1052,16 +1041,13 @@ function admin_page_site(App $a) {
|
||||||
'$nodeinfo' => array('nodeinfo', t("Publish server information"), get_config('system','nodeinfo'), t("If enabled, general server and usage data will be published. The data contains the name and version of the server, number of users with public profiles, number of posts and the activated protocols and connectors. See <a href='http://the-federation.info/'>the-federation.info</a> for details.")),
|
'$nodeinfo' => array('nodeinfo', t("Publish server information"), get_config('system','nodeinfo'), t("If enabled, general server and usage data will be published. The data contains the name and version of the server, number of users with public profiles, number of posts and the activated protocols and connectors. See <a href='http://the-federation.info/'>the-federation.info</a> for details.")),
|
||||||
|
|
||||||
'$use_fulltext_engine' => array('use_fulltext_engine', t("Use MySQL full text engine"), get_config('system','use_fulltext_engine'), t("Activates the full text engine. Speeds up search - but can only search for four and more characters.")),
|
'$use_fulltext_engine' => array('use_fulltext_engine', t("Use MySQL full text engine"), get_config('system','use_fulltext_engine'), t("Activates the full text engine. Speeds up search - but can only search for four and more characters.")),
|
||||||
'$suppress_language' => array('suppress_language', t("Suppress Language"), get_config('system','suppress_language'), t("Suppress language information in meta information about a posting.")),
|
|
||||||
'$suppress_tags' => array('suppress_tags', t("Suppress Tags"), get_config('system','suppress_tags'), t("Suppress showing a list of hashtags at the end of the posting.")),
|
'$suppress_tags' => array('suppress_tags', t("Suppress Tags"), get_config('system','suppress_tags'), t("Suppress showing a list of hashtags at the end of the posting.")),
|
||||||
'$itemcache' => array('itemcache', t("Path to item cache"), get_config('system','itemcache'), t("The item caches buffers generated bbcode and external images.")),
|
'$itemcache' => array('itemcache', t("Path to item cache"), get_config('system','itemcache'), t("The item caches buffers generated bbcode and external images.")),
|
||||||
'$itemcache_duration' => array('itemcache_duration', t("Cache duration in seconds"), get_config('system','itemcache_duration'), t("How long should the cache files be hold? Default value is 86400 seconds (One day). To disable the item cache, set the value to -1.")),
|
'$itemcache_duration' => array('itemcache_duration', t("Cache duration in seconds"), get_config('system','itemcache_duration'), t("How long should the cache files be hold? Default value is 86400 seconds (One day). To disable the item cache, set the value to -1.")),
|
||||||
'$max_comments' => array('max_comments', t("Maximum numbers of comments per post"), get_config('system','max_comments'), t("How much comments should be shown for each post? Default value is 100.")),
|
'$max_comments' => array('max_comments', t("Maximum numbers of comments per post"), get_config('system','max_comments'), t("How much comments should be shown for each post? Default value is 100.")),
|
||||||
'$lockpath' => array('lockpath', t("Path for lock file"), get_config('system','lockpath'), t("The lock file is used to avoid multiple pollers at one time. Only define a folder here.")),
|
|
||||||
'$temppath' => array('temppath', t("Temp path"), get_config('system','temppath'), t("If you have a restricted system where the webserver can't access the system temp path, enter another path here.")),
|
'$temppath' => array('temppath', t("Temp path"), get_config('system','temppath'), t("If you have a restricted system where the webserver can't access the system temp path, enter another path here.")),
|
||||||
'$basepath' => array('basepath', t("Base path to installation"), get_config('system','basepath'), t("If the system cannot detect the correct path to your installation, enter the correct path here. This setting should only be set if you are using a restricted system and symbolic links to your webroot.")),
|
'$basepath' => array('basepath', t("Base path to installation"), get_config('system','basepath'), t("If the system cannot detect the correct path to your installation, enter the correct path here. This setting should only be set if you are using a restricted system and symbolic links to your webroot.")),
|
||||||
'$proxy_disabled' => array('proxy_disabled', t("Disable picture proxy"), get_config('system','proxy_disabled'), t("The picture proxy increases performance and privacy. It shouldn't be used on systems with very low bandwith.")),
|
'$proxy_disabled' => array('proxy_disabled', t("Disable picture proxy"), get_config('system','proxy_disabled'), t("The picture proxy increases performance and privacy. It shouldn't be used on systems with very low bandwith.")),
|
||||||
'$old_pager' => array('old_pager', t("Enable old style pager"), get_config('system','old_pager'), t("The old style pager has page numbers but slows down massively the page speed.")),
|
|
||||||
'$only_tag_search' => array('only_tag_search', t("Only search in tags"), get_config('system','only_tag_search'), t("On large systems the text search can slow down the system extremely.")),
|
'$only_tag_search' => array('only_tag_search', t("Only search in tags"), get_config('system','only_tag_search'), t("On large systems the text search can slow down the system extremely.")),
|
||||||
|
|
||||||
'$relocate_url' => array('relocate_url', t("New base url"), App::get_baseurl(), t("Change base url for this server. Sends relocate message to all DFRN contacts of all users.")),
|
'$relocate_url' => array('relocate_url', t("New base url"), App::get_baseurl(), t("Change base url for this server. Sends relocate message to all DFRN contacts of all users.")),
|
||||||
|
@ -1069,7 +1055,6 @@ function admin_page_site(App $a) {
|
||||||
'$rino' => array('rino', t("RINO Encryption"), intval(get_config('system','rino_encrypt')), t("Encryption layer between nodes."), array("Disabled", "RINO1 (deprecated)", "RINO2")),
|
'$rino' => array('rino', t("RINO Encryption"), intval(get_config('system','rino_encrypt')), t("Encryption layer between nodes."), array("Disabled", "RINO1 (deprecated)", "RINO2")),
|
||||||
'$embedly' => array('embedly', t("Embedly API key"), get_config('system','embedly'), t("<a href='http://embed.ly'>Embedly</a> is used to fetch additional data for web pages. This is an optional parameter.")),
|
'$embedly' => array('embedly', t("Embedly API key"), get_config('system','embedly'), t("<a href='http://embed.ly'>Embedly</a> is used to fetch additional data for web pages. This is an optional parameter.")),
|
||||||
|
|
||||||
'$worker' => array('worker', t("Enable 'worker' background processing"), get_config('system','worker'), t("The worker background processing limits the number of parallel background jobs to a maximum number and respects the system load.")),
|
|
||||||
'$worker_queues' => array('worker_queues', t("Maximum number of parallel workers"), get_config('system','worker_queues'), t("On shared hosters set this to 2. On larger systems, values of 10 are great. Default value is 4.")),
|
'$worker_queues' => array('worker_queues', t("Maximum number of parallel workers"), get_config('system','worker_queues'), t("On shared hosters set this to 2. On larger systems, values of 10 are great. Default value is 4.")),
|
||||||
'$worker_dont_fork' => array('worker_dont_fork', t("Don't use 'proc_open' with the worker"), get_config('system','worker_dont_fork'), t("Enable this if your system doesn't allow the use of 'proc_open'. This can happen on shared hosters. If this is enabled you should increase the frequency of poller calls in your crontab.")),
|
'$worker_dont_fork' => array('worker_dont_fork', t("Don't use 'proc_open' with the worker"), get_config('system','worker_dont_fork'), t("Enable this if your system doesn't allow the use of 'proc_open'. This can happen on shared hosters. If this is enabled you should increase the frequency of poller calls in your crontab.")),
|
||||||
'$worker_fastlane' => array('worker_fastlane', t("Enable fastlane"), get_config('system','worker_fastlane'), t("When enabed, the fastlane mechanism starts an additional worker if processes with higher priority are blocked by processes of lower priority.")),
|
'$worker_fastlane' => array('worker_fastlane', t("Enable fastlane"), get_config('system','worker_fastlane'), t("When enabed, the fastlane mechanism starts an additional worker if processes with higher priority are blocked by processes of lower priority.")),
|
||||||
|
@ -1097,42 +1082,45 @@ function admin_page_dbsync(App $a) {
|
||||||
|
|
||||||
$o = '';
|
$o = '';
|
||||||
|
|
||||||
if($a->argc > 3 && intval($a->argv[3]) && $a->argv[2] === 'mark') {
|
if ($a->argc > 3 && intval($a->argv[3]) && $a->argv[2] === 'mark') {
|
||||||
set_config('database', 'update_'.intval($a->argv[3]), 'success');
|
set_config('database', 'update_'.intval($a->argv[3]), 'success');
|
||||||
$curr = get_config('system','build');
|
$curr = get_config('system','build');
|
||||||
if(intval($curr) == intval($a->argv[3]))
|
if (intval($curr) == intval($a->argv[3])) {
|
||||||
set_config('system','build',intval($curr) + 1);
|
set_config('system','build',intval($curr) + 1);
|
||||||
|
}
|
||||||
info(t('Update has been marked successful').EOL);
|
info(t('Update has been marked successful').EOL);
|
||||||
goaway('admin/dbsync');
|
goaway('admin/dbsync');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($a->argc > 2) AND (intval($a->argv[2]) OR ($a->argv[2] === 'check'))) {
|
if (($a->argc > 2) AND (intval($a->argv[2]) OR ($a->argv[2] === 'check'))) {
|
||||||
require_once("include/dbstructure.php");
|
require_once("include/dbstructure.php");
|
||||||
$retval = update_structure(false, true);
|
$retval = update_structure(false, true);
|
||||||
if(!$retval) {
|
if (!$retval) {
|
||||||
$o .= sprintf(t("Database structure update %s was successfully applied."), DB_UPDATE_VERSION)."<br />";
|
$o .= sprintf(t("Database structure update %s was successfully applied."), DB_UPDATE_VERSION)."<br />";
|
||||||
set_config('database', 'dbupdate_'.DB_UPDATE_VERSION, 'success');
|
set_config('database', 'dbupdate_'.DB_UPDATE_VERSION, 'success');
|
||||||
} else
|
} else {
|
||||||
$o .= sprintf(t("Executing of database structure update %s failed with error: %s"),
|
$o .= sprintf(t("Executing of database structure update %s failed with error: %s"),
|
||||||
DB_UPDATE_VERSION, $retval)."<br />";
|
DB_UPDATE_VERSION, $retval)."<br />";
|
||||||
if($a->argv[2] === 'check')
|
}
|
||||||
|
if ($a->argv[2] === 'check') {
|
||||||
return $o;
|
return $o;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($a->argc > 2 && intval($a->argv[2])) {
|
if ($a->argc > 2 && intval($a->argv[2])) {
|
||||||
require_once('update.php');
|
require_once('update.php');
|
||||||
$func = 'update_'.intval($a->argv[2]);
|
$func = 'update_'.intval($a->argv[2]);
|
||||||
if(function_exists($func)) {
|
if (function_exists($func)) {
|
||||||
$retval = $func();
|
$retval = $func();
|
||||||
if($retval === UPDATE_FAILED) {
|
if ($retval === UPDATE_FAILED) {
|
||||||
$o .= sprintf(t("Executing %s failed with error: %s"), $func, $retval);
|
$o .= sprintf(t("Executing %s failed with error: %s"), $func, $retval);
|
||||||
}
|
}
|
||||||
elseif($retval === UPDATE_SUCCESS) {
|
elseif ($retval === UPDATE_SUCCESS) {
|
||||||
$o .= sprintf(t('Update %s was successfully applied.', $func));
|
$o .= sprintf(t('Update %s was successfully applied.', $func));
|
||||||
set_config('database',$func, 'success');
|
set_config('database',$func, 'success');
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
$o .= sprintf(t('Update %s did not return a status. Unknown if it succeeded.'), $func);
|
$o .= sprintf(t('Update %s did not return a status. Unknown if it succeeded.'), $func);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$o .= sprintf(t('There was no additional update function %s that needed to be called.'), $func)."<br />";
|
$o .= sprintf(t('There was no additional update function %s that needed to be called.'), $func)."<br />";
|
||||||
set_config('database',$func, 'success');
|
set_config('database',$func, 'success');
|
||||||
|
@ -1145,8 +1133,9 @@ function admin_page_dbsync(App $a) {
|
||||||
if (dbm::is_result($r)) {
|
if (dbm::is_result($r)) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
$upd = intval(substr($rr['k'],7));
|
$upd = intval(substr($rr['k'],7));
|
||||||
if($upd < 1139 || $rr['v'] === 'success')
|
if ($upd < 1139 || $rr['v'] === 'success') {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
$failed[] = $upd;
|
$failed[] = $upd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1186,7 +1175,7 @@ function admin_page_users_post(App $a) {
|
||||||
|
|
||||||
check_form_security_token_redirectOnErr('/admin/users', 'admin_users');
|
check_form_security_token_redirectOnErr('/admin/users', 'admin_users');
|
||||||
|
|
||||||
if (!($nu_name==="") && !($nu_email==="") && !($nu_nickname==="")) {
|
if (!($nu_name === "") && !($nu_email === "") && !($nu_nickname === "")) {
|
||||||
require_once('include/user.php');
|
require_once('include/user.php');
|
||||||
|
|
||||||
$result = create_user(array('username'=>$nu_name, 'email'=>$nu_email,
|
$result = create_user(array('username'=>$nu_name, 'email'=>$nu_email,
|
||||||
|
@ -1237,31 +1226,31 @@ function admin_page_users_post(App $a) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(x($_POST,'page_users_block')) {
|
if (x($_POST,'page_users_block')) {
|
||||||
foreach($users as $uid){
|
foreach ($users as $uid) {
|
||||||
q("UPDATE `user` SET `blocked` = 1-`blocked` WHERE `uid` = %s",
|
q("UPDATE `user` SET `blocked` = 1-`blocked` WHERE `uid` = %s",
|
||||||
intval($uid)
|
intval($uid)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
notice(sprintf(tt("%s user blocked/unblocked", "%s users blocked/unblocked", count($users)), count($users)));
|
notice(sprintf(tt("%s user blocked/unblocked", "%s users blocked/unblocked", count($users)), count($users)));
|
||||||
}
|
}
|
||||||
if(x($_POST,'page_users_delete')) {
|
if (x($_POST,'page_users_delete')) {
|
||||||
require_once("include/Contact.php");
|
require_once("include/Contact.php");
|
||||||
foreach($users as $uid){
|
foreach ($users as $uid) {
|
||||||
user_remove($uid);
|
user_remove($uid);
|
||||||
}
|
}
|
||||||
notice(sprintf(tt("%s user deleted", "%s users deleted", count($users)), count($users)));
|
notice(sprintf(tt("%s user deleted", "%s users deleted", count($users)), count($users)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(x($_POST,'page_users_approve')) {
|
if (x($_POST,'page_users_approve')) {
|
||||||
require_once("mod/regmod.php");
|
require_once("mod/regmod.php");
|
||||||
foreach($pending as $hash){
|
foreach ($pending as $hash) {
|
||||||
user_allow($hash);
|
user_allow($hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(x($_POST,'page_users_deny')) {
|
if (x($_POST,'page_users_deny')) {
|
||||||
require_once("mod/regmod.php");
|
require_once("mod/regmod.php");
|
||||||
foreach($pending as $hash){
|
foreach ($pending as $hash) {
|
||||||
user_deny($hash);
|
user_deny($hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1282,31 +1271,31 @@ function admin_page_users_post(App $a) {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function admin_page_users(App $a) {
|
function admin_page_users(App $a) {
|
||||||
if($a->argc>2) {
|
if ($a->argc>2) {
|
||||||
$uid = $a->argv[3];
|
$uid = $a->argv[3];
|
||||||
$user = q("SELECT `username`, `blocked` FROM `user` WHERE `uid` = %d", intval($uid));
|
$user = q("SELECT `username`, `blocked` FROM `user` WHERE `uid` = %d", intval($uid));
|
||||||
if(count($user)==0) {
|
if (count($user) == 0) {
|
||||||
notice('User not found'.EOL);
|
notice('User not found'.EOL);
|
||||||
goaway('admin/users');
|
goaway('admin/users');
|
||||||
return ''; // NOTREACHED
|
return ''; // NOTREACHED
|
||||||
}
|
}
|
||||||
switch($a->argv[2]){
|
switch($a->argv[2]) {
|
||||||
case "delete":{
|
case "delete":
|
||||||
check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't');
|
check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't');
|
||||||
// delete user
|
// delete user
|
||||||
require_once("include/Contact.php");
|
require_once("include/Contact.php");
|
||||||
user_remove($uid);
|
user_remove($uid);
|
||||||
|
|
||||||
notice(sprintf(t("User '%s' deleted"), $user[0]['username']).EOL);
|
notice(sprintf(t("User '%s' deleted"), $user[0]['username']).EOL);
|
||||||
}; break;
|
break;
|
||||||
case "block":{
|
case "block":
|
||||||
check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't');
|
check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't');
|
||||||
q("UPDATE `user` SET `blocked` = %d WHERE `uid` = %s",
|
q("UPDATE `user` SET `blocked` = %d WHERE `uid` = %s",
|
||||||
intval(1-$user[0]['blocked']),
|
intval(1-$user[0]['blocked']),
|
||||||
intval($uid)
|
intval($uid)
|
||||||
);
|
);
|
||||||
notice(sprintf(($user[0]['blocked']?t("User '%s' unblocked"):t("User '%s' blocked")) , $user[0]['username']).EOL);
|
notice(sprintf(($user[0]['blocked']?t("User '%s' unblocked"):t("User '%s' blocked")) , $user[0]['username']).EOL);
|
||||||
}; break;
|
break;
|
||||||
}
|
}
|
||||||
goaway('admin/users');
|
goaway('admin/users');
|
||||||
return ''; // NOTREACHED
|
return ''; // NOTREACHED
|
||||||
|
@ -1322,7 +1311,7 @@ function admin_page_users(App $a) {
|
||||||
|
|
||||||
/* get users */
|
/* get users */
|
||||||
$total = qu("SELECT COUNT(*) AS `total` FROM `user` WHERE 1");
|
$total = qu("SELECT COUNT(*) AS `total` FROM `user` WHERE 1");
|
||||||
if(count($total)) {
|
if (count($total)) {
|
||||||
$a->set_pager_total($total[0]['total']);
|
$a->set_pager_total($total[0]['total']);
|
||||||
$a->set_pager_itemspage(100);
|
$a->set_pager_itemspage(100);
|
||||||
}
|
}
|
||||||
|
@ -1339,22 +1328,22 @@ function admin_page_users(App $a) {
|
||||||
|
|
||||||
$order = "contact.name";
|
$order = "contact.name";
|
||||||
$order_direction = "+";
|
$order_direction = "+";
|
||||||
if (x($_GET,'o')){
|
if (x($_GET,'o')) {
|
||||||
$new_order = $_GET['o'];
|
$new_order = $_GET['o'];
|
||||||
if ($new_order[0]==="-") {
|
if ($new_order[0] === "-") {
|
||||||
$order_direction = "-";
|
$order_direction = "-";
|
||||||
$new_order = substr($new_order,1);
|
$new_order = substr($new_order,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array($new_order, $valid_orders)){
|
if (in_array($new_order, $valid_orders)) {
|
||||||
$order = $new_order;
|
$order = $new_order;
|
||||||
}
|
}
|
||||||
if (x($_GET,'d')){
|
if (x($_GET,'d')) {
|
||||||
$new_direction = $_GET['d'];
|
$new_direction = $_GET['d'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sql_order = "`".str_replace('.','`.`',$order)."`";
|
$sql_order = "`".str_replace('.','`.`',$order)."`";
|
||||||
$sql_order_direction = ($order_direction==="+")?"ASC":"DESC";
|
$sql_order_direction = ($order_direction === "+")?"ASC":"DESC";
|
||||||
|
|
||||||
$users = qu("SELECT `user`.*, `contact`.`name`, `contact`.`url`, `contact`.`micro`, `user`.`account_expired`, `contact`.`last-item` AS `lastitem_date`
|
$users = qu("SELECT `user`.*, `contact`.`name`, `contact`.`url`, `contact`.`micro`, `user`.`account_expired`, `contact`.`last-item` AS `lastitem_date`
|
||||||
FROM `user`
|
FROM `user`
|
||||||
|
@ -1368,7 +1357,7 @@ function admin_page_users(App $a) {
|
||||||
//echo "<pre>$users"; killme();
|
//echo "<pre>$users"; killme();
|
||||||
|
|
||||||
$adminlist = explode(",", str_replace(" ", "", $a->config['admin_email']));
|
$adminlist = explode(",", str_replace(" ", "", $a->config['admin_email']));
|
||||||
$_setup_users = function ($e) use ($adminlist){
|
$_setup_users = function ($e) use ($adminlist) {
|
||||||
$accounts = array(
|
$accounts = array(
|
||||||
t('Normal Account'),
|
t('Normal Account'),
|
||||||
t('Soapbox Account'),
|
t('Soapbox Account'),
|
||||||
|
@ -1394,22 +1383,21 @@ function admin_page_users(App $a) {
|
||||||
$tmp_users = array();
|
$tmp_users = array();
|
||||||
$deleted = array();
|
$deleted = array();
|
||||||
|
|
||||||
while(count($users)) {
|
while (count($users)) {
|
||||||
$new_user = array();
|
$new_user = array();
|
||||||
foreach(array_pop($users) as $k => $v) {
|
foreach (array_pop($users) as $k => $v) {
|
||||||
$k = str_replace('-','_',$k);
|
$k = str_replace('-','_',$k);
|
||||||
$new_user[$k] = $v;
|
$new_user[$k] = $v;
|
||||||
}
|
}
|
||||||
if($new_user['deleted']) {
|
if ($new_user['deleted']) {
|
||||||
array_push($deleted, $new_user);
|
array_push($deleted, $new_user);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
array_push($tmp_users, $new_user);
|
array_push($tmp_users, $new_user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Reversing the two array, and moving $tmp_users to $users
|
//Reversing the two array, and moving $tmp_users to $users
|
||||||
array_reverse($deleted);
|
array_reverse($deleted);
|
||||||
while(count($tmp_users)) {
|
while (count($tmp_users)) {
|
||||||
array_push($users, array_pop($tmp_users));
|
array_push($users, array_pop($tmp_users));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1486,19 +1474,19 @@ function admin_page_plugins(App $a) {
|
||||||
/*
|
/*
|
||||||
* Single plugin
|
* Single plugin
|
||||||
*/
|
*/
|
||||||
if($a->argc == 3) {
|
if ($a->argc == 3) {
|
||||||
$plugin = $a->argv[2];
|
$plugin = $a->argv[2];
|
||||||
if(!is_file("addon/$plugin/$plugin.php")) {
|
if (!is_file("addon/$plugin/$plugin.php")) {
|
||||||
notice(t("Item not found."));
|
notice(t("Item not found."));
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(x($_GET,"a") && $_GET['a']=="t") {
|
if (x($_GET,"a") && $_GET['a']=="t") {
|
||||||
check_form_security_token_redirectOnErr('/admin/plugins', 'admin_themes', 't');
|
check_form_security_token_redirectOnErr('/admin/plugins', 'admin_themes', 't');
|
||||||
|
|
||||||
// Toggle plugin status
|
// Toggle plugin status
|
||||||
$idx = array_search($plugin, $a->plugins);
|
$idx = array_search($plugin, $a->plugins);
|
||||||
if($idx !== false) {
|
if ($idx !== false) {
|
||||||
unset($a->plugins[$idx]);
|
unset($a->plugins[$idx]);
|
||||||
uninstall_plugin($plugin);
|
uninstall_plugin($plugin);
|
||||||
info(sprintf(t("Plugin %s disabled."), $plugin));
|
info(sprintf(t("Plugin %s disabled."), $plugin));
|
||||||
|
@ -1515,22 +1503,22 @@ function admin_page_plugins(App $a) {
|
||||||
// display plugin details
|
// display plugin details
|
||||||
require_once('library/markdown.php');
|
require_once('library/markdown.php');
|
||||||
|
|
||||||
if(in_array($plugin, $a->plugins)) {
|
if (in_array($plugin, $a->plugins)) {
|
||||||
$status="on"; $action= t("Disable");
|
$status="on"; $action= t("Disable");
|
||||||
} else {
|
} else {
|
||||||
$status="off"; $action= t("Enable");
|
$status="off"; $action= t("Enable");
|
||||||
}
|
}
|
||||||
|
|
||||||
$readme=Null;
|
$readme=Null;
|
||||||
if(is_file("addon/$plugin/README.md")) {
|
if (is_file("addon/$plugin/README.md")) {
|
||||||
$readme = file_get_contents("addon/$plugin/README.md");
|
$readme = file_get_contents("addon/$plugin/README.md");
|
||||||
$readme = Markdown($readme);
|
$readme = Markdown($readme);
|
||||||
} elseif(is_file("addon/$plugin/README")) {
|
} elseif (is_file("addon/$plugin/README")) {
|
||||||
$readme = "<pre>". file_get_contents("addon/$plugin/README") ."</pre>";
|
$readme = "<pre>". file_get_contents("addon/$plugin/README") ."</pre>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$admin_form="";
|
$admin_form="";
|
||||||
if(is_array($a->plugins_admin) && in_array($plugin, $a->plugins_admin)) {
|
if (is_array($a->plugins_admin) && in_array($plugin, $a->plugins_admin)) {
|
||||||
@require_once("addon/$plugin/$plugin.php");
|
@require_once("addon/$plugin/$plugin.php");
|
||||||
$func = $plugin.'_plugin_admin';
|
$func = $plugin.'_plugin_admin';
|
||||||
$func($a, $admin_form);
|
$func($a, $admin_form);
|
||||||
|
@ -1622,8 +1610,8 @@ function admin_page_plugins(App $a) {
|
||||||
*/
|
*/
|
||||||
function toggle_theme(&$themes,$th,&$result) {
|
function toggle_theme(&$themes,$th,&$result) {
|
||||||
for($x = 0; $x < count($themes); $x ++) {
|
for($x = 0; $x < count($themes); $x ++) {
|
||||||
if($themes[$x]['name'] === $th) {
|
if ($themes[$x]['name'] === $th) {
|
||||||
if($themes[$x]['allowed']) {
|
if ($themes[$x]['allowed']) {
|
||||||
$themes[$x]['allowed'] = 0;
|
$themes[$x]['allowed'] = 0;
|
||||||
$result = 0;
|
$result = 0;
|
||||||
}
|
}
|
||||||
|
@ -1642,8 +1630,8 @@ function toggle_theme(&$themes,$th,&$result) {
|
||||||
*/
|
*/
|
||||||
function theme_status($themes,$th) {
|
function theme_status($themes,$th) {
|
||||||
for($x = 0; $x < count($themes); $x ++) {
|
for($x = 0; $x < count($themes); $x ++) {
|
||||||
if($themes[$x]['name'] === $th) {
|
if ($themes[$x]['name'] === $th) {
|
||||||
if($themes[$x]['allowed']) {
|
if ($themes[$x]['allowed']) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1661,11 +1649,12 @@ function theme_status($themes,$th) {
|
||||||
*/
|
*/
|
||||||
function rebuild_theme_table($themes) {
|
function rebuild_theme_table($themes) {
|
||||||
$o = '';
|
$o = '';
|
||||||
if(count($themes)) {
|
if (count($themes)) {
|
||||||
foreach($themes as $th) {
|
foreach ($themes as $th) {
|
||||||
if($th['allowed']) {
|
if ($th['allowed']) {
|
||||||
if(strlen($o))
|
if (strlen($o)) {
|
||||||
$o .= ',';
|
$o .= ',';
|
||||||
|
}
|
||||||
$o .= $th['name'];
|
$o .= $th['name'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1695,15 +1684,18 @@ function admin_page_themes(App $a) {
|
||||||
$allowed_themes_str = get_config('system','allowed_themes');
|
$allowed_themes_str = get_config('system','allowed_themes');
|
||||||
$allowed_themes_raw = explode(',',$allowed_themes_str);
|
$allowed_themes_raw = explode(',',$allowed_themes_str);
|
||||||
$allowed_themes = array();
|
$allowed_themes = array();
|
||||||
if(count($allowed_themes_raw))
|
if (count($allowed_themes_raw)) {
|
||||||
foreach($allowed_themes_raw as $x)
|
foreach ($allowed_themes_raw as $x) {
|
||||||
if(strlen(trim($x)))
|
if (strlen(trim($x))) {
|
||||||
$allowed_themes[] = trim($x);
|
$allowed_themes[] = trim($x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$themes = array();
|
$themes = array();
|
||||||
$files = glob('view/theme/*');
|
$files = glob('view/theme/*');
|
||||||
if($files) {
|
if ($files) {
|
||||||
foreach($files as $file) {
|
foreach ($files as $file) {
|
||||||
$f = basename($file);
|
$f = basename($file);
|
||||||
|
|
||||||
// Is there a style file?
|
// Is there a style file?
|
||||||
|
@ -1718,12 +1710,13 @@ function admin_page_themes(App $a) {
|
||||||
$is_supported = 1-(intval(file_exists($file.'/unsupported')));
|
$is_supported = 1-(intval(file_exists($file.'/unsupported')));
|
||||||
$is_allowed = intval(in_array($f,$allowed_themes));
|
$is_allowed = intval(in_array($f,$allowed_themes));
|
||||||
|
|
||||||
if($is_allowed OR $is_supported OR get_config("system", "show_unsupported_themes"))
|
if ($is_allowed OR $is_supported OR get_config("system", "show_unsupported_themes")) {
|
||||||
$themes[] = array('name' => $f, 'experimental' => $is_experimental, 'supported' => $is_supported, 'allowed' => $is_allowed);
|
$themes[] = array('name' => $f, 'experimental' => $is_experimental, 'supported' => $is_supported, 'allowed' => $is_allowed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! count($themes)) {
|
if (! count($themes)) {
|
||||||
notice(t('No themes found.'));
|
notice(t('No themes found.'));
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -1732,25 +1725,24 @@ function admin_page_themes(App $a) {
|
||||||
* Single theme
|
* Single theme
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if($a->argc == 3) {
|
if ($a->argc == 3) {
|
||||||
$theme = $a->argv[2];
|
$theme = $a->argv[2];
|
||||||
if(! is_dir("view/theme/$theme")) {
|
if (! is_dir("view/theme/$theme")) {
|
||||||
notice(t("Item not found."));
|
notice(t("Item not found."));
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(x($_GET,"a") && $_GET['a']=="t") {
|
if (x($_GET,"a") && $_GET['a']=="t") {
|
||||||
check_form_security_token_redirectOnErr('/admin/themes', 'admin_themes', 't');
|
check_form_security_token_redirectOnErr('/admin/themes', 'admin_themes', 't');
|
||||||
|
|
||||||
// Toggle theme status
|
// Toggle theme status
|
||||||
|
|
||||||
toggle_theme($themes,$theme,$result);
|
toggle_theme($themes,$theme,$result);
|
||||||
$s = rebuild_theme_table($themes);
|
$s = rebuild_theme_table($themes);
|
||||||
if($result) {
|
if ($result) {
|
||||||
install_theme($theme);
|
install_theme($theme);
|
||||||
info(sprintf('Theme %s enabled.',$theme));
|
info(sprintf('Theme %s enabled.',$theme));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
uninstall_theme($theme);
|
uninstall_theme($theme);
|
||||||
info(sprintf('Theme %s disabled.',$theme));
|
info(sprintf('Theme %s disabled.',$theme));
|
||||||
}
|
}
|
||||||
|
@ -1763,22 +1755,22 @@ function admin_page_themes(App $a) {
|
||||||
// display theme details
|
// display theme details
|
||||||
require_once('library/markdown.php');
|
require_once('library/markdown.php');
|
||||||
|
|
||||||
if(theme_status($themes,$theme)) {
|
if (theme_status($themes,$theme)) {
|
||||||
$status="on"; $action= t("Disable");
|
$status="on"; $action= t("Disable");
|
||||||
} else {
|
} else {
|
||||||
$status="off"; $action= t("Enable");
|
$status="off"; $action= t("Enable");
|
||||||
}
|
}
|
||||||
|
|
||||||
$readme=Null;
|
$readme = Null;
|
||||||
if(is_file("view/theme/$theme/README.md")) {
|
if (is_file("view/theme/$theme/README.md")) {
|
||||||
$readme = file_get_contents("view/theme/$theme/README.md");
|
$readme = file_get_contents("view/theme/$theme/README.md");
|
||||||
$readme = Markdown($readme);
|
$readme = Markdown($readme);
|
||||||
} elseif(is_file("view/theme/$theme/README")) {
|
} elseif (is_file("view/theme/$theme/README")) {
|
||||||
$readme = "<pre>". file_get_contents("view/theme/$theme/README") ."</pre>";
|
$readme = "<pre>". file_get_contents("view/theme/$theme/README") ."</pre>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$admin_form="";
|
$admin_form = "";
|
||||||
if(is_file("view/theme/$theme/config.php")) {
|
if (is_file("view/theme/$theme/config.php")) {
|
||||||
function __get_theme_admin_form(App $a, $theme) {
|
function __get_theme_admin_form(App $a, $theme) {
|
||||||
$orig_theme = $a->theme;
|
$orig_theme = $a->theme;
|
||||||
$orig_page = $a->page;
|
$orig_page = $a->page;
|
||||||
|
@ -1789,8 +1781,10 @@ function admin_page_themes(App $a) {
|
||||||
|
|
||||||
|
|
||||||
$init = $theme."_init";
|
$init = $theme."_init";
|
||||||
if(function_exists($init)) $init($a);
|
if (function_exists($init)) {
|
||||||
if(function_exists("theme_admin")) {
|
$init($a);
|
||||||
|
}
|
||||||
|
if (function_exists("theme_admin")) {
|
||||||
$admin_form = theme_admin($a);
|
$admin_form = theme_admin($a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1803,9 +1797,9 @@ function admin_page_themes(App $a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$screenshot = array(get_theme_screenshot($theme), t('Screenshot'));
|
$screenshot = array(get_theme_screenshot($theme), t('Screenshot'));
|
||||||
if(! stristr($screenshot[0],$theme))
|
if (! stristr($screenshot[0],$theme)) {
|
||||||
$screenshot = null;
|
$screenshot = null;
|
||||||
|
}
|
||||||
|
|
||||||
$t = get_markup_template("admin_plugins_details.tpl");
|
$t = get_markup_template("admin_plugins_details.tpl");
|
||||||
return replace_macros($t, array(
|
return replace_macros($t, array(
|
||||||
|
@ -1851,7 +1845,7 @@ function admin_page_themes(App $a) {
|
||||||
|
|
||||||
$xthemes = array();
|
$xthemes = array();
|
||||||
if ($themes) {
|
if ($themes) {
|
||||||
foreach($themes as $th) {
|
foreach ($themes as $th) {
|
||||||
$xthemes[] = array($th['name'],(($th['allowed']) ? "on" : "off"), get_theme_info($th['name']));
|
$xthemes[] = array($th['name'],(($th['allowed']) ? "on" : "off"), get_theme_info($th['name']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1976,25 +1970,25 @@ function admin_page_viewlogs(App $a) {
|
||||||
$f = get_config('system','logfile');
|
$f = get_config('system','logfile');
|
||||||
$data = '';
|
$data = '';
|
||||||
|
|
||||||
if(!file_exists($f)) {
|
if (!file_exists($f)) {
|
||||||
$data = t("Error trying to open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f exist and is readable.");
|
$data = t("Error trying to open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f exist and is readable.");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$fp = fopen($f, 'r');
|
$fp = fopen($f, 'r');
|
||||||
if(!$fp) {
|
if (!$fp) {
|
||||||
$data = t("Couldn't open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f is readable.");
|
$data = t("Couldn't open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f is readable.");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$fstat = fstat($fp);
|
$fstat = fstat($fp);
|
||||||
$size = $fstat['size'];
|
$size = $fstat['size'];
|
||||||
if($size != 0) {
|
if ($size != 0) {
|
||||||
if($size > 5000000 || $size < 0)
|
if ($size > 5000000 || $size < 0) {
|
||||||
$size = 5000000;
|
$size = 5000000;
|
||||||
|
}
|
||||||
$seek = fseek($fp,0-$size,SEEK_END);
|
$seek = fseek($fp,0-$size,SEEK_END);
|
||||||
if($seek === 0) {
|
if ($seek === 0) {
|
||||||
$data = escape_tags(fread($fp,$size));
|
$data = escape_tags(fread($fp,$size));
|
||||||
while(! feof($fp))
|
while (! feof($fp)) {
|
||||||
$data .= escape_tags(fread($fp,4096));
|
$data .= escape_tags(fread($fp,4096));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
|
@ -2022,22 +2016,24 @@ function admin_page_features_post(App $a) {
|
||||||
$arr = array();
|
$arr = array();
|
||||||
$features = get_features(false);
|
$features = get_features(false);
|
||||||
|
|
||||||
foreach($features as $fname => $fdata) {
|
foreach ($features as $fname => $fdata) {
|
||||||
foreach(array_slice($fdata,1) as $f) {
|
foreach (array_slice($fdata,1) as $f) {
|
||||||
$feature = $f[0];
|
$feature = $f[0];
|
||||||
$feature_state = 'feature_'.$feature;
|
$feature_state = 'feature_'.$feature;
|
||||||
$featurelock = 'featurelock_'.$feature;
|
$featurelock = 'featurelock_'.$feature;
|
||||||
|
|
||||||
if(x($_POST[$feature_state]))
|
if (x($_POST[$feature_state])) {
|
||||||
$val = intval($_POST['feature_'.$feature]);
|
$val = intval($_POST['feature_'.$feature]);
|
||||||
else
|
} else {
|
||||||
$val = 0;
|
$val = 0;
|
||||||
|
}
|
||||||
set_config('feature',$feature,$val);
|
set_config('feature',$feature,$val);
|
||||||
|
|
||||||
if(x($_POST[$featurelock]))
|
if (x($_POST[$featurelock])) {
|
||||||
set_config('feature_lock',$feature,$val);
|
set_config('feature_lock',$feature,$val);
|
||||||
else
|
} else {
|
||||||
del_config('feature_lock',$feature);
|
del_config('feature_lock',$feature);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2061,18 +2057,19 @@ function admin_page_features_post(App $a) {
|
||||||
*/
|
*/
|
||||||
function admin_page_features(App $a) {
|
function admin_page_features(App $a) {
|
||||||
|
|
||||||
if((argc() > 1) && (argv(1) === 'features')) {
|
if ((argc() > 1) && (argv(1) === 'features')) {
|
||||||
$arr = array();
|
$arr = array();
|
||||||
$features = get_features(false);
|
$features = get_features(false);
|
||||||
|
|
||||||
foreach($features as $fname => $fdata) {
|
foreach ($features as $fname => $fdata) {
|
||||||
$arr[$fname] = array();
|
$arr[$fname] = array();
|
||||||
$arr[$fname][0] = $fdata[0];
|
$arr[$fname][0] = $fdata[0];
|
||||||
foreach(array_slice($fdata,1) as $f) {
|
foreach (array_slice($fdata,1) as $f) {
|
||||||
|
|
||||||
$set = get_config('feature',$f[0]);
|
$set = get_config('feature',$f[0]);
|
||||||
if($set === false)
|
if ($set === false) {
|
||||||
$set = $f[3];
|
$set = $f[3];
|
||||||
|
}
|
||||||
$arr[$fname][1][] = array(
|
$arr[$fname][1][] = array(
|
||||||
array('feature_' .$f[0],$f[1],$set,$f[2],array(t('Off'),t('On'))),
|
array('feature_' .$f[0],$f[1],$set,$f[2],array(t('Off'),t('On'))),
|
||||||
array('featurelock_' .$f[0],sprintf(t('Lock feature %s'),$f[1]),(($f[4] !== false) ? "1" : ''),'',array(t('Off'),t('On')))
|
array('featurelock_' .$f[0],sprintf(t('Lock feature %s'),$f[1]),(($f[4] !== false) ? "1" : ''),'',array(t('Off'),t('On')))
|
||||||
|
|
|
@ -48,27 +48,6 @@ function community_content(App $a, $update = 0) {
|
||||||
// Only public posts can be shown
|
// Only public posts can be shown
|
||||||
// OR your own posts if you are a logged in member
|
// OR your own posts if you are a logged in member
|
||||||
|
|
||||||
if(get_config('system', 'old_pager')) {
|
|
||||||
$r = qu("SELECT COUNT(distinct(`item`.`uri`)) AS `total`
|
|
||||||
FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
|
||||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
|
||||||
INNER JOIN `user` ON `user`.`uid` = `item`.`uid` AND `user`.`hidewall` = 0
|
|
||||||
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
|
|
||||||
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
|
|
||||||
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
|
|
||||||
AND `item`.`private` = 0 AND `item`.`wall` = 1"
|
|
||||||
);
|
|
||||||
|
|
||||||
if (dbm::is_result($r))
|
|
||||||
$a->set_pager_total($r[0]['total']);
|
|
||||||
|
|
||||||
if(! $r[0]['total']) {
|
|
||||||
info( t('No results.') . EOL);
|
|
||||||
return $o;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$r = community_getitems($a->pager['start'], $a->pager['itemspage']);
|
$r = community_getitems($a->pager['start'], $a->pager['itemspage']);
|
||||||
|
|
||||||
if (! dbm::is_result($r)) {
|
if (! dbm::is_result($r)) {
|
||||||
|
@ -105,13 +84,9 @@ function community_content(App $a, $update = 0) {
|
||||||
|
|
||||||
// we behave the same in message lists as the search module
|
// we behave the same in message lists as the search module
|
||||||
|
|
||||||
$o .= conversation($a,$s,'community',$update);
|
$o .= conversation($a, $s, 'community', $update);
|
||||||
|
|
||||||
if(!get_config('system', 'old_pager')) {
|
$o .= alt_pager($a, count($r));
|
||||||
$o .= alt_pager($a,count($r));
|
|
||||||
} else {
|
|
||||||
$o .= paginate($a);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
|
@ -599,21 +599,6 @@ function network_content(App $a, $update = 0) {
|
||||||
$pager_sql = '';
|
$pager_sql = '';
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if(get_config('system', 'old_pager')) {
|
|
||||||
$r = qu("SELECT COUNT(*) AS `total`
|
|
||||||
FROM $sql_table $sql_post_table INNER JOIN `contact` ON `contact`.`id` = $sql_table.`contact-id`
|
|
||||||
AND (NOT `contact`.`blocked` OR `contact`.`pending`)
|
|
||||||
WHERE $sql_table.`uid` = %d AND $sql_table.`visible` AND NOT $sql_table.`deleted`
|
|
||||||
$sql_extra2 $sql_extra3
|
|
||||||
$sql_extra $sql_nets ",
|
|
||||||
intval($_SESSION['uid'])
|
|
||||||
);
|
|
||||||
|
|
||||||
if (dbm::is_result($r)) {
|
|
||||||
$a->set_pager_total($r[0]['total']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if we serve a mobile device and get the user settings
|
// check if we serve a mobile device and get the user settings
|
||||||
// accordingly
|
// accordingly
|
||||||
if ($a->is_mobile) {
|
if ($a->is_mobile) {
|
||||||
|
@ -788,15 +773,13 @@ function network_content(App $a, $update = 0) {
|
||||||
|
|
||||||
$mode = (($nouveau) ? 'network-new' : 'network');
|
$mode = (($nouveau) ? 'network-new' : 'network');
|
||||||
|
|
||||||
$o .= conversation($a,$items,$mode,$update);
|
$o .= conversation($a, $items, $mode, $update);
|
||||||
|
|
||||||
if (!$update) {
|
if (!$update) {
|
||||||
if (get_pconfig(local_user(),'system','infinite_scroll')) {
|
if (get_pconfig(local_user(), 'system', 'infinite_scroll')) {
|
||||||
$o .= scroll_loader();
|
$o .= scroll_loader();
|
||||||
} elseif (!get_config('system', 'old_pager')) {
|
|
||||||
$o .= alt_pager($a,count($items));
|
|
||||||
} else {
|
} else {
|
||||||
$o .= paginate($a);
|
$o .= alt_pager($a, count($items));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ function openid_content(App $a) {
|
||||||
// mod/settings.php in 8367cad so it might have left mixed
|
// mod/settings.php in 8367cad so it might have left mixed
|
||||||
// records in the user table
|
// records in the user table
|
||||||
//
|
//
|
||||||
$r = q("SELECT * FROM `user`
|
$r = q("SELECT *, `user`.`pubkey` as `upubkey`, `user`.`prvkey` as `uprvkey` FROM `user`
|
||||||
WHERE ( `openid` = '%s' OR `openid` = '%s' )
|
WHERE ( `openid` = '%s' OR `openid` = '%s' )
|
||||||
AND `blocked` = 0 AND `account_expired` = 0
|
AND `blocked` = 0 AND `account_expired` = 0
|
||||||
AND `account_removed` = 0 AND `verified` = 1
|
AND `account_removed` = 0 AND `verified` = 1
|
||||||
|
|
232
mod/poco.php
232
mod/poco.php
|
@ -7,14 +7,14 @@ function poco_init(App $a) {
|
||||||
|
|
||||||
$system_mode = false;
|
$system_mode = false;
|
||||||
|
|
||||||
if(intval(get_config('system','block_public')) || (get_config('system','block_local_dir')))
|
if (intval(get_config('system','block_public')) || (get_config('system','block_local_dir'))) {
|
||||||
http_status_exit(401);
|
http_status_exit(401);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($a->argc > 1) {
|
||||||
if($a->argc > 1) {
|
|
||||||
$user = notags(trim($a->argv[1]));
|
$user = notags(trim($a->argv[1]));
|
||||||
}
|
}
|
||||||
if(! x($user)) {
|
if (! x($user)) {
|
||||||
$c = q("SELECT * FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1");
|
$c = q("SELECT * FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1");
|
||||||
if (! dbm::is_result($c)) {
|
if (! dbm::is_result($c)) {
|
||||||
http_status_exit(401);
|
http_status_exit(401);
|
||||||
|
@ -27,42 +27,55 @@ function poco_init(App $a) {
|
||||||
$justme = false;
|
$justme = false;
|
||||||
$global = false;
|
$global = false;
|
||||||
|
|
||||||
if($a->argc > 1 && $a->argv[1] === '@global') {
|
if ($a->argc > 1 && $a->argv[1] === '@server') {
|
||||||
|
// List of all servers that this server knows
|
||||||
|
$ret = poco_serverlist();
|
||||||
|
header('Content-type: application/json');
|
||||||
|
echo json_encode($ret);
|
||||||
|
killme();
|
||||||
|
}
|
||||||
|
if ($a->argc > 1 && $a->argv[1] === '@global') {
|
||||||
|
// List of all profiles that this server recently had data from
|
||||||
$global = true;
|
$global = true;
|
||||||
$update_limit = date("Y-m-d H:i:s", time() - 30 * 86400);
|
$update_limit = date("Y-m-d H:i:s", time() - 30 * 86400);
|
||||||
}
|
}
|
||||||
if($a->argc > 2 && $a->argv[2] === '@me')
|
if ($a->argc > 2 && $a->argv[2] === '@me') {
|
||||||
$justme = true;
|
$justme = true;
|
||||||
if($a->argc > 3 && $a->argv[3] === '@all')
|
}
|
||||||
|
if ($a->argc > 3 && $a->argv[3] === '@all') {
|
||||||
$justme = false;
|
$justme = false;
|
||||||
if($a->argc > 3 && $a->argv[3] === '@self')
|
}
|
||||||
|
if ($a->argc > 3 && $a->argv[3] === '@self') {
|
||||||
$justme = true;
|
$justme = true;
|
||||||
if($a->argc > 4 && intval($a->argv[4]) && $justme == false)
|
}
|
||||||
|
if ($a->argc > 4 && intval($a->argv[4]) && $justme == false) {
|
||||||
$cid = intval($a->argv[4]);
|
$cid = intval($a->argv[4]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$system_mode AND !$global) {
|
||||||
if(!$system_mode AND !$global) {
|
|
||||||
$r = q("SELECT `user`.*,`profile`.`hide-friends` from user left join profile on `user`.`uid` = `profile`.`uid`
|
$r = q("SELECT `user`.*,`profile`.`hide-friends` from user left join profile on `user`.`uid` = `profile`.`uid`
|
||||||
where `user`.`nickname` = '%s' and `profile`.`is-default` = 1 limit 1",
|
where `user`.`nickname` = '%s' and `profile`.`is-default` = 1 limit 1",
|
||||||
dbesc($user)
|
dbesc($user)
|
||||||
);
|
);
|
||||||
if(! dbm::is_result($r) || $r[0]['hidewall'] || $r[0]['hide-friends'])
|
if (! dbm::is_result($r) || $r[0]['hidewall'] || $r[0]['hide-friends']) {
|
||||||
http_status_exit(404);
|
http_status_exit(404);
|
||||||
|
}
|
||||||
|
|
||||||
$user = $r[0];
|
$user = $r[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($justme)
|
if ($justme) {
|
||||||
$sql_extra = " AND `contact`.`self` = 1 ";
|
$sql_extra = " AND `contact`.`self` = 1 ";
|
||||||
|
}
|
||||||
// else
|
// else
|
||||||
// $sql_extra = " AND `contact`.`self` = 0 ";
|
// $sql_extra = " AND `contact`.`self` = 0 ";
|
||||||
|
|
||||||
if($cid)
|
if ($cid) {
|
||||||
$sql_extra = sprintf(" AND `contact`.`id` = %d ",intval($cid));
|
$sql_extra = sprintf(" AND `contact`.`id` = %d ",intval($cid));
|
||||||
|
}
|
||||||
if(x($_GET,'updatedSince'))
|
if (x($_GET,'updatedSince')) {
|
||||||
$update_limit = date("Y-m-d H:i:s",strtotime($_GET['updatedSince']));
|
$update_limit = date("Y-m-d H:i:s",strtotime($_GET['updatedSince']));
|
||||||
|
}
|
||||||
if ($global) {
|
if ($global) {
|
||||||
$r = q("SELECT count(*) AS `total` FROM `gcontact` WHERE `updated` >= '%s' AND `updated` >= `last_failure` AND NOT `hide` AND `network` IN ('%s', '%s', '%s')",
|
$r = q("SELECT count(*) AS `total` FROM `gcontact` WHERE `updated` >= '%s' AND `updated` >= `last_failure` AND NOT `hide` AND `network` IN ('%s', '%s', '%s')",
|
||||||
dbesc($update_limit),
|
dbesc($update_limit),
|
||||||
|
@ -70,7 +83,7 @@ function poco_init(App $a) {
|
||||||
dbesc(NETWORK_DIASPORA),
|
dbesc(NETWORK_DIASPORA),
|
||||||
dbesc(NETWORK_OSTATUS)
|
dbesc(NETWORK_OSTATUS)
|
||||||
);
|
);
|
||||||
} elseif($system_mode) {
|
} elseif ($system_mode) {
|
||||||
$r = q("SELECT count(*) AS `total` FROM `contact` WHERE `self` = 1
|
$r = q("SELECT count(*) AS `total` FROM `contact` WHERE `self` = 1
|
||||||
AND `uid` IN (SELECT `uid` FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1) ");
|
AND `uid` IN (SELECT `uid` FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1) ");
|
||||||
} else {
|
} else {
|
||||||
|
@ -84,14 +97,15 @@ function poco_init(App $a) {
|
||||||
dbesc(NETWORK_STATUSNET)
|
dbesc(NETWORK_STATUSNET)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (dbm::is_result($r))
|
if (dbm::is_result($r)) {
|
||||||
$totalResults = intval($r[0]['total']);
|
$totalResults = intval($r[0]['total']);
|
||||||
else
|
} else {
|
||||||
$totalResults = 0;
|
$totalResults = 0;
|
||||||
|
}
|
||||||
$startIndex = intval($_GET['startIndex']);
|
$startIndex = intval($_GET['startIndex']);
|
||||||
if(! $startIndex)
|
if (! $startIndex) {
|
||||||
$startIndex = 0;
|
$startIndex = 0;
|
||||||
|
}
|
||||||
$itemsPerPage = ((x($_GET,'count') && intval($_GET['count'])) ? intval($_GET['count']) : $totalResults);
|
$itemsPerPage = ((x($_GET,'count') && intval($_GET['count'])) ? intval($_GET['count']) : $totalResults);
|
||||||
|
|
||||||
if ($global) {
|
if ($global) {
|
||||||
|
@ -105,7 +119,7 @@ function poco_init(App $a) {
|
||||||
intval($startIndex),
|
intval($startIndex),
|
||||||
intval($itemsPerPage)
|
intval($itemsPerPage)
|
||||||
);
|
);
|
||||||
} elseif($system_mode) {
|
} elseif ($system_mode) {
|
||||||
logger("Start system mode query", LOGGER_DEBUG);
|
logger("Start system mode query", LOGGER_DEBUG);
|
||||||
$r = q("SELECT `contact`.*, `profile`.`about` AS `pabout`, `profile`.`locality` AS `plocation`, `profile`.`pub_keywords`,
|
$r = q("SELECT `contact`.*, `profile`.`about` AS `pabout`, `profile`.`locality` AS `plocation`, `profile`.`pub_keywords`,
|
||||||
`profile`.`gender` AS `pgender`, `profile`.`address` AS `paddress`, `profile`.`region` AS `pregion`,
|
`profile`.`gender` AS `pgender`, `profile`.`address` AS `paddress`, `profile`.`region` AS `pregion`,
|
||||||
|
@ -134,13 +148,15 @@ function poco_init(App $a) {
|
||||||
logger("Query done", LOGGER_DEBUG);
|
logger("Query done", LOGGER_DEBUG);
|
||||||
|
|
||||||
$ret = array();
|
$ret = array();
|
||||||
if(x($_GET,'sorted'))
|
if (x($_GET,'sorted')) {
|
||||||
$ret['sorted'] = false;
|
$ret['sorted'] = false;
|
||||||
if(x($_GET,'filtered'))
|
}
|
||||||
|
if (x($_GET,'filtered')) {
|
||||||
$ret['filtered'] = false;
|
$ret['filtered'] = false;
|
||||||
if(x($_GET,'updatedSince') AND !$global)
|
}
|
||||||
|
if (x($_GET,'updatedSince') AND !$global) {
|
||||||
$ret['updatedSince'] = false;
|
$ret['updatedSince'] = false;
|
||||||
|
}
|
||||||
$ret['startIndex'] = (int) $startIndex;
|
$ret['startIndex'] = (int) $startIndex;
|
||||||
$ret['itemsPerPage'] = (int) $itemsPerPage;
|
$ret['itemsPerPage'] = (int) $itemsPerPage;
|
||||||
$ret['totalResults'] = (int) $totalResults;
|
$ret['totalResults'] = (int) $totalResults;
|
||||||
|
@ -164,58 +180,61 @@ function poco_init(App $a) {
|
||||||
'generation' => false
|
'generation' => false
|
||||||
);
|
);
|
||||||
|
|
||||||
if((! x($_GET,'fields')) || ($_GET['fields'] === '@all'))
|
if ((! x($_GET,'fields')) || ($_GET['fields'] === '@all')) {
|
||||||
foreach($fields_ret as $k => $v)
|
foreach ($fields_ret as $k => $v) {
|
||||||
$fields_ret[$k] = true;
|
$fields_ret[$k] = true;
|
||||||
else {
|
}
|
||||||
|
} else {
|
||||||
$fields_req = explode(',',$_GET['fields']);
|
$fields_req = explode(',',$_GET['fields']);
|
||||||
foreach($fields_req as $f)
|
foreach ($fields_req as $f) {
|
||||||
$fields_ret[trim($f)] = true;
|
$fields_ret[trim($f)] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_array($r)) {
|
if (is_array($r)) {
|
||||||
if (dbm::is_result($r)) {
|
if (dbm::is_result($r)) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
if (!isset($rr['generation'])) {
|
if (!isset($rr['generation'])) {
|
||||||
if ($global)
|
if ($global) {
|
||||||
$rr['generation'] = 3;
|
$rr['generation'] = 3;
|
||||||
elseif ($system_mode)
|
} elseif ($system_mode) {
|
||||||
$rr['generation'] = 1;
|
$rr['generation'] = 1;
|
||||||
else
|
} else {
|
||||||
$rr['generation'] = 2;
|
$rr['generation'] = 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($rr['about'] == "") AND isset($rr['pabout']))
|
if (($rr['about'] == "") AND isset($rr['pabout'])) {
|
||||||
$rr['about'] = $rr['pabout'];
|
$rr['about'] = $rr['pabout'];
|
||||||
|
}
|
||||||
if ($rr['location'] == "") {
|
if ($rr['location'] == "") {
|
||||||
if (isset($rr['plocation']))
|
if (isset($rr['plocation'])) {
|
||||||
$rr['location'] = $rr['plocation'];
|
$rr['location'] = $rr['plocation'];
|
||||||
|
}
|
||||||
if (isset($rr['pregion']) AND ($rr['pregion'] != "")) {
|
if (isset($rr['pregion']) AND ($rr['pregion'] != "")) {
|
||||||
if ($rr['location'] != "")
|
if ($rr['location'] != "") {
|
||||||
$rr['location'] .= ", ";
|
$rr['location'] .= ", ";
|
||||||
|
}
|
||||||
$rr['location'] .= $rr['pregion'];
|
$rr['location'] .= $rr['pregion'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($rr['pcountry']) AND ($rr['pcountry'] != "")) {
|
if (isset($rr['pcountry']) AND ($rr['pcountry'] != "")) {
|
||||||
if ($rr['location'] != "")
|
if ($rr['location'] != "") {
|
||||||
$rr['location'] .= ", ";
|
$rr['location'] .= ", ";
|
||||||
|
}
|
||||||
$rr['location'] .= $rr['pcountry'];
|
$rr['location'] .= $rr['pcountry'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($rr['gender'] == "") AND isset($rr['pgender']))
|
if (($rr['gender'] == "") AND isset($rr['pgender'])) {
|
||||||
$rr['gender'] = $rr['pgender'];
|
$rr['gender'] = $rr['pgender'];
|
||||||
|
}
|
||||||
if (($rr['keywords'] == "") AND isset($rr['pub_keywords']))
|
if (($rr['keywords'] == "") AND isset($rr['pub_keywords'])) {
|
||||||
$rr['keywords'] = $rr['pub_keywords'];
|
$rr['keywords'] = $rr['pub_keywords'];
|
||||||
|
}
|
||||||
if (isset($rr['account-type']))
|
if (isset($rr['account-type'])) {
|
||||||
$rr['contact-type'] = $rr['account-type'];
|
$rr['contact-type'] = $rr['account-type'];
|
||||||
|
}
|
||||||
$about = Cache::get("about:".$rr['updated'].":".$rr['nurl']);
|
$about = Cache::get("about:".$rr['updated'].":".$rr['nurl']);
|
||||||
if (is_null($about)) {
|
if (is_null($about)) {
|
||||||
$about = bbcode($rr['about'], false, false);
|
$about = bbcode($rr['about'], false, false);
|
||||||
|
@ -230,111 +249,122 @@ function poco_init(App $a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$entry = array();
|
$entry = array();
|
||||||
if($fields_ret['id'])
|
if ($fields_ret['id']) {
|
||||||
$entry['id'] = (int)$rr['id'];
|
$entry['id'] = (int)$rr['id'];
|
||||||
if($fields_ret['displayName'])
|
|
||||||
$entry['displayName'] = $rr['name'];
|
|
||||||
if($fields_ret['aboutMe'])
|
|
||||||
$entry['aboutMe'] = $about;
|
|
||||||
if($fields_ret['currentLocation'])
|
|
||||||
$entry['currentLocation'] = $rr['location'];
|
|
||||||
if($fields_ret['gender'])
|
|
||||||
$entry['gender'] = $rr['gender'];
|
|
||||||
if($fields_ret['generation'])
|
|
||||||
$entry['generation'] = (int)$rr['generation'];
|
|
||||||
if($fields_ret['urls']) {
|
|
||||||
$entry['urls'] = array(array('value' => $rr['url'], 'type' => 'profile'));
|
|
||||||
if($rr['addr'] && ($rr['network'] !== NETWORK_MAIL))
|
|
||||||
$entry['urls'][] = array('value' => 'acct:' . $rr['addr'], 'type' => 'webfinger');
|
|
||||||
}
|
}
|
||||||
if($fields_ret['preferredUsername'])
|
if ($fields_ret['displayName']) {
|
||||||
|
$entry['displayName'] = $rr['name'];
|
||||||
|
}
|
||||||
|
if ($fields_ret['aboutMe']) {
|
||||||
|
$entry['aboutMe'] = $about;
|
||||||
|
}
|
||||||
|
if ($fields_ret['currentLocation']) {
|
||||||
|
$entry['currentLocation'] = $rr['location'];
|
||||||
|
}
|
||||||
|
if ($fields_ret['gender']) {
|
||||||
|
$entry['gender'] = $rr['gender'];
|
||||||
|
}
|
||||||
|
if ($fields_ret['generation']) {
|
||||||
|
$entry['generation'] = (int)$rr['generation'];
|
||||||
|
}
|
||||||
|
if ($fields_ret['urls']) {
|
||||||
|
$entry['urls'] = array(array('value' => $rr['url'], 'type' => 'profile'));
|
||||||
|
if ($rr['addr'] && ($rr['network'] !== NETWORK_MAIL)) {
|
||||||
|
$entry['urls'][] = array('value' => 'acct:' . $rr['addr'], 'type' => 'webfinger');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($fields_ret['preferredUsername']) {
|
||||||
$entry['preferredUsername'] = $rr['nick'];
|
$entry['preferredUsername'] = $rr['nick'];
|
||||||
if($fields_ret['updated']) {
|
}
|
||||||
|
if ($fields_ret['updated']) {
|
||||||
if (!$global) {
|
if (!$global) {
|
||||||
$entry['updated'] = $rr['success_update'];
|
$entry['updated'] = $rr['success_update'];
|
||||||
|
|
||||||
if ($rr['name-date'] > $entry['updated'])
|
if ($rr['name-date'] > $entry['updated']) {
|
||||||
$entry['updated'] = $rr['name-date'];
|
$entry['updated'] = $rr['name-date'];
|
||||||
|
}
|
||||||
if ($rr['uri-date'] > $entry['updated'])
|
if ($rr['uri-date'] > $entry['updated']) {
|
||||||
$entry['updated'] = $rr['uri-date'];
|
$entry['updated'] = $rr['uri-date'];
|
||||||
|
}
|
||||||
if ($rr['avatar-date'] > $entry['updated'])
|
if ($rr['avatar-date'] > $entry['updated']) {
|
||||||
$entry['updated'] = $rr['avatar-date'];
|
$entry['updated'] = $rr['avatar-date'];
|
||||||
} else
|
}
|
||||||
|
} else {
|
||||||
$entry['updated'] = $rr['updated'];
|
$entry['updated'] = $rr['updated'];
|
||||||
|
}
|
||||||
$entry['updated'] = date("c", strtotime($entry['updated']));
|
$entry['updated'] = date("c", strtotime($entry['updated']));
|
||||||
}
|
}
|
||||||
if($fields_ret['photos'])
|
if ($fields_ret['photos']) {
|
||||||
$entry['photos'] = array(array('value' => $rr['photo'], 'type' => 'profile'));
|
$entry['photos'] = array(array('value' => $rr['photo'], 'type' => 'profile'));
|
||||||
if($fields_ret['network']) {
|
|
||||||
$entry['network'] = $rr['network'];
|
|
||||||
if ($entry['network'] == NETWORK_STATUSNET)
|
|
||||||
$entry['network'] = NETWORK_OSTATUS;
|
|
||||||
if (($entry['network'] == "") AND ($rr['self']))
|
|
||||||
$entry['network'] = NETWORK_DFRN;
|
|
||||||
}
|
}
|
||||||
if($fields_ret['tags']) {
|
if ($fields_ret['network']) {
|
||||||
|
$entry['network'] = $rr['network'];
|
||||||
|
if ($entry['network'] == NETWORK_STATUSNET) {
|
||||||
|
$entry['network'] = NETWORK_OSTATUS;
|
||||||
|
}
|
||||||
|
if (($entry['network'] == "") AND ($rr['self'])) {
|
||||||
|
$entry['network'] = NETWORK_DFRN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($fields_ret['tags']) {
|
||||||
$tags = str_replace(","," ",$rr['keywords']);
|
$tags = str_replace(","," ",$rr['keywords']);
|
||||||
$tags = explode(" ", $tags);
|
$tags = explode(" ", $tags);
|
||||||
|
|
||||||
$cleaned = array();
|
$cleaned = array();
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
$tag = trim(strtolower($tag));
|
$tag = trim(strtolower($tag));
|
||||||
if ($tag != "")
|
if ($tag != "") {
|
||||||
$cleaned[] = $tag;
|
$cleaned[] = $tag;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$entry['tags'] = array($cleaned);
|
$entry['tags'] = array($cleaned);
|
||||||
}
|
}
|
||||||
if($fields_ret['address']) {
|
if ($fields_ret['address']) {
|
||||||
$entry['address'] = array();
|
$entry['address'] = array();
|
||||||
|
|
||||||
// Deactivated. It just reveals too much data. (Although its from the default profile)
|
// Deactivated. It just reveals too much data. (Although its from the default profile)
|
||||||
//if (isset($rr['paddress']))
|
//if (isset($rr['paddress']))
|
||||||
// $entry['address']['streetAddress'] = $rr['paddress'];
|
// $entry['address']['streetAddress'] = $rr['paddress'];
|
||||||
|
|
||||||
if (isset($rr['plocation']))
|
if (isset($rr['plocation'])) {
|
||||||
$entry['address']['locality'] = $rr['plocation'];
|
$entry['address']['locality'] = $rr['plocation'];
|
||||||
|
}
|
||||||
if (isset($rr['pregion']))
|
if (isset($rr['pregion'])) {
|
||||||
$entry['address']['region'] = $rr['pregion'];
|
$entry['address']['region'] = $rr['pregion'];
|
||||||
|
}
|
||||||
// See above
|
// See above
|
||||||
//if (isset($rr['ppostalcode']))
|
//if (isset($rr['ppostalcode']))
|
||||||
// $entry['address']['postalCode'] = $rr['ppostalcode'];
|
// $entry['address']['postalCode'] = $rr['ppostalcode'];
|
||||||
|
|
||||||
if (isset($rr['pcountry']))
|
if (isset($rr['pcountry'])) {
|
||||||
$entry['address']['country'] = $rr['pcountry'];
|
$entry['address']['country'] = $rr['pcountry'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($fields_ret['contactType'])
|
if ($fields_ret['contactType']) {
|
||||||
$entry['contactType'] = intval($rr['contact-type']);
|
$entry['contactType'] = intval($rr['contact-type']);
|
||||||
|
}
|
||||||
$ret['entry'][] = $entry;
|
$ret['entry'][] = $entry;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
$ret['entry'][] = array();
|
$ret['entry'][] = array();
|
||||||
}
|
}
|
||||||
else
|
} else {
|
||||||
http_status_exit(500);
|
http_status_exit(500);
|
||||||
|
}
|
||||||
logger("End of poco", LOGGER_DEBUG);
|
logger("End of poco", LOGGER_DEBUG);
|
||||||
|
|
||||||
if($format === 'xml') {
|
if ($format === 'xml') {
|
||||||
header('Content-type: text/xml');
|
header('Content-type: text/xml');
|
||||||
echo replace_macros(get_markup_template('poco_xml.tpl'),array_xmlify(array('$response' => $ret)));
|
echo replace_macros(get_markup_template('poco_xml.tpl'),array_xmlify(array('$response' => $ret)));
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
if($format === 'json') {
|
if ($format === 'json') {
|
||||||
header('Content-type: application/json');
|
header('Content-type: application/json');
|
||||||
echo json_encode($ret);
|
echo json_encode($ret);
|
||||||
killme();
|
killme();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
http_status_exit(500);
|
http_status_exit(500);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,23 +251,6 @@ function profile_content(App $a, $update = 0) {
|
||||||
$sql_extra3 = sprintf(" AND `thread`.`contact-id` = %d ", intval(intval($a->profile['contact_id'])));
|
$sql_extra3 = sprintf(" AND `thread`.`contact-id` = %d ", intval(intval($a->profile['contact_id'])));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(get_config('system', 'old_pager')) {
|
|
||||||
$r = q("SELECT COUNT(*) AS `total`
|
|
||||||
FROM `thread` INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
|
|
||||||
$sql_post_table INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
|
|
||||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
|
||||||
WHERE `thread`.`uid` = %d AND `thread`.`visible` = 1 AND `thread`.`deleted` = 0
|
|
||||||
and `thread`.`moderated` = 0
|
|
||||||
AND `thread`.`wall` = 1
|
|
||||||
$sql_extra3 $sql_extra $sql_extra2 ",
|
|
||||||
intval($a->profile['profile_uid'])
|
|
||||||
);
|
|
||||||
|
|
||||||
if (dbm::is_result($r)) {
|
|
||||||
$a->set_pager_total($r[0]['total']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if we serve a mobile device and get the user settings
|
// check if we serve a mobile device and get the user settings
|
||||||
// accordingly
|
// accordingly
|
||||||
if ($a->is_mobile) {
|
if ($a->is_mobile) {
|
||||||
|
@ -335,14 +318,10 @@ function profile_content(App $a, $update = 0) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$o .= conversation($a,$items,'profile',$update);
|
$o .= conversation($a, $items, 'profile', $update);
|
||||||
|
|
||||||
if(! $update) {
|
if (!$update) {
|
||||||
if(!get_config('system', 'old_pager')) {
|
$o .= alt_pager($a, count($items));
|
||||||
$o .= alt_pager($a,count($items));
|
|
||||||
} else {
|
|
||||||
$o .= paginate($a);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
|
|
|
@ -15,28 +15,18 @@ function share_init(App $a) {
|
||||||
if(! dbm::is_result($r) || ($r[0]['private'] == 1))
|
if(! dbm::is_result($r) || ($r[0]['private'] == 1))
|
||||||
killme();
|
killme();
|
||||||
|
|
||||||
if (!intval(get_config('system','old_share'))) {
|
if (strpos($r[0]['body'], "[/share]") !== false) {
|
||||||
if (strpos($r[0]['body'], "[/share]") !== false) {
|
$pos = strpos($r[0]['body'], "[share");
|
||||||
$pos = strpos($r[0]['body'], "[share");
|
$o = substr($r[0]['body'], $pos);
|
||||||
$o = substr($r[0]['body'], $pos);
|
|
||||||
} else {
|
|
||||||
$o = share_header($r[0]['author-name'], $r[0]['author-link'], $r[0]['author-avatar'], $r[0]['guid'], $r[0]['created'], $r[0]['plink']);
|
|
||||||
|
|
||||||
if($r[0]['title'])
|
|
||||||
$o .= '[b]'.$r[0]['title'].'[/b]'."\n";
|
|
||||||
$o .= $r[0]['body'];
|
|
||||||
$o.= "[/share]";
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$o = '';
|
$o = share_header($r[0]['author-name'], $r[0]['author-link'], $r[0]['author-avatar'], $r[0]['guid'], $r[0]['created'], $r[0]['plink']);
|
||||||
|
|
||||||
$o .= "\xE2\x99\xb2" . ' [url=' . $r[0]['author-link'] . ']' . $r[0]['author-name'] . '[/url]' . "\n";
|
|
||||||
if($r[0]['title'])
|
if($r[0]['title'])
|
||||||
$o .= '[b]' . $r[0]['title'] . '[/b]' . "\n";
|
$o .= '[b]'.$r[0]['title'].'[/b]'."\n";
|
||||||
$o .= $r[0]['body'] . "\n" ;
|
$o .= $r[0]['body'];
|
||||||
|
$o.= "[/share]";
|
||||||
$o .= (($r[0]['plink']) ? '[url=' . $r[0]['plink'] . ']' . t('link') . '[/url]' . "\n" : '');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $o;
|
echo $o;
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ use \Friendica\Core\PConfig;
|
||||||
|
|
||||||
function worker_init($a){
|
function worker_init($a){
|
||||||
|
|
||||||
if (!Config::get("system", "frontend_worker") OR !Config::get("system", "worker")) {
|
if (!Config::get("system", "frontend_worker")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -287,32 +287,6 @@ class Item extends BaseObject {
|
||||||
|
|
||||||
localize_item($item);
|
localize_item($item);
|
||||||
|
|
||||||
if ($item["postopts"] and !get_config("system", "suppress_language")) {
|
|
||||||
//$langdata = explode(";", $item["postopts"]);
|
|
||||||
//$langstr = substr($langdata[0], 5)." (".round($langdata[1]*100, 1)."%)";
|
|
||||||
$langstr = "";
|
|
||||||
if (substr($item["postopts"], 0, 5) == "lang=") {
|
|
||||||
$postopts = substr($item["postopts"], 5);
|
|
||||||
|
|
||||||
$languages = explode(":", $postopts);
|
|
||||||
|
|
||||||
if (sizeof($languages) == 1) {
|
|
||||||
$languages = array();
|
|
||||||
$languages[] = $postopts;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($languages as $language) {
|
|
||||||
$langdata = explode(";", $language);
|
|
||||||
if ($langstr != "") {
|
|
||||||
$langstr .= ", ";
|
|
||||||
}
|
|
||||||
|
|
||||||
//$langstr .= $langdata[0]." (".round($langdata[1]*100, 1)."%)";
|
|
||||||
$langstr .= round($langdata[1]*100, 1)."% ".$langdata[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$body = prepare_body($item,true);
|
$body = prepare_body($item,true);
|
||||||
|
|
||||||
list($categories, $folders) = get_cats_and_terms($item);
|
list($categories, $folders) = get_cats_and_terms($item);
|
||||||
|
@ -420,7 +394,6 @@ class Item extends BaseObject {
|
||||||
'previewing' => ($conv->is_preview() ? ' preview ' : ''),
|
'previewing' => ($conv->is_preview() ? ' preview ' : ''),
|
||||||
'wait' => t('Please wait'),
|
'wait' => t('Please wait'),
|
||||||
'thread_level' => $thread_level,
|
'thread_level' => $thread_level,
|
||||||
'postopts' => $langstr,
|
|
||||||
'edited' => $edited,
|
'edited' => $edited,
|
||||||
'network' => $item["item_network"],
|
'network' => $item["item_network"],
|
||||||
'network_name' => network_to_name($item['item_network'], $profile_link),
|
'network_name' => network_to_name($item['item_network'], $profile_link),
|
||||||
|
|
|
@ -56,7 +56,6 @@
|
||||||
{{include file="field_select.tpl" field=$theme_mobile}}
|
{{include file="field_select.tpl" field=$theme_mobile}}
|
||||||
{{include file="field_select.tpl" field=$ssl_policy}}
|
{{include file="field_select.tpl" field=$ssl_policy}}
|
||||||
{{if $ssl_policy.2 == 1}}{{include file="field_checkbox.tpl" field=$force_ssl}}{{/if}}
|
{{if $ssl_policy.2 == 1}}{{include file="field_checkbox.tpl" field=$force_ssl}}{{/if}}
|
||||||
{{include file="field_checkbox.tpl" field=$old_share}}
|
|
||||||
{{include file="field_checkbox.tpl" field=$hide_help}}
|
{{include file="field_checkbox.tpl" field=$hide_help}}
|
||||||
{{include file="field_select.tpl" field=$singleuser}}
|
{{include file="field_select.tpl" field=$singleuser}}
|
||||||
<div class="submit"><input type="submit" name="page_site" value="{{$submit|escape:'html'}}" /></div>
|
<div class="submit"><input type="submit" name="page_site" value="{{$submit|escape:'html'}}" /></div>
|
||||||
|
@ -120,19 +119,13 @@
|
||||||
{{include file="field_input.tpl" field=$proxy}}
|
{{include file="field_input.tpl" field=$proxy}}
|
||||||
{{include file="field_input.tpl" field=$proxyuser}}
|
{{include file="field_input.tpl" field=$proxyuser}}
|
||||||
{{include file="field_input.tpl" field=$timeout}}
|
{{include file="field_input.tpl" field=$timeout}}
|
||||||
{{if NOT $worker.2}}
|
|
||||||
{{include file="field_input.tpl" field=$delivery_interval}}
|
|
||||||
{{include file="field_input.tpl" field=$poll_interval}}
|
|
||||||
{{/if}}
|
|
||||||
{{include file="field_input.tpl" field=$maxloadavg}}
|
{{include file="field_input.tpl" field=$maxloadavg}}
|
||||||
{{include file="field_input.tpl" field=$maxloadavg_frontend}}
|
{{include file="field_input.tpl" field=$maxloadavg_frontend}}
|
||||||
{{include file="field_input.tpl" field=$optimize_max_tablesize}}
|
{{include file="field_input.tpl" field=$optimize_max_tablesize}}
|
||||||
{{include file="field_input.tpl" field=$optimize_fragmentation}}
|
{{include file="field_input.tpl" field=$optimize_fragmentation}}
|
||||||
{{include file="field_input.tpl" field=$abandon_days}}
|
{{include file="field_input.tpl" field=$abandon_days}}
|
||||||
{{include file="field_input.tpl" field=$lockpath}}
|
|
||||||
{{include file="field_input.tpl" field=$temppath}}
|
{{include file="field_input.tpl" field=$temppath}}
|
||||||
{{include file="field_input.tpl" field=$basepath}}
|
{{include file="field_input.tpl" field=$basepath}}
|
||||||
{{include file="field_checkbox.tpl" field=$suppress_language}}
|
|
||||||
{{include file="field_checkbox.tpl" field=$suppress_tags}}
|
{{include file="field_checkbox.tpl" field=$suppress_tags}}
|
||||||
{{include file="field_checkbox.tpl" field=$nodeinfo}}
|
{{include file="field_checkbox.tpl" field=$nodeinfo}}
|
||||||
{{include file="field_input.tpl" field=$embedly}}
|
{{include file="field_input.tpl" field=$embedly}}
|
||||||
|
@ -153,17 +146,13 @@
|
||||||
{{include file="field_input.tpl" field=$itemcache_duration}}
|
{{include file="field_input.tpl" field=$itemcache_duration}}
|
||||||
{{include file="field_input.tpl" field=$max_comments}}
|
{{include file="field_input.tpl" field=$max_comments}}
|
||||||
{{include file="field_checkbox.tpl" field=$proxy_disabled}}
|
{{include file="field_checkbox.tpl" field=$proxy_disabled}}
|
||||||
{{include file="field_checkbox.tpl" field=$old_pager}}
|
|
||||||
<div class="submit"><input type="submit" name="page_site" value="{{$submit|escape:'html'}}" /></div>
|
<div class="submit"><input type="submit" name="page_site" value="{{$submit|escape:'html'}}" /></div>
|
||||||
|
|
||||||
<h3>{{$worker_title}}</h3>
|
<h3>{{$worker_title}}</h3>
|
||||||
{{include file="field_checkbox.tpl" field=$worker}}
|
{{include file="field_input.tpl" field=$worker_queues}}
|
||||||
{{if $worker.2}}
|
{{include file="field_checkbox.tpl" field=$worker_dont_fork}}
|
||||||
{{include file="field_input.tpl" field=$worker_queues}}
|
{{include file="field_checkbox.tpl" field=$worker_fastlane}}
|
||||||
{{include file="field_checkbox.tpl" field=$worker_dont_fork}}
|
{{include file="field_checkbox.tpl" field=$worker_frontend}}
|
||||||
{{include file="field_checkbox.tpl" field=$worker_fastlane}}
|
|
||||||
{{include file="field_checkbox.tpl" field=$worker_frontend}}
|
|
||||||
{{/if}}
|
|
||||||
<div class="submit"><input type="submit" name="page_site" value="{{$submit|escape:'html'}}" /></div>
|
<div class="submit"><input type="submit" name="page_site" value="{{$submit|escape:'html'}}" /></div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
<dl>
|
<dl>
|
||||||
<dt>{{$queues.label}}</dt>
|
<dt>{{$queues.label}}</dt>
|
||||||
<dd>{{$queues.deliverq}} - <a href="{{$baseurl}}/admin/queue">{{$queues.queue}}</a>{{if $workeractive}} - {{$queues.workerq}}{{/if}}</dd>
|
<dd>{{$queues.deliverq}} - <a href="{{$baseurl}}/admin/queue">{{$queues.queue}}</a> - {{$queues.workerq}}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<dl>
|
<dl>
|
||||||
<dt>{{$pending.0}}</dt>
|
<dt>{{$pending.0}}</dt>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{{if $pager}}
|
{{if $pager}}
|
||||||
{{if $pager.prev}}<span class="pager_prev {{$pager.prev.class}}"><a href="{{$pager.prev.url}}">{{$pager.prev.text}}</a></span>{{/if}}
|
{{if $pager.prev}}<span class="pager_prev {{$pager.prev.class}}"><a href="{{$pager.prev.url}}">{{$pager.prev.text}}</a></span>{{/if}}
|
||||||
|
|
||||||
{{if $pager.first}}<span class="pager_first $pager.first.class"><a href="{{$pager.first.url}}">{{$pager.first.text}}</a></span>{{/if}}
|
{{if $pager.first}}<span class="pager_first {{$pager.first.class}}"><a href="{{$pager.first.url}}">{{$pager.first.text}}</a></span>{{/if}}
|
||||||
|
|
||||||
{{foreach $pager.pages as $p}}<span class="pager_{{$p.class}}"><a href="{{$p.url}}">{{$p.text}}</a></span>{{/foreach}}
|
{{foreach $pager.pages as $p}}<span class="pager_{{$p.class}}"><a href="{{$p.url}}">{{$p.text}}</a></span>{{/foreach}}
|
||||||
|
|
||||||
|
|
|
@ -1552,6 +1552,9 @@ blockquote.shared_content {
|
||||||
clear:left;
|
clear:left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pager .disabled {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.pager_first,
|
.pager_first,
|
||||||
.pager_last,
|
.pager_last,
|
||||||
|
|
|
@ -2508,6 +2508,56 @@ body .tread-wrapper .hovercard:hover .hover-card-content a {
|
||||||
color: $link_color !important;
|
color: $link_color !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Pagination improvements */
|
||||||
|
.pagination {
|
||||||
|
text-align: center;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.pagination > li > a,
|
||||||
|
.pagination > li > span {
|
||||||
|
color: $link_color;
|
||||||
|
float: none;
|
||||||
|
}
|
||||||
|
.pagination>li>a:hover,
|
||||||
|
.pagination>li>span:hover {
|
||||||
|
color: $link_hover_color;
|
||||||
|
}
|
||||||
|
.pagination > .active > a,
|
||||||
|
.pagination > .active > a:focus,
|
||||||
|
.pagination > .active > a:hover,
|
||||||
|
.pagination > .active > span,
|
||||||
|
.pagination > .active > span:focus,
|
||||||
|
.pagination > .active > span:hover {
|
||||||
|
background-color: $link_color;
|
||||||
|
border-color: $link_color;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
.pagination li.pager_n a {
|
||||||
|
margin-left: 3px;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
.pagination .pager_prev a {
|
||||||
|
margin-left: -5px;
|
||||||
|
margin-right: 4px;
|
||||||
|
border-top-right-radius: 3px;
|
||||||
|
border-bottom-right-radius: 3px;
|
||||||
|
}
|
||||||
|
.pagination .pager_next a {
|
||||||
|
margin-left: 4px;
|
||||||
|
margin-right: -5px;
|
||||||
|
border-top-left-radius: 3px;
|
||||||
|
border-bottom-left-radius: 3px;
|
||||||
|
}
|
||||||
|
.pager .next > a,
|
||||||
|
.pager .previous > a {
|
||||||
|
float: none;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
.pagination .disabled > a,
|
||||||
|
.pager .disabled > a {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* some temporary workarounds until this will solved
|
* some temporary workarounds until this will solved
|
||||||
* elsewhere (e.g. new templates)
|
* elsewhere (e.g. new templates)
|
||||||
|
|
|
@ -162,21 +162,29 @@ function qCommentInsert(obj,id) {
|
||||||
|
|
||||||
function confirmDelete() { return confirm(aStr.delitem); }
|
function confirmDelete() { return confirm(aStr.delitem); }
|
||||||
|
|
||||||
function dropItem(url, object) {
|
/**
|
||||||
|
* Hide and removes an item element from the DOM after the deletion url is
|
||||||
|
* successful, restore it else.
|
||||||
|
*
|
||||||
|
* @param {string} url The item removal URL
|
||||||
|
* @param {string} elementId The DOM id of the item element
|
||||||
|
* @returns {undefined}
|
||||||
|
*/
|
||||||
|
function dropItem(url, elementId) {
|
||||||
var confirm = confirmDelete();
|
var confirm = confirmDelete();
|
||||||
|
|
||||||
//if the first character of the object is #, remove it because
|
if (confirm) {
|
||||||
// we use getElementById which don't need the #
|
|
||||||
// getElementByID selects elements even if there are special characters
|
|
||||||
// in the ID (like %) which won't work with jQuery
|
|
||||||
/// @todo ceck if we can solve this in the template
|
|
||||||
object = object.indexOf('#') == 0 ? object.substring(1) : object;
|
|
||||||
|
|
||||||
if(confirm) {
|
|
||||||
$('body').css('cursor', 'wait');
|
$('body').css('cursor', 'wait');
|
||||||
$(document.getElementById(object)).fadeTo('fast', 0.33, function () {
|
|
||||||
$.get(url).done(function() {
|
var $el = $(document.getElementById(elementId));
|
||||||
$(document.getElementById(object)).remove();
|
|
||||||
|
$el.fadeTo('fast', 0.33, function () {
|
||||||
|
$.get(url).then(function() {
|
||||||
|
$el.remove();
|
||||||
|
}).fail(function() {
|
||||||
|
// @todo Show related error message
|
||||||
|
$el.show();
|
||||||
|
}).always(function() {
|
||||||
$('body').css('cursor', 'auto');
|
$('body').css('cursor', 'auto');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -573,31 +573,38 @@ String.prototype.rtrim = function() {
|
||||||
return trimmed;
|
return trimmed;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Scroll to a specific item and highlight it
|
/**
|
||||||
// Note: jquery.color.js is needed
|
* Scroll the screen to the item element whose id is provided, then highlights it
|
||||||
function scrollToItem(itemID) {
|
*
|
||||||
if( typeof itemID === "undefined")
|
* Note: jquery.color.js is required
|
||||||
|
*
|
||||||
|
* @param {string} elementId The item element id
|
||||||
|
* @returns {undefined}
|
||||||
|
*/
|
||||||
|
function scrollToItem(elementId) {
|
||||||
|
if (typeof elementId === "undefined") {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var elm = $('#'+itemID);
|
var $el = $(document.getElementById(elementId));
|
||||||
// Test if the Item exists
|
// Test if the Item exists
|
||||||
if(!elm.length)
|
if (!$el.length) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Define the colors which are used for highlighting
|
// Define the colors which are used for highlighting
|
||||||
var colWhite = {backgroundColor:'#F5F5F5'};
|
var colWhite = {backgroundColor:'#F5F5F5'};
|
||||||
var colShiny = {backgroundColor:'#FFF176'};
|
var colShiny = {backgroundColor:'#FFF176'};
|
||||||
|
|
||||||
// Get the Item Position (we need to substract 100 to match
|
// Get the Item Position (we need to substract 100 to match correct position
|
||||||
// correct position
|
var itemPos = $el.offset().top - 100;
|
||||||
var itemPos = $(elm).offset().top - 100;
|
|
||||||
|
|
||||||
// Scroll to the DIV with the ID (GUID)
|
// Scroll to the DIV with the ID (GUID)
|
||||||
$('html, body').animate({
|
$('html, body').animate({
|
||||||
scrollTop: itemPos
|
scrollTop: itemPos
|
||||||
}, 400, function() {
|
}, 400, function() {
|
||||||
// Highlight post/commenent with ID (GUID)
|
// Highlight post/commenent with ID (GUID)
|
||||||
$(elm).animate(colWhite, 1000).animate(colShiny).animate(colWhite, 600);
|
$el.animate(colWhite, 1000).animate(colShiny).animate(colWhite, 600);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,292 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
class colors {
|
|
||||||
|
|
||||||
/* Convert hexdec color string to rgb(a) string */
|
|
||||||
|
|
||||||
function hex2rgba($color, $opacity = false) {
|
|
||||||
|
|
||||||
$default = 'rgb(0,0,0)';
|
|
||||||
|
|
||||||
//Return default if no color provided
|
|
||||||
if(empty($color))
|
|
||||||
return $default;
|
|
||||||
|
|
||||||
//Sanitize $color if "#" is provided
|
|
||||||
if ($color[0] == '#' ) {
|
|
||||||
$color = substr( $color, 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
//Check if color has 6 or 3 characters and get values
|
|
||||||
if (strlen($color) == 6) {
|
|
||||||
$hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] );
|
|
||||||
} elseif ( strlen( $color ) == 3 ) {
|
|
||||||
$hex = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] );
|
|
||||||
} else {
|
|
||||||
return $default;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Convert hexadec to rgb
|
|
||||||
$rgb = array_map('hexdec', $hex);
|
|
||||||
|
|
||||||
//Check if opacity is set(rgba or rgb)
|
|
||||||
if($opacity){
|
|
||||||
if(abs($opacity) > 1)
|
|
||||||
$opacity = 1.0;
|
|
||||||
$output = 'rgba('.implode(",",$rgb).','.$opacity.')';
|
|
||||||
} else {
|
|
||||||
$output = 'rgb('.implode(",",$rgb).')';
|
|
||||||
}
|
|
||||||
|
|
||||||
//Return rgb(a) color string
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
function hex2rgb( $colour ) {
|
|
||||||
if ( $colour[0] == '#' ) {
|
|
||||||
$colour = substr( $colour, 1 );
|
|
||||||
}
|
|
||||||
if ( strlen( $colour ) == 6 ) {
|
|
||||||
list( $r, $g, $b ) = array( $colour[0] . $colour[1], $colour[2] . $colour[3], $colour[4] . $colour[5] );
|
|
||||||
} elseif ( strlen( $colour ) == 3 ) {
|
|
||||||
list( $r, $g, $b ) = array( $colour[0] . $colour[0], $colour[1] . $colour[1], $colour[2] . $colour[2] );
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$r = hexdec( $r );
|
|
||||||
$g = hexdec( $g );
|
|
||||||
$b = hexdec( $b );
|
|
||||||
return array( 'red' => $r, 'green' => $g, 'blue' => $b );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function rgbToHsl( $r, $g, $b ) {
|
|
||||||
$oldR = $r;
|
|
||||||
$oldG = $g;
|
|
||||||
$oldB = $b;
|
|
||||||
$r /= 255;
|
|
||||||
$g /= 255;
|
|
||||||
$b /= 255;
|
|
||||||
$max = max( $r, $g, $b );
|
|
||||||
$min = min( $r, $g, $b );
|
|
||||||
$h;
|
|
||||||
$s;
|
|
||||||
$l = ( $max + $min ) / 2;
|
|
||||||
$d = $max - $min;
|
|
||||||
|
|
||||||
if( $d == 0 ){
|
|
||||||
$h = $s = 0; // achromatic
|
|
||||||
} else {
|
|
||||||
$s = $d / ( 1 - abs( 2 * $l - 1 ) );
|
|
||||||
switch( $max ){
|
|
||||||
case $r:
|
|
||||||
$h = 60 * fmod( ( ( $g - $b ) / $d ), 6 );
|
|
||||||
if ($b > $g) {
|
|
||||||
$h += 360;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case $g:
|
|
||||||
$h = 60 * ( ( $b - $r ) / $d + 2 );
|
|
||||||
break;
|
|
||||||
case $b:
|
|
||||||
$h = 60 * ( ( $r - $g ) / $d + 4 );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return array( round( $h, 2 ), round( $s, 2 ), round( $l, 2 ) );
|
|
||||||
}
|
|
||||||
function hslToRgb( $h, $s, $l ){
|
|
||||||
$r = "";
|
|
||||||
$g = "";
|
|
||||||
$b = "";
|
|
||||||
|
|
||||||
$c = ( 1 - abs( 2 * $l - 1 ) ) * $s;
|
|
||||||
$x = $c * ( 1 - abs( fmod( ( $h / 60 ), 2 ) - 1 ) );
|
|
||||||
$m = $l - ( $c / 2 );
|
|
||||||
if ( $h < 60 ) {
|
|
||||||
$r = $c;
|
|
||||||
$g = $x;
|
|
||||||
$b = 0;
|
|
||||||
} else if ( $h < 120 ) {
|
|
||||||
$r = $x;
|
|
||||||
$g = $c;
|
|
||||||
$b = 0;
|
|
||||||
} else if ( $h < 180 ) {
|
|
||||||
$r = 0;
|
|
||||||
$g = $c;
|
|
||||||
$b = $x;
|
|
||||||
} else if ( $h < 240 ) {
|
|
||||||
$r = 0;
|
|
||||||
$g = $x;
|
|
||||||
$b = $c;
|
|
||||||
} else if ( $h < 300 ) {
|
|
||||||
$r = $x;
|
|
||||||
$g = 0;
|
|
||||||
$b = $c;
|
|
||||||
} else {
|
|
||||||
$r = $c;
|
|
||||||
$g = 0;
|
|
||||||
$b = $x;
|
|
||||||
}
|
|
||||||
|
|
||||||
$r = ( $r + $m ) * 255;
|
|
||||||
$g = ( $g + $m ) * 255;
|
|
||||||
$b = ( $b + $m ) * 255;
|
|
||||||
|
|
||||||
return array( floor( $r ), floor( $g ), floor( $b ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Som more example code - this needs to be deletet if we don't need it in
|
|
||||||
* the future
|
|
||||||
*/
|
|
||||||
|
|
||||||
function HTMLToRGB($htmlCode)
|
|
||||||
{
|
|
||||||
if($htmlCode[0] == '#')
|
|
||||||
$htmlCode = substr($htmlCode, 1);
|
|
||||||
|
|
||||||
if (strlen($htmlCode) == 3)
|
|
||||||
{
|
|
||||||
$htmlCode = $htmlCode[0] . $htmlCode[0] . $htmlCode[1] . $htmlCode[1] . $htmlCode[2] . $htmlCode[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
$r = hexdec($htmlCode[0] . $htmlCode[1]);
|
|
||||||
$g = hexdec($htmlCode[2] . $htmlCode[3]);
|
|
||||||
$b = hexdec($htmlCode[4] . $htmlCode[5]);
|
|
||||||
|
|
||||||
return $b + ($g << 0x8) + ($r << 0x10);
|
|
||||||
}
|
|
||||||
|
|
||||||
function RGBToHTML($RGB)
|
|
||||||
{
|
|
||||||
$r = 0xFF & ($RGB >> 0x10);
|
|
||||||
$g = 0xFF & ($RGB >> 0x8);
|
|
||||||
$b = 0xFF & $RGB;
|
|
||||||
|
|
||||||
$r = dechex($r);
|
|
||||||
$g = dechex($g);
|
|
||||||
$b = dechex($b);
|
|
||||||
|
|
||||||
return "#" . str_pad($r, 2, "0", STR_PAD_LEFT) . str_pad($g, 2, "0", STR_PAD_LEFT) . str_pad($b, 2, "0", STR_PAD_LEFT);
|
|
||||||
}
|
|
||||||
|
|
||||||
function ChangeLuminosity($RGB, $LuminosityPercent)
|
|
||||||
{
|
|
||||||
$HSL = RGBToHSL($RGB);
|
|
||||||
$NewHSL = (int)(((float)$LuminosityPercent / 100) * 255) + (0xFFFF00 & $HSL);
|
|
||||||
return HSLToRGB($NewHSL);
|
|
||||||
}
|
|
||||||
|
|
||||||
function RGBToHSL($RGB)
|
|
||||||
{
|
|
||||||
$r = 0xFF & ($RGB >> 0x10);
|
|
||||||
$g = 0xFF & ($RGB >> 0x8);
|
|
||||||
$b = 0xFF & $RGB;
|
|
||||||
|
|
||||||
$r = ((float)$r) / 255.0;
|
|
||||||
$g = ((float)$g) / 255.0;
|
|
||||||
$b = ((float)$b) / 255.0;
|
|
||||||
|
|
||||||
$maxC = max($r, $g, $b);
|
|
||||||
$minC = min($r, $g, $b);
|
|
||||||
|
|
||||||
$l = ($maxC + $minC) / 2.0;
|
|
||||||
|
|
||||||
if($maxC == $minC)
|
|
||||||
{
|
|
||||||
$s = 0;
|
|
||||||
$h = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if($l < .5)
|
|
||||||
{
|
|
||||||
$s = ($maxC - $minC) / ($maxC + $minC);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$s = ($maxC - $minC) / (2.0 - $maxC - $minC);
|
|
||||||
}
|
|
||||||
if($r == $maxC)
|
|
||||||
$h = ($g - $b) / ($maxC - $minC);
|
|
||||||
if($g == $maxC)
|
|
||||||
$h = 2.0 + ($b - $r) / ($maxC - $minC);
|
|
||||||
if($b == $maxC)
|
|
||||||
$h = 4.0 + ($r - $g) / ($maxC - $minC);
|
|
||||||
|
|
||||||
$h = $h / 6.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$h = (int)round(255.0 * $h);
|
|
||||||
$s = (int)round(255.0 * $s);
|
|
||||||
$l = (int)round(255.0 * $l);
|
|
||||||
|
|
||||||
$HSL = $l + ($s << 0x8) + ($h << 0x10);
|
|
||||||
return $HSL;
|
|
||||||
}
|
|
||||||
|
|
||||||
function HSLToRGB($HSL)
|
|
||||||
{
|
|
||||||
$h = 0xFF & ($HSL >> 0x10);
|
|
||||||
$s = 0xFF & ($HSL >> 0x8);
|
|
||||||
$l = 0xFF & $HSL;
|
|
||||||
|
|
||||||
$h = ((float)$h) / 255.0;
|
|
||||||
$s = ((float)$s) / 255.0;
|
|
||||||
$l = ((float)$l) / 255.0;
|
|
||||||
|
|
||||||
if($s == 0)
|
|
||||||
{
|
|
||||||
$r = $l;
|
|
||||||
$g = $l;
|
|
||||||
$b = $l;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if($l < .5)
|
|
||||||
{
|
|
||||||
$t2 = $l * (1.0 + $s);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$t2 = ($l + $s) - ($l * $s);
|
|
||||||
}
|
|
||||||
$t1 = 2.0 * $l - $t2;
|
|
||||||
|
|
||||||
$rt3 = $h + 1.0/3.0;
|
|
||||||
$gt3 = $h;
|
|
||||||
$bt3 = $h - 1.0/3.0;
|
|
||||||
|
|
||||||
if($rt3 < 0) $rt3 += 1.0;
|
|
||||||
if($rt3 > 1) $rt3 -= 1.0;
|
|
||||||
if($gt3 < 0) $gt3 += 1.0;
|
|
||||||
if($gt3 > 1) $gt3 -= 1.0;
|
|
||||||
if($bt3 < 0) $bt3 += 1.0;
|
|
||||||
if($bt3 > 1) $bt3 -= 1.0;
|
|
||||||
|
|
||||||
if(6.0 * $rt3 < 1) $r = $t1 + ($t2 - $t1) * 6.0 * $rt3;
|
|
||||||
elseif(2.0 * $rt3 < 1) $r = $t2;
|
|
||||||
elseif(3.0 * $rt3 < 2) $r = $t1 + ($t2 - $t1) * ((2.0/3.0) - $rt3) * 6.0;
|
|
||||||
else $r = $t1;
|
|
||||||
|
|
||||||
if(6.0 * $gt3 < 1) $g = $t1 + ($t2 - $t1) * 6.0 * $gt3;
|
|
||||||
elseif(2.0 * $gt3 < 1) $g = $t2;
|
|
||||||
elseif(3.0 * $gt3 < 2) $g = $t1 + ($t2 - $t1) * ((2.0/3.0) - $gt3) * 6.0;
|
|
||||||
else $g = $t1;
|
|
||||||
|
|
||||||
if(6.0 * $bt3 < 1) $b = $t1 + ($t2 - $t1) * 6.0 * $bt3;
|
|
||||||
elseif(2.0 * $bt3 < 1) $b = $t2;
|
|
||||||
elseif(3.0 * $bt3 < 2) $b = $t1 + ($t2 - $t1) * ((2.0/3.0) - $bt3) * 6.0;
|
|
||||||
else $b = $t1;
|
|
||||||
}
|
|
||||||
|
|
||||||
$r = (int)round(255.0 * $r);
|
|
||||||
$g = (int)round(255.0 * $g);
|
|
||||||
$b = (int)round(255.0 * $b);
|
|
||||||
|
|
||||||
$RGB = $b + ($g << 0x8) + ($r << 0x10);
|
|
||||||
return $RGB;
|
|
||||||
}
|
|
||||||
}
|
|
16
view/theme/frio/templates/paginate.tpl
Normal file
16
view/theme/frio/templates/paginate.tpl
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
{{* Pager template, uses output of paginate_data() in include/text.php *}}
|
||||||
|
|
||||||
|
{{if $pager}}
|
||||||
|
<ul class="{{$pager.class}} pagination-sm">
|
||||||
|
{{if $pager.first}}<li class="pager_first {{$pager.first.class}}"><a href="{{$pager.first.url}}" title="{{$pager.first.text}}">∣<</a></li>{{/if}}
|
||||||
|
|
||||||
|
{{if $pager.prev}}<li class="pager_prev {{$pager.prev.class}}"><a href="{{$pager.prev.url}}" title="{{$pager.prev.text}}"><</a></li>{{/if}}
|
||||||
|
|
||||||
|
{{foreach $pager.pages as $p}}<li class="pager_{{$p.class}} hidden-xs hidden-sm"><a href="{{$p.url}}">{{$p.text}}</a></li>{{/foreach}}
|
||||||
|
|
||||||
|
{{if $pager.next}}<li class="pager_next {{$pager.next.class}}"><a href="{{$pager.next.url}}" title="{{$pager.next.text}}">></a></li>{{/if}}
|
||||||
|
|
||||||
|
{{if $pager.last}}<li class="pager_last {{$pager.last.class}}"><a href="{{$pager.last.url}}" title="{{$pager.last.text}}">>∣</a></li>{{/if}}
|
||||||
|
</ul>
|
||||||
|
{{/if}}
|
|
@ -7,7 +7,7 @@
|
||||||
<!-- ./TODO => Unknow block -->
|
<!-- ./TODO => Unknow block -->
|
||||||
|
|
||||||
|
|
||||||
<div class="panel">
|
<div class="panel" id="item-{{$item.guid}}">
|
||||||
<div class="wall-item-container panel-body{{$item.indent}} {{$item.shiny}} {{$item.previewing}}" >
|
<div class="wall-item-container panel-body{{$item.indent}} {{$item.shiny}} {{$item.previewing}}" >
|
||||||
<div class="media">
|
<div class="media">
|
||||||
{{* Put additional actions in a top-right dropdown menu *}}
|
{{* Put additional actions in a top-right dropdown menu *}}
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
{{if $item.drop.dropping}}
|
{{if $item.drop.dropping}}
|
||||||
<li role="separator" class="divider"></li>
|
<li role="separator" class="divider"></li>
|
||||||
<li role="menuitem">
|
<li role="menuitem">
|
||||||
<a class="navicon delete" onclick="dropItem('item/drop/{{$item.id}}', '#item-{{$item.guid}}'); return false;" title="{{$item.drop.delete}}"><i class="fa fa-trash"></i> {{$item.drop.delete}}</a>
|
<a class="navicon delete" onclick="dropItem('item/drop/{{$item.id}}', 'item-{{$item.guid}}'); return false;" title="{{$item.drop.delete}}"><i class="fa fa-trash"></i> {{$item.drop.delete}}</a>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -68,9 +68,9 @@ as the value of $top_child_total (this is done at the end of this file)
|
||||||
|
|
||||||
{{* Use a different div container in dependence max thread-level = 7 *}}
|
{{* Use a different div container in dependence max thread-level = 7 *}}
|
||||||
{{if $item.thread_level<7}}
|
{{if $item.thread_level<7}}
|
||||||
<div class="wall-item-container {{$item.indent}} {{$item.shiny}} {{$item.network}} thread_level_{{$item.thread_level}} {{if $item.thread_level==1}}panel-body h-entry{{else}}u-comment h-cite{{/if}}" id="item-{{$item.guid|regex_replace:'/%.*/':''}}"><!-- wall-item-container -->
|
<div class="wall-item-container {{$item.indent}} {{$item.shiny}} {{$item.network}} thread_level_{{$item.thread_level}} {{if $item.thread_level==1}}panel-body h-entry{{else}}u-comment h-cite{{/if}}" id="item-{{$item.guid}}"><!-- wall-item-container -->
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="wall-item-container {{$item.indent}} {{$item.shiny}} {{$item.network}} thread_level_7 u-comment h-cite" id="item-{{$item.guid|regex_replace:'/%.*/':''}}">
|
<div class="wall-item-container {{$item.indent}} {{$item.shiny}} {{$item.network}} thread_level_7 u-comment h-cite" id="item-{{$item.guid}}">
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<div class="media">
|
<div class="media">
|
||||||
{{* Put addional actions in a top-right dropdown menu *}}
|
{{* Put addional actions in a top-right dropdown menu *}}
|
||||||
|
@ -129,7 +129,7 @@ as the value of $top_child_total (this is done at the end of this file)
|
||||||
|
|
||||||
{{if $item.drop.dropping}}
|
{{if $item.drop.dropping}}
|
||||||
<li role="menuitem">
|
<li role="menuitem">
|
||||||
<a class="navicon delete" onclick="dropItem('item/drop/{{$item.id}}', '#item-{{$item.guid}}'); return false;" title="{{$item.drop.delete}}"><i class="fa fa-trash"></i> {{$item.drop.delete}}</a>
|
<a class="navicon delete" onclick="dropItem('item/drop/{{$item.id}}', 'item-{{$item.guid}}'); return false;" title="{{$item.drop.delete}}"><i class="fa fa-trash"></i> {{$item.drop.delete}}</a>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -1909,6 +1909,9 @@ input#profile-jot-email {
|
||||||
-webkit-border-radius: 10px;
|
-webkit-border-radius: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pager .disabled {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.pager_first,
|
.pager_first,
|
||||||
.pager_last,
|
.pager_last,
|
||||||
|
|
|
@ -1866,6 +1866,9 @@ input#dfrn-url {
|
||||||
-webkit-border-radius: 10px;
|
-webkit-border-radius: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pager .disabled {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.pager_first,
|
.pager_first,
|
||||||
.pager_last,
|
.pager_last,
|
||||||
|
|
|
@ -2481,6 +2481,9 @@ footer {
|
||||||
margin-top: 25px;
|
margin-top: 25px;
|
||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
|
.pager .disabled {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* ADMIN
|
* ADMIN
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2481,6 +2481,9 @@ footer {
|
||||||
margin-top: 25px;
|
margin-top: 25px;
|
||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
|
.pager .disabled {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* ADMIN
|
* ADMIN
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1675,6 +1675,9 @@ footer { height: 100px; display: table-row; }
|
||||||
margin-top: 25px;
|
margin-top: 25px;
|
||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
|
.pager .disabled {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ADMIN
|
* ADMIN
|
||||||
|
|
|
@ -396,6 +396,10 @@ ul.menu-popup li a:hover {
|
||||||
margin: 4px;
|
margin: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pager .disabled {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.pager_current {
|
.pager_current {
|
||||||
background-color: #1873a2;
|
background-color: #1873a2;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
|
|
|
@ -247,6 +247,10 @@ div.pager {
|
||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pager .disabled {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.hide-comments-outer {
|
.hide-comments-outer {
|
||||||
margin-left: 80px;
|
margin-left: 80px;
|
||||||
margin-bottom: 5px;
|
margin-bottom: 5px;
|
||||||
|
|
Loading…
Reference in a new issue