<html>
<head>
<link rel="stylesheet" href="css/main.css" />
</head>
<body>
<?php
$path = str_replace("inc/firsttimerun.php","",__FILE__);
if(isset($_POST['install']))
{
$file = fopen($path."config/config.php","w");
fwrite($file,"<?php
define(\"MYSQL_HOST\",'$_POST[mysqlhost]');
define(\"MYSQL_USERNAME\",'$_POST[mysqlusername]');
define(\"MYSQL_PASSWORD\",'$_POST[mysqlpassword]');
define(\"MYSQL_DATABASE\",'$_POST[mysqldatabase]');
?>
");
fclose($file);
include($path."config/config.php");
if(!isset($_POST['existing']))
{
$error = false;
$message = "";
if($_POST['password']!=$_POST['password2'])
{
$error = true;
$message .= "Passwords are not the same";
}
if($_POST['password']=='')
{
$error = true;
$message .= "Passwords cannot be blank";
}
if($_POST['username']=='')
{
$error = true;
$message .="Username cannot be blank";
}
if($error == false)
{
//Okay Here Goes...
mysql_connect(MYSQL_HOST,MYSQL_USERNAME,MYSQL_PASSWORD);
mysql_select_db(MYSQL_DATABASE);
mysql_query("CREATE TABLE IF NOT EXISTS `Book` (`ID` int(11) NOT NULL auto_increment,`Name` varchar(100) NOT NULL,`Folder` int(11) NOT NULL,PRIMARY KEY (`ID`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;");
mysql_query("CREATE TABLE IF NOT EXISTS `Bookmark` (`Book` int(11) NOT NULL,`UID` int(11) NOT NULL default '1',`Page` varchar(100) NOT NULL,`Time` int(8) NOT NULL,`IsRead` tinyint(1) NOT NULL default '0',PRIMARY KEY USING BTREE (`Book`,`UID`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
mysql_query("CREATE TABLE IF NOT EXISTS `Folder` (`ID` int(11) NOT NULL auto_increment,`Path` varchar(200) NOT NULL,PRIMARY KEY (`ID`)) ENGINE=MyISAM DEFAULT CHARSET=latin1");
mysql_query("CREATE TABLE IF NOT EXISTS `Setting` (`KeyName` varchar(20) NOT NULL,`UID` int(8) NOT NULL,`Value` varchar(100) NOT NULL,PRIMARY KEY USING BTREE (`KeyName`,`UID`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
mysql_query("INSERT INTO `Setting` (`KeyName`, `UID`, `Value`) VALUES('ShowCovers', 0, '1')");
mysql_query("CREATE TABLE IF NOT EXISTS `Users` (`ID` int(11) NOT NULL auto_increment,`Username` varchar(50) NOT NULL,`Password` varchar(100) NOT NULL,`Admin` tinyint(1) NOT NULL,`FullName` varchar(150) NOT NULL,PRIMARY KEY (`ID`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 ");
mysql_query("INSERT INTO Users(Username,Password,Admin,FullName)VALUES('".addslashes($_POST['username'])."','".MD5($_POST['password'])."',1,'".addslashes($_POST['fullname'])."'".")");
$UID = mysql_insert_id();
mysql_query("INSERT INTO `Setting` (`KeyName`, `UID`, `Value`) VALUES('CoversDirectory', 0, '$path"."covers')");
mysql_query("INSERT INTO `Setting` (`KeyName`, `UID`, `Value`) VALUES('CacheDirectory', 0, '$path"."cache')");
$errors = mysql_error();
if(empty($errors))
{
session_start();
session_register("UID");
session_register("FullName");
session_register("Admin");
$_SESSION['UID'] = $UID;
$_SESSION['FullName'] = $_POST['fullname'];
$_SESSION['Admin'] = 1;
header('Location','admin_settings.php');
}
else
{
echo $errors;
}
}
}
}
$errorsonpage = false;
?>
<form action="" method="post">
<h1>First Time Run</h1>
<h2>Database</h2>
<table>
<tr>
<td>Host:</td>
<td><input type="text" name="mysqlhost" value="localhost" /></td>
</tr>
<tr>
<td>Database:</td>
<td><input type="text" name="mysqldatabase" value="phpcomics" /></td>
</tr>
<tr>
<td>Username:</td>
<td><input type="text" name="mysqlusername" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="mysqlpassword" /></td>
</tr>
</table>
<input type="checkbox" name="existing" value="y" />Database is from existing installation
<h2>Main User</h2>
This is a user that will have full administration privaleges,and may be your only user.
Each User has their own bookmarks.
<table>
<tr>
<td>
Username:
</td>
<td>
<input type="text" name="username" id="username" />
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<input type="password" name="password" id="password" />
</td>
</tr>
<tr>
<td>
Repeat Password:
</td>
<td>
<input type="password" name="password2" id="password2" />
</td>
</tr>
<tr>
<td>
Full Name:
</td>
<td>
<input type="text" name="fullname" id="fullname" />
</td>
</tr>
</table>
<h2>Required Extensions</h2>
These extensions are required for php-comics to run.
<table>
<tr>
<td>
GD:
</td>
<td>
<?php if(function_exists('imagejpeg'))
{
echo "<span class='success'>Successfully Installed</span>";
}
else
{
echo "<span class='failure'>Not Installed. Install instructions <a href='http://www.libgd.org/FAQ_PHP#How_do_I_get_gd_to_work_with_PHP.3F'>here</a></span>";
$errorsonpage = true;
}?>
</td>
</tr>
<tr>
<td>
RAR:
</td>
<td> <?php if(function_exists('rar_open'))
{
echo "<span class='success'>Successfully Installed</span>";
}
else
{
echo "<span class='failure'>Not Installed. Install instructions <a href='http://ca3.php.net/manual/en/rar.installation.php'>here</a></span>";
$errorsonpage = true;
}?>
</td>
</tr>
<tr>
<td>
ZIP:
</td>
<td>
<?php if(function_exists('zip_open'))
{
echo "<span class='success'>Successfully Installed</span>";
}
else
{
echo "<span class='failure'>Not Installed. Install instructions <a href='http://ca2.php.net/manual/en/zip.installation.php#zip.pecl.installation'>here</a></span>";
$errorsonpage = true;
}?>
</td>
</tr>
</table>
<h2>Folder Permissions</h2>
The following must be writable by php:
<table>
<tr>
<td>
<?=$path?>config/
</td>
<td>
<?php if(is_writeable($path.'config'))
{
echo "<span class='success'>Folder is writable</span>";
}
else
{
echo "<span class='failure'>Folder is not writable. Change permissions of this folder to '777'</span>";
$errorsonpage = true;
}?>
</td>
</tr>
<tr>
<td>
<?=$path?>cache/
</td>
<td>
<?php if(is_writeable($path.'cache'))
{
echo "<span class='success'>Folder is writable</span>";
}
else
{
echo "<span class='failure'>Folder is not writable. Change permissions of this folder to '777'</span>";
$errorsonpage = true;
}?>
</td>
</tr>
<tr>
<td>
<?=$path?>covers/
</td>
<td>
<?php if(is_writeable('covers'))
{
echo "<span class='success'>Folder is writable</span>";
}
else
{
echo "<span class='failure'>Folder is not writable. Change permissions of this folder to '777'</span>";
$errorsonpage = true;
}?>
</td>
</tr>
</table>
<?php if($errorsonpage)
{
echo "<span class='failure'>Errors on page. Fix to continue.</span>";
}
else
{
?><input type="submit" name="install" value="Install Application"/>
<?php }?>
</form>
</body>
</html>