-
Notifications
You must be signed in to change notification settings - Fork 7
/
Code.class.php
executable file
·166 lines (123 loc) · 3.55 KB
/
Code.class.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
<?php
class Code
{
/* common */
const SUCCESS = 0;
const FAIL = 1;
const NO_PRIVILEGE = 2;
const UNKNOWN_ERROR = 3;
const IN_DEVELOP = 4;
const INVALID_REQUEST = 5;
const UNKNOWN_REQUEST = 6;
const CAN_NOT_BE_EMPTY = 7;
const INCOMPLETE_CONTENT = 8;
const FILE_NOT_UPLOADED = 9;
const RECORD_NOT_EXIST = 10;
const INVALID_PASSWORD = 11;
const UNABLE_TO_CONNECT_REDIS = 12;
const UNABLE_TO_CONNECT_MYSQL = 13;
/* user */
const USERNAME_OCCUPIED = 14;
const EMAIL_OCCUPIED = 15;
const INVALID_USERNAME = 16;
const INVALID_EMAIL = 17;
const WRONG_PASSWORD = 18;
const NOT_LOGGED = 19;
const USER_NOT_EXIST = 20;
const USER_IS_BLOCKED = 21;
const USER_IS_REMOVED = 22;
const EMAIL_IS_NOT_VERIFIED = 33;
const USERNAME_MISMATCH_EMAIL = 23;
const CODE_EXPIRED = 24;
const EMAIL_ALREADY_VERIFIED = 25;
const INVALID_COOKIE = 26;
const REGISTRATION_CLOSED = 34;
/* auth */
const TOKEN_EXPIRED = 27;
const SITE_NOT_EXIST = 28;
const INVALID_URL = 29;
const INVALID_PARAM = 31;
const DOMAIN_MISMATCH = 32;
const OAUTH_DISABLED = 35;
/* rate limit */
const TOO_FAST = 30;
public static function getErrorMsg($errno)
{
switch ($errno) {
case Code::SUCCESS:
return 'Success !';
case Code::USERNAME_OCCUPIED:
return 'Username exists !';
case Code::EMAIL_OCCUPIED:
return 'Email exists !';
case Code::NO_PRIVILEGE:
return 'You don\'t have permission to do this !';
case Code::INVALID_USERNAME:
return 'Invalid username !';
case Code::INVALID_EMAIL:
return 'Invalid email !';
case Code::UNKNOWN_ERROR:
return 'Unknown error !';
case Code::WRONG_PASSWORD:
return 'Wrong password !';
case Code::IN_DEVELOP:
return 'In develop ^_^ !';
case Code::UNABLE_TO_CONNECT_REDIS:
return 'Unable to connect Redis !';
case Code::UNABLE_TO_CONNECT_MYSQL:
return 'Unable to connect Mysql !';
case Code::NOT_LOGGED:
return 'You haven\'t loged !';
case Code::USER_NOT_EXIST:
return 'User not exist !';
case Code::INVALID_REQUEST:
return 'Invalid request !';
case Code::UNKNOWN_REQUEST:
return 'Unknown request !';
case Code::CAN_NOT_BE_EMPTY:
return 'Input is empty !';
case Code::FAIL:
return 'Failed !';
case Code::INCOMPLETE_CONTENT:
return 'Cannot be empty !';
case Code::FILE_NOT_UPLOADED:
return 'Upload failed !';
case Code::RECORD_NOT_EXIST:
return 'Record not found !';
case Code::USER_IS_BLOCKED:
return 'Account is blocked !';
case Code::USER_IS_REMOVED:
return 'Account is removed !';
case Code::INVALID_PASSWORD:
return 'Invalid password !';
case Code::USERNAME_MISMATCH_EMAIL:
return 'Username or email not match !';
case Code::CODE_EXPIRED:
return 'Code is wrong or expires !';
case Code::EMAIL_ALREADY_VERIFIED:
return 'Email is already verified !';
case Code::TOO_FAST:
return 'System busy !';
case Code::INVALID_COOKIE:
return 'Invalid Cookie !';
case Code::TOKEN_EXPIRED:
return 'Token expired !';
case Code::SITE_NOT_EXIST:
return 'Site not exist !';
case Code::INVALID_URL:
return 'Invalid url !';
case Code::INVALID_PARAM:
return 'Invalid param !';
case Code::DOMAIN_MISMATCH:
return 'redirect_uri not in allowed hosts !';
case Code::EMAIL_IS_NOT_VERIFIED:
return 'Verify your email first !';
case Code::REGISTRATION_CLOSED:
return 'Registration is temporally closed !';
case Code::OAUTH_DISABLED:
return 'OAuth is temporally disabled !';
default:
return 'Unknown error(' . $errno . ') !';
}
}
}