aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/connections.php137
-rw-r--r--mod/connedit.php11
-rwxr-xr-xmod/events.php5
-rw-r--r--mod/import.php18
-rw-r--r--mod/linkinfo.php (renamed from mod/urlinfo.php)386
-rw-r--r--mod/xrd.php2
-rw-r--r--mod/zfinger.php2
7 files changed, 219 insertions, 342 deletions
diff --git a/mod/connections.php b/mod/connections.php
index 2f1a1fdf5..2060ca85e 100644
--- a/mod/connections.php
+++ b/mod/connections.php
@@ -19,143 +19,6 @@ function connections_init(&$a) {
}
-function connections_post(&$a) {
-
- if(! local_channel())
- return;
-
- $contact_id = intval(argv(1));
- if(! $contact_id)
- return;
-
- $orig_record = q("SELECT * FROM abook WHERE abook_id = %d AND abook_channel = %d LIMIT 1",
- intval($contact_id),
- intval(local_channel())
- );
-
- if(! $orig_record) {
- notice( t('Could not access contact record.') . EOL);
- goaway(z_root() . '/connections');
- return; // NOTREACHED
- }
-
- call_hooks('contact_edit_post', $_POST);
-
- $profile_id = $_POST['profile_assign'];
- if($profile_id) {
- $r = q("SELECT profile_guid FROM profile WHERE profile_guid = '%s' AND `uid` = %d LIMIT 1",
- dbesc($profile_id),
- intval(local_channel())
- );
- if(! count($r)) {
- notice( t('Could not locate selected profile.') . EOL);
- return;
- }
- }
-
- $hidden = intval($_POST['hidden']);
-
- $priority = intval($_POST['poll']);
- if($priority > 5 || $priority < 0)
- $priority = 0;
-
- $closeness = intval($_POST['closeness']);
- if($closeness < 0)
- $closeness = 99;
-
- $abook_my_perms = 0;
-
- foreach($_POST as $k => $v) {
- if(strpos($k,'perms_') === 0) {
- $abook_my_perms += $v;
- }
- }
-
- $new_friend = false;
-
- if(($_REQUEST['pending']) && intval($orig_record[0]['abook_pending'])) {
- $new_friend = true;
- }
-
- $r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_pending = %d
- where abook_id = %d AND abook_channel = %d",
- dbesc($profile_id),
- intval($abook_my_perms),
- intval($closeness),
- intval(1 - intval($new_friend)),
- intval($contact_id),
- intval(local_channel())
- );
-
- if($r)
- info( t('Connection updated.') . EOL);
- else
- notice( t('Failed to update connection record.') . EOL);
-
- if((x($a->data,'abook')) && $a->data['abook']['abook_my_perms'] != $abook_my_perms
- && (! intval($a->data['abook']['abook_self']))) {
- proc_run('php', 'include/notifier.php', 'permission_update', $contact_id);
- }
-
- if($new_friend) {
- $channel = $a->get_channel();
- $default_group = $channel['channel_default_group'];
- if($default_group) {
- require_once('include/group.php');
- $g = group_rec_byhash(local_channel(),$default_group);
- if($g)
- group_add_member(local_channel(),'',$a->data['abook_xchan'],$g['id']);
- }
-
-
-
- // Check if settings permit ("post new friend activity" is allowed, and
- // friends in general or this friend in particular aren't hidden)
- // and send out a new friend activity
- // TODO
-
- // pull in a bit of content if there is any to pull in
- proc_run('php','include/onepoll.php',$contact_id);
-
- }
-
- // Refresh the structure in memory with the new data
-
- $r = q("SELECT abook.*, xchan.*
- FROM abook left join xchan on abook_xchan = xchan_hash
- WHERE abook_channel = %d and abook_id = %d LIMIT 1",
- intval(local_channel()),
- intval($contact_id)
- );
- if($r) {
- $a->data['abook'] = $r[0];
- }
-
- if($new_friend) {
- $arr = array('channel_id' => local_channel(), 'abook' => $a->data['abook']);
- call_hooks('accept_follow', $arr);
- }
-
- connections_clone($a);
-
- return;
-
-}
-
-function connections_clone(&$a) {
-
- if(! array_key_exists('abook',$a->data))
- return;
- $clone = $a->data['abook'];
-
- unset($clone['abook_id']);
- unset($clone['abook_account']);
- unset($clone['abook_channel']);
-
- build_sync_packet(0 /* use the current local_channel */, array('abook' => array($clone)));
-}
-
-
function connections_content(&$a) {
$sort_type = 0;
diff --git a/mod/connedit.php b/mod/connedit.php
index 866f83615..75a5fd719 100644
--- a/mod/connedit.php
+++ b/mod/connedit.php
@@ -314,6 +314,17 @@ function connedit_clone(&$a) {
if(! $a->poi)
return;
+
+ $r = q("SELECT abook.*, xchan.*
+ FROM abook left join xchan on abook_xchan = xchan_hash
+ WHERE abook_channel = %d and abook_id = %d LIMIT 1",
+ intval(local_channel()),
+ intval($a->poi['abook_id'])
+ );
+ if($r) {
+ $a->poi = $r[0];
+ }
+
$clone = $a->poi;
unset($clone['abook_id']);
diff --git a/mod/events.php b/mod/events.php
index 15fed9df2..edb61a6cd 100755
--- a/mod/events.php
+++ b/mod/events.php
@@ -132,6 +132,10 @@ function events_post(&$a) {
}
return;
}
+
+ $created = $x[0]['created'];
+ $edited = datetime_convert();
+
if($x[0]['allow_cid'] === '<' . $channel['channel_hash'] . '>'
&& $x[0]['allow_gid'] === '' && $x[0]['deny_cid'] === '' && $x[0]['deny_gid'] === '') {
$share = false;
@@ -150,6 +154,7 @@ function events_post(&$a) {
}
}
else {
+ $created = $edited = datetime_convert();
if($share) {
$str_group_allow = perms2str($_POST['group_allow']);
$str_contact_allow = perms2str($_POST['contact_allow']);
diff --git a/mod/import.php b/mod/import.php
index deee0c6e7..bf1f0ca2e 100644
--- a/mod/import.php
+++ b/mod/import.php
@@ -257,7 +257,6 @@ function import_post(&$a) {
$profile['photo'] = z_root() . '/photo/profile/l/' . $channel['channel_id'];
$profile['thumb'] = z_root() . '/photo/profile/m/' . $channel['channel_id'];
-
dbesc_array($profile);
$r = dbq("INSERT INTO profile (`"
. implode("`, `", array_keys($profile))
@@ -277,7 +276,13 @@ function import_post(&$a) {
if($hublocs) {
foreach($hublocs as $hubloc) {
- if(! array_key_exists('hubloc_primary',$hublocs)) {
+ $hash = make_xchan_hash($hubloc['hubloc_guid'],$hubloc['hubloc_guid_sig']);
+ if($hubloc['hubloc_network'] === 'zot' && $hash !== $hubloc['hubloc_hash']) {
+ logger('forged hubloc: ' . print_r($hubloc,true));
+ continue;
+ }
+
+ if(! array_key_exists('hubloc_primary',$hubloc)) {
$hubloc['hubloc_primary'] = (($hubloc['hubloc_flags'] & 0x0001) ? 1 : 0);
$hubloc['hubloc_orphancheck'] = (($hubloc['hubloc_flags'] & 0x0004) ? 1 : 0);
$hubloc['hubloc_error'] = (($hubloc['hubloc_status'] & 0x0003) ? 1 : 0);
@@ -286,7 +291,7 @@ function import_post(&$a) {
$arr = array(
'guid' => $hubloc['hubloc_guid'],
- 'guid_sig' => $hubloc['guid_sig'],
+ 'guid_sig' => $hubloc['hubloc_guid_sig'],
'url' => $hubloc['hubloc_url'],
'url_sig' => $hubloc['hubloc_url_sig']
);
@@ -384,6 +389,13 @@ function import_post(&$a) {
$xchans = $data['xchan'];
if($xchans) {
foreach($xchans as $xchan) {
+
+ $hash = make_xchan_hash($xchan['xchan_guid'],$xchan['xchan_guid_sig']);
+ if($xchan['xchan_network'] === 'zot' && $hash !== $xchan['xchan_hash']) {
+ logger('forged xchan: ' . print_r($xchan,true));
+ continue;
+ }
+
if(! array_key_exists('xchan_hidden',$xchan)) {
$xchan['xchan_hidden'] = (($xchan['xchan_flags'] & 0x0001) ? 1 : 0);
$xchan['xchan_orphan'] = (($xchan['xchan_flags'] & 0x0002) ? 1 : 0);
diff --git a/mod/urlinfo.php b/mod/linkinfo.php
index 6b9be3f6f..c3df1305d 100644
--- a/mod/urlinfo.php
+++ b/mod/linkinfo.php
@@ -1,29 +1,180 @@
<?php
-require_once('include/oembed.php');
-
-/* To-Do
-https://developers.google.com/+/plugins/snippet/
-
-<meta itemprop="name" content="Toller Titel">
-<meta itemprop="description" content="Eine tolle Beschreibung">
-<meta itemprop="image" content="http://maple.libertreeproject.org/images/tree-icon.png">
-
-<body itemscope itemtype="http://schema.org/Product">
- <h1 itemprop="name">Shiny Trinket</h1>
- <img itemprop="image" src="{image-url}" />
- <p itemprop="description">Shiny trinkets are shiny.</p>
-</body>
-*/
-
-if(!function_exists('deletenode')) {
- function deletenode(&$doc, $node)
- {
- $xpath = new DomXPath($doc);
- $list = $xpath->query("//".$node);
- foreach ($list as $child)
- $child->parentNode->removeChild($child);
+
+function arr_add_hashes(&$item,$k) {
+ $item = '#' . $item;
+}
+
+
+
+function linkinfo_content(&$a) {
+
+ logger('linkinfo: ' . print_r($_REQUEST,true));
+
+ $text = null;
+ $str_tags = '';
+
+
+ $br = "\n";
+
+ if(x($_GET,'binurl'))
+ $url = trim(hex2bin($_GET['binurl']));
+ else
+ $url = trim($_GET['url']);
+
+ if((substr($url,0,1) != '/') && (substr($url,0,4) != 'http'))
+ $url = 'http://' . $url;
+
+
+ if($_GET['title'])
+ $title = strip_tags(trim($_GET['title']));
+
+ if($_GET['description'])
+ $text = strip_tags(trim($_GET['description']));
+
+ if($_GET['tags']) {
+ $arr_tags = str_getcsv($_GET['tags']);
+ if(count($arr_tags)) {
+ array_walk($arr_tags,'arr_add_hashes');
+ $str_tags = $br . implode(' ',$arr_tags) . $br;
+ }
+ }
+
+ logger('linkinfo: ' . $url);
+
+ $result = z_fetch_url($url,false,0,array('novalidate' => true, 'nobody' => true));
+ if($result['success']) {
+ $hdrs=array();
+ $h = explode("\n",$result['header']);
+ foreach ($h as $l) {
+ list($k,$v) = array_map("trim", explode(":", trim($l), 2));
+ $hdrs[$k] = $v;
+ }
+ if (array_key_exists('Content-Type', $hdrs))
+ $type = $hdrs['Content-Type'];
+ if($type) {
+ $zrl = is_matrix_url($url);
+ if(stripos($type,'image/') !== false) {
+ if($zrl)
+ echo $br . '[zmg]' . $url . '[/zmg]' . $br;
+ else
+ echo $br . '[img]' . $url . '[/img]' . $br;
+ killme();
+ }
+ if(stripos($type,'video/') !== false) {
+ if($zrl)
+ echo $br . '[zvideo]' . $url . '[/zvideo]' . $br;
+ else
+ echo $br . '[video]' . $url . '[/video]' . $br;
+ killme();
+ }
+ if(stripos($type,'audio/') !== false) {
+ if($zrl)
+ echo $br . '[zaudio]' . $url . '[/zaudio]' . $br;
+ else
+ echo $br . '[audio]' . $url . '[/audio]' . $br;
+ killme();
+ }
+ }
+ }
+
+ $template = $br . '#^[url=%s]%s[/url]%s' . $br;
+
+ $arr = array('url' => $url, 'text' => '');
+
+ call_hooks('parse_link', $arr);
+
+ if(strlen($arr['text'])) {
+ echo $arr['text'];
+ killme();
+ }
+
+ $x = oembed_process($url);
+ if($x) {
+ echo $x;
+ killme();
+ }
+
+ if($url && $title && $text) {
+
+ $text = $br . '[quote]' . trim($text) . '[/quote]' . $br;
+
+ $title = str_replace(array("\r","\n"),array('',''),$title);
+
+ $result = sprintf($template,$url,($title) ? $title : $url,$text) . $str_tags;
+
+ logger('linkinfo (unparsed): returns: ' . $result);
+
+ echo $result;
+ killme();
+ }
+
+ $siteinfo = parseurl_getsiteinfo($url);
+
+ // If this is a Red site, use zrl rather than url so they get zids sent to them by default
+
+ if( x($siteinfo,'generator') && (strpos($siteinfo['generator'],PLATFORM_NAME . ' ') === 0))
+ $template = str_replace('url','zrl',$template);
+
+ if($siteinfo["title"] == "") {
+ echo sprintf($template,$url,$url,'') . $str_tags;
+ killme();
+ } else {
+ $text = $siteinfo["text"];
+ $title = $siteinfo["title"];
+ }
+
+ $image = "";
+
+ if(sizeof($siteinfo["images"]) > 0){
+ /* Execute below code only if image is present in siteinfo */
+
+ $total_images = 0;
+ $max_images = get_config('system','max_bookmark_images');
+ if($max_images === false)
+ $max_images = 2;
+ else
+ $max_images = intval($max_images);
+
+ foreach ($siteinfo["images"] as $imagedata) {
+ if ($url) {
+ $image .= sprintf('[url=%s]', $url);
+ }
+ $image .= '[img='.$imagedata["width"].'x'.$imagedata["height"].']'.$imagedata["src"].'[/img]';
+ if ($url) {
+ $image .= '[/url]';
+ }
+ $image .= "\n";
+ $total_images ++;
+ if($max_images && $max_images >= $total_images)
+ break;
+ }
+ }
+
+ if(strlen($text)) {
+ $text = $br.'[quote]'.trim($text).'[/quote]'.$br ;
}
+
+ if($image) {
+ $text = $br.$br.$image.$text;
+ }
+ $title = str_replace(array("\r","\n"),array('',''),$title);
+
+ $result = sprintf($template,$url,($title) ? $title : $url,$text) . $str_tags;
+
+ logger('linkinfo: returns: ' . $result, LOGGER_DEBUG);
+
+ echo trim($result);
+ killme();
+
+}
+
+
+function deletexnode(&$doc, $node) {
+ $xpath = new DomXPath($doc);
+ $list = $xpath->query("//".$node);
+ foreach ($list as $child)
+ $child->parentNode->removeChild($child);
}
function completeurl($url, $scheme) {
@@ -53,6 +204,7 @@ function completeurl($url, $scheme) {
return($complete);
}
+
function parseurl_getsiteinfo($url) {
$siteinfo = array();
@@ -70,17 +222,17 @@ function parseurl_getsiteinfo($url) {
$doc = new DOMDocument();
@$doc->loadHTML($body);
- deletenode($doc, 'style');
- deletenode($doc, 'script');
- deletenode($doc, 'option');
- deletenode($doc, 'h1');
- deletenode($doc, 'h2');
- deletenode($doc, 'h3');
- deletenode($doc, 'h4');
- deletenode($doc, 'h5');
- deletenode($doc, 'h6');
- deletenode($doc, 'ol');
- deletenode($doc, 'ul');
+ deletexnode($doc, 'style');
+ deletexnode($doc, 'script');
+ deletexnode($doc, 'option');
+ deletexnode($doc, 'h1');
+ deletexnode($doc, 'h2');
+ deletexnode($doc, 'h3');
+ deletexnode($doc, 'h4');
+ deletexnode($doc, 'h5');
+ deletexnode($doc, 'h6');
+ deletexnode($doc, 'ol');
+ deletexnode($doc, 'ul');
$xpath = new DomXPath($doc);
@@ -215,169 +367,3 @@ function parseurl_getsiteinfo($url) {
return($siteinfo);
}
-
-function arr_add_hashes(&$item,$k) {
- $item = '#' . $item;
-}
-
-function urlinfo_content(&$a) {
-
- logger('urlinfo: ' . print_r($_REQUEST,true));
-
- $text = null;
- $str_tags = '';
-
-
- $br = "\n";
-
- if(x($_GET,'binurl'))
- $url = trim(hex2bin($_GET['binurl']));
- else
- $url = trim($_GET['url']);
-
- if((substr($url,0,1) != '/') && (substr($url,0,4) != 'http'))
- $url = 'http://' . $url;
-
-
- if($_GET['title'])
- $title = strip_tags(trim($_GET['title']));
-
- if($_GET['description'])
- $text = strip_tags(trim($_GET['description']));
-
- if($_GET['tags']) {
- $arr_tags = str_getcsv($_GET['tags']);
- if(count($arr_tags)) {
- array_walk($arr_tags,'arr_add_hashes');
- $str_tags = $br . implode(' ',$arr_tags) . $br;
- }
- }
-
- logger('urlinfo: ' . $url);
-
- $result = z_fetch_url($url,false,0,array('novalidate' => true, 'nobody' => true));
- if($result['success']) {
- $hdrs=array();
- $h = explode("\n",$result['header']);
- foreach ($h as $l) {
- list($k,$v) = array_map("trim", explode(":", trim($l), 2));
- $hdrs[$k] = $v;
- }
- if (array_key_exists('Content-Type', $hdrs))
- $type = $hdrs['Content-Type'];
- if($type) {
- $zrl = is_matrix_url($url);
- if(stripos($type,'image/') !== false) {
- if($zrl)
- echo $br . '[zmg]' . $url . '[/zmg]' . $br;
- else
- echo $br . '[img]' . $url . '[/img]' . $br;
- killme();
- }
- if(stripos($type,'video/') !== false) {
- if($zrl)
- echo $br . '[zvideo]' . $url . '[/zvideo]' . $br;
- else
- echo $br . '[video]' . $url . '[/video]' . $br;
- killme();
- }
- if(stripos($type,'audio/') !== false) {
- if($zrl)
- echo $br . '[zaudio]' . $url . '[/zaudio]' . $br;
- else
- echo $br . '[audio]' . $url . '[/audio]' . $br;
- killme();
- }
- }
- }
-
- $template = $br . '#^[url=%s]%s[/url]%s' . $br;
-
- $arr = array('url' => $url, 'text' => '');
-
- call_hooks('parse_link', $arr);
-
- if(strlen($arr['text'])) {
- echo $arr['text'];
- killme();
- }
-
- $x = oembed_process($url);
- if($x) {
- echo $x;
- killme();
- }
-
- if($url && $title && $text) {
-
-
- $text = $br . '[quote]' . trim($text) . '[/quote]' . $br;
-
- $title = str_replace(array("\r","\n"),array('',''),$title);
-
- $result = sprintf($template,$url,($title) ? $title : $url,$text) . $str_tags;
-
- logger('urlinfo (unparsed): returns: ' . $result);
-
- echo $result;
- killme();
- }
-
- $siteinfo = parseurl_getsiteinfo($url);
-
- // If this is a Red site, use zrl rather than url so they get zids sent to them by default
-
- if( x($siteinfo,'generator') && (strpos($siteinfo['generator'],PLATFORM_NAME . ' ') === 0))
- $template = str_replace('url','zrl',$template);
-
- if($siteinfo["title"] == "") {
- echo sprintf($template,$url,$url,'') . $str_tags;
- killme();
- } else {
- $text = $siteinfo["text"];
- $title = $siteinfo["title"];
- }
-
- $image = "";
-
- if(sizeof($siteinfo["images"]) > 0){
- /* Execute below code only if image is present in siteinfo */
-
- $total_images = 0;
- $max_images = get_config('system','max_bookmark_images');
- if($max_images === false)
- $max_images = 2;
- else
- $max_images = intval($max_images);
-
- foreach ($siteinfo["images"] as $imagedata) {
- if ($url) {
- $image .= sprintf('[url=%s]', $url);
- }
- $image .= '[img='.$imagedata["width"].'x'.$imagedata["height"].']'.$imagedata["src"].'[/img]';
- if ($url) {
- $image .= '[/url]';
- }
- $image .= "\n";
- $total_images ++;
- if($max_images && $max_images >= $total_images)
- break;
- }
- }
-
- if(strlen($text)) {
- $text = $br.'[quote]'.trim($text).'[/quote]'.$br ;
- }
-
- if($image) {
- $text = $br.$br.$image.$text;
- }
- $title = str_replace(array("\r","\n"),array('',''),$title);
-
- $result = sprintf($template,$url,($title) ? $title : $url,$text) . $str_tags;
-
- logger('urlinfo: returns: ' . $result, LOGGER_DEBUG);
-
- echo trim($result);
- killme();
-}
diff --git a/mod/xrd.php b/mod/xrd.php
index 4fa81c7f3..d547194ad 100644
--- a/mod/xrd.php
+++ b/mod/xrd.php
@@ -24,7 +24,7 @@ function xrd_init(&$a) {
$dspr = replace_macros(get_markup_template('xrd_diaspora.tpl'),array(
'$baseurl' => $a->get_baseurl(),
- '$dspr_guid' => $r[0]['channel_guid'],
+ '$dspr_guid' => $r[0]['channel_guid'] . str_replace('.','',$a->get_hostname()),
'$dspr_key' => base64_encode(pemtorsa($r[0]['channel_pubkey']))
));
diff --git a/mod/zfinger.php b/mod/zfinger.php
index 8ddd92f3d..ba80fc9b6 100644
--- a/mod/zfinger.php
+++ b/mod/zfinger.php
@@ -108,7 +108,7 @@ function zfinger_init(&$a) {
$public_forum = false;
$role = get_pconfig($e['channel_id'],'system','permissions_role');
- if($role === 'forum') {
+ if($role === 'forum' || $role === 'repository') {
$public_forum = true;
}
else {