/* This function reads all the items in a directory and returns an array with this information */ function dirList ($directory) { $results = array(); $handler = opendir($directory); while ($file = readdir($handler)) { if ($file != '.' && $file != '..') { if (is_file($directory . "/" . $file) && ((returnExtension($file) == "jpg") || (returnExtension($file) == "png"))) { array_push($results, $file); } else if (is_dir($directory . "/" . $file) && ($file[0] != ".")) { array_push($results, $file); } } } closedir($handler); sort($results); reset($results); return $results; } /* This function looks at what the GET request is and decides if someone is trying to exploit the script or not */ function authoriseRequest($request) { $illegal = false; // First have a look if the string contains a .. characters $pos = strpos($request, ".."); if ($pos === 0 || $pos > 0) //strpos can return boolean false or non boolen 0 which evaulates to false { $illegal = true; } if ($request[0] == "/") { $illegal = true; } if ($illegal) { echo "
This request has been denied to prevent potential abuse of FsPHPGallery (providing listing of arbitrary directories under the file system). If you are attempting to set up FsPHPGallery for the first time, please do not set \$imagePath (in config.php) to a value starting with \"/\" or containing \"..\" -- it is advisable to use symbolic links to get around this.
"; echo "