PageRenderTime 1038ms CodeModel.GetById 34ms RepoModel.GetById 1ms app.codeStats 0ms

/library/sites/windowBox/pageThumbnailUpload.php

https://github.com/SamGoody/feindura-flat-file-cms
PHP | 202 lines | 145 code | 24 blank | 33 comment | 26 complexity | e244075fb0fddbd272f53aa4f0885b73 MD5 | raw file
  1. <?php
  2. /*
  3. feindura - Flat File Content Management System
  4. Copyright (C) Fabian Vogelsteller [frozeman.de]
  5. This program is free software;
  6. you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
  8. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  9. without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License along with this program;
  12. if not,see <http://www.gnu.org/licenses/>.
  13. * pageThumbnailUpload.php version 1.04
  14. */
  15. /**
  16. * Includes the login and filters the incoming data by xssFilter
  17. */
  18. require_once(dirname(__FILE__)."/../../includes/secure.include.php");
  19. $error = false;
  20. $response = false;
  21. $site = $_GET['site'];
  22. $page = $_GET['page'];
  23. $category = $_GET['category'];
  24. echo ' '; // hack for safari, otherwise it throws an error that he could not find htmlentities like &ouml;
  25. $pageContent = $generalFunctions->readPage($page,$category);
  26. $categoryRatio = false;
  27. $thumbRatioX = false;
  28. $thumbRatioY = false;
  29. $thumbRatio = false;
  30. // GET THUMBNAIL SIZE
  31. // --------------------------
  32. // THUMB WIDTH
  33. if(!empty($categoryConfig[$category]['thumbWidth'])) {
  34. $thumbWidth = $categoryConfig[$category]['thumbWidth'];
  35. $categoryRatio = true;
  36. } else
  37. $thumbWidth = $adminConfig['pageThumbnail']['width'];
  38. // THUMB HEIGHT
  39. if(!empty($categoryConfig[$category]['thumbHeight'])) {
  40. $thumbHeight = $categoryConfig[$category]['thumbHeight'];
  41. $categoryRatio = true;
  42. } else
  43. $thumbHeight = $adminConfig['pageThumbnail']['height'];
  44. // THUMB RATIO X
  45. if($categoryRatio) {
  46. if($categoryConfig[$category]['thumbRatio'] == 'y' ||
  47. $categoryConfig[$category]['thumbRatio'] == '') {
  48. //$thumbRatioX = ' disabled="disabled"';
  49. $thumbRatioX = true;
  50. $thumbRatio = 'y';
  51. }
  52. } else {
  53. if($adminConfig['pageThumbnail']['ratio'] == 'y' ||
  54. $adminConfig['pageThumbnail']['ratio'] == '') {
  55. //$thumbRatioX = ' disabled="disabled"';
  56. $thumbRatioX = true;
  57. $thumbRatio = 'y';
  58. }
  59. }
  60. // THUMB RATIO Y
  61. if($categoryRatio) {
  62. if($categoryConfig[$category]['thumbRatio'] == 'x' ||
  63. $categoryConfig[$category]['thumbRatio'] == '') {
  64. //$thumbRatioY = ' disabled="disabled"';
  65. $thumbRatioY = true;
  66. $thumbRatio = 'x';
  67. }
  68. } else {
  69. if($adminConfig['pageThumbnail']['ratio'] == 'x' ||
  70. $adminConfig['pageThumbnail']['ratio'] == '') {
  71. //$thumbRatioY = ' disabled="disabled"';
  72. $thumbRatioY = true;
  73. $thumbRatio = 'x';
  74. }
  75. }
  76. ?>
  77. <h1><?php echo $langFile['pagethumbnail_h1_part1'].' &quot;<span style="color:#000000;">'.$pageContent['title'].'</span>&quot; '.$langFile['pagethumbnail_h1_part2']; ?></h1>
  78. <div id="thumbInfo">
  79. <ul>
  80. <li><?php echo $langFile['pagethumbnail_thumbinfo_formats']; ?><br /><b>JPG</b>, <b>JPEG</b>, <b>GIF</b>, <b>PNG</b></li>
  81. <li><?php echo $langFile['pagethumbnail_thumbinfo_filesize'].' <b>'.ini_get('upload_max_filesize').'B</b>'; ?></li>
  82. <li><b><?php echo $langFile['pagethumbnail_thumbinfo_standardthumbsize']; ?></b><br />
  83. <?php
  84. if($thumbRatioY) echo $langFile['pagethumbnail_thumbsize_width'].' = <b>'.$thumbWidth.'</b> '.$langFile['THUMBNAIL_TEXT_UNIT'].'<br />';
  85. if($thumbRatioX) echo $langFile['pagethumbnail_thumbsize_height'].' = <b>'.$thumbHeight.'</b> '.$langFile['THUMBNAIL_TEXT_UNIT'];
  86. ?>
  87. </li>
  88. </ul>
  89. </div>
  90. <div style="position: relative">
  91. <!-- <form action="?site=pageThumbnail&amp;category=<?php echo $category; ?>&amp;id=<?php echo $page; ?>" id="pageThumbnailUploadForm" enctype="multipart/form-data" method="post" onsubmit="requestSite('<?php echo $_SERVER['PHP_SELF']; ?>','','pageThumbnailUploadForm');return false;" accept-charset="UTF-8"> -->
  92. <form action="library/processes/thumbnailUpload.process.php" id="pageThumbnailUploadForm" enctype="multipart/form-data" method="post" onsubmit="startUploadAnimation();" target="uploadTargetFrame" accept-charset="UTF-8">
  93. <input type="hidden" name="upload" value="true" />
  94. <input type="hidden" name="category" value="<?php echo $category; ?>" />
  95. <input type="hidden" name="id" value="<?php echo $page; ?>" />
  96. <input type="hidden" name="thumbRatio" value="<?php echo $thumbRatio; ?>" />
  97. <!-- file selection -->
  98. <h2><?php echo $langFile['pagethumbnail_field1']; ?></h2>
  99. <input type="file" name="thumbFile" />
  100. <br />
  101. <br />
  102. <a href="#" id="thumbSizeToogle" class="down"><?php echo $langFile['pagethumbnail_thumbsize_h1']; ?></a><br />
  103. <br clear="all"/>
  104. <table id="thumbSize">
  105. <?php
  106. // -> THUMB-WIDTH
  107. if($thumbRatioY) {
  108. ?>
  109. <tr><td style="width: 80px">
  110. <label for="windowBox_thumbWidth">
  111. <?php echo $langFile['pagethumbnail_thumbsize_width'] ?></label>
  112. </td><td>
  113. <input id="windowBox_thumbWidth" name="thumbWidth" class="short" value="<?php echo $thumbWidth; ?>"<?php echo $thumbRatioX; ?> />
  114. <?php echo $langFile['pagethumbnail_thumbsize_unit']; ?>
  115. </td></tr>
  116. <!-- shows the width in a scale -->
  117. <?php
  118. if($thumbWidth)
  119. $styleThumbWidth = 'width:'.$thumbWidth.'px';
  120. else
  121. $styleThumbWidth = 'width:0px';
  122. ?>
  123. <tr><td>
  124. </td><td style="height:40px;">
  125. <div id="windowBox_thumbWidthScale" class="scale" style="<?php echo $styleThumbWidth; ?>"><div></div></div>
  126. </td></tr>
  127. <?php
  128. }
  129. // -> THUMB-HEIGHT
  130. if($thumbRatioX) {
  131. ?>
  132. <tr><td style="width: 80px">
  133. <label for="windowBox_thumbHeight">
  134. <?php echo $langFile['pagethumbnail_thumbsize_height'] ?></label>
  135. </td><td>
  136. <input id="windowBox_thumbHeight" name="thumbHeight" class="short" value="<?php echo $thumbHeight; ?>"<?php echo $thumbRatioY; ?> />
  137. <?php echo $langFile['pagethumbnail_thumbsize_unit']; ?>
  138. </td></tr>
  139. <!-- shows the height in a scale -->
  140. <?php
  141. if($thumbHeight)
  142. $styleThumbHeight = 'width:'.$thumbHeight.'px';
  143. else
  144. $styleThumbHeight = 'width:0px';
  145. ?>
  146. <tr><td>
  147. </td><td style="height:40px;">
  148. <div id="windowBox_thumbHeightScale" class="scale" style="<?php echo $styleThumbHeight; ?>"><div></div></div>
  149. </td></tr>
  150. <?php
  151. }
  152. ?>
  153. </table>
  154. <!-- show a PREVIEW of the current THUMBNAIL -->
  155. <?php
  156. // show thumbnail if the page has one
  157. if(!empty($pageContent['thumbnail'])) {
  158. $thumbnailWidth = @getimagesize(DOCUMENTROOT.$adminConfig['uploadPath'].$adminConfig['pageThumbnail']['path'].$pageContent['thumbnail']);
  159. if($thumbnailWidth[0] <= 250)
  160. $thumbnailWidth = ' width="'.$thumbnailWidth[0].'"';
  161. else
  162. $thumbnailWidth = ' width="250"';
  163. echo '<div style="z-index:0; position:relative; width: 280px; margin-bottom: 10px; float:right; text-align: center;">';
  164. echo '<img src="'.$adminConfig['uploadPath'].$adminConfig['pageThumbnail']['path'].$pageContent['thumbnail'].'" class="thumbnailPreview toolTip"'.$thumbnailWidth.' alt="thumbnail" title="'.$adminConfig['uploadPath'].$adminConfig['pageThumbnail']['path'].$pageContent['thumbnail'].'::'.$langFile['THUMBNAIL_TOOLTIP_PREVIEW'].'" />';
  165. echo '</div>';
  166. }
  167. ?>
  168. <input type="submit" value="" class="button thumbnailUpload" title="<?php echo $langFile['pagethumbnail_submit_tip']; ?>" />
  169. </form>
  170. </div>
  171. <!-- ok button, after upload -->
  172. <a href="?category=<?= $category; ?>&amp;page=<?= $page; ?>" onclick="closeWindowBox('index.php?site=<?= $site; ?>&amp;category=<?= $category; ?>&amp;page=<?= $page; ?>');return false;" id="pageThumbnailOkButton" class="ok center">&nbsp;</a>
  173. <!-- UPLOAD IFRAME -->
  174. <iframe id="uploadTargetFrame" name="uploadTargetFrame" src="library/processes/thumbnailUpload.process.php"></iframe>