diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/acl.php | 115 | ||||
-rw-r--r-- | mod/admin.php | 2 | ||||
-rw-r--r-- | mod/common.php | 61 | ||||
-rw-r--r-- | mod/contacts.php | 5 | ||||
-rw-r--r-- | mod/dfrn_request.php | 22 | ||||
-rw-r--r-- | mod/display.php | 3 | ||||
-rw-r--r-- | mod/follow.php | 6 | ||||
-rw-r--r-- | mod/friendica.php | 68 | ||||
-rw-r--r-- | mod/friendika.php | 65 | ||||
-rw-r--r-- | mod/install.php | 8 | ||||
-rw-r--r-- | mod/item.php | 46 | ||||
-rw-r--r-- | mod/like.php | 3 | ||||
-rw-r--r-- | mod/network.php | 14 | ||||
-rw-r--r-- | mod/parse_url.php | 78 | ||||
-rw-r--r-- | mod/photos.php | 17 | ||||
-rw-r--r-- | mod/poco.php | 129 | ||||
-rw-r--r-- | mod/profile.php | 5 | ||||
-rw-r--r-- | mod/profile_photo.php | 3 | ||||
-rw-r--r-- | mod/profiles.php | 5 | ||||
-rw-r--r-- | mod/register.php | 8 | ||||
-rw-r--r-- | mod/search.php | 18 | ||||
-rw-r--r-- | mod/settings.php | 25 | ||||
-rw-r--r-- | mod/suggest.php | 62 | ||||
-rw-r--r-- | mod/tagger.php | 198 | ||||
-rw-r--r-- | mod/viewsrc.php | 30 | ||||
-rw-r--r-- | mod/xrd.php | 1 |
26 files changed, 830 insertions, 167 deletions
diff --git a/mod/acl.php b/mod/acl.php index f2d2456a6..735c2c0b0 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -10,73 +10,90 @@ function acl_init(&$a){ $start = (x($_POST,'start')?$_POST['start']:0); $count = (x($_POST,'count')?$_POST['count']:100); $search = (x($_POST,'search')?$_POST['search']:""); + $type = (x($_POST,'type')?$_POST['type']:""); + if ($search!=""){ $sql_extra = "AND `name` LIKE '%%".dbesc($search)."%%'"; + $sql_extra2 = "AND (`attag` LIKE '%%".dbesc($search)."%%' OR `name` LIKE '%%".dbesc($search)."%%' OR `nick` LIKE '%%".dbesc($search)."%%')"; } // count groups and contacts - $r = q("SELECT COUNT(`id`) AS g FROM `group` WHERE `deleted` = 0 AND `uid` = %d $sql_extra", - intval(local_user()) - ); - $group_count = (int)$r[0]['g']; - $r = q("SELECT COUNT(`id`) AS c FROM `contact` - WHERE `uid` = %d AND `self` = 0 - AND `blocked` = 0 AND `pending` = 0 - AND `notify` != '' $sql_extra" , - intval(local_user()) - ); - $contact_count = (int)$r[0]['c']; + if ($type=='' || $type=='g'){ + $r = q("SELECT COUNT(`id`) AS g FROM `group` WHERE `deleted` = 0 AND `uid` = %d $sql_extra", + intval(local_user()) + ); + $group_count = (int)$r[0]['g']; + } else { + $group_count = 0; + } + + if ($type=='' || $type=='c'){ + $r = q("SELECT COUNT(`id`) AS c FROM `contact` + WHERE `uid` = %d AND `self` = 0 + AND `blocked` = 0 AND `pending` = 0 + AND `notify` != '' $sql_extra" , + intval(local_user()) + ); + $contact_count = (int)$r[0]['c']; + } else { + $contact_count = 0; + } $tot = $group_count+$contact_count; $groups = array(); $contacts = array(); - $r = q("SELECT `group`.`id`, `group`.`name`, GROUP_CONCAT(DISTINCT `group_member`.`contact-id` SEPARATOR ',') as uids - FROM `group`,`group_member` - WHERE `group`.`deleted` = 0 AND `group`.`uid` = %d - AND `group_member`.`gid`=`group`.`id` - $sql_extra - GROUP BY `group`.`id` - ORDER BY `group`.`name` - LIMIT %d,%d", - intval(local_user()), - intval($start), - intval($count) - ); - - - foreach($r as $g){ - $groups[] = array( - "type" => "g", - "photo" => "images/default-group-mm.png", - "name" => $g['name'], - "id" => intval($g['id']), - "uids" => array_map("intval", explode(",",$g['uids'])), - "link" => '' + if ($type=='' || $type=='g'){ + + $r = q("SELECT `group`.`id`, `group`.`name`, GROUP_CONCAT(DISTINCT `group_member`.`contact-id` SEPARATOR ',') as uids + FROM `group`,`group_member` + WHERE `group`.`deleted` = 0 AND `group`.`uid` = %d + AND `group_member`.`gid`=`group`.`id` + $sql_extra + GROUP BY `group`.`id` + ORDER BY `group`.`name` + LIMIT %d,%d", + intval(local_user()), + intval($start), + intval($count) ); + + + foreach($r as $g){ + $groups[] = array( + "type" => "g", + "photo" => "images/default-group-mm.png", + "name" => $g['name'], + "id" => intval($g['id']), + "uids" => array_map("intval", explode(",",$g['uids'])), + "link" => '' + ); + } } + if ($type=='' || $type=='c'){ - $r = q("SELECT `id`, `name`, `micro`, `network`, `url` FROM `contact` - WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `notify` != '' - $sql_extra - ORDER BY `name` ASC ", - intval(local_user()) - ); - foreach($r as $g){ - $contacts[] = array( - "type" => "c", - "photo" => $g['micro'], - "name" => $g['name'], - "id" => intval($g['id']), - "network" => $g['network'], - "link" => $g['url'], + $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url` FROM `contact` + WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `notify` != '' + $sql_extra2 + ORDER BY `name` ASC ", + intval(local_user()) ); + foreach($r as $g){ + $contacts[] = array( + "type" => "c", + "photo" => $g['micro'], + "name" => $g['name'], + "id" => intval($g['id']), + "network" => $g['network'], + "link" => $g['url'], + "nick" => ($g['attag']) ? $g['attag'] : $g['nick'], + ); + } + } - - $items = array_merge($groups, $contacts); diff --git a/mod/admin.php b/mod/admin.php index f178e67f6..c4bb70056 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -506,7 +506,7 @@ function admin_page_plugins(&$a){ if (x($_GET,"a") && $_GET['a']=="t"){ // Toggle plugin status $idx = array_search($plugin, $a->plugins); - if ($idx){ + if ($idx !== false){ unset($a->plugins[$idx]); uninstall_plugin($plugin); info( sprintf( t("Plugin %s disabled."), $plugin ) ); diff --git a/mod/common.php b/mod/common.php new file mode 100644 index 000000000..852388c14 --- /dev/null +++ b/mod/common.php @@ -0,0 +1,61 @@ +<?php + +require_once('include/socgraph.php'); + +function common_content(&$a) { + + $o = ''; + if(! local_user()) { + notice( t('Permission denied.') . EOL); + return; + } + + if($a->argc > 1) + $cid = intval($a->argv[1]); + if(! $cid) + return; + + $c = q("select name, url, photo from contact where id = %d and uid = %d limit 1", + intval($cid), + intval(local_user()) + ); + + $a->page['aside'] .= '<div class="vcard">' + . '<div class="fn label">' . $c[0]['name'] . '</div>' + . '<div id="profile-photo-wrapper">' + . '<a href="/contacts/' . $cid . '"><img class="photo" width="175" height="175" + src="' . $c[0]['photo'] . '" alt="' . $c[0]['name'] . '" /></div>' + . '</div>'; + + + if(! count($c)) + return; + + $o .= '<h2>' . t('Common Friends') . '</h2>'; + +// $o .= '<h3>' . sprintf( t('You and %s'),$c[0]['name']) . '</h3>'; + + + $r = common_friends(local_user(),$cid); + + if(! count($r)) { + $o .= t('No friends in common.'); + return $o; + } + + $tpl = get_markup_template('common_friends.tpl'); + + foreach($r as $rr) { + + $o .= replace_macros($tpl,array( + '$url' => $rr['url'], + '$name' => $rr['name'], + '$photo' => $rr['photo'], + '$tags' => '' + )); + } + + $o .= cleardiv(); +// $o .= paginate($a); + return $o; +} diff --git a/mod/contacts.php b/mod/contacts.php index 9bbcea07d..ecfbe6c2c 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -1,6 +1,7 @@ <?php require_once('include/Contact.php'); +require_once('include/socgraph.php'); function contacts_init(&$a) { if(! local_user()) @@ -265,6 +266,8 @@ function contacts_content(&$a) { $nettype = '<div id="contact-edit-nettype">' . sprintf( t('Network type: %s'),network_to_name($r[0]['network'])) . '</div>'; + $common = count_common_friends(local_user(),$r[0]['id']); + $common_text = (($common) ? sprintf( tt('%d friends in common','%d friends in common', $common),$common) : ''); $o .= replace_macros($tpl,array( '$header' => t('Contact Editor'), '$submit' => t('Submit'), @@ -275,6 +278,8 @@ function contacts_content(&$a) { '$lbl_rep2' => t('Occasionally your friends may wish to inquire about this person\'s online legitimacy.'), '$lbl_rep3' => t('You may help them choose whether or not to interact with this person by providing a <em>reputation</em> to guide them.'), '$lbl_rep4' => t('Please take a moment to elaborate on this selection if you feel it could be helpful to others.'), + '$common_text' => $common_text, + '$common_link' => $a->get_baseurl() . '/common/' . $r[0]['id'], '$visit' => sprintf( t('Visit %s\'s profile [%s]'),$r[0]['name'],$r[0]['url']), '$blockunblock' => t('Block/Unblock contact'), '$ignorecont' => t('Ignore contact'), diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 5d789f480..9755895ce 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -142,12 +142,13 @@ function dfrn_request_post(&$a) { * Create a contact record on our site for the other person */ - $r = q("INSERT INTO `contact` ( `uid`, `created`,`url`, `name`, `nick`, `photo`, `site-pubkey`, - `request`, `confirm`, `notify`, `poll`, `network`, `aes_allow`) - VALUES ( %d, '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d)", + $r = q("INSERT INTO `contact` ( `uid`, `created`,`url`, `nurl`, `name`, `nick`, `photo`, `site-pubkey`, + `request`, `confirm`, `notify`, `poll`, `poco`, `network`, `aes_allow`) + VALUES ( %d, '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d)", intval(local_user()), datetime_convert(), dbesc($dfrn_url), + dbesc(normalise_link($dfrn_url)), $parms['fn'], $parms['nick'], $parms['photo'], @@ -156,6 +157,7 @@ function dfrn_request_post(&$a) { $parms['dfrn-confirm'], $parms['dfrn-notify'], $parms['dfrn-poll'], + $parms['dfrn-poco'], dbesc(NETWORK_DFRN), intval($aes_allow) ); @@ -370,12 +372,13 @@ function dfrn_request_post(&$a) { dbesc_array($parms); - $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `name`, `nick`, `issued-id`, `photo`, `site-pubkey`, - `request`, `confirm`, `notify`, `poll`, `network` ) - VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", + $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`,`name`, `nick`, `issued-id`, `photo`, `site-pubkey`, + `request`, `confirm`, `notify`, `poll`, `poco`, `network` ) + VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", intval($uid), - datetime_convert(), + dbesc(datetime_convert()), $parms['url'], + dbesc(normalise_link($parms['url'])), $parms['fn'], $parms['nick'], $parms['issued-id'], @@ -385,6 +388,7 @@ function dfrn_request_post(&$a) { $parms['dfrn-confirm'], $parms['dfrn-notify'], $parms['dfrn-poll'], + $parms['dfrn-poco'], dbesc(NETWORK_DFRN) ); @@ -635,14 +639,14 @@ function dfrn_request_content(&$a) { $o .= replace_macros($tpl,array( '$header' => t('Friend/Connection Request'), - '$desc' => t('Examples: jojo@demo.friendika.com, http://demo.friendika.com/profile/jojo, testuser@identi.ca'), + '$desc' => t('Examples: jojo@demo.friendica.com, http://demo.friendica.com/profile/jojo, testuser@identi.ca'), '$pls_answer' => t('Please answer the following:'), '$does_know' => sprintf( t('Does %s know you?'),$a->profile['name']), '$yes' => t('Yes'), '$no' => t('No'), '$add_note' => t('Add a personal note:'), '$page_desc' => $page_desc, - '$friendika' => t('Friendika'), + '$friendika' => t('Friendica'), '$statusnet' => t('StatusNet/Federated Social Web'), '$diaspora' => t('Diaspora'), '$diasnote' => t('- please share from your own site as noted above'), diff --git a/mod/display.php b/mod/display.php index 281ce1dd4..761eb4997 100644 --- a/mod/display.php +++ b/mod/display.php @@ -15,6 +15,9 @@ function display_content(&$a) { $o = '<div id="live-display"></div>' . "\r\n"; + $a->page['htmlhead'] .= '<script>$(document).ready(function() { $(".comment-edit-wrapper textarea").contact_autocomplete(baseurl+"/acl"); });</script>'; + + $nick = (($a->argc > 1) ? $a->argv[1] : ''); profile_load($a,$nick); diff --git a/mod/follow.php b/mod/follow.php index 77c8ae18f..0329d1eee 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -100,17 +100,19 @@ function follow_post(&$a) { $new_relation = CONTACT_IS_FOLLOWER; // create contact record - $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `addr`, `alias`, `batch`, `notify`, `poll`, `name`, `nick`, `photo`, `network`, `pubkey`, `rel`, `priority`, + $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `name`, `nick`, `photo`, `network`, `pubkey`, `rel`, `priority`, `writable`, `blocked`, `readonly`, `pending` ) - VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0 ) ", + VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0 ) ", intval(local_user()), dbesc(datetime_convert()), dbesc($ret['url']), + dbesc(normalise_link($ret['url'])), dbesc($ret['addr']), dbesc($ret['alias']), dbesc($ret['batch']), dbesc($ret['notify']), dbesc($ret['poll']), + dbesc($ret['poco']), dbesc($ret['name']), dbesc($ret['nick']), dbesc($ret['photo']), diff --git a/mod/friendica.php b/mod/friendica.php new file mode 100644 index 000000000..363f1409f --- /dev/null +++ b/mod/friendica.php @@ -0,0 +1,68 @@ +<?php + +function friendica_init(&$a) { + if ($a->argv[1]=="json"){ + $register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN'); + + if (isset($a->config['admin_email']) && $a->config['admin_email']!=''){ + $r = q("SELECT username, nickname FROM user WHERE email='%s'", $a->config['admin_email']); + $admin = array( + 'name' => $r[0]['username'], + 'profile'=> $a->get_baseurl().'/profile/'.$r[0]['nickname'], + ); + } else { + $admin = false; + } + + $data = Array( + 'version' => FRIENDIKA_VERSION, + 'url' => z_root(), + 'plugins' => $a->plugins, + 'register_policy' => $register_policy[$a->config['register_policy']], + 'admin' => $admin, + 'site_name' => $a->config['sitename'], + 'platform' => FRIENDIKA_PLATFORM, + 'info' => ((x($a->config,'info')) ? $a->config['info'] : '') + ); + + echo json_encode($data); + killme(); + } +} + + + +function friendica_content(&$a) { + + $o = ''; + $o .= '<h3>Friendica</h3>'; + + + $o .= '<p></p><p>'; + + $o .= t('This is Friendica, version') . ' ' . FRIENDIKA_VERSION . ' '; + $o .= t('running at web location') . ' ' . z_root() . '</p><p>'; + + $o .= t('Please visit <a href="http://project.friendika.com">Project.Friendika.com</a> to learn more about the Friendica project.') . '</p><p>'; + + $o .= t('Bug reports and issues: please visit') . ' ' . '<a href="http://bugs.friendika.com">Bugs.Friendika.com</a></p><p>'; + $o .= t('Suggestions, praise, donations, etc. - please email "Info" at Friendica - dot com') . '</p>'; + + $o .= '<p></p>'; + + if(count($a->plugins)) { + $o .= '<p>' . t('Installed plugins/addons/apps') . '</p>'; + $o .= '<ul>'; + foreach($a->plugins as $p) + if(strlen($p)) + $o .= '<li>' . $p . '</li>'; + $o .= '</ul>'; + } + else + $o .= '<p>' . t('No installed plugins/addons/apps'); + + call_hooks('about_hook', $o); + + return $o; + +} diff --git a/mod/friendika.php b/mod/friendika.php index b12110bd5..1f3df565d 100644 --- a/mod/friendika.php +++ b/mod/friendika.php @@ -1,68 +1,11 @@ <?php -function friendika_init(&$a) { - if ($a->argv[1]=="json"){ - $register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN'); - - if (isset($a->config['admin_email']) && $a->config['admin_email']!=''){ - $r = q("SELECT username, nickname FROM user WHERE email='%s'", $a->config['admin_email']); - $admin = array( - 'name' => $r[0]['username'], - 'profile'=> $a->get_baseurl().'/profile/'.$r[0]['nickname'], - ); - } else { - $admin = false; - } - - $data = Array( - 'version' => FRIENDIKA_VERSION, - 'url' => z_root(), - 'plugins' => $a->plugins, - 'register_policy' => $register_policy[$a->config['register_policy']], - 'admin' => $admin, - 'site_name' => $a->config['sitename'], - 'platform' => FRIENDIKA_PLATFORM, - 'info' => ((x($a->config,'info')) ? $a->config['info'] : '') - ); +require_once('mod/friendica.php'); - echo json_encode($data); - killme(); - } +function friendika_init(&$a) { + friendica_init($a); } - - function friendika_content(&$a) { - - $o = ''; - $o .= '<h3>Friendika</h3>'; - - - $o .= '<p></p><p>'; - - $o .= t('This is Friendika version') . ' ' . FRIENDIKA_VERSION . ' '; - $o .= t('running at web location') . ' ' . z_root() . '</p><p>'; - - $o .= t('Please visit <a href="http://project.friendika.com">Project.Friendika.com</a> to learn more about the Friendika project.') . '</p><p>'; - - $o .= t('Bug reports and issues: please visit') . ' ' . '<a href="http://bugs.friendika.com">Bugs.Friendika.com</a></p><p>'; - $o .= t('Suggestions, praise, donations, etc. - please email "Info" at Friendika - dot com') . '</p>'; - - $o .= '<p></p>'; - - if(count($a->plugins)) { - $o .= '<p>' . t('Installed plugins/addons/apps') . '</p>'; - $o .= '<ul>'; - foreach($a->plugins as $p) - if(strlen($p)) - $o .= '<li>' . $p . '</li>'; - $o .= '</ul>'; - } - else - $o .= '<p>' . t('No installed plugins/addons/apps'); - - call_hooks('about_hook', $o); - - return $o; - + return friendica_content($a); } diff --git a/mod/install.php b/mod/install.php index 27cc6af84..78e537cfe 100644 --- a/mod/install.php +++ b/mod/install.php @@ -52,7 +52,7 @@ function install_post(&$a) { $result = file_put_contents('.htconfig.php', $txt); if(! $result) { - $a->data = $txt; + $a->data['txt'] = $txt; } $errors = load_database($db); @@ -107,7 +107,7 @@ function install_content(&$a) { if(strlen($o)) return $o; - if(strlen($a->data)) { + if(strlen($a->data['txt'])) { $o .= manual_config($a); return; } @@ -203,7 +203,7 @@ function check_funcs() { if(! function_exists('mb_strlen')) notice( t('Error: mb_string PHP module required but not installed.') . EOL); - if((x($_SESSION,'sysmsg')) && strlen($_SESSION['sysmsg'])) + if((x($_SESSION,'sysmsg')) && is_array($_SESSION['sysmsg']) && count($_SESSION['sysmsg'])) notice( t('Please see the file "INSTALL.txt".') . EOL); } @@ -224,7 +224,7 @@ function check_htconfig() { function manual_config(&$a) { - $data = htmlentities($a->data); + $data = htmlentities($a->data['txt']); $o = t('The database configuration file ".htconfig.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.'); $o .= "<textarea rows=\"24\" cols=\"80\" >$data</textarea>"; return $o; diff --git a/mod/item.php b/mod/item.php index ab104735b..ee3bdca99 100644 --- a/mod/item.php +++ b/mod/item.php @@ -333,15 +333,20 @@ function item_post(&$a) { } } - // embedded bookmark in post? convert to regular url and set bookmark flag + // embedded bookmark in post? set bookmark flag $bookmark = 0; - if(preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",$body,$match)) { + if(preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",$body,$match,PREG_SET_ORDER)) { $bookmark = 1; - $body = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",'[url=$1]$2[/url]',$body); +// foreach($match as $mtch) { +// $body = str_replace( +// '[bookmark=' . $mtch[1] . ']' . $mtch[2] . '[/bookmark]', +// '[url=' . $mtch[1] . ']' . $mtch[2] . '[/url]', +// $body +// ); +// } } - $body = bb_translate_video($body); /** @@ -373,6 +378,7 @@ function item_post(&$a) { if(count($tags)) { foreach($tags as $tag) { + if(isset($profile)) unset($profile); if(strpos($tag,'#') === 0) { @@ -408,7 +414,19 @@ function item_post(&$a) { else { $newname = $name; $alias = ''; - if(strstr($name,'_') || strstr($name,' ')) { + $tagcid = 0; + if(strrpos($newname,'+')) { + $tagcid = intval(substr($newname,strrpos($newname,'+') + 1)); + if(strpos($name,' ')) + $name = substr($name,0,strpos($name,' ')); + } + if($tagcid) { + $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($tagcid), + intval($profile_uid) + ); + } + elseif(strstr($name,'_') || strstr($name,' ')) { $newname = str_replace('_',' ',$name); $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1", dbesc($newname), @@ -440,17 +458,23 @@ function item_post(&$a) { if($profile) { $body = str_replace('@' . $name, '@' . '[url=' . $profile . ']' . $newname . '[/url]', $body); $profile = str_replace(',','%2c',$profile); - if(strlen($str_tags)) - $str_tags .= ','; - $str_tags .= '@[url=' . $profile . ']' . $newname . '[/url]'; + $newtag = '@[url=' . $profile . ']' . $newname . '[/url]'; + if(! stristr($str_tags,$newtag)) { + if(strlen($str_tags)) + $str_tags .= ','; + $str_tags .= $newtag; + } // Status.Net seems to require the numeric ID URL in a mention if the person isn't // subscribed to you. But the nickname URL is OK if they are. Grrr. We'll tag both. if(strlen($alias)) { - if(strlen($str_tags)) - $str_tags .= ','; - $str_tags .= '@[url=' . $alias . ']' . $newname . '[/url]'; + $newtag = '@[url=' . $alias . ']' . $newname . '[/url]'; + if(! stristr($str_tags,$newtag)) { + if(strlen($str_tags)) + $str_tags .= ','; + $str_tags .= $newtag; + } } } } diff --git a/mod/like.php b/mod/like.php index 5c3dd323e..6b97fafb5 100644 --- a/mod/like.php +++ b/mod/like.php @@ -197,5 +197,6 @@ EOT; proc_run('php',"include/notifier.php","like","$post_id"); - return; // NOTREACHED + killme(); +// return; // NOTREACHED }
\ No newline at end of file diff --git a/mod/network.php b/mod/network.php index 04c2a1782..9fed8592e 100644 --- a/mod/network.php +++ b/mod/network.php @@ -328,15 +328,21 @@ function network_content(&$a, $update = 0) { } } - if((! $group) && (! $cid) && (! $update)) + if((! $group) && (! $cid) && (! $update)) { $o .= get_birthdays(); + $o .= get_events(); + } $sql_extra2 = (($nouveau) ? '' : " AND `item`.`parent` = `item`.`id` "); - if(x($_GET,'search')) - $sql_extra .= " AND `item`.`body` REGEXP '" . dbesc(escape_tags($_GET['search'])) . "' "; + if(x($_GET,'search')) { + $search = escape_tags($_GET['search']); + $sql_extra .= sprintf(" AND ( `item`.`body` REGEXP '%s' OR `item`.`tag` REGEXP '%s' ) ", + dbesc($search), + dbesc('\\]' . $search . '\\[') + ); + } - $r = q("SELECT COUNT(*) AS `total` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 diff --git a/mod/parse_url.php b/mod/parse_url.php index a238ecb2f..2df9de476 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -46,6 +46,7 @@ function parse_url_content(&$a) { killme(); } + if($url && $title && $text) { $text = '<br /><br /><blockquote>' . $text . '</blockquote><br />'; @@ -67,13 +68,26 @@ function parse_url_content(&$a) { killme(); } - logger('parse_url: data: ' . $s, LOGGER_DATA); +// logger('parse_url: data: ' . $s, LOGGER_DATA); if(! $s) { echo sprintf($template,$url,$url,'') . $str_tags; killme(); } + $matches = ''; + $c = preg_match('/\<head(.*?)\>(.*?)\<\/head\>/ism',$s,$matches); + if($c) { +// logger('parse_url: header: ' . $matches[2], LOGGER_DATA); + try { + $domhead = HTML5_Parser::parse($matches[2]); + } catch (DOMException $e) { + logger('scrape_dfrn: parse error: ' . $e); + } + if($domhead) + logger('parsed header'); + } + if(! $title) { if(strpos($s,'<title>')) { $title = substr($s,strpos($s,'<title>')+7,64); @@ -84,13 +98,16 @@ function parse_url_content(&$a) { $config = HTMLPurifier_Config::createDefault(); $config->set('Cache.DefinitionImpl', null); - $purifier = new HTMLPurifier($config); $s = $purifier->purify($s); -// logger('parse_url: purified: ' . $s, LOGGER_DATA); +// logger('purify_output: ' . $s); - $dom = @HTML5_Parser::parse($s); + try { + $dom = HTML5_Parser::parse($s); + } catch (DOMException $e) { + logger('scrape_dfrn: parse error: ' . $e); + } if(! $dom) { echo sprintf($template,$url,$url,'') . $str_tags; @@ -155,10 +172,63 @@ function parse_url_content(&$a) { } } + if(! $text) { + logger('parsing meta'); + $items = $domhead->getElementsByTagName('meta'); + if($items) { + foreach($items as $item) { + $property = $item->getAttribute('property'); + if($property && (stristr($property,':description'))) { + + $text = $item->getAttribute('content'); + if(stristr($text,'<script')) { + $text = ''; + continue; + } + $text = strip_tags($text); + + + $text = substr($text,0,250) . '...' ; + } + if($property && (stristr($property,':image'))) { + + $image = $item->getAttribute('content'); + if(stristr($text,'<script')) { + $image = ''; + continue; + } + $image = strip_tags($image); + + $i = fetch_url($image); + if($i) { + require_once('include/Photo.php'); + $ph = new Photo($i); + if($ph->is_valid()) { + if($ph->getWidth() > 300 || $ph->getHeight() > 300) { + $ph->scaleImage(300); + $new_width = $ph->getWidth(); + $new_height = $ph->getHeight(); + $image = '<br /><br /><img height="' . $new_height . '" width="' . $new_width . '" src="' .$image . '" alt="photo" />'; + } + else + $image = '<br /><br /><img src="' . $image . '" alt="photo" />'; + } + else + $image = ''; + + } + } + } + } + } + if(strlen($text)) { $text = '<br /><br /><blockquote>' . $text . '</blockquote><br />'; } + if($image) { + $text = $image . '<br />' . $text; + } $title = str_replace(array("\r","\n"),array('',''),$title); $result = sprintf($template,$url,($title) ? $title : $url,$text) . $str_tags; diff --git a/mod/photos.php b/mod/photos.php index 663d0a40c..51d6a4b65 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -408,7 +408,18 @@ function photos_post(&$a) { } else { $newname = $name; - if(strstr($name,'_') || strstr($name,' ')) { + $alias = ''; + $tagcid = 0; + if(strrpos($newname,'+')) + $tagcid = intval(substr($newname,strrpos($newname,'+') + 1)); + + if($tagcid) { + $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($tagcid), + intval($profile_uid) + ); + } + elseif(strstr($name,'_') || strstr($name,' ')) { $newname = str_replace('_',' ',$name); $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1", dbesc($newname), @@ -581,8 +592,8 @@ function photos_post(&$a) { $visible = 1; else $visible = 0; - - if(intval($_REQUEST['not_visible'])) + + if(intval($_REQUEST['not_visible']) || $_REQUEST['not_visible'] === 'true') $visible = 0; $str_group_allow = perms2str(((is_array($_REQUEST['group_allow'])) ? $_REQUEST['group_allow'] : explode(',',$_REQUEST['group_allow']))); diff --git a/mod/poco.php b/mod/poco.php new file mode 100644 index 000000000..21ee4df69 --- /dev/null +++ b/mod/poco.php @@ -0,0 +1,129 @@ +<?php + +function poco_init(&$a) { + + if($a->argc > 1) { + $user = notags(trim($a->argv[1])); + } + if(! x($user) || get_config('system','block_public')) + http_status_exit(401); + + $format = (($_GET['format']) ? $_GET['format'] : 'json'); + + $justme = false; + + if($a->argc > 2 && $a->argv[2] === '@me') + $justme = true; + if($a->argc > 3 && $a->argv[3] === '@all') + $justme = false; + if($a->argc > 3 && $a->argv[3] === '@self') + $justme = true; + if($a->argc > 4 && intval($a->argv[4]) && $justme == false) + $cid = intval($a->argv[4]); + + + $r = q("SELECT `user`.*,`profile`.`hide-friends` from user left join profile on `user`.`uid` = `profile`.`uid` + where `user`.`nickname` = '%s' and `profile`.`is-default` = 1 limit 1", + dbesc($user) + ); + if(! count($r) || $r[0]['hidewall'] || $r[0]['hide-friends']) + http_status_exit(404); + + $user = $r[0]; + + if($justme) + $sql_extra = " and `contact`.`self` = 1 "; + + if($cid) + $sql_extra = sprintf(" and `contact`.`id` = %d ",intval($cid)); + + $r = q("SELECT count(*) as `total` from `contact` where `uid` = %d and blocked = 0 and pending = 0 + $sql_extra ", + intval($user['uid']) + ); + if(count($r)) + $totalResults = intval($r[0]['total']); + else + $totalResults = 0; + + $startIndex = intval($_GET['startIndex']); + if(! $startIndex) + $startIndex = 0; + $itemsPerPage = ((x($_GET,'count') && intval($_GET['count'])) ? intval($_GET['count']) : $totalResults); + + $r = q("SELECT * from `contact` where `uid` = %d and blocked = 0 and pending = 0 + $sql_extra LIMIT %d, %d", + intval($user['uid']), + intval($startIndex), + intval($itemsPerPage) + ); + + $ret = array(); + if(x($_GET,'sorted')) + $ret['sorted'] = 'false'; + if(x($_GET,'filtered')) + $ret['filtered'] = 'false'; + if(x($_GET,'updatedSince')) + $ret['updateSince'] = 'false'; + + $ret['startIndex'] = (string) $startIndex; + $ret['itemsPerPage'] = (string) $itemsPerPage; + $ret['totalResults'] = (string) $totalResults; + $ret['entry'] = array(); + + + $fields_ret = array( + 'id' => false, + 'displayName' => false, + 'urls' => false, + 'preferredUsername' => false, + 'photos' => false + ); + + if((! x($_GET,'fields')) || ($_GET['fields'] === '@all')) + foreach($fields_ret as $k => $v) + $fields_ret[$k] = true; + else { + $fields_req = explode(',',$_GET['fields']); + foreach($fields_req as $f) + $fields_ret[trim($f)] = true; + } + + if(is_array($r)) { + if(count($r)) { + foreach($r as $rr) { + $entry = array(); + if($fields_ret['id']) + $entry['id'] = $rr['id']; + if($fields_ret['displayName']) + $entry['displayName'] = $rr['name']; + if($fields_ret['urls']) + $entry['urls'] = array(array('value' => $rr['url'], 'type' => 'profile')); + if($fields_ret['preferredUsername']) + $entry['preferredUsername'] = $rr['nick']; + if($fields_ret['photos']) + $entry['photos'] = array(array('value' => $rr['photo'], 'type' => 'profile')); + $ret['entry'][] = $entry; + } + } + else + $ret['entry'][] = array(); + } + else + http_status_exit(500); + + if($format === 'xml') { + header('Content-type: text/xml'); + echo replace_macros(get_markup_template('poco_xml.tpl'),array_xmlify(array('$response' => $ret))); + http_status_exit(500); + } + if($format === 'json') { + header('Content-type: application/json'); + echo json_encode($ret); + killme(); + } + else + http_status_exit(500); + + +}
\ No newline at end of file diff --git a/mod/profile.php b/mod/profile.php index a453f72f1..f68006af5 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -46,6 +46,7 @@ function profile_init(&$a) { $dfrn_pages = array('request', 'confirm', 'notify', 'poll'); foreach($dfrn_pages as $dfrn) $a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".$a->get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n"; + $a->page['htmlhead'] .= "<link rel=\"dfrn-poco\" href=\"".$a->get_baseurl()."/poco/{$which}\" />\r\n"; } @@ -223,8 +224,10 @@ function profile_content(&$a, $update = 0) { ); } - if($is_owner && ! $update) + if($is_owner && ! $update) { $o .= get_birthdays(); + $o .= get_events(); + } $o .= conversation($a,$r,'profile',$update); diff --git a/mod/profile_photo.php b/mod/profile_photo.php index 4de3aaa3e..47f0f8d8e 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -90,6 +90,9 @@ function profile_photo_post(&$a) { $url = $a->get_baseurl() . '/profile/' . $a->user['nickname']; if($url && strlen(get_config('system','directory_submit_url'))) proc_run('php',"include/directory.php","$url"); + + require_once('include/profile_update.php'); + profile_change(); } else notice( t('Unable to process image') . EOL); diff --git a/mod/profiles.php b/mod/profiles.php index f5f335c7e..ccd7d5474 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -210,6 +210,9 @@ function profiles_post(&$a) { $url = $_SESSION['my_url']; if($url && strlen(get_config('system','directory_submit_url'))) proc_run('php',"include/directory.php","$url"); + + require_once('include/profile_update.php'); + profile_change(); } } } @@ -455,7 +458,7 @@ function profiles_content(&$a) { $tpl_header = get_markup_template('profile_listing_header.tpl'); $o .= replace_macros($tpl_header,array( - '$header' => t('Profiles'), + '$header' => t('Edit/Manage Profiles'), '$chg_photo' => t('Change profile photo'), '$cr_new' => t('Create New Profile') )); diff --git a/mod/register.php b/mod/register.php index 85e1f9faa..6ebe35dbf 100644 --- a/mod/register.php +++ b/mod/register.php @@ -268,9 +268,9 @@ function register_post(&$a) { intval($newuid)); return; } - $r = q("INSERT INTO `contact` ( `uid`, `created`, `self`, `name`, `nick`, `photo`, `thumb`, `micro`, `blocked`, `pending`, `url`, - `request`, `notify`, `poll`, `confirm`, `name-date`, `uri-date`, `avatar-date` ) - VALUES ( %d, '%s', 1, '%s', '%s', '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", + $r = q("INSERT INTO `contact` ( `uid`, `created`, `self`, `name`, `nick`, `photo`, `thumb`, `micro`, `blocked`, `pending`, `url`, `nurl`, + `request`, `notify`, `poll`, `confirm`, `poco`, `name-date`, `uri-date`, `avatar-date` ) + VALUES ( %d, '%s', 1, '%s', '%s', '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", intval($newuid), datetime_convert(), dbesc($username), @@ -279,10 +279,12 @@ function register_post(&$a) { dbesc($a->get_baseurl() . "/photo/avatar/{$newuid}.jpg"), dbesc($a->get_baseurl() . "/photo/micro/{$newuid}.jpg"), dbesc($a->get_baseurl() . "/profile/$nickname"), + dbesc(normalise_link($a->get_baseurl() . "/profile/$nickname")), dbesc($a->get_baseurl() . "/dfrn_request/$nickname"), dbesc($a->get_baseurl() . "/dfrn_notify/$nickname"), dbesc($a->get_baseurl() . "/dfrn_poll/$nickname"), dbesc($a->get_baseurl() . "/dfrn_confirm/$nickname"), + dbesc($a->get_baseurl() . "/poco/$nickname"), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(datetime_convert()) diff --git a/mod/search.php b/mod/search.php index 2a8bf1484..819100204 100644 --- a/mod/search.php +++ b/mod/search.php @@ -96,12 +96,16 @@ function search_content(&$a) { // Only public wall posts can be shown // OR your own posts if you are a logged in member - $s_bool = "AND MATCH (`item`.`body`) AGAINST ( '%s' IN BOOLEAN MODE )"; - $s_regx = "AND `item`.`body` REGEXP '%s' "; + $escaped_search = str_replace(array('[',']'),array('\\[','\\]'),$search); + +// $s_bool = sprintf("AND MATCH (`item`.`body`) AGAINST ( '%s' IN BOOLEAN MODE )", dbesc($search)); + $s_regx = sprintf("AND ( `item`.`body` REGEXP '%s' OR `item`.`tag` REGEXP '%s' )", + dbesc($escaped_search), dbesc('\\]' . $escaped_search . '\\[')); + +// if(mb_strlen($search) >= 3) +// $search_alg = $s_bool; +// else - if(mb_strlen($search) >= 3) - $search_alg = $s_bool; - else $search_alg = $s_regx; $r = q("SELECT COUNT(*) AS `total` @@ -111,8 +115,7 @@ function search_content(&$a) { OR `item`.`uid` = %d ) AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 $search_alg ", - intval(local_user()), - dbesc($search) + intval(local_user()) ); if(count($r)) @@ -137,7 +140,6 @@ function search_content(&$a) { $search_alg ORDER BY `received` DESC LIMIT %d , %d ", intval(local_user()), - dbesc($search), intval($a->pager['start']), intval($a->pager['itemspage']) diff --git a/mod/settings.php b/mod/settings.php index 2b9cde735..938f6a0d5 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -222,6 +222,7 @@ function settings_post(&$a) { $old_visibility = (((x($_POST,'visibility')) && (intval($_POST['visibility']) == 1)) ? 1 : 0); $page_flags = (((x($_POST,'page-flags')) && (intval($_POST['page-flags']))) ? intval($_POST['page-flags']) : 0); $blockwall = (((x($_POST,'blockwall')) && (intval($_POST['blockwall']) == 1)) ? 0: 1); // this setting is inverted! + $blocktags = (((x($_POST,'blocktags')) && (intval($_POST['blocktags']) == 1)) ? 0: 1); // this setting is inverted! $hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0); $hidewall = (($_POST['hidewall'] == 1) ? 1: 0); @@ -296,7 +297,7 @@ function settings_post(&$a) { $openidserver = ''; } - $r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `openid` = '%s', `timezone` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `page-flags` = %d, `default-location` = '%s', `allow_location` = %d, `theme` = '%s', `maxreq` = %d, `expire` = %d, `openidserver` = '%s', `blockwall` = %d, `hidewall` = %d WHERE `uid` = %d LIMIT 1", + $r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `openid` = '%s', `timezone` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `page-flags` = %d, `default-location` = '%s', `allow_location` = %d, `theme` = '%s', `maxreq` = %d, `expire` = %d, `openidserver` = '%s', `blockwall` = %d, `hidewall` = %d, `blocktags` = %d WHERE `uid` = %d LIMIT 1", dbesc($username), dbesc($email), dbesc($openid), @@ -315,6 +316,7 @@ function settings_post(&$a) { dbesc($openidserver), intval($blockwall), intval($hidewall), + intval($blocktags), intval(local_user()) ); if($r) @@ -348,9 +350,9 @@ function settings_post(&$a) { } -// not yet ready for prime time -// require_once('include/profile_update.php'); -// profile_change(); + + require_once('include/profile_update.php'); + profile_change(); $_SESSION['theme'] = $theme; if($email_changed && $a->config['register_policy'] == REGISTER_VERIFY) { @@ -582,6 +584,7 @@ function settings_content(&$a) { $maxreq = $a->user['maxreq']; $expire = ((intval($a->user['expire'])) ? $a->user['expire'] : ''); $blockwall = $a->user['blockwall']; + $blocktags = $a->user['blocktags']; if(! strlen($a->user['timezone'])) $timezone = date_default_timezone_get(); @@ -645,6 +648,17 @@ function settings_content(&$a) { )); + $blockwall = replace_macros($opt_tpl,array( + '$field' => array('blockwall', t('Allow friends to post to your profile page?'), ! $a->user['blockwall'], '', array(t('No'),t('Yes'))), + + )); + + + $blocktags = replace_macros($opt_tpl,array( + '$field' => array('blocktags', t('Allow friends to tag your posts?'), ! $a->user['blocktags'], '', array(t('No'),t('Yes'))), + + )); + $invisible = (((! $profile['publish']) && (! $profile['net-publish'])) ? true : false); @@ -720,7 +734,8 @@ function settings_content(&$a) { '$visibility' => $profile['net-publish'], '$aclselect' => populate_acl($a->user,$celeb), - '$blockwall'=> array('blockwall', t('Allow friends to post to your profile page:'), !$blockwall, ''), + '$blockwall'=> $blockwall, // array('blockwall', t('Allow friends to post to your profile page:'), !$blockwall, ''), + '$blocktags'=> $blocktags, // array('blocktags', t('Allow friends to tag your posts:'), !$blocktags, ''), '$expire' => array('expire', t("Automatically expire posts after days:"), $expire, t('If empty, posts will not expire. Expired posts will be deleted')), '$profile_in_dir' => $profile_in_dir, diff --git a/mod/suggest.php b/mod/suggest.php new file mode 100644 index 000000000..aedf3fd46 --- /dev/null +++ b/mod/suggest.php @@ -0,0 +1,62 @@ +<?php + +require_once('include/socgraph.php'); +require_once('include/contact_widgets.php'); + + +function suggest_init(&$a) { + if(! local_user()) + return; + + if(x($_GET,'ignore') && intval($_GET['ignore'])) { + q("insert into gcign ( uid, gcid ) values ( %d, %d ) ", + intval(local_user()), + intval($_GET['ignore']) + ); + } + +} + + + + + +function suggest_content(&$a) { + + $o = ''; + if(! local_user()) { + notice( t('Permission denied.') . EOL); + return; + } + + $a->page['aside'] .= follow_widget(); + $a->page['aside'] .= findpeople_widget(); + + + $o .= '<h2>' . t('Friend Suggestions') . '</h2>'; + + + $r = suggestion_query(local_user()); + + if(! count($r)) { + $o .= t('No suggestions. This works best when you have more than one contact/friend.'); + return $o; + } + + $tpl = get_markup_template('suggest_friends.tpl'); + + foreach($r as $rr) { + + $o .= replace_macros($tpl,array( + '$url' => $rr['url'], + '$name' => $rr['name'], + '$photo' => $rr['photo'], + '$ignlnk' => $a->get_baseurl() . '/suggest?ignore=' . $rr['id'], + '$ignore' => t('Ignore/Hide') + )); + } + + $o .= cleardiv(); +// $o .= paginate($a); + return $o; +} diff --git a/mod/tagger.php b/mod/tagger.php new file mode 100644 index 000000000..da4e74c61 --- /dev/null +++ b/mod/tagger.php @@ -0,0 +1,198 @@ +<?php + +require_once('include/security.php'); +require_once('include/bbcode.php'); +require_once('include/items.php'); + + +function tagger_content(&$a) { + + if(! local_user() && ! remote_user()) { + return; + } + + $term = notags(trim($_GET['term'])); + // no commas allowed + $term = str_replace(array(',',' '),array('','_'),$term); + + if(! $term) + return; + + $item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0); + + logger('tagger: tag ' . $term . ' item ' . $item_id); + + + $r = q("SELECT * FROM `item` WHERE `id` = '%s' LIMIT 1", + dbesc($item_id) + ); + + if(! $item_id || (! count($r))) { + logger('tagger: no item ' . $item_id); + return; + } + + $item = $r[0]; + + $owner_uid = $item['uid']; + + $r = q("select `nickname`,`blocktags` from user where uid = %d limit 1", + intval($owner_uid) + ); + if(count($r)) { + $owner_nick = $r[0]['nickname']; + $blocktags = $r[0]['blocktags']; + } + + if(local_user() != $owner_uid) + return; + + if(remote_user()) { + $r = q("select * from contact where id = %d AND `uid` = %d limit 1", + intval(remote_user()), + intval($item['uid']) + ); + } + else { + $r = q("select * from contact where self = 1 and uid = %d limit 1", + intval(local_user()) + ); + } + if(count($r)) + $contact = $r[0]; + else { + logger('tagger: no contact_id'); + return; + } + + $uri = item_new_uri($a->get_hostname(),$owner_uid); + + $post_type = (($item['resource-id']) ? t('photo') : t('status')); + $targettype = (($item['resource-id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE ); + + $link = xmlify('<link rel="alternate" type="text/html" href="' + . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ; + + $body = $item['body']; + + $target = <<< EOT + <target> + <type>$targettype</type> + <local>1</local> + <id>{$item['uri']}</id> + <link>$link</link> + <title></title> + <content>$body</content> + </target> +EOT; + + $tagid = $a->get_baseurl() . '/search?search=' . $term; + $objtype = ACTIVITY_OBJ_TAGTERM; + + $obj = <<< EOT + <object> + <type>$objtype</type> + <local>1</local> + <id>$tagid</id> + <link>$tagid</link> + <title>$term</title> + <content>$term</content> + </object> +EOT; + + $bodyverb = t('%1$s tagged %2$s\'s %3$s with %4$s'); + + if(! isset($bodyverb)) + return; + + $termlink = '#[url=' . $a->get_baseurl() . '/search?search=' . urlencode($term) . ']'. $term . '[/url]'; + + $arr = array(); + + $arr['uri'] = $uri; + $arr['uid'] = $owner_uid; + $arr['contact-id'] = $contact['id']; + $arr['type'] = 'activity'; + $arr['wall'] = $item['wall']; + $arr['gravity'] = GRAVITY_COMMENT; + $arr['parent'] = $item['id']; + $arr['parent-uri'] = $item['uri']; + $arr['owner-name'] = $item['author-name']; + $arr['owner-link'] = $item['author-link']; + $arr['owner-avatar'] = $item['author-avatar']; + $arr['author-name'] = $contact['name']; + $arr['author-link'] = $contact['url']; + $arr['author-avatar'] = $contact['thumb']; + + $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]'; + $alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]'; + $plink = '[url=' . $item['plink'] . ']' . $post_type . '[/url]'; + $arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink, $termlink ); + + $arr['verb'] = ACTIVITY_TAG; + $arr['target-type'] = $targettype; + $arr['target'] = $target; + $arr['object-type'] = $objtype; + $arr['object'] = $obj; + $arr['allow_cid'] = $item['allow_cid']; + $arr['allow_gid'] = $item['allow_gid']; + $arr['deny_cid'] = $item['deny_cid']; + $arr['deny_gid'] = $item['deny_gid']; + $arr['visible'] = 1; + $arr['unseen'] = 1; + $arr['last-child'] = 1; + $arr['origin'] = 1; + + $post_id = item_store($arr); + + q("UPDATE `item` set plink = '%s' where id = %d limit 1", + dbesc($a->get_baseurl() . '/display/' . $owner_nick . '/' . $post_id), + intval($post_id) + ); + + + if(! $item['visible']) { + $r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($item['id']), + intval($owner_uid) + ); + } + + if((! $blocktags) && (! stristr($item['tag'], ']' . $term . '[' ))) { + q("update item set tag = '%s' where id = %d limit 1", + dbesc($item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?search=' . $term . ']'. $term . '[/url]'), + intval($item['id']) + ); + } + + // if the original post is on this site, update it. + + $r = q("select `tag`,`id`,`uid` from item where `origin` = 1 AND `uri` = '%s' LIMIT 1", + dbesc($item['uri']) + ); + if(count($r)) { + $x = q("SELECT `blocktags` FROM `user` WHERE `uid` = %d limit 1", + intval($r[0]['uid']) + ); + if(count($x) && !$x[0]['blocktags'] && (! stristr($r[0]['tag'], ']' . $term . '['))) { + q("update item set tag = '%s' where id = %d limit 1", + dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?search=' . $term . ']'. $term . '[/url]'), + intval($r[0]['id']) + ); + } + + } + + + $arr['id'] = $post_id; + + call_hooks('post_local_end', $arr); + + proc_run('php',"include/notifier.php","tag","$post_id"); + + killme(); + + return; // NOTREACHED + + +}
\ No newline at end of file diff --git a/mod/viewsrc.php b/mod/viewsrc.php new file mode 100644 index 000000000..8900e44db --- /dev/null +++ b/mod/viewsrc.php @@ -0,0 +1,30 @@ +<?php + + +function viewsrc_content(&$a) { + + if(! local_user()) { + notice( t('Access denied.') . EOL); + return; + } + + $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); + + if(! $item_id) { + $a->error = 404; + notice( t('Item not found.') . EOL); + return; + } + + $r = q("SELECT `item`.`body` FROM `item` + WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 + AND `item`.`id` = '%s' LIMIT 1", + intval(local_user()), + dbesc($item_id) + ); + + if(count($r)) + $o .= str_replace("\n",'<br />',$r[0]['body']); + return $o; +} + diff --git a/mod/xrd.php b/mod/xrd.php index a416a2cf3..2fa6bcd99 100644 --- a/mod/xrd.php +++ b/mod/xrd.php @@ -47,6 +47,7 @@ function xrd_init(&$a) { '$hcard_url' => $a->get_baseurl() . '/hcard/' . $r[0]['nickname'], '$atom' => $a->get_baseurl() . '/dfrn_poll/' . $r[0]['nickname'], '$zot_post' => $a->get_baseurl() . '/post/' . $r[0]['nickname'], + '$poco_url' => $a->get_baseurl() . '/poco/' . $r[0]['nickname'], '$photo' => $a->get_baseurl() . '/photo/profile/' . $r[0]['uid'] . '.jpg', '$dspr' => $dspr, '$salmon' => $a->get_baseurl() . '/salmon/' . $r[0]['nickname'], |