Ejemplo n.º 1
0
                            <div class="span8">
                                <div class="progress progress-striped active" id="load">
                                    <div class="bar" style="width: 100%;"></div>
                                </div>
                            </div>
                            <div class="span2"></div>
                        </div>

                        <div class="row-fluid" id="home_view_posts">
                            <ul class="thumbnails">
                                <?php 
//                                ($cat_data as $detail)
$count = 1;
foreach ($cat_data as $detail) {
    $user = useritemsquery::create()->filterByitemid($detail['item_id'])->findOne()->getuserid();
    $user = userprofilequery::create()->filterByuserid($user)->findOne();
    $thumb = $detail['field_value'];
    $obj = json_decode($thumb);
    ?>
                                    <li class="span3 <?php 
    echo $count == 1 ? 'first' : '';
    ?>
">
                                        <div class="thumbnail">
                                            <img data-src="holder.js/a" src="http://webdekeyif.com/uploads/<?php 
    echo $obj->thumbnail;
    ?>
" alt="<?php 
    echo $detail['item_name'];
    ?>
"
Ejemplo n.º 2
0
 /**
  * Function get login with the Facebook
  * and save the session of the logged in user
  */
 public function fbLogin()
 {
     //load the models
     $this->load->model(array('users', 'userprofile', 'userprofilequery', 'usersquery'));
     //get the Facebook appId and app secret from facebook.php which located in config directory for the creating the object for Facebook class
     $facebook = new Facebook(array('appId' => $this->config->item('appID'), 'secret' => $this->config->item('appSecret'), 'access_token' => $this->config->item('appID') . '|' . $this->config->item('appSecret')));
     $user = $facebook->getUser();
     // Get the facebook user id
     if ($user) {
         try {
             $userData = $facebook->api('/me');
             //Get the facebook user profile data
             $auth = $this->encrypt->encode(strrev(random_string('unique', 16)) . '_' . strrev(now()));
             //Set the values of the user
             $checkUser = $this->userprofilequery->filterByemail($userData['email'])->findOne();
             if (empty($checkUser)) {
                 $data['fb_user_data'] = base64_encode(json_encode($userData));
                 //set the rules for the form validation
                 $this->form_validation->set_rules('username', $this->lang->line('username'), 'trim|required|min_length[6]|xss_clean|callback_check_whitespaces|callback_check_user');
                 $this->form_validation->set_rules('password', $this->lang->line('password'), 'trim|required|min_length[6]|max_length[32]');
                 $this->form_validation->set_rules('confirm_password', $this->lang->line('confirm_password'), 'trim|required|matches[password]');
                 //Form validation
                 if ($this->form_validation->run() == FALSE) {
                     $this->stencil->title($this->lang->line('create_account'));
                     $this->stencil->paint('user/fblogin');
                 } else {
                     $post = $this->input->post();
                     $auth = $this->encrypt->encode(strrev(random_string('unique', 16)) . '_' . strrev(now()));
                     //save the user detail
                     $user = new users();
                     $user->setusername($post['username']);
                     $user->setpassword($this->encrypt->encode($post['password']));
                     $user->setusertype('0');
                     $user->setstatus('0');
                     $user->setauthtoken($auth);
                     $user->save();
                     //User profile data
                     $userprofile = new userprofile();
                     $userprofile->setuserid($user->getid());
                     $userprofile->setfirstname($userData['first_name']);
                     $userprofile->setlastname($userData['last_name']);
                     $userprofile->setemail($userData['email']);
                     $userprofile->setdob($userData['birthday']);
                     $userprofile->setregisteron(now());
                     $userprofile->setlastlogin(now());
                     $userprofile->setlastip($_SERVER['SERVER_ADDR']);
                     $userprofile->save();
                     //send the verification mail
                     $this->sendVerificationMail($userData['email'], $user->getusername(), $auth);
                     //redirect to thanks page
                     $this->thanks($userData['email']);
                 }
             } else {
                 $profile = userprofilequery::create()->filterByemail($userData['email'])->findOne();
                 $users = usersquery::create()->filterByPrimaryKey($profile->getuserid())->findOne();
                 //Set the session data
                 $data['username'] = $users->getusername();
                 $data['user_id'] = $profile->getuserid();
                 $data['auth'] = $users->getauthtoken();
                 $data['valid'] = $users->getstatus();
                 $data['first_name'] = $profile->getfirstname();
                 $data['last_name'] = $profile->getlastname();
                 $data['email'] = $profile->getemail();
                 $data['last_login'] = $profile->getlastlogin();
                 $data['ip'] = $_SERVER['SERVER_ADDR'];
                 $data['is_logged_in'] = TRUE;
                 //Set the session of the user
                 $this->session->set_userdata($data);
                 $this->session->set_flashdata('info', '<div class="alert alert-info top_buffer">Hi ' . $this->users->getUsername() . '! you have logged in successfully.</div>');
                 redirect('user/dashboard', 'refresh');
             }
         } catch (FacebookApiException $e) {
             error_log($e);
         }
     }
 }