Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Profil_model extends Model {
- var $gallery_path;
- var $gallery_path_url;
- ## Til billed upload ##
- function Profil_model() {
- parent::Model();
- $this->gallery_path = realpath(APPPATH . '../images/users');
- }
- function vis_profil($id)
- {
- $query = $this->db->where('username', $id);
- $query = $this->db->get('users');
- if($query->num_rows() == 1)
- {
- $result = $query->row();
- } else {
- $result = "Der skete en fejl, kontakt en administrator";
- }
- return $result;
- }
- function indstillinger($id)
- {
- $query = $this->db->where('username', $id);
- $query = $this->db->get('users');
- if($query->num_rows() == 1)
- {
- $result = $query->row();
- } else {
- $result = "Der skete en fejl, kontakt en administrator";
- }
- return $result;
- }
- function ret_profil($id)
- {
- $this->db->select('firstname', 'lastname', 'hood', 'city', 'email', 'freetext', 'birthday', 'birthmonth', 'birthyear', 'profile_picture');
- $this->db->where('username', $id);
- $query = $this->db->get('users');
- if($query->num_rows() == 1)
- {
- return $query->row();
- } else {
- return false;
- }
- }
- ## Upload profil billed ##
- function addProfileImg()
- {
- $config = array(
- 'allowed_types' => 'jpg|jpeg|gif|png',
- 'upload_path' => $this->gallery_path,
- 'max_size' => 2000,
- 'encrypt_name' => true
- );
- $this->load->library('upload', $config);
- $this->upload->do_upload();
- $image_data = $this->upload->data();
- $config = array(
- 'source_image' => $image_data['full_path'],
- 'new_image' => $this->gallery_path . '/thumbs',
- 'maintain_ration' => true,
- 'width' => 200,
- 'height' => 200,
- 'encrypt_name' => true,
- 'max_size' => 2000
- );
- $this->load->library('image_lib', $config);
- $this->image_lib->resize();
- # Ret profil billed navn #
- //$data = $this->upload->data('file_name');
- //print_r($data);
- $file_array = $this->upload->data('file_name');
- $profilBilledNavn['profile_picture'] = $file_array['file_name'];
- $this->db->where('username', $this->input->post('username'));
- $this->db->update('users', $profilBilledNavn);
- }
- ## Ret password ##
- function passwordCheck($password, $username) {
- $this->db->select('password');
- $this->db->where('username', $username);
- $query = $this->db->get('users');
- if($query->num_rows() === true)
- {
- return true;
- } else {
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement