Advertisement
Guest User

Untitled

a guest
Jan 15th, 2011
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.49 KB | None | 0 0
  1. <?php
  2.  
  3. class Profil_model extends Model {
  4.    
  5.     var $gallery_path;
  6.     var $gallery_path_url;
  7.    
  8.     ## Til billed upload ##
  9.     function Profil_model() {
  10.         parent::Model();
  11.        
  12.         $this->gallery_path = realpath(APPPATH . '../images/users');
  13.     }
  14.    
  15.    
  16.     function vis_profil($id)
  17.     {
  18.         $query = $this->db->where('username', $id);
  19.         $query = $this->db->get('users');
  20.        
  21.         if($query->num_rows() == 1)
  22.         {
  23.             $result = $query->row();
  24.         } else {
  25.             $result = "Der skete en fejl, kontakt en administrator";
  26.         }
  27.         return $result;
  28.     }
  29.    
  30.     function indstillinger($id)
  31.     {
  32.         $query = $this->db->where('username', $id);
  33.         $query = $this->db->get('users');
  34.        
  35.         if($query->num_rows() == 1)
  36.         {
  37.             $result = $query->row();
  38.         } else {
  39.             $result = "Der skete en fejl, kontakt en administrator";
  40.         }
  41.         return $result;
  42.     }
  43.  
  44.     function ret_profil($id)
  45.     {
  46.         $this->db->select('firstname', 'lastname', 'hood', 'city', 'email', 'freetext', 'birthday', 'birthmonth', 'birthyear', 'profile_picture');
  47.         $this->db->where('username', $id);
  48.         $query = $this->db->get('users');
  49.        
  50.         if($query->num_rows() == 1)
  51.         {
  52.             return $query->row();
  53.         } else {
  54.             return false;
  55.         }
  56.     }
  57.    
  58.     ## Upload profil billed ##
  59.     function addProfileImg()
  60.     {
  61.         $config = array(
  62.             'allowed_types' => 'jpg|jpeg|gif|png',
  63.             'upload_path' => $this->gallery_path,
  64.             'max_size' => 2000,
  65.             'encrypt_name' => true
  66.         );
  67.        
  68.         $this->load->library('upload', $config);
  69.         $this->upload->do_upload();
  70.         $image_data = $this->upload->data();
  71.        
  72.         $config = array(
  73.             'source_image'    => $image_data['full_path'],
  74.             'new_image'       => $this->gallery_path . '/thumbs',
  75.             'maintain_ration' => true,
  76.             'width'           => 200,
  77.             'height'          => 200,
  78.             'encrypt_name'    => true,
  79.             'max_size'        => 2000
  80.         );
  81.        
  82.         $this->load->library('image_lib', $config);
  83.         $this->image_lib->resize();
  84.        
  85.        
  86.         # Ret profil billed navn #
  87.        
  88.         //$data = $this->upload->data('file_name');
  89.         //print_r($data);
  90.  
  91.         $file_array = $this->upload->data('file_name');
  92.         $profilBilledNavn['profile_picture'] = $file_array['file_name'];
  93.        
  94.         $this->db->where('username', $this->input->post('username'));
  95.         $this->db->update('users', $profilBilledNavn);
  96.        
  97.        
  98.     }
  99.    
  100.     ## Ret password ##
  101.     function passwordCheck($password, $username) {
  102.        
  103.         $this->db->select('password');
  104.         $this->db->where('username', $username);
  105.         $query = $this->db->get('users');
  106.        
  107.         if($query->num_rows() === true)
  108.         {
  109.             return true;
  110.         } else {
  111.             return false;
  112.         }
  113.        
  114.        
  115.     }
  116.    
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement