(.*?)<\/a>/is';
- $Text = preg_replace($pattern, '#$2', $Text);
- }
-*/
call_hooks('bbcode',$Text);
- $a->save_timestamp($stamp1, "parser");
-
- return $Text;
+ return trim($Text);
}
?>
diff --git a/include/conversation.php b/include/conversation.php
index 558942063..20b54728c 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -203,12 +203,11 @@ function localize_item(&$item){
// 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
-
- $txt = str_replace( t('poked'), t($verb), $txt);
+ $poked_t = trim(sprintf($txt, "",""));
+ $txt = str_replace( $poked_t, t($verb), $txt);
// then do the sprintf on the translation string
@@ -1102,16 +1101,16 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
'$shortsetloc' => t('set location'),
'$noloc' => t('Clear browser location'),
'$shortnoloc' => t('clear location'),
- '$title' => "",
+ '$title' => $x['title'],
'$placeholdertitle' => t('Set title'),
- '$category' => "",
+ '$category' => $x['category'],
'$placeholdercategory' => (feature_enabled(local_user(),'categories') ? t('Categories (comma-separated list)') : ''),
'$wait' => t('Please wait'),
'$permset' => t('Permission settings'),
'$shortpermset' => t('permissions'),
'$ptyp' => (($notes_cid) ? 'note' : 'wall'),
- '$content' => '',
- '$post_id' => '',
+ '$content' => $x['content'],
+ '$post_id' => $x['post_id'],
'$baseurl' => $a->get_baseurl(true),
'$defloc' => $x['default_location'],
'$visitor' => $x['visitor'],
diff --git a/include/cronhooks.php b/include/cronhooks.php
index c0549dfff..3a09da48c 100644
--- a/include/cronhooks.php
+++ b/include/cronhooks.php
@@ -66,6 +66,6 @@ function cronhooks_run(&$argv, &$argc){
}
if (array_search(__file__,get_included_files())===0){
- cronhooks_run($argv,$argc);
+ cronhooks_run($_SERVER["argv"],$_SERVER["argc"]);
killme();
}
diff --git a/include/dbstructure.php b/include/dbstructure.php
index 66e67c0a9..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);
}
@@ -413,6 +419,10 @@ function db_definition() {
"network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
+ "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
+ "about" => array("type" => "text", "not null" => "1"),
+ "keywords" => array("type" => "text", "not null" => "1"),
+ "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
"attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"photo" => array("type" => "text", "not null" => "1"),
"thumb" => array("type" => "text", "not null" => "1"),
@@ -616,6 +626,13 @@ function db_definition() {
"nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
+ "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
+ "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
+ "about" => array("type" => "text", "not null" => "1"),
+ "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"),
@@ -765,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"),
@@ -823,6 +843,7 @@ function db_definition() {
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
"name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
"locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
+ "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
),
"indexes" => array(
"PRIMARY" => array("id"),
@@ -1176,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"),
),
@@ -1184,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(
@@ -1247,6 +1273,8 @@ function db_definition() {
"nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
+ "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
+ "about" => array("type" => "text", "not null" => "1"),
),
"indexes" => array(
"PRIMARY" => array("id"),
@@ -1335,10 +1363,32 @@ 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){
- dbstructure_run($argv,$argc);
+ dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);
killme();
}
diff --git a/include/dbupdate.php b/include/dbupdate.php
index eb2eda48d..28f1de340 100644
--- a/include/dbupdate.php
+++ b/include/dbupdate.php
@@ -8,7 +8,7 @@ function dbupdate_run(&$argv, &$argc) {
if(is_null($a)){
$a = new App;
}
-
+
if(is_null($db)) {
@include(".htconfig.php");
require_once("include/dba.php");
@@ -23,7 +23,6 @@ function dbupdate_run(&$argv, &$argc) {
}
if (array_search(__file__,get_included_files())===0){
- dbupdate_run($argv,$argc);
+ dbupdate_run($_SERVER["argv"],$_SERVER["argc"]);
killme();
}
-
diff --git a/include/delivery.php b/include/delivery.php
index bf41b3d13..1def8ad2c 100644
--- a/include/delivery.php
+++ b/include/delivery.php
@@ -565,6 +565,6 @@ function delivery_run(&$argv, &$argc){
}
if (array_search(__file__,get_included_files())===0){
- delivery_run($argv,$argc);
+ delivery_run($_SERVER["argv"],$_SERVER["argc"]);
killme();
}
diff --git a/include/diaspora.php b/include/diaspora.php
index 8b85e7b95..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,170 @@ 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)
+ return false;
+
+ $a = get_app();
+
+ // This will not work if the server is not a Diaspora server
+ $source_url = $server.'/p/'.$guid.'.xml';
+ $x = fetch_url($source_url);
+ if(!$x)
+ return false;
+
+ $x = str_replace(array('',''),array('',''),$x);
+ $source_xml = parse_xml_string($x,false);
+
+ $item = array();
+ $item["app"] = 'Diaspora';
+ $item["guid"] = $guid;
+ $body = "";
+
+ if ($source_xml->post->status_message->created_at)
+ $item["created"] = unxmlify($source_xml->post->status_message->created_at);
+
+ if ($source_xml->post->status_message->provider_display_name)
+ $item["app"] = unxmlify($source_xml->post->status_message->provider_display_name);
+
+ if ($source_xml->post->status_message->diaspora_handle)
+ $item["author"] = unxmlify($source_xml->post->status_message->diaspora_handle);
+
+ if ($source_xml->post->status_message->guid)
+ $item["guid"] = unxmlify($source_xml->post->status_message->guid);
+
+ $item["private"] = (unxmlify($source_xml->post->status_message->public) == 'false');
+
+ if(strlen($source_xml->post->asphoto->objectId) && ($source_xml->post->asphoto->objectId != 0) && ($source_xml->post->asphoto->image_url)) {
+ $body = '[url=' . notags(unxmlify($source_xml->post->asphoto->image_url)) . '][img]' . notags(unxmlify($source_xml->post->asphoto->objectId)) . '[/img][/url]' . "\n";
+ $body = scale_external_images($body,false);
+ } elseif($source_xml->post->asphoto->image_url) {
+ $body = '[img]' . notags(unxmlify($source_xml->post->asphoto->image_url)) . '[/img]' . "\n";
+ $body = scale_external_images($body);
+ } elseif($source_xml->post->status_message) {
+ $body = diaspora2bb($source_xml->post->status_message->raw_message);
+
+ // Checking for embedded pictures
+ if($source_xml->post->status_message->photo->remote_photo_path AND
+ $source_xml->post->status_message->photo->remote_photo_name) {
+
+ $remote_photo_path = notags(unxmlify($source_xml->post->status_message->photo->remote_photo_path));
+ $remote_photo_name = notags(unxmlify($source_xml->post->status_message->photo->remote_photo_name));
+
+ $body = '[img]'.$remote_photo_path.$remote_photo_name.'[/img]'."\n".$body;
+
+ logger('embedded picture link found: '.$body, LOGGER_DEBUG);
+ }
+
+ $body = scale_external_images($body);
+
+ // Add OEmbed and other information to the body
+ $body = add_page_info_to_body($body, false, true);
+ } elseif($source_xml->post->reshare) {
+ // Reshare of a reshare
+ return diaspora_fetch_message($source_xml->post->reshare->root_guid, $server, ++$level);
+ } else {
+ // Maybe it is a reshare of a photo that will be delivered at a later time (testing)
+ logger('no content found: '.print_r($source_xml,true));
+ $body = "";
+ }
+
+ if ($body == "")
+ return false;
+
+ $item["tag"] = '';
+ $item["body"] = $body;
+
+ return $item;
+}
+
function diaspora_reshare($importer,$xml,$msg) {
logger('diaspora_reshare: init: ' . print_r($xml,true));
@@ -945,70 +1072,66 @@ function diaspora_reshare($importer,$xml,$msg) {
$orig_author = notags(unxmlify($xml->root_diaspora_id));
$orig_guid = notags(unxmlify($xml->root_guid));
- $source_url = 'https://' . substr($orig_author,strpos($orig_author,'@')+1) . '/p/' . $orig_guid . '.xml';
- $orig_url = 'https://'.substr($orig_author,strpos($orig_author,'@')+1).'/posts/'.$orig_guid;
- $x = fetch_url($source_url);
- if(! $x)
- $x = fetch_url(str_replace('https://','http://',$source_url));
- if(! $x) {
- logger('diaspora_reshare: unable to fetch source url ' . $source_url);
- return;
+ $create_original_post = false;
+
+ // Do we already have this item?
+ $r = q("SELECT `body`, `tag`, `app`, `author-link`, `plink` FROM `item` WHERE `guid` = '%s' AND `visible` AND NOT `deleted` AND `body` != '' LIMIT 1",
+ dbesc($orig_guid),
+ dbesc(NETWORK_DIASPORA)
+ );
+ if(count($r)) {
+ logger('reshared message '.orig_guid." reshared by ".$guid.' already exists on system: '.$orig_url);
+
+ // Maybe it is already a reshared item?
+ // Then refetch the content, since there can be many side effects with reshared posts from other networks or reshares from reshares
+ require_once('include/api.php');
+ if (api_share_as_retweet($r[0]))
+ $r = array();
+ else
+ $orig_url = $a->get_baseurl().'/display/'.$orig_guid;
}
- logger('diaspora_reshare: source: ' . $x);
- $x = str_replace(array('',''),array('',''),$x);
- $source_xml = parse_xml_string($x,false);
+ if (!count($r)) {
+ $body = "";
+ $str_tags = "";
+ $app = "";
- if(strlen($source_xml->post->asphoto->objectId) && ($source_xml->post->asphoto->objectId != 0) && ($source_xml->post->asphoto->image_url)) {
- $body = '[url=' . notags(unxmlify($source_xml->post->asphoto->image_url)) . '][img]' . notags(unxmlify($source_xml->post->asphoto->objectId)) . '[/img][/url]' . "\n";
- $body = scale_external_images($body,false);
- }
- elseif($source_xml->post->asphoto->image_url) {
- $body = '[img]' . notags(unxmlify($source_xml->post->asphoto->image_url)) . '[/img]' . "\n";
- $body = scale_external_images($body);
- }
- elseif($source_xml->post->status_message) {
- $body = diaspora2bb($source_xml->post->status_message->raw_message);
+ $orig_url = 'https://'.substr($orig_author,strpos($orig_author,'@')+1).'/posts/'.$orig_guid;
- // Checking for embedded pictures
- if($source_xml->post->status_message->photo->remote_photo_path AND
- $source_xml->post->status_message->photo->remote_photo_name) {
+ $server = 'https://'.substr($orig_author,strpos($orig_author,'@')+1);
+ logger('1st try: reshared message '.$orig_guid." reshared by ".$guid.' will be fetched from original server: '.$server);
+ $item = diaspora_fetch_message($orig_guid, $server);
- $remote_photo_path = notags(unxmlify($source_xml->post->status_message->photo->remote_photo_path));
- $remote_photo_name = notags(unxmlify($source_xml->post->status_message->photo->remote_photo_name));
-
- $body = '[img]'.$remote_photo_path.$remote_photo_name.'[/img]'."\n".$body;
-
- logger('diaspora_reshare: embedded picture link found: '.$body, LOGGER_DEBUG);
+ if (!$item) {
+ $server = 'https://'.substr($diaspora_handle,strpos($diaspora_handle,'@')+1);
+ logger('2nd try: reshared message '.$orig_guid." reshared by ".$guid." will be fetched from sharer's server: ".$server);
+ $item = diaspora_fetch_message($orig_guid, $server);
+ }
+ if (!$item) {
+ $server = 'http://'.substr($orig_author,strpos($orig_author,'@')+1);
+ logger('3rd try: reshared message '.$orig_guid." reshared by ".$guid.' will be fetched from original server: '.$server);
+ $item = diaspora_fetch_message($orig_guid, $server);
+ }
+ if (!$item) {
+ $server = 'http://'.substr($diaspora_handle,strpos($diaspora_handle,'@')+1);
+ logger('4th try: reshared message '.$orig_guid." reshared by ".$guid." will be fetched from sharer's server: ".$server);
+ $item = diaspora_fetch_message($orig_guid, $server);
}
- $body = scale_external_images($body);
-
- // Add OEmbed and other information to the body
- $body = add_page_info_to_body($body, false, true);
+ if ($item) {
+ $body = $item["body"];
+ $str_tags = $item["tag"];
+ $app = $item["app"];
+ $orig_created = $item["created"];
+ $orig_author = $item["author"];
+ $orig_guid = $item["guid"];
+ $create_original_post = ($body != "");
+ $orig_url = $a->get_baseurl()."/display/".$orig_guid;
+ }
}
- else {
- // Maybe it is a reshare of a photo that will be delivered at a later time (testing)
- logger('diaspora_reshare: no reshare content found: ' . print_r($source_xml,true));
- $body = "";
- //return;
- }
-
- //if(! $body) {
- // logger('diaspora_reshare: empty body: source= ' . $x);
- // return;
- //}
$person = find_diaspora_person_by_handle($orig_author);
- /*if(is_array($person) && x($person,'name') && x($person,'url'))
- $details = '[url=' . $person['url'] . ']' . $person['name'] . '[/url]';
- else
- $details = $orig_author;
-
- $prefix = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . $details . "\n";*/
-
-
// allocate a guid on our system - we aren't fixing any collisions.
// we're ignoring them
@@ -1026,34 +1149,6 @@ function diaspora_reshare($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;
- }
- }
- }
-
$plink = 'https://'.substr($diaspora_handle,strpos($diaspora_handle,'@')+1).'/posts/'.$guid;
$datarray['uid'] = $importer['uid'];
@@ -1073,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'];
@@ -1087,19 +1184,40 @@ function diaspora_reshare($importer,$xml,$msg) {
}
$datarray['tag'] = $str_tags;
- $datarray['app'] = 'Diaspora';
+ $datarray['app'] = $app;
// if empty content it might be a photo that hasn't arrived yet. If a photo arrives, we'll make it visible. (testing)
$datarray['visible'] = ((strlen($body)) ? 1 : 0);
- $message_id = item_store($datarray);
+ // Store the original item of a reshare
+ if ($create_original_post) {
+ require_once("include/Contact.php");
- //if($message_id) {
- // q("update item set plink = '%s' where id = %d",
- // dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id),
- // intval($message_id)
- // );
- //}
+ $datarray2 = $datarray;
+
+ $datarray2['uid'] = 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);
+ $datarray2['plink'] = 'https://'.substr($orig_author,strpos($orig_author,'@')+1).'/posts/'.$orig_guid;
+
+ $datarray2['author-name'] = $person['name'];
+ $datarray2['author-link'] = $person['url'];
+ $datarray2['author-avatar'] = ((x($person,'thumb')) ? $person['thumb'] : $person['photo']);
+ $datarray2['owner-name'] = $datarray2['author-name'];
+ $datarray2['owner-link'] = $datarray2['author-link'];
+ $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;
@@ -1191,6 +1309,7 @@ function diaspora_asphoto($importer,$xml,$msg) {
$datarray['app'] = 'Diaspora/Cubbi.es';
+ DiasporaFetchGuid($datarray);
$message_id = item_store($datarray);
//if($message_id) {
@@ -1314,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';
@@ -1365,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) {
@@ -1765,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;
@@ -1844,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;
}
@@ -1860,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
@@ -1887,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;
}
}
@@ -2028,6 +2120,7 @@ function diaspora_retraction($importer,$xml) {
dbesc(datetime_convert()),
intval($r[0]['id'])
);
+ delete_thread($r[0]['id'], $r[0]['parent-uri']);
}
}
}
@@ -2100,6 +2193,7 @@ function diaspora_signed_retraction($importer,$xml,$msg) {
dbesc(datetime_convert()),
intval($r[0]['id'])
);
+ delete_thread($r[0]['id'], $r[0]['parent-uri']);
// Now check if the retraction needs to be relayed by us
//
@@ -2159,14 +2253,27 @@ function diaspora_profile($importer,$xml,$msg) {
$name = unxmlify($xml->first_name) . ((strlen($xml->last_name)) ? ' ' . unxmlify($xml->last_name) : '');
$image_url = unxmlify($xml->image_url);
$birthday = unxmlify($xml->birthday);
+ $location = diaspora2bb(unxmlify($xml->location));
+ $about = diaspora2bb(unxmlify($xml->bio));
+ $gender = unxmlify($xml->gender);
+ $tags = unxmlify($xml->tag_string);
+ $tags = explode("#", $tags);
+
+ $keywords = array();
+ foreach ($tags as $tag) {
+ $tag = trim(strtolower($tag));
+ if ($tag != "")
+ $keywords[] = $tag;
+ }
+
+ $keywords = implode(", ", $keywords);
$handle_parts = explode("@", $diaspora_handle);
if($name === '') {
$name = $handle_parts[0];
}
-
-
+
if( preg_match("|^https?://|", $image_url) === 0) {
$image_url = "http://" . $handle_parts[1] . $image_url;
}
@@ -2180,8 +2287,8 @@ function diaspora_profile($importer,$xml,$msg) {
require_once('include/Photo.php');
$images = import_profile_photo($image_url,$importer['uid'],$contact['id']);
-
- // Generic birthday. We don't know the timezone. The year is irrelevant.
+
+ // Generic birthday. We don't know the timezone. The year is irrelevant.
$birthday = str_replace('1000','1901',$birthday);
@@ -2194,9 +2301,9 @@ function diaspora_profile($importer,$xml,$msg) {
$birthday = $contact['bd'];
// TODO: update name on item['author-name'] if the name changed. See consume_feed()
- // Not doing this currently because D* protocol is scheduled for revision soon.
+ // Not doing this currently because D* protocol is scheduled for revision soon.
- $r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' , `bd` = '%s' WHERE `id` = %d AND `uid` = %d",
+ $r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' , `bd` = '%s', `location` = '%s', `about` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc($name),
dbesc(datetime_convert()),
dbesc($images[0]),
@@ -2204,9 +2311,34 @@ function diaspora_profile($importer,$xml,$msg) {
dbesc($images[2]),
dbesc(datetime_convert()),
dbesc($birthday),
+ dbesc($location),
+ dbesc($about),
+ dbesc($keywords),
+ dbesc($gender),
intval($contact['id']),
intval($importer['uid'])
- );
+ );
+
+ 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(), 2, $contact['id'], $importer['uid']);
+ }
+
+ $profileurl = "";
+ $author = q("SELECT * FROM `unique_contacts` WHERE `url`='%s' LIMIT 1",
+ dbesc(normalise_link($contact['url'])));
+
+ if (count($author) == 0) {
+ q("INSERT INTO `unique_contacts` (`url`, `name`, `avatar`, `location`, `about`) VALUES ('%s', '%s', '%s', '%s', '%s')",
+ dbesc(normalise_link($contact['url'])), dbesc($name), dbesc($location), dbesc($about), dbesc($images[0]));
+
+ $author = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1",
+ dbesc(normalise_link($contact['url'])));
+ } else if (normalise_link($contact['url']).$name.$location.$about != normalise_link($author[0]["url"]).$author[0]["name"].$author[0]["location"].$author[0]["about"]) {
+ q("UPDATE unique_contacts SET name = '%s', avatar = '%s', `location` = '%s', `about` = '%s' WHERE url = '%s'",
+ dbesc($name), dbesc($images[0]), dbesc($location), dbesc($about), dbesc(normalise_link($contact['url'])));
+ }
/* if($r) {
if($oldphotos) {
@@ -2380,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/directory.php b/include/directory.php
index 5c1a7c4b4..aed700fa8 100644
--- a/include/directory.php
+++ b/include/directory.php
@@ -46,6 +46,6 @@ function directory_run(&$argv, &$argc){
}
if (array_search(__file__,get_included_files())===0){
- directory_run($argv,$argc);
+ directory_run($_SERVER["argv"],$_SERVER["argc"]);
killme();
}
diff --git a/include/dsprphotoq.php b/include/dsprphotoq.php
index 47592006d..7e252cd84 100644
--- a/include/dsprphotoq.php
+++ b/include/dsprphotoq.php
@@ -45,6 +45,6 @@ function dsprphotoq_run($argv, $argc){
if (array_search(__file__,get_included_files())===0){
- dsprphotoq_run($argv,$argc);
+ dsprphotoq_run($_SERVER["argv"],$_SERVER["argc"]);
killme();
}
diff --git a/include/enotify.php b/include/enotify.php
index 51263871b..4327e75b8 100644
--- a/include/enotify.php
+++ b/include/enotify.php
@@ -21,13 +21,21 @@ function notification($params) {
$thanks = t('Thank You,');
$sitename = $a->config['sitename'];
$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 = $a->config['sender_email'];
+ if (empty($sender_email)) {
+ $sender_email = t('noreply') . '@' . $hostname;
+ }
- $sender_email = t('noreply') . '@' . $hostname;
+ $user = q("SELECT `nickname` FROM `user` WHERE `uid` = %d", intval($params['uid']));
+ if ($user)
+ $nickname = $user[0]["nickname"];
// with $params['show_in_notification_page'] == false, the notification isn't inserted into
// the database, and an email is sent if applicable.
@@ -37,6 +45,7 @@ function notification($params) {
$additional_mail_header = "";
$additional_mail_header .= "Precedence: list\n";
$additional_mail_header .= "X-Friendica-Host: ".$hostname."\n";
+ $additional_mail_header .= "X-Friendica-Account: <".$nickname."@".$hostname.">\n";
$additional_mail_header .= "X-Friendica-Platform: ".FRIENDICA_PLATFORM."\n";
$additional_mail_header .= "X-Friendica-Version: ".FRIENDICA_VERSION."\n";
$additional_mail_header .= "List-ID: \n";
@@ -344,7 +353,7 @@ function notification($params) {
$show_in_notification_page = false;
}
-
+ $subject .= " (".$nickname."@".$hostname.")";
$h = array(
'params' => $params,
@@ -592,6 +601,7 @@ function notification($params) {
// use the Emailer class to send the message
return Emailer::send(array(
+ 'uid' => $params['uid'],
'fromName' => $sender_name,
'fromEmail' => $sender_email,
'replyTo' => $sender_email,
diff --git a/include/expire.php b/include/expire.php
index a7b561bf0..308680421 100644
--- a/include/expire.php
+++ b/include/expire.php
@@ -55,6 +55,6 @@ function expire_run(&$argv, &$argc){
}
if (array_search(__file__,get_included_files())===0){
- expire_run($argv,$argc);
+ expire_run($_SERVER["argv"],$_SERVER["argc"]);
killme();
}
diff --git a/include/follow.php b/include/follow.php
index 285f864b9..ba036cd48 100644
--- a/include/follow.php
+++ b/include/follow.php
@@ -37,7 +37,7 @@ function new_contact($uid,$url,$interactive = false) {
call_hooks('follow', $arr);
- if(x($arr['contact'],'name'))
+ if(x($arr['contact'],'name'))
$ret = $arr['contact'];
else
$ret = probe_url($url);
@@ -73,7 +73,7 @@ function new_contact($uid,$url,$interactive = false) {
// do we have enough information?
-
+
if(! ((x($ret,'name')) && (x($ret,'poll')) && ((x($ret,'url')) || (x($ret,'addr'))))) {
$result['message'] .= t('The profile address specified does not provide adequate information.') . EOL;
if(! x($ret,'poll'))
@@ -120,12 +120,12 @@ function new_contact($uid,$url,$interactive = false) {
// the poll url is more reliable than the profile url, as we may have
// indirect links or webfinger links
- $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `poll` = '%s' LIMIT 1",
+ $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `poll` = '%s' AND `network` = '%s' LIMIT 1",
intval($uid),
- dbesc($ret['poll'])
+ dbesc($ret['poll']),
+ dbesc($ret['network'])
);
-
if(count($r)) {
// update contact
if($r[0]['rel'] == CONTACT_IS_FOLLOWER || ($network === NETWORK_DIASPORA && $r[0]['rel'] == CONTACT_IS_SHARING)) {
@@ -169,10 +169,10 @@ function new_contact($uid,$url,$interactive = false) {
if($ret['network'] === NETWORK_DIASPORA)
$new_relation = CONTACT_IS_FOLLOWER;
- // create contact record
- $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `name`, `nick`, `photo`, `network`, `pubkey`, `rel`, `priority`,
+ // create contact record
+ $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `name`, `nick`, `network`, `pubkey`, `rel`, `priority`,
`writable`, `hidden`, `blocked`, `readonly`, `pending`, `subhub` )
- VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, 0, 0, 0, %d ) ",
+ VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, 0, 0, 0, %d ) ",
intval($uid),
dbesc(datetime_convert()),
dbesc($ret['url']),
@@ -185,7 +185,6 @@ function new_contact($uid,$url,$interactive = false) {
dbesc($ret['poco']),
dbesc($ret['name']),
dbesc($ret['nick']),
- dbesc($ret['photo']),
dbesc($ret['network']),
dbesc($ret['pubkey']),
intval($new_relation),
@@ -196,8 +195,9 @@ function new_contact($uid,$url,$interactive = false) {
);
}
- $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1",
+ $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `network` = '%s' AND `uid` = %d LIMIT 1",
dbesc($ret['url']),
+ dbesc($ret['network']),
intval($uid)
);
@@ -228,8 +228,7 @@ function new_contact($uid,$url,$interactive = false) {
`name-date` = '%s',
`uri-date` = '%s',
`avatar-date` = '%s'
- WHERE `id` = %d
- ",
+ WHERE `id` = %d",
dbesc($photos[0]),
dbesc($photos[1]),
dbesc($photos[2]),
diff --git a/include/gprobe.php b/include/gprobe.php
index 36650eb9a..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') ",
@@ -63,6 +79,6 @@ function gprobe_run(&$argv, &$argc){
}
if (array_search(__file__,get_included_files())===0){
- gprobe_run($argv,$argc);
+ gprobe_run($_SERVER["argv"],$_SERVER["argc"]);
killme();
}
diff --git a/include/html2bbcode.php b/include/html2bbcode.php
index 6e9532c92..d2699460e 100644
--- a/include/html2bbcode.php
+++ b/include/html2bbcode.php
@@ -16,7 +16,7 @@ function node2bbcode(&$doc, $oldnode, $attributes, $startbb, $endbb)
function node2bbcodesub(&$doc, $oldnode, $attributes, $startbb, $endbb)
{
- $savestart = str_replace('$', '%', $startbb);
+ $savestart = str_replace('$', '\x01', $startbb);
$replace = false;
$xpath = new DomXPath($doc);
@@ -37,7 +37,7 @@ function node2bbcodesub(&$doc, $oldnode, $attributes, $startbb, $endbb)
foreach ($attributes as $attribute => $value) {
- $startbb = str_replace('%'.++$i, '$1', $startbb);
+ $startbb = str_replace('\x01'.++$i, '$1', $startbb);
if (strpos('*'.$startbb, '$1') > 0) {
@@ -76,20 +76,18 @@ function node2bbcodesub(&$doc, $oldnode, $attributes, $startbb, $endbb)
return($replace);
}
+if(!function_exists('deletenode')) {
function deletenode(&$doc, $node)
{
$xpath = new DomXPath($doc);
$list = $xpath->query("//".$node);
foreach ($list as $child)
$child->parentNode->removeChild($child);
-}
+}}
function html2bbcode($message)
{
- //$file = tempnam("/tmp/", "html");
- //file_put_contents($file, $message);
-
$message = str_replace("\r", "", $message);
$message = str_replace(array(
@@ -206,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 0398f5458..0b8bf8fea 100644
--- a/include/items.php
+++ b/include/items.php
@@ -11,6 +11,7 @@ require_once('include/text.php');
require_once('include/email.php');
require_once('include/ostatus_conversation.php');
require_once('include/threads.php');
+require_once('include/socgraph.php');
function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) {
@@ -872,9 +873,19 @@ function get_atom_elements($feed, $item, $contact = array()) {
}
if (isset($contact["network"]) AND ($contact["network"] == NETWORK_FEED) AND $contact['fetch_further_information']) {
- $res["body"] = $res["title"].add_page_info($res['plink'], false, "", ($contact['fetch_further_information'] == 2), $contact['ffi_keyword_blacklist']);
+ $preview = "";
+
+ // Handle enclosures and treat them as preview picture
+ if (isset($attach))
+ foreach ($attach AS $attachment)
+ if ($attachment->type == "image/jpeg")
+ $preview = $attachment->link;
+
+ $res["body"] = $res["title"].add_page_info($res['plink'], false, $preview, ($contact['fetch_further_information'] == 2), $contact['ffi_keyword_blacklist']);
+ $res["tag"] = add_page_keywords($res['plink'], false, $preview, ($contact['fetch_further_information'] == 2), $contact['ffi_keyword_blacklist']);
$res["title"] = "";
$res["object-type"] = ACTIVITY_OBJ_BOOKMARK;
+ unset($res["attach"]);
} elseif (isset($contact["network"]) AND ($contact["network"] == NETWORK_OSTATUS))
$res["body"] = add_page_info_to_body($res["body"]);
elseif (isset($contact["network"]) AND ($contact["network"] == NETWORK_FEED) AND strstr($res['plink'], ".app.net/")) {
@@ -936,12 +947,20 @@ function add_page_info_data($data) {
return("\n[class=type-".$data["type"]."]".$text."[/class]".$hashtags);
}
-function add_page_info($url, $no_photos = false, $photo = "", $keywords = false, $keyword_blacklist = "") {
+function query_page_info($url, $no_photos = false, $photo = "", $keywords = false, $keyword_blacklist = "") {
require_once("mod/parse_url.php");
- $data = parseurl_getsiteinfo($url, true);
+ $data = Cache::get("parse_url:".$url);
+ if (is_null($data)){
+ $data = parseurl_getsiteinfo($url, true);
+ Cache::set("parse_url:".$url,serialize($data));
+ } else
+ $data = unserialize($data);
- logger('add_page_info: fetch page info for '.$url.' '.print_r($data, true), LOGGER_DEBUG);
+ if ($photo != "")
+ $data["images"][0]["src"] = $photo;
+
+ logger('fetch page info for '.$url.' '.print_r($data, true), LOGGER_DEBUG);
if (!$keywords AND isset($data["keywords"]))
unset($data["keywords"]);
@@ -956,6 +975,32 @@ function add_page_info($url, $no_photos = false, $photo = "", $keywords = false,
}
}
+ return($data);
+}
+
+function add_page_keywords($url, $no_photos = false, $photo = "", $keywords = false, $keyword_blacklist = "") {
+ $data = query_page_info($url, $no_photos, $photo, $keywords, $keyword_blacklist);
+
+ $tags = "";
+ if (isset($data["keywords"]) AND count($data["keywords"])) {
+ $a = get_app();
+ foreach ($data["keywords"] AS $keyword) {
+ $hashtag = str_replace(array(" ", "+", "/", ".", "#", "'"),
+ array("","", "", "", "", ""), $keyword);
+
+ if ($tags != "")
+ $tags .= ",";
+
+ $tags .= "#[url=".$a->get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url]";
+ }
+ }
+
+ return($tags);
+}
+
+function add_page_info($url, $no_photos = false, $photo = "", $keywords = false, $keyword_blacklist = "") {
+ $data = query_page_info($url, $no_photos, $photo, $keywords, $keyword_blacklist);
+
$text = add_page_info_data($data);
return($text);
@@ -1027,7 +1072,7 @@ function encode_rel_links($links) {
-function item_store($arr,$force_parent = false, $notify = false) {
+function item_store($arr,$force_parent = false, $notify = false, $dontcache = false) {
// If it is a posting where users should get notifications, then define it as wall posting
if ($notify) {
@@ -1165,8 +1210,8 @@ function item_store($arr,$force_parent = false, $notify = false) {
$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 );
@@ -1194,6 +1239,9 @@ function item_store($arr,$force_parent = false, $notify = false) {
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;
@@ -1298,6 +1346,20 @@ function item_store($arr,$force_parent = false, $notify = false) {
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')) {
@@ -1305,6 +1367,9 @@ function item_store($arr,$force_parent = false, $notify = false) {
return 0;
}
+ // Store the unescaped version
+ $unescaped = $arr;
+
dbesc_array($arr);
logger('item_store: ' . print_r($arr,true), LOGGER_DATA);
@@ -1315,10 +1380,12 @@ function item_store($arr,$force_parent = false, $notify = false) {
. implode("', '", array_values($arr))
. "')" );
- // find the item we just created
+ // And restore it
+ $arr = $unescaped;
+ // find the item we just created
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d ORDER BY `id` ASC ",
- $arr['uri'], // already dbesc'd
+ dbesc($arr['uri']),
intval($arr['uid'])
);
@@ -1326,57 +1393,23 @@ function item_store($arr,$force_parent = false, $notify = false) {
$current_post = $r[0]['id'];
logger('item_store: created item ' . $current_post);
- // 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'])
+ // 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.
+ // Don't set this value if it isn't from the owner (could be an author that we don't know)
+ if (!$arr['private'] AND (($arr["author-link"] === $arr["owner-link"]) OR ($arr["parent-uri"] === $arr["uri"])))
+ q("UPDATE `contact` SET `success_update` = '%s' WHERE `id` = %d",
+ dbesc($arr['received']),
+ intval($arr['contact-id'])
);
-
- 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 ",
- $arr['uri'],
+ dbesc($arr['uri']),
intval($arr['uid']),
intval($current_post)
);
@@ -1418,13 +1451,18 @@ function item_store($arr,$force_parent = false, $notify = false) {
$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') ",
@@ -1450,39 +1488,157 @@ function item_store($arr,$force_parent = false, $notify = false) {
$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) {
-
- // 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);
- }
+ if (!$deleted AND !$dontcache) {
$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);
- }
}
+ // 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))
@@ -2008,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);
@@ -2023,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'];
}
@@ -2036,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;
@@ -2093,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'])
@@ -2117,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);
@@ -2163,7 +2336,6 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
$contact['bdyear'] = substr($birthday,0,4);
}
-
}
$community_page = 0;
@@ -2645,20 +2817,24 @@ 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;
$datarray2 = $datarray;
logger('remote-self start - Contact '.$contact['url'].' - '.$contact['remote_self'].' Item '.print_r($datarray, true), LOGGER_DEBUG);
if ($contact['remote_self'] == 2) {
- $r = q("SELECT `id`,`url`,`name`,`photo`,`network` FROM `contact` WHERE `uid` = %d AND `self`",
+ $r = q("SELECT `id`,`url`,`name`,`thumb` FROM `contact` WHERE `uid` = %d AND `self`",
intval($contact['uid']));
if (count($r)) {
$datarray['contact-id'] = $r[0]["id"];
$datarray['owner-name'] = $r[0]["name"];
$datarray['owner-link'] = $r[0]["url"];
- $datarray['owner-avatar'] = $r[0]["avatar"];
+ $datarray['owner-avatar'] = $r[0]["thumb"];
$datarray['author-name'] = $datarray['owner-name'];
$datarray['author-link'] = $datarray['owner-link'];
@@ -2725,6 +2901,7 @@ function local_delivery($importer,$data) {
$new_name = '';
$photo_timestamp = '';
$photo_url = '';
+ $contact_updated = '';
$rawtags = $feed->get_feed_tags( NAMESPACE_DFRN, 'owner');
@@ -2738,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;
@@ -2804,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'])
@@ -2828,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' );
@@ -2867,6 +3058,7 @@ function local_delivery($importer,$data) {
thumb = '%s',
micro = '%s',
url = '%s',
+ nurl = '%s',
request = '%s',
confirm = '%s',
notify = '%s',
@@ -2878,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']),
@@ -4037,6 +4230,7 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) {
else
$body = $item['body'];
+
$o = "\r\n\r\n\r\n";
if(is_array($author))
@@ -4051,13 +4245,22 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) {
$o .= '' . "\r\n";
}
+ $htmlbody = $body;
+
+ if ($item['title'] != "")
+ $htmlbody = "[b]".$item['title']."[/b]\n\n".$htmlbody;
+
+ $htmlbody = bbcode(bb_remove_share_information($htmlbody), false, false, 7);
+
$o .= '' . xmlify($item['uri']) . '' . "\r\n";
$o .= '' . xmlify($item['title']) . '' . "\r\n";
$o .= '' . xmlify(datetime_convert('UTC','UTC',$item['created'] . '+00:00',ATOM_TIME)) . '' . "\r\n";
$o .= '' . xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)) . '' . "\r\n";
$o .= '' . base64url_encode($body, true) . '' . "\r\n";
- $o .= '' . xmlify((($type === 'html') ? bbcode($body) : $body)) . '' . "\r\n";
+ $o .= '' . xmlify((($type === 'html') ? $htmlbody : $body)) . '' . "\r\n";
$o .= '' . "\r\n";
+
+
if($comment)
$o .= '' . intval($item['last-child']) . '' . "\r\n";
@@ -4475,7 +4678,7 @@ function drop_item($id,$interactive = true) {
);
create_tags_from_item($item['id']);
create_files_from_item($item['id']);
- delete_thread($item['id']);
+ delete_thread($item['id'], $item['parent-uri']);
// clean up categories and tags so they don't end up as orphans
@@ -4569,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/lock.php b/include/lock.php
index caf1f855a..70cf4b787 100644
--- a/include/lock.php
+++ b/include/lock.php
@@ -11,20 +11,22 @@ function lock_function($fn_name, $block = true, $wait_sec = 2, $timeout = 30) {
$start = time();
do {
- q("LOCK TABLE locks WRITE");
- $r = q("SELECT locked FROM locks WHERE name = '%s' LIMIT 1",
+ q("LOCK TABLE `locks` WRITE");
+ $r = q("SELECT `locked`, `created` FROM `locks` WHERE `name` = '%s' LIMIT 1",
dbesc($fn_name)
);
- if((count($r)) && (! $r[0]['locked'])) {
- q("UPDATE locks SET locked = 1 WHERE name = '%s'",
+ if((count($r)) AND (!$r[0]['locked'] OR (strtotime($r[0]['created']) < time() - 3600))) {
+ q("UPDATE `locks` SET `locked` = 1, `created` = '%s' WHERE `name` = '%s'",
+ dbesc(datetime_convert()),
dbesc($fn_name)
);
$got_lock = true;
}
elseif(! $r) { // the Boolean value for count($r) should be equivalent to the Boolean value of $r
- q("INSERT INTO locks ( name, locked ) VALUES ( '%s', 1 )",
- dbesc($fn_name)
+ q("INSERT INTO `locks` (`name`, `created`, `locked`) VALUES ('%s', '%s', 1)",
+ dbesc($fn_name),
+ dbesc(datetime_convert())
);
$got_lock = true;
}
@@ -37,7 +39,7 @@ function lock_function($fn_name, $block = true, $wait_sec = 2, $timeout = 30) {
} while(($block) && (! $got_lock) && ((time() - $start) < $timeout));
logger('lock_function: function ' . $fn_name . ' with blocking = ' . $block . ' got_lock = ' . $got_lock . ' time = ' . (time() - $start), LOGGER_DEBUG);
-
+
return $got_lock;
}}
@@ -65,7 +67,7 @@ function block_on_function_lock($fn_name, $wait_sec = 2, $timeout = 30) {
if(! function_exists('unlock_function')) {
function unlock_function($fn_name) {
- $r = q("UPDATE locks SET locked = 0 WHERE name = '%s'",
+ $r = q("UPDATE `locks` SET `locked` = 0, `created` = '0000-00-00 00:00:00' WHERE `name` = '%s'",
dbesc($fn_name)
);
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
-
-
-
-
-
-