]> git.mxchange.org Git - friendica.git/blobdiff - mod/item.php
use gravatar for default avatars
[friendica.git] / mod / item.php
index 39865cdafa47cc9a96a6622fa9f291559b829aad..430500f99876906ef5d4fe1d48d05f31c3748e44 100644 (file)
@@ -14,8 +14,7 @@ function item_post(&$a) {
 
        require_once('include/security.php');
 
-       $uid = $_SESSION['uid'];
-
+       $uid = local_user();
 
        $parent = ((x($_POST,'parent')) ? intval($_POST['parent']) : 0);
 
@@ -57,6 +56,7 @@ function item_post(&$a) {
        $title             = notags(trim($_POST['title']));
        $body              = escape_tags(trim($_POST['body']));
        $location          = notags(trim($_POST['location']));
+       $coord             = notags(trim($_POST['coord']));
        $verb              = notags(trim($_POST['verb']));
 
        if(! strlen($body)) {
@@ -113,6 +113,70 @@ function item_post(&$a) {
                }
        }
 
+       $str_tags = '';
+       $inform   = '';
+
+       $tags = get_tags($body);
+
+
+       if(count($tags)) {
+               foreach($tags as $tag) {
+                       if(strpos($tag,'#') === 0) {
+                               $basetag = substr($tag,1);
+                               $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?search=' . urlencode($basetag) . ']' . $basetag . '[/url]',$body);
+                               continue;
+                       }
+                       if(strpos($tag,'@') === 0) {
+                               $name = substr($tag,1);
+                               if((strpos($name,'@')) || (strpos($name,'http://'))) {
+                                       $newname = $name;
+                                       $links = @lrdd($name);
+                                       if(count($links)) {
+                                               foreach($links as $link) {
+                                                       if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page')
+                                       $profile = $link['@attributes']['href'];
+                                                       if($link['@attributes']['rel'] === 'salmon') {
+                                                               if(strlen($inform))
+                                                                       $inform .= ',';
+                                       $inform .= 'url:' . str_replace(',','%2c',$link['@attributes']['href']);
+                                                       }
+                                               }
+                                       }
+                               }
+                               else {
+                                       $newname = $name;
+                                       if(strstr($name,'_')) {
+                                               $newname = str_replace('_',' ',$name);
+                                               $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
+                                                       dbesc($newname),
+                                                       intval($profile_uid)
+                                               );
+                                       }
+                                       else {
+                                               $r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
+                                                       dbesc($name),
+                                                       intval($profile_uid)
+                                               );
+                                       }
+                                       if(count($r)) {
+                                               $profile = $r[0]['url'];
+                                               $newname = $r[0]['name'];
+                                               if(strlen($inform))
+                                                       $inform .= ',';
+                                               $inform .= 'cid:' . $r[0]['id'];
+                                       }
+                               }
+                               if($profile) {
+                                       $body = str_replace($name,'[url=' . $profile . ']' . $newname   . '[/url]', $body);
+                                       if(strlen($str_tags))
+                                               $str_tags .= ',';
+                                       $profile = str_replace(',','%2c',$profile);
+                                       $str_tags .= '@[url=' . $profile . ']' . $newname       . '[/url]';
+                               }
+                       }
+               }
+       }
+
        $wall = 0;
        if($post_type === 'wall' || $post_type === 'wall-comment')
                $wall = 1;
@@ -127,9 +191,9 @@ function item_post(&$a) {
        $uri = item_new_uri($a->get_hostname(),$profile_uid);
 
        $r = q("INSERT INTO `item` (`uid`,`type`,`wall`,`gravity`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`, 
-               `author-name`, `author-link`, `author-avatar`, `created`,
-               `edited`, `changed`, `uri`, `title`, `body`, `location`, `verb`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`)
-               VALUES( %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
+               `author-name`, `author-link`, `author-avatar`, `created`, `edited`, `changed`, `uri`, `title`, `body`, `location`, `coord`, 
+               `tag`, `inform`, `verb`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`)
+               VALUES( %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
                intval($profile_uid),
                dbesc($post_type),
                intval($wall),
@@ -148,6 +212,9 @@ function item_post(&$a) {
                dbesc($title),
                dbesc($body),
                dbesc($location),
+               dbesc($coord),
+               dbesc($str_tags),
+               dbesc($inform),
                dbesc($verb),
                dbesc($str_contact_allow),
                dbesc($str_group_allow),
@@ -190,6 +257,7 @@ function item_post(&$a) {
                                        '$username' => $user['username'],
                                        '$email' => $user['email'],
                                        '$from' => $from,
+                                       '$display' => $a->get_baseurl() . '/display/' . $post_id,
                                        '$body' => strip_tags(bbcode($body))
                                ));
 
@@ -212,6 +280,7 @@ function item_post(&$a) {
                                        '$username' => $user['username'],
                                        '$email' => $user['email'],
                                        '$from' => $from,
+                                       '$display' => $a->get_baseurl() . '/display/' . $post_id,
                                        '$body' => strip_tags(bbcode($body))
                                ));
 
@@ -240,9 +309,8 @@ function item_post(&$a) {
        }
 
        $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
-       $proc_debug = get_config('system','proc_debug');
 
-       proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"$notify_type\" \"$post_id\" $proc_debug &",
+       proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"$notify_type\" \"$post_id\" &",
                array(),$foo));
 
        goaway($a->get_baseurl() . "/" . $_POST['return'] );
@@ -329,12 +397,10 @@ function item_content(&$a) {
                        }
                        $drop_id = intval($item['id']);
                        $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
-                       $proc_debug = get_config('system','proc_debug');
-
                        
                        // send the notification upstream/downstream as the case may be
 
-                       proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"drop\" \"$drop_id\" $proc_debug &",
+                       proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"drop\" \"$drop_id\" &",
                                array(), $foo));
 
                        goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
@@ -343,7 +409,7 @@ function item_content(&$a) {
                else {
                        notice( t('Permission denied.') . EOL);
                        goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
-                       return; //NOTREACHED
+                       //NOTREACHED
                }
        }
 }
\ No newline at end of file