mirror of
https://github.com/LX3JL/xlxd.git
synced 2025-12-06 07:42:01 +01:00
Fix hard-coded path issues that stopped flags from showing - simplified
This commit is contained in:
parent
e21fa2e404
commit
50078541eb
|
|
@ -149,28 +149,13 @@ class xReflector {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function SetFlagFile($Flagfile) {
|
public function SetFlagFile($Flagfile) {
|
||||||
// Prevent path traversal - get the real path
|
// Security: Only allow country.csv from the pgs directory
|
||||||
|
$expectedFile = dirname(__FILE__) . '/country.csv';
|
||||||
$realPath = realpath($Flagfile);
|
$realPath = realpath($Flagfile);
|
||||||
|
|
||||||
// If realpath fails, the file doesn't exist
|
// Must resolve to the exact expected file
|
||||||
if ($realPath === false) {
|
if ($realPath !== $expectedFile) {
|
||||||
error_log("Flag file does not exist: " . $Flagfile);
|
error_log("Flag file must be country.csv in pgs directory. Expected: " . $expectedFile . ", Got: " . $realPath);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Security: Ensure it's the country.csv file we expect
|
|
||||||
if (basename($realPath) !== 'country.csv') {
|
|
||||||
error_log("Flag file must be country.csv, got: " . basename($realPath));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Security: Ensure the file is in the same directory as this class file or subdirectory
|
|
||||||
$thisDir = dirname(__FILE__); // Gets /path/to/pgs
|
|
||||||
$thisDirReal = realpath($thisDir);
|
|
||||||
|
|
||||||
// The flag file must be in the same directory as this class
|
|
||||||
if (dirname($realPath) !== $thisDirReal) {
|
|
||||||
error_log("Flag file must be in the same directory as class files. Expected: " . $thisDirReal . ", Got: " . dirname($realPath));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue