Repository navigation
Expand file tree
/
Copy pathInstall.php
More file actions
49 lines (43 loc) · 1.58 KB
/
Copy pathInstall.php
File metadata and controls
49 lines (43 loc) · 1.58 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
47
48
49
<?php namespace App\Controllers;
use CodeIgniter\Controller;
use App\Libraries\SqlManager;
class Install extends Controller{
public function index(){
echo view('system/install/home');
}
public function form($param = ""){
$inputs = $this->request->getPost(["site_title", "language", "login", "pass", "pass-confirmation", "register", "utc"]);
$data = ["error" => -1, "inputs" => $inputs];
if($param == "process"){
if(empty($inputs["site_title"])) $data["error"] = 1;
elseif(empty($inputs["language"])) $data["error"] = 2;
elseif(empty($inputs["login"])) $data["error"] = 3;
elseif(empty($inputs["pass"]) || ($inputs["pass"] != $inputs["pass-confirmation"])) $data["error"] = 4;
else $data["error"] = 0;
}
if($data["error"] != 0) echo view('system/install/form',$data);
else{
$this->UserModel = model('App\Models\UserModel');
$query_data = [
"id" => 1,
"login" => $inputs["login"],
"pass" => password_hash($inputs["pass"],PASSWORD_DEFAULT),
"utc" => $inputs["utc"]
];
$this->UserModel->builder->insert($query_data);
$this->SettingModel = model('App\Models\SettingModel');
$inputs["register"] = ($inputs["register"] == "on");
$query_data = [
"id" => 1,
"db_version" => $this->SettingModel->getSystemDBVersion(),
"title" => $inputs["site_title"],
"language" => $inputs["language"],
"register" => $inputs["register"],
"utc" => $inputs["utc"]
];
$this->SettingModel->builder->insert($query_data);
echo view('system/install/done',$data);
}
}
}
?>