Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
BuzzPoll (Sondaggio PHP) - install.php

install.php

Caricato da: A_butta
Scarica il programma completo

  1. <?
  2. function creaImmagini()
  3. {
  4.   $im = ImageCreate(250,10);
  5.   $rect = ImageColorAllocate($im,209,215,220);
  6.   $blu = ImageColorAllocate($im,0,0,255);
  7.   imagefill($im,0,0,$nero); //SFONDO
  8.   for ($i=0;$i<=250;$i++)
  9.   {
  10.     if ($i!=0)
  11.       imagefilledrectangle($im,0,0,$i,10,$blu); //RETTANGOLO
  12.     imagepng($im,"img/$i.png");
  13.   }
  14.   imagedestroy($im);
  15. }
  16. ?>
  17.  
  18. <html>
  19. <head>
  20.   <title>Configurazione sondaggi</title>
  21. </head>
  22. <body style="background: black; color: white">
  23. <div style="position: absolute; margin: 0 auto">
  24. <form method="post" action="" style="position: relative; margin: 0 auto; border: solid red 3px; padding: 5px">
  25.   Nome DataBase : <input type="text" name="dbname" value="" /><br /><br />
  26.   Host* : <input type="text" name="host" value="localhost" style="margin-left: 64px"/><br /><br />
  27.   Utente : <input type="text" name="user" value="" style="margin-left: 60px"/><br /><br />
  28.   Password : <input type="password" name="pass" value=""  style="margin-left: 40px"/><br /><br />
  29.   <input type="submit" value="C  O  N  F  I  G  U  R  A" name="config" style="border: groove blue; font-weight: bold; width: 258px;" /><br />
  30. <?
  31.  
  32. if (isset($_POST['config']))
  33. {
  34.     $HostName = $_POST['host'];
  35.     $dbPass = $_POST['pass'];
  36.     $dbUser = $_POST['user'];
  37.     $dbName = $_POST['dbname'];
  38.     echo '--- Connessione al database in corso --- <br />';
  39.     $db = @mysql_connect($HostName,$dbUser,$dbPass);
  40.     if ($db == false)  die ("<span style='color:red'><strong>Impossibile connettersi al database</strong></span>");
  41.     mysql_select_db($dbName,$db)    or die ("<span style='color:red'><strong>Impossibile selezionare database</strong></span>");
  42.     echo '<strong>Connessione al database avvenuta con successo</strong><br />';
  43.     echo '---Creazione delle tabelle in corso---<br />';
  44.     $query = "CREATE TABLE `sondaggi` (
  45.    `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
  46.    `titolo` VARCHAR( 255 ) NOT NULL ,
  47.    `voci` TEXT NOT NULL ,
  48.    `dataCreazione` INT NOT NULL,
  49.    `votazione` TEXT NOT NULL
  50.    )";
  51.     $result = mysql_query($query);
  52.     if ($result)
  53.     {
  54.       echo '<strong>Tabella '.addslashes('sondaggi').' creata con successo</strong><br />';
  55.       creaImmagini();
  56.       $codice = "<? \r \$dbName = '$dbName'; \r \$HostName = '$HostName'; \r \$dbUser = '$dbUser'; \r \$dbPass = '$dbPass'; \r ?>";
  57.       $f = fopen('config.php','w+');
  58.       fwrite($f,$codice);
  59.       fclose($f);      
  60.    }
  61.    else
  62.       echo '<span style="color:red"><strong>Tabella '.addslashes('sondaggi').' non creata correttamente. Ripetere l\'operazione di installazione</strong></span>';
  63.    mysql_close($db);
  64. }
  65. ?>
  66.  
  67. </form>
  68. <span style="color: green">* di solito è <strong>localhost</strong>
  69. </div>
  70. </body>
  71. </html>