-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclass.inc.php
102 lines (102 loc) · 3.74 KB
/
class.inc.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
/**
* This file conatins the class U. This class is used on every page.
* @license https://standards.casegames.ch/cgs/0003/v1.txt Case Games Open-Source license
*/
// This if statement checks the inclusion of configuration.php
if(gettype($USOC) == "array"){
/**
* This function initialise the U class in $U if it doesn't exist
* @version Pb2.0Bfx0
* @since Pb2.0Bfx0RCA
*/
function newClass(){
global $U;
if(!isset($U)){
$U = new U();
}
}
/**
* This class contains all functions for USOC. When a function is needed, U includes it.
* This class only works when configuration.php is included.
* Use newClass() and not this class.
* @see newClass()
* @version Pb2.4Bfx0
* @since Pb2.0Bfx0RCA
*/
class U{
/**
* Version name
* @since Pb2.0Bfx0RCA
* @var string
*/
public string $version = "Pb2.4Bfx0";
/**
* Version code
* @since Pb2.4Bfx0
* @var int
*/
public int $versionCode = 20240901;
/**
* True when USOC is modded
* @since Pb2.0Bfx0RCA
* @var boolean
*/
public bool $modded = false;
/**
* The database connection
* @since Pb2.3Bfx0
* @var object
*/
public $db_link;
/**
* Content handlers.
* @see https://github.com/Case-Games/USOC/wiki/reference:Plugin-API
* @since Pb2.4Bfx0
*/
public $contentHandlers = [];
/**
* @ignore
*/
function __construct(){
// Set db_link
$this->db_link = mysqli_connect(MYSQL_HOST,MYSQL_USER,MYSQL_PASSWORD,MYSQL_DATABASE);
set_time_limit (20);
}
/**
* @ignore
*/
function __call($name,$arguments){
$found = False;
try{
include_once "functions/".$name.".inc.php";
$found = True;
}catch (Exception $e){
echo "Error! Function not found: ".$name."()";
}
if($found){
return call_user_func_array($name,$arguments);
}
}
}
newClass();
// Set default content handlers
$U->contentHandlers["Sites"] = ["Name" => "sites", "DisplayName" => $U->getLang("admin.site"), "PackageVersion" => 1, "Author" => "Case Games", "InfoURL" => "https://github.com/case-games/USOC", "URL" => "/", "AddHandler" => function (int $Id, array $data){}, "DeleteHandler" => function (int $Id){if($Id==0){return False;}}, "ShowHandler" => function ($code, $data){return $code;}, "EditHandler" => function (int $Id, $data){}, "CreateNewContent" => True, "ContentCreateHandler" => "Text", "ContentEditHandler" => "Text"];
$U->contentHandlers["Blog"] = ["Name" => "blog", "DisplayName" => $U->getLang("admin.blog"), "PackageVersion" => 1, "Author" => "Case Games", "InfoURL" => "https://github.com/case-games/USOC", "URL" => "/blog/", "AddHandler" => function (int $Id, array $data){}, "DeleteHandler" => function (int $Id){}, "ShowHandler" => function ($code, $data){return $code;}, "EditHandler" => function (int $Id, $data){}, "CreateNewContent" => True, "ContentCreateHandler" => "Text", "ContentEditHandler" => "Text"];
// Clears the output buffer because somewhere it's outputing some spaces and I can't find where
ob_clean();
foreach($USOC["afterInitialization"] as $key => $value){
$value();
}
// Import the plugin overview file if it exists
if(file_exists($USOC["SITE_PATH"]."/plugins/plugins.php")){
include_once $USOC["SITE_PATH"]."/plugins/plugins.php";
}elseif(file_exists("plugins/plugins.php")){
include_once "plugins/plugins.php";
}
}elseif(!file_exists("/configuration.php")){
header("Location: /install/index.php");
}else{
echo "You can't access API from class.php";
}
?>