/ajax.php

https://github.com/tekimaki/boards · PHP · 102 lines · 79 code · 7 blank · 16 comment · 7 complexity · 7d1f02875d4c20bc9913eb9071ab46bd MD5 · raw file

  1. <?php
  2. /**
  3. * AJAX Function Call Stuff
  4. *
  5. * reqs:
  6. * 1 - list all boards
  7. * 2 - switch lock state on a given topic
  8. * 3 - switch sticky state on a given topic
  9. * @package boards
  10. * @subpackage functions
  11. */
  12. /**
  13. * required setup
  14. */
  15. require_once( '../kernel/setup_inc.php' );
  16. // Is package installed and enabled
  17. $gBitSystem->verifyPackage( 'boards' );
  18. // Now check permissions to access this page
  19. $gBitSystem->verifyPermission( 'p_boards_read' );
  20. function ajax_nice_error($errno, $errstr, $errfile, $errline) {
  21. $errortype = array (
  22. E_ERROR => array(
  23. 'desc'=>"Error",
  24. 'ignore'=>false),
  25. E_WARNING => array(
  26. 'desc'=> "Warning",
  27. 'ignore'=>false),
  28. E_PARSE => array(
  29. 'desc'=> "Parsing Error",
  30. 'ignore'=>false),
  31. E_NOTICE => array(
  32. 'desc'=> "Notice",
  33. 'ignore'=>true),
  34. E_CORE_ERROR => array(
  35. 'desc'=> "Core Error",
  36. 'ignore'=>false),
  37. E_CORE_WARNING => array(
  38. 'desc'=> "Core Warning",
  39. 'ignore'=>false),
  40. E_COMPILE_ERROR => array(
  41. 'desc'=> "Compile Error",
  42. 'ignore'=>false),
  43. E_COMPILE_WARNING => array(
  44. 'desc'=> "Compile Warning",
  45. 'ignore'=>false),
  46. E_USER_ERROR => array(
  47. 'desc'=> "User Error",
  48. 'ignore'=>false),
  49. E_USER_WARNING => array(
  50. 'desc'=> "User Warning",
  51. 'ignore'=>false),
  52. E_USER_NOTICE => array(
  53. 'desc'=> "User Notice",
  54. 'ignore'=>false),
  55. E_STRICT => array(
  56. 'desc'=> "Runtime Notice",
  57. 'ignore'=>true),
  58. );
  59. // set of errors for which a var trace will be saved
  60. if(!$errortype[$errno]['ignore']) {
  61. $l = ob_get_level();
  62. if ($l>0) {
  63. $body = ob_get_contents();
  64. ob_end_clean();
  65. }
  66. static $sent=false;
  67. if (!$sent) {
  68. header("HTTP/1.0 500 Internal Server Error");
  69. echo "<h1>PHP Exception</h1>";
  70. $sent=true;
  71. }
  72. $str= "<br />\n<b>{$errortype[$errno]['desc']}</b>: $errstr in <b>$errfile</b> on line <b>$errline</b>\n<br />\n";
  73. echo $str;//. "<pre>". htmlspecialchars(var_export($vars,true))."</pre>";
  74. if ($l>0) {
  75. ob_start();
  76. echo $body;
  77. }
  78. }
  79. }
  80. set_error_handler("ajax_nice_error");
  81. switch ($_GET['req']) {
  82. case 10:
  83. require_once( BOARDS_PKG_PATH.'BitBoardPost.php' );
  84. $comment = new BitBoardPost($_GET['comment_id']);
  85. $comment->loadMetaData();
  86. if (@$comment->verifyId($comment->mCommentId)) {
  87. print $comment->mInfo['warned_message'];
  88. } else {
  89. trigger_error(var_export($comment->mErrors,true ));
  90. }
  91. break;
  92. default:
  93. break;
  94. }
  95. ?>