sub_checkpost.php
4.03 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
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
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: sub_checkpost.php 32489 2013-01-29 03:57:16Z monkey $
*/
if(!defined('IN_MOBILE_API')) {
exit('Access Denied');
}
class mobile_api_sub {
function getvariable() {
global $_G;
if(empty($_G['forum'])) {
$allowpost = 0;
} elseif(!$_G['uid'] && !((!$_G['forum']['postperm'] && $_G['group']['allowpost']) || ($_G['forum']['postperm'] && forumperm($_G['forum']['postperm'])))) {
$allowpost = 0;
} elseif(empty($_G['forum']['allowpost'])) {
if(!$_G['forum']['postperm'] && !$_G['group']['allowpost']) {
$allowpost = 0;
} elseif($_G['forum']['postperm'] && !forumperm($_G['forum']['postperm'])) {
$allowpost = 0;
} else {
$allowpost = 1;
}
} elseif($_G['forum']['allowpost'] == -1) {
$allowpost = 0;
} else {
$allowpost = 1;
}
if(empty($_G['forum'])) {
$allowreply = 0;
} elseif(!$_G['uid'] && !((!$_G['forum']['replyperm'] && $_G['group']['allowreply']) || ($_G['forum']['replyperm'] && forumperm($_G['forum']['replyperm'])))) {
$allowreply = 0;
} elseif(empty($_G['forum']['allowreply'])) {
if(!$_G['forum']['replyperm'] && !$_G['group']['allowreply']) {
$allowreply = 0;
} elseif($_G['forum']['replyperm'] && !forumperm($_G['forum']['replyperm'])) {
$allowreply = 0;
} else {
$allowreply = 1;
}
} elseif($_G['forum']['allowreply'] == -1) {
$allowreply = 0;
} else {
$allowreply = 1;
}
$mobile_attachextensions = array('jpg', 'jpeg', 'gif', 'png', 'mp3', 'txt', 'zip', 'rar', 'pdf');
$_G['forum']['allowpostattach'] = isset($_G['forum']['allowpostattach']) ? $_G['forum']['allowpostattach'] : '';
$allowupload = $_G['forum']['allowpostattach'] != -1 && ($_G['forum']['allowpostattach'] == 1 || (!$_G['forum']['postattachperm'] && $_G['group']['allowpostattach']) || ($_G['forum']['postattachperm'] && forumperm($_G['forum']['postattachperm'])));
$allowupload = $allowupload && (!$_G['group']['maxattachnum'] || $_G['group']['maxattachnum'] && $_G['group']['maxattachnum'] > getuserprofile('todayattachs'));
$attachremain = array();
if($allowupload) {
$attachextensions = !$_G['group']['attachextensions'] ? $mobile_attachextensions : array_map('trim', explode(',', $_G['group']['attachextensions']));
$allowupload = $forummaxattachsize = array();
loadcache('attachtype');
if(isset($_G['cache']['attachtype'][$_G['forum']['fid']])) {
$attachtype = $_G['cache']['attachtype'][$_G['forum']['fid']];
} elseif(isset($_G['cache']['attachtype'][0])) {
$attachtype = $_G['cache']['attachtype'][0];
} else {
$attachtype = array();
}
if($attachtype) {
foreach($attachtype as $extension => $maxsize) {
$forummaxattachsize[$extension] = $maxsize;
}
}
foreach($mobile_attachextensions as $ext) {
if(in_array($ext, $attachextensions)) {
if(isset($forummaxattachsize[$ext])) {
if($forummaxattachsize[$ext] > 0) {
$allowupload[$ext] = $forummaxattachsize[$ext] ? $forummaxattachsize[$ext] : $_G['group']['maxattachsize'];
} else {
$allowupload[$ext] = 0;
}
} else {
$allowupload[$ext] = -1;
}
} else {
$allowupload[$ext] = 0;
}
}
$attachremain = array(
'size' => $_G['group']['maxsizeperday'] ? $_G['group']['maxsizeperday'] - getuserprofile('todayattachsize') : -1,
'count' => $_G['group']['maxattachnum'] ? $_G['group']['maxattachnum'] - getuserprofile('todayattachs') : -1,
);
} else {
$allowupload = array();
}
$uploadhash = md5(substr(md5($_G['config']['security']['authkey']), 8).$_G['uid']);
$allowperm = array();
$allowperm['allowperm'] = array();
$allowkey = array('allowpost', 'allowreply', 'allowupload', 'attachremain', 'uploadhash');
foreach($allowkey as $key) {
if((!empty(${$key}) || ${$key} === 0) || !empty($_GET['debug'])) {
$allowperm['allowperm'][$key] = ${$key};
}
}
return $allowperm;
}
}
?>