Advertisement
Guest User

Untitled

a guest
Aug 1st, 2017
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4.  
  5. if (!(is_writable('config.php')))//controllo se il file config.php รƒยจ scrivibile
  6. die("<em>Settare i permessi del file config.php a 777 (chmod)</em>");
  7.  
  8. if(!(file_exists('config.php'))) // controllo se il file config.php esiste
  9. die("<em>File 'config.php' inesistente| Creare un file chiamato config.php vuoto</em>");
  10.  
  11. ?>
  12.  
  13. <html>
  14. <head>
  15. <title>Installazione xl0g</title>
  16. </head>
  17. <body>
  18. <link rel="stylesheet" href="style.css" type="text/css">
  19. <b><font color ="red"><pre align ="center">
  20. _ ___
  21. | |/ _ \
  22. __ _| | | | | __ _
  23. \ \/ / | | | |/ _` |
  24. > <| | |_| | (_| |
  25. /_/\_\_|\___/ \__, |
  26. __/ |
  27. |___/
  28. </pre></font></b>
  29. <center><form action="?send=1" method="post">
  30. <div id ="install">
  31. <br>
  32. <font color ="white"><b>Dati per la connessione al MySQL</b></font><br><br>
  33. Hostname: <input type="text" name="host" value="localhost"/><br>
  34. Username: <input type="text" name="user" /><br>
  35. Password: <input type="password" name="pass" /><br>
  36. DB Name: <input type="text" name="dbname"/><br>
  37. <hr>
  38. <br>
  39. <font color ="white"><b>Dati del blog</b></font><br><br>
  40. Titolo del blog: <input type="text" name="site_title" /><br>
  41. Username : <input type="text" name="username" /><br>
  42. Password : <input type="password" name="password" /><br>
  43. <br>
  44. <input type="submit" value="Installa!" name="send" />
  45. </div>
  46. </form></center>
  47.  
  48.  
  49. <?php
  50.  
  51. if(@$_GET['send'] == 1) {
  52. //controllo inserimento campi
  53. if(empty($_POST['host']) || empty($_POST['user']) || empty($_POST['pass']) || empty($_POST['dbname']) || empty ($_POST['site_title']) || empty ($_POST['username']) || empty ($_POST['password']))
  54. die("<script>alert('Inserisci tutti i dati'); window.loading=\"index.php\";</script>");
  55. }
  56. if (isset($_POST['host'])
  57. && isset($_POST['user'])
  58. && isset($_POST['pass'])
  59. && isset($_POST['dbname'])) {
  60.  
  61. //Dati Connessione MySQL
  62. $host = $_POST['host'];
  63. $user = $_POST['user'];
  64. $passwd = $_POST['pass'];
  65. $dbname = $_POST['dbname'];
  66.  
  67.  
  68. $conn = mysql_connect ($host , $user ,$passwd) or die(mysql_error());
  69. mysql_select_db ($dbname,$conn) or die(mysql_error());
  70. $site_title = $_POST['site_title'];
  71. $username = $_POST['username'];
  72. $password = $_POST['password'];
  73.  
  74. //creo la prima SQL da eseguire
  75. $sql = "CREATE TABLE project (
  76. `id` int(11) NOT NULL auto_increment,
  77. `titolo` TEXT NOT NULL,
  78. `username` TEXT NOT NULL,
  79. `commento` TEXT NOT NULL,
  80. `data` TEXT NOT NULL,
  81. `ip` TEXT NOT NULL,
  82.  
  83. PRIMARY KEY ( id )
  84. );";
  85.  
  86. mysql_query($sql) or die ("SQL Error:".mysql_error());//eseguo la prima SQL, se da errori li stampo
  87. echo "<font color=\"green\">Table 'project' creata</font><br />\n";
  88.  
  89.  
  90. // creazione contenuto file config.php
  91. $config='<?php
  92.  
  93. $host = "'.$host.'";
  94. $user = "'.$user.'";
  95. $passwd = "'.$passwd.'";
  96. $dbname = "'.$dbname.'";
  97.  
  98. $conn = mysql_connect($host, $user, $passwd) or die(mysql_error()); //connetto al DB
  99. mysql_select_db($dbname, $conn) or die(mysql_error()); //Seleziono il DB
  100.  
  101. $site_title = "'.$site_title.'";
  102. $username = "'.$username.'";
  103. $password = "'.$password.'";
  104. ?>';
  105.  
  106. // Scriviamo sul config.php i dati che ci occorrono
  107. if(!($open = fopen( "config.php", "w" )))
  108. die("Errore durante l'apertura sul file config.php");
  109.  
  110. fwrite ($open, $config);//Scrivo sul file config.php
  111.  
  112. fclose ($open); // chiudo il file
  113.  
  114. echo "<font color=\"green\">File 'config.php' creato con successo</font><br />\n";
  115. echo "<font color=green>Installazione avvenuta con successo!</font>"; //stampo l'avvenuto successo di installazione
  116. }
  117.  
  118. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement