This repository was archived by the owner on Dec 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.php
executable file
·83 lines (65 loc) · 2.07 KB
/
init.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
<?php
// Initialize
$configuration = [];
require 'config.php';
require 'vendor/autoload.php';
use Illuminate\Database\Capsule\Manager as Capsule;
$whmcsDB = new mysqli($configuration["whmcs"]["host"], $configuration["whmcs"]["username"], $configuration["whmcs"]["password"], $configuration["whmcs"]["database"]);
if ($whmcsDB->connect_errno) {
echo json_encode(['status' => 'error', 'message' => 'WHMCS veritabanına bağlanılamadı. '.$whmcsDB->connect_error]);
exit();
}
$whmcsDB->set_charset("utf8");
$current = new Capsule;
$current->addConnection($configuration["wisecp"]);
$current->setAsGlobal();
$current->bootEloquent();
$smarty = new Smarty();
$smarty->template_dir = "templates";
$smarty->compile_dir = "templates_c";
$smarty->cache_dir = "cache";
$smarty->config_dir = "configs";
$now = new \DateTime("now");
session_start();
$sitetitle = "WAGONN Software and Design Solutions";
$version = "v1.0";
function page_title($title)
{
global $sitetitle;
global $smarty;
$smarty->assign("page_title", $title . " - " . $sitetitle);
}
function display($templatefile)
{
global $smarty;
$smarty->display($templatefile.".tpl");
}
function assign($smarty_variable, $variable)
{
global $smarty;
$smarty->assign($smarty_variable, $variable);
}
function insert_query($table, $array)
{
global $whmcsDB;
$fieldnamelist = $fieldvaluelist = "";
$query = "INSERT INTO " . ($table) . " ";
foreach ($array as $key => $value) {
$fieldnamelist .= "`{$key}`,";
if ($value === "now()") {
$fieldvaluelist .= "'" . date("YmdHis") . "',";
continue;
}
if ($value === "NULL") {
$fieldvaluelist .= "NULL,";
continue;
}
$fieldvaluelist .= "'" . $whmcsDB->real_escape_string($value) . "',";
}
$fieldnamelist = substr($fieldnamelist, 0, 0 - 1);
$fieldvaluelist = substr($fieldvaluelist, 0, 0 - 1);
$query .= "(" . $fieldnamelist . ") VALUES (" . $fieldvaluelist . ")";
return $query;
}
assign("version", $version);
assign("currentyear", $now->format("Y"));