(.*?)<\/a>/is';
- $Text = preg_replace($pattern, '#$2', $Text);
- }
-*/
call_hooks('bbcode',$Text);
- $a->save_timestamp($stamp1, "parser");
-
return trim($Text);
}
?>
diff --git a/include/dbstructure.php b/include/dbstructure.php
index adb826c8b..f131abe64 100644
--- a/include/dbstructure.php
+++ b/include/dbstructure.php
@@ -106,29 +106,17 @@ function table_structure($table) {
}
function print_structure($database) {
+ echo "-- ------------------------------------------\n";
+ echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
+ echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
+ echo "-- ------------------------------------------\n\n\n";
foreach ($database AS $name => $structure) {
- echo "\t".'$database["'.$name."\"] = array(\n";
+ echo "--\n";
+ echo "-- TABLE $name\n";
+ echo "--\n";
+ db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
- echo "\t\t\t".'"fields" => array('."\n";
- foreach ($structure["fields"] AS $fieldname => $parameters) {
- echo "\t\t\t\t\t".'"'.$fieldname.'" => array(';
-
- $data = "";
- foreach ($parameters AS $name => $value) {
- if ($data != "")
- $data .= ", ";
- $data .= '"'.$name.'" => "'.$value.'"';
- }
-
- echo $data."),\n";
- }
- echo "\t\t\t\t\t),\n";
- echo "\t\t\t".'"indexes" => array('."\n";
- foreach ($structure["indexes"] AS $indexname => $fieldnames) {
- echo "\t\t\t\t\t".'"'.$indexname.'" => array("'.implode($fieldnames, '","').'"'."),\n";
- }
- echo "\t\t\t\t\t)\n";
- echo "\t\t\t);\n";
+ echo "\n";
}
}
@@ -231,9 +219,13 @@ function db_field_command($parameters, $create = true) {
if ($parameters["not null"])
$fieldstruct .= " NOT NULL";
- if (isset($parameters["default"]))
- $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
-
+ if (isset($parameters["default"])){
+ if (strpos(strtolower($parameters["type"]),"int")!==false) {
+ $fieldstruct .= " DEFAULT ".$parameters["default"];
+ } else {
+ $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
+ }
+ }
if ($parameters["extra"] != "")
$fieldstruct .= " ".$parameters["extra"];
@@ -243,20 +235,28 @@ function db_field_command($parameters, $create = true) {
return($fieldstruct);
}
-function db_create_table($name, $fields, $verbose, $action) {
+function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
global $a, $db;
$r = true;
$sql = "";
+ $sql_rows = array();
foreach($fields AS $fieldname => $field) {
- if ($sql != "")
- $sql .= ",\n";
-
- $sql .= "`".dbesc($fieldname)."` ".db_field_command($field);
+ $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
}
- $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n", dbesc($name)).$sql."\n) DEFAULT CHARSET=utf8";
+ if (!is_null($indexes)) {
+
+ foreach ($indexes AS $indexname => $fieldnames) {
+ $sql_index = db_create_index($indexname, $fieldnames, "");
+ if (!is_null($sql_index)) $sql_rows[] = $sql_index;
+ }
+ }
+
+ $sql = implode(",\n\t", $sql_rows);
+
+ $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT CHARSET=utf8";
if ($verbose)
echo $sql.";\n";
@@ -282,7 +282,7 @@ function db_drop_index($indexname) {
return($sql);
}
-function db_create_index($indexname, $fieldnames) {
+function db_create_index($indexname, $fieldnames, $method="ADD") {
if ($indexname == "PRIMARY")
return;
@@ -298,7 +298,13 @@ function db_create_index($indexname, $fieldnames) {
$names .= "`".dbesc($fieldname)."`";
}
- $sql = sprintf("ADD INDEX `%s` (%s)", dbesc($indexname), $names);
+ $method = strtoupper(trim($method));
+ if ($method!="" && $method!="ADD") {
+ throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
+ killme();
+ }
+
+ $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
return($sql);
}
@@ -626,6 +632,7 @@ function db_definition() {
"keywords" => array("type" => "text", "not null" => "1"),
"gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
"network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
+ "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
),
"indexes" => array(
"PRIMARY" => array("id"),
@@ -775,6 +782,9 @@ function db_definition() {
"last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
"mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
"network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
+ "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
+ "rendered-html" => array("type" => "mediumtext", "not null" => "1"),
+ "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
),
"indexes" => array(
"PRIMARY" => array("id"),
@@ -1187,6 +1197,10 @@ function db_definition() {
"type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
"term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
+ "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
+ "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
"aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
),
@@ -1195,8 +1209,9 @@ function db_definition() {
"oid_otype_type_term" => array("oid","otype","type","term"),
"uid_term_tid" => array("uid","term","tid"),
"type_term" => array("type","term"),
- "uid_otype_type_term_tid" => array("uid","otype","type","term","tid"),
+ "uid_otype_type_term_global_created" => array("uid","otype","type","term","global","created"),
"otype_type_term_tid" => array("otype","type","term","tid"),
+ "guid" => array("guid"),
)
);
$database["thread"] = array(
@@ -1348,7 +1363,29 @@ function dbstructure_run(&$argv, &$argc) {
unset($db_host, $db_user, $db_pass, $db_data);
}
- update_structure(true, true);
+ if ($argc==2) {
+ switch ($argv[1]) {
+ case "update":
+ update_structure(true, true);
+ return;
+ case "dumpsql":
+ print_structure(db_definition());
+ return;
+ }
+ }
+
+
+ // print help
+ echo $argv[0]." \n";
+ echo "\n";
+ echo "commands:\n";
+ echo "update update database schema\n";
+ echo "dumpsql dump database schema\n";
+ return;
+
+
+
+
}
if (array_search(__file__,get_included_files())===0){
diff --git a/include/diaspora.php b/include/diaspora.php
index affd59d48..dd877112b 100755
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -6,6 +6,7 @@ require_once('include/bb2diaspora.php');
require_once('include/contact_selectors.php');
require_once('include/queue_fn.php');
require_once('include/lock.php');
+require_once('include/threads.php');
function diaspora_dispatch_public($msg) {
@@ -589,7 +590,7 @@ function diaspora_request($importer,$xml) {
intval($importer['uid'])
);
- if((count($r)) && (! $r[0]['hide-friends']) && (! $contact['hidden'])) {
+ if((count($r)) && (!$r[0]['hide-friends']) && (!$contact['hidden']) && intval(get_pconfig($importer['uid'],'system','post_newfriend'))) {
require_once('include/items.php');
$self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
@@ -833,31 +834,6 @@ function diaspora_post($importer,$xml,$msg) {
$str_tags = '';
- $tags = get_tags($body);
-
- if(count($tags)) {
- foreach($tags as $tag) {
- if(strpos($tag,'#') === 0) {
- if(strpos($tag,'[url='))
- continue;
-
- // don't link tags that are already embedded in links
-
- if(preg_match('/\[(.*?)' . preg_quote($tag,'/') . '(.*?)\]/',$body))
- continue;
- if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag,'/') . '(.*?)\)/',$body))
- continue;
-
- $basetag = str_replace('_',' ',substr($tag,1));
- $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
- if(strlen($str_tags))
- $str_tags .= ',';
- $str_tags .= '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
- continue;
- }
- }
- }
-
$cnt = preg_match_all('/@\[url=(.*?)\[\/url\]/ism',$body,$matches,PREG_SET_ORDER);
if($cnt) {
foreach($matches as $mtch) {
@@ -895,19 +871,92 @@ function diaspora_post($importer,$xml,$msg) {
$datarray['visible'] = ((strlen($body)) ? 1 : 0);
+ DiasporaFetchGuid($datarray);
$message_id = item_store($datarray);
- //if($message_id) {
- // q("update item set plink = '%s' where id = %d",
- // dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id),
- // intval($message_id)
- // );
- //}
-
return;
}
+function DiasporaFetchGuid($item) {
+ preg_replace_callback("&\[url=/posts/([^\[\]]*)\](.*)\[\/url\]&Usi",
+ function ($match) use ($item){
+ return(DiasporaFetchGuidSub($match, $item));
+ },$item["body"]);
+}
+
+function DiasporaFetchGuidSub($match, $item) {
+ $a = get_app();
+
+ $author = parse_url($item["author-link"]);
+ $authorserver = $author["scheme"]."://".$author["host"];
+
+ $owner = parse_url($item["owner-link"]);
+ $ownerserver = $owner["scheme"]."://".$owner["host"];
+
+ if (!diaspora_store_by_guid($match[1], $authorserver))
+ diaspora_store_by_guid($match[1], $ownerserver);
+}
+
+function diaspora_store_by_guid($guid, $server) {
+ require_once("include/Contact.php");
+
+ logger("fetching item ".$guid." from ".$server, LOGGER_DEBUG);
+
+ $item = diaspora_fetch_message($guid, $server);
+
+ if (!$item)
+ return false;
+
+ $body = $item["body"];
+ $str_tags = $item["tag"];
+ $app = $item["app"];
+ $created = $item["created"];
+ $author = $item["author"];
+ $guid = $item["guid"];
+ $private = $item["private"];
+
+ $message_id = $author.':'.$guid;
+ $r = q("SELECT `id` FROM `item` WHERE `uid` = 0 AND `uri` = '%s' AND `guid` = '%s' LIMIT 1",
+ dbesc($message_id),
+ dbesc($guid)
+ );
+ if(count($r))
+ return $r[0]["id"];
+
+ $person = find_diaspora_person_by_handle($author);
+
+ $datarray = array();
+ $datarray['uid'] = 0;
+ $datarray['contact-id'] = get_contact($person['url'], 0);
+ $datarray['wall'] = 0;
+ $datarray['network'] = NETWORK_DIASPORA;
+ $datarray['guid'] = $guid;
+ $datarray['uri'] = $datarray['parent-uri'] = $message_id;
+ $datarray['changed'] = $datarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created);
+ $datarray['private'] = $private;
+ $datarray['parent'] = 0;
+ $datarray['plink'] = 'https://'.substr($author,strpos($author,'@')+1).'/posts/'.$guid;
+ $datarray['author-name'] = $person['name'];
+ $datarray['author-link'] = $person['url'];
+ $datarray['author-avatar'] = ((x($person,'thumb')) ? $person['thumb'] : $person['photo']);
+ $datarray['owner-name'] = $datarray['author-name'];
+ $datarray['owner-link'] = $datarray['author-link'];
+ $datarray['owner-avatar'] = $datarray['author-avatar'];
+ $datarray['body'] = $body;
+ $datarray['tag'] = $str_tags;
+ $datarray['app'] = $app;
+ $datarray['visible'] = ((strlen($body)) ? 1 : 0);
+
+ DiasporaFetchGuid($datarray);
+ $message_id = item_store($datarray);
+
+ // To-Do:
+ // Looking if there is some subscribe mechanism in Diaspora to get all comments for this post
+
+ return $message_id;
+}
+
function diaspora_fetch_message($guid, $server, $level = 0) {
if ($level > 5)
@@ -981,34 +1030,8 @@ function diaspora_fetch_message($guid, $server, $level = 0) {
return false;
$item["tag"] = '';
-
- $tags = get_tags($body);
-
- if(count($tags)) {
- foreach($tags as $tag) {
- if(strpos($tag,'#') === 0) {
- if(strpos($tag,'[url='))
- continue;
-
- // don't link tags that are already embedded in links
-
- if(preg_match('/\[(.*?)' . preg_quote($tag,'/') . '(.*?)\]/',$body))
- continue;
- if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag,'/') . '(.*?)\)/',$body))
- continue;
-
-
- $basetag = str_replace('_',' ',substr($tag,1));
- $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
- if(strlen($item["tag"]))
- $item["tag"] .= ',';
- $item["tag"] .= '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
- continue;
- }
- }
- }
-
$item["body"] = $body;
+
return $item;
}
@@ -1102,7 +1125,8 @@ function diaspora_reshare($importer,$xml,$msg) {
$orig_created = $item["created"];
$orig_author = $item["author"];
$orig_guid = $item["guid"];
- //$create_original_post = ($body != "");
+ $create_original_post = ($body != "");
+ $orig_url = $a->get_baseurl()."/display/".$orig_guid;
}
}
@@ -1144,6 +1168,8 @@ function diaspora_reshare($importer,$xml,$msg) {
$prefix = "[share author='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$person['name']).
"' profile='".$person['url'].
"' avatar='".((x($person,'thumb')) ? $person['thumb'] : $person['photo']).
+ "' guid='".$orig_guid.
+ "' posted='".$orig_created.
"' link='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$orig_url)."']";
$datarray['author-name'] = $contact['name'];
$datarray['author-link'] = $contact['url'];
@@ -1164,12 +1190,13 @@ function diaspora_reshare($importer,$xml,$msg) {
$datarray['visible'] = ((strlen($body)) ? 1 : 0);
// Store the original item of a reshare
- // Deactivated by now. Items without a matching contact can't be shown via "mod/display.php" by now.
if ($create_original_post) {
+ require_once("include/Contact.php");
+
$datarray2 = $datarray;
$datarray2['uid'] = 0;
- $datarray2['contact-id'] = 0;
+ $datarray2['contact-id'] = get_contact($person['url'], 0);
$datarray2['guid'] = $orig_guid;
$datarray2['uri'] = $datarray2['parent-uri'] = $orig_author.':'.$orig_guid;
$datarray2['changed'] = $datarray2['created'] = $datarray2['edited'] = datetime_convert('UTC','UTC',$orig_created);
@@ -1183,11 +1210,13 @@ function diaspora_reshare($importer,$xml,$msg) {
$datarray2['owner-avatar'] = $datarray2['author-avatar'];
$datarray2['body'] = $body;
+ DiasporaFetchGuid($datarray2);
$message_id = item_store($datarray2);
logger("Store original item ".$orig_guid." under message id ".$message_id);
}
+ DiasporaFetchGuid($datarray);
$message_id = item_store($datarray);
return;
@@ -1280,6 +1309,7 @@ function diaspora_asphoto($importer,$xml,$msg) {
$datarray['app'] = 'Diaspora/Cubbi.es';
+ DiasporaFetchGuid($datarray);
$message_id = item_store($datarray);
//if($message_id) {
@@ -1403,34 +1433,6 @@ function diaspora_comment($importer,$xml,$msg) {
$datarray = array();
- $str_tags = '';
-
- $tags = get_tags($body);
-
- if(count($tags)) {
- foreach($tags as $tag) {
- if(strpos($tag,'#') === 0) {
- if(strpos($tag,'[url='))
- continue;
-
- // don't link tags that are already embedded in links
-
- if(preg_match('/\[(.*?)' . preg_quote($tag,'/') . '(.*?)\]/',$body))
- continue;
- if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag,'/') . '(.*?)\)/',$body))
- continue;
-
-
- $basetag = str_replace('_',' ',substr($tag,1));
- $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
- if(strlen($str_tags))
- $str_tags .= ',';
- $str_tags .= '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
- continue;
- }
- }
- }
-
$datarray['uid'] = $importer['uid'];
$datarray['contact-id'] = $contact['id'];
$datarray['type'] = 'remote-comment';
@@ -1454,12 +1456,12 @@ function diaspora_comment($importer,$xml,$msg) {
$datarray['author-link'] = $person['url'];
$datarray['author-avatar'] = ((x($person,'thumb')) ? $person['thumb'] : $person['photo']);
$datarray['body'] = $body;
- $datarray['tag'] = $str_tags;
// We can't be certain what the original app is if the message is relayed.
if(($parent_item['origin']) && (! $parent_author_signature))
$datarray['app'] = 'Diaspora';
+ DiasporaFetchGuid($datarray);
$message_id = item_store($datarray);
//if($message_id) {
@@ -1854,11 +1856,12 @@ function diaspora_photo($importer,$xml,$msg,$attempt=1) {
array($remote_photo_name, 'scaled_full_' . $remote_photo_name));
if(strpos($parent_item['body'],$link_text) === false) {
- $r = q("update item set `body` = '%s', `visible` = 1 where `id` = %d and `uid` = %d",
+ $r = q("UPDATE `item` SET `body` = '%s', `visible` = 1 WHERE `id` = %d AND `uid` = %d",
dbesc($link_text . $parent_item['body']),
intval($parent_item['id']),
intval($parent_item['uid'])
);
+ update_thread($parent_item['id']);
}
return;
@@ -1933,7 +1936,7 @@ function diaspora_like($importer,$xml,$msg) {
if($positive === 'false') {
logger('diaspora_like: received a like with positive set to "false"');
logger('diaspora_like: unlike received with no corresponding like...ignoring');
- return;
+ return;
}
@@ -1949,26 +1952,28 @@ function diaspora_like($importer,$xml,$msg) {
who sent the salmon
*/
- $signed_data = $guid . ';' . $target_type . ';' . $parent_guid . ';' . $positive . ';' . $diaspora_handle;
+ // Diaspora has changed the way they are signing the likes.
+ // Just to make sure that we don't miss any likes we will check the old and the current way.
+ $old_signed_data = $guid . ';' . $target_type . ';' . $parent_guid . ';' . $positive . ';' . $diaspora_handle;
+
+ $signed_data = $positive . ';' . $guid . ';' . $target_type . ';' . $parent_guid . ';' . $diaspora_handle;
+
$key = $msg['key'];
- if($parent_author_signature) {
+ if ($parent_author_signature) {
// If a parent_author_signature exists, then we've received the like
// relayed from the top-level post owner. There's no need to check the
// author_signature if the parent_author_signature is valid
$parent_author_signature = base64_decode($parent_author_signature);
- if(! rsa_verify($signed_data,$parent_author_signature,$key,'sha256')) {
- if (intval(get_config('system','ignore_diaspora_like_signature')))
- logger('diaspora_like: top-level owner verification failed. Proceeding anyway.');
- else {
- logger('diaspora_like: top-level owner verification failed.');
- return;
- }
+ if (!rsa_verify($signed_data,$parent_author_signature,$key,'sha256') AND
+ !rsa_verify($old_signed_data,$parent_author_signature,$key,'sha256')) {
+
+ logger('diaspora_like: top-level owner verification failed.');
+ return;
}
- }
- else {
+ } else {
// If there's no parent_author_signature, then we've received the like
// from the like creator. In that case, the person is "like"ing
// our post, so he/she must be a contact of ours and his/her public key
@@ -1976,13 +1981,11 @@ function diaspora_like($importer,$xml,$msg) {
$author_signature = base64_decode($author_signature);
- if(! rsa_verify($signed_data,$author_signature,$key,'sha256')) {
- if (intval(get_config('system','ignore_diaspora_like_signature')))
- logger('diaspora_like: like creator verification failed. Proceeding anyway');
- else {
- logger('diaspora_like: like creator verification failed.');
- return;
- }
+ if (!rsa_verify($signed_data,$author_signature,$key,'sha256') AND
+ !rsa_verify($old_signed_data,$author_signature,$key,'sha256')) {
+
+ logger('diaspora_like: like creator verification failed.');
+ return;
}
}
@@ -2319,7 +2322,7 @@ function diaspora_profile($importer,$xml,$msg) {
if (unxmlify($xml->searchable) == "true") {
require_once('include/socgraph.php');
poco_check($contact['url'], $name, NETWORK_DIASPORA, $images[0], $about, $location, $gender, $keywords, "",
- datetime_convert(), $contact['id'], $importer['uid']);
+ datetime_convert(), 2, $contact['id'], $importer['uid']);
}
$profileurl = "";
@@ -2509,6 +2512,26 @@ function diaspora_is_reshare($body) {
if ($body == $attributes)
return(false);
+ $guid = "";
+ preg_match("/guid='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $guid = $matches[1];
+
+ preg_match('/guid="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $guid = $matches[1];
+
+ if ($guid != "") {
+ $r = q("SELECT `contact-id` FROM `item` WHERE `guid` = '%s' AND `network` IN ('%s', '%s') LIMIT 1",
+ dbesc($guid), NETWORK_DFRN, NETWORK_DIASPORA);
+ if ($r) {
+ $ret= array();
+ $ret["root_handle"] = diaspora_handle_from_contact($r[0]["contact-id"]);
+ $ret["root_guid"] = $guid;
+ return($ret);
+ }
+ }
+
$profile = "";
preg_match("/profile='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
diff --git a/include/enotify.php b/include/enotify.php
index 99bc0fd32..4327e75b8 100644
--- a/include/enotify.php
+++ b/include/enotify.php
@@ -23,12 +23,15 @@ function notification($params) {
$site_admin = sprintf( t('%s Administrator'), $sitename);
$nickname = "";
- $sender_name = $product;
+ $sender_name = $sitename;
$hostname = $a->get_hostname();
if(strpos($hostname,':'))
$hostname = substr($hostname,0,strpos($hostname,':'));
-
- $sender_email = t('noreply') . '@' . $hostname;
+
+ $sender_email = $a->config['sender_email'];
+ if (empty($sender_email)) {
+ $sender_email = t('noreply') . '@' . $hostname;
+ }
$user = q("SELECT `nickname` FROM `user` WHERE `uid` = %d", intval($params['uid']));
if ($user)
diff --git a/include/gprobe.php b/include/gprobe.php
index 52c5483c8..03cdbd072 100644
--- a/include/gprobe.php
+++ b/include/gprobe.php
@@ -41,7 +41,23 @@ function gprobe_run(&$argv, &$argc){
if(! count($r)) {
+ // Is it a DDoS attempt?
+ $urlparts = parse_url($url);
+
+ $result = Cache::get("gprobe:".$urlparts["host"]);
+ if (!is_null($result)) {
+ $result = unserialize($result);
+ if ($result["network"] == NETWORK_FEED) {
+ logger("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), LOGGER_DEBUG);
+ return;
+ }
+ }
+
$arr = probe_url($url);
+
+ if (is_null($result))
+ Cache::set("gprobe:".$urlparts["host"],serialize($arr));
+
if(count($arr) && x($arr,'network') && $arr['network'] === NETWORK_DFRN) {
q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`)
values ( '%s', '%s', '%s', '%s') ",
diff --git a/include/html2bbcode.php b/include/html2bbcode.php
index 650bbdcae..d2699460e 100644
--- a/include/html2bbcode.php
+++ b/include/html2bbcode.php
@@ -88,9 +88,6 @@ function deletenode(&$doc, $node)
function html2bbcode($message)
{
- //$file = tempnam("/tmp/", "html");
- //file_put_contents($file, $message);
-
$message = str_replace("\r", "", $message);
$message = str_replace(array(
@@ -207,12 +204,19 @@ function html2bbcode($message)
//node2bbcode($doc, 'tr', array(), "[tr]", "[/tr]");
//node2bbcode($doc, 'td', array(), "[td]", "[/td]");
- node2bbcode($doc, 'h1', array(), "\n\n[size=xx-large][b]", "[/b][/size]\n");
- node2bbcode($doc, 'h2', array(), "\n\n[size=x-large][b]", "[/b][/size]\n");
- node2bbcode($doc, 'h3', array(), "\n\n[size=large][b]", "[/b][/size]\n");
- node2bbcode($doc, 'h4', array(), "\n\n[size=medium][b]", "[/b][/size]\n");
- node2bbcode($doc, 'h5', array(), "\n\n[size=small][b]", "[/b][/size]\n");
- node2bbcode($doc, 'h6', array(), "\n\n[size=x-small][b]", "[/b][/size]\n");
+ //node2bbcode($doc, 'h1', array(), "\n\n[size=xx-large][b]", "[/b][/size]\n");
+ //node2bbcode($doc, 'h2', array(), "\n\n[size=x-large][b]", "[/b][/size]\n");
+ //node2bbcode($doc, 'h3', array(), "\n\n[size=large][b]", "[/b][/size]\n");
+ //node2bbcode($doc, 'h4', array(), "\n\n[size=medium][b]", "[/b][/size]\n");
+ //node2bbcode($doc, 'h5', array(), "\n\n[size=small][b]", "[/b][/size]\n");
+ //node2bbcode($doc, 'h6', array(), "\n\n[size=x-small][b]", "[/b][/size]\n");
+
+ node2bbcode($doc, 'h1', array(), "\n\n[h1]", "[/h1]\n");
+ node2bbcode($doc, 'h2', array(), "\n\n[h2]", "[/h2]\n");
+ node2bbcode($doc, 'h3', array(), "\n\n[h3]", "[/h3]\n");
+ node2bbcode($doc, 'h4', array(), "\n\n[h4]", "[/h4]\n");
+ node2bbcode($doc, 'h5', array(), "\n\n[h5]", "[/h5]\n");
+ node2bbcode($doc, 'h6', array(), "\n\n[h6]", "[/h6]\n");
node2bbcode($doc, 'a', array('href'=>'/mailto:(.+)/'), '[mail=$1]', '[/mail]');
node2bbcode($doc, 'a', array('href'=>'/(.+)/'), '[url=$1]', '[/url]');
diff --git a/include/html2plain.php b/include/html2plain.php
index f09087e0b..1d5910d83 100644
--- a/include/html2plain.php
+++ b/include/html2plain.php
@@ -113,12 +113,6 @@ function html2plain($html, $wraplength = 75, $compact = false)
$message = str_replace("\r", "", $html);
- // replace all hashtag addresses
-/* if (get_config("system", "remove_hashtags_on_export")) {
- $pattern = '/#(.*?)<\/a>/is';
- $message = preg_replace($pattern, '#$2', $message);
- }
-*/
$doc = new DOMDocument();
$doc->preserveWhiteSpace = false;
diff --git a/include/items.php b/include/items.php
index 344b06ec8..0b8bf8fea 100644
--- a/include/items.php
+++ b/include/items.php
@@ -1210,8 +1210,8 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
$arr['attach'] = ((x($arr,'attach')) ? notags(trim($arr['attach'])) : '');
$arr['app'] = ((x($arr,'app')) ? notags(trim($arr['app'])) : '');
$arr['origin'] = ((x($arr,'origin')) ? intval($arr['origin']) : 0 );
- $arr['guid'] = ((x($arr,'guid')) ? notags(trim($arr['guid'])) : get_guid(30));
$arr['network'] = ((x($arr,'network')) ? trim($arr['network']) : '');
+ $arr['guid'] = ((x($arr,'guid')) ? notags(trim($arr['guid'])) : get_guid(32, $arr['network']));
$arr['postopts'] = ((x($arr,'postopts')) ? trim($arr['postopts']) : '');
$arr['resource-id'] = ((x($arr,'resource-id')) ? trim($arr['resource-id']) : '');
$arr['event-id'] = ((x($arr,'event-id')) ? intval($arr['event-id']) : 0 );
@@ -1239,6 +1239,9 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
logger("item_store: Set network to ".$arr["network"]." for ".$arr["uri"], LOGGER_DEBUG);
}
+ // Check for hashtags in the body and repair or add hashtag links
+ item_body_set_hashtags($arr);
+
$arr['thr-parent'] = $arr['parent-uri'];
if($arr['parent-uri'] === $arr['uri']) {
$parent_id = 0;
@@ -1343,6 +1346,20 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
return 0;
}
+ // Is this item available in the global items (with uid=0)?
+ if ($arr["uid"] == 0) {
+ $arr["global"] = true;
+
+ q("UPDATE `item` SET `global` = 1 WHERE `guid` = '%s'", dbesc($arr["guid"]));
+ } else {
+ $isglobal = q("SELECT `global` FROM `item` WHERE `uid` = 0 AND `guid` = '%s'", dbesc($arr["guid"]));
+
+ $arr["global"] = (count($isglobal) > 0);
+ }
+
+ // Fill the cache field
+ put_item_in_cache($arr);
+
call_hooks('post_remote',$arr);
if(x($arr,'cancel')) {
@@ -1376,16 +1393,6 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
$current_post = $r[0]['id'];
logger('item_store: created item ' . $current_post);
- // Add every contact to the global contact table
- // Contacts from the statusnet connector are also added since you could add them in OStatus as well.
- if (!$arr['private'] AND in_array($arr["network"],
- array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_STATUSNET, ""))) {
- poco_check($arr["author-link"], $arr["author-name"], $arr["network"], $arr["author-avatar"], "", "", "", "", "", $arr["received"], $arr["contact-id"], $arr["uid"]);
-
- // Maybe its a body with a shared item? Then extract a global contact from it.
- poco_contact_from_body($arr["body"], $arr["received"], $arr["contact-id"], $arr["uid"]);
- }
-
// Set "success_update" to the date of the last time we heard from this contact
// This can be used to filter for inactive contacts and poco.
// Only do this for public postings to avoid privacy problems, since poco data is public.
@@ -1395,56 +1402,12 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
dbesc($arr['received']),
intval($arr['contact-id'])
);
-
- // Only check for notifications on start posts
- if ($arr['parent-uri'] === $arr['uri']) {
- add_thread($r[0]['id']);
- logger('item_store: Check notification for contact '.$arr['contact-id'].' and post '.$current_post, LOGGER_DEBUG);
-
- // Send a notification for every new post?
- $r = q("SELECT `notify_new_posts` FROM `contact` WHERE `id` = %d AND `uid` = %d AND `notify_new_posts` LIMIT 1",
- intval($arr['contact-id']),
- intval($arr['uid'])
- );
-
- if(count($r)) {
- logger('item_store: Send notification for contact '.$arr['contact-id'].' and post '.$current_post, LOGGER_DEBUG);
- $u = q("SELECT * FROM user WHERE uid = %d LIMIT 1",
- intval($arr['uid']));
-
- $item = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d",
- intval($current_post),
- intval($arr['uid'])
- );
-
- $a = get_app();
-
- require_once('include/enotify.php');
- notification(array(
- 'type' => NOTIFY_SHARE,
- 'notify_flags' => $u[0]['notify-flags'],
- 'language' => $u[0]['language'],
- 'to_name' => $u[0]['username'],
- 'to_email' => $u[0]['email'],
- 'uid' => $u[0]['uid'],
- 'item' => $item[0],
- 'link' => $a->get_baseurl().'/display/'.urlencode($arr['guid']),
- 'source_name' => $item[0]['author-name'],
- 'source_link' => $item[0]['author-link'],
- 'source_photo' => $item[0]['author-avatar'],
- 'verb' => ACTIVITY_TAG,
- 'otype' => 'item'
- ));
- logger('item_store: Notification sent for contact '.$arr['contact-id'].' and post '.$current_post, LOGGER_DEBUG);
- }
- }
-
} else {
logger('item_store: could not locate created item');
return 0;
}
if(count($r) > 1) {
- logger('item_store: duplicated post occurred. Removing duplicates.');
+ logger('item_store: duplicated post occurred. Removing duplicates. uri = '.$arr['uri'].' uid = '.$arr['uid']);
q("DELETE FROM `item` WHERE `uri` = '%s' AND `uid` = %d AND `id` != %d ",
dbesc($arr['uri']),
intval($arr['uid']),
@@ -1488,13 +1451,18 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
$arr['deleted'] = $parent_deleted;
// update the commented timestamp on the parent
-
- q("UPDATE `item` set `commented` = '%s', `changed` = '%s' WHERE `id` = %d",
- dbesc(datetime_convert()),
- dbesc(datetime_convert()),
- intval($parent_id)
- );
- update_thread($parent_id);
+ // Only update "commented" if it is really a comment
+ if (($arr['verb'] == ACTIVITY_POST) OR !get_config("system", "like_no_comment"))
+ q("UPDATE `item` SET `commented` = '%s', `changed` = '%s' WHERE `id` = %d",
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
+ intval($parent_id)
+ );
+ else
+ q("UPDATE `item` SET `changed` = '%s' WHERE `id` = %d",
+ dbesc(datetime_convert()),
+ intval($parent_id)
+ );
if($dsprsig) {
q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
@@ -1520,39 +1488,157 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
$deleted = tag_deliver($arr['uid'],$current_post);
- // current post can be deleted if is for a communuty page and no mention are
+ // current post can be deleted if is for a community page and no mention are
// in it.
if (!$deleted AND !$dontcache) {
- // Store the fresh generated item into the cache
- $cachefile = get_cachefile(urlencode($arr["guid"])."-".hash("md5", $arr['body']));
-
- if (($cachefile != '') AND !file_exists($cachefile)) {
- $s = prepare_text($arr['body']);
- $a = get_app();
- $stamp1 = microtime(true);
- file_put_contents($cachefile, $s);
- $a->save_timestamp($stamp1, "file");
- logger('item_store: put item '.$current_post.' into cachefile '.$cachefile);
- }
-
$r = q('SELECT * FROM `item` WHERE id = %d', intval($current_post));
if (count($r) == 1) {
call_hooks('post_remote_end', $r[0]);
- } else {
+ } else
logger('item_store: new item not found in DB, id ' . $current_post);
- }
}
- create_tags_from_item($current_post, $dontcache);
+ // Add every contact of the post to the global contact table
+ poco_store($arr);
+
+ create_tags_from_item($current_post);
create_files_from_item($current_post);
+ // Only check for notifications on start posts
+ if ($arr['parent-uri'] === $arr['uri']) {
+ add_thread($current_post);
+ logger('item_store: Check notification for contact '.$arr['contact-id'].' and post '.$current_post, LOGGER_DEBUG);
+
+ // Send a notification for every new post?
+ $r = q("SELECT `notify_new_posts` FROM `contact` WHERE `id` = %d AND `uid` = %d AND `notify_new_posts` LIMIT 1",
+ intval($arr['contact-id']),
+ intval($arr['uid'])
+ );
+ $send_notification = count($r);
+
+ if (!$send_notification) {
+ $tags = q("SELECT `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` = %d AND `uid` = %d",
+ intval(TERM_OBJ_POST), intval($current_post), intval(TERM_MENTION), intval($arr['uid']));
+
+ if (count($tags)) {
+ foreach ($tags AS $tag) {
+ $r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `notify_new_posts`",
+ normalise_link($tag["url"]), intval($arr['uid']));
+ if (count($r))
+ $send_notification = true;
+ }
+ }
+ }
+
+ if ($send_notification) {
+ logger('item_store: Send notification for contact '.$arr['contact-id'].' and post '.$current_post, LOGGER_DEBUG);
+ $u = q("SELECT * FROM user WHERE uid = %d LIMIT 1",
+ intval($arr['uid']));
+
+ $item = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d",
+ intval($current_post),
+ intval($arr['uid'])
+ );
+
+ $a = get_app();
+
+ require_once('include/enotify.php');
+ notification(array(
+ 'type' => NOTIFY_SHARE,
+ 'notify_flags' => $u[0]['notify-flags'],
+ 'language' => $u[0]['language'],
+ 'to_name' => $u[0]['username'],
+ 'to_email' => $u[0]['email'],
+ 'uid' => $u[0]['uid'],
+ 'item' => $item[0],
+ 'link' => $a->get_baseurl().'/display/'.urlencode($arr['guid']),
+ 'source_name' => $item[0]['author-name'],
+ 'source_link' => $item[0]['author-link'],
+ 'source_photo' => $item[0]['author-avatar'],
+ 'verb' => ACTIVITY_TAG,
+ 'otype' => 'item'
+ ));
+ logger('item_store: Notification sent for contact '.$arr['contact-id'].' and post '.$current_post, LOGGER_DEBUG);
+ }
+ } else {
+ update_thread($parent_id);
+ add_shadow_entry($arr);
+ }
+
if ($notify)
proc_run('php', "include/notifier.php", $notify_type, $current_post);
return $current_post;
}
+function item_body_set_hashtags(&$item) {
+
+ $tags = get_tags($item["body"]);
+
+ // No hashtags?
+ if(!count($tags))
+ return(false);
+
+ // This sorting is important when there are hashtags that are part of other hashtags
+ // Otherwise there could be problems with hashtags like #test and #test2
+ rsort($tags);
+
+ $a = get_app();
+
+ $URLSearchString = "^\[\]";
+
+ // All hashtags should point to the home server
+ //$item["body"] = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
+ // "#[url=".$a->get_baseurl()."/search?tag=$2]$2[/url]", $item["body"]);
+
+ //$item["tag"] = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
+ // "#[url=".$a->get_baseurl()."/search?tag=$2]$2[/url]", $item["tag"]);
+
+ // mask hashtags inside of url, bookmarks and attachments to avoid urls in urls
+ $item["body"] = preg_replace_callback("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
+ function ($match){
+ return("[url=".$match[1]."]".str_replace("#", "#", $match[2])."[/url]");
+ },$item["body"]);
+
+ $item["body"] = preg_replace_callback("/\[bookmark\=([$URLSearchString]*)\](.*?)\[\/bookmark\]/ism",
+ function ($match){
+ return("[bookmark=".$match[1]."]".str_replace("#", "#", $match[2])."[/bookmark]");
+ },$item["body"]);
+
+ $item["body"] = preg_replace_callback("/\[attachment (.*)\](.*?)\[\/attachment\]/ism",
+ function ($match){
+ return("[attachment ".str_replace("#", "#", $match[1])."]".$match[2]."[/attachment]");
+ },$item["body"]);
+
+ // Repair recursive urls
+ $item["body"] = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
+ "#$2", $item["body"]);
+
+ foreach($tags as $tag) {
+ if(strpos($tag,'#') !== 0)
+ continue;
+
+ if(strpos($tag,'[url='))
+ continue;
+
+ $basetag = str_replace('_',' ',substr($tag,1));
+
+ $newtag = '#[url='.$a->get_baseurl().'/search?tag='.rawurlencode($basetag).']'.$basetag.'[/url]';
+
+ $item["body"] = str_replace($tag, $newtag, $item["body"]);
+
+ if(!stristr($item["tag"],"/search?tag=".$basetag."]".$basetag."[/url]")) {
+ if(strlen($item["tag"]))
+ $item["tag"] = ','.$item["tag"];
+ $item["tag"] = $newtag.$item["tag"];
+ }
+ }
+
+ // Convert back the masked hashtags
+ $item["body"] = str_replace("#", "#", $item["body"]);
+}
+
function get_item_guid($id) {
$r = q("SELECT `guid` FROM `item` WHERE `id` = %d LIMIT 1", intval($id));
if (count($r))
@@ -2078,6 +2164,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
$photo_timestamp = '';
$photo_url = '';
$birthday = '';
+ $contact_updated = '';
$hubs = $feed->get_links('hub');
logger('consume_feed: hubs: ' . print_r($hubs,true), LOGGER_DATA);
@@ -2093,9 +2180,16 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
if($elems['name'][0]['attribs'][NAMESPACE_DFRN]['updated']) {
$name_updated = $elems['name'][0]['attribs'][NAMESPACE_DFRN]['updated'];
$new_name = $elems['name'][0]['data'];
+
+ // Manually checking for changed contact names
+ if (($new_name != $contact['name']) AND ($new_name != "") AND ($name_updated <= $contact['name-date'])) {
+ $name_updated = date("c");
+ $photo_timestamp = date("c");
+ }
}
if((x($elems,'link')) && ($elems['link'][0]['attribs']['']['rel'] === 'photo') && ($elems['link'][0]['attribs'][NAMESPACE_DFRN]['updated'])) {
- $photo_timestamp = datetime_convert('UTC','UTC',$elems['link'][0]['attribs'][NAMESPACE_DFRN]['updated']);
+ if ($photo_timestamp == "")
+ $photo_timestamp = datetime_convert('UTC','UTC',$elems['link'][0]['attribs'][NAMESPACE_DFRN]['updated']);
$photo_url = $elems['link'][0]['attribs']['']['href'];
}
@@ -2106,6 +2200,9 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
if((is_array($contact)) && ($photo_timestamp) && (strlen($photo_url)) && ($photo_timestamp > $contact['avatar-date'])) {
logger('consume_feed: Updating photo for '.$contact['name'].' from '.$photo_url.' uid: '.$contact['uid']);
+
+ $contact_updated = $photo_timestamp;
+
require_once("include/Photo.php");
$photo_failure = false;
$have_photo = false;
@@ -2163,6 +2260,9 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
}
if((is_array($contact)) && ($name_updated) && (strlen($new_name)) && ($name_updated > $contact['name-date'])) {
+ if ($name_updated > $contact_updated)
+ $contact_updated = $name_updated;
+
$r = q("select * from contact where uid = %d and id = %d limit 1",
intval($contact['uid']),
intval($contact['id'])
@@ -2187,6 +2287,9 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
}
}
+ if ($contact_updated AND $new_name AND $photo_url)
+ poco_check($contact['url'], $new_name, NETWORK_DFRN, $photo_url, "", "", "", "", "", $contact_updated, 2, $contact['id'], $contact['uid']);
+
if(strlen($birthday)) {
if(substr($birthday,0,4) != $contact['bdyear']) {
logger('consume_feed: updating birthday: ' . $birthday);
@@ -2233,7 +2336,6 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
$contact['bdyear'] = substr($birthday,0,4);
}
-
}
$community_page = 0;
@@ -2715,6 +2817,10 @@ function item_is_remote_self($contact, &$datarray) {
if ($datarray["app"] == $a->get_hostname())
return false;
+ // Only forward posts
+ if ($datarray["verb"] != ACTIVITY_POST)
+ return false;
+
if (($contact['network'] != NETWORK_FEED) AND $datarray['private'])
return false;
@@ -2795,6 +2901,7 @@ function local_delivery($importer,$data) {
$new_name = '';
$photo_timestamp = '';
$photo_url = '';
+ $contact_updated = '';
$rawtags = $feed->get_feed_tags( NAMESPACE_DFRN, 'owner');
@@ -2808,14 +2915,24 @@ function local_delivery($importer,$data) {
if($elems['name'][0]['attribs'][NAMESPACE_DFRN]['updated']) {
$name_updated = $elems['name'][0]['attribs'][NAMESPACE_DFRN]['updated'];
$new_name = $elems['name'][0]['data'];
+
+ // Manually checking for changed contact names
+ if (($new_name != $importer['name']) AND ($new_name != "") AND ($name_updated <= $importer['name-date'])) {
+ $name_updated = date("c");
+ $photo_timestamp = date("c");
+ }
}
if((x($elems,'link')) && ($elems['link'][0]['attribs']['']['rel'] === 'photo') && ($elems['link'][0]['attribs'][NAMESPACE_DFRN]['updated'])) {
- $photo_timestamp = datetime_convert('UTC','UTC',$elems['link'][0]['attribs'][NAMESPACE_DFRN]['updated']);
+ if ($photo_timestamp == "")
+ $photo_timestamp = datetime_convert('UTC','UTC',$elems['link'][0]['attribs'][NAMESPACE_DFRN]['updated']);
$photo_url = $elems['link'][0]['attribs']['']['href'];
}
}
if(($photo_timestamp) && (strlen($photo_url)) && ($photo_timestamp > $importer['avatar-date'])) {
+
+ $contact_updated = $photo_timestamp;
+
logger('local_delivery: Updating photo for ' . $importer['name']);
require_once("include/Photo.php");
$photo_failure = false;
@@ -2874,6 +2991,9 @@ function local_delivery($importer,$data) {
}
if(($name_updated) && (strlen($new_name)) && ($name_updated > $importer['name-date'])) {
+ if ($name_updated > $contact_updated)
+ $contact_updated = $name_updated;
+
$r = q("select * from contact where uid = %d and id = %d limit 1",
intval($importer['importer_uid']),
intval($importer['id'])
@@ -2898,7 +3018,8 @@ function local_delivery($importer,$data) {
}
}
-
+ if ($contact_updated AND $new_name AND $photo_url)
+ poco_check($importer['url'], $new_name, NETWORK_DFRN, $photo_url, "", "", "", "", "", $contact_updated, 2, $importer['id'], $importer['importer_uid']);
// Currently unsupported - needs a lot of work
$reloc = $feed->get_feed_tags( NAMESPACE_DFRN, 'relocate' );
@@ -2937,6 +3058,7 @@ function local_delivery($importer,$data) {
thumb = '%s',
micro = '%s',
url = '%s',
+ nurl = '%s',
request = '%s',
confirm = '%s',
notify = '%s',
@@ -2948,6 +3070,7 @@ function local_delivery($importer,$data) {
dbesc($newloc['thumb']),
dbesc($newloc['micro']),
dbesc($newloc['url']),
+ dbesc(normalise_link($newloc['url'])),
dbesc($newloc['request']),
dbesc($newloc['confirm']),
dbesc($newloc['notify']),
@@ -4649,8 +4772,8 @@ function drop_item($id,$interactive = true) {
dbesc($item['parent-uri']),
intval($item['uid'])
);
- create_tags_from_item($item['parent-uri'], $item['uid']);
- create_files_from_item($item['parent-uri'], $item['uid']);
+ create_tags_from_itemuri($item['parent-uri'], $item['uid']);
+ create_files_from_itemuri($item['parent-uri'], $item['uid']);
delete_thread_uri($item['parent-uri'], $item['uid']);
// ignore the result
}
diff --git a/include/markdownify/LICENSE_LGPL.txt b/include/markdownify/LICENSE_LGPL.txt
deleted file mode 100644
index 5ab7695ab..000000000
--- a/include/markdownify/LICENSE_LGPL.txt
+++ /dev/null
@@ -1,504 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- , 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
-
-
diff --git a/include/markdownify/TODO b/include/markdownify/TODO
deleted file mode 100644
index 06ec8508b..000000000
--- a/include/markdownify/TODO
+++ /dev/null
@@ -1,29 +0,0 @@
-Markdownify
-===========
-* handle non-markdownifiable lists (i.e. `
asdf
`)
-* organize methods better (i.e. flushlinebreaks & setlinebreaks close to each other)
-* take a look at function names etc.
-* is the new (in rev. 93) lastclosedtag property needed?
-* word wrapping (some work is done but it's still very buggy)
-
-
-Markdownify Extra
-=================
-
-* handle table alignment with KEEP_HTML=false
-* handle tables without headings when KEEP_HTML=false is set
-* handle Markdown inside non-markdownable tags
-
-
-Implementation Thoughts
-=======================
-* non-markdownifiable lists and markdown inside non-markdownable tags as well as the current
- table implementation could be rewritten by using a rollback mechanism.
-
- example:
-
-
asdf
asdf
-
- we come to `
`, know that this might fail and create a snapshot of our current parser
- we keep on parsing and when we reach `
` we gotta rollback and keep this
- list in HTML format.
diff --git a/include/markdownify/example.php b/include/markdownify/example.php
deleted file mode 100644
index ef86dca83..000000000
--- a/include/markdownify/example.php
+++ /dev/null
@@ -1,51 +0,0 @@
-parseString($_POST['input']);
- } else {
- $_POST['input'] = '';
- }
-?>
-
-
-
- HTML to Markdown Converter
-
-
-
-
-
-