Location: PHPKode > scripts > secShield > secshield/secShield.class.php
<?PHP
// Developed By Tiago Sarlo
// Email: hide@address.com

class secShield {

   const _CRYPT_KEY  = '##CRYPT!KEY##';
   var $Query;
   var $secShield_EC;
   var $secShield_IP;
   var $secShield_TS;
   var $_crypt_mode = CRYPT_MODE_BASE64;

////////////////////////////////////////////////////////////////////////////////////////////////////

public function __construct() { if(!isset($_SESSION)) { @session_start(); } }

// QUERY HANDLER -----------------------------------------------------------------------------------

public function getQuery() { if(!isset($_GET["secShield"])) { return false; } $data = $_GET["secShield"]; $data = $this->decrypt($data); @$data = gzuncompress($data); if(!$data) { if(isset($_SESSION['secShield_EC'])) { $_SESSION['secShield_EC'] = $_SESSION['secShield_EC'] + 1; } else { $_SESSION['secShield_EC'] = 1; } $_SESSION['secShield_IP'] = $_SERVER['REMOTE_ADDR']; $_SESSION['secShield_TS'] = date("m/d/y H:i:s"); $data = 'secShield_EC=' . $_SESSION['secShield_EC'] . '&secShield_IP=' . $_SERVER['REMOTE_ADDR'] . '&secShield_TS=' . date("m/d/y H:i:s"); } parse_str($data, $this->Query); return $this->Query; }
public function setQuery($data) { $data.= $data; $data.= '&query_sentby=' . $_SERVER['REMOTE_ADDR']; $data = gzcompress($data, 9); $data = $this->encrypt($data); $data = urlencode($data); return $data; }

// ACESS HANDLER -----------------------------------------------------------------------------------

public function AcessControl() { if(isset($_SESSION['secShield_EC']) AND $_SESSION['secShield_EC'] >= '10') { if (!isset($_COOKIE['secShield'])) { return $this->secShield_ban(); } } if (isset($_COOKIE['secShield'])) { $value = $_COOKIE['secShield']; $value = $this->decrypt($value); parse_str($value, $data); $this->secShield_EC = $data[secShield_EC]; $this->secShield_IP = $data[secShield_IP]; $this->secShield_TS = $data[secShield_TS]; return false; } else { return true; } }
private function secShield_ban() { $value = 'secShield_EC=' . $_SESSION['secShield_EC'] . '&secShield_IP=' . $_SERVER['REMOTE_ADDR'] . '&secShield_TS=' . date("m/d/y H:i:s"); $value = $this->encrypt($value); setcookie('secShield', $value, time() + 86400); return false; }

// CRYPTOGRAPHY HANDLER ----------------------------------------------------------------------------

private function encrypt($value)   { $value = (string) $value; $crypt_key = (string) self::_CRYPT_KEY; for ($i=0;$i<strlen($value);$i++) @$encrypt .= $value[$i] ^ $crypt_key[$i % strlen($crypt_key)]; if ($this->_crypt_mode == CRYPT_MODE_BIN) return @$encrypt; if ($this->_crypt_mode == CRYPT_MODE_BASE64) return base64_encode(@$encrypt); if ($this->_crypt_mode == CRYPT_MODE_HEX) return $this->encodeHex(base64_encode(@$encrypt)); }
private function decrypt($value)   { if ($this->_crypt_mode == CRYPT_MODE_HEX) $value = base64_decode($this->decodeHex($value)); if ($this->_crypt_mode == CRYPT_MODE_BASE64) $value = (string) base64_decode($value); $crypt_key = (string) self::_CRYPT_KEY; for ($i=0;$i<strlen($value);$i++) @$decrypt .= $value[$i] ^ $crypt_key[$i % strlen($crypt_key)]; return @$decrypt; }
private function encodeHex($value) { $value = (string) $value; for ($i=0;$i<strlen($value);$i++) @$encrypt .= dechex(ord($value[$i])); return @$encrypt; }
private function decodeHex($value) { $value = (string) $value; for ($i=0;$i<strlen($value);$i+=2) @$decrypt .= chr(hexdec(substr($value, $i, 2))); return @$decrypt; }

////////////////////////////////////////////////////////////////////////////////////////////////////

}





?>
Return current item: secShield