1
0
Fork 0

Random and Latest are better if they continue to display their url so they can be bookmarked or refreshed.

This commit is contained in:
Andrew Tomaka 2011-11-07 22:16:31 -05:00
parent b9bce9cbe5
commit 131766e798
2 changed files with 8 additions and 2 deletions

View file

@ -42,6 +42,8 @@ $route['default_controller'] = "upload";
$route['404_override'] = ''; $route['404_override'] = '';
$route['[0-9]+'] = 'view/specific/$1'; $route['[0-9]+'] = 'view/specific/$1';
$route['random'] = 'view/specific';
$route['latest'] = 'view/specific';
/* End of file routes.php */ /* End of file routes.php */

View file

@ -18,8 +18,12 @@ class View extends CI_Controller {
$id = $this->uri->segment($this->uri->total_segments()); $id = $this->uri->segment($this->uri->total_segments());
$total_uploads = $this->fileupload->count_uploads(); $total_uploads = $this->fileupload->count_uploads();
if($id == false || !is_numeric($id) || $id < 0 || $id > $total_uploads) { if($id == 'latest') {
exit('bad id'); $id = $total_uploads;
} elseif($id == 'random') {
$id = rand(1,$total_uploads);
} elseif($id == false || !is_numeric($id) || $id < 0 || $id > $total_uploads) {
exit('bad id' . $id);
} }
$upload = $this->fileupload->get_upload($id); $upload = $this->fileupload->get_upload($id);