admin-up-icon.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. // by 请勿倒卖,已申请软著,否则追究法律责任
  3. include "../../system/db.class.php";
  4. $json = json_decode(stripslashes($_POST["post"]), true);
  5. if ($json["_id"] == "IN_WXQRCODE" || $json["_id"] == "IN_LOGO") {
  6. $filepart = pathinfo($_FILES["file"]["name"]);
  7. if (in_array(strtolower($filepart["extension"]), array("jpg", "jpeg", "gif", "png"))) {
  8. $file = "data/image/" . $json["_id"] . ".png";
  9. @move_uploaded_file($_FILES["file"]["tmp_name"], IN_ROOT . $file);
  10. echo $file;
  11. } else {
  12. echo "-1";
  13. }
  14. } else {
  15. $id = intval($json["_id"]);
  16. $aid = intval($json["_aid"]);
  17. $apw = $json["_apw"];
  18. $icon = db("app")->where("in_id", $id)->value("in_icon");
  19. if (!db("admin")->where("in_adminid", $aid)->value("in_adminid") || md5(db("admin")->where("in_adminid", $aid)->value("in_adminpassword")) !== $apw) {
  20. exit("Access denied");
  21. }
  22. if (!empty($_FILES)) {
  23. $in_icon = stristr($icon, "/") ? substr(strrchr($icon, "/"), 1) : $icon;
  24. $filepart = pathinfo($_FILES["file"]["name"]);
  25. if (in_array(strtolower($filepart["extension"]), array("jpg", "jpeg", "gif", "png"))) {
  26. $file = IN_ROOT . "data/attachment/" . $in_icon;
  27. @move_uploaded_file($_FILES["file"]["tmp_name"], $file);
  28. echo $in_icon;
  29. } else {
  30. echo "-1";
  31. }
  32. }
  33. }