Просмотр файла MyLounge/myred/setup.php

Размер файла: 9.22Kb
<?php
include("include/vars.php");
require("include/functions.php");
$lang=setlanguage();
require("language/$lang");
$menu=setmenu();

if (!$do) {
	$do="first";
	}

if ($do=='first') {

$main.="<br>
<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"500\" align=\"center\">
<tr>
<td align=\"center\"><b>myLounge Redirection setup - Step 1</b></td>
</tr>
<tr>
<td>Welcome to the setup of your redirection service!<br><br>
This setup will be done in 4 easy to follow steps; too late to stop: you are already in the middle of step 1 ;-)<br><br>
Please check the following values that are saved in the file &quot/include/mysql.php&quot that you already might have edited.<br>
If you didn't edit this file for your needs until now, please do so and afterwards call &quotsetup.php&quot again.<br><br>
The name of your database: <b>$mysql_dbase</b><br>
Your mysql-username: <b>$mysql_username</b><br>
Your mysql-password: <b>$mysql_passwd</b><br><br>
You have two options:<br><br>
Click <a href=\"setup.php?do=second&createdb=on\">here</a> to proceed to step 2 and let setup create the database for you.<br>
<b>Important:</b> Note that this is not possible on every server. If not, please create the database first, and afterwards click <a href=\"setup.php?do=second\">here</a> to proceed to step 2.<br>
Setup will then only create the tables for you.
</td>
</tr>
</table>";

$template = new MyredTemplate("template/template.html");
$template->assign("TITLE", $pagetitle);
$template->assign("MENU", $menu);
$template->assign("MAIN", $main);
$template->myred_print() or die($template->error);
exit;
}

if ($do=='second') {
// Connect to the database
mysql_connect("$mysql_host","$mysql_username","$mysql_passwd") OR DIE (mysql_error());
if ($createdb=='on') { // Create database
	mysql_query("CREATE DATABASE $mysql_dbase") OR DIE (mysql_error());
	}
// Select database
mysql_select_db("$mysql_dbase") OR DIE (mysql_error());

// Create the tables...hard work :-)
mysql_query("CREATE TABLE adclicks ( id int(12) NOT NULL auto_increment, adid int(12) DEFAULT '0' NOT NULL, date varchar(20) NOT NULL, browser varchar(255) NOT NULL, ip varchar(25) NOT NULL, PRIMARY KEY (id) )") OR DIE (mysql_error()); 
mysql_query("CREATE TABLE advertiser ( userid int(12) NOT NULL auto_increment, password varchar(50) NOT NULL, realname varchar(50) NOT NULL, email varchar(50) NOT NULL, address varchar(150) NOT NULL, zipcode varchar(15) NOT NULL, town varchar(50) NOT NULL, country varchar(50) NOT NULL, regdate varchar(20) NOT NULL, ip varchar(25) NOT NULL, PRIMARY KEY (userid) )") OR DIE (mysql_error());  
mysql_query("CREATE TABLE adverts ( adid int(12) NOT NULL auto_increment, userid int(12) DEFAULT '0' NOT NULL, adlink text NOT NULL, linktext text NOT NULL, adtext text NOT NULL, maxviews int(10) DEFAULT '0' NOT NULL, views int(10) DEFAULT '0' NOT NULL, maxhits int(10) DEFAULT '0' NOT NULL, hits int(10) DEFAULT '0' NOT NULL, active varchar(20) DEFAULT 'no' NOT NULL, lastdate varchar(20) NOT NULL, lastip varchar(25) NOT NULL, startdate varchar(20) NOT NULL, PRIMARY KEY (adid) )") OR DIE (mysql_error()); 
mysql_query("CREATE TABLE adviews ( id int(12) NOT NULL auto_increment, adid int(12) DEFAULT '0' NOT NULL, date varchar(20) NOT NULL, browser varchar(255) NOT NULL, ip varchar(25) NOT NULL, PRIMARY KEY (id) )") OR DIE (mysql_error()); 
mysql_query("CREATE TABLE categories ( category varchar(50) NOT NULL )") OR DIE (mysql_error()); 
mysql_query("CREATE TABLE options ( home varchar(50) NOT NULL, sitetitle varchar(150) NOT NULL, adminemail varchar(50) NOT NULL, username varchar(10) NOT NULL, password varchar(10) NOT NULL, domainip varchar(15) NOT NULL, maindomain varchar(50) NOT NULL, ads varchar(50) NOT NULL, standardad text NOT NULL )") OR DIE (mysql_error()); 
mysql_query("CREATE TABLE redir ( host varchar(100) NOT NULL, name varchar(25) NOT NULL, vname varchar(25) NOT NULL, passwd varchar(25) NOT NULL, email varchar(100) NOT NULL, url varchar(100) NOT NULL, title varchar(100) NOT NULL, descr text NOT NULL, keyw text NOT NULL, counter int(11), robots varchar(50) NOT NULL, news char(3) NOT NULL, revisit text NOT NULL, time varchar(15) NOT NULL, ip varchar(20) NOT NULL, cat varchar(50) NOT NULL,  lasttime varchar(15) NOT NULL, PRIMARY KEY (host), UNIQUE host (host) )") OR DIE (mysql_error()); 
mysql_query("CREATE TABLE tld ( domain varchar(50) NOT NULL )") OR DIE (mysql_error()); 
// finished

// Everything went ok, show a success and then continue...

$main="<table cellspacing=\"1\" cellpadding=\"4\" border=\"0\" width=\"500\" align=\"center\">
<tr>
<td align=\"center\"><b>myLounge Redirection setup - Step 2</b></td>
</tr>
<tr>
<td><b>Congratulations!</b> If you havn't seen any error messages yet, the database and all tables were created and step 2 is completed successfully.<br>
<a href=\"setup.php?do=third\">Proceed to step 3</a>.
</td>
</tr>
</table>";

$template = new MyredTemplate("template/template.html");
$template->assign("TITLE", $pagetitle);
$template->assign("MENU", $menu);
$template->assign("MAIN", $main);
$template->myred_print() or die($template->error);
exit;
}

