Merge develop into 20170407_-_group_edit
Conflicts: mod/group.php
This commit is contained in:
commit
f99bb958f6
163 changed files with 14447 additions and 11967 deletions
15
boot.php
15
boot.php
|
@ -38,7 +38,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica');
|
|||
define ( 'FRIENDICA_CODENAME', 'Asparagus');
|
||||
define ( 'FRIENDICA_VERSION', '3.5.2-dev' );
|
||||
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
|
||||
define ( 'DB_UPDATE_VERSION', 1216 );
|
||||
define ( 'DB_UPDATE_VERSION', 1219 );
|
||||
|
||||
/**
|
||||
* @brief Constant with a HTML line break.
|
||||
|
@ -382,6 +382,7 @@ define ( 'ACTIVITY_UPDATE', NAMESPACE_ACTIVITY_SCHEMA . 'update' );
|
|||
define ( 'ACTIVITY_TAG', NAMESPACE_ACTIVITY_SCHEMA . 'tag' );
|
||||
define ( 'ACTIVITY_FAVORITE', NAMESPACE_ACTIVITY_SCHEMA . 'favorite' );
|
||||
define ( 'ACTIVITY_SHARE', NAMESPACE_ACTIVITY_SCHEMA . 'share' );
|
||||
define ( 'ACTIVITY_DELETE', NAMESPACE_ACTIVITY_SCHEMA . 'delete' );
|
||||
|
||||
define ( 'ACTIVITY_POKE', NAMESPACE_ZOT . '/activity/poke' );
|
||||
define ( 'ACTIVITY_MOOD', NAMESPACE_ZOT . '/activity/mood' );
|
||||
|
@ -1366,11 +1367,15 @@ class App {
|
|||
$cmdline = implode($args, " ");
|
||||
|
||||
if (get_config('system', 'proc_windows')) {
|
||||
proc_close(proc_open('cmd /c start /b ' . $cmdline, array(), $foo, dirname(__FILE__)));
|
||||
$resource = proc_open('cmd /c start /b ' . $cmdline, array(), $foo, dirname(__FILE__));
|
||||
} else {
|
||||
proc_close(proc_open($cmdline . " &", array(), $foo, dirname(__FILE__)));
|
||||
$resource = proc_open($cmdline . " &", array(), $foo, dirname(__FILE__));
|
||||
}
|
||||
|
||||
if (!is_resource($resource)) {
|
||||
logger('We got no resource for command '.$cmdline, LOGGER_DEBUG);
|
||||
return;
|
||||
}
|
||||
proc_close($resource);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2472,7 +2477,7 @@ function get_temppath() {
|
|||
// Check if it is usable
|
||||
if (($temppath != "") AND App::directory_usable($temppath)) {
|
||||
// To avoid any interferences with other systems we create our own directory
|
||||
$new_temppath .= "/".$a->get_hostname();
|
||||
$new_temppath = $temppath."/".$a->get_hostname();
|
||||
if (!is_dir($new_temppath)) {
|
||||
/// @TODO There is a mkdir()+chmod() upwards, maybe generalize this (+ configurable) into a function/method?
|
||||
mkdir($new_temppath);
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
"require": {
|
||||
"ezyang/htmlpurifier": "~4.7.0",
|
||||
"mobiledetect/mobiledetectlib": "2.8.*",
|
||||
"league/html-to-markdown": "~4.4.1",
|
||||
"pear-pear.php.net/Text_Highlighter": "*"
|
||||
},
|
||||
"repositories": [
|
||||
|
|
66
composer.lock
generated
66
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "4d3a9e742e7ad746fb7206f3b5aff5af",
|
||||
"content-hash": "802372ddf124ef949e80dd8dc1d38797",
|
||||
"packages": [
|
||||
{
|
||||
"name": "ezyang/htmlpurifier",
|
||||
|
@ -50,6 +50,70 @@
|
|||
],
|
||||
"time": "2015-08-05T01:03:42+00:00"
|
||||
},
|
||||
{
|
||||
"name": "league/html-to-markdown",
|
||||
"version": "4.4.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/thephpleague/html-to-markdown.git",
|
||||
"reference": "82ea375b5b2b1da1da222644c0565c695bf88186"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/thephpleague/html-to-markdown/zipball/82ea375b5b2b1da1da222644c0565c695bf88186",
|
||||
"reference": "82ea375b5b2b1da1da222644c0565c695bf88186",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-dom": "*",
|
||||
"ext-xml": "*",
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"mikehaertl/php-shellcommand": "~1.1.0",
|
||||
"phpunit/phpunit": "4.*",
|
||||
"scrutinizer/ocular": "~1.1"
|
||||
},
|
||||
"bin": [
|
||||
"bin/html-to-markdown"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.5-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"League\\HTMLToMarkdown\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Colin O'Dell",
|
||||
"email": "colinodell@gmail.com",
|
||||
"homepage": "http://www.colinodell.com",
|
||||
"role": "Lead Developer"
|
||||
},
|
||||
{
|
||||
"name": "Nick Cernis",
|
||||
"email": "nick@cern.is",
|
||||
"homepage": "http://modernnerd.net",
|
||||
"role": "Original Author"
|
||||
}
|
||||
],
|
||||
"description": "An HTML-to-markdown conversion helper for PHP",
|
||||
"homepage": "https://github.com/thephpleague/html-to-markdown",
|
||||
"keywords": [
|
||||
"html",
|
||||
"markdown"
|
||||
],
|
||||
"time": "2017-03-16T00:45:59+00:00"
|
||||
},
|
||||
{
|
||||
"name": "mobiledetect/mobiledetectlib",
|
||||
"version": "2.8.25",
|
||||
|
|
114
database.sql
114
database.sql
|
@ -1,6 +1,6 @@
|
|||
-- ------------------------------------------
|
||||
-- Friendica 3.5.2-dev (Asparagus)
|
||||
-- DB_UPDATE_VERSION 1215
|
||||
-- DB_UPDATE_VERSION 1219
|
||||
-- ------------------------------------------
|
||||
|
||||
|
||||
|
@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS `addon` (
|
|||
`plugin_admin` tinyint(1) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE INDEX `name` (`name`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE attach
|
||||
|
@ -37,7 +37,7 @@ CREATE TABLE IF NOT EXISTS `attach` (
|
|||
`deny_cid` mediumtext,
|
||||
`deny_gid` mediumtext,
|
||||
PRIMARY KEY(`id`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE auth_codes
|
||||
|
@ -49,7 +49,7 @@ CREATE TABLE IF NOT EXISTS `auth_codes` (
|
|||
`expires` int(11) NOT NULL DEFAULT 0,
|
||||
`scope` varchar(250) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY(`id`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE cache
|
||||
|
@ -61,7 +61,7 @@ CREATE TABLE IF NOT EXISTS `cache` (
|
|||
`updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
|
||||
PRIMARY KEY(`k`),
|
||||
INDEX `expire_mode_updated` (`expire_mode`,`updated`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE challenge
|
||||
|
@ -74,7 +74,7 @@ CREATE TABLE IF NOT EXISTS `challenge` (
|
|||
`type` varchar(255) NOT NULL DEFAULT '',
|
||||
`last_update` varchar(255) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY(`id`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE clients
|
||||
|
@ -87,7 +87,7 @@ CREATE TABLE IF NOT EXISTS `clients` (
|
|||
`icon` text,
|
||||
`uid` int(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY(`client_id`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE config
|
||||
|
@ -99,7 +99,7 @@ CREATE TABLE IF NOT EXISTS `config` (
|
|||
`v` mediumtext,
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE INDEX `cat_k` (`cat`,`k`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE contact
|
||||
|
@ -159,7 +159,7 @@ CREATE TABLE IF NOT EXISTS `contact` (
|
|||
`writable` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`forum` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`prv` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`contact-type` int(11) unsigned NOT NULL DEFAULT 0,
|
||||
`contact-type` int(11) NOT NULL DEFAULT 0,
|
||||
`hidden` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`archive` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`pending` tinyint(1) NOT NULL DEFAULT 1,
|
||||
|
@ -169,7 +169,7 @@ CREATE TABLE IF NOT EXISTS `contact` (
|
|||
`info` mediumtext,
|
||||
`profile-id` int(11) NOT NULL DEFAULT 0,
|
||||
`bdyear` varchar(4) NOT NULL DEFAULT '',
|
||||
`bd` date NOT NULL DEFAULT '0000-00-00',
|
||||
`bd` date NOT NULL DEFAULT '0001-01-01',
|
||||
`notify_new_posts` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`fetch_further_information` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`ffi_keyword_blacklist` text,
|
||||
|
@ -186,7 +186,7 @@ CREATE TABLE IF NOT EXISTS `contact` (
|
|||
INDEX `nick_uid` (`nick`(32),`uid`),
|
||||
INDEX `dfrn-id` (`dfrn-id`),
|
||||
INDEX `issued-id` (`issued-id`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE conv
|
||||
|
@ -202,7 +202,7 @@ CREATE TABLE IF NOT EXISTS `conv` (
|
|||
`subject` text,
|
||||
PRIMARY KEY(`id`),
|
||||
INDEX `uid` (`uid`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE event
|
||||
|
@ -230,7 +230,7 @@ CREATE TABLE IF NOT EXISTS `event` (
|
|||
`deny_gid` mediumtext,
|
||||
PRIMARY KEY(`id`),
|
||||
INDEX `uid_start` (`uid`,`start`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE fcontact
|
||||
|
@ -256,7 +256,7 @@ CREATE TABLE IF NOT EXISTS `fcontact` (
|
|||
PRIMARY KEY(`id`),
|
||||
INDEX `addr` (`addr`(32)),
|
||||
INDEX `url` (`url`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE ffinder
|
||||
|
@ -267,7 +267,7 @@ CREATE TABLE IF NOT EXISTS `ffinder` (
|
|||
`cid` int(10) unsigned NOT NULL DEFAULT 0,
|
||||
`fid` int(10) unsigned NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY(`id`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE fserver
|
||||
|
@ -279,7 +279,7 @@ CREATE TABLE IF NOT EXISTS `fserver` (
|
|||
`key` text,
|
||||
PRIMARY KEY(`id`),
|
||||
INDEX `server` (`server`(32))
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE fsuggest
|
||||
|
@ -295,7 +295,7 @@ CREATE TABLE IF NOT EXISTS `fsuggest` (
|
|||
`note` text,
|
||||
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
|
||||
PRIMARY KEY(`id`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE gcign
|
||||
|
@ -307,7 +307,7 @@ CREATE TABLE IF NOT EXISTS `gcign` (
|
|||
PRIMARY KEY(`id`),
|
||||
INDEX `uid` (`uid`),
|
||||
INDEX `gcid` (`gcid`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE gcontact
|
||||
|
@ -328,7 +328,7 @@ CREATE TABLE IF NOT EXISTS `gcontact` (
|
|||
`about` text,
|
||||
`keywords` text,
|
||||
`gender` varchar(32) NOT NULL DEFAULT '',
|
||||
`birthday` varchar(32) NOT NULL DEFAULT '0000-00-00',
|
||||
`birthday` varchar(32) NOT NULL DEFAULT '0001-01-01',
|
||||
`community` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`contact-type` tinyint(1) NOT NULL DEFAULT -1,
|
||||
`hide` tinyint(1) NOT NULL DEFAULT 0,
|
||||
|
@ -346,7 +346,7 @@ CREATE TABLE IF NOT EXISTS `gcontact` (
|
|||
INDEX `addr` (`addr`(64)),
|
||||
INDEX `hide_network_updated` (`hide`,`network`,`updated`),
|
||||
INDEX `updated` (`updated`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE glink
|
||||
|
@ -361,7 +361,7 @@ CREATE TABLE IF NOT EXISTS `glink` (
|
|||
PRIMARY KEY(`id`),
|
||||
UNIQUE INDEX `cid_uid_gcid_zcid` (`cid`,`uid`,`gcid`,`zcid`),
|
||||
INDEX `gcid` (`gcid`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE group
|
||||
|
@ -374,7 +374,7 @@ CREATE TABLE IF NOT EXISTS `group` (
|
|||
`name` varchar(255) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY(`id`),
|
||||
INDEX `uid` (`uid`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE group_member
|
||||
|
@ -388,7 +388,7 @@ CREATE TABLE IF NOT EXISTS `group_member` (
|
|||
INDEX `contactid` (`contact-id`),
|
||||
INDEX `gid_contactid` (`gid`,`contact-id`),
|
||||
UNIQUE INDEX `uid_gid_contactid` (`uid`,`gid`,`contact-id`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE gserver
|
||||
|
@ -411,7 +411,7 @@ CREATE TABLE IF NOT EXISTS `gserver` (
|
|||
`last_failure` datetime DEFAULT '0001-01-01 00:00:00',
|
||||
PRIMARY KEY(`id`),
|
||||
INDEX `nurl` (`nurl`(32))
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE hook
|
||||
|
@ -424,7 +424,7 @@ CREATE TABLE IF NOT EXISTS `hook` (
|
|||
`priority` int(11) unsigned NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE INDEX `hook_file_function` (`hook`(50),`file`(80),`function`(60))
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE intro
|
||||
|
@ -442,7 +442,7 @@ CREATE TABLE IF NOT EXISTS `intro` (
|
|||
`blocked` tinyint(1) NOT NULL DEFAULT 1,
|
||||
`ignore` tinyint(1) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY(`id`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE item
|
||||
|
@ -539,7 +539,7 @@ CREATE TABLE IF NOT EXISTS `item` (
|
|||
INDEX `uid_eventid` (`uid`,`event-id`),
|
||||
INDEX `uid_authorlink` (`uid`,`author-link`),
|
||||
INDEX `uid_ownerlink` (`uid`,`owner-link`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE item_id
|
||||
|
@ -555,7 +555,7 @@ CREATE TABLE IF NOT EXISTS `item_id` (
|
|||
INDEX `sid` (`sid`),
|
||||
INDEX `service` (`service`(32)),
|
||||
INDEX `iid` (`iid`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE locks
|
||||
|
@ -566,7 +566,7 @@ CREATE TABLE IF NOT EXISTS `locks` (
|
|||
`locked` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`created` datetime DEFAULT '0001-01-01 00:00:00',
|
||||
PRIMARY KEY(`id`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE mail
|
||||
|
@ -594,7 +594,7 @@ CREATE TABLE IF NOT EXISTS `mail` (
|
|||
INDEX `convid` (`convid`),
|
||||
INDEX `uri` (`uri`(64)),
|
||||
INDEX `parent-uri` (`parent-uri`(64))
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE mailacct
|
||||
|
@ -614,7 +614,7 @@ CREATE TABLE IF NOT EXISTS `mailacct` (
|
|||
`pubmail` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
|
||||
PRIMARY KEY(`id`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE manage
|
||||
|
@ -625,7 +625,7 @@ CREATE TABLE IF NOT EXISTS `manage` (
|
|||
`mid` int(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE INDEX `uid_mid` (`uid`,`mid`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE notify
|
||||
|
@ -653,7 +653,7 @@ CREATE TABLE IF NOT EXISTS `notify` (
|
|||
INDEX `seen_uid_date` (`seen`,`uid`,`date`),
|
||||
INDEX `uid_date` (`uid`,`date`),
|
||||
INDEX `uid_type_link` (`uid`,`type`,`link`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE notify-threads
|
||||
|
@ -665,7 +665,7 @@ CREATE TABLE IF NOT EXISTS `notify-threads` (
|
|||
`parent-item` int(10) unsigned NOT NULL DEFAULT 0,
|
||||
`receiver-uid` int(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY(`id`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE oembed
|
||||
|
@ -676,7 +676,7 @@ CREATE TABLE IF NOT EXISTS `oembed` (
|
|||
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
|
||||
PRIMARY KEY(`url`),
|
||||
INDEX `created` (`created`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE parsed_url
|
||||
|
@ -689,7 +689,7 @@ CREATE TABLE IF NOT EXISTS `parsed_url` (
|
|||
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
|
||||
PRIMARY KEY(`url`,`guessing`,`oembed`),
|
||||
INDEX `created` (`created`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE pconfig
|
||||
|
@ -702,7 +702,7 @@ CREATE TABLE IF NOT EXISTS `pconfig` (
|
|||
`v` mediumtext,
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE photo
|
||||
|
@ -736,7 +736,7 @@ CREATE TABLE IF NOT EXISTS `photo` (
|
|||
INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
|
||||
INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`(64),`created`),
|
||||
INDEX `resource-id` (`resource-id`(64))
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE poll
|
||||
|
@ -756,7 +756,7 @@ CREATE TABLE IF NOT EXISTS `poll` (
|
|||
`q9` text,
|
||||
PRIMARY KEY(`id`),
|
||||
INDEX `uid` (`uid`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE poll_result
|
||||
|
@ -768,7 +768,7 @@ CREATE TABLE IF NOT EXISTS `poll_result` (
|
|||
PRIMARY KEY(`id`),
|
||||
INDEX `poll_id` (`poll_id`),
|
||||
INDEX `choice` (`choice`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE process
|
||||
|
@ -779,7 +779,7 @@ CREATE TABLE IF NOT EXISTS `process` (
|
|||
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
|
||||
PRIMARY KEY(`pid`),
|
||||
INDEX `command` (`command`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE profile
|
||||
|
@ -792,7 +792,7 @@ CREATE TABLE IF NOT EXISTS `profile` (
|
|||
`hide-friends` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`name` varchar(255) NOT NULL DEFAULT '',
|
||||
`pdesc` varchar(255) NOT NULL DEFAULT '',
|
||||
`dob` varchar(32) NOT NULL DEFAULT '0000-00-00',
|
||||
`dob` varchar(32) NOT NULL DEFAULT '0001-01-01',
|
||||
`address` varchar(255) NOT NULL DEFAULT '',
|
||||
`locality` varchar(255) NOT NULL DEFAULT '',
|
||||
`region` varchar(255) NOT NULL DEFAULT '',
|
||||
|
@ -829,7 +829,7 @@ CREATE TABLE IF NOT EXISTS `profile` (
|
|||
`net-publish` tinyint(1) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY(`id`),
|
||||
INDEX `uid_is-default` (`uid`,`is-default`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE profile_check
|
||||
|
@ -842,7 +842,7 @@ CREATE TABLE IF NOT EXISTS `profile_check` (
|
|||
`sec` varchar(255) NOT NULL DEFAULT '',
|
||||
`expire` int(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY(`id`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE push_subscriber
|
||||
|
@ -857,7 +857,7 @@ CREATE TABLE IF NOT EXISTS `push_subscriber` (
|
|||
`last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
|
||||
`secret` varchar(255) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY(`id`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE queue
|
||||
|
@ -876,7 +876,7 @@ CREATE TABLE IF NOT EXISTS `queue` (
|
|||
INDEX `last` (`last`),
|
||||
INDEX `network` (`network`),
|
||||
INDEX `batch` (`batch`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE register
|
||||
|
@ -890,7 +890,7 @@ CREATE TABLE IF NOT EXISTS `register` (
|
|||
`language` varchar(16) NOT NULL DEFAULT '',
|
||||
`note` text,
|
||||
PRIMARY KEY(`id`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE search
|
||||
|
@ -901,7 +901,7 @@ CREATE TABLE IF NOT EXISTS `search` (
|
|||
`term` varchar(255) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY(`id`),
|
||||
INDEX `uid` (`uid`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE session
|
||||
|
@ -914,7 +914,7 @@ CREATE TABLE IF NOT EXISTS `session` (
|
|||
PRIMARY KEY(`id`),
|
||||
INDEX `sid` (`sid`(64)),
|
||||
INDEX `expire` (`expire`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE sign
|
||||
|
@ -927,7 +927,7 @@ CREATE TABLE IF NOT EXISTS `sign` (
|
|||
`signer` varchar(255) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY(`id`),
|
||||
INDEX `iid` (`iid`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE spam
|
||||
|
@ -944,7 +944,7 @@ CREATE TABLE IF NOT EXISTS `spam` (
|
|||
INDEX `spam` (`spam`),
|
||||
INDEX `ham` (`ham`),
|
||||
INDEX `term` (`term`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE term
|
||||
|
@ -967,7 +967,7 @@ CREATE TABLE IF NOT EXISTS `term` (
|
|||
INDEX `uid_otype_type_term_global_created` (`uid`,`otype`,`type`,`term`(32),`global`,`created`),
|
||||
INDEX `uid_otype_type_url` (`uid`,`otype`,`type`,`url`(64)),
|
||||
INDEX `guid` (`guid`(64))
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE thread
|
||||
|
@ -1007,7 +1007,7 @@ CREATE TABLE IF NOT EXISTS `thread` (
|
|||
INDEX `uid_created` (`uid`,`created`),
|
||||
INDEX `uid_commented` (`uid`,`commented`),
|
||||
INDEX `uid_wall_created` (`uid`,`wall`,`created`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE tokens
|
||||
|
@ -1020,7 +1020,7 @@ CREATE TABLE IF NOT EXISTS `tokens` (
|
|||
`scope` varchar(200) NOT NULL DEFAULT '',
|
||||
`uid` int(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY(`id`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE user
|
||||
|
@ -1071,7 +1071,7 @@ CREATE TABLE IF NOT EXISTS `user` (
|
|||
`openidserver` text,
|
||||
PRIMARY KEY(`uid`),
|
||||
INDEX `nickname` (`nickname`(32))
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE userd
|
||||
|
@ -1081,7 +1081,7 @@ CREATE TABLE IF NOT EXISTS `userd` (
|
|||
`username` varchar(255) NOT NULL,
|
||||
PRIMARY KEY(`id`),
|
||||
INDEX `username` (`username`(32))
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE workerqueue
|
||||
|
@ -1094,5 +1094,5 @@ CREATE TABLE IF NOT EXISTS `workerqueue` (
|
|||
`pid` int(11) NOT NULL DEFAULT 0,
|
||||
`executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
|
||||
PRIMARY KEY(`id`)
|
||||
) DEFAULT CHARSET=utf8mb4;
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
|
|
10
doc/KeyboardShortcuts.md
Normal file
10
doc/KeyboardShortcuts.md
Normal file
|
@ -0,0 +1,10 @@
|
|||
Keyboard shortcuts in Friendica
|
||||
=======================
|
||||
|
||||
* [Home](help)
|
||||
|
||||
General
|
||||
-------
|
||||
|
||||
* j: Scroll to next thread
|
||||
* k: Scroll to previous thread
|
|
@ -6,12 +6,10 @@ If you are the admin of a Friendica node, you have access to the so called **Adm
|
|||
|
||||
On the front page of the admin panel you will see a summary of information about your node.
|
||||
These information include the amount of messages currently being processed in the queues.
|
||||
The first number is the number of messages being actively sent.
|
||||
This number should decrease quickly.
|
||||
The second is the messages which could for various reasons not being delivered.
|
||||
The first number is the number of messages which could not been delivered for various reasons.
|
||||
They will be resend later.
|
||||
You can have a quick glance into that second queus in the "Inspect Queue" section of the admin panel.
|
||||
If you have activated the background workers, there is a third number representing the count of jobs queued for the workers.
|
||||
The second number represents the current number of jobs for the background workers.
|
||||
These worker tasks are prioritised and are done accordingly.
|
||||
|
||||
Then you get an overview of the accounts on your node, which can be moderated in the "Users" section of the panel.
|
||||
|
@ -135,6 +133,9 @@ By default, any (valid) email address is allowed in registrations.
|
|||
If you enable the `Allow Users to set remote_self` users can select Atom feeds from their contact list being their *remote self* in die advanced contact settings.
|
||||
Which means that postings by the remote self are automatically reposted by Friendica in their names.
|
||||
|
||||
This feature can be used to let the user mirror e.g. blog postings into their Friendica postings.
|
||||
It is disabled by default, as it causes additional load on the server and may be misused to distribute SPAM.
|
||||
|
||||
As admin of the node you can also set this flag directly in the database.
|
||||
Before doing so, you should be sure you know what you do and have a backup of the database.
|
||||
|
||||
|
@ -169,6 +170,19 @@ This will mean you cannot connect (at all) to self-signed SSL sites.
|
|||
|
||||
### Worker
|
||||
|
||||
This section allows you to configure the background process that is triggered by the `cron` job that was created during the installation.
|
||||
The process does check the available system resources before creating a new worker for a task.
|
||||
Because of this, it may happen that the maximum number of worker processes you allow will not be reached.
|
||||
|
||||
If your server setup does not allow you to use the `proc_open` function of PHP, please disable it in this section.
|
||||
|
||||
The tasks for the background process have priorities.
|
||||
To guarantee that important tasks are executed even though the system has a lot of work to do, it is useful to enable the *fastlane*.
|
||||
|
||||
Should you not be able to run a cron job on your server, you can also activate the *frontend* worker.
|
||||
If you have done so, you can call `example.com/worker` (replace example.com with your actual domain name) on a regular basis from an external servie.
|
||||
This will then trigger the execution of the background process.
|
||||
|
||||
### Relocate
|
||||
|
||||
## Users
|
||||
|
|
|
@ -14,7 +14,6 @@ Database Tables
|
|||
| [config](help/database/db_config) | main configuration storage |
|
||||
| [contact](help/database/db_contact) | contact table |
|
||||
| [conv](help/database/db_conv) | private messages |
|
||||
| [deliverq](help/database/db_deliverq) | |
|
||||
| [event](help/database/db_event) | Events |
|
||||
| [fcontact](help/database/db_fcontact) | friend suggestion stuff |
|
||||
| [ffinder](help/database/db_ffinder) | friend suggestion stuff |
|
||||
|
|
|
@ -10,8 +10,8 @@ Table attach
|
|||
| filetype | mimetype | varchar(64) | NO | | | |
|
||||
| filesize | size in bytes | int(11) | NO | | 0 | |
|
||||
| data | file data | longblob | NO | | NULL | |
|
||||
| created | creation time | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| edited | last edit time | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| created | creation time | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| edited | last edit time | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| allow_cid | Access Control - list of allowed contact.id '<19><78> | mediumtext | NO | | NULL | |
|
||||
| allow_gid | Access Control - list of allowed groups | mediumtext | NO | | NULL | |
|
||||
| deny_cid | Access Control - list of denied contact.id | mediumtext | NO | | NULL | |
|
||||
|
|
|
@ -5,7 +5,7 @@ Table cache
|
|||
| ------------ | ---------------------------------- | ------------ | ---- | --- | ------------------- | ----- |
|
||||
| k | horizontal width + url or resource | varchar(255) | NO | PRI | NULL | |
|
||||
| v | OEmbed response from site | text | NO | | NULL | |
|
||||
| updated | datetime of cache insertion | datetime | NO | MUL | 0000-00-00 00:00:00 | |
|
||||
| updated | datetime of cache insertion | datetime | NO | MUL | 0001-01-01 00:00:00 | |
|
||||
| expire_mode | | int(11) | NO | | 0 | |
|
||||
|
||||
Return to [database documentation](help/database)
|
||||
|
|
|
@ -5,7 +5,7 @@ Table contact
|
|||
|---------------------------|-----------------------------------------------------------|--------------|------|-----|---------------------|----------------|
|
||||
| id | sequential ID | int(11) | NO | PRI | NULL | auto_increment |
|
||||
| uid | user.id of the owner of this data | int(11) | NO | MUL | 0 | |
|
||||
| created | | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| created | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| self | 1 if the contact is the user him/her self | tinyint(1) | NO | | 0 | |
|
||||
| remote_self | | tinyint(1) | NO | | 0 | |
|
||||
| rel | The kind of the relation between the user and the contact | tinyint(1) | NO | | 0 | |
|
||||
|
@ -41,14 +41,14 @@ Table contact
|
|||
| usehub | | tinyint(1) | NO | | 0 | |
|
||||
| subhub | | tinyint(1) | NO | | 0 | |
|
||||
| hub-verify | | varchar(255) | NO | | | |
|
||||
| last-update | Date of the last try to update the contact info | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| success_update | Date of the last successful contact update | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| failure_update | Date of the last failed update | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| name-date | | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| uri-date | | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| avatar-date | | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| term-date | | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| last-item | date of the last post | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| last-update | Date of the last try to update the contact info | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| success_update | Date of the last successful contact update | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| failure_update | Date of the last failed update | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| name-date | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| uri-date | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| avatar-date | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| term-date | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| last-item | date of the last post | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| priority | | tinyint(3) | NO | | 0 | |
|
||||
| blocked | | tinyint(1) | NO | | 1 | |
|
||||
| readonly | posts of the contact are readonly | tinyint(1) | NO | | 0 | |
|
||||
|
@ -64,7 +64,7 @@ Table contact
|
|||
| info | | mediumtext | NO | | NULL | |
|
||||
| profile-id | | int(11) | NO | | 0 | |
|
||||
| bdyear | | varchar(4) | NO | | | |
|
||||
| bd | | date | NO | | 0000-00-00 | |
|
||||
| bd | | date | NO | | 0001-01-01 | |
|
||||
| notify_new_posts | | tinyint(1) | NO | | 0 | |
|
||||
| fetch_further_information | | tinyint(1) | NO | | 0 | |
|
||||
| ffi_keyword_blacklist | | mediumtext | NO | | NULL | |
|
||||
|
|
|
@ -8,8 +8,8 @@ Table conv
|
|||
| recips | sender_handle;recipient_handle | mediumtext | NO | | NULL | |
|
||||
| uid | user_id of the owner of this data | int(11) | NO | MUL | 0 | |
|
||||
| creator | handle of creator | varchar(255) | NO | | | |
|
||||
| created | creation timestamp | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| updated | edited timestamp | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| created | creation timestamp | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| updated | edited timestamp | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| subject | subject of initial message | mediumtext | NO | | NULL | |
|
||||
|
||||
Return to [database documentation](help/database)
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
Table deliverq
|
||||
==============
|
||||
|
||||
| Field | Description | Type | Null | Key | Default | Extra |
|
||||
|---------|------------------|------------------|------|-----|---------|----------------|
|
||||
| id | sequential ID | int(10) unsigned | NO | PRI | NULL | auto_increment |
|
||||
| cmd | | varchar(32) | NO | | | |
|
||||
| item | | int(11) | NO | | 0 | |
|
||||
| contact | | int(11) | NO | | 0 | |
|
||||
|
||||
|
||||
Return to [database documentation](help/database)
|
|
@ -7,10 +7,10 @@ Table event
|
|||
| uid | user_id of the owner of this data | int(11) | NO | MUL | 0 | |
|
||||
| cid | contact_id (ID of the contact in contact table) | int(11) | NO | | 0 | |
|
||||
| uri | | varchar(255) | NO | | | |
|
||||
| created | creation time | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| edited | last edit time | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| start | event start time | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| finish | event end time | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| created | creation time | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| edited | last edit time | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| start | event start time | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| finish | event end time | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| summary | short description or title of the event | text | NO | | NULL | |
|
||||
| desc | event description | text | NO | | NULL | |
|
||||
| location | event location | text | NO | | NULL | |
|
||||
|
|
|
@ -19,6 +19,6 @@ Table fcontact
|
|||
| network | | varchar(32) | NO | | | |
|
||||
| alias | | varchar(255) | NO | | | |
|
||||
| pubkey | | text | NO | | NULL | |
|
||||
| updated | | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| updated | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
|
||||
Return to [database documentation](help/database)
|
||||
|
|
|
@ -11,6 +11,6 @@ Table fsuggest
|
|||
| request | | varchar(255) | NO | | | |
|
||||
| photo | | varchar(255) | NO | | | |
|
||||
| note | | text | NO | | NULL | |
|
||||
| created | | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| created | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
|
||||
Return to [database documentation](help/database)
|
||||
|
|
|
@ -10,15 +10,15 @@ Table gcontact
|
|||
| nurl | | varchar(255) | NO | MUL | | |
|
||||
| photo | Link to the profile photo | varchar(255) | NO | | | |
|
||||
| connect | | varchar(255) | NO | | | |
|
||||
| created | | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| updated | | datetime | YES | MUL | 0000-00-00 00:00:00 | |
|
||||
| last_contact | | datetime | YES | | 0000-00-00 00:00:00 | |
|
||||
| last_failure | | datetime | YES | | 0000-00-00 00:00:00 | |
|
||||
| created | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| updated | | datetime | YES | MUL | 0001-01-01 00:00:00 | |
|
||||
| last_contact | | datetime | YES | | 0001-01-01 00:00:00 | |
|
||||
| last_failure | | datetime | YES | | 0001-01-01 00:00:00 | |
|
||||
| location | | varchar(255) | NO | | | |
|
||||
| about | | text | NO | | NULL | |
|
||||
| keywords | puplic keywords (interests) | text | NO | | NULL | |
|
||||
| gender | | varchar(32) | NO | | | |
|
||||
| birthday | | varchar(32) | NO | | 0000-00-00 | |
|
||||
| birthday | | varchar(32) | NO | | 0001-01-01 | |
|
||||
| community | 1 if contact is forum account | tinyint(1) | NO | | 0 | |
|
||||
| hide | 1 = should be hidden from search | tinyint(1) | NO | | 0 | |
|
||||
| nsfw | 1 = contact posts nsfw content | tinyint(1) | NO | | 0 | |
|
||||
|
|
|
@ -8,6 +8,6 @@ Table glink
|
|||
| uid | | int(11) | NO | | 0 | |
|
||||
| gcid | | int(11) | NO | MUL | 0 | |
|
||||
| zcid | | int(11) | NO | MUL | 0 | |
|
||||
| updated | | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| updated | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
|
||||
Return to [database documentation](help/database)
|
||||
|
|
|
@ -14,10 +14,10 @@ Table gserver
|
|||
| noscrape | | varchar(255) | NO | | | |
|
||||
| network | | varchar(32) | NO | | | |
|
||||
| platform | | varchar(255) | NO | | | |
|
||||
| created | | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| last_poco_query | | datetime | YES | | 0000-00-00 00:00:00 | |
|
||||
| last_contact | | datetime | YES | | 0000-00-00 00:00:00 | |
|
||||
| last_failure | | datetime | YES | | 0000-00-00 00:00:00 | |
|
||||
| created | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| last_poco_query | | datetime | YES | | 0001-01-01 00:00:00 | |
|
||||
| last_contact | | datetime | YES | | 0001-01-01 00:00:00 | |
|
||||
| last_failure | | datetime | YES | | 0001-01-01 00:00:00 | |
|
||||
|
||||
|
||||
Return to [database documentation](help/database)
|
||||
|
|
|
@ -11,7 +11,7 @@ Table intro
|
|||
| duplex | | tinyint(1) | NO | | 0 | |
|
||||
| note | | text | NO | | NULL | |
|
||||
| hash | | varchar(255) | NO | | | |
|
||||
| datetime | | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| datetime | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| blocked | | tinyint(1) | NO | | 1 | |
|
||||
| ignore | | tinyint(1) | NO | | 0 | |
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@ Table item
|
|||
| parent-uri | uri of the parent to this item | varchar(255) | NO | MUL | | |
|
||||
| extid | | varchar(255 | NO | MUL | | |
|
||||
| thr-parent | If the parent of this item is not the top-level item in the conversation, the uri of the immediate parent; otherwise set to parent-uri | varchar(255) | NO | | | |
|
||||
| created | Creation timestamp. | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| edited | Date of last edit (default is created) | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| commented | Date of last comment/reply to this item | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| received | datetime | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| changed | Date that something in the conversation changed, indicating clients should fetch the conversation again | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| created | Creation timestamp. | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| edited | Date of last edit (default is created) | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| commented | Date of last comment/reply to this item | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| received | datetime | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| changed | Date that something in the conversation changed, indicating clients should fetch the conversation again | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| owner-name | Name of the owner of this item | varchar(255) | NO | | | |
|
||||
| owner-link | Link to the profile page of the owner of this item | varchar(255) | NO | | | |
|
||||
| owner-avatar | Link to the avatar picture of the owner of this item | varchar(255) | NO | | | |
|
||||
|
|
|
@ -6,6 +6,6 @@ Table locks
|
|||
| id | sequential ID | int(11) | NO | PRI | NULL | auto_increment |
|
||||
| name | | varchar(128) | NO | | | |
|
||||
| locked | | tinyint(1) | NO | | 0 | |
|
||||
| created | | datetime | YES | | 0000-00-00 00:00:00 | |
|
||||
| created | | datetime | YES | | 0001-01-01 00:00:00 | |
|
||||
|
||||
Return to [database documentation](help/database)
|
||||
|
|
|
@ -19,6 +19,6 @@ Table mail
|
|||
| unknown | if sender not in the contact table this is 1 | varchar(255) | NO | | 0 | |
|
||||
| uri | | varchar(255) | NO | MUL | | |
|
||||
| parent-uri | | varchar(255) | NO | MUL | | |
|
||||
| created | creation time of the private message | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| created | creation time of the private message | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
|
||||
Return to [database documentation](help/database)
|
||||
|
|
|
@ -15,6 +15,6 @@ Table mailacct
|
|||
| action | | int(11) | NO | | 0 | |
|
||||
| movetofolder | | varchar(255) | NO | | | |
|
||||
| pubmail | | tinyint(1) | NO | | 0 | |
|
||||
| last_check | | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| last_check | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
|
||||
Return to [database documentation](help/database)
|
||||
|
|
|
@ -9,7 +9,7 @@ Table notify
|
|||
| name | | varchar(255) | NO | | | |
|
||||
| url | | varchar(255) | NO | | | |
|
||||
| photo | | varchar(255) | NO | | | |
|
||||
| date | | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| date | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| msg | | mediumtext | YES | | NULL | |
|
||||
| uid | user.id of the owner of this data | int(11) | NO | MUL | 0 | |
|
||||
| link | | varchar(255) | NO | | | |
|
||||
|
|
|
@ -5,6 +5,6 @@ Table oembed
|
|||
| ------------ | ---------------------------------- | ------------ | ---- | --- | ------------------- | ----- |
|
||||
| url | page url | varchar(255) | NO | PRI | NULL | |
|
||||
| content | OEmbed data of the page | text | NO | | NULL | |
|
||||
| created | datetime of creation | datetime | NO | MUL | 0000-00-00 00:00:00 | |
|
||||
| created | datetime of creation | datetime | NO | MUL | 0001-01-01 00:00:00 | |
|
||||
|
||||
Return to [database documentation](help/database)
|
||||
|
|
|
@ -7,6 +7,6 @@ Table parsed_url
|
|||
| guessing | is the "guessing" mode active? | tinyint(1) | NO | PRI | 0 | |
|
||||
| oembed | is the data the result of oembed? | tinyint(1) | NO | PRI | 0 | |
|
||||
| content | page data | text | NO | | NULL | |
|
||||
| created | datetime of creation | datetime | NO | MUL | 0000-00-00 00:00:00 | |
|
||||
| created | datetime of creation | datetime | NO | MUL | 0001-01-01 00:00:00 | |
|
||||
|
||||
Return to [database documentation](help/database)
|
||||
|
|
|
@ -8,8 +8,8 @@ Table photo
|
|||
| contact-id | contact.id | int(10) unsigned | NO | | 0 | |
|
||||
| guid | A unique identifier for this photo | varchar(64) | NO | MUL | | |
|
||||
| resource-id | | varchar(255) | NO | MUL | | |
|
||||
| created | creation date | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| edited | last edited date | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| created | creation date | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| edited | last edited date | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| title | | varchar(255) | NO | | | |
|
||||
| desc | | text | NO | | NULL | |
|
||||
| album | The name of the album to which the photo belongs | varchar(255) | NO | | | |
|
||||
|
|
|
@ -10,7 +10,7 @@ Table profile
|
|||
| hide-friends | Hide friend list from viewers of this profile | tinyint(1) | NO | | 0 | |
|
||||
| name | | varchar(255) | NO | | | |
|
||||
| pdesc | Title or description | varchar(255) | NO | | | |
|
||||
| dob | Day of birth | varchar(32) | NO | | 0000-00-00 | |
|
||||
| dob | Day of birth | varchar(32) | NO | | 0001-01-01 | |
|
||||
| address | | varchar(255) | NO | | | |
|
||||
| locality | | varchar(255) | NO | | | |
|
||||
| region | | varchar(255) | NO | | | |
|
||||
|
@ -20,7 +20,7 @@ Table profile
|
|||
| gender | | varchar(32) | NO | | | |
|
||||
| marital | | varchar(255) | NO | | | |
|
||||
| with | | text | NO | | NULL | |
|
||||
| howlong | | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| howlong | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| sexual | | varchar(255) | NO | | | |
|
||||
| politic | | varchar(255) | NO | | | |
|
||||
| religion | | varchar(255) | NO | | | |
|
||||
|
|
|
@ -6,8 +6,8 @@ Table queue
|
|||
| id | sequential ID | int(11) | NO | PRI | NULL | auto_increment |
|
||||
| cid | | int(11) | NO | MUL | 0 | |
|
||||
| network | | varchar(32) | NO | MUL | | |
|
||||
| created | | datetime | NO | MUL | 0000-00-00 00:00:00 | |
|
||||
| last | | datetime | NO | MUL | 0000-00-00 00:00:00 | |
|
||||
| created | | datetime | NO | MUL | 0001-01-01 00:00:00 | |
|
||||
| last | | datetime | NO | MUL | 0001-01-01 00:00:00 | |
|
||||
| content | | mediumtext | NO | | NULL | |
|
||||
| batch | | tinyint(1) | NO | MUL | 0 | |
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ Table register
|
|||
| -------- | ------------- | ---------------- | ---- | --- | ------------------- | --------------- |
|
||||
| id | sequential ID | int(11) unsigned | NO | PRI | NULL | auto_increment |
|
||||
| hash | | varchar(255) | NO | | | |
|
||||
| created | | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| created | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| uid | user.id | int(11) unsigned | NO | | | |
|
||||
| password | | varchar(255) | NO | | | |
|
||||
| language | | varchar(16) | NO | | | |
|
||||
|
|
|
@ -8,6 +8,6 @@ Table spam
|
|||
| spam | | int(11) | NO | MUL | 0 | |
|
||||
| ham | | int(11) | NO | MUL | 0 | |
|
||||
| term | | varchar(255) | NO | MUL | | |
|
||||
| date | | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| date | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
|
||||
Return to [database documentation](help/database)
|
||||
|
|
|
@ -12,8 +12,8 @@ Table term
|
|||
| aid | | int(10) unsigned | NO | | 0 | |
|
||||
| uid | | int(10) unsigned | NO | MUL | 0 | |
|
||||
| guid | | varchar(255) | NO | MUL | | |
|
||||
| created | | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| received | | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| created | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| received | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| global | | tinyint(1) | NO | | 0 | |
|
||||
|
||||
Return to [database documentation](help/database)
|
||||
|
|
|
@ -9,11 +9,11 @@ Table thread
|
|||
| gcontact-id | Global Contact | int(11) unsigned | NO | | 0 | |
|
||||
| owner-id | Item owner | int(11) unsigned | NO | MUL | 0 | |
|
||||
| author-id | Item author | int(11) unsigned | NO | MUL | 0 | |
|
||||
| created | | datetime | NO | MUL | 0000-00-00 00:00:00 | |
|
||||
| edited | | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| commented | | datetime | NO | MUL | 0000-00-00 00:00:00 | |
|
||||
| received | | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| changed | | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| created | | datetime | NO | MUL | 0001-01-01 00:00:00 | |
|
||||
| edited | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| commented | | datetime | NO | MUL | 0001-01-01 00:00:00 | |
|
||||
| received | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| changed | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| wall | | tinyint(1) | NO | MUL | 0 | |
|
||||
| private | | tinyint(1) | NO | | 0 | |
|
||||
| pubmail | | tinyint(1) | NO | | 0 | |
|
||||
|
|
|
@ -12,8 +12,8 @@ Table user
|
|||
| openid | | varchar(255) | NO | | | |
|
||||
| timezone | PHP-legal timezone | varchar(128) | NO | | | |
|
||||
| language | default language | varchar(32) | NO | | en | |
|
||||
| register_date | timestamp of registration | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| login_date | timestamp of last login | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| register_date | timestamp of registration | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| login_date | timestamp of last login | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| default-location | Default for item.location | varchar(255) | NO | | | |
|
||||
| allow_location | 1 allows to display the location | tinyint(1) | NO | | 0 | |
|
||||
| theme | user theme preference | varchar(255) | NO | | | |
|
||||
|
@ -36,8 +36,8 @@ Table user
|
|||
| expire | | int(11) unsigned | NO | | 0 | |
|
||||
| account_removed | if 1 the account is removed | tinyint(1) | NO | | 0 | |
|
||||
| account_expired | | tinyint(1) | NO | | 0 | |
|
||||
| account_expires_on | timestamp when account expires and will be deleted | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| expire_notification_sent | timestamp of last warning of account expiration | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| account_expires_on | timestamp when account expires and will be deleted | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| expire_notification_sent | timestamp of last warning of account expiration | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| service_class | service class for this account, determines what if any limits/restrictions are in place | varchar(32) | NO | | | |
|
||||
| def_gid | | int(11) | NO | | 0 | |
|
||||
| allow_cid | default permission for this user | mediumtext | NO | | NULL | |
|
||||
|
|
|
@ -6,8 +6,8 @@ Table workerqueue
|
|||
| id | sequential ID | int(11) | NO | PRI | NULL | auto_increment |
|
||||
| parameter | | text | NO | | NULL | |
|
||||
| priority | | tinyint(3) unsigned | NO | | 0 | |
|
||||
| created | | datetime | NO | MUL | 0000-00-00 00:00:00 | |
|
||||
| created | | datetime | NO | MUL | 0001-01-01 00:00:00 | |
|
||||
| pid | | int(11) | NO | | 0 | |
|
||||
| executed | | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||
| executed | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
|
||||
Return to [database documentation](help/database)
|
||||
|
|
|
@ -5,14 +5,11 @@
|
|||
Wenn du der Administrator einer Friendica Instanz bist, hast du Zugriff auf das so genannte **Admin Panel** in dem du die Friendica Instanz konfigurieren kannst,
|
||||
|
||||
Auf der Startseite des Admin Panels werden die Informationen zu der Instanz zusammengefasst.
|
||||
Diese Informationen beinhalten die Anzahl der Nachrichten, die sich aktuell in den Warteschlangen befinden.
|
||||
Hierbei ist die erste Zahl die Zahl der Nachrichten die gerade aktiv verteilt werden.
|
||||
Diese Zahl sollte sich relativ schnell sinken.
|
||||
Die zweite Zahl gibt die Anzahl von Nachrichten an, die nicht zugestellt werden konnten.
|
||||
Die erste Zahl gibt die Anzahl von Nachrichten an, die nicht zugestellt werden konnten.
|
||||
Die Zustellung wird zu einem späteren Zeitpunkt noch einmal versucht.
|
||||
Unter dem Punkt "Warteschlange Inspizieren" kannst du einen schnellen Blick auf die zweite Warteschlange werfen.
|
||||
Solltest du für die Hintergrundprozesse die Worker aktiviert haben, wird eine dritte Zahl angezeigt.
|
||||
Diese repräsentiert die Anzahl der Aufgaben, die die Worker noch vor sich haben.
|
||||
Die zweite Zahl steht für die Anzahl der Aufgaben, die die Worker noch vor sich haben.
|
||||
Die Worker arbeiten Hintergrundprozesse ab.
|
||||
Die Aufgaben der Worker sind priorisiert und werden anhand dieser Prioritäten abgearbeitet.
|
||||
|
||||
Desweiteren findest du eine Übersicht über die Accounts auf dem Friendica Knoten, die unter dem Punkt "Nutzer" moderiert werden können.
|
||||
|
@ -129,6 +126,10 @@ Wildcards werden akzeptiert (Wildcard-Unterstützung unter Windows benötigt PHP
|
|||
Webb du die Option `Nutzern erlauben das remote_self Flag zu setzen` aktivierst, können alle Nutzer Atom Feeds in den erweiterten Einstellungen des Kontakts als "Entferntes Konto" markieren.
|
||||
Dadurch werden automatisch alle Beiträge dieser Feeds für diesen Nutzer gespiegelt und an die Kontakte bei Friendica verteilt.
|
||||
|
||||
Dieses Feature kann z.B. dafür genutzt werden Blogbeiträge zu spiegeln.
|
||||
In der Grundeinstellung ist es nicht aktiviert, da es zusätzliche Last auf dem Server verursachen kann.
|
||||
Außerdem könnte es durch Nutzer als Spam Verteiler missbraucht werden.
|
||||
|
||||
Als Administrator der Friendica Instanz kannst du diese Einstellungen ansonsten nur direkt in der Datenbank vornehmen.
|
||||
Bevor du das tust solltest du sicherstellen, dass du ein Backup der Datenbank hast und genau weißt was die Änderungen an der Datenbank bewirken, die du vornehmen willst.
|
||||
|
||||
|
@ -165,6 +166,19 @@ Das führt dazu, dass du keinerlei Verbindung zu einer selbst unterzeichneten SS
|
|||
|
||||
### Worker
|
||||
|
||||
In diesem Abschnitt kann der Hintergrund-Prozess konfiguriert werden.
|
||||
Bevor ein neuer *Worker* Prozess gestartet wird, überprüft das System, dass die vorhandenen Resourchen ausrechend sind,
|
||||
Aus diesem Grund kann es sein, dass die maximale Zahl der Hintergrungprozesse nicht erreicht wird.
|
||||
|
||||
Sollte die PHP Funktion `proc_open` auf dem Server nicht verfügbar sein, kann die Verwendung durch Friendica hier unterbunden werden.
|
||||
|
||||
Die Aufgaben die im Hintergrund erledigt werden, haben Prioritäten zugeteilt.
|
||||
Um garantieren zu können, das wichtige Prozesse schnellst möglich abgearbeitet werden können, selbst wenn das System gerade stark belastet ist, sollte die *fastlane* aktiviert sein.
|
||||
|
||||
Wenn es auf deinem Server nicht möglich ist, einen cron Job zu starten, kannst du den *frontend* Worker einschalten.
|
||||
Nachdem dies geschehen ist, kannst du `example.com/worker` (tausche example.com mit dem echten Domainnamen aus) aufrufen werden.
|
||||
Dadurch werden dann die Aufgaben aktiviert, die der cron Job sonst aktivieren würde.
|
||||
|
||||
### Umsiedeln
|
||||
|
||||
## Nutzer
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -16,7 +16,7 @@ $db_user = 'mysqlusername';
|
|||
$db_pass = 'mysqlpassword';
|
||||
$db_data = 'mysqldatabasename';
|
||||
|
||||
// Set the database connection charset to UTF8.
|
||||
// Set the database connection charset to full Unicode (utf8mb4).
|
||||
// Changing this value will likely corrupt the special characters.
|
||||
// You have been warned.
|
||||
$a->config['system']['db_charset'] = "utf8mb4";
|
||||
|
@ -87,7 +87,7 @@ $a->config['system']['no_regfullname'] = true;
|
|||
//$a->config['system']['block_local_dir'] = false;
|
||||
|
||||
// Location of the global directory
|
||||
$a->config['system']['directory'] = 'http://dir.friendi.ca';
|
||||
$a->config['system']['directory'] = 'https://dir.friendica.social';
|
||||
|
||||
// Allowed protocols in link URLs; HTTP protocols always are accepted
|
||||
$a->config['system']['allowed_link_protocols'] = array('ftp', 'ftps', 'mailto', 'cid', 'gopher');
|
||||
|
|
|
@ -212,6 +212,10 @@ function unmark_for_death($contact) {
|
|||
function get_contact_details_by_url($url, $uid = -1, $default = array()) {
|
||||
static $cache = array();
|
||||
|
||||
if ($url == '') {
|
||||
return $default;
|
||||
}
|
||||
|
||||
if ($uid == -1) {
|
||||
$uid = local_user();
|
||||
}
|
||||
|
@ -254,7 +258,7 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
|
|||
|
||||
// "bd" always contains the upcoming birthday of a contact.
|
||||
// "birthday" might contain the birthday including the year of birth.
|
||||
if ($profile["birthday"] != "0000-00-00") {
|
||||
if ($profile["birthday"] > '0001-01-01') {
|
||||
$bd_timestamp = strtotime($profile["birthday"]);
|
||||
$month = date("m", $bd_timestamp);
|
||||
$day = date("d", $bd_timestamp);
|
||||
|
@ -271,7 +275,7 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
|
|||
$profile["bd"] = (++$current_year)."-".$month."-".$day;
|
||||
}
|
||||
} else {
|
||||
$profile["bd"] = "0000-00-00";
|
||||
$profile["bd"] = '0001-01-01';
|
||||
}
|
||||
} else {
|
||||
$profile = $default;
|
||||
|
@ -307,7 +311,7 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
|
|||
$profile["location"] = "";
|
||||
$profile["about"] = "";
|
||||
$profile["gender"] = "";
|
||||
$profile["birthday"] = "0000-00-00";
|
||||
$profile["birthday"] = '0001-01-01';
|
||||
}
|
||||
|
||||
$cache[$url][$uid] = $profile;
|
||||
|
@ -328,6 +332,10 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
|
|||
function get_contact_details_by_addr($addr, $uid = -1) {
|
||||
static $cache = array();
|
||||
|
||||
if ($addr == '') {
|
||||
return array();
|
||||
}
|
||||
|
||||
if ($uid == -1) {
|
||||
$uid = local_user();
|
||||
}
|
||||
|
@ -534,6 +542,10 @@ function get_contact($url, $uid = 0, $no_update = false) {
|
|||
$data = array();
|
||||
$contact_id = 0;
|
||||
|
||||
if ($url == '') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// We first try the nurl (http://server.tld/nick), most common case
|
||||
$contacts = q("SELECT `id`, `avatar-date` FROM `contact`
|
||||
WHERE `nurl` = '%s'
|
||||
|
|
|
@ -364,9 +364,9 @@ class Probe {
|
|||
return self::mail($uri, $uid);
|
||||
}
|
||||
|
||||
if ($network == NETWORK_MAIL)
|
||||
if ($network == NETWORK_MAIL) {
|
||||
return self::mail($uri, $uid);
|
||||
|
||||
}
|
||||
// Remove "acct:" from the URI
|
||||
$uri = str_replace('acct:', '', $uri);
|
||||
|
||||
|
@ -391,37 +391,37 @@ class Probe {
|
|||
/// @todo Do we need the prefix "acct:" or "acct://"?
|
||||
|
||||
foreach ($lrdd AS $key => $link) {
|
||||
if ($webfinger)
|
||||
if ($webfinger) {
|
||||
continue;
|
||||
}
|
||||
if (!in_array($key, array("lrdd", "lrdd-xml", "lrdd-json"))) {
|
||||
continue;
|
||||
}
|
||||
// At first try it with the given uri
|
||||
$path = str_replace('{uri}', urlencode($uri), $link);
|
||||
$webfinger = self::webfinger($path);
|
||||
|
||||
if (!in_array($key, array("lrdd", "lrdd-xml", "lrdd-json")))
|
||||
continue;
|
||||
// We cannot be sure that the detected address was correct, so we don't use the values
|
||||
if ($webfinger AND ($uri != $addr)) {
|
||||
$nick = "";
|
||||
$addr = "";
|
||||
}
|
||||
|
||||
// Try webfinger with the address (user@domain.tld)
|
||||
if (!$webfinger) {
|
||||
$path = str_replace('{uri}', urlencode($addr), $link);
|
||||
$webfinger = self::webfinger($path);
|
||||
}
|
||||
|
||||
// Mastodon needs to have it with "acct:"
|
||||
if (!$webfinger) {
|
||||
$path = str_replace('{uri}', urlencode("acct:".$addr), $link);
|
||||
$webfinger = self::webfinger($path);
|
||||
}
|
||||
|
||||
// If webfinger wasn't successful then try it with the URL - possibly in the format https://...
|
||||
if (!$webfinger AND ($uri != $addr)) {
|
||||
$path = str_replace('{uri}', urlencode($uri), $link);
|
||||
$webfinger = self::webfinger($path);
|
||||
|
||||
// Since the detection with the address wasn't successful, we delete it.
|
||||
if ($webfinger) {
|
||||
$nick = "";
|
||||
$addr = "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (!$webfinger)
|
||||
if (!$webfinger) {
|
||||
return self::feed($uri);
|
||||
}
|
||||
|
||||
$result = false;
|
||||
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
* @file include/acl_selectors.php
|
||||
*/
|
||||
|
||||
require_once("include/contact_selectors.php");
|
||||
require_once("include/contact_widgets.php");
|
||||
require_once("include/DirSearch.php");
|
||||
require_once("include/features.php");
|
||||
require_once("mod/proxy.php");
|
||||
require_once "include/contact_selectors.php";
|
||||
require_once "include/contact_widgets.php";
|
||||
require_once "include/DirSearch.php";
|
||||
require_once "include/features.php";
|
||||
require_once "mod/proxy.php";
|
||||
|
||||
|
||||
/**
|
||||
|
@ -35,10 +35,11 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
|
|||
|
||||
if (dbm::is_result($r)) {
|
||||
foreach ($r as $rr) {
|
||||
if((is_array($preselected)) && in_array($rr['id'], $preselected))
|
||||
if ((is_array($preselected)) && in_array($rr['id'], $preselected)) {
|
||||
$selected = " selected=\"selected\" ";
|
||||
else
|
||||
} else {
|
||||
$selected = '';
|
||||
}
|
||||
|
||||
$trimmed = mb_substr($rr['name'],0,12);
|
||||
|
||||
|
@ -54,7 +55,8 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
|
|||
return $o;
|
||||
}
|
||||
|
||||
|
||||
/// @TODO after an optional parameter, no mandadory parameter can follow
|
||||
/// @TODO find proper type-hints
|
||||
function contact_selector($selname, $selclass, $preselected = false, $options) {
|
||||
|
||||
$a = get_app();
|
||||
|
@ -88,18 +90,20 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
|
|||
$networks = array(NETWORK_DFRN);
|
||||
break;
|
||||
case 'PRIVATE':
|
||||
if(is_array($a->user) && $a->user['prvnets'])
|
||||
if (is_array($a->user) && $a->user['prvnets']) {
|
||||
$networks = array(NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA);
|
||||
else
|
||||
} else {
|
||||
$networks = array(NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA);
|
||||
}
|
||||
break;
|
||||
case 'TWO_WAY':
|
||||
if(is_array($a->user) && $a->user['prvnets'])
|
||||
if (is_array($a->user) && $a->user['prvnets']) {
|
||||
$networks = array(NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA);
|
||||
else
|
||||
} else {
|
||||
$networks = array(NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA, NETWORK_OSTATUS);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
default: /// @TODO Maybe log this call?
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -113,26 +117,30 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
|
|||
|
||||
$sql_extra = '';
|
||||
|
||||
if($x['mutual']) {
|
||||
if (x($x, 'mutual')) {
|
||||
$sql_extra .= sprintf(" AND `rel` = %d ", intval(CONTACT_IS_FRIEND));
|
||||
}
|
||||
|
||||
if(intval($x['exclude']))
|
||||
if (x($x, 'exclude')) {
|
||||
$sql_extra .= sprintf(" AND `id` != %d ", intval($x['exclude']));
|
||||
}
|
||||
|
||||
if (is_array($x['networks']) && count($x['networks'])) {
|
||||
for($y = 0; $y < count($x['networks']) ; $y ++)
|
||||
/// @TODO rewrite to foreach()
|
||||
for ($y = 0; $y < count($x['networks']) ; $y ++) {
|
||||
$x['networks'][$y] = "'" . dbesc($x['networks'][$y]) . "'";
|
||||
}
|
||||
$str_nets = implode(',', $x['networks']);
|
||||
$sql_extra .= " AND `network` IN ( $str_nets ) ";
|
||||
}
|
||||
|
||||
$tabindex = (x($options, 'tabindex') ? "tabindex=\"" . $options["tabindex"] . "\"" : "");
|
||||
|
||||
if($x['single'])
|
||||
if ($x['single']) {
|
||||
$o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"" . $x['size'] . "\" $tabindex >\r\n";
|
||||
else
|
||||
} else {
|
||||
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"" . $x['size'] . "$\" $tabindex >\r\n";
|
||||
}
|
||||
|
||||
$r = q("SELECT `id`, `name`, `url`, `network` FROM `contact`
|
||||
WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
|
||||
|
@ -174,7 +182,7 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
|
|||
|
||||
function contact_select($selname, $selclass, $preselected = false, $size = 4, $privmail = false, $celeb = false, $privatenet = false, $tabindex = null) {
|
||||
|
||||
require_once("include/bbcode.php");
|
||||
require_once "include/bbcode.php";
|
||||
|
||||
$a = get_app();
|
||||
|
||||
|
@ -189,25 +197,28 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
|
|||
$sql_extra .= sprintf(" AND `rel` = %d ", intval(CONTACT_IS_FRIEND));
|
||||
}
|
||||
|
||||
if($privmail)
|
||||
if ($privmail) {
|
||||
$sql_extra .= sprintf(" AND `network` IN ('%s' , '%s') ",
|
||||
NETWORK_DFRN, NETWORK_DIASPORA);
|
||||
elseif($privatenet)
|
||||
} elseif ($privatenet) {
|
||||
$sql_extra .= sprintf(" AND `network` IN ('%s' , '%s', '%s', '%s') ",
|
||||
NETWORK_DFRN, NETWORK_MAIL, NETWORK_FACEBOOK, NETWORK_DIASPORA);
|
||||
}
|
||||
|
||||
$tabindex = ($tabindex > 0 ? "tabindex=\"$tabindex\"" : "");
|
||||
|
||||
if ($privmail AND $preselected) {
|
||||
$sql_extra .= " AND `id` IN (".implode(",", $preselected).")";
|
||||
$hidepreselected = ' style="display: none;"';
|
||||
} else
|
||||
} else {
|
||||
$hidepreselected = "";
|
||||
}
|
||||
|
||||
if($privmail)
|
||||
if ($privmail) {
|
||||
$o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"$size\" $tabindex $hidepreselected>\r\n";
|
||||
else
|
||||
} else {
|
||||
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" $tabindex >\r\n";
|
||||
}
|
||||
|
||||
$r = q("SELECT `id`, `name`, `url`, `network` FROM `contact`
|
||||
WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
|
||||
|
@ -229,8 +240,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
|
|||
foreach ($r as $rr) {
|
||||
if ((is_array($preselected)) && in_array($rr['id'], $preselected)) {
|
||||
$selected = " selected=\"selected\" ";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$selected = '';
|
||||
}
|
||||
|
||||
|
@ -249,8 +259,9 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
|
|||
|
||||
$o .= "</select>\r\n";
|
||||
|
||||
if ($privmail AND $preselected)
|
||||
if ($privmail AND $preselected) {
|
||||
$o .= implode(", ", $receiverlist);
|
||||
}
|
||||
|
||||
call_hooks($a->module . '_post_' . $selname, $o);
|
||||
|
||||
|
@ -330,10 +341,11 @@ function populate_acl($user = null, $show_jotnets = false) {
|
|||
);
|
||||
if (dbm::is_result($r)) {
|
||||
$mail_enabled = true;
|
||||
if(intval($r[0]['pubmail']))
|
||||
if (intval($r[0]['pubmail'])) {
|
||||
$pubmail_enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$user['hidewall']) {
|
||||
if ($mail_enabled) {
|
||||
|
@ -342,10 +354,11 @@ function populate_acl($user = null, $show_jotnets = false) {
|
|||
}
|
||||
|
||||
call_hooks('jot_networks', $jotnets);
|
||||
} else
|
||||
} else {
|
||||
$jotnets .= sprintf(t('Connectors disabled, since "%s" is enabled.'),
|
||||
t('Hide your profile details from unknown viewers?'));
|
||||
}
|
||||
}
|
||||
|
||||
$tpl = get_markup_template("acl_selector.tpl");
|
||||
$o = replace_macros($tpl, array(
|
||||
|
@ -363,7 +376,7 @@ function populate_acl($user = null, $show_jotnets = false) {
|
|||
'$aclModalTitle' => t('Permissions'),
|
||||
'$aclModalDismiss' => t('Close'),
|
||||
'$features' => array(
|
||||
"aclautomention"=>(feature_enabled($user['uid'],"aclautomention")?"true":"false")
|
||||
'aclautomention' => (feature_enabled($user['uid'], "aclautomention") ? "true" : "false")
|
||||
),
|
||||
));
|
||||
|
||||
|
@ -383,22 +396,24 @@ function construct_acl_data(App $a, $user) {
|
|||
foreach ($acl_data['groups'] as $key => $group) {
|
||||
// Add a "selected" flag to groups that are posted to by default
|
||||
if ($user_defaults['allow_gid'] &&
|
||||
in_array($group['id'], $user_defaults['allow_gid']) && !in_array($group['id'], $user_defaults['deny_gid']) )
|
||||
in_array($group['id'], $user_defaults['allow_gid']) && !in_array($group['id'], $user_defaults['deny_gid']) ) {
|
||||
$acl_data['groups'][$key]['selected'] = 1;
|
||||
else
|
||||
} else {
|
||||
$acl_data['groups'][$key]['selected'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($acl_data['contacts']) {
|
||||
foreach ($acl_data['contacts'] as $key => $contact) {
|
||||
// Add a "selected" flag to groups that are posted to by default
|
||||
if ($user_defaults['allow_cid'] &&
|
||||
in_array($contact['id'], $user_defaults['allow_cid']) && !in_array($contact['id'], $user_defaults['deny_cid']) )
|
||||
in_array($contact['id'], $user_defaults['allow_cid']) && !in_array($contact['id'], $user_defaults['deny_cid']) ) {
|
||||
$acl_data['contacts'][$key]['selected'] = 1;
|
||||
else
|
||||
} else {
|
||||
$acl_data['contacts'][$key]['selected'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $acl_data;
|
||||
|
||||
|
@ -420,8 +435,9 @@ function acl_lookup(App $a, $out_type = 'json') {
|
|||
// For use with jquery.textcomplete for private mail completion
|
||||
|
||||
if (x($_REQUEST, 'query') && strlen($_REQUEST['query'])) {
|
||||
if(! $type)
|
||||
if (! $type) {
|
||||
$type = 'm';
|
||||
}
|
||||
$search = $_REQUEST['query'];
|
||||
}
|
||||
|
||||
|
@ -431,6 +447,7 @@ function acl_lookup(App $a, $out_type = 'json') {
|
|||
$sql_extra = "AND `name` LIKE '%%".dbesc($search)."%%'";
|
||||
$sql_extra2 = "AND (`attag` LIKE '%%".dbesc($search)."%%' OR `name` LIKE '%%".dbesc($search)."%%' OR `nick` LIKE '%%".dbesc($search)."%%')";
|
||||
} else {
|
||||
/// @TODO Avoid these needless else blocks by putting variable-initialization atop of if()
|
||||
$sql_extra = $sql_extra2 = "";
|
||||
}
|
||||
|
||||
|
@ -446,8 +463,8 @@ function acl_lookup(App $a, $out_type = 'json') {
|
|||
|
||||
$sql_extra2 .= " ".unavailable_networks();
|
||||
|
||||
// autocomplete for editor mentions
|
||||
if ($type == '' || $type == 'c') {
|
||||
// autocomplete for editor mentions
|
||||
$r = q("SELECT COUNT(*) AS c FROM `contact`
|
||||
WHERE `uid` = %d AND NOT `self`
|
||||
AND NOT `blocked` AND NOT `pending` AND NOT `archive`
|
||||
|
@ -502,7 +519,7 @@ function acl_lookup(App $a, $out_type = 'json') {
|
|||
INNER JOIN `group_member` ON `group_member`.`gid`=`group`.`id` AND `group_member`.`uid` = `group`.`uid`
|
||||
WHERE NOT `group`.`deleted` AND `group`.`uid` = %d
|
||||
$sql_extra
|
||||
GROUP BY `group`.`name`
|
||||
GROUP BY `group`.`name`, `group`.`id`
|
||||
ORDER BY `group`.`name`
|
||||
LIMIT %d,%d",
|
||||
intval(local_user()),
|
||||
|
@ -534,9 +551,7 @@ function acl_lookup(App $a, $out_type = 'json') {
|
|||
intval(local_user()),
|
||||
dbesc(NETWORK_OSTATUS), dbesc(NETWORK_STATUSNET)
|
||||
);
|
||||
}
|
||||
elseif ($type=='c'){
|
||||
|
||||
} elseif ($type == 'c') {
|
||||
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact`
|
||||
WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
|
||||
AND NOT (`network` IN ('%s'))
|
||||
|
@ -602,7 +617,7 @@ function acl_lookup(App $a, $out_type = 'json') {
|
|||
'network' => $g['network'],
|
||||
'link' => $g['url'],
|
||||
'nick' => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']),
|
||||
'forum' => ((x($g['forum']) || x($g['prv'])) ? 1 : 0),
|
||||
'forum' => ((x($g, 'forum') || x($g, 'prv')) ? 1 : 0),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -610,16 +625,22 @@ function acl_lookup(App $a, $out_type = 'json') {
|
|||
$items = array_merge($groups, $contacts);
|
||||
|
||||
if ($conv_id) {
|
||||
/* if $conv_id is set, get unknow contacts in thread */
|
||||
/* but first get know contacts url to filter them out */
|
||||
function _contact_link($i){ return dbesc($i['link']); }
|
||||
$known_contacts = array_map(_contact_link, $contacts);
|
||||
$unknow_contacts=array();
|
||||
$r = q("SELECT `author-avatar`,`author-name`,`author-link`
|
||||
/*
|
||||
* if $conv_id is set, get unknown contacts in thread
|
||||
* but first get known contacts url to filter them out
|
||||
*/
|
||||
$known_contacts = array_map(
|
||||
function ($i) {
|
||||
return dbesc($i['link']);
|
||||
}
|
||||
, $contacts);
|
||||
|
||||
$unknown_contacts = array();
|
||||
$r = q("SELECT `author-link`
|
||||
FROM `item` WHERE `parent` = %d
|
||||
AND (`author-name` LIKE '%%%s%%' OR `author-link` LIKE '%%%s%%')
|
||||
AND `author-link` NOT IN ('%s')
|
||||
GROUP BY `author-link`
|
||||
GROUP BY `author-link`, `author-avatar`, `author-name`
|
||||
ORDER BY `author-name` ASC
|
||||
",
|
||||
intval($conv_id),
|
||||
|
@ -629,27 +650,25 @@ function acl_lookup(App $a, $out_type = 'json') {
|
|||
);
|
||||
if (dbm::is_result($r)) {
|
||||
foreach ($r as $row) {
|
||||
// nickname..
|
||||
$up = parse_url($row['author-link']);
|
||||
$nick = explode("/",$up['path']);
|
||||
$nick = $nick[count($nick)-1];
|
||||
$nick .= "@".$up['host'];
|
||||
// /nickname
|
||||
$unknow_contacts[] = array(
|
||||
$contact = get_contact_details_by_url($row['author-link']);
|
||||
|
||||
if (count($contact) > 0) {
|
||||
$unknown_contacts[] = array(
|
||||
'type' => 'c',
|
||||
'photo' => proxy_url($row['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||
'name' => htmlentities($row['author-name']),
|
||||
'id' => '',
|
||||
'network' => 'unknown',
|
||||
'link' => $row['author-link'],
|
||||
'nick' => htmlentities($nick),
|
||||
'forum' => false
|
||||
'photo' => proxy_url($contact['micro'], false, PROXY_SIZE_MICRO),
|
||||
'name' => htmlentities($contact['name']),
|
||||
'id' => intval($contact['cid']),
|
||||
'network' => $contact['network'],
|
||||
'link' => $contact['url'],
|
||||
'nick' => htmlentities($contact['nick'] ? : $contact['addr']),
|
||||
'forum' => $contact['forum']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$items = array_merge($items, $unknow_contacts);
|
||||
$tot += count($unknow_contacts);
|
||||
$items = array_merge($items, $unknown_contacts);
|
||||
$tot += count($unknown_contacts);
|
||||
}
|
||||
|
||||
$results = array(
|
||||
|
|
1037
include/api.php
1037
include/api.php
File diff suppressed because it is too large
Load diff
|
@ -1067,6 +1067,7 @@ function z_mime_content_type($filename) {
|
|||
return $mime_types[$ext];
|
||||
}
|
||||
}
|
||||
/// @TODO Then let's get rid of it?
|
||||
// can't use this because we're just passing a name, e.g. not a file that can be opened
|
||||
// elseif (function_exists('finfo_open')) {
|
||||
// $finfo = @finfo_open(FILEINFO_MIME);
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
<?php
|
||||
|
||||
require_once("include/oembed.php");
|
||||
require_once("include/event.php");
|
||||
require_once("library/markdown.php");
|
||||
require_once("include/html2bbcode.php");
|
||||
require_once("include/bbcode.php");
|
||||
require_once("library/html-to-markdown/HTML_To_Markdown.php");
|
||||
use League\HTMLToMarkdown\HtmlConverter;
|
||||
|
||||
require_once "include/oembed.php";
|
||||
require_once "include/event.php";
|
||||
require_once "library/markdown.php";
|
||||
require_once "include/html2bbcode.php";
|
||||
require_once "include/bbcode.php";
|
||||
|
||||
/**
|
||||
* @brief Callback function to replace a Diaspora style mention in a mention for Friendica
|
||||
|
@ -29,11 +30,12 @@ function diaspora_mention2bb($match) {
|
|||
return '@[url=' . $data['url'] . ']' . $name . '[/url]';
|
||||
}
|
||||
|
||||
// we don't want to support a bbcode specific markdown interpreter
|
||||
// and the markdown library we have is pretty good, but provides HTML output.
|
||||
// So we'll use that to convert to HTML, then convert the HTML back to bbcode,
|
||||
// and then clean up a few Diaspora specific constructs.
|
||||
|
||||
/*
|
||||
* we don't want to support a bbcode specific markdown interpreter
|
||||
* and the markdown library we have is pretty good, but provides HTML output.
|
||||
* So we'll use that to convert to HTML, then convert the HTML back to bbcode,
|
||||
* and then clean up a few Diaspora specific constructs.
|
||||
*/
|
||||
function diaspora2bb($s) {
|
||||
|
||||
$s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
|
||||
|
@ -92,11 +94,11 @@ function diaspora_mentions($match) {
|
|||
|
||||
$contact = get_contact_details_by_url($match[3]);
|
||||
|
||||
if (!isset($contact['addr'])) {
|
||||
if (!x($contact, 'addr')) {
|
||||
$contact = Probe::uri($match[3]);
|
||||
}
|
||||
|
||||
if (!isset($contact['addr'])) {
|
||||
if (!x($contact, 'addr')) {
|
||||
return $match[0];
|
||||
}
|
||||
|
||||
|
@ -104,27 +106,52 @@ function diaspora_mentions($match) {
|
|||
return $mention;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Converts a BBCode text into Markdown
|
||||
*
|
||||
* This function converts a BBCode item body to be sent to Markdown-enabled
|
||||
* systems like Diaspora and Libertree
|
||||
*
|
||||
* @param string $Text
|
||||
* @param bool $preserve_nl Effects unclear, unused in Friendica
|
||||
* @param bool $fordiaspora Diaspora requires more changes than Libertree
|
||||
* @return string
|
||||
*/
|
||||
function bb2diaspora($Text, $preserve_nl = false, $fordiaspora = true) {
|
||||
|
||||
$a = get_app();
|
||||
|
||||
$OriginalText = $Text;
|
||||
|
||||
// Since Diaspora is creating a summary for links, this function removes them before posting
|
||||
if ($fordiaspora)
|
||||
if ($fordiaspora) {
|
||||
$Text = bb_remove_share_information($Text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform #tags, strip off the [url] and replace spaces with underscore
|
||||
*/
|
||||
$URLSearchString = "^\[\]";
|
||||
$Text = preg_replace_callback("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/i", create_function('$match',
|
||||
'return \'#\'. str_replace(\' \', \'_\', $match[2]);'
|
||||
), $Text);
|
||||
$Text = preg_replace_callback("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/i",
|
||||
function ($matches) {
|
||||
return '#' . str_replace(' ', '_', $matches[2]);
|
||||
}
|
||||
, $Text);
|
||||
|
||||
// Converting images with size parameters to simple images. Markdown doesn't know it.
|
||||
$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $Text);
|
||||
|
||||
// Extracting multi-line code blocks before the whitespace processing/code highlighter in bbcode()
|
||||
$codeblocks = [];
|
||||
$Text = preg_replace_callback('#\[code(?:=([^\]]*))?\](?=\n)(.*?)\[\/code\]#is',
|
||||
function ($matches) use (&$codeblocks) {
|
||||
$return = '#codeblock-' . count($codeblocks) . '#';
|
||||
|
||||
$prefix = '````' . $matches[1] . PHP_EOL;
|
||||
$codeblocks[] = $prefix . trim($matches[2]) . PHP_EOL . '````';
|
||||
return $return;
|
||||
}
|
||||
, $Text);
|
||||
|
||||
// Convert it to HTML - don't try oembed
|
||||
if ($fordiaspora) {
|
||||
$Text = bbcode($Text, $preserve_nl, false, 3);
|
||||
|
@ -134,14 +161,15 @@ function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) {
|
|||
$tagline = "";
|
||||
foreach ($tags[2] as $tag) {
|
||||
$tag = html_entity_decode($tag, ENT_QUOTES, 'UTF-8');
|
||||
if (!strpos(html_entity_decode($Text, ENT_QUOTES, 'UTF-8'), "#".$tag))
|
||||
$tagline .= "#".$tag." ";
|
||||
if (!strpos(html_entity_decode($Text, ENT_QUOTES, 'UTF-8'), '#' . $tag)) {
|
||||
$tagline .= '#' . $tag . ' ';
|
||||
}
|
||||
}
|
||||
$Text = $Text." ".$tagline;
|
||||
}
|
||||
|
||||
} else
|
||||
} else {
|
||||
$Text = bbcode($Text, $preserve_nl, false, 4);
|
||||
}
|
||||
|
||||
// mask some special HTML chars from conversation to markdown
|
||||
$Text = str_replace(array('<', '>', '&'), array('&_lt_;', '&_gt_;', '&_amp_;'), $Text);
|
||||
|
@ -153,7 +181,8 @@ function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) {
|
|||
$stamp1 = microtime(true);
|
||||
|
||||
// Now convert HTML to Markdown
|
||||
$Text = new HTML_To_Markdown($Text);
|
||||
$converter = new HtmlConverter();
|
||||
$Text = $converter->convert($Text);
|
||||
|
||||
// unmask the special chars back to HTML
|
||||
$Text = str_replace(array('&_lt_;', '&_gt_;', '&_amp_;'), array('<', '>', '&'), $Text);
|
||||
|
@ -172,6 +201,17 @@ function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) {
|
|||
$Text = preg_replace_callback("/([@]\[(.*?)\])\(([$URLSearchString]*?)\)/ism", 'diaspora_mentions', $Text);
|
||||
}
|
||||
|
||||
// Restore code blocks
|
||||
$Text = preg_replace_callback('/#codeblock-([0-9]+)#/iU',
|
||||
function ($matches) use ($codeblocks) {
|
||||
$return = '';
|
||||
if (isset($codeblocks[intval($matches[1])])) {
|
||||
$return = $codeblocks[$matches[1]];
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
, $Text);
|
||||
|
||||
call_hooks('bb2diaspora',$Text);
|
||||
|
||||
return $Text;
|
||||
|
@ -183,9 +223,9 @@ function unescape_underscores_in_links($m) {
|
|||
}
|
||||
|
||||
function format_event_diaspora($ev) {
|
||||
|
||||
if(! ((is_array($ev)) && count($ev)))
|
||||
if (! ((is_array($ev)) && count($ev))) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM
|
||||
|
||||
|
@ -200,17 +240,19 @@ function format_event_diaspora($ev) {
|
|||
$ev['start'] , $bd_format)))
|
||||
. '](' . App::get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['start'])) . ")\n";
|
||||
|
||||
if(! $ev['nofinish'])
|
||||
if (! $ev['nofinish']) {
|
||||
$o .= t('Finishes:') . ' ' . '['
|
||||
. (($ev['adjust']) ? day_translate(datetime_convert('UTC', 'UTC',
|
||||
$ev['finish'] , $bd_format ))
|
||||
: day_translate(datetime_convert('UTC', 'UTC',
|
||||
$ev['finish'] , $bd_format )))
|
||||
. '](' . App::get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['finish'])) . ")\n";
|
||||
}
|
||||
|
||||
if(strlen($ev['location']))
|
||||
if (strlen($ev['location'])) {
|
||||
$o .= t('Location:') . bb2diaspora($ev['location'])
|
||||
. "\n";
|
||||
}
|
||||
|
||||
$o .= "\n";
|
||||
return $o;
|
||||
|
|
|
@ -1,24 +1,26 @@
|
|||
<?php
|
||||
use \Friendica\Core\Config;
|
||||
|
||||
require_once("include/oembed.php");
|
||||
require_once('include/event.php');
|
||||
require_once('include/map.php');
|
||||
require_once('mod/proxy.php');
|
||||
require_once('include/Contact.php');
|
||||
require_once('include/plaintext.php');
|
||||
require_once 'include/oembed.php';
|
||||
require_once 'include/event.php';
|
||||
require_once 'include/map.php';
|
||||
require_once 'mod/proxy.php';
|
||||
require_once 'include/Contact.php';
|
||||
require_once 'include/plaintext.php';
|
||||
|
||||
function bb_PictureCacheExt($matches) {
|
||||
if (strpos($matches[3], "data:image/") === 0)
|
||||
return ($matches[0]);
|
||||
if (strpos($matches[3], "data:image/") === 0) {
|
||||
return $matches[0];
|
||||
}
|
||||
|
||||
$matches[3] = proxy_url($matches[3]);
|
||||
return "[img=" . $matches[1] . "x" . $matches[2] . "]" . $matches[3] . "[/img]";
|
||||
}
|
||||
|
||||
function bb_PictureCache($matches) {
|
||||
if (strpos($matches[1], "data:image/") === 0)
|
||||
return ($matches[0]);
|
||||
if (strpos($matches[1], "data:image/") === 0) {
|
||||
return $matches[0];
|
||||
}
|
||||
|
||||
$matches[1] = proxy_url($matches[1]);
|
||||
return "[img]" . $matches[1] . "[/img]";
|
||||
|
@ -36,8 +38,9 @@ function bb_map_location($match) {
|
|||
function bb_attachment($Text, $simplehtml = false, $tryoembed = true) {
|
||||
|
||||
$data = get_attachment_data($Text);
|
||||
if (!$data)
|
||||
if (!$data) {
|
||||
return $Text;
|
||||
}
|
||||
|
||||
if (isset($data["title"])) {
|
||||
$data["title"] = strip_tags($data["title"]);
|
||||
|
@ -57,73 +60,81 @@ function bb_attachment($Text, $simplehtml = false, $tryoembed = true) {
|
|||
|
||||
// If the link description is similar to the text above then don't add the link description
|
||||
if (($data["title"] != "") AND ((strpos($test1,$test2) !== false) OR
|
||||
(similar_text($test1,$test2) / strlen($data["title"])) > 0.9))
|
||||
(similar_text($test1,$test2) / strlen($data["title"])) > 0.9)) {
|
||||
$title2 = $data["url"];
|
||||
$text = sprintf('<a href="%s" title="%s" class="attachment thumbnail" rel="nofollow external">%s</a><br />',
|
||||
}
|
||||
$text = sprintf('<a href="%s" title="%s" class="attachment" rel="nofollow external">%s</a><br />',
|
||||
$data["url"], $data["title"], $title2);
|
||||
} elseif (($simplehtml != 4) AND ($simplehtml != 0))
|
||||
} elseif (($simplehtml != 4) AND ($simplehtml != 0)) {
|
||||
$text = sprintf('<a href="%s" target="_blank">%s</a><br>', $data["url"], $data["title"]);
|
||||
else {
|
||||
} else {
|
||||
$text = sprintf('<span class="type-%s">', $data["type"]);
|
||||
|
||||
$bookmark = array(sprintf('[bookmark=%s]%s[/bookmark]', $data["url"], $data["title"]), $data["url"], $data["title"]);
|
||||
if ($tryoembed)
|
||||
if ($tryoembed) {
|
||||
$oembed = tryoembed($bookmark);
|
||||
else
|
||||
} else {
|
||||
$oembed = $bookmark[0];
|
||||
}
|
||||
|
||||
if (strstr(strtolower($oembed), "<iframe "))
|
||||
if (strstr(strtolower($oembed), "<iframe ")) {
|
||||
$text = $oembed;
|
||||
else {
|
||||
if (($data["image"] != "") AND !strstr(strtolower($oembed), "<img "))
|
||||
} else {
|
||||
if (($data["image"] != "") AND !strstr(strtolower($oembed), "<img ")) {
|
||||
$text .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a><br />', $data["url"], proxy_url($data["image"]), $data["title"]);
|
||||
elseif (($data["preview"] != "") AND !strstr(strtolower($oembed), "<img "))
|
||||
} elseif (($data["preview"] != "") AND !strstr(strtolower($oembed), "<img ")) {
|
||||
$text .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-preview" /></a><br />', $data["url"], proxy_url($data["preview"]), $data["title"]);
|
||||
}
|
||||
|
||||
if (($data["type"] == "photo") AND ($data["url"] != "") AND ($data["image"] != ""))
|
||||
if (($data["type"] == "photo") AND ($data["url"] != "") AND ($data["image"] != "")) {
|
||||
$text .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a>', $data["url"], proxy_url($data["image"]), $data["title"]);
|
||||
else
|
||||
} else {
|
||||
$text .= $oembed;
|
||||
}
|
||||
|
||||
if (trim($data["description"]) != "")
|
||||
if (trim($data["description"]) != "") {
|
||||
$text .= sprintf('<blockquote>%s</blockquote></span>', trim(bbcode($data["description"])));
|
||||
}
|
||||
}
|
||||
return $data["text"].$text.$data["after"];
|
||||
}
|
||||
return trim($data["text"].' '.$text.' '.$data["after"]);
|
||||
}
|
||||
|
||||
function bb_remove_share_information($Text, $plaintext = false, $nolink = false) {
|
||||
|
||||
$data = get_attachment_data($Text);
|
||||
|
||||
if (!$data)
|
||||
if (!$data) {
|
||||
return $Text;
|
||||
|
||||
if ($nolink)
|
||||
} elseif ($nolink) {
|
||||
return $data["text"] . $data["after"];
|
||||
}
|
||||
|
||||
$title = htmlentities($data["title"], ENT_QUOTES, 'UTF-8', false);
|
||||
$text = htmlentities($data["text"], ENT_QUOTES, 'UTF-8', false);
|
||||
if ($plaintext OR (($title != "") AND strstr($text, $title)))
|
||||
if ($plaintext OR (($title != "") AND strstr($text, $title))) {
|
||||
$data["title"] = $data["url"];
|
||||
elseif (($text != "") AND strstr($title, $text)) {
|
||||
} elseif (($text != "") AND strstr($title, $text)) {
|
||||
$data["text"] = $data["title"];
|
||||
$data["title"] = $data["url"];
|
||||
}
|
||||
|
||||
if (($data["text"] == "") AND ($data["title"] != "") AND ($data["url"] == ""))
|
||||
if (($data["text"] == "") AND ($data["title"] != "") AND ($data["url"] == "")) {
|
||||
return $data["title"] . $data["after"];
|
||||
}
|
||||
|
||||
// If the link already is included in the post, don't add it again
|
||||
if (($data["url"] != "") AND strpos($data["text"], $data["url"]))
|
||||
if (($data["url"] != "") AND strpos($data["text"], $data["url"])) {
|
||||
return $data["text"] . $data["after"];
|
||||
}
|
||||
|
||||
$text = $data["text"];
|
||||
|
||||
if (($data["url"] != "") AND ($data["title"] != ""))
|
||||
if (($data["url"] != "") AND ($data["title"] != "")) {
|
||||
$text .= "\n[url=" . $data["url"] . "]" . $data["title"] . "[/url]";
|
||||
elseif (($data["url"] != ""))
|
||||
} elseif (($data["url"] != "")) {
|
||||
$text .= "\n" . $data["url"];
|
||||
}
|
||||
|
||||
return $text . "\n" . $data["after"];
|
||||
}
|
||||
|
@ -145,27 +156,22 @@ function cleancss($input) {
|
|||
for ($i = 0; $i < strlen($input); $i++) {
|
||||
$char = substr($input, $i, 1);
|
||||
|
||||
if (($char >= "a") and ($char <= "z"))
|
||||
$cleaned .= $char;
|
||||
|
||||
if (!(strpos(" #;:0123456789-_.%", $char) === false))
|
||||
if (($char >= "a") and ($char <= "z")) {
|
||||
$cleaned .= $char;
|
||||
}
|
||||
|
||||
return($cleaned);
|
||||
if (!(strpos(" #;:0123456789-_.%", $char) === false)) {
|
||||
$cleaned .= $char;
|
||||
}
|
||||
}
|
||||
|
||||
return $cleaned;
|
||||
}
|
||||
|
||||
function stripcode_br_cb($s) {
|
||||
return '[code]' . str_replace('<br />', '', $s[1]) . '[/code]';
|
||||
}
|
||||
|
||||
function bb_onelinecode_cb($match) {
|
||||
if (strpos($match[1],"<br>")===false){
|
||||
return "<key>".$match[1]."</key>";
|
||||
}
|
||||
return "<code>".$match[1]."</code>";
|
||||
}
|
||||
|
||||
function tryoembed($match) {
|
||||
$url = $match[1];
|
||||
|
||||
|
@ -173,26 +179,30 @@ function tryoembed($match){
|
|||
$url = str_replace(array("http://www.youtube.com/", "http://player.vimeo.com/"),
|
||||
array("https://www.youtube.com/", "https://player.vimeo.com/"), $url);
|
||||
|
||||
|
||||
$o = oembed_fetch_url($url);
|
||||
|
||||
if (!is_object($o))
|
||||
if (!is_object($o)) {
|
||||
return $match[0];
|
||||
|
||||
if (isset($match[2]))
|
||||
$o->title = $match[2];
|
||||
|
||||
if ($o->type=="error") return $match[0];
|
||||
|
||||
$html = oembed_format_object($o);
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
// [noparse][i]italic[/i][/noparse] turns into
|
||||
// [noparse][ i ]italic[ /i ][/noparse],
|
||||
// to hide them from parser.
|
||||
if (isset($match[2])) {
|
||||
$o->title = $match[2];
|
||||
}
|
||||
|
||||
if ($o->type == "error") {
|
||||
return $match[0];
|
||||
}
|
||||
|
||||
$html = oembed_format_object($o);
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/*
|
||||
* [noparse][i]italic[/i][/noparse] turns into
|
||||
* [noparse][ i ]italic[ /i ][/noparse],
|
||||
* to hide them from parser.
|
||||
*/
|
||||
function bb_spacefy($st) {
|
||||
$whole_match = $st[0];
|
||||
$captured = $st[1];
|
||||
|
@ -201,10 +211,11 @@ function bb_spacefy($st) {
|
|||
return $new_str;
|
||||
}
|
||||
|
||||
// The previously spacefied [noparse][ i ]italic[ /i ][/noparse],
|
||||
// now turns back and the [noparse] tags are trimed
|
||||
// returning [i]italic[/i]
|
||||
|
||||
/*
|
||||
* The previously spacefied [noparse][ i ]italic[ /i ][/noparse],
|
||||
* now turns back and the [noparse] tags are trimed
|
||||
* returning [i]italic[/i]
|
||||
*/
|
||||
function bb_unspacefy_and_trim($st) {
|
||||
$whole_match = $st[0];
|
||||
$captured = $st[1];
|
||||
|
@ -212,61 +223,78 @@ function bb_unspacefy_and_trim($st) {
|
|||
return $unspacefied;
|
||||
}
|
||||
|
||||
function bb_find_open_close($s, $open, $close, $occurance = 1) {
|
||||
|
||||
if($occurance < 1)
|
||||
$occurance = 1;
|
||||
|
||||
$start_pos = -1;
|
||||
for($i = 1; $i <= $occurance; $i++) {
|
||||
if( $start_pos !== false)
|
||||
$start_pos = strpos($s, $open, $start_pos + 1);
|
||||
function bb_find_open_close($s, $open, $close, $occurence = 1) {
|
||||
if ($occurence < 1) {
|
||||
$occurence = 1;
|
||||
}
|
||||
|
||||
if( $start_pos === false)
|
||||
$start_pos = -1;
|
||||
for ($i = 1; $i <= $occurence; $i++) {
|
||||
if ($start_pos !== false) {
|
||||
$start_pos = strpos($s, $open, $start_pos + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if ($start_pos === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$end_pos = strpos($s, $close, $start_pos);
|
||||
|
||||
if( $end_pos === false)
|
||||
if ($end_pos === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$res = array( 'start' => $start_pos, 'end' => $end_pos );
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
function get_bb_tag_pos($s, $name, $occurance = 1) {
|
||||
|
||||
if($occurance < 1)
|
||||
$occurance = 1;
|
||||
|
||||
$start_open = -1;
|
||||
for($i = 1; $i <= $occurance; $i++) {
|
||||
if( $start_open !== false)
|
||||
$start_open = strpos($s, '[' . $name, $start_open + 1); // allow [name= type tags
|
||||
function get_bb_tag_pos($s, $name, $occurence = 1) {
|
||||
if ($occurence < 1) {
|
||||
$occurence = 1;
|
||||
}
|
||||
|
||||
if( $start_open === false)
|
||||
$start_open = -1;
|
||||
for ($i = 1; $i <= $occurence; $i++) {
|
||||
if ($start_open !== false) {
|
||||
$start_open = strpos($s, '[' . $name, $start_open + 1); // allow [name= type tags
|
||||
}
|
||||
}
|
||||
|
||||
if ($start_open === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$start_equal = strpos($s, '=', $start_open);
|
||||
$start_close = strpos($s, ']', $start_open);
|
||||
|
||||
if( $start_close === false)
|
||||
if ($start_close === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$start_close++;
|
||||
|
||||
$end_open = strpos($s, '[/' . $name . ']', $start_close);
|
||||
|
||||
if( $end_open === false)
|
||||
if ($end_open === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$res = array( 'start' => array('open' => $start_open, 'close' => $start_close),
|
||||
'end' => array('open' => $end_open, 'close' => $end_open + strlen('[/' . $name . ']')) );
|
||||
if( $start_equal !== false)
|
||||
$res = array(
|
||||
'start' => array(
|
||||
'open' => $start_open,
|
||||
'close' => $start_close
|
||||
),
|
||||
'end' => array(
|
||||
'open' => $end_open,
|
||||
'close' => $end_open + strlen('[/' . $name . ']')
|
||||
),
|
||||
);
|
||||
|
||||
if ($start_equal !== false) {
|
||||
$res['start']['equal'] = $start_equal + 1;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
@ -275,21 +303,21 @@ function bb_tag_preg_replace($pattern, $replace, $name, $s) {
|
|||
|
||||
$string = $s;
|
||||
|
||||
$occurance = 1;
|
||||
$pos = get_bb_tag_pos($string, $name, $occurance);
|
||||
while($pos !== false && $occurance < 1000) {
|
||||
|
||||
$occurence = 1;
|
||||
$pos = get_bb_tag_pos($string, $name, $occurence);
|
||||
while ($pos !== false && $occurence < 1000) {
|
||||
$start = substr($string, 0, $pos['start']['open']);
|
||||
$subject = substr($string, $pos['start']['open'], $pos['end']['close'] - $pos['start']['open']);
|
||||
$end = substr($string, $pos['end']['close']);
|
||||
if($end === false)
|
||||
if ($end === false) {
|
||||
$end = '';
|
||||
}
|
||||
|
||||
$subject = preg_replace($pattern, $replace, $subject);
|
||||
$string = $start . $subject . $end;
|
||||
|
||||
$occurance++;
|
||||
$pos = get_bb_tag_pos($string, $name, $occurance);
|
||||
$occurence++;
|
||||
$pos = get_bb_tag_pos($string, $name, $occurence);
|
||||
}
|
||||
|
||||
return $string;
|
||||
|
@ -318,14 +346,16 @@ function bb_extract_images($body) {
|
|||
$new_body = $new_body . substr($orig_body, 0, $img_start) . '[$#saved_image' . $cnt . '#$]';
|
||||
|
||||
$cnt++;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
$new_body = $new_body . substr($orig_body, 0, $img_end + strlen('[/img]'));
|
||||
}
|
||||
|
||||
$orig_body = substr($orig_body, $img_end + strlen('[/img]'));
|
||||
|
||||
if($orig_body === false) // in case the body ends on a closing image tag
|
||||
if ($orig_body === false) {
|
||||
// in case the body ends on a closing image tag
|
||||
$orig_body = '';
|
||||
}
|
||||
|
||||
$img_start = strpos($orig_body, '[img');
|
||||
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
|
||||
|
@ -512,104 +542,114 @@ function bb_ShareAttributes($share, $simplehtml) {
|
|||
);
|
||||
break;
|
||||
}
|
||||
return($text);
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
function GetProfileUsername($profile, $username, $compact = false, $getnetwork = false) {
|
||||
|
||||
$twitter = preg_replace("=https?://twitter.com/(.*)=ism", "$1@twitter.com", $profile);
|
||||
if ($twitter != $profile) {
|
||||
if ($getnetwork)
|
||||
return(NETWORK_TWITTER);
|
||||
elseif ($compact)
|
||||
return($twitter);
|
||||
else
|
||||
if ($getnetwork) {
|
||||
return NETWORK_TWITTER;
|
||||
} elseif ($compact) {
|
||||
return $twitter;
|
||||
} else {
|
||||
return ($username . " (" . $twitter . ")");
|
||||
}
|
||||
}
|
||||
|
||||
$appnet = preg_replace("=https?://alpha.app.net/(.*)=ism", "$1@alpha.app.net", $profile);
|
||||
if ($appnet != $profile) {
|
||||
if ($getnetwork)
|
||||
return(NETWORK_APPNET);
|
||||
elseif ($compact)
|
||||
return($appnet);
|
||||
else
|
||||
if ($getnetwork) {
|
||||
return NETWORK_APPNET;
|
||||
} elseif ($compact) {
|
||||
return $appnet;
|
||||
} else {
|
||||
return ($username . " (" . $appnet . ")");
|
||||
}
|
||||
}
|
||||
|
||||
$gplus = preg_replace("=https?://plus.google.com/(.*)=ism", "$1@plus.google.com", $profile);
|
||||
if ($gplus != $profile) {
|
||||
if ($getnetwork)
|
||||
return(NETWORK_GPLUS);
|
||||
elseif ($compact)
|
||||
if ($getnetwork) {
|
||||
return NETWORK_GPLUS;
|
||||
} elseif ($compact) {
|
||||
return ($gplususername . " (" . $username . ")");
|
||||
else
|
||||
} else {
|
||||
return ($username . " (" . $gplus . ")");
|
||||
}
|
||||
}
|
||||
|
||||
$friendica = preg_replace("=https?://(.*)/profile/(.*)=ism", "$2@$1", $profile);
|
||||
if ($friendica != $profile) {
|
||||
if ($getnetwork)
|
||||
return(NETWORK_DFRN);
|
||||
elseif ($compact)
|
||||
return($friendica);
|
||||
else
|
||||
if ($getnetwork) {
|
||||
return NETWORK_DFRN;
|
||||
} elseif ($compact) {
|
||||
return $friendica;
|
||||
} else {
|
||||
return ($username . " (" . $friendica . ")");
|
||||
}
|
||||
}
|
||||
|
||||
$diaspora = preg_replace("=https?://(.*)/u/(.*)=ism", "$2@$1", $profile);
|
||||
if ($diaspora != $profile) {
|
||||
if ($getnetwork)
|
||||
return(NETWORK_DIASPORA);
|
||||
elseif ($compact)
|
||||
return($diaspora);
|
||||
else
|
||||
if ($getnetwork) {
|
||||
return NETWORK_DIASPORA;
|
||||
} elseif ($compact) {
|
||||
return $diaspora;
|
||||
} else {
|
||||
return ($username . " (" . $diaspora . ")");
|
||||
}
|
||||
}
|
||||
|
||||
$red = preg_replace("=https?://(.*)/channel/(.*)=ism", "$2@$1", $profile);
|
||||
if ($red != $profile) {
|
||||
if ($getnetwork)
|
||||
if ($getnetwork) {
|
||||
// red is identified as Diaspora - friendica can't connect directly to it
|
||||
return(NETWORK_DIASPORA);
|
||||
elseif ($compact)
|
||||
return($red);
|
||||
else
|
||||
return NETWORK_DIASPORA;
|
||||
} elseif ($compact) {
|
||||
return $red;
|
||||
} else {
|
||||
return ($username . " (" . $red . ")");
|
||||
}
|
||||
}
|
||||
|
||||
$StatusnetHost = preg_replace("=https?://(.*)/user/(.*)=ism", "$1", $profile);
|
||||
if ($StatusnetHost != $profile) {
|
||||
$StatusnetUser = preg_replace("=https?://(.*)/user/(.*)=ism", "$2", $profile);
|
||||
if ($StatusnetUser != $profile) {
|
||||
/// @TODO Some hosts run on https, not just http and sometimes http is disabled, let's support both here
|
||||
$UserData = fetch_url("http://".$StatusnetHost."/api/users/show.json?user_id=".$StatusnetUser);
|
||||
$user = json_decode($UserData);
|
||||
if ($user) {
|
||||
if ($getnetwork)
|
||||
return(NETWORK_STATUSNET);
|
||||
elseif ($compact)
|
||||
if ($getnetwork) {
|
||||
return NETWORK_STATUSNET;
|
||||
} elseif ($compact) {
|
||||
return ($user->screen_name . "@" . $StatusnetHost);
|
||||
else
|
||||
} else {
|
||||
return ($username . " (" . $user->screen_name . "@" . $StatusnetHost . ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// pumpio (http://host.name/user)
|
||||
$rest = preg_replace("=https?://([\.\w]+)/([\.\w]+)(.*)=ism", "$3", $profile);
|
||||
if ($rest == "") {
|
||||
$pumpio = preg_replace("=https?://([\.\w]+)/([\.\w]+)(.*)=ism", "$2@$1", $profile);
|
||||
if ($pumpio != $profile) {
|
||||
if ($getnetwork)
|
||||
return(NETWORK_PUMPIO);
|
||||
elseif ($compact)
|
||||
return($pumpio);
|
||||
else
|
||||
if ($getnetwork) {
|
||||
return NETWORK_PUMPIO;
|
||||
} elseif ($compact) {
|
||||
return $pumpio;
|
||||
} else {
|
||||
return ($username . " (" . $pumpio . ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return($username);
|
||||
return $username;
|
||||
}
|
||||
|
||||
function bb_DiasporaLinks($match) {
|
||||
|
@ -660,15 +700,17 @@ function bb_RemovePictureLinks($match) {
|
|||
}
|
||||
Cache::set($match[1],$text);
|
||||
}
|
||||
return($text);
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
function bb_expand_links($match) {
|
||||
if (($match[3] == "") OR ($match[2] == $match[3]) OR stristr($match[2], $match[3]))
|
||||
if (($match[3] == "") OR ($match[2] == $match[3]) OR stristr($match[2], $match[3])) {
|
||||
return ($match[1] . "[url]" . $match[2] . "[/url]");
|
||||
else
|
||||
} else {
|
||||
return ($match[1] . $match[3] . " [url]" . $match[2] . "[/url]");
|
||||
}
|
||||
}
|
||||
|
||||
function bb_CleanPictureLinksSub($match) {
|
||||
$text = Cache::get($match[1]);
|
||||
|
@ -715,24 +757,48 @@ function bb_CleanPictureLinksSub($match) {
|
|||
}
|
||||
Cache::set($match[1],$text);
|
||||
}
|
||||
return($text);
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
function bb_CleanPictureLinks($text) {
|
||||
$text = preg_replace_callback("&\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]&Usi", 'bb_CleanPictureLinksSub', $text);
|
||||
return ($text);
|
||||
return $text;
|
||||
}
|
||||
|
||||
function bb_highlight($match) {
|
||||
if (in_array(strtolower($match[1]), ['php', 'css', 'mysql', 'sql', 'abap', 'diff', 'html', 'perl', 'ruby',
|
||||
'vbscript','avrc','dtd','java','xml','cpp','python','javascript','js','sh']))
|
||||
'vbscript', 'avrc', 'dtd', 'java', 'xml', 'cpp', 'python', 'javascript', 'js', 'sh'])) {
|
||||
return text_highlight($match[2], strtolower($match[1]));
|
||||
}
|
||||
return $match[0];
|
||||
}
|
||||
|
||||
// BBcode 2 HTML was written by WAY2WEB.net
|
||||
// extended to work with Mistpark/Friendica - Mike Macgirvin
|
||||
|
||||
/**
|
||||
* @brief Converts a BBCode message to HTML message
|
||||
*
|
||||
* BBcode 2 HTML was written by WAY2WEB.net
|
||||
* extended to work with Mistpark/Friendica - Mike Macgirvin
|
||||
*
|
||||
* Simple HTML values meaning:
|
||||
* - 0: Friendica display
|
||||
* - 1: Unused
|
||||
* - 2: Used for Facebook, Google+, Windows Phone push, Friendica API
|
||||
* - 3: Used before converting to Markdown in bb2diaspora.php
|
||||
* - 4: Used for WordPress, Libertree (before Markdown), pump.io and tumblr
|
||||
* - 5: Unused
|
||||
* - 6: Used for Appnet
|
||||
* - 7: Used for dfrn, OStatus
|
||||
* - 8: Used for WP backlink text setting
|
||||
*
|
||||
* @staticvar array $allowed_src_protocols
|
||||
* @param string $Text
|
||||
* @param bool $preserve_nl
|
||||
* @param bool $tryoembed
|
||||
* @param int $simplehtml
|
||||
* @param bool $forplaintext
|
||||
* @return string
|
||||
*/
|
||||
function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = false, $forplaintext = false) {
|
||||
|
||||
$a = get_app();
|
||||
|
@ -779,8 +845,9 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
|||
$Text = preg_replace("/\[\/code\]\n/ism", "[/code]", $Text);
|
||||
|
||||
// when the content is meant exporting to other systems then remove the avatar picture since this doesn't really look good on these systems
|
||||
if (!$tryoembed)
|
||||
if (!$tryoembed) {
|
||||
$Text = preg_replace("/\[share(.*?)avatar\s?=\s?'.*?'\s?(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism", "\n[share$1$2]$3[/share]", $Text);
|
||||
}
|
||||
|
||||
// Check for [code] text here, before the linefeeds are messed with.
|
||||
// The highlighter will unescape and re-escape the content.
|
||||
|
@ -814,8 +881,9 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
|||
|
||||
$Text = str_replace(array("\r","\n"), array('<br />', '<br />'), $Text);
|
||||
|
||||
if($preserve_nl)
|
||||
if ($preserve_nl) {
|
||||
$Text = str_replace(array("\n", "\r"), array('', ''), $Text);
|
||||
}
|
||||
|
||||
// Set up the parameters for a URL search string
|
||||
$URLSearchString = "^\[\]";
|
||||
|
@ -823,20 +891,21 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
|||
$MAILSearchString = $URLSearchString;
|
||||
|
||||
// Remove all hashtag addresses
|
||||
if ((!$tryoembed OR $simplehtml) AND !in_array($simplehtml, array(3, 7)))
|
||||
if ((!$tryoembed OR $simplehtml) AND !in_array($simplehtml, array(3, 7))) {
|
||||
$Text = preg_replace("/([#@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $Text);
|
||||
elseif ($simplehtml == 3)
|
||||
} elseif ($simplehtml == 3) {
|
||||
$Text = preg_replace("/([@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
|
||||
'$1<a href="$2">$3</a>',
|
||||
$Text);
|
||||
elseif ($simplehtml == 7)
|
||||
} elseif ($simplehtml == 7) {
|
||||
$Text = preg_replace("/([@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
|
||||
'$1<span class="vcard"><a href="$2" class="url" title="$3"><span class="fn nickname mention">$3</span></a></span>',
|
||||
$Text);
|
||||
elseif (!$simplehtml)
|
||||
} elseif (!$simplehtml) {
|
||||
$Text = preg_replace("/([@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
|
||||
'$1<a href="$2" class="userinfo mention" title="$3">$3</a>',
|
||||
$Text);
|
||||
}
|
||||
|
||||
// Bookmarks in red - will be converted to bookmarks in friendica
|
||||
$Text = preg_replace("/#\^\[url\]([$URLSearchString]*)\[\/url\]/ism", '[bookmark=$1]$1[/bookmark]', $Text);
|
||||
|
@ -850,33 +919,37 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
|||
$Text = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", ' $2 [url]$1[/url]',$Text);
|
||||
}
|
||||
|
||||
if ($simplehtml == 5)
|
||||
if ($simplehtml == 5) {
|
||||
$Text = preg_replace("/[^#@]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[url]$1[/url]', $Text);
|
||||
}
|
||||
|
||||
// Perform URL Search
|
||||
if ($tryoembed)
|
||||
if ($tryoembed) {
|
||||
$Text = preg_replace_callback("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", 'tryoembed', $Text);
|
||||
}
|
||||
|
||||
if ($simplehtml == 5)
|
||||
if ($simplehtml == 5) {
|
||||
$Text = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", '[url]$1[/url]', $Text);
|
||||
else
|
||||
} else {
|
||||
$Text = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", '[url=$1]$2[/url]', $Text);
|
||||
}
|
||||
|
||||
// Handle Diaspora posts
|
||||
$Text = preg_replace_callback("&\[url=/posts/([^\[\]]*)\](.*)\[\/url\]&Usi", 'bb_DiasporaLinks', $Text);
|
||||
|
||||
// if the HTML is used to generate plain text, then don't do this search, but replace all URL of that kind to text
|
||||
// if ($simplehtml != 7) {
|
||||
if (!$forplaintext)
|
||||
if (!$forplaintext) {
|
||||
$Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1<a href="$2" target="_blank">$2</a>', $Text);
|
||||
else {
|
||||
} else {
|
||||
$Text = preg_replace("(\[url\]([$URLSearchString]*)\[\/url\])ism", " $1 ", $Text);
|
||||
$Text = preg_replace_callback("&\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]&Usi", 'bb_RemovePictureLinks', $Text);
|
||||
}
|
||||
// }
|
||||
|
||||
if ($tryoembed)
|
||||
if ($tryoembed) {
|
||||
$Text = preg_replace_callback("/\[url\]([$URLSearchString]*)\[\/url\]/ism", 'tryoembed', $Text);
|
||||
}
|
||||
|
||||
$Text = preg_replace("/([#])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
|
||||
'$1<a href="$2" class="tag" title="$3">$3</a>', $Text);
|
||||
|
@ -1007,8 +1080,9 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
|||
// Check for [spoiler] text
|
||||
// handle nested quotes
|
||||
$endlessloop = 0;
|
||||
while ((strpos($Text, "[/spoiler]") !== false) and (strpos($Text, "[spoiler]") !== false) and (++$endlessloop < 20))
|
||||
while ((strpos($Text, "[/spoiler]") !== false) and (strpos($Text, "[spoiler]") !== false) and (++$endlessloop < 20)) {
|
||||
$Text = preg_replace("/\[spoiler\](.*?)\[\/spoiler\]/ism", "$SpoilerLayout", $Text);
|
||||
}
|
||||
|
||||
// Check for [spoiler=Author] text
|
||||
|
||||
|
@ -1016,10 +1090,11 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
|||
|
||||
// handle nested quotes
|
||||
$endlessloop = 0;
|
||||
while ((strpos($Text, "[/spoiler]")!== false) and (strpos($Text, "[spoiler=") !== false) and (++$endlessloop < 20))
|
||||
while ((strpos($Text, "[/spoiler]")!== false) and (strpos($Text, "[spoiler=") !== false) and (++$endlessloop < 20)) {
|
||||
$Text = preg_replace("/\[spoiler=[\"\']*(.*?)[\"\']*\](.*?)\[\/spoiler\]/ism",
|
||||
"<br /><strong class=".'"spoiler"'.">" . $t_wrote . "</strong><blockquote class=".'"spoiler"'.">$2</blockquote>",
|
||||
$Text);
|
||||
}
|
||||
|
||||
// Declare the format for [quote] layout
|
||||
$QuoteLayout = '<blockquote>$1</blockquote>';
|
||||
|
@ -1027,8 +1102,9 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
|||
// Check for [quote] text
|
||||
// handle nested quotes
|
||||
$endlessloop = 0;
|
||||
while ((strpos($Text, "[/quote]") !== false) and (strpos($Text, "[quote]") !== false) and (++$endlessloop < 20))
|
||||
while ((strpos($Text, "[/quote]") !== false) and (strpos($Text, "[quote]") !== false) and (++$endlessloop < 20)) {
|
||||
$Text = preg_replace("/\[quote\](.*?)\[\/quote\]/ism", "$QuoteLayout", $Text);
|
||||
}
|
||||
|
||||
// Check for [quote=Author] text
|
||||
|
||||
|
@ -1036,10 +1112,11 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
|||
|
||||
// handle nested quotes
|
||||
$endlessloop = 0;
|
||||
while ((strpos($Text, "[/quote]")!== false) and (strpos($Text, "[quote=") !== false) and (++$endlessloop < 20))
|
||||
while ((strpos($Text, "[/quote]")!== false) and (strpos($Text, "[quote=") !== false) and (++$endlessloop < 20)) {
|
||||
$Text = preg_replace("/\[quote=[\"\']*(.*?)[\"\']*\](.*?)\[\/quote\]/ism",
|
||||
"<br /><strong class=".'"author"'.">" . $t_wrote . "</strong><blockquote>$2</blockquote>",
|
||||
$Text);
|
||||
}
|
||||
|
||||
|
||||
// [img=widthxheight]image source[/img]
|
||||
|
@ -1058,14 +1135,13 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
|||
// Shared content
|
||||
$Text = preg_replace_callback("/(.*?)\[share(.*?)\](.*?)\[\/share\]/ism",
|
||||
function ($match) use ($simplehtml) {
|
||||
return(bb_ShareAttributes($match, $simplehtml));
|
||||
return bb_ShareAttributes($match, $simplehtml);
|
||||
}, $Text);
|
||||
|
||||
$Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism", '<br/><img src="' .App::get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . t('Encrypted content') . '" /><br />', $Text);
|
||||
$Text = preg_replace("/\[crypt(.*?)\](.*?)\[\/crypt\]/ism", '<br/><img src="' .App::get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . '$1' . ' ' . t('Encrypted content') . '" /><br />', $Text);
|
||||
//$Text = preg_replace("/\[crypt=(.*?)\](.*?)\[\/crypt\]/ism", '<br/><img src="' .App::get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . '$1' . ' ' . t('Encrypted content') . '" /><br />', $Text);
|
||||
|
||||
|
||||
// Try to Oembed
|
||||
if ($tryoembed) {
|
||||
$Text = preg_replace("/\[video\](.*?\.(ogg|ogv|oga|ogm|webm|mp4))\[\/video\]/ism", '<video src="$1" controls="controls" width="' . $a->videowidth . '" height="' . $a->videoheight . '"><a href="$1">$1</a></video>', $Text);
|
||||
|
@ -1083,10 +1159,11 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
|||
// html5 video and audio
|
||||
|
||||
|
||||
if ($tryoembed)
|
||||
if ($tryoembed) {
|
||||
$Text = preg_replace("/\[iframe\](.*?)\[\/iframe\]/ism", '<iframe src="$1" width="' . $a->videowidth . '" height="' . $a->videoheight . '"><a href="$1">$1</a></iframe>', $Text);
|
||||
else
|
||||
} else {
|
||||
$Text = preg_replace("/\[iframe\](.*?)\[\/iframe\]/ism", '<a href="$1">$1</a>', $Text);
|
||||
}
|
||||
|
||||
// Youtube extensions
|
||||
if ($tryoembed) {
|
||||
|
@ -1099,11 +1176,12 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
|||
$Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/embed\/(.*?)\[\/youtube\]/ism", '[youtube]$1[/youtube]', $Text);
|
||||
$Text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/ism", '[youtube]$1[/youtube]', $Text);
|
||||
|
||||
if ($tryoembed)
|
||||
if ($tryoembed) {
|
||||
$Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '<iframe width="' . $a->videowidth . '" height="' . $a->videoheight . '" src="https://www.youtube.com/embed/$1" frameborder="0" ></iframe>', $Text);
|
||||
else
|
||||
} else {
|
||||
$Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism",
|
||||
'<a href="https://www.youtube.com/watch?v=$1" target="_blank">https://www.youtube.com/watch?v=$1</a>', $Text);
|
||||
}
|
||||
|
||||
if ($tryoembed) {
|
||||
$Text = preg_replace_callback("/\[vimeo\](https?:\/\/player.vimeo.com\/video\/[0-9]+).*?\[\/vimeo\]/ism", 'tryoembed', $Text);
|
||||
|
@ -1113,11 +1191,12 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
|||
$Text = preg_replace("/\[vimeo\]https?:\/\/player.vimeo.com\/video\/([0-9]+)(.*?)\[\/vimeo\]/ism", '[vimeo]$1[/vimeo]', $Text);
|
||||
$Text = preg_replace("/\[vimeo\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/vimeo\]/ism", '[vimeo]$1[/vimeo]', $Text);
|
||||
|
||||
if ($tryoembed)
|
||||
if ($tryoembed) {
|
||||
$Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '<iframe width="' . $a->videowidth . '" height="' . $a->videoheight . '" src="https://player.vimeo.com/video/$1" frameborder="0" ></iframe>', $Text);
|
||||
else
|
||||
} else {
|
||||
$Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism",
|
||||
'<a href="https://vimeo.com/$1" target="_blank">https://vimeo.com/$1</a>', $Text);
|
||||
}
|
||||
|
||||
// $Text = preg_replace("/\[youtube\](.*?)\[\/youtube\]/", '<object width="425" height="350" type="application/x-shockwave-flash" data="http://www.youtube.com/v/$1" ><param name="movie" value="http://www.youtube.com/v/$1"></param><!--[if IE]><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350" /><![endif]--></object>', $Text);
|
||||
|
||||
|
@ -1145,8 +1224,17 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
|||
}
|
||||
|
||||
|
||||
//replace oneliner <code> with <key>
|
||||
$Text = preg_replace_callback("|(?!<br[^>]*>)<code>([^<]*)</code>(?!<br[^>]*>)|ism", 'bb_onelinecode_cb', $Text);
|
||||
// Replace inline code blocks
|
||||
$Text = preg_replace_callback("|(?!<br[^>]*>)<code>([^<]*)</code>(?!<br[^>]*>)|ism",
|
||||
function ($match) use ($simplehtml) {
|
||||
$return = '<key>' . $match[1] . '</key>';
|
||||
// Use <code> for Diaspora inline code blocks
|
||||
if ($simplehtml === 3) {
|
||||
$return = '<code>' . $match[1] . '</code>';
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
, $Text);
|
||||
|
||||
// Unhide all [noparse] contained bbtags unspacefying them
|
||||
// and triming the [noparse] tag.
|
||||
|
@ -1253,4 +1341,3 @@ function fetch_abstract($text, $addon = "") {
|
|||
|
||||
return $abstract;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -9,12 +9,12 @@ function contact_profile_assign($current,$foreign_net) {
|
|||
|
||||
$o .= "<select id=\"contact-profile-selector\" class=\"form-control\" $disabled name=\"profile-assign\" />\r\n";
|
||||
|
||||
$r = q("SELECT `id`, `profile-name` FROM `profile` WHERE `uid` = %d",
|
||||
$r = q("SELECT `id`, `profile-name`, `is-default` FROM `profile` WHERE `uid` = %d",
|
||||
intval($_SESSION['uid']));
|
||||
|
||||
if (dbm::is_result($r)) {
|
||||
foreach ($r as $rr) {
|
||||
$selected = (($rr['id'] == $current) ? " selected=\"selected\" " : "");
|
||||
$selected = (($rr['id'] == $current || ($current == 0 && $rr['is-default'] == 1)) ? " selected=\"selected\" " : "");
|
||||
$o .= "<option value=\"{$rr['id']}\" $selected >{$rr['profile-name']}</option>\r\n";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ function follow_widget($value = "") {
|
|||
}
|
||||
|
||||
function findpeople_widget() {
|
||||
require_once('include/Contact.php');
|
||||
require_once 'include/Contact.php';
|
||||
|
||||
$a = get_app();
|
||||
|
||||
|
@ -45,32 +45,41 @@ function unavailable_networks() {
|
|||
|
||||
$networks = array();
|
||||
|
||||
if (!plugin_enabled("appnet"))
|
||||
if (!plugin_enabled("appnet")) {
|
||||
$networks[] = NETWORK_APPNET;
|
||||
}
|
||||
|
||||
if (!plugin_enabled("fbpost") AND !plugin_enabled("facebook"))
|
||||
if (!plugin_enabled("fbpost") AND !plugin_enabled("facebook")) {
|
||||
$networks[] = NETWORK_FACEBOOK;
|
||||
}
|
||||
|
||||
if (!plugin_enabled("statusnet"))
|
||||
if (!plugin_enabled("statusnet")) {
|
||||
$networks[] = NETWORK_STATUSNET;
|
||||
}
|
||||
|
||||
if (!plugin_enabled("pumpio"))
|
||||
if (!plugin_enabled("pumpio")) {
|
||||
$networks[] = NETWORK_PUMPIO;
|
||||
}
|
||||
|
||||
if (!plugin_enabled("twitter"))
|
||||
if (!plugin_enabled("twitter")) {
|
||||
$networks[] = NETWORK_TWITTER;
|
||||
}
|
||||
|
||||
if (get_config("system","ostatus_disabled"))
|
||||
if (get_config("system", "ostatus_disabled")) {
|
||||
$networks[] = NETWORK_OSTATUS;
|
||||
}
|
||||
|
||||
if (!get_config("system","diaspora_enabled"))
|
||||
if (!get_config("system", "diaspora_enabled")) {
|
||||
$networks[] = NETWORK_DIASPORA;
|
||||
}
|
||||
|
||||
if (!plugin_enabled("pnut"))
|
||||
if (!plugin_enabled("pnut")) {
|
||||
$networks[] = NETWORK_PNUT;
|
||||
}
|
||||
|
||||
if (!sizeof($networks))
|
||||
if (!sizeof($networks)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
$network_filter = implode("','", $networks);
|
||||
|
||||
|
@ -99,7 +108,7 @@ function networks_widget($baseurl,$selected = '') {
|
|||
|
||||
$nets = array();
|
||||
if (dbm::is_result($r)) {
|
||||
require_once('include/contact_selectors.php');
|
||||
require_once 'include/contact_selectors.php';
|
||||
foreach ($r as $rr) {
|
||||
/// @TODO If 'network' is not there, this triggers an E_NOTICE
|
||||
if ($rr['network']) {
|
||||
|
@ -108,8 +117,9 @@ function networks_widget($baseurl,$selected = '') {
|
|||
}
|
||||
}
|
||||
|
||||
if(count($nets) < 2)
|
||||
if (count($nets) < 2) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return replace_macros(get_markup_template('nets.tpl'), array(
|
||||
'$title' => t('Networks'),
|
||||
|
@ -173,6 +183,7 @@ function categories_widget($baseurl,$selected = '') {
|
|||
$matches = false;
|
||||
$terms = array();
|
||||
$cnt = preg_match_all('/<(.*?)>/', $saved, $matches, PREG_SET_ORDER);
|
||||
|
||||
if ($cnt) {
|
||||
foreach ($matches as $mtch) {
|
||||
$unescaped = xmlify(file_tag_decode($mtch[1]));
|
||||
|
@ -195,8 +206,9 @@ function common_friends_visitor_widget($profile_uid) {
|
|||
|
||||
$a = get_app();
|
||||
|
||||
if(local_user() == $profile_uid)
|
||||
if (local_user() == $profile_uid) {
|
||||
return;
|
||||
}
|
||||
|
||||
$cid = $zcid = 0;
|
||||
|
||||
|
@ -215,9 +227,9 @@ function common_friends_visitor_widget($profile_uid) {
|
|||
dbesc(normalise_link(get_my_url())),
|
||||
intval($profile_uid)
|
||||
);
|
||||
if (dbm::is_result($r))
|
||||
if (dbm::is_result($r)) {
|
||||
$cid = $r[0]['id'];
|
||||
else {
|
||||
} else {
|
||||
$r = q("select id from gcontact where nurl = '%s' limit 1",
|
||||
dbesc(normalise_link(get_my_url()))
|
||||
);
|
||||
|
@ -227,22 +239,26 @@ function common_friends_visitor_widget($profile_uid) {
|
|||
}
|
||||
}
|
||||
|
||||
if($cid == 0 && $zcid == 0)
|
||||
if ($cid == 0 && $zcid == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
require_once('include/socgraph.php');
|
||||
require_once 'include/socgraph.php';
|
||||
|
||||
if($cid)
|
||||
if ($cid) {
|
||||
$t = count_common_friends($profile_uid, $cid);
|
||||
else
|
||||
} else {
|
||||
$t = count_common_friends_zcid($profile_uid, $zcid);
|
||||
if(! $t)
|
||||
}
|
||||
if (! $t) {
|
||||
return;
|
||||
}
|
||||
|
||||
if($cid)
|
||||
if ($cid) {
|
||||
$r = common_friends($profile_uid, $cid, 0, 5, true);
|
||||
else
|
||||
} else {
|
||||
$r = common_friends_zcid($profile_uid, $zcid, 0, 5, true);
|
||||
}
|
||||
|
||||
return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
|
||||
'$desc' => sprintf( tt("%d contact in common", "%d contacts in common", $t), $t),
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
<?php
|
||||
|
||||
require_once("include/bbcode.php");
|
||||
require_once("include/acl_selectors.php");
|
||||
require_once "include/bbcode.php";
|
||||
require_once "include/acl_selectors.php";
|
||||
|
||||
|
||||
// Note: the code in 'item_extract_images' and 'item_redir_and_replace_images'
|
||||
// is identical to the code in mod/message.php for 'item_extract_images' and
|
||||
// 'item_redir_and_replace_images'
|
||||
/*
|
||||
* Note: the code in 'item_extract_images' and 'item_redir_and_replace_images'
|
||||
* is identical to the code in mod/message.php for 'item_extract_images' and
|
||||
* 'item_redir_and_replace_images'
|
||||
*/
|
||||
if (! function_exists('item_extract_images')) {
|
||||
function item_extract_images($body) {
|
||||
|
||||
|
@ -30,14 +32,16 @@ function item_extract_images($body) {
|
|||
$new_body = $new_body . substr($orig_body, 0, $img_start) . '[!#saved_image' . $cnt . '#!]';
|
||||
|
||||
$cnt++;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
$new_body = $new_body . substr($orig_body, 0, $img_end + strlen('[/img]'));
|
||||
}
|
||||
|
||||
$orig_body = substr($orig_body, $img_end + strlen('[/img]'));
|
||||
|
||||
if($orig_body === false) // in case the body ends on a closing image tag
|
||||
if ($orig_body === false) {
|
||||
// in case the body ends on a closing image tag
|
||||
$orig_body = '';
|
||||
}
|
||||
|
||||
$img_start = strpos($orig_body, '[img');
|
||||
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
|
||||
|
@ -66,8 +70,9 @@ function item_redir_and_replace_images($body, $images, $cid) {
|
|||
$newbody .= substr($origbody, 0, $pos['start']['open']);
|
||||
$subject = substr($origbody, $pos['start']['open'], $pos['end']['close'] - $pos['start']['open']);
|
||||
$origbody = substr($origbody, $pos['end']['close']);
|
||||
if($origbody === false)
|
||||
if ($origbody === false) {
|
||||
$origbody = '';
|
||||
}
|
||||
|
||||
$subject = preg_replace($search, $replace, $subject);
|
||||
$newbody .= $subject;
|
||||
|
@ -79,26 +84,28 @@ function item_redir_and_replace_images($body, $images, $cid) {
|
|||
|
||||
$cnt = 0;
|
||||
foreach ($images as $image) {
|
||||
// We're depending on the property of 'foreach' (specified on the PHP website) that
|
||||
// it loops over the array starting from the first element and going sequentially
|
||||
// to the last element
|
||||
/*
|
||||
* We're depending on the property of 'foreach' (specified on the PHP website) that
|
||||
* it loops over the array starting from the first element and going sequentially
|
||||
* to the last element.
|
||||
*/
|
||||
$newbody = str_replace('[!#saved_image' . $cnt . '#!]', '[img]' . $image . '[/img]', $newbody);
|
||||
$cnt++;
|
||||
}
|
||||
return $newbody;
|
||||
}}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Render actions localized
|
||||
*/
|
||||
function localize_item(&$item) {
|
||||
|
||||
$extracted = item_extract_images($item['body']);
|
||||
if($extracted['images'])
|
||||
if ($extracted['images']) {
|
||||
$item['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $item['contact-id']);
|
||||
}
|
||||
|
||||
/// @Separted ???
|
||||
$xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
|
||||
if (activity_match($item['verb'], ACTIVITY_LIKE)
|
||||
|| activity_match($item['verb'], ACTIVITY_DISLIKE)
|
||||
|
@ -106,10 +113,14 @@ function localize_item(&$item){
|
|||
|| activity_match($item['verb'], ACTIVITY_ATTENDNO)
|
||||
|| activity_match($item['verb'], ACTIVITY_ATTENDMAYBE)) {
|
||||
|
||||
$r = q("SELECT * from `item`,`contact` WHERE
|
||||
`item`.`contact-id`=`contact`.`id` AND `item`.`uri`='%s';",
|
||||
/// @TODO may hurt performance
|
||||
$r = q("SELECT * FROM `item`, `contact`
|
||||
WHERE `item`.`contact-id`=`contact`.`id`
|
||||
AND `item`.`uri`='%s'",
|
||||
dbesc($item['parent-uri']));
|
||||
if (!dbm::is_result($r)) return;
|
||||
if (!dbm::is_result($r)) {
|
||||
return;
|
||||
}
|
||||
$obj = $r[0];
|
||||
|
||||
$author = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
|
||||
|
@ -128,7 +139,8 @@ function localize_item(&$item){
|
|||
default:
|
||||
if ($obj['resource-id']) {
|
||||
$post_type = t('photo');
|
||||
$m=array(); preg_match("/\[url=([^]]*)\]/", $obj['body'], $m);
|
||||
$m = array();
|
||||
preg_match("/\[url=([^]]*)\]/", $obj['body'], $m);
|
||||
$rr['plink'] = $m[1];
|
||||
} else {
|
||||
$post_type = t('status');
|
||||
|
@ -175,21 +187,25 @@ function localize_item(&$item){
|
|||
case "alternate": $Blink = $atts['href'];
|
||||
case "photo": $Bphoto = $atts['href'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$A = '[url=' . zrl($Alink) . ']' . $Aname . '[/url]';
|
||||
$B = '[url=' . zrl($Blink) . ']' . $Bname . '[/url]';
|
||||
if ($Bphoto!="") $Bphoto = '[url=' . zrl($Blink) . '][img]' . $Bphoto . '[/img][/url]';
|
||||
if ($Bphoto != "") {
|
||||
$Bphoto = '[url=' . zrl($Blink) . '][img]' . $Bphoto . '[/img][/url]';
|
||||
}
|
||||
|
||||
$item['body'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$Bphoto;
|
||||
|
||||
}
|
||||
if (stristr($item['verb'], ACTIVITY_POKE)) {
|
||||
$verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1));
|
||||
if(! $verb)
|
||||
if (! $verb) {
|
||||
return;
|
||||
if ($item['object-type']=="" || $item['object-type']!== ACTIVITY_OBJ_PERSON) return;
|
||||
}
|
||||
if ($item['object-type']=="" || $item['object-type']!== ACTIVITY_OBJ_PERSON) {
|
||||
return;
|
||||
}
|
||||
|
||||
$Aname = $item['author-name'];
|
||||
$Alink = $item['author-link'];
|
||||
|
@ -200,22 +216,26 @@ function localize_item(&$item){
|
|||
$links = parse_xml_string($xmlhead."<links>".unxmlify($obj->link)."</links>");
|
||||
|
||||
$Bname = $obj->title;
|
||||
$Blink = ""; $Bphoto = "";
|
||||
$Blink = "";
|
||||
$Bphoto = "";
|
||||
foreach ($links->link as $l) {
|
||||
$atts = $l->attributes();
|
||||
switch ($atts['rel']) {
|
||||
case "alternate": $Blink = $atts['href'];
|
||||
case "photo": $Bphoto = $atts['href'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$A = '[url=' . zrl($Alink) . ']' . $Aname . '[/url]';
|
||||
$B = '[url=' . zrl($Blink) . ']' . $Bname . '[/url]';
|
||||
if ($Bphoto!="") $Bphoto = '[url=' . zrl($Blink) . '][img=80x80]' . $Bphoto . '[/img][/url]';
|
||||
if ($Bphoto != "") {
|
||||
$Bphoto = '[url=' . zrl($Blink) . '][img=80x80]' . $Bphoto . '[/img][/url]';
|
||||
}
|
||||
|
||||
// we can't have a translation string with three positions but no distinguishable text
|
||||
// So here is the translate string.
|
||||
/*
|
||||
* we can't have a translation string with three positions but no distinguishable text
|
||||
* So here is the translate string.
|
||||
*/
|
||||
$txt = t('%1$s poked %2$s');
|
||||
|
||||
// now translate the verb
|
||||
|
@ -229,8 +249,9 @@ function localize_item(&$item){
|
|||
}
|
||||
if (stristr($item['verb'], ACTIVITY_MOOD)) {
|
||||
$verb = urldecode(substr($item['verb'], strpos($item['verb'], '#') + 1));
|
||||
if(! $verb)
|
||||
if (! $verb) {
|
||||
return;
|
||||
}
|
||||
|
||||
$Aname = $item['author-name'];
|
||||
$Alink = $item['author-link'];
|
||||
|
@ -242,10 +263,16 @@ function localize_item(&$item){
|
|||
}
|
||||
|
||||
if (activity_match($item['verb'], ACTIVITY_TAG)) {
|
||||
$r = q("SELECT * from `item`,`contact` WHERE
|
||||
`item`.`contact-id`=`contact`.`id` AND `item`.`uri`='%s';",
|
||||
/// @TODO may hurt performance "joining" two tables + asterisk
|
||||
$r = q("SELECT * FROM `item`, `contact`
|
||||
WHERE `item`.`contact-id`=`contact`.`id`
|
||||
AND `item`.`uri`='%s'",
|
||||
dbesc($item['parent-uri']));
|
||||
if (!dbm::is_result($r)) return;
|
||||
|
||||
if (!dbm::is_result($r)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$obj = $r[0];
|
||||
|
||||
$author = '[url=' . zrl($item['author-link']) . ']' . $item['author-name'] . '[/url]';
|
||||
|
@ -269,6 +296,8 @@ function localize_item(&$item){
|
|||
} else {
|
||||
$post_type = t('status');
|
||||
}
|
||||
// Let's break everthing ... ;-)
|
||||
break;
|
||||
}
|
||||
$plink = '[url=' . $obj['plink'] . ']' . $post_type . '[/url]';
|
||||
|
||||
|
@ -280,8 +309,9 @@ function localize_item(&$item){
|
|||
}
|
||||
if (activity_match($item['verb'], ACTIVITY_FAVORITE)) {
|
||||
|
||||
if ($item['object-type']== "")
|
||||
if ($item['object-type'] == "") {
|
||||
return;
|
||||
}
|
||||
|
||||
$Aname = $item['author-name'];
|
||||
$Alink = $item['author-link'];
|
||||
|
@ -290,10 +320,11 @@ function localize_item(&$item){
|
|||
|
||||
$obj = parse_xml_string($xmlhead.$item['object']);
|
||||
if (strlen($obj->id)) {
|
||||
$r = q("select * from item where uri = '%s' and uid = %d limit 1",
|
||||
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc($obj->id),
|
||||
intval($item['uid'])
|
||||
);
|
||||
|
||||
if (dbm::is_result($r) && $r[0]['plink']) {
|
||||
$target = $r[0];
|
||||
$Bname = $target['author-name'];
|
||||
|
@ -302,17 +333,17 @@ function localize_item(&$item){
|
|||
$B = '[url=' . zrl($Blink) . ']' . $Bname . '[/url]';
|
||||
$P = '[url=' . $target['plink'] . ']' . t('post/item') . '[/url]';
|
||||
$item['body'] = sprintf( t('%1$s marked %2$s\'s %3$s as favorite'), $A, $B, $P)."\n";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
$matches = null;
|
||||
if (preg_match_all('/@\[url=(.*?)\]/is', $item['body'], $matches, PREG_SET_ORDER)) {
|
||||
foreach ($matches as $mtch) {
|
||||
if(! strpos($mtch[1],'zrl='))
|
||||
if (! strpos($mtch[1], 'zrl=')) {
|
||||
$item['body'] = str_replace($mtch[0], '@[url=' . zrl($mtch[1]) . ']', $item['body']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add zrl's to public images
|
||||
$photo_pattern = "/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is";
|
||||
|
@ -332,21 +363,20 @@ function localize_item(&$item){
|
|||
$item['plink'] = $y . '?f=&url=' . $item['plink'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the total of comments on this item and its desendants
|
||||
* @TODO proper type-hint + doc-tag
|
||||
*/
|
||||
function count_descendants($item) {
|
||||
$total = count($item['children']);
|
||||
|
||||
if ($total > 0) {
|
||||
foreach ($item['children'] as $child) {
|
||||
if(! visible_activity($child))
|
||||
if (! visible_activity($child)) {
|
||||
$total --;
|
||||
}
|
||||
$total += count_descendants($child);
|
||||
}
|
||||
}
|
||||
|
@ -356,9 +386,10 @@ function count_descendants($item) {
|
|||
|
||||
function visible_activity($item) {
|
||||
|
||||
// likes (etc.) can apply to other things besides posts. Check if they are post children,
|
||||
// in which case we handle them specially
|
||||
|
||||
/*
|
||||
* likes (etc.) can apply to other things besides posts. Check if they are post children,
|
||||
* in which case we handle them specially
|
||||
*/
|
||||
$hidden_activities = array(ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
|
||||
foreach ($hidden_activities as $act) {
|
||||
if (activity_match($item['verb'], $act)) {
|
||||
|
@ -379,7 +410,6 @@ function visible_activity($item) {
|
|||
* @brief SQL query for items
|
||||
*/
|
||||
function item_query() {
|
||||
|
||||
return "SELECT " . item_fieldlists() . " FROM `item` " .
|
||||
item_joins() . " WHERE " . item_condition();
|
||||
}
|
||||
|
@ -439,7 +469,6 @@ These Fields are not added below (yet). They are here to for bug search.
|
|||
* @brief SQL join for contacts that are needed for displaying items
|
||||
*/
|
||||
function item_joins() {
|
||||
|
||||
return "STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND
|
||||
(NOT `contact`.`blocked` OR `contact`.`pending`)
|
||||
LEFT JOIN `contact` AS `author` ON `author`.`id`=`item`.`author-id`
|
||||
|
@ -450,10 +479,10 @@ function item_joins() {
|
|||
* @brief SQL condition for items that are needed for displaying items
|
||||
*/
|
||||
function item_condition() {
|
||||
|
||||
return "`item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`";
|
||||
}
|
||||
|
||||
if (!function_exists('conversation')) {
|
||||
/**
|
||||
* "Render" a conversation or list of items for HTML display.
|
||||
* There are two major forms of display:
|
||||
|
@ -464,13 +493,11 @@ function item_condition() {
|
|||
* that are based on unique features of the calling module.
|
||||
*
|
||||
*/
|
||||
|
||||
if(!function_exists('conversation')) {
|
||||
function conversation(App $a, $items, $mode, $update, $preview = false) {
|
||||
|
||||
require_once('include/bbcode.php');
|
||||
require_once('include/Contact.php');
|
||||
require_once('mod/proxy.php');
|
||||
require_once 'include/bbcode.php';
|
||||
require_once 'include/Contact.php';
|
||||
require_once 'mod/proxy.php';
|
||||
|
||||
$ssl_state = ((local_user()) ? true : false);
|
||||
|
||||
|
@ -484,9 +511,10 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
$str_blocked = get_pconfig(local_user(), 'system', 'blocked');
|
||||
if ($str_blocked) {
|
||||
$arr_blocked = explode(',', $str_blocked);
|
||||
for($x = 0; $x < count($arr_blocked); $x ++)
|
||||
for ($x = 0; $x < count($arr_blocked); $x ++) {
|
||||
$arr_blocked[$x] = trim($arr_blocked[$x]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -496,10 +524,11 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
$profile_owner = local_user();
|
||||
$page_writeable = true;
|
||||
if (!$update) {
|
||||
// The special div is needed for liveUpdate to kick in for this page.
|
||||
// We only launch liveUpdate if you aren't filtering in some incompatible
|
||||
// way and also you aren't writing a comment (discovered in javascript).
|
||||
|
||||
/*
|
||||
* The special div is needed for liveUpdate to kick in for this page.
|
||||
* We only launch liveUpdate if you aren't filtering in some incompatible
|
||||
* way and also you aren't writing a comment (discovered in javascript).
|
||||
*/
|
||||
$live_update_div = '<div id="live-network"></div>' . "\r\n"
|
||||
. "<script> var profile_uid = " . $_SESSION['uid']
|
||||
. "; var netargs = '" . substr($a->cmd, 8)
|
||||
|
@ -519,8 +548,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
|
||||
. "'; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
|
||||
}
|
||||
}
|
||||
else if($mode === 'profile') {
|
||||
} elseif ($mode === 'profile') {
|
||||
$profile_owner = $a->profile['profile_uid'];
|
||||
$page_writeable = can_write_wall($a,$profile_owner);
|
||||
|
||||
|
@ -528,16 +556,17 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
$tab = notags(trim($_GET['tab']));
|
||||
$tab = ( $tab ? $tab : 'posts' );
|
||||
if ($tab === 'posts') {
|
||||
// This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
|
||||
// because browser prefetching might change it on us. We have to deliver it with the page.
|
||||
/*
|
||||
* This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
|
||||
* because browser prefetching might change it on us. We have to deliver it with the page.
|
||||
*/
|
||||
|
||||
$live_update_div = '<div id="live-profile"></div>' . "\r\n"
|
||||
. "<script> var profile_uid = " . $a->profile['profile_uid']
|
||||
. "; var netargs = '?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if($mode === 'notes') {
|
||||
} elseif ($mode === 'notes') {
|
||||
$profile_owner = local_user();
|
||||
$page_writeable = true;
|
||||
if (!$update) {
|
||||
|
@ -545,8 +574,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
. "<script> var profile_uid = " . local_user()
|
||||
. "; var netargs = '/?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
|
||||
}
|
||||
}
|
||||
else if($mode === 'display') {
|
||||
} elseif ($mode === 'display') {
|
||||
$profile_owner = $a->profile['uid'];
|
||||
$page_writeable = can_write_wall($a,$profile_owner);
|
||||
if (!$update) {
|
||||
|
@ -554,26 +582,25 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
. "<script> var profile_uid = " . $_SESSION['uid'] . ";"
|
||||
. " var profile_page = 1; </script>";
|
||||
}
|
||||
}
|
||||
else if($mode === 'community') {
|
||||
} elseif ($mode === 'community') {
|
||||
$profile_owner = 0;
|
||||
$page_writeable = false;
|
||||
if (!$update) {
|
||||
$live_update_div = '<div id="live-community"></div>' . "\r\n"
|
||||
. "<script> var profile_uid = -1; var netargs = '/?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
|
||||
}
|
||||
}
|
||||
else if($mode === 'search') {
|
||||
} elseif ($mode === 'search') {
|
||||
$live_update_div = '<div id="live-search"></div>' . "\r\n";
|
||||
}
|
||||
|
||||
$page_dropping = ((local_user() && local_user() == $profile_owner) ? true : false);
|
||||
|
||||
|
||||
if($update)
|
||||
if ($update) {
|
||||
$return_url = $_SESSION['return_url'];
|
||||
else
|
||||
} else {
|
||||
$return_url = $_SESSION['return_url'] = $a->query_string;
|
||||
}
|
||||
|
||||
$cb = array('items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview);
|
||||
call_hooks('conversation_start',$cb);
|
||||
|
@ -598,9 +625,12 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
|
||||
if ($mode === 'network-new' || $mode === 'search' || $mode === 'community') {
|
||||
|
||||
// "New Item View" on network page or search page results
|
||||
// - just loop through the items and format them minimally for display
|
||||
/*
|
||||
* "New Item View" on network page or search page results
|
||||
* - just loop through the items and format them minimally for display
|
||||
*/
|
||||
|
||||
/// @TODO old lost code?
|
||||
// $tpl = get_markup_template('search_item.tpl');
|
||||
$tpl = 'search_item.tpl';
|
||||
|
||||
|
@ -614,9 +644,10 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if($blocked)
|
||||
if ($blocked) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$threadsid++;
|
||||
|
@ -631,19 +662,19 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
&& ($item['id'] != $item['parent']))
|
||||
continue;
|
||||
$nickname = $item['nickname'];
|
||||
}
|
||||
else
|
||||
} else {
|
||||
$nickname = $a->user['nickname'];
|
||||
}
|
||||
|
||||
// prevent private email from leaking.
|
||||
if($item['network'] === NETWORK_MAIL && local_user() != $item['uid'])
|
||||
if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
|
||||
if($item['author-link'] && (! $item['author-name']))
|
||||
if ($item['author-link'] && (! $item['author-name'])) {
|
||||
$profile_name = $item['author-link'];
|
||||
|
||||
|
||||
}
|
||||
|
||||
$tags = array();
|
||||
$hashtags = array();
|
||||
|
@ -654,8 +685,9 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
|
||||
foreach ($taglist as $tag) {
|
||||
|
||||
if ($tag["url"] == "")
|
||||
if ($tag["url"] == "") {
|
||||
$tag["url"] = $searchpath . strtolower($tag["term"]);
|
||||
}
|
||||
|
||||
if ($tag["type"] == TERM_HASHTAG) {
|
||||
$hashtags[] = "#<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
|
||||
|
@ -669,28 +701,33 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
|
||||
$sp = false;
|
||||
$profile_link = best_link_url($item,$sp);
|
||||
if($profile_link === 'mailbox')
|
||||
if ($profile_link === 'mailbox') {
|
||||
$profile_link = '';
|
||||
if($sp)
|
||||
$sparkle = ' sparkle';
|
||||
else
|
||||
$profile_link = zrl($profile_link);
|
||||
}
|
||||
|
||||
if (!isset($item['author-thumb']) OR ($item['author-thumb'] == "")) {
|
||||
if ($sp) {
|
||||
$sparkle = ' sparkle';
|
||||
} else {
|
||||
$profile_link = zrl($profile_link);
|
||||
}
|
||||
|
||||
if (!x($item, 'author-thumb') OR ($item['author-thumb'] == "")) {
|
||||
$author_contact = get_contact_details_by_url($item['author-link'], $profile_owner);
|
||||
if ($author_contact["thumb"])
|
||||
if ($author_contact["thumb"]) {
|
||||
$item['author-thumb'] = $author_contact["thumb"];
|
||||
else
|
||||
} else {
|
||||
$item['author-thumb'] = $item['author-avatar'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($item['owner-thumb']) OR ($item['owner-thumb'] == "")) {
|
||||
$owner_contact = get_contact_details_by_url($item['owner-link'], $profile_owner);
|
||||
if ($owner_contact["thumb"])
|
||||
if ($owner_contact["thumb"]) {
|
||||
$item['owner-thumb'] = $owner_contact["thumb"];
|
||||
else
|
||||
} else {
|
||||
$item['owner-thumb'] = $item['owner-avatar'];
|
||||
}
|
||||
}
|
||||
|
||||
$locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => '');
|
||||
call_hooks('render_location',$locate);
|
||||
|
@ -698,11 +735,11 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
$location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate));
|
||||
|
||||
localize_item($item);
|
||||
if($mode === 'network-new')
|
||||
if ($mode === 'network-new') {
|
||||
$dropping = true;
|
||||
else
|
||||
} else {
|
||||
$dropping = false;
|
||||
|
||||
}
|
||||
|
||||
$drop = array(
|
||||
'dropping' => $dropping,
|
||||
|
@ -720,7 +757,6 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
|
||||
$body = prepare_body($item, true, $preview);
|
||||
|
||||
|
||||
list($categories, $folders) = get_cats_and_terms($item);
|
||||
|
||||
if ($a->theme['template_engine'] === 'internal') {
|
||||
|
@ -732,8 +768,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
$mentions_e = template_escape($mentions);
|
||||
$location_e = template_escape($location);
|
||||
$owner_name_e = template_escape($owner_name);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$profile_name_e = $profile_name;
|
||||
$item['title_e'] = $item['title'];
|
||||
$body_e = $body;
|
||||
|
@ -744,8 +779,9 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
$owner_name_e = $owner_name;
|
||||
}
|
||||
|
||||
if ($item['item_network'] == "")
|
||||
if ($item['item_network'] == "") {
|
||||
$item['item_network'] = $item['network'];
|
||||
}
|
||||
|
||||
$tmp_item = array(
|
||||
'template' => $tpl,
|
||||
|
@ -802,38 +838,35 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
$threads[$threadsid]['items'] = array($arr['output']);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Normal View
|
||||
$page_template = get_markup_template("threaded_conversation.tpl");
|
||||
|
||||
require_once('object/Conversation.php');
|
||||
require_once('object/Item.php');
|
||||
require_once 'object/Conversation.php';
|
||||
require_once 'object/Item.php';
|
||||
|
||||
$conv = new Conversation($mode, $preview);
|
||||
|
||||
// get all the topmost parents
|
||||
// this shouldn't be needed, as we should have only them in our array
|
||||
// But for now, this array respects the old style, just in case
|
||||
|
||||
/*
|
||||
* get all the topmost parents
|
||||
* this shouldn't be needed, as we should have only them in our array
|
||||
* But for now, this array respects the old style, just in case
|
||||
*/
|
||||
$threads = array();
|
||||
foreach ($items as $item) {
|
||||
|
||||
if ($arr_blocked) {
|
||||
$blocked = false;
|
||||
foreach ($arr_blocked as $b) {
|
||||
|
||||
if ($b && link_compare($item['author-link'], $b)) {
|
||||
$blocked = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($blocked)
|
||||
if ($blocked) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Can we put this after the visibility check?
|
||||
builtin_activity_puller($item, $conv_responses);
|
||||
|
@ -842,6 +875,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! visible_activity($item)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -889,25 +923,25 @@ function best_link_url($item,&$sparkle,$ssl_state = false) {
|
|||
if (local_user()) {
|
||||
$r = q("SELECT `id` FROM `contact` WHERE `network` = '%s' AND `uid` = %d AND `nurl` = '%s' AND NOT `pending` LIMIT 1",
|
||||
dbesc(NETWORK_DFRN), intval(local_user()), dbesc(normalise_link($clean_url)));
|
||||
if ($r) {
|
||||
if (dbm::is_result($r)) {
|
||||
$best_url = 'redir/' . $r[0]['id'];
|
||||
$sparkle = true;
|
||||
}
|
||||
}
|
||||
if (! $best_url) {
|
||||
if(strlen($item['author-link']))
|
||||
if (strlen($item['author-link'])) {
|
||||
$best_url = $item['author-link'];
|
||||
else
|
||||
} else {
|
||||
$best_url = $item['url'];
|
||||
}
|
||||
}
|
||||
|
||||
return $best_url;
|
||||
}
|
||||
|
||||
|
||||
if (! function_exists('item_photo_menu')) {
|
||||
function item_photo_menu($item)
|
||||
{
|
||||
function item_photo_menu($item) {
|
||||
$ssl_state = false;
|
||||
|
||||
if (local_user()) {
|
||||
|
@ -938,7 +972,7 @@ function item_photo_menu($item)
|
|||
$rel = 0;
|
||||
$r = q("SELECT `id`, `network`, `rel` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' LIMIT 1",
|
||||
intval(local_user()), dbesc(normalise_link($item['author-link'])));
|
||||
if ($r) {
|
||||
if (dbm::is_result($r)) {
|
||||
$cid = $r[0]['id'];
|
||||
$network = $r[0]['network'];
|
||||
$rel = $r[0]['rel'];
|
||||
|
@ -964,7 +998,7 @@ function item_photo_menu($item)
|
|||
}
|
||||
|
||||
if (local_user()) {
|
||||
$menu = Array(
|
||||
$menu = array(
|
||||
t('Follow Thread') => $sub_link,
|
||||
t('View Status') => $status_link,
|
||||
t('View Profile') => $profile_link,
|
||||
|
@ -1004,6 +1038,7 @@ function item_photo_menu($item)
|
|||
return $o;
|
||||
}}
|
||||
|
||||
if (! function_exists('builtin_activity_puller')) {
|
||||
/**
|
||||
* @brief Checks item to see if it is one of the builtin activities (like/dislike, event attendance, consensus items, etc.)
|
||||
* Increments the count of each matching activity and adds a link to the author as needed.
|
||||
|
@ -1012,7 +1047,6 @@ function item_photo_menu($item)
|
|||
* @param array &$conv_responses (already created with builtin activity structure)
|
||||
* @return void
|
||||
*/
|
||||
if(! function_exists('builtin_activity_puller')) {
|
||||
function builtin_activity_puller($item, &$conv_responses) {
|
||||
foreach ($conv_responses as $mode => $v) {
|
||||
$url = '';
|
||||
|
@ -1044,27 +1078,31 @@ function builtin_activity_puller($item, &$conv_responses) {
|
|||
if ((local_user()) && (local_user() == $item['uid']) && ($item['network'] === NETWORK_DFRN) && (! $item['self']) && (link_compare($item['author-link'], $item['url']))) {
|
||||
$url = 'redir/' . $item['contact-id'];
|
||||
$sparkle = ' class="sparkle" ';
|
||||
}
|
||||
else
|
||||
} else {
|
||||
$url = zrl($url);
|
||||
}
|
||||
|
||||
$url = '<a href="'. $url . '"'. $sparkle .'>' . htmlentities($item['author-name']) . '</a>';
|
||||
|
||||
if(! $item['thr-parent'])
|
||||
if (! $item['thr-parent']) {
|
||||
$item['thr-parent'] = $item['parent-uri'];
|
||||
}
|
||||
|
||||
if (! ((isset($conv_responses[$mode][$item['thr-parent'] . '-l']))
|
||||
&& (is_array($conv_responses[$mode][$item['thr-parent'] . '-l']))))
|
||||
&& (is_array($conv_responses[$mode][$item['thr-parent'] . '-l'])))) {
|
||||
$conv_responses[$mode][$item['thr-parent'] . '-l'] = array();
|
||||
}
|
||||
|
||||
// only list each unique author once
|
||||
if(in_array($url,$conv_responses[$mode][$item['thr-parent'] . '-l']))
|
||||
if (in_array($url,$conv_responses[$mode][$item['thr-parent'] . '-l'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(! isset($conv_responses[$mode][$item['thr-parent']]))
|
||||
if (! isset($conv_responses[$mode][$item['thr-parent']])) {
|
||||
$conv_responses[$mode][$item['thr-parent']] = 1;
|
||||
else
|
||||
} else {
|
||||
$conv_responses[$mode][$item['thr-parent']] ++;
|
||||
}
|
||||
|
||||
if (public_contact() == $item['author-id']) {
|
||||
$conv_responses[$mode][$item['thr-parent'] . '-self'] = 1;
|
||||
|
@ -1078,15 +1116,16 @@ function builtin_activity_puller($item, &$conv_responses) {
|
|||
}
|
||||
}}
|
||||
|
||||
// Format the vote text for a profile item
|
||||
// $cnt = number of people who vote the item
|
||||
// $arr = array of pre-linked names of likers/dislikers
|
||||
// $type = one of 'like, 'dislike', 'attendyes', 'attendno', 'attendmaybe'
|
||||
// $id = item id
|
||||
// returns formatted text
|
||||
|
||||
if (! function_exists('format_like')) {
|
||||
function format_like($cnt,$arr,$type,$id) {
|
||||
/**
|
||||
* Format the vote text for a profile item
|
||||
* @param int $cnt = number of people who vote the item
|
||||
* @param array $arr = array of pre-linked names of likers/dislikers
|
||||
* @param string $type = one of 'like, 'dislike', 'attendyes', 'attendno', 'attendmaybe'
|
||||
* @param int $id = item id
|
||||
* @return formatted text
|
||||
*/
|
||||
function format_like($cnt, array $arr, $type, $id) {
|
||||
$o = '';
|
||||
$expanded = '';
|
||||
|
||||
|
@ -1116,8 +1155,9 @@ function format_like($cnt,$arr,$type,$id) {
|
|||
|
||||
if ($cnt > 1) {
|
||||
$total = count($arr);
|
||||
if($total >= MAX_LIKERS)
|
||||
if ($total >= MAX_LIKERS) {
|
||||
$arr = array_slice($arr, 0, MAX_LIKERS - 1);
|
||||
}
|
||||
if ($total < MAX_LIKERS) {
|
||||
$last = t('and') . ' ' . $arr[count($arr)-1];
|
||||
$arr2 = array_slice($arr, 0, -1);
|
||||
|
@ -1169,11 +1209,10 @@ function format_like($cnt,$arr,$type,$id) {
|
|||
return $o;
|
||||
}}
|
||||
|
||||
|
||||
function status_editor($a,$x, $notes_cid = 0, $popup=false) {
|
||||
function status_editor(App $a, $x, $notes_cid = 0, $popup = false) {
|
||||
$o = '';
|
||||
|
||||
$geotag = (($x['allow_location']) ? replace_macros(get_markup_template('jot_geotag.tpl'), array()) : '');
|
||||
$geotag = (x($x, 'allow_location') ? replace_macros(get_markup_template('jot_geotag.tpl'), array()) : '');
|
||||
|
||||
$tpl = get_markup_template('jot-header.tpl');
|
||||
$a->page['htmlhead'] .= replace_macros($tpl, array(
|
||||
|
@ -1211,22 +1250,25 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
|
|||
|
||||
// Private/public post links for the non-JS ACL form
|
||||
$private_post = 1;
|
||||
if($_REQUEST['public'])
|
||||
if (x($_REQUEST, 'public')) {
|
||||
$private_post = 0;
|
||||
}
|
||||
|
||||
$query_str = $a->query_string;
|
||||
if(strpos($query_str, 'public=1') !== false)
|
||||
if (strpos($query_str, 'public=1') !== false) {
|
||||
$query_str = str_replace(array('?public=1', '&public=1'), array('', ''), $query_str);
|
||||
}
|
||||
|
||||
// I think $a->query_string may never have ? in it, but I could be wrong
|
||||
// It looks like it's from the index.php?q=[etc] rewrite that the web
|
||||
// server does, which converts any ? to &, e.g. suggest&ignore=61 for suggest?ignore=61
|
||||
if(strpos($query_str, '?') === false)
|
||||
/*
|
||||
* I think $a->query_string may never have ? in it, but I could be wrong
|
||||
* It looks like it's from the index.php?q=[etc] rewrite that the web
|
||||
* server does, which converts any ? to &, e.g. suggest&ignore=61 for suggest?ignore=61
|
||||
*/
|
||||
if (strpos($query_str, '?') === false) {
|
||||
$public_post_link = '?public=1';
|
||||
else
|
||||
} else {
|
||||
$public_post_link = '&public=1';
|
||||
|
||||
|
||||
}
|
||||
|
||||
// $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
|
||||
$tpl = get_markup_template("jot.tpl");
|
||||
|
@ -1292,7 +1334,6 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
|
|||
|
||||
if ($popup == true) {
|
||||
$o = '<div id="jot-popup" style="display: none;">'.$o.'</div>';
|
||||
|
||||
}
|
||||
|
||||
return $o;
|
||||
|
@ -1307,15 +1348,15 @@ function get_item_children($arr, $parent) {
|
|||
if (get_config('system', 'thread_allow') && $a->theme_thread_allow) {
|
||||
// Fallback to parent-uri if thr-parent is not set
|
||||
$thr_parent = $item['thr-parent'];
|
||||
if($thr_parent == '')
|
||||
if ($thr_parent == '') {
|
||||
$thr_parent = $item['parent-uri'];
|
||||
}
|
||||
|
||||
if ($thr_parent == $parent['uri']) {
|
||||
$item['children'] = get_item_children($arr, $item);
|
||||
$children[] = $item;
|
||||
}
|
||||
}
|
||||
else if($item['parent'] == $parent['id']) {
|
||||
} elseif ($item['parent'] == $parent['id']) {
|
||||
$children[] = $item;
|
||||
}
|
||||
}
|
||||
|
@ -1323,6 +1364,7 @@ function get_item_children($arr, $parent) {
|
|||
return $children;
|
||||
}
|
||||
|
||||
/// @TODO Add type-hint
|
||||
function sort_item_children($items) {
|
||||
$result = $items;
|
||||
usort($result, 'sort_thr_created_rev');
|
||||
|
@ -1334,44 +1376,58 @@ function sort_item_children($items) {
|
|||
return $result;
|
||||
}
|
||||
|
||||
/// @TODO Add type-hint
|
||||
function add_children_to_list($children, &$arr) {
|
||||
foreach ($children as $y) {
|
||||
$arr[] = $y;
|
||||
if(count($y['children']))
|
||||
if (count($y['children'])) {
|
||||
add_children_to_list($y['children'], $arr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// @TODO Add type-hint
|
||||
function conv_sort($arr, $order) {
|
||||
|
||||
if((!(is_array($arr) && count($arr))))
|
||||
if ((!(is_array($arr) && count($arr)))) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$parents = array();
|
||||
$children = array();
|
||||
$newarr = array();
|
||||
|
||||
// This is a preparation for having two different items with the same uri in one thread
|
||||
// This will otherwise lead to an endless loop.
|
||||
foreach($arr as $x)
|
||||
if (!isset($newarr[$x['uri']]))
|
||||
/*
|
||||
* This is a preparation for having two different items with the same uri in one thread
|
||||
* This will otherwise lead to an endless loop.
|
||||
*/
|
||||
foreach ($arr as $x) {
|
||||
if (!isset($newarr[$x['uri']])) {
|
||||
$newarr[$x['uri']] = $x;
|
||||
}
|
||||
}
|
||||
|
||||
$arr = $newarr;
|
||||
|
||||
foreach($arr as $x)
|
||||
if($x['id'] == $x['parent'])
|
||||
foreach ($arr as $x) {
|
||||
if ($x['id'] == $x['parent']) {
|
||||
$parents[] = $x;
|
||||
}
|
||||
}
|
||||
|
||||
if(stristr($order,'created'))
|
||||
if (stristr($order, 'created')) {
|
||||
usort($parents, 'sort_thr_created');
|
||||
elseif(stristr($order,'commented'))
|
||||
} elseif (stristr($order, 'commented')) {
|
||||
usort($parents, 'sort_thr_commented');
|
||||
}
|
||||
|
||||
if(count($parents))
|
||||
foreach($parents as $i=>$_x)
|
||||
if (count($parents)) {
|
||||
foreach ($parents as $i => $_x) {
|
||||
$parents[$i]['children'] = get_item_children($arr, $_x);
|
||||
}
|
||||
}
|
||||
|
||||
/// @TODO Old-lost code?
|
||||
/*foreach ($arr as $x) {
|
||||
if ($x['id'] != $x['parent']) {
|
||||
$p = find_thread_parent_index($parents,$x);
|
||||
|
@ -1383,6 +1439,7 @@ function conv_sort($arr,$order) {
|
|||
foreach ($parents as $k => $v) {
|
||||
if (count($parents[$k]['children'])) {
|
||||
$parents[$k]['children'] = sort_item_children($parents[$k]['children']);
|
||||
/// @TODO Old-lost code?
|
||||
/*$y = $parents[$k]['children'];
|
||||
usort($y,'sort_thr_created_rev');
|
||||
$parents[$k]['children'] = $y;*/
|
||||
|
@ -1394,44 +1451,55 @@ function conv_sort($arr,$order) {
|
|||
if (count($parents)) {
|
||||
foreach ($parents as $x) {
|
||||
$ret[] = $x;
|
||||
if(count($x['children']))
|
||||
if (count($x['children'])) {
|
||||
add_children_to_list($x['children'], $ret);
|
||||
/// @TODO Old-lost code?
|
||||
/*foreach ($x['children'] as $y)
|
||||
$ret[] = $y;*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
/// @TODO Add type-hint
|
||||
function sort_thr_created($a, $b) {
|
||||
return strcmp($b['created'], $a['created']);
|
||||
}
|
||||
|
||||
/// @TODO Add type-hint
|
||||
function sort_thr_created_rev($a, $b) {
|
||||
return strcmp($a['created'], $b['created']);
|
||||
}
|
||||
|
||||
/// @TODO Add type-hint
|
||||
function sort_thr_commented($a, $b) {
|
||||
return strcmp($b['commented'], $a['commented']);
|
||||
}
|
||||
|
||||
/// @TODO Add type-hint
|
||||
function find_thread_parent_index($arr, $x) {
|
||||
foreach($arr as $k => $v)
|
||||
if($v['id'] == $x['parent'])
|
||||
foreach ($arr as $k => $v) {
|
||||
if ($v['id'] == $x['parent']) {
|
||||
return $k;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// @TODO Add type-hint
|
||||
function render_location_dummy($item) {
|
||||
if ($item['location'] != "")
|
||||
if ($item['location'] != "") {
|
||||
return $item['location'];
|
||||
|
||||
if ($item['coord'] != "")
|
||||
return $item['coord'];
|
||||
}
|
||||
|
||||
if ($item['coord'] != "") {
|
||||
return $item['coord'];
|
||||
}
|
||||
}
|
||||
|
||||
/// @TODO Add type-hint
|
||||
function get_responses($conv_responses, $response_verbs, $ob, $item) {
|
||||
$ret = array();
|
||||
foreach ($response_verbs as $v) {
|
||||
|
@ -1443,8 +1511,7 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) {
|
|||
$ret[$v]['list_part'] = array_slice($ret[$v]['list'], 0, MAX_LIKERS);
|
||||
array_push($ret[$v]['list_part'], '<a href="#" data-toggle="modal" data-target="#' . $v . 'Modal-'
|
||||
. (($ob) ? $ob->get_id() : $item['id']) . '"><b>' . t('View all') . '</b></a>');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$ret[$v]['list_part'] = '';
|
||||
}
|
||||
$ret[$v]['button'] = get_response_button_text($v, $ret[$v]['count']);
|
||||
|
@ -1453,9 +1520,10 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) {
|
|||
|
||||
$count = 0;
|
||||
foreach ($ret as $key) {
|
||||
if ($key['count'] == true)
|
||||
if ($key['count'] == true) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
$ret['count'] = $count;
|
||||
|
||||
return $ret;
|
||||
|
|
|
@ -4,7 +4,7 @@ use \Friendica\Core\Config;
|
|||
function cron_run(&$argv, &$argc){
|
||||
global $a;
|
||||
|
||||
require_once('include/datetime.php');
|
||||
require_once 'include/datetime.php';
|
||||
|
||||
// Poll contacts with specific parameters
|
||||
if ($argc > 1) {
|
||||
|
@ -18,6 +18,7 @@ function cron_run(&$argv, &$argc){
|
|||
if (! $poll_interval) {
|
||||
$poll_interval = 10;
|
||||
}
|
||||
|
||||
if ($last) {
|
||||
$next = $last + ($poll_interval * 60);
|
||||
if ($next > time()) {
|
||||
|
@ -156,7 +157,7 @@ function cron_poll_contacts($argc, $argv) {
|
|||
dbesc(NETWORK_MAIL2)
|
||||
);
|
||||
|
||||
if (!count($contacts)) {
|
||||
if (!dbm::is_result($contacts)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -183,25 +184,24 @@ function cron_poll_contacts($argc, $argv) {
|
|||
}
|
||||
|
||||
if ($contact['subhub'] AND in_array($contact['network'], array(NETWORK_DFRN, NETWORK_ZOT, NETWORK_OSTATUS))) {
|
||||
// We should be getting everything via a hub. But just to be sure, let's check once a day.
|
||||
// (You can make this more or less frequent if desired by setting 'pushpoll_frequency' appropriately)
|
||||
// This also lets us update our subscription to the hub, and add or replace hubs in case it
|
||||
// changed. We will only update hubs once a day, regardless of 'pushpoll_frequency'.
|
||||
|
||||
/*
|
||||
* We should be getting everything via a hub. But just to be sure, let's check once a day.
|
||||
* (You can make this more or less frequent if desired by setting 'pushpoll_frequency' appropriately)
|
||||
* This also lets us update our subscription to the hub, and add or replace hubs in case it
|
||||
* changed. We will only update hubs once a day, regardless of 'pushpoll_frequency'.
|
||||
*/
|
||||
$poll_interval = get_config('system', 'pushpoll_frequency');
|
||||
$contact['priority'] = (($poll_interval !== false) ? intval($poll_interval) : 3);
|
||||
}
|
||||
|
||||
if ($contact['priority'] AND !$force) {
|
||||
|
||||
$update = false;
|
||||
|
||||
$t = $contact['last-update'];
|
||||
|
||||
/**
|
||||
/*
|
||||
* Based on $contact['priority'], should we poll this site now? Or later?
|
||||
*/
|
||||
|
||||
switch ($contact['priority']) {
|
||||
case 5:
|
||||
if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + 1 month")) {
|
||||
|
|
|
@ -5,22 +5,24 @@ use \Friendica\Core\Config;
|
|||
function cronhooks_run(&$argv, &$argc) {
|
||||
global $a;
|
||||
|
||||
require_once('include/datetime.php');
|
||||
require_once 'include/datetime.php';
|
||||
|
||||
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]) {
|
||||
logger("Calling cron hook '" . $hook[1] . "'", LOGGER_DEBUG);
|
||||
call_single_hook($a, $name, $hook, $data);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$last = get_config('system', 'last_cronhook');
|
||||
|
||||
$poll_interval = intval(get_config('system', 'cronhook_interval'));
|
||||
if(! $poll_interval)
|
||||
if (! $poll_interval) {
|
||||
$poll_interval = 9;
|
||||
}
|
||||
|
||||
if ($last) {
|
||||
$next = $last + ($poll_interval * 60);
|
||||
|
|
|
@ -15,12 +15,19 @@ use \Friendica\Core\Config;
|
|||
*/
|
||||
function timezone_cmp($a, $b) {
|
||||
if (strstr($a, '/') && strstr($b, '/')) {
|
||||
if ( t($a) == t($b)) return 0;
|
||||
if ( t($a) == t($b)) {
|
||||
return 0;
|
||||
}
|
||||
return ( t($a) < t($b)) ? -1 : 1;
|
||||
}
|
||||
if(strstr($a,'/')) return -1;
|
||||
if(strstr($b,'/')) return 1;
|
||||
if ( t($a) == t($b)) return 0;
|
||||
|
||||
if (strstr($a, '/')) {
|
||||
return -1;
|
||||
} elseif (strstr($b, '/')) {
|
||||
return 1;
|
||||
} elseif ( t($a) == t($b)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ( t($a) < t($b)) ? -1 : 1;
|
||||
}
|
||||
|
@ -43,17 +50,18 @@ function select_timezone($current = 'America/Los_Angeles') {
|
|||
$ex = explode("/", $value);
|
||||
if (count($ex) > 1) {
|
||||
if ($ex[0] != $continent) {
|
||||
if($continent != '')
|
||||
if ($continent != '') {
|
||||
$o .= '</optgroup>';
|
||||
}
|
||||
$continent = $ex[0];
|
||||
$o .= '<optgroup label="' . t($continent) . '">';
|
||||
}
|
||||
if(count($ex) > 2)
|
||||
if (count($ex) > 2) {
|
||||
$city = substr($value,strpos($value,'/')+1);
|
||||
else
|
||||
} else {
|
||||
$city = $ex[1];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$city = $ex[0];
|
||||
if ($continent != t('Miscellaneous')) {
|
||||
$o .= '</optgroup>';
|
||||
|
@ -114,48 +122,50 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d
|
|||
// Defaults to UTC if nothing is set, but throws an exception if set to empty string.
|
||||
// Provide some sane defaults regardless.
|
||||
|
||||
if($from === '')
|
||||
if ($from === '') {
|
||||
$from = 'UTC';
|
||||
if($to === '')
|
||||
}
|
||||
if ($to === '') {
|
||||
$to = 'UTC';
|
||||
if( ($s === '') || (! is_string($s)) )
|
||||
}
|
||||
if ( ($s === '') || (! is_string($s)) ) {
|
||||
$s = 'now';
|
||||
}
|
||||
|
||||
// Slight hackish adjustment so that 'zero' datetime actually returns what is intended
|
||||
// otherwise we end up with -0001-11-30 ...
|
||||
// add 32 days so that we at least get year 00, and then hack around the fact that
|
||||
// months and days always start with 1.
|
||||
/*
|
||||
* Slight hackish adjustment so that 'zero' datetime actually returns what is intended
|
||||
* otherwise we end up with -0001-11-30 ...
|
||||
* add 32 days so that we at least get year 00, and then hack around the fact that
|
||||
* months and days always start with 1.
|
||||
*/
|
||||
|
||||
if(substr($s,0,10) == '0000-00-00') {
|
||||
if (substr($s,0,10) <= '0001-01-01') {
|
||||
$d = new DateTime($s . ' + 32 days', new DateTimeZone('UTC'));
|
||||
return str_replace('1','0',$d->format($fmt));
|
||||
}
|
||||
|
||||
try {
|
||||
$from_obj = new DateTimeZone($from);
|
||||
}
|
||||
catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$from_obj = new DateTimeZone('UTC');
|
||||
}
|
||||
|
||||
try {
|
||||
$d = new DateTime($s, $from_obj);
|
||||
}
|
||||
catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
logger('datetime_convert: exception: ' . $e->getMessage());
|
||||
$d = new DateTime('now', $from_obj);
|
||||
}
|
||||
|
||||
try {
|
||||
$to_obj = new DateTimeZone($to);
|
||||
}
|
||||
catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$to_obj = new DateTimeZone('UTC');
|
||||
}
|
||||
|
||||
$d->setTimeZone($to_obj);
|
||||
|
||||
return($d->format($fmt));
|
||||
return $d->format($fmt);
|
||||
}
|
||||
|
||||
|
||||
|
@ -169,12 +179,14 @@ function dob($dob) {
|
|||
list($year,$month,$day) = sscanf($dob,'%4d-%2d-%2d');
|
||||
|
||||
$f = get_config('system','birthday_input_format');
|
||||
if(! $f)
|
||||
if (! $f) {
|
||||
$f = 'ymd';
|
||||
if($dob === '0000-00-00')
|
||||
}
|
||||
if ($dob <= '0001-01-01') {
|
||||
$value = '';
|
||||
else
|
||||
} else {
|
||||
$value = (($year) ? datetime_convert('UTC','UTC',$dob,'Y-m-d') : datetime_convert('UTC','UTC',$dob,'m-d'));
|
||||
}
|
||||
|
||||
$age = ((intval($value)) ? age($value, $a->user["timezone"], $a->user["timezone"]) : "");
|
||||
|
||||
|
@ -189,7 +201,8 @@ function dob($dob) {
|
|||
)
|
||||
));
|
||||
|
||||
// if ($dob && $dob != '0000-00-00')
|
||||
/// @TODO Old-lost code?
|
||||
// if ($dob && $dob > '0001-01-01')
|
||||
// $o = datesel($f,mktime(0,0,0,0,0,1900),mktime(),mktime(0,0,0,$month,$day,$year),'dob');
|
||||
// else
|
||||
// $o = datesel($f,mktime(0,0,0,0,0,1900),mktime(),false,'dob');
|
||||
|
@ -267,7 +280,9 @@ function datetimesel($format, $min, $max, $default, $label, $id = 'datetimepicke
|
|||
|
||||
// First day of the week (0 = Sunday)
|
||||
$firstDay = get_pconfig(local_user(),'system','first_day_of_week');
|
||||
if ($firstDay === false) $firstDay=0;
|
||||
if ($firstDay === false) {
|
||||
$firstDay=0;
|
||||
}
|
||||
|
||||
$lang = substr(get_browser_language(), 0, 2);
|
||||
|
||||
|
@ -279,9 +294,15 @@ function datetimesel($format, $min, $max, $default, $label, $id = 'datetimepicke
|
|||
$o = '';
|
||||
$dateformat = '';
|
||||
|
||||
if($pickdate) $dateformat .= 'Y-m-d';
|
||||
if($pickdate && $picktime) $dateformat .= ' ';
|
||||
if($picktime) $dateformat .= 'H:i';
|
||||
if ($pickdate) {
|
||||
$dateformat .= 'Y-m-d';
|
||||
}
|
||||
if ($pickdate && $picktime) {
|
||||
$dateformat .= ' ';
|
||||
}
|
||||
if ($picktime) {
|
||||
$dateformat .= 'H:i';
|
||||
}
|
||||
|
||||
$minjs = $min ? ",minDate: new Date({$min->getTimestamp()}*1000), yearStart: " . $min->format('Y') : '';
|
||||
$maxjs = $max ? ",maxDate: new Date({$max->getTimestamp()}*1000), yearEnd: " . $max->format('Y') : '';
|
||||
|
@ -290,15 +311,21 @@ function datetimesel($format, $min, $max, $default, $label, $id = 'datetimepicke
|
|||
$defaultdatejs = $default ? ",defaultDate: new Date({$default->getTimestamp()}*1000)" : '';
|
||||
|
||||
$pickers = '';
|
||||
if(!$pickdate) $pickers .= ',datepicker: false';
|
||||
if(!$picktime) $pickers .= ',timepicker: false';
|
||||
if (!$pickdate) {
|
||||
$pickers .= ',datepicker: false';
|
||||
}
|
||||
if (!$picktime) {
|
||||
$pickers .= ',timepicker: false';
|
||||
}
|
||||
|
||||
$extra_js = '';
|
||||
$pickers .= ",dayOfWeekStart: ".$firstDay.",lang:'".$lang."'";
|
||||
if($minfrom != '')
|
||||
if ($minfrom != '') {
|
||||
$extra_js .= "\$('#id_$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})";
|
||||
if($maxfrom != '')
|
||||
}
|
||||
if ($maxfrom != '') {
|
||||
$extra_js .= "\$('#id_$maxfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({maxDate: currentDateTime})}})";
|
||||
}
|
||||
|
||||
$readable_format = $dateformat;
|
||||
$readable_format = str_replace('Y','yyyy',$readable_format);
|
||||
|
@ -394,12 +421,15 @@ function relative_date($posted_date, $format = null) {
|
|||
* @return int Age in years
|
||||
*/
|
||||
function age($dob, $owner_tz = '', $viewer_tz = '') {
|
||||
if(! intval($dob))
|
||||
if (! intval($dob)) {
|
||||
return 0;
|
||||
if(! $owner_tz)
|
||||
}
|
||||
if (! $owner_tz) {
|
||||
$owner_tz = date_default_timezone_get();
|
||||
if(! $viewer_tz)
|
||||
}
|
||||
if (! $viewer_tz) {
|
||||
$viewer_tz = date_default_timezone_get();
|
||||
}
|
||||
|
||||
$birthdate = datetime_convert('UTC',$owner_tz,$dob . ' 00:00:00+00:00','Y-m-d');
|
||||
list($year,$month,$day) = explode("-",$birthdate);
|
||||
|
@ -407,8 +437,9 @@ function age($dob,$owner_tz = '',$viewer_tz = '') {
|
|||
$curr_month = datetime_convert('UTC',$viewer_tz,'now','m');
|
||||
$curr_day = datetime_convert('UTC',$viewer_tz,'now','d');
|
||||
|
||||
if(($curr_month < $month) || (($curr_month == $month) && ($curr_day < $day)))
|
||||
if (($curr_month < $month) || (($curr_month == $month) && ($curr_day < $day))) {
|
||||
$year_diff--;
|
||||
}
|
||||
|
||||
return $year_diff;
|
||||
}
|
||||
|
@ -430,11 +461,11 @@ function get_dim($y,$m) {
|
|||
31, 28, 31, 30, 31, 30,
|
||||
31, 31, 30, 31, 30, 31);
|
||||
|
||||
if($m != 2)
|
||||
if ($m != 2) {
|
||||
return $dim[$m];
|
||||
|
||||
if(((($y % 4) == 0) && (($y % 100) != 0)) || (($y % 400) == 0))
|
||||
} elseif (((($y % 4) == 0) && (($y % 100) != 0)) || (($y % 400) == 0)) {
|
||||
return 29;
|
||||
}
|
||||
|
||||
return $dim[2];
|
||||
}
|
||||
|
@ -473,8 +504,6 @@ function get_first_dim($y,$m) {
|
|||
* @todo Provide (prev,next) links, define class variations for different size calendars
|
||||
*/
|
||||
function cal($y = 0,$m = 0, $links = false, $class='') {
|
||||
|
||||
|
||||
// month table - start at 1 to match human usage.
|
||||
|
||||
$mtab = array(' ',
|
||||
|
@ -486,10 +515,12 @@ function cal($y = 0,$m = 0, $links = false, $class='') {
|
|||
|
||||
$thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
|
||||
$thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m');
|
||||
if(! $y)
|
||||
if (! $y) {
|
||||
$y = $thisyear;
|
||||
if(! $m)
|
||||
}
|
||||
if (! $m) {
|
||||
$m = intval($thismonth);
|
||||
}
|
||||
|
||||
$dn = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
|
||||
$f = get_first_dim($y,$m);
|
||||
|
@ -498,29 +529,33 @@ function cal($y = 0,$m = 0, $links = false, $class='') {
|
|||
$dow = 0;
|
||||
$started = false;
|
||||
|
||||
if(($y == $thisyear) && ($m == $thismonth))
|
||||
if (($y == $thisyear) && ($m == $thismonth)) {
|
||||
$tddate = intval(datetime_convert('UTC',date_default_timezone_get(),'now','j'));
|
||||
}
|
||||
|
||||
$str_month = day_translate($mtab[$m]);
|
||||
$o = '<table class="calendar' . $class . '">';
|
||||
$o .= "<caption>$str_month $y</caption><tr>";
|
||||
for($a = 0; $a < 7; $a ++)
|
||||
for ($a = 0; $a < 7; $a ++) {
|
||||
$o .= '<th>' . mb_substr(day_translate($dn[$a]),0,3,'UTF-8') . '</th>';
|
||||
}
|
||||
|
||||
$o .= '</tr><tr>';
|
||||
|
||||
while ($d <= $l) {
|
||||
if(($dow == $f) && (! $started))
|
||||
if (($dow == $f) && (! $started)) {
|
||||
$started = true;
|
||||
}
|
||||
|
||||
$today = (((isset($tddate)) && ($tddate == $d)) ? "class=\"today\" " : '');
|
||||
$o .= "<td $today>";
|
||||
$day = str_replace(' ',' ',sprintf('%2.2d', $d));
|
||||
if ($started) {
|
||||
if(is_array($links) && isset($links[$d]))
|
||||
if (is_array($links) && isset($links[$d])) {
|
||||
$o .= "<a href=\"{$links[$d]}\">$day</a>";
|
||||
else
|
||||
} else {
|
||||
$o .= $day;
|
||||
}
|
||||
|
||||
$d ++;
|
||||
} else {
|
||||
|
@ -534,9 +569,11 @@ function cal($y = 0,$m = 0, $links = false, $class='') {
|
|||
$o .= '</tr><tr>';
|
||||
}
|
||||
}
|
||||
if($dow)
|
||||
for($a = $dow; $a < 7; $a ++)
|
||||
if ($dow) {
|
||||
for ($a = $dow; $a < 7; $a ++) {
|
||||
$o .= '<td> </td>';
|
||||
}
|
||||
}
|
||||
|
||||
$o .= '</tr></table>'."\r\n";
|
||||
|
||||
|
@ -553,7 +590,7 @@ function update_contact_birthdays() {
|
|||
// This only handles foreign or alien networks where a birthday has been provided.
|
||||
// In-network birthdays are handled within local_delivery
|
||||
|
||||
$r = q("SELECT * FROM contact WHERE `bd` != '' AND `bd` != '0000-00-00' AND SUBSTRING(`bd`,1,4) != `bdyear` ");
|
||||
$r = q("SELECT * FROM contact WHERE `bd` != '' AND `bd` > '0001-01-01' AND SUBSTRING(`bd`,1,4) != `bdyear` ");
|
||||
if (dbm::is_result($r)) {
|
||||
foreach ($r as $rr) {
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ class dba {
|
|||
private $driver;
|
||||
public $connected = false;
|
||||
public $error = false;
|
||||
private $_server_info = '';
|
||||
|
||||
function __construct($server, $user, $pass, $db, $install = false) {
|
||||
$a = get_app();
|
||||
|
@ -103,18 +104,20 @@ class dba {
|
|||
* @return string
|
||||
*/
|
||||
public function server_info() {
|
||||
if ($this->_server_info == '') {
|
||||
switch ($this->driver) {
|
||||
case 'pdo':
|
||||
$version = $this->db->getAttribute(PDO::ATTR_SERVER_VERSION);
|
||||
$this->_server_info = $this->db->getAttribute(PDO::ATTR_SERVER_VERSION);
|
||||
break;
|
||||
case 'mysqli':
|
||||
$version = $this->db->server_info;
|
||||
$this->_server_info = $this->db->server_info;
|
||||
break;
|
||||
case 'mysql':
|
||||
$version = mysql_get_server_info($this->db);
|
||||
$this->_server_info = mysql_get_server_info($this->db);
|
||||
break;
|
||||
}
|
||||
return $version;
|
||||
}
|
||||
return $this->_server_info;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -474,6 +477,26 @@ class dba {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Replaces ANY_VALUE() function by MIN() function,
|
||||
* if the database server does not support ANY_VALUE().
|
||||
*
|
||||
* Considerations for Standard SQL, or MySQL with ONLY_FULL_GROUP_BY (default since 5.7.5).
|
||||
* ANY_VALUE() is available from MySQL 5.7.5 https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html
|
||||
* A standard fall-back is to use MIN().
|
||||
*
|
||||
* @param string $sql An SQL string without the values
|
||||
* @return string The input SQL string modified if necessary.
|
||||
*/
|
||||
public function any_value_fallback($sql) {
|
||||
$server_info = $this->server_info();
|
||||
if (version_compare($server_info, '5.7.5', '<') ||
|
||||
(stripos($server_info, 'MariaDB') !== false)) {
|
||||
$sql = str_ireplace('ANY_VALUE(', 'MIN(', $sql);
|
||||
}
|
||||
return $sql;
|
||||
}
|
||||
}
|
||||
|
||||
function printable($s) {
|
||||
|
@ -514,6 +537,7 @@ function q($sql) {
|
|||
unset($args[0]);
|
||||
|
||||
if ($db && $db->connected) {
|
||||
$sql = $db->any_value_fallback($sql);
|
||||
$stmt = @vsprintf($sql,$args); // Disabled warnings
|
||||
//logger("dba: q: $stmt", LOGGER_ALL);
|
||||
if ($stmt === false)
|
||||
|
@ -550,6 +574,7 @@ function qu($sql) {
|
|||
unset($args[0]);
|
||||
|
||||
if ($db && $db->connected) {
|
||||
$sql = $db->any_value_fallback($sql);
|
||||
$stmt = @vsprintf($sql,$args); // Disabled warnings
|
||||
if ($stmt === false)
|
||||
logger('dba: vsprintf error: ' . print_r(debug_backtrace(),true), LOGGER_DEBUG);
|
||||
|
|
|
@ -78,8 +78,18 @@ function update_fail($update_id, $error_message){
|
|||
function table_structure($table) {
|
||||
$structures = q("DESCRIBE `%s`", $table);
|
||||
|
||||
$full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table);
|
||||
|
||||
$indexes = q("SHOW INDEX FROM `%s`", $table);
|
||||
|
||||
$table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table);
|
||||
|
||||
if (dbm::is_result($table_status)) {
|
||||
$table_status = $table_status[0];
|
||||
} else {
|
||||
$table_status = array();
|
||||
}
|
||||
|
||||
$fielddata = array();
|
||||
$indexdata = array();
|
||||
|
||||
|
@ -104,7 +114,6 @@ function table_structure($table) {
|
|||
|
||||
$indexdata[$index["Key_name"]][] = $column;
|
||||
}
|
||||
|
||||
if (dbm::is_result($structures)) {
|
||||
foreach ($structures AS $field) {
|
||||
$fielddata[$field["Field"]]["type"] = $field["Type"];
|
||||
|
@ -125,10 +134,16 @@ function table_structure($table) {
|
|||
}
|
||||
}
|
||||
}
|
||||
return(array("fields"=>$fielddata, "indexes"=>$indexdata));
|
||||
if (dbm::is_result($full_columns)) {
|
||||
foreach ($full_columns AS $column) {
|
||||
$fielddata[$column["Field"]]["Collation"] = $column["Collation"];
|
||||
}
|
||||
}
|
||||
|
||||
function print_structure($database, $charset) {
|
||||
return array("fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status);
|
||||
}
|
||||
|
||||
function print_structure($database) {
|
||||
echo "-- ------------------------------------------\n";
|
||||
echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
|
||||
echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
|
||||
|
@ -137,24 +152,33 @@ function print_structure($database, $charset) {
|
|||
echo "--\n";
|
||||
echo "-- TABLE $name\n";
|
||||
echo "--\n";
|
||||
db_create_table($name, $structure['fields'], $charset, true, false, $structure["indexes"]);
|
||||
db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
|
||||
|
||||
echo "\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Print out database error messages
|
||||
*
|
||||
* @param object $db Database object
|
||||
* @param string $message Message to be added to the error message
|
||||
*
|
||||
* @return string Error message
|
||||
*/
|
||||
function print_update_error($db, $message) {
|
||||
echo sprintf(t("\nError %d occured during database update:\n%s\n"),
|
||||
$db->errorno, $db->error);
|
||||
|
||||
return t('Errors encountered performing database changes: ').$message.EOL;
|
||||
}
|
||||
|
||||
function update_structure($verbose, $action, $tables=null, $definition=null) {
|
||||
global $a, $db;
|
||||
|
||||
if ($action) {
|
||||
Config::set('system', 'maintenance', 1);
|
||||
Config::set('system', 'maintenance_reason', 'Database update');
|
||||
}
|
||||
|
||||
if (isset($a->config["system"]["db_charset"])) {
|
||||
$charset = $a->config["system"]["db_charset"];
|
||||
} else {
|
||||
$charset = "utf8";
|
||||
Config::set('system', 'maintenance_reason', sprintf(t(': Database update'), dbm::date().' '.date('e')));
|
||||
}
|
||||
|
||||
$errors = false;
|
||||
|
@ -168,16 +192,18 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
|
|||
$tables = q("SHOW TABLES");
|
||||
}
|
||||
|
||||
if (dbm::is_result($tables)) {
|
||||
foreach ($tables AS $table) {
|
||||
$table = current($table);
|
||||
|
||||
logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
|
||||
$database[$table] = table_structure($table);
|
||||
}
|
||||
}
|
||||
|
||||
// Get the definition
|
||||
if (is_null($definition)) {
|
||||
$definition = db_definition($charset);
|
||||
$definition = db_definition();
|
||||
}
|
||||
|
||||
// MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
|
||||
|
@ -194,9 +220,9 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
|
|||
$group_by = "";
|
||||
$sql3 = "";
|
||||
if (!isset($database[$name])) {
|
||||
$r = db_create_table($name, $structure["fields"], $charset, $verbose, $action, $structure['indexes']);
|
||||
$r = db_create_table($name, $structure["fields"], $verbose, $action, $structure['indexes']);
|
||||
if (!dbm::is_result($r)) {
|
||||
$errors .= t('Errors encountered creating database tables.').$name.EOL;
|
||||
$errors .= print_update_error($db, $name);
|
||||
}
|
||||
$is_new_table = True;
|
||||
} else {
|
||||
|
@ -252,7 +278,15 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
|
|||
}
|
||||
} else {
|
||||
// Compare the field definition
|
||||
$current_field_definition = implode(",",$database[$name]["fields"][$fieldname]);
|
||||
$field_definition = $database[$name]["fields"][$fieldname];
|
||||
|
||||
// We change the collation after the indexes had been changed.
|
||||
// This is done to avoid index length problems.
|
||||
// So here we always ensure that there is no need to change it.
|
||||
unset($parameters['Collation']);
|
||||
unset($field_definition['Collation']);
|
||||
|
||||
$current_field_definition = implode(",", $field_definition);
|
||||
$new_field_definition = implode(",", $parameters);
|
||||
if ($current_field_definition != $new_field_definition) {
|
||||
$sql2 = db_modify_table_field($fieldname, $parameters);
|
||||
|
@ -262,7 +296,6 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
|
|||
$sql3 .= ", ".$sql2;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -288,16 +321,59 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
|
|||
$group_by = db_group_by($indexname, $fieldnames);
|
||||
}
|
||||
if ($sql2 != "") {
|
||||
if ($sql3 == "")
|
||||
if ($sql3 == "") {
|
||||
$sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
|
||||
else
|
||||
} else {
|
||||
$sql3 .= ", ".$sql2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($database[$name]["table_status"]["Collation"])) {
|
||||
if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
|
||||
$sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
|
||||
|
||||
if ($sql3 == "") {
|
||||
$sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
|
||||
} else {
|
||||
$sql3 .= ", ".$sql2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($sql3 != "") {
|
||||
$sql3 .= "; ";
|
||||
}
|
||||
|
||||
// Now have a look at the field collations
|
||||
// Compare the field structure field by field
|
||||
foreach ($structure["fields"] AS $fieldname => $parameters) {
|
||||
// Compare the field definition
|
||||
$field_definition = $database[$name]["fields"][$fieldname];
|
||||
|
||||
// Define the default collation if not given
|
||||
if (!isset($parameters['Collation']) AND !is_null($field_definition['Collation'])) {
|
||||
$parameters['Collation'] = 'utf8mb4_general_ci';
|
||||
} else {
|
||||
$parameters['Collation'] = null;
|
||||
}
|
||||
|
||||
if ($field_definition['Collation'] != $parameters['Collation']) {
|
||||
$sql2 = db_modify_table_field($fieldname, $parameters);
|
||||
if (($sql3 == "") OR (substr($sql3, -2, 2) == "; ")) {
|
||||
$sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
|
||||
} else {
|
||||
$sql3 .= ", ".$sql2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($sql3 != "") {
|
||||
if (substr($sql3, -2, 2) != "; ") {
|
||||
$sql3 .= ";";
|
||||
}
|
||||
|
||||
if ($verbose) {
|
||||
// Ensure index conversion to unique removes duplicates
|
||||
|
@ -323,6 +399,8 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
|
|||
}
|
||||
|
||||
if ($action) {
|
||||
Config::set('system', 'maintenance_reason', sprintf(t('%s: updating %s table.'), dbm::date().' '.date('e'), $name));
|
||||
|
||||
// Ensure index conversion to unique removes duplicates
|
||||
if ($is_unique) {
|
||||
if ($ignore != "") {
|
||||
|
@ -330,33 +408,33 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
|
|||
} else {
|
||||
$r = $db->q("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
|
||||
if (!dbm::is_result($r)) {
|
||||
$errors .= t('Errors encountered performing database changes.').$sql3.EOL;
|
||||
$errors .= print_update_error($db, $sql3);
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$r = @$db->q($sql3);
|
||||
if (!dbm::is_result($r))
|
||||
$errors .= t('Errors encountered performing database changes.').$sql3.EOL;
|
||||
|
||||
if (!dbm::is_result($r)) {
|
||||
$errors .= print_update_error($db, $sql3);
|
||||
}
|
||||
if ($is_unique) {
|
||||
if ($ignore != "") {
|
||||
$db->q("SET session old_alter_table=0;");
|
||||
} else {
|
||||
$r = $db->q("INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";");
|
||||
if (!dbm::is_result($r)) {
|
||||
$errors .= t('Errors encountered performing database changes.').$sql3.EOL;
|
||||
$errors .= print_update_error($db, $sql3);
|
||||
return $errors;
|
||||
}
|
||||
$r = $db->q("DROP TABLE `".$name."`;");
|
||||
if (!dbm::is_result($r)) {
|
||||
$errors .= t('Errors encountered performing database changes.').$sql3.EOL;
|
||||
$errors .= print_update_error($db, $sql3);
|
||||
return $errors;
|
||||
}
|
||||
$r = $db->q("RENAME TABLE `".$temp_name."` TO `".$name."`;");
|
||||
if (!dbm::is_result($r)) {
|
||||
$errors .= t('Errors encountered performing database changes.').$sql3.EOL;
|
||||
$errors .= print_update_error($db, $sql3);
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
|
@ -376,6 +454,10 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
|
|||
function db_field_command($parameters, $create = true) {
|
||||
$fieldstruct = $parameters["type"];
|
||||
|
||||
if (!is_null($parameters["Collation"])) {
|
||||
$fieldstruct .= " COLLATE ".$parameters["Collation"];
|
||||
}
|
||||
|
||||
if ($parameters["not null"])
|
||||
$fieldstruct .= " NOT NULL";
|
||||
|
||||
|
@ -395,7 +477,7 @@ function db_field_command($parameters, $create = true) {
|
|||
return($fieldstruct);
|
||||
}
|
||||
|
||||
function db_create_table($name, $fields, $charset, $verbose, $action, $indexes=null) {
|
||||
function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
|
||||
global $a, $db;
|
||||
|
||||
$r = true;
|
||||
|
@ -420,7 +502,7 @@ function db_create_table($name, $fields, $charset, $verbose, $action, $indexes=n
|
|||
|
||||
$sql = implode(",\n\t", $sql_rows);
|
||||
|
||||
$sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT CHARSET=".$charset;
|
||||
$sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
|
||||
if ($verbose)
|
||||
echo $sql.";\n";
|
||||
|
||||
|
@ -503,18 +585,7 @@ function db_group_by($indexname, $fieldnames) {
|
|||
return $sql;
|
||||
}
|
||||
|
||||
function db_index_suffix($charset, $reduce = 0) {
|
||||
if ($charset != "utf8mb4") {
|
||||
return "";
|
||||
}
|
||||
|
||||
// On utf8mb4 indexes can only have a length of 191
|
||||
$indexlength = 191 - $reduce;
|
||||
|
||||
return "(".$indexlength.")";
|
||||
}
|
||||
|
||||
function db_definition($charset) {
|
||||
function db_definition() {
|
||||
|
||||
$database = array();
|
||||
|
||||
|
@ -671,7 +742,7 @@ function db_definition($charset) {
|
|||
"writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
"forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
"prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
"contact-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
|
||||
"contact-type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
"hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
"archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
"pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
|
||||
|
@ -681,7 +752,7 @@ function db_definition($charset) {
|
|||
"info" => array("type" => "mediumtext"),
|
||||
"profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
"bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
|
||||
"bd" => array("type" => "date", "not null" => "1", "default" => "0000-00-00"),
|
||||
"bd" => array("type" => "date", "not null" => "1", "default" => "0001-01-01"),
|
||||
"notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
"fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
"ffi_keyword_blacklist" => array("type" => "text"),
|
||||
|
@ -840,7 +911,7 @@ function db_definition($charset) {
|
|||
"about" => array("type" => "text"),
|
||||
"keywords" => array("type" => "text"),
|
||||
"gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
|
||||
"birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
|
||||
"birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
|
||||
"community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
"contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
|
||||
"hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
|
@ -1304,7 +1375,7 @@ function db_definition($charset) {
|
|||
"hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||
"name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
|
||||
"dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
|
||||
"address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
|
@ -1658,9 +1729,7 @@ function dbstructure_run(&$argv, &$argc) {
|
|||
set_config('system','build',DB_UPDATE_VERSION);
|
||||
return;
|
||||
case "dumpsql":
|
||||
// For the dump that is used to create the database.sql we always assume utfmb4
|
||||
$charset = "utf8mb4";
|
||||
print_structure(db_definition($charset), $charset);
|
||||
print_structure(db_definition());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -554,8 +554,9 @@ class dfrn {
|
|||
xml::add_element($doc, $author, "poco:displayName", $profile["name"]);
|
||||
xml::add_element($doc, $author, "poco:updated", $namdate);
|
||||
|
||||
if (trim($profile["dob"]) != "0000-00-00")
|
||||
if (trim($profile["dob"]) > '0001-01-01') {
|
||||
xml::add_element($doc, $author, "poco:birthday", "0000-".date("m-d", strtotime($profile["dob"])));
|
||||
}
|
||||
|
||||
xml::add_element($doc, $author, "poco:note", $profile["about"]);
|
||||
xml::add_element($doc, $author, "poco:preferredUsername", $profile["nickname"]);
|
||||
|
@ -1402,7 +1403,7 @@ class dfrn {
|
|||
// "poco:birthday" is the birthday in the format "yyyy-mm-dd"
|
||||
$value = $xpath->evaluate($element . "/poco:birthday/text()", $context)->item(0)->nodeValue;
|
||||
|
||||
if (!in_array($value, array("", "0000-00-00"))) {
|
||||
if (!in_array($value, array("", "0000-00-00", "0001-01-01"))) {
|
||||
$bdyear = date("Y");
|
||||
$value = str_replace("0000", $bdyear, $value);
|
||||
|
||||
|
|
|
@ -3591,7 +3591,7 @@ class Diaspora {
|
|||
if ($searchable === 'true') {
|
||||
$dob = '1000-00-00';
|
||||
|
||||
if (($profile['dob']) && ($profile['dob'] != '0000-00-00'))
|
||||
if (($profile['dob']) && ($profile['dob'] > '0001-01-01'))
|
||||
$dob = ((intval($profile['dob'])) ? intval($profile['dob']) : '1000') .'-'. datetime_convert('UTC','UTC',$profile['dob'],'m-d');
|
||||
|
||||
$about = $profile['about'];
|
||||
|
@ -3649,17 +3649,20 @@ class Diaspora {
|
|||
}
|
||||
|
||||
$r = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1", intval($contact['uid']));
|
||||
if(!$r)
|
||||
if (!dbm::is_result($r)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$contact["uprvkey"] = $r[0]['prvkey'];
|
||||
|
||||
$r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", intval($post_id));
|
||||
if (!$r)
|
||||
if (!dbm::is_result($r)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!in_array($r[0]["verb"], array(ACTIVITY_LIKE, ACTIVITY_DISLIKE)))
|
||||
if (!in_array($r[0]["verb"], array(ACTIVITY_LIKE, ACTIVITY_DISLIKE))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$message = self::construct_like($r[0], $contact);
|
||||
$message["author_signature"] = self::signature($contact, $message);
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
<?php
|
||||
/// @TODO no longer used?
|
||||
use \Friendica\Core\Config;
|
||||
|
||||
function directory_run(&$argv, &$argc){
|
||||
if ($argc != 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
$dir = get_config('system', 'directory');
|
||||
|
||||
if (!strlen($dir)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($argc < 2) {
|
||||
directory_update_all();
|
||||
return;
|
||||
}
|
||||
|
||||
$dir .= "/submit";
|
||||
|
||||
$arr = array('url' => $argv[1]);
|
||||
|
@ -22,5 +24,20 @@ function directory_run(&$argv, &$argc){
|
|||
if (strlen($arr['url'])) {
|
||||
fetch_url($dir . '?url=' . bin2hex($arr['url']));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
function directory_update_all() {
|
||||
$r = q("SELECT `url` FROM `contact`
|
||||
INNER JOIN `profile` ON `profile`.`uid` = `contact`.`uid`
|
||||
INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
|
||||
WHERE `contact`.`self` AND `profile`.`net-publish` AND `profile`.`is-default` AND
|
||||
NOT `user`.`account_expired` AND `user`.`verified`");
|
||||
|
||||
if (dbm::is_result($r)) {
|
||||
foreach ($r AS $user) {
|
||||
proc_run(PRIORITY_LOW, 'include/directory.php', $user['url']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -212,7 +212,7 @@ function discover_directory($search) {
|
|||
foreach ($j->results as $jj) {
|
||||
// Check if the contact already exists
|
||||
$exists = q("SELECT `id`, `last_contact`, `last_failure`, `updated` FROM `gcontact` WHERE `nurl` = '%s'", normalise_link($jj->url));
|
||||
if ($exists) {
|
||||
if (dbm::is_result($exists)) {
|
||||
logger("Profile ".$jj->url." already exists (".$search.")", LOGGER_DEBUG);
|
||||
|
||||
if (($exists[0]["last_contact"] < $exists[0]["last_failure"]) AND
|
||||
|
@ -272,11 +272,15 @@ function gs_search_user($search) {
|
|||
if (!$result["success"]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$contacts = json_decode($result["body"]);
|
||||
|
||||
if ($contacts->status == 'ERROR') {
|
||||
return false;
|
||||
}
|
||||
|
||||
/// @TODO AS is considered as a notation for constants (as they usually being written all upper-case)
|
||||
/// @TODO find all those and convert to all lower-case which is a keyword then
|
||||
foreach ($contacts->data AS $user) {
|
||||
$contact = probe_url($user->site_address."/".$user->name);
|
||||
if ($contact["network"] != NETWORK_PHANTOM) {
|
||||
|
|
|
@ -411,10 +411,12 @@ function notification($params) {
|
|||
$hash = random_string();
|
||||
$r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
|
||||
dbesc($hash));
|
||||
if (dbm::is_result($r))
|
||||
if (dbm::is_result($r)) {
|
||||
$dups = true;
|
||||
}
|
||||
} while ($dups == true);
|
||||
|
||||
/// @TODO One statement is enough
|
||||
$datarray = array();
|
||||
$datarray['hash'] = $hash;
|
||||
$datarray['name'] = $params['source_name'];
|
||||
|
|
|
@ -11,12 +11,13 @@ function expire_run(&$argv, &$argc){
|
|||
|
||||
// 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");
|
||||
|
||||
// make this optional as it could have a performance impact on large sites
|
||||
|
||||
if(intval(get_config('system','optimize_items')))
|
||||
q("optimize table item");
|
||||
if (intval(get_config('system','optimize_items'))) {
|
||||
q("OPTIMIZE TABLE `item`");
|
||||
}
|
||||
|
||||
logger('expire: start');
|
||||
|
||||
|
|
|
@ -200,7 +200,6 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
|
|||
if ($item["plink"] == "") {
|
||||
$item["plink"] = $xpath->evaluate('rss:link/text()', $entry)->item(0)->nodeValue;
|
||||
}
|
||||
$item["plink"] = original_url($item["plink"]);
|
||||
|
||||
$item["uri"] = $xpath->evaluate('atom:id/text()', $entry)->item(0)->nodeValue;
|
||||
|
||||
|
@ -210,12 +209,17 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
|
|||
if ($item["uri"] == "") {
|
||||
$item["uri"] = $item["plink"];
|
||||
}
|
||||
|
||||
$orig_plink = $item["plink"];
|
||||
|
||||
$item["plink"] = original_url($item["plink"]);
|
||||
|
||||
$item["parent-uri"] = $item["uri"];
|
||||
|
||||
if (!$simulate) {
|
||||
$r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' AND `network` IN ('%s', '%s')",
|
||||
intval($importer["uid"]), dbesc($item["uri"]), dbesc(NETWORK_FEED), dbesc(NETWORK_DFRN));
|
||||
if ($r) {
|
||||
if (dbm::is_result($r)) {
|
||||
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$r[0]["id"], LOGGER_DEBUG);
|
||||
continue;
|
||||
}
|
||||
|
@ -340,6 +344,7 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
|
|||
// Distributed items should have a well formatted URI.
|
||||
// Additionally we have to avoid conflicts with identical URI between imported feeds and these items.
|
||||
if ($notify) {
|
||||
$item['guid'] = uri_to_guid($orig_plink, $a->get_hostname());
|
||||
unset($item['uri']);
|
||||
unset($item['parent-uri']);
|
||||
}
|
||||
|
|
|
@ -202,6 +202,9 @@ function profile_sidebar($profile, $block = 0) {
|
|||
$address = false;
|
||||
// $pdesc = true;
|
||||
|
||||
// This function can also use contact information in $profile
|
||||
$is_contact = x($profile, 'cid');
|
||||
|
||||
if((! is_array($profile)) && (! count($profile)))
|
||||
return $o;
|
||||
|
||||
|
@ -281,7 +284,7 @@ function profile_sidebar($profile, $block = 0) {
|
|||
}
|
||||
|
||||
// show edit profile to yourself
|
||||
if ($profile['uid'] == local_user() && feature_enabled(local_user(),'multi_profiles')) {
|
||||
if (!$is_contact && $profile['uid'] == local_user() && feature_enabled(local_user(),'multi_profiles')) {
|
||||
$profile['edit'] = array(App::get_baseurl(). '/profiles', t('Profiles'),"", t('Manage/edit profiles'));
|
||||
$r = q("SELECT * FROM `profile` WHERE `uid` = %d",
|
||||
local_user());
|
||||
|
@ -310,7 +313,7 @@ function profile_sidebar($profile, $block = 0) {
|
|||
|
||||
}
|
||||
}
|
||||
if ($profile['uid'] == local_user() && !feature_enabled(local_user(),'multi_profiles')) {
|
||||
if (!$is_contact && $profile['uid'] == local_user() && !feature_enabled(local_user(),'multi_profiles')) {
|
||||
$profile['edit'] = array(App::get_baseurl(). '/profiles/'.$profile['id'], t('Edit profile'),"", t('Edit profile'));
|
||||
$profile['menu'] = array(
|
||||
'chg_photo' => t('Change profile photo'),
|
||||
|
@ -628,7 +631,7 @@ function advanced_profile(App $a) {
|
|||
if($a->profile['gender']) $profile['gender'] = array( t('Gender:'), $a->profile['gender'] );
|
||||
|
||||
|
||||
if(($a->profile['dob']) && ($a->profile['dob'] != '0000-00-00')) {
|
||||
if(($a->profile['dob']) && ($a->profile['dob'] > '0001-01-01')) {
|
||||
|
||||
$year_bd_format = t('j F, Y');
|
||||
$short_bd_format = t('j F');
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -516,7 +516,8 @@ function notifier_run(&$argv, &$argc){
|
|||
$r0 = Diaspora::relay_list();
|
||||
}
|
||||
|
||||
$r1 = q("SELECT DISTINCT(`batch`), `id`, `name`,`network` FROM `contact` WHERE `network` = '%s'
|
||||
$r1 = q("SELECT `batch`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`name`) AS `name`, ANY_VALUE(`network`) AS `network`
|
||||
FROM `contact` WHERE `network` = '%s'
|
||||
AND `uid` = %d AND `rel` != %d AND NOT `blocked` AND NOT `pending` AND NOT `archive` GROUP BY `batch` ORDER BY rand()",
|
||||
dbesc(NETWORK_DIASPORA),
|
||||
intval($owner['uid']),
|
||||
|
|
|
@ -355,6 +355,14 @@ class ostatus {
|
|||
|
||||
$item["body"] = add_page_info_to_body(html2bbcode($xpath->query('atom:content/text()', $entry)->item(0)->nodeValue));
|
||||
$item["object-type"] = $xpath->query('activity:object-type/text()', $entry)->item(0)->nodeValue;
|
||||
$item["verb"] = $xpath->query('activity:verb/text()', $entry)->item(0)->nodeValue;
|
||||
|
||||
// Mastodon Content Warning
|
||||
if (($item["verb"] == ACTIVITY_POST) AND $xpath->evaluate('boolean(atom:summary)', $entry)) {
|
||||
$clear_text = $xpath->query('atom:summary/text()', $entry)->item(0)->nodeValue;
|
||||
|
||||
$item["body"] = html2bbcode($clear_text) . '[spoiler]' . $item["body"] . '[/spoiler]';
|
||||
}
|
||||
|
||||
if (($item["object-type"] == ACTIVITY_OBJ_BOOKMARK) OR ($item["object-type"] == ACTIVITY_OBJ_EVENT)) {
|
||||
$item["title"] = $xpath->query('atom:title/text()', $entry)->item(0)->nodeValue;
|
||||
|
@ -363,11 +371,10 @@ class ostatus {
|
|||
$item["title"] = $xpath->query('atom:title/text()', $entry)->item(0)->nodeValue;
|
||||
}
|
||||
$item["object"] = $xml;
|
||||
$item["verb"] = $xpath->query('activity:verb/text()', $entry)->item(0)->nodeValue;
|
||||
|
||||
/// @TODO
|
||||
/// Delete a message
|
||||
if ($item["verb"] == "qvitter-delete-notice") {
|
||||
if ($item["verb"] == "qvitter-delete-notice" || $item["verb"] == ACTIVITY_DELETE) {
|
||||
// ignore "Delete" messages (by now)
|
||||
logger("Ignore delete message ".print_r($item, true));
|
||||
continue;
|
||||
|
@ -713,11 +720,11 @@ class ostatus {
|
|||
$conversations = q("SELECT `term`.`oid`, `term`.`url`, `term`.`uid` FROM `term`
|
||||
STRAIGHT_JOIN `thread` ON `thread`.`iid` = `term`.`oid` AND `thread`.`uid` = `term`.`uid`
|
||||
WHERE `term`.`type` = 7 AND `term`.`term` > '%s' AND `thread`.`mention`
|
||||
GROUP BY `term`.`url`, `term`.`uid` ORDER BY `term`.`term` DESC", dbesc($start));
|
||||
GROUP BY `term`.`url`, `term`.`uid`, `term`.`oid`, `term`.`term` ORDER BY `term`.`term` DESC", dbesc($start));
|
||||
} else {
|
||||
$conversations = q("SELECT `oid`, `url`, `uid` FROM `term`
|
||||
WHERE `type` = 7 AND `term` > '%s'
|
||||
GROUP BY `url`, `uid` ORDER BY `term` DESC", dbesc($start));
|
||||
GROUP BY `url`, `uid`, `oid`, `term` ORDER BY `term` DESC", dbesc($start));
|
||||
}
|
||||
|
||||
foreach ($conversations AS $conversation) {
|
||||
|
@ -1473,14 +1480,6 @@ class ostatus {
|
|||
$siteinfo = get_attached_data($item["body"]);
|
||||
|
||||
switch ($siteinfo["type"]) {
|
||||
case 'link':
|
||||
$attributes = array("rel" => "enclosure",
|
||||
"href" => $siteinfo["url"],
|
||||
"type" => "text/html; charset=UTF-8",
|
||||
"length" => "",
|
||||
"title" => $siteinfo["title"]);
|
||||
xml::add_element($doc, $root, "link", "", $attributes);
|
||||
break;
|
||||
case 'photo':
|
||||
$imgdata = get_photo_info($siteinfo["image"]);
|
||||
$attributes = array("rel" => "enclosure",
|
||||
|
@ -1502,13 +1501,15 @@ class ostatus {
|
|||
}
|
||||
|
||||
if (($siteinfo["type"] != "photo") AND isset($siteinfo["image"])) {
|
||||
$photodata = get_photo_info($siteinfo["image"]);
|
||||
$imgdata = get_photo_info($siteinfo["image"]);
|
||||
$attributes = array("rel" => "enclosure",
|
||||
"href" => $siteinfo["image"],
|
||||
"type" => $imgdata["mime"],
|
||||
"length" => intval($imgdata["size"]));
|
||||
|
||||
$attributes = array("rel" => "preview", "href" => $siteinfo["image"], "media:width" => $photodata[0], "media:height" => $photodata[1]);
|
||||
xml::add_element($doc, $root, "link", "", $attributes);
|
||||
}
|
||||
|
||||
|
||||
$arr = explode('[/attach],', $item['attach']);
|
||||
if (count($arr)) {
|
||||
foreach ($arr as $r) {
|
||||
|
@ -1519,12 +1520,12 @@ class ostatus {
|
|||
"href" => $matches[1],
|
||||
"type" => $matches[3]);
|
||||
|
||||
if(intval($matches[2]))
|
||||
if (intval($matches[2])) {
|
||||
$attributes["length"] = intval($matches[2]);
|
||||
|
||||
if(trim($matches[4]) != "")
|
||||
}
|
||||
if (trim($matches[4]) != "") {
|
||||
$attributes["title"] = trim($matches[4]);
|
||||
|
||||
}
|
||||
xml::add_element($doc, $root, "link", "", $attributes);
|
||||
}
|
||||
}
|
||||
|
@ -2052,7 +2053,7 @@ class ostatus {
|
|||
|
||||
$mentioned = array();
|
||||
|
||||
if (($item['parent'] != $item['id']) || ($item['parent-uri'] !== $item['uri']) || (($item['thr-parent'] !== '') && ($item['thr-parent'] !== $item['uri']))) {
|
||||
if (($item['parent'] != $item['id']) OR ($item['parent-uri'] !== $item['uri']) OR (($item['thr-parent'] !== '') AND ($item['thr-parent'] !== $item['uri']))) {
|
||||
$parent = q("SELECT `guid`, `author-link`, `owner-link` FROM `item` WHERE `id` = %d", intval($item["parent"]));
|
||||
$parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
|
||||
|
||||
|
@ -2082,7 +2083,13 @@ class ostatus {
|
|||
if (intval($item["parent"]) > 0) {
|
||||
$conversation = App::get_baseurl()."/display/".$owner["nick"]."/".$item["parent"];
|
||||
xml::add_element($doc, $entry, "link", "", array("rel" => "ostatus:conversation", "href" => $conversation));
|
||||
xml::add_element($doc, $entry, "ostatus:conversation", $conversation);
|
||||
|
||||
$attributes = array(
|
||||
"href" => $conversation,
|
||||
"local_id" => $item["parent"],
|
||||
"ref" => $conversation);
|
||||
|
||||
xml::add_element($doc, $entry, "ostatus:conversation", $conversation, $attributes);
|
||||
}
|
||||
|
||||
$tags = item_getfeedtags($item);
|
||||
|
|
|
@ -44,7 +44,7 @@ function get_browser_language() {
|
|||
// check if we have translations for the preferred languages and pick the 1st that has
|
||||
for ($i=0; $i<count($lang_list); $i++) {
|
||||
$lang = $lang_list[$i];
|
||||
if(file_exists("view/lang/$lang") && is_dir("view/lang/$lang")) {
|
||||
if ($lang === 'en' || (file_exists("view/lang/$lang") && is_dir("view/lang/$lang"))) {
|
||||
$preferred = $lang;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ function photo_albums($uid, $update = false) {
|
|||
if (!Config::get('system', 'no_count', false)) {
|
||||
/// @todo This query needs to be renewed. It is really slow
|
||||
// At this time we just store the data in the cache
|
||||
$albums = qu("SELECT COUNT(DISTINCT `resource-id`) AS `total`, `album`
|
||||
$albums = qu("SELECT COUNT(DISTINCT `resource-id`) AS `total`, `album`, ANY_VALUE(`created`) AS `created`
|
||||
FROM `photo`
|
||||
WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' $sql_extra
|
||||
GROUP BY `album` ORDER BY `created` DESC",
|
||||
|
@ -59,9 +59,8 @@ function photo_albums($uid, $update = false) {
|
|||
} else {
|
||||
// This query doesn't do the count and is much faster
|
||||
$albums = qu("SELECT DISTINCT(`album`), '' AS `total`
|
||||
FROM `photo`
|
||||
WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' $sql_extra
|
||||
GROUP BY `album` ORDER BY `created` DESC",
|
||||
FROM `photo` USE INDEX (`uid_album_scale_created`)
|
||||
WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' $sql_extra",
|
||||
intval($uid),
|
||||
dbesc('Contact Photos'),
|
||||
dbesc(t('Contact Photos'))
|
||||
|
|
|
@ -16,8 +16,7 @@ function get_salmon_key($uri,$keyhash) {
|
|||
$ret[] = $a['@attributes']['href'];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -50,8 +49,7 @@ function get_salmon_key($uri,$keyhash) {
|
|||
// have one key we'll be right.
|
||||
|
||||
return $ret[0];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
foreach ($ret as $a) {
|
||||
$hash = base64url_encode(hash('sha256', $a));
|
||||
if ($hash == $keyhash) {
|
||||
|
@ -69,9 +67,9 @@ function slapper($owner,$url,$slap) {
|
|||
|
||||
// does contact have a salmon endpoint?
|
||||
|
||||
if(! strlen($url))
|
||||
if (! strlen($url)) {
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (! $owner['sprvkey']) {
|
||||
logger(sprintf("user '%s' (%d) does not have a salmon private key. Send failed.",
|
||||
|
@ -89,25 +87,28 @@ function slapper($owner,$url,$slap) {
|
|||
$algorithm = 'RSA-SHA256';
|
||||
$keyhash = base64url_encode(hash('sha256', salmon_key($owner['spubkey'])), true);
|
||||
|
||||
// precomputed base64url encoding of data_type, encoding, algorithm concatenated with periods
|
||||
$precomputed = '.' . base64url_encode($data_type) . '.' . base64url_encode($encoding) . '.' . base64url_encode($algorithm);
|
||||
|
||||
$precomputed = '.YXBwbGljYXRpb24vYXRvbSt4bWw=.YmFzZTY0dXJs.UlNBLVNIQTI1Ng==';
|
||||
// GNU Social format
|
||||
$signature = base64url_encode(rsa_sign($data . $precomputed, $owner['sprvkey']));
|
||||
|
||||
$signature = base64url_encode(rsa_sign(str_replace('=','',$data . $precomputed),$owner['sprvkey']));
|
||||
|
||||
$signature2 = base64url_encode(rsa_sign($data . $precomputed,$owner['sprvkey']));
|
||||
// Compliant format
|
||||
$signature2 = base64url_encode(rsa_sign(str_replace('=', '', $data . $precomputed), $owner['sprvkey']));
|
||||
|
||||
// Old Status.net format
|
||||
$signature3 = base64url_encode(rsa_sign($data, $owner['sprvkey']));
|
||||
|
||||
$salmon_tpl = get_markup_template('magicsig.tpl');
|
||||
// At first try the non compliant method that works for GNU Social
|
||||
$xmldata = array("me:env" => array("me:data" => $data,
|
||||
"@attributes" => array("type" => $data_type),
|
||||
"me:encoding" => $encoding,
|
||||
"me:alg" => $algorithm,
|
||||
"me:sig" => $signature,
|
||||
"@attributes2" => array("key_id" => $keyhash)));
|
||||
|
||||
$salmon = replace_macros($salmon_tpl,array(
|
||||
'$data' => $data,
|
||||
'$encoding' => $encoding,
|
||||
'$algorithm' => $algorithm,
|
||||
'$keyhash' => $keyhash,
|
||||
'$signature' => $signature
|
||||
));
|
||||
$namespaces = array("me" => "http://salmon-protocol.org/ns/magic-env");
|
||||
|
||||
$salmon = xml::from_array($xmldata, $xml, false, $namespaces);
|
||||
|
||||
// slap them
|
||||
post_url($url, $salmon, array(
|
||||
|
@ -122,19 +123,19 @@ function slapper($owner,$url,$slap) {
|
|||
|
||||
if ($return_code > 299) {
|
||||
|
||||
logger('compliant salmon failed. Falling back to status.net hack2');
|
||||
logger('GNU Social salmon failed. Falling back to compliant mode');
|
||||
|
||||
// Entirely likely that their salmon implementation is
|
||||
// non-compliant. Let's try once more, this time only signing
|
||||
// the data, without stripping '=' chars
|
||||
// Now try the compliant mode that normally isn't used for GNU Social
|
||||
$xmldata = array("me:env" => array("me:data" => $data,
|
||||
"@attributes" => array("type" => $data_type),
|
||||
"me:encoding" => $encoding,
|
||||
"me:alg" => $algorithm,
|
||||
"me:sig" => $signature2,
|
||||
"@attributes2" => array("key_id" => $keyhash)));
|
||||
|
||||
$salmon = replace_macros($salmon_tpl,array(
|
||||
'$data' => $data,
|
||||
'$encoding' => $encoding,
|
||||
'$algorithm' => $algorithm,
|
||||
'$keyhash' => $keyhash,
|
||||
'$signature' => $signature2
|
||||
));
|
||||
$namespaces = array("me" => "http://salmon-protocol.org/ns/magic-env");
|
||||
|
||||
$salmon = xml::from_array($xmldata, $xml, false, $namespaces);
|
||||
|
||||
// slap them
|
||||
post_url($url, $salmon, array(
|
||||
|
@ -142,23 +143,22 @@ function slapper($owner,$url,$slap) {
|
|||
'Content-length: ' . strlen($salmon)
|
||||
));
|
||||
$return_code = $a->get_curl_code();
|
||||
|
||||
}
|
||||
|
||||
if ($return_code > 299) {
|
||||
logger('compliant salmon failed. Falling back to old status.net');
|
||||
|
||||
logger('compliant salmon failed. Falling back to status.net hack3');
|
||||
// Last try. This will most likely fail as well.
|
||||
$xmldata = array("me:env" => array("me:data" => $data,
|
||||
"@attributes" => array("type" => $data_type),
|
||||
"me:encoding" => $encoding,
|
||||
"me:alg" => $algorithm,
|
||||
"me:sig" => $signature3,
|
||||
"@attributes2" => array("key_id" => $keyhash)));
|
||||
|
||||
// Entirely likely that their salmon implementation is
|
||||
// non-compliant. Let's try once more, this time only signing
|
||||
// the data, without the precomputed blob
|
||||
$namespaces = array("me" => "http://salmon-protocol.org/ns/magic-env");
|
||||
|
||||
$salmon = replace_macros($salmon_tpl,array(
|
||||
'$data' => $data,
|
||||
'$encoding' => $encoding,
|
||||
'$algorithm' => $algorithm,
|
||||
'$keyhash' => $keyhash,
|
||||
'$signature' => $signature3
|
||||
));
|
||||
$salmon = xml::from_array($xmldata, $xml, false, $namespaces);
|
||||
|
||||
// slap them
|
||||
post_url($url, $salmon, array(
|
||||
|
@ -167,13 +167,13 @@ function slapper($owner,$url,$slap) {
|
|||
));
|
||||
$return_code = $a->get_curl_code();
|
||||
}
|
||||
}
|
||||
logger('slapper for '.$url.' returned ' . $return_code);
|
||||
if(! $return_code)
|
||||
return(-1);
|
||||
if(($return_code == 503) && (stristr($a->get_curl_headers(),'retry-after')))
|
||||
return(-1);
|
||||
|
||||
logger('slapper for '.$url.' returned ' . $return_code);
|
||||
if (! $return_code) {
|
||||
return(-1);
|
||||
}
|
||||
if (($return_code == 503) && (stristr($a->get_curl_headers(), 'retry-after'))) {
|
||||
return(-1);
|
||||
}
|
||||
return ((($return_code >= 200) && ($return_code < 300)) ? 0 : 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
* @todo Detect if it is a forum
|
||||
*/
|
||||
|
||||
use \Friendica\Core\Config;
|
||||
|
||||
require_once('include/datetime.php');
|
||||
require_once("include/Scrape.php");
|
||||
require_once("include/network.php");
|
||||
|
@ -1656,6 +1658,20 @@ function poco_discover_federation() {
|
|||
}
|
||||
}
|
||||
|
||||
// Disvover Mastodon servers
|
||||
if (!Config::get('system','ostatus_disabled')) {
|
||||
$serverdata = fetch_url("https://instances.mastodon.xyz/instances.json");
|
||||
|
||||
if ($serverdata) {
|
||||
$servers = json_decode($serverdata);
|
||||
|
||||
foreach ($servers AS $server) {
|
||||
$url = (is_null($server->https_score) ? 'http' : 'https').'://'.$server->name;
|
||||
proc_run(PRIORITY_LOW, "include/discover_poco.php", "server", base64_encode($url));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Currently disabled, since the service isn't available anymore.
|
||||
// It is not removed since I hope that there will be a successor.
|
||||
// Discover GNU Social Servers.
|
||||
|
@ -2096,7 +2112,7 @@ function update_gcontact($contact) {
|
|||
fix_alternate_contact_address($contact);
|
||||
|
||||
if (!isset($contact["updated"]))
|
||||
$contact["updated"] = datetime_convert();
|
||||
$contact["updated"] = dbm::date();
|
||||
|
||||
if ($contact["server_url"] == "") {
|
||||
$server_url = $contact["url"];
|
||||
|
@ -2151,7 +2167,7 @@ function update_gcontact($contact) {
|
|||
dbesc($contact["gender"]), dbesc($contact["keywords"]), intval($contact["hide"]),
|
||||
intval($contact["nsfw"]), intval($contact["contact-type"]), dbesc($contact["alias"]),
|
||||
dbesc($contact["notify"]), dbesc($contact["url"]), dbesc($contact["location"]),
|
||||
dbesc($contact["about"]), intval($contact["generation"]), dbesc($contact["updated"]),
|
||||
dbesc($contact["about"]), intval($contact["generation"]), dbesc(dbm::date($contact["updated"])),
|
||||
dbesc($contact["server_url"]), dbesc($contact["connect"]),
|
||||
dbesc(normalise_link($contact["url"])), intval($contact["generation"]));
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ ACL.prototype.add_mention = function(id) {
|
|||
if (this.element.val().indexOf( searchText) >= 0 ) {
|
||||
return;
|
||||
}
|
||||
this.element.val(searchText + this.element.val());
|
||||
this.element.val(searchText + this.element.val()).trigger('change');
|
||||
}
|
||||
|
||||
ACL.prototype.on_submit = function(){
|
||||
|
|
|
@ -166,7 +166,7 @@ function listNewLineAutocomplete(id) {
|
|||
if (word != null) {
|
||||
var textBefore = text.value.substring(0, caretPos);
|
||||
var textAfter = text.value.substring(caretPos, text.length);
|
||||
$('#' + id).val(textBefore + '\r\n[*] ' + textAfter);
|
||||
$('#' + id).val(textBefore + '\r\n[*] ' + textAfter).trigger('change');
|
||||
setCaretPosition(text, caretPos + 5);
|
||||
return true;
|
||||
}
|
||||
|
|
38
js/main.js
38
js/main.js
|
@ -101,6 +101,7 @@
|
|||
var start = textarea.selectionStart;
|
||||
var end = textarea.selectionEnd;
|
||||
textarea.value = textarea.value.substring(0, start) + bbcode + textarea.value.substring(end, textarea.value.length);
|
||||
$(textarea).trigger('change');
|
||||
});
|
||||
|
||||
|
||||
|
@ -223,8 +224,11 @@
|
|||
var nnm = $("#nav-notifications-menu");
|
||||
nnm.html(notifications_all + notifications_mark);
|
||||
|
||||
var notification_lastitem = parseInt(localStorage.getItem("notification-lastitem"));
|
||||
var lastItemStorageKey = "notification-lastitem:" + localUser;
|
||||
var notification_lastitem = parseInt(localStorage.getItem(lastItemStorageKey));
|
||||
var notification_id = 0;
|
||||
|
||||
// Insert notifs into the notifications-menu
|
||||
$(data.notifications).each(function(key, notif){
|
||||
var text = notif.message.format('<span class="contactname">' + notif.name + '</span>');
|
||||
var contact = ('<a href="' + notif.url + '"><span class="contactname">' + notif.name + '</span></a>');
|
||||
|
@ -242,9 +246,11 @@
|
|||
);
|
||||
nnm.append(html);
|
||||
});
|
||||
|
||||
// Desktop Notifications
|
||||
$(data.notifications.reverse()).each(function(key, e){
|
||||
notification_id = parseInt(e.timestamp);
|
||||
if (notification_lastitem !== null && notification_id > notification_lastitem) {
|
||||
if (notification_lastitem !== null && notification_id > notification_lastitem && Number(e.seen) === 0) {
|
||||
if (getNotificationPermission() === "granted") {
|
||||
var notification = new Notification(document.title, {
|
||||
body: decodeHtml(e.message.replace('→ ', '').format(e.name)),
|
||||
|
@ -259,7 +265,7 @@
|
|||
|
||||
});
|
||||
notification_lastitem = notification_id;
|
||||
localStorage.setItem("notification-lastitem", notification_lastitem)
|
||||
localStorage.setItem(lastItemStorageKey, notification_lastitem)
|
||||
|
||||
$("img[data-src]", nnm).each(function(i, el){
|
||||
// Add src attribute for images with a data-src attribute
|
||||
|
@ -285,7 +291,7 @@
|
|||
$.jGrowl(message, {sticky: false, theme: 'info', life: 5000});
|
||||
});
|
||||
|
||||
/* update the js scrollbars */
|
||||
// Update the js scrollbars
|
||||
$('#nav-notifications-menu').perfectScrollbar('update');
|
||||
|
||||
});
|
||||
|
@ -317,6 +323,30 @@
|
|||
}
|
||||
});
|
||||
|
||||
// Scroll to the next/previous thread when pressing J and K
|
||||
$(document).keydown(function (event) {
|
||||
var threads = $('.thread_level_1');
|
||||
if ((event.keyCode === 74 || event.keyCode === 75) && !$(event.target).is('textarea, input')) {
|
||||
var scrollTop = $(window).scrollTop();
|
||||
if (event.keyCode === 75) {
|
||||
threads = $(threads.get().reverse());
|
||||
}
|
||||
threads.each(function(key, item) {
|
||||
var comparison;
|
||||
var top = $(item).offset().top - 100;
|
||||
if (event.keyCode === 74) {
|
||||
comparison = top > scrollTop + 1;
|
||||
} else if (event.keyCode === 75) {
|
||||
comparison = top < scrollTop - 1;
|
||||
}
|
||||
if (comparison) {
|
||||
$('html, body').animate({ scrollTop: top }, 200);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Set an event listener for infinite scroll
|
||||
if(typeof infinite_scroll !== 'undefined') {
|
||||
$(window).scroll(function(e){
|
||||
|
|
3
library/html-to-markdown/.gitignore
vendored
3
library/html-to-markdown/.gitignore
vendored
|
@ -1,3 +0,0 @@
|
|||
~*
|
||||
vendor
|
||||
composer.lock
|
|
@ -1,6 +0,0 @@
|
|||
language: php
|
||||
php:
|
||||
- "5.5"
|
||||
- "5.4"
|
||||
- "5.3"
|
||||
script: phpunit --no-configuration HTML_To_MarkdownTest ./tests/HTML_To_MarkdownTest.php
|
|
@ -1,598 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Class HTML_To_Markdown
|
||||
*
|
||||
* A helper class to convert HTML to Markdown.
|
||||
*
|
||||
* @version 2.2.1
|
||||
* @author Nick Cernis <nick@cern.is>
|
||||
* @link https://github.com/nickcernis/html2markdown/ Latest version on GitHub.
|
||||
* @link http://twitter.com/nickcernis Nick on twitter.
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
*/
|
||||
class HTML_To_Markdown
|
||||
{
|
||||
/**
|
||||
* @var DOMDocument The root of the document tree that holds our HTML.
|
||||
*/
|
||||
private $document;
|
||||
|
||||
/**
|
||||
* @var string|boolean The Markdown version of the original HTML, or false if conversion failed
|
||||
*/
|
||||
private $output;
|
||||
|
||||
/**
|
||||
* @var array Class-wide options users can override.
|
||||
*/
|
||||
private $options = array(
|
||||
'header_style' => 'setext', // Set to "atx" to output H1 and H2 headers as # Header1 and ## Header2
|
||||
'suppress_errors' => true, // Set to false to show warnings when loading malformed HTML
|
||||
'strip_tags' => false, // Set to true to strip tags that don't have markdown equivalents. N.B. Strips tags, not their content. Useful to clean MS Word HTML output.
|
||||
'bold_style' => '**', // Set to '__' if you prefer the underlined style
|
||||
'italic_style' => '*', // Set to '_' if you prefer the underlined style
|
||||
'remove_nodes' => '', // space-separated list of dom nodes that should be removed. example: "meta style script"
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Set up a new DOMDocument from the supplied HTML, convert it to Markdown, and store it in $this->$output.
|
||||
*
|
||||
* @param string $html The HTML to convert to Markdown.
|
||||
* @param array $overrides [optional] List of style and error display overrides.
|
||||
*/
|
||||
public function __construct($html = null, $overrides = null)
|
||||
{
|
||||
if ($overrides)
|
||||
$this->options = array_merge($this->options, $overrides);
|
||||
|
||||
if ($html)
|
||||
$this->convert($html);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setter for conversion options
|
||||
*
|
||||
* @param $name
|
||||
* @param $value
|
||||
*/
|
||||
public function set_option($name, $value)
|
||||
{
|
||||
$this->options[$name] = $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert
|
||||
*
|
||||
* Loads HTML and passes to get_markdown()
|
||||
*
|
||||
* @param $html
|
||||
* @return string The Markdown version of the html
|
||||
*/
|
||||
public function convert($html)
|
||||
{
|
||||
$html = preg_replace('~>\s+<~', '><', $html); // Strip white space between tags to prevent creation of empty #text nodes
|
||||
|
||||
$this->document = new DOMDocument();
|
||||
|
||||
if ($this->options['suppress_errors'])
|
||||
libxml_use_internal_errors(true); // Suppress conversion errors (from http://bit.ly/pCCRSX )
|
||||
|
||||
$this->document->loadHTML('<?xml encoding="UTF-8">' . $html); // Hack to load utf-8 HTML (from http://bit.ly/pVDyCt )
|
||||
$this->document->encoding = 'UTF-8';
|
||||
|
||||
if ($this->options['suppress_errors'])
|
||||
libxml_clear_errors();
|
||||
|
||||
return $this->get_markdown($html);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Is Child Of?
|
||||
*
|
||||
* Is the node a child of the given parent tag?
|
||||
*
|
||||
* @param $parent_name string|array The name of the parent node(s) to search for e.g. 'code' or array('pre', 'code')
|
||||
* @param $node
|
||||
* @return bool
|
||||
*/
|
||||
private static function is_child_of($parent_name, $node)
|
||||
{
|
||||
for ($p = $node->parentNode; $p != false; $p = $p->parentNode) {
|
||||
if (is_null($p))
|
||||
return false;
|
||||
|
||||
if ( is_array($parent_name) && in_array($p->nodeName, $parent_name) )
|
||||
return true;
|
||||
|
||||
if ($p->nodeName == $parent_name)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert Children
|
||||
*
|
||||
* Recursive function to drill into the DOM and convert each node into Markdown from the inside out.
|
||||
*
|
||||
* Finds children of each node and convert those to #text nodes containing their Markdown equivalent,
|
||||
* starting with the innermost element and working up to the outermost element.
|
||||
*
|
||||
* @param $node
|
||||
*/
|
||||
private function convert_children($node)
|
||||
{
|
||||
// Don't convert HTML code inside <code> and <pre> blocks to Markdown - that should stay as HTML
|
||||
if (self::is_child_of(array('pre', 'code'), $node))
|
||||
return;
|
||||
|
||||
// If the node has children, convert those to Markdown first
|
||||
if ($node->hasChildNodes()) {
|
||||
$length = $node->childNodes->length;
|
||||
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$child = $node->childNodes->item($i);
|
||||
$this->convert_children($child);
|
||||
}
|
||||
}
|
||||
|
||||
// Now that child nodes have been converted, convert the original node
|
||||
$markdown = $this->convert_to_markdown($node);
|
||||
|
||||
// Create a DOM text node containing the Markdown equivalent of the original node
|
||||
$markdown_node = $this->document->createTextNode($markdown);
|
||||
|
||||
// Replace the old $node e.g. "<h3>Title</h3>" with the new $markdown_node e.g. "### Title"
|
||||
$node->parentNode->replaceChild($markdown_node, $node);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Markdown
|
||||
*
|
||||
* Sends the body node to convert_children() to change inner nodes to Markdown #text nodes, then saves and
|
||||
* returns the resulting converted document as a string in Markdown format.
|
||||
*
|
||||
* @return string|boolean The converted HTML as Markdown, or false if conversion failed
|
||||
*/
|
||||
private function get_markdown()
|
||||
{
|
||||
// Work on the entire DOM tree (including head and body)
|
||||
$input = $this->document->getElementsByTagName("html")->item(0);
|
||||
|
||||
if (!$input)
|
||||
return false;
|
||||
|
||||
// Convert all children of this root element. The DOMDocument stored in $this->doc will
|
||||
// then consist of #text nodes, each containing a Markdown version of the original node
|
||||
// that it replaced.
|
||||
$this->convert_children($input);
|
||||
|
||||
// Sanitize and return the body contents as a string.
|
||||
$markdown = $this->document->saveHTML(); // stores the DOMDocument as a string
|
||||
$markdown = html_entity_decode($markdown, ENT_QUOTES, 'UTF-8');
|
||||
$markdown = html_entity_decode($markdown, ENT_QUOTES, 'UTF-8'); // Double decode to cover cases like &nbsp; http://www.php.net/manual/en/function.htmlentities.php#99984
|
||||
$markdown = preg_replace("/<!DOCTYPE [^>]+>/", "", $markdown); // Strip doctype declaration
|
||||
$unwanted = array('<html>', '</html>', '<body>', '</body>', '<head>', '</head>', '<?xml encoding="UTF-8">', '
');
|
||||
$markdown = str_replace($unwanted, '', $markdown); // Strip unwanted tags
|
||||
$markdown = trim($markdown, "\n\r\0\x0B");
|
||||
|
||||
$this->output = $markdown;
|
||||
|
||||
return $markdown;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert to Markdown
|
||||
*
|
||||
* Converts an individual node into a #text node containing a string of its Markdown equivalent.
|
||||
*
|
||||
* Example: An <h3> node with text content of "Title" becomes a text node with content of "### Title"
|
||||
*
|
||||
* @param $node
|
||||
* @return string The converted HTML as Markdown
|
||||
*/
|
||||
private function convert_to_markdown($node)
|
||||
{
|
||||
$tag = $node->nodeName; // the type of element, e.g. h1
|
||||
$value = $node->nodeValue; // the value of that element, e.g. The Title
|
||||
|
||||
// Strip nodes named in remove_nodes
|
||||
$tags_to_remove = explode(' ', $this->options['remove_nodes']);
|
||||
if ( in_array($tag, $tags_to_remove) )
|
||||
return false;
|
||||
|
||||
switch ($tag) {
|
||||
case "p":
|
||||
$markdown = (trim($value)) ? rtrim($value) . PHP_EOL . PHP_EOL : '';
|
||||
break;
|
||||
case "pre":
|
||||
$markdown = PHP_EOL . $this->convert_code($node) . PHP_EOL;
|
||||
break;
|
||||
case "h1":
|
||||
case "h2":
|
||||
$markdown = $this->convert_header($tag, $node);
|
||||
break;
|
||||
case "h3":
|
||||
$markdown = "### " . $value . PHP_EOL . PHP_EOL;
|
||||
break;
|
||||
case "h4":
|
||||
$markdown = "#### " . $value . PHP_EOL . PHP_EOL;
|
||||
break;
|
||||
case "h5":
|
||||
$markdown = "##### " . $value . PHP_EOL . PHP_EOL;
|
||||
break;
|
||||
case "h6":
|
||||
$markdown = "###### " . $value . PHP_EOL . PHP_EOL;
|
||||
break;
|
||||
case "em":
|
||||
case "i":
|
||||
case "strong":
|
||||
case "b":
|
||||
$markdown = $this->convert_emphasis($tag, $value);
|
||||
break;
|
||||
case "hr":
|
||||
$markdown = "- - - - - -" . PHP_EOL . PHP_EOL;
|
||||
break;
|
||||
case "br":
|
||||
$markdown = " " . PHP_EOL;
|
||||
break;
|
||||
case "blockquote":
|
||||
$markdown = $this->convert_blockquote($node);
|
||||
break;
|
||||
case "code":
|
||||
$markdown = $this->convert_code($node);
|
||||
break;
|
||||
case "ol":
|
||||
case "ul":
|
||||
$markdown = $value . PHP_EOL;
|
||||
break;
|
||||
case "li":
|
||||
$markdown = $this->convert_list($node);
|
||||
break;
|
||||
case "img":
|
||||
$markdown = $this->convert_image($node);
|
||||
break;
|
||||
case "a":
|
||||
$markdown = $this->convert_anchor($node);
|
||||
break;
|
||||
case "#text":
|
||||
$markdown = preg_replace('~\s+~', ' ', $value);
|
||||
$markdown = preg_replace('~^#~', '\\\\#', $markdown);
|
||||
break;
|
||||
case "#comment":
|
||||
$markdown = '';
|
||||
break;
|
||||
case "div":
|
||||
$markdown = ($this->options['strip_tags']) ? $value . PHP_EOL . PHP_EOL : html_entity_decode($node->C14N());
|
||||
break;
|
||||
default:
|
||||
// If strip_tags is false (the default), preserve tags that don't have Markdown equivalents,
|
||||
// such as <span> nodes on their own. C14N() canonicalizes the node to a string.
|
||||
// See: http://www.php.net/manual/en/domnode.c14n.php
|
||||
$markdown = ($this->options['strip_tags']) ? $value : html_entity_decode($node->C14N());
|
||||
}
|
||||
|
||||
return $markdown;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert Header
|
||||
*
|
||||
* Converts h1 and h2 headers to Markdown-style headers in setext style,
|
||||
* matching the number of underscores with the length of the title.
|
||||
*
|
||||
* e.g. Header 1 Header Two
|
||||
* ======== ----------
|
||||
*
|
||||
* Returns atx headers instead if $this->options['header_style'] is "atx"
|
||||
*
|
||||
* e.g. # Header 1 ## Header Two
|
||||
*
|
||||
* @param string $level The header level, including the "h". e.g. h1
|
||||
* @param string $node The node to convert.
|
||||
* @return string The Markdown version of the header.
|
||||
*/
|
||||
private function convert_header($level, $node)
|
||||
{
|
||||
$content = $node->nodeValue;
|
||||
|
||||
if (!$this->is_child_of('blockquote', $node) && $this->options['header_style'] == "setext") {
|
||||
$length = (function_exists('mb_strlen')) ? mb_strlen($content, 'utf-8') : strlen($content);
|
||||
$underline = ($level == "h1") ? "=" : "-";
|
||||
$markdown = $content . PHP_EOL . str_repeat($underline, $length) . PHP_EOL . PHP_EOL; // setext style
|
||||
} else {
|
||||
$prefix = ($level == "h1") ? "# " : "## ";
|
||||
$markdown = $prefix . $content . PHP_EOL . PHP_EOL; // atx style
|
||||
}
|
||||
|
||||
return $markdown;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts inline styles
|
||||
* This function is used to render strong and em tags
|
||||
*
|
||||
* eg <strong>bold text</strong> becomes **bold text** or __bold text__
|
||||
*
|
||||
* @param string $tag
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
private function convert_emphasis($tag, $value)
|
||||
{
|
||||
if ($tag == 'i' || $tag == 'em') {
|
||||
$markdown = $this->options['italic_style'] . $value . $this->options['italic_style'];
|
||||
} else {
|
||||
$markdown = $this->options['bold_style'] . $value . $this->options['bold_style'];
|
||||
}
|
||||
|
||||
return $markdown;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert Image
|
||||
*
|
||||
* Converts <img /> tags to Markdown.
|
||||
*
|
||||
* e.g. <img src="/path/img.jpg" alt="alt text" title="Title" />
|
||||
* becomes ![alt text](/path/img.jpg "Title")
|
||||
*
|
||||
* @param $node
|
||||
* @return string
|
||||
*/
|
||||
private function convert_image($node)
|
||||
{
|
||||
$src = $node->getAttribute('src');
|
||||
$alt = $node->getAttribute('alt');
|
||||
$title = $node->getAttribute('title');
|
||||
|
||||
if ($title != "") {
|
||||
$markdown = '![' . $alt . '](' . $src . ' "' . $title . '")'; // No newlines added. <img> should be in a block-level element.
|
||||
} else {
|
||||
$markdown = '![' . $alt . '](' . $src . ')';
|
||||
}
|
||||
|
||||
return $markdown;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert Anchor
|
||||
*
|
||||
* Converts <a> tags to Markdown.
|
||||
*
|
||||
* e.g. <a href="http://modernnerd.net" title="Title">Modern Nerd</a>
|
||||
* becomes [Modern Nerd](http://modernnerd.net "Title")
|
||||
*
|
||||
* @param $node
|
||||
* @return string
|
||||
*/
|
||||
private function convert_anchor($node)
|
||||
{
|
||||
$href = $node->getAttribute('href');
|
||||
$title = $node->getAttribute('title');
|
||||
$text = $node->nodeValue;
|
||||
|
||||
if ($title != "") {
|
||||
$markdown = '[' . $text . '](' . $href . ' "' . $title . '")';
|
||||
} else {
|
||||
$markdown = '[' . $text . '](' . $href . ')';
|
||||
}
|
||||
|
||||
if (! $href)
|
||||
$markdown = html_entity_decode($node->C14N());
|
||||
|
||||
// Append a space if the node after this one is also an anchor
|
||||
$next_node_name = $this->get_next_node_name($node);
|
||||
|
||||
if ($next_node_name == 'a')
|
||||
$markdown = $markdown . ' ';
|
||||
|
||||
return $markdown;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert List
|
||||
*
|
||||
* Converts <ul> and <ol> lists to Markdown.
|
||||
*
|
||||
* @param $node
|
||||
* @return string
|
||||
*/
|
||||
private function convert_list($node)
|
||||
{
|
||||
// If parent is an ol, use numbers, otherwise, use dashes
|
||||
$list_type = $node->parentNode->nodeName;
|
||||
$value = $node->nodeValue;
|
||||
|
||||
if ($list_type == "ul") {
|
||||
$markdown = "- " . trim($value) . PHP_EOL;
|
||||
} else {
|
||||
$number = $this->get_position($node);
|
||||
$markdown = $number . ". " . trim($value) . PHP_EOL;
|
||||
}
|
||||
|
||||
return $markdown;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert Code
|
||||
*
|
||||
* Convert code tags by indenting blocks of code and wrapping single lines in backticks.
|
||||
*
|
||||
* @param DOMNode $node
|
||||
* @return string
|
||||
*/
|
||||
private function convert_code($node)
|
||||
{
|
||||
// Store the content of the code block in an array, one entry for each line
|
||||
|
||||
$markdown = '';
|
||||
|
||||
$code_content = html_entity_decode($node->C14N());
|
||||
$code_content = str_replace(array("<code>", "</code>"), "", $code_content);
|
||||
$code_content = str_replace(array("<pre>", "</pre>"), "", $code_content);
|
||||
|
||||
$lines = preg_split('/\r\n|\r|\n/', $code_content);
|
||||
$total = count($lines);
|
||||
|
||||
// If there's more than one line of code, prepend each line with four spaces and no backticks.
|
||||
if ($total > 1 || $node->nodeName === 'pre') {
|
||||
|
||||
// Remove the first and last line if they're empty
|
||||
$first_line = trim($lines[0]);
|
||||
$last_line = trim($lines[$total - 1]);
|
||||
$first_line = trim($first_line, "
"); //trim XML style carriage returns too
|
||||
$last_line = trim($last_line, "
");
|
||||
|
||||
if (empty($first_line))
|
||||
array_shift($lines);
|
||||
|
||||
if (empty($last_line))
|
||||
array_pop($lines);
|
||||
|
||||
$count = 1;
|
||||
foreach ($lines as $line) {
|
||||
$line = str_replace('
', '', $line);
|
||||
$markdown .= " " . $line;
|
||||
// Add newlines, except final line of the code
|
||||
if ($count != $total)
|
||||
$markdown .= PHP_EOL;
|
||||
$count++;
|
||||
}
|
||||
$markdown .= PHP_EOL;
|
||||
|
||||
} else { // There's only one line of code. It's a code span, not a block. Just wrap it with backticks.
|
||||
|
||||
$markdown .= "`" . $lines[0] . "`";
|
||||
|
||||
}
|
||||
|
||||
return $markdown;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert blockquote
|
||||
*
|
||||
* Prepend blockquotes with > chars.
|
||||
*
|
||||
* @param $node
|
||||
* @return string
|
||||
*/
|
||||
private function convert_blockquote($node)
|
||||
{
|
||||
// Contents should have already been converted to Markdown by this point,
|
||||
// so we just need to add ">" symbols to each line.
|
||||
|
||||
$markdown = '';
|
||||
|
||||
$quote_content = trim($node->nodeValue);
|
||||
|
||||
$lines = preg_split('/\r\n|\r|\n/', $quote_content);
|
||||
|
||||
$total_lines = count($lines);
|
||||
|
||||
foreach ($lines as $i => $line) {
|
||||
$markdown .= "> " . $line . PHP_EOL;
|
||||
if ($i + 1 == $total_lines)
|
||||
$markdown .= PHP_EOL;
|
||||
}
|
||||
|
||||
return $markdown;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Position
|
||||
*
|
||||
* Returns the numbered position of a node inside its parent
|
||||
*
|
||||
* @param $node
|
||||
* @return int The numbered position of the node, starting at 1.
|
||||
*/
|
||||
private function get_position($node)
|
||||
{
|
||||
// Get all of the nodes inside the parent
|
||||
$list_nodes = $node->parentNode->childNodes;
|
||||
$total_nodes = $list_nodes->length;
|
||||
|
||||
$position = 1;
|
||||
|
||||
// Loop through all nodes and find the given $node
|
||||
for ($a = 0; $a < $total_nodes; $a++) {
|
||||
$current_node = $list_nodes->item($a);
|
||||
|
||||
if ($current_node->isSameNode($node))
|
||||
$position = $a + 1;
|
||||
}
|
||||
|
||||
return $position;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Next Node Name
|
||||
*
|
||||
* Return the name of the node immediately after the passed one.
|
||||
*
|
||||
* @param $node
|
||||
* @return string|null The node name (e.g. 'h1') or null.
|
||||
*/
|
||||
private function get_next_node_name($node)
|
||||
{
|
||||
$next_node_name = null;
|
||||
|
||||
$current_position = $this->get_position($node);
|
||||
$next_node = $node->parentNode->childNodes->item($current_position);
|
||||
|
||||
if ($next_node)
|
||||
$next_node_name = $next_node->nodeName;
|
||||
|
||||
return $next_node_name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To String
|
||||
*
|
||||
* Magic method to return Markdown output when HTML_To_Markdown instance is treated as a string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->output();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Output
|
||||
*
|
||||
* Getter for the converted Markdown contents stored in $this->output
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function output()
|
||||
{
|
||||
if (!$this->output) {
|
||||
return '';
|
||||
} else {
|
||||
return $this->output;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,138 +0,0 @@
|
|||
HTML To Markdown for PHP
|
||||
========================
|
||||
|
||||
A helper class that converts HTML to [Markdown](http://daringfireball.net/projects/markdown/) for your sanity and convenience.
|
||||
|
||||
[![Build Status](https://travis-ci.org/nickcernis/html-to-markdown.png?branch=master)](https://travis-ci.org/nickcernis/html-to-markdown)
|
||||
|
||||
**Version**: 2.2.1
|
||||
**Requires**: PHP 5.3+
|
||||
**Author**: [@nickcernis](http://twitter.com/nickcernis)
|
||||
**License**: [MIT](http://www.opensource.org/licenses/mit-license.php)
|
||||
|
||||
### Why convert HTML to Markdown?
|
||||
|
||||
*"What alchemy is this?"* you mutter. *"I can see why you'd convert [Markdown to HTML](http://michelf.com/projects/php-markdown/),"* you continue, already labouring the question somewhat, *"but why go the other way?"*
|
||||
|
||||
Typically you would convert HTML to Markdown if:
|
||||
|
||||
1. You have an existing HTML document that needs to be edited by people with good taste.
|
||||
2. You want to store new content in HTML format but edit it as Markdown.
|
||||
3. You want to convert HTML email to plain text email.
|
||||
4. You know a guy who's been converting HTML to Markdown for years, and now he can speak Elvish. You'd quite like to be able to speak Elvish.
|
||||
5. You just really like Markdown.
|
||||
|
||||
### How to use it
|
||||
|
||||
Either include HTML_To_Markdown.php directly:
|
||||
|
||||
require_once( dirname( __FILE__) . '/HTML_To_Markdown.php' );
|
||||
|
||||
Or, require the library in your composer.json:
|
||||
|
||||
{
|
||||
"require": {
|
||||
"nickcernis/html-to-markdown": "dev-master"
|
||||
}
|
||||
}
|
||||
|
||||
Then `composer install` and add `require 'vendor/autoload.php';` to the top of your script.
|
||||
|
||||
Next, create a new HTML_To_Markdown instance, passing in your valid HTML code:
|
||||
|
||||
$html = "<h3>Quick, to the Batpoles!</h3>";
|
||||
$markdown = new HTML_To_Markdown($html);
|
||||
|
||||
The `$markdown` object now contains the Markdown version of your HTML. Use it like a string:
|
||||
|
||||
echo $markdown; // ==> ### Quick, to the Batpoles!
|
||||
|
||||
Or access the Markdown output directly:
|
||||
|
||||
$string = $markdown->output();
|
||||
|
||||
The included `demo` directory contains an HTML->Markdown conversion form to try out.
|
||||
|
||||
### Conversion options
|
||||
|
||||
By default, HTML To Markdown preserves HTML tags without Markdown equivalents, like `<span>` and `<div>`.
|
||||
|
||||
To strip HTML tags that don't have a Markdown equivalent while preserving the content inside them, set `strip_tags` to true, like this:
|
||||
|
||||
$html = '<span>Turnips!</span>';
|
||||
$markdown = new HTML_To_Markdown($html, array('strip_tags' => true)); // $markdown now contains "Turnips!"
|
||||
|
||||
Or more explicitly, like this:
|
||||
|
||||
$html = '<span>Turnips!</span>';
|
||||
$markdown = new HTML_To_Markdown();
|
||||
$markdown->set_option('strip_tags', true);
|
||||
$markdown->convert($html); // $markdown now contains "Turnips!"
|
||||
|
||||
Note that only the tags themselves are stripped, not the content they hold.
|
||||
|
||||
To strip tags and their content, pass a space-separated list of tags in `remove_nodes`, like this:
|
||||
|
||||
$html = '<span>Turnips!</span><div>Monkeys!</div>';
|
||||
$markdown = new HTML_To_Markdown($html, array('remove_nodes' => 'span div')); // $markdown now contains ""
|
||||
|
||||
### Style options
|
||||
|
||||
Bold and italic tags are converted using the asterisk syntax by default. Change this to the underlined syntax using the `bold_style` and `italic_style` options.
|
||||
|
||||
$html = '<em>Italic</em> and a <strong>bold</strong>';
|
||||
$markdown = new HTML_To_Markdown();
|
||||
$markdown->set_option('italic_style', '_');
|
||||
$markdown->set_option('bold_style', '__');
|
||||
$markdown->convert($html); // $markdown now contains "_Italic_ and a __bold__"
|
||||
|
||||
### Limitations
|
||||
|
||||
- Markdown Extra, MultiMarkdown and other variants aren't supported – just Markdown.
|
||||
|
||||
### Known issues
|
||||
|
||||
- Nested lists and lists containing multiple paragraphs aren't converted correctly.
|
||||
- Lists inside blockquotes aren't converted correctly.
|
||||
- Any reported [open issues here](https://github.com/nickcernis/html-to-markdown/issues?state=open).
|
||||
|
||||
[Report your issue or request a feature here.](https://github.com/nickcernis/html2markdown/issues/new) Issues with patches or failing tests are especially welcome.
|
||||
|
||||
### Style notes
|
||||
|
||||
- Setext (underlined) headers are the default for H1 and H2. If you prefer the ATX style for H1 and H2 (# Header 1 and ## Header 2), set `header_style` to 'atx' in the options array when you instantiate the object:
|
||||
|
||||
`$markdown = new HTML_To_Markdown( $html, array('header_style'=>'atx') );`
|
||||
|
||||
Headers of H3 priority and lower always use atx style.
|
||||
|
||||
- Links and images are referenced inline. Footnote references (where image src and anchor href attributes are listed in the footnotes) are not used.
|
||||
- Blockquotes aren't line wrapped – it makes the converted Markdown easier to edit.
|
||||
|
||||
### Dependencies
|
||||
|
||||
HTML To Markdown requires PHP's [xml](http://www.php.net/manual/en/xml.installation.php), [lib-xml](http://www.php.net/manual/en/libxml.installation.php), and [dom](http://www.php.net/manual/en/dom.installation.php) extensions, all of which are enabled by default on most distributions.
|
||||
|
||||
Errors such as "Fatal error: Class 'DOMDocument' not found" on distributions such as CentOS that disable PHP's xml extension can be resolved by installing php-xml.
|
||||
|
||||
### Architecture notes
|
||||
|
||||
HTML To Markdown is a single file that uses native DOM manipulation libraries (DOMDocument), not regex voodoo, to convert code.
|
||||
|
||||
### Contributors
|
||||
|
||||
Many thanks to all [contributors](https://github.com/nickcernis/html2markdown/graphs/contributors) so far. Further improvements and feature suggestions are very welcome.
|
||||
|
||||
### How it works
|
||||
|
||||
HTML To Markdown creates a DOMDocument from the supplied HTML, walks through the tree, and converts each node to a text node containing the equivalent markdown, starting from the most deeply nested node and working inwards towards the root node.
|
||||
|
||||
### To-do
|
||||
|
||||
- Support for nested lists and lists inside blockquotes.
|
||||
- Offer an option to preserve tags as HTML if they contain attributes that can't be represented with Markdown (e.g. `style`).
|
||||
|
||||
### Trying to convert Markdown to HTML?
|
||||
|
||||
Use [PHP Markdown](http://michelf.com/projects/php-markdown/) from Michel Fortin. No guarantees about the Elvish, though.
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
test:
|
||||
override:
|
||||
- phpunit --no-configuration HTML_To_MarkdownTest ./tests/HTML_To_MarkdownTest.php
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
{
|
||||
"name": "nickcernis/html-to-markdown",
|
||||
"type": "library",
|
||||
"description": "An HTML-to-markdown conversion helper for PHP",
|
||||
"keywords": ["markdown", "html"],
|
||||
"homepage": "https://github.com/nickcernis/html-to-markdown",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nick Cernis",
|
||||
"email": "nick@cern.is",
|
||||
"homepage": "http://modernnerd.net"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"classmap": [ "HTML_To_Markdown.php" ]
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"php": ">=5.3.3",
|
||||
"phpunit/phpunit": "4.*"
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/* ACL selector json backend */
|
||||
|
||||
require_once("include/acl_selectors.php");
|
||||
require_once 'include/acl_selectors.php';
|
||||
|
||||
function acl_init(App $a) {
|
||||
acl_lookup($a);
|
||||
|
|
|
@ -290,7 +290,8 @@ function admin_page_federation(App $a) {
|
|||
foreach ($platforms as $p) {
|
||||
// get a total count for the platform, the name and version of the
|
||||
// highest version and the protocol tpe
|
||||
$c = qu('SELECT COUNT(*) AS `total`, `platform`, `network`, `version` FROM `gserver`
|
||||
$c = qu('SELECT COUNT(*) AS `total`, ANY_VALUE(`platform`) AS `platform`,
|
||||
ANY_VALUE(`network`) AS `network`, MAX(`version`) AS `version` FROM `gserver`
|
||||
WHERE `platform` LIKE "%s" AND `last_contact` >= `last_failure`
|
||||
ORDER BY `version` ASC;', $p);
|
||||
$total = $total + $c[0]['total'];
|
||||
|
@ -474,9 +475,6 @@ function admin_page_summary(App $a) {
|
|||
$r = qu("SELECT COUNT(`id`) AS `count` FROM `register`");
|
||||
$pending = $r[0]['count'];
|
||||
|
||||
$r = qu("SELECT COUNT(*) AS `total` FROM `deliverq` WHERE 1");
|
||||
$deliverq = (($r) ? $r[0]['total'] : 0);
|
||||
|
||||
$r = qu("SELECT COUNT(*) AS `total` FROM `queue` WHERE 1");
|
||||
$queue = (($r) ? $r[0]['total'] : 0);
|
||||
|
||||
|
@ -485,7 +483,7 @@ function admin_page_summary(App $a) {
|
|||
|
||||
// We can do better, but this is a quick queue status
|
||||
|
||||
$queues = array('label' => t('Message queues'), 'deliverq' => $deliverq, 'queue' => $queue, 'workerq' => $workerqueue);
|
||||
$queues = array('label' => t('Message queues'), 'queue' => $queue, 'workerq' => $workerqueue);
|
||||
|
||||
|
||||
$t = get_markup_template("admin_summary.tpl");
|
||||
|
@ -655,7 +653,6 @@ function admin_page_site_post(App $a) {
|
|||
$force_ssl = ((x($_POST,'force_ssl')) ? True : False);
|
||||
$hide_help = ((x($_POST,'hide_help')) ? True : False);
|
||||
$suppress_tags = ((x($_POST,'suppress_tags')) ? True : False);
|
||||
$use_fulltext_engine = ((x($_POST,'use_fulltext_engine')) ? True : False);
|
||||
$itemcache = ((x($_POST,'itemcache')) ? notags(trim($_POST['itemcache'])) : '');
|
||||
$itemcache_duration = ((x($_POST,'itemcache_duration')) ? intval($_POST['itemcache_duration']) : 0);
|
||||
$max_comments = ((x($_POST,'max_comments')) ? intval($_POST['max_comments']) : 0);
|
||||
|
@ -670,6 +667,12 @@ function admin_page_site_post(App $a) {
|
|||
$worker_fastlane = ((x($_POST,'worker_fastlane')) ? True : False);
|
||||
$worker_frontend = ((x($_POST,'worker_frontend')) ? True : False);
|
||||
|
||||
// Has the directory url changed? If yes, then resubmit the existing profiles there
|
||||
if ($global_directory != Config::get('system', 'directory') AND ($global_directory != '')) {
|
||||
Config::set('system', 'directory', $global_directory);
|
||||
proc_run(PRIORITY_LOW, 'include/directory.php');
|
||||
}
|
||||
|
||||
if ($a->get_path() != "") {
|
||||
$diaspora_enabled = false;
|
||||
}
|
||||
|
@ -773,7 +776,6 @@ function admin_page_site_post(App $a) {
|
|||
set_config('system', 'allowed_email', $allowed_email);
|
||||
set_config('system', 'block_public', $block_public);
|
||||
set_config('system', 'publish_all', $force_publish);
|
||||
set_config('system', 'directory', $global_directory);
|
||||
set_config('system', 'thread_allow', $thread_allow);
|
||||
set_config('system', 'newuser_private', $newuser_private);
|
||||
set_config('system', 'enotify_no_content', $enotify_no_content);
|
||||
|
@ -799,7 +801,6 @@ function admin_page_site_post(App $a) {
|
|||
|
||||
set_config('system', 'force_ssl', $force_ssl);
|
||||
set_config('system', 'hide_help', $hide_help);
|
||||
set_config('system', 'use_fulltext_engine', $use_fulltext_engine);
|
||||
set_config('system', 'itemcache', $itemcache);
|
||||
set_config('system', 'itemcache_duration', $itemcache_duration);
|
||||
set_config('system', 'max_comments', $max_comments);
|
||||
|
@ -1028,7 +1029,6 @@ 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.")),
|
||||
|
||||
'$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_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_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.")),
|
||||
|
|
|
@ -75,7 +75,7 @@ function hovercard_content() {
|
|||
'tags' => $contact["keywords"],
|
||||
// 'nsfw' => intval($contact["nsfw"]),
|
||||
// 'server_url' => $contact["server_url"],
|
||||
'bd' => (($contact["birthday"] == "0000-00-00") ? "" : $contact["birthday"]),
|
||||
'bd' => (($contact["birthday"] <= '0001-01-01') ? "" : $contact["birthday"]),
|
||||
// 'generation' => $contact["generation"],
|
||||
'account_type' => account_type($contact),
|
||||
'actions' => $actions,
|
||||
|
|
|
@ -48,7 +48,7 @@ function install_post(App $a) {
|
|||
$db = new dba($dbhost, $dbuser, $dbpass, '', true);
|
||||
|
||||
if(! get_db_errno()) {
|
||||
$r = q("CREATE DATABASE '%s'",
|
||||
$r = q("CREATE DATABASE '%s' DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci",
|
||||
dbesc($dbdata)
|
||||
);
|
||||
if ($r) {
|
||||
|
|
26
mod/manifest.php
Normal file
26
mod/manifest.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
use Friendica\Core\Config;
|
||||
|
||||
function manifest_content(App $a) {
|
||||
|
||||
$tpl = get_markup_template('manifest.tpl');
|
||||
|
||||
header('Content-type: application/manifest+json');
|
||||
|
||||
$touch_icon = Config::get('system', 'touch_icon', 'images/friendica-128.png');
|
||||
if ($touch_icon == '') {
|
||||
$touch_icon = 'images/friendica-128.png';
|
||||
}
|
||||
|
||||
$o = replace_macros($tpl, array(
|
||||
'$baseurl' => App::get_baseurl(),
|
||||
'$touch_icon' => $touch_icon,
|
||||
'$title' => Config::get('config', 'sitename', 'Friendica'),
|
||||
));
|
||||
|
||||
echo $o;
|
||||
|
||||
killme();
|
||||
|
||||
}
|
||||
?>
|
|
@ -349,7 +349,7 @@ function message_content(App $a) {
|
|||
|
||||
$o .= $header;
|
||||
|
||||
$r = q("SELECT count(*) AS `total` FROM `mail`
|
||||
$r = q("SELECT count(*) AS `total` FROM `mail`, ANY_VALUE(`created`) AS `created`
|
||||
WHERE `mail`.`uid` = %d GROUP BY `parent-uri` ORDER BY `created` DESC",
|
||||
intval(local_user())
|
||||
);
|
||||
|
@ -528,10 +528,18 @@ function message_content(App $a) {
|
|||
}
|
||||
|
||||
function get_messages($user, $lstart, $lend) {
|
||||
|
||||
//TODO: rewritte with a sub-query to get the first message of each private thread with certainty
|
||||
return q("SELECT max(`mail`.`created`) AS `mailcreated`, min(`mail`.`seen`) AS `mailseen`,
|
||||
`mail`.* , `contact`.`name`, `contact`.`url`, `contact`.`thumb` , `contact`.`network`,
|
||||
count( * ) as count
|
||||
ANY_VALUE(`mail`.`id`) AS `id`, ANY_VALUE(`mail`.`uid`) AS `uid`, ANY_VALUE(`mail`.`guid`) AS `guid`,
|
||||
ANY_VALUE(`mail`.`from-name`) AS `from-name`, ANY_VALUE(`mail`.`from-photo`) AS `from-photo`,
|
||||
ANY_VALUE(`mail`.`from-url`) AS `from-url`, ANY_VALUE(`mail`.`contact-id`) AS `contact-id`,
|
||||
ANY_VALUE(`mail`.`convid`) AS `convid`, ANY_VALUE(`mail`.`title`) AS `title`, ANY_VALUE(`mail`.`body`) AS `body`,
|
||||
ANY_VALUE(`mail`.`seen`) AS `seen`, ANY_VALUE(`mail`.`reply`) AS `reply`, ANY_VALUE(`mail`.`replied`) AS `replied`,
|
||||
ANY_VALUE(`mail`.`unknown`) AS `unknown`, ANY_VALUE(`mail`.`uri`) AS `uri`,
|
||||
`mail`.`parent-uri`,
|
||||
ANY_VALUE(`mail`.`created`) AS `created`, ANY_VALUE(`contact`.`name`) AS `name`, ANY_VALUE(`contact`.`url`) AS `url`,
|
||||
ANY_VALUE(`contact`.`thumb`) AS `thumb`, ANY_VALUE(`contact`.`network`) AS `network`,
|
||||
count( * ) as `count`
|
||||
FROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id`
|
||||
WHERE `mail`.`uid` = %d GROUP BY `parent-uri` ORDER BY `mailcreated` DESC LIMIT %d , %d ",
|
||||
intval($user), intval($lstart), intval($lend)
|
||||
|
|
|
@ -581,10 +581,6 @@ function network_content(App $a, $update = 0) {
|
|||
$sql_order = "`item`.`id`";
|
||||
$order_mode = "id";
|
||||
} else {
|
||||
// Disabled until final decision what to do with this
|
||||
//if (get_config('system','use_fulltext_engine'))
|
||||
// $sql_extra = sprintf(" AND MATCH (`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode) ", dbesc(protect_sprintf($search)));
|
||||
//else
|
||||
$sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
|
||||
$sql_order = "`item`.`id`";
|
||||
$order_mode = "id";
|
||||
|
|
|
@ -292,7 +292,7 @@ function notifications_content(App $a) {
|
|||
'$item_link' => $it['link'],
|
||||
'$item_image' => $it['image'],
|
||||
'$item_url' => $it['url'],
|
||||
'$item_text' => htmlentities($it['text']),
|
||||
'$item_text' => $it['text'],
|
||||
'$item_when' => $it['when'],
|
||||
'$item_ago' => $it['ago'],
|
||||
'$item_seen' => $it['seen'],
|
||||
|
|
|
@ -1240,7 +1240,10 @@ function photos_content(App $a) {
|
|||
$order = 'DESC';
|
||||
}
|
||||
|
||||
$r = q("SELECT `resource-id`, `id`, `filename`, type, max(`scale`) AS `scale`, `desc` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
|
||||
$r = q("SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`,
|
||||
ANY_VALUE(`type`) AS `type`, max(`scale`) AS `scale`, ANY_VALUE(`desc`) as `desc`,
|
||||
ANY_VALUE(`created`) as `created`
|
||||
FROM `photo` WHERE `uid` = %d AND `album` = '%s'
|
||||
AND `scale` <= 4 $sql_extra GROUP BY `resource-id` ORDER BY `created` $order LIMIT %d , %d",
|
||||
intval($owner_uid),
|
||||
dbesc($album),
|
||||
|
@ -1840,7 +1843,9 @@ function photos_content(App $a) {
|
|||
$a->set_pager_itemspage(20);
|
||||
}
|
||||
|
||||
$r = qu("SELECT `resource-id`, `id`, `filename`, type, `album`, max(`scale`) AS `scale` FROM `photo`
|
||||
$r = qu("SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`,
|
||||
ANY_VALUE(`type`) AS `type`, ANY_VALUE(`album`) AS `album`, max(`scale`) AS `scale`,
|
||||
ANY_VALUE(`created`) AS `created` FROM `photo`
|
||||
WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
|
||||
$sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
|
||||
intval($a->data['user']['uid']),
|
||||
|
|
|
@ -199,7 +199,7 @@ function ping_init(App $a)
|
|||
$cachekey = "ping_init:".local_user();
|
||||
$ev = Cache::get($cachekey);
|
||||
if (is_null($ev)) {
|
||||
$ev = qu("SELECT count(`event`.`id`) AS total, type, start, adjust FROM `event`
|
||||
$ev = qu("SELECT type, start, adjust FROM `event`
|
||||
WHERE `event`.`uid` = %d AND `start` < '%s' AND `finish` > '%s' and `ignore` = 0
|
||||
ORDER BY `start` ASC ",
|
||||
intval(local_user()),
|
||||
|
@ -212,7 +212,7 @@ function ping_init(App $a)
|
|||
}
|
||||
|
||||
if (dbm::is_result($ev)) {
|
||||
$all_events = intval($ev[0]['total']);
|
||||
$all_events = count($ev);
|
||||
|
||||
if ($all_events) {
|
||||
$str_now = datetime_convert('UTC', $a->timezone, 'now', 'Y-m-d');
|
||||
|
|
|
@ -4,6 +4,13 @@ require_once('include/Scrape.php');
|
|||
|
||||
function probe_content(App $a) {
|
||||
|
||||
if (!local_user()) {
|
||||
http_status_exit(403,
|
||||
array("title" => t("Public access denied."),
|
||||
"description" => t("Only logged in users are permitted to perform a probing.")));
|
||||
killme();
|
||||
}
|
||||
|
||||
$o .= '<h3>Probe Diagnostic</h3>';
|
||||
|
||||
$o .= '<form action="probe" method="get">';
|
||||
|
|
|
@ -210,7 +210,7 @@ function profile_content(App $a, $update = 0) {
|
|||
|
||||
if ($update) {
|
||||
|
||||
$r = q("SELECT distinct(parent) AS `item_id`, `item`.`network` AS `item_network`
|
||||
$r = q("SELECT distinct(parent) AS `item_id`, `item`.`network` AS `item_network`, `item`.`created`
|
||||
FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND
|
||||
|
|
|
@ -193,7 +193,7 @@ function profiles_post(App $a) {
|
|||
return;
|
||||
}
|
||||
|
||||
$dob = $_POST['dob'] ? escape_tags(trim($_POST['dob'])) : '0000-00-00'; // FIXME: Needs to be validated?
|
||||
$dob = $_POST['dob'] ? escape_tags(trim($_POST['dob'])) : '0001-01-01'; // FIXME: Needs to be validated?
|
||||
|
||||
$y = substr($dob, 0, 4);
|
||||
if ((! ctype_digit($y)) || ($y < 1900)) {
|
||||
|
@ -201,15 +201,15 @@ function profiles_post(App $a) {
|
|||
} else {
|
||||
$ignore_year = false;
|
||||
}
|
||||
if ($dob != '0000-00-00') {
|
||||
if (strpos($dob, '0000-') === 0) {
|
||||
if (!in_array($dob, array('0000-00-00', '0001-01-01'))) {
|
||||
if (strpos($dob, '0000-') === 0 || strpos($dob, '0001-') === 0) {
|
||||
$ignore_year = true;
|
||||
$dob = substr($dob, 5);
|
||||
}
|
||||
$dob = datetime_convert('UTC', 'UTC', (($ignore_year) ? '1900-' . $dob : $dob), (($ignore_year) ? 'm-d' : 'Y-m-d'));
|
||||
|
||||
if ($ignore_year) {
|
||||
$dob = '0000-' . $dob;
|
||||
$dob = '0001-' . $dob;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -115,16 +115,20 @@ function salmon_post(App $a) {
|
|||
|
||||
// We should have everything we need now. Let's see if it verifies.
|
||||
|
||||
$verify = rsa_verify($compliant_format,$signature,$pubkey);
|
||||
// Try GNU Social format
|
||||
$verify = rsa_verify($signed_data, $signature, $pubkey);
|
||||
$mode = 1;
|
||||
|
||||
if (! $verify) {
|
||||
logger('mod-salmon: message did not verify using protocol. Trying padding hack.');
|
||||
$verify = rsa_verify($signed_data,$signature,$pubkey);
|
||||
logger('mod-salmon: message did not verify using protocol. Trying compliant format.');
|
||||
$verify = rsa_verify($compliant_format, $signature, $pubkey);
|
||||
$mode = 2;
|
||||
}
|
||||
|
||||
if (! $verify) {
|
||||
logger('mod-salmon: message did not verify using padding. Trying old statusnet hack.');
|
||||
logger('mod-salmon: message did not verify using padding. Trying old statusnet format.');
|
||||
$verify = rsa_verify($stnet_signed_data, $signature, $pubkey);
|
||||
$mode = 3;
|
||||
}
|
||||
|
||||
if (! $verify) {
|
||||
|
@ -132,7 +136,7 @@ function salmon_post(App $a) {
|
|||
http_status_exit(400);
|
||||
}
|
||||
|
||||
logger('mod-salmon: Message verified.');
|
||||
logger('mod-salmon: Message verified with mode '.$mode);
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -203,18 +203,13 @@ function search_content(App $a) {
|
|||
} else {
|
||||
logger("Start fulltext search for '".$search."'", LOGGER_DEBUG);
|
||||
|
||||
// Disabled until finally is decided how to proceed with this
|
||||
//if (get_config('system','use_fulltext_engine')) {
|
||||
// $sql_extra = sprintf(" AND MATCH (`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode) ", dbesc(protect_sprintf($search)));
|
||||
//} else {
|
||||
$sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
|
||||
//}
|
||||
|
||||
$r = q("SELECT %s
|
||||
FROM `item` %s
|
||||
WHERE %s AND (`item`.`uid` = 0 OR (`item`.`uid` = %s AND NOT `item`.`global`))
|
||||
$sql_extra
|
||||
GROUP BY `item`.`uri` ORDER BY `item`.`id` DESC LIMIT %d , %d",
|
||||
GROUP BY `item`.`uri`, `item`.`id` ORDER BY `item`.`id` DESC LIMIT %d , %d",
|
||||
item_fieldlists(), item_joins(), item_condition(),
|
||||
intval(local_user()),
|
||||
intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||
|
|
|
@ -1168,13 +1168,13 @@ function settings_content(App $a) {
|
|||
$profile_in_dir = '<input type="hidden" name="profile_in_directory" value="1" />';
|
||||
} else {
|
||||
$profile_in_dir = replace_macros($opt_tpl, array(
|
||||
'$field' => array('profile_in_directory', t('Publish your default profile in your local site directory?'), $profile['publish'], '', array(t('No'),t('Yes'))),
|
||||
'$field' => array('profile_in_directory', t('Publish your default profile in your local site directory?'), $profile['publish'], t("Your profile may be visible in public."), array(t('No'), t('Yes')))
|
||||
));
|
||||
}
|
||||
|
||||
if (strlen(get_config('system','directory'))) {
|
||||
$profile_in_net_dir = replace_macros($opt_tpl, array(
|
||||
'$field' => array('profile_in_netdirectory', t('Publish your default profile in the global social directory?'), $profile['net-publish'], '', array(t('No'),t('Yes'))),
|
||||
'$field' => array('profile_in_netdirectory', t('Publish your default profile in the global social directory?'), $profile['net-publish'], '', array(t('No'), t('Yes')))
|
||||
));
|
||||
} else {
|
||||
$profile_in_net_dir = '';
|
||||
|
|
|
@ -356,7 +356,9 @@ function videos_content(App $a) {
|
|||
$a->set_pager_itemspage(20);
|
||||
}
|
||||
|
||||
$r = q("SELECT hash, `id`, `filename`, filetype FROM `attach`
|
||||
$r = q("SELECT hash, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`created`) AS `created`,
|
||||
ANY_VALUE(`filename`) AS `filename`, ANY_VALUE(`filetype`) as `filetype`
|
||||
FROM `attach`
|
||||
WHERE `uid` = %d AND filetype LIKE '%%video%%'
|
||||
$sql_extra GROUP BY hash ORDER BY `created` DESC LIMIT %d , %d",
|
||||
intval($a->data['user']['uid']),
|
||||
|
|
|
@ -3,6 +3,13 @@ require_once("include/Probe.php");
|
|||
|
||||
function webfinger_content(App $a) {
|
||||
|
||||
if (!local_user()) {
|
||||
http_status_exit(403,
|
||||
array("title" => t("Public access denied."),
|
||||
"description" => t("Only logged in users are permitted to perform a probing.")));
|
||||
killme();
|
||||
}
|
||||
|
||||
$o .= '<h3>Webfinger Diagnostic</h3>';
|
||||
|
||||
$o .= '<form action="webfinger" method="get">';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
define('UPDATE_VERSION' , 1216);
|
||||
define('UPDATE_VERSION' , 1219);
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -6,8 +6,8 @@ Albert
|
|||
Alberto Díaz Tormo
|
||||
Alex
|
||||
Alexander Kampmann
|
||||
Alexandre Alapetite
|
||||
AlfredSK
|
||||
Aliaksei Sakalou
|
||||
Andi Stadler
|
||||
Andreas H.
|
||||
Andrej Stieben
|
||||
|
@ -130,11 +130,12 @@ Paolo Wave
|
|||
Pavel Morozov
|
||||
Perig Gouanvic
|
||||
peturisfeld
|
||||
Pierre Rudloff
|
||||
Piotr Blonkowski
|
||||
pokerazor
|
||||
Rabuzarus
|
||||
Radek
|
||||
Rafael
|
||||
Rafael Garau
|
||||
Rainulf Pineda
|
||||
Ralph
|
||||
rcmaniac
|
||||
|
@ -153,6 +154,7 @@ Seth
|
|||
Silke Meyer
|
||||
Simon L'nu
|
||||
Simó Albert i Beltran
|
||||
soko1
|
||||
Stanislav N.
|
||||
StefOfficiel
|
||||
Sveinn í Felli
|
||||
|
|
|
@ -100,7 +100,7 @@ sudo ln -fs /vagrant /var/www
|
|||
cp /vagrant/util/htconfig.vagrant.php /vagrant/.htconfig.php
|
||||
|
||||
# create the friendica database
|
||||
echo "create database friendica" | mysql -u root -proot
|
||||
echo "create database friendica DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci" | mysql -u root -proot
|
||||
# import test database
|
||||
$MYSQL -uroot -proot friendica < /vagrant/friendica_test_data.sql
|
||||
|
||||
|
|
17
vendor/bin/html-to-markdown
vendored
Normal file
17
vendor/bin/html-to-markdown
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
dir=$(d=${0%[/\\]*}; cd "$d"; cd "../league/html-to-markdown/bin" && pwd)
|
||||
|
||||
# See if we are running in Cygwin by checking for cygpath program
|
||||
if command -v 'cygpath' >/dev/null 2>&1; then
|
||||
# Cygwin paths start with /cygdrive/ which will break windows PHP,
|
||||
# so we need to translate the dir path to windows format. However
|
||||
# we could be using cygwin PHP which does not require this, so we
|
||||
# test if the path to PHP starts with /cygdrive/ rather than /usr/bin
|
||||
if [[ $(which php) == /cygdrive/* ]]; then
|
||||
dir=$(cygpath -m "$dir");
|
||||
fi
|
||||
fi
|
||||
|
||||
dir=$(echo $dir | sed 's/ /\ /g')
|
||||
"${dir}/html-to-markdown" "$@"
|
4
vendor/bin/html-to-markdown.bat
vendored
Normal file
4
vendor/bin/html-to-markdown.bat
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
@ECHO OFF
|
||||
setlocal DISABLEDELAYEDEXPANSION
|
||||
SET BIN_TARGET=%~dp0/../league/html-to-markdown/bin/html-to-markdown
|
||||
php "%BIN_TARGET%" %*
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue