• 19-04-2008, 22:19:07
    #46
    Üyeliği durduruldu
    İstediğiniz IP adresine, istediğiniz sayıda ping atar.

    <?php 
    ini_set('display_errors', 1); 
    error_reporting(E_ALL ^ E_NOTICE); 
     
    $ping_ip_addr = $_POST['ping_ip_addr']; // input 
    $ping_count   = $_POST['ping_count'];   // select 
     
    if (get_magic_quotes_gpc()) 
        { 
        $ping_ip_addr = stripslashes($ping_ip_addr); 
        } 
     
    $ping_count_array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 25); 
    ?> 
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
    <head> 
    <title>Ping</title> 
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9" /> 
    <meta name="author" content="firstbase" /> 
    <style type="text/css"> 
    div.output { 
        margin:0; padding:10px; background-color:#eeeeee; border-style:solid; border-width:1px; border-color:#000000; } 
     
    body { 
        margin:0; padding:10px; background-color:#ffffff; } 
    </style> 
    </head> 
    <body> 
    <h1>Ping Atma</h1> 
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> 
    <p><label for="ping_ip_addr">IP Adresi:</label><br /> 
    <input name="ping_ip_addr" id="ping_ip_addr" type="text" value="<?php echo $_POST['submit'] == 'Ping' ? htmlentities($ping_ip_addr, ENT_QUOTES) : $_SERVER['REMOTE_ADDR'];; ?>" size="40" maxlength="15" /></p> 
    <p><label for="ping_count">Ping Sayısı:</label><br /> 
    <select name="ping_count" id="ping_count"> 
    <?php 
    foreach ($ping_count_array as $ping_count_item) 
        { 
        echo '<option' . ($ping_count == $ping_count_item ? ' selected="selected"' : '') . '>' . $ping_count_item . '</option>' . "\n"; 
        } 
    ?> 
    </select></p> 
    <p><input type="submit" name="submit" value="Ping At" /></p> 
    </form> 
    <p>Ping atma işlemi zaman alabilir, lütfen bekleyiniz.</p> 
    <?php 
     
    if ($_POST['submit'] == 'Ping At') 
        { 
        echo '<div class="output">' . "\n"; 
     
        $illegal = FALSE; 
     
        if (strlen($ping_ip_addr) > 15) 
            { 
            $illegal = TRUE; 
            } 
     
        if (!in_array($ping_count, $ping_count_array)) 
            { 
            $illegal = TRUE; 
            } 
     
        if (!$illegal) // Form submission was not spoofed. 
            { 
            if (ereg('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$', $ping_ip_addr)) // Acquired data contains no problems. 
                { 
                // Display result. 
     
                echo '<pre>' . "\n" . 
                     'ping -c ' . $ping_count . ' ' . $ping_ip_addr . "\n\n"; 
     
                system('ping -c ' . $ping_count . ' ' . $ping_ip_addr);  
     
                echo '</pre>' . "\n" . 
                     '<p>Ping tamamlandı.</p>' . "\n"; 
                } 
            else 
                { 
                echo '<p>Lütfeb geçerli bir IP adresi giriniz.</p>' . "\n"; 
                } 
            } 
        else 
            { 
            echo '<p>Bir hata oluştu.</p>' . "\n"; 
            } 
     
        echo '</div>' . "\n"; 
        } 
    ?> 
    </body> 
    </html>
  • 19-04-2008, 22:21:38
    #47
    Üyeliği durduruldu
    <?php 
     
    /* PHP RSS Reader v1.1 
     
    By Richard James Kendall  
     
    Bugs to richard@richardjameskendall.com  
     
    Free to use, please acknowledge me  
     
     
     
    Place the URL of an RSS feed in the $file variable. 
     
     
     
    The $rss_channel array will be filled with data from the feed, 
     
    every RSS feed is different by by and large it should contain: 
     
     
     
    Array { 
     
    [TITLE] = feed title 
     
    [DESCRIPTION] = feed description 
     
    [LINK] = link to their website 
     
     
     
    [IMAGE] = Array { 
     
    [URL] = url of image 
     
    [DESCRIPTION] = alt text of image 
     
    } 
     
     
     
    [ITEMS] = Array { 
     
    [0] = Array { 
     
    [TITLE] = item title 
     
    [DESCRIPTION] = item description 
     
    [LINK = a link to the story 
     
    } 
     
    . 
     
    . 
     
    . 
     
    } 
     
    } 
     
     
     
    By default it retrives the Reuters Oddly Enough RSS feed. The data is put into the array 
     
    structure so you can format the information as you see fit. 
     
    */ 
     
    set_time_limit(0); 
     
    $file = "rss adresi"; 
     
    $rss_channel = array(); 
    $currently_writing = ""; 
     
    $main = ""; 
     
    $item_counter = 0; 
     
    function startElement($parser, $name, $attrs) { 
     
    global $rss_channel, $currently_writing, $main; 
     
    switch($name) { 
     
    case "RSS": 
     
    case "RDF:RDF": 
     
    case "ITEMS": 
     
    $currently_writing = ""; 
     
    break; 
     
    case "CHANNEL": 
     
    $main = "CHANNEL"; 
     
    break; 
     
    case "IMAGE": 
     
    $main = "IMAGE"; 
     
    $rss_channel["IMAGE"] = array(); 
     
    break; 
     
    case "ITEM": 
     
    $main = "ITEMS"; 
     
    break; 
     
    default: 
     
    $currently_writing = $name; 
     
    break; 
     
    } 
     
    } 
     
    function endElement($parser, $name) { 
     
    global $rss_channel, $currently_writing, $item_counter; 
     
    $currently_writing = ""; 
     
    if ($name == "ITEM") { 
     
    $item_counter++; 
     
    } 
     
    } 
     
    function characterData($parser, $data) { 
     
    global $rss_channel, $currently_writing, $main, $item_counter; 
     
    if ($currently_writing != "") { 
     
    switch($main) { 
     
    case "CHANNEL": 
     
    if (isset($rss_channel[$currently_writing])) { 
     
    $rss_channel[$currently_writing] .= $data; 
     
    } else { 
     
    $rss_channel[$currently_writing] = $data; 
     
    } 
     
    break; 
     
    case "IMAGE": 
     
    if (isset($rss_channel[$main][$currently_writing])) { 
     
    $rss_channel[$main][$currently_writing] .= $data; 
     
    } else { 
     
    $rss_channel[$main][$currently_writing] = $data; 
     
    } 
     
    break; 
     
    case "ITEMS": 
     
    if (isset($rss_channel[$main][$item_counter][$currently_writing])) { 
     
    $rss_channel[$main][$item_counter][$currently_writing] .= $data; 
     
    } else { 
     
    //print ("rss_channel[$main][$item_counter][$currently_writing] = $data<br>"); 
     
    $rss_channel[$main][$item_counter][$currently_writing] = $data; 
     
    } 
     
    break; 
     
    } 
     
    } 
     
    } 
     
    $xml_parser = xml_parser_create(); 
     
    xml_set_element_handler($xml_parser, "startElement", "endElement"); 
     
    xml_set_character_data_handler($xml_parser, "characterData"); 
     
    if (!($fp = fopen($file, "r"))) { 
     
    die("could not open XML input"); 
     
    } 
     
    while ($data = fread($fp, 4096)) { 
     
    if (!xml_parse($xml_parser, $data, feof($fp))) { 
     
    die(sprintf("XML error: %s at line %d", 
     
    xml_error_string(xml_get_error_code($xml_parser)),   
     
    xml_get_current_line_number($xml_parser))); 
     
    } 
     
    } 
     
    xml_parser_free($xml_parser); 
     
    // output as HTML 
     
    print ("<html><head><title>PHP RSS Reader</title></head><body>"); 
     
    if (isset($rss_channel["IMAGE"])) { 
     
    print ("<a href=\"" . $rss_channel["LINK"] . "\" target=\"_blank\"><img border=\"0\" src=\"" . $rss_channel["IMAGE"]["URL"] . "\" align=\"middle\" alt=\"" . $rss_channel["IMAGE"]["TITLE"] . "\"></a>  <font size=\"5\">" . $rss_channel["TITLE"] . "</font><br><br>"); 
     
    } else { 
     
    print ("<font size=\"5\">" . $rss_channel["TITLE"] . "</font><br><br>"); 
     
    } 
     
    print ("<i>" . $rss_channel["DESCRIPTION"] . "</i><br><br>"); 
     
    if (isset($rss_channel["ITEMS"])) { 
     
    if (count($rss_channel["ITEMS"]) > 0) { 
     
    for($i = 0;$i < count($rss_channel["ITEMS"]);$i++) { 
     
    print ("\n<table width=\"100%\" border=\"1\"><tr><td width=\"100%\"><a href=\"" . $rss_channel["ITEMS"][$i]["LINK"] . "\" target=\"_blank\"><h2>" . $rss_channel["ITEMS"][$i]["TITLE"] . "</h2></a></b>"); 
     
    print ("<i>" . html_entity_decode($rss_channel["ITEMS"][$i]["DESCRIPTION"]) . "</i>"); 
     
    print ("</td></tr></table><br>"); 
     
    } 
     
    } else { 
     
    print ("<b>There are no articles in this feed.</b>"); 
     
    } 
     
    } 
     
    print ("</body></html>"); 
     
    ?>
  • 19-04-2008, 22:22:57
    #48
    Üyeliği durduruldu
    <? 
    
    //mr.kurtbey mart 13 2008
    
    function getmicrotime(){  
     
       list($usec, $sec) = explode(" ",microtime());  
     
       return ((float)$usec + (float)$sec);  
     
       } 
     
    $time_start = getmicrotime(); 
     
     
     
    [B]// Buradan sonrası sayfanın en altına yerleştirilsin ki sayfanın yüklenme zamanı belli olsun. [/B]
     
    $time_end = getmicrotime();  
     
    $time = $time_end - $time_start; 
     
    $time = number_format($time, 4, ".", ""); 
     
    echo $time." saniye"; 
     
    ?>
  • 20-04-2008, 01:05:39
    #49
    Kimlik doğrulama veya yönetimden onay bekliyor.
    çok teşekkürler güzel arşiv olmuş.
  • 20-04-2008, 03:32:54
    #50
    Kaynaklarını da belirtseydiniz nasıl olurdu?
    Kaynak belirtmek uymaz mı size yoksa?
  • 20-04-2008, 03:48:00
    #51
    Virtuozzo adlı üyeden alıntı: mesajı görüntüle
    Kaynaklarını da belirtseydiniz nasıl olurdu?
    Kaynak belirtmek uymaz mı size yoksa?
    konunun 3 nolou postundaki kodu 2004 de yazmıştım cevize
    geneli cevizden alınma bunların yahu
  • 20-04-2008, 20:30:06
    #52
    Üyeliği durduruldu
    Arşivimdeki kodları sizlerle paylaştım. Çogu cevizden alma diyen arkadaşlar var.

    Evet bazıları cevizden alınmış olabilir hatırlamıyorum bayagı onceden arsivime eklemıstım.

    Kodların cogunu editleyip hatalı olanları duzelttim ve bazılarını açıklama yaparak anlatmaya çalıştım.Bundan sonraki kodları kendim yazıp bizzat açıklamalarınmı kendim yapacagım.

    Devamı gelecek ...
  • 29-04-2008, 18:59:45
    #53
    Üyeliği durduruldu
    <?php
    
    // ----------------------------------------------------------------------------
    //
    // class.floodblocker.php - FloodBlocker class, ver.0.01 (April 15, 2005)
    //
    // Description:
    //   Class allowing to protect the scripts from flooding and to prevent
    //   automatic download of the site from single IP.
    //
    // Author:
    //   Vagharshak Tozalakyan <vagh@armdex.com>
    //   This module was written by author on its leasure time.
    //
    // Warning:
    //   This class is non commercial, non professional work. It should not have
    //   unexpected results. However, if any damage is caused by this class the
    //   author can not be responsible. The use of this class is at the risk of
    //   the user.
    //
    // Requirements:
    //   PHP >= 4.1.0
    //
    // ----------------------------------------------------------------------------
    
    
    // Errors and warnings
    
    define ( 'E_TMP_DIR',    'Incorrect temprorary directory specified.' );
    define ( 'E_IP_ADDR',    'Incorrect IP address specified.' );
    define ( 'E_LOG_FILE',   'Log file access error! Check permissions to write.' );
    define ( 'E_CRON_FNAME', 'The name of cron file must begin with dot.' );
    define ( 'E_CRON_FILE',  'Cron file access error! Check permissions to write.' );
    define ( 'E_CRON_JOB',   'Unable to perform the cron job.' );
    
    
    // Class definition
    
    class FloodBlocker
    {
    
      // The directory where log files will be saved. Must have permissions to write.
      var $logs_path;
    
      // IP address of current connection. REMOTE_ADDR will be used by default.
      var $ip_addr;
    
      // An associative array of [$interval=>$limit] format, where $limit is the
      // number of possible requests during $interval seconds.
      var $rules;
    
      // The name of the cron file. Must begin with dot. Default filename is '.time'.
      var $cron_file;
    
      // Cron execution interval in seconds. 1800 secs (30 mins) by default.
      var $cron_interval;
    
      // After how many of seconds to consider a file as old? By default the files
      // will consider as old after 7200 secs (2 hours).
      var $logs_timeout;
    
    
      /*
        Description:
          Class constructor.
        Prototype:
          void FloodBlocker ( string logs_path, string ip = '' )
        Parameters:
          logs_path - the directory where log files will be saved
          ip - the ip address of the current connection,
               $_SERVER['REMOTE_ADDR'] will be used if ip=''
      */
      function FloodBlocker ( $logs_path, $ip = '' )
      {
    
        if ( ! is_dir ( $logs_path ) )
          trigger_error ( E_TMP_DIR, E_USER_ERROR );
    
        $logs_path = str_replace ( '\\', '/', $logs_path );
        if ( substr ( $logs_path, -1 ) != '/' )
          $logs_path .= '/';
    
        $this->logs_path = $logs_path;
    
        if ( empty ( $ip ) )
          $ip = $_SERVER['REMOTE_ADDR'];
    
        $ip = ip2long ( $ip );
        if ( $ip == -1 || $ip === FALSE )
          trigger_error ( E_IP_ADDR, E_USER_ERROR );
    
        $this->ip_addr = $ip;
    
        $this->rules = array ( );
        $this->cron_file = '.time';
        $this->cron_interval = 1800;  // 30 minutes
        $this->logs_timeout = 7200;  // 2 hours
    
      }
    
    
      /*
        Description:
          Used to check flooding. Generally this function acts as private method
          and will be called internally by public methods. However, it can be called
          directly when storing logs in db.
        Prototype:
          bool RawCheck ( array &info )
        Parameters:
          info - $interval=>$time, $interval=>$count array
        Return:
          FALSE if flood detected, otherwise - TRUE.
      */
      function RawCheck ( &$info )
      {
    
        $no_flood = TRUE;
    
        foreach ( $this->rules as $interval=>$limit )
        {
          if ( ! isset ( $info[$interval] ) )
          {
            $info[$interval]['time'] = time ( );
            $info[$interval]['count'] = 0;
          }
    
          $info[$interval]['count'] += 1;
    
          if ( time ( ) - $info[$interval]['time'] > $interval )
          {
            $info[$interval]['count'] = 1;
            $info[$interval]['time'] = time ( );
          }
    
          if ( $info[$interval]['count'] > $limit )
          {
            $info[$interval]['time'] = time ( );
            $no_flood = FALSE;
          }
    
          // The following two lines can be used for debugging
          // echo $info[$interval]['count'].'  ';
          // echo $info[$interval]['time'].'<br>';
    
        }  // foreach
    
        return $no_flood;
    
      }
    
    
      /*
        Description:
          Checks flooding. Must be called after setting up all necessary properties.
        Prototype:
          bool CheckFlood ( )
        Return:
          FALSE if flood detected, otherwise - TRUE.
      */
      function CheckFlood ( )
      {
    
        $this->CheckCron ( );
    
        $path = $this->logs_path . $this->ip_addr;
    
        if ( ! ( $f = fopen ( $path, 'a+' ) ) )
          trigger_error ( E_LOG_FILE, E_USER_ERROR);
    
        flock ( $f, LOCK_EX );
    
        $info = fread ( $f, filesize ( $path ) + 10 );
        $info = unserialize( $info );
    
        $result = $this->RawCheck ( $info );
    
        ftruncate ( $f, 0 );
        fwrite ( $f, serialize( $info ) );
        fflush ( $f );
    
        flock($f, LOCK_UN);
    
        fclose($f);
    
        return $result;
    
      }
    
    
      /*
        Description:
          Checks the cron file and calls CronJob() to delete old entries from logs
          directory if the time-out is reached.
        Prototype:
          void CheckCron ( )
      */
      function CheckCron ( )
      {
    
        if ( substr ( $this->cron_file, 0, 1 ) != '.' )
        {
          trigger_error ( E_CRON_FNAME, E_USER_WARNING );
          return;
        }
    
        $path = $this->logs_path . $this->cron_file;
    
        if ( ! ( $f = fopen ( $path, 'a+' ) ) )
        {
          trigger_error ( E_CRON_FILE, E_USER_WARNING );
          return;
        }
    
        flock ( $f, LOCK_EX );
    
        $last_cron = fread ( $f, filesize ( $path ) + 10 );
        $last_cron = abs ( intval ( $last_cron ) );
    
        if ( time ( ) - $last_cron > $this->cron_interval )
        {
          $this->CronJob ( );
          $last_cron = time ( );
        }
    
        ftruncate ( $f, 0 );
        fwrite ( $f, $last_cron );
        fflush ( $f );
    
        flock ( $f, LOCK_UN );
    
        fclose ( $f );
    
      }
    
    
      /*
        Description:
          Deletes all old files from logs directory, except the files starting
          with dot.
        Prototype:
          void CronJob ( )
      */
      function CronJob ( )
      {
    
        $path = $this->logs_path;
    
        if ( ! ( $dir_hndl = opendir ( $this->logs_path ) ) )
        {
          trigger_error ( E_CRON_JOB, E_USER_WARNING);
          return;
        }
    
        while ( $fname = readdir ( $dir_hndl ) )
        {
          if ( substr( $fname, 0, 1 ) == '.' )
            continue;
          clearstatcache ( );
          $ftm = filemtime ( $path . $fname );
          if ( time ( ) - $ftm > $this->logs_timeout )
            @unlink ( $path . $fname );
        }
    
        closedir ( $dir_hndl );
    
      }
    
    }  // end of class definition
    
    
    
    /*
      $flb = new FloodBlocker ( 'example/tmp-ips/' );
      $flb->rules = array ( 10=>5 );
      $res = $flb->CheckFlood ( );
      if ( $res )
        echo 'Succeed!';
      else
        die ( 'Too many requests! Please try later.' );
    */
    
    ?>
    Kullanım Şekli:

    <?php
    
      // Place flood protection code at the top of the script you want to protect.
      // You can write protection code into separate file and include it in every
      // page of your site.
    
      // Sample protection code starts here...
    
      // Include the class definition module.
    
      require_once ( '../class.floodblocker.php' );
    
      // In the following line write the full path to temporary directory in which
      // you want to store flood counters. It is good idea to create such folder
      // somewhere outside your documents directory, to make it unaccessable from Web.
      // Don't forget that the directory must have permissions to write files in it.
      // IMPORTANT!
      // All files in this folder (except those that start with dot, e.g.'.htaccess')
      // will be deleted by FloodBlocker, so don't keep anything there.
    
      $flb = new FloodBlocker ( 'tmp-ips/' );
    
      // Create as many rules as you want...
    
      $flb->rules = array (
        10=>10,    // rule 1 - maximum 10 requests in 10 secs
        60=>30,    // rule 2 - maximum 30 requests in 60 secs
        300=>50,   // rule 3 - maximum 50 requests in 300 secs
        3600=>200  // rule 4 - maximum 200 requests in 3600 secs
      );
    
      // At last call CheckFlood(), it will return FALSE if flood detected on any
      // of specified rules.
    
      if ( ! $flb->CheckFlood ( ) )
        die ( 'Too many requests! Please try later.' );
    
      // ... that's all. Enjoy!
    
    ?>
    
    <html>
    <head>
    <title>The title of my page...</title>
    </head>
    <body bgcolor="#cccccc">
    <h1>Welcome to my page...</h1>
    No flood was detected if you see the contents of this page...
    </body>
    </html>
  • 29-04-2008, 19:01:45
    #54
    Üyeliği durduruldu
    <?php
    /**
    * Class : TextSearch
    *
    * @author  :  MA Razzaque Rupom <rupom_315@yahoo.com>, <rupom.bd@gmail.com>
    *             Moderator, phpResource Group(http://groups.yahoo.com/group/phpresource/)
    *             URL: http://rupom.wordpress.com 
    *        
    * @version :  1.0
    * Date     :  06/25/2006
    * Purpose  :  Searching and replacing text within files of specified path
    */
    
    class TextSearch
    {	 
    	 var $extensions         = array();
    	 var $searchKey          = '';	 
    	 var $replacementKey     = '';
    	 var $caseSensitive      = 0; //by default case sensitivity is OFF
    	 var $findAllExts        = 1; //by default all extensions
    	 var $isReplacingEnabled = 0;
    	 var $logString          = '';
    	 var $errorText          = '';
    	 var $totalFound         = 0; //total matches
    	 
       /** 
       *   Sets extensions to look
       *   @param Array extensions
       *   @return none
       */   
       function setExtensions($extensions = array())
       {
          $this->extensions = $extensions;
          
          if(sizeof($this->extensions))	
          {
             $this->findAllExts = 0; //not all extensions
          }
       }//End of Method
    
       /** 
       * Adds a search extension
       * @param  file extension
       * @return none
       */   
       function addExtension($extension)
       {
          
          array_push($this->extensions, $extension);      
          $this->findAllExts = 0; //not all extensions 
          
       }//End of function
    
      
       /** 
       * Sets search key and case sensitivity
       * @param search key, case sensitivity
       * @return none
       */   
       function setSearchKey($searchKey, $caseSensitive = 0)
       {
          $this->searchKey = $searchKey;
          
          if($caseSensitivity)
          {
             $this->caseSensitive	= 1; //yeah, case sensitive
          }
       }//End of function
    
       /** 
       *   Sets key to replace searchKey with
       *   @param : replacement key
       *   @return none
       */   
       function setReplacementKey($replacementKey)
       {
       
          $this->replacementKey     = $replacementKey;
          $this->isReplacingEnabled = 1;   
       
       }//End of function
       
       /**
       * Wrapper function around function findDirFiles()
       * @param $path to search
       * @return none
       */
       function startSearching($path)
       {
          $this->findDirFiles($path);      
       }//EO Method
       
       /** 
       * Recursively traverses files of a specified path 
       * @param  path to execute
       * @return  none
       */   
       function findDirFiles($path)
       {
          $dir = opendir ($path);
          
          while ($file = readdir ($dir)) 
          {
             if (($file == ".") or ($file == ".."))
             {
                continue;
             }                
    		     	
    		     if (filetype ("$path/$file") == "dir")
    		     {		     	
                $this->findDirFiles("$path/$file"); //recursive traversing here
             }                         
    				 elseif($this->matchedExtension($file)) //checks extension if we need to search this file
    				 {				 	  
               if(filesize("$path/$file"))
               {
                   $this->searchFileData("$path/$file"); //search file data           	
               }   
             }               	 
          } //End of while
          
          closedir($dir);
             
       }//EO Method
    
       /** 
       * Finds extension of a file
       * @param filename
       * @return file extension
       */
       function findExtension($file)
       {
    	   return array_pop(explode(".",$file));
       }//End of function
       
       /**
       * Checks if a file extension is one the extensions we are going to search 
       * @param filename
       * @return true in success, false otherwise
       */   
       function matchedExtension($file)
       {   
          if($this->findAllExts) //checks if all extensions are to be searched
          {
             return true;	
          }      
          elseif(sizeof(array_keys($this->extensions, $this->findExtension($file)))==1)
          {
             return true;	
          }
          
          return false;		
       
       }//EO Method
       
       /**
       * Searches data, replaces (if enabled) with given key, prepares log 
       * @param $file
       * @return none
       */
       function searchFileData($file)
       {
          $searchKey  = preg_quote($this->searchKey);
          
          if($this->caseSensitive)
          {
             $pattern    = "/$searchKey/U";
          }
          else
          {
          	 $pattern    = "/$searchKey/Ui";
          }
          
          $subject       = file_get_contents($file);
                
          $found = 0;
                
          $found = preg_match_all($pattern, $subject, $matches, PREG_PATTERN_ORDER);	           
          
          $this->totalFound +=$found;
                      
          if($found)
          {
          	 $foundStr = "Found in $found places";
             $this->appendToLog($file, $foundStr);
          }
          
           
          if($this->isReplacingEnabled && $this->replacementKey && $found)
          {           
             $outputStr = preg_replace($pattern, $this->replacementKey, $subject);	                             
             $foundStr = "Found in $found places";
             $this->writeToFile($file, $outputStr);
             $this->appendToLog($file, $foundStr, $this->replacementKey);
            
          }
          elseif($this->isReplacingEnabled && $this->replacementKey == '')
          {
             $this->errorText .= "Replacement Text is not defined\n";
             $this->appendToLog($file, "Replacement Text is not defined", $this->replacementKey);
          }
          elseif(!found)
          {
             $this->appendToLog($file, "No matching Found", $this->replacementKey);
          }
          
       }//EO Method
       
       /**
       * Writes new data (after the replacement) to file
       * @param $file, $data
       * @return none
       */
       function writeToFile($file, $data)
       {           
          if(is_writable($file))
          {
             $fp = fopen($file, "w");
             fwrite($fp, $data);
             fclose($fp);	
          }
          else
          {
             $this->errorText .= "Can not replace text. File $file is not writable. \nPlease make it writable\n";	
          }
          
       }//EO Method
    
       /**
       * Appends log data to previous log data
       * @param filename, match string, replacement key if any
       * @return none
       */   
       function appendToLog($file, $matchStr, $replacementKey = null)
       {
       	  if($this->logString == '')
       	  {
       	     $this->logString = " --- Searching for '".$this->searchKey."' --- \n";
       	  } 
          
          if($replacementKey == null)
          {
             $this->logString .= "Searching File $file : " . $matchStr."\n";       	
          }
          else
          {
             $this->logString .= "Searching File $file : " . $matchStr.". Replaced by '$replacementKey'\n";       	
          }
          
       }//EO Method
       
       /**
       * Shows Log
       * @param none
       * @return none
       */
       function showLog()
       {
          $this->dBug("------ Total ".$this->totalFound." Matches Found -----");
          $this->dBug(nl2br($this->logString));              
          
          if($this->errorText!='')
          {
          	 $this->dBug("------Error-----");
             $this->dBug(nl2br($this->errorText));   	 	
          }
       }//EO Method
       
       /**
       * Writes log to file
       * @param log filename
       * @return none
       */
       function writeLogToFile($file)
       {      
          $fp = fopen($file, "wb") OR die("Can not open file <b>$file</b>");            
          fwrite($fp, $this->logString);
          fwrite($fp, "\n------ Total ".$this->totalFound." Matches Found -----\n");
          if($this->errorText!='')
          {
             fwrite($fp, "\n------Error-----\n");     
             fwrite($fp, $this->errorText);
          }
          
          fclose($fp);      
       }//EO Method
       
       /**
       * Dumps data
       * @param data to be dumped
       * @return none
       */
       function dBug($dump)
       {
          echo "<pre>";
          print_r($dump);
          echo "</pre>";	 
       }//EO Method
       
    } //End of class
    
    ?>

    Kullanım

    <?php
    $path = "a"; //setting search path
    //$logFile = "/projects/rupom/test_search/searchResult.txt"; //setting log file
    $aranan='Aradığım metin'; 
    $replace='değiştirlecek veri ';
    //$aranan='<TR><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH></TR>';
    //$replace='<TR><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH></TR><TR><TD COLSPAN="3" ALIGN="center">SELAM</TD></TR>';
    $obj = new TextSearch();
    $obj->setExtensions(array('html')); //setting extensions to search files within
    //$obj->addExtension('php');//adding an extension to search within
    $obj->setSearchKey($aranan);
    $obj->setReplacementKey($replace);//setting replacement text if you want to replace matches with that
    $obj->startSearching($path);//starting search
    //$obj->showLog();//showing log
    //$obj->writeLogToFile($logFile); //writting result to log file
    ?>
    Yukarıdakı kullanımda Find and Replace işlemi yapılmıştır.