PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/admin/includes/delete_item.php

https://bitbucket.org/mpercy/deeemm-cms
PHP | 54 lines | 16 code | 12 blank | 26 comment | 4 complexity | 69a73694555bed5752fa3dee1acea4eb MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause
  1. <?php
  2. defined( '_INDM' ) or die( 'POSSIBLE HACK ATTEMPT!' );
  3. /*===========================================================================
  4. Check user priviledges
  5. ===========================================================================*/
  6. require VALIDATE;
  7. if ($user != 'ADMIN') header("Location: " . $default_url . "index.php");
  8. if ($action == 'delete') {
  9. $sql_query = mysql_query("SELECT * FROM `" . $db_table_prefix . 'cat_' . "$page` WHERE `id` = '$id'");
  10. while($sql_result = mysql_fetch_array($sql_query)){
  11. $filename = $sql_result[image];
  12. }
  13. // //check to make sure image stored in image field not used elsewhere
  14. // //may need to only check this for media type articles
  15. // $no_times_used = 1;
  16. // for($count=0;$count<$num_tables+1;$count++){
  17. // $sql_query = mysql_query("SELECT * FROM `" . $db_table_prefix . $all_tables[$count] . "` WHERE `title_lan_" . $language . "` LIKE '%" . $filename . "%' OR `description_lan_" . $language . "` LIKE '%" . $filename . "%' ");
  18. //
  19. // while($sql_result = @mysql_fetch_array($sql_query)){
  20. // //keep tally of number of times file used
  21. // $no_times_used += 1;
  22. // //generate list of items for the messagebox
  23. // $file_list .= '<a href = "' . $default_url . 'index.php?page=' . $all_tables[$count] . '&id=' . $sql_result[id] . '">' . $sql_result['title_lan_'.$language] . '</a><br>';
  24. // }
  25. // }
  26. //
  27. // if ($no_times_used > 1) {
  28. // $page = 'messagebox';
  29. // $warning_message = $lan['image_used'] . $file_list;
  30. // } else {
  31. //delete image
  32. unlink ("$media_dir/$filename");
  33. //remove article
  34. mysql_query("DELETE FROM `" . $db_table_prefix . 'cat_' . "$page` WHERE `id` = '$id'");
  35. //defragment table
  36. mysql_query("ALTER TABLE `" . $db_table_prefix . 'cat_' . "$page` ENGINE=INNODB");
  37. //return to where you came from
  38. header("Location: " . $default_url . "index.php");
  39. exit;
  40. // }
  41. }
  42. ?>