diff --git a/private/.gitignore b/private/.gitignore new file mode 100644 index 0000000..810869a --- /dev/null +++ b/private/.gitignore @@ -0,0 +1,7 @@ +config.php +dbconfig.conf +settings.txt +tmp/cache/* +tmp/config/* +tmp/templates/* + diff --git a/public/.gitignore b/public/.gitignore new file mode 100644 index 0000000..03c88fd --- /dev/null +++ b/public/.gitignore @@ -0,0 +1 @@ +.htaccess diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..7d04df5 --- /dev/null +++ b/public/index.php @@ -0,0 +1,37 @@ +template_dir = '../source/templates'; + $smarty->compile_dir = '../private/tmp/templates'; + $smarty->cache_dir = '../private/tmp/cache'; + $smarty->config_dir = '../private/config'; + $smarty->register_modifier('formatDuration', array('MediaListing_Main', 'formatDuration')); + $smarty->register_modifier('formatFilesize', array('MediaListing_Main', 'formatFilesize')); + $smarty->assign('version', '0.1'); + $smarty->assign('base_uri', $main->baseUri()); + + $request = new MediaListing_RequestParser(isset($_GET['l']) ? $_GET['l'] : ''); + $page = new MediaListing_Page($smarty, $request); + if ($page->evaluate( + array( + 'smarty' => $smarty, + 'request' => $request, + ) + )) { + $smarty->display('index.tpl'); + } + +} catch (Sihnon_Exception $e) { + die("Uncaught " . get_class($e) . ": " . $e->getMessage()); +} + +?> \ No newline at end of file diff --git a/public/styles/normal.css b/public/styles/normal.css new file mode 100644 index 0000000..89dafec --- /dev/null +++ b/public/styles/normal.css @@ -0,0 +1,118 @@ +body { + margin: 0em; + padding: 0em; + background: #a7a09a; + font-family: verdana, helvetica, sans-serif; +} + +a { + color: gray; +} + +label { + margin-left: 1em; + margin-right: 1em; +} + +#container { + width: 75%; + min-width: 75em; + margin: auto; +} + +#banner { + margin: 0em; + padding: 0em; + background: #eeeeee; +} + +#banner h1 { + padding: 0.5em; +} + +#navigation { + background: #eeeeee; + margin-top: 0em; + margin-bottom: 1em; + padding: 0.2em; +} + +#navigation ul { + margin: 0em; + padding: 0em 5em;; + list-style: none; +} + +#navigation li { + margin: 1em; + padding: 0em; + display: inline; +} + +#page-container { + margin: 0em; + padding: 0em; +} + +#sidebar { + float: left; + width: 20em; + margin-bottom: 1em; + + background: #eeeeee; +} + +#page { + margin-left: 21em; + margin-bottom: 1em; + padding: 0.5em; + + background: #eeeeee; +} + +#footer { + clear: both; + padding: 2em; + font-size: smaller; + font-style: italic; + + background: #eeeeee; + color: #333333; + +} + +#errors { + background: peachpuff; + color: darkred; + margin: 1em; +} + +#messages { + background: lightcyan; + color: darkblue; + margin: 1em; +} + +.default { + background: beige; + color: darkgray; + font-style: italic; +} + +.icon { + height: 16px; + width: 16px; +} + +form#setup-rips input[type="text"] { + width: 30em; +} + +#quantizer-slider { + width: 20em; +} + +select.rip-streams { + width: 20em; +} + diff --git a/source/lib/MediaListing/Directory.class.php b/source/lib/MediaListing/Directory.class.php new file mode 100644 index 0000000..b6f27a1 --- /dev/null +++ b/source/lib/MediaListing/Directory.class.php @@ -0,0 +1,60 @@ +parent = $parent; + + if ($scan) { + $this->scan(); + } + } + + protected function scan() { + try { + $iterator = new MediaListing_Utility_VisibleFilesIterator(new DirectoryIterator($this->path)); + foreach ($iterator as /** @var SplFileInfo */ $source) { + $filename = $source->getPathname(); + $basename = basename($filename); + $this->files["{$basename}"] = MediaListing_FileObject::create($filename, $this, false); + } + } catch (Exception $e) { + echo $e->getMessage(); + } + + uasort($this->files, function($a, $b) { + return ($a->type() == $b->type()) ? strcasecmp($a->basename(), $b->basename()) : ($a->type() < $b->type()); + } + ); + } + + public function parent() { + return $this->parent; + } + + public function files() { + return $this->files; + } + + public function file($basename) { + if ( ! key_exists($basename, $this->files)) { + throw new MediaListing_Exception_FileNotFound($basename); + } + + $subdir = $this->files["{$basename}"]; + $subdir->scan(); + + return $subdir; + } + +} + +?> \ No newline at end of file diff --git a/source/lib/MediaListing/Exceptions.class.php b/source/lib/MediaListing/Exceptions.class.php new file mode 100644 index 0000000..002f40c --- /dev/null +++ b/source/lib/MediaListing/Exceptions.class.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/source/lib/MediaListing/File.class.php b/source/lib/MediaListing/File.class.php new file mode 100644 index 0000000..8991552 --- /dev/null +++ b/source/lib/MediaListing/File.class.php @@ -0,0 +1,23 @@ +size = filesize($this->path); + } + + public function size() { + return $this->size; + } + +} + +?> \ No newline at end of file diff --git a/source/lib/MediaListing/FileObject.class.php b/source/lib/MediaListing/FileObject.class.php new file mode 100644 index 0000000..d3a1059 --- /dev/null +++ b/source/lib/MediaListing/FileObject.class.php @@ -0,0 +1,56 @@ +type = $type; + $this->path = $path; + $this->basename = basename($path); + } + + public function isFile() { + return $this->type == self::TYPE_File; + } + + public function isDirectory() { + return $this->type == self::TYPE_Directory; + } + + public function type() { + return $this->type; + } + + public function path() { + return $this->path; + } + + public function basename() { + return $this->basename; + } + +} + +?> \ No newline at end of file diff --git a/source/lib/MediaListing/Source.class.php b/source/lib/MediaListing/Source.class.php new file mode 100644 index 0000000..5bfdf1d --- /dev/null +++ b/source/lib/MediaListing/Source.class.php @@ -0,0 +1,36 @@ +name = $name; + $this->path = $path; + + if ($scan) { + $this->scan(); + } + } + + protected function scan() { + $this->root = MediaListing_FileObject::create($this->path); + } + + public function name() { + return $this->name; + } + + public function path() { + return $this->path(); + } + + public function root() { + return $this->root; + } + +} + +?> \ No newline at end of file diff --git a/source/lib/MediaListing/Utility/VideoFilesIterator.class.php b/source/lib/MediaListing/Utility/VideoFilesIterator.class.php new file mode 100644 index 0000000..b41d838 --- /dev/null +++ b/source/lib/MediaListing/Utility/VideoFilesIterator.class.php @@ -0,0 +1,9 @@ +current()->getFilename()); + } +} + +?> \ No newline at end of file diff --git a/source/pages/errors/404.php b/source/pages/errors/404.php new file mode 100644 index 0000000..15c5adc --- /dev/null +++ b/source/pages/errors/404.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/source/pages/errors/unhandled-exception.php b/source/pages/errors/unhandled-exception.php new file mode 100644 index 0000000..f2820a6 --- /dev/null +++ b/source/pages/errors/unhandled-exception.php @@ -0,0 +1,10 @@ +config(); + +$this->smarty->assign('display_exceptions', $config->get('debug.display_exceptions')); +$this->smarty->assign('exception', $exception); +$this->smarty->assign('exception_type', get_class($exception)); + +?> \ No newline at end of file diff --git a/source/pages/home.php b/source/pages/home.php new file mode 100644 index 0000000..003b4f8 --- /dev/null +++ b/source/pages/home.php @@ -0,0 +1,15 @@ +config(); +$source_paths = $config->get('sources'); +$sources = array(); + +foreach ($source_paths as $source_path) { + list($name, $path) = explode(':', $source_path); + + $sources[] = new MediaListing_Source($name, $path, false); +} + +$smarty->assign('sources', $sources); + +?> \ No newline at end of file diff --git a/source/pages/list.php b/source/pages/list.php new file mode 100644 index 0000000..bf47b0f --- /dev/null +++ b/source/pages/list.php @@ -0,0 +1,40 @@ +config(); +$source_paths = $config->get('sources'); +$sources = array(); + +foreach ($source_paths as $source_path) { + list($name, $path) = explode(':', $source_path); + + $sources[$name] = new MediaListing_Source($name, $path); +} + +$source_name = $request->get('source'); +$source = $sources[$source_name]; +$source_path = $request->getRemainder('source', true); +$directory = $sources[$source_name]->root(); +foreach ($source_path as $subdir) { + $directory = $directory->file($subdir); +} + +$path = implode('/', $source_path); +if ($path) { + $path .= '/'; +} + +$parent_source_path = $source_path; +array_pop($parent_source_path); +$parent_path = implode('/', $parent_source_path); +if ($parent_path) { + $parent_path .= '/'; +} + +$smarty->assign('parent', $directory->parent()); +$smarty->assign('parent_path', $parent_path); +$smarty->assign('source', $source); +$smarty->assign('path', $path); +$smarty->assign('root', $directory); +$smarty->assign('files', $directory->files()); + +?> \ No newline at end of file diff --git a/source/templates/errors/404.tpl b/source/templates/errors/404.tpl new file mode 100644 index 0000000..7b44ec3 --- /dev/null +++ b/source/templates/errors/404.tpl @@ -0,0 +1 @@ +Error 404 \ No newline at end of file diff --git a/source/templates/errors/unhandled-exception.tpl b/source/templates/errors/unhandled-exception.tpl new file mode 100644 index 0000000..58ce7f6 --- /dev/null +++ b/source/templates/errors/unhandled-exception.tpl @@ -0,0 +1,46 @@ +
+ There was a problem trying to complete the requested action. Please try again and if the problem persists, let us know. +
+ +{if $display_exceptions} ++ An unhandled exception was caught during the page template processing. The full details are shown below: +
+| Exception | +{$exception_type} | +
|---|---|
| File | +{$exception->getFile()} | +
| Line | +{$exception->getLine()} | +
| Message | +{$exception->getMessage()} | +
| Stack Trace | +{$exception->getTrace()|print_r} |
+
+ Note: Exception details should not be displayed on production systems.
+ Disable the debug.show_exceptions
+ setting to omit the exception details from this page.
+
| Filename | +Size | +|
|---|---|---|
| ../ Parent Directory | +- | +|
| {$file->basename()} | + {else} +{$file->basename()} | + {/if} +{if $file->isFile()} + {$file->size()|formatFilesize} + {else} + - + {/if} + | +