Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <style content="text/css">
- body
- {
- background-color: #FFFFFF;
- color: #191919;
- font: 8pt arial,tahoma,sans-serif;
- }
- a
- {
- text-decoration: none;
- }
- a:link
- {
- color: #000000;
- }
- a:visited
- {
- color: #7D7D7D;
- }
- a:hover
- {
- color: #000000;
- text-decoration: underline;
- }
- a:active
- {
- color: #000000;
- }
- .disabled
- {
- color: #FFFFFF;
- }
- </style>
- <?PHP
- function GetFileContents($filename)
- {
- if (function_exists('file_get_contents'))
- return file_get_contents($filename);
- $handle = @fopen($filename, "rt");
- if (!$handle)
- return false;
- $contents = fread($handle, filesize($filename));
- fclose($handle);
- return $contents;
- }
- function GetFileList($path)
- {
- $list = array();
- $list[0] = '';
- if ( ($dir = @opendir($path)) )
- {
- while (($file = readdir($dir)) !== false)
- {
- if (preg_match('/\.(jpe?g|png)$/i', $file) > 0)
- {
- $list[] = $file;
- }
- }
- }
- natcasesort($list);
- $list = array_values($list);
- unset($list[0]);
- return $list;
- }
- function SizeToStr($size)
- {
- $ss = array(' bytes', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb');
- $base = floor(log($size) / log(1024));
- if ($base == 0)
- return $size . ' ' . $ss[0];
- // for the future minded
- $base = min($base, 5);
- $size /= 1 << ($base * 10);
- return round($size, 2) . $ss[$base];
- }
- function DisplayImage($id)
- {
- global $files;
- $image = intval($id);
- $vars = array();
- $vars['TITLE'] = $image;
- $vars['COUNT'] = '/' . count($files);
- if ($image < 1) {
- return DisplayImage(1);
- }
- if ($image > count($files)) {
- return DisplayImage(count($files));
- }
- if ($image > 1) {
- $vars['FIRST'] = '<a href="index.php?id=1><b>FIRST</b></a>';
- $vars['PREV'] = '<a href="index.php?id=' . ($image - 1) . '"><b>PREV</b></a>';
- } else {
- $vars['PREV'] = '<span class="disabled">PREV</span>';
- $vars['FIRST'] = '<span class="disabled">FIRST</span>';
- }
- if ($image < count($files)) {
- $vars['NEXT'] = '<a href="index.php?id=' . ($image + 1) . '"><b>NEXT</b></a>';
- $vars['LAST'] = '<a href="index.php?id=' . count($files) . '"><b>LAST</b></a>';
- } else {
- $vars['NEXT'] = '<span class="disabled">NEXT</span>';
- $vars['LAST'] = '<span class="disabled">LAST</span>';
- }
- $vars['IMAGE'] = '<a href="index.php"></a> ' . $image;
- $vars['IMAGESRC'] = $files[$image];
- echo '<title>' . $vars['TITLE'] . '</title>' . "\n";
- echo "</head>\n<body>";
- echo '<p>';
- echo $vars['FIRST'] . ' ' . $vars['PREV'] . ' ' . $vars['NEXT'] . ' ' . $vars['IMAGE'] . $vars['COUNT'];
- echo '</p>';
- echo '<p><img src="' . $vars['IMAGESRC'] . '"></p>';
- }
- function DisplayIndex()
- {
- global $files;
- $image = intval($id);
- $vars = array();
- $vars['TITLE'] = $image;
- $vars['COUNT'] = '/' . count($files);
- if ($image > 1) {
- $vars['FIRST'] = '<a href="index.php?id=1><b>FIRST</b></a>';
- $vars['PREV'] = '<a href="index.php?id=' . ($image - 1) . '"><b>PREV</b></a>';
- } else {
- $vars['PREV'] = '<span class="disabled">PREV</span>';
- $vars['FIRST'] = '<span class="disabled">FIRST</span>';
- }
- if ($image < count($files)) {
- $vars['NEXT'] = '<a href="index.php?id=' . ($image + 1) . '"><b>NEXT</b></a>';
- $vars['LAST'] = '<a href="index.php?id=' . count($files) . '"><b>LAST</b></a>';
- } else {
- $vars['NEXT'] = '<span class="disabled">NEXT</span>';
- $vars['LAST'] = '<span class="disabled">LAST</span>';
- }
- $vars['IMAGE'] = '<a href="index.php"></a> ' . $image;
- $vars['IMAGESRC'] = $files[$image];
- echo '<title>' . $vars['TITLE'] . '</title>' . "\n";
- echo "</head>\n<body>";
- echo '<p>';
- echo $vars['FIRST'] . ' ' . $vars['PREV'] . ' ' . $vars['NEXT'] . ' ' . $vars['LAST'] . ' ' . $vars['IMAGE'] . $vars['COUNT'];
- echo '</p>';
- echo '<p><img src="' . $vars['IMAGESRC'] . '"></p>';
- }
- $files = GetFileList('.');
- if (isset($_GET['id']) && is_numeric($_GET['id']))
- {
- // single image mode
- $id = $_GET['id'];
- DisplayImage($id);
- } else {
- // index list mode
- DisplayIndex();
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement