example

  1. <?php
  2. /**
  3.  * File containing example 5(check referer with "www" and without "www") use DefensiveAttack.
  4.  *
  5.  * @package     DefensiveAttack
  6.  * @version     1.0.0
  7.  * @copyright     Copyright (C)2006 TheLordOfWeb. All rights reserved.
  8.  * @license     http://www.gnu.org/copyleft/gpl.html GNU Public License
  9.  * @filesource
  10.  */
  11.  
  12. //Load class DefensiveAttack
  13. require("class.php5.DefensiveAttack.php");
  14.  
  15. /**
  16.  * MyDefensiveAttack class for php 5.x
  17.  *
  18.  * 
  19.  * @package     MyDefensiveAttack extends by DefensiveAttack
  20.  * @author         TheLordOfWeb    <http://thelordofweb.atspace.com/>
  21.  * @version     1.0.0
  22.  * @copyright     Copyright (C)2006 TheLordOfWeb. All rights reserved.
  23.  * @license     http://www.gnu.org/copyleft/gpl.html GNU Public License
  24.  * @example        example_5.php
  25.  */
  26.     
  27.     /**
  28.      * My host name 2 with "www" or not
  29.      *
  30.      * @access protected
  31.      * @var string 
  32.      */
  33.     protected   $mMyHostName2   =   '';
  34.     
  35.     /**
  36.      * MyDefensiveAttack constructor
  37.      *
  38.      * @access public
  39.      * @param  string hostname
  40.      * @see    parent::__construct()
  41.      */
  42.     public function __construct($myHostName  =  null{
  43.         
  44.         parent::__construct($myHostName);
  45.  
  46.         $pos    =   stripos($this->mMyHostName,'www.');
  47.         
  48.         $this->mMyHostName2   =   (false !== $pos AND === (int)$possubstr($this->mMyHostName,4"www." $this->mMyHostName;
  49.         
  50.     }
  51.     
  52.     /**
  53.      * Check referer for my url address with "www" and without "www"
  54.      *
  55.      * @access public
  56.      * @return bool 
  57.      */
  58.     public function CheckReferer({
  59.  
  60.         return (strcmp($this->mMyHostName,$this->mReferer== OR strcmp($this->mMyHostName2,$this->mReferer== 0true false;
  61.         
  62.     }
  63.     
  64. }
  65.  
  66. //Create object
  67. $def_attack     =   new MyDefensiveAttack('mysite.com');
  68.  
  69. //Check referer if I do not want direct access to my site
  70. if (false === $def_attack->CheckReferer()) {
  71.     print "Access deny " '<a href="example_5.php" >Use link</a>';
  72. else {
  73.     print "Access allow";
  74. }
  75.  
  76.  
  77. ?>

Documentation generated on Wed, 01 Nov 2006 00:00:01 +0200 by phpDocumentor 1.3.1