| Server IP : 74.208.236.16 / Your IP : 216.73.217.22 Web Server : Apache System : Linux info 3.0 #1337 SMP Tue Jan 01 00:00:00 CEST 2000 all GNU/Linux User : u102440577 ( 7172810) PHP Version : 8.4.28 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /homepages/oneclick/typo3/6.2.14/3/scripts/ |
Upload File : |
<?php
include_once 'env-variables.php';
include_once 'PasswordHash.php';
ini_set('include_path', '.');
class mysql_db_connect {
public function __construct() {
;
}
var $conn;
var $link;
var $table_names;
var $queries;
var $host;
var $socket;
function start_connection() {
$socket = explode(":", DB_host);
if (count($socket) > 1) {
if ($socket[1] != '3306') {
$this->link = "mysql:unix_socket=" . $socket[1] . ";dbname=" . DB_name . ';host=' . $socket[0];
$this->host = $socket[0];
$this->socket = $socket[1];
} else {
$this->link = 'mysql:dbname=' . db_name . ';host=' . DB_host;
$this->host = DB_host;
$this->socket = '';
}
} else {
$this->link = 'mysql:dbname=' . db_name . ';host=' . DB_host;
$this->host = DB_host;
$this->socket = '';
}
try {
$this->conn = new PDO($this->link, DB_user, DB_pass, array(PDO::ATTR_PERSISTENT => TRUE));
} catch (PDOException $e) {
echo $e;
$this->conn = $this->conn->errorInfo();
exit(1);
}
}
function drop_tables() {
$this->start_connection();
$tables = ["__bootstrappackage_form_style",
"backend_layout",
"be_groups",
"be_sessions",
"be_users",
"cache_imagesizes",
"cache_md5params",
"cache_treelist",
"cache_typo3temp_log",
"cf_cache_hash",
"cf_cache_hash_tags",
"cf_cache_pages",
"cf_cache_pages_tags",
"cf_cache_pagesection",
"cf_cache_pagesection_tags",
"cf_cache_rootline",
"cf_cache_rootline_tags",
"cf_extbase_datamapfactory_datamap",
"cf_extbase_datamapfactory_datamap_tags",
"cf_extbase_object",
"cf_extbase_object_tags",
"cf_extbase_reflection",
"cf_extbase_reflection_tags",
"cf_extbase_typo3dbbackend_queries",
"cf_extbase_typo3dbbackend_queries_tags",
"cf_extbase_typo3dbbackend_tablecolumns",
"cf_extbase_typo3dbbackend_tablecolumns_tags",
"fe_groups",
"fe_session_data",
"fe_sessions",
"fe_users",
"pages",
"pages_language_overlay",
"sys_be_shortcuts",
"sys_category",
"sys_category_record_mm",
"sys_collection",
"sys_collection_entries",
"sys_domain",
"sys_file",
"sys_file_collection",
"sys_file_metadata",
"sys_file_processedfile",
"sys_file_reference",
"sys_file_storage",
"sys_filemounts",
"sys_history",
"sys_language",
"sys_lockedrecords",
"sys_log",
"sys_news",
"sys_note",
"sys_refindex",
"sys_registry",
"sys_template",
"tt_content",
"tx_bootstrappackage_accordion_item",
"tx_bootstrappackage_carousel_item",
"tx_extensionmanager_domain_model_extension",
"tx_extensionmanager_domain_model_repository",
"tx_impexp_presets",
"tx_realurl_chashcache",
"tx_realurl_errorlog",
"tx_realurl_pathcache",
"tx_realurl_redirects",
"tx_realurl_uniqalias",
"tx_realurl_urldecodecache",
"tx_realurl_urlencodecache",
"tx_rsaauth_keys",
"tx_rtehtmlarea_acronym"];
$sql = " Drop table ";
foreach ($tables as $value) {
$this->conn->query($sql . str_replace(" ", "", $value) . ";");
}
}
function split_file($source) {
$this->queries = explode("\n\n", file_get_contents($source));
}
function executeq($sql) {
$this->start_connection();
$error = $this->conn->query($sql);
if ($error === false) {
printf($error);
}
}
function create_database() {
$obj = new user_setting();
$lang = $obj->get_lang(lang);
foreach ($this->queries as $value) {
$value = str_replace("#LOCALE#", $lang['lang'], $value);
$value = str_replace("#LOCALEID#", $lang['langid'], $value);
$error = $this->executeq($value);
}
return $error;
}
function db_query($query) {
$this->start_connection();
$result = $this->conn->query($query);
if ($result != FALSE) {
$value = $result->fetch(PDO::FETCH_ASSOC);
} else {
$value = false;
}
return $value;
}
function close_connection() {
$this->conn = null;
}
}
class user_setting {
var $db_obj;
var $conf;
public function __construct() {
$this->db_obj = new mysql_db_connect();
$this->conf = new configuration_file();
}
function switch_user() {
$password = md5(password);
$user = username;
$email = email;
$old_email = OLD_email;
$lang = $this->get_lang(lang);
$query = "UPDATE be_users SET password='$password', username='$user',lang='" . $lang['lang'] . "', email='$email' WHERE email = '$old_email'";
$this->db_obj->executeq($query);
if (lang != OLD_lang) {
$old_l = $this->get_lang(OLD_lang);
$l = $this->get_lang(lang);
$query = "Select uc, lang from be_users where username='" . $user . "';";
$val = $this->db_obj->db_query($query);
if (lang != 'en_US') {
$val1 = str_replace('s:4:"lang";s:' . $old_l['langid'] . ':"' . $old_l['lang'] . '";s:19:', 's:4:"lang";s:' . $l['langid'] . ':"' . $l['lang'] . '";s:19:', $val['uc']);
} else {
$val1 = str_replace('s:4:"lang";s:' . $old_l['langid'] . ':"' . $old_l['lang'] . '";s:19:', 's:4:"lang";s:0:"";s:19:', $val['uc']);
}
$query = "UPDATE be_users SET uc='$val1' where username='$user';";
$this->db_obj->executeq($query);
}
$t_hasher = new PasswordHash(8, FALSE);
$hash = $t_hasher->HashPassword(password);
$query = "UPDATE be_users SET password='$hash' where username = 'simple_editor'";
$this->db_obj->executeq($query);
$query = "UPDATE be_users SET password='$hash' where username = 'advanced_editor'";
$this->db_obj->executeq($query);
}
function new_user() {
//$password = md5(password);
$user = username;
$email = email;
$lang = $this->get_lang(lang);
$t_hasher = new PasswordHash(8, true);
$hash = $t_hasher->HashPassword(password);
$query = "UPDATE be_users SET password='$hash', username='$user',lang='" . $lang['lang'] . "', email='$email' WHERE username = 'admin'";
$this->db_obj->executeq($query);
$query = "UPDATE be_users SET password='$hash' where username = 'simple_editor'";
$this->db_obj->executeq($query);
$query = "UPDATE be_users SET password='$hash' where username = 'advanced_editor'";
$this->db_obj->executeq($query);
}
function get_lang($lang) {
$str = explode("_", $lang);
$lan = array('lang' => '', 'langid' => '');
if (strtolower($str[0]) == strtolower($str[0]) && $str[0] != 'en') {
$lan['lang'] = $str[0];
$lan['langid'] = '2';
} else {
if (strtolower($str[0]) != strtolower($str[0]) && $str[0] != 'en') {
$lan['lang'] = $lang;
$lan['langid'] = '2';
}
}
if ($str[0] == 'en') {
$lan['lang'] = '';
$lan['langid'] = '0';
}
return $lan;
}
}
class configuration_file {
var $randstr;
public function __construct() {
$this->randstr = new RandomStringGenerator();
}
function create_file() {
$db_obj = new mysql_db_connect();
$db_obj->start_connection();
$file = file_get_contents("LocalConfiguration.php");
$port = DB_port;
if (!empty($port)) {
$port = ":" . $port;
}
$pass = new Password();
$file = str_replace('#DB_NAME#', DB_name, $file);
$file = str_replace('#DB_HOST#', $db_obj->host . $port, $file);
$file = str_replace('#DB_PASSWORD#', DB_pass, $file);
$file = str_replace('#DB_USER#', DB_user, $file);
$file = str_replace('#DB_SOCKET#', $db_obj->socket, $file);
$file = str_replace('#site_name#', sitename, $file);
$file = str_replace('#domain#', str_replace("/", "", base_url_host), $file);
$file = str_replace('#hashed_password#', (String) $pass->get_pass(password), $file);
$file = str_replace('#encryption_key#', $this->randstr->generate(96), $file);
file_put_contents(webdir . "/typo3conf/LocalConfiguration.php", $file);
$db_obj->close_connection();
$file = file_get_contents("realurl_autoconf.php");
$file = str_replace('#domain#', $this->site_url(), $file);
file_put_contents(webdir . "/typo3conf/realurl_autoconf.php", $file);
}
function site_url() {
$site_url = substr(base_url_host, 0, 7);
if ($site_url == "http://") {
$site_url = base_url_host . base_url_path;
} else {
$site_url = "http://" . base_url_host . base_url_path;
}
if (substr($site_url, -1) == "/") {
$site_url = substr($site_url, 0, -1);
}
return $site_url;
}
function switch_file() {
$db_obj = new mysql_db_connect();
$db_obj->start_connection();
$farray = array();
$fp = fopen(webdir . "/typo3conf/LocalConfiguration.php", 'rb');
while (($line = fgets($fp)) !== false) {
array_push($farray, $line);
}
fclose($fp);
$port = DB_port;
if (!empty($port)) {
$port = ":" . $port;
}
$pass = new Password();
$key = $this->find_in_array("'database'", $farray);
$farray[$key[0]] = "\t\t" . "'database' =>" . "'" . DB_name . "'," . "\n";
unset($key);
$key = $this->find_in_array("'host'", $farray);
$farray[$key[0]] = "\t\t" . "'host' =>" . "'" . $db_obj->host . "'," . "\n";
unset($key);
$key = $this->find_in_array("'password'", $farray);
$farray[$key[0]] = "\t\t" . "'password' =>" . "'" . DB_pass . "'," . "\n";
unset($key);
$key = $this->find_in_array("'socket'", $farray);
$farray[$key[0]] = "\t\t" . "'socket' =>" . "'" . $db_obj->socket . "'," . "\n";
unset($key);
$key = $this->find_in_array("'username'", $farray);
$farray[$key[0]] = "\t\t" . "'username' =>" . "'" . DB_user . "'," . "\n";
unset($key);
$key = $this->find_in_array("'sitename'", $farray);
$farray[$key[0]] = "\t\t" . "'sitename' =>" . "'" . sitename . "'," . "\n";
unset($key);
$key = $this->find_in_array("'trustedHostsPattern'", $farray);
$farray[$key[0]] = "\t\t" . "'trustedHostsPattern' => '(www\.)?" . addslashes(str_replace("/", "", base_url_host)) . "'," . "\n";
unset($key);
$key = $this->find_in_array("'installToolPassword'", $farray);
$farray[$key[0]] = "\t\t" . "'installToolPassword' =>" . "'" . $pass->get_pass(password) . "'," . "\n";
unset($key);
$str = implode("", $farray);
file_put_contents(webdir . "/typo3conf/LocalConfiguration.php", $str);
$db_obj->close_connection();
$file = file_get_contents("realurl_autoconf.php");
$file = str_replace('#domain#', $this->site_url(), $file);
file_put_contents(webdir . "/typo3conf/realurl_autoconf.php", $file);
}
function upgrade_file() {
$db_obj = new mysql_db_connect();
$db_obj->start_connection();
$farray = array();
$fp = fopen(webdir . "/typo3conf/LocalConfiguration.php", 'rb');
while (($line = fgets($fp)) !== false) {
array_push($farray, $line);
}
fclose($fp);
$key = $this->find_in_array("'trustedHostsPattern'", $farray);
if ($farray[$key[0]] == NULL || $farray[$key[0]] == FALSE) {
$key2 = $this->find_in_array("'sitename'", $farray);
$farray[$key2[0]] = $farray[$key2[0]] . "\n" . "\t\t" . "'trustedHostsPattern' => '(www\.)?" . str_replace("/", "", base_url_host) . "'," . "\n";
unset($key2);
$str = implode("", $farray);
file_put_contents(webdir . "/typo3conf/LocalConfiguration.php", $str);
}
unset($key);
unset($farray);
$file = file_get_contents("realurl_autoconf.php");
$file = str_replace('#domain#', $this->site_url(), $file);
file_put_contents(webdir . "/typo3conf/realurl_autoconf.php", $file);
}
function find_in_array($key, $sarray) {
$ret = array_keys(array_filter($sarray, function($var) use ($key) {
return strpos($var, $key) !== false;
}));
return $ret;
}
}
class utility {
var $db_obj;
var $conf_obj;
var $user_obj;
public function __construct() {
$this->db_obj = new mysql_db_connect();
$this->conf_obj = new configuration_file();
$this->user_obj = new user_setting();
}
function patch() {
exit(1);
}
function install() {
system("mv " . webdir . "/uploads2 " . webdir . "/uploads");
system("mv " . webdir . "/typo3conf/PackageStates2.php " . webdir . "/typo3conf/PackageStates.php");
$this->db_obj->executeq("ALTER " . DB_name . " mydatabasename charset=utf8;");
$this->db_obj->split_file("typo3.sql");
$this->db_obj->create_database();
$this->conf_obj->create_file();
$this->user_obj->new_user();
$this->db_obj->executeq("DELETE FROM `cf_cache_hash`;");
$this->db_obj->executeq("DELETE FROM `cf_cache_hash_tags`;");
$this->db_obj->executeq("DELETE FROM `cf_cache_pages`;");
$this->db_obj->executeq("DELETE FROM `cf_cache_pages_tags`;");
$this->db_obj->executeq("DELETE FROM `cf_cache_pagesection`;");
$this->db_obj->executeq("DELETE FROM `cf_cache_pagesection_tags`;");
$this->db_obj->executeq("DELETE FROM `cf_cache_rootline`;");
$this->db_obj->executeq("DELETE FROM `cf_cache_rootline_tags`;");
$this->db_obj->executeq("DELETE FROM `cf_extbase_object`;");
$this->db_obj->executeq("DELETE FROM `cf_extbase_object_tags`;");
$this->db_obj->executeq("DELETE FROM `cf_extbase_reflection`;");
$this->db_obj->executeq("DELETE FROM `cf_extbase_reflection_tags`;");
$this->db_obj->executeq("DELETE FROM `be_sessions`;");
$this->db_obj->executeq("DELETE FROM `tx_realurl_urlencodecache`;");
$this->db_obj->executeq("DELETE FROM `tx_rsaauth_keys`;");
$files = scandir(webdir . "/typo3temp", 1);
foreach ($files as $key => $value) {
if ($value != "GB" && $value != "llmxl" && $value != "pics" && $value != "temp" && $value != "index.php" && $value != "." && $value != "..") {
system("rm -rf " . webdir . "/typo3temp/" . $value);
}
}
system("rm -rf " . webdir . "/typo3temp/GB/*");
system("rm -rf " . webdir . "/typo3temp/llxml/*");
system("rm -rf " . webdir . "/typo3temp/pics/*");
system("rm -rf " . webdir . "/typo3temp/temp/*");
$file = file_get_contents("htaccess.in");
$file = $this->replace(str_replace("/", "", base_url_path), '##BASE_URL_PATH##', $file);
file_put_contents(webdir . "/.htaccess", $file);
}
function upgrade() {
$files = scandir(webdir . "/typo3temp", 1);
foreach ($files as $key => $value) {
if ($value != "GB" && $value != "llmxl" && $value != "pics" && $value != "temp" && $value != "index.php") {
system("rm -rf " . webdir . "/typo3temp/" . $value);
}
}
system("rm -rf " . webdir . "/typo3temp/GB/*");
system("rm -rf " . webdir . "/typo3temp/llxml/*");
system("rm -rf " . webdir . "/typo3temp/pics/*");
system("rm -rf " . webdir . "/typo3temp/temp/*");
$this->db_obj->executeq("DELETE FROM `cf_cache_hash`;");
$this->db_obj->executeq("DELETE FROM `cf_cache_hash_tags`;");
$this->db_obj->executeq("DELETE FROM `cf_cache_pages`;");
$this->db_obj->executeq("DELETE FROM `cf_cache_pages_tags`;");
$this->db_obj->executeq("DELETE FROM `cf_cache_pagesection`;");
$this->db_obj->executeq("DELETE FROM `cf_cache_pagesection_tags`;");
$this->db_obj->executeq("DELETE FROM `cf_cache_rootline`;");
$this->db_obj->executeq("DELETE FROM `cf_cache_rootline_tags`;");
$this->db_obj->executeq("DELETE FROM `cf_extbase_object`;");
$this->db_obj->executeq("DELETE FROM `cf_extbase_object_tags`;");
$this->db_obj->executeq("DELETE FROM `cf_extbase_reflection`;");
$this->db_obj->executeq("DELETE FROM `cf_extbase_reflection_tags`;");
$this->db_obj->executeq("DELETE FROM `be_sessions`;");
$this->db_obj->executeq("DELETE FROM `tx_realurl_urlencodecache`;");
$this->db_obj->executeq("DELETE FROM `tx_rsaauth_keys`;");
$file = file_get_contents("htaccess.in");
$file = $this->replace(str_replace("/", "", base_url_path), '##BASE_URL_PATH##', $file);
file_put_contents(webdir . "/.htaccess", $file);
system("rm -rf " . webdir . "/uploads2");
system("rm -rf " . webdir . "/typo3conf/PackageStates2.php");
$this->conf_obj->upgrade_file();
}
function switch_config() {
$this->conf_obj->switch_file();
$this->user_obj->switch_user();
$files = scandir(webdir . "/typo3temp", 1);
foreach ($files as $key => $value) {
if ($value != "GB" && $value != "llmxl" && $value != "pics" && $value != "temp" && $value != "index.php") {
system("rm -rf " . webdir . "/typo3temp/" . $value);
}
}
system("rm -rf " . webdir . "/typo3temp/GB/*");
system("rm -rf " . webdir . "/typo3temp/llxml/*");
system("rm -rf " . webdir . "/typo3temp/pics/*");
system("rm -rf " . webdir . "/typo3temp/temp/*");
$this->db_obj->executeq("DELETE FROM `cf_cache_hash`;");
$this->db_obj->executeq("DELETE FROM `cf_cache_hash_tags`;");
$this->db_obj->executeq("DELETE FROM `cf_cache_pages`;");
$this->db_obj->executeq("DELETE FROM `cf_cache_pages_tags`;");
$this->db_obj->executeq("DELETE FROM `cf_cache_pagesection`;");
$this->db_obj->executeq("DELETE FROM `cf_cache_pagesection_tags`;");
$this->db_obj->executeq("DELETE FROM `cf_cache_rootline`;");
$this->db_obj->executeq("DELETE FROM `cf_cache_rootline_tags`;");
$this->db_obj->executeq("DELETE FROM `cf_extbase_object`;");
$this->db_obj->executeq("DELETE FROM `cf_extbase_object_tags`;");
$this->db_obj->executeq("DELETE FROM `cf_extbase_reflection`;");
$this->db_obj->executeq("DELETE FROM `cf_extbase_reflection_tags`;");
$this->db_obj->executeq("DELETE FROM `be_sessions`;");
$this->db_obj->executeq("DELETE FROM `tx_realurl_urlencodecache`;");
$this->db_obj->executeq("DELETE FROM `tx_rsaauth_keys`;");
$file = file_get_contents("htaccess.in");
$file = $this->replace(str_replace("/", "", base_url_path), '##BASE_URL_PATH##', $file);
file_put_contents(webdir . "/.htaccess", $file);
}
function remove() {
$this->db_obj->drop_tables();
}
function replace($str, $orig_str, $query) {
return str_replace($orig_str, $str, $query);
}
}
class Password extends PasswordHash {
var $pass;
public function __construct() {
$this->pass = new PasswordHash();
}
public function get_pass($password) {
return $this->pass->HashPassword($password);
}
}
class RandomStringGenerator {
/** @var string */
protected $alphabet;
/** @var int */
protected $alphabetLength;
/**
* @param string $alphabet
*/
public function __construct($alphabet = '') {
if ('' !== $alphabet) {
$this->setAlphabet($alphabet);
} else {
$this->setAlphabet(
implode(range('a', 'z'))
. implode(range('A', 'Z'))
. implode(range(0, 9))
);
}
}
/**
* @param string $alphabet
*/
public function setAlphabet($alphabet) {
$this->alphabet = $alphabet;
$this->alphabetLength = strlen($alphabet);
}
/**
* @param int $length
* @return string
*/
public function generate($length) {
$token = '';
for ($i = 0; $i < $length; $i++) {
$randomKey = $this->getRandomInteger(0, $this->alphabetLength);
$token .= $this->alphabet[$randomKey];
}
return $token;
}
/**
* @param int $min
* @param int $max
* @return int
*/
protected function getRandomInteger($min, $max) {
$range = ($max - $min);
if ($range < 0) {
// Not so random...
return $min;
}
$log = log($range, 2);
// Length in bytes.
$bytes = (int) ($log / 8) + 1;
// Length in bits.
$bits = (int) $log + 1;
// Set all lower bits to 1.
$filter = (int) (1 << $bits) - 1;
do {
$rnd = hexdec(bin2hex(openssl_random_pseudo_bytes($bytes)));
// Discard irrelevant bits.
$rnd = $rnd & $filter;
} while ($rnd >= $range);
return ($min + $rnd);
}
}