<?
//////////////////////////////////////////////////////////////////////////////
//                                                                          //
//  Program Name         : ProPhotoHost                                     //
//  Release Version      : 1.0                                              //
//  Home Page            : http://www.prophotohost.com                      //
//  Program Author       : Jake P                                           //
//  Supplied by          : drew010                                          //
//  Nullified by         : CyKuH [WTN]                                      //
//  Distribution         : via WebForum, ForumRU and associated file dumps  //
//                                                                          //
//////////////////////////////////////////////////////////////////////////////
// COPYRIGHT NOTICE                                                         //
// (c) 2002 WTN Team,  All Rights Reserved.                                 //
// Distributed under the licencing agreement located in wtn_release.nfo     //
//////////////////////////////////////////////////////////////////////////////
?>
<html>
<!--
<?php
// CHECK ENV
// determine if php is running
if(1==0)
{
	echo "-->You are not running PHP - Please contact your system administrator.<!--";
}else{
	echo "-->";
}
// /* <? */ Securety info
$programm =   'ProPhotoHost';
$version	= '1.0';
$thisscript	= 'install.php';
if($HTTP_GET_VARS['step'])
{
	$step 	= $HTTP_GET_VARS['step'];
}else{
	$step 	= $HTTP_POST_VARS['step'];
}
$userip		= $HTTP_ENV_VARS['REMOTE_ADDR'];
$userphpself	= $HTTP_SERVER_VARS['PHP_SELF'];
$userpathtran	= $HTTP_SERVER_VARS['PATH_TRANSLATED'];
$usersafemode	= get_cfg_var("safe_mode");

//include('./define.inc.php');

error_reporting(E_ERROR | E_WARNING | E_PARSE);

if (function_exists("set_time_limit")==1 && get_cfg_var("safe_mode")==0)
{
	@set_time_limit(1200);
}

if (get_cfg_var("safe_mode") != 0)
{
	$installnote ="<p><b>Note:</b> In your server PHP configuration the <b>Safe Mode is active</b>, You will need edit your config.inc.php file to allow safe mode uploading!</p>";
	$safemode ="1";
}
$onvservers	= "0"; // set this to 1 if you're on Vservers and get disconnected after running an ALTER TABLE command

function dodb_queries()
{
	global $DB_site,$query,$explain,$onvservers;
	while (list($key,$val)=each($query))
	{
		echo "<p>$explain[$key]</p>\n";
		echo "<!-- ".htmlspecialchars($val)." -->\n\n";
		flush();
		if ($onvservers==1 and substr($val, 0, 5)=="ALTER")
		{
			$DB_site->reporterror=0;
		}
		$DB_site->query($val);
		if ($onvservers==1 and substr($val, 0, 5)=="ALTER")
		{
			$DB_site->connect();
			$DB_site->reporterror=1;
		}
	}
	unset ($query);
	unset ($explain);
}
function gotonext($extra="") {
	global $step,$thisscript;
	
	$nextstep = $step+1;
	echo "<div align=\"center\"><p><a href=\"$thisscript?step=$nextstep\"><b>Click here to continue &raquo;&raquo;</b></a> $extra</p>\n</div>";
echo <<<EOF
<p align="center"><!--CyKuH [WTN]-->&copy WTN Team `2000 - `2003</p>
EOF;
}
function stripslashesarray(&$arr) {
	while (list($key,$val) = each($arr))
	{
		if ((strtoupper($key)!=$key || "".intval($key)=="$key") && $key!="argc" && $key!="argv")
		{
			if(is_string($val))
			{
				$arr[$key] = stripslashes($val);
			}
			if(is_array($val))
			{
				$arr[$key] = stripslashesarray($val);
			}
		}
	}
	return $arr;
}
if (get_magic_quotes_gpc() and is_array($GLOBALS))
{
	$GLOBALS = stripslashesarray($GLOBALS);
}
set_magic_quotes_runtime(0);

