203 lines
7.5 KiB
PHP
203 lines
7.5 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="cs">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Loading...</title>
|
|
<style>
|
|
.loader {
|
|
border: 16px solid #707080;
|
|
border-radius: 50%;
|
|
border-top: 16px solid #fff;
|
|
width: 170px;
|
|
height: 170px;
|
|
animation: spin 2.5s linear infinite;
|
|
position: absolute;
|
|
margin: 0 auto;
|
|
transform: translate(-50%, -50%);
|
|
background: url('https://service.espressowp.com/plugins-storage/hoster-logo-19.png') center center no-repeat;
|
|
background-size: 150px;
|
|
}
|
|
|
|
@keyframes spin {
|
|
0% { transform: rotate(0deg); }
|
|
100% { transform: rotate(360deg); }
|
|
}
|
|
|
|
body {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
height: 100vh;
|
|
margin: 0;
|
|
background-color: #2d2d31;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="loader"></div>
|
|
</body>
|
|
</html>
|
|
|
|
<?php
|
|
|
|
// Inicializace WP
|
|
define('WP_INSTALLING', true);
|
|
require_once __DIR__ . '/autoinstall-partials/functions.php';
|
|
replace_wp_config_salts(__DIR__ . '/wp-config.php');
|
|
|
|
require_once __DIR__ . '/wp-load.php';
|
|
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
|
|
|
$user_email = $_GET['email'];
|
|
|
|
// Kontrola emailové adresy
|
|
if (isset($user_email) && filter_var($user_email, FILTER_VALIDATE_EMAIL)) {
|
|
$user_email = htmlspecialchars(trim($_GET['email']));
|
|
$lang_allowed = array('en_US','de_DE','fr_FR','pl_PL','cs_CZ','sk_SK','lb_LU','ro_RO','el_GR',
|
|
'lt_LT','sr_RS@latin','sl_SI','pt_PT','sv_SE','nl_NL','lv_LV','hr_HR','fi_FI','it_IT','es_ES','hu_HU');
|
|
|
|
if(isset($_GET['language']) && in_array($_GET['language'], $lang_allowed))
|
|
$language = $_GET['language'];
|
|
else
|
|
$language = 'en_US';
|
|
|
|
$locale = $language;
|
|
|
|
if (!in_array($locale, $lang_allowed, true)) $locale = 'en_US';
|
|
|
|
if (function_exists('opcache_reset')) {
|
|
opcache_reset();
|
|
}
|
|
|
|
// Funkce pro smazání adresáře a jeho obsahu
|
|
function delete_directory($dir) {
|
|
if (!is_dir($dir)) return;
|
|
$items = scandir($dir);
|
|
foreach ($items as $item) {
|
|
if ($item == '.' || $item == '..') continue;
|
|
$path = $dir . DIRECTORY_SEPARATOR . $item;
|
|
if (is_dir($path))
|
|
delete_directory($path);
|
|
else
|
|
unlink($path);
|
|
}
|
|
rmdir($dir);
|
|
}
|
|
|
|
// Podmínka pro smazání adresáře, pokud je just-hosting=1
|
|
if (isset($_GET['just-hosting']) && $_GET['just-hosting'] == '1') {
|
|
$directory_to_delete = ABSPATH . 'wp-content/mu-plugins/espresso-ai';
|
|
if (is_dir($directory_to_delete))
|
|
delete_directory($directory_to_delete);
|
|
|
|
$directory_to_delete_wir = ABSPATH . 'wp-content/mu-plugins/wedos-wir';
|
|
if (is_dir($directory_to_delete_wir))
|
|
delete_directory($directory_to_delete_wir);
|
|
}
|
|
|
|
// Získání URL skriptu
|
|
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://';
|
|
$domain_name = $_SERVER['HTTP_HOST'];
|
|
$request_uri = $_SERVER['REQUEST_URI'];
|
|
$directory_path = dirname($request_uri);
|
|
|
|
$url_with_filename = $protocol . $domain_name . $request_uri;
|
|
$url_without_filename = $protocol . $domain_name . $directory_path;
|
|
|
|
// Nastavení domovské URL
|
|
define('WP_SITEURL', $url_without_filename);
|
|
define('WP_HOME', $url_without_filename);
|
|
|
|
// Základní informace
|
|
$blog_title = 'My WordPress Site';
|
|
$user_name = getEmailPrefix($user_email);
|
|
$user_password = generateRandomString();
|
|
$user_password_hash = hash('sha256', $user_password);
|
|
$empty_user_email = 'trash@sodew.ai'; // znemožní zaslání uvítacího emailu po instalaci wp
|
|
$full_login_url = $url_without_filename.'wp-login.php';
|
|
$from = 'ai.info@sodew.ai';
|
|
$headers = "From: SODEW AI <$from>\r\n";
|
|
$headers .= "Reply-To: $from\r\n";
|
|
$headers .= "MIME-Version: 1.0\r\n";
|
|
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
|
|
$unsubscribe_url = 'https://sodew.ai/unsubscribe/?email='.$user_email.'&lang=' . $language;
|
|
$api_key = isset($_GET['utm']) ? sanitize_text_field($_GET['utm']) : '0';
|
|
$demo = isset($_GET['demo']) && in_array($_GET['demo'], ['1', '0'], true) ? $_GET['demo'] : '0';
|
|
|
|
// Instalace WP
|
|
if (!is_blog_installed()) {
|
|
global $wpdb;
|
|
|
|
require_once ABSPATH . 'wp-admin/includes/translation-install.php';
|
|
|
|
// 1) stáhni jazyk, je-li potřeba
|
|
if (function_exists('wp_can_install_language_pack') && wp_can_install_language_pack()) {
|
|
wp_download_language_pack($locale);
|
|
}
|
|
|
|
// 2) nainstaluj WP a předej language
|
|
// signatura: wp_install($blog_title, $user_name, $user_email, $public, $deprecated='', $user_password='', $user_language='')
|
|
wp_install($blog_title, $user_name, $empty_user_email, true, '', $user_password, $locale);
|
|
|
|
// 3) pojisti nastavení jazyka a přepni locale pro aktuální request
|
|
update_option('WPLANG', $locale);
|
|
if (function_exists('switch_to_locale')) {
|
|
switch_to_locale($locale);
|
|
}
|
|
load_default_textdomain();
|
|
|
|
// Uloží do DB korektní emailovou adresu admina
|
|
update_option('siteurl', $url_without_filename);
|
|
update_option('home', $url_without_filename);
|
|
update_option('admin_email', $user_email);
|
|
update_option('api_key', $api_key);
|
|
update_option('demo', $demo);
|
|
update_option('temp_pass', $user_password);
|
|
wp_update_user(array('ID' => 1, 'user_email' => $user_email));
|
|
|
|
if($demo == 0) {
|
|
// E-mail body
|
|
if ($language == 'cs_CZ') { include(__DIR__ . "/autoinstall-partials/local_cs.php"); }
|
|
elseif ($language == 'de_DE') { include(__DIR__ . "/autoinstall-partials/local_de.php"); }
|
|
elseif ($language == 'pl_PL') { include(__DIR__ . "/autoinstall-partials/local_pl.php"); }
|
|
elseif ($language == 'ro_RO') { include(__DIR__ . "/autoinstall-partials/local_ro.php"); }
|
|
elseif ($language == 'fr_FR') { include(__DIR__ . "/autoinstall-partials/local_fr.php"); }
|
|
else { include(__DIR__ . "/autoinstall-partials/local_en.php"); }
|
|
|
|
mail($user_email, $subject, $message, $headers, "-f $from");
|
|
}
|
|
|
|
// vytvoří cookies pro trvalé přihlášení na 1 rok
|
|
$cookie_expiration = time() + (365 * 24 * 60 * 60);
|
|
$cookie_path = COOKIEPATH;
|
|
$cookie_domain = COOKIE_DOMAIN;
|
|
setcookie(LOGGED_IN_COOKIE, wp_generate_auth_cookie(1, $cookie_expiration, 'logged_in'), $cookie_expiration, $cookie_path, $cookie_domain, is_ssl(), true);
|
|
|
|
// Registrace funkce pro smazání skriptu po ukončení běhu
|
|
register_shutdown_function('delete_self', __FILE__, $full_login_url);
|
|
|
|
// Přesměrování a přihlášení
|
|
$login_url = $url_without_filename . 'wp-login.php';
|
|
echo '
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
</head>
|
|
<body>
|
|
<form name="loginform" id="loginform" action="' . $login_url . '" method="post">
|
|
<input type="hidden" name="log" value="' . $user_name . '" />
|
|
<input type="hidden" name="pwd" value="' . $user_password . '" />
|
|
<input type="hidden" name="rememberme" value="1" />
|
|
</form>
|
|
<script type="text/javascript">
|
|
document.getElementById("loginform").submit();
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|
|
';
|
|
exit;
|
|
}
|
|
}
|
|
?>
|