This repository has been archived by the owner on Jan 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathautoload.php
73 lines (65 loc) · 2.17 KB
/
autoload.php
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
if (basename(__FILE__) == basename($_SERVER["SCRIPT_FILENAME"])) {
header("Status: 301 Moved Permanently", false, 301);
header("Location: https://www.youtube.com/watch?v=dQw4w9WgXcQ");
# si le fichier est appelé via un navigateur, rick roll ! :)
# sinon, donner les variables a PHP
} else {
# https://medium.com/@hfally/how-to-create-an-environment-variable-file-like-laravel-symphonys-env-37c20fc23e72
$success = include "env.php";
if (!$success) {
echo "Missing env.php, copy env.example.php to env.php\n";
die();
}
if (!function_exists("env")) {
function env($key, $default = null)
{
$value = getenv($key);
if ($value === false) {
return $default;
}
return $value;
}
}
if (!function_exists("is_curl")) {
function is_curl() {
# is the page being curl'd, wget'd or shown thru a browser ?
if (stristr($_SERVER["HTTP_USER_AGENT"], 'curl')) {
# page is cURL'd
return True;
} else {
# page is being accessed from a web browser
return False;
}
}
}
if (!function_exists("get_current_git_commit")) {
# https://gist.github.com/stevegrunwell/3363975
function get_current_git_commit(string $branch = 'master', bool $pretty = false) {
if (file_get_contents(sprintf('.git/refs/heads/%s', $branch))) {
$hash = file_get_contents(sprintf('.git/refs/heads/%s', $branch));
if ($pretty) {
return substr($hash, 0, 7);
} else {
return $hash;
}
} else {
return false;
}
}
}
if (!function_exists("add_header")) {
function add_header() {
if (! is_curl()) {
require "src/html/header.php";
}
}
}
if (!function_exists("add_footer")) {
function add_footer() {
if (! is_curl()) {
require "src/html/footer.php";
}
}
}
}