-
Notifications
You must be signed in to change notification settings - Fork 42
/
install.php
249 lines (235 loc) · 9.36 KB
/
install.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
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<?php
/*
@nom: install
@auteur: Idleman (http://blog.idleman.fr)
@description: Page d'installation du script (a supprimer après installation)
*/
require_once('Functions.class.php');
require_once('Install.class.php');
require_once('i18n.php');
global $i18n;
$install = new Install();
/* Prend le choix de langue de l'utilisateur, soit :
* - lorsqu'il vient de changer la langue du sélecteur ($lang)
* - lorsqu'il vient de lancer l'installeur ($install_changeLngLeed)
*/
$lang = '';
if (isset($_GET['lang'])) $lang = $_GET['lang'];
elseif (isset($_POST['install_changeLngLeed'])) $lang = $_POST['install_changeLngLeed'];
$installDirectory = dirname(__FILE__).'/install';
// N'affiche que les langues du navigateur
// @TODO: il faut afficher toutes les langues disponibles
// avec le choix par défaut de la langue préférée
$languageList = Translation::getHttpAcceptLanguages();
if (!empty($lang)) {
// L'utilisateur a choisi une langue, qu'on incorpore dans la liste
array_unshift($languageList, $lang);
$liste = array_unique($languageList);
}
unset($i18n); //@TODO: gérer un singleton et le choix de langue / liste de langue
$currentLanguage = i18n_init($languageList, $installDirectory);
$languageList = array_unique($i18n->languages);
if (file_exists('constant.php')) {
die(_t('ALREADY_INSTALLED'));
}
define('DEFAULT_TEMPLATE', 'marigolds');
$templates = scandir('templates');
if (!in_array(DEFAULT_TEMPLATE, $templates)) die('Missing default template : '.DEFAULT_TEMPLATE);
$templates = array_diff($templates, array(DEFAULT_TEMPLATE, '.', '..')); // Répertoires non voulus sous Linux
sort($templates);
$templates = array_merge(array(DEFAULT_TEMPLATE), $templates); // le thème par défaut en premier
// Cookie de la session
$cookiedir = '';
if(dirname($_SERVER['SCRIPT_NAME'])!='/') $cookiedir=dirname($_SERVER["SCRIPT_NAME"]).'/';
session_set_cookie_params(0, $cookiedir);
session_start();
// Protection des variables
$_ = array_merge($_GET, $_POST);
$installActionName = 'installButton';
$install->launch($_, $installActionName);
?>
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="<?php echo $currentLanguage;?>"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="<?php echo $currentLanguage;?>"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="<?php echo $currentLanguage;?>"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="<?php echo $currentLanguage;?>"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="referrer" content="no-referrer" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title><?php echo _t('INSTALL_TITLE') ?></title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="templates/marigolds/css/style.css">
<style>
code {
color:#000;
font-size: 1em;
}
.install h1 {
margin-bottom: 1.3em;
}
.install h2 {
margin-bottom: 0.1em;
font-size: 1.5em;
}
.install ul {
margin: 0;
padding: 0;
}
.install li {
list-style: none outside none;
}
.install span {
display: inline-block;
width: 8em;
padding-right: 1em;
}
button#installButton {
margin-top: 1em;
font-size: 2em;
}
.message {
color: #ffffff;
margin-bottom: 2em;
}
.message li {
border:1px solid #212121
}
.messageError {
background-color: #F16529;
}
.messageSuccess {
background-color: #008000;
}
</style>
</head>
<body>
<div class="global-wrapper">
<div id="header-container">
<header class="wrapper clearfix">
<h1 class="logo" id="title"><a href="./">L<i>eed</i></a></h1>
<nav>
</nav>
</header>
</div>
<?php
if ($install->getFinished()){
echo '<div id="main-container">
<div id="main" class="wrapper clearfix">
<div id="menuBar"></div>
<h1>'._t('INSTALL_TITLE_END').'</h1>
<span>'._t('INSTALL_END').'</span>
<hr>
<button id="installButton" name="<?php echo $installActionName; ?>" onclick="document.location.href=\'settings.php#preferenceBloc\'">'._t('INSTALL_BTN_END').'</button>
';
// écriture des balises de fin et ne pas faire la suite
echo '</div>
<div id="footer-container">
<footer class="wrapper">
<p>Leed "Light Feed" by <a target="_blank" rel="noopener noreferrer" href="http://blog.idleman.fr">Idleman</a></p>
</footer>
</div>
</body>
</html>';
exit();
}
?>
<div id="main-container">
<div id="main" class="wrapper clearfix">
<div id="menuBar">
<aside>
<h3 class="left"><?php echo _t('INSTALL_PRE_REQUIS') ?></h3>
<ul class="clear" style="margin:0">
<?php
foreach($install->logs as $type => $messages){
if(empty($messages)) {
continue;
}
$class = 'message ';
$class .= $type === 'errors' ? 'messageError':'messageSuccess';
$label = $type === 'errors' ? _t('ERROR') : _t('SUCCESS');
echo "<li class='$class'>$label :<ul>";
foreach ($messages as $message){
echo "<li>$message</li>";
}
echo "</ul></li>";
}
?>
</ul>
</aside>
</div>
<form action="install.php" method="POST" class="install">
<h1><?php echo _t('INSTALL_TITLE') ?></h1>
<h2><?php echo _t('INSTALL_TAB_GENERAL') ?></h2>
<ul>
<li>
<span><?php echo _t('INSTALL_LANGUAGE') ?></span>
<select name="install_changeLngLeed" onchange="window.location.href='install.php?lang='+this[this.selectedIndex].value">
<?php
foreach($languageList as $lang){
$sel = $lang==$currentLanguage?'selected=selected':'';
echo "<option $sel value='$lang'>$lang</option>";
}
?>
</select>
</li>
<li>
<span><?php echo _t('INSTALL_TEMPLATE') ?></span>
<?php
$disabled = count($templates)<2 ? "disabled" : "";
echo "<select name='template' $disabled>\n";
foreach($templates as $name){
echo "<option value='$name'>$name</option>";
}
?>
</select>
</li>
<li>
<span><?php echo _t('PROJECT_ROOT') ?></span>
<input type="text" name="root" value="<?php echo $install->getDefaultRoot(); ?>">
</li>
</ul>
<h2><?php echo _t('INSTALL_TAB_BDD') ?></h2>
<ul>
<li>
<span><?php echo _t('INSTALL_HOST') ?></span>
<input type="text" name="mysqlHost" value="<?php echo $install->options['db']['mysqlHost']; ?>" placeholder="<?php echo _t('INSTALL_COMMENT_HOST') ?>">
</li>
<li>
<span><?php echo _t('LOGIN') ?></span>
<input type="text" name="mysqlLogin" value="<?php echo $install->options['db']['mysqlLogin']; ?>">
</li>
<li>
<span><?php echo _t('PASSWORD') ?></span>
<input type="text" autocomplete="off" name="mysqlMdp" value="<?php echo $install->options['db']['mysqlMdp']; ?>" placeholder="<?php echo _t('INSTALL_DISPLAY_CLEAR') ?>">
</li>
<li>
<span><?php echo _t('INSTALL_BDD') ?></span>
<input type="text" name="mysqlBase" value="<?php echo $install->options['db']['mysqlBase']; ?>" placeholder="<?php echo _t('INSTALL_COMMENT_BDD') ?>">
</li>
<li>
<span><?php echo _t('INSTALL_PREFIX_TABLE') ?></span>
<input type="text" name="mysqlPrefix" value="<?php echo $install->options['db']['mysqlPrefix']; ?>">
</li>
</ul>
<h2><?php echo _t('INSTALL_TAB_ADMIN') ?></h2>
<ul>
<li>
<span><?php echo _t('LOGIN') ?></span>
<input type="text" name="login" value="<?php echo $install->options['user']['login']; ?>" placeholder="<?php echo _t('LOGIN') ?>">
</li>
<li>
<span><?php echo _t('PASSWORD') ?></span>
<input type="text" autocomplete="off" name="password" value="<?php echo $install->options['user']['password']; ?>" placeholder="<?php echo _t('INSTALL_DISPLAY_CLEAR') ?>">
</li>
</ul>
<button id="installButton" name="<?php echo $installActionName; ?>"><?php echo _t('INSTALL_BTN') ?></button>
</form>
</div>
<div id="footer-container">
<footer class="wrapper">
<p>Leed "Light Feed" by <a target="_blank" rel="noopener noreferrer" href="http://blog.idleman.fr">Idleman</a></p>
</footer>
</div>
</body>
</html>