Created
February 10, 2014 10:09
-
-
Save kolyadin/8913404 to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* Данное api обеспечивает взаимодействие между мобильными приложениями (iphone,ipad,android) и backend'ом кино | |
* | |
* @date 23.07.2013 | |
* @author Колядин Алексей | |
*/ | |
ini_set('display_errors',1); | |
ini_set('html_errors',1); | |
error_reporting(E_ALL); | |
//Загружаем основной кино-фреймворк | |
require_once '/data/sites/vendor/ka/autoload.php'; | |
$app = Ka::Application(dirname(__FILE__)); | |
$app->config()->setTimeZone('+4');#По умолчанию ставим Московскую временную зону | |
$app->config()->setDebugMode(true);#Режим отладки | |
$app->config()->setupEnvironment(); | |
//Загружаем конфигурационные файлы | |
$app->config()->loadConfigFile(sprintf('globals.%s.conf.php',$app->config()->getEnv()),'globals'); | |
$app->config()->loadConfigFile('city.conf.php','city'); | |
require_once($app->config()->globals['PROJECT_ROOT'].'/platform/PlatformInterface.php'); | |
//Правила маршрутизации | |
$router = $app->router(); | |
$router->setSource($_SERVER['REQUEST_URI']); | |
/** | |
* Основное правило маршрутизации, которое зависит от операционной системы и версии api | |
* @example /mobile/ios/1.0 | |
* @example /mobile/android/1.2 | |
*/ | |
$router->setRuleCallback('GET POST /mobile/(ios|android)/([^/]+)', function($os,$version) use($app) { | |
$tryPath = sprintf('%s/platform/%s/%s/init.php' | |
,$app->config()->globals['PROJECT_ROOT'] | |
,$os | |
,$version | |
); | |
if (file_exists($tryPath)) | |
{ | |
require_once($tryPath); | |
$call = sprintf('Platform_%s_%s', $os, filter_var($version, FILTER_SANITIZE_NUMBER_INT)); | |
$call::initialize($app); | |
} | |
else | |
{ | |
header('HTTP/1.0 404 Not Found'); | |
die; | |
} | |
}); | |
//Если ничего не совпало - показываем 404 ошибку | |
if ($router->noMatch()) | |
{ | |
header('HTTP/1.0 404 Not Found'); | |
die; | |
} | |
__halt_compiler(); | |
print '<pre>'.print_r($app->mysqli()->q,true).'</pre>'; | |
printf("\n<!-- time %s -->", $app->genTime()); | |
printf("\n<!-- memory %s -->", $app->getMemoryUsage()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment