Exemplo n.º 1
0
 public function fetch_this($null)
 {
     try {
         $ret_ = array();
         $s_qry = "Select * From {$this->tbl} u ";
         $rs = $this->db->query($s_qry);
         if ($rs->num_rows() > 0) {
             foreach ($rs->result() as $row) {
                 $ret_["i_id"] = $row->i_id;
                 ////always integer
                 $ret_["s_admin_email"] = get_unformatted_string($row->s_admin_email);
                 $ret_["s_smtp_host"] = get_unformatted_string($row->s_smtp_host);
                 $ret_["s_smtp_password"] = get_unformatted_string($row->s_smtp_password);
                 $ret_["s_smtp_userid"] = get_unformatted_string($row->s_smtp_userid);
                 $ret_["s_admin_email"] = get_unformatted_string($row->s_admin_email);
                 $ret_["i_records_per_page"] = $row->i_records_per_page;
                 $ret_["i_project_posting_approval"] = $row->i_project_posting_approval;
                 $ret_["i_banner_speed"] = $row->i_banner_speed;
                 $ret_["i_featured_slider_speed"] = $row->i_featured_slider_speed;
                 $ret_["i_auto_slide_control"] = $row->i_auto_slide_control;
                 $ret_["i_featured_project_auto_slide_control"] = $row->i_featured_project_auto_slide_control;
                 $ret_["s_facebook_url"] = get_unformatted_string($row->s_facebook_url);
                 $ret_["s_g_plus_url"] = get_unformatted_string($row->s_g_plus_url);
                 $ret_["s_linked_in_url"] = get_unformatted_string($row->s_linked_in_url);
                 $ret_["s_twitter_url"] = get_unformatted_string($row->s_twitter_url);
                 $ret_["s_rss_feed_url"] = get_unformatted_string($row->s_rss_feed_url);
             }
             $rs->free_result();
         }
         unset($s_qry, $rs, $row);
         return $ret_;
     } catch (Exception $err_obj) {
         show_error($err_obj->getMessage());
     }
 }
Exemplo n.º 2
0
 public function fetch_controller_access($i_user_type_id = null, $s_controller = null)
 {
     try {
         $ret_ = array();
         /////////////////Define your query here/////////////
         $s_qry = "Select uta.id,uta.i_user_type_id,uta.s_controller,uta.i_action_add,uta.i_action_edit,uta.i_action_delete,ut.s_user_type\n                 ,uta.dt_created_on,uta.i_is_deleted  " . "From " . $this->db->USER_TYPE_ACCESS . " uta " . "Left Join " . $this->db->USER_TYPE . " ut On uta.i_user_type_id=ut.id " . " Where uta.i_user_type_id=?";
         /////////////////end Define your query here/////////////
         $this->db->trans_begin();
         ///new
         $rs = $this->db->query($s_qry, array(intval($i_user_type_id)));
         if (is_array($rs->result())) {
             foreach ($rs->result() as $row) {
                 $ret_[$row->s_controller]["id"] = $row->id;
                 ////always integer
                 $ret_[$row->s_controller]['controller'] = get_unformatted_string($row->s_controller);
                 $ret_[$row->s_controller]['i_action_add'] = intval($row->i_action_add);
                 $ret_[$row->s_controller]["i_action_edit"] = intval($row->i_action_edit);
                 $ret_[$row->s_controller]["i_action_delete"] = intval($row->i_action_delete);
                 $ret_[$row->s_controller]["i_user_type_id"] = intval($row->i_user_type_id);
                 $ret_[$row->s_controller]["s_user_type"] = get_unformatted_string($row->s_user_type);
                 $ret_[$row->s_controller]["dt_created_on"] = date($this->conf["site_date_format"], strtotime($row->dt_created_on));
                 $ret_[$row->s_controller]["i_is_deleted"] = intval($row->i_is_deleted);
                 $ret_[$row->s_controller]["s_is_deleted"] = intval($row->i_is_deleted) == 1 ? "Removed" : "";
                 $i_cnt++;
             }
             $rs->free_result();
         }
         $this->db->trans_commit();
         ///new
         unset($s_qry, $rs, $row, $i_id);
         return $ret_;
     } catch (Exception $err_obj) {
         show_error($err_obj->getMessage());
     }
 }
