Does anyone know where I can get a copy of a web based installer script. I need to create a custom installer script for my site and was hoping to get some ideas by looking at another script.
What I am tryign to do is have a user fill out a form with their FTP login information and the install path, and install a script from my server using the supplied information.
Thanks for your help.
web based installer
Moderator: General Moderators
The coolest php installer script I have seen is the one for phpBB. In certain situations it uses php's ftp support to update config files. Download a copy of the code and check out what they do. http://www.phpbb.com/
Takuma wrote:make it yourself, just have a form for every information you need and use that to create tables in db etc. It's quite easy...
How??
Example needed... i have a table called $small and a table called $big
And the forms are like this:
Small Table Name:
[_________]
Big Table Name:
[________________]
What would the code be for the forms and the tables stuff?
Ok here's my script for installation...
Code: Select all
<?php
/*
Install.php - Install LSlogin
Author: Liteshaw Web Design
Copyright: Copyright (c) Liteshaw Technology 2002
Contact: lslogin@liteshaw.co.uk
Web Address: http://www.liteshaw.co.uk
*/
require("config.php");
require("library/class.FastTemplate.php");
$tpl = new FastTemplate('library/');
if(defined("INSTALLED"))
{
$fh = fopen("log.txt","w+");
flock($fh,2);
$string = "Unauthorised Access to Install.php by ".$REMOTE_ADDR." at ".gmdate("d/F/Y, h:i:s a");
fwrite($fh,$string);
fclose($fh);
$tpl->define(array("main" => "main.tpl"));
$tpl->assign("TITLE", $system_name." - Installation Error");
$tpl->assign("PAGE_TITLE", "Installation Error");
$tpl->assign("CONTENT",'<span class="errormsg">
Invalid Access, system already installed.
</span>');
$tpl->parse("result","main");
$tpl->FastPrint("result");
exit();
}
if($session != "install")
{
?>
<html lang="en-gb">
<head>
<title>LSLogin 2.2 Installer</title>
<meta name="Author" content="Liteshaw Technology">
<meta name="Copyright" content="Liteshaw Technology">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<link type="text/css" rel="stylesheet" href="library/base.css">
</head>
<body oncontextmenu="return false;">
<div align="center">
<span class="title">LSLogin 2.2 Installer</span><br>
</div>
<table border="0" align="center">
<tr>
<td colspan="2">
<p>
Welcome to MySQL based Login System by Liteshaw Technology.<br>
This system is copyrighted by Liteshaw Technology, and therefore<br>
you are not to redistribute the system unless with permission.<br>
</p>
</tr>
<tr>
<td colspan="2">
<p>
For more information either visit our website at <a href="http://www.liteshaw.co.uk" target="_blank">http://www.liteshaw.co.uk</a><br>
or e-mail us at <a href="http://www.liteshaw.co.uk/contact.html" target="_blank">http://www.liteshaw.co.uk/contact.html</a>.<br>
</p>
</td>
</tr>
<tr>
<td colspan="2">
<p>
Please put your Login System Name, this name will be the part of the title of the pages.<br>
If you do not fill in all the details, the system may not work,<br>
please fill all the details unless you are sure that you don't need them.<br>
</p>
</td>
</tr>
<tr>
<td colspan="2">&nbsp;&nbsp;</td>
</tr>
<tr>
<td colspan="2">
<div style="font-weight: bold;">Instructions:-</div>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1. Fill in all the details below.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2. Click "Install" and the system will be installed.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3. Now go to "login.php" and login as yourself.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4. Click "Please Click here" and you will be taken to the Control Panel.<br>
</td>
</tr>
<tr>
<td colspan="2">&nbsp;&nbsp;</td>
</tr>
<form method="POST" action="install.php" name="info">
<tr>
<th colspan="2" height="30">MySQL Server Settings</th>
</tr>
<tr>
<td height="30px" width="235" align="right" class="row1">MySQL Username:</td>
<td height="30px" width="320" class="row2">
<input type="text" name="mysql_username" value="root">
</td>
</tr>
<tr>
<td height="30px" width="235" align="right" class="row1">MySQL Password:</td>
<td height="30px" width="320" class="row2">
<input type="password" name="mysql_password" value="">
</td>
</tr>
<tr>
<td height="30px" width="235" align="right" class="row1">MySQL Host Address:</td>
<td height="30px" width="320" class="row2">
<input type="text" name="mysql_host" value="localhost">
</td>
</tr>
<tr>
<td height="30px" width="235" align="right" class="row1">Database name</td>
<td height="30px" width="320" class="row2">
<input type="text" name="db" value="liteshaw">
</td>
</tr>
<tr>
<td height="30px" width="235" align="right" class="row1">Prefix for tables</td>
<td height="30px" width="320" class="row2">
<input type="text" name="prefix" value="lslogin">
</td>
</tr>
<tr>
<th colspan="2" height="30">Administrator Settings</th>
</tr>
<tr>
<td height="30px" width="235" align="right" class="row1">Administrator Username:</td>
<td height="30px" width="320" class="row2">
<input type="text" name="admin_username" value="admin">
</td>
</tr>
<tr>
<td height="30px" width="235" align="right" class="row1">Administrator Password:</td>
<td height="30px" width="320" class="row2">
<input type="password" name="admin_password" value="">
</td>
</tr>
<tr>
<td height="30px" width="235" align="right" class="row1">Administrator Password (Confirmation):</td>
<td height="30px" width="320" class="row2">
<input type="password" name="admin_password2" value="">
</td>
</tr>
<tr>
<td height="30px" width="235" align="right" class="row1">Administrator E-mail Address:</td>
<td height="30px" width="320" class="row2">
<input type="text" name="admin_email" value="">
</td>
</tr>
<tr>
<th colspan="2" height="30px">System Settings</th>
</tr>
<tr>
<td height="30px" width="235" align="right" class="row1">Login System Name:</td>
<td height="30px" width="320" class="row2">
<input type="text" name="system_name" value="LSlogin 2.2">
</td>
</tr>
<tr>
<td align="right" class="row1">Enable Signups:</td>
<td class="row2"><input type="checkbox" name="signup" value="true"></td>
</tr>
<tr>
<td align="right" class="row1">Enable Lost Password Feature:</td>
<td class="row2"><input type="checkbox" name="lost_password" value="true"></td>
</tr>
<tr>
<td colspan="2" height="30px" align="center" class="buttons">
<input type="hidden" name="session" value="install">
<input type="submit" name="submit" value="Install">
<input type="reset" name="reset" value="Reset">
</td>
</tr>
</form>
</table>
<hr width="70%">
<center>
<p>
If you do not know your MySQL details please contact your hosting administrator.<br>
For more information about MySQL visit <a href="http://www.mysql.com/" target="_blank">http://www.mysql.com</a>.<br>
For more information about PHP visit <a href="http://www.php.net" target="_blank">http://www.php.net</a>.<br>
For more information about Liteshaw visit <a href="http://www.liteshaw.co.uk" target="_blank">http://www.liteshaw.co.uk</a>.
</p>
</center>
<hr width="70%">
<div align="center">
LSlogin 2.2 Professional<br>
Copyright &copy; Liteshaw Technology 2002<br>
</div>
</body>
</html>
<?php
exit();
}
if(!@mysql_connect($HTTP_POST_VARSї"mysql_host"],$HTTP_POST_VARSї"mysql_username"],$HTTP_POST_VARSї"mysql_password"]))
{
$tpl->define(array("main" => "main.tpl"));
$tpl->assign("TITLE", $HTTP_POST_VARSї"system_name"]." - Installation Error");
$tpl->assign("PAGE_TITLE", "Installation Error");
$tpl->assign("CONTENT",'<span class="errormsg">
Incorrect MySQL Server Details, MySQL Server has returned the following error:-<br>
'.mysql_error().'
</span>');
$tpl->parse("result","main");
$tpl->FastPrint("result");
exit();
}
mysql_connect($HTTP_POST_VARSї"mysql_host"],$HTTP_POST_VARSї"mysql_username"],$HTTP_POST_VARSї"mysql_password"]);
if(!@mysql_select_db($HTTP_POST_VARSї"db"]))
{
$create = @mysql_create_db($HTTP_POST_VARSї"db"]);
if(!$create)
{
$tpl->define(array("main" => "main.tpl"));
$tpl->assign("TITLE", $HTTP_POST_VARSї"system_name"]." - Installation Error");
$tpl->assign("PAGE_TITLE", "Installation Error");
$tpl->assign("CONTENT",'<span class="errormsg">
Fail to create database, MySQL Server has returned following error:-<br>
'.mysql_error().'
</span>');
$tpl->parse("result","main");
$tpl->FastPrint("result");
mysql_close();
exit();
}
}
mysql_select_db($HTTP_POST_VARSї"db"]);
if($HTTP_POST_VARSї"password"] != $HTTP_POST_VARSї"password2"])
{
$tpl->define(array("main" => "main.tpl"));
$tpl->assign("TITLE", $HTTP_POST_VARSї"system_name"]." - Installation Error");
$tpl->assign("PAGE_TITLE", "Installation Error");
$tpl->assign("CONTENT",'<span class="errormsg">
Passwords did not match.
</span>');
$tpl->parse("result","main");
$tpl->FastPrint("result");
mysql_close();
exit();
}
$validity = true;
if( (strstr($HTTP_POST_VARSї"admin_username"],""")) or (strstr($HTTP_POST_VARSї"admin_username"],"'")) or (strstr($HTTP_POST_VARSї"admin_username"],""e;)) or (strstr($HTTP_POST_VARSї"admin_username"],"/")) )
{
$validity = false;
}
if( (strstr($HTTP_POST_VARSї"admin_password"],""")) or (strstr($HTTP_POST_VARSї"admin_password"],"'")) or (strstr($HTTP_POST_VARSї"admin_password"],""e;)) or (strstr($HTTP_POST_VARSї"admin_password"],"/")) )
{
$validity = false;
}
if( (strstr($HTTP_POST_VARSї"admin_email"],""")) or (strstr($HTTP_POST_VARSї"admin_email"],"'")) or (strstr($HTTP_POST_VARSї"admin_email"],""e;)) or (strstr($HTTP_POST_VARSї"admin_email"],"/")) or (!strstr($HTTP_POST_VARSї"admin_email"],".")) or (!strstr($HTTP_POST_VARSї"admin_email"],"@")) )
{
$validity = false;
}
if($validity == false)
{
$tpl->define(array("main" => "main.tpl"));
$tpl->assign("TITLE", $HTTP_POST_VARSї"system_name"]." - Installation Error");
$tpl->assign("PAGE_TITLE", "Installation Error");
$tpl->assign("CONTENT","<span class="errormsg">
You cannot use ", '', \\, /, in your username
password. Also your e-mail address has to be valid.
</span>");
$tpl->parse("result","main");
$tpl->FastPrint("result");
mysql_close();
exit();
}
$ip = @fopen("log.txt","w+");
flock($ip,2);
if(!$ip)
{
$tpl->define(array("main" => "main.tpl"));
$tpl->assign("TITLE", $HTTP_POST_VARSї"system_name"]." - Installation Error");
$tpl->assign("PAGE_TITLE", "Installation Error");
$tpl->assign("CONTENT",'<span class="errormsg">
"Log.txt" not CHMOD to "777".
</span>');
$tpl->parse("result","main");
$tpl->FastPrint("result");
mysql_close();
exit();
}
ftruncate($ip,0);
fclose($ip);
$config = @fopen("config.php","w+");
flock($config,2);
if(!$config)
{
$tpl->define(array("main" => "main.tpl"));
$tpl->assign("TITLE", $HTTP_POST_VARSї"system_name"]." - Installation Error");
$tpl->assign("PAGE_TITLE", "Installation Error");
$tpl->assign("CONTENT",'<span class="errormsg">
"Config.php" not CHMOD to "777".
</span>');
$tpl->parse("result","main");
$tpl->FastPrint("result");
mysql_close();
exit();
}
ftruncate($config,0);
$string =
'<?'."\n".
' $mysql_username = "'.$HTTP_POST_VARSї"mysql_username"].'";'."\n".
' $mysql_password = "'.$HTTP_POST_VARSї"mysql_password"].'";'."\n".
' $mysql_host = "'.$HTTP_POST_VARSї"mysql_host"].'";'."\n".
' $db = "'.$HTTP_POST_VARSї"db"].'";'."\n".
' $system_name = "'.$HTTP_POST_VARSї"system_name"].'";'."\n".
' $signup = "'.$HTTP_POST_VARSї"signup"].'";'."\n".
' $prefix = "'.$HTTP_POST_VARSї"prefix"].'";'."\n".
' $lost_password = "'.$HTTP_POST_VARSї"lost_password"].'";'."\n".
' define("INSTALLED","true");'."\n".
'?>'."\n";
fwrite($config,$string);
fclose($config);
$sql_get_tables = mysql_list_tables($db);
for($i=0; $i < mysql_num_rows($sql_get_tables); $i++)
{
$result = mysql_tablename($sql_get_tables,$i);
if($result == $HTTP_POST_VARSї"prefix"]."_members")
{
$query_members = "DROP TABLE ".$HTTP_POST_VARSї"prefix"]."_members";
mysql_query($query_members);
}
if($result == $HTTP_POST_VARSї"prefix"]."_config")
{
$query_config = "DROP TABLE ".$HTTP_POST_VARSї"prefix"]."_config";
mysql_query($query_config);
}
}
$sql_install_members = "
CREATE TABLE ".$HTTP_POST_VARSї"prefix"]."_members (
username varchar(50),
password varchar(32),
userrank char(3),
page varchar(100),
email varchar(200),
lost char(5),
name text,
company text,
designation text,
prof text,
address text,
city text,
state text,
pin text,
website text,
phone text,
fax text,
jdate text
)
";
$sql_install_config = "
CREATE TABLE ".$HTTP_POST_VARSї"prefix"]."_config (
banned_ip varchar(15),
banned_names varchar(50)
)
";
$query_install_members = @mysql_query($sql_install_members);
if(!$query_install_members)
{
$tpl->define(array("main" => "main.tpl"));
$tpl->assign("TITLE", $HTTP_POST_VARSї"system_name"]." - Installation Error");
$tpl->assign("PAGE_TITLE", "Installation Error");
$tpl->assign("CONTENT",'<span class="errormsg">
Fail to install table, MySQL Server has returned the following error:-<br>
'.mysql_error().'
</span>');
$tpl->parse("result","main");
$tpl->FastPrint("result");
mysql_close();
exit();
}
$query_install_config = @mysql_query($sql_install_config);
if(!$query_install_config)
{
$tpl->define(array("main" => "main.tpl"));
$tpl->assign("TITLE", $HTTP_POST_VARSї"system_name"]." - Installation Error");
$tpl->assign("PAGE_TITLE", "Installation Error");
$tpl->assign("CONTENT",'<span class="errormsg">
Fail to install table, MySQL Server has returned the following error:-<br>
'.mysql_error().'
</span>');
$tpl->parse("result","main");
$tpl->FastPrint("result");
mysql_close();
exit();
}
$HTTP_POST_VARSї"admin_password"] = md5($HTTP_POST_VARSї"admin_password"]);
$ctime = gmdate("l jS F Y");
$sql_admin = "INSERT INTO ".$HTTP_POST_VARSї"prefix"]."_members VALUES('".$HTTP_POST_VARSї"admin_username"]."', '".$HTTP_POST_VARSї"admin_password"]."', 'adm' , 'index.php' , '".$HTTP_POST_VARSї"admin_email"]."', 'true', '', '', '', '', '', '', '', '', '', '', '', '$ctime')";
$query_admin = @mysql_query($sql_admin);
if(!$query_admin)
{
$tpl->define(array("main" => "main.tpl"));
$tpl->assign("TITLE", $HTTP_POST_VARSї"system_name"]." - Installation Error");
$tpl->assign("PAGE_TITLE", "Installation Error");
$tpl->assign("CONTENT",'<span class="errormsg">
Fail to create administrator, MySQL Server has returned the following error:-<br>
'.mysql_error().'
</span>');
$tpl->parse("result","main");
$tpl->FastPrint("result");
exit();
}
?>
<html lang="en-gb">
<head>
<title>Liteshaw Login System Installer</title>
<meta name="Author" content="Liteshaw Web Design">
<meta name="copyright" content="Liteshaw Web Design">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<link type="text/css" rel="stylesheet" href="library/base.css">
</head>
<body oncontextmenu="return false;">
<div align="center">
<span class="bold">
Liteshaw Login System has successfully been installed<br>
Click here to <a href="login.php">login</a>.
</span>
</div>
<hr>
<div align="center">
LSlogin 2.2 Professional<br>
Copyright &copy; Liteshaw Technology 2002<br>
</div>
</body>
</html>
<?php
exit();
?>
Last edited by Takuma on Fri Sep 20, 2002 2:20 am, edited 1 time in total.