API is now working on my nginx server.

This commit is contained in:
Michael 2012-02-20 01:53:22 +01:00
parent b6d7777226
commit 0fb22e1284
3 changed files with 24 additions and 12 deletions

View file

@ -309,8 +309,12 @@ class App {
. 'library/phpsec' . PATH_SEPARATOR . 'library/phpsec' . PATH_SEPARATOR
. '.' ); . '.' );
if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") {
$this->query_string = substr($_SERVER['QUERY_STRING'],2); $this->query_string = substr($_SERVER['QUERY_STRING'],2);
// removing trailing / - maybe a nginx problem
if (substr($this->query_string, 0, 1) == "/")
$this->query_string = substr($this->query_string, 1);
}
if(x($_GET,'q')) if(x($_GET,'q'))
$this->cmd = trim($_GET['q'],'/\\'); $this->cmd = trim($_GET['q'],'/\\');

View file

@ -99,6 +99,10 @@
**************************/ **************************/
function api_call(&$a){ function api_call(&$a){
GLOBAL $API, $called_api; GLOBAL $API, $called_api;
// preset
$type="json";
foreach ($API as $p=>$info){ foreach ($API as $p=>$info){
if (strpos($a->query_string, $p)===0){ if (strpos($a->query_string, $p)===0){
$called_api= explode("/",$p); $called_api= explode("/",$p);
@ -162,7 +166,6 @@
header ("Content-Type: application/atom+xml"); header ("Content-Type: application/atom+xml");
return '<?xml version="1.0" encoding="UTF-8"?>'."\n".$r; return '<?xml version="1.0" encoding="UTF-8"?>'."\n".$r;
break; break;
} }
} }

View file

@ -24,6 +24,9 @@ function diaspora2bb($s) {
// Simply remove cr. // Simply remove cr.
$s = str_replace("\r","",$s); $s = str_replace("\r","",$s);
// <br/> is invalid. Replace it with the valid expression
$s = str_replace("<br/>","<br />",$s);
$s = preg_replace('/\@\{(.+?)\; (.+?)\@(.+?)\}/','@[url=https://$3/u/$2]$1[/url]',$s); $s = preg_replace('/\@\{(.+?)\; (.+?)\@(.+?)\}/','@[url=https://$3/u/$2]$1[/url]',$s);
// Escaping the hash tags - doesn't always seem to work // Escaping the hash tags - doesn't always seem to work
@ -40,12 +43,14 @@ function diaspora2bb($s) {
$s = html2bbcode($s); $s = html2bbcode($s);
// $s = str_replace('&#42;','*',$s); // $s = str_replace('&#42;','*',$s);
// Convert everything that looks like a link to a link
$s = preg_replace("/([^\]\=]|^)(https?\:\/\/)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3]$2$3[/url]',$s);
//$s = preg_replace("/([^\]\=]|^)(https?\:\/\/)(vimeo|youtu|www\.youtube|soundcloud)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3$4]$2$3$4[/url]',$s);
$s = preg_replace("/\[url\=?(.*?)\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/url\]/ism",'[youtube]$2[/youtube]',$s); $s = preg_replace("/\[url\=?(.*?)\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/url\]/ism",'[youtube]$2[/youtube]',$s);
$s = preg_replace("/\[url\=https?:\/\/www.youtube.com\/watch\?v\=(.*?)\].*?\[\/url\]/ism",'[youtube]$1[/youtube]',$s); $s = preg_replace("/\[url\=https?:\/\/www.youtube.com\/watch\?v\=(.*?)\].*?\[\/url\]/ism",'[youtube]$1[/youtube]',$s);
$s = preg_replace("/\[url\=?(.*?)\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/url\]/ism",'[vimeo]$2[/vimeo]',$s); $s = preg_replace("/\[url\=?(.*?)\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/url\]/ism",'[vimeo]$2[/vimeo]',$s);
$s = preg_replace("/\[url\=https?:\/\/vimeo.com\/([0-9]+)\](.*?)\[\/url\]/ism",'[vimeo]$1[/vimeo]',$s); $s = preg_replace("/\[url\=https?:\/\/vimeo.com\/([0-9]+)\](.*?)\[\/url\]/ism",'[vimeo]$1[/vimeo]',$s);
$s = preg_replace("/([^\]\=]|^)(https?\:\/\/)(vimeo|youtu|www\.youtube|soundcloud)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url]$2$3$4[/url]',$s);
// remove duplicate adjacent code tags // remove duplicate adjacent code tags
$s = preg_replace("/(\[code\])+(.*?)(\[\/code\])+/ism","[code]$2[/code]", $s); $s = preg_replace("/(\[code\])+(.*?)(\[\/code\])+/ism","[code]$2[/code]", $s);