Update website
This commit is contained in:
parent
4413528994
commit
1d90fbf296
6865 changed files with 1091082 additions and 0 deletions
72
common.php
Normal file
72
common.php
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
require_once dirname(__FILE__).'/vendor/autoload.php';
|
||||
require_once dirname(__FILE__).'/lib/config/config.php';
|
||||
require_once dirname(__FILE__).'/lib/schema.php';
|
||||
require_once dirname(__FILE__).'/assets/jslib.php';
|
||||
|
||||
// If debug mode, we activate the helper
|
||||
if ($iap_debug) {
|
||||
\Symfony\Component\ErrorHandler\Debug::enable();
|
||||
}
|
||||
|
||||
// Start session
|
||||
if(session_status() !== PHP_SESSION_ACTIVE) session_start();
|
||||
|
||||
Mustache_Autoloader::register();
|
||||
|
||||
function setup_mustache()
|
||||
{
|
||||
$mustache = new Mustache_Engine(array(
|
||||
'template_class_prefix' => '__MyTemplates__',
|
||||
'cache' => '/tmp/cache/mustache',
|
||||
'loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views'),
|
||||
'partials_loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views/partials'),
|
||||
'escape' => function ($value) {
|
||||
return htmlspecialchars($value, ENT_COMPAT, 'UTF-8');
|
||||
},
|
||||
'charset' => 'ISO-8859-1',
|
||||
));
|
||||
return $mustache;
|
||||
}
|
||||
|
||||
function return_error($e, array $extra = null)
|
||||
{
|
||||
header('Content-Type: application/json');
|
||||
$data =[
|
||||
'return_code'=>'-1',
|
||||
'exception_code'=>$e->getCode(),
|
||||
'exception_message'=>$e->getMessage(),
|
||||
'exception_trace'=>$e->getTrace()
|
||||
];
|
||||
if ($extra) {
|
||||
$data['extra'] = $extra;
|
||||
}
|
||||
echo json_encode($data);
|
||||
exit(200);
|
||||
}
|
||||
|
||||
function return_generic_error($data)
|
||||
{
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode([
|
||||
'return_code'=>'-2',
|
||||
'error'=>$data
|
||||
]);
|
||||
exit(200);
|
||||
}
|
||||
|
||||
function return_ok($data)
|
||||
{
|
||||
header('Content-Type: application/json');
|
||||
$data = [
|
||||
'return_code'=>'1',
|
||||
'data'=>$data
|
||||
];
|
||||
echo json_encode($data);
|
||||
exit(200);
|
||||
}
|
||||
|
||||
$db_conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams);
|
||||
|
||||
$schema = new PersoSchema([], $db_conn);
|
Loading…
Add table
Add a link
Reference in a new issue