3 declare(strict_types=1);
9 public const SEC =
".sec";
17 public function __construct(array $white_list, array $black_list)
19 $this->white_list[] =
'';
20 $this->white_list = array_unique($white_list);
42 $pi = pathinfo($filename);
44 $basename = str_replace(
".",
"", $pi[
"basename"]);
45 if (trim($basename) ==
"") {
46 throw new \RuntimeException(
"Invalid upload filename.");
48 $basename .= self::SEC;
49 if ($pi[
"dirname"] !=
"" && ($pi[
"dirname"] !=
"." || substr($filename, 0, 2) ==
"./")) {
50 $filename = $pi[
"dirname"] .
"/" . $basename;
52 $filename = $basename;
62 $pi = pathinfo($filename);
64 return in_array(strtolower($pi[
"extension"]), $this->white_list)
65 && !in_array(strtolower($pi[
"extension"]), $this->black_list);
hasValidFileName(string $filename)
getValidFileName(string $filename)
__construct(array $white_list, array $black_list)