Apache/2.4.7 (Ubuntu) Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) safemode : OFF MySQL: ON | Perl: ON | cURL: OFF | WGet: ON > / var / www / html / sman1baleendahoppppppp / install / | server ip : 104.21.89.46 your ip : 172.69.130.130 H O M E |
Filename | /var/www/html/sman1baleendahoppppppp/install/core_class.php |
Size | 1.89 kb |
Permission | rw-r--r-- |
Owner | root : root |
Create time | 04-May-2025 17:23 |
Last modified | 04-May-2025 17:23 |
Last accessed | 06-Jul-2025 22:30 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
class Core {
/**
* @param Array
* @return Boolean
*/
public function validate_post($data) {
/* Validating the hostname, the database name and the username. The password is optional. */
return !empty($data['database_hostname']) && !empty($data['database_username']) && !empty($data['database_name']);
}
/**
* Write File
* @param array
* @return Boolean
*/
public function write_config($data) {
// Config path
$template_path = 'template/database.php';
$output_path = '../application/config/database.php';
// Open the file
$database_file = file_get_contents($template_path);
$new = str_replace("%DATABASE_HOSTNAME%", $data['database_hostname'], $database_file);
$new = str_replace("%DATABASE_USERNAME%", $data['database_username'], $new);
$new = str_replace("%DATABASE_PASSWORD%", $data['database_password'], $new);
$new = str_replace("%DATABASE_NAME%", $data['database_name'], $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($this->is_really_writable($output_path)) {
return fwrite($handle, $new);
}
return false;
}
private function is_really_writable($file)
{
// If we're on a Unix server with safe_mode off we call is_writable
if (DIRECTORY_SEPARATOR === '/' && (is_php('5.4') OR ! ini_get('safe_mode')))
{
return is_writable($file);
}
/* For Windows servers and safe_mode "on" installations we'll actually
* write a file then read it. Bah...
*/
if (is_dir($file))
{
$file = rtrim($file, '/').'/'.md5(mt_rand());
if (($fp = @fopen($file, 'ab')) === FALSE)
{
return FALSE;
}
fclose($fp);
@chmod($file, 0777);
@unlink($file);
return TRUE;
}
elseif ( ! is_file($file) OR ($fp = @fopen($file, 'ab')) === FALSE)
{
return FALSE;
}
fclose($fp);
return TRUE;
}
}
class Core {
/**
* @param Array
* @return Boolean
*/
public function validate_post($data) {
/* Validating the hostname, the database name and the username. The password is optional. */
return !empty($data['database_hostname']) && !empty($data['database_username']) && !empty($data['database_name']);
}
/**
* Write File
* @param array
* @return Boolean
*/
public function write_config($data) {
// Config path
$template_path = 'template/database.php';
$output_path = '../application/config/database.php';
// Open the file
$database_file = file_get_contents($template_path);
$new = str_replace("%DATABASE_HOSTNAME%", $data['database_hostname'], $database_file);
$new = str_replace("%DATABASE_USERNAME%", $data['database_username'], $new);
$new = str_replace("%DATABASE_PASSWORD%", $data['database_password'], $new);
$new = str_replace("%DATABASE_NAME%", $data['database_name'], $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($this->is_really_writable($output_path)) {
return fwrite($handle, $new);
}
return false;
}
private function is_really_writable($file)
{
// If we're on a Unix server with safe_mode off we call is_writable
if (DIRECTORY_SEPARATOR === '/' && (is_php('5.4') OR ! ini_get('safe_mode')))
{
return is_writable($file);
}
/* For Windows servers and safe_mode "on" installations we'll actually
* write a file then read it. Bah...
*/
if (is_dir($file))
{
$file = rtrim($file, '/').'/'.md5(mt_rand());
if (($fp = @fopen($file, 'ab')) === FALSE)
{
return FALSE;
}
fclose($fp);
@chmod($file, 0777);
@unlink($file);
return TRUE;
}
elseif ( ! is_file($file) OR ($fp = @fopen($file, 'ab')) === FALSE)
{
return FALSE;
}
fclose($fp);
return TRUE;
}
}