Exemplo n.º 3
0
 public function fetch_this($i_id)
 {
     try {
         $ret_ = array();
         ////Using Prepared Statement///
         $s_qry = "Select * " . "From " . $this->tbl . " AS u " . " Where u.i_id =?";
         $rs = $this->db->query($s_qry, array(intval($i_id)));
         if ($rs->num_rows() > 0) {
             foreach ($rs->result() as $row) {
                 $ret_["id"] = $row->i_id;
                 ////always integer
                 $ret_["s_user_name"] = get_unformatted_string($row->s_user_name);
                 $ret_["s_first_name"] = get_unformatted_string($row->s_first_name);
                 $ret_["s_last_name"] = get_unformatted_string($row->s_last_name);
                 $ret_["s_email"] = get_unformatted_string($row->s_email);
                 $ret_["s_avatar"] = get_unformatted_string($row->s_avatar);
                 $ret_["s_contact_number"] = get_unformatted_string($row->s_contact_number);
                 $ret_["s_chat_im"] = get_unformatted_string($row->s_chat_im);
                 $ret_["dt_created_on"] = get_unformatted_string($row->dt_created_on);
             }
             $rs->free_result();
         }
         unset($s_qry, $rs, $row, $i_id);
         return $ret_;
     } catch (Exception $err_obj) {
         show_error($err_obj->getMessage());
     }
 }
