<?php
/*****************************************************************
* Spacemarc News
* Version: 1.2.0
* Author and copyright (C): Marcello Vitagliano
* Web site: http://www.spacemarc.it
* License: GNU General Public License
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* Current file: install.php
*****************************************************************/
define('IN_NEWS', true);
header('Content-type: text/html; charset=ISO-8859-1');
//includo i file di configurazione
require_once (dirname(__FILE__) . '/../config.php');
$db = mysql_connect($db_host, $db_user, $db_password) or die("Impossibile connettersi a MySQL<br />Numero errore: " . mysql_errno() . "<br />Tipo di errore: " . mysql_error());
mysql_select_db($db_name, $db) or die("Impossibile selezionare il database $db_name<br />Numero errore: " . mysql_errno() . "<br />Tipo di errore: " . mysql_error());
//aumento il tempo di timeout dello script a 180 secondi
set_time_limit(180);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Spacemarc News v1.2.0: nuova installazione
</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body>
<div align="center" class="text">
<form name="install" action="install.php" method="post">
<table width="800" border="0" cellpadding="2" cellspacing="2">
<tr>
<td class="text" align="center" valign="top">
<img src="../images/logonews.gif" alt="logo" /><br />Installazione di <b>Spacemarc News</b> <b>v1.2.0</b> (
<a href="../docs/index.html">guida</a>)<br /><br /></td>
</tr>
<tr>
<td class="text2" align="center" bgcolor="#EEEEEE"><b>Accettazione licenza</b><br /> </td>
</tr>
<tr>
<td class="text2" align="center">
<?php
$file = "../docs/gpl-3.0.txt";
$op = fopen($file, "r") or die("Impossibile aprire il file ../docs/gpl-3.0.txt");
$rd = fread($op, filesize($file));
fclose($op);
echo "<textarea name=\"license\" rows=\"12\" cols=\"88\" readonly=\"readonly\">" . $rd . "</textarea>";
?><br />
<input type="checkbox" name="lic_OK" id="lic_OK" />
<label for="lic_OK">Accetto i termini della licenza GNU GENERAL PUBLIC LICENSE
</label><br /><br /><br /></td>
</tr>
<tr>
<td class="text2" align="center" bgcolor="#EEEEEE"><b>Impostazioni iniziali</b><br /></td>
</tr>
<tr>
<td align="left">
<label for="nome_cognome" style="font-size: 11px; cursor: help; border-bottom: 1px dotted #000;" title="Tuo nome e cognome o Nickname">Nome e cognome
</label>
<input type="text" name="nome_cognome" id="nome_cognome" size="20" maxlength="40" /> <br />
<label for="email" style="font-size: 11px; cursor: help; border-bottom: 1px dotted #000;" title="Servirà per accedere al sistema">Email valida
</label>
<input type="text" name="email" id="email" size="20" maxlength="30" /><br />
<label for="password" style="font-size: 11px; cursor: help; border-bottom: 1px dotted #000;" title="Scegli una password di accesso">Scegli la password
</label>
<input type="password" name="password" id="password" size="20" /><br />
<label for="nome_sito" style="font-size: 11px; cursor: help; border-bottom: 1px dotted #000;" title="Esempio: Spacemarc.it">Nome del sito
</label>
<input type="text" name="nome_sito" id="nome_sito" size="20" maxlength="40" /><br />
<label for="url_sito" style="font-size: 11px; cursor: help; border-bottom: 1px dotted #000;" title="Con http:// e senza / finale">URL sito
</label>
<input type="text" name="url_sito" id="url_sito" size="20" value="http://" maxlength="40" /></td>
</tr>
<tr>
<td align="center"><br />
<input type="submit" name="upgrade" value="Installa" style="font-weight: bold;" /><br /><br /></td>
</tr>
<tr>
<td align="center" class="text2" bgcolor="#C2D8FE">Spacemarc News
<?php echo $vers; ?> ©
<a href="http://www.spacemarc.it" target="_blank" class="piccolo">Spacemarc.it</a></td>
</tr>
</table>
</form> <br />
<table width="800" cellpadding="2" cellspacing="2" border="0">
<tr><td>
<?php
if (isset($_POST['upgrade'])) {
if (!isset($_POST['lic_OK']) || trim($_POST['nome_cognome']) == '' || trim($_POST['email']) == '' || trim($_POST['password']) == '' || trim($_POST['nome_sito']) == '' || trim($_POST['url_sito']) == 'http://') {
die("<b>Tutti i campi e l'accettazione della licenza sono obbligatori</b></td></tr></table></div></body></html>");
}
echo "<b>Installazione in corso...</b><br /><br />";
//CREO LA TABELLA DI CONFIGURAZIONE
if (mysql_query("CREATE TABLE IF NOT EXISTS `$tab_config` (
`nome_sito` varchar(40) NOT NULL,
`url_sito` varchar(40) NOT NULL,
`max_archivio` int(3) NOT NULL default '10',
`max_archivio_parole` int(3) NOT NULL default '50',
`max_ricerche` int(3) NOT NULL default '15',
`max_tit_include` int(2) NOT NULL default '5',
`max_parole_include` int(2) NOT NULL default '0',
`sfondo_titolo` char(7) NOT NULL default '#F6F6F6',
`sfondo_notizia` char(7) NOT NULL default '#FFFFFF',
`sfondo_strumenti` char(7) NOT NULL default '#F6F6F6',
`larghezza` int(4) NOT NULL default '600',
`larghezza_pager` int(4) NOT NULL default '300',
`formato_data` int(1) NOT NULL default '1',
`max_gest_news` int(3) NOT NULL default '10',
`max_utenti` int(3) NOT NULL default '10',
`max_news_personali` int(3) NOT NULL default '10',
`nuova_news_day` int(2) NOT NULL default '10',
PRIMARY KEY (`nome_sito`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;")) {
echo "Tabella `$tab_config` creata con successo... <b>OK</b><br />";
}
else {
echo "<font color=\"#FF0000\">SQL1: " . mysql_error() . " ... ERRORE</font><br />";
}
//POPOLO LA TABELLA DI CONFIGURAZIONE
if (mysql_query("INSERT INTO `$tab_config` (`nome_sito`, `url_sito`, `max_archivio`, `max_archivio_parole`, `max_ricerche`, `max_tit_include`, `max_parole_include`, `sfondo_titolo`, `sfondo_notizia`, `sfondo_strumenti`, `larghezza`, `larghezza_pager`, `formato_data`, `max_gest_news`, `max_utenti`, `max_news_personali`, `nuova_news_day`) VALUES ('" . mysql_real_escape_string($_POST['nome_sito']) . "', '" . mysql_real_escape_string($_POST['url_sito']) . "', 15, 0, 15, 6, 0, '#F6F6F6', '#FFFFFF', '#F6F6F6', 605, 300, 5, 20, 20, 20, 1)")) {
echo "Tabella `$tab_config` popolata con successo... <b>OK</b><br />";
}
else {
echo "<font color=\"#FF0000\">SQL2: " . mysql_error() . " ... ERRORE</font><br />";
}
//CREO LA TABELLA DEGLI UTENTI
if (mysql_query("CREATE TABLE IF NOT EXISTS `$tab_utenti` (
`user_id` int(4) unsigned NOT NULL auto_increment,
`nome_cognome` varchar(40) NOT NULL default '',
`email` varchar(30) NOT NULL default '',
`livello_id` tinyint(1) NOT NULL default '3',
`nome_livello` varchar(14) NOT NULL,
`user_password` char(32) NOT NULL,
`attivo` tinyint(1) NOT NULL default '1',
`permessi` enum('letturestampe','nessuno','tutto','upload') NOT NULL default 'tutto',
`mostra_link` varchar(7) NOT NULL default 'nome',
`email_nascosta` tinyint(1) NOT NULL default '1',
`sito` varchar(40) default NULL,
`im` varchar(6) default NULL,
`im_num` varchar(30) default NULL,
`data_nascita` char(10) default NULL,
`citta` varchar(50) default NULL,
`occupazione` varchar(50) default NULL,
`hobby` varchar(255) default NULL,
`ultimo_accesso` int(10) NOT NULL default '0',
`data_registrazione` int(10) NOT NULL default '0',
`token` char(32) default NULL,
`cookie` tinyint(1) NOT NULL,
`new_pwd` char(8) default NULL,
`key_pwd` char(10) default NULL,
UNIQUE KEY `user_id` (`user_id`),
UNIQUE KEY `email` (`email`),
KEY `nome_cognome` (`nome_cognome`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;")) {
echo "Tabella `$tab_utenti` creata con successo... <b>OK</b><br />";
}
else {
echo "<font color=\"#FF0000\">SQL3: " . mysql_error() . " ... ERRORE</font><br />";
}
//POPOLO LA TABELLA DEGLI UTENTI
define('SALT', '0123456789abcdefghij>-+*/%!=[$');
$password_utente = md5(SALT . $_POST['password']);
if (mysql_query("INSERT INTO `$tab_utenti` (nome_cognome, email, livello_id, nome_livello, attivo, user_password, permessi, mostra_link, email_nascosta, ultimo_accesso, data_registrazione) VALUES ('" . htmlspecialchars($_POST['nome_cognome'], ENT_QUOTES) . "', '" . mysql_real_escape_string($_POST['email']) . "', 1, 'Amministratore', 1, '$password_utente', 'tutto', 'nome', 1, 0, " . mktime() . ")")) {
echo "Tabella `$tab_utenti` popolata con successo... <b>OK</b><br />";
}
else {
echo "<font color=\"#FF0000\">SQL4: " . mysql_error() . " ... ERRORE</font><br />";
}
//CREO LA TABELLA DELLE NEWS
if (mysql_query("CREATE TABLE IF NOT EXISTS `$tab_news` (
`id` int(8) unsigned NOT NULL auto_increment,
`titolo` varchar(150) NOT NULL,
`testo` text NOT NULL,
`user_id` int(4) NOT NULL,
`data_pubb` int(10) NOT NULL default '0',
`letture` int(8) NOT NULL default '0',
`stampe` int(8) NOT NULL default '0',
`immagine` varchar(70) default NULL,
`nosmile` tinyint(1) NOT NULL default '0',
`ip` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
FULLTEXT KEY `titolo` (`titolo`),
FULLTEXT KEY `testo` (`testo`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;")) {
echo "Tabella `$tab_news` creata con successo... <b>OK</b><br />";
}
else {
echo "<font color=\"#FF0000\">SQL5: " . mysql_error() . " ... ERRORE</font><br />";
}
echo "<br /><b>Se non ci sono stati errori puoi accedere al <a href=\"../admin/login.php\">pannello di controllo</a></b>";
}
?><br /><br /></td>
</tr>
</table>
</div>
</body>
</html>