From 131766e798116ba5fd254e983e45703b3a25c815 Mon Sep 17 00:00:00 2001 From: atomaka Date: Mon, 7 Nov 2011 22:16:31 -0500 Subject: [PATCH] Random and Latest are better if they continue to display their url so they can be bookmarked or refreshed. --- application/config/routes.php | 2 ++ application/controllers/view.php | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/application/config/routes.php b/application/config/routes.php index 38c9417..d32f16f 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -42,6 +42,8 @@ $route['default_controller'] = "upload"; $route['404_override'] = ''; $route['[0-9]+'] = 'view/specific/$1'; +$route['random'] = 'view/specific'; +$route['latest'] = 'view/specific'; /* End of file routes.php */ diff --git a/application/controllers/view.php b/application/controllers/view.php index 29f3d0c..9253a5d 100644 --- a/application/controllers/view.php +++ b/application/controllers/view.php @@ -18,8 +18,12 @@ class View extends CI_Controller { $id = $this->uri->segment($this->uri->total_segments()); $total_uploads = $this->fileupload->count_uploads(); - if($id == false || !is_numeric($id) || $id < 0 || $id > $total_uploads) { - exit('bad id'); + if($id == 'latest') { + $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);