\ * | " $AllBlockedChars = ' : ? / < > \ * | " '; // Only the following characters need to be escaped: // \ - ^ ] if (preg_match('/[\/\\:?<>*|"]*/', $Name, $Matches)) { character_error($Matches[0], $AllBlockedChars); } } function check_extensions($Type, $Name) { global $MusicExtensions, $ComicsExtensions; if ($Type == 'Music' || $Type == 'Audiobooks' || $Type == 'Comedy' || $Type == 'E-Books') { if (!isset($MusicExtensions[get_file_extension($Name)])) { invalid_error($Name); } } elseif ($Type == 'Comics') { if (!isset($ComicsExtensions[get_file_extension($Name)])) { invalid_error($Name); } } } function get_file_extension($FileName) { return strtolower(substr(strrchr($FileName, '.'), 1)); } function invalid_error($Name) { global $Err; $Err = 'The torrent contained one or more invalid files (' . display_str($Name) . ')'; } function forbidden_error($Name) { global $Err; $Err = 'The torrent contained one or more forbidden files (' . display_str($Name) . ')'; } function character_error($Character, $AllBlockedChars) { global $Err; $Err = "One or more of the files in the torrent has a name that contains the forbidden character '$Character'. Please rename the files as necessary and recreate the torrent.\n\nNote: The complete list of characters that are disallowed are shown below:\n\n\t$AllBlockedChars"; }