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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
<?php
function version(): string {
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/.version")) {
return substr(trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/.version")), 0, 8);
} else if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/.git/refs/heads/trunk")) {
return substr(trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/.git/refs/heads/trunk")), 0, 8);
} else {
return "trunk";
}
}
function build(): string {
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/.build")) {
$a = trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/.build"));
} else {
$a = "dev";
}
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/.prjbuild")) {
$b = trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/.prjbuild"));
} else {
$b = "testing";
}
return "$a.$b";
}
function build_dom(): string {
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/.build")) {
$a = trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/.build"));
} else {
$a = "dev";
}
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/.prjbuild")) {
$b = trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/.prjbuild"));
} else {
$b = "testing";
}
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/.build.id")) {
$aa = trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/.build.id"));
} else {
$aa = "-1";
}
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/.prjbuild.id")) {
$ba = trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/.prjbuild.id"));
} else {
$ba = "-1";
}
return "<a href='https://ci.minteck.org/buildConfiguration/WebX_Stable/$aa' target='_blank' class='footer-link-mini'>$a</a>.<a href='https://ci.minteck.org/buildConfiguration/WebX_Projects/$ba' target='_blank' class='footer-link-mini'>$b</a>";
}
function getLetters(string $project): string {
$words = explode(" ", preg_replace('/#+/m', "#", preg_replace('/[^a-z0-9 ]/m', "#", strtolower(trim(preg_replace('/[A-Z]/m', ' $0', $project))))));
$words = array_slice(array_filter($words, function ($v) {
return trim($v);
}), 0);
return substr($words[0], 0, 1);
}
function timeAgo($time): string {
if (!is_numeric($time)) {
$time = strtotime($time);
}
$periods = array("second", "minute", "hour", "day", "week", "month", "year", "age");
$lengths = array("60", "60", "24", "7", "4.35", "12", "100");
$now = time();
$difference = $now - $time;
if ($difference <= 10 && $difference >= 0) {
return $tense = 'just now';
} elseif ($difference > 0) {
$tense = 'ago';
} else {
$tense = 'later';
}
for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
$difference /= $lengths[$j];
}
$difference = round($difference);
$period = $periods[$j] . ($difference >1 ? 's' :'');
return "{$difference} {$period} {$tense} ";
}
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/Parsedown.php";
global $Parsedown;
$Parsedown = new Parsedown();
|