Файл: Luxe-Shop v6.0/install/includes/core_class.php
Строк: 87
<?php
class Core {
// Function to validate the post data
function validate_post($data)
{
/* Validating the hostname, the database name and the username. The password is optional. */
return !empty($data['hostname']) && !empty($data['username']) && !empty($data['database']) && !empty($data['useremail']) && !empty($data['userpass']);
}
// Function to show an error
function show_message($type,$message) {
return $message;
}
// Function to write the config file
function write_config($data) {
// Config path
$template_path = 'config/database.php';
$output_path = '../application/config/database.php';
// Open the file
$database_file = file_get_contents($template_path);
$new = str_replace("%HOSTNAME%",$data['hostname'],$database_file);
$new = str_replace("%USERNAME%",$data['username'],$new);
$new = str_replace("%PASSWORD%",$data['password'],$new);
$new = str_replace("%DATABASE%",$data['database'],$new);
// Write the new database.php file
$handle = fopen($output_path,'w+');
// Chmod the file, in case the user forgot
@chmod($output_path,0777);
// Verify file permissions
if(is_writable($output_path)) {
// Write the file
if(fwrite($handle,$new)) {
return true;
} else {
return false;
}
} else {
return false;
}
}
function generate_password($number)
{
$arr = array('a','b','c','d','e','f',
'g','h','i','j','k','l',
'm','n','o','p','r','s',
't','u','v','x','y','z',
'A','B','C','D','E','F',
'G','H','I','J','K','L',
'M','N','O','P','R','S',
'T','U','V','X','Y','Z',
'1','2','3','4','5','6',
'7','8','9','0',
'(',')','[',']','!','?',
'&','%','@','*','$',
'<','>','/','|','+','-',
'{','}');
// Генерируем пароль
$pass = "";
for($i = 0; $i < $number; $i++)
{
// Вычисляем случайный индекс массива
$index = rand(0, count($arr) - 1);
$pass .= $arr[$index];
}
return $pass;
}
function write_scconf($data) {
// Config path
$template_path = 'config/config.php';
$output_path = '../application/config/config.php';
// Open the file
$database_file = file_get_contents($template_path);
$crypt = $this->generate_password(30);
$new = str_replace("%CRYPTCODE%",$crypt,$database_file);
// Write the new database.php file
$handle = fopen($output_path,'w+');
// Chmod the file, in case the user forgot
@chmod($output_path,0777);
// Verify file permissions
if(is_writable($output_path)) {
// Write the file
if(fwrite($handle,$new)) {
return true;
} else {
return false;
}
} else {
return false;
}
}
}