- do {
- $dups = false;
- $item_hash = random_string();
-
- $uri = "urn:X-dfrn:" . $a->get_hostname() . ':' . $_SESSION['uid'] . ':' . $item_hash;
-
- $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
- dbesc($uri));
- if(count($r))
- $dups = true;
- } while($dups == true);
-
-
- $r = q("INSERT INTO `item` (`uid`, `type`, `resource-id`, `contact-id`,
- `owner-name`,`owner-link`,`owner-avatar`, `created`,
- `edited`, `uri`, `parent-uri`, `title`, `body`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`)
- VALUES( %d, '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
- intval($_SESSION['uid']),
- dbesc('photo'),
- dbesc($p[0]['resource-id']),
- intval($contact_record['id']),
- dbesc($contact_record['name']),
- dbesc($contact_record['url']),
- dbesc($contact_record['thumb']),
- datetime_convert(),
- datetime_convert(),
- dbesc($uri),
- dbesc($uri),
- dbesc($title),
- dbesc($body),
- dbesc($p[0]['allow_cid']),
- dbesc($p[0]['allow_gid']),
- dbesc($p[0]['deny_cid']),
- dbesc($p[0]['deny_gid'])
+ if(strlen($rawtags)) {
+
+ $str_tags = '';
+ $inform = '';
+
+ // if the new tag doesn't have a namespace specifier (@foo or #foo) give it a hashtag
+
+ $x = substr($rawtags,0,1);
+ if($x !== '@' && $x !== '#')
+ $rawtags = '#' . $rawtags;
+
+ $taginfo = array();
+ $tags = get_tags($rawtags);
+
+ if(count($tags)) {
+ foreach($tags as $tag) {
+ 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') {
+ $salmon = '$url:' . str_replace(',','%sc',$link['@attributes']['href']);
+ if(strlen($inform))
+ $inform .= ',';
+ $inform .= $salmon;
+ }
+ }
+ }
+ $taginfo[] = array($newname,$profile,$salmon);
+ }
+ 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($page_owner_uid)
+ );
+ }
+ else {
+ $r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($name),
+ intval($page_owner_uid)
+ );
+ }
+ if(count($r)) {
+ $newname = $r[0]['name'];
+ $profile = $r[0]['url'];
+ $notify = 'cid:' . $r[0]['id'];
+ if(strlen($inform))
+ $inform .= ',';
+ $inform .= $notify;
+ }
+ }
+ if($profile) {
+ if(substr($notify,0,4) === 'cid:')
+ $taginfo[] = array($newname,$profile,$notify,$r[0],'@[url=' . str_replace(',','%2c',$profile) . ']' . $newname . '[/url]');
+ else
+ $taginfo[] = array($newname,$profile,$notify,null,$str_tags .= '@[url=' . $profile . ']' . $newname . '[/url]');
+ if(strlen($str_tags))
+ $str_tags .= ',';
+ $profile = str_replace(',','%2c',$profile);
+ $str_tags .= '@[url=' . $profile . ']' . $newname . '[/url]';
+ }
+ }
+ }
+ }