<?php
header('Expires: Thu, 18 Aug 1994 05:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
if (file_exists(__DIR__.'/data/beta')) {$beta = 1;} else {$beta = 0;}
// страница отладки
$ok = 1;
$result = '<ul>';
if(function_exists('exec')) {
if (exec('whoami') == get_current_user()) {
$result .= '<li style="color:green;">file owner = php user (good practice)</li>';
} elseif (get_current_user() == 'root') {
$result .= '<li style="color:red;">Uploading files by the root user is a bad practice!</li>';
} else {
$result .= '<li style="color:red;">file owner != php user (bad practice)</li>';
}
}

if (extension_loaded('curl')) {
$result .= '<li style="color:green;">CURL - installed</li>';
} else {
$result .= '<li style="color:red;">CURL - not installed (<a href="https://www.php.net/manual/en/book.curl.php" target="_blank" rel="noopener">more</a>)</li>';
}

if (extension_loaded('zip')) {
$result .= '<li style="color:green;">ZIP - installed</li>';
} else {
$result .= '<li style="color:red;">ZIP - not installed (<a href="https://www.php.net/manual/en/book.zip.php" target="_blank" rel="noopener">more</a>)</li>';
}

if (extension_loaded('gmp')) {
$result .= '<li style="color:green;">GMP - installed</li>';
} else {
$result .= '<li style="color:red;">GMP - not installed (<a href="https://www.php.net/manual/en/book.gmp.php" target="_blank" rel="noopener">more</a>), needed for IPv6 support</li>';
$ok = 0; // обязательное условие
}

if (extension_loaded('sqlite3')) {
$result .= '<li style="color:green;">SQLite3 v. '.SQLite3::version()['versionString'].' - installed</li>';
} else {
$result .= '<li style="color:red;">SQLite3 - not installed (<a href="https://www.php.net/manual/en/book.sqlite3.php" target="_blank" rel="noopener">more</a>)</li>';
$ok = 0; // обязательное условие
}

if (extension_loaded('mbstring')) {
$result .= '<li style="color:green;">Mbstring - installed</li>';
} else {
$result .= '<li style="color:red;">Mbstring - not installed (<a href="https://www.php.net/manual/en/book.mbstring.php" target="_blank" rel="noopener">more</a>)</li>';
$ok = 0; // обязательное условие
}

if(function_exists('imagecreatetruecolor')) {
$result .= '<li style="color:green;">GD library - installed</li>';
} else {
$result .= '<li style="color:red;">GD library - not installed (<a href="https://www.php.net/manual/en/book.image.php" target="_blank" rel="noopener">more</a>)</li>';
}


if (defined('AF_INET6')) {
$result .=  '<li style="color:green;">PHP was compiled without --disable-ipv6 option</li>';
} else {
$result .=  '<li style="color:red;">PHP was compiled with --disable-ipv6 option</li>';
}


if (version_compare(PHP_VERSION, '7.0.0', '>=')) {
$result .= '<li style="color:green;">PHP version: '.PHP_VERSION.'</li>';
} else {
$result .= '<li style="color:red;">PHP version: '.PHP_VERSION.' (Minimum version: 7.0)</li>';
$ok = 0; // обязательное условие
}

if ($ok == 1) {
require_once(__DIR__.'/code/include.php');
}

$result .= '</ul>';

if ($ok != 1) {
echo '<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Test Server</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
</head>
<body>
'.$result.'
<p><a href="https://antibot.cloud/" target="_blank" rel="noopener noreferrer">Powered by AntiBot.Cloud</a></p>
</body>
</html>
';
die();
}

echo '<!DOCTYPE html>
<html>
<head>
<title>Antibot Demo Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta charset="utf-8">
</head>
<body>
'.$result.'
<ul>
<li>Version: '.((isset($ab_version)) ? $ab_version : 'not set').' '.(($beta == 1) ? '<span style="color:red;">Beta</span>' : '').'</li>
<li>Host: '.((isset($ab_config['host'])) ? $ab_config['host'] : 'not set').'</li>
<li>You are identified as a <strong>'.(($ab_config['whitebot'] == 1) ? 'Good Bot' : 'USER').'</strong>.</li>
<li>Your IP: <strong>'.((isset($ab_config['ip'])) ? $ab_config['ip'] : 'not set').'</strong> (it is right?)</li>
<li><a href="admin.php">Log in Admin Panel</a>.</li>
</ul>
</body>
</html>';
