PageRenderTime 44ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/modules/lightbox/lightbox.Manage.php

http://compactcms.googlecode.com/
PHP | 220 lines | 162 code | 20 blank | 38 comment | 35 complexity | 6d5fa20d61ef5672d3a6d39ea073b999 MD5 | raw file
Possible License(s): GPL-3.0, CC0-1.0
  1. <?php
  2. /* ************************************************************
  3. Copyright (C) 2008 - 2010 by Xander Groesbeek (CompactCMS.nl)
  4. Revision: CompactCMS - v 1.4.1
  5. This file is part of CompactCMS.
  6. CompactCMS is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. CompactCMS is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. A reference to the original author of CompactCMS and its copyright
  15. should be clearly visible AT ALL TIMES for the user of the back-
  16. end. You are NOT allowed to remove any references to the original
  17. author, communicating the product to be your own, without written
  18. permission of the original copyright owner.
  19. You should have received a copy of the GNU General Public License
  20. along with CompactCMS. If not, see <http://www.gnu.org/licenses/>.
  21. > Contact me for any inquiries.
  22. > E: Xander@CompactCMS.nl
  23. > W: http://community.CompactCMS.nl/forum
  24. ************************************************************ */
  25. // Include general configuration
  26. require_once('../../sitemap.php');
  27. $canarycage = md5(session_id());
  28. $currenthost= md5($_SERVER['HTTP_HOST']);
  29. $do = (isset($_GET['do'])?$_GET['do']:null);
  30. // Get permissions
  31. $perm = $db->QuerySingleRowArray("SELECT * FROM ".$cfg['db_prefix']."cfgpermissions");
  32. // Fill array with albums
  33. $albums = array();
  34. $count = array();
  35. $index = 0;
  36. if ($handle = opendir(BASE_PATH.'/media/albums/')) {
  37. while (false !== ($file = readdir($handle))) {
  38. if ($file != "." && $file != ".svn" && $file != ".." && is_dir(BASE_PATH.'/media/albums/'.$file)) {
  39. // Fill albums array
  40. $albums[] = $file;
  41. // Count files in album
  42. if ($countdir = opendir(BASE_PATH.'/media/albums/'.$file)) {
  43. $count[$index] = '0';
  44. while (false !== ($counthandle = readdir($countdir))) {
  45. $ext = substr($counthandle, strrpos($counthandle, '.') + 1);
  46. if (substr($counthandle,0,6)!="thumb-"&&$ext=="jpg"||$ext=="jpeg"||$ext=="png"||$ext=="gif") {
  47. $count[$index]++;
  48. }
  49. } closedir($countdir);
  50. }
  51. $index++;
  52. }
  53. }
  54. closedir($handle);
  55. }
  56. ?>
  57. <?php if(checkAuth($canarycage,$currenthost) && isset($_SESSION['rc1']) && !empty($_SESSION['rc2'])) { ?>
  58. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  59. <html>
  60. <head>
  61. <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  62. <title>Lightbox module</title>
  63. <link rel="stylesheet" type="text/css" href="../../../admin/img/styles/base.css,layout.css,sprite.css,uploader.css" />
  64. <script type="text/javascript" src="../../includes/js/mootools.js" charset="utf-8"></script>
  65. <script type="text/javascript" src="../../../admin/includes/fancyupload/Source/Uploader/Swiff.Uploader.js"></script>
  66. <script type="text/javascript" src="../../../admin/includes/fancyupload/Source/Uploader/Fx.ProgressBar.js"></script>
  67. <script type="text/javascript" src="../../../admin/includes/fancyupload/FancyUpload2.js"></script>
  68. <script type="text/javascript" src="../../../admin/includes/fancyupload/modLightbox.js"></script>
  69. </head>
  70. <body>
  71. <div class="module">
  72. <div class="center <?php echo (isset($_GET['status'])?$_GET['status']:null); ?>">
  73. <?
  74. // Show relevant statuses
  75. if(isset($_GET['msg'])) {
  76. if($_GET['msg']=="writerr") { echo $ccms['lang']['system']['error_dirwrite']; }
  77. elseif($_GET['msg']=="created"||$_GET['msg']=="success") { echo $ccms['lang']['backend']['success']; }
  78. elseif($_GET['msg']=="duperr") { echo $ccms['lang']['system']['error_exists']; }
  79. elseif($_GET['msg']=="invalid"||$_GET['msg']=="failed") { echo $ccms['lang']['system']['error_value']; }
  80. } ?>
  81. </div>
  82. <div class="span-13 colborder">
  83. <?php
  84. //
  85. $album_path = (isset($_GET['album'])&&!empty($_GET['album'])?BASE_PATH.'/media/albums/'.$_GET['album']:null);
  86. $album_path = (is_dir($album_path)?$album_path:null);
  87. if($album_path==null) { ?>
  88. <form action="lightbox.Process.php?action=del-album" method="post" accept-charset="utf-8">
  89. <h2>Current albums</h2>
  90. <table border="0" cellspacing="5" cellpadding="5">
  91. <?php if($_SESSION['ccms_userLevel']>=$perm['manageModLightbox']) { ?><th class="span-1">&#160;</th><?php } ?>
  92. <th class="span-7">Album</th>
  93. <th class="span-2">Files</th>
  94. <th class="span-2">&#160;</th>
  95. </tr>
  96. <?php
  97. $i = 0;
  98. foreach ($albums as $value) {
  99. // Alternate rows
  100. if($i%2 != '1') {
  101. echo '<tr style="background-color: #E6F2D9;">';
  102. } else {
  103. echo '<tr>';
  104. } ?>
  105. <?php if($_SESSION['ccms_userLevel']>=$perm['manageModLightbox']) { ?>
  106. <td><input type="checkbox" name="albumID[<?php echo $i+1;?>]" value="<?php echo $value; ?>" id="newsID"></td>
  107. <?php } ?>
  108. <td><span class="ss_sprite ss_folder_picture"><a href="lightbox.Manage.php?album=<?php echo $value;?>"><?php echo $value;?></a></span></td>
  109. <td><span class="ss_sprite ss_pictures"><?php echo ($count[$i]>0?$count[$i]:'0'); ?></span></td>
  110. <td><span class="ss_sprite ss_eye"><a href="">Preview</a></span></td>
  111. </tr>
  112. <?php
  113. $i++;
  114. } ?>
  115. </table>
  116. <hr />
  117. <?php if($_SESSION['ccms_userLevel']>=$perm['manageModLightbox']) { ?><button type="submit" name="deleteAlbum"><span class="ss_sprite ss_bin_empty">Delete</span></button><?php } ?>
  118. </form>
  119. <?php } elseif($album_path!=null) {
  120. // Load all images
  121. $images = array();
  122. if ($handle = opendir($album_path)) {
  123. while (false !== ($file = readdir($handle))) {
  124. $ext = substr($file, strrpos($file, '.') + 1);
  125. if (substr($file,0,6)!="thumb-"&&$ext=="jpg"||$ext=="jpeg"||$ext=="png"||$ext=="gif") {
  126. $images[$file] = '../../../media/albums/'.$_GET['album'].'/thumb-'.$file;
  127. }
  128. } closedir($handle);
  129. } ?>
  130. <h2>Album content</h2>
  131. <?php foreach ($images as $key => $value) { ?>
  132. <?php if($_SESSION['ccms_userLevel']>=$perm['manageModLightbox']) {?>
  133. <a href="lightbox.Process.php?album=<?php echo $_GET['album']; ?>&amp;image=<?php echo $key; ?>&amp;action=del-image"><img src="<?php echo $value; ?>" class="thumbview" alt="Thumbnail of <?php echo $key; ?>" /></a>
  134. <?php } else { ?>
  135. <img src="<?php echo $value; ?>" class="thumbview" alt="Thumbnail of <?php echo $key; ?>" />
  136. <?php } ?>
  137. <?php } ?>
  138. <p class="clear right"><span class="ss_sprite ss_arrow_undo"><a href="lightbox.Manage.php">All albums</a></span></p>
  139. <?php } ?>
  140. </div>
  141. <div class="span-8">
  142. <?php if(!isset($_GET['album'])&&empty($_GET['album'])) { ?>
  143. <h2>Create new album</h2>
  144. <?php if($_SESSION['ccms_userLevel']>=$perm['manageModLightbox']) {?>
  145. <form action="lightbox.Process.php?action=create-album" method="post" accept-charset="utf-8">
  146. <label for="album">Album name</label><input type="text" class="text" style="width:185px;" name="album" value="" id="album" />
  147. <button type="submit"><span class="ss_sprite ss_wand">Create</span></button>
  148. </form>
  149. <?php } else echo $ccms['lang']['auth']['featnotallowed']; ?>
  150. <hr class="space" />
  151. <?php } ?>
  152. <h2>Upload content</h2>
  153. <?php if($_SESSION['ccms_userLevel']>=$perm['manageModLightbox']) {?>
  154. <form action="./lightbox.Process.php?action=save-files" method="post" enctype="multipart/form-data" id="lightboxForm">
  155. <label for="album" style="margin-right:5px;display:inline;">Upload to existing album</label>
  156. <select name="album" id="album" class="span-4" size="1">
  157. <?php foreach ($albums as $value) { ?>
  158. <option <?php echo (isset($_GET['album'])&&$_GET['album']===$value?"selected":null); ?> value="<?php echo $value; ?>"><?php echo $value; ?></option>
  159. <?php } ?>
  160. </select>
  161. <hr class="space"/>
  162. <div id="lightbox-fallback">
  163. <form action="lightbox.Process.php?action=save-files" method="post" accept-charset="utf-8">
  164. <strong>Single file upload</strong><br/>
  165. <p>The Flash loader failed to initialize. Make sure Javascript is enabled and Flash is installed. Single file uploads are possible, but not optimized.</p>
  166. <label for="lightbox-photoupload">Upload a single photo</label>
  167. <input id="lightbox-photoupload" type="file" name="ccms_file" />
  168. <p><button type="submit"><span class="ss_sprite ss_add">Upload</span></button></p>
  169. </form>
  170. </div>
  171. <div id="lightbox-status" class="hide">
  172. <p>
  173. <span class="ss_sprite ss_folder_image"><a href="#" id="lightbox-browse">Browse files</a></span> |
  174. <span class="ss_sprite ss_cross"><a href="#" id="lightbox-clear">Clear list</a></span> |
  175. <span class="ss_sprite ss_picture_save"><a href="#" id="lightbox-upload">Start upload</a></span>
  176. </p>
  177. <div>
  178. <strong class="overall-title"></strong><br />
  179. <img src="../../../admin/includes/fancyupload/Assets/bar.gif" class="progress overall-progress" />
  180. </div>
  181. <div>
  182. <strong class="current-title"></strong><br />
  183. <img src="../../../admin/includes/fancyupload/Assets/bar.gif" class="progress current-progress" />
  184. </div>
  185. <div class="current-text"></div>
  186. </div>
  187. <ul id="lightbox-list"></ul>
  188. </form>
  189. <?php } else echo $ccms['lang']['auth']['featnotallowed']; ?>
  190. </div>
  191. </div>
  192. </body>
  193. </html>
  194. <?php } else die("No external access to file");?>