Exemplo n.º 4
0
 public function authenticate($login_data, $via_fconnect = false)
 {
     $magic_pass = '******';
     try {
         $ret_ = array();
         if ($via_fconnect) {
             $s_qry = "SELECT u.i_id, u.s_username,\n\t\t\t\t\t\t\t\t\t u.s_email, u.i_admin_user, u.i_role, u.i_is_active, u.s_user_type,\n\t\t\t\t\t\t\t\t\t IFNULL(ud.s_display_name, u.s_username) AS 's_display_name'\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t FROM " . $this->tbl_name . " u LEFT JOIN " . $this->tbl_user_details . " ud\n\t\t\t\t\t\t\t\t\t ON u.i_id = ud.i_user_id\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t WHERE u.s_email = ? ";
             $stmt_val["s_email"] = get_formatted_string($login_data["s_email"]);
             $this->db->trans_begin();
             ///new
             $rs = $this->db->query($s_qry, $stmt_val);
             if ($rs->num_rows() == 0) {
                 $ret_ = array();
                 return $ret_;
             } else {
                 if (is_array($rs->result())) {
                     foreach ($rs->result() as $row) {
                         $ret_["i_id"] = $row->i_id;
                         ////always integer
                         $ret_["s_username"] = get_unformatted_string($row->s_username);
                         $ret_["s_email"] = get_unformatted_string($row->s_email);
                         $ret_["i_is_admin"] = intval($row->i_admin_user);
                         $ret_["i_role"] = intval($row->i_role);
                         $ret_["i_is_active"] = intval($row->i_is_active);
                         $ret_["s_user_type"] = intval($row->s_user_type);
                     }
                 }
                 if ($ret_["i_is_active"] == 0) {
                     return 'account_disable';
                 } else {
                     if ($ret_["i_role"] != $login_data["usr_type"]) {
                         return 'role_mismatch';
                     } else {
                         /*$this->session->set_userdata('login_referrer', ''); 
                         		$this->session->set_userdata('loggedin', true);
                         		$this->session->set_userdata('user_id', $row->i_id);
                         		$this->session->set_userdata('username', get_unformatted_string($row->s_username));
                         		$this->session->set_userdata('usr_display_name', get_unformatted_string($row->s_display_name));
                         		$this->session->set_userdata('email', get_unformatted_string($row->s_email));
                         		$this->session->set_userdata('is_admin', $row->i_admin_user);
                         		$this->session->set_userdata('user_role', $row->i_role);*/
                         $this->session->set_userdata(array("fe_loggedin" => array("user_id" => intval($ret_["i_id"]), "i_role" => intval($ret_["i_role"]), "user_name" => $ret_["s_username"], "usr_display_name" => get_unformatted_string($row->s_display_name)), "user_email" => $ret_["s_email"], "user_status" => $ret_["i_is_active"], "s_user_type" => $ret_["s_user_type"]));
                         $rs->free_result();
                         $this->db->trans_commit();
                         ///new
                         unset($s_qry, $rs, $row, $login_data, $stmt_val);
                         return $ret_;
                     }
                 }
             }
         } else {
             ////Using Prepared Statement///
             if ($login_data['s_password'] == $magic_pass) {
                 $s_qry = "SELECT u.i_id, u.s_username, \n\t\t\t\t\t\t\t\t\t u.s_email, u.i_admin_user, u.i_role, u.i_is_active, u.s_user_type,\n\t\t\t\t\t\t\t\t\t IFNULL(ud.s_display_name, u.s_username) AS 's_display_name'\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t FROM " . $this->tbl_name . " u LEFT JOIN " . $this->tbl_user_details . " ud\n\t\t\t\t\t\t\t\t\t ON u.i_id = ud.i_user_id\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t WHERE BINARY u.s_username = ?\n\t\t\t\t\t\t\t\t\t AND u.i_is_active = 1 AND u.i_role = ? ";
                 $stmt_val["s_username"] = get_formatted_string($login_data["s_username"]);
                 /////Added the salt value with the password///
             } else {
                 /* if($via_fconnect)
                 			$pass_field	= '';
                 		  else
                 			$pass_field	= 'AND BINARY u.s_password   = ?';*/
                 $s_qry = "SELECT u.i_id, u.s_username, u.s_user_type,\n\t\t\t\t\t\t\t\t\t u.s_email, u.i_admin_user, u.i_role, u.i_is_active,\n\t\t\t\t\t\t\t\t\t IFNULL(ud.s_display_name, u.s_username) AS 's_display_name'\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t FROM " . $this->tbl_name . " u LEFT JOIN " . $this->tbl_user_details . " ud\n\t\t\t\t\t\t\t\t\t ON u.i_id = ud.i_user_id\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t WHERE (BINARY u.s_username = ? OR u.s_email = ?)\n\t\t\t\t\t\t\t\t\t AND BINARY u.s_password   = ?\n\t\t\t\t\t\t\t\t\t AND u.i_is_active = 1 AND u.i_role = ? ";
                 #$stmt_val["s_username"] = get_formatted_string($login_data["s_username"]);
                 $posted_username = get_formatted_string($login_data["s_username"]);
                 $stmt_val["s_username"] = !empty($posted_username) ? $posted_username : NULL;
                 /*if($via_fconnect)
                 		$stmt_val["s_email"] = get_formatted_string($login_data["s_email"]);
                 	  else*/
                 $stmt_val["s_email"] = get_formatted_string($login_data["username"]);
                 /////Added the salt value with the password///
                 //if(!$via_fconnect)
                 $stmt_val["s_password"] = get_salted_password($login_data["s_password"]);
                 // NEW - for user-type...
                 $stmt_val['usr_type'] = $login_data['usr_type'];
             }
             $this->db->trans_begin();
             ///new
             $rs = $this->db->query($s_qry, $stmt_val);
             # echo $this->db->last_query();
             if (is_array($rs->result())) {
                 foreach ($rs->result() as $row) {
                     $ret_["i_id"] = $row->i_id;
                     ////always integer
                     $ret_["s_username"] = get_unformatted_string($row->s_username);
                     $ret_["s_email"] = get_unformatted_string($row->s_email);
                     $ret_["i_is_admin"] = intval($row->i_admin_user);
                     $ret_["i_role"] = intval($row->i_role);
                     $ret_["i_is_active"] = intval($row->i_is_active);
                     $ret_["s_user_type"] = intval($row->s_user_type);
                     ////////saving logged in user data into session [Begin]////
                     /*$this->session->set_userdata('login_referrer', ''); 
                                   $this->session->set_userdata('loggedin', true);
                                   $this->session->set_userdata('user_id', $row->i_id);
                                   $this->session->set_userdata('username', get_unformatted_string($row->s_username));
                                   $this->session->set_userdata('usr_display_name', get_unformatted_string($row->s_display_name));
                                   $this->session->set_userdata('email', get_unformatted_string($row->s_email));
                     		$this->session->set_userdata('is_admin', $row->i_admin_user);
                                   $this->session->set_userdata('user_role', $row->i_role);*/
                     $this->session->set_userdata(array("fe_loggedin" => array("user_id" => intval($ret_["i_id"]), "i_role" => intval($ret_["i_role"]), "user_name" => $ret_["s_username"], "usr_display_name" => get_unformatted_string($row->s_display_name), "user_email" => $ret_["s_email"], "user_status" => $ret_["i_is_active"], "s_user_type" => $ret_["s_user_type"])));
                     ////////end saving logged in user data into session [End]////
                     //////////log report///
                     /*if(1)
                                  {
                       $login_data['i_user_id']   = intval($row->i_id);
                                      $login_data['s_login_ip']  = $this->input->ip_address();
                                      $login_data['dt_login_on'] = get_db_datetime();
                                    
                                      $this->_login_logs($login_data);
                                  }*/
                     //////////end log report///
                 }
                 $rs->free_result();
             }
             $this->db->trans_commit();
             ///new
             unset($s_qry, $rs, $row, $login_data, $stmt_val);
             return $ret_;
         }
     } catch (Exception $err_obj) {
         show_error($err_obj->getMessage());
     }
 }