| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?
- require 'config.php';
- # Cleanup the provided series name
- # This does NOT provide comprehensively safe output,
- # it merely attempts to make names compatible with the filesystem and local convetions
- function cleanSeries($series) {
- # Clearly unreasonable characters
- $series = preg_replace('/[\0\n\r]/', ' ', $series);
- # Not allowed on our filesystem
- $series = preg_replace('/\s+[\/\:]\s+/', ' - ', $series);
- # General string cleanup
- $series = preg_replace('/\s+/', ' ', $series);
- # Ensure we don't go out-of-scope
- $series = basename($series);
- return $series;
- }
- # True if the input path is junk -- self-links, OS X noise, etc.
- function isJunk($path) {
- $path = basename($path);
-
- # Ignore certain fixed paths
- foreach (array('.', '..', '.DS_Store') as $value) {
- if ($path == $value) {
- return true;
- }
- }
-
- # Ignore ._ paths
- if (preg_match('/^\.\_/', $path)) {
- return true;
- }
-
- # Otherwise the path is good
- return false;
- }
- function sortTitle($title) {
- $title = displayTitle($title);
- $title = preg_replace('/^The\s+/i', '', $title);
- $title = preg_replace('/^A\s+/i', '', $title);
- return $title;
- }
- function displayTitle($title) {
- $title = preg_replace('/\xEF\x80\xA9$/', '.', $title);
- $title = preg_replace('/\xEF\x80\xA5/', '?', $title);
- return $title;
- }
- ?>
|