Advertisement
Guest User

Untitled

a guest
Jan 15th, 2011
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.66 KB | None | 0 0
  1. <?php
  2.  
  3. class Profil extends Controller {
  4.    
  5.     function index()
  6.     {
  7.         $this->load->model('profil_model');
  8.         $data['query'] = $this->profil_model->vis_profil($this->uri->segment(3));
  9.        
  10.         $data['content'] = 'profil_view';
  11.         $this->load->view('includes/template', $data);
  12.     }
  13.    
  14.     function indstillinger()
  15.     {
  16.         $this->access->protect();
  17.         $this->load->model('profil_model');
  18.         $data['query'] = $this->profil_model->indstillinger($this->uri->segment(3));
  19.        
  20.         $data['content'] = 'indstillinger_view';
  21.         $this->load->view('includes/template', $data);
  22.     }
  23.    
  24.     function ret_profil()
  25.     {
  26.         $username = $this->session->userdata('username');
  27.        
  28.         if ($this->_submit_ret() === false) {
  29.             redirect('profil/indstillinger/'.$username);
  30.             return;
  31.             //echo "validate fejl";
  32.         } else {
  33.        
  34.             $new_member_insert_data = array(
  35.                 'firstname'         => $this->input->post('fornavn'),
  36.                 'lastname'  => $this->input->post('efternavn'),
  37.                 'email'         => $this->input->post('email'),
  38.                 'hood'          => $this->input->post('hood'),
  39.                 'city'          => $this->input->post('city'),
  40.                 'freetext'      => $this->input->post('fritekst'),
  41.                 'sex'           => $this->input->post('kon'),
  42.                 'birthday'      => $this->input->post('birthday'),
  43.                 'birthmonth'    => $this->input->post('birthmonth'),
  44.                 'birthyear'     => $this->input->post('birthyear')
  45.             );
  46.            
  47.             $this->db->where('username', $username);
  48.             $this->db->update('users', $new_member_insert_data);
  49.            
  50.            
  51.             //echo $birthDay;
  52.             //echo $alder;
  53.             //$data['besked'] = 'Din information blev opdateret';
  54.             //$data['content'] = 'indstillinger_view';
  55.             //$this->load->view('includes/template', $data);
  56.             redirect('profil/indstillinger/'.$username);
  57.         }
  58.     }
  59.    
  60.     // function til ret profil indstillinger
  61.     function _submit_ret()
  62.     {
  63.         $this->form_validation->set_rules('fornavn', 'Fornavn',
  64.             'required|alpha_numeric|min_length[2]|max_length[30]');
  65.            
  66.         $this->form_validation->set_rules('efternavn', 'Efternavn',
  67.             'required|alpha_numeric|min_length[2]|max_length[70]');
  68.            
  69.         $this->form_validation->set_rules('hood', 'Hood',
  70.             'required|numeric|min_length[4]|max_length[4]');
  71.            
  72.         $this->form_validation->set_rules('city', 'City',
  73.             'required|min_length[4]|max_length[90]');
  74.  
  75.         $this->form_validation->set_rules('email', 'E-mail',
  76.             'required|valid_email');
  77.            
  78.         return $this->form_validation->run();
  79.     }
  80.    
  81.     ## Billed upload til ret profil ##
  82.    
  83.     function uploadImg()
  84.     {
  85.         $this->load->model('profil_model');
  86.        
  87.         if($this->input->post('upload'))
  88.         {
  89.             $this->profil_model->addProfileImg();
  90.             redirect('profil/indstillinger/'.$this->session->userdata('username'));
  91.         }
  92.        
  93.        
  94.     }
  95.    
  96.     function editPassword()
  97.     {
  98.         $this->form_validation->set_rules('password', 'Password',
  99.             'required|min_length[6]');
  100.        
  101.         $this->form_validation->set_rules('newPassword', 'newPassword',
  102.             'required|min_length[6]');
  103.            
  104.         $this->form_validation->set_rules('matchPassword', 'matchPassword',
  105.             'required|min_length[6]|matches[newPassword]');
  106.        
  107.        
  108.         if($this->form_validation->run() === false)
  109.         {
  110.             //$this->load->view('indstillinger_view');
  111.             //echo "vis fejl";
  112.         } else {
  113.             $username = $this->input->post('username');
  114.             $password = $this->input->post('password');
  115.             $this->load->model('profil_model');
  116.             $query = $this->profil_model->passwordCheck($password, $username);
  117.            
  118.             if($query === true)
  119.             {
  120.                 //henter det nye password
  121.                 $newPassword = $this->input->post('newPassword');
  122.                 $this->db->update('password', $newPassword);
  123.                 $this->db->where('username', $username);
  124.             } else {
  125.                 echo "forkert";
  126.             }
  127.            
  128.         }
  129.     }
  130.    
  131.    
  132.     function logud()
  133.     {
  134.         $this->session->sess_destroy();
  135.         redirect('/');
  136.        
  137.     }
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement