source: trunk/install/install4.php@ 2

Last change on this file since 2 was 2, checked in by root, 15 years ago

importo il progetto

File size: 18.9 KB
Line 
1<?php
2
3/************************************************************************/
4/* Eleonline */
5/* ============================================ */
6/* Installer was based on Joomla Installer */
7/************************************************************************/
8
9error_reporting (E_ALL);
10
11// Set flag that this is a parent file
12define( "_VALID_MOS", 1 );
13
14// Include common.php
15require_once( 'common.php' );
16require_once( './includes/database.php' );
17
18$DBhostname = mosGetParam( $_POST, 'DBhostname', '' );
19$DBuserName = mosGetParam( $_POST, 'DBuserName', '' );
20$DBpassword = mosGetParam( $_POST, 'DBpassword', '' );
21$DBname = mosGetParam( $_POST, 'DBname', '' );
22$DBPrefix = mosGetParam( $_POST, 'DBPrefix', 'soraldo' );
23
24$sitename = mosGetParam( $_POST, 'sitename', '' );
25$nomecomune = mosGetParam( $_POST, 'nomecomune', '' ) ;
26$istat = mosGetParam( $_POST, 'istat', '' ) ;
27$Capoluogo = mosGetParam( $_POST, 'Capoluogo', '' );
28$Lingua = mosGetParam( $_POST, 'Lingua', '' );
29$Multicomune = mosGetParam( $_POST, 'Multicomune', '' );
30$Replica = mosGetParam( $_POST, 'Replica', '' );
31
32//tema
33$tema = mosGetParam( $_POST, 'tema', '' );
34$sceltatema = mosGetParam( $_POST, 'sceltatema', '' );
35$blocco = mosGetParam( $_POST, 'blocco', '' );
36$flash = mosGetParam( $_POST, 'flash', '' );
37// d'hondt
38
39$Limite = mosGetParam( $_POST, 'Limite', '' );
40
41
42$adminName = mosGetParam( $_POST, 'adminName', '');
43$adminEmail = mosGetParam( $_POST, 'adminEmail', '');
44$CreateUSer = intval( mosGetParam( $_POST, 'CreateUSer', '' ) );
45$siteUrl = mosGetParam( $_POST, 'siteUrl', '' );
46$absolutePath = mosGetParam( $_POST, 'absolutePath', '' );
47$adminPassword = mosGetParam( $_POST, 'adminPassword', '');
48
49if ((trim($adminEmail== "")) || (preg_match("/[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}/", $adminEmail )==false)) {
50
51 echo "<form name=\"stepBack\" method=\"post\" action=\"install3.php\">
52 <input type=\"hidden\" name=\"DBhostname\" value=\"$DBhostname\" />
53 <input type=\"hidden\" name=\"DBuserName\" value=\"$DBuserName\" />
54 <input type=\"hidden\" name=\"DBpassword\" value=\"$DBpassword\" />
55 <input type=\"hidden\" name=\"DBname\" value=\"$DBname\" />
56 <input type=\"hidden\" name=\"DBPrefix\" value=\"$DBPrefix\" />
57
58 <input type=\"hidden\" name=\"DBcreated\" value=\"1\" />
59 <input type=\"hidden\" name=\"sitename\" value=\"$sitename\" />";
60
61
62 echo " <input type=\"hidden\" name=\"nomecomune\" value=\"$nomecomune\" />
63 <input type=\"hidden\" name=\"istat\" value=\"$istat\"/>
64 <input type=\"hidden\" name=\"Capoluogo\" value= \"$Capoluogo\" />
65 <input type=\"hidden\" name=\"Lingua\" value= \"$Lingua\" />
66 <input type=\"hidden\" name=\"Multicomune\" value=\"$Multicomune\" />
67 <input type=\"hidden\" name=\"Replica\" value=\"$Replica\" />
68
69 <input type=\"hidden\" name=\"tema\" value=\"$tema\" />
70 <input type=\"hidden\" name=\"sceltatema\" value=\"$sceltatema\" />
71 <input type=\"hidden\" name=\"blocco\" value=\"$blocco\" />
72 <input type=\"hidden\" name=\"flash\" value= \"$flash\" />
73
74
75 <input type=\"hidden\" name=\"Limite\" value=\"$Linite\" />";
76
77
78 echo "Indirizzo Email non valido";
79
80
81 echo " <input type=\"hidden\" name=\"adminName\" value=\"$adminName\" />
82 <input type=\"hidden\" name=\"adminEmail\" value=\"$adminEmail\" />
83
84 <input type=\"hidden\" name=\"siteUrl\" value=\"$siteUrl\" />
85 <input type=\"hidden\" name=\"absolutePath\" value=\"$absolutePath\" />
86 </form>";
87 echo "<script>alert('Devi inserire un indirizzo email valido.'); document.stepBack.submit(); </script>";
88 return;
89}
90
91if($DBhostname && $DBuserName && $DBname) {
92 $configArray['DBhostname'] = $DBhostname;
93 $configArray['DBuserName'] = $DBuserName;
94 $configArray['DBpassword'] = $DBpassword;
95 $configArray['DBname'] = $DBname;
96 $configArray['DBPrefix'] = $DBPrefix;
97} else {
98 echo "<form name=\"stepBack\" method=\"post\" action=\"install3.php\">
99 <input type=\"hidden\" name=\"DBhostname\" value=\"$DBhostname\" />
100 <input type=\"hidden\" name=\"DBuserName\" value=\"$DBuserName\" />
101 <input type=\"hidden\" name=\"DBpassword\" value=\"$DBpassword\" />
102 <input type=\"hidden\" name=\"DBname\" value=\"$DBname\" />
103 <input type=\"hidden\" name=\"DBPrefix\" value=\"$DBPrefix\" />
104
105 <input type=\"hidden\" name=\"DBcreated\" value=\"1\" />
106 <input type=\"hidden\" name=\"sitename\" value=\"$sitename\" />";
107
108 echo ' <input type="hidden" name="nomecomune" value="<?php echo "$nomecomune"; ?>" />
109 <input type="hidden" name="istat" value="<?php echo "$istat"; ?>" />
110 <input type="hidden" name="Capoluogo" value="<?php echo "$Capoluogo"; ?>" />
111 <input type="hidden" name="Lingua" value="<?php echo "$Lingua"; ?>" />
112 <input type="hidden" name="Multicomune" value="<?php echo "$Multicomune"; ?>" />
113 <input type="hidden" name="Replica" value="<?php echo "$Replica"; ?>" />
114
115 <input type="hidden" name="tema" value="<?php echo "$tema"; ?>" />
116 <input type="hidden" name="sceltatema" value="<?php echo "$sceltatema"; ?>" />
117 <input type="hidden" name="blocco" value="<?php echo "$blocco"; ?>" />
118 <input type="hidden" name="flash" value="<?php echo "$flash"; ?>" />
119
120
121 <input type="hidden" name="Limite" value="<?php echo "$Linite"; ?>" />';
122
123
124
125
126
127 echo " <input type=\"hidden\" name=\"adminName\" value=\"$adminName\" />
128 <input type=\"hidden\" name=\"adminEmail\" value=\"$adminEmail\" />
129
130 <input type=\"hidden\" name=\"siteUrl\" value=\"$siteUrl\" />
131 <input type=\"hidden\" name=\"absolutePath\" value=\"$absolutePath\" />
132 </form>";
133
134 echo "<script>alert('The database details provided are incorrect and/or empty'); document.stepBack.submit(); </script>";
135 return;
136}
137
138if ($sitename) {
139 if (!get_magic_quotes_gpc()) {
140 $configArray['sitename'] = addslashes($sitename);
141 } else {
142 $configArray['sitename'] = $sitename;
143 }
144} else {
145 echo "<form name=\"stepBack\" method=\"post\" action=\"install3.php\">
146 <input type=\"hidden\" name=\"DBhostname\" value=\"$DBhostname\" />
147 <input type=\"hidden\" name=\"DBuserName\" value=\"$DBuserName\" />
148 <input type=\"hidden\" name=\"DBpassword\" value=\"$DBpassword\" />
149 <input type=\"hidden\" name=\"DBname\" value=\"$DBname\" />
150 <input type=\"hidden\" name=\"DBPrefix\" value=\"$DBPrefix\" />
151
152 <input type=\"hidden\" name=\"DBcreated\" value=\"1\" />
153 <input type=\"hidden\" name=\"sitename\" value=\"$sitename\" />";
154
155 echo ' <input type="hidden" name="nomecomune" value="<?php echo "$nomecomune"; ?>" />
156 <input type="hidden" name="istat" value="<?php echo "$istat"; ?>" />
157 <input type="hidden" name="Lingua" value="<?php echo "$Lingua"; ?>" />
158 <input type="hidden" name="Capoluogo" value="<?php echo "$Capoluogo"; ?>" />
159 <input type="hidden" name="Multicomune" value="<?php echo "$Multicomune"; ?>" />
160 <input type="hidden" name="Replica" value="<?php echo "$Replica"; ?>" />
161
162 <input type="hidden" name="tema" value="<?php echo "$tema"; ?>" />
163 <input type="hidden" name="sceltatema" value="<?php echo "$sceltatema"; ?>" />
164 <input type="hidden" name="blocco" value="<?php echo "$blocco"; ?>" />
165 <input type="hidden" name="flash" value="<?php echo "$flash"; ?>" />
166
167
168 <input type="hidden" name="Limite" value="<?php echo "$Linite"; ?>" />
169 ';
170
171
172 echo " <input type=\"hidden\" name=\"adminName\" value=\"$adminName\" />
173 <input type=\"hidden\" name=\"adminEmail\" value=\"$adminEmail\" />
174
175 <input type=\"hidden\" name=\"siteUrl\" value=\"$siteUrl\" />
176 <input type=\"hidden\" name=\"absolutePath\" value=\"$absolutePath\" />
177 </form>";
178
179 echo "<script>alert('The sitename has not been provided'); document.stepBack2.submit();</script>";
180 return;
181}
182
183if (file_exists( '../client/config.php' )) {
184 $canWrite = is_writable( '../client/config.php' );
185} else {
186 $canWrite = is_writable( '../client' );
187}
188
189// admin
190if (file_exists( '../client/config.php' )) {
191 $canWrite2 = is_writable( '../admin/config.php' );
192} else {
193 $canWrite2 = is_writable( '../admin' );
194}
195
196
197
198if ($siteUrl) {
199 $configArray['siteUrl']=$siteUrl;
200 // Fix for Windows
201 $absolutePath= str_replace("\\\\","/", $absolutePath);
202 $configArray['absolutePath']=$absolutePath;
203
204
205#########################################################################
206# Config visualizzazione
207$config = "<?php\n";
208$config .= "\n";
209
210$config .= "/************************************************************************/\n";
211$config .= "/* Eleonline - Raccolta e diffusione dei dati elettorali */\n";
212$config .= "/* by Roberto Gigli & Luciano Apolito */\n";
213$config .= "/* http://www.eleonline.it */\n";
214$config .= "/* info@eleonline.it luciano@aniene.net rgigli@libero.it */\n";
215$config .= "/************************************************************************/\n";
216$config .= "\n";
217$config .= "\n";
218$config .= "if (eregi(\"config.php\",\$_SERVER['PHP_SELF'])) {\n";
219$config .= " Header(\"Location: index.php\");\n";
220$config .= " die();\n";
221$config .= "}\n";
222$config .= "\n";
223$config .= "\n";
224$config .= "/* Variabili di configurazione accesso db */\n";
225$config .= "\$dbhost = \"{$configArray['DBhostname']}\";\n";
226$config .= "\$dbuname = \"{$configArray['DBuserName']}\";\n";
227$config .= "\$dbpass = \"{$configArray['DBpassword']}\";\n";
228$config .= "\$dbname = \"{$configArray['DBname']}\";\n";
229$config .= "\$prefix = \"{$configArray['DBPrefix']}\";\n";
230$config .= "\$dbtype = \"MySQL\";\n";
231
232
233
234
235$config .= "\n";
236$config .= "ini_set('display_errors',0);\n";
237$config .= "?>\n";
238
239
240#####################################################################################
241# config amministrazione
242#####################################################################################
243
244$config_adm = "<?php\n";
245$config_adm .= "\n";
246
247$config_adm .= "/************************************************************************/\n";
248$config_adm .= "/* Eleonline - Raccolta e diffusione dei dati elettorali */\n";
249$config_adm .= "/* by Roberto Gigli & Luciano Apolito */\n";
250$config_adm .= "/* http://www.eleonline.it */\n";
251$config_adm .= "/* info@eleonline.it luciano@aniene.net rgigli@libero.it */\n";
252$config_adm .= "/************************************************************************/\n";
253$config_adm .= "\n";
254$config_adm .= "\n";
255$config_adm .= "if (eregi(\"config.php\",\$_SERVER['PHP_SELF'])) {\n";
256$config_adm .= " Header(\"Location: index.php\");\n";
257$config_adm .= " die();\n";
258$config_adm .= "}\n";
259$config_adm .= "\n";
260$config_adm .= "\n";
261$config_adm .= "\n";
262$config_adm .= "\$dbhost = \"{$configArray['DBhostname']}\";\n";
263$config_adm .= "\$dbuname = \"{$configArray['DBuserName']}\";\n";
264$config_adm .= "\$dbpass = \"{$configArray['DBpassword']}\";\n";
265$config_adm .= "\$dbname = \"{$configArray['DBname']}\";\n";
266$config_adm .= "\$prefix = \"{$configArray['DBPrefix']}\";\n";
267$config_adm .= "\$dbtype = \"MySQL\";\n";
268$config_adm .= "ini_set('display_errors',0);\n";
269$config_adm .= "?>\n";
270
271
272
273
274
275
276
277
278
279
280
281 if ($canWrite && ($fp = fopen("../client/config.php", "w"))) {
282 fputs( $fp, $config, strlen( $config ) );
283 fclose( $fp );
284 } else {
285 $canWrite = false;
286 }
287
288 if ($canWrite2 && ($fp = fopen("../admin/config.php", "w"))) {
289 fputs( $fp, $config_adm, strlen( $config_adm ) );
290 fclose( $fp );
291 } else {
292 $canWrite2 = false;
293 }
294
295
296
297
298 $database = new database( $DBhostname, $DBuserName, $DBpassword, $DBname );
299 $nullDate = $database->getNullDate();
300
301 // create the admin user
302 $cryptpass = md5( $adminPassword );
303 //$query = "INSERT INTO {$configArray['DBPrefix']}_authors VALUES ('$adminName', '$adminName', '0', '$adminEmail', '$cryptpass','1','0','0','1','it')";
304 $query = "UPDATE {$configArray['DBPrefix']}_authors SET aid='$adminName', name='$adminName', email='$adminEmail', pwd= '$cryptpass' WHERE aid='suser'";
305 $database->setQuery( $query );
306 $database->query();
307
308 // create Comune
309
310 $query = "INSERT INTO {$configArray['DBPrefix']}_ele_comuni VALUES ('$istat', '$nomecomune', '','','','','$Limite','$Capoluogo','','','')";
311
312 $database->setQuery( $query );
313 $database->query();
314
315 $query = "UPDATE {$configArray['DBPrefix']}_config SET sitename='$sitename', siteurl='$siteUrl', adminmail='$adminEmail', tema='$tema', foot='',language='$Lingua',blocco='$blocco',fileout='$Replica',Versione='2.0 beta', siteistat='$istat',multicomune='$Multicomune',flash='$flash', tema_on='$sceltatema' WHERE sitename=''";
316
317
318 $database->setQuery( $query );
319 $database->query();
320
321
322 // touch config table
323 $date = date("F Y");
324 $query = "UPDATE {$configArray['DBPrefix']}_config SET sitename='$sitename', nukeurl='$siteUrl', startdate='$date', adminmail='$adminEmail', backend_title='$sitename', notify_email='$adminEmail'";
325 $database->setQuery( $query );
326 $database->query();
327
328} else {
329?>
330 <form action="install3.php" method="post" name="stepBack3" id="stepBack3">
331 <input type="hidden" name="DBhostname" value="<?php echo $DBhostname;?>" />
332 <input type="hidden" name="DBusername" value="<?php echo $DBuserName;?>" />
333 <input type="hidden" name="DBpassword" value="<?php echo $DBpassword;?>" />
334 <input type="hidden" name="DBname" value="<?php echo $DBname;?>" />
335 <input type="hidden" name="DBcreated" value="1" />
336 <input type="hidden" name="sitename" value="<?php echo $sitename;?>" />
337 <input type="hidden" name="adminName" value="$adminName" />
338 <input type="hidden" name="adminEmail" value="$adminEmail" />
339 <input type="hidden" name="CreateUSer" value="$CreateUSer" />
340 <input type="hidden" name="siteUrl" value="$siteUrl" />
341 <input type="hidden" name="absolutePath" value="$absolutePath" />
342 <?php
343 echo '<input type="hidden" name="nomecomune" value="<?php echo "$nomecomune"; ?>" />
344 <input type="hidden" name="istat" value="<?php echo "$istat"; ?>" />
345 <input type="hidden" name="Capoluogo" value="<?php echo "$Capoluogo"; ?>" />
346 <input type="hidden" name="Lingua" value="<?php echo "$Lingua"; ?>" />
347 <input type="hidden" name="Multicomune" value="<?php echo "$Multicomune"; ?>" />
348 <input type="hidden" name="Replica" value="<?php echo "$Replica"; ?>" />
349
350 <input type="hidden" name="tema" value="<?php echo "$tema"; ?>" />
351 <input type="hidden" name="sceltatema" value="<?php echo "$sceltatema"; ?>" />
352 <input type="hidden" name="blocco" value="<?php echo "$blocco"; ?>" />
353 <input type="hidden" name="flash" value="<?php echo "$flash"; ?>" />
354
355 <input type="hidden" name="Limite" value="<?php echo "$Linite"; ?>" />
356 ';
357 ?>
358 </form>
359 <script>alert('The site url has not been provided'); document.stepBack3.submit();</script>
360<?php
361}
362include("header.php");
363?>
364<div id="ctr" align="center">
365 <form action="dummy" name="form" id="form">
366 <div class="install">
367 <div id="stepbar">
368 <div class="step-off">inizio</div>
369 <div class="step-off">licenza</div>
370 <div class="step-off">passo 1</div>
371 <div class="step-off">passo 2</div>
372 <div class="step-off">passo 3</div>
373 <div class="step-on">passo 4</div>
374 </div>
375 <div id="right">
376 <div id="step">passo 4</div>
377 <div class="far-right">
378 <input class="button" type="button" name="runSite" value="Guarda il Sito"
379<?php
380 if ($siteUrl) {
381 echo "onClick=\"window.location.href='$siteUrl/index.php' \"";
382 } else {
383 echo "onClick=\"window.location.href='".$configArray['siteURL']."/index.php' \"";
384 }
385?>/>
386 <input class="button" type="button" name="Admin" value="Amministrazione"
387<?php
388 if ($siteUrl) {
389 echo "onClick=\"window.location.href='$siteUrl/../admin' \"";
390 } else {
391 echo "onClick=\"window.location.href='".$configArray['siteURL']."/../admin' \"";
392 }
393?>/>
394 </div>
395 <div class="clr"></div>
396 <h1>Congratulazioni! EleOnLine e' installato</h1>
397 <div class="install-text">
398 <p>Clicca sul pulsante "Guarda il Sito" per visitare la parte in Visualizzazione oppure su "Amministrazione" per entrare nel pannello di ammnistrazione.</p>
399 </div>
400 <div class="install-form">
401 <div class="form-block">
402 <table width="100%">
403 <tr><td class="error" align="center">Una volta configurato e testato il sistema<br/>
404e prima di avviare il servizio online<br/>
405ricordati di effettuare una politica di sicurezza<br/>
406come la separazione della parte di visualizzazione (client)<br/>
407da quella di amministrazione (admin)<br/>
408od anche l'utenza del database pubblico in sola lettura<br/>
409e altri accorgimenti che riterrai necessarie<br/>
410
411
412
413</td></tr>
414 <tr><td align="center"><h5>Dettagli Login Amministrazione</h5></td></tr>
415 <tr><td align="center" class="notice"><b>Username : <?php echo $adminName; ?></b></td></tr>
416 <tr><td align="center" class="notice"><b>Password : <?php echo $adminPassword; ?></b></td></tr>
417 <tr><td>&nbsp;</td></tr>
418 <tr><td align="right">&nbsp;</td></tr>
419<!-- client -->
420<?php if (!$canWrite) { ?>
421 <tr>
422 <td class="small">
423 <h1>config.php per visualizzazione</h1>
424 <font color="#FF0000"><b>ATTENZIONE:</b></font> Il tuo file di configurazione o la cartella non sono scrivibili,
425 o c'Ú stato un problema nella creazione del file di configurazione. Clicca nella area di testo per evidenziare
426 tutto il codice. Crea un nuovo file chiamato <b>config.php</b> e copialo nella cartella <b>client</b>.
427 </td>
428 </tr>
429
430
431 <tr>
432 <td align="center">
433 <textarea rows="15" cols="48" name="configcode" onClick="javascript:this.form.configcode.focus();this.form.configcode.select();" ><?php echo htmlspecialchars( $config );?></textarea>
434 </td>
435 </tr>
436<?php } ?>
437
438<!-- admin -->
439<?php if (!$canWrite2) { ?>
440 <tr>
441 <td class="small">
442 <h1>config.php per amministrazione</h1>
443 <font color="#FF0000"><b>ATTENZIONE:</b></font> Il tuo file di configurazione o la cartella non sono scrivibili,
444 o c'Ú stato un problema nella creazione del file di configurazione. Clicca nella area di testo per evidenziare
445 tutto il codice. Crea un nuovo file chiamato <strong>config.php</strong> e copialo nella cartella <b>admin</b>.
446 </td>
447 </tr>
448
449
450 <tr>
451 <td align="center">
452 <textarea rows="15" cols="48" name="configcode" onClick="javascript:this.form.configcode.focus();this.form.configcode.select();" ><?php echo htmlspecialchars( $config_adm );?></textarea>
453 </td>
454 </tr>
455<?php } ?>
456
457
458
459
460 <tr><td class="small"><?php /*echo $chmod_report*/; ?></td></tr>
461 </table>
462 </div>
463 </div>
464 <div id="break"></div>
465 </div>
466 <div class="clr"></div>
467 </div>
468 </form>
469</div>
470<div class="clr"></div>
471<div class="ctr">
472
473</div>
474<?php include("footer.php"); ?>
475</div>
476</html>
Note: See TracBrowser for help on using the repository browser.