HEX
Server: Apache
System: Linux info 3.0 #1337 SMP Tue Jan 01 00:00:00 CEST 2000 all GNU/Linux
User: u103727277 (3416564)
PHP: 8.0.30
Disabled: NONE
Upload Files
File: /homepages/oneclick/joomla/3.5.1/2/scripts/custom.php
<?php
require_once('env-parser.php');
require_once('file-util.php');

function admin_password_crypt($value)
{
	return md5($value);
}

function get_localized_schema_files()
{
	mysql_db_connect(get_db_address('main'), get_db_login('main'), get_db_password('main'), get_db_name('main'));
	$db_version = explode('.', mysql_get_server_info());

	if(!empty($db_version[1]) AND (int)$db_version[1] < 5)
	{
		$schema_files = array('schema.legacy.sql' => 'main');
	}
	else
	{
		$schema_files = array('schema.sql' => 'main');
	}

	$schema_files['admin_user.sql'] = 'main';

	//Set schema_version
	$schema_files['schema_schema_version.sql'] = 'main';

	$sample_data = fetch_env_var('SETTINGS_sample_data');

	if(strlen($sample_data) > 0 && $sample_data == 'no')
	{
		return $schema_files;
	}

	$locale = fetch_env_var('SETTINGS_locale');
	$fname = "${locale}_data.sql";
	if(!@file_exists($fname))
	{
		$fname = 'en-GB_data.sql';
	}
	$schema_files[$fname] = 'main';

	return $schema_files;
}

function rebuild_config_file($old_config_file, $file_source, $file_dest, $meta_settings)
{
	$file_content = read_file($file_source);

	require_once $old_config_file;
	$old_conf = new JConfig();

	foreach(get_object_vars($old_conf) as $key => $value)
	{
		foreach($meta_settings as $field)
		{
			if($key == $field)
			{
				continue 2;
			}
		}

		$file_content = preg_replace('@public \$'.$key.' = \'.*\';@i', "public \$".$key." = '".php_quote($value)."';", $file_content);
	}
	write_file($file_dest, $file_content);
}

function get_additional_modify_hash()
{
	$parameters = array();
	$parameters['@@SECRET_KEY@@'] = genRandomPassword(16);

	return $parameters;
}

function genRandomPassword($length = 8)
{
	$salt = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	$len = strlen($salt);
	$makepass = '';
	mt_srand(10000000 * (double)microtime());

	for($i = 0; $i < $length; $i++)
	{
		$makepass .= $salt[mt_rand(0, $len - 1)];
	}

	return $makepass;
}

function install_extra_component($root_dir, $locale)
{
	if(version_compare(PHP_VERSION, '5.3.1', '<'))
	{
		return;
	}

	install_component($locale.'_joomla_lang_full.zip', $root_dir);
	install_component('com_akeeba.zip', $root_dir);
	install_component('plg_bruteforceprotection.zip', $root_dir);
	enable_plg_bruteforceprotection();
	disable_plg_system_stats();

	// Run the core functionality to set the default language
	JLoad::loadFramework($root_dir);
	JSetDefaultLanguage::setLanguage($locale);
}

function activateDefaultLanguage()
{
	// Not needed yet
}

function enable_plg_bruteforceprotection()
{
	$db_id = "main";
	mysql_db_connect(get_db_address($db_id), get_db_login($db_id), get_db_password($db_id), get_db_name($db_id));
	mysql_query("UPDATE `".get_db_prefix($db_id)."jos_extensions` SET `enabled`=1 WHERE `type`='plugin' AND `element`='bruteforceprotection';");
}

function disable_plg_system_stats()
{
	$db_id = "main";
	mysql_db_connect(get_db_address($db_id), get_db_login($db_id), get_db_password($db_id), get_db_name($db_id));
	mysql_query("UPDATE `".get_db_prefix($db_id)."jos_extensions` SET `enabled`=0 WHERE `type`='plugin' AND `element`='stats';");
}

function enable_plg_autologin()
{
	$db_id = "main";
	mysql_db_connect(get_db_address($db_id), get_db_login($db_id), get_db_password($db_id), get_db_name($db_id));
	mysql_query("UPDATE `".get_db_prefix($db_id)."jos_extensions` SET `enabled`=1, `params`='{\"urlredirect\":\"\",\"authmethod\":\"0\"}' WHERE `name`='System - Autologin' AND `type`='plugin' AND `element`='autologin';");
}

function install_component($zip_file, $root_dir)
{
	if(version_compare(PHP_VERSION, '5.3.1', '<'))
	{
		//problem on Plesk ignoring php version requirement
		return;
	}

	defined('APS_EXTENSION_INSTALL') || define('APS_EXTENSION_INSTALL', 'on');
	$script_dir = getcwd();
	chdir($root_dir);
	ob_start();
	require_once($root_dir."/cli/install_package_cli.php");
	$joomlaExtensionFromAPS = new InstallJoomlaExtensionFromAPS();
	$joomlaExtensionFromAPS->install($root_dir."/tmp/distributives/${zip_file}");

	if(ob_get_length() > 0)
	{
		ob_end_clean();
	}

	chdir($script_dir);
}

