<?php
$step = $_GET['step'];
if ( empty($step) ) {
$step = 1;
}
switch($step){
default:
case 1:
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Step 1 of 2 | Installing Ultimate Regnow Affiliate by Goldorak _[NUL]</title>
<style type="text/css" />
html {
background: #ccc;
padding: 30px;
margin: 0;
}
body {
width: 500px;
margin: 0 auto;
text-align: left;
padding: 20px;
background: #fff;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
line-height: 19px;
}
h1 {
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 20px;
line-height: 23px;
color: #666666;
border-bottom: 1px solid #CCCCCC;
}
.ok {
color: #339900;
font-weight: bold;
}
.warn {
color: #0066CC;
font-weight: bold;
}
.error {
color: #FF0000;
font-weight: bold;
}
.warning {
border: 1px solid #990000;
background: #FFEEEE;
color: #000;
text-align: center;
padding: 15px;
}
#footer_note {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
padding: 10px;
border-top: 1px dotted #ccc;
text-align: center;
margin-top: 20px;
}
#footer_note a:link, #footer_note a:visited {
color: #077307;
text-decoration: none;
}
#footer_note a:hover {
color: #114605;
text-decoration: none;
}
.button {
color: #fff;
background: #003399;
border: 1px solid #000000;
padding: 3px;
text-decoration: none;
}
</style>
</head>
<body>
<img src="admin/images/logo.gif" alt="Ultimate Regnow Affiliate" /><br /><br />
<h1>First step</h1>
<?
$error = 0;
echo "<p>Checking if <strong>config.php</strong> exists ... ";
if( !file_exists('config.php')) {
$error = 1;
echo "<span class=\"error\">ERROR : The required file is not found.</span>";
}
else echo "<span class=\"ok\">[OK]</span>";
echo "</p>";
@require_once('config.php');
@require_once('include/functions.php');
echo "<p>Checking the database connection ... ";
$connection = @mysql_connect($db_host, $db_user, $db_pass);
if( !$connection ) {
$error = 1;
echo "<span class=\"error\">ERROR : ".mysql_error()."</span>";
}
else echo "<span class=\"ok\">[OK]</span>";
echo "</p>";
echo "<p>Checking for existing database ... ";
$db = @mysql_select_db($db_name);
if( !$db ) {
echo "<span class=\"error\">ERROR : ".mysql_error()."</span>";
$error = 1;
}
else echo "<span class=\"ok\">[OK]</span>";
echo "</p>";
/*
echo "<p>Changing chmod permission for the \"admin/temp.txt\" to 0777 ... ";
if( !@chmod('admin/temp.txt', 0777) ) {
$error = 1;
echo "<span class=\"error\">Couldn't CHMOD. Please do it manually.</span>";
}
else echo "<span class=\"ok\">[OK]</span>";
echo "</p>";
echo "<p>Changing chmod permission for the \"cache\" directory to 0777 ... ";
if( !@chmod('cache', 0777) ) {
$error = 1;
echo "<span class=\"error\">Couldn't CHMOD. Please do it manually.</span>";
}
else echo "<span class=\"ok\">[OK]</span>";
echo "</p>";
*/
echo "<p class=\"warn\">It's crucial that you don't forget to setup the access rights with CHMOD 777 for the following:</p>
- <b>/admin/temp.txt</b><br />
- <b>/cache</b>";
$sql = "SELECT id FROM ura_settings WHERE id = '0'";
$result = @mysql_query($sql);
if( $result ) {
$error = 1;
echo "<p class=\"warning\">It seems that Ultimate Regnow Affiliate is already installed!<br />To reinstall it, please empty the database first (by dropping the existing tables) !</p>";
}
if( !$error ){
echo "<p class=\"ok\">Everything seems to be fine. Let's create the database tables and fill them up.</p><br />";
echo "<a href=\"install.php?step=2&start=1&pointer=0\" class=\"button\"><strong>Continue »</strong></a>";
}
else {
echo "<center><p><a href=\"install.php\" class=\"button\"><strong>Retry</strong></a></p></center>";
}
?>
<div id="footer_note">
Copyright 2007 Goldorak _[NUL]<a href="http://www." target="_blank" rel="nofollow">Goldorak _[NUL]</a>.<br />
</div>
</body>
</html>
<?
break;
//Step 2 - start importing the database;
case 2:
include('config.php');
include('include/functions.php');
function get_percentage($full, $part){
$percent = ceil(($part * 100)/$full);
return $percent;
}
$connection = db_connect();
header("Expires: Mon, 1 Jan 1999 01:01:01 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
ini_set("auto_detect_line_endings", true);
$filename = "ura_database.sql";
$linesize = 65536;
$querybatch = 300;
$linesbatch = 2000;
$sleep = 2000;
$comment[0]="#";
$comment[1]="-- ";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Step 2 of 2 | Installing Ultimate Regnow Affiliate by Goldorak _[NUL]</title>
<style type="text/css" />
html {
background: #ccc;
padding: 30px;
margin: 0;
}
body {
width: 500px;
margin: 0 auto;
text-align: left;
padding: 20px;
background: #fff;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
line-height: 19px;
}
h1 {
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 20px;
line-height: 23px;
color: #666666;
border-bottom: 1px solid #CCCCCC;
}
.ok {
color: #339900;
font-weight: bold;
}
.error {
color: #FF0000;
font-weight: bold;
}
.loading {
font-size: 14px;
color: #990000;
text-align: center;
}
.warning {
border: 1px solid #990000;
background: #FFEEEE;
color: #000;
text-align: center;
padding: 15px;
}
#footer_note {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
padding: 10px;
border-top: 1px dotted #ccc;
text-align: center;
margin-top: 20px;
}
#footer_note a:link, #footer_note a:visited {
color: #077307;
text-decoration: none;
}
#footer_note a:hover {
color: #114605;
text-decoration: none;
}
</style>
</head>
<body>
<img src="admin/images/logo.gif" alt="Ultimate Regnow Affiliate" /><br /><br />
<h1>Last step</h1>
<p class="warning">Please be patient and don't close the window or STOP this page from loading! <br />This may take a while because we're importing a large database now.</p>
<?
$error = 0;
if (!$error && isset($filename)){
//open the .sql file
if ( !$file = @fopen($filename,"rt")){
echo "<p class=\"error\">Cannot open <strong>".$filename."</strong>";
if( !file_exists($filename) )
echo "<br /> It seems that the file does not exist! Please check that you've uploaded all the files.";
echo "<br />The script was killed at this line : <strong>".__LINE__."</strong></p>";
$error = 1;
}
elseif ( fseek($file, 0, SEEK_END)==0) {
$filesize = ftell($file);
}
else{
echo "<p class=\"error\">Cannot get the filesize of ".$filename;
echo "<br />The script was killed at this line : <strong>".__LINE__."</strong></p>";
$error = 1;
}
}
if (!$error && isset($_REQUEST["start"]) && isset($_REQUEST["pointer"])){
echo "<p class=\"loading\"><i>Please wait ...</i></p>";
if ($_REQUEST["pointer"] > $filesize){
// If the script ended here, it means that the file pointer is somewhere after the end of file.
$error = 1;
echo "<p class=\"error\">The file pointer is out of bounds.";
echo "<br />The script was killed at this line : <strong>".__LINE__."</strong></p>";
}
if (!$error && (fseek($file, $_REQUEST["pointer"]) != 0) ){
// If the script ended here, it means that the file pointer could not be set at $_REQUEST["pointer"];
$error = 1;
echo "<br /><p class=\"error\">The script was killed at this line : <strong>".__LINE__."</strong></p>";
}
if (!$error){
$query = "";
$queries = 0;
$linenumber = $_REQUEST["start"];
$querylines = 0;
$inparents = false;
while (($linenumber < $_REQUEST["start"] + $linesbatch || $query!="")
&& ($dumpline=fgets($file, $linesize)) ){
$dumpline = ereg_replace("\r\n$", "\n", $dumpline);
$dumpline = ereg_replace("\r$", "\n", $dumpline);
if ( !$inparents ){
$skipline = false;
reset($comment);
foreach ($comment as $comment_value)
{ if (!$inparents && (trim($dumpline)=="" || strpos ($dumpline, $comment_value) === 0))
{ $skipline=true;
break;
}
}
if( $skipline ){
$linenumber++;
continue;
}
}
$dumpline_deslashed = str_replace ("\\\\","",$dumpline);
$parents = substr_count($dumpline_deslashed, "'")-substr_count ($dumpline_deslashed, "\\'");
if( $parents%2 != 0 )
$inparents=!$inparents;
$query .= $dumpline;
if (!$inparents)
$querylines++;
if ( $querylines > $querybatch)
{
// If the script ended here, it means that the current query includes more than $querybatch dump lines. Possible cause : missing ";" (semicolon) after every dump line.
// This shouldn't ever happen, but is better to be safe than sorry
echo "<br /><p class=\"error\">The script was killed at this line : <strong>".__LINE__."</strong></p>";
$error = 1;
break;
}
if (ereg(";$",trim($dumpline)) && !$inparents)
{ if(!mysql_query(trim($query), $connection))
{
echo "<p class=\"error\">There was a problem during the installation process. The reported MySQL error is : <br />";
echo mysql_error();
echo "<br />The script was killed at this line : <strong>".__LINE__."</strong></p>";
$error = 1;
break;
}
$queries++;
$query="";
$querylines=0;
}
$linenumber++;
}
}
if (!$error){
$pointer = ftell($file);
if (!$pointer){
// If the script ended here, it means that it cannot read the file pointer offset.
$error = 1;
$line_of_end = __LINE__;
}
}
if ( !$error ){
if ($linenumber < $_REQUEST["start"]+ $linesbatch){
echo "<span class=\"ok\">Great! Ultimate Regnow Affiliate is now installed.</span><br /><br />";
echo "<p>Now you can <a href=\""._URL."/admin/login.php\" target=\"_blank\">login</a> as admin with <b>username</b> 'admin' and <b>password</b> 'admin'.</p><br />";
echo "<p>We recommend that you go to <i>Admin Area -> Settings -> Edit Admin Details</i> and update your password.</p><br /><br />";
echo "<p class=\"warning\">Also, please make sure you delete the following files : <br />
<strong>install.php</strong><br />
<strong>".$filename."</strong></p>";
echo "</p>";
// $error = 1;
}
else
{
echo "<script language=\"JavaScript\" type=\"text/javascript\">window.setTimeout('location.href=\"install.php?step=2&start=$linenumber&pointer=$pointer\";',500+$sleep);</script>\n";
echo "<noscript>\n";
echo "<p>Click <a href=\"install.php?step=2&start=$linenumber&pointer=$pointer\">continue »</a> (Please enable JavaScript to do this automatically)</p>\n";
echo "</noscript>\n";
}
}
}
if ($error)
echo "<p class=\"error\">There was an error encountered. Please drop the old tables before restarting !<br /><a href=\"install.php\">« Go back</a></p>";
// close both the connection and file;
if ($connection) mysql_close();
if ($file) fclose($file);
?>
<div id="footer_note">
©Copyright <?=date('Y')?> <a href="http://www." target="_blank" rel="nofollow">Goldorak _[NUL]</a>.<br />
</div>
</body>
</html>
<?
break;
}
// end switch;
?>