if($HTTP_GET_VARS['see_phpinfo']==1)
{
	phpinfo();
	exit;
}
?>
<HTML>
	<HEAD>
	<title><? echo $programm ?> Install Script</title>
<STYLE TYPE="text/css">
	<!--
	A { text-decoration: none; }
	A:hover { text-decoration: underline; }
	H1 { font-family: arial,helvetica,sans-serif; font-size: 18pt; font-weight: bold;}
	H2 { font-family: arial,helvetica,sans-serif; font-size: 14pt; font-weight: bold;}
	BODY,TD,FORM,INPUT,TEXTAREA { font-family: arial,helvetica,sans-serif; font-size: 10pt; }
	TH { font-family: arial,helvetica,sans-serif; font-size: 11pt; font-weight: bold; }
	.textpre {font-family : "Courier New", Courier, monospace; font-size : 1px; font-weight : bold;}
	//-->
</STYLE>
	</HEAD>
<BODY onLoad="window.defaultStatus=' '" leftmargin="10" topmargin="10" marginwidth="10" marginheight="10">
<table width="600" border="0" cellspacing="1" cellpadding="3" align="center" bgcolor="Black">
	<tr valign="middle" bgcolor="#9999CC">
		<td align="left">
		<!--CyKuH [WTN]-->
		<font size=3><b><? echo $programm ?> Script</b></font><br>
		<b>Installation: version <?php echo $version; ?></b></td>
	</TR>
</TABLE>
<BR>

<table width="600" border="0" cellspacing="1" cellpadding="3" align="center" bgcolor="Black">
<TR VALIGN="top" BGCOLOR="#CCCCCC"><TD ALIGN="left">
Note: Please be patient as some parts of this may take quite some time.<br>
Nullified by <b>CyKuH [WTN]</b>
</TD></TR>
</TABLE><BR>

