/album.php

https://github.com/rninne/picManager · PHP · 125 lines · 96 code · 15 blank · 14 comment · 14 complexity · ef5fa7ffb175e865a738810fd2a1adb4 MD5 · raw file

  1. <?php
  2. /*** Include configuration scripts and image scaler
  3. */
  4. include('php/SimpleImage.php');
  5. include('php/iniProperties.php');
  6. /*** Set page defaults based on selection at choice of album page
  7. */
  8. if(isset($_GET['folder'])){
  9. $folder = $_GET['folder'];
  10. }else {
  11. $folder = 'photobooth';
  12. }
  13. //$username = $SESSION[''];
  14. //$userFolder = './users/'. $username;
  15. $dir = './images/'.$folder.'/';
  16. $files = scandir($dir);
  17. ?>
  18. <html>
  19. <head>
  20. <script src="js/prototype.js" type="text/javascript"></script>
  21. <script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
  22. <script type="text/javascript" src="js/lightbox.js"></script>
  23. <script type="text/javascript">
  24. var imagePosition = {};
  25. var imageList = [];
  26. function toggleImage(id){
  27. for(i=0; i<imageList.length; i++){
  28. if(imageList[i] == id){
  29. //image is already in the download list, remove it
  30. removeImageFromDownloads(id, i);
  31. updateURL();
  32. return;
  33. }
  34. }
  35. //image not found in imageList, add it
  36. addImageToDownloads(id);
  37. updateURL();
  38. }
  39. function removeImageFromDownloads(id, index){
  40. $('DL_'+id).remove();
  41. $('A_'+id).title = '<input id="CBL_'+ id +'" class="CBL" type="checkbox" onchange="toggleImage(\''+ id +'\')" /> Add to downloads';
  42. imageList.splice(index, 1);
  43. }
  44. function addImageToDownloads(id){
  45. $('downloads').insert('<div id="DL_'+ id +'" class="choice"><img src="<?php echo $dir ?>thumbs/small/'+ id +'.jpg" onmouseup="toggleImage(\''+ id +'\')" /><br />'+id+'</div>');
  46. $('A_'+id).title = '<input id="CBL_'+ id +'" class="CBL" type="checkbox" checked="checked" onchange="toggleImage(\''+ id +'\')" /> Add to downloads';
  47. imageList.push(id);
  48. }
  49. function updateURL(){
  50. $('DLZIP').href = 'zipDownload.php?folder=<?php echo $folder ?>&files=' + imageList.toString();
  51. }
  52. </script>
  53. <link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
  54. <?php
  55. if($folder == 'photobooth'){
  56. echo '<link rel="stylesheet" href="css/photobooth.css" type="text/css" media="screen" />';
  57. } else {
  58. echo '<link rel="stylesheet" href="css/thumbnails.css" type="text/css" media="screen" />';
  59. }
  60. ?>
  61. </head>
  62. <body>
  63. <?php
  64. /*** remove all non image files from the array
  65. */
  66. $i=0;
  67. foreach($files as $index => $file){
  68. //echo $dir.$file;
  69. if(is_dir($dir.$file)){
  70. array_splice($files, $index-$i, 1);
  71. $i++;
  72. }
  73. }
  74. ?>
  75. <div id="picContainer" style="clear:none;">
  76. <div class="row">
  77. <?php
  78. foreach($files as $index => $file){
  79. list($id, $extension) = preg_split('/\./', $file);
  80. if ($index%3 == 0) {
  81. //left
  82. echo '<div class="left">';
  83. } elseif ($index%3 == 1){
  84. //middle
  85. echo '<div class="middle">';
  86. } elseif ($index%3 == 2) {
  87. //right
  88. echo '<div class="right">';
  89. }
  90. echo <<<EOS
  91. <img src="${dir}thumbs/small/$file" id="$id" onclick="toggleImage('$id')"/>
  92. <br />
  93. <a id="A_$id" href="${dir}thumbs/large/$file" rel="lightbox[photobooth]" title="&lt;input id=&quot;CBL_$id&quot; class=&quot;CBL&quot; type=&quot;checkbox&quot; onchange=&quot;toggleImage('$id')&quot; /&gt; Add to downloads">Show in slide show</a>
  94. </div>
  95. EOS;
  96. if ($index%6 == 5) {
  97. echo <<<EOS
  98. </div>
  99. <div class="row">
  100. EOS;
  101. }
  102. }
  103. ?>
  104. </div>
  105. </div>
  106. <div id="downloads">
  107. <a id="DLZIP" href="#">Download .zip</a>
  108. </div>
  109. </body>
  110. </html>