PageRenderTime 45ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/inc/php/unlink.php

https://bitbucket.org/linards/dzeerveniite
PHP | 42 lines | 34 code | 3 blank | 5 comment | 7 complexity | 1c11fb07bf51de63b1beccea787ec660 MD5 | raw file
Possible License(s): LGPL-2.1, MPL-2.0-no-copyleft-exception, GPL-2.0
  1. <?
  2. error_reporting(E_ALL);
  3. ini_set("display_errors", "1");
  4. include_once("../../config.php");
  5. include_once("../../functions.php");
  6. if($_REQUEST["op"] == "top_image"){
  7. @unlink("../../top-images/".$_REQUEST["img"]);
  8. @unlink("../../top-images/thumbs/".$_REQUEST["img"]);
  9. @unlink("../../top-images/pixelated/".$_REQUEST["img"]);
  10. header("Location: ../../admin.php?op=".$_REQUEST["op"]);
  11. }
  12. elseif($_REQUEST["op"] == "db_data"){
  13. @unlink($GLOBALS["cwd"].$_REQUEST["file"]);
  14. $path = explode("/",$_REQUEST["file"]);
  15. $length = count($path);
  16. $thumb[0] = "../..";
  17. for($i = 1; $i < $length; $i++){
  18. $thumb[] = $path[$i];
  19. if(($length - 2) == $i) $thumb[] = "thumbs";
  20. }
  21. @unlink($GLOBALS["cwd"].implode("/",$thumb));
  22. $sql->query("delete from files_$GLOBALS[db_lang] where file = '".filename_to_db(str_replace("/assets/", "", $_REQUEST["file"]))."'");
  23. //echo "delete * from files_$GLOBALS[db_lang] where file = '".filename_to_db(str_replace("/assets/", "", $_REQUEST["file"]))."' ";
  24. //var_dump($mysqli); die();
  25. echo "Fails $_REQUEST[file] dzēsts";
  26. }
  27. elseif($_REQUEST["op"] == "db_graphics"){
  28. $file = substr($GLOBALS["cwd"], 0, strlen($GLOBALS["cwd"]) - 1).$_REQUEST["file"];
  29. @unlink($file);
  30. //echo $file;
  31. $pi = pathinfo($file);
  32. @unlink($pi["dirname"]."/thumbs/".$pi["basename"]);
  33. @unlink($pi["dirname"]."/thumbs/".$GLOBALS["thumbsize"]."/".$pi["basename"]);
  34. $sql->query("delete from graphics_$GLOBALS[db_lang] where filename = '".$pi["basename"]."'");
  35. //echo "delete from graphics_$GLOBALS[db_lang] where filename = '".$pi["filename"]."'";
  36. //var_dump($mysqli); die();
  37. echo "Fails $_REQUEST[file] dzēsts";
  38. }
  39. ?>