<?php
/*
asaancart - easy shopping cart solution
---------------------------------------
Copyright 2009 Nasir Ahmad Khan
Email: hide@address.com
This file is part of asaancart - open source easy shopping cart solution.
asaancart 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 3 of the License, or
(at your option) any later version.
asaancart 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 asaancart. If not, see <http://www.gnu.org/licenses/>.
*/
?>
<?php
$db_username = $_POST['db_username'];
$db_name = $_POST['db_name'];
$db_password = $_POST['db_password'];
$db_hostname = $_POST['db_hostname'];
//Shop settings....
$admin_password = $_POST['admin_password'];
//General Information
$store_title = $_POST['store_title'];
$full_name = $_POST['full_name'];
$email_address = $_POST['email_address'];
//Store/Business Information
$business_name = $_POST['business_name'];
$b_address = $_POST['b_address'];
$store_currency = $_POST['store_currency'];
$installation_dir = $_POST['installation_dir'];
if($installation_dir=="root"){$installation_dir="";}
$domain_name = "http://".$_POST['domain_name'];
//create config file
$file_content = "<?php
//GLOBAL
include('lang_en.php');
define('APP_ROOT_DIR','$installation_dir');
define('APP_ROOT',§_SERVER['DOCUMENT_ROOT'].'/' . APP_ROOT_DIR);
define('DOMAIN_NAME','$domain_name');
define('SITE_URL','$domain_name');
define('credit','Nasir Ahmad Khan');
define('COPYRIGHTS','Nasir Khan');
define('DEVELOPEDBY','Nasir Khan');
define('POWEREDBY','asaancart - easy shopping cart solution');
// DATA BASE SETTINGS
define('DB_HOST', '$db_hostname');
define('DB_USERNAME', '$db_username');
define('DB_PASSWORD', '$db_password');
define('DB_NAME', '$db_name');
mysql_connect(DB_HOST,DB_USERNAME,DB_PASSWORD);
mysql_select_db(DB_NAME);
§current_issue = date('d-m-Y');
//Smarty Settings
//---------------------
// put full path to Smarty.class.php
require(APP_ROOT.'/libs/Smarty.class.php');
§smarty = new Smarty();
§smarty->template_dir = APP_ROOT.'/templates';
§smarty->compile_dir = APP_ROOT.'/templates_c';
§smarty->cache_dir = APP_ROOT.'/cache';
§smarty->config_dir = APP_ROOT.'/configs';
//---------------------
//Global variables
//----------------
§smarty->assign('copyrights', COPYRIGHTS);
§smarty->assign('developedby', DEVELOPEDBY);
§smarty->assign('poweredby', POWEREDBY);
§smarty->assign('store_url', SITE_URL);
//-------------------------------
?>
";
$db_file_content = "
<?php
define('DB_HOST', '$db_hostname');
define('DB_USERNAME', '$db_username');
define('DB_PASSWORD', '$db_password');
define('DB_NAME', '$db_name');
mysql_connect(DB_HOST,DB_USERNAME,DB_PASSWORD);
mysql_select_db(DB_NAME);
?>
";
$config_main = '../config/config.php';
$config_db = '../config/config_db_only.php';
if (!$handle = fopen($config_main, 'a')) {
echo "Cannot open file ($config_main)";
exit;
}
// Write content to our opened file.
if (fwrite($handle, str_replace("§","$",str_replace(">",">",str_replace("<","<",$file_content)))) === FALSE) {
echo "Cannot write to file ($config_main)";
exit;
}
echo "Success, config.php created successfull<br>";
fclose($handle);
//creating db config
if (!$handle = fopen($config_db, 'a')) {
echo "Cannot open file ($config_main)";
exit;
}
// Write content to our opened file.
if (fwrite($handle, str_replace(">",">",str_replace("<","<",$db_file_content))) === FALSE) {
echo "Cannot write to file ($config_db)";
exit;
}
echo "Success, config_db_only.php created successfull<br>";
fclose($handle);
//end config
$handle_db = mysql_connect($db_hostname,$db_username,$db_password);
if (!$handle_db)
{
die('Could not connect: ' . mysql_error());
}
// make foo the current db
$db_selected = mysql_select_db($db_name, $handle_db);
if (!$db_selected) {
die ("Can't use $db_name : " . mysql_error());
}
$FP = fopen ( 'db.sql', 'r' );
$READ = fread ( $FP, filesize ( 'db.sql') );
$READ = explode ( "~~", $READ );
foreach ( $READ as $RED )
{
mysql_query ( $RED, $handle_db );
//echo $RED . "<br><br><br>";
}
//settings
$sql = "UPDATE store_settings SET store_title='$store_title', b_name='$business_name', b_address='$b_address', b_email_address='$email_address', b_country='$b_country', o_fullname='$full_name', o_email_address='$email_address', currency='$store_currency' WHERE store_id=1";
$results = mysql_query($sql);
//password
$sql = "UPDATE auth_user_admin SET password='".md5($admin_password)."' WHERE username='admin'";
$results = mysql_query($sql);
echo 'Done - please delete setup folder';
mysql_close($handle_db);
?>