Skip to content

Commit

Permalink
feat: access log config setting and a real get-post-cookie logger
Browse files Browse the repository at this point in the history
This is a very naive and primitive logger of user requests to the game.
To be used on systems where access to webserver's log data is not
available (especially if the webserver doesn't store POST data as well).
  • Loading branch information
martinambrus committed Oct 28, 2017
1 parent 133a512 commit f5c3e02
Show file tree
Hide file tree
Showing 44 changed files with 291 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
Deny from all
</Files>

<Files "*.log">
Order Allow,Deny
Deny from all
</Files>

<Files "installed">
Order Allow,Deny
Deny from all
Expand Down
3 changes: 3 additions & 0 deletions a2b.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
## ##
#################################################################################

use App\Utils\AccessLogger;

include("GameEngine/Village.php");
AccessLogger::logRequest();

$start = $generator->pageLoadTimeStart();
if(isset($_GET['newdid'])) {
Expand Down
3 changes: 3 additions & 0 deletions a2b2.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
## ##
#################################################################################

use App\Utils\AccessLogger;

include("GameEngine/Village.php");
AccessLogger::logRequest();

$amount = $_SESSION['amount'];
$start = $generator->pageLoadTimeStart();
if(isset($_GET['newdid'])) {
Expand Down
4 changes: 4 additions & 0 deletions activate.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
## ##
#################################################################################

use App\Utils\AccessLogger;

include('GameEngine/Account.php');
AccessLogger::logRequest();

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
Expand Down
23 changes: 23 additions & 0 deletions ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,29 @@
## ##
#################################################################################

// even with autoloader created, we can't use it here yet, as it's not been created
// ... so, let's see where it is and include it
$autoloader_found = false;
// go max 5 levels up - we don't have folders that go deeper than that
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
$autoloader_found = true;
include_once $autoprefix.'autoloader.php';
break;
}
}

if (!$autoloader_found) {
die('Could not find autoloading class.');
}

// we need config to determine whether to log access or not
include_once($autoprefix.'GameEngine/config.php');

use App\Utils\AccessLogger;
AccessLogger::logRequest();

switch($_GET['f']) {
case 'k7':
header('Content-Type: application/json');
Expand Down
4 changes: 4 additions & 0 deletions allianz.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?php
//fix by ronix
use App\Utils\AccessLogger;

if(isset($_GET['aid']) && !is_numeric($_GET['aid'])) die('Hacking Attemp');
include ("GameEngine/Village.php");
include ("GameEngine/Chat.php");
AccessLogger::logRequest();

$start = $generator->pageLoadTimeStart();
$alliance->procAlliance($_GET);
if(isset($_GET['newdid'])) {
Expand Down
3 changes: 3 additions & 0 deletions anleitung.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
## ##
#################################################################################

use App\Utils\AccessLogger;

include("GameEngine/config.php");
include("GameEngine/Database.php");
include("GameEngine/Lang/".LANG.".php");
AccessLogger::logRequest();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
Expand Down
4 changes: 4 additions & 0 deletions anmelden.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@
## ##
#################################################################################

use App\Utils\AccessLogger;

if(!file_exists('var/installed') && @opendir('install')) {
header("Location: install/");
exit;
}

include('GameEngine/Account.php');
AccessLogger::logRequest();

$invited=(isset($_GET['uid'])) ? filter_var($_GET['uid'], FILTER_SANITIZE_NUMBER_INT):$form->getError('invt');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Expand Down
5 changes: 4 additions & 1 deletion banned.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
## ##
#################################################################################

use App\Utils\AccessLogger;

include("GameEngine/Village.php");
$start = $generator->pageLoadTimeStart();
AccessLogger::logRequest();

$start = $generator->pageLoadTimeStart();
if($session->access == BANNED){
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Expand Down
4 changes: 4 additions & 0 deletions berichte.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
## ##
#################################################################################

use App\Utils\AccessLogger;

include("GameEngine/Village.php");
AccessLogger::logRequest();

$start = $generator->pageLoadTimeStart();
$message->noticeType($_GET);
$message->procNotice($_POST);
Expand Down
4 changes: 4 additions & 0 deletions build.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
## ##
#################################################################################

use App\Utils\AccessLogger;

ob_start();
include_once("GameEngine/Village.php");
include_once("GameEngine/Units.php");
AccessLogger::logRequest();

if(isset($_GET['newdid'])) {
$_SESSION['wid'] = $_GET['newdid'];
header("Location: ".$_SERVER['PHP_SELF'].(isset($_GET['id'])?'?id='.$_GET['id']:(isset($_GET['gid'])?'?gid='.$_GET['gid']:'')));
Expand Down
4 changes: 4 additions & 0 deletions celebration.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
## Copyright: TravianX (c) 2010-2011. All rights reserved. ##
## ##
#################################################################################
use App\Utils\AccessLogger;

include("GameEngine/Village.php");
AccessLogger::logRequest();

if(isset($_GET['newdid'])){
$_SESSION['wid'] = $_GET['newdid'];
header("Location: ".$_SERVER['PHP_SELF']);
Expand Down
2 changes: 2 additions & 0 deletions create_account.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


use App\Entity\User;
use App\Utils\AccessLogger;

global $autoprefix;

Expand All @@ -34,6 +35,7 @@

include_once ($autoprefix."GameEngine/Session.php");
include_once ($autoprefix."GameEngine/config.php");
AccessLogger::logRequest();


/**
Expand Down
3 changes: 3 additions & 0 deletions crop_finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
| Copyright: TravianX Project All rights reserved |
\*-------------------------------------------------------*/

use App\Utils\AccessLogger;

include ("GameEngine/Village.php");
AccessLogger::logRequest();

if($session->goldclub == 0) {
header("Location: plus.php?id=3");
Expand Down
4 changes: 4 additions & 0 deletions dorf1.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
## Copyright: TravianX (c) 2010-2011. All rights reserved. ##
## ##
#################################################################################
use App\Utils\AccessLogger;

include("GameEngine/Village.php");
AccessLogger::logRequest();

$start = $generator->pageLoadTimeStart();
if(isset($_GET['ok'])){
$database->updateUserField($session->uid,'ok','0','1'); $_SESSION['ok'] = '0';
Expand Down
4 changes: 4 additions & 0 deletions dorf2.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
## Copyright: TravianX (c) 2010-2011. All rights reserved. ##
## ##
#################################################################################
use App\Utils\AccessLogger;

include("GameEngine/Village.php");
AccessLogger::logRequest();

$start = $generator->pageLoadTimeStart();
if(isset($_GET['newdid'])) {
$_SESSION['wid'] = $_GET['newdid'];
Expand Down
4 changes: 4 additions & 0 deletions dorf3.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
#################################################################################


use App\Utils\AccessLogger;

include("GameEngine/Village.php");
AccessLogger::logRequest();

$start = $generator->pageLoadTimeStart();
if(isset($_GET['newdid'])) {
$_SESSION['wid'] = $_GET['newdid'];
Expand Down
3 changes: 3 additions & 0 deletions impressum.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
## ##
#################################################################################

use App\Utils\AccessLogger;

include("GameEngine/config.php");
include("GameEngine/Database.php");
include("GameEngine/Lang/".LANG.".php");
AccessLogger::logRequest();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
Expand Down
9 changes: 7 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
use App\Utils\AccessLogger;

#################################################################################
## ##
## -= YOU MUST NOT REMOVE OR CHANGE THIS NOTICE =- ##
Expand Down Expand Up @@ -44,8 +46,11 @@
{
die('Security: Please activate security class!');
}
include ("GameEngine/Database.php");
include ("GameEngine/Lang/".LANG.".php");

include_once "GameEngine/Database.php";
include_once "GameEngine/Lang/".LANG.".php";

AccessLogger::logRequest();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
Expand Down
4 changes: 4 additions & 0 deletions install/data/constant_format.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ define("MULTIHUNTER",8);
define("ADMIN",9);
define("COOKIE_EXPIRE", 60*60*24*7);
define("COOKIE_PATH", "/");
define("LOG_PAGE_ACCESS", false);
define("PAGE_ACCESS_LOG_DATE", true);
define("PAGE_ACCESS_LOG_IP", true);
define("PAGE_ACCESS_LOG_FILENAME", 'access.log'); // filename ONLY, no path!


////////////////////////////////////////////
Expand Down
4 changes: 4 additions & 0 deletions karte.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
## ##
#################################################################################

use App\Utils\AccessLogger;

if(isset($_GET['z']) && !is_numeric($_GET['z'])) die('Hacking Attempt');
include("GameEngine/Village.php");
AccessLogger::logRequest();

$start = $generator->pageLoadTimeStart();
if(isset($_GET['newdid'])) {
$_SESSION['wid'] = $_GET['newdid'];
Expand Down
6 changes: 5 additions & 1 deletion karte2.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
## Copyright: TravianX (c) 2010-2011. All rights reserved. ##
## ##
#################################################################################
use App\Utils\AccessLogger;

include("GameEngine/Village.php");
$building->procBuild($_GET);
AccessLogger::logRequest();

$building->procBuild($_GET);
if($session->plus){
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Expand Down
5 changes: 4 additions & 1 deletion login.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
## ##
#################################################################################

use App\Utils\AccessLogger;

if(!file_exists('var/installed') && @opendir('install')) {
header("Location: install/");
exit;
}

error_reporting(E_ALL);
include("GameEngine/Account.php");
AccessLogger::logRequest();

if(isset($_GET['del_cookie'])) {
setcookie("COOKUSR","",time()-3600*24,"/");
header("Location: login.php");
Expand Down
4 changes: 4 additions & 0 deletions logout.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
#################################################################################


use App\Utils\AccessLogger;

include("GameEngine/Account.php");
AccessLogger::logRequest();

$start = $generator->pageLoadTimeStart();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Expand Down
6 changes: 5 additions & 1 deletion massmessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
## ##
#################################################################################

use App\Utils\AccessLogger;

include_once("GameEngine/Account.php");
AccessLogger::logRequest();

$max_per_pass = 1000;

if (mysqli_num_rows(mysqli_query($GLOBALS['link'],"SELECT id FROM ".TB_PREFIX."users WHERE access = 9 AND id = ".(int) $session->uid)) != '1') die("Hacking attemp!");
Expand Down Expand Up @@ -189,7 +193,7 @@ function toggleDisplay(e){
<?php echo MASS_UNITS; ?>
<a href="javascript:toggleDisplay('message_smilies')"><?php echo MASS_SHOWHIDE; ?></a>

<div id="smilll" id="message_smilies" style="background:none repeat scroll 0 0 #EFEFEF;border:1px solid #71D000;left:20px;margin-top:5px;max-width:660px;padding:5px;position:relative;display: none;">
<div id="message_smilies" style="background:none repeat scroll 0 0 #EFEFEF;border:1px solid #71D000;left:20px;margin-top:5px;max-width:660px;padding:5px;position:relative;display: none;">
<?php echo MASS_READ; ?>
<a href="#" onclick="smilie('*u1*')"><img src="img/x.gif" class="uu1" /></a>
<a href="#" onclick="smilie('*u2*')"><img src="img/x.gif" class="uu2" /></a>
Expand Down
6 changes: 5 additions & 1 deletion nachrichten.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@
#################################################################################


use App\Utils\AccessLogger;

include("GameEngine/Village.php");
AccessLogger::logRequest();

$start = $generator->pageLoadTimeStart();
$message->procMessage($_POST);
if($_GET['t'] == 1){
if(isset($_GET['t']) && $_GET['t'] == 1){
$automation->isWinner();
}
if(isset($_GET['newdid'])) {
Expand Down
4 changes: 4 additions & 0 deletions packages.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
## ##
#################################################################################

use App\Utils\AccessLogger;

include("GameEngine/Village.php");
AccessLogger::logRequest();

$start = $generator->pageLoadTimeStart();
$id = $_GET['id'];
if($session->access != BANNED){
Expand Down
Loading

0 comments on commit f5c3e02

Please sign in to comment.