Advertisement
Guest User

dfsdfds

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