if ($do=='third') {
// Now for the admin options...
$main="<form method=\"post\" action=\"setup.php?do=fourth\">
<table cellspacing=\"1\" cellpadding=\"4\" border=\"0\" width=\"500\" align=\"center\">
<tr>
<td align=\"center\"><b>myLounge Redirection setup - Step 3</b></td>
</tr>
<tr>
<td>Now we need some input from you: please fill out the following form carefully in order to setup your service correctly.<br>
(You may change these values later on in the admin area)
<p><i>All fields are required!</i></p>
<p>Administrator username:<br>
<input type=\"text\" name=\"adminusername1\"></p>
<p>Administrator password:<br>
<input type=\"password\" name=\"passwd1\" maxlength=\"25\"><br>
Administrator password again:<br>
<input type=\"password\" name=\"passwd2\" maxlength=\"25\"><br>
</p>
<p>Default startpage:<br>
<input type=\"text\" name=\"startpage1\"><br>
Where should youre users be redirected if they mistyped an url?<br>What is the main page of your website?<br>
For example: main.html</p>
<p>Your website's title:<br>
<input type=\"text\" name=\"sitetitle1\"></p>
<p>Your main domainname (without &quothttp://www.&quot):<br>
<input type=\"text\" name=\"maindomain1\"></p>
<p>Your server's ip (not necessary, for future functions):<br>
<input type=\"text\" name=\"domainip1\"></p>
<p>Your E-mail Address:<br>
<input type=\"text\" name=\"adminemail1\"><br></p>
<p>Your standard-ad (in case no other ads are active):<br>
<input type=\"text\" name=\"standardad1\" size=\"40\"><br>
(fill in any text, HTML is allowed)</p>
</td>
</tr>
<tr>
<td align=\"center\">
<input type=\"submit\" name=\"submit\" value=\"proceed to step 4\">
</td>
</tr>
</table>
</form>";

$template = new MyredTemplate("template/template.html");
$template->assign("TITLE", $pagetitle);
$template->assign("MENU", $menu);
$template->assign("MAIN", $main);
$template->myred_print() or die($template->error);
exit;
}

if ($do=='fourth') {
	if (!$adminusername1) {
		$admin_error="You forgot to fill in the administrator username.<br>";
	}
	if ($passwd1=="") {
		$admin_error.="You forgot to fill in the administrator password.<br>";
	}
	if ($passwd1 != $passwd2) {
		$admin_error.="Please enter the adminpassword twice just the same way.<br>";
	}
	if (!$startpage1) {
		$admin_error.="You forgot to fill in the startpage.<br>";
	}
	if (!$sitetitle1) {
		$admin_error.="You forgot to fill in your website title.<br>";
	}
	if (!$maindomain1) {
		$admin_error.="You forgot to fill in your main domainname.<br>";
	}
	if (!$adminemail1 || verify_email($adminemail1)!=1) {
		$admin_error.="You have to provide a valid administrator emailaddress.<br>";
	}
	if (!$standardad1) {
		$admin_error.="Please type in a text to use as standard-ad.<br>";
	}
	if ($admin_error) {
		errormsg($admin_error);	
		exit;
	}
	else {
	$standardad=addslashes($standardad);
	// Select database
	mysql_connect("$mysql_host","$mysql_username","$mysql_passwd") OR DIE (mysql_error());
	mysql_select_db("$mysql_dbase") OR DIE (mysql_error());
	mysql_query("INSERT INTO $options_table (home, sitetitle, adminemail, username, password, maindomain, domainip, standardad, ads) VALUES ('$startpage1', '$sitetitle1', '$adminemail1', '$adminusername1', '$passwd1', '$maindomain1', '$domainip1', '$standardad1', 'ad-free')") OR DIE (mysql_error());
	}

$main="<br>
<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"500\" align=\"center\">
<tr>
<td align=\"center\"><b>myLounge Redirection setup - Step 4</b></td>
</tr>
<tr>
<td><b>Step 3 completed successfully!</b><br>All data has been saved, and now it is your turn to do step 4:<br>
Simply delete the file you are running now (&quotsetup.php&quot) or otherwise you won't be able to log into the admin area.<br>
The call <a href=\"admin.php\">admin.php</a> and change everything to fit your needs (add categories, add domains, set advertising, ...).<br>
Good luck and have fun!
</td>
</tr>
</table>";

$template = new MyredTemplate("template/template.html");
$template->assign("TITLE", $pagetitle);
$template->assign("MENU", $menu);
$template->assign("MAIN", $main);
$template->myred_print() or die($template->error);
exit;
}
?>