Location: PHPKode > projects > MembersGear > membersgear/includes/system_log_class.php
<?php
 
 require_once "peardb_class.php";
    
 class system_log_class extends peardb_class
 {  
 
    
    
        
    function View($pQuery, $pValues=false, $types=true, $pStart=0, $pEnd=0)
    {
        /*
        global $mdb2;    
        $result;  
 
        $query      = 'SELECT * FROM tbluser1 t limit 10;';
        $resultset  = $mdb2->query($query);
        
        if(PEAR::isError($resultset)) 
        {
            die("Failed to issue query, error message : " . $resultset->getMessage());
        }
                                           
        while($row = $resultset->fetchRow(MDB2_FETCHMODE_ASSOC))
        {
            $result[] = $row;
        }
                                                                                                                 
        return  $result;   
        */
        //print_r($pParameters);
        
        return $this->BaseView($pQuery,$pValues,$types,$pStart,$pEnd);
        
    }
    
    function Update($pQuery, $pValues=false, $types=true)
    { 
       
        return $this->BaseUpdate($pQuery, $pValues, $types);
    
    }

    
    function Insert($pQuery, $pValues=false, $types=true)
    { 
    
        return $this->BaseInsert($pQuery, $pValues, $types);
    
    }
    
     function delete($pQuery, $pValues=false, $types=true)
    {
        
      return $this->BaseDelete($pQuery, $pValues,null);
        
    } 
    
    function insertToSystemLog()
    {
        if(strpos($_SERVER['REQUEST_URI'],'admin_user_log_v.php'))
            return false;
            
        $iUserId="";    
         
       
        if(IsAdminDirectoryRequested()==true)
        {
             if(isset($_SESSION[SESSION_PREFIX.'Admin_UserID']))
             $iUserId=$_SESSION[SESSION_PREFIX.'Admin_UserID'];
        } 
        else
        {
             if(isset($_SESSION[SESSION_PREFIX.'UserID']))
              $iUserId=$_SESSION[SESSION_PREFIX.'UserID'];   
            
        }     
        if($iUserId=="")
           $iUserId=0;
           
        $lsPage_name=$_SERVER['REQUEST_URI'];
        $substringStartAt=strrpos($lsPage_name, "/");
        $filename=substr($lsPage_name,$substringStartAt+1);
        $charAtQueryString=strpos($filename, "?");
        if(!isset($charAtQueryString) or $charAtQueryString==null or $charAtQueryString ==0)
            $charAtQueryString=strlen($filename);
         
         $filename=substr($lsPage_name,$substringStartAt+1,$charAtQueryString); 
           
         if(isset($_SERVER['HTTP_REFERER']))  
          $lsreferer_page_name=$_SERVER['HTTP_REFERER'];
         else
           $lsreferer_page_name="";
         
        
       // $lenReferer=strlen($lsreferer_page_name);
       // $flag=false;   
        /*while($lenReferer>39)
         {
           
            $firstString=substr($lsreferer_page_name,0,39);
            $secondString=substr($lsreferer_page_name,39);
            $refererString.=$firstString.'<br>';
            $lenReferer=strlen($secondString)-1; 
            $lsreferer_page_name=$secondString;
            $flag=true;   
             
         } */
        
       // if($flag==false) 
          $refererString=$lsreferer_page_name;
        //else
          //  $refererString.=$secondString;
        $lshost_name=$_SERVER['REMOTE_ADDR']; 
        $lshost_address=strtolower(trim(gethostbyaddr($_SERVER['REMOTE_ADDR'])));
        $lsrequest_method=$_SERVER['REQUEST_METHOD'];
        $lsvisitedon=strtotime(date("Y/m/dH:i:s")); 
        $post_string="";
        $get_string="";
        $cookie_string=""; 
        if($lsrequest_method=="GET")
         {
            $len=sizeof($_GET);
            
            if($len>0)
             {
                foreach($_GET as $key=>$value)
                {
                    $get_string .= $key.'='.stripslashes($value).','; 
                
                }   
                
            }
         
         
         }
        else if($lsrequest_method=="POST")
         {
            $len=sizeof($_POST);
            
            if($len>0)
             {
                foreach($_GET as $key=>$value)
                {
                    $post_string .= $key.'='.stripslashes($value).','; 
                
                }   
                
            }
         
         
         }
         
         $lsPostdata=$post_string;
         $lsGetdata=$get_string;
        
        if(isset($_COKKIE))
        { 
             if(is_array($_COKKIE))
              {
                 $lencokkie=sizeof($_COKKIE);
                 if($lencokkie>0)
                  {
                      foreach($_COKKIE as $key=>$value)
                       {
                          $cookie_string .= $key.'='.stripslashes($value).','; 
                    
                        }  
                      
                  }
              
              
              
              }
        }
           
          $insetQuerySytem_log           ="insert into ".TABLE_PREFIX."users_log(userid,page_name,referer_page_name,host_name,host_address, request_method, visitedon,postdata,getdata,cookiedata)
                                           values($iUserId,'$filename','$refererString','$lshost_name','$lshost_address','$lsrequest_method',$lsvisitedon,'$post_string','$get_string','$cookie_string')";
                                                      
          $result                         =$this->Insert($insetQuerySytem_log);
          
          if($iUserId!=0)
          {
            $lsValues = array(); 
            $lsValues[0]=$lsvisitedon; 
            $lsValues[1]=$iUserId;
            $updatequeryforuserlastlogin    ="update ".TABLE_PREFIX ."users set last_login_date=? where id=?";
                                             
            $lsUpdatedrows                  =$this->Update($updatequeryforuserlastlogin,$lsValues,$lTypes);
          }
        
    }
  
 }   
   
   
 
    

?>
Return current item: MembersGear