aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authormrjive <mrjive@mrjive.it>2016-02-03 22:46:54 +0100
committermrjive <mrjive@mrjive.it>2016-02-03 22:46:54 +0100
commite527a52f6a123b695775a24fdeb64d0a5ab00df9 (patch)
tree7f72feb65e8f8790d6d80f631d1e608bfed1dd48 /mod
parent337735094b944fd31ed96e36c869227a0d63e5d1 (diff)
parenta7ed50ecd4b4defbc1d5fdf0bb4fd7d65d08a0fd (diff)
downloadvolse-hubzilla-e527a52f6a123b695775a24fdeb64d0a5ab00df9.tar.gz
volse-hubzilla-e527a52f6a123b695775a24fdeb64d0a5ab00df9.tar.bz2
volse-hubzilla-e527a52f6a123b695775a24fdeb64d0a5ab00df9.zip
Merge pull request #21 from redmatrix/master
updating from original codebase
Diffstat (limited to 'mod')
-rw-r--r--mod/channel.php2
-rw-r--r--mod/linkinfo.php2
-rw-r--r--mod/oep.php179
-rw-r--r--mod/profile.php1
4 files changed, 183 insertions, 1 deletions
diff --git a/mod/channel.php b/mod/channel.php
index 3b80e2cb8..dcccb16b6 100644
--- a/mod/channel.php
+++ b/mod/channel.php
@@ -156,6 +156,8 @@ function channel_content(&$a, $update = 0, $load = false) {
$abook_uids = " and abook.abook_channel = " . intval($a->profile['profile_uid']) . " ";
$simple_update = (($update) ? " AND item_unseen = 1 " : '');
+
+ $a->page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . $a->query_string) . '" title="oembed" />' . "\r\n";
if($update && $_SESSION['loadtime'])
$simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) ";
diff --git a/mod/linkinfo.php b/mod/linkinfo.php
index d615b178f..5d9e2bc67 100644
--- a/mod/linkinfo.php
+++ b/mod/linkinfo.php
@@ -22,6 +22,8 @@ function linkinfo_content(&$a) {
else
$url = trim($_GET['url']);
+ $url = strip_zids($url);
+
if((substr($url,0,1) != '/') && (substr($url,0,4) != 'http'))
$url = 'http://' . $url;
diff --git a/mod/oep.php b/mod/oep.php
index 9bc0de98f..3855a1b4a 100644
--- a/mod/oep.php
+++ b/mod/oep.php
@@ -6,9 +6,13 @@
function oep_init(&$a) {
+ logger('oep: ' . print_r($_REQUEST,true), LOGGER_DEBUG, LOG_INFO);
+ if($_REQUEST['url']) {
+ $_REQUEST['url'] = strip_zids($_REQUEST['url']);
+ $url = $_REQUEST['url'];
+ }
- $url = $_REQUEST['url'];
if(! $url)
http_status_exit(404, 'Not found');
@@ -24,6 +28,14 @@ function oep_init(&$a) {
$arr = oep_photo_reply($_REQUEST);
elseif(fnmatch('*/photos*',$url))
$arr = oep_phototop_reply($_REQUEST);
+ elseif(fnmatch('*/display/*',$url))
+ $arr = oep_display_reply($_REQUEST);
+ elseif(fnmatch('*/channel/*mid=*',$url))
+ $arr = oep_mid_reply($_REQUEST);
+ elseif(fnmatch('*/channel*',$url))
+ $arr = oep_profile_reply($_REQUEST);
+ elseif(fnmatch('*/profile/*',$url))
+ $arr = oep_profile_reply($_REQUEST);
if($arr) {
header('Content-Type: application/json+oembed');
@@ -35,6 +47,171 @@ function oep_init(&$a) {
}
+function oep_display_reply($args) {
+
+ $ret = array();
+ $url = $args['url'];
+ $maxwidth = intval($args['maxwidth']);
+ $maxheight = intval($args['maxheight']);
+
+ if(preg_match('#//(.*?)/(.*?)/(.*?)/(.*?)mid\=(.*?)(&|$)#',$url,$matches)) {
+ $chn = $matches[3];
+ $res = $matches[5];
+ }
+
+ if(! ($chn && $res))
+ return;
+ $c = q("select * from channel where channel_address = '%s' limit 1",
+ dbesc($chn)
+ );
+
+ if(! $c)
+ return;
+
+ $sql_extra = item_permissions_sql($c[0]['channel_id']);
+
+ $p = q("select * from item where mid = '%s' and uid = %d $sql_extra limit 1",
+ dbesc($res),
+ intval($c[0]['channel_id'])
+ );
+ if(! $p)
+ return;
+
+ xchan_query($p,true);
+ $p = fetch_post_tags($p,true);
+
+ $o = "[share author='".urlencode($p[0]['author']['xchan_name']).
+ "' profile='".$p[0]['author']['xchan_url'] .
+ "' avatar='".$p[0]['author']['xchan_photo_s'].
+ "' link='".$p[0]['plink'].
+ "' posted='".$p[0]['created'].
+ "' message_id='".$p[0]['mid']."']";
+ if($p[0]['title'])
+ $o .= '[b]'.$p[0]['title'].'[/b]'."\r\n";
+ $o .= $p[0]['body'];
+ $o .= "[/share]";
+ $o = bbcode($o);
+
+ $ret['type'] = 'rich';
+
+ $w = (($maxwidth) ? $maxwidth : 640);
+ $h = (($maxheight) ? $maxheight : $w * 2 / 3);
+
+ $ret['html'] = '<div style="width: ' . $w . '; height: ' . $h . ';" >' . $o . '</div>';
+
+ $ret['width'] = $w;
+ $ret['height'] = $h;
+
+ return $ret;
+
+}
+
+function oep_mid_reply($args) {
+
+ $ret = array();
+ $url = $args['url'];
+ $maxwidth = intval($args['maxwidth']);
+ $maxheight = intval($args['maxheight']);
+
+ if(preg_match('#//(.*?)/(.*?)/(.*?)/(.*?)mid\=(.*?)(&|$)#',$url,$matches)) {
+ $chn = $matches[3];
+ $res = $matches[5];
+ }
+
+ if(! ($chn && $res))
+ return;
+ $c = q("select * from channel where channel_address = '%s' limit 1",
+ dbesc($chn)
+ );
+
+ if(! $c)
+ return;
+
+ $sql_extra = item_permissions_sql($c[0]['channel_id']);
+
+ $p = q("select * from item where mid = '%s' and uid = %d $sql_extra limit 1",
+ dbesc($res),
+ intval($c[0]['channel_id'])
+ );
+ if(! $p)
+ return;
+
+ xchan_query($p,true);
+ $p = fetch_post_tags($p,true);
+
+ $o = "[share author='".urlencode($p[0]['author']['xchan_name']).
+ "' profile='".$p[0]['author']['xchan_url'] .
+ "' avatar='".$p[0]['author']['xchan_photo_s'].
+ "' link='".$p[0]['plink'].
+ "' posted='".$p[0]['created'].
+ "' message_id='".$p[0]['mid']."']";
+ if($p[0]['title'])
+ $o .= '[b]'.$p[0]['title'].'[/b]'."\r\n";
+ $o .= $p[0]['body'];
+ $o .= "[/share]";
+ $o = bbcode($o);
+
+ $ret['type'] = 'rich';
+
+ $w = (($maxwidth) ? $maxwidth : 640);
+ $h = (($maxheight) ? $maxheight : $w * 2 / 3);
+
+ $ret['html'] = '<div style="width: ' . $w . '; height: ' . $h . ';" >' . $o . '</div>';
+
+ $ret['width'] = $w;
+ $ret['height'] = $h;
+
+ return $ret;
+
+}
+
+function oep_profile_reply($args) {
+
+
+ require_once('include/identity.php');
+ require_once('include/Contact.php');
+ $url = $args['url'];
+
+ if(preg_match('#//(.*?)/(.*?)/(.*?)(/|\?|&|$)#',$url,$matches)) {
+ $chn = $matches[3];
+ }
+
+ if(! $chn)
+ return;
+
+ $c = channelx_by_nick($chn);
+
+ if(! $c)
+ return;
+
+
+ $maxwidth = intval($args['maxwidth']);
+ $maxheight = intval($args['maxheight']);
+
+ $width = 800;
+ $height = 375;
+
+ if($maxwidth) {
+ $width = $maxwidth;
+ $height = (375 / 800) * $width;
+ }
+ if($maxheight) {
+ if($maxheight < $height) {
+ $width = (800 / 375) * $maxheight;
+ $height = $maxheight;
+ }
+ }
+ $ret = array();
+
+ $ret['type'] = 'rich';
+ $ret['width'] = intval($width);
+ $ret['height'] = intval($height);
+
+ $ret['html'] = get_zcard($c,get_observer_hash(),array('width' => $width, 'height' => $height));
+
+ return $ret;
+
+}
function oep_album_reply($args) {
diff --git a/mod/profile.php b/mod/profile.php
index 430d039e9..7ee03a77b 100644
--- a/mod/profile.php
+++ b/mod/profile.php
@@ -75,6 +75,7 @@ function profile_content(&$a, $update = 0) {
$o .= profile_tabs($a, $is_owner, $a->profile['channel_address']);
+ $a->page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . $a->query_string) . '" title="oembed" />' . "\r\n";
$o .= advanced_profile($a);
call_hooks('profile_advanced',$o);