/************************************************************************/
/* 						Get Joomla Admin User Id						*/
/* 		Old Joomla APS Admin User Id is diferent (like Joomla 2.5.1)	*/
/************************************************************************/
function getJoomlaAdminUserId()
{
	$joomlaAdminUserId = 62;
	$db_id = "main";
	mysql_db_connect(get_db_address($db_id), get_db_login($db_id), get_db_password($db_id), get_db_name($db_id));

	$result = mysql_query("SELECT `id` FROM `".get_db_prefix($db_id)."jos_users` LIMIT 1");
	if($result)
	{
		$joomlaAdminUserId = mysql_result($result, 0);
	}

	return $joomlaAdminUserId;
}

/************************************************************************/
/* 					Delete Old Joomla Files (Plesk bug)					*/
/************************************************************************/
function deleteOldJoomlaFiles($root_dir)
{
	$old_filelist = 'old_joomla_files.files';
	if(file_exists($old_filelist))
	{
		$lines = file($old_filelist);
		foreach($lines as $lnum => $fpath)
		{
			$fpath = rtrim($fpath, "\r\n");
			if(file_exists($root_dir."/".$fpath))
			{
				@unlink($root_dir."/".$fpath);
			}
		}
	}
}

/* 
/* removing 1.7.x.sql files to avoid error message in Extensions -> Database
/* If these files present, there is 2 messages of kind "Table 'jos_content' does not have column 'title_alias' with type 'VARCHAR(255)'. (From file 1.7.3-2011-10-15.sql.)"
*/
function removeJoomla17UpgradeScripts($root_dir)
{
	$mysql_updates_dir = "$root_dir/administrator/components/com_admin/sql/updates/mysql/";
	if($handle = @opendir($mysql_updates_dir))
	{
		while(strlen($file = readdir($handle)))
		{
			if(preg_match("/^1\.7\..*\.sql$/", $file))
			{
				@unlink($mysql_updates_dir.$file);
			}
		}
	}
	@closedir($handle);
}

function get_table_prefix($db_modify_hash, $psa_modify_hash)
{
	$dbprefix = $db_modify_hash['@@DB_MAIN_PREFIX@@'].'jos_'; // this is our default prefix. Get the one from configuration.php just in case
	$config_content = read_file($psa_modify_hash['@@ROOT_DIR@@'].'/configuration.php');
	if(preg_match('#public \$dbprefix *= *[\'\"]([^\'\"]*)[\'\"]#m', $config_content, $mres))
	{
		$dbprefix = $mres[1];
	}

	return $dbprefix;
}

function clean_up_installation($folder, $create_empty_folder = false, $create_empty_index_html = false, $delete_folder = true, $not_remove = array())
{
	if(substr($folder, -1) != '/')
	{
		$folder .= '/';
	}

	if(file_exists($folder))
	{
		if($handle = @opendir($folder))
		{
			while(strlen($file = readdir($handle)))
			{
				if($file != '.' && $file != '..' && !in_array($file, $not_remove))
				{
					set_write_permissions($folder.$file);

					if(is_dir($folder.$file))
					{
						if(!@rmdir($folder.$file))
						{
							clean_up_installation($folder.$file.'/');
						}
					}
					else
					{
						@unlink($folder.$file);
					}
				}
			}
		}

		@closedir($handle);

		if($delete_folder)
		{
			set_write_permissions($folder);
			@rmdir($folder);
		}

		if($create_empty_folder AND !file_exists($folder))
		{
			if($create_empty_folder)
			{
				mkdir($folder);
			}
		}

		if($create_empty_index_html)
		{
			file_put_contents($folder."/index.html", '');
		}
	}
}

function createHtaccessFile($base_path, $root_dir)
{
	$htaccess_txt_path = $root_dir.'/.htaccess';

	// We have to reset the .htaccess
	if(file_exists($htaccess_txt_path))
	{
		set_write_permissions($htaccess_txt_path);
		delete_file($htaccess_txt_path);
	}

	// Create .htaccess file if this file does not exist yet
	if(!file_exists($htaccess_txt_path))
	{
		if(empty($base_path))
		{
			$base_path = '/';
		}

		$file_content = read_file('htaccess.txt');
		$file_content = str_replace('###BASE_PATH###', $base_path, $file_content);
		write_file($htaccess_txt_path, $file_content);
	}
}

function createRobotsFile($root_dir, $product_domain)
{
	$robots_txt_path = $root_dir.'/robots.txt';

	// We have to reset the robots.txt
	if(file_exists($robots_txt_path))
	{
		set_write_permissions($robots_txt_path);
		delete_file($robots_txt_path);
	}

	// Create robots.txt file if this file does not exist yet
	if(!file_exists($robots_txt_path))
	{
		if($product_domain)
		{
			$robots_txt_source_path = 'robots.txt.noindex';
		}
		else
		{
			$robots_txt_source_path = 'robots.txt.dist';
		}

		$file_content = read_file($robots_txt_source_path);
		write_file($robots_txt_path, $file_content);
	}
}

function isProductDomain($host_url)
{
	$product_domains = array('apps-1and1.net', 'apps-1and1.com');

	$domain_parts = explode('.', $host_url);
	$domain_parts = array_slice($domain_parts, -2);
	$main_domain = implode('.', $domain_parts);

	if(in_array($main_domain, $product_domains))
	{
		return true;
	}

	return false;
}