Advertisement
Guest User

unzip.php

a guest
May 21st, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.52 KB | None | 0 0
  1. <?php
  2. /**
  3. * The Jembut
  4. * do not have shell access. E.g. if you want to upload a lot of files
  5. * The Jembut
  6. *
  7. *
  8. * @author Malaikat Galau
  9. * @license GNU GPL v3
  10. * @package attec.toolbox
  11. * @version 0.0.2 Alpha
  12. */
  13. $timestart = microtime(TRUE);
  14. $arc = new Unzipper;
  15. $timeend = microtime(TRUE);
  16. $time = $timeend - $timestart;
  17. class Unzipper {
  18. public $localdir = '.';
  19. public $zipfiles = array();
  20. public static $status = '';
  21. public function __construct() {
  22. //read directory and pick .zip and .gz files
  23. if ($dh = opendir($this->localdir)) {
  24. while (($file = readdir($dh)) !== FALSE) {
  25. if (pathinfo($file, PATHINFO_EXTENSION) === 'zip'
  26. || pathinfo($file, PATHINFO_EXTENSION) === 'gz'
  27. ) {
  28. $this->zipfiles[] = $file;
  29. }
  30. }
  31. closedir($dh);
  32. if(!empty($this->zipfiles)) {
  33. self::$status = '.zip or .gz files found, ready for extraction';
  34. }
  35. else {
  36. self::$status = '<span style="color:red; font-weight:bold;font-size:120%;">Error: No .zip or .gz files found.</span>';
  37. }
  38. }
  39. //check if an archive was selected for unzipping
  40. //check if archive has been selected
  41. $input = '';
  42. $input = strip_tags($_POST['zipfile']);
  43. //allow only local existing archives to extract
  44. if ($input !== '') {
  45. if (in_array($input, $this->zipfiles)) {
  46. self::extract($input, $this->localdir);
  47. }
  48. }
  49. }
  50. public static function extract($archive, $destination) {
  51. $ext = pathinfo($archive, PATHINFO_EXTENSION);
  52. if ($ext === 'zip') {
  53. self::extractZipArchive($archive, $destination);
  54. }
  55. else {
  56. if ($ext === 'gz') {
  57. self::extractGzipFile($archive, $destination);
  58. }
  59. }
  60. }
  61. /**
  62. * Decompress/extract a zip archive using ZipArchive.
  63. *
  64. * @param $archive
  65. * @param $destination
  66. */
  67. public static function extractZipArchive($archive, $destination) {
  68. // Check if webserver supports unzipping.
  69. if(!class_exists('ZipArchive')) {
  70. self::$status = '<span style="color:red; font-weight:bold;font-size:120%;">Error: Your PHP version does not support unzip functionality.</span>';
  71. return;
  72. }
  73. $zip = new ZipArchive;
  74. // Check if archive is readable.
  75. if ($zip->open($archive) === TRUE) {
  76. // Check if destination is writable
  77. if(is_writeable($destination . '/')) {
  78. $zip->extractTo($destination);
  79. $zip->close();
  80. self::$status = '<span style="color:green; font-weight:bold;font-size:120%;">Files unzipped successfully</span>';
  81. }
  82. else {
  83. self::$status = '<span style="color:red; font-weight:bold;font-size:120%;">Error: Directory not writeable by webserver.</span>';
  84. }
  85. }
  86. else {
  87. self::$status = '<span style="color:red; font-weight:bold;font-size:120%;">Error: Cannot read .zip archive.</span>';
  88. }
  89. }
  90. /**
  91. * Decompress a .gz File.
  92. *
  93. * @param $archive
  94. * @param $destination
  95. */
  96. public static function extractGzipFile($archive, $destination) {
  97. // Check if zlib is enabled
  98. if(!function_exists('gzopen')) {
  99. self::$status = '<span style="color:red; font-weight:bold;font-size:120%;">Error: Your PHP has no zlib support enabled.</span>';
  100. return;
  101. }
  102. $filename = pathinfo($archive, PATHINFO_FILENAME);
  103. $gzipped = gzopen($archive, "rb");
  104. $file = fopen($filename, "w");
  105. while ($string = gzread($gzipped, 4096)) {
  106. fwrite($file, $string, strlen($string));
  107. }
  108. gzclose($gzipped);
  109. fclose($file);
  110. // Check if file was extracted.
  111. if(file_exists($destination . '/' . $filename)) {
  112. self::$status = '<span style="color:green; font-weight:bold;font-size:120%;">File unzipped successfully.</span>';
  113. }
  114. else {
  115. self::$status = '<span style="color:red; font-weight:bold;font-size:120%;">Error unzipping file.</span>';
  116. }
  117. }
  118. }
  119. ?>
  120.  
  121. <!DOCTYPE html>
  122. <head>
  123. <title>Jancok</title>
  124. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  125. <style type="text/css">
  126. <!--
  127. body {
  128. font-family: Arial, serif;
  129. line-height: 150%;
  130. }
  131. fieldset {
  132. border: 0px solid #000;
  133. }
  134. .select {
  135. padding: 5px;
  136. font-size: 110%;
  137. }
  138. .status {
  139. margin-top: 20px;
  140. padding: 5px;
  141. font-size: 80%;
  142. background: #EEE;
  143. border: 1px dotted #DDD;
  144. }
  145. .submit {
  146. -moz-box-shadow: inset 0px 1px 0px 0px #bbdaf7;
  147. -webkit-box-shadow: inset 0px 1px 0px 0px #bbdaf7;
  148. box-shadow: inset 0px 1px 0px 0px #bbdaf7;
  149. background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #79bbff), color-stop(1, #378de5));
  150. background: -moz-linear-gradient(center top, #79bbff 5%, #378de5 100%);
  151. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#79bbff', endColorstr='#378de5');
  152. background-color: #79bbff;
  153. -moz-border-radius: 4px;
  154. -webkit-border-radius: 4px;
  155. border-radius: 4px;
  156. border: 1px solid #84bbf3;
  157. display: inline-block;
  158. color: #ffffff;
  159. font-family: arial;
  160. font-size: 15px;
  161. font-weight: bold;
  162. padding: 10px 24px;
  163. text-decoration: none;
  164. text-shadow: 1px 1px 0px #528ecc;
  165. }
  166. .submit:hover {
  167. background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #378de5), color-stop(1, #79bbff));
  168. background: -moz-linear-gradient(center top, #378de5 5%, #79bbff 100%);
  169. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#378de5', endColorstr='#79bbff');
  170. background-color: #378de5;
  171. }
  172. .submit:active {
  173. position: relative;
  174. top: 1px;
  175. }
  176. /* This imageless css button was generated by CSSButtonGenerator.com */
  177. -->
  178. </style>
  179. </head>
  180.  
  181. <body>
  182. </script>
  183.  
  184. <br>
  185. <br>
  186.  
  187.  
  188. <div align="center"><table border="0" width="70%"><tr><td>
  189.  
  190.  
  191.  
  192. <h1><font face="Bradley Hand ITC"><center><SCRIPT>
  193.  
  194.  
  195.  
  196. farbbibliothek = new Array();
  197.  
  198.  
  199.  
  200. farbbibliothek[0] = new Array("#FF0000","#FF1100","#FF2200","#FF3300","#FF4400","#FF5500","#FF6600","#FF7700","#FF8800","#FF9900","#FFaa00","#FFbb00","#FFcc00","#FFdd00","#FFee00","#FFff00","#FFee00","#FFdd00","#FFcc00","#FFbb00","#FFaa00","#FF9900","#FF8800","#FF7700","#FF6600","#FF5500","#FF4400","#FF3300","#FF2200","#FF1100");
  201.  
  202.  
  203.  
  204. farbbibliothek[1] = new Array("#FF0000","#FFFFFF","#FFFFFF","#FF0000");
  205.  
  206.  
  207.  
  208. farbbibliothek[2] = new Array("#FFFFFF","#FF0000","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF");
  209.  
  210.  
  211.  
  212. farbbibliothek[3] = new Array("#FF0000","#FF4000","#FF8000","#FFC000","#FFFF00","#C0FF00","#80FF00","#40FF00","#00FF00","#00FF40","#00FF80","#00FFC0","#00FFFF","#00C0FF","#0080FF","#0040FF","#0000FF","#4000FF","#8000FF","#C000FF","#FF00FF","#FF00C0","#FF0080","#FF0040");
  213.  
  214.  
  215.  
  216. farbbibliothek[4] = new Array("#FF0000","#EE0000","#DD0000","#CC0000","#BB0000","#AA0000","#990000","#880000","#770000","#660000","#550000","#440000","#330000","#220000","#110000","#000000","#110000","#220000","#330000","#440000","#550000","#660000","#770000","#880000","#990000","#AA0000","#BB0000","#CC0000","#DD0000","#EE0000");
  217.  
  218.  
  219. farbbibliothek[5] = new Array("#FF0000","#FF0000","#FF0000","#FFFFFF","#FFFFFF","#FFFFFF");
  220.  
  221.  
  222. farbbibliothek[6] = new Array("#FF0000","#FDF5E6");
  223.  
  224.  
  225.  
  226. farben = farbbibliothek[4];
  227.  
  228.  
  229.  
  230. function farbschrift()
  231.  
  232.  
  233.  
  234. {
  235.  
  236.  
  237.  
  238. for(var i=0 ; i<Buchstabe.length; i++)
  239.  
  240.  
  241.  
  242. {
  243.  
  244.  
  245.  
  246. document.all["a"+i].style.color=farben[i];
  247.  
  248.  
  249.  
  250. }
  251.  
  252.  
  253.  
  254. farbverlauf();
  255.  
  256.  
  257.  
  258. }
  259.  
  260.  
  261.  
  262. function string2array(text)
  263.  
  264.  
  265.  
  266. {
  267.  
  268.  
  269.  
  270. Buchstabe = new Array();
  271.  
  272.  
  273.  
  274. while(farben.length<text.length)
  275.  
  276.  
  277.  
  278. {
  279.  
  280.  
  281.  
  282. farben = farben.concat(farben);
  283.  
  284.  
  285.  
  286. }
  287.  
  288.  
  289.  
  290. k=0;
  291.  
  292.  
  293.  
  294. while(k<=text.length)
  295.  
  296.  
  297.  
  298. {
  299.  
  300.  
  301.  
  302. Buchstabe[k] = text.charAt(k);
  303.  
  304.  
  305.  
  306. k++;
  307.  
  308.  
  309.  
  310. }
  311.  
  312.  
  313.  
  314. }
  315.  
  316.  
  317.  
  318. function divserzeugen()
  319.  
  320.  
  321.  
  322. {
  323.  
  324.  
  325.  
  326. for(var i=0 ; i<Buchstabe.length; i++)
  327.  
  328.  
  329.  
  330. {
  331.  
  332.  
  333.  
  334. document.write("<span id='a"+i+"' class='a"+i+"'>"+Buchstabe[i] + "</span>");
  335.  
  336.  
  337.  
  338. }
  339.  
  340.  
  341.  
  342. farbschrift();
  343.  
  344.  
  345.  
  346. }
  347.  
  348.  
  349.  
  350. var a=1;
  351.  
  352.  
  353.  
  354. function farbverlauf()
  355.  
  356.  
  357.  
  358. {
  359.  
  360.  
  361.  
  362. for(var i=0 ; i<farben.length; i++)
  363.  
  364.  
  365.  
  366. {
  367.  
  368.  
  369.  
  370. farben[i-1]=farben[i];
  371.  
  372.  
  373.  
  374. }
  375.  
  376.  
  377.  
  378. farben[farben.length-1]=farben[-1];
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386. setTimeout("farbschrift()",30);
  387.  
  388.  
  389.  
  390. }
  391.  
  392.  
  393.  
  394. //
  395.  
  396.  
  397.  
  398. var farbsatz=1;
  399.  
  400.  
  401.  
  402. function farbtauscher()
  403.  
  404.  
  405.  
  406. {
  407.  
  408.  
  409.  
  410. farben = farbbibliothek[farbsatz];
  411.  
  412.  
  413.  
  414. while(farben.length<text.length)
  415.  
  416.  
  417.  
  418. {
  419.  
  420.  
  421.  
  422. farben = farben.concat(farben);
  423.  
  424.  
  425.  
  426. }
  427.  
  428.  
  429.  
  430. farbsatz=Math.floor(Math.random()*(farbbibliothek.length-0.0001));
  431.  
  432.  
  433.  
  434. }
  435.  
  436.  
  437.  
  438. setInterval("farbtauscher()",9000);
  439.  
  440.  
  441.  
  442. text ="INDONESIA GALAUERS ";//h
  443.  
  444.  
  445.  
  446. string2array(text);
  447.  
  448.  
  449.  
  450. divserzeugen();
  451.  
  452.  
  453.  
  454. //document.write(text);
  455.  
  456.  
  457.  
  458.  
  459. </SCRIPT>
  460.  
  461. <p>Malaikat Galau defacer tersakiti</p>
  462.  
  463. <form action="" method="POST">
  464. <fieldset>
  465.  
  466. <select name="zipfile" size="1" class="select">
  467. <?php foreach ($arc->zipfiles as $zip) {
  468. echo "<option>$zip</option>";
  469. }
  470. ?>
  471. </select>
  472.  
  473. <br/>
  474.  
  475. <input type="submit" name="submit" class="submit" value="Unzip Archive"/>
  476.  
  477. </fieldset>
  478. </form>
  479. <p class="status">
  480. Status: <?php echo $arc::$status; ?>
  481. <br/>
  482. Processingtime: <?php echo $time; ?> ms
  483. </p>
  484. </body>
  485. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement