Files
IlLievitario-Service/include.php

41 lines
1.3 KiB
PHP

<?php
require_once "./config.inc.php";
// inclusione del file contenente la classe
require_once "./MySqlClass.php";
require_once "./utility.php";
require_once 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
date_default_timezone_set('Europe/Rome');
$app->hook('slim.before.router', function () use ($app, $allowedHost) {
/*$currentRefererRequest = $app->request()->getReferer();
$currentRefererRequest = substr($currentRefererRequest, 7); //Senza http://
$indexDoublePoint = strpos($currentRefererRequest, ':');
$indexFirstSlash = strpos($currentRefererRequest, '/');
$currentRefererRequest = substr($currentRefererRequest, 0, $indexDoublePoint > 0 && $indexDoublePoint < $indexFirstSlash ? $indexDoublePoint : $indexFirstSlash );
if(!in_array($currentRefererRequest, $allowedHost))
{
$app->halt(500, "Generic error occurred");
return;
}
$currentHostRequest = $app->request()->getHost();
if(!in_array($currentHostRequest, $allowedHost))
{
$app->halt(403, "Request arrive from host not allowed " . $currentHostRequest );
return;
}
*/
if(isset($_SERVER['HTTP_ORIGIN']))
header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
});
?>