setTimeZone(new DateTimeZone($timezone))->format("Y-m-d H:i:s.u ").$loglevel.$logtext."\n"); fclose($loghandle); if($norotate == false && filesize($file) > 5242880) { $loghandle = fopen($file, 'a'); fwrite($loghandle, DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''))->setTimeZone(new DateTimeZone($timezone))->format("Y-m-d H:i:s.u ")." NOTICE Logfile filesie of 5 MiB reached.. Rotate logfile.\n"); fclose($loghandle); $file2 = "$file.old"; if (file_exists($file2)) unlink($file2); rename($file, $file2); $loghandle = fopen($file, 'a'); fwrite($loghandle, DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''))->setTimeZone(new DateTimeZone($timezone))->format("Y-m-d H:i:s.u ")." NOTICE Rotated logfile...\n"); fclose($loghandle); } } function getclientip() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) return $_SERVER['HTTP_CLIENT_IP']; elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) return $_SERVER['HTTP_X_FORWARDED_FOR']; elseif(!empty($_SERVER['HTTP_X_FORWARDED'])) return $_SERVER['HTTP_X_FORWARDED']; elseif(!empty($_SERVER['HTTP_FORWARDED_FOR'])) return $_SERVER['HTTP_FORWARDED_FOR']; elseif(!empty($_SERVER['HTTP_FORWARDED'])) return $_SERVER['HTTP_FORWARDED']; elseif(!empty($_SERVER['REMOTE_ADDR'])) return $_SERVER['REMOTE_ADDR']; else return false; } if(($last_access = $mysqlcon->query("SELECT `last_access`,`count_access` FROM `$dbname`.`config`")) === false) { $err_msg .= print_r($mysqlcon->errorInfo(), true); } $last_access = $last_access->fetchAll(); if(($last_access[0]['last_access'] + 1) >= time()) { $again = $last_access[0]['last_access'] + 2 - time(); $err_msg = sprintf($lang['errlogin2'],$again); $err_lvl = 3; } elseif ($last_access[0]['count_access'] >= 10) { enter_logfile($logpath,$timezone,3,sprintf($lang['brute'], getclientip())); $err_msg = $lang['errlogin3']; $err_lvl = 3; $bantime = time() + 299; if($mysqlcon->exec("UPDATE `$dbname`.`config` SET `last_access`='$bantime',`count_access`='0'") === false) { } } elseif (isset($_POST['username']) && $_POST['username'] == $webuser && password_verify($_POST['password'], $webpass)) { $_SESSION[$rspathhex.'username'] = $webuser; $_SESSION[$rspathhex.'password'] = $webpass; $_SESSION[$rspathhex.'clientip'] = getclientip(); $_SESSION[$rspathhex.'newversion'] = $newversion; $_SESSION[$rspathhex.'csrf_token'] = bin2hex(openssl_random_pseudo_bytes(32)); enter_logfile($logpath,$timezone,6,sprintf($lang['brute2'], getclientip())); if($mysqlcon->exec("UPDATE `$dbname`.`config` SET `count_access`='0'") === false) { } header("Location: //".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\')."/bot.php"); exit; } elseif(isset($_POST['username'])) { $nowtime = time(); enter_logfile($logpath,$timezone,5,sprintf($lang['brute1'], getclientip(), $_POST['username'])); if($mysqlcon->exec("UPDATE `$dbname`.`config` SET `last_access`='$nowtime',`count_access`=`count_access` + 1") === false) { } $err_msg = $lang['errlogin']; $err_lvl = 3; } if(isset($_SESSION[$rspathhex.'username']) && $_SESSION[$rspathhex.'username'] == $webuser && $_SESSION[$rspathhex.'password'] == $webpass) { header("Location: //".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\')."/bot.php"); exit; } require_once('nav.php'); ?>