ZLIB.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. namespace ZN\Compression\Drivers;
  3. use ZN\Compression\CompressInterface;
  4. class ZlibDriver implements CompressInterface
  5. {
  6. //----------------------------------------------------------------------------------------------------
  7. //
  8. // Yazar : Ozan UYKUN <ozanbote@windowslive.com> | <ozanbote@gmail.com>
  9. // Site : www.zntr.net
  10. // Lisans : The MIT License
  11. // Telif Hakkı: Copyright (c) 2012-2016, zntr.net
  12. //
  13. //----------------------------------------------------------------------------------------------------
  14. public function __construct()
  15. {
  16. if( ! isPhpVersion('5.4.0') )
  17. {
  18. die(getErrorMessage('Error', 'invalidVersion', ['%' => 'zlib_', '#' => '5.4.0']));
  19. }
  20. }
  21. public function extract($source = '', $target = '.', $password = NULL)
  22. {
  23. // Bu sürücü tarafından desteklenmemektedir!
  24. return false;
  25. }
  26. public function write($file = NULL, $data = NULL, $mode = NULL)
  27. {
  28. // Bu sürücü tarafından desteklenmemektedir!
  29. return false;
  30. }
  31. public function read($file = '', $length = 1024, $mode = 'r')
  32. {
  33. // Bu sürücü tarafından desteklenmemektedir!
  34. return false;
  35. }
  36. public function compress($data = '', $blockSize = NULL, $workFactor = NULL)
  37. {
  38. // Bu sürücü tarafından desteklenmemektedir!
  39. return false;
  40. }
  41. public function uncompress($data = '', $small = 0)
  42. {
  43. // Bu sürücü tarafından desteklenmemektedir!
  44. return false;
  45. }
  46. /******************************************************************************************
  47. * ENCODE *
  48. *******************************************************************************************
  49. | Genel Kullanım: Zlibli bir dizge oluşturur. |
  50. | |
  51. ******************************************************************************************/
  52. public function encode($data = '', $level = -1, $encoding = ZLIB_ENCODING_GZIP)
  53. {
  54. if( ! is_scalar($data) )
  55. {
  56. return \Errors::set('Error', 'valueParameter', '1.(data)');
  57. }
  58. if( ! is_numeric($level) || ! is_numeric($encoding) )
  59. {
  60. return \Errors::set('Error', 'numericParameter', '2.(level) & 3.(encoding)');
  61. }
  62. return zlib_encode($data, $encoding, $level);
  63. }
  64. /******************************************************************************************
  65. * DECODE *
  66. *******************************************************************************************
  67. | Genel Kullanım: Gzipli bir dizgenin sıkıştırmasını açar. |
  68. | |
  69. ******************************************************************************************/
  70. public function decode($data = '', $length = 0)
  71. {
  72. if( ! is_scalar($data) )
  73. {
  74. return \Errors::set('Error', 'valueParameter', '1.(data)');
  75. }
  76. if( ! is_numeric($length) )
  77. {
  78. return \Errors::set('Error', 'numericParameter', '2.(length)');
  79. }
  80. return zlib_decode ($data, $length);
  81. }
  82. public function deflate($data = NULL, $level = NULL, $encoding = NULL)
  83. {
  84. // Bu sürücü tarafından desteklenmemektedir!
  85. return false;
  86. }
  87. public function inflate($data = NULL, $length = NULL)
  88. {
  89. // Bu sürücü tarafından desteklenmemektedir!
  90. return false;
  91. }
  92. }