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

class Ip_Allwed extends CI_Controller {  
     public function __construct() {
        parent::__construct();  
        date_default_timezone_set('Asia/Kolkata');
         $this->load->database();
         $this->load->model('Login_model');
           $ip = $this->input->ip_address();

    }
    
public function ip_status($id ,$st){
      
        if($st=='0'){
            $nw = 1;
        }else{
            $nw = 0;
        }
        $f = array(
          'status'=> $nw
          
          
          );
          $this->Login_model->Update('allowed_ip', $f, array('id'=> $id ));
         
                $this->session->set_flashdata('message_name', 'Status Change Successfully.');
                            redirect(base_url() . 'index.php/Ip_Allwed/ip_Allwed');
          
    }
    
    
    
     public function add_IP(){
      $ip = $_POST['ip_ad'];
      $name = $_POST['name'];
      
      if(empty($ip)  && empty($name)  ){
          
           $this->session->set_flashdata('message_name', 'Please Enter the Address.');
           redirect(base_url() . 'index.php/Ip_Allwed/ip_Allwed');
           
      }
      $f = array(
          'ip_adr'=> $ip,
          'name' => $name , 
          'status'=> 0
          );
          
          $this->Login_model->insert('allowed_ip', $f);
                        
                        $this->session->set_flashdata('message_name', 'Added Successfully.');
                          redirect(base_url() . 'index.php/Ip_Allwed/ip_Allwed');
      
      
  }
    
   

public function ip_Allwed(){
    
    
 $this->load->view('ip_allwed');
    
    
    
}






}
