Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!(is_writable('config.php')))//controllo se il file config.php รจ scrivibile
- die("<em>Settare i permessi del file config.php a 777 (chmod)</em>");
- if(!(file_exists('config.php'))) // controllo se il file config.php esiste
- die("<em>File 'config.php' inesistente| Creare un file chiamato config.php vuoto</em>");
- ?>
- <html>
- <head>
- <title>Installazione</title>
- </head>
- <body>
- <center><h1>Installazione</h1></center>
- <table>
- <tr><td>
- <form action="?send=1" method="post">
- </td></tr>
- <tr><td><b>Dati per la connessione al MySQL</b></td></tr>
- <tr><td>Hostname:</td><td><input type="text" name="host" value="localhost"/></td></tr>
- <tr><td>Username:</td><td><input type="text" name="user" /></td></tr>
- <tr><td>Password:</td><td><input type="password" name="pass" /></td></tr>
- <tr><td>DB Name:</td><td><input type="text" name="dbname"/></td></tr><br />
- <input type="submit" value="Installa!" name="send" />
- </form>
- </table>
- <?php
- if(@$_GET['send'] == 1) {
- if (isset($_POST['host'])
- && isset($_POST['user'])
- && isset($_POST['pass'])
- && isset($_POST['dbname'])) {
- //Dati Connessione MySQL
- $host = $_POST['host'];
- $user = $_POST['user'];
- $passwd = $_POST['pass'];
- $dbname = $_POST['dbname'];
- $conn = mysql_connect ($host , $user ,$passwd) or die(mysql_error());
- mysql_select_db ($dbname,$conn) or die(mysql_error());
- //creo la prima SQL da eseguire
- $sql = "CREATE TABLE project (
- `id` int(11) NOT NULL auto_increment,
- `titolo` TEXT NOT NULL,
- `username` TEXT NOT NULL,
- `commento` TEXT NOT NULL,
- `data` TEXT NOT NULL,
- `ip` TEXT NOT NULL,
- PRIMARY KEY ( id )
- );";
- mysql_query($sql) or die ("SQL Error:".mysql_error());//eseguo la prima SQL, se da errori li stampo
- echo "<font color=\"green\">Table 'project' creata</font><br />\n";
- // creazione contenuto file config.php
- $config='<?php
- $host = "'.$host.'";
- $user = "'.$user.'";
- $passwd = "'.$passwd.'";
- $dbname = "'.$dbname.'";
- $conn = mysql_connect($host, $user, $passwd) or die(mysql_error()); //connetto al DB
- mysql_select_db($dbname, $conn) or die(mysql_error()); //Seleziono il DB
- ?>';
- // Scriviamo sul config.php i dati che ci occorrono
- if(!($open = fopen( "config.php", "w" )))
- die("Errore durante l'apertura sul file config.php");
- fwrite ($open, $config);//Scrivo sul file config.php
- fclose ($open); // chiudo il file
- echo "<font color=\"green\">File 'config.php' creato con successo</font><br />\n";
- echo "<font color=green>Installazione avvenuta con successo!</font>"; //stampo l'avvenuto successo di installazione
- } else {
- print "<script>alert('riempire tutti i campi');</script>";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement