PageRenderTime 63ms CodeModel.GetById 37ms RepoModel.GetById 0ms app.codeStats 0ms

/add.php

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