Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
- class Site extends CI_Controller {
- function index() {
- //enable profiler
- //$this->output->enable_profiler(TRUE);
- $data = array();
- $this->load->model('Site_model');
- if($this->input->post('upload')) {
- $uploaded_image_ids = $this->Site_model->do_upload();
- $uploaded_image_id = $this->Site_model->get_last();
- $values = array(
- 'image_id' => implode(",",$uploaded_image_ids),
- 'session_id' => $this->session->userdata('session_id')
- );
- $this->session->set_userdata('edit', $values);
- echo implode(",",$uploaded_image_ids) . '?links';
- //show uploaded image
- //redirect(implode(",",$uploaded_image_ids) . '?links');
- }
- if($query = $this->Site_model->get_images()) {
- $data['records'] = $query;
- }
- $this->load->view('home', $data);
- } //index
- function view() {
- //converts query string into global GET array variable
- parse_str($_SERVER['QUERY_STRING'],$_GET);
- //enable profiler
- //$this->output->enable_profiler(TRUE);
- $id = $this->uri->segment(1);
- $id_array = explode(",", $id);
- $this->load->model('Site_model');
- foreach ($id_array as $key => $id) {
- // use alphaID function
- $id = alphaID($id ,true);
- if($query = $this->Site_model->get_image($id)) {
- $data['records_array'][$key] = $query;
- // added second array for comparison in view
- $data['id_array'][$key] = $id;
- // increment view count
- //$this->Site_model->increment_views($id); //now in the image
- if($key == 0) { //if the first id in url
- //setup gallery array, right side
- if($query = $this->Site_model->get_images_except($id)) {
- $data['gallery_array'] = $query;
- }
- } // if
- } else {
- show_404();
- } // if
- } //for
- $data['userdata'] = $this->session->userdata;
- print_r($data['userdata']);
- $this->load->helper('my_img');
- $this->load->view('view', $data);
- }
- } //file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement