aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-07-14 01:38:16 -0700
committerfriendica <info@friendica.com>2014-07-14 01:38:16 -0700
commit233e4e13636edd857ded7393555feb4bf198eed3 (patch)
tree27c06018d534ff5e411a8aff4831a513d92801a5
parent17bd39fcd4b28e6475a8a349f136c788202eaff4 (diff)
downloadvolse-hubzilla-233e4e13636edd857ded7393555feb4bf198eed3.tar.gz
volse-hubzilla-233e4e13636edd857ded7393555feb4bf198eed3.tar.bz2
volse-hubzilla-233e4e13636edd857ded7393555feb4bf198eed3.zip
remove some code duplication
-rw-r--r--include/bbcode.php22
-rw-r--r--include/bookmarks.php11
-rw-r--r--include/hubloc.php12
-rwxr-xr-xinclude/items.php22
-rwxr-xr-xinclude/oembed.php16
-rw-r--r--version.inc2
6 files changed, 26 insertions, 59 deletions
diff --git a/include/bbcode.php b/include/bbcode.php
index bab50240c..45126c0eb 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -3,7 +3,7 @@
require_once("include/oembed.php");
require_once('include/event.php');
require_once('include/zot.php');
-
+require_once('include/hubloc.php');
function tryoembed($match) {
$url = ((count($match)==2)?$match[1]:$match[2]);
@@ -19,15 +19,7 @@ function tryoembed($match) {
function tryzrlaudio($match) {
$link = $match[1];
- $m = @parse_url($link);
- $zrl = false;
- if($m['host']) {
- $r = q("select hubloc_url from hubloc where hubloc_host = '%s' limit 1",
- dbesc($m['host'])
- );
- if($r)
- $zrl = true;
- }
+ $zrl = is_matrix_url($link);
if($zrl)
$link = zid($link);
return '<audio src="' . $link . '" controls="controls" ><a href="' . $link . '">' . $link . '</a></audio>';
@@ -35,15 +27,7 @@ function tryzrlaudio($match) {
function tryzrlvideo($match) {
$link = $match[1];
- $m = @parse_url($link);
- $zrl = false;
- if($m['host']) {
- $r = q("select hubloc_url from hubloc where hubloc_host = '%s' limit 1",
- dbesc($m['host'])
- );
- if($r)
- $zrl = true;
- }
+ $zrl = is_matrix_url($link);
if($zrl)
$link = zid($link);
return '<video controls="controls" src="' . $link . '" style="width:100%; max-width:' . get_app()->videowidth . 'px"><a href="' . $link . '">' . $link . '</a></video>';
diff --git a/include/bookmarks.php b/include/bookmarks.php
index 21a775f9a..e70158476 100644
--- a/include/bookmarks.php
+++ b/include/bookmarks.php
@@ -23,15 +23,8 @@ function bookmark_add($channel,$sender,$taxonomy,$private,$opts = null) {
$iarr['mitem_desc'] = $taxonomy['term'];
$iarr['mitem_flags'] = (($ischat) ? MENU_ITEM_CHATROOM : 0);
- $m = @parse_url($taxonomy['url']);
- $zrl = false;
- if($m['host']) {
- $r = q("select hubloc_url from hubloc where hubloc_host = '%s' limit 1",
- dbesc($m['host'])
- );
- if($r)
- $zrl = true;
- }
+ require_once('include/hubloc.php');
+ $zrl = is_matrix_url($taxonomy['url']);
if($zrl)
$iarr['mitem_flags'] |= MENU_ITEM_ZID;
diff --git a/include/hubloc.php b/include/hubloc.php
index 35d9dbeb1..566875ce9 100644
--- a/include/hubloc.php
+++ b/include/hubloc.php
@@ -1,5 +1,17 @@
<?php /** @file */
+function is_matrix_url($url) {
+ $m = @parse_url($url);
+ if($m['host']) {
+ $r = q("select hubloc_url from hubloc where hubloc_host = '%s' limit 1",
+ dbesc($m['host'])
+ );
+ if($r)
+ return true;
+ }
+ return false;
+}
+
function prune_hub_reinstalls() {
diff --git a/include/items.php b/include/items.php
index 7f4dabaa7..26d2fbe1c 100755
--- a/include/items.php
+++ b/include/items.php
@@ -189,15 +189,8 @@ function add_source_route($iid,$hash) {
function red_zrl_callback($matches) {
- $m = @parse_url($matches[2]);
- $zrl = false;
- if($m['host']) {
- $r = q("select hubloc_url from hubloc where hubloc_host = '%s' limit 1",
- dbesc($m['host'])
- );
- if($r)
- $zrl = true;
- }
+ require_once('include/hubloc.php');
+ $zrl = is_matrix_url($matches[2]);
$t = strip_zids($matches[2]);
if($t !== $matches[2]) {
@@ -236,15 +229,8 @@ function red_unescape_codeblock($m) {
function red_zrlify_img_callback($matches) {
- $m = @parse_url($matches[2]);
- $zrl = false;
- if($m['host']) {
- $r = q("select hubloc_url from hubloc where hubloc_host = '%s' limit 1",
- dbesc($m['host'])
- );
- if($r)
- $zrl = true;
- }
+ require_once('include/hubloc.php');
+ $zrl = is_matrix_url($matches[2]);
$t = strip_zids($matches[2]);
if($t !== $matches[2]) {
diff --git a/include/oembed.php b/include/oembed.php
index 42a9881ed..de3a6edc8 100755
--- a/include/oembed.php
+++ b/include/oembed.php
@@ -29,18 +29,10 @@ function oembed_fetch_url($embedurl){
$txt = "";
if (in_array($ext, $noexts)) {
- $m = @parse_url($embedurl);
- $zrl = false;
- if($m['host']) {
- $r = q("select hubloc_url from hubloc where hubloc_host = '%s' limit 1",
- dbesc($m['host'])
- );
- if($r)
- $zrl = true;
- }
- if($zrl) {
- $embedurl = zid($embedurl);
- }
+ require_once('include/hubloc.php');
+ $zrl = is_matrix_url($embedurl);
+ if($zrl)
+ $embedurl = zid($embedurl);
}
else {
// try oembed autodiscovery
diff --git a/version.inc b/version.inc
index 575af80dc..053356f75 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2014-07-13.735
+2014-07-14.736