Skip to content

Commit

Permalink
Updated PHP script dir references
Browse files Browse the repository at this point in the history
More efficient and readable this way.
Found while working with PHP script updates and paths were getting mixed in a refactoring.
Some various whitespace cleanup too.
  • Loading branch information
Pysis868 committed Feb 22, 2022
1 parent b292446 commit bcc4b5b
Show file tree
Hide file tree
Showing 30 changed files with 42 additions and 41 deletions.
2 changes: 1 addition & 1 deletion ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
}
$cmd = $_GET["command"];
$cmd = preg_replace("#[^a-zA-Z_]#","",$cmd);
$path = DIRNAME(__FILE__);
$path = __DIR__;
$cmdpath = "$path/ajax/$cmd.php";
if(!file_exists($cmdpath)) {
die(json_encode(array("success"=>false,"code"=>-1,"msg"=>"Invalid command!")));
Expand Down
16 changes: 8 additions & 8 deletions ajax/add_bulk_complete_marker.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$path = DIRNAME(__FILE__);
$path = __DIR__;
include_once("$path/../config.php");

begin();
Expand All @@ -25,11 +25,11 @@
, marker_id
, complete_date
, visible
) values ";
) values ";

// @TODO: Move to a Config in the DB?
$commitEvery = 10;

for ($i = 0; $i < count($markerList); $i++) {
$query = $query . "(" .$_POST['userId'] . ", " . $markerList[$i] . ", now(), 1)";
if ($i == count($markerList) - 1) {
Expand All @@ -38,23 +38,23 @@
$query = $query . ",";
} else {
$query = $query . " ON DUPLICATE KEY UPDATE user_id=user_id;";

$result = @$mysqli->query($query); // or die(mysql_error());
if ($result) {

} else {
echo json_encode(array("success"=>false, "msg"=>$mysqli->error()));
rollback();
exit(0);
}

if ($i != count($markerList) - 1) {
$query = "insert into " . $map_prefix . "user_completed_marker (
user_id
, marker_id
, complete_date
, visible
) values ";
) values ";
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ajax/add_complete_marker.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$path = DIRNAME(__FILE__);
$path = __DIR__;
include_once("$path/../config.php");

begin();
Expand Down
2 changes: 1 addition & 1 deletion ajax/add_marker.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$path = DIRNAME(__FILE__);
$path = __DIR__;
include_once("$path/../config.php");

begin();
Expand Down
2 changes: 1 addition & 1 deletion ajax/change_password.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$path = DIRNAME(__FILE__);
$path = __DIR__;
include("$path/../config.php");

begin();
Expand Down
2 changes: 1 addition & 1 deletion ajax/del_complete_marker.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$path = DIRNAME(__FILE__);
$path = __DIR__;
include_once("$path/../config.php");

begin();
Expand Down
2 changes: 1 addition & 1 deletion ajax/del_completed_marker_all.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$path = DIRNAME(__FILE__);
$path = __DIR__;
include_once("$path/../config.php");

begin();
Expand Down
2 changes: 1 addition & 1 deletion ajax/del_marker.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$path = DIRNAME(__FILE__);
$path = __DIR__;
include_once("$path/../config.php");

begin();
Expand Down
2 changes: 1 addition & 1 deletion ajax/get_categories.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$path = DIRNAME(__FILE__);
$path = __DIR__;
include("$path/../config.php");

$map = $_GET["game"];
Expand Down
2 changes: 1 addition & 1 deletion ajax/get_category_tree.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$path = DIRNAME(__FILE__);
$path = __DIR__;
include("$path/../config.php");

$map = $_GET["game"];
Expand Down
2 changes: 1 addition & 1 deletion ajax/get_changelog.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$path = DIRNAME(__FILE__);
$path = __DIR__;
include("$path/../config.php");

if(isset($_GET["sinceVersion"]))
Expand Down
9 changes: 5 additions & 4 deletions ajax/get_container.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php
$path = DIRNAME(__FILE__);

$path = __DIR__;
include("$path/../config.php");

$map = $_GET["game"];

$query = 'select id
, name
, short_name as shortName
Expand Down Expand Up @@ -41,7 +42,7 @@
print($mysqli->error);
return;
}

