Location: PHPKode > projects > Db-newsletter > db-newsletter/install.php
<?

/*
Copyright (c) 2007-2008, Daniel Braun

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

$stat = $_GET['install'];

if($stat == "yes")
{
 $http = "http://";
 $ay = dirname($_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']);
 $link = "/delet.php?id=(id)";
 //Formular-Daten lesen
 $host   = $_POST['server'];
 $user     = $_POST['user'];
 $database = $_POST['database'];
 $pw       = $_POST['pw'];
 
 $dz = mysql_connect($host, $user, $pw);
 mysql_select_db($database, $dz); 
 
 //Tabelle "liste" erstellen
 $table = "liste";
 $create= "CREATE TABLE $table (
  `id` int(11) NOT NULL auto_increment,
  `anrede` varchar(4) collate utf8_unicode_ci NOT NULL,
  `vorname` varchar(30) collate utf8_unicode_ci NOT NULL,
  `nachname` varchar(30) collate utf8_unicode_ci NOT NULL,
  `email` varchar(255) collate utf8_unicode_ci NOT NULL,
  `status` varchar(3) collate utf8_unicode_ci NOT NULL,
  
  PRIMARY KEY (id))";
  
 mysql_query($create);
 
 //Tabelle "settings" erstellen
 $table = "settings";
 $create= "CREATE TABLE $table (
  `anrede_m` varchar(255) NOT NULL,
  `anrede_f` varchar(255) NOT NULL,
  `un` varchar(255) NOT NULL,
  `absender` varchar(255) NOT NULL,
  `passwort` varchar(255) NOT NULL,
  `umleitung` varchar(255) NOT NULL,
  `art` varchar(255) NOT NULL,
  `ordner` varchar(255) NOT NULL,
    
  PRIMARY KEY  (`anrede_m`))";
  
 mysql_query($create);
 
 //Passwort auf admin setzen
 $pass = md5(admin666);
 $update = "INSERT INTO settings (anrede_m, anrede_f, passwort, umleitung, art, ordner) VALUES  ('Sehr geehrter Herr', 'Sehr geehrte Frau', '$pass', 'index.php', 'html', '$http$ay$link')";
 $dummy = mysql_query($update);
 
// mysql.php schreiben
$fp = fopen("include/mysql.php", "w+");
fwrite($fp, "<?
\$host = \"$host\";
\$user = \"$user\";
\$pw = \"$pw\";
\$database = \"$database\";

\$dz = mysql_connect(\$host, \$user, \$pw);
mysql_select_db(\$database, \$dz);
?>");
fclose($fp);


 echo "<div align=center><b>Die Installation ist nun beendet. Klicken Sie <a href=\"index.php\">hier</a> um zur Anmledung zu gelangen, das Passwort lautet admin666. Denken Sie daran das Passwort zu &auml;ndern und die install.php zu l&ouml;schen.</b></div><br><br><br>";
  
}


$mysqlconf = "include/mysql.php"; //Pfad zur MySQL-Config

// Pr?fe ob Datei gesschrieben werden kann
if(is_writable($mysqlconf))
{
 $wr = "1";
}

else
{
 $wr = "0";
}


?>


<html>

<head><link rel="stylesheet" type="text/css" href="style.css"></head>
	
	
	
	<div align="center">
		<h1>DB-Newsletter Installation</h1>
	</div>
	<h2>Zugriffstest</h2>
	    <?
		 if($wr == 1)
		 {
		  echo "<font color=green><b>Datei mysql.php ist schreibbar</b></font>";
		 }
		 
		 else
		 {
		  echo "<font color=red><b>Die Datei \"mysql.php\" im Verzeichnis include kann nicht geschrieben werden. Bitte  &auml;ndern Sie die Zugriffsrechte auf 777</b></font>";
		 }
		?>
		
	<br><br>
	<h2>MySQL-Daten</h2>
	<form id="mysql" action="install.php?install=yes" method="post" name="mysql">
		<table width="337" border="0" cellspacing="5" cellpadding="0">
			<tr>
				<td><b>Host</b></td>
				<td><input type="text" name="server" value="localhost" size="24"></td>
			</tr>
			<tr>
				<td><b>User</b></td>
				<td><input type="text" name="user" value="root" size="24"></td>
			</tr>
			<tr>
				<td><b>Datenbank-Name</b></td>
				<td><input type="text" name="database" size="24"></td>
			</tr>
			<tr>
				<td><b>Passwort</b></td>
				<td><input type="text" name="pw" size="24"></td>
			</tr>
		</table>
		<?
         if($wr == 1)
         {
          echo "<p><input type=\"submit\" name=\"submitButtonName\" value=\"Datenbank erstellen\"></p> <p>Bitte beachten Sie, dass die Datenbank vor der Installtion erstellt werden muss!</p>";
         }
         
         else
         {
         }
        ?>
        
	</form>
	</div>
		
	
	
	
</html>
Return current item: Db-newsletter