Random and Latest are better if they continue to display their url so they can be bookmarked or refreshed.
This commit is contained in:
parent
b9bce9cbe5
commit
131766e798
2 changed files with 8 additions and 2 deletions
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue