PHP | Gelişmiş Lisanslama Mekanizması - CACHE Entegreli

  • HyperFilter | DoS Protection | DDoS Protection | DoS Mitigation | DDoS Mitigation | AntiDoS | AntiDDoS | Proxy Shielding

saintx

Karizma Cüce
Kayıtlı Üye
Katılım
12 Mart 2012
Mesajlar
250
Reaction score
0
Puanları
18
Yaş
29
Web sitesi
saintx.net
Merhaba arkadaşlar,



Sistemi tamamiyle değiştirdim ve sınıfsal bir yapıya kavuşturdum.Sizlerin yorumları doğrultusunda cache sistemini entegre ettim.

Öncelikle nasıl kuracağınızı adım adım anlatacağım.



1-) alttaki kodu lisans.php diyerek ana dizine kaydediyoruz.

Konu link görüntülemek için konuya cevap yazmalısınız.
Kod:
<?php

	

	class checklicense

	{

		

		protected $cl_license_server;

		protected $cl_ip_address;

		protected $cl_product_key;

		protected $cl_license_array;

		

		/* önbellekleme değişkenleri */

		

		protected $cl_cache_time;

		protected $cl_cache_file;

		

		public function __construct($license_server, $cache_time)

		{

			$this->cl_ip_address		= $_SERVER['HTTP_HOST'];

			$this->cl_product_key		= null;

			$this->cl_license_server	= $license_server;

			$this->cl_cache_time		= $cache_time;

			$this->cl_cache_file		= 'cache/'.md5($this->cl_license_server.$this->cl_ip_address).'.cache';

			/* Çalıştırmalar */

			$this->_check_ip_address();

			$this->_create_product_key();

			if( $this->_is_available_cache() != true )

			{

				$this->_write_cache($this->cl_cache_file, $this->_get_license_file());

				$this->_check_license($this->_read_cache($this->cl_cache_file));

			}

			else

			{

				$this->_check_license($this->_read_cache($this->cl_cache_file));

			}

		}

		

		/* IP Kontrolleri */

		

		protected function _check_ip_address()

		{

			if( ! is_numeric(substr($this->cl_ip_address, 0, 3)) )

			{

				if( substr($this->cl_ip_address, 0, 4) == 'www.' )

				{

					$this->cl_ip_address = substr($this->cl_ip_address, 4);

				}

			}

		}

		

		/* Ürün anahtarı oluşturma ve kontroller */

		

		protected function _create_product_key()

		{

			$this->cl_product_key = wordwrap(strtoupper(md5(sha1(sha1($this->cl_product_key)))), 4, '-', true);

		}

		

		protected function _check_license(array $data)

		{

			if( ! in_array($this->cl_product_key, $data) )

			{

				die($_SERVER['HTTP_HOST'].' isimli sunucunuzun lisansı bulunmamaktadır.');

				exit;

			}

		}

		

		/* Uzak sunucudan dosya okuma işlemleri */

		

		protected function _get_license_file()

		{

			if( function_exists('file') )

			{

				$file = file($this->cl_license_server, FILE_IGNORE_NEW_LINES);

				$data = array();

				foreach($file as $key => $value)

				{

					$data[$key] = rtrim($value, '\r\n');

				}

				return $data;

			}

		}

		

		/* Önbellekleme Fonksiyonları */

		

		protected function _is_available_cache()

		{

			$this->cl_cache_file = 'cache/'.md5($this->cl_license_server.$this->cl_ip_address).'.cache';

			if( ! file_exists($this->cl_cache_file) ) return false;

			$this->cl_cache_time = $this->cl_cache_time * 60;

			if( time() - filemtime($this->cl_cache_file) > $this->cl_cache_time )

			{

				unlink($this->cl_cache_file);

				return false;

			}

			return true;

		}

		

		protected function _write_cache($path, $data)

		{

			$handler = fopen($path, 'a');

			fwrite($handler, serialize($data));

			fclose($handler);

		}

		

		protected function _read_cache($path)

		{

			$data = unserialize(file_get_contents($path));

			return $data;

		}

	}

	

?>

2-) scriptinizin kilit dosyalarından bir tanesine şu kodları en üst kısma ekliyoruz. ;

Konu link görüntülemek için konuya cevap yazmalısınız.
PHP:
include('lisans.php');

new checklicense('http://127.0.0.1:81/lisans.txt', 10); // 1. parametre lisans dosyası 2. parametre kaç dakika cache kalacak.

3-) lisanslamak istediğiniz sunucu için bir adet key oluşturmanız gerekir bu key'i ise şu kodlar ile oluşturacağız.

Konu link görüntülemek için konuya cevap yazmalısınız.
Kod:
<?php

    

    $lisans_adresi = 'www.saintx.net';

    $olustur = wordwrap(strtoupper(md5(sha1(sha1($lisans_adresi)))), 4, '-', true);

    echo $lisans_adresi.'\'i için oluşturulan ürün anahtarı ;';

    echo '

';

    echo $olustur;

    

?>

4-) yemeğimiz hazır 🙂 iyi forumlar ben .ogün! ~~ saintx
 
Teşekkürler ogün 🙂
 
Teşekkürler Ogün 🙂
 
Bi sistem de ben paylaşayım bundan biraz farklı benim paylaşacağım biraz daha kolay olucak yani gapışceesek gapılaım 🙂
 
Deneyek 🙂

[MENTION=74]ognkrks[/MENTION] sanki aşılabilir gibi, şu cache olayından bir açık düşündüm hani.
 
[MENTION=74]ognkrks[/MENTION] sayesinde php yi öğrenip çıkıcam 😀
 
bunu ioncube ile şifrelemek gerek.
 
Upssssssssss :
 
Geri
Üst Alt
Reklam
Reklam