Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.50 KB | None | 0 0
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4.  
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6.  
  7. <style content="text/css">
  8. body
  9. {
  10. background-color: #FFFFFF;
  11. color: #191919;
  12. font: 8pt arial,tahoma,sans-serif;
  13. }
  14. a
  15. {
  16. text-decoration: none;
  17. }
  18. a:link
  19. {
  20. color: #000000;
  21. }
  22. a:visited
  23. {
  24. color: #7D7D7D;
  25. }
  26. a:hover
  27. {
  28. color: #000000;
  29. text-decoration: underline;
  30. }
  31. a:active
  32. {
  33. color: #000000;
  34. }
  35. .disabled
  36. {
  37. color: #FFFFFF;
  38. }
  39. </style>
  40.  
  41. <?PHP
  42.  
  43. function GetFileContents($filename)
  44. {
  45. if (function_exists('file_get_contents'))
  46. return file_get_contents($filename);
  47.  
  48. $handle = @fopen($filename, "rt");
  49. if (!$handle)
  50. return false;
  51. $contents = fread($handle, filesize($filename));
  52. fclose($handle);
  53. return $contents;
  54. }
  55.  
  56. function GetFileList($path)
  57. {
  58. $list = array();
  59. $list[0] = '';
  60. if ( ($dir = @opendir($path)) )
  61. {
  62. while (($file = readdir($dir)) !== false)
  63. {
  64. if (preg_match('/\.(jpe?g|png)$/i', $file) > 0)
  65. {
  66. $list[] = $file;
  67. }
  68. }
  69. }
  70. natcasesort($list);
  71.  
  72. $list = array_values($list);
  73. unset($list[0]);
  74. return $list;
  75. }
  76.  
  77. function SizeToStr($size)
  78. {
  79. $ss = array(' bytes', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb');
  80.  
  81. $base = floor(log($size) / log(1024));
  82.  
  83. if ($base == 0)
  84. return $size . ' ' . $ss[0];
  85.  
  86. // for the future minded
  87. $base = min($base, 5);
  88.  
  89. $size /= 1 << ($base * 10);
  90.  
  91. return round($size, 2) . $ss[$base];
  92. }
  93.  
  94. function DisplayImage($id)
  95. {
  96. global $files;
  97.  
  98. $image = intval($id);
  99.  
  100. $vars = array();
  101. $vars['TITLE'] = $image;
  102. $vars['COUNT'] = '/' . count($files);
  103.  
  104. if ($image < 1) {
  105. return DisplayImage(1);
  106. }
  107.  
  108. if ($image > count($files)) {
  109. return DisplayImage(count($files));
  110. }
  111.  
  112. if ($image > 1) {
  113. $vars['FIRST'] = '<a href="index.php?id=1><b>FIRST</b></a>';
  114. $vars['PREV'] = '<a href="index.php?id=' . ($image - 1) . '"><b>PREV</b></a>';
  115. } else {
  116. $vars['PREV'] = '<span class="disabled">PREV</span>';
  117. $vars['FIRST'] = '<span class="disabled">FIRST</span>';
  118. }
  119.  
  120. if ($image < count($files)) {
  121. $vars['NEXT'] = '<a href="index.php?id=' . ($image + 1) . '"><b>NEXT</b></a>';
  122. $vars['LAST'] = '<a href="index.php?id=' . count($files) . '"><b>LAST</b></a>';
  123. } else {
  124. $vars['NEXT'] = '<span class="disabled">NEXT</span>';
  125. $vars['LAST'] = '<span class="disabled">LAST</span>';
  126. }
  127.  
  128. $vars['IMAGE'] = '<a href="index.php"></a>&nbsp;&nbsp;&nbsp;' . $image;
  129. $vars['IMAGESRC'] = $files[$image];
  130.  
  131.  
  132. echo '<title>' . $vars['TITLE'] . '</title>' . "\n";
  133. echo "</head>\n<body>";
  134. echo '<p>';
  135. echo $vars['FIRST'] . '&nbsp;&nbsp;&nbsp;' . $vars['PREV'] . '&nbsp;&nbsp;&nbsp;' . $vars['NEXT'] . '&nbsp;&nbsp;&nbsp;' . $vars['IMAGE'] . $vars['COUNT'];
  136. echo '</p>';
  137. echo '<p><img src="' . $vars['IMAGESRC'] . '"></p>';
  138. }
  139.  
  140. function DisplayIndex()
  141. {
  142. global $files;
  143.  
  144. $image = intval($id);
  145.  
  146. $vars = array();
  147. $vars['TITLE'] = $image;
  148. $vars['COUNT'] = '/' . count($files);
  149.  
  150. if ($image > 1) {
  151. $vars['FIRST'] = '<a href="index.php?id=1><b>FIRST</b></a>';
  152. $vars['PREV'] = '<a href="index.php?id=' . ($image - 1) . '"><b>PREV</b></a>';
  153. } else {
  154. $vars['PREV'] = '<span class="disabled">PREV</span>';
  155. $vars['FIRST'] = '<span class="disabled">FIRST</span>';
  156. }
  157.  
  158. if ($image < count($files)) {
  159. $vars['NEXT'] = '<a href="index.php?id=' . ($image + 1) . '"><b>NEXT</b></a>';
  160. $vars['LAST'] = '<a href="index.php?id=' . count($files) . '"><b>LAST</b></a>';
  161. } else {
  162. $vars['NEXT'] = '<span class="disabled">NEXT</span>';
  163. $vars['LAST'] = '<span class="disabled">LAST</span>';
  164. }
  165.  
  166.  
  167. $vars['IMAGE'] = '<a href="index.php"></a>&nbsp;&nbsp;&nbsp;' . $image;
  168. $vars['IMAGESRC'] = $files[$image];
  169.  
  170.  
  171. echo '<title>' . $vars['TITLE'] . '</title>' . "\n";
  172. echo "</head>\n<body>";
  173. echo '<p>';
  174. echo $vars['FIRST'] . '&nbsp;&nbsp;&nbsp;' . $vars['PREV'] . '&nbsp;&nbsp;&nbsp;' . $vars['NEXT'] . '&nbsp;&nbsp;&nbsp;' . $vars['LAST'] . '&nbsp;&nbsp;&nbsp;' . $vars['IMAGE'] . $vars['COUNT'];
  175. echo '</p>';
  176. echo '<p><img src="' . $vars['IMAGESRC'] . '"></p>';
  177. }
  178.  
  179. $files = GetFileList('.');
  180.  
  181. if (isset($_GET['id']) && is_numeric($_GET['id']))
  182. {
  183. // single image mode
  184. $id = $_GET['id'];
  185. DisplayImage($id);
  186. } else {
  187. // index list mode
  188. DisplayIndex();
  189. }
  190.  
  191. ?>
  192.  
  193. </body>
  194. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement