From 743a4423a036928c3e86e8edc81bbaecb82bdc27 Mon Sep 17 00:00:00 2001 From: "Dr. Simon A. Xaies" Date: Wed, 3 Jul 2019 17:43:58 +1000 Subject: [PATCH] More Settings And Symaltypes! --- .htaccess | 2 ++ test.php | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100755 test.php diff --git a/.htaccess b/.htaccess index 87ea14e..657a0de 100755 --- a/.htaccess +++ b/.htaccess @@ -9,6 +9,7 @@ RewriteEngine On RewriteCond %{HTTP_HOST} !([a-z0-9]){1,64}.(localhost|snails.email)$ +RewriteRule ^test.json$ ./test.php?action=test&version=$1 [L,NC,QSA] RewriteRule ^$ ./index.php?action=jump&subdomain=1 [L,NC,QSA] RewriteEngine On @@ -26,6 +27,7 @@ RewriteRule ^/(media|css|jquery|images)/(.*?)$ ./assets/$1/$2 [L,NC,QSA] RewriteEngine On RewriteCond %{HTTP_HOST} !(.*?).([a-z0-9]){1,64}.(localhost|snails.email)$ RewriteCond %{REQUEST_URI} ^([a-z0-9]{2})/(.*?)$ +RewriteRule ^([a-z0-9]{2})/test.json$ ./test.php?action=test&version=$1 [L,NC,QSA] RewriteRule ^([a-z0-9]{2})/url.api$ ./index.php?action=url [L,NC,QSA] RewriteRule ^([a-z0-9]{2})/(.*?)$ ./index.php?action=jump&item=$2&version=$1 [L,NC,QSA] diff --git a/test.php b/test.php new file mode 100755 index 0000000..a0f4398 --- /dev/null +++ b/test.php @@ -0,0 +1,66 @@ + + * @version 2.2.1 + * @subpackage shortening-url + * @description Short Link URIs API + * @link http://internetfounder.wordpress.com + * @link http://sourceoforge.net/projects/chronolabsapis/files/jump.labs.coop + * @link https://github.com/Chronolabs-Cooperative/Jump-API-PHP + */ + + include_once __DIR__ . DIRECTORY_SEPARATOR . 'deployment.php'; + require_once __DIR__ . DIRECTORY_SEPARATOR . 'apiconfig.php'; + require_once __DIR__ . DIRECTORY_SEPARATOR . 'functions.php'; + + $data = array('time' => time(), 'ip' => getIP(true)); + + $response = (isset($_REQUEST['response'])?$_REQUEST['response']:'json'); + if (function_exists("http_response_code")) + if (isset($data['code']) && !empty($data['code'])) { + http_response_code($data['code']); + unset($data['code']); + } else { + http_response_code(201);; + } + + // Send Responses + switch ($response) + { + case 'raw': + header('Content-type: text'); + die($data["short"]); + break; + case 'php': + header('Content-type: application/php'); + die(""); + break; + case 'json': + header('Content-type: application/json'); + die(json_encode($data)); + break; + case 'serial': + header('Content-type: text/html'); + die(serialize($data)); + break; + case 'xml': + header('Content-type: application/xml'); + $dom = new XmlDomConstruct('1.0', 'utf-8'); + $dom->fromMixed(array('root'=>$data)); + die($dom->saveXML()); + break; + } +?>