$res = array();
while($row = $result->fetch_assoc()) {
$res[] = $row;
Expand Down
2 changes: 1 addition & 1 deletion ajax/get_container_name.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$path = DIRNAME(__FILE__);
$path = __DIR__;
include("$path/../config.php");

$game = $_GET["game"];
Expand Down
2 changes: 1 addition & 1 deletion ajax/get_games.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$path = DIRNAME(__FILE__);
$path = __DIR__;
include("$path/../config.php");

$query = "select c.id
Expand Down
2 changes: 1 addition & 1 deletion ajax/get_map.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$path = DIRNAME(__FILE__);
$path = __DIR__;
include("$path/../config.php");

$map = $_GET["game"];
Expand Down
2 changes: 1 addition & 1 deletion ajax/get_markers.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
if (!isset($_GET['newMarkerId'])) {
$path = DIRNAME(__FILE__);
$path = __DIR__;
include_once("$path/../config.php");
}
/*
Expand Down
2 changes: 1 addition & 1 deletion ajax/get_user_completed_markers.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
if (!isset($_GET['newMarkerId'])) {
$path = DIRNAME(__FILE__);
$path = __DIR__;
include_once("$path/../config.php");
}

Expand Down
2 changes: 1 addition & 1 deletion ajax/get_user_info.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$path = DIRNAME(__FILE__);
$path = __DIR__;
include("$path/../config.php");

start_session("zmap");
Expand Down
2 changes: 1 addition & 1 deletion ajax/login.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$path = DIRNAME(__FILE__);
$path = __DIR__;
include("$path/../config.php");

begin();
Expand Down
2 changes: 1 addition & 1 deletion ajax/logout.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$path = DIRNAME(__FILE__);
$path = __DIR__;
include("$path/../config.php");

start_session("zmap");
Expand Down
2 changes: 1 addition & 1 deletion ajax/lost_password.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$path = DIRNAME(__FILE__);
$path = __DIR__;
include("$path/../config.php");

begin();
Expand Down
2 changes: 1 addition & 1 deletion ajax/search_markers.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
if (!isset($_GET['newMarkerId'])) {
$path = DIRNAME(__FILE__);
$path = __DIR__;
include("$path/../config.php");
}
/*
Expand Down
2 changes: 1 addition & 1 deletion ajax/update_user_version.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$path = DIRNAME(__FILE__);
$path = __DIR__;
include("$path/../config.php");

start_session("zmap");
Expand Down
2 changes: 1 addition & 1 deletion ajax/user_add.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$path = DIRNAME(__FILE__);
$path = __DIR__;
include("$path/../config.php");

begin();
Expand Down
2 changes: 1 addition & 1 deletion content/upload.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$path = DIRNAME(__FILE__);
$path = __DIR__;
include_once("$path/../config.php");

start_session("zmap");
Expand Down
2 changes: 1 addition & 1 deletion lib/minify.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
function includeMini() {
$path = DIRNAME(__FILE__);
$path = __DIR__;
include_once("$path/JSMin.php");
include_once("$path/CSSmin.php");
}
Expand Down
2 changes: 1 addition & 1 deletion lib/zmailer.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$path = DIRNAME(__FILE__);
$path = __DIR__;
include_once("$path/../config.php");

function prepareMailTransport() {
Expand Down
2 changes: 1 addition & 1 deletion res.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$path = DIRNAME(__FILE__);
$path=__DIR__;

if(!isset($_GET["type"])) {
print("A type must be provided! javascript or css.");
Expand Down
2 changes: 1 addition & 1 deletion sitemap/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php
$path = DIRNAME(__FILE__);
$path = __DIR__;
include_once("$path/../config.php");

$query = 'select c.short_name
Expand Down
4 changes: 2 additions & 2 deletions tests/res.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
$path = DIRNAME(__FILE__);
$path = __DIR__;

include_once("$path/../config.php");
if(!$enableTests) exit;

$path = DIRNAME(__FILE__);
$path = __DIR__;

include "$path/../lib/minify.php";

Expand Down

0 comments on commit bcc4b5b

Please sign in to comment.