Location: PHPKode > projects > MembersGear > membersgear/admin/admin_banlist_m.php
<?php

require_once "../config/config.php"; 
require_once "../includes/banlist_class.php";
require_once INCLUDE_DIR."/users_class.php"; 
$users=new users_class();

if($_SERVER['REQUEST_METHOD']=="GET")
        $_SESSION[SESSION_PREFIX.'page_referrer']=$_SERVER['HTTP_REFERER'];

        
if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can view banned IPs')==false)
{
        Redirect('admin_nopermission.php',true);  
}
if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can manage banned IPs')==false)
{

       Redirect('admin_nopermission.php',true);
}           
$loBanList = new banlist_class();
//print_r($users->View());die;

switch($_action)
{
    case 'insert':
           //Insert
           $lTypes=null;   
           $query = 'INSERT INTO '.TABLE_PREFIX.'banlist
                    (hostaddress, bantype, isactive, createdby, createdon, createdipaddress)
                    VALUES(?,?,?,?,?,?)';
                    //VALUES('user4','user4','hide@address.com','address1','1950-12-12 00:00:00',1,1)'
           
           //$lsValues = array('user4','user4','hide@address.com','address1','1950-12-12 00:00:00',1,1);         
           $lsValues = array();
           
           if($_POST['ddlbanList'] == 3)
                $lsValues[0] = $_POST['txtBanListAddress'].' To '.$_POST['txtBanListRange'];
           else
                $lsValues[0] = $_POST['txtBanListAddress'];
           
           $lsValues[1] = $_POST['ddlbanList'];
           $lsValues[2] = $_POST['ddlIsActive']+0;
           $lsValues[3] = $_SESSION[SESSION_PREFIX.'Admin_UserID'];
           $lsValues[4] = mktime();
           $lsValues[5] = $_SERVER['REMOTE_ADDR'];
           
           $lsInsertedrows = $loBanList->Insert($query,$lsValues,null);
           
           if($lsInsertedrows > 0)
           {
                $message->SetMessage('Ban IP is added successfully.');
           }
           else
           {
                $message->SetMessage('Some error occure while inserting records.');
           }
                  
              if(isset($_SESSION[SESSION_PREFIX.'page_referrer']))
                     Redirect($_SESSION[SESSION_PREFIX.'page_referrer'],true);
              else  
                     Redirect('admin_banlist_v.php');
           
           break;
    case 'update':                     
           //Update           
           $lTypes=null;   
           $query = 'UPDATE '.TABLE_PREFIX.'banlist SET hostaddress=?,bantype=?,isactive=?,modifiedby=?,modifiedon=?,modifiedipaddress=? WHERE id=?';
                    //VALUES('user4','user4','hide@address.com','address1','1950-12-12 00:00:00',1,1)'
           
           //$lsValues = array('user4','user4','hide@address.com','address1','1950-12-12 00:00:00',1,1);         
           $lsValues = array();
           
           if($_POST['ddlbanList'] == 3)
                $lsValues[0] = $_POST['txtBanListAddress'].' To '.$_POST['txtBanListRange'];
           else
                $lsValues[0] = $_POST['txtBanListAddress'];
           
           $lsValues [1] = $_POST['ddlbanList'];
           $lsValues[2] = $_POST['ddlIsActive']+0;
           $lsValues[3] = $_SESSION[SESSION_PREFIX.'Admin_UserID'];
           $lsValues[4] = mktime();
           $lsValues[5] = $_SERVER['REMOTE_ADDR'];
           $lsValues[6] = $_POST['hdnID']; 
           
           $lsUpdatedrows = $loBanList->Update($query,$lsValues,null);
           
           if($lsUpdatedrows > 0)
           {
                $message->SetMessage('Ban IP is updated successfully.');
           }
           else
           {
                $message->SetMessage('Some error occure while updating records.');
           }
           
          if(isset($_SESSION[SESSION_PREFIX.'page_referrer']))
                 Redirect($_SESSION[SESSION_PREFIX.'page_referrer'],true);
          else  
                 Redirect('admin_banlist_v.php');

           
           break;
    
    case 'delete':
            if(isset($_GET['id']) and $_GET['id'] != '')
            {
                $lTypes = null;
                $query = 'DELETE FROM '.TABLE_PREFIX.'banlist WHERE id=?';
                $lsValues = array($_GET['id']);
                
                $lsDeletedrow = $loBanList->Delete($query,$lsValues,null);
                
                if($lsDeletedrow > 0)
                {
                    $message->SetMessage('Record is deleted successfully.');
                }   
            }
            $quest="&";
            if(isset($_GET) && !empty($_GET))
             {
                 foreach($_GET as $keyname => $value) {
                      if(strtoupper($keyname)!='ACTION')
                         $quest.=$keyname."=".$value."&";
                    }     
             
             }

              if(isset($_SESSION[SESSION_PREFIX.'page_referrer']))
                     Redirect($_SESSION[SESSION_PREFIX.'page_referrer'],true);
              else  
                 Redirect("admin_banlist_v.php?$quest"); 

            break;
    
    case 'edit':
            $lTypes=null;
             $lsValues = array($_GET['id']);
             $query = "SELECT * FROM ".TABLE_PREFIX."banlist WHERE id=?";
             
             $result = $loBanList->View($query,$lsValues,null);
             
            
                $smarty->assign('data',$result);

                $smarty->assign('IsEdit','yes');
                $smarty->display('admin_banlist_m.tpl'); 
            break;      
    default:       
           ////Parameterized View
           /*$lsValues = array("user4");
           $lTypes=null;
           
           $result = $users->View('SELECT * FROM tbluser1 t where username=?',$lsValues,$lTypes,1,1000);
           
           $smarty->assign('row',$result);
           
           $smarty->display('users.tpl'); */
           $smarty->display('admin_banlist_m.tpl');
                       
}
?>
Return current item: MembersGear