mobile.php
2.49 KB
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
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: mobile.php 35127 2014-12-02 08:17:18Z nemohou $
*/
define('IN_MOBILE_API', 1);
define('IN_MOBILE', 1);
chdir('../../../');
require_once 'source/plugin/mobile/mobile.class.php';
$modules = array('extends', 'buyattachment', 'buythread', 'checkpost', 'connect',
'favforum', 'favthread', 'forumdisplay', 'forumindex',
'forumnav', 'forumupload', 'friend', 'hotforum', 'hotthread',
'login', 'myfavforum', 'myfavthread', 'mypm', 'mythread',
'newthread', 'profile', 'publicpm', 'register', 'seccode',
'secure', 'sendpm', 'sendreply', 'sub_checkpost', 'sublist',
'toplist', 'viewthread', 'uploadavatar', 'pollvote', 'mynotelist', 'credit', 'profiles',
'modcp', 'topicadmin', 'forumimage', 'newthreads', 'signin', 'smiley', 'threadrecommend', 'check', 'mobilesign',
'wsqindex', 'wsqsiteinfo', 'recommend',
'wechat', 'wechat_clearlogin', 'checkinfo', 'seccodehtml',
'showactivity', 'bestanswer', 'forummisc', 'checkcookie', 'viewcomment', 'plugin');
$defaultversions = array(
'wechat' => 4,
);
if(!in_array($_GET['module'], $modules)) {
mobile_core::result(array('error' => 'module_not_exists'));
}
$_GET['version'] = !empty($_GET['version']) ? intval($_GET['version']) : (!$defaultversions[$_GET['module']] ? 1 : $defaultversions[$_GET['module']]);
$_GET['version'] = $_GET['version'] > MOBILE_PLUGIN_VERSION ? MOBILE_PLUGIN_VERSION : $_GET['version'];
if(empty($_GET['module']) || empty($_GET['version']) || !preg_match('/^[\w\.]+$/', $_GET['module']) || !preg_match('/^[\d\.]+$/', $_GET['version'])) {
mobile_core::result(array('error' => 'param_error'));
}
if($_GET['module'] == 'extends') {
require_once 'source/plugin/mobile/mobile_extends.php';
return;
}
if(!empty($_GET['_auth'])) {
unset($_GET['formhash'], $_POST['formhash']);
}
$apifile = 'source/plugin/mobile/api/'.$_GET['version'].'/'.$_GET['module'].'.php';
if(file_exists($apifile)) {
require_once $apifile;
} else {
if($_GET['version'] > 1) {
for($i = $_GET['version']; $i >= 1; $i--) {
$apifile = 'source/plugin/mobile/api/'.$i.'/'.$_GET['module'].'.php';
if(file_exists($apifile)) {
$_GET['version'] = $i;
require_once $apifile;
break;
} elseif($i==1 && !file_exists($apifile)) {
mobile_core::result(array('error' => 'module_not_exists'));
}
}
} else {
mobile_core::result(array('error' => 'module_not_exists'));
}
}
?>