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 xl0g</title>
- </head>
- <body>
- <link rel="stylesheet" href="style.css" type="text/css">
- <b><font color ="red"><pre align ="center">
- _ ___
- | |/ _ \
- __ _| | | | | __ _
- \ \/ / | | | |/ _` |
- > <| | |_| | (_| |
- /_/\_\_|\___/ \__, |
- __/ |
- |___/
- </pre></font></b>
- <center><form action="?send=1" method="post">
- <div id ="install">
- <br>
- <font color ="white"><b>Dati per la connessione al MySQL</b></font><br><br>
- Hostname: <input type="text" name="host" value="localhost"/><br>
- Username: <input type="text" name="user" /><br>
- Password: <input type="password" name="pass" /><br>
- DB Name: <input type="text" name="dbname"/><br>
- <hr>
- <br>
- <font color ="white"><b>Dati del blog</b></font><br><br>
- Titolo del blog: <input type="text" name="site_title" /><br>
- Username : <input type="text" name="username" /><br>
- Password : <input type="password" name="password" /><br>
- <br>
- <input type="submit" value="Installa!" name="send" />
- </div>
- </form></center>
- <?php
- if(@$_GET['send'] == 1) {
- //controllo inserimento campi
- if(empty($_POST['host']) || empty($_POST['user']) || empty($_POST['pass']) || empty($_POST['dbname']) || empty ($_POST['site_title']) || empty ($_POST['username']) || empty ($_POST['password']))
- die("<script>alert('Inserisci tutti i dati'); window.loading=\"index.php\";</script>");
- }
- 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());
- $site_title = $_POST['site_title'];
- $username = $_POST['username'];
- $password = $_POST['password'];
- //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
- $site_title = "'.$site_title.'";
- $username = "'.$username.'";
- $password = "'.$password.'";
- ?>';
- // 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
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement