Skip to content

Commit

Permalink
reindent
Browse files Browse the repository at this point in the history
git-svn-id: https://xerteonlinetoolkits.googlecode.com/svn/trunk@273 912cdd6b-5c7d-d5a7-a2ba-d0f0cdb91641
  • Loading branch information
Dave Goodwin committed Mar 5, 2012
1 parent c1d20c0 commit 62b9df5
Showing 1 changed file with 111 additions and 136 deletions.
247 changes: 111 additions & 136 deletions setup/page2.php
@@ -1,185 +1,162 @@
<?PHP
<?php

echo file_get_contents("page_top");
echo file_get_contents("page_top");

if(!isset($_POST['database_file'])){

$mysql_connect_id = mysql_connect($_POST['host'], $_POST['username'], $_POST['password']);
if(!isset($_POST['database_file'])) {

// Check for connection and error if failed
$mysql_connect_id = mysql_connect($_POST['host'], $_POST['username'], $_POST['password']);

if(!$mysql_connect_id){

?>

<p>Sorry, the attempt to connect to the host has failed. MySQL reports the following error - <?PHP echo mysql_errno($mysql_connect_id) . " - " . mysql_error($mysql_connect_id); ?></p>

<?PHP }

$query = "create database if not exists " . $_POST['database_name'];

$query_response = mysql_query($query);

if($query_response){


}else{

?>

<p>Sorry, the attempt to create the database to the database has failed. MySQL reports the following error - <?PHP echo mysql_errno($mysql_connect_id) . " - " . mysql_error($mysql_connect_id);?></p>

<?PHP }

$query = "USE " . $_POST['database_name'];

$query_response = mysql_query($query);

if($query_response){


}else{

?>

<p>Sorry, the attempt to specify which database we need to work on (the MySQL keyword - USE) has failed. MySQL reports the following error - <?PHP echo mysql_errno($mysql_connect_id) . " - " . mysql_error($mysql_connect_id); echo "The query response was " . $query_response . "<br>"; ?></p>

<?PHP }

$temp = explode(";",file_get_contents("basic.sql"));

$x=0;

while($x!=count($temp)){

if($_POST['database_prefix']!=""){

$query = str_replace("$",$_POST['database_prefix'],ltrim($temp[$x++]));
// Check for connection and error if failed
if(!$mysql_connect_id) {
?>
<p>Sorry, the attempt to connect to the host has failed. MySQL reports the following error -
<?php echo mysql_errno($mysql_connect_id) . " - " . mysql_error($mysql_connect_id); ?></p>
<?php
}

}else{
$query = "create database if not exists " . $_POST['database_name'];

$query = str_replace("$","",ltrim($temp[$x++]));
$query_response = mysql_query($query);

}
if(!$query_response){
?>
<p>Sorry, the attempt to create the database to the database has failed. MySQL reports the following error -
<?php
echo mysql_errno($mysql_connect_id) . " - " . mysql_error($mysql_connect_id);?>
</p>
<?php
}

if($query!=""){

$query_response = mysql_query($query);
$query = "USE " . $_POST['database_name'];

}
$query_response = mysql_query($query);

if($query_response){
if(!$query_response){
?>
<p>Sorry, the attempt to specify which database we need to work on (the MySQL keyword - USE) has failed. MySQL reports the following error -
<?php
echo mysql_errno($mysql_connect_id) . " - " . mysql_error($mysql_connect_id); echo "The query response was " . $query_response . "<br></p>";
}

$temp = explode(";", file_get_contents("basic.sql"));

}else{
$x=0;

?>
while($x!=count($temp)){

<p>Sorry, The query <?PHP echo $query; ?> has failed. MySQL reports the following error - <?PHP echo mysql_errno($mysql_connect_id) . " - " . mysql_error($mysql_connect_id); ?></p>
if($_POST['database_prefix']!=""){

<?PHP }
$query = str_replace("$",$_POST['database_prefix'],ltrim($temp[$x++]));


}
}else{

$buffer = file_get_contents("database.txt");
$query = str_replace("$","",ltrim($temp[$x++]));

$buffer = str_replace("DATABASE_HOST",$_POST['host'],$buffer);
$buffer = str_replace("DATABASE_NAME",$_POST['database_name'],$buffer);
$buffer = str_replace("DATABASE_PREFIX",$_POST['database_prefix'],$buffer);
}

$file_handle = fopen("database.txt",'w');
if($query!=""){

$work = true;
$query_response = mysql_query($query);

if(!$file_handle){
}

$work = false;

?>
<p>The file /setup/database.txt was not set to be writable - this means future pages will not work. Please edit this file before continuing.
<?PHP
if(!$query_response){
?>
<p>Sorry, The query <?php echo $query; ?> has failed. MySQL reports the following error -
<?php echo mysql_errno($mysql_connect_id) . " - " . mysql_error($mysql_connect_id); ?></p>
<?php
}
}

}

$buffer = file_get_contents("database.txt");

if(!fwrite($file_handle,$buffer,strlen($buffer))){
$buffer = str_replace("DATABASE_HOST",$_POST['host'],$buffer);
$buffer = str_replace("DATABASE_NAME",$_POST['database_name'],$buffer);
$buffer = str_replace("DATABASE_PREFIX",$_POST['database_prefix'],$buffer);

$work = false;
$file_handle = fopen("database.txt",'w');

?>
<p>The file /setup/database.txt could not be written too - this means future pages will not work. Please edit this file before continuing.
<?PHP
$work = true;

}
if(!$file_handle){
$work = false;
?>
<p>The file /setup/database.txt was not set to be writable - this means future pages will not work. Please edit this file before continuing.
<?php
}

if(!$work){
if(!fwrite($file_handle,$buffer,strlen($buffer))){
$work = false;
?>
<p>The file /setup/database.txt could not be written too - this means future pages will not work. Please edit this file before continuing.
<?php
}

?>
<p>Edit the file to add in the database host, database name and prefix</p>
<form action="page2.php" method="POST">
<input type="hidden" value="datafileonly" name="databasefile" />
<input type="submit" value="Try again" />
</form>
<?PHP
if(!$work)
{
?>
<p>Edit the file to add in the database host, database name and prefix</p>
<form action="page2.php" method="POST">
<input type="hidden" value="datafileonly" name="databasefile" />
<input type="submit" value="Try again" />
</form>
<?php
}

}
fclose($file_handle);
@chmod("database.txt",0777);

}else{

fclose($file_handle);
@chmod("database.txt",0777);
$buffer = file_get_contents("database.txt");

}else{
$buffer = str_replace("DATABASE_HOST",$_POST['host'],$buffer);
$buffer = str_replace("DATABASE_NAME",$_POST['database_name'],$buffer);
$buffer = str_replace("DATABASE_PREFIX",$_POST['database_prefix'],$buffer);

$buffer = file_get_contents("database.txt");
$file_handle = fopen("database.txt",'w');

$buffer = str_replace("DATABASE_HOST",$_POST['host'],$buffer);
$buffer = str_replace("DATABASE_NAME",$_POST['database_name'],$buffer);
$buffer = str_replace("DATABASE_PREFIX",$_POST['database_prefix'],$buffer);
$work = true;

$file_handle = fopen("database.txt",'w');
if(!$file_handle){

$work = true;
$work = false;

if(!$file_handle){
?>
<p>The file /setup/database.txt was not set to be writable - this means future pages will not work. Please edit this file before continuing.
<?PHP

$work = false;

?>
<p>The file /setup/database.txt was not set to be writable - this means future pages will not work. Please edit this file before continuing.
<?PHP
}

}


if(!fwrite($file_handle,$buffer,strlen($buffer))){
if(!fwrite($file_handle,$buffer,strlen($buffer))){

$work = false;
$work = false;

?>
<p>The file /setup/database.txt could not be written too - this means future pages will not work. Please edit this file before continuing.
<?PHP
?>
<p>The file /setup/database.txt could not be written too - this means future pages will not work. Please edit this file before continuing.
<?PHP

}
}

if(!$work){
if(!$work){

?>
<p>Edit the file to add in the database host, database name and prefix</p>
<form action="page2.php" method="POST">
<input type="hidden" value="datafileonly" name="databasefile" />
<input type="submit" value="Try again" />
</form>
<?PHP
?>
<p>Edit the file to add in the database host, database name and prefix</p>
<form action="page2.php" method="POST">
<input type="hidden" value="datafileonly" name="databasefile" />
<input type="submit" value="Try again" />
</form>
<?PHP

}
}


fclose($file_handle);
@chmod("database.txt",0777);
fclose($file_handle);
@chmod("database.txt",0777);


}
}

?>

Expand All @@ -191,13 +168,11 @@
</p>
<p>
<form action="page3.php" method="post" enctype="multipart/form-data">
<label>Database account name for users of the site. People following the XAMPP path / or testing locally should type in root.</label><br /><br /><input type="text" width="100" name="account" /><br /><br />
<label>Database password for the account above. People following the XAMPP path / or testing locally should leave this field blank.</label><br /><br /><input type="password" width="100" name="password" /><br /><br />
<input type="image" src="next.gif" />
<label for="account">Database account name for users of the site. People following the XAMPP path / or testing locally should type in root.</label><br /><br /><input type="text" width="100" name="account" id="account" /><br /><br />
<label for="password">Database password for the account above. People following the XAMPP path / or testing locally should leave this field blank.</label><br /><br /><input type="password" width="100" name="password" id="password"/><br /><br />
<input type="image" src="next.gif" />
</form>
</p>
</div>
</body>
</html>


0 comments on commit 62b9df5

Please sign in to comment.