-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.php
More file actions
46 lines (39 loc) · 1.11 KB
/
common.php
File metadata and controls
46 lines (39 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
require 'vendor/autoload.php';
use DsvSu\Daisy;
function getCurrentUrlDir()
{
$port = $_SERVER['SERVER_PORT'];
return '//' . $_SERVER['SERVER_NAME'] .
($port != 80 && $port != 443 ? ":$port" : '') .
rtrim(dirname($_SERVER['PHP_SELF']), '/');
}
function inEnglish()
{
return isset($_GET['lang']) && $_GET['lang'] === 'en';
}
function getLanguage()
{
return inEnglish() ? 'en' : 'sv';
}
function getTwigEnv()
{
$loader = new Twig_Loader_Filesystem(dirname(__FILE__) . '/twig');
return new Twig_Environment(
$loader,
[
'cache' => dirname(__FILE__) . '/cache',
'auto_reload' => true
]
);
}
function isXhr()
{
return !empty($_SERVER['HTTP_ORIGIN'])
|| (isset($_SERVER['HTTP_X_REQUESTED_WITH'])
&& 'xmlhttprequest' ===
strtolower($_SERVER['HTTP_X_REQUESTED_WITH']));
}
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: *, Accept-Encoding, Cache-Control'); // Behövs för Safari
Daisy\Client::initUsingConfigFile(dirname(__FILE__) . '/daisy_api.json');