Merge remote-tracking branch 'upstream/develop' into 1503-load-issues
This commit is contained in:
@@ -46,6 +46,10 @@ function user_remove($uid) {
|
||||
// q("DELETE FROM `user` WHERE `uid` = %d", intval($uid));
|
||||
q("UPDATE `user` SET `account_removed` = 1, `account_expires_on` = UTC_TIMESTAMP() WHERE `uid` = %d", intval($uid));
|
||||
proc_run('php', "include/notifier.php", "removeme", $uid);
|
||||
|
||||
// Send an update to the directory
|
||||
proc_run('php', "include/directory.php", $r[0]['url']);
|
||||
|
||||
if($uid == local_user()) {
|
||||
unset($_SESSION['authenticated']);
|
||||
unset($_SESSION['uid']);
|
||||
|
||||
@@ -364,17 +364,6 @@ function probe_url($url, $mode = PROBE_NORMAL) {
|
||||
$network = NETWORK_TWITTER;
|
||||
}
|
||||
|
||||
if (strpos($url,'www.facebook.com')) {
|
||||
$connectornetworks = true;
|
||||
$network = NETWORK_FACEBOOK;
|
||||
}
|
||||
|
||||
if (strpos($url,'alpha.app.net')) {
|
||||
$appnet = true;
|
||||
$network = NETWORK_APPNET;
|
||||
}
|
||||
|
||||
|
||||
// Twitter is deactivated since twitter closed its old API
|
||||
//$twitter = ((strpos($url,'twitter.com') !== false) ? true : false);
|
||||
$lastfm = ((strpos($url,'last.fm/user') !== false) ? true : false);
|
||||
|
||||
+60
-15
@@ -7,6 +7,9 @@
|
||||
require_once("include/conversation.php");
|
||||
require_once("include/oauth.php");
|
||||
require_once("include/html2plain.php");
|
||||
require_once("mod/share.php");
|
||||
require_once("include/Photo.php");
|
||||
|
||||
/*
|
||||
* Twitter-Like API
|
||||
*
|
||||
@@ -821,6 +824,18 @@
|
||||
$_REQUEST['body'] .= "\n\n".$media;
|
||||
}
|
||||
|
||||
// To-Do: Multiple IDs
|
||||
if (requestdata('media_ids')) {
|
||||
$r = q("SELECT `resource-id`, `scale`, `nickname`, `type` FROM `photo` INNER JOIN `user` ON `user`.`uid` = `photo`.`uid` WHERE `resource-id` IN (SELECT `resource-id` FROM `photo` WHERE `id` = %d) AND `scale` > 0 AND `photo`.`uid` = %d ORDER BY `photo`.`width` DESC LIMIT 1",
|
||||
intval(requestdata('media_ids')), api_user());
|
||||
if ($r) {
|
||||
$phototypes = Photo::supportedTypes();
|
||||
$ext = $phototypes[$r[0]['type']];
|
||||
$_REQUEST['body'] .= "\n\n".'[url='.$a->get_baseurl().'/photos/'.$r[0]['nickname'].'/image/'.$r[0]['resource-id'].']';
|
||||
$_REQUEST['body'] .= '[img]'.$a->get_baseurl()."/photo/".$r[0]['resource-id']."-".$r[0]['scale'].".".$ext."[/img][/url]";
|
||||
}
|
||||
}
|
||||
|
||||
// set this so that the item_post() function is quiet and doesn't redirect or emit json
|
||||
|
||||
$_REQUEST['api_source'] = true;
|
||||
@@ -840,6 +855,41 @@
|
||||
api_register_func('api/statuses/update_with_media','api_statuses_update', true);
|
||||
|
||||
|
||||
function api_media_upload(&$a, $type) {
|
||||
if (api_user()===false) {
|
||||
logger('no user');
|
||||
return false;
|
||||
}
|
||||
|
||||
$user_info = api_get_user($a);
|
||||
|
||||
if(!x($_FILES,'media')) {
|
||||
// Output error
|
||||
return false;
|
||||
}
|
||||
|
||||
require_once('mod/wall_upload.php');
|
||||
$media = wall_upload_post($a, false);
|
||||
if(!$media) {
|
||||
// Output error
|
||||
return false;
|
||||
}
|
||||
|
||||
$returndata = array();
|
||||
$returndata["media_id"] = $media["id"];
|
||||
$returndata["media_id_string"] = (string)$media["id"];
|
||||
$returndata["size"] = $media["size"];
|
||||
$returndata["image"] = array("w" => $media["width"],
|
||||
"h" => $media["height"],
|
||||
"image_type" => $media["type"]);
|
||||
|
||||
logger("Media uploaded: ".print_r($returndata, true), LOGGER_DEBUG);
|
||||
|
||||
return array("media" => $returndata);
|
||||
}
|
||||
|
||||
api_register_func('api/media/upload','api_media_upload', true);
|
||||
|
||||
function api_status_show(&$a, $type){
|
||||
$user_info = api_get_user($a);
|
||||
|
||||
@@ -1129,15 +1179,15 @@
|
||||
|
||||
$ret = api_format_items($r,$user_info);
|
||||
|
||||
// We aren't going to try to figure out at the item, group, and page
|
||||
// level which items you've seen and which you haven't. If you're looking
|
||||
// at the network timeline just mark everything seen.
|
||||
// Set all posts from the query above to seen
|
||||
$idarray = array();
|
||||
foreach ($r AS $item)
|
||||
$idarray[] = intval($item["id"]);
|
||||
|
||||
$r = q("UPDATE `item` SET `unseen` = 0
|
||||
WHERE `unseen` = 1 AND `uid` = %d",
|
||||
//intval($user_info['uid'])
|
||||
intval(api_user())
|
||||
);
|
||||
$idlist = implode(",", $idarray);
|
||||
|
||||
if ($idlist != "")
|
||||
$r = q("UPDATE `item` SET `unseen` = 0 WHERE `unseen` AND `id` IN (%s)", $idlist);
|
||||
|
||||
|
||||
$data = array('$statuses' => $ret);
|
||||
@@ -1390,10 +1440,8 @@
|
||||
$pos = strpos($r[0]['body'], "[share");
|
||||
$post = substr($r[0]['body'], $pos);
|
||||
} else {
|
||||
$post = "[share author='".str_replace("'", "'", $r[0]['author-name']).
|
||||
"' profile='".$r[0]['author-link'].
|
||||
"' avatar='".$r[0]['author-avatar'].
|
||||
"' link='".$r[0]['plink']."']";
|
||||
$post = share_header($r[0]['author-name'], $r[0]['author-link'], $r[0]['author-avatar'], $r[0]['guid'], $r[0]['created'], $r[0]['plink']);
|
||||
|
||||
$post .= $r[0]['body'];
|
||||
$post .= "[/share]";
|
||||
}
|
||||
@@ -1877,8 +1925,6 @@
|
||||
if (!$ret)
|
||||
return false;
|
||||
|
||||
require_once("include/Photo.php");
|
||||
|
||||
$attachments = array();
|
||||
|
||||
foreach ($images[1] AS $image) {
|
||||
@@ -2004,7 +2050,6 @@
|
||||
|
||||
$start = iconv_strpos($text, $url, $offset, "UTF-8");
|
||||
if (!($start === false)) {
|
||||
require_once("include/Photo.php");
|
||||
$image = get_photo_info($url);
|
||||
if ($image) {
|
||||
// If image cache is activated, then use the following sizes:
|
||||
|
||||
+3
-5
@@ -42,7 +42,7 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
|
||||
$title = $matches[1];
|
||||
|
||||
//$title = htmlentities($title, ENT_QUOTES, 'UTF-8', false);
|
||||
$title = bbcode(html_entity_decode($title), false, false, true);
|
||||
$title = bbcode(html_entity_decode($title, ENT_QUOTES, 'UTF-8'), false, false, true);
|
||||
$title = str_replace(array("[", "]"), array("[", "]"), $title);
|
||||
|
||||
$image = "";
|
||||
@@ -509,9 +509,7 @@ function bb_ShareAttributes($share, $simplehtml) {
|
||||
$text = $preshare.html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').' '.$userid_compact.": <br />".$share[3];
|
||||
break;
|
||||
case 3: // Diaspora
|
||||
$headline = '<div class="shared_header">';
|
||||
$headline .= '<span><b>'.html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').$userid.':</b></span>';
|
||||
$headline .= "</div>";
|
||||
$headline .= '<b>'.html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').$userid.':</b><br />';
|
||||
|
||||
$text = trim($share[1]);
|
||||
|
||||
@@ -519,7 +517,7 @@ function bb_ShareAttributes($share, $simplehtml) {
|
||||
$text .= "<hr />";
|
||||
|
||||
if (substr(normalise_link($link), 0, 19) != "http://twitter.com/") {
|
||||
$text .= $headline.'<blockquote class="shared_content">'.trim($share[3])."</blockquote><br />";
|
||||
$text .= $headline.'<blockquote>'.trim($share[3])."</blockquote><br />";
|
||||
|
||||
if ($link != "")
|
||||
$text .= '<br /><a href="'.$link.'">[l]</a>';
|
||||
|
||||
+61
-33
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1357,7 +1363,29 @@ function dbstructure_run(&$argv, &$argc) {
|
||||
unset($db_host, $db_user, $db_pass, $db_data);
|
||||
}
|
||||
|
||||
update_structure(true, true);
|
||||
if ($argc==2) {
|
||||
switch ($argv[1]) {
|
||||
case "update":
|
||||
update_structure(true, true);
|
||||
return;
|
||||
case "dumpsql":
|
||||
print_structure(db_definition());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// print help
|
||||
echo $argv[0]." <command>\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){
|
||||
|
||||
+63
-32
@@ -6,6 +6,8 @@ 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');
|
||||
require_once('mod/share.php');
|
||||
|
||||
function diaspora_dispatch_public($msg) {
|
||||
|
||||
@@ -777,6 +779,18 @@ function diaspora_post_allow($importer,$contact) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function diaspora_plink($addr, $guid) {
|
||||
$r = q("SELECT `url`, `nick` FROM `fcontact` WHERE `addr`='%s' LIMIT 1", $addr);
|
||||
|
||||
// Fallback
|
||||
if (!$r)
|
||||
return 'https://'.substr($addr,strpos($addr,'@')+1).'/posts/'.$guid;
|
||||
|
||||
if (strstr($r[0]["url"], "/channel/"))
|
||||
return $r[0]["url"]."/?f=&mid=".$guid;
|
||||
|
||||
return 'https://'.substr($addr,strpos($addr,'@')+1).'/posts/'.$guid;
|
||||
}
|
||||
|
||||
function diaspora_post($importer,$xml,$msg) {
|
||||
|
||||
@@ -842,7 +856,7 @@ function diaspora_post($importer,$xml,$msg) {
|
||||
}
|
||||
}
|
||||
|
||||
$plink = 'https://'.substr($diaspora_handle,strpos($diaspora_handle,'@')+1).'/posts/'.$guid;
|
||||
$plink = diaspora_plink($diaspora_handle, $guid);
|
||||
|
||||
$datarray['uid'] = $importer['uid'];
|
||||
$datarray['contact-id'] = $contact['id'];
|
||||
@@ -935,7 +949,7 @@ function diaspora_store_by_guid($guid, $server) {
|
||||
$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['plink'] = diaspora_plink($author, $guid);
|
||||
$datarray['author-name'] = $person['name'];
|
||||
$datarray['author-link'] = $person['url'];
|
||||
$datarray['author-avatar'] = ((x($person,'thumb')) ? $person['thumb'] : $person['photo']);
|
||||
@@ -1148,7 +1162,7 @@ function diaspora_reshare($importer,$xml,$msg) {
|
||||
|
||||
$datarray = array();
|
||||
|
||||
$plink = 'https://'.substr($diaspora_handle,strpos($diaspora_handle,'@')+1).'/posts/'.$guid;
|
||||
$plink = diaspora_plink($diaspora_handle, $guid);
|
||||
|
||||
$datarray['uid'] = $importer['uid'];
|
||||
$datarray['contact-id'] = $contact['id'];
|
||||
@@ -1164,12 +1178,8 @@ function diaspora_reshare($importer,$xml,$msg) {
|
||||
$datarray['owner-link'] = $contact['url'];
|
||||
$datarray['owner-avatar'] = ((x($contact,'thumb')) ? $contact['thumb'] : $contact['photo']);
|
||||
if (!intval(get_config('system','wall-to-wall_share'))) {
|
||||
$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)."']";
|
||||
$prefix = share_header($person['name'], $person['url'], ((x($person,'thumb')) ? $person['thumb'] : $person['photo']), $orig_guid, $orig_created, $orig_url);
|
||||
|
||||
$datarray['author-name'] = $contact['name'];
|
||||
$datarray['author-link'] = $contact['url'];
|
||||
$datarray['author-avatar'] = $contact['thumb'];
|
||||
@@ -1198,8 +1208,8 @@ function diaspora_reshare($importer,$xml,$msg) {
|
||||
$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['changed'] = $datarray2['created'] = $datarray2['edited'] = $datarray2['commented'] = $datarray2['received'] = datetime_convert('UTC','UTC',$orig_created);
|
||||
$datarray2['plink'] = diaspora_plink($orig_author, $orig_guid);
|
||||
|
||||
$datarray2['author-name'] = $person['name'];
|
||||
$datarray2['author-link'] = $person['url'];
|
||||
@@ -1283,7 +1293,7 @@ function diaspora_asphoto($importer,$xml,$msg) {
|
||||
return;
|
||||
}
|
||||
|
||||
$plink = 'https://'.substr($diaspora_handle,strpos($diaspora_handle,'@')+1).'/posts/'.$guid;
|
||||
$plink = diaspora_plink($diaspora_handle, $guid);
|
||||
|
||||
$datarray = array();
|
||||
|
||||
@@ -1855,11 +1865,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;
|
||||
@@ -1934,7 +1945,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1950,26 +1961,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
|
||||
@@ -1977,13 +1990,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2510,6 +2521,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] != "")
|
||||
|
||||
@@ -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') ",
|
||||
|
||||
+8
-8
@@ -12,6 +12,7 @@ require_once('include/email.php');
|
||||
require_once('include/ostatus_conversation.php');
|
||||
require_once('include/threads.php');
|
||||
require_once('include/socgraph.php');
|
||||
require_once('mod/share.php');
|
||||
|
||||
function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) {
|
||||
|
||||
@@ -838,10 +839,7 @@ function get_atom_elements($feed, $item, $contact = array()) {
|
||||
logger('get_atom_elements: fixing sender of repeated message.');
|
||||
|
||||
if (!intval(get_config('system','wall-to-wall_share'))) {
|
||||
$prefix = "[share author='".str_replace("'", "'",$name).
|
||||
"' profile='".$uri.
|
||||
"' avatar='".$avatar.
|
||||
"' link='".$orig_uri."']";
|
||||
$prefix = share_header($name, $uri, $avatar, "", "", $orig_uri);
|
||||
|
||||
$res["body"] = $prefix.html2bbcode($message)."[/share]";
|
||||
} else {
|
||||
@@ -1183,9 +1181,9 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
|
||||
$arr['owner-avatar'] = ((x($arr,'owner-avatar')) ? notags(trim($arr['owner-avatar'])) : '');
|
||||
$arr['created'] = ((x($arr,'created') !== false) ? datetime_convert('UTC','UTC',$arr['created']) : datetime_convert());
|
||||
$arr['edited'] = ((x($arr,'edited') !== false) ? datetime_convert('UTC','UTC',$arr['edited']) : datetime_convert());
|
||||
$arr['commented'] = datetime_convert();
|
||||
$arr['received'] = datetime_convert();
|
||||
$arr['changed'] = datetime_convert();
|
||||
$arr['commented'] = ((x($arr,'commented') !== false) ? datetime_convert('UTC','UTC',$arr['commented']) : datetime_convert());
|
||||
$arr['received'] = ((x($arr,'received') !== false) ? datetime_convert('UTC','UTC',$arr['received']) : datetime_convert());
|
||||
$arr['changed'] = ((x($arr,'changed') !== false) ? datetime_convert('UTC','UTC',$arr['changed']) : datetime_convert());
|
||||
$arr['title'] = ((x($arr,'title')) ? notags(trim($arr['title'])) : '');
|
||||
$arr['location'] = ((x($arr,'location')) ? notags(trim($arr['location'])) : '');
|
||||
$arr['coord'] = ((x($arr,'coord')) ? notags(trim($arr['coord'])) : '');
|
||||
@@ -1561,8 +1559,10 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
|
||||
));
|
||||
logger('item_store: Notification sent for contact '.$arr['contact-id'].' and post '.$current_post, LOGGER_DEBUG);
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
update_thread($parent_id);
|
||||
add_shadow_entry($arr);
|
||||
}
|
||||
|
||||
if ($notify)
|
||||
proc_run('php', "include/notifier.php", $notify_type, $current_post);
|
||||
|
||||
@@ -37,6 +37,9 @@ function create_tags_from_item($itemid) {
|
||||
|
||||
$data = " ".$message["title"]." ".$message["body"]." ".$tags." ";
|
||||
|
||||
// ignore anything in a code block
|
||||
$data = preg_replace('/\[code\](.*?)\[\/code\]/sm','',$data);
|
||||
|
||||
$tags = array();
|
||||
|
||||
$pattern = "/\W\#([^\[].*?)[\s'\".,:;\?!\[\]\/]/ism";
|
||||
|
||||
+1
-1
@@ -270,7 +270,7 @@ if(! function_exists('paginate_data')) {
|
||||
* @return Array data for pagination template
|
||||
*/
|
||||
function paginate_data(&$a, $count=null) {
|
||||
$stripped = preg_replace('/(&page=[0-9]*)/','',$a->query_string);
|
||||
$stripped = preg_replace('/([&?]page=[0-9]*)/','',$a->query_string);
|
||||
|
||||
$stripped = str_replace('q=','',$stripped);
|
||||
$stripped = trim($stripped,'/');
|
||||
|
||||
@@ -74,6 +74,35 @@ function add_thread($itemid, $onlyshadow = false) {
|
||||
}
|
||||
}
|
||||
|
||||
function add_shadow_entry($item) {
|
||||
|
||||
// Is this a shadow entry?
|
||||
if ($item['uid'] == 0)
|
||||
return;
|
||||
|
||||
// Is there a shadow parent?
|
||||
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = 0 LIMIT 1", dbesc($item['parent-uri']));
|
||||
if (!count($r))
|
||||
return;
|
||||
|
||||
// Is there already a shadow entry?
|
||||
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = 0 LIMIT 1", dbesc($item['uri']));
|
||||
|
||||
if (count($r))
|
||||
return;
|
||||
|
||||
// Preparing public shadow (removing user specific data)
|
||||
require_once("include/items.php");
|
||||
require_once("include/Contact.php");
|
||||
|
||||
unset($item['id']);
|
||||
$item['uid'] = 0;
|
||||
$item['contact-id'] = get_contact($item['author-link'], 0);
|
||||
$public_shadow = item_store($item, false, false, true);
|
||||
|
||||
logger("Stored public shadow for comment ".$item['uri']." under id ".$public_shadow, LOGGER_DEBUG);
|
||||
}
|
||||
|
||||
function update_thread_uri($itemuri, $uid) {
|
||||
$messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user