function check_name($Name) { global $Keywords; $NameLC = strtolower($Name); foreach ($Keywords as &$Value) { if (strpos($NameLC, $Value) !== false) { forbidden_error($Name); } } if (preg_match('/INCOMPLETE~\\*/i', $Name)) { forbidden_error($Name); } /* * These characters are invalid in NTFS on Windows systems: * : ? / < > \ * | " * * TODO: Add "/" to the blacklist. Adding "/" to the blacklist causes problems with nested dirs, apparently. * * Only the following characters need to be escaped (see the link below): * \ - ^ ] * * http://www.php.net/manual/en/regexp.reference.character-classes.php */ $AllBlockedChars = ' : ? < > \\ * | " '; if (preg_match('/[\\:?<>*|"]/', $Name, $Matches)) { character_error($Matches[0], $AllBlockedChars); } }
function check_extensions($Type, $Name) { global $MusicExtensions, $ComicsExtensions, $BadExtensions; $extension = get_file_extension($Name); if ($Type == 'Music' || $Type == 'Audiobooks' || $Type == 'Comedy' || $Type == 'E-Books') { if (!isset($MusicExtensions[$extension])) { invalid_error($Name); } } elseif ($Type == 'Comics') { if (!isset($ComicsExtensions[$extension])) { invalid_error($Name); } } else { if (isset($BadExtensions[$extension])) { forbidden_error($Name); } } }