Advertisement
Guest User

dfsdf

a guest
Mar 1st, 2012
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.08 KB | None | 0 0
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. class Site extends CI_Controller {
  4.  
  5.    
  6.     function index() {
  7.         //enable profiler
  8.         //$this->output->enable_profiler(TRUE);
  9.        
  10.         $data = array();
  11.         $this->load->model('Site_model');
  12.  
  13.         if($this->input->post('upload')) {
  14.        
  15.             $uploaded_image_ids = $this->Site_model->do_upload();
  16.             $uploaded_image_id = $this->Site_model->get_last();
  17.  
  18.             $values = array(
  19.             'image_id' => implode(",",$uploaded_image_ids),
  20.             'session_id' => $this->session->userdata('session_id')
  21.             );
  22.             $this->session->set_userdata('edit', $values);
  23.  
  24.             echo implode(",",$uploaded_image_ids) . '?links';
  25.             //show uploaded image
  26.             //redirect(implode(",",$uploaded_image_ids) . '?links');
  27.  
  28.         }  
  29.    
  30.         if($query = $this->Site_model->get_images()) {
  31.             $data['records'] = $query;
  32.         }
  33.        
  34.         $this->load->view('home', $data);  
  35.     } //index
  36.  
  37.  
  38.     function view() {
  39.         //converts query string into global GET array variable
  40.         parse_str($_SERVER['QUERY_STRING'],$_GET);
  41.  
  42.         //enable profiler
  43.         //$this->output->enable_profiler(TRUE);
  44.        
  45.         $id = $this->uri->segment(1);
  46.         $id_array = explode(",", $id);
  47.  
  48.         $this->load->model('Site_model');
  49.  
  50.         foreach ($id_array as $key => $id) {
  51.             // use alphaID function
  52.             $id = alphaID($id ,true);
  53.             if($query = $this->Site_model->get_image($id)) {
  54.  
  55.                 $data['records_array'][$key] = $query;
  56.  
  57.                 // added second array for comparison in view
  58.                 $data['id_array'][$key] = $id;
  59.  
  60.                 // increment view count
  61.                 //$this->Site_model->increment_views($id); //now in the image
  62.  
  63.                 if($key == 0) { //if the first id in url
  64.                     //setup gallery array, right side
  65.                     if($query = $this->Site_model->get_images_except($id)) {
  66.                         $data['gallery_array'] = $query;
  67.                     }
  68.                 } // if
  69.  
  70.             } else {
  71.                 show_404();
  72.             } // if
  73.  
  74.         } //for
  75.  
  76.  
  77.         $data['userdata'] = $this->session->userdata;
  78. print_r($data['userdata']);
  79.         $this->load->helper('my_img');       
  80.         $this->load->view('view', $data);
  81.     }
  82.  
  83.  
  84.    
  85. } //file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement