<?php
// =======================================================================
// Module name: Install
// File name: install.php
// Version: 1.0
// Description: This script contains php code for the software installer.
//
// Comments are included within this script to document changes made to
// the code with each new version of the script. Each comment also lists
// the author's initials to document who made the changes to the code.
//
// Copyright (C) 2006-2010 Dustin Cowell Enterprises
//
// License: GNU General Public License, Version 2
//
// Link: http://www.gnu.org/licenses/gpl-2.0.txt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to:
//
// Free Software Foundation, Inc.
// 51 Franklin Street, Fifth Floor
// Boston, MA 02110-1301 USA
// =======================================================================
?>
<html>
<head>
<title>Free Simple Software Installation</title>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW, NOARCHIVE">
<META NAME="GOOGLEBOT" CONTENT="NOARCHIVE">
</head>
<body>
<?php
$request = $_GET['request'];
$phpincdir = "includes/";
$font_header = "<font face='arial' size='4'>";
$font_menu = "<font face='arial' size='2'>";
$font_body = "<font face='arial' size='2'>";
if (!$request) {
echo("<form action='" . $_SERVER['PHP_SELF'] . "?request=run_install&install_type=express' method='post' enctype='multipart/form-data'>");
echo("<input type='hidden' name='php_include_directory' value='$phpincdir'>");
echo("<input type='hidden' name='on_off' value='on'>");
echo("<input type='hidden' name='theme_name' value='Default'>");
echo("<input type='hidden' name='header_font_color' value='#000000'>");
echo("<input type='hidden' name='menu_font_color' value='#000000'>");
echo("<input type='hidden' name='body_font_color' value='#000000'>");
echo("<input type='hidden' name='link_color' value='#FF0000'>");
echo("<input type='hidden' name='header_background_color' value='#FFFFFF'>");
echo("<input type='hidden' name='menu_background_color' value='#FFFFFF'>");
echo("<input type='hidden' name='body_background_color' value='#FFFFFF'>");
echo("<input type='hidden' name='page_background_color' value='#FFFFFF'>");
echo("<input type='hidden' name='font_face_header' value='Arial'>");
echo("<input type='hidden' name='font_face_menu' value='Arial'>");
echo("<input type='hidden' name='font_face_body' value='Arial'>");
echo("<input type='hidden' name='font_size_header' value='4'>");
echo("<input type='hidden' name='font_size_menu' value='2'>");
echo("<input type='hidden' name='font_size_body' value='2'>");
echo("<input type='hidden' name='index_name' value='index.php'>");
echo("<input type='hidden' name='index_path' value='themes/default/'>");
echo($font_header . "<center><b>Free Simple Software Installation</b>");
echo("<center>" . $font_body);
echo("<table border='0' cellpadding='20' cellspacing='0'>");
echo("<tr>");
echo("<td align='left' valign='top'>" . $font_body);
echo("<b>Server Information</b><p>");
echo("<table border='1' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "MySQL Server Address:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='mysql_address' value='localhost'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "MySQL Server User Name:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='mysql_user_name'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "MySQL Server Password:</font></td>");
echo("<td>" . $font_body . "<input type='password' name='mysql_password'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "MySQL Database Name:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='mysql_database'></font></td>");
echo("</tr>");
echo("</table>");
echo("<p><b>Admin Login Setup</b><p>");
echo("<table border='1' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "First Name:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='first_name'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Last Name:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='last_name'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Email Address:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='email_address'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Password:</font></td>");
echo("<td>" . $font_body . "<input type='password' name='password'></font></td>");
echo("</tr>");
echo("</table>");
echo("</font></td>");
echo("<td align='left' valign='top'>" . $font_body);
echo("<b>Website Settings</b><p>");
echo("<table border='1' cellpadding='5' cellsacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Website Name:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='website_name' size='20'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Logo (Header) Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name='image'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Time Zone:</font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='time_zone'>");
echo("<option value='-12'>UTC-12</option>");
echo("<option value='-11'>UTC-11</option>");
echo("<option value='-10'>UTC-10</option>");
echo("<option value='-9.5'>UTC-9:30</option>");
echo("<option value='-9'>UTC-9</option>");
echo("<option value='-8' selected>UTC-8</option>");
echo("<option value='-7'>UTC-7</option>");
echo("<option value='-6'>UTC-6</option>");
echo("<option value='-5'>UTC-5</option>");
echo("<option value='-4.5'>UTC-4:30</option>");
echo("<option value='-4'>UTC-4</option>");
echo("<option value='-3.5'>UTC-3:30</option>");
echo("<option value='-3'>UTC-3</option>");
echo("<option value='-2'>UTC-2</option>");
echo("<option value='-1'>UTC-1</option>");
echo("<option value='0'>UTC</option>");
echo("<option value='+1'>UTC+1</option>");
echo("<option value='+2'>UTC+2</option>");
echo("<option value='+3'>UTC+3</option>");
echo("<option value='+3.5'>UTC+3:30</option>");
echo("<option value='+4'>UTC+4</option>");
echo("<option value='+4.5'>UTC+4:30</option>");
echo("<option value='+5'>UTC+5</option>");
echo("<option value='+5.5'>UTC+5:30</option>");
echo("<option value='+5.75'>UTC+5:45</option>");
echo("<option value='+6'>UTC+6</option>");
echo("<option value='+6.5'>UTC+6:30</option>");
echo("<option value='+7'>UTC+7</option>");
echo("<option value='+8'>UTC+8</option>");
echo("<option value='+8.75'>UTC+8:45</option>");
echo("<option value='+9'>UTC+9</option>");
echo("<option value='+9.5'>UTC+9:30</option>");
echo("<option value='+10'>UTC+10</option>");
echo("<option value='+10.5'>UTC+10:30</option>");
echo("<option value='+11'>UTC+11</option>");
echo("<option value='+11.5'>UTC+11:30</option>");
echo("<option value='+12'>UTC+12</option>");
echo("<option value='+12.75'>UTC+12:45</option>");
echo("<option value='+13'>UTC+13</option>");
echo("<option value='+14'>UTC+14</option>");
echo("</select>");
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Daylight Savings Time:</font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='dst'>");
echo("<option value='On' selected>On</option>");
echo("<option value='Off'>Off</option>");
echo("</select>");
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Google Analytics ID:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='google_analytics_id' size='20'></font></td>");
echo("</tr>");
echo("</table>");
echo("<p><b>Free Simple Shop</b><p>");
echo("<table border='1' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Install?</font></td>");
echo("<td>" . $font_body . "<input type='checkbox' name='freephpshoppingcartsoftware' value='yes'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Paypal email address:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='paypal_email_address'></font></td>");
echo("</tr>");
echo("</table>");
echo("<p><b>Free Simple Blog</b><p>");
echo("<table border='1' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Install?</font></td>");
echo("<td>" . $font_body . "<input type='checkbox' name='freephpblogsoftware' value='yes'></font></td>");
echo("</tr>");
echo("</table>");
echo("</font></td>");
echo("</tr>");
echo("</table>");
echo($font_body . "<p><p><input type='submit' name='submit' value='Install'></font>");
echo("</form>");
echo("</font></center>");
}
if ($request == "run_install") {
$admin_rights = "Admin";
$install_type = $_GET['install_type'];
$mysql_address = $_POST['mysql_address'];
$mysql_user_name = $_POST['mysql_user_name'];
$mysql_password = $_POST['mysql_password'];
$mysql_database = $_POST['mysql_database'];
$php_include_directory = $_POST['php_include_directory'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email_address = $_POST['email_address'];
$password = $_POST['password'];
$on_off = $_POST['on_off'];
$theme_name = $_POST['theme_name'];
$website_name = $_POST['website_name'];
$time_zone = $_POST['time_zone'];
$dst = $_POST['dst'];
$paypal_email_address = $_POST['paypal_email_address'];
$order_from_email = $email_address;
$order_to_email = $email_address;
$service_email = $email_address;
$default_email = $email_address;
$font_face_header = $_POST['font_face_header'];
$font_face_menu = $_POST['font_face_menu'];
$font_face_body = $_POST['font_face_body'];
$font_size_header = $_POST['font_size_header'];
$font_size_menu = $_POST['font_size_menu'];
$font_size_body = $_POST['font_size_body'];
$font_color_header = $_POST['header_font_color'];
$font_color_menu = $_POST['menu_font_color'];
$font_color_body = $_POST['body_font_color'];
$link_color = $_POST['link_color'];
$background_color_header = $_POST['header_background_color'];
$background_color_menu = $_POST['menu_background_color'];
$background_color_body = $_POST['body_background_color'];
$background_color_page = $_POST['page_background_color'];
$index_name = $_POST['index_name'];
$index_path = $_POST['index_path'];
$freephpshoppingcartsoftware = $_POST['freephpshoppingcartsoftware'];
$freephpblogsoftware = $_POST['freephpblogsoftware'];
$db_connect = mysql_connect($mysql_address, $mysql_user_name, $mysql_password);
$db_select = mysql_select_db($mysql_database, $db_connect);
echo($font_header . "<center><b>Free Simple Software Installation</b><p>");
echo("<center>" . $font_body);
echo("<table border='1' cellspacing='0' cellpadding='5'>");
echo("<center>");
echo("<tr>");
echo("<td>" . $font_body . "Includes Directory</font></td>");
echo("<td>" . $font_body . "");
if (file_exists("./includes")) {
chmod("./includes", 0755);
echo "Exists, set permissions";
} else {
mkdir("./includes", 0755);
echo "Created, set permissions";
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Images Directory</font></td>");
echo("<td>" . $font_body . "");
if (file_exists("./images")) {
chmod("./images", 0755);
echo "Exists, set permissions";
} else {
mkdir("./images", 0755);
echo "Created, set permissions";
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Themes Directory</font></td>");
echo("<td>" . $font_body . "");
if (file_exists("./themes")) {
chmod("./themes", 0755);
echo "Exists, set permissions";
} else {
mkdir("./themes", 0755);
echo "Created, set permissions";
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Default Theme Directory</font></td>");
echo("<td>" . $font_body . "");
$old_dir = getcwd();
chdir("./themes");
$new_dir = getcwd();
if (file_exists("./default")) {
chmod("./default", 0755);
echo "Exists, set permissions";
} else {
mkdir("./default", 0755);
echo "Created, set permissions";
}
chdir($old_dir);
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Server Connection</font></td>");
echo("<td>" . $font_body . "");
if ($db_connect) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Database Setup</font></td>");
echo("<td>" . $font_body . "");
if (!$db_select) {
if (mysql_query($db_create_database)) {
echo("Successful");
} else {
die('Error');
echo("</font></td>");
echo("</tr>");
}
} else {
echo("Already exists");
echo("</font></td>");
echo("</tr>");
}
$db_select = mysql_select_db($mysql_database, $db_connect);
echo("<tr>");
echo("<td>" . $font_body . "Select Database</font></td>");
echo("<td>" . $font_body . "");
if ($db_select) {
echo("Successful");
} else {
die('Error: ' . mysql_error());
}
echo("</font></td>");
echo("</tr>");
// Create the settings file
$file = "includes/settings.php";
$method = fopen($file, 'w');
$data = "<?php\n";
fwrite($method, $data);
$data = "\$dbconnect = mysql_connect('$mysql_address', '$mysql_user_name', '$mysql_password');\n";
fwrite($method, $data);
$data = "\$dbselect = mysql_select_db('$mysql_database', \$dbconnect);\n";
fwrite($method, $data);
$data = "\$image_upload_dir = 'images/';\n";
fwrite($method, $data);
$data = "\$image_view_dir = 'images/';\n";
fwrite($method, $data);
$data = "?>\n";
fwrite($method, $data);
fclose($method);
// Copy include files to the includes directory
$dir = ".";
$handle = opendir($dir);
while (($file = readdir($handle)) !== false) {
if(substr($file, -4) == ".inc") {
$source = "./$file";
$destination = "./includes/$file";
if (rename($source, $destination)) {
$include_file_move = "successful";
} else {
$include_file_move = "error";
}
}
}
closedir($handle);
echo("<tr>");
echo("<td>" . $font_body . "Copy Include Files</font></td>");
echo("<td>" . $font_body . "");
if ($include_file_move == "successful") {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
// Copy and rename the theme file to the theme directory
$file = 'default_theme.php';
$newfile = './themes/default/index.php';
// Copy the recaptchalib file to the include directory
$file = 'recaptchalib.php';
$newfile = './includes/recaptchalib.php';
copy($file, $newfile);
echo("<tr>");
echo("<td>" . $font_body . "Copy Theme Files</font></td>");
echo("<td>" . $font_body . "");
if (rename($file, $newfile)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
// Upload the logo
$uploadedfile = $_FILES['image']['tmp_name'];
$file_type = $_FILES['image']['type'];
if ($uploadedfile) {
if ($file_type == "image/pjpeg" || $file_type == "image/jpeg") {
$src = imagecreatefromjpeg($uploadedfile);
}
if ($file_type == "image/gif") {
$src = imagecreatefromgif($uploadedfile);
}
if ($file_type == "image/x-png" || $file_type == "image/png") {
$src = imagecreatefrompng($uploadedfile);
}
list($image_width,$image_height)=getimagesize($uploadedfile);
$image_tmp=imagecreatetruecolor($image_width,$image_height);
imagecopyresampled($image_tmp,$src,0,0,0,0,$image_width,$image_height,$image_width,$image_height);
$image_file_path = "./themes/default/" . $_FILES['image']['name'];
if ($file_type == "image/pjpeg" || $file_type == "image/jpeg") {
imagejpeg($image_tmp,$image_file_path,100);
}
if ($file_type == "image/gif") {
imagegif($image_tmp,$image_file_path);
}
if ($file_type == "image/x-png" || $file_type == "image/png") {
imagepng($image_tmp,$image_file_path);
}
$image_file_name = $_FILES['image']['name'];
$image_file_dir = "./themes/default/";
$image_file_path = addslashes($image_file_path);
imagedestroy($src);
imagedestroy($image_tmp);
}
// Install the core
include($phpincdir . "admin_users.inc");
include($phpincdir . "themes_menu_left.inc");
include($phpincdir . "admin_modules.inc");
include($phpincdir . "admin_settings.inc");
include($phpincdir . "themes.inc");
include($phpincdir . "pages.inc");
include($phpincdir . "links.inc");
include("downloads.php");
echo("</center>");
echo("</table>");
// Install shopping cart
if ($freephpshoppingcartsoftware) {
echo($font_header . "<p><b>Free Simple Shop Installation</b><p>");
echo($font_body);
echo("<table border='1' cellspacing='0' cellpadding='5'>");
echo("<center>");
echo("<tr>");
echo("<td>" . $font_body . "Shop Images Directory</font></td>");
echo("<td>" . $font_body . "");
if (file_exists("./shop_images")) {
chmod("./shop_images", 0755);
echo "Exists, set permissions";
} else {
mkdir("./shop_images", 0755);
echo "Created, set permissions";
}
echo("</font></td>");
echo("</tr>");
include($phpincdir . "members.inc");
include($phpincdir . "products.inc");
include($phpincdir . "catalog.inc");
include($phpincdir . "service.inc");
echo("</center>");
echo("</table>");
}
if ($freephpblogsoftware) {
echo($font_header . "<p><b>Free Simple Blog Installation</b><p>");
echo($font_body);
echo("<table border='1' cellspacing='0' cellpadding='5'>");
echo("<center>");
echo("<tr>");
echo("<td>" . $font_body . "Blog Directory</font></td>");
echo("<td>" . $font_body . "");
if (file_exists("./blog")) {
chmod("./blog", 0755);
echo "Exists, set permissions";
} else {
mkdir("./blog", 0755);
echo "Created, set permissions";
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Blog Images Directory</font></td>");
echo("<td>" . $font_body . "");
if (file_exists("./blog_images")) {
chmod("./blog_images", 0755);
echo "Exists, set permissions";
} else {
mkdir("./blog_images", 0755);
echo "Created, set permissions";
}
echo("</font></td>");
echo("</tr>");
include($phpincdir . "blog.inc");
echo("</center>");
echo("</table>");
}
echo("</font></center>");
$delete_install_file = unlink("install.php");
if ($delete_install_file) {
echo ($font_body . "<p><center><b>Install file deleted.</b></center></font>");
} else {
echo ($font_body . "<p><center><b>Error deleting install file.</b></center></font>");
}
}
?>
</body>
</html>