Файловый менеджер - Редактировать - /var/www/vhosts/studiocol.dev1.mndrn.cloud/app/api/_/api.ctrl.php
Назад
<?php ### GYURAL ### /* ------------ Gyural 1.9.1 ------------ Filename: /app/api/_/api.ctrl.php Version: 1.9.1 Author: federicoq <f.quagliotto@mandarinoadv.com> Date: 04/11/2014 */ class apiCtrl extends standardController { var $index_tollerant = true; var $help = true; var $apiExcludeList = array('gyu_bucket', 'gyu_optimization', 'gyu_sdk', 'utenti'); var $format; function __construct() { $GLOBALS["api"] = true; # 4604a2883005ededce3ec344ae2509cd if(!isset($_REQUEST["format"])) $_REQUEST["format"] = 'json'; // This will work for JSON payloads.. (angular.js, for example.) $request_body = file_get_contents('php://input'); $data = json_decode($request_body, true); if(is_array($data)) $_REQUEST = array_merge($_REQUEST, $data); $this->format = $_REQUEST["format"]; #sleep(1); if(isset($_REQUEST["token"])) { if($u = LoadClass('utenti', 1)->filter(array('chiave', $_REQUEST["token"]), 'ONE')) { $_SESSION["login"] = $u; } } } function CtrlIndex() { $ok = false; $portions = explode('/', $_REQUEST["x"]); $guess = count($portions) - 1; if($guess == 0) { LoadApp('api',1)->NoInput(); exit; } if(strstr($portions[$guess], '.')) { $available[] = $portions[$guess]; $ok = true; } if(!$ok) { foreach($portions as $portion) { if(strstr($portion, '.')) $available[] = $portion; } } foreach($available as $shall) { $class = explode('.', $shall); $method = $class[count($class)-1]; unset($class[count($class)-1]); $controller = implode('/', $class); if(isController($controller . '/' . $method)) break; } $controller = LoadApp($controller, 1); $res = $controller->{'Api' . $method}(); if(!$res) { $res["error"] = 1; } if($this->format == 'json') { header('Content-type: application/json; charset=utf-8'); echo json_encode($res); } else if($this->format == 'php') { header('Content-type: text/plain; charset=utf-8'); echo serialize($res); } else if($this->format == 'xml') { header('Content-Type: application/xml; charset=utf-8'); $xml = new SimpleXMLElement('<root/>'); CallFunction('api', 'to_xml', $xml, $res); echo $xml->asXML(); } } function FindAllApiControllers() { $applications = CallFunction('gyu_bucket','installed_app'); foreach($applications as $app) { if(in_array($app["name"], $this->apiExcludeList)) continue; $files = (glob('app/' . $app["name"] . '/_/*')); foreach($files as $file) { if(strstr($file, '.ctrl.php')) { $validCtrls[] = $file; } } } $pattern = '/function Api(\w+)/i'; foreach($validCtrls as $checkInside) { $content = file_get_contents($checkInside); preg_match_all($pattern, $content, $matches); if(count($matches[1]) > 0) { $portions = explode('/', $checkInside); list($method) = explode('.', $portions[count($portions)-1]); $methods[] = array('name' => $method, 'methods' => $matches[1]); } } return $methods; } function CtrlHelp() { if(!$this->help) $this->NoInput(1); $nodes = $this->FindAllApiControllers(); echo '<pre>'; Application('/api/_v/help'); echo "\n\n"; foreach($nodes as $node) { echo '<strong>'.strtolower($node["name"]).'</strong>' . "\n"; foreach($node["methods"] as $metodo) echo "— " . strtolower($metodo) . ' <small>'.uri.'/api/'.str_replace('_', '.', $node["name"]).'.'.strtolower($metodo).'</small>' . "\n"; echo "\n"; } echo "\n\n<hr />\n" . '<em>Gyural '.version.'</em>'; echo '</pre>'; } function NoInput($stop = false) { echo 'Sorry, no request.'; if($stop) die(); } } ?>
| ver. 1.4 |
Github
|
.
| PHP 8.2.5 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка