-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dr. Simon A. Xaies
committed
Jul 3, 2019
1 parent
524f55e
commit 743a442
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
/** | ||
* Chronolabs REST Short Link URIs API | ||
* | ||
* You may not change or alter any portion of this comment or credits | ||
* of supporting developers from this source code or any supporting source code | ||
* which is considered copyrighted (c) material of the original comment or credit authors. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* | ||
* @copyright Chronolabs Cooperative http://au.syd.labs.coop | ||
* @license Academic + GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) | ||
* @package api | ||
* @since 2.2.1 | ||
* @author Simon Roberts <[email protected]> | ||
* @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("<?php\n\nreturn " . var_export($data) . ";\n\n?>"); | ||
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; | ||
} | ||
?> |