setTimeZone(new DateTimeZone($timezone))->format("Y-m-d H:i:s.u ").$loglevel.$logtext."\n"; $loghandle = fopen($file, 'a'); fwrite($loghandle, $input); if (filesize($file) > 5242880) { 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"); fwrite($loghandle, DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''))->setTimeZone(new DateTimeZone($timezone))->format("Y-m-d H:i:s.u ")." NOTICE Restart Bot to continue with new log file...\n"); fclose($loghandle); $file2 = "$file.old"; if (file_exists($file2)) unlink($file2); rename($file, $file2); if (substr(php_uname(), 0, 7) == "Windows") { exec("del /F ".substr(__DIR__,0,-12).'logs/pid'); $WshShell = new COM("WScript.Shell"); $oExec = $WshShell->Run("cmd /C ".$phpcommand." ".substr(__DIR__,0,-12)."worker.php start", 0, false); exit; } else { exec("rm -f ".substr(__DIR__,0,-12).'logs/pid'); exec($phpcommand." ".substr(__DIR__,0,-12)."worker.php start"); exit; } } } 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 (isset($_POST['resetpw']) && $_POST['csrf_token'] != $_SESSION[$rspathhex.'csrf_token']) { echo $lang['errcsrf']; rem_session_ts3($rspathhex); exit; } 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 (isset($_POST['resetpw']) && ($adminuuid==NULL || count($adminuuid) == 0)) { $err_msg = $lang['wirtpw1']; $err_lvl=3; } elseif (isset($_POST['resetpw']) && $_POST['csrf_token'] == $_SESSION[$rspathhex.'csrf_token']) { $nowtime = time(); if($mysqlcon->exec("UPDATE `$dbname`.`config` SET `last_access`='$nowtime',`count_access`=`count_access` + 1") === false) { } require_once(substr(__DIR__,0,-12).'libs/ts3_lib/TeamSpeak3.php'); try { $ts3 = TeamSpeak3::factory("serverquery://".$ts['user'].":".$ts['pass']."@".$ts['host'].":".$ts['query']."/?server_port=".$ts['voice']."&blocking=0"); try { usleep($slowmode); $ts3->selfUpdate(array('client_nickname' => "Ranksystem - Reset Password")); } catch (Exception $e) { } usleep($slowmode); $allclients = $ts3->clientList(); $adminuuid_flipped = array_flip($adminuuid); foreach ($allclients as $client) { if(in_array($client['client_unique_identifier'] , $adminuuid)) { $uuid = $client['client_unique_identifier']; $checkuuid = 1; if($client['connection_client_ip'] == getclientip()) { $checkip = 1; } } } if (!isset($checkuuid)) { $err_msg = $lang['wirtpw2']; $err_lvl = 3; } elseif (!isset($checkip)) { $err_msg = $lang['wirtpw3']; $err_lvl = 3; } else { usleep($slowmode); $pwd = substr(str_shuffle("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#*+;:-_~?=%&$§!()"),0,12); $webpass = password_hash($pwd, PASSWORD_DEFAULT); if($mysqlcon->exec("UPDATE `$dbname`.`config` SET `webpass`='$webpass',`last_access`='0'") === false) { $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; } else { try { $ts3->clientGetByUid($uuid)->message(sprintf($lang['wirtpw4'], $webuser, $pwd, '[URL=http'.(!empty($_SERVER['HTTPS'])?"s":"").'://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['SCRIPT_NAME']).']','[/URL]')); $err_msg = sprintf($lang['wirtpw5'],'',''); $err_lvl = 1; enter_logfile($logpath,$timezone,3,sprintf($lang['wirtpw6'],getclientip())); } catch (Exception $e) { $err_msg = 'TeamSpeak '.$lang['error'].$e->getCode().': '.$e->getMessage(); $err_lvl = 3; } } } } catch (Exception $e) { $err_msg = 'TeamSpeak '.$lang['error'].$e->getCode().': '.$e->getMessage(); $err_lvl = 3; } } $_SESSION[$rspathhex.'csrf_token'] = bin2hex(openssl_random_pseudo_bytes(32)); require_once('nav.php'); ?>