Skip to content
This repository was archived by the owner on Apr 16, 2025. It is now read-only.

Commit 50230f3

Browse files
committed
refactor: add classes
Pretty much everything is in a class now.. Keeps thing organised (I hope).
1 parent 268e40e commit 50230f3

File tree

4 files changed

+270
-223
lines changed

4 files changed

+270
-223
lines changed

index.php

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
require_once("utils/minifier.php");
2626
require_once("utils/config.php");
2727
require_once("utils/params.php");
28+
29+
$config = Config::getConfig();
30+
$parser = ParamParser::getParser();
2831
?>
2932

3033
<html>
@@ -60,7 +63,7 @@
6063
<link type="text/css" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700">
6164
<?php
6265
// Print the CSS stuff for the webapp. This will either print the minfied version or, links to the CSS filees
63-
printCss($debug);
66+
Minifier::printCss($config->debug);
6467
?>
6568

6669
<script src="js/jquery-3.2.1.min.js"></script>
@@ -73,29 +76,29 @@
7376
///////////////////////////////////////////////////////////////////////////
7477
// PLEASE CHNAGE THE VAUES INSIDE THE CONFIG FILE
7578
///////////////////////////////////////////////////////////////////////////
76-
var _MAP_tileURL = "<?php echo $mapTileUrl; ?>";
77-
var _MAP_iconURL = "<?php echo $mapIconUrl; ?>";
79+
var _MAP_tileURL = "<?php echo $config->mapTileUrl; ?>";
80+
var _MAP_iconURL = "<?php echo $config->mapIconUrl; ?>";
7881

7982
// Set if to show Atlas map (WARNING: REQUIRES "atlas" TILE DIRECTORY)
80-
var _MAP_atlasMap = <?php echo $atlasEnabled; ?>;
83+
var _MAP_atlasMap = <?php echo $config->atlasEnabled; ?>;
8184

8285
// Set if to show Satellite map (WARNING: REQUIRES "satellite" TILE DIRECTORY)
83-
var _MAP_satelliteMap = <?php echo $satelliteEnabled; ?>;
86+
var _MAP_satelliteMap = <?php echo $config->satelliteEnabled; ?>;
8487

8588
// Set if to show Road map (WARNING: REQUIRES "road" TILE DIRECTORY)
86-
var _MAP_roadMap = <?php echo $roadEnabled; ?>;
89+
var _MAP_roadMap = <?php echo $config->roadEnabled; ?>;
8790

8891
// Set if to show UV Invert map (WARNING: REQUIRES "uv-invert" TILE DIRECTORY)
89-
var _MAP_UVInvMap = <?php echo $uvInveredEnabled; ?>;
92+
var _MAP_UVInvMap = <?php echo $config->uvInveredEnabled; ?>;
9093

9194
// Set to the IP of the GTA server running "live_map" and change the port to the
9295
// number that is set
93-
var _SETTINGS_socketUrl = "<?php echo $socketUrl ?>";
96+
var _SETTINGS_socketUrl = "<?php echo $config->socketUrl() ?>";
9497

9598
// Set to false if you don't want to show the player's identifiers (this may be their IP)
96-
var _SETTINGS_showIdentifiers = <?php echo $showIdentifiers; ?>;
99+
var _SETTINGS_showIdentifiers = <?php echo $config->showIdentifiers; ?>;
97100

98-
var _SETTINGS_blipUrl = "<?php echo $blipUrl; ?>";
101+
var _SETTINGS_blipUrl = "<?php echo $config->blipUrl(); ?>";
99102

100103
// Do not remove unless you know what you're doing (and you have a google api key)
101104
// Hack from https://stackoverflow.com/questions/38148097/google-maps-api-without-key/38809129#38809129
@@ -127,7 +130,7 @@
127130
</script>
128131

129132
<?php
130-
printFirstJs($debug);
133+
Minifier::printFirstJs($config->debug);
131134
?>
132135

133136
</head>
@@ -199,8 +202,8 @@
199202
</div>
200203

201204
<?php
202-
printLastJs($debug);
203-
printJsForParams();
205+
Minifier::printLastJs($config->debug);
206+
$parser->printJsForParams();
204207
?>
205208

206209
</body>

utils/config.php

Lines changed: 86 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -17,66 +17,92 @@
1717
// along with this program in the file "LICENSE". If not, see <http://www.gnu.org/licenses/>.
1818
// ************************************************************************** //
1919

