1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
<?php
/**
* AJAX Function Call Stuff
*
* reqs:
* 1 - list all boards
* 2 - switch lock state on a given topic
* 3 - switch sticky state on a given topic
* @package boards
* @subpackage functions
*/
/**
* required setup
*/
require_once( '../bit_setup_inc.php' );
require_once( BOARDS_PKG_PATH.'BitBoardTopic.php' );
require_once( BOARDS_PKG_PATH.'BitBoardPost.php' );
require_once( BOARDS_PKG_PATH.'BitBoard.php' );
// Is package installed and enabled
$gBitSystem->verifyPackage( 'boards' );
// Now check permissions to access this page
$gBitSystem->verifyPermission( 'p_boards_read' );
function ajax_nice_error($errno, $errstr, $errfile, $errline) {
$errortype = array (
E_ERROR => array(
'desc'=>"Error",
'ignore'=>false),
E_WARNING => array(
'desc'=> "Warning",
'ignore'=>false),
E_PARSE => array(
'desc'=> "Parsing Error",
'ignore'=>false),
E_NOTICE => array(
'desc'=> "Notice",
'ignore'=>true),
E_CORE_ERROR => array(
'desc'=> "Core Error",
'ignore'=>false),
E_CORE_WARNING => array(
'desc'=> "Core Warning",
'ignore'=>false),
E_COMPILE_ERROR => array(
'desc'=> "Compile Error",
'ignore'=>false),
E_COMPILE_WARNING => array(
'desc'=> "Compile Warning",
'ignore'=>false),
E_USER_ERROR => array(
'desc'=> "User Error",
'ignore'=>false),
E_USER_WARNING => array(
'desc'=> "User Warning",
'ignore'=>false),
E_USER_NOTICE => array(
'desc'=> "User Notice",
'ignore'=>false),
E_STRICT => array(
'desc'=> "Runtime Notice",
'ignore'=>true),
);
// set of errors for which a var trace will be saved
if(!$errortype[$errno]['ignore']) {
$l = ob_get_level();
if ($l>0) {
$body = ob_get_contents();
ob_end_clean();
}
static $sent=false;
if (!$sent) {
header("HTTP/1.0 500 Internal Server Error");
echo "<h1>PHP Exception</h1>";
$sent=true;
}
$str= "<br />\n<b>{$errortype[$errno]['desc']}</b>: $errstr in <b>$errfile</b> on line <b>$errline</b>\n<br />\n";
echo $str;//. "<pre>". htmlspecialchars(var_export($vars,true))."</pre>";
if ($l>0) {
ob_start();
echo $body;
}
}
}
set_error_handler("ajax_nice_error");
switch ($_GET['req']) {
case 1:
$board = new BitBoard();
$boardList=$board->getBoardSelectList();
$gBitSmarty->assign_by_ref('boardList',$boardList);
$gBitSmarty->display('bitpackage:boards/ajax.tpl');
break;
case 2:
// Now check permissions to access this page
$gBitSystem->verifyPermission( 'p_boards_edit' );
require_once( BOARDS_PKG_PATH.'lookup_inc.php' );
if($gContent->lock($_REQUEST["is_locked"]) ) {
$gContent->load();
$gBitSmarty->assign_by_ref('flip',$gContent->getFlipFlop());
$gBitSmarty->assign('flip_name','is_locked');
$gBitSmarty->display('bitpackage:boards/flipswitch.tpl');
} else {
trigger_error(var_export($gContent->mErrors,true ));
}
break;
case 3:
// Now check permissions to access this page
$gBitSystem->verifyPermission( 'p_boards_edit' );
require_once( BOARDS_PKG_PATH.'lookup_inc.php' );
if($gContent->sticky($_REQUEST["is_sticky"]) ) {
$gContent->load();
$gBitSmarty->assign('flip',$gContent->getFlipFlop());
$gBitSmarty->assign('flip_name','is_sticky');
$gBitSmarty->display('bitpackage:boards/flipswitch.tpl');
} else {
trigger_error(var_export($gContent->mErrors,true ));
}
break;
case 4:
// Now check permissions to access this page
$gBitSystem->verifyPermission( 'p_boards_read' );
require_once( BOARDS_PKG_PATH.'lookup_inc.php' );
if($gContent->readTopicSet($_REQUEST["new"]) ) {
$gContent->load();
$gBitSmarty->assign_by_ref('flip',$gContent->getFlipFlop());
$gBitSmarty->assign('flip_name','new');
$gBitSmarty->display('bitpackage:boards/flipswitch.tpl');
} else {
trigger_error(var_export($gContent->mErrors,true ));
}
break;
case 5:
// Now check permissions to access this page
$gBitSystem->verifyPermission( 'p_boards_read' );
require_once( BOARDS_PKG_PATH.'lookup_inc.php' );
if($gContent->notify($_REQUEST["notify"]) ) {
$gContent->load();
$gBitSmarty->assign_by_ref('flip',$gContent->getFlipFlop());
$gBitSmarty->assign('flip_name','notify');
$gBitSmarty->display('bitpackage:boards/flipswitch.tpl');
} else {
trigger_error(var_export($gContent->mErrors,true ));
}
break;
case 10:
$comment = new BitBoardPost($_GET['comment_id']);
$comment->loadMetaData();
if (@$comment->verifyId($comment->mCommentId)) {
print $comment->mInfo['warned_message'];
} else {
trigger_error(var_export($comment->mErrors,true ));
}
break;
default:
break;
}
?>
|