PageRenderTime 90ms CodeModel.GetById 38ms RepoModel.GetById 1ms app.codeStats 0ms

/update_07-01-04/administration/images.php

https://github.com/frostzhenya/php
PHP | 138 lines | 113 code | 8 blank | 17 comment | 39 complexity | 114525e261bcf0bb6a93f361b4c39e08 MD5 | raw file
  1. <?php
  2. /*-------------------------------------------------------+
  3. | PHP-Fusion Content Management System
  4. | Copyright (C) 2002 - 2010 Nick Jones
  5. | http://www.php-fusion.co.uk/
  6. +--------------------------------------------------------+
  7. | Filename: images.php
  8. | Author: Nick Jones (Digitanium)
  9. +--------------------------------------------------------+
  10. | This program is released as free software under the
  11. | Affero GPL license. You can redistribute it and/or
  12. | modify it under the terms of this license which you
  13. | can read by viewing the included agpl.txt or online
  14. | at www.gnu.org/licenses/agpl.html. Removal of this
  15. | copyright header is strictly prohibited without
  16. | written permission from the original author(s).
  17. +--------------------------------------------------------*/
  18. require_once "../maincore.php";
  19. require_once THEMES."templates/admin_header.php";
  20. include LOCALE.LOCALESET."admin/image_uploads.php";
  21. if (!checkrights("IM") || !defined("iAUTH") || $_GET['aid'] != iAUTH) { redirect("../index.php"); }
  22. if (isset($_GET['action']) && $_GET['action'] = "update") include INCLUDES."buildlist.php";
  23. $folders = array("images" => IMAGES, "imagesa" => IMAGES_A, "imagesn" => IMAGES_N, "imagesnc" => IMAGES_NC);
  24. if (isset($_GET['ifolder']) && ctype_alnum($_GET['ifolder']) == 1 && isset($folders[$_GET['ifolder']])) {
  25. $_GET['ifolder'] = stripinput($_GET['ifolder']);
  26. $afolder = $folders[$_GET['ifolder']];
  27. } else {
  28. $_GET['ifolder'] = "images"; $afolder = IMAGES;
  29. }
  30. // List images
  31. $image_list = makefilelist($afolder, ".|..", true, "files", "php|js|ico|DS_Store|SVN");
  32. if ($image_list) {
  33. $image_count = count($image_list);
  34. } else {
  35. $image_count = 0;
  36. }
  37. if (isset($_GET['status'])) {
  38. if ($_GET['status'] == "del") {
  39. $title = $locale['400'];
  40. $message = "<strong>".$locale['401']."</strong>";
  41. } elseif ($_GET['status'] == "upn") {
  42. $title = $locale['420'];
  43. $message = "<strong>".$locale['425']."</strong>";
  44. } elseif ($_GET['status'] == "upy") {
  45. $title = $locale['420'];
  46. $message = "<img src='".$afolder.stripinput($_GET['img'])."' alt='".stripinput($_GET['img'])."' /><br /><br />\n<strong>".$locale['426']."</strong>";
  47. }
  48. opentable($title);
  49. echo "<div style='text-align:center'>".$message."</div>\n";
  50. closetable();
  51. }
  52. if (isset($_GET['del']) && in_array($_GET['del'], $image_list)) {
  53. unlink($afolder.stripinput($_GET['del']));
  54. if ($settings['tinymce_enabled'] == 1) { include INCLUDES."buildlist.php"; }
  55. redirect(FUSION_SELF.$aidlink."&status=del&ifolder=".$_GET['ifolder']);
  56. } elseif (isset($_POST['uploadimage'])) {
  57. $error = "";
  58. $image_types = array(
  59. ".gif",
  60. ".GIF",
  61. ".jpeg",
  62. ".JPEG",
  63. ".jpg",
  64. ".JPG",
  65. ".png",
  66. ".PNG"
  67. );
  68. $imgext = strrchr(strtolower($_FILES['myfile']['name']), ".");
  69. $imgname = stripfilename(strtolower(substr($_FILES['myfile']['name'], 0, strrpos($_FILES['myfile']['name'], "."))));
  70. $imgsize = $_FILES['myfile']['size'];
  71. $imgtemp = $_FILES['myfile']['tmp_name'];
  72. if (!in_array($imgext, $image_types)) {
  73. redirect(FUSION_SELF.$aidlink."&status=upn&ifolder=".$_GET['ifolder']);
  74. } elseif (is_uploaded_file($imgtemp)){
  75. move_uploaded_file($imgtemp, $afolder.$imgname.$imgext);
  76. @chmod($afolder.$imgname.$imgext, 0644);
  77. if ($settings['tinymce_enabled'] == 1) { include INCLUDES."buildlist.php"; }
  78. redirect(FUSION_SELF.$aidlink."&status=upy&ifolder=".$_GET['ifolder']."&img=".$imgname.$imgext);
  79. }
  80. } else {
  81. opentable($locale['420']);
  82. echo "<form name='uploadform' method='post' action='".FUSION_SELF.$aidlink."&amp;ifolder=".$_GET['ifolder']."' enctype='multipart/form-data'>\n";
  83. echo "<table cellpadding='0' cellspacing='0' width='350' class='center'>\n<tr>\n";
  84. echo "<td width='80' class='tbl'>".$locale['421']."</td>\n";
  85. echo "<td class='tbl'><input type='file' name='myfile' class='textbox' style='width:250px;' /></td>\n";
  86. echo "</tr>\n<tr>\n";
  87. echo "<td align='center' colspan='2' class='tbl'>\n";
  88. echo "<input type='submit' name='uploadimage' value='".$locale['420']."' class='button' style='width:100px;' /></td>\n";
  89. echo "</tr>\n</table>\n</form>\n";
  90. closetable();
  91. if (isset($_GET['view']) && in_array($_GET['view'], $image_list)) {
  92. opentable($locale['440']);
  93. echo "<div style='text-align:center'><br />\n";
  94. $image_ext = strrchr($afolder.stripinput($_GET['view']),".");
  95. if (in_array($image_ext, array(".gif",".GIF",".ico",".jpg",".JPG",".jpeg",".JPEG",".png",".PNG"))) {
  96. echo "<img src='".$afolder.stripinput($_GET['view'])."' alt='".stripinput($_GET['view'])."' /><br /><br />\n";
  97. } else {
  98. echo $locale['441']."<br /><br />\n";
  99. }
  100. echo "<a href='".FUSION_SELF.$aidlink."&amp;ifolder=".$_GET['ifolder']."&amp;del=".stripinput($_GET['view'])." onclick=\"return confirm('".$locale['470']."');\"'>".$locale['442']."</a>";
  101. echo "<br /><br />\n<a href='".FUSION_SELF.$aidlink."'>".$locale['402']."</a><br /><br />\n</div>\n";
  102. closetable();
  103. } else {
  104. opentable($locale['460']);
  105. echo "<table cellpadding='0' cellspacing='1' width='450' class='tbl-border center'>\n<tr>\n";
  106. echo "<td align='center' colspan='2' class='tbl2'>\n";
  107. echo "<span style='font-weight:".($_GET['ifolder'] == "images" ? "bold" : "normal")."'><a href='".FUSION_SELF.$aidlink."&amp;ifolder=images'>".$locale['422']."</a></span> |\n";
  108. echo "<span style='font-weight:".($_GET['ifolder'] == "imagesa" ? "bold" : "normal")."'><a href='".FUSION_SELF.$aidlink."&amp;ifolder=imagesa'>".$locale['423']."</a></span> |\n";
  109. echo "<span style='font-weight:".($_GET['ifolder'] == "imagesn" ? "bold" : "normal")."'><a href='".FUSION_SELF.$aidlink."&amp;ifolder=imagesn'>".$locale['424']."</a></span> |\n";
  110. echo "<span style='font-weight:".($_GET['ifolder'] == "imagesnc" ? "bold" : "normal")."'><a href='".FUSION_SELF.$aidlink."&amp;ifolder=imagesnc'>".$locale['427']."</a></span>\n";
  111. echo "</td>\n</tr>\n";
  112. if ($image_list) {
  113. for ($i=0; $i < $image_count; $i++) {
  114. if ($i % 2 == 0) { $row_color = "tbl1"; } else { $row_color = "tbl2"; }
  115. echo "<tr>\n<td class='".$row_color."'>".$image_list[$i]."</td>\n";
  116. echo "<td align='right' width='1%' class='".$row_color."' style='white-space:nowrap'>\n";
  117. echo "<a href='".FUSION_SELF.$aidlink."&amp;ifolder=".$_GET['ifolder']."&amp;view=".$image_list[$i]."'>".$locale['461']."</a> -\n";
  118. echo "<a href='".FUSION_SELF.$aidlink."&amp;ifolder=".$_GET['ifolder']."&amp;del=".$image_list[$i]."' onclick=\"return confirm('".$locale['470']."');\">".$locale['462']."</a></td>\n";
  119. echo "</tr>\n";
  120. }
  121. if ($settings['tinymce_enabled'] == 1) echo "<tr>\n<td align='center' colspan='2' class='tbl1'><a href='".FUSION_SELF.$aidlink."&amp;ifolder=".$_GET['ifolder']."&amp;action=update'>".$locale['464']."</a></td>\n</tr>\n";
  122. } else {
  123. echo "<tr>\n<td align='center' class='tbl1'>".$locale['463']."</td>\n</tr>\n";
  124. }
  125. echo "</table>\n";
  126. closetable();
  127. }
  128. }
  129. require_once THEMES."templates/footer.php";
  130. ?>