20-
/*
21-
This is the config for the webapp.
22-
Please change the values to make it work.
23-
24-
DO NOT CHANGE ANY VARIABLE THAT SAYS NOT TO CHANGE.
25-
*/
26-
27-
// Set to false to enable the miinified versions of JS and CSS files
28-
// that should speed up content delivery on production websites
29-
$debug = false;
30-
31-
// Set to the IP of your FiveM server (public address).
32-
$fivemIP = "127.0.0.1";
33-
34-
// Set to the port your FiveM server is using (needs to be reachable from the internet)
35-
$fivemPort = "30120";
36-
37-
// Set to the port that you set in the "socket_port" convar.
38-
// If you haven't set this in the config, don't change this.
39-
$socketPort = "30121";
40-
41-
// Set to the name of the "live_map" resourcee that is added to the FiveM server.
42-
// Note: If you change the folder name on the GTA server you NEED to change this
43-
$liveMapName = "live_map";
44-
45-
// These will be injected into the JS code to configure how the map works
46-
47-
// The directory that contains the folders for the map tiles. Can be relative or, full URL..
48-
// Make sure it has the trailing slash
49-
$mapTileUrl = "images/map/";
50-
51-
// The directory that contains the folders for the map icons. Can be relative or a URL.
52-
// Make sure it has the trailing slash.
53-
$mapIconUrl = "images/icons/";
54-
55-
// Controls whether the atlas map is enabled or not
56-
// (WARNING: REQUIRES "atlas" TILE DIRECTORY INSIDE "mapTileUrl")
57-
$atlasEnabled = true;
58-
// Controls whether the satellite map is enabled or not
59-
// (WARNING: REQUIRES "satellite" TILE DIRECTORY INSIDE "mapTileUrl")
60-
$satelliteEnabled = true;
61-
// Controls whether the road map is enabled or not
62-
// (WARNING: REQUIRES "road" TILE DIRECTORY INSIDE "mapTileUrl")
63-
$roadEnabled = true;
64-
// Controls whether the uv-invert map is enabled or not
65-
// (WARNING: REQUIRES "uv-invert" TILE DIRECTORY INSIDE "mapTileUrl"
66-
$uvInveredEnabled = true;
67-
68-
// Do you want to show the player's identifiers on the map?
69-
// Note: THIS MAY BE THE PLAYER'S IP ADDRESS
70-
$showIdentifiers = true;
71-
72-
// DO NOT CHANGE
73-
$gtaServer = "http://$fivemIP:$fivemPort/";
74-
// DO NOT CHANGE
75-
$socketUrl = "ws://$fivemIP:$socketPort/";
76-
77-
// Builds the url that we need to use in ajax requests to get the blips
78-
// DO NOT CHANGE
79-
$blipUrl = $gtaServer . $liveMapName . "/blips.json";
20+
class Config{
21+
22+
/*
23+
This is the config for the webapp.
24+
Please change the values to make it work.
25+
26+
DO NOT CHANGE ANY VARIABLE THAT SAYS NOT TO CHANGE.
27+
*/
28+
29+
// Set to false to enable the miinified versions of JS and CSS files
30+
// that should speed up content delivery on production websites
31+
public $debug = false;
32+
33+
// Set to the IP of your FiveM server (public address).
34+
public $fivemIP = "127.0.0.1";
35+
36+
// Set to the port your FiveM server is using (needs to be reachable from the internet)
37+
public $fivemPort = "30120";
38+
39+
// Set to the port that you set in the "socket_port" convar.
40+
// If you haven't set this in the config, don't change this.
41+
public $socketPort = "30121";
42+
43+
// Set to the name of the "live_map" resourcee that is added to the FiveM server.
44+
// Note: If you change the folder name on the GTA server you NEED to change this
45+
public $liveMapName = "live_map";
46+
47+
// These will be injected into the JS code to configure how the map works
48+
49+
// The directory that contains the folders for the map tiles. Can be relative or, full URL..
50+
// Make sure it has the trailing slash
51+
public $mapTileUrl = "images/map/";
52+
53+
// The directory that contains the folders for the map icons. Can be relative or a URL.
54+
// Make sure it has the trailing slash.
55+
public $mapIconUrl = "images/icons/";
56+
57+
// Controls whether the atlas map is enabled or not
58+
// (WARNING: REQUIRES "atlas" TILE DIRECTORY INSIDE "mapTileUrl")
59+
public $atlasEnabled = true;
60+
// Controls whether the satellite map is enabled or not
61+
// (WARNING: REQUIRES "satellite" TILE DIRECTORY INSIDE "mapTileUrl")
62+
public $satelliteEnabled = true;
63+
// Controls whether the road map is enabled or not
64+
// (WARNING: REQUIRES "road" TILE DIRECTORY INSIDE "mapTileUrl")
65+
public $roadEnabled = true;
66+
// Controls whether the uv-invert map is enabled or not
67+
// (WARNING: REQUIRES "uv-invert" TILE DIRECTORY INSIDE "mapTileUrl"
68+
public $uvInveredEnabled = true;
69+
70+
// Do you want to show the player's identifiers on the map?
71+
// Note: THIS MAY BE THE PLAYER'S IP ADDRESS
72+
public $showIdentifiers = true;
73+
74+
public function gtaServer(){
75+
return "http://$this->fivemIP:$this->fivemPort/";
76+
}
77+
78+
public function socketUrl(){
79+
return "ws://$this->fivemIP:$this->socketPort/";
80+
}
81+
82+
public function blipUrl(){
83+
return $this->gtaServer() . $this->liveMapName . "/blips.json";
84+
}
85+
86+
/*
87+
// DO NOT CHANGE
88+
public $gtaServer = "http://$this->fivemIP:$this->fivemPort/";
89+
// DO NOT CHANGE
90+
public $socketUrl = "ws://$this->fivemIP:$this->socketPort/";
91+
92+
// Builds the url that we need to use in ajax requests to get the blips
93+
// DO NOT CHANGE
94+
public $blipUrl = $this->gtaServer . $this->liveMapName . "/blips.json";
95+
*/
96+
97+
private static $instance = NULL;
98+
99+
public static function getConfig(){
100+
if (is_null(self::$instance)){
101+
self::$instance = new self();
102+
}
103+
return self::$instance;
104+
}
105+
}
80106

81107

82108
?>

0 commit comments

Comments
 (0)