Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   PHP (https://www.askmehelpdesk.com/forumdisplay.php?f=454)
-   -   Backspace bug (https://www.askmehelpdesk.com/showthread.php?t=768338)

  • Sep 22, 2013, 10:07 PM
    Goochi
    Backspace bug
    Hi there


    My problem is I have an app with admin and partners access group lvl 1 and 2

    The problem here when I login as partner I have to see only items that assigned to me by the admin

    But when I press backspace button the page refresh and show up all the items that the admin have

    Please can you chk where I made the error and thank you for your help

    Here is the code

    PHP Code:

    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

    class 
    Members extends CI_Controller {
        public 
    $success$message$data;
        var 
    $table "subscribers";
        var 
    $part_tabel "partners";
        var 
    $serv_tabel "servers";
        var 
    $user NULL;
        
        function 
    __construct() {
            
    parent::__construct();
            
    $this->success true;
            
    $this->data = array();
            
    $this->message ""
            if (!
    $this->ion_auth->logged_in())
            {
                if(
    $this->ion_auth->isAjax()){
                    
    $this->success false;
                    
    $this->to_json(array("login"=>true));
                    exit;
                }else{
                    
    redirect('auth/login');
                }
            }
            
    $this->load->model("tools_model");
            
    $this->load->model("user_model");        
            
    $this->user $this->get_partner_id();
        }
        function 
    user_info(){
            
    $lines = array();
            
    $users json_decode($this->input->post("users"), true);        
            foreach(
    $users as $user){            
                if(
    $t $this->tools_model->fetch_user_infos($user))
                    
    $lines array_merge($lines,$t);
                    
            }
            
    $this->load->view("user_infos", array("lines"=>$lines));
        }
        function 
    get_record($id){
            
    $q $this->db->get_where($this->table, array("id"=>$id));
            return 
    $q->num_rows() > $q->row_array() : array();    
        }
        
        }
        private function 
    get_partner_id(){
            
    $q $this->db->get_where($this->part_tabel, array("user_id"=>$this->ion_auth->user()->row()->id));
            if(
    $q->num_rows() > 0)
                return 
    $q->row()->id;
            else
                return 
    false;    
        }
        public function 
    index()
        {
            
    $this->load->view("members");
        }
        
        function 
    retrive(){
         
             
    $this->db->select("(TO_DAYS(date) + duration) - TO_DAYS(NOW())  as days_left");
            
    $this->db->select("subscribers.id, subscribers.name,subscribers.amount_left, proxy,subscribers.username,subscribers.date,subscribers.duration,subscribers.end_date,subscribers.amount,subscribers.chat,subscribers.mobile,subscribers.created,subscribers.payment,subscribers.type,subscribers.status,subscribers.server_id,subscribers.namo");
            
            if(
    $this->input->post("fields")){
                
    $fields json_decode($this->input->post("fields"),true);            
                foreach(
    $fields as $field){
                    
    $this->db->or_like("subscribers.".$field,$this->input->post("query"));
                }
            }
            
                

            
    $this->db->join('partners''partners.id = subscribers.partner_id',"left");
            if(!empty(
    $this->user))
                
    $this->db->where("partner_id"$this->user);
            else
                
    $this->db->where("0"1false);
            
    $q $this->db->get($this->table);        
            
    $total $q->num_rows();
            
    $q->free_result();
            
                
                
    $this->db->select("subscribers.id, subscribers.name,amount_left,subscribers.proxy, subscribers.username,subscribers.date,subscribers.duration,subscribers.end_date,subscribers.amount,subscribers.chat,subscribers.mobile,subscribers.created,subscribers.payment,subscribers.type,subscribers.status, subscribers.server_id,subscribers.namo");
                
    $this->db->select("CONCAT('C: ',servers.url,' ',servers.listen_port,' ',subscribers.username,' ',subscribers.password) as cline"FALSE);
                 
    $this->db->select("(TO_DAYS(date) + duration) - TO_DAYS(NOW())  as days_left");
                 
    $this->db->join('servers''servers.id = subscribers.server_id',"left");
                
            if(!empty(
    $this->user))
                
    $this->db->where("partner_id"$this->user);
            else
                
    $this->db->where("0"1false);
            
            if(
    $this->input->post("fields")){
                
    $fields json_decode($this->input->post("fields"),true);
                        
                foreach(
    $fields as $field){
                    
    $this->db->or_like($field,$this->input->post("query"));
                }
            }        
            
            
            
            if(
    $this->input->post("sort")){
                
    $this->db->order_by($this->input->post("sort"),$this->input->post("dir"));            
            }else{        
                
    $this->db->order_by("subscribers.status","ASC");
                
    $this->db->order_by("subscribers.created","DESC");
            }
                
            if(
    $this->input->post("start"))
                
    $this->db->limit($this->input->post("limit"), $this->input->post("start"));
            else
                
    $this->db->limit(100);
            
    $this->db->where("subscribers.partner_id !=",1);

            
    $q $this->db->get($this->table);     
        
    //    print($this->db->last_query());
            
    if($q->num_rows() > 0){
                
    $this->data $q->result_array();
            }
            
    $this->to_json(array("total"=>$total));
        }
        function 
    to_json($params false){
            
    $properties = array(
                
    "success"=>$this->success,
                
    "message"=>$this->message,
                
    "data"   =>$this->data
            
    );
            if(
    is_array($params)){
                foreach(
    $params as $key=>$val)
                
    $properties[$key] = $val;
            }
            echo 
    json_encode($properties);
        }
        
        function 
    download(){            
            
    $this->load->library('zip');        
            
    $users $this->input->get('users');
            
    $users explode(":",$users);
            
    $this->db->select("subscribers.username");        
            
    $this->db->select("CONCAT('C: ',servers.url,' ',servers.listen_port,' ',subscribers.username,' ',subscribers.password) as cline"FALSE);
            
    $this->db->join('servers''servers.id = subscribers.server_id',"left");
            
    $this->db->where_in("subscribers.id"$users);
            
    $q $this->db->get($this->table);
            
            if(
    $q->num_rows() > 0){
                foreach(
    $q->result() as $row){
                    
    $name $row->username.""    ;
                    
    $this->zip->add_data($name$row->cline);
                }
            }
            
            
    $this->zip->download("abonnements-".date("d-m-Y").".zip");
        }

    }


  • All times are GMT -7. The time now is 04:23 PM.