]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #1645 from annando/1506-api
authorTobias Diekershoff <tobias.diekershoff@gmx.net>
Tue, 2 Jun 2015 20:47:41 +0000 (22:47 +0200)
committerTobias Diekershoff <tobias.diekershoff@gmx.net>
Tue, 2 Jun 2015 20:47:41 +0000 (22:47 +0200)
Small change in the API (some new Twitter fields - but without function)

boot.php
database.sql
htconfig.php
include/bbcode.php
include/dbstructure.php
include/items.php
include/oembed.php
mod/directory.php
mod/item.php
mod/poco.php
update.php

index 5994b2030ac21c5aa2c045ade6bcb0524758c945..465bec6775cb5f9e8be98392be2be5acab61b3c8 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -18,7 +18,7 @@ define ( 'FRIENDICA_PLATFORM',     'Friendica');
 define ( 'FRIENDICA_CODENAME',     'Lily of the valley');
 define ( 'FRIENDICA_VERSION',      '3.4.0' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.23'    );
-define ( 'DB_UPDATE_VERSION',      1184      );
+define ( 'DB_UPDATE_VERSION',      1185      );
 define ( 'EOL',                    "<br />\r\n"     );
 define ( 'ATOM_TIME',              'Y-m-d\TH:i:s\Z' );
 
index ab597825cd2ca653a228da81700258935c1ca705..b65dee657b0dc5acadb37afd287dd3ec3de36d76 100644 (file)
@@ -1,6 +1,6 @@
 -- ------------------------------------------
 -- Friendica 3.4.0 (Lily of the valley)
--- DB_UPDATE_VERSION 1183
+-- DB_UPDATE_VERSION 1185
 -- ------------------------------------------
 
 
@@ -358,7 +358,12 @@ CREATE TABLE IF NOT EXISTS `group_member` (
 CREATE TABLE IF NOT EXISTS `guid` (
        `id` int(10) unsigned NOT NULL auto_increment PRIMARY KEY,
        `guid` varchar(255) NOT NULL DEFAULT '',
-        INDEX `guid` (`guid`)
+       `plink` varchar(255) NOT NULL DEFAULT '',
+       `uri` varchar(255) NOT NULL DEFAULT '',
+       `network` varchar(32) NOT NULL DEFAULT '',
+        INDEX `guid` (`guid`),
+        INDEX `plink` (`plink`),
+        INDEX `uri` (`uri`)
 ) DEFAULT CHARSET=utf8;
 
 --
@@ -587,6 +592,7 @@ CREATE TABLE IF NOT EXISTS `notify` (
        `msg` mediumtext NOT NULL,
        `uid` int(11) NOT NULL DEFAULT 0,
        `link` varchar(255) NOT NULL DEFAULT '',
+       `iid` int(11) NOT NULL DEFAULT 0,
        `parent` int(11) NOT NULL DEFAULT 0,
        `seen` tinyint(1) NOT NULL DEFAULT 0,
        `verb` varchar(255) NOT NULL DEFAULT '',
index 4208924cfd3f2d510288e16b8ca387d8776eb6e6..4c88b6e742dbc70fa8edf38a6af0c1016f2d5432 100644 (file)
@@ -94,3 +94,7 @@ $a->config['system']['lockpath'] = "";
 
 // Use the old style "share"
 // $a->config['system']['old_share'] = false;
+
+//Deny public access to the local directory
+//$a->config['system']['block_local_dir'] = false;
+
index 01a141956797c17b53d45c6a7f0133d67da3d56c..6c7f39a9ffd6c0ca7ee9808fd3b938d91ac294b5 100644 (file)
@@ -1180,13 +1180,13 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
 
                $Text = preg_replace("/\[event\-summary\](.*?)\[\/event\-summary\]/ism",'',$Text);
                $Text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/ism",'',$Text);
-               $Text = preg_replace("/\[event\-start\](.*?)\[\/event\-start\]/ism",$sub,$Text); 
+               $Text = preg_replace("/\[event\-start\](.*?)\[\/event\-start\]/ism",$sub,$Text);
                $Text = preg_replace("/\[event\-finish\](.*?)\[\/event\-finish\]/ism",'',$Text);
                $Text = preg_replace("/\[event\-location\](.*?)\[\/event\-location\]/ism",'',$Text);
                $Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/ism",'',$Text);
        }
 
-       // Unhide all [noparse] contained bbtags unspacefying them 
+       // Unhide all [noparse] contained bbtags unspacefying them
        // and triming the [noparse] tag.
 
        $Text = preg_replace_callback("/\[noparse\](.*?)\[\/noparse\]/ism", 'bb_unspacefy_and_trim',$Text);
@@ -1200,7 +1200,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
 
        // fix any escaped ampersands that may have been converted into links
        $Text = preg_replace("/\<([^>]*?)(src|href)=(.*?)\&amp\;(.*?)\>/ism",'<$1$2=$3&$4>',$Text);
-       $Text = preg_replace("/\<([^>]*?)(src|href)=\"(?!http|ftp|mailto|cid)(.*?)\>/ism",'<$1$2="">',$Text);
+//     $Text = preg_replace("/\<([^>]*?)(src|href)=\"(?!http|ftp|mailto|cid)(.*?)\>/ism",'<$1$2="">',$Text);
 
        if($saved_image)
                $Text = bb_replace_images($Text, $saved_image);
index 3a6e0705d0debf49105c2d9d2287aefb6c741497..0f81ee6249e8a2cb824acb85e0ebc6c6619dc229 100644 (file)
@@ -687,10 +687,15 @@ function db_definition() {
                        "fields" => array(
                                        "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
                                        "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
+                                       "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
+                                       "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
+                                       "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
                                        ),
                        "indexes" => array(
                                        "PRIMARY" => array("id"),
                                        "guid" => array("guid"),
+                                       "plink" => array("plink"),
+                                       "uri" => array("uri"),
                                        )
                        );
        $database["hook"] = array(
index 87a7daea0b42407a0dc1af8918c0ee1661ddcbd7..588bd353f7d27cb6c63b4c706f19ba33ecb6fda3 100644 (file)
@@ -1099,7 +1099,15 @@ function encode_rel_links($links) {
        return xmlify($o);
 }
 
+function add_guid($item) {
+       $r = q("SELECT `guid` FROM `guid` WHERE `guid` = '%s' LIMIT 1", dbesc($item["guid"]));
+       if ($r)
+               return;
 
+       q("INSERT INTO `guid` (`guid`,`plink`,`uri`,`network`) VALUES ('%s','%s','%s','%s')",
+               dbesc($item["guid"]), dbesc($item["plink"]),
+               dbesc($item["uri"]), dbesc($item["network"]));
+}
 
 function item_store($arr,$force_parent = false, $notify = false, $dontcache = false) {
 
@@ -1168,11 +1176,10 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
        }
 
        // If there is no guid then take the same guid that was taken before for the same uri
-       if ((trim($arr['guid']) == "") AND (trim($arr['uri']) != "")) {
+       if ((trim($arr['guid']) == "") AND (trim($arr['uri']) != "") AND (trim($arr['network']) != "")) {
                logger('item_store: checking for an existing guid for uri '.$arr['uri'], LOGGER_DEBUG);
-               $r = q("SELECT `guid` FROM `item` WHERE `uri` = '%s' AND `guid` != '' LIMIT 1",
-                       dbesc(trim($arr['uri']))
-               );
+               $r = q("SELECT `guid` FROM `guid` WHERE `uri` = '%s' AND `network` = '%s' LIMIT 1",
+                       dbesc(trim($arr['uri'])), dbesc(trim($arr['network'])));
 
                if(count($r)) {
                        $arr['guid'] = $r[0]["guid"];
@@ -1181,11 +1188,10 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
        }
 
        // If there is no guid then take the same guid that was taken before for the same plink
-       if ((trim($arr['guid']) == "") AND (trim($arr['plink']) != "")) {
+       if ((trim($arr['guid']) == "") AND (trim($arr['plink']) != "") AND (trim($arr['network']) != "")) {
                logger('item_store: checking for an existing guid for plink '.$arr['plink'], LOGGER_DEBUG);
-               $r = q("SELECT `guid` FROM `item` WHERE `plink` = '%s' AND `guid` != '' LIMIT 1",
-                       dbesc(trim($arr['plink']))
-               );
+               $r = q("SELECT `guid` FROM `guid` WHERE `plink` = '%s' AND `network` = '%s' LIMIT 1",
+                       dbesc(trim($arr['plink'])), dbesc(trim($arr['network'])));
 
                if(count($r)) {
                        $arr['guid'] = $r[0]["guid"];
@@ -1476,6 +1482,10 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
        );
 
        if(count($r)) {
+
+               // Store the guid and other relevant data
+               add_guid($arr);
+
                $current_post = $r[0]['id'];
                logger('item_store: created item ' . $current_post);
 
@@ -1697,12 +1707,12 @@ function item_body_set_hashtags(&$item) {
        // 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("#", "&num;", $match[2])."[/url]");
+                       return("[url=".str_replace("#", "&num;", $match[1])."]".str_replace("#", "&num;", $match[2])."[/url]");
                },$item["body"]);
 
        $item["body"] = preg_replace_callback("/\[bookmark\=([$URLSearchString]*)\](.*?)\[\/bookmark\]/ism",
                function ($match){
-                       return("[bookmark=".$match[1]."]".str_replace("#", "&num;", $match[2])."[/bookmark]");
+                       return("[bookmark=".str_replace("#", "&num;", $match[1])."]".str_replace("#", "&num;", $match[2])."[/bookmark]");
                },$item["body"]);
 
        $item["body"] = preg_replace_callback("/\[attachment (.*)\](.*?)\[\/attachment\]/ism",
@@ -1714,6 +1724,7 @@ function item_body_set_hashtags(&$item) {
        $item["body"] = preg_replace("/&num;\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
                        "&num;$2", $item["body"]);
 
+
        foreach($tags as $tag) {
                if(strpos($tag,'#') !== 0)
                        continue;
@@ -4956,17 +4967,17 @@ function first_post_date($uid,$wall = false) {
 /* modified posted_dates() {below} to arrange the list in years */
 function list_post_dates($uid, $wall) {
        $dnow = datetime_convert('',date_default_timezone_get(),'now','Y-m-d');
-       
-       $dthen = first_post_date($uid, $wall);        
+
+       $dthen = first_post_date($uid, $wall);
        if(! $dthen)
                return array();
-        
+
        // Set the start and end date to the beginning of the month
         $dnow = substr($dnow,0,8).'01';
        $dthen = substr($dthen,0,8).'01';
-        
+
        $ret = array();
-        
+
        // Starting with the current month, get the first and last days of every
        // month down to and including the month of the first post
        while(substr($dnow, 0, 7) >= substr($dthen, 0, 7)) {
@@ -5021,19 +5032,19 @@ function posted_date_widget($url,$uid,$wall) {
 
 /*     if($wall && intval(get_pconfig($uid,'system','no_wall_archive_widget')))
                return $o;*/
-        
+
        $visible_years = get_pconfig($uid,'system','archive_visible_years');
        if(! $visible_years)
-               $visible_years = 5;     
-        
+               $visible_years = 5;
+
         $ret = list_post_dates($uid,$wall);
-        
+
        if(! count($ret))
                return $o;
 
         $cutoff_year = intval(datetime_convert('',date_default_timezone_get(),'now','Y')) - $visible_years;
        $cutoff = ((array_key_exists($cutoff_year,$ret))? true : false);
-        
+
        $o = replace_macros(get_markup_template('posted_date_widget.tpl'),array(
                '$title' => t('Archives'),
                '$size' => $visible_years,
index 6fc981729944a29323b969bb6fcdf78ba1de1b4c..26746af51c17e13d637c4c177940abec99dc5489 100755 (executable)
@@ -193,8 +193,9 @@ function oembed_format_object($j){
        } else {
                // add <a> for html2bbcode conversion
                $ret .= "<a href='$embedurl' rel='oembed'>$embedurl</a>";
-               $ret.="<br style='clear:left'></span>";
+               $ret .= "<br style='clear:left'>";
        }
+       $ret.="</span>";
        return  mb_convert_encoding($ret, 'HTML-ENTITIES', mb_detect_encoding($ret));
 }
 
index 7fab53b6807cadd363da70227b1f3c3a6679e5aa..b13e17627a8dd6fd347d6e46a23b54efc3d902ca 100644 (file)
@@ -29,7 +29,8 @@ function directory_content(&$a) {
 
        require_once("mod/proxy.php");
 
-       if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+       if((get_config('system','block_public')) && (! local_user()) && (! remote_user()) || 
+                (get_config('system','block_local_dir')) && (! local_user()) && (! remote_user())) {
                notice( t('Public access denied.') . EOL);
                return;
        }
index 27bd5108d2df7dfe95c08c7089428b96b798aaa8..b104663e9e34448be70e5ab30408688db4aab424 100644 (file)
@@ -864,6 +864,9 @@ function item_post(&$a) {
                // NOTREACHED
        }
 
+       // Store the guid and other relevant data
+       add_guid($datarray);
+
        $post_id = $r[0]['id'];
        logger('mod_item: saved item ' . $post_id);
 
index 86b43d651dc916e9ac6c19920a3b993a4e394c4e..89f2f879a05c1763b30358e62591fe0a935b614a 100644 (file)
@@ -5,7 +5,7 @@ function poco_init(&$a) {
 
        $system_mode = false;
 
-       if(intval(get_config('system','block_public')))
+       if(intval(get_config('system','block_public')) || (get_config('system','block_local_dir')))
                http_status_exit(401);
 
 
index ca86c8557e494b5328af2c93fb1db3fa405b1781..c182eb590e1fbe49b3beb605c6392f1940875d89 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-define( 'UPDATE_VERSION' , 1184 );
+define( 'UPDATE_VERSION' , 1185 );
 
 /**
  *