This repository has been archived by the owner on Apr 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
325 lines (316 loc) · 16.5 KB
/
index.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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
<?php
if(isset($_GET['phpinfo'])){
echo '<a href="/">← Home</a>';
phpinfo();
}
elseif(isset($_GET['onlineoffline'])){
$_SERVER['argv'][1] = ($wampConf['status'] == "offline") ? "on" : "off";
require("../scripts/onlineOffline.php");
header('Location: /?refresh');
}
elseif(isset($_GET['refresh'])){
require("../scripts/refresh.php");
header('Location: /');
}
else{
// Page créé par Dryusdan <[email protected]>
// Fork de la page d'accueil de WampServer
//Par défaut la valeur est "../"
//$server_dir = "WAMPROOT/";
$server_dir = "../";
require $server_dir.'scripts/config.inc.php';
require $server_dir.'scripts/wampserver.lib.php';
//chemin jusqu'aux fichiers alias
$aliasDir = $server_dir.'alias/';
//Fonctionne à condition d'avoir ServerSignature On et ServerTokens Full dans httpd.conf
$server_software = $_SERVER['SERVER_SOFTWARE'];
$error_content = '';
$langues = array(
'en' => array(
'langue' => 'English',
'locale' => 'english',
'autreLangue' => 'Version Française',
'autreLangueLien' => 'fr',
'titreHtml' => 'WAMPSERVER Homepage',
'titreConf' => 'Server Configuration',
'versa' => 'Apache Version:',
'doca2.2' => 'httpd.apache.org/docs/2.2/en/',
'doca2.4' => 'httpd.apache.org/docs/2.4/en/',
'versp' => 'PHP Version:',
'versCli' => 'PHP CLI Version:',
'server' => 'Server Software:',
'docp' => 'www.php.net/manual/en/',
'versm' => 'MySQL Version:',
'docm' => 'dev.mysql.com/doc/index.html',
'phpExt' => 'Loaded Extensions : ',
'titrePage' => 'Tools',
'txtProjet' => 'Your Projects',
'txtNoProjet' => 'No projects yet.<br />To create a new one, just create a directory in \'www\'.',
'txtAlias' => 'Your Aliases',
'txtNoAlias' => 'No Alias yet.<br />To create a new one, use the WAMPSERVER menu.',
'txtVhost' => 'Your VirtualHost',
'txtServerName' => 'The ServerName %s has syntax error in file %s',
'txtVhostNotClean' => 'The %s file has not been cleaned. There remain VirtualHost examples like: dummy-host.example.com',
'txtNoVhost' => 'No VirtualHost yet. Add one for each project in the file: wamp/bin/apache/apache%s/conf/extra/httpd-vhosts.conf',
'txtNoIncVhost' => 'Uncomment or add <i>Include conf/extra/httpd-vhosts.conf</i> in file wamp/bin/apache/apache%s/conf/httpd.conf',
'txtNoVhostFile' => 'The file: %s does not exists',
'txtNoPath' => 'The path %s for %s does not exist (File %s)',
'txtNotWritable' => 'The file: %s is not writable',
'txtNbNotEqual' => 'The number of %s does not match the number of %s in %s file',
'txtAddVhost' => 'Add a Virtual Host',
'txtPortNumber' => 'Port number for %s has not correct value or is not the same in file %s',
'txtCorrected' => 'Some VirtualHosts errors can be corrected.',
'forum' => 'http://forum.wampserver.com/list.php?2',
'portUsed' => 'Port defined for Apache: ',
'mysqlportUsed' => 'Port defined for MySQL: ',
'nolocalhost' => 'It\'s a bad idea to add localhost in the url of launching projects. It is best to define VirtualHost in<br />wamp/bin/apache/apache%s/conf/extra/httpd-vhosts.conf<br />file and not add localhost in the url.',
'serverStatusOffline' => 'Serveur hors ligne',
'serverStatusOnline' => 'Serveur en ligne',
),
'fr' => array(
'langue' => 'Français',
'locale' => 'french',
'autreLangue' => 'English Version',
'autreLangueLien' => 'en',
'titreHtml' => 'Accueil WAMPSERVER',
'titreConf' => 'Configuration Serveur',
'versa' => 'Version Apache :',
'doca2.2' => 'httpd.apache.org/docs/2.2/fr/',
'doca2.4' => 'httpd.apache.org/docs/2.4/fr/',
'versp' => 'Version de PHP :',
'verspCli' => 'Version de PHP CLI',
'server' => 'Server Software :',
'docp' => 'www.php.net/manual/fr/',
'versm' => 'Version de MySQL :',
'docm' => 'dev.mysql.com/doc/index.html',
'phpExt' => 'Extensions Chargées :',
'titrePage' => 'Outils',
'txtProjet' => 'Vos Projets',
'txtServerName' => 'Le ServerName %s comporte des erreurs de syntaxe dans le fichier %s',
'txtVhostNotClean' => 'Le fichier %s n\'a pas été nettoyé. Il reste des exemples de VirtualHost comme : dummy-host.example.com',
'txtNoProjet' => 'Aucun projet.<br /> Pour en ajouter un nouveau, créez simplement un répertoire dans \'www\'.',
'txtAlias' => 'Vos Alias',
'txtNoAlias' => 'Aucun alias.<br /> Pour en ajouter un nouveau, utilisez le menu de WAMPSERVER.',
'txtVhost' => 'Vos VirtualHost',
'txtNoVhost' => 'Aucun VirtualHost. Ajouter-en un par projet dans le fichier : wamp/bin/apache/apache%s/conf/extra/httpd-vhosts.conf',
'txtNoIncVhost' => 'Décommentez ou ajouter <i>Include conf/extra/httpd-vhosts.conf</i> dans le fichier wamp/bin/apache/apache%s/conf/httpd.conf',
'txtNoVhostFile' => 'Le fichier : %s n\'existe pas',
'txtNoPath' => 'Le chemin %s pour %s n\'existe pas (Fichier %s)',
'txtNotWritable' => 'Le fichier : %s est en lecture seule',
'txtNbNotEqual' => 'Le nombre %s ne correspond pas au nombre de %s dans le fichier %s',
'txtAddVhost' => 'Ajouter un Virtual Host',
'txtCorrected' => 'Certaines erreurs VirtualHosts pourront être corrigées.',
'txtPortNumber' => 'Le numéro de port pour %s n\'est pas correct ou ne sont pas identiques dans le fichier %s',
'forum' => 'http://forum.wampserver.com/list.php?1',
'portUsed' => 'Port défini pour Apache : ',
'mysqlportUsed' => 'Port défini pour MySQL : ',
'nolocalhost' => 'C\'est une mauvaise idée d\'ajouter localhost dans les url de lancement des projets. Il est préférable de définir des VirtualHost dans le fichier<br />wamp/bin/apache/apache%s/conf/extra/httpd-vhosts.conf<br />et de ne pas ajouter localhost dans les url.',
'serverStatusOffline' => 'Serveur hors ligne',
'serverStatusOnline' => 'Serveur en ligne',
)
);
$lang = 'fr';
//var_dump($wampConf);
$version['apache'] = $wampConf;
$version['php'] = $wampConf;
$version['phpCli'] = $wampConf;
$version['mysql'] = $wampConf;
//var_dump(get_loaded_extensions());
$loaded_extensions = get_loaded_extensions();
// classement alphabétique des extensions
setlocale(LC_ALL,"{$langues[$lang]['locale']}");
sort($loaded_extensions,SORT_LOCALE_STRING);
$connectMySQLTested = false;
$connectMySQLValid = false;
$phpExtContents = "<ul>";
foreach ($loaded_extensions as $extension){
$phpExtContents .= "<li>${extension}</li>";
if($extension == "PDO" && !$connectMySQLTested){
try{
$db = new PDO('mysql:host=127.0.0.1;dbname="";port=3306;charset=utf8', "root", "performance_schema");
$connectMySQLValid = true;
}
catch (Exception $e){
$mysqlError = $e->getMessage();
}
$connectMySQLTested = true;
}
elseif($extension == "mysqli" && !$connectMySQLTested){
$mysqli = @new mysqli('127.0.0.1', 'root', '', 'performance_schema', $wampConf['mysqlPortUsed']);
if ($mysqli->connect_error) {
$mysqlError = utf8_encode($mysqli->connect_error);
}
else{
$connectMySQLValid = true;
$mysqli->close();
}
$connectMySQLTested = true;
}
}
$phpExtContents = "</ul>";
if($wampConf['VirtualHostSubMenu'] == "on"){
$vhostError = false;
$vhostsContents = check_virtualhost()['ServerName'];
if(empty($vhostsContents)) {
$vhostDisplay['vhost'][0] = "<li><i style='color:red:'>No VirtualHost</i></li>";
$vhostError = true;
$error_message[] = sprintf($langues[$lang]['txtNoVhost'],$wampConf['apacheVersion']);
}
else{
$vhostAccess = "";
foreach ($vhostsContents as $url) {
$vhostDisplay['vhost'][] = $url;
}
}
if(!$c_hostsFile_writable){
$vhostError = true;
$error_message[] = sprintf($langues[$lang]['txtNotWritable'],$c_hostsFile);
}
if($vhostError) {
foreach($error_message as $value) {
$vhostDisplay['error'][] = $value;
}
}
$vhost['title'] = $langues[$lang]['txtVhost'];
}
else{
$vhost['title'] = $langues[$lang]['nolocalhost'];
}
$aliasDir = $server_dir.'alias/';
$aliasContents = '';
// récupération des alias
if (is_dir($aliasDir))
{
$handle=opendir($aliasDir);
$vhost['aliasTitle'] = $langues[$lang]['txtAlias'];
while (($file = readdir($handle))!==false)
{
if (is_file($aliasDir.$file) && strstr($file, '.conf'))
{
$msg = '';
$vhost['alias'][] = str_replace('.conf','',$file);
}
}
closedir($handle);
}
if (empty($vhost['alias'])){
$vhost['alias'][0] = $langues[$lang]['txtNoAlias'];
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Accueil WampServer</title>
<link rel="stylesheet" href="wampthemes/metro/normalize.css">
<link rel="stylesheet" href="wampthemes/metro/style.css">
</head>
<header>
<div class="container">
<img src="wampthemes/metro/img/logo.png">
<nav>
<ul>
<li>
<a href="/phpmyadmin/">PHPMyAdmin</a>
</li>
<li>
<a href="add_vhost.php?lang=<?php echo $lang;?>"><?php echo $langues[$lang]['txtAddVhost'];?></a>
</li>
<li>
<a href="" class="noClic">Information</a>
<div class="animated scrollDown">
<h2 class="titleConf animated fadeInDown"><?php echo $langues[$lang]['titreConf'];?></h2>
<div class="grid animated fadeInDown">
<div class="tabConfTitle"><p><?php echo $langues[$lang]['versa'];?></p></div>
<div class="col-2"><p><?php echo $wampConf['apacheVersion'];?></p></div>
<div class="tabPortTitle"><p><?php echo $langues[$lang]['portUsed'];?></p></div>
<div class="col-1"><p class="success"><?php echo $wampConf['apachePortUsed'];?></p></div>
<div class="tabPortTitle" style="width:5%;"><p>Status :</p></div>
<div class="col-1"><p><a href="/?onlineoffline" class="<?php echo ($wampConf['status'] == 'offline')?'error':'success';?>"><?php echo ($wampConf['status'] == 'offline')?$langues[$lang]['serverStatusOffline']:$langues[$lang]['serverStatusOnline'];?></a></p></div>
</div>
<div class="grid animated fadeInDown">
<div class="tabConfTitle"><p><?php echo $langues[$lang]['versp'];?></p></div>
<div class="col-2"><p><?php echo $wampConf['phpVersion'];?></p></div>
<div class="tabPortTitle"><p><?php echo $langues[$lang]['verspCli'];?></p></div>
<div class="col-1"><p><?php echo $wampConf['phpCliVersion'];?></p></div>
<div class="col-2"><p><a href="/?phpinfo=1">phpinfo</a></p></div>
</div>
<div class="grid animated fadeInDown">
<div class="tabConfTitle"><p><?php echo $langues[$lang]['versm'];?></p></div>
<div class="col-2"><p><?php echo $wampConf['mysqlVersion'];?></p></div>
<div class="tabPortTitle"><p><?php echo $langues[$lang]['mysqlportUsed'];?></p></div>
<div class="col-2"><p class="<?php echo ($connectMySQLValid)? 'success':'error';?>"><?php echo (!$connectMySQLValid)?$mysqlError:$wampConf['mysqlPortUsed'];?></p></div>
</div>
<p></p>
</div>
</li>
</ul>
</nav>
</div>
</header>
<main>
<div class="container">
<h1><?php echo $vhost['title'];?></h1>
<div>
<?php
if(!empty($vhostDisplay['error'])){
foreach ($vhostDisplay['error'] as $value) {
?>
<h3><i style='color:red;'>Error(s)</i> See below</h3>
<p class="error">
<?php
echo $value;
?>
</p>
<?php
}
}
else{
foreach ($vhostDisplay['vhost'] as $url) {
?>
<div class="vhost">
<a href="http://<?php echo $url;?>" >
<img src="http://<?php echo $url;?>/screenshot.png" width="255" height="250">
<span><?php echo $url;?></span>
</a>
</div>
<?php
}
}
?>
<h1><?php echo $vhost['aliasTitle'];?></h1>
<div>
<?php
if(!empty($vhostDisplay['error'])){
foreach ($vhostDisplay['error'] as $value) {
?>
<h3><i style='color:red;'>Error(s)</i> See below</h3>
<p class="error">
<?php
echo $value;
?>
</p>
<?php
}
}
else{
foreach ($vhost['alias'] as $url) {
?>
<div class="vhost">
<a href="http://localhost/<?php echo $url;?>" >
<img src="http://localhost/<?php echo $url;?>/screenshot.png" width="255" height="250"> <!-- recommende 255 x 200 -->
<span><?php echo $url;?></span>
</a>
</div>
<?php
}
}
?>
</div>
</div>
</main>
<footer>
<div class="container"><p><a href="http://www.dryusdan.fr">Dryusdan</a> | <a href="<?php echo $langues[$lang]['forum'];?>">WampServer Forum</a></p></div>
</footer>
</html>
<?php } ?>