PageRenderTime 39ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/delete.php

http://github.com/taylorchu/goolog
PHP | 93 lines | 88 code | 5 blank | 0 comment | 17 complexity | d33339ae35ef3c5d2cd0ed921b2a4816 MD5 | raw file
  1. <?php
  2. $out['self'] = 'delete';
  3. require 'header.php';
  4. if(isGETValidEntry('post', 'post') && isAdmin())
  5. {
  6. $postEntry = readEntry('post', $_GET['post']);
  7. $out['subtitle'] = lang('delete post : %s', $postEntry['title']);
  8. if(checkBot())
  9. {
  10. deleteEntry('post', $_GET['post']);
  11. if($postEntry['category'] !== '')
  12. {
  13. $categoryEntry = readEntry('category', $postEntry['category']);
  14. unset($categoryEntry['post'][$_GET['post']]);
  15. saveEntry('category', $postEntry['category'], $categoryEntry);
  16. }
  17. foreach($postEntry['reply'] as $reply)
  18. {
  19. deleteEntry('reply', $reply);
  20. }
  21. $out['content'] .= '<p><a href="index.php/post">? ' .$lang['redirect']. ' : ' .$lang['post']. '</a></p>';
  22. }
  23. else
  24. {
  25. $out['content'] .= form('delete.php/post/' .$_GET['post'],
  26. submit());
  27. }
  28. }
  29. else if(isGETValidEntry('reply', 'reply') && (isAdmin() || isAuthor($_GET['reply'])))
  30. {
  31. $replyEntry = readEntry('reply', $_GET['reply']);
  32. $out['subtitle'] = lang('delete reply');
  33. if(checkBot())
  34. {
  35. deleteEntry('reply', $_GET['reply']);
  36. $postEntry = readEntry('post', $replyEntry['post']);
  37. unset($postEntry['reply'][$_GET['reply']]);
  38. saveEntry('post', $replyEntry['post'], $postEntry);
  39. $out['content'] .= '<p><a href="view.php/post/' .$replyEntry['post']. '">? ' .$lang['redirect']. ' : ' .$postEntry['title']. '</a></p>';
  40. }
  41. else
  42. {
  43. $out['content'] .= form('delete.php/reply/' .$_GET['reply'],
  44. submit());
  45. }
  46. }
  47. else if(isGETValidEntry('link', 'link') && isAdmin())
  48. {
  49. $linkEntry = readEntry('link', $_GET['link']);
  50. $out['subtitle'] = lang('delete link : %s', $linkEntry['name']);
  51. if(checkBot())
  52. {
  53. deleteEntry('link', $_GET['link']);
  54. $out['content'] .= '<p><a href="index.php/post">? ' .$lang['redirect']. ' : ' .$lang['post']. '</a></p>';
  55. }
  56. else
  57. {
  58. $out['content'] .= form('delete.php/link/' .$_GET['link'],
  59. submit());
  60. }
  61. }
  62. else if(isGETValidEntry('category', 'category') && isAdmin())
  63. {
  64. $categoryEntry = readEntry('category', $_GET['category']);
  65. $out['subtitle'] = lang('delete category : %s', $categoryEntry['name']);
  66. if(checkBot())
  67. {
  68. deleteEntry('category', $_GET['category']);
  69. foreach($categoryEntry['post'] as $post)
  70. {
  71. $postEntry = readEntry('post', $post);
  72. $postEntry['category'] = '';
  73. saveEntry('post', $post, $postEntry);
  74. }
  75. $out['content'] .= '<p><a href="index.php/post">? ' .$lang['redirect']. ' : ' .$lang['post']. '</a></p>';
  76. }
  77. else
  78. {
  79. $out['content'] .= form('delete.php/category/' .$_GET['category'],
  80. submit());
  81. }
  82. }
  83. else
  84. {
  85. exit;
  86. }
  87. require 'footer.php';
  88. ?>