Merge branch 'pull'
This commit is contained in:
commit
4218e3f494
1
boot.php
1
boot.php
|
@ -6,6 +6,7 @@ require_once('include/plugin.php');
|
||||||
require_once('include/text.php');
|
require_once('include/text.php');
|
||||||
require_once("include/pgettext.php");
|
require_once("include/pgettext.php");
|
||||||
require_once('include/nav.php');
|
require_once('include/nav.php');
|
||||||
|
require_once('include/cache.php');
|
||||||
|
|
||||||
define ( 'FRIENDIKA_PLATFORM', 'Free Friendika');
|
define ( 'FRIENDIKA_PLATFORM', 'Free Friendika');
|
||||||
define ( 'FRIENDIKA_VERSION', '2.3.1144' );
|
define ( 'FRIENDIKA_VERSION', '2.3.1144' );
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 420 B |
Binary file not shown.
After Width: | Height: | Size: 508 B |
Binary file not shown.
After Width: | Height: | Size: 601 B |
Binary file not shown.
After Width: | Height: | Size: 1017 B |
|
@ -1,7 +1,8 @@
|
||||||
|
|
||||||
IMAGES=add.png edit.png gear.png info.png menu.png \
|
IMAGES=add.png edit.png gear.png info.png menu.png \
|
||||||
notify_off.png star.png delete.png feed.png group.png \
|
notify_off.png star.png delete.png feed.png group.png \
|
||||||
lock.png notice.png notify_on.png user.png link.png
|
lock.png notice.png notify_on.png user.png link.png \
|
||||||
|
play.png
|
||||||
|
|
||||||
DESTS=10/ 16/ 22/ 48/ \
|
DESTS=10/ 16/ 22/ 48/ \
|
||||||
$(addprefix 10/, $(IMAGES)) \
|
$(addprefix 10/, $(IMAGES)) \
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 6.1 KiB |
|
@ -9,6 +9,22 @@ function stripcode_br_cb($s) {
|
||||||
return '[code]' . str_replace('<br />', '', $s[1]) . '[/code]';
|
return '[code]' . str_replace('<br />', '', $s[1]) . '[/code]';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function tryoembed($match){
|
||||||
|
$url = ((count($match)==2)?$match[1]:$match[2]);
|
||||||
|
|
||||||
|
$o = oembed_fetch_url($url);
|
||||||
|
|
||||||
|
//echo "<pre>"; var_dump($match, $url, $o); killme();
|
||||||
|
|
||||||
|
if ($o->type=="error") return $match[0];
|
||||||
|
|
||||||
|
$html = oembed_format_object($o);
|
||||||
|
|
||||||
|
return $html;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// BBcode 2 HTML was written by WAY2WEB.net
|
// BBcode 2 HTML was written by WAY2WEB.net
|
||||||
// extended to work with Mistpark/Friendika - Mike Macgirvin
|
// extended to work with Mistpark/Friendika - Mike Macgirvin
|
||||||
|
@ -40,11 +56,14 @@ function bbcode($Text,$preserve_nl = false) {
|
||||||
// Set up the parameters for a MAIL search string
|
// Set up the parameters for a MAIL search string
|
||||||
$MAILSearchString = $URLSearchString;
|
$MAILSearchString = $URLSearchString;
|
||||||
|
|
||||||
|
|
||||||
// Perform URL Search
|
// Perform URL Search
|
||||||
|
|
||||||
|
|
||||||
$Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1<a href="$2" target="external-link">$2</a>', $Text);
|
$Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1<a href="$2" target="external-link">$2</a>', $Text);
|
||||||
|
|
||||||
|
$Text = preg_replace_callback("/\[bookmark\=([^\]]*)\].*?\[\/bookmark\]/ism",'tryoembed',$Text);
|
||||||
|
$Text = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",'[url=$1]$2[/url]',$Text);
|
||||||
|
|
||||||
|
$Text = preg_replace_callback("/\[url\]([$URLSearchString]*)\[\/url\]/ism",'tryoembed',$Text);
|
||||||
$Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/ism", '<a href="$1" target="external-link">$1</a>', $Text);
|
$Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/ism", '<a href="$1" target="external-link">$1</a>', $Text);
|
||||||
$Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '<a href="$1" target="external-link">$2</a>', $Text);
|
$Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '<a href="$1" target="external-link">$2</a>', $Text);
|
||||||
//$Text = preg_replace("/\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[\/url\]/ism", '<a href="$1" target="_blank">$2</a>', $Text);
|
//$Text = preg_replace("/\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[\/url\]/ism", '<a href="$1" target="_blank">$2</a>', $Text);
|
||||||
|
@ -120,6 +139,13 @@ function bbcode($Text,$preserve_nl = false) {
|
||||||
// [img]pathtoimage[/img]
|
// [img]pathtoimage[/img]
|
||||||
$Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img src="$1" alt="' . t('Image/photo') . '" />', $Text);
|
$Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img src="$1" alt="' . t('Image/photo') . '" />', $Text);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Try to Oembed
|
||||||
|
$Text = preg_replace_callback("/\[video\](.*?)\[\/video\]/ism", 'tryoembed', $Text);
|
||||||
|
$Text = preg_replace_callback("/\[audio\](.*?)\[\/audio\]/ism", 'tryoembed', $Text);
|
||||||
|
|
||||||
|
|
||||||
// html5 video and audio
|
// html5 video and audio
|
||||||
|
|
||||||
$Text = preg_replace("/\[video\](.*?)\[\/video\]/ism", '<video src="$1" controls="controls" width="425" height="350"><a href="$1">$1</a></video>', $Text);
|
$Text = preg_replace("/\[video\](.*?)\[\/video\]/ism", '<video src="$1" controls="controls" width="425" height="350"><a href="$1">$1</a></video>', $Text);
|
||||||
|
@ -129,17 +155,25 @@ function bbcode($Text,$preserve_nl = false) {
|
||||||
$Text = preg_replace("/\[iframe\](.*?)\[\/iframe\]/ism", '<iframe src="$1" width="425" height="350"><a href="$1">$1</a></iframe>', $Text);
|
$Text = preg_replace("/\[iframe\](.*?)\[\/iframe\]/ism", '<iframe src="$1" width="425" height="350"><a href="$1">$1</a></iframe>', $Text);
|
||||||
|
|
||||||
|
|
||||||
if (get_pconfig(local_user(), 'oembed', 'use_for_youtube' )==1){
|
/*if (get_pconfig(local_user(), 'oembed', 'use_for_youtube' )==1){
|
||||||
// use oembed for youtube links
|
// use oembed for youtube links
|
||||||
$Text = preg_replace("/\[youtube\]/",'[embed]',$Text);
|
$Text = preg_replace("/\[youtube\]/",'[embed]',$Text);
|
||||||
$Text = preg_replace("/\[\/youtube\]/",'[/embed]',$Text);
|
$Text = preg_replace("/\[\/youtube\]/",'[/embed]',$Text);
|
||||||
} else {
|
} else {*/
|
||||||
// Youtube extensions
|
// Youtube extensions
|
||||||
|
$Text = preg_replace_callback("/\[youtube\](https?:\/\/www.youtube.com\/watch\?v\=.*?)\[\/youtube\]/ism", 'tryoembed', $Text);
|
||||||
|
$Text = preg_replace_callback("/\[youtube\](https?:\/\/youtu.be\/.*?)\[\/youtube\]/ism",'tryoembed',$Text);
|
||||||
|
|
||||||
$Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text);
|
$Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text);
|
||||||
$Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/embed\/(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text);
|
$Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/embed\/(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text);
|
||||||
$Text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text);
|
$Text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text);
|
||||||
|
|
||||||
|
|
||||||
$Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '<iframe width="425" height="350" src="http://www.youtube.com/embed/$1" frameborder="0" ></iframe>', $Text);
|
$Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '<iframe width="425" height="350" src="http://www.youtube.com/embed/$1" frameborder="0" ></iframe>', $Text);
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
$Text = preg_replace_callback("/\[vimeo\](https?:\/\/player.vimeo.com\/video\/[0-9]+).*?\[\/vimeo\]/ism",'tryoembed',$Text);
|
||||||
|
$Text = preg_replace_callback("/\[vimeo\](https?:\/\/vimeo.com\/[0-9]+).*?\[\/vimeo\]/ism",'tryoembed',$Text);
|
||||||
|
|
||||||
$Text = preg_replace("/\[vimeo\]https?:\/\/player.vimeo.com\/video\/([0-9]+)(.*?)\[\/vimeo\]/ism",'[vimeo]$1[/vimeo]',$Text);
|
$Text = preg_replace("/\[vimeo\]https?:\/\/player.vimeo.com\/video\/([0-9]+)(.*?)\[\/vimeo\]/ism",'[vimeo]$1[/vimeo]',$Text);
|
||||||
$Text = preg_replace("/\[vimeo\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/vimeo\]/ism",'[vimeo]$1[/vimeo]',$Text);
|
$Text = preg_replace("/\[vimeo\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/vimeo\]/ism",'[vimeo]$1[/vimeo]',$Text);
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* cache api
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Cache {
|
||||||
|
public static function get($key){
|
||||||
|
$r = q("SELECT `v` FROM `cache` WHERE `k`='%s'",
|
||||||
|
dbesc($key)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (count($r)) return $r[0]['v'];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function set($key,$value) {
|
||||||
|
q("INSERT INTO `cache` VALUES ('%s','%s','%s')",
|
||||||
|
dbesc($key),
|
||||||
|
dbesc($value),
|
||||||
|
dbesc(datetime_convert()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function clear(){
|
||||||
|
q("DELETE FROM `cache` WHERE `updated` < '%s'",
|
||||||
|
dbesc(datetime_convert('UTC','UTC',"now - 30 days")));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -7,30 +7,27 @@ function oembed_replacecb($matches){
|
||||||
|
|
||||||
|
|
||||||
function oembed_fetch_url($embedurl){
|
function oembed_fetch_url($embedurl){
|
||||||
|
|
||||||
$r = q("SELECT v FROM `cache` WHERE k='%s'",
|
$txt = Cache::get($embedurl);
|
||||||
dbesc($embedurl));
|
|
||||||
|
|
||||||
if(count($r)){
|
if(is_null($txt)){
|
||||||
$txt = $r[0]['v'];
|
|
||||||
} else {
|
|
||||||
$txt = "";
|
$txt = "";
|
||||||
|
|
||||||
// try oembed autodiscovery
|
// try oembed autodiscovery
|
||||||
$redirects = 0;
|
$redirects = 0;
|
||||||
$html_text = fetch_url($embedurl, false, $redirects, 15);
|
$html_text = fetch_url($embedurl, false, $redirects, 15);
|
||||||
if(! $html_text)
|
if($html_text){
|
||||||
return;
|
$dom = @DOMDocument::loadHTML($html_text);
|
||||||
$dom = @DOMDocument::loadHTML($html_text);
|
if ($dom){
|
||||||
if ($dom){
|
$xpath = new DOMXPath($dom);
|
||||||
$xpath = new DOMXPath($dom);
|
$attr = "oembed";
|
||||||
$attr = "oembed";
|
|
||||||
|
$xattr = oe_build_xpath("class","oembed");
|
||||||
$xattr = oe_build_xpath("class","oembed");
|
$entries = $xpath->query("//link[@type='application/json+oembed']");
|
||||||
$entries = $xpath->query("//link[@type='application/json+oembed']");
|
foreach($entries as $e){
|
||||||
foreach($entries as $e){
|
$href = $e->getAttributeNode("href")->nodeValue;
|
||||||
$href = $e->getAttributeNode("href")->nodeValue;
|
$txt = fetch_url($href);
|
||||||
$txt = fetch_url($href);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,10 +41,8 @@ function oembed_fetch_url($embedurl){
|
||||||
if ($txt[0]!="{") $txt='{"type":"error"}';
|
if ($txt[0]!="{") $txt='{"type":"error"}';
|
||||||
|
|
||||||
//save in cache
|
//save in cache
|
||||||
/*q("INSERT INTO `cache` VALUES ('%s','%s','%s')",
|
Cache::set($embedurl,$txt);
|
||||||
dbesc($embedurl),
|
|
||||||
dbesc($txt),
|
|
||||||
dbesc(datetime_convert()));*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$j = json_decode($txt);
|
$j = json_decode($txt);
|
||||||
|
@ -61,12 +56,20 @@ function oembed_format_object($j){
|
||||||
switch ($j->type) {
|
switch ($j->type) {
|
||||||
case "video": {
|
case "video": {
|
||||||
if (isset($j->thumbnail_url)) {
|
if (isset($j->thumbnail_url)) {
|
||||||
/*$tw = (isset($j->thumbnail_width)) ? $j->thumbnail_width:200;
|
$tw = (isset($j->thumbnail_width)) ? $j->thumbnail_width:200;
|
||||||
$th = (isset($j->thumbnail_height)) ? $j->thumbnail_height:180;*/
|
$th = (isset($j->thumbnail_height)) ? $j->thumbnail_height:180;
|
||||||
$tw=150; $th=120;
|
$tr = $tw/$th;
|
||||||
$ret.= "<a href='".$embedurl."' onclick='this.innerHTML=unescape(\"".urlencode($j->html)."\").replace(/\+/g,\" \"); return false;' style='float:left; margin: 1em; '>";
|
|
||||||
$ret.= "<img width='$tw' height='$th' src='".$j->thumbnail_url."'>";
|
$th=120; $tw = $th*$tr;
|
||||||
$ret.= "</a>";
|
$tpl=get_markup_template('oembed_video.tpl');
|
||||||
|
$ret.=replace_macros($tpl, array(
|
||||||
|
'$embedurl'=>$embedurl,
|
||||||
|
'$escapedhtml'=>urlencode($j->html),
|
||||||
|
'$tw'=>$tw,
|
||||||
|
'$th'=>$th,
|
||||||
|
'$turl'=>$j->thumbnail_url,
|
||||||
|
));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$ret=$j->html;
|
$ret=$j->html;
|
||||||
}
|
}
|
||||||
|
@ -154,4 +157,5 @@ function oembed_html2bbcode($text) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
|
|
|
@ -64,8 +64,7 @@ function poller_run($argv, $argc){
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear old cache
|
// clear old cache
|
||||||
q("DELETE FROM `cache` WHERE `updated` < '%s'",
|
Cache::clear();
|
||||||
dbesc(datetime_convert('UTC','UTC',"now - 30 days")));
|
|
||||||
|
|
||||||
$manual_id = 0;
|
$manual_id = 0;
|
||||||
$generation = 0;
|
$generation = 0;
|
||||||
|
|
|
@ -338,7 +338,6 @@ function item_post(&$a) {
|
||||||
$bookmark = 0;
|
$bookmark = 0;
|
||||||
if(preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",$body,$match)) {
|
if(preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",$body,$match)) {
|
||||||
$bookmark = 1;
|
$bookmark = 1;
|
||||||
$body = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",'[url=$1]$2[/url]',$body);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
<a href='$embedurl' onclick='this.innerHTML=unescape("$escapedhtml").replace(/\+/g," "); return false;' style='float:left; margin: 1em; position: relative;'>
|
||||||
|
<img width='$tw' height='$th' src='$turl' >
|
||||||
|
<div style='position: absolute; top: 0px; left: 0px; width: $twpx; height: $thpx; background: url(images/icons/48/play.png) no-repeat center center;'></div>
|
||||||
|
</a>
|
Loading…
Reference in New Issue
Block a user