Repository navigation
Expand file tree
/
Copy pathapi.php
More file actions
73 lines (63 loc) · 1.44 KB
/
Copy pathapi.php
File metadata and controls
73 lines (63 loc) · 1.44 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
define('Execute',true);
define('Api',true);
ob_start();
switch(session_status()){
case PHP_SESSION_NONE:
session_start();
break;
case PHP_SESSION_DISABLED:
break;
case PHP_SESSION_ACTIVE:
break;
}
$model="account";
$action="login";
if(array_key_exists('model',$_GET)){
$model=$_GET['model'];
}
if(array_key_exists('action',$_GET)){
$action=$_GET['action'];
}
function ValidateModelAction($model,$action){
if($model == 'topic')
return false;
if($model == 'user' && $action == 'authorize')
return false;
if($model == 'categoryimage')
return false;
if($model == 'image')
return false;
return true;
}
if(ValidateModelAction($model,$action) && empty(CurrentUserId())){
header('Content-Type: application/json;');
echo json_encode(array('status' => false,'code' => 401));
exit();
}
date_default_timezone_set('PRC');
function GetLibFile(){
$params = func_get_args();
if(empty($params))return;
array_unshift($params,'.','cgi','api');
return implode(DIRECTORY_SEPARATOR,$params).'.php';
}
function CurrentUserId(){
$params = func_get_args();
if(!empty($params)){
foreach($params as $item){
$_SESSION['UserId'] = $item;
return $item;
}
}
if(empty($_SESSION)){
return 0;
}
if(!array_key_exists("UserId",$_SESSION)){
return 0;
}
return $_SESSION['UserId'];
}
$libFile = GetLibFile($model,$action);
if(file_exists($libFile))
include $libFile;