Visualizzazione dei risultati da 1 a 4 su 4

Discussione: blocco proxy

  1. #1
    Utente di HTML.it L'avatar di mybox
    Registrato dal
    Mar 2007
    Messaggi
    507

    blocco proxy

    ciao ragazzi in rete ho trovato questo file:

    Codice PHP:
    <?php
    /**
     * @version 1.0
     * @package SNB proxy
     * @copyright &copy; 2008 security-net.biz
     * @author Ivan Markovic <ivanm@security-net.biz>
     */
     
    /**
     * Proxy check functions.
     * Collection of some functions that can help proxy detection
     * Contains common methods needed as:
     * headers check, open ports check, cookie trap.
     * 
     * Sample usage:
     * $myProxy = new proxyCheck();
     * $myProxy->serverVar = $_SERVER;
     * $headers = $myProxy->checkHeder();
     * $ports = $myProxy->checkPort();
     */

    class proxyCheck {
          
          
    /**
           * Server vars ($_SERVER)
           * @access public
           * @var array
           */
          
    var $serverVar = array();
          
           
    /**
           * Timeout for fsockopen
           * @access public
           * @var int
           */
          
    var $timeout 5;
          
          
    /**
           * Common ports for testing
           * @access public
           * @var array
           */
          
    var $ports = array(3128,8080,80);
          
          
    /**
           * Cookie name
           * @access public
           * @var string
           */
          
    var $cookieName "proxyCheck";
          
          
    /**
           * Finded headers
           * @access private
           * @var array
           */
          
    private $proxyHeder = array();
          
          
    /**
           * Finded open ports
           * @access private
           * @var array
           */
          
    private $portsData = array();
          
          
          
    /**
             * proxyCheck constructor
             * @access public
             */
            
    function proxyCheck() {
                
    // TODO
            
    }
        
            
    /**
             * Check usual proxy headers
             * @return array data
             * @access public
             */
            
    function checkHeader() {
                
                  if(isset(
    $this->serverVar['HTTP_X_FORWARDED_FOR'])) {
                          
    $this->proxyHeder['HTTP_X_FORWARDED_FOR'] = $this->serverVar['HTTP_X_FORWARDED_FOR'];
                  }
                  
                if(isset(
    $this->serverVar['HTTP_X_FORWARDED'])) {
                        
    $this->proxyHeder['HTTP_X_FORWARDED'] = $this->serverVar['HTTP_X_FORWARDED'];
                  }
                  
                  if(isset(
    $this->serverVar['HTTP_FORWARDED'])) {
                        
    $this->proxyHeder['HTTP_FORWARDED'] = $this->serverVar['HTTP_FORWARDED'];
                  }
                  
                  if(isset(
    $this->serverVar['HTTP_PROXY_AGENT'])) {
                        
    $this->proxyHeder['HTTP_PROXY_AGENT'] = $this->serverVar['HTTP_PROXY_AGENT'];
                  }
                  
                  if(isset(
    $this->serverVar['HTTP_VIA'])) {
                        
    $this->proxyHeder['HTTP_VIA'] = $this->serverVar['HTTP_VIA'];
                  }
                  
                  if(isset(
    $this->serverVar['HTTP_PROXY_CONNECTION'])) {
                        
    $this->proxyHeder['HTTP_PROXY_CONNECTION'] = $this->serverVar['HTTP_PROXY_CONNECTION'];
                  }
                  
                  if(isset(
    $this->serverVar['HTTP_CLIENT_IP'])) {
                        
    $this->proxyHeder['HTTP_CLIENT_IP'] = $this->serverVar['HTTP_CLIENT_IP'];
                  }
                  
                  return 
    $this->proxyHeder;
            }
            
            
    /**
             * Check common ports
             * @param string ip
             * @return array data
             * @access public
             */
            
    function checkPort($ip '') {
                
                  if(empty(
    $ip)) $ip $this->serverVar['REMOTE_ADDR'];
                
                    foreach(
    $this->ports as $port) {
                            
    $fp = @fsockopen($ip,$port,$errno,$errstr,$this->timeout);
                            if(!empty(
    $fp)) $this->portsData[$port] == $port;
                            @
    fclose($fp);
                    }
                    
                    return 
    $this->portsData;
            }
            
            
    /**
             * Cookie trap
             * @return true on finded proxy
             * @access public
             */
            
    function checkCookie() {
                    if(isset(
    $_COOKIE[$this->cookieName])) {
                            if(
    $this->serverVar['REMOTE_ADDR'] != $_COOKIE[$this->cookieName]) return true;
                    } else {
                            @
    setcookie($this->cookieName$this->serverVar['REMOTE_ADDR']);    
                    }
            }
            
    }

    ?>
    mi chidevo usando uno script che non utilizza i cookies ma database posso includerlo in una pagina e funziona oppure no???

  2. #2
    Per prima cosa lo script contiene solo una classe. Includerlo non serve a niente se non scrivi del codice che utilizza la classe.

    Per il resto, il fatto che il tuo sito non utilizzi i cookie è irrilevante, la classe può utilizzarli o meno a seconda del codice che andrai a scrivere.

  3. #3
    Utente di HTML.it L'avatar di mybox
    Registrato dal
    Mar 2007
    Messaggi
    507
    dovrebbe essere un bel codice

    quindi dovrei scrivere:


    $myProxy = new proxyCheck();
    $myProxy->serverVar = $_SERVER;
    $headers = $myProxy->checkHeder();
    $ports = $myProxy->checkPort();

    e poi un include("nomefile.class.php");

    in questo caso andrebbe?!

  4. #4
    L'include va prima, altrimenti non puoi istanziare la classe.
    Ed in ogni caso il codice che hai indicato non fa altro che richiamare dei metodi. Se non utilizzi i valori restituiti dalla classe, è inutile.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.