# ## License: GNU LGPL v.3 # ## Site: http://www.apphp.com/php-calendar/ # ## Copyright: ApPHP Calendar (c) 2009-2011. All rights reserved. # ## # ################################################################################ require_once('settings.inc.php'); require_once('functions.inc.php'); if(file_exists(EI_CONFIG_FILE_PATH)){ header('location: ../'.EI_APPLICATION_START_FILE); exit; } if(EI_MODE == 'debug') error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); $completed = false; $error_mg = array(); $submit = isset($_POST['submit']) ? stripcslashes($_POST['submit']) : ''; if($submit != 'step2'){ header('location: step1.php'); exit; }else{ $username = isset($_POST['username']) ? stripcslashes($_POST['username']) : ''; $password = isset($_POST['password']) ? stripcslashes($_POST['password']) : ''; $database_host = isset($_POST['database_host']) ? $_POST['database_host'] : ''; $database_name = isset($_POST['database_name']) ? $_POST['database_name'] : ''; $database_username = isset($_POST['database_username']) ? prepare_input($_POST['database_username']) : ''; $database_password = isset($_POST['database_password']) ? $_POST['database_password'] : ''; $database_prefix = isset($_POST['database_prefix']) ? stripcslashes($_POST['database_prefix']) : ''; $install_type = isset($_POST['install_type']) ? $_POST['install_type'] : 'new'; $password_encryption = isset($_POST['password_encryption']) ? $_POST['password_encryption'] : EI_PASSWORD_ENCRYPTION_TYPE; $sql_dump_file = ($install_type == 'new') ? EI_SQL_DUMP_FILE_NEW : EI_SQL_DUMP_FILE_UPDATE; $link = null; if (empty($database_host)) $error_mg[] = 'Database host cannot be empty! Please re-enter.'; if (empty($database_name)) $error_mg[] = 'Database name cannot be empty! Please re-enter.'; if (empty($database_username)) $error_mg[] = 'Database username cannot be empty! Please re-enter.'; /// if (empty($database_password)) $error_mg[] = 'Database password cannot be empty! Please re-enter.'; if (EI_USE_USERNAME_AND_PASWORD && empty($username)) $error_mg[] = 'Admin username cannot be empty! Please re-enter.'; if (EI_USE_USERNAME_AND_PASWORD && empty($password)) $error_mg[] = 'Admin password cannot be empty! Please re-enter.'; if(empty($error_mg)){ if(EI_MODE == 'demo'){ if($database_host == 'localhost' && $database_name == 'db_name' && $database_username == 'test' && $database_password == 'test'){ $completed = true; }else{ $error_mg[] = 'Testing parameters are wrong! Please enter valid parameters.'; } }else{ $config_file = file_get_contents(EI_CONFIG_FILE_TEMPLATE); $config_file = str_replace('', $database_host, $config_file); $config_file = str_replace('', $database_name, $config_file); $config_file = str_replace('', $database_username, $config_file); $config_file = str_replace('', $database_password, $config_file); $config_file = str_replace('', $database_prefix, $config_file); $config_file = str_replace('', (EI_USE_PASSWORD_ENCRYPTION) ? 'true' : 'false', $config_file); $config_file = str_replace('', $password_encryption, $config_file); $config_file = str_replace('', EI_PASSWORD_ENCRYPTION_KEY, $config_file); $config_file = str_replace('', random_string(10), $config_file); @chmod(EI_CONFIG_FILE_PATH, 0755); $f = @fopen(EI_CONFIG_FILE_PATH, 'w+'); if(@fwrite($f, $config_file) > 0){ @chmod(EI_CONFIG_FILE_DIRECTORY, 0755); $link = @mysqli_connect($database_host, $database_username, $database_password, $database_name); if($link){ // read sql dump file $sql_dump = file_get_contents($sql_dump_file); if($sql_dump != ''){ if(false == ($db_error = apphp_db_install($sql_dump_file))){ $error_mg[] = 'SQL execution error! Please check carefully a syntax of SQL dump file.'; }else{ // additional operations, like setting up system preferences etc. // ... // ... $completed = true; } }else{ $error_mg[] = 'Could not read file '.$sql_dump_file.'! Please check if a file exists.'; } }else{ if(EI_MODE == 'debug'){ $error_mg[] = 'Database connecting error! Please check your connection parameters.
Error: '.mysqli_connect_error().'
'; }else{ $error_mg[] = 'Database connecting error! Please check your connection parameters.
Error: '.mysqli_connect_error().'
'; } } }else{ $error_mg[] = 'Cannot open configuration file '.EI_CONFIG_FILE_PATH.'. Please make sure you have the \'write\' permissions on this path.'; } @fclose($f); if(count($error_mg) > 0) @unlink(EI_CONFIG_FILE_PATH); } } } ?> Installation Guide
 

New Installation of !

Follow the wizard to setup your database.

'; } ?>
• '.$msg.'
 
    
 
Step 2. Installation Completed
 
The file was sucessfully created.


For security reasons, please remove install/ directory from your server!

Proceed to example page