]> git.mxchange.org Git - friendica.git/blobdiff - include/items.php
pull request #91 fabrixxm (manual merge)
[friendica.git] / include / items.php
index 5969466813a0d1b406a8319c3802abfc4ef6a007..733cd8048410911943cc79d867b3c306e85695ac 100644 (file)
@@ -477,10 +477,12 @@ function get_atom_elements($feed,$item) {
        if($attach) {
                $att_arr = array();
                foreach($attach as $att) {
-                       $len = intval($att->get_length());
-                       $link = str_replace(',','%2D', notags(trim($att->get_link())));
-                       $title = str_replace(',','%2D',notags(trim($att->get_title())));
-                       $type = notags(trim($att->get_type()));
+                       $len   = intval($att->get_length());
+                       $link  = str_replace(array(',','"'),array('%2D','%22'),notags(trim(unxmlify($att->get_link()))));
+                       $title = str_replace(array(',','"'),array('%2D','%22'),notags(trim(unxmlify($att->get_title()))));
+                       $type  = str_replace(array(',','"'),array('%2D','%22'),notags(trim(unxmlify($att->get_type()))));
+                       if(strpos($type,';'))
+                               $type = substr($type,0,strpos($type,';'));
                        if((! $link) || (strpos($link,'http') !== 0))
                                continue;
 
@@ -489,9 +491,7 @@ function get_atom_elements($feed,$item) {
                        if(! $type)
                                $type = 'application/octet-stream';
 
-                       // this isn't legal html - there is no size in an 'a' tag, remember to strip it before display
-
-                       $att_arr[] = '<a href="' . $link . '" size="' . $len . '" type="' . $type . '">' . $title . '</a>'; 
+                       $att_arr[] = '[attach]href="' . $link . '" size="' . $len . '" type="' . $type . '" title="' . $title . '"[/attach]'; 
                }
                $res['attach'] = implode(',', $att_arr);
        }
@@ -867,14 +867,14 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
        if($dissolve)
                $postvars['dissolve'] = '1';
 
-       if(($contact['rel']) && ($contact['rel'] != REL_FAN) && (! $contact['blocked']) && (! $contact['readonly'])) {
-               $postvars['data'] = $atom;
-       }
-       elseif($owner['page-flags'] == PAGE_COMMUNITY) {
+
+       if((($contact['rel']) && ($contact['rel'] != REL_FAN) && (! $contact['blocked'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) {
                $postvars['data'] = $atom;
+               $postvars['perm'] = 'rw';
        }
        else {
                $postvars['data'] = str_replace('<dfrn:comment-allow>1','<dfrn:comment-allow>0',$atom);
+               $postvars['perm'] = 'r';
        }
 
        if($rino && $rino_allowed && (! $dissolve)) {
@@ -916,7 +916,6 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
        if((! $curl_stat) || (! strlen($xml)))
                return(-1); // timed out
 
-
        if(strpos($xml,'<?xml') === false) {
                logger('dfrn_deliver: phase 2: no valid XML returned');
                logger('dfrn_deliver: phase 2: returned XML: ' . $xml, LOGGER_DATA);
@@ -925,8 +924,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
 
        $res = parse_xml_string($xml);
 
-       return $res->status;
+       return $res->status; 
 }
 
 
@@ -1369,8 +1367,8 @@ function new_follower($importer,$contact,$datarray,$item) {
                // create contact record - set to readonly
 
                $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `name`, `nick`, `photo`, `network`, `rel`, 
-                       `blocked`, `readonly`, `pending` )
-                       VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, 0, 1, 1 ) ",
+                       `blocked`, `readonly`, `pending`, `writable` )
+                       VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, 0, 1, 1, 1 ) ",
                        intval($importer['uid']),
                        dbesc(datetime_convert()),
                        dbesc($url),
@@ -1417,7 +1415,9 @@ function new_follower($importer,$contact,$datarray,$item) {
                                $res = mail($r[0]['email'], 
                                        t("You have a new follower at ") . $a->config['sitename'],
                                        $email,
-                                       'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] );
+                                       'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n"
+                                       . 'Content-type: text/plain; charset=UTF-8' . "\n"
+                                       . 'Content-transfer-encoding: 8bit' );
                        
                        }
                }
@@ -1590,13 +1590,13 @@ function item_getfeedattach($item) {
        if(count($arr)) {
                foreach($arr as $r) {
                        $matches = false;
-                       $cnt = preg_match('|\<a href=\"(.+?)\" size=\"(.+?)\" type=\"(.+?)\" >(.+?)</a>|',$r,$matches);
+                       $cnt = preg_match('|\[attach\]href=\"(.+?)\" size=\"(.+?)\" type=\"(.+?)\" title=\"(.+?)\"\[\/attach\]|',$r,$matches);
                        if($cnt) {
                                $ret .= '<link rel="enclosure" href="' . xmlify($matches[1]) . '" type="' . xmlify($matches[3]) . '" ';
                                if(intval($matches[2]))
                                        $ret .= 'size="' . intval($matches[2]) . '" ';
                                if($matches[4] !== ' ')
-                                       $ret .= 'title="' . xmlify($matches[4]) . '" ';
+                                       $ret .= 'title="' . xmlify(trim($matches[4])) . '" ';
                                $ret .= ' />' . "\r\n";
                        }
                }