blob: 70c899fe6cfbd65a6fb2ddd4bdfa1db5f11edac0 (
plain)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
<?php
namespace Wcms;
class Application
{
/**
* @var Modeluser
*/
protected $usermanager;
public function __construct() {
$this->usermanager = new Modeluser();
}
public function wakeup()
{
if(isset($_POST['configinit'])) {
if(Config::readconfig()) {
Config::createconfig($_POST['configinit']);
} else {
Config::hydrate($_POST['configinit']);
}
Config::getdomain();
if(!is_dir(Model::RENDER_DIR)) {
mkdir(Model::RENDER_DIR);
}
if(!Config::savejson()) {
echo 'Cant write config file';
exit;
} else{
header('Location: ./');
exit;
}
} elseif(isset($_POST['userinit']) && !empty($_POST['userinit']['id']) && !empty($_POST['userinit']['password'])) {
$userdata = $_POST['userinit'];
$userdata['level'] = 10;
$user = new User($userdata);
$this->usermanager->add($user);
header('Location: ./');
exit;
} else {
if(Config::readconfig()) {
if(!Config::checkbasepath() || empty(Config::pagetable()) || !is_dir(Model::RENDER_DIR) || !Config::checkdomain()) {
echo '<ul>';
if(!Config::checkbasepath()) {
echo '<li>Wrong path</li>';
}
if(empty(Config::pagetable())) {
echo '<li>Unset table name</li>';
}
if(!Config::checkdomain()) {
echo '<li>Need to recheck the domain</li>';
}
if(!is_dir(Model::RENDER_DIR)) {
echo '<li>Render path not existing</li>';
}
echo '</ul>';
$this->configform();
exit;
} else {
if($this->usermanager->admincount() === 0) {
echo 'missing admin user';
$this->adminform();
exit;
}
}
} else {
echo 'Missing config file';
$this->configform();
exit;
}
}
}
public function configform()
{
?>
<h1>Configuration</h1>
<h3>Version :</h3>
<p><?= getversion() ?></p>
<form action="" method="post">
<div>
<h2>
<label for="basepath">Path to W-CMS</label>
</h2>
<input type="text" name="configinit[basepath]" value="<?= Config::basepath() ?>" id="basepath">
<p><i>Leave it empty if W-CMS is in your root folder, otherwise, indicate the subfolder(s) in witch you installed the CMS</i></p>
</div>
<div>
<h2>
<label for="pagetable">Name of your database table</label>
</h2>
<input type="text" name="configinit[pagetable]" value="<?= Config::pagetable() ?>" id="pagetable">
<p><i>Set the name of the first folder that is going to store all your work</i></p>
</div>
<input type="submit" value="set">
</form>
<?php
}
public function adminform()
{
?>
<form action="" method="post">
<div>
<h2>
<label for="id">Your identifiant</label>
</h2>
<input type="text" name="userinit[id]" id="admin" maxlength="64" required>
<p><i>Your user id as the first administrator.</i></p>
</div>
<div>
<h2>
<label for="password">Your password</label>
</h2>
<input type="password" name="userinit[password]" id="password" minlength="4" maxlength="64" required>
<p><i>Your user passworder as first administrator.</i></p>
</div>
<input type="submit" value="set">
</form>
<?php
}
}
?>
|