<?php
if ($step == "")
{
?>
<table width="600" border="0" cellspacing="1" cellpadding="3" align="center" bgcolor="Black">
<tr valign="top" bgcolor="#CCCCCC"><TD ALIGN="left">
<p>Welcome to <? echo $programm ?> Installation Script.</p>
<p>Running this script will do an install of <? echo $programm ?> database strucuctury and default data onto your server.</p>
</TD></TR>
</TABLE><BR>

	<table width="600" border="0" cellspacing="1" cellpadding="3" align="center" bgcolor="#000000">
	<tr valign="baseline" bgcolor="#CCCCCC"><th bgcolor="#9999CC" colspan="3" align="center"><b> Database Check </b></th></tr>
	<tr valign="baseline" bgcolor="#CCCCCC" align="center">
		<td bgcolor="#CCCCFF"><b><? echo $programm ?> version <?php echo $version; ?></b></td>
		<td><b>System Requirements:</b></td>
		<td><b>Your System:</b></td>
	</tr>
	<tr valign="baseline" bgcolor="#CCCCCC">
		<td bgcolor="#CCCCFF"><b>PHP version</b></td>
		<td>PHP 4 >= 4.0.4</td>
		<td>Your PHP version: <b><?php echo phpversion();?></b></td>
	</tr>
	<tr valign="baseline" bgcolor="#CCCCCC">
		<td bgcolor="#CCCCFF"><b>MySQL version</b></td>
		<td>MySQL version 3.22 or higher</td>
		<td>See your MySQL version (<a href="install.php?see_phpinfo=1#module_mysql" target="_blank">check ver.</a>)</td>
	</tr>
	</table>
<?php
	$step = 1;
	gotonext();
}
if ($step == 2)
{
?>
<FORM action="?step=3" method=post>
<center>
<TABLE cellSpacing=0 cellPadding=3 border=0>
<TD>Your Page Name:</TD>
<TD><INPUT maxLength=40 size=30 name="pn" value="Your Page Name"></TD></TR>
<TR>
<TD>Your Page URL:</TD>
<TD><INPUT maxLength=40 size=30 name="pu" value="http://<? echo $HTTP_HOST ?>"></TD></TR>
<TR>

<TD>Paypal E-Mail</TD>
<TD><INPUT maxLength=40 size=30 name="pe" value="playpal@youemail.com"></TD></TR>
<TR>
<TD>Contact E-Mail</TD>
<TD><INPUT maxLength=40 size=30 name="ce" value="contact@youemail.com"></TD></TR>
<TR>
<TD>Admin E-Mail</TD>
<TD><INPUT maxLength=40 size=30 name="ae" value="name@youemail.com"></TD></TR>
<TR>
<TD>Admin Password</TD>
<TD><INPUT maxLength=40 size=30 name="ap" value="password"></TD></TR>
<TR>
<TD>Service Pricing</TD>
<TD><INPUT maxLength=40 size=30 name="sp" value="9.95"></TD></TR>
<TR>

<TD>MySQL hostname:</TD>
<TD><INPUT maxLength=40 size=30 name="dbhost" value="localhost"></TD></TR>
<TR>
<TD>MySQL user:</TD>
<TD><INPUT  maxLength=40 size=30 name="dbuname" value="mysql-user"></TD></TR>
<TR>
<TD>MySQL password:</TD>
<TD><INPUT  maxLength=40 size=30 name="dbpass" value="mysql-password"></TD></TR>
<TR>
<TD>MySQL db name:</TD>
<TD><INPUT  maxLength=40 size=30 name="dbname" value="prophotohost"></TD></TR>
<TR>
<TD>&nbsp;</TD>
<TD><INPUT type=submit value="Continue &raquo;&raquo;"></FORM></TD></TR></TBODY></TABLE>
<?
echo <<<EOF
<p align="center"><!--CyKuH [WTN]-->&copy WTN Team `2000 - `2003</p>
EOF;
	exit;
}
if ($step >= 3)
{

}
if ($step == 3)
{
        $fp = fopen('i.setup.php', 'w');

        $config = "///////////////////////////////////////////////////////////////////////////////\n";
        $config .= "//                                                                           //\n";
        $config .= "//   Program Name         : ProPhotoHost                                     //\n";
        $config .= "//   Release Version      : 1.0                                              //\n";
        $config .= "//   Home Page            : http://www.prophotohost.com                      //\n";
        $config .= "//   Program Author       : Jake P                                           //\n";
        $config .= "//   Supplied by          : drew010                                          //\n";
        $config .= "//   Nullified by         : CyKuH [WTN]                                      //\n";
        $config .= "//   Distribution         : via WebForum, ForumRU and associated file dumps  //\n";
        $config .= "//                                                                           //\n";
        $config .= "///////////////////////////////////////////////////////////////////////////////\n";
        $config .= "// page setup\n";
        $config .= "\$page_name = \"$pn\";\n";
        $config .= "\$page_url = \"$pu\";\n";
        $config .= "\$page_title = \"$pn\";\n";
        $config .= "\$page_footer = \"2002 © DreamweaverDesigns\";\n";
        $config .= "// meta tags\n";
        $config .= "\$page_desc = \"Reliable photo and image hosting.\";\n";
        $config .= "\$page_key = \"photo hosting, image hosting, reliable service\";\n";
        $config .= "// image colors\n";
        $config .= "\$page_bgimage = \"header.background.gif\";\n";
        $config .= "\$page_logoimage = \"header.logo.gif\";\n";
        $config .= "// email setup\n";
        $config .= "\$paypal_email       = \"$pe\";\n";
        $config .= "\$contact_email      = \"$ce\";\n";
        $config .= "\$page_info_email    = \"$ce\";\n";
        $config .= "\$page_signup_email  = \"$ce\";\n";
        $config .= "\$page_support_email = \"$ce\";\n";
        $config .= "// admin setup to login main page\n";
        $config .= "\$page_admin_email = \"$ae\";\n";
        $config .= "\$admin_password = \"$ap\";\n";
        $config .= "// service pricing\n";
        $config .= "\$service_pricing =\"$sp\";\n";
        $config .= "// database setup\n";
        $config .= "\$dbhost = \"$dbhost\";\n";
        $config .= "\$db_database = \"$dbname\";\n";
        $config .= "\$db_username = \"$dbuname\";\n";
        $config .= "\$db_password = \"$dbpass\";\n";
        $config .= "// form input colors\n";
        $config .= "\$form_blur_color = \"#EEEEEE\";\n";
        $config .= "\$form_blur_border_color = \"#CCCCCC\";\n";


        fwrite($fp, "<?\n".$config."?>");
        fclose($fp);
echo "<center>";
include "i.setup.php";
mysql_connect($dbhost, $db_username, $db_password) or die(mysql_error());
mysql_select_db($db_database) or die(mysql_error());

echo <<<EOF
Setting install config - ok.<br>
Connect to server - ok.<br>
Connect to database - ok.
EOF;
	gotonext();
	exit;
}

