1
0
Fork 0
NCA-Screens/application/controllers/view.php

39 lines
1 KiB
PHP
Raw Normal View History

2011-11-05 14:55:02 -04:00
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class View extends CI_Controller {
public function index() {
}
public function specific() {
2011-11-05 14:55:02 -04:00
$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);
$display_views = $upload->views;
2011-11-05 14:55:02 -04:00
$this->load->model('viewer');
if($this->viewer->add_viewer($_SERVER['REMOTE_ADDR'], $id)) {
$this->fileupload->add_view($id);
$display_views++;
}
$this->data['prev'] = $id - 1;
$this->data['next'] = ($id + 1 <= $total_uploads) ? $id + 1 : 0;
$this->data['image'] = $id . $upload->extension;
$this->data['original'] = $upload->original_name;
$this->data['views'] = $display_views;
$this->data['created'] = $upload->created;
2011-11-05 14:55:02 -04:00
$this->template->load('template', 'view', $this->data);
2011-11-05 14:55:02 -04:00
}
}