Begin basic view functionality.
This commit is contained in:
parent
7f88eb83df
commit
3c5c19a712
2 changed files with 31 additions and 0 deletions
20
application/controllers/view.php
Normal file
20
application/controllers/view.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class View extends CI_Controller {
|
||||
public function index() {
|
||||
$this->load->model('fileupload');
|
||||
|
||||
$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');
|
||||
}
|
||||
|
||||
$upload = $this->fileupload->get_upload($id);
|
||||
|
||||
$this->load->model('viewer');
|
||||
|
||||
print_r($upload);
|
||||
}
|
||||
}
|
|
@ -15,6 +15,17 @@ class Fileupload extends CI_Model {
|
|||
|
||||
return $this->db->insert_id();
|
||||
}
|
||||
|
||||
function count_uploads() {
|
||||
return $this->db->count_all('uploads');
|
||||
}
|
||||
|
||||
function get_upload($id) {
|
||||
$this->db->select('extension, views, created')->from('uploads')->where('id',$id);
|
||||
$query = $this->db->get();
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in a new issue