if($step>=4)
{
}

if($step==4)
{
echo "<center>";
include "i.setup.php";
mysql_connect($dbhost, $db_username, $db_password) or die(mysql_error());
mysql_select_db($db_database) or die(mysql_error());
////////////////////////////////////////////////////////////////////////
////////////////////////// Dump MySQL //////////////////////////////////
////////////////////////////////////////////////////////////////////////

mysql_query("CREATE TABLE image (
  image_id int(11) NOT NULL auto_increment,
  image_name varchar(32) NOT NULL default '',
  image_original varchar(128) NOT NULL default '',
  image_ext varchar(16) NOT NULL default '',
  image_size varchar(16) NOT NULL default '',
  image_width varchar(16) NOT NULL default '',
  image_height varchar(16) NOT NULL default '',
  image_caption varchar(128) NOT NULL default '',
  image_member_id int(11) NOT NULL default '0',
  image_status char(1) NOT NULL default '',
  created_on varchar(19) NOT NULL default '',
  updated_on varchar(19) NOT NULL default '',
  PRIMARY KEY  (image_id)
) TYPE=MyISAM;");
echo "Creating  table Image  -  ok<br>";
mysql_query("CREATE TABLE member (
  member_id int(11) NOT NULL auto_increment,
  member_name varchar(32) NOT NULL default '',
  member_email varchar(64) NOT NULL default '',
  member_password varchar(32) NOT NULL default '',
  member_newsletter char(1) NOT NULL default '',
  member_key varchar(32) NOT NULL default '',
  member_status char(1) NOT NULL default '',
  created_on varchar(19) default NULL,
  updated_on varchar(19) default NULL,
  PRIMARY KEY  (member_id)
) TYPE=MyISAM;");
echo "Creating  table Member  -  ok<br>";

////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
//srand((double)microtime()*1000000);
//function packx($x){ return $x==""?$x:md5($x*31+11); }
echo "<center><font color=ffffff>Insert Data Complite<br>";

	gotonext();
	exit;
}

if ($step == 5)
{
include "i.setup.php";
//	unlink('install.php');
	echo "<p><h2><b>You has completed the installation of ".$programm." successfully.</b></h2>"; 
	echo "<blockquote>	<p><b>Automatic delete file: install.php </b> for security reasons."; 
	echo "<blockquote>	<p><b>Please Edit i.setup.php for more settings. </b>"; 

	echo "	<p><a href=\"./\" target=\"blank\">Access your admin page here &raquo;&raquo;</a><br><font color=blue>( <b>username:</b>$page_admin_email / <b>password:</b>$admin_password)</p>";
	echo " $installnote";                                                                                
	echo "	</body>";
	echo "	</html>";
}
?>