芝麻web文件管理V1.00
编辑当前文件:/home/digitalh/network.digitalhubbd.com/layouts/installer/installer.php
pro_version\s*=\s*\'pro\'\s*;/'; $newConfig = preg_replace($pattern, '', $currentConfig); file_put_contents($configFile, $newConfig); if (!empty($variables)) { if (isset($variables->license)) { $license_info_file = 'assets/cache/license_record.cache'; file_put_contents($license_info_file, $response); if (isset($variables->extended_license)) { $newLine = "\n\$config->pro_version = 'pro';\n"; $pattern = '/(\$db_error_mode\s*=\s*PDO::ERRMODE_SILENT\s*;)/'; if (preg_match($pattern, $currentConfig, $matches, PREG_OFFSET_CAPTURE)) { $position = $matches[0][1]; $newConfig = substr_replace($currentConfig, $newLine, $position, 0); file_put_contents($configFile, $newConfig); } } else { $pattern = '/\n\s*\$config->pro_version\s*=\s*\'pro\'\s*;/'; $newConfig = preg_replace($pattern, '', $currentConfig); file_put_contents($configFile, $newConfig); } $noerror = true; } } } if ($noerror) { try { $db_instance = new Medoo([ 'type' => $data["database_type"], 'host' => $data["database_hostname"], 'database' => $data["database_name"], 'username' => $data["database_username"], 'password' => $data["database_password"], 'port' => $data["database_port"], 'error' => PDO::ERRMODE_SILENT, 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_general_ci', ]); } catch (PDOException $exception) { $noerror = false; $result['error_message'] = 'Invalid Database Credentials'; if (!empty($exception->getMessage())) { $result['error_message'] = $exception->getMessage(); } } } if ($noerror) { $config_file = 'include/config.php'; if (is_writable($config_file)) { $file_contents = file_get_contents($config_file); $file_contents = preg_replace("/'type' => '([^']+(?='))'/", "'type' => '".$data['database_type']."'", $file_contents); $file_contents = preg_replace("/'host' => '([^']+(?='))'/", "'host' => '".$data['database_hostname']."'", $file_contents); $file_contents = preg_replace("/'database' => '([^']+(?='))'/", "'database' => '".$data['database_name']."'", $file_contents); $file_contents = preg_replace("/'username' => '([^']+(?='))'/", "'username' => '".$data['database_username']."'", $file_contents); $file_contents = preg_replace("/'password' => '([^']+(?='))'/", "'password' => '".$data['database_password']."'", $file_contents); $file_contents = preg_replace("/'port' => '([^']+(?='))'/", "'port' => '".$data['database_port']."'", $file_contents); file_put_contents($config_file, $file_contents); } else { $noerror = false; $result['error_message'] = 'Permission Denied : Unable to write to include/config.php file'; } } if ($noerror) { include('layouts/installer/item_support_register.php'); $import_sql = file_get_contents('layouts/installer/installer.sql'); try { $db_instance->query($import_sql); } catch (PDOException $exception) { $noerror = false; $result['error_message'] = 'Database Import Failed'; } } if ($noerror) { $data["username"] = sanitize_username($data["username"]); if (empty($data["username"])) { $data["username"] = 'admin'; } try { $db_instance = new Medoo([ 'type' => $data["database_type"], 'host' => $data["database_hostname"], 'database' => $data["database_name"], 'username' => $data["database_username"], 'password' => $data["database_password"], 'port' => $data["database_port"], 'error' => PDO::ERRMODE_SILENT, 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_general_ci', ]); $update_data = array(); $update_data["email_address"] = $data['email_address']; $update_data["username"] = $data['username']; $update_data["password"] = password_hash($data['password'], PASSWORD_BCRYPT); $update_data["encrypt_type"] = 'php_password_hash'; $update_data["salt"] = ''; $update_data["created_on"] = $formattedTimestamp; $update_data["updated_on"] = $formattedTimestamp; $db_instance->update("gr_site_users", $update_data, ["OR" => ["username" => "admin", "user_id" => 1]]); } catch (PDOException $exception) { $data["username"] = 'admin'; $data["password"] = 'pass'; } $api_secret_key = random_string('15'); $db_instance->update("gr_settings", ['value' => $api_secret_key], ["setting" => "api_secret_key"]); $cs_where = ['string_constant[~]' => 'custom_page_%']; $cs_columns = ['string_id', 'string_constant']; $custom_page_contents = $db_instance->select("gr_language_strings", $cs_columns, $cs_where); $string_ids = array(); $string_value = '[YOU CAN MODIFY THE PAGE CONTENTS VIA CUSTOM PAGES MODULE]'; foreach ($custom_page_contents as $custom_page_content) { $string_constant = $custom_page_content['string_constant']; if (strpos($string_constant, '_content') !== false) { $string_ids[] = $custom_page_content['string_id']; } } if (!empty($string_ids)) { $db_instance->update("gr_language_strings", ['string_value' => $string_value], ["string_id" => $string_ids]); } if (file_exists('layouts/installer/cache_rebuild.php')) { include 'layouts/installer/cache_rebuild.php'; } if (file_exists('pages/installer.php')) { $rename_to = 'pages/installer_'.strtolower(random_string('10')); '.php'; rename('pages/installer.php', $rename_to); } if (file_exists('htaccess.backup')) { unlink('htaccess.backup'); } if (file_exists('assets/cache/total_cloud_storage_size.cache')) { unlink('assets/cache/total_cloud_storage_size.cache'); } $robotsTxtContent = "User-agent: *\nDisallow: \nDisallow: /cgi-bin/\nSitemap: ".Registry::load('config')->site_url."sitemap/"; $robotsTxtFilePath = 'robots.txt'; file_put_contents($robotsTxtFilePath, $robotsTxtContent); $result = array(); $result['success'] = true; $result['alert_message'] = "Installation Complete. \n\nYour Login Details:\n"; $result['alert_message'] .= "Username : ".$data["username"]."\n"; $result['alert_message'] .= "Password : ".strip_tags($data["password"])."\n"; } } } $result = json_encode($result); echo $result;