-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mobiquoCommon.php
270 lines (236 loc) · 8.59 KB
/
mobiquoCommon.php
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
<?php
define('MBQ_IN_IT', true); /* is in mobiquo flag */
define('MBQ_REG_SHUTDOWN', true); /* register shutdown function flag */
require_once('MbqConfig.php');
$mbqDebug = false;
if(isset($_SERVER['HTTP_X_PHPDEBUG']))
{
if(isset($_SERVER['HTTP_X_PHPDEBUGCODE']))
{
$code = trim($_SERVER['HTTP_X_PHPDEBUGCODE']);
if (!class_exists('classTTConnection')){
require_once(MBQ_3RD_LIB_PATH.'classTTConnection.php');
}
$connection = new classTTConnection();
$response = $connection->actionVerification($code,'PHPDEBUG');
if($response)
{
$mbqDebug = $_SERVER['HTTP_X_PHPDEBUG'];
}
}
else if(file_exists(MBQ_PATH . 'debug.on'))
{
$mbqDebug = $_SERVER['HTTP_X_PHPDEBUG'];
}
}
define('MBQ_DEBUG', $mbqDebug); /* is in debug mode flag */
if (MBQ_DEBUG) {
ini_set('display_errors','1');
ini_set('display_startup_errors','1');
error_reporting($mbqDebug);
} else { // Turn off all error reporting
error_reporting(0);
ini_set('display_errors','0');
ini_set('display_startup_errors','0');
}
define('PHPBB_MSG_HANDLER', 'mobiquo_error_handler');
function mobiquo_error_handler($errno, $msg_text, $errfile, $errline)
{
global $auth, $user, $msg_long_text;
// Do not display notices if we suppress them via @
if (MBQ_DEBUG == 0 && $errno != E_USER_ERROR && $errno != E_USER_WARNING && $errno != E_USER_NOTICE)
{
return;
}
/*if(strpos($errfile, 'session.php') !== false)
{
return ;
}*/
if ($msg_text == 'NO_SEARCH_RESULTS')
{
$response = search_func();
echo $response;
exit;
}
if(preg_match('/vendor/', $errfile))
{
return;
}
if(!empty($user) && in_array('REPORTS_CLOSED_SUCCESS',$user->lang) && (strstr(strip_tags($msg_text),$user->lang['REPORTS_CLOSED_SUCCESS']) || strstr(strip_tags($msg_text),$user->lang['REPORT_CLOSED_SUCCESS'])))
{
MbqError::alert('', basic_clean($user->lang['REPORTS_CLOSED_SUCCESS']));
exit;
}
if(preg_match('/^SQL ERROR/', $msg_text))
{
MbqMain::$oMbqIo->alert("An SQL error occurred while fetching this page. Please contact the administrator if the problem persists.", true, null, $msg_text);
}
// Message handler is stripping text. In case we need it, we are possible to define long text...
if (isset($msg_long_text) && $msg_long_text && !$msg_text)
{
$msg_text = $msg_long_text;
}
$msg_text = basic_clean($msg_text);
if (!defined('E_DEPRECATED'))
{
define('E_DEPRECATED', 8192);
}
switch ($errno)
{
case E_NOTICE:
case E_WARNING:
// Check the error reporting level and return if the error level does not match
// If DEBUG is defined the default level is E_ALL
if (MBQ_DEBUG == 0)
{
return;
}
if (strpos($errfile, 'cache') === false && strpos($errfile, 'template.') === false)
{
$errfile = phpbb_filter_root_path($errfile);
$msg_text = phpbb_filter_root_path($msg_text);
$error_name = ($errno === E_WARNING) ? 'PHP Warning' : 'PHP Notice';
echo '[phpBB Debug] ' . $error_name . ': in file ' . $errfile . ' on line ' . $errline . ': ' . $msg_text . "\n";
}
return;
break;
case E_USER_ERROR:
if (!empty($user) && !empty($user->lang))
{
$msg_text = (!empty($user->lang[$msg_text])) ? $user->lang[$msg_text] : $msg_text;
}
garbage_collection();
break;
case E_USER_WARNING:
case E_USER_NOTICE:
define('IN_ERROR_HANDLER', true);
if (empty($user->data))
{
$user->session_begin();
}
// We re-init the auth array to get correct results on login/logout
$auth->acl($user->data);
if (empty($user->lang))
{
$user->setup();
}
if ($msg_text == 'ERROR_NO_ATTACHMENT' || $msg_text == 'NO_FORUM' || $msg_text == 'NO_TOPIC' || $msg_text == 'NO_USER')
{
//send_status_line(404, 'Not Found');
}
$msg_text = (!empty($user->lang[$msg_text])) ? $user->lang[$msg_text] : $msg_text;
break;
// PHP4 compatibility
case E_DEPRECATED:
return true;
break;
}
if (in_array($errno, array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE)))
{
if(!check_error_status($msg_text))
{
if (MBQ_DEBUG == -1) $msg_text .= " > $errfile, $errline";
MbqError::alert('', $msg_text);
exit;
}
}
// If we notice an error not handled here we pass this back to PHP by returning false
// This may not work for all php versions
return false;
}
/**
* frame main program
*/
Abstract Class MbqMain extends MbqBaseMain {
public static function init() {
parent::init();
self::$oMbqCm->changeWorkDir('..'); /* change work dir to parent dir.Important!!! */
self::regShutDown();
}
public static function getCurrentCmd()
{
global $tapatalk_cmd;
if (isset($_GET['method_name']) && $_GET['method_name']) { //for more flexibility
self::$cmd = $_GET['method_name'];
}
else if (isset($_POST['method_name']) && $_POST['method_name']) { //for upload_attach and other post method
self::$cmd = $_POST['method_name'];
foreach ($_POST as $k => $v) {
self::$input[$k] = $v;
}
}
if(!self::$cmd && isset($_SERVER['PATH_INFO']))
{
$splitArray = preg_split('[&?]',$_SERVER['PATH_INFO']);
$pathInfoCmd = $splitArray[0];
$pathInfoCmd = substr($pathInfoCmd, 1);
self::$cmd = $pathInfoCmd;
}
if(!self::$cmd && isset($tapatalk_cmd)) //for avatar.php
{
self::$cmd = $tapatalk_cmd;
}
return self::$cmd;
}
/**
* action
*/
public static function action() {
parent::action();
if (self::hasLogin()) {
header('Mobiquo_is_login: true');
} else {
header('Mobiquo_is_login: false');
}
self::$oMbqConfig->calCfg(); /* you should do some modify within this function in multiple different type applications! */
if (!self::$oMbqConfig->pluginIsOpen() && self::$cmd != 'get_config' && self::$cmd != 'set_forum_info' && self::$cmd != 'call_tapatalk_api') {
MbqError::alert('', self::$oMbqConfig->getPluginClosedMessage());
}
self::$cmd = self::getCurrentCmd();
if (self::$cmd) {
self::$cmd = (string) self::$cmd;
//MbqError::alert('', self::$cmd);
if (preg_match('/[A-Za-z0-9_]{1,128}/', self::$cmd)) {
$arr = explode('_', self::$cmd);
foreach ($arr as &$v) {
$v = ucfirst(strtolower($v));
}
$hookClassName = 'MbqHook'.implode('', $arr);
$actionClassName = 'MbqAct'.implode('', $arr);
if (self::$oClk->hasReg($actionClassName)) {
self::$oAct = self::$oClk->newObj($actionClassName);
if(file_exists(MBQ_HOOK_PATH . $hookClassName . '.php'))
{
include_once(MBQ_HOOK_PATH . $hookClassName . '.php');
self::$oAct = new $hookClassName();
self::$oAct->actionImplement(self::$oAct->getInput());
}
else
{
self::$oAct->actionImplement(self::$oAct->getInput());
}
} else {
//MbqError::alert('', "Not support action for ".self::$cmd."!", '', MBQ_ERR_NOT_SUPPORT);
MbqError::alert('', "Sorry!This feature is not available in this forum.Method name:".self::$cmd, '', MBQ_ERR_NOT_SUPPORT);
}
} else {
MbqError::alert('', "Need valid cmd!");
}
} else {
if(empty($_POST) && empty($_GET))
{
// include(MBQ_PATH . 'pluginstatus.php');
}
else
{
MbqError::alert('', "Need not empty cmd!");
}
}
}
/**
* do something before output
*/
public static function beforeOutPut() {
parent::beforeOutput();
}
}