forked from Shadowss/TravianZ
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathajax.php
More file actions
106 lines (99 loc) · 3.95 KB
/
Copy pathajax.php
File metadata and controls
106 lines (99 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename : ajax.php ##
## Type : In Game Ajax File ##
## --------------------------------------------------------------------------- ##
## Developed by : Dzoki & Advocaite & Donnchadh ##
## Refactored by : Shadow ##
## Redesign by : Shadow ##
## --------------------------------------------------------------------------- ##
## Contact : cata7007@gmail.com ##
## Project : TravianZ ##
## URLs: : https://travianz.org ##
## GitHub : https://github.com/Shadowss/TravianZ ##
## --------------------------------------------------------------------------- ##
## License : TravianZ Project ##
## Copyright : TravianZ (c) 2010-2026. All rights reserved. ##
## --------------------------------------------------------------------------- ##
#################################################################################
// 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');
$x = preg_replace("/[^a-zA-Z0-9_-]/","",$_GET['x']);
$y = preg_replace("/[^a-zA-Z0-9_-]/","",$_GET['y']);
$xx = preg_replace("/[^a-zA-Z0-9_-]/","",$_GET['xx']);
$yy = preg_replace("/[^a-zA-Z0-9_-]/","",$_GET['yy']);
$howmany = $x - $xx;
if($howmany == 12 || $howmany == -12) {
include("Templates/Ajax/mapscroll2.tpl");
}
else {
include("Templates/Ajax/mapscroll.tpl");
}
break;
case 'qst':
if (isset($_GET['qact'])){
$qact=preg_replace("/[^a-zA-Z0-9_-]/","",$_GET['qact']);
}else {
$qact=null;
}
if (isset($_GET['qact2'])){
$qact2=preg_replace("/[^a-zA-Z0-9_-]/","",$_GET['qact2']);
}else {
$qact2=null;
}
if (isset($_GET['qact3'])){
$qact3=preg_replace("/[^a-zA-Z0-9_-]/","",$_GET['qact3']);
}else {
$qact3=null;
}
if (!isset($_SESSION)) {
session_start();
}
if (isset($_SESSION['qtyp']) && $_SESSION['qtyp']==37) {
include("Templates/Ajax/quest_core.tpl");
}else{
include("Templates/Ajax/quest_core25.tpl");
}
break;
// Rally-point attack marker (issue #245): persist the green/yellow/red tag
// a defender sets on an incoming attack. setMovementMarker() enforces that
// the targeted village belongs to the logged-in user.
case 'marker':
header('Content-Type: application/json');
if (!isset($_SESSION)) {
session_start();
}
include_once($autoprefix.'GameEngine/Database.php');
$uid = (int) ($_SESSION['id_user'] ?? 0);
if (!$uid) {
http_response_code(403);
echo json_encode(['ok' => 0]);
break;
}
$ok = $database->setMovementMarker($_POST['moveid'] ?? 0, $_POST['marker'] ?? 0, $uid);
echo json_encode(['ok' => $ok ? 1 : 0]);
break;
}
?>