[eluser]Patu[/eluser]
<!-- Controller -->
<?php
class File extends Controller {
function File()
{
parent::Controller();
$this->load->library('ion_auth');
$this->load->model('file_model');
$this->load->library('form_validation');
$this->load->library('session');
$this->load->database();
$this->load->helper('url');
}
function index()
{
if (!$this->ion_auth->is_admin())
{
//redirect them to the home page because they must be an administrator to view this
redirect($this->config->item('base_url'));
}
//set the flash data error message if there is one
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
//list the file
$this->data['files'] = $this->file_model->getall();
$this->data['categories'] = $this->file_model->getallcategories();
//print_r($this->data);exit;
$this->load->view('files/view_file', $this->data);
}
function create_file()
{
.....
}
function edit_file($id=null,$type =null)
{
.....
}
function delete_file()
{
......
}
function cat_name_check($str)
{
......
}
public function upload($secid=0)
{
if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin())
{
redirect('auth');
}
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'avi|mp3|wmv|jpg|jpeg|png';//$this->startup->group_config->files_types;
$config['max_size'] = 500;//(1024 * intval($this->startup->group_config->upload_size_limit));
$this->load->library('upload', $config);
if($this->upload->do_upload()) {
$data = array('upload_data' => $this->upload->data());
$this->file_model->upload($data,$secid);
echo "WIN";
} else {
echo "FAIL";
}
}
public function getLinks($secid)
{
$data['link'] = $this->file_model->getLinks($secid);
$this->load->view('file/links', $data);
}
}?>