Compare commits
443 Commits
revert-735
...
malio-A
| Author | SHA1 | Date |
|---|---|---|
|
|
8633e1cd2d | 6 years ago |
|
|
ba85e469ac | 6 years ago |
|
|
5e6638547f | 6 years ago |
|
|
cfb13c8ef0 | 6 years ago |
|
|
b91b0c3e33 | 6 years ago |
|
|
78d09700ea | 6 years ago |
|
|
80cd95f334 | 6 years ago |
|
|
d14e8f8115 | 6 years ago |
|
|
025bbeb9d3 | 6 years ago |
|
|
bc49882353 | 6 years ago |
|
|
e3eab497ae | 6 years ago |
|
|
5645bb1b1a | 6 years ago |
|
|
18ecb3723f | 6 years ago |
|
|
a822b502b2 | 6 years ago |
|
|
af02fc0efb | 6 years ago |
|
|
fdf582dcdf | 6 years ago |
|
|
882aa266cb | 6 years ago |
|
|
d19cd32055 | 6 years ago |
|
|
62d8f8ead8 | 6 years ago |
|
|
1f87696d86 | 6 years ago |
|
|
e6a23af95f | 6 years ago |
|
|
04d20e52f6 | 6 years ago |
|
|
53e817431c | 6 years ago |
|
|
28213af6ba | 7 years ago |
|
|
d7d536c79d | 7 years ago |
|
|
8043684bf6 | 7 years ago |
|
|
deeb5ecdac | 7 years ago |
|
|
4bb967085a | 7 years ago |
|
|
f9fb905aa8 | 7 years ago |
|
|
8701e6ed2b | 7 years ago |
|
|
2c05cd08e3 | 7 years ago |
|
|
a05176d2b6 | 7 years ago |
|
|
b4c7d13296 | 7 years ago |
|
|
23014aad36 | 7 years ago |
|
|
ed481f683d | 7 years ago |
|
|
b1aa5090f6 | 7 years ago |
|
|
171c39bb87 | 7 years ago |
|
|
af2a7d2a41 | 7 years ago |
|
|
493d0232aa | 7 years ago |
|
|
0ec4414b33 | 7 years ago |
|
|
df8a2b2190 | 7 years ago |
|
|
196a8bc151 | 7 years ago |
|
|
8a56a0ba90 | 7 years ago |
|
|
69fedbcbf3 | 7 years ago |
|
|
a3f0c7ece6 | 7 years ago |
|
|
ed9c1eb7bb | 7 years ago |
|
|
1ba142cd90 | 7 years ago |
|
|
a902d4e60d | 7 years ago |
|
|
69e4d22e4a | 7 years ago |
|
|
e350d32b1a | 7 years ago |
|
|
f57ffdfb0a | 7 years ago |
|
|
c38ab82d42 | 7 years ago |
|
|
76517c9172 | 7 years ago |
|
|
8924e5fd82 | 7 years ago |
|
|
facc66d78a | 7 years ago |
|
|
787e8f16be | 7 years ago |
|
|
0185572e5c | 7 years ago |
|
|
1c455e0b3c | 7 years ago |
|
|
b547121472 | 7 years ago |
|
|
4b75975399 | 7 years ago |
|
|
b516a11f87 | 7 years ago |
|
|
d971fa429e | 7 years ago |
|
|
aa0e40e893 | 7 years ago |
|
|
79e8b40dfd | 7 years ago |
|
|
516344fa7b | 7 years ago |
|
|
7da5fae5eb | 7 years ago |
|
|
73cdeb69a9 | 7 years ago |
|
|
7e0f4fc5ce | 7 years ago |
|
|
c49fe18b2f | 7 years ago |
|
|
3de1210f39 | 7 years ago |
|
|
784c82a50d | 7 years ago |
|
|
360d09d94b | 7 years ago |
|
|
68e1a92672 | 7 years ago |
|
|
edbebf43fd | 7 years ago |
|
|
90a746a633 | 7 years ago |
|
|
0cb6c62614 | 7 years ago |
|
|
4dc562a41d | 7 years ago |
|
|
0c042b3aee | 7 years ago |
|
|
735cbc129b | 7 years ago |
|
|
5c1112b3a6 | 7 years ago |
|
|
2717862e29 | 7 years ago |
|
|
fe546e5024 | 7 years ago |
|
|
47f3813ec2 | 7 years ago |
|
|
7abed27b75 | 7 years ago |
|
|
27542ca725 | 7 years ago |
|
|
13abb867dd | 7 years ago |
|
|
9ff825c294 | 7 years ago |
|
|
bd4fc024b2 | 7 years ago |
|
|
533d1423ff | 7 years ago |
|
|
d47bd98773 | 7 years ago |
|
|
7c817b6174 | 7 years ago |
|
|
733a11048d | 7 years ago |
|
|
c010a67300 | 7 years ago |
|
|
f6a94fbdf3 | 7 years ago |
|
|
c259030c9a | 7 years ago |
|
|
7814d7ec83 | 7 years ago |
|
|
2244627804 | 7 years ago |
|
|
ac5c582b76 | 7 years ago |
|
|
5838189366 | 7 years ago |
|
|
c3daab80cb | 7 years ago |
|
|
5a8b03a106 | 7 years ago |
|
|
b3dac73008 | 7 years ago |
|
|
dd41e26a0d | 7 years ago |
|
|
01e10aeaf0 | 7 years ago |
|
|
04e4ec061b | 7 years ago |
|
|
6415da3819 | 7 years ago |
|
|
3f39e56b52 | 7 years ago |
|
|
e28ede416b | 7 years ago |
|
|
81fc72a9b5 | 7 years ago |
|
|
b2d1f1d6fe | 7 years ago |
|
|
1a99f59c6f | 7 years ago |
|
|
aacef2eaec | 7 years ago |
|
|
e12fa43ef4 | 7 years ago |
|
|
441a081724 | 7 years ago |
|
|
781c41f2ae | 7 years ago |
|
|
38ccb7960e | 7 years ago |
|
|
4326f52b8e | 7 years ago |
|
|
ef84384ecc | 7 years ago |
|
|
41dab53a8c | 7 years ago |
|
|
251f4095d1 | 7 years ago |
|
|
6d8559c78b | 7 years ago |
|
|
f59c424407 | 7 years ago |
|
|
3661829e80 | 7 years ago |
|
|
b2df72ef79 | 7 years ago |
|
|
6c863f745b | 7 years ago |
|
|
eaea2b336e | 7 years ago |
|
|
96f7a23400 | 7 years ago |
|
|
ae330b454c | 7 years ago |
|
|
ee4060f8ab | 7 years ago |
|
|
56cfbfe67d | 7 years ago |
|
|
9465a24947 | 7 years ago |
|
|
48100a0f98 | 7 years ago |
|
|
2b97a04e8f | 7 years ago |
|
|
40848af02f | 7 years ago |
|
|
d56edcf7e2 | 7 years ago |
|
|
4313d1e428 | 7 years ago |
|
|
ae6eca628b | 7 years ago |
|
|
795bfe8af5 | 7 years ago |
|
|
66274de89c | 7 years ago |
|
|
4e6db25d6a | 7 years ago |
|
|
228158c84d | 7 years ago |
|
|
134fe6cb29 | 7 years ago |
|
|
7204c32e9e | 7 years ago |
|
|
8e61ac1175 | 7 years ago |
|
|
2a6b4ba9d6 | 7 years ago |
|
|
07a6120651 | 7 years ago |
|
|
9cbf3d88db | 7 years ago |
|
|
56099ff991 | 7 years ago |
|
|
fe2fb3ae29 | 7 years ago |
|
|
05054f2910 | 7 years ago |
|
|
043ff80923 | 7 years ago |
|
|
1514e36e44 | 7 years ago |
|
|
d1c0bf6d5d | 7 years ago |
|
|
2ee42af5f5 | 7 years ago |
|
|
239e2fc6d2 | 7 years ago |
|
|
157805d495 | 7 years ago |
|
|
08eefe35e6 | 7 years ago |
|
|
b4f7bf6e55 | 7 years ago |
|
|
8fed9d184c | 7 years ago |
|
|
1723af4419 | 7 years ago |
|
|
7eaaf1addf | 7 years ago |
|
|
133918163b | 7 years ago |
|
|
3edc891722 | 7 years ago |
|
|
02fdf1e90d | 7 years ago |
|
|
049f71d913 | 7 years ago |
|
|
478339ff4f | 7 years ago |
|
|
e95205d203 | 7 years ago |
|
|
0d2b25b4e2 | 7 years ago |
|
|
4009d7d883 | 7 years ago |
|
|
12ecd51269 | 7 years ago |
|
|
758b4272ff | 7 years ago |
|
|
f20a405c0c | 7 years ago |
|
|
730a6e432a | 7 years ago |
|
|
15d9462d3e | 7 years ago |
|
|
41a44f3c12 | 7 years ago |
|
|
d7d83c2b0d | 7 years ago |
|
|
6b9d5800d3 | 7 years ago |
|
|
6d6a01b3e9 | 7 years ago |
|
|
f8b08a0bb6 | 7 years ago |
|
|
fa7933966f | 7 years ago |
|
|
06483130dd | 7 years ago |
|
|
efa11e17e3 | 7 years ago |
|
|
9079c21340 | 7 years ago |
|
|
691aef4578 | 7 years ago |
|
|
f6f1267e28 | 7 years ago |
|
|
f922d60e9d | 7 years ago |
|
|
5c5de895e8 | 7 years ago |
|
|
5873a37fed | 7 years ago |
|
|
34569c5dc2 | 7 years ago |
|
|
df9f9009a5 | 7 years ago |
|
|
a04c1755d2 | 7 years ago |
|
|
e8be1d0a39 | 7 years ago |
|
|
a709cfae54 | 7 years ago |
|
|
30b8239dd6 | 7 years ago |
|
|
cd20d8c37a | 7 years ago |
|
|
cc96e2e3b5 | 7 years ago |
|
|
73afc143cd | 7 years ago |
|
|
bc7e18e211 | 7 years ago |
|
|
b57e618ee3 | 7 years ago |
|
|
c37c12d8a4 | 7 years ago |
|
|
78b378b978 | 7 years ago |
|
|
5dff6c4ce1 | 7 years ago |
|
|
4ac06220b9 | 7 years ago |
|
|
3cd4017f37 | 7 years ago |
|
|
6bdc510cf2 | 7 years ago |
|
|
096228c6c7 | 7 years ago |
|
|
4fc6ae0db4 | 7 years ago |
|
|
438b4fe3a4 | 7 years ago |
|
|
c0fb19dbf4 | 7 years ago |
|
|
b6fc28819e | 7 years ago |
|
|
5eff0b6a01 | 7 years ago |
|
|
d1c3e9cf9c | 7 years ago |
|
|
7669cf7768 | 7 years ago |
|
|
cd529f5657 | 7 years ago |
|
|
95a437f04b | 7 years ago |
|
|
e76026a5d8 | 7 years ago |
|
|
339dfaac21 | 7 years ago |
|
|
006250ff76 | 7 years ago |
|
|
487cefb418 | 7 years ago |
|
|
dbb3bd7751 | 7 years ago |
|
|
33aeabf077 | 7 years ago |
|
|
fa6026c4c9 | 7 years ago |
|
|
952825b7d4 | 7 years ago |
|
|
e554b29711 | 7 years ago |
|
|
5061561e71 | 7 years ago |
|
|
6ab5fcd17e | 7 years ago |
|
|
086f4c5b58 | 7 years ago |
|
|
7b78b7800c | 7 years ago |
|
|
1ad8d806ac | 7 years ago |
|
|
5afc5e0ac9 | 7 years ago |
|
|
609bc6ed1c | 7 years ago |
|
|
0dabf932f9 | 7 years ago |
|
|
653e82f1c4 | 7 years ago |
|
|
ca36add3f9 | 7 years ago |
|
|
b889f2b366 | 7 years ago |
|
|
36f167c0dd | 7 years ago |
|
|
a797a8d2b3 | 7 years ago |
|
|
94d822a708 | 7 years ago |
|
|
1ca33982b2 | 7 years ago |
|
|
b2d78c0d63 | 7 years ago |
|
|
3dc8e6001a | 7 years ago |
|
|
e775d9a329 | 7 years ago |
|
|
5eee24df84 | 7 years ago |
|
|
5e7b07d256 | 7 years ago |
|
|
dd532ab945 | 7 years ago |
|
|
4c19b026a9 | 7 years ago |
|
|
9c994800cc | 7 years ago |
|
|
e704107a5d | 7 years ago |
|
|
d645c8659e | 7 years ago |
|
|
98d9f04c68 | 7 years ago |
|
|
1dc1d9e555 | 7 years ago |
|
|
545c021013 | 7 years ago |
|
|
64589d8e03 | 7 years ago |
|
|
0567e05d80 | 7 years ago |
|
|
e2773f5a2d | 7 years ago |
|
|
ff4177668b | 7 years ago |
|
|
a984e01afb | 7 years ago |
|
|
f6f88fc19a | 7 years ago |
|
|
1fd4b4a8e3 | 7 years ago |
|
|
90958f2aa1 | 7 years ago |
|
|
78a7c0ff14 | 7 years ago |
|
|
3b85685260 | 7 years ago |
|
|
e89a266572 | 7 years ago |
|
|
f02d933b8f | 7 years ago |
|
|
3150594b86 | 7 years ago |
|
|
6997a7fb0c | 7 years ago |
|
|
a116d92e00 | 7 years ago |
|
|
513697ea18 | 7 years ago |
|
|
d4ce819dc5 | 7 years ago |
|
|
14c4db9be5 | 7 years ago |
|
|
edaad4aec6 | 7 years ago |
|
|
a8f2224484 | 7 years ago |
|
|
8f7c22a991 | 7 years ago |
|
|
083826931a | 7 years ago |
|
|
23390cd207 | 7 years ago |
|
|
2911b9e7a7 | 7 years ago |
|
|
8b004688c9 | 7 years ago |
|
|
457e4277ca | 7 years ago |
|
|
96db900a6b | 7 years ago |
|
|
b57f817475 | 7 years ago |
|
|
659bc38af8 | 7 years ago |
|
|
c210019290 | 7 years ago |
|
|
894cec5373 | 7 years ago |
|
|
aa1fe9be44 | 7 years ago |
|
|
c2a09434b9 | 7 years ago |
|
|
95e96d2c99 | 7 years ago |
|
|
e5e244d0b4 | 7 years ago |
|
|
4cabe238f9 | 7 years ago |
|
|
16f003a1bb | 7 years ago |
|
|
ee6f8b86db | 7 years ago |
|
|
c9b3d22040 | 7 years ago |
|
|
57de09ea4a | 7 years ago |
|
|
ab60f5c7c8 | 7 years ago |
|
|
d68337872e | 7 years ago |
|
|
b6135efc88 | 7 years ago |
|
|
e7ac0b9562 | 7 years ago |
|
|
d809788106 | 7 years ago |
|
|
c2bf1dc952 | 7 years ago |
|
|
be32a13c9b | 7 years ago |
|
|
777c409031 | 7 years ago |
|
|
e7700ee755 | 7 years ago |
|
|
c7d2b5f614 | 7 years ago |
|
|
30654b7cd2 | 7 years ago |
|
|
a647590326 | 7 years ago |
|
|
931eb9d1d2 | 7 years ago |
|
|
d3c1ae3f20 | 7 years ago |
|
|
3c84838193 | 7 years ago |
|
|
aded91b730 | 7 years ago |
|
|
e1127e863a | 7 years ago |
|
|
9b0cd43a2e | 7 years ago |
|
|
e9e59e4dcb | 7 years ago |
|
|
6996425e9b | 7 years ago |
|
|
67af63b052 | 7 years ago |
|
|
0449eed1fe | 7 years ago |
|
|
b8d383f8f3 | 7 years ago |
|
|
f0cb4b710a | 7 years ago |
|
|
4f312527ae | 7 years ago |
|
|
d69fb6b1b8 | 7 years ago |
|
|
000abaa4d7 | 7 years ago |
|
|
9dfd9e992a | 7 years ago |
|
|
90f11f9e50 | 7 years ago |
|
|
8bfa574c7f | 7 years ago |
|
|
ad160e46f7 | 7 years ago |
|
|
38283cf96d | 7 years ago |
|
|
67334f8abf | 7 years ago |
|
|
56ebebf928 | 7 years ago |
|
|
8546a43f9e | 7 years ago |
|
|
895410e80f | 7 years ago |
|
|
3c063f5b4b | 7 years ago |
|
|
ccac5960ff | 7 years ago |
|
|
9c905ff215 | 7 years ago |
|
|
051ffc57f9 | 7 years ago |
|
|
74e5f87b84 | 7 years ago |
|
|
d01adce482 | 7 years ago |
|
|
8d7e1f9293 | 7 years ago |
|
|
0fecd8600b | 7 years ago |
|
|
082f7c5a00 | 7 years ago |
|
|
e40e820135 | 7 years ago |
|
|
d06ebb83c4 | 7 years ago |
|
|
2dbdf2a25c | 7 years ago |
|
|
a98ff85079 | 7 years ago |
|
|
6be1abfaf1 | 7 years ago |
|
|
83db32626f | 7 years ago |
|
|
b56272fe07 | 7 years ago |
|
|
588696234e | 7 years ago |
|
|
cf12b34262 | 7 years ago |
|
|
dfa3e01157 | 7 years ago |
|
|
be379f66a9 | 7 years ago |
|
|
accd82e754 | 7 years ago |
|
|
ff2d944dbe | 7 years ago |
|
|
0a4f629226 | 7 years ago |
|
|
eed442a52b | 7 years ago |
|
|
3aabb5c58a | 7 years ago |
|
|
52b1e8ca1d | 7 years ago |
|
|
245f584a9e | 7 years ago |
|
|
273e6c39c2 | 7 years ago |
|
|
da7ca38780 | 7 years ago |
|
|
30e24b24c3 | 7 years ago |
|
|
c0eee00f74 | 7 years ago |
|
|
6d918b8c11 | 7 years ago |
|
|
1c6b49555d | 7 years ago |
|
|
04899474d3 | 7 years ago |
|
|
c358c7ae45 | 7 years ago |
|
|
fd4aa61bb9 | 7 years ago |
|
|
1279aea9cf | 7 years ago |
|
|
110229fe5a | 7 years ago |
|
|
6c2830c0db | 7 years ago |
|
|
30e7577b86 | 7 years ago |
|
|
9b0005b013 | 7 years ago |
|
|
e4329a7661 | 7 years ago |
|
|
9f24cffb73 | 7 years ago |
|
|
2db61fb807 | 7 years ago |
|
|
cf4b62966c | 7 years ago |
|
|
1a8dd4d873 | 7 years ago |
|
|
d217000ca2 | 7 years ago |
|
|
a2e471d9f9 | 7 years ago |
|
|
2782c532cc | 7 years ago |
|
|
532f2f457f | 7 years ago |
|
|
9601dd3aa6 | 7 years ago |
|
|
7911c76057 | 7 years ago |
|
|
12ccc306d8 | 7 years ago |
|
|
60e82fc07f | 7 years ago |
|
|
e9fa797b25 | 7 years ago |
|
|
b24f68098e | 7 years ago |
|
|
77c7f2e8c9 | 7 years ago |
|
|
c7140d35ad | 7 years ago |
|
|
42cf1b8749 | 7 years ago |
|
|
31b53a0052 | 7 years ago |
|
|
0e3e64b952 | 7 years ago |
|
|
2806ea97fa | 7 years ago |
|
|
f955323d3c | 7 years ago |
|
|
0a4cda9047 | 7 years ago |
|
|
764b300582 | 7 years ago |
|
|
a8470bb0a3 | 7 years ago |
|
|
7a7ec8a192 | 7 years ago |
|
|
fea0fc9580 | 7 years ago |
|
|
5bc4a557b7 | 7 years ago |
|
|
972bd1ede8 | 7 years ago |
|
|
8082ea7bb2 | 7 years ago |
|
|
093dbc3d48 | 7 years ago |
|
|
805e602d5a | 7 years ago |
|
|
a835ba415b | 7 years ago |
|
|
ae58db22ee | 7 years ago |
|
|
647efbecc7 | 7 years ago |
|
|
51a10a31b6 | 7 years ago |
|
|
7fc7046290 | 7 years ago |
|
|
44bcbbcb6f | 7 years ago |
|
|
7a7a7d8044 | 7 years ago |
|
|
7516dfcf83 | 7 years ago |
|
|
87d178fd29 | 7 years ago |
|
|
36799fc57b | 7 years ago |
|
|
9beb73c5a0 | 7 years ago |
|
|
f4c1688f84 | 7 years ago |
|
|
c4e38e84d3 | 7 years ago |
|
|
53c9578796 | 7 years ago |
|
|
6dab034a26 | 7 years ago |
|
|
275941191f | 7 years ago |
|
|
ed70ab3ed8 | 7 years ago |
|
|
d747eedadd | 7 years ago |
|
|
576e9e5b98 | 7 years ago |
|
|
8d5b103234 | 7 years ago |
|
|
e42e5ee3e0 | 7 years ago |
|
|
e1907e3b7b | 7 years ago |
|
|
8916041998 | 7 years ago |
|
|
c92a52df64 | 7 years ago |
|
|
a7503a8207 | 7 years ago |
|
|
129137b773 | 7 years ago |
|
|
84ad7f2bf3 | 7 years ago |
|
|
89ea1b75d8 | 7 years ago |
|
|
797bd35f1b | 7 years ago |
|
|
189bbf9026 | 7 years ago |
|
|
91b2bf2016 | 7 years ago |
|
|
fb8bd622fb | 7 years ago |
|
|
040e987aa6 | 7 years ago |
|
|
badc98f29e | 7 years ago |
|
|
76d7d586d9 | 7 years ago |
|
|
bc05bb18ff | 7 years ago |
|
|
66f8d8bc8f | 7 years ago |
|
|
85306ae54d | 7 years ago |
|
|
8d5122c7b4 | 7 years ago |
|
|
bb805d65a4 | 7 years ago |
|
|
0a94ae0778 | 8 years ago |
|
|
c9b0573f43 | 8 years ago |
@ -1,22 +0,0 @@
|
||||
# https://editorconfig.org/
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
tab_width = 4
|
||||
|
||||
[*.php]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_style = space
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
max_line_length = 80
|
||||
@ -1,2 +0,0 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
@ -0,0 +1,19 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an new idea for this project
|
||||
title: "[Feature Request]"
|
||||
labels: enhancement
|
||||
|
||||
---
|
||||
|
||||
- [ ] I acknowledge if I don't follow the format below or I don't check these box, my issue could be closed without any notice.
|
||||
- [ ] I certify that I have read project Wiki and other issue may related to this one.
|
||||
|
||||
**Feature**
|
||||
The feature you want.
|
||||
|
||||
**Solution**
|
||||
If you have some solution about this issue, type it here.
|
||||
|
||||
**Addition**
|
||||
Additional context here.
|
||||
@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>ss-panel-v3-mod_UIChanges</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>com.aptana.ide.core.unifiedBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>com.aptana.projects.webnature</nature>
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1522297588605</id>
|
||||
<name></name>
|
||||
<type>26</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.ui.ide.multiFilter</id>
|
||||
<arguments>1.0-name-matches-false-false-node_modules</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
||||
@ -1,19 +0,0 @@
|
||||
根据时间从 2018 年 12 月始...
|
||||
|
||||
- 支持 Quantumult 格式的 V2Ray 订阅以及策略组配置导出
|
||||
- 支持 Surge 2 & 3 的托管配置以及 policy group
|
||||
- 支持 SurfBoard 的托管配置
|
||||
- 支持 Shadowrocket 支持的 Shadowsocks(R) & VMess 合并订阅
|
||||
- 提供用户使用文档
|
||||
- 完全合并普通端口和单端口的订阅及托管
|
||||
- ShadowsocksR 订阅中的账户及流量信息改为可选
|
||||
- ~~一键切换 SS/SSR 加密、协议、混淆~~ (已废弃)
|
||||
- 订阅链接兼容 Anankke
|
||||
- ~~支持 ss-v2ray-plugin 类型节点~~ (已合并到 Anankke)
|
||||
- V2Ray 订阅可选支持显示账户及流量信息
|
||||
- 可选使用预定义的加密、协议、混淆配置方案
|
||||
- 支持用户自定义 Surge 托管配置
|
||||
- 支持用户自定义 Clash 托管配置
|
||||
|
||||
……
|
||||
|
||||
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Controllers\AdminController;
|
||||
use App\Services\Auth;
|
||||
use App\Models\GConfig;
|
||||
|
||||
class GConfigController extends AdminController
|
||||
{
|
||||
public function update($request, $response, $args)
|
||||
{
|
||||
$key = trim($args['key']);
|
||||
$user = Auth::getUser();
|
||||
|
||||
$config = GConfig::find($key);
|
||||
$config->oldvalue = $config->value;
|
||||
$config->value = $request->getParam('value');
|
||||
$config->operator_id = $user->id;
|
||||
$config->operator_name = $user->user_name;
|
||||
$config->operator_email = $user->email;
|
||||
$config->last_update = time();
|
||||
if (!$config->save()) {
|
||||
$rs['ret'] = 0;
|
||||
$rs['msg'] = '修改失败';
|
||||
return $response->write(json_encode($rs));
|
||||
}
|
||||
$rs['ret'] = 1;
|
||||
$rs['msg'] = '修改成功';
|
||||
return $response->write(json_encode($rs));
|
||||
}
|
||||
|
||||
public function telegram($request, $response, $args)
|
||||
{
|
||||
$table_config['total_column'] = array(
|
||||
'op' => '操作',
|
||||
'name' => '配置名称',
|
||||
'key' => '配置名',
|
||||
'value' => '配置值',
|
||||
'operator_id' => '操作员 ID',
|
||||
'operator_name' => '操作员名称',
|
||||
'operator_email' => '操作员邮箱',
|
||||
'last_update' => '修改时间'
|
||||
);
|
||||
$table_config['default_show_column'] = array();
|
||||
foreach ($table_config['total_column'] as $column => $value) {
|
||||
$table_config['default_show_column'][] = $column;
|
||||
}
|
||||
$table_config['ajax_url'] = 'telegram/ajax';
|
||||
return $this->view()->assign('table_config', $table_config)->fetch('admin/config/telegram/index.tpl');
|
||||
}
|
||||
|
||||
public function telegram_edit($request, $response, $args)
|
||||
{
|
||||
$key = trim($args['key']);
|
||||
$config = GConfig::find($key);
|
||||
return $this->view()->assign('edit_config', $config)->fetch('admin/config/telegram/edit.tpl');
|
||||
}
|
||||
|
||||
public function telegram_update($request, $response, $args)
|
||||
{
|
||||
return self::update($request, $response, $args);
|
||||
}
|
||||
|
||||
public function telegram_ajax($request, $response, $args)
|
||||
{
|
||||
$start = $request->getParam("start");
|
||||
$limit_length = $request->getParam('length');
|
||||
$configs = GConfig::skip($start)->where('key', 'LIKE', "%Telegram%")->limit($limit_length)->get();
|
||||
$total_conut = GConfig::where('key', 'LIKE', "%Telegram%")->count();
|
||||
$data = [];
|
||||
foreach ($configs as $config) {
|
||||
$tempdata = [];
|
||||
$tempdata['op'] = '<a class="btn btn-brand" href="/admin/config/telegram/' . $config->key . '/edit">编辑</a>';
|
||||
$tempdata['name'] = $config->name;
|
||||
$tempdata['key'] = $config->key;
|
||||
$tempdata['value'] = $config->value;
|
||||
$tempdata['operator_id'] = $config->operator_id;
|
||||
$tempdata['operator_name'] = $config->operator_name;
|
||||
$tempdata['operator_email'] = $config->operator_email;
|
||||
$tempdata['last_update'] = date('Y-m-d H:i:s', $config->last_update);
|
||||
if (strpos($config->key, '.enable.')) {
|
||||
switch ((int) $config->value) {
|
||||
case 0:
|
||||
$tempdata['value'] = '关闭';
|
||||
break;
|
||||
case 1:
|
||||
$tempdata['value'] = '开启';
|
||||
break;
|
||||
default:
|
||||
$tempdata['value'] = '未知';
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$tempdata['value'] = '(请在编辑页面查看)';
|
||||
}
|
||||
$data[] = $tempdata;
|
||||
}
|
||||
$info = [
|
||||
'draw' => $request->getParam('draw'),
|
||||
'recordsTotal' => $total_conut,
|
||||
'recordsFiltered' => $total_conut,
|
||||
'data' => $data
|
||||
];
|
||||
|
||||
return json_encode($info, true);
|
||||
}
|
||||
}
|
||||
@ -1,162 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\Node;
|
||||
use App\Models\User;
|
||||
use App\Services\Factory;
|
||||
use App\Services\Config;
|
||||
use App\Utils\Tools;
|
||||
use App\Utils\Hash;
|
||||
use App\Utils\Helper;
|
||||
|
||||
/**
|
||||
* ApiController
|
||||
*/
|
||||
class ApiController extends BaseController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
}
|
||||
|
||||
public function token($request, $response, $args)
|
||||
{
|
||||
$accessToken = $id = $args['token'];
|
||||
$storage = Factory::createTokenStorage();
|
||||
$token = $storage->get($accessToken);
|
||||
if ($token == null) {
|
||||
$res['ret'] = 0;
|
||||
$res['msg'] = 'token is null';
|
||||
return $this->echoJson($response, $res);
|
||||
}
|
||||
$res['ret'] = 1;
|
||||
$res['msg'] = 'ok';
|
||||
$res['data'] = $token;
|
||||
return $this->echoJson($response, $res);
|
||||
}
|
||||
|
||||
public function newToken($request, $response, $args)
|
||||
{
|
||||
// $data = $request->post('sdf');
|
||||
$email = $request->getParam('email');
|
||||
|
||||
$email = strtolower($email);
|
||||
$passwd = $request->getParam('passwd');
|
||||
|
||||
// Handle Login
|
||||
$user = User::where('email', '=', $email)->first();
|
||||
|
||||
if ($user == null) {
|
||||
$res['ret'] = 0;
|
||||
$res['msg'] = '401 邮箱或者密码错误';
|
||||
return $this->echoJson($response, $res);
|
||||
}
|
||||
|
||||
if (!Hash::checkPassword($user->pass, $passwd)) {
|
||||
$res['ret'] = 0;
|
||||
$res['msg'] = '402 邮箱或者密码错误';
|
||||
return $this->echoJson($response, $res);
|
||||
}
|
||||
$tokenStr = Tools::genToken();
|
||||
$storage = Factory::createTokenStorage();
|
||||
$expireTime = time() + 3600 * 24 * 7;
|
||||
if ($storage->store($tokenStr, $user, $expireTime)) {
|
||||
$res['ret'] = 1;
|
||||
$res['msg'] = 'ok';
|
||||
$res['data']['token'] = $tokenStr;
|
||||
$res['data']['user_id'] = $user->id;
|
||||
return $this->echoJson($response, $res);
|
||||
}
|
||||
$res['ret'] = 0;
|
||||
$res['msg'] = 'system error';
|
||||
return $this->echoJson($response, $res);
|
||||
}
|
||||
|
||||
public function node($request, $response, $args)
|
||||
{
|
||||
$accessToken = Helper::getParam($request, 'access_token');
|
||||
$storage = Factory::createTokenStorage();
|
||||
$token = $storage->get($accessToken);
|
||||
$user = User::find($token->userId);
|
||||
$nodes = Node::where('sort', 0)->where('type', '1')->where(
|
||||
static function ($query) use ($user) {
|
||||
$query->where('node_group', '=', $user->node_group)
|
||||
->orWhere('node_group', '=', 0);
|
||||
}
|
||||
)->orderBy('name')->get();
|
||||
|
||||
$mu_nodes = Node::where('sort', 9)->where('node_class', '<=', $user->class)->where('type', '1')->where(
|
||||
static function ($query) use ($user) {
|
||||
$query->where('node_group', '=', $user->node_group)
|
||||
->orWhere('node_group', '=', 0);
|
||||
}
|
||||
)->orderBy('name')->get();
|
||||
|
||||
$temparray = array();
|
||||
foreach ($nodes as $node) {
|
||||
if ($node->mu_only == 0) {
|
||||
$temparray[] = array('remarks' => $node->name,
|
||||
'server' => $node->server,
|
||||
'server_port' => $user->port,
|
||||
'method' => $node->custom_method == 1 ? $user->method : $node->method,
|
||||
'obfs' => str_replace('_compatible', '', (($node->custom_rss == 1 && !($user->obfs == 'plain' && $user->protocol == 'origin')) ? $user->obfs : 'plain')),
|
||||
'obfsparam' => ($node->custom_rss == 1 && !($user->obfs == 'plain' && $user->protocol == 'origin')) ? $user->obfs_param : '',
|
||||
'remarks_base64' => base64_encode($node->name),
|
||||
'password' => $user->passwd,
|
||||
'tcp_over_udp' => false,
|
||||
'udp_over_tcp' => false,
|
||||
'group' => Config::get('appName'),
|
||||
'protocol' => str_replace('_compatible', '', (($node->custom_rss == 1 && !($user->obfs == 'plain' && $user->protocol == 'origin')) ? $user->protocol : 'origin')),
|
||||
'obfs_udp' => false,
|
||||
'enable' => true);
|
||||
}
|
||||
|
||||
if ($node->custom_rss == 1) {
|
||||
foreach ($mu_nodes as $mu_node) {
|
||||
$mu_user = User::where('port', '=', $mu_node->server)->first();
|
||||
$mu_user->obfs_param = $user->getMuMd5();
|
||||
|
||||
$temparray[] = array('remarks' => $node->name . '- ' . $mu_node->server . ' 单端口',
|
||||
'server' => $node->server,
|
||||
'server_port' => $mu_user->port,
|
||||
'method' => $mu_user->method,
|
||||
'group' => Config::get('appName'),
|
||||
'obfs' => str_replace('_compatible', '', (($node->custom_rss == 1 && !($mu_user->obfs == 'plain' && $mu_user->protocol == 'origin')) ? $mu_user->obfs : 'plain')),
|
||||
'obfsparam' => ($node->custom_rss == 1 && !($mu_user->obfs == 'plain' && $mu_user->protocol == 'origin')) ? $mu_user->obfs_param : '',
|
||||
'remarks_base64' => base64_encode($node->name . '- ' . $mu_node->server . ' 单端口'),
|
||||
'password' => $mu_user->passwd,
|
||||
'tcp_over_udp' => false,
|
||||
'udp_over_tcp' => false,
|
||||
'protocol' => str_replace('_compatible', '', (($node->custom_rss == 1 && !($mu_user->obfs == 'plain' && $mu_user->protocol == 'origin')) ? $mu_user->protocol : 'origin')),
|
||||
'obfs_udp' => false,
|
||||
'enable' => true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$res['ret'] = 1;
|
||||
$res['msg'] = 'ok';
|
||||
$res['data'] = $temparray;
|
||||
return $this->echoJson($response, $res);
|
||||
}
|
||||
|
||||
public function userInfo($request, $response, $args)
|
||||
{
|
||||
$id = $args['id'];
|
||||
$accessToken = Helper::getParam($request, 'access_token');
|
||||
$storage = Factory::createTokenStorage();
|
||||
$token = $storage->get($accessToken);
|
||||
if ($id != $token->userId) {
|
||||
$res['ret'] = 0;
|
||||
$res['msg'] = 'access denied';
|
||||
return $this->echoJson($response, $res);
|
||||
}
|
||||
$user = User::find($token->userId);
|
||||
$user->pass = null;
|
||||
$data = $user;
|
||||
$res['ret'] = 1;
|
||||
$res['msg'] = 'ok';
|
||||
$res['data'] = $data;
|
||||
return $this->echoJson($response, $res);
|
||||
}
|
||||
}
|
||||
@ -1,68 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: kaguya
|
||||
* Date: 2018/06/30
|
||||
* Time: 21:40
|
||||
*/
|
||||
|
||||
namespace App\Controllers\Client;
|
||||
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Controllers\LinkController;
|
||||
use App\Models\Ann;
|
||||
use App\Models\User;
|
||||
use App\Services\Auth;
|
||||
use App\Services\Config;
|
||||
use App\Services\Factory;
|
||||
use App\Utils\Helper;
|
||||
|
||||
class ClientApiController extends BaseController
|
||||
{
|
||||
public function GetAnnouncement($request, $response, $args)
|
||||
{
|
||||
$accessToken = Helper::getParam($request, 'access_token');
|
||||
$storage = Factory::createTokenStorage();
|
||||
$token = $storage->get($accessToken);
|
||||
$user = User::find($token->userId);
|
||||
$Anns = Ann::orderBy('date', 'desc')->first();
|
||||
$res['ret'] = 1;
|
||||
$res['msg'] = 'ok';
|
||||
$res['data'] = $Anns;
|
||||
return $this->echoJson($response, $res);
|
||||
}
|
||||
|
||||
public function Redirect($request, $response, $args)
|
||||
{
|
||||
$user = Auth::getUser();
|
||||
$url = $request->getQueryParams()['target'];
|
||||
if (!$user->isLogin) {
|
||||
$accessToken = Helper::getParam($request, 'access_token');
|
||||
$storage = Factory::createTokenStorage();
|
||||
$token = $storage->get($accessToken);
|
||||
if ($token == null) {
|
||||
$res['ret'] = 0;
|
||||
$res['msg'] = 'token is null';
|
||||
return $this->echoJson($response, $res);
|
||||
}
|
||||
$user = User::find($token->userId);
|
||||
$time = 3600 * 24;
|
||||
Auth::login($user->id, $time);
|
||||
}
|
||||
return $response->withRedirect($url);
|
||||
}
|
||||
|
||||
public function GetSubLink($request, $response, $args)
|
||||
{
|
||||
$accessToken = Helper::getParam($request, 'access_token');
|
||||
$storage = Factory::createTokenStorage();
|
||||
$token = $storage->get($accessToken);
|
||||
$user = User::find($token->userId);
|
||||
$ssr_sub_token = LinkController::GenerateSSRSubCode($user->id, 0);
|
||||
$res['ret'] = 1;
|
||||
$res['msg'] = 'ok';
|
||||
$res['data'] = Config::get('subUrl') . $ssr_sub_token . '?sub=1';
|
||||
return $this->echoJson($response, $res);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Controllers\Mu;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\NodeOnlineLog;
|
||||
use App\Models\NodeInfoLog;
|
||||
|
||||
class NodeController extends BaseController
|
||||
{
|
||||
public function onlineUserLog($request, $response, $args)
|
||||
{
|
||||
$node_id = $args['id'];
|
||||
$count = $request->getParam('count');
|
||||
$log = new NodeOnlineLog();
|
||||
$log->node_id = $node_id;
|
||||
$log->online_user = $count;
|
||||
$log->log_time = time();
|
||||
if (!$log->save()) {
|
||||
$res = [
|
||||
'ret' => 0,
|
||||
'msg' => 'update failed',
|
||||
];
|
||||
return $this->echoJson($response, $res);
|
||||
}
|
||||
$res = [
|
||||
'ret' => 1,
|
||||
'msg' => 'ok',
|
||||
];
|
||||
return $this->echoJson($response, $res);
|
||||
}
|
||||
|
||||
public function info($request, $response, $args)
|
||||
{
|
||||
$node_id = $args['id'];
|
||||
$load = $request->getParam('load');
|
||||
$uptime = $request->getParam('uptime');
|
||||
$log = new NodeInfoLog();
|
||||
$log->node_id = $node_id;
|
||||
$log->load = $load;
|
||||
$log->uptime = $uptime;
|
||||
$log->log_time = time();
|
||||
if (!$log->save()) {
|
||||
$res = [
|
||||
'ret' => 0,
|
||||
'msg' => 'update failed',
|
||||
];
|
||||
return $this->echoJson($response, $res);
|
||||
}
|
||||
$res = [
|
||||
'ret' => 1,
|
||||
'msg' => 'ok',
|
||||
];
|
||||
return $this->echoJson($response, $res);
|
||||
}
|
||||
}
|
||||
@ -1,122 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Mu;
|
||||
|
||||
use App\Models\Node;
|
||||
use App\Models\TrafficLog;
|
||||
use App\Models\User;
|
||||
use App\Controllers\BaseController;
|
||||
use App\Utils\Tools;
|
||||
|
||||
class UserController extends BaseController
|
||||
{
|
||||
// User List
|
||||
public function index($request, $response, $args)
|
||||
{
|
||||
$node = Node::where('node_ip', '=', $_SERVER['REMOTE_ADDR'])->where(
|
||||
static function ($query) {
|
||||
$query->where('sort', '=', 0)
|
||||
->orWhere('sort', '=', 10)->orWhere('sort', '=', 12);
|
||||
}
|
||||
)->first();
|
||||
$node->node_heartbeat = time();
|
||||
$node->save();
|
||||
|
||||
if ($node->node_group != 0) {
|
||||
$users_raw = User::where(
|
||||
static function ($query) use ($node) {
|
||||
$query->where(
|
||||
static function ($query1) use ($node) {
|
||||
$query1->where('class', '>=', $node->node_class)
|
||||
->where('node_group', '=', $node->node_group);
|
||||
}
|
||||
)->orwhere('is_admin', 1);
|
||||
}
|
||||
)
|
||||
->where('enable', 1)->where('expire_in', '>', date('Y-m-d H:i:s'))->get();
|
||||
} else {
|
||||
$users_raw = User::where(
|
||||
static function ($query) use ($node) {
|
||||
$query->where(
|
||||
static function ($query1) use ($node) {
|
||||
$query1->where('class', '>=', $node->node_class);
|
||||
}
|
||||
)->orwhere('is_admin', 1);
|
||||
}
|
||||
)->where('enable', 1)->where('expire_in', '>', date('Y-m-d H:i:s'))->get();
|
||||
}
|
||||
if (($node->node_bandwidth_limit != 0) && $node->node_bandwidth_limit < $node->node_bandwidth) {
|
||||
$users = null;
|
||||
|
||||
$res = [
|
||||
'ret' => 1,
|
||||
'data' => $users
|
||||
];
|
||||
return $this->echoJson($response, $res);
|
||||
}
|
||||
|
||||
$key_list = array('method', 'id', 'port', 'passwd', 'u', 'd', 'enable',
|
||||
't', 'transfer_enable', 'switch', 'email');
|
||||
|
||||
$users_output = array();
|
||||
|
||||
foreach ($users_raw as $user_raw) {
|
||||
if ($user_raw->transfer_enable > $user_raw->u + $user_raw->d) {
|
||||
$user_raw = Tools::keyFilter($user_raw, $key_list);
|
||||
$users_output[] = $user_raw;
|
||||
}
|
||||
}
|
||||
|
||||
$res = [
|
||||
'ret' => 1,
|
||||
'msg' => 'ok',
|
||||
'data' => $users_output
|
||||
];
|
||||
return $this->echoJson($response, $res);
|
||||
}
|
||||
|
||||
// Update Traffic
|
||||
public function addTraffic($request, $response, $args)
|
||||
{
|
||||
$id = $args['id'];
|
||||
$u = $request->getParam('u');
|
||||
$d = $request->getParam('d');
|
||||
$nodeId = $request->getParam('node_id');
|
||||
$node = Node::find($nodeId);
|
||||
|
||||
$node->node_bandwidth = $node->node_bandwidth + $d + $u;
|
||||
|
||||
$node->save();
|
||||
|
||||
|
||||
$rate = $node->traffic_rate;
|
||||
$user = User::find($id);
|
||||
|
||||
$user->t = time();
|
||||
$user->u += ($u * $rate);
|
||||
$user->d += ($d * $rate);
|
||||
if (!$user->save()) {
|
||||
$res = [
|
||||
'ret' => 0,
|
||||
'msg' => 'update failed',
|
||||
];
|
||||
//return $this->echoJson($response, $res);
|
||||
}
|
||||
// log
|
||||
$traffic = new TrafficLog();
|
||||
$traffic->user_id = $id;
|
||||
$traffic->u = $u;
|
||||
$traffic->d = $d;
|
||||
$traffic->node_id = $nodeId;
|
||||
$traffic->rate = $rate;
|
||||
$traffic->traffic = Tools::flowAutoShow(($u + $d) * $rate);
|
||||
$traffic->log_time = time();
|
||||
$traffic->save();
|
||||
|
||||
$res = [
|
||||
'ret' => 1,
|
||||
'msg' => 'ok',
|
||||
];
|
||||
return $this->echoJson($response, $res);
|
||||
}
|
||||
}
|
||||
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Middleware;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use App\Services\Factory;
|
||||
use App\Utils\Helper;
|
||||
|
||||
class Api
|
||||
{
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, $next)
|
||||
{
|
||||
$accessToken = Helper::getParam($request, 'access_token');
|
||||
if ($accessToken == null) {
|
||||
$res['ret'] = 0;
|
||||
$res['msg'] = 'token is null';
|
||||
$response->getBody()->write(json_encode($res));
|
||||
return $response;
|
||||
}
|
||||
$storage = Factory::createTokenStorage();
|
||||
$token = $storage->get($accessToken);
|
||||
if ($token == null) {
|
||||
$res['ret'] = 0;
|
||||
$res['msg'] = 'token is null';
|
||||
$response->getBody()->write(json_encode($res));
|
||||
return $response;
|
||||
}
|
||||
if ($token->expireTime < time()) {
|
||||
$res['ret'] = 0;
|
||||
$res['msg'] = 'token is expire';
|
||||
$response->getBody()->write(json_encode($res));
|
||||
return $response;
|
||||
}
|
||||
$response = $next($request, $response);
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@ -1,55 +1,50 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Middleware;
|
||||
|
||||
use App\Services\Config;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use App\Utils\Helper;
|
||||
use App\Models\Node;
|
||||
use App\Services\MalioConfig;
|
||||
|
||||
class Mod_Mu
|
||||
{
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, $next)
|
||||
/**
|
||||
* @param \Slim\Http\Request $request
|
||||
* @param \Slim\Http\Response $response
|
||||
* @param callable $next
|
||||
*
|
||||
* @return \Slim\Http\Response
|
||||
*/
|
||||
public function __invoke($request, $response, $next)
|
||||
{
|
||||
$key = Helper::getParam($request, 'key');
|
||||
$key = $request->getQueryParam('key');
|
||||
if ($key === null) {
|
||||
$res['ret'] = 0;
|
||||
$res['data'] = 'null';
|
||||
$response->getBody()->write(json_encode($res));
|
||||
return $response;
|
||||
return $response->withjson([
|
||||
'ret' => 0,
|
||||
'data' => 'Your key is null.'
|
||||
]);
|
||||
}
|
||||
|
||||
$auth = false;
|
||||
$keys = Config::getMuKey();
|
||||
foreach ($keys as $k) {
|
||||
if ($key == $k) {
|
||||
$auth = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$auth = in_array($key, $keys);
|
||||
|
||||
if (MalioConfig::get('enable_webapi_ip_verification') == true) {
|
||||
$node = Node::where('node_ip', 'LIKE', $_SERVER['REMOTE_ADDR'] . '%')->first();
|
||||
if ($node == null && $_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
|
||||
$res['ret'] = 0;
|
||||
$res['data'] = 'token or source is invalid, Your ip address is ' . $_SERVER['REMOTE_ADDR'];
|
||||
$response->getBody()->write(json_encode($res));
|
||||
return $response;
|
||||
}
|
||||
if ($auth == false) {
|
||||
$res['ret'] = 0;
|
||||
$res['data'] = 'token is invalid';
|
||||
$response->getBody()->write(json_encode($res));
|
||||
return $response;
|
||||
}
|
||||
|
||||
if (Config::get('checkNodeIp') === true){
|
||||
$node = Node::where('node_ip', 'LIKE', $_SERVER['REMOTE_ADDR'] . '%')->first();
|
||||
if ($node == null && $_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
|
||||
$res['ret'] = 0;
|
||||
$res['data'] = 'token or source is invalid, Your ip address is ' . $_SERVER['REMOTE_ADDR'];
|
||||
$response->getBody()->write(json_encode($res));
|
||||
return $response;
|
||||
if ($auth === false || ($node === null && $_SERVER['REMOTE_ADDR'] != '127.0.0.1')) {
|
||||
return $response->withJson([
|
||||
'ret' => 0,
|
||||
'data' => 'Token or IP is invalid. Now, your IP address is ' . $_SERVER['REMOTE_ADDR']
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$response = $next($request, $response);
|
||||
return $response;
|
||||
return $next($request, $response);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Middleware;
|
||||
|
||||
use App\Services\Config;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use App\Utils\Helper;
|
||||
use App\Models\Node;
|
||||
|
||||
class Mu
|
||||
{
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, $next)
|
||||
{
|
||||
$key = Helper::getParam($request, 'key');
|
||||
if ($key === null) {
|
||||
$res['ret'] = 0;
|
||||
$res['msg'] = 'key is null';
|
||||
$response->getBody()->write(json_encode($res));
|
||||
return $response;
|
||||
}
|
||||
|
||||
$auth = false;
|
||||
$keyset = explode(',', Config::get('muKey'));
|
||||
foreach ($keyset as $sinkey) {
|
||||
if ($key == $sinkey) {
|
||||
$auth = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($auth == false) {
|
||||
$res['ret'] = 0;
|
||||
$res['msg'] = 'token or source is invalid';
|
||||
$response->getBody()->write(json_encode($res));
|
||||
return $response;
|
||||
}
|
||||
|
||||
$node = Node::where('node_ip', 'LIKE', $_SERVER['REMOTE_ADDR'] . '%')->first();
|
||||
if ($node == null && $_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
|
||||
$res['ret'] = 0;
|
||||
$res['msg'] = 'token or source is invalid';
|
||||
$response->getBody()->write(json_encode($res));
|
||||
return $response;
|
||||
}
|
||||
|
||||
$response = $next($request, $response);
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Services\DefaultConfig;
|
||||
|
||||
class GConfig extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $connection = 'default';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'gconfig';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'key';
|
||||
|
||||
/**
|
||||
* Indicates if the IDs are auto-incrementing.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $incrementing = false;
|
||||
|
||||
/**
|
||||
* The "type" of the auto-incrementing ID.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $keyType = 'string';
|
||||
|
||||
public static function recover($user)
|
||||
{
|
||||
$this->oldvalue = $this->value;
|
||||
$this->value = DefaultConfig::default_value($this->key)['value'];
|
||||
$this->operator_id = $user->id;
|
||||
$this->operator_name = ('[恢复默认] - ' . $user->user_name);
|
||||
$this->operator_email = $user->email;
|
||||
$this->last_update = time();
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Auth;
|
||||
|
||||
class File
|
||||
{
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Services\Auth;
|
||||
|
||||
use App\Services\Factory;
|
||||
|
||||
class Token extends Base
|
||||
{
|
||||
protected $storage;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->storage = Factory::createTokenStorage();
|
||||
}
|
||||
|
||||
public function login($uid, $time)
|
||||
{
|
||||
// TODO: Implement getUser() method.
|
||||
}
|
||||
|
||||
public function logout()
|
||||
{
|
||||
// TODO: Implement logout() method.
|
||||
}
|
||||
|
||||
public function getUser()
|
||||
{
|
||||
$token = Cookie::get('token');
|
||||
}
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
class Cache
|
||||
{
|
||||
}
|
||||
@ -1,161 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: tonyzou
|
||||
* Author:
|
||||
* Date: 2018/9/24
|
||||
* Time: 下午4:01
|
||||
*/
|
||||
|
||||
/**
|
||||
* Made By Leo
|
||||
* 黛米付接口
|
||||
* 2.1.4版本
|
||||
* 适用于 V1 API 黛米付面板V1
|
||||
* copyright all rights reserved
|
||||
*/
|
||||
|
||||
namespace App\Services\Gateway;
|
||||
|
||||
use App\Services\View;
|
||||
use App\Services\Auth;
|
||||
use App\Services\Config;
|
||||
|
||||
use App\Models\Paylist;
|
||||
|
||||
|
||||
class DoiAMPay extends AbstractPayment
|
||||
{
|
||||
public function getPurchaseHTML()
|
||||
{
|
||||
return View::getSmarty()->assign('enabled', Config::get('doiampay')['enabled'])->fetch('user/doiam.tpl');
|
||||
}
|
||||
|
||||
public function notify($request, $response, $args)
|
||||
{
|
||||
$order_data = $_POST;
|
||||
$status = $order_data['status']; //获取传递过来的交易状态
|
||||
$invoiceid = $order_data['out_trade_no']; //订单号
|
||||
$transid = $order_data['trade_no']; //转账交易号
|
||||
$amount = $order_data['money']; //获取递过来的总价格
|
||||
if (!DoiAM::checksign($_POST, Config::get('doiampay')['mchdata'][$args['type']]['token'])) {
|
||||
return json_encode(array('errcode' => 2333));
|
||||
}
|
||||
if ($status == 'success') {
|
||||
$this->postPayment($invoiceid, '黛米付' . ['wepay' => '(微信)', 'qqpay' => '(QQ支付)', 'alipay' => '(支付宝)'][$args['type']]);
|
||||
return json_encode(['errcode' => 0]);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function purchase($request, $response, $args)
|
||||
{
|
||||
$type = $request->getParam('type');
|
||||
$price = $request->getParam('price');
|
||||
if (Config::get('doiampay')['enabled'][$type] == 0) {
|
||||
return json_encode(['errcode' => -1, 'errmsg' => '非法的支付方式.']);
|
||||
}
|
||||
if ($price <= 0) {
|
||||
return json_encode(['errcode' => -1, 'errmsg' => '非法的金额.']);
|
||||
}
|
||||
$user = Auth::getUser();
|
||||
$settings = Config::get('doiampay')['mchdata'][$type];
|
||||
$pl = new Paylist();
|
||||
$pl->userid = $user->id;
|
||||
$pl->total = $price;
|
||||
$pl->tradeno = self::generateGuid();
|
||||
$pl->save();
|
||||
$data = [
|
||||
'trade' => $pl->tradeno,
|
||||
'price' => $price,
|
||||
'phone' => $settings['phone'],
|
||||
'mchid' => $settings['mchid'],
|
||||
'subject' => Config::get('appName') . '充值' . $price . '元',
|
||||
'body' => Config::get('appName') . '充值' . $price . '元',
|
||||
'type' => 'Mod',
|
||||
];
|
||||
$data = DoiAM::sign($data, $settings['token']);
|
||||
$ret = DoiAM::post('https://api.daimiyun.cn/v2/' . $type . '/create', $data);
|
||||
$result = json_decode($ret, true);
|
||||
if ($result && $result['errcode'] == 0) {
|
||||
$result['pid'] = $pl->tradeno;
|
||||
return json_encode($result);
|
||||
}
|
||||
|
||||
return json_encode([
|
||||
'errcode' => -1,
|
||||
'errmsg' => '接口调用失败!' . $ret,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function getReturnHTML($request, $response, $args)
|
||||
{
|
||||
$money = $_GET['money'];
|
||||
echo "您已经成功支付 $money 元,正在跳转..";
|
||||
echo <<<HTML
|
||||
<script>
|
||||
location.href="/user/code";
|
||||
</script>
|
||||
HTML;
|
||||
}
|
||||
|
||||
public function getStatus($request, $response, $args)
|
||||
{
|
||||
$p = Paylist::where('tradeno', $_POST['pid'])->first();
|
||||
$return['ret'] = 1;
|
||||
$return['result'] = $p->status;
|
||||
return json_encode($return);
|
||||
}
|
||||
}
|
||||
|
||||
class DoiAM
|
||||
{
|
||||
public static function sort(&$array)
|
||||
{
|
||||
ksort($array);
|
||||
}
|
||||
|
||||
public static function getsign($array, $key)
|
||||
{
|
||||
unset($array['sign']);
|
||||
self::sort($array);
|
||||
$sss = http_build_query($array);
|
||||
$sign = hash('sha256', $sss . $key);
|
||||
$sign = sha1($sign . hash('sha256', $key));
|
||||
return $sign;
|
||||
}
|
||||
|
||||
public static function sign($array, $key)
|
||||
{
|
||||
$array['sign'] = self::getSign($array, $key);
|
||||
return $array;
|
||||
}
|
||||
|
||||
public static function checksign($array, $key)
|
||||
{
|
||||
$new = $array;
|
||||
$new = self::sign($new, $key);
|
||||
if (!isset($array['sign'])) {
|
||||
return false;
|
||||
}
|
||||
return $array['sign'] == $new['sign'];
|
||||
}
|
||||
|
||||
public static function post($url, $data = null)
|
||||
{
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
if (!empty($data)) {
|
||||
curl_setopt($curl, CURLOPT_POST, 1);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
||||
}
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
$output = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,458 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Gateway;
|
||||
|
||||
use App\Services\View;
|
||||
use App\Services\Auth;
|
||||
use App\Services\Config;
|
||||
use App\Models\Paylist;
|
||||
use App\Services\MalioConfig;
|
||||
use Omnipay\Omnipay;
|
||||
use Stripe\Stripe;
|
||||
use Stripe\Charge;
|
||||
|
||||
class MalioPay extends AbstractPayment
|
||||
{
|
||||
public function purchase($request, $response, $args)
|
||||
{
|
||||
$price = $request->getParam('price');
|
||||
$type = $request->getParam('type');
|
||||
$user = Auth::getUser();
|
||||
if ($type != 'alipay' and $type != 'wechat') {
|
||||
return json_encode(['ret' => 0, 'msg' => 'wrong type']);
|
||||
}
|
||||
|
||||
if ($price < MalioConfig::get('mups_minimum_amount')) {
|
||||
return json_encode(['ret' => 0, 'errmsg' => '充值最低金额为' . MalioConfig::get('mups_minimum_amount') . '元']);
|
||||
}
|
||||
|
||||
if ($price <= 0) {
|
||||
return json_encode(['ret' => 0, 'msg' => "金额必须大于0元"]);
|
||||
}
|
||||
|
||||
if ($type == 'alipay') {
|
||||
$payment_system = MalioConfig::get('mups_alipay');
|
||||
switch ($payment_system) {
|
||||
case ('bitpayx'):
|
||||
$bitpayx = new BitPayX(Config::get('bitpay_secret'));
|
||||
$result = $bitpayx->purchase_maliopay($type, $price);
|
||||
if ($result['errcode'] == 0) {
|
||||
$return = array(
|
||||
'ret' => 1,
|
||||
'type' => 'url',
|
||||
'tradeno' => $result['tradeno'],
|
||||
'url' => $result['url']
|
||||
);
|
||||
} else {
|
||||
$return = array(
|
||||
'ret' => 0,
|
||||
'msg' => $result['errmsg']
|
||||
);
|
||||
}
|
||||
return json_encode($return);
|
||||
case ('tomatopay'):
|
||||
$tomatopay = new TomatoPay();
|
||||
$result = $tomatopay->purchase_maliopay($type, $price);
|
||||
if ($result['errcode'] == 0) {
|
||||
$return = array(
|
||||
'ret' => 1,
|
||||
'type' => 'url',
|
||||
'tradeno' => $result['tradeno'],
|
||||
'url' => $result['code']
|
||||
);
|
||||
} else {
|
||||
$return = array(
|
||||
'ret' => 0,
|
||||
'msg' => $result['errmsg']
|
||||
);
|
||||
}
|
||||
return json_encode($return);
|
||||
case ('f2fpay'):
|
||||
$f2fpay = new AopF2F();
|
||||
$result = $f2fpay->purchase_maliopay($type, $price);
|
||||
if ($result['errcode'] == 0) {
|
||||
$return = array(
|
||||
'ret' => 1,
|
||||
'type' => 'qrcode',
|
||||
'tradeno' => $result['tradeno'],
|
||||
'url' => $result['url']
|
||||
);
|
||||
} else {
|
||||
$return = array(
|
||||
'ret' => 0,
|
||||
'msg' => $result['errmsg']
|
||||
);
|
||||
}
|
||||
return json_encode($return);
|
||||
case ('stripe'):
|
||||
$stripe = new StripePay();
|
||||
$result = $stripe->purchase_maliopay($type, $price);
|
||||
if ($result['errcode'] == 0) {
|
||||
$return = array(
|
||||
'ret' => 1,
|
||||
'type' => 'url',
|
||||
'tradeno' => $result['tradeno'],
|
||||
'url' => $result['url']
|
||||
);
|
||||
} else {
|
||||
$return = array(
|
||||
'ret' => 0,
|
||||
'msg' => $result['errmsg']
|
||||
);
|
||||
}
|
||||
return json_encode($return);
|
||||
case ('wolfpay'):
|
||||
$wolfpay = new Wolfpay();
|
||||
$result = $wolfpay->purchase_maliopay($type, $price);
|
||||
if ($result['errcode'] == 0) {
|
||||
$return = array(
|
||||
'ret' => 1,
|
||||
'type' => 'url',
|
||||
'tradeno' => $result['tradeno'],
|
||||
'url' => $result['url']
|
||||
);
|
||||
} else {
|
||||
$return = array(
|
||||
'ret' => 0,
|
||||
'msg' => $result['errmsg']
|
||||
);
|
||||
}
|
||||
return json_encode($return);
|
||||
case ('materialpay'):
|
||||
$materialpay = new MaterialPay(Config::get('materialpay_secret'));
|
||||
$result = $materialpay->purchase_maliopay($type, $price);
|
||||
if ($result['errcode'] == 0) {
|
||||
$return = array(
|
||||
'ret' => 1,
|
||||
'type' => 'url',
|
||||
'tradeno' => $result['tradeno'],
|
||||
'url' => $result['url']
|
||||
);
|
||||
} else {
|
||||
$return = array(
|
||||
'ret' => 0,
|
||||
'msg' => $result['errmsg']
|
||||
);
|
||||
}
|
||||
return json_encode($return);
|
||||
}
|
||||
} else if ($type == 'wechat') {
|
||||
$payment_system = MalioConfig::get('mups_wechat');
|
||||
switch ($payment_system) {
|
||||
case ('bitpayx'):
|
||||
$bitpayx = new BitPayX(Config::get('bitpay_secret'));
|
||||
$result = $bitpayx->purchase_maliopay($type, $price);
|
||||
if ($result['errcode'] == 0) {
|
||||
$return = array(
|
||||
'ret' => 1,
|
||||
'type' => 'qrcode',
|
||||
'tradeno' => $result['tradeno'],
|
||||
'url' => $result['qrcode_url']
|
||||
);
|
||||
} else {
|
||||
$return = array(
|
||||
'ret' => 0,
|
||||
'msg' => $result['errmsg']
|
||||
);
|
||||
}
|
||||
return json_encode($return);
|
||||
case ('tomatopay'):
|
||||
$tomatopay = new TomatoPay();
|
||||
$result = $tomatopay->purchase_maliopay($type, $price);
|
||||
if ($result['errcode'] == 0) {
|
||||
$return = array(
|
||||
'ret' => 1,
|
||||
'type' => 'url',
|
||||
'tradeno' => $result['tradeno'],
|
||||
'url' => $result['code']
|
||||
);
|
||||
} else {
|
||||
$return = array(
|
||||
'ret' => 0,
|
||||
'msg' => $result['errmsg']
|
||||
);
|
||||
}
|
||||
return json_encode($return);
|
||||
case ('stripe'):
|
||||
$stripe = new StripePay();
|
||||
$result = $stripe->purchase_maliopay($type, $price);
|
||||
if ($result['errcode'] == 0) {
|
||||
$return = array(
|
||||
'ret' => 1,
|
||||
'type' => 'qrcode',
|
||||
'tradeno' => $result['tradeno'],
|
||||
'url' => $result['url']
|
||||
);
|
||||
} else {
|
||||
$return = array(
|
||||
'ret' => 0,
|
||||
'msg' => $result['errmsg']
|
||||
);
|
||||
}
|
||||
return json_encode($return);
|
||||
case ('materialpay'):
|
||||
$materialpay = new MaterialPay(Config::get('materialpay_secret'));
|
||||
$result = $materialpay->purchase_maliopay($type, $price);
|
||||
if ($result['errcode'] == 0) {
|
||||
$return = array(
|
||||
'ret' => 1,
|
||||
'type' => 'qrcode',
|
||||
'tradeno' => $result['tradeno'],
|
||||
'url' => $result['url']
|
||||
);
|
||||
} else {
|
||||
$return = array(
|
||||
'ret' => 0,
|
||||
'msg' => $result['errmsg']
|
||||
);
|
||||
}
|
||||
return json_encode($return);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function notify($request, $response, $args)
|
||||
{
|
||||
$path = $request->getUri()->getPath();
|
||||
$path_exploded = explode('/', $path);
|
||||
$payment_system = $path_exploded[3];
|
||||
|
||||
switch ($payment_system) {
|
||||
case ('bitpayx'):
|
||||
$bitpayx = new BitPayX(Config::get('bitpay_secret'));
|
||||
if (!Config::get('bitpay_secret') || Config::get('bitpay_secret') === '') {
|
||||
$return = [];
|
||||
$return['status'] = 400;
|
||||
echo json_encode($return);
|
||||
return $return;
|
||||
}
|
||||
$inputString = file_get_contents('php://input', 'r');
|
||||
$inputStripped = str_replace(array("\r", "\n", "\t", "\v"), '', $inputString);
|
||||
$inputJSON = json_decode($inputStripped, true); //convert JSON into array
|
||||
$data = array();
|
||||
if ($inputJSON !== null) {
|
||||
$data['status'] = $inputJSON['status'];
|
||||
$data['order_id'] = $inputJSON['order_id'];
|
||||
$data['merchant_order_id'] = $inputJSON['merchant_order_id'];
|
||||
$data['price_amount'] = $inputJSON['price_amount'];
|
||||
$data['price_currency'] = $inputJSON['price_currency'];
|
||||
$data['created_at_t'] = $inputJSON['created_at_t'];
|
||||
}
|
||||
$str_to_sign = $bitpayx->prepareSignId($inputJSON['merchant_order_id']);
|
||||
$resultVerify = $bitpayx->verify($str_to_sign, $inputJSON['token']);
|
||||
$isPaid = $data !== null && $data['status'] !== null && $data['status'] === 'PAID';
|
||||
if ($resultVerify && $isPaid) {
|
||||
$bitpayx->postPaymentMaliopay($data['merchant_order_id'], '在线支付 ' . $data['merchant_order_id']);
|
||||
// echo 'SUCCESS';
|
||||
$return = [];
|
||||
$return['status'] = 200;
|
||||
echo json_encode($return);
|
||||
} else {
|
||||
// echo 'FAIL';
|
||||
$return = [];
|
||||
$return['status'] = 400;
|
||||
echo json_encode($return);
|
||||
}
|
||||
return $return;
|
||||
case ('tomatopay'):
|
||||
$type = 'alipay';
|
||||
$settings = Config::get("tomatopay")[$type];
|
||||
$order_data = $_REQUEST;
|
||||
$transid = $order_data['trade_no']; //转账交易号
|
||||
$invoiceid = $order_data['out_trade_no']; //订单号
|
||||
$amount = $order_data['total_fee']; //获取递过来的总价格
|
||||
$status = $order_data['trade_status']; //获取传递过来的交易状态
|
||||
$signs = $order_data['sign'];
|
||||
|
||||
if ($request->isGet()) {
|
||||
header("Location: /user/payment/return?tradeno=".$order_data['out_trade_no']);
|
||||
return 0;
|
||||
}
|
||||
|
||||
$security = array();
|
||||
$security['out_trade_no'] = $invoiceid;
|
||||
$security['total_fee'] = $amount;
|
||||
$security['trade_no'] = $transid;
|
||||
$security['trade_status'] = $status;
|
||||
foreach ($security as $k => $v) {
|
||||
$o .= "$k=" . urlencode($v) . "&";
|
||||
}
|
||||
$sign = md5(substr($o, 0, -1) . $settings['token']);
|
||||
|
||||
|
||||
if ($sign == $signs) {
|
||||
//验重
|
||||
$p = Paylist::where('tradeno', '=', $order_data['out_trade_no'])->first();
|
||||
$money = $p->total;
|
||||
if ($p->status != 1) {
|
||||
$this->postPaymentMaliopay($order_data['out_trade_no'], "在线支付");
|
||||
echo 'SUCCESS';
|
||||
} else {
|
||||
echo 'ERROR';
|
||||
}
|
||||
echo 'success';
|
||||
} else {
|
||||
echo '验证失败';
|
||||
}
|
||||
|
||||
return 'tomatopay';
|
||||
case ('f2fpay'):
|
||||
$f2fpay = new AopF2F();
|
||||
|
||||
$gateway = Omnipay::create('Alipay_AopF2F');
|
||||
$gateway->setSignType('RSA2'); //RSA/RSA2
|
||||
$gateway->setAppId(Config::get('f2fpay_app_id'));
|
||||
$gateway->setPrivateKey(Config::get('merchant_private_key')); // 可以是路径,也可以是密钥内容
|
||||
$gateway->setAlipayPublicKey(Config::get('alipay_public_key')); // 可以是路径,也可以是密钥内容
|
||||
|
||||
$aliRequest = $gateway->completePurchase();
|
||||
$aliRequest->setParams($_POST);
|
||||
|
||||
$aliResponse = $aliRequest->send();
|
||||
$pid = $aliResponse->data('out_trade_no');
|
||||
if ($aliResponse->isPaid()) {
|
||||
$this->postPaymentMaliopay($pid, '支付宝');
|
||||
die('success'); //The response should be 'success' only
|
||||
}
|
||||
return 'f2fpay';
|
||||
case ('stripe'):
|
||||
Stripe::setApiKey(Config::get('stripe_key'));
|
||||
$endpoint_secret = Config::get('stripe_webhook_endpoint_secret');
|
||||
$payload = @file_get_contents('php://input');
|
||||
$sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'];
|
||||
$event = null;
|
||||
|
||||
try {
|
||||
$event = \Stripe\Webhook::constructEvent(
|
||||
$payload,
|
||||
$sig_header,
|
||||
$endpoint_secret
|
||||
);
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
http_response_code(400);
|
||||
exit();
|
||||
} catch (\Stripe\Error\SignatureVerification $e) {
|
||||
http_response_code(400);
|
||||
exit();
|
||||
}
|
||||
|
||||
switch ($event->type) {
|
||||
case 'source.chargeable':
|
||||
$source = $event->data->object;
|
||||
$charge = Charge::create([
|
||||
'amount' => $source['amount'],
|
||||
'currency' => $source['currency'],
|
||||
'source' => $source['id'],
|
||||
]);
|
||||
if ($charge['status'] == 'succeeded') {
|
||||
$type = null;
|
||||
if ($source['type'] == 'alipay') {
|
||||
$type = '支付宝支付';
|
||||
} else if ($source['type'] == 'wechat') {
|
||||
$type = '微信支付';
|
||||
}
|
||||
$order = Paylist::where('tradeno', '=', $source['id'])->first();
|
||||
if ($order->status != 1) {
|
||||
$this->postPaymentMaliopay($source['id'], 'Stripe '.$type);
|
||||
echo 'SUCCESS';
|
||||
} else {
|
||||
echo 'ERROR';
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
http_response_code(400);
|
||||
exit();
|
||||
}
|
||||
|
||||
http_response_code(200);
|
||||
case ('wolfpay'):
|
||||
$type = $args['method'];
|
||||
$settings = Config::get("wolfpay") ['config'];
|
||||
$security['orderid'] = $_REQUEST['out_trade_no'];
|
||||
if ($security['orderid'] == '' OR $security['orderid'] == null) {
|
||||
header("Location: /user/code");
|
||||
} else {
|
||||
//实例化支付类
|
||||
//$pay = new Pays($settings['hid'], $settings['key']);
|
||||
$wolfpay = new Wolfpay();
|
||||
//接收异步通知数据
|
||||
$data = $_GET;
|
||||
//商户订单号
|
||||
$out_trade_no = $data['out_trade_no'];
|
||||
//验证签名
|
||||
if ($wolfpay->verify($data)) {
|
||||
//验证支付状态
|
||||
if ($data['trade_status'] == 'TRADE_SUCCESS') {
|
||||
$wolfpay->postPaymentMaliopay($data['out_trade_no'], "在线支付");
|
||||
echo "success";
|
||||
header("Location: /user/code");
|
||||
}
|
||||
} else {
|
||||
echo '錯誤';
|
||||
}
|
||||
}
|
||||
case ('materialpay'):
|
||||
$data = array();
|
||||
$data['tradeStatus'] = $request->getParam('tradeStatus');
|
||||
$data['payAmount'] = number_format($request->getParam('payAmount'),2);
|
||||
$data['tradeNo'] = $request->getParam('tradeNo');
|
||||
$data['payType'] = $request->getParam('payType');
|
||||
$data['outTradeNo'] = $request->getParam('outTradeNo');
|
||||
|
||||
$pl = Paylist::where('tradeno',$data['outTradeNo'])->first();
|
||||
if ($pl->status == 1) {
|
||||
echo 'success';
|
||||
return;
|
||||
}
|
||||
|
||||
$materialpay = new MaterialPay(Config::get('materialpay_secret'));
|
||||
// 准备待签名数据
|
||||
$str_to_sign = $materialpay->prepareSign($data);
|
||||
// 验证签名
|
||||
$resultVerify = $materialpay->verify($str_to_sign, $request->getParam('sign'));
|
||||
if ($resultVerify) {
|
||||
$materialpay->postPaymentMaliopay($data['outTradeNo'], 'MaterialPay - ' . $data['outTradeNo']);
|
||||
echo 'success';
|
||||
return;
|
||||
} else {
|
||||
echo 'fail';
|
||||
return;
|
||||
}
|
||||
default:
|
||||
return 'failed';
|
||||
}
|
||||
}
|
||||
|
||||
public function getPurchaseHTML()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getReturnHTML($request, $response, $args)
|
||||
{
|
||||
$tradeno = $_GET['tradeno'];
|
||||
if ($tradeno == '' || $tradeno == null) {
|
||||
$tradeno = $_GET['source'];
|
||||
}
|
||||
if ($tradeno == '' || $tradeno == null) {
|
||||
$tradeno = $_GET['out_trade_no'];
|
||||
}
|
||||
$p = Paylist::where('tradeno', '=', $tradeno)->first();
|
||||
$money = $p->total;
|
||||
if ($p->status === 1) {
|
||||
$success = 1;
|
||||
} else {
|
||||
$success = 0;
|
||||
}
|
||||
return View::getSmarty()->assign('money', $money)->assign('success', $success)->fetch('user/pay_success.tpl');
|
||||
}
|
||||
|
||||
public function getStatus($request, $response, $args)
|
||||
{
|
||||
$p = Paylist::where('tradeno', $_POST['tradeno'])->first();
|
||||
$return['ret'] = 1;
|
||||
$return['result'] = $p->status;
|
||||
return json_encode($return);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,131 @@
|
||||
<?php
|
||||
namespace App\Services\Gateway;
|
||||
use App\Services\View;
|
||||
use App\Services\Auth;
|
||||
use App\Services\Config;
|
||||
use App\Models\Paylist;
|
||||
|
||||
class Wolfpay extends AbstractPayment {
|
||||
private $pid;
|
||||
private $key;
|
||||
private $url;
|
||||
public function __construct() {
|
||||
$config = Config::get("wolfpay") ['config'];
|
||||
$this->pid = $config['hid'];
|
||||
$this->key = $config['key'];
|
||||
$this->url = $config['url'];
|
||||
}
|
||||
|
||||
public function purchase($request, $response, $args) {
|
||||
return '';
|
||||
}
|
||||
|
||||
public function purchase_maliopay($type, $price) {
|
||||
$user = Auth::getUser();
|
||||
$settings = Config::get("wolfpay")['config'];
|
||||
$pl = new Paylist();
|
||||
$pl->userid = $user->id;
|
||||
$pl->total = $price;
|
||||
$pl->tradeno = self::generateGuid();
|
||||
$pl->save();
|
||||
|
||||
//支付方式
|
||||
$type = 'all'; //$type;
|
||||
//订单号
|
||||
$out_trade_no = $pl->tradeno;
|
||||
//异步通知地址
|
||||
$notify_url = 'https://' . $_SERVER['HTTP_HOST'] . '/payment/notify/wolfpay/' . $type;
|
||||
//回调通知地址
|
||||
$return_url = 'https://' . $_SERVER['HTTP_HOST'] . '/user/payment/return';
|
||||
//商品名称
|
||||
$name = 'SS商品-' . $_SERVER['HTTP_HOST'];
|
||||
//支付金额(保留小数点后两位)
|
||||
$money = round($price, 2);
|
||||
//站点名称
|
||||
$sitename = $_SERVER['HTTP_HOST'];
|
||||
//发起支付
|
||||
$url = $this->submit($type, $out_trade_no, $notify_url, $return_url, $name, $money, $sitename);
|
||||
|
||||
return array(
|
||||
'url' => $url,
|
||||
'errcode' => 0,
|
||||
'tradeno' => $pl->tradeno
|
||||
);
|
||||
}
|
||||
|
||||
public function notify($request, $response, $args) {
|
||||
return '';
|
||||
}
|
||||
public function getPurchaseHTML() {
|
||||
return '';
|
||||
}
|
||||
public function getReturnHTML($request, $response, $args) {
|
||||
}
|
||||
public function getStatus($request, $response, $args) {
|
||||
// TODO: Implement getStatus() method.
|
||||
|
||||
}
|
||||
|
||||
public function verify($data) {
|
||||
if (!isset($data['sign']) || !$data['sign']) {
|
||||
return false;
|
||||
}
|
||||
$sign = $data['sign'];
|
||||
unset($data['sign']);
|
||||
unset($data['sign_type']);
|
||||
$sign2 = $this->getSign($data, $this->key);
|
||||
if ($sign != $sign2) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function submit($type, $out_trade_no, $notify_url, $return_url, $name, $money, $sitename) {
|
||||
$data = ['pid' => $this->pid, 'type' => $type, 'out_trade_no' => $out_trade_no, 'notify_url' => $notify_url, 'return_url' => $return_url, 'name' => $name, 'money' => $money, 'sitename' => $sitename];
|
||||
$string = http_build_query($data);
|
||||
$keys = $this->ensy($string, $this->pid);
|
||||
$keyss = $this->base64url_encode($this->pid . '-' . $keys);
|
||||
$sign = substr($this->ensy($keyss, $this->key) , 0, 15);
|
||||
return 'https://' . $this->url . '/submit?skey=' . $keyss . '&sign=' . $sign . '&sign_type=MD5';
|
||||
}
|
||||
|
||||
private function getSign($data) {
|
||||
$data = array_filter($data);
|
||||
ksort($data);
|
||||
$str1 = '';
|
||||
foreach ($data as $k => $v) {
|
||||
$str1.= '&' . $k . "=" . $v;
|
||||
}
|
||||
$str = $str1 . $this->key;
|
||||
$str = trim($str, '&');
|
||||
$sign = md5($str);
|
||||
return $sign;
|
||||
}
|
||||
|
||||
public function ensy($data, $key) {
|
||||
$key = md5($key);
|
||||
$len = strlen($data);
|
||||
$code = '';
|
||||
for ($i = 0; $i < ceil($len / 32); $i++) {
|
||||
for ($j = 0; $j < 32; $j++) {
|
||||
$p = $i * 32 + $j;
|
||||
if ($p < $len) {
|
||||
$code.= $data{$p} ^ $key{$j};
|
||||
}
|
||||
}
|
||||
}
|
||||
$code = str_replace(array(
|
||||
'+',
|
||||
'/',
|
||||
'='
|
||||
) , array(
|
||||
'_',
|
||||
'$',
|
||||
''
|
||||
) , base64_encode($code));
|
||||
return $code;
|
||||
}
|
||||
public function base64url_encode($data) {
|
||||
return rtrim(strtr(base64_encode($data) , '+/', '-_') , '=');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Utils\Cookie;
|
||||
|
||||
class Internationalization
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->lang = MalioConfig::get('default_lang');
|
||||
}
|
||||
|
||||
public function detectLang($request, $response, $args)
|
||||
{
|
||||
$user = Auth::getUser();
|
||||
if ($user->isLogin == true && $user->lang != null) {
|
||||
$lang = $user->lang;
|
||||
} else {
|
||||
$cookie = Cookie::get('lang');
|
||||
if ($cookie != null || $cookie != '') {
|
||||
$lang = $cookie;
|
||||
} else {
|
||||
$accept_language = $request->getHeader('Accept-Language');
|
||||
$accept_language = strtolower($accept_language[0]);
|
||||
$accept_language = explode(";",$accept_language)[0];
|
||||
$accept_language = explode(",",$accept_language)[0];
|
||||
if (strpos($accept_language, 'zh') !== false) {
|
||||
if (strpos($accept_language, 'cn') !== false || strpos($accept_language, 'sg') !== false) {
|
||||
$lang = 'zh-cn';
|
||||
} elseif (strpos($accept_language, 'tw') !== false || strpos($accept_language, 'hk') !== false) {
|
||||
$lang = 'zh-cn';
|
||||
} else {
|
||||
$lang = 'zh-cn';
|
||||
}
|
||||
} else if (strpos($accept_language, 'en') !== false) {
|
||||
$lang = 'en';
|
||||
}
|
||||
|
||||
if ($lang == null) {
|
||||
$lang = MalioConfig::get('default_lang');
|
||||
}
|
||||
|
||||
Cookie::set([
|
||||
'lang' => $lang
|
||||
],'1775445251');
|
||||
}
|
||||
}
|
||||
|
||||
$this->lang = $lang;
|
||||
return $lang;
|
||||
}
|
||||
|
||||
public function get($name, $args=null) {
|
||||
global $I18N;
|
||||
if ($args == null){
|
||||
return $I18N[$name][$this->lang];
|
||||
} else {
|
||||
$counter = 1;
|
||||
$text = $I18N[$name][$this->lang];
|
||||
foreach ($args as $arg) {
|
||||
$text = str_replace("$".$counter, $arg, $text);
|
||||
$counter += 1;
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getPublicConfig()
|
||||
{
|
||||
global $I18N;
|
||||
return $I18N;
|
||||
}
|
||||
}
|
||||
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Slim\App;
|
||||
use Zeuxisoo\Whoops\Provider\Slim\WhoopsMiddleware;
|
||||
|
||||
/***
|
||||
* The slim documents: http://www.slimframework.com/docs/objects/router.html
|
||||
*/
|
||||
class Slim
|
||||
{
|
||||
public $app;
|
||||
|
||||
public function newApp()
|
||||
{
|
||||
// config
|
||||
$debug = false;
|
||||
if (defined('DEBUG')) {
|
||||
$debug = true;
|
||||
}
|
||||
|
||||
// Make a Slim App
|
||||
$app = new App([
|
||||
'settings' => [
|
||||
'debug' => $debug,
|
||||
'whoops.editor' => 'sublime',
|
||||
'displayErrorDetails' => $debug
|
||||
]
|
||||
]);
|
||||
$app->add(new WhoopsMiddleware());
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
$this->app->run();
|
||||
}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Token;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
abstract class Base
|
||||
{
|
||||
abstract public function store($token, User $user, $expireTime);
|
||||
|
||||
abstract public function delete($token);
|
||||
|
||||
abstract public function get($token);
|
||||
}
|
||||
@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Services\Token;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Token as TokenModel;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
|
||||
class DB extends Base
|
||||
{
|
||||
public function store($tokenStr, User $user, $expireTime)
|
||||
{
|
||||
$token = new TokenModel();
|
||||
$token->token = $tokenStr;
|
||||
$token->user_id = $user->id;
|
||||
$token->create_time = time();
|
||||
$token->expire_time = $expireTime;
|
||||
if ($token->save()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function delete($token)
|
||||
{
|
||||
$token = TokenModel::where('token', $token)->first();
|
||||
if ($token == null) {
|
||||
return false;
|
||||
}
|
||||
$token->delete();
|
||||
return true;
|
||||
}
|
||||
|
||||
public function get($token)
|
||||
{
|
||||
try {
|
||||
$tokenModel = TokenModel::where('token', $token)->firstOrFail();
|
||||
} catch (ModelNotFoundException $e) {
|
||||
return null;
|
||||
}
|
||||
$token = new Token();
|
||||
$token->token = $tokenModel->token;
|
||||
$token->userId = $tokenModel->user_id;
|
||||
$token->createTime = $tokenModel->create_time;
|
||||
$token->expireTime = $tokenModel->expire_time;
|
||||
return $token;
|
||||
}
|
||||
}
|
||||
@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Token;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Services\Aws\Factory;
|
||||
|
||||
class Dynamodb extends Base
|
||||
{
|
||||
protected $client;
|
||||
|
||||
protected $tableName = 'token';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->client = Factory::createDynamodb();
|
||||
$this->tableName = 'token';
|
||||
}
|
||||
|
||||
public function store($token, User $user, $expireTime)
|
||||
{
|
||||
$result = $this->client->putItem(array(
|
||||
'TableName' => $this->tableName,
|
||||
'Item' => array(
|
||||
'token' => array('S' => $token),
|
||||
'user_id' => array('N' => (string)$user->id),
|
||||
'create_time' => array('N' => (string)time()),
|
||||
'expire_time' => array('N' => (string)$expireTime)
|
||||
)
|
||||
));
|
||||
return true;
|
||||
}
|
||||
|
||||
public function delete($token)
|
||||
{
|
||||
$this->client->deleteItem(array(
|
||||
'TableName' => $this->tableName,
|
||||
'Key' => array(
|
||||
'token' => array('S' => $token),
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
public function get($token)
|
||||
{
|
||||
$result = $this->client->getItem(array(
|
||||
'ConsistentRead' => true,
|
||||
'TableName' => $this->tableName,
|
||||
'Key' => array(
|
||||
'token' => array('S' => $token),
|
||||
)
|
||||
));
|
||||
$token = new Token();
|
||||
$token->token = $result['Item']['token']['S'];
|
||||
$token->userId = $result['Item']['user_id']['N'];
|
||||
$token->createTime = $result['Item']['create_time']['N'];
|
||||
$token->expireTime = $result['Item']['expire_time']['N'];
|
||||
return $token;
|
||||
}
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Services\Token;
|
||||
|
||||
class Token
|
||||
{
|
||||
public $token;
|
||||
public $userId;
|
||||
public $createTime;
|
||||
public $expireTime;
|
||||
}
|
||||
@ -0,0 +1,519 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utils;
|
||||
|
||||
use App\Services\Config;
|
||||
|
||||
class AppURI
|
||||
{
|
||||
public static function getSurgeURI($item, $version)
|
||||
{
|
||||
$return = null;
|
||||
switch ($version) {
|
||||
case 2:
|
||||
if ($item['obfs'] == 'v2ray') {
|
||||
break;
|
||||
}
|
||||
if ($item['type'] == 'ss') {
|
||||
$return = ($item['remark'] . ' = custom, ' . $item['address'] . ', ' . $item['port'] . ', ' . $item['method'] . ', ' . $item['passwd'] . ', https://raw.githubusercontent.com/lhie1/Rules/master/SSEncrypt.module' . URL::getSurgeObfs($item));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
switch ($item['type']) {
|
||||
case 'ss':
|
||||
if ($item['obfs'] == 'v2ray') {
|
||||
break;
|
||||
}
|
||||
$return = ($item['remark'] . ' = ss, ' . $item['address'] . ', ' . $item['port'] . ', encrypt-method=' . $item['method'] . ', password=' . $item['passwd'] . URL::getSurgeObfs($item) . ', udp-relay=true');
|
||||
break;
|
||||
case 'vmess':
|
||||
if (!in_array($item['net'], ['ws', 'tcp'])) {
|
||||
break;
|
||||
}
|
||||
$tls = ($item['tls'] == 'tls'
|
||||
? ', tls=true'
|
||||
: '');
|
||||
$ws = ($item['net'] == 'ws'
|
||||
? ', ws=true, ws-path=' . $item['path'] . ', ws-headers=host:' . $item['host']
|
||||
: '');
|
||||
$return = $item['remark'] . ' = vmess, ' . $item['add'] . ', ' . $item['port'] . ', username = ' . $item['id'] . $ws . $tls;
|
||||
break;
|
||||
case 'trojan':
|
||||
$return = ($item['remark'] . ' = trojan, ' . $item['address'] . ', ' . $item['port'] . ', password=' . $item['passwd']) . ", sni=" . $item['host'];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function getQuantumultURI($item, $base64_encode = false)
|
||||
{
|
||||
$return = null;
|
||||
switch ($item['type']) {
|
||||
case 'ss':
|
||||
if ($item['obfs'] == 'v2ray') {
|
||||
break;
|
||||
}
|
||||
$return = ($item['remark'] . ' = shadowsocks, ' . $item['address'] . ', ' . $item['port'] . ', ' . $item['method'] . ', "' . $item['passwd'] . '", upstream-proxy=false, upstream-proxy-auth=false' . URL::getSurgeObfs($item) . ', group=' . Config::get('appName') . '_ss');
|
||||
break;
|
||||
case 'ssr':
|
||||
$return = ($item['remark'] . ' = shadowsocksr, ' . $item['address'] . ', ' . $item['port'] . ', ' . $item['method'] . ', "' . $item['passwd'] . '", protocol=' . $item['protocol'] . ', protocol_param=' . $item['protocol_param'] . ', obfs=' . $item['obfs'] . ', obfs_param="' . $item['obfs_param'] . '", group=' . Config::get('appName'));
|
||||
break;
|
||||
case 'vmess':
|
||||
if (!in_array($item['net'], ['ws', 'tcp', 'http'])) {
|
||||
break;
|
||||
}
|
||||
$tls = ', over-tls=false, certificate=1';
|
||||
if ($item['tls'] == 'tls') {
|
||||
$tls = ', over-tls=true';
|
||||
if ($item['verify_cert']) {
|
||||
$tls .=', tls-host=' . $item['host'];
|
||||
$tls .= ', certificate=1';
|
||||
} else {
|
||||
$tls .=', tls-host=' . $item['host'];
|
||||
$tls .= ', certificate=0';
|
||||
}
|
||||
}
|
||||
$obfs = '';
|
||||
if (in_array($item['net'], ['ws', 'http'])) {
|
||||
$obfs = ', obfs=' . $item['net'] . ', obfs-path="' . $item['path'] . '", obfs-header="Host: ' . $item['host'] . '[Rr][Nn]User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 18_0_0 like Mac OS X) AppleWebKit/888.8.88 (KHTML, like Gecko) Mobile/6666666"';
|
||||
}
|
||||
$return = ($item['remark'] . ' = vmess, ' . $item['add'] . ', ' . $item['port'] . ', chacha20-ietf-poly1305, "' . $item['id'] . '", group=' . Config::get('appName') . '_VMess' . $tls . $obfs);
|
||||
if ($base64_encode === true) {
|
||||
$return = 'vmess://' . base64_encode($return);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function getQuantumultXURI($item)
|
||||
{
|
||||
$return = null;
|
||||
switch ($item['type']) {
|
||||
case 'ss':
|
||||
// ;shadowsocks=example.com:80, method=chacha20, password=pwd, obfs=http, obfs-host=bing.com, obfs-uri=/resource/file, fast-open=false, udp-relay=false, server_check_url=http://www.apple.com/generate_204, tag=ss-01
|
||||
// ;shadowsocks=example.com:80, method=chacha20, password=pwd, obfs=http, obfs-host=bing.com, obfs-uri=/resource/file, fast-open=false, udp-relay=false, tag=ss-02
|
||||
// ;shadowsocks=example.com:443, method=chacha20, password=pwd, obfs=tls, obfs-host=bing.com, fast-open=false, udp-relay=false, tag=ss-03
|
||||
// ;shadowsocks=example.com:80, method=aes-128-gcm, password=pwd, obfs=ws, fast-open=false, udp-relay=false, tag=ss-ws-01
|
||||
// ;shadowsocks=example.com:80, method=aes-128-gcm, password=pwd, obfs=ws, obfs-uri=/ws, fast-open=false, udp-relay=false, tag=ss-ws-02
|
||||
// ;shadowsocks=example.com:443, method=aes-128-gcm, password=pwd, obfs=wss, obfs-uri=/ws, fast-open=false, udp-relay=false, tag=ss-ws-tls
|
||||
$return = ('shadowsocks=' . $item['address'] . ':' . $item['port'] . ', method=' . $item['method'] . ', password=' . $item['passwd']);
|
||||
switch ($item['obfs']) {
|
||||
case 'simple_obfs_http':
|
||||
$return .= ', obfs=http';
|
||||
$return .= ($item['obfs_param'] != '' ? ', obfs-host=' . $item['obfs_param'] : ', obfs-host=wns.windows.com');
|
||||
$return .= ', obfs-uri=/';
|
||||
break;
|
||||
case 'simple_obfs_tls':
|
||||
$return .= ', obfs=tls';
|
||||
$return .= ($item['obfs_param'] != '' ? ', obfs-host=' . $item['obfs_param'] : ', obfs-host=wns.windows.com');
|
||||
$return .= ', obfs-uri=/';
|
||||
break;
|
||||
case 'v2ray';
|
||||
$return .= ($item['tls'] == 'tls' ? ', obfs=wss' : ', obfs=ws');
|
||||
$return .= ', obfs-uri=' . $item['path'];
|
||||
break;
|
||||
}
|
||||
$return .= (', tag=' . $item['remark']);
|
||||
break;
|
||||
case 'ssr':
|
||||
// ;shadowsocks=example.com:443, method=chacha20, password=pwd, ssr-protocol=auth_chain_b, ssr-protocol-param=def, obfs=tls1.2_ticket_fastauth, obfs-host=bing.com, tag=ssr
|
||||
$return = ('shadowsocks=' . $item['address'] . ':' . $item['port'] . ', method=' . $item['method'] . ', password=' . $item['passwd']);
|
||||
$return .= (', ssr-protocol=' . $item['protocol']);
|
||||
$return .= (', ssr-protocol-param=' . $item['protocol_param']);
|
||||
$return .= (', obfs=' . $item['obfs']);
|
||||
$return .= (', obfs-host="' . $item['obfs_param']);
|
||||
$return .= (', tag=' . $item['remark']);
|
||||
break;
|
||||
case 'vmess':
|
||||
// ;vmess=example.com:80, method=none, password=23ad6b10-8d1a-40f7-8ad0-e3e35cd32291, fast-open=false, udp-relay=false, tag=vmess-01
|
||||
// ;vmess=example.com:80, method=aes-128-gcm, password=23ad6b10-8d1a-40f7-8ad0-e3e35cd32291, fast-open=false, udp-relay=false, tag=vmess-02
|
||||
// ;vmess=example.com:443, method=none, password=23ad6b10-8d1a-40f7-8ad0-e3e35cd32291, obfs=over-tls, fast-open=false, udp-relay=false, tag=vmess-tls
|
||||
// ;vmess=example.com:80, method=chacha20-poly1305, password=23ad6b10-8d1a-40f7-8ad0-e3e35cd32291, obfs=ws, obfs-uri=/ws, fast-open=false, udp-relay=false, tag=vmess-ws
|
||||
// ;vmess=example.com:443, method=chacha20-poly1305, password=23ad6b10-8d1a-40f7-8ad0-e3e35cd32291, obfs=wss, obfs-uri=/ws, fast-open=false, udp-relay=false, tag=vmess-ws-tls
|
||||
if (!in_array($item['net'], ['ws', 'tcp'])) {
|
||||
break;
|
||||
}
|
||||
$return = ('vmess=' . $item['add'] . ':' . $item['port'] . ', method=chacha20-poly1305' . ', password=' . $item['id']);
|
||||
switch ($item['net']) {
|
||||
case 'ws':
|
||||
$return .= ($item['tls'] == 'tls' ? ', obfs=wss' : ', obfs=ws');
|
||||
$return .= ', obfs-uri=' . $item['path'];
|
||||
break;
|
||||
case 'tcp':
|
||||
$return .= ($item['tls'] == 'tls' ? ', obfs=over-tls' : '');
|
||||
break;
|
||||
}
|
||||
$return .= (', tag=' . $item['remark']);
|
||||
break;
|
||||
case 'trojan':
|
||||
// ;trojan=example.com:443, password=pwd, over-tls=true, tls-verification=true, fast-open=false, udp-relay=false, tag=trojan-tls-01
|
||||
$return = ('trojan=' . $item['address'] . ':' . $item['port'] . ', password=' . $item['passwd'] . ', tls-host=' . $item['host']);
|
||||
$return .= ', over-tls=true, tls-verification=true';
|
||||
$return .= (', tag=' . $item['remark']);
|
||||
break;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function getSurfboardURI($item)
|
||||
{
|
||||
$return = null;
|
||||
switch ($item['type']) {
|
||||
case 'ss':
|
||||
if ($item['obfs'] == 'v2ray') {
|
||||
break;
|
||||
}
|
||||
$return = ($item['remark'] . ' = custom, ' . $item['address'] . ', ' . $item['port'] . ', ' . $item['method'] . ', ' . $item['passwd'] . ', https://raw.githubusercontent.com/lhie1/Rules/master/SSEncrypt.module' . URL::getSurgeObfs($item));
|
||||
break;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function getClashURI($item, $ssr_support = false)
|
||||
{
|
||||
$return = null;
|
||||
if ($item['type'] == 'ssr' && $ssr_support === false) {
|
||||
return $return;
|
||||
}
|
||||
switch ($item['type']) {
|
||||
case 'ss':
|
||||
$method = ['rc4-md5-6', 'camellia-128-cfb', 'camellia-192-cfb', 'camellia-256-cfb', 'bf-cfb', 'cast5-cfb', 'des-cfb', 'des-ede3-cfb', 'idea-cfb', 'rc2-cfb', 'seed-cfb', 'salsa20', 'chacha20', 'xsalsa20', 'none'];
|
||||
if (in_array($item['method'], $method)) {
|
||||
// 不支持的
|
||||
break;
|
||||
}
|
||||
$return = [
|
||||
'name' => $item['remark'],
|
||||
'type' => 'ss',
|
||||
'server' => $item['address'],
|
||||
'port' => $item['port'],
|
||||
'cipher' => $item['method'],
|
||||
'password' => $item['passwd'],
|
||||
'udp' => true
|
||||
];
|
||||
if ($item['obfs'] != 'plain') {
|
||||
switch ($item['obfs']) {
|
||||
case 'simple_obfs_http':
|
||||
$return['plugin'] = 'obfs';
|
||||
$return['plugin-opts']['mode'] = 'http';
|
||||
break;
|
||||
case 'simple_obfs_tls':
|
||||
$return['plugin'] = 'obfs';
|
||||
$return['plugin-opts']['mode'] = 'tls';
|
||||
break;
|
||||
case 'v2ray':
|
||||
$return['plugin'] = 'v2ray-plugin';
|
||||
$return['plugin-opts']['mode'] = 'websocket';
|
||||
if ($item['tls'] == 'tls') {
|
||||
$return['plugin-opts']['tls'] = true;
|
||||
if ($item['verify_cert'] == false) {
|
||||
$return['plugin-opts']['skip-cert-verify'] = true;
|
||||
}
|
||||
}
|
||||
$return['plugin-opts']['host'] = $item['host'];
|
||||
$return['plugin-opts']['path'] = $item['path'];
|
||||
break;
|
||||
}
|
||||
if ($item['obfs'] != 'v2ray') {
|
||||
if ($item['obfs_param'] != '') {
|
||||
$return['plugin-opts']['host'] = $item['obfs_param'];
|
||||
} else {
|
||||
$return['plugin-opts']['host'] = 'windowsupdate.windows.com';
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'ssr':
|
||||
if (
|
||||
in_array($item['method'], ['rc4-md5-6', 'des-ede3-cfb', 'xsalsa20', 'none'])
|
||||
||
|
||||
in_array($item['protocol'], array_merge(Config::getSupportParam('allow_none_protocol'), ['verify_deflate']))
|
||||
||
|
||||
in_array($item['obfs'], ['tls1.2_ticket_fastauth'])
|
||||
) {
|
||||
// 不支持的
|
||||
break;
|
||||
}
|
||||
$return = [
|
||||
'name' => $item['remark'],
|
||||
'type' => 'ssr',
|
||||
'server' => $item['address'],
|
||||
'port' => $item['port'],
|
||||
'cipher' => $item['method'],
|
||||
'password' => $item['passwd'],
|
||||
'protocol' => $item['protocol'],
|
||||
'protocolparam' => $item['protocol_param'],
|
||||
'obfs' => $item['obfs'],
|
||||
'obfsparam' => $item['obfs_param']
|
||||
];
|
||||
break;
|
||||
case 'vmess':
|
||||
if (!in_array($item['net'], array('ws', 'tcp'))) {
|
||||
break;
|
||||
}
|
||||
$return = [
|
||||
'name' => $item['remark'],
|
||||
'type' => 'vmess',
|
||||
'server' => $item['add'],
|
||||
'port' => $item['port'],
|
||||
'uuid' => $item['id'],
|
||||
'alterId' => $item['aid'],
|
||||
'cipher' => 'auto',
|
||||
'udp' => true
|
||||
];
|
||||
if ($item['net'] == 'ws') {
|
||||
$return['network'] = 'ws';
|
||||
$return['ws-path'] = $item['path'];
|
||||
$return['ws-headers']['Host'] = ($item['host'] != '' ? $item['host'] : $item['add']);
|
||||
}
|
||||
if ($item['tls'] == 'tls') {
|
||||
$return['tls'] = true;
|
||||
if ($item['verify_cert'] == false) {
|
||||
$return['skip-cert-verify'] = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'trojan':
|
||||
$return = [
|
||||
'name' => $item['remark'],
|
||||
'type' => 'trojan',
|
||||
'server' => $item['address'],
|
||||
'port' => $item['port'],
|
||||
'password' => $item['passwd'],
|
||||
'sni' => $item['host']
|
||||
];
|
||||
break;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function getShadowrocketURI($item)
|
||||
{
|
||||
$return = null;
|
||||
switch ($item['type']) {
|
||||
case 'ss':
|
||||
if (in_array($item['obfs'], Config::getSupportParam('ss_obfs'))) {
|
||||
$return = (URL::getItemUrl($item, 1));
|
||||
} else {
|
||||
if ($item['obfs'] == 'v2ray') {
|
||||
$v2rayplugin = [
|
||||
'address' => $item['address'],
|
||||
'port' => (string) $item['port'],
|
||||
'path' => $item['path'],
|
||||
'host' => $item['host'],
|
||||
'mode' => 'websocket',
|
||||
];
|
||||
$v2rayplugin['tls'] = $item['tls'] == 'tls' ? true : false;
|
||||
if ($v2rayplugin['tls']) {
|
||||
if ($v2rayplugin['host'] != '' && $v2rayplugin['host'] != 'microsoft.com'){
|
||||
$v2rayplugin['peer'] = $v2rayplugin['host'];
|
||||
}else {
|
||||
$v2rayplugin['peer'] = $v2rayplugin['address'];
|
||||
}
|
||||
}else {
|
||||
$v2rayplugin['peer'] = '';
|
||||
}
|
||||
|
||||
$return = ('ss://' . Tools::base64_url_encode($item['method'] . ':' . $item['passwd'] . '@' . $item['address'] . ':' . $item['port']) . '?v2ray-plugin=' . base64_encode(json_encode($v2rayplugin)) . '#' . rawurlencode($item['remark']));
|
||||
}
|
||||
if ($item['obfs'] == 'plain') {
|
||||
$return = (URL::getItemUrl($item, 2));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'ssr':
|
||||
$return = (URL::getItemUrl($item, 0));
|
||||
break;
|
||||
case 'vmess':
|
||||
if (!in_array($item['net'], ['tcp', 'ws', 'http', 'h2'])) {
|
||||
break;
|
||||
}
|
||||
$obfs = '';
|
||||
switch ($item['net']) {
|
||||
case 'ws':
|
||||
$obfs .= ($item['host'] != ''
|
||||
? ('&obfsParam=' . $item['host'] . '&path=' . $item['path'] . '&obfs=websocket')
|
||||
: ('&obfsParam=' . $item['add'] . '&path=' . $item['path'] . '&obfs=websocket'));
|
||||
break;
|
||||
case 'kcp':
|
||||
$obfs .= 'obfsParam={"header":' . '"' . ($item['headerType'] == '' || $item['headerType'] == 'noop' ? 'none' : $item['headerType']) . '"' . '}&obfs=mkcp';
|
||||
break;
|
||||
case 'mkcp':
|
||||
$obfs .= 'obfsParam={"header":' . '"' . ($item['headerType'] == '' || $item['headerType'] == 'noop' ? 'none' : $item['headerType']) . '"' . '}&obfs=mkcp';
|
||||
break;
|
||||
case 'h2':
|
||||
$obfs .= ($item['host'] != ''
|
||||
? ('&obfsParam=' . $item['host'] . '&path=' . $item['path'] . '&obfs=h2')
|
||||
: ('&obfsParam=' . $item['add'] . '&path=' . $item['path'] . '&obfs=h2'));
|
||||
break;
|
||||
default:
|
||||
$obfs .= '&obfs=none';
|
||||
break;
|
||||
}
|
||||
$tls = '';
|
||||
if ($item['tls'] == 'tls') {
|
||||
$tls = '&tls=1';
|
||||
if ($item['verify_cert'] == false){
|
||||
$tls .= '&allowInsecure=1';
|
||||
}
|
||||
$tls .= '&peer=' . $item['host'];
|
||||
}
|
||||
$return = ('vmess://' . Tools::base64_url_encode('chacha20-poly1305:' . $item['id'] . '@' . $item['add'] . ':' . $item['port']) . '?remarks=' . rawurlencode($item['remark']) . $obfs . $tls);
|
||||
break;
|
||||
case 'trojan':
|
||||
$return = ('trojan://' . $item['passwd'] . '@' . $item['address'] . ':' . $item['port']);
|
||||
$return .= ('?peer=' . $item['host'] . '#' . rawurlencode($item['remark']));
|
||||
break;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function getKitsunebiURI($item)
|
||||
{
|
||||
$return = null;
|
||||
switch ($item['type']) {
|
||||
case 'ss':
|
||||
if (in_array($item['obfs'], ['v2ray', 'simple_obfs_http', 'simple_obfs_tls'])) {
|
||||
break;
|
||||
}
|
||||
$return = (URL::getItemUrl($item, 2));
|
||||
break;
|
||||
case 'vmess':
|
||||
$network = ($item['net'] == 'tls'
|
||||
? '&network=tcp'
|
||||
: ('&network=' . $item['net']));
|
||||
$protocol = '';
|
||||
switch ($item['net']) {
|
||||
case 'kcp':
|
||||
$protocol .= ('&kcpheader=' . $item['headerType']);
|
||||
break;
|
||||
case 'ws':
|
||||
$protocol .= ('&wspath=' . $item['path'] . '&wsHost=' . $item['host']);
|
||||
break;
|
||||
case 'h2':
|
||||
$protocol .= ('&h2Path=' . $item['path'] . '&h2Host=' . $item['host']);
|
||||
break;
|
||||
}
|
||||
$tls = '';
|
||||
if ($item['tls'] == 'tls') {
|
||||
$tls = '&tls=1';
|
||||
if ($item['verify_cert'] == false) {
|
||||
$tls .= '&allowInsecure=1';
|
||||
}
|
||||
}
|
||||
$return .= ('vmess://' . base64_encode('auto:' . $item['id'] . '@' . $item['add'] . ':' . $item['port']) . '?remark=' . rawurlencode($item['remark']) . $network . $protocol . '&aid=' . $item['aid'] . $tls);
|
||||
break;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function getSSDURI($item)
|
||||
{
|
||||
$return = null;
|
||||
switch ($item['type']) {
|
||||
case 'ss':
|
||||
# 666
|
||||
$return['remarks'] = $item['remark'];
|
||||
$return['server'] = $item['address'];
|
||||
$return['port'] = $item['port'];
|
||||
$return['encryption'] = $item['method'];
|
||||
$return['password'] = $item['passwd'];
|
||||
$plugin_options = '';
|
||||
if ($item['obfs'] != 'plain') {
|
||||
switch ($item['obfs']) {
|
||||
case 'simple_obfs_http':
|
||||
$return['plugin'] = 'simple-obfs';
|
||||
$plugin_options .= 'obfs=http;obfs-host=' . $item['obfs_param'];
|
||||
break;
|
||||
case 'simple_obfs_tls':
|
||||
$return['plugin'] = 'simple-obfs';
|
||||
$plugin_options .= 'obfs=tls;obfs-host=' . $item['obfs_param'];
|
||||
break;
|
||||
case 'v2ray':
|
||||
$return['plugin'] = 'v2ray';
|
||||
if ($item['net'] == 'ws') {
|
||||
$plugin_options .= 'mode=ws';
|
||||
}
|
||||
if ($item['tls'] == 'tls') {
|
||||
$plugin_options .= ';security=tls';
|
||||
} else {
|
||||
$plugin_options .= ';security=none';
|
||||
}
|
||||
$plugin_options .= ';path=' . $item['path'];
|
||||
if ($item['host'] != '') {
|
||||
$plugin_options .= ';host=' . $item['host'];
|
||||
} else {
|
||||
$plugin_options .= ';host=' . $item['address'];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
$return['plugin_options'] = $plugin_options;
|
||||
$return['ratio'] = $item['ratio'];
|
||||
break;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function getSSJSON($item)
|
||||
{
|
||||
$return = null;
|
||||
switch ($item['type']) {
|
||||
case 'ss':
|
||||
# 666
|
||||
$return['remarks'] = $item['remark'];
|
||||
$return['server'] = $item['address'];
|
||||
$return['server_port'] = $item['port'];
|
||||
$return['method'] = $item['method'];
|
||||
$return['password'] = $item['passwd'];
|
||||
if ($item['obfs'] != 'plain') {
|
||||
$plugin_options = '';
|
||||
switch ($item['obfs']) {
|
||||
case 'simple_obfs_http':
|
||||
$return['plugin'] = 'simple-obfs';
|
||||
$plugin_options .= 'obfs=http;obfs-host=' . $item['obfs_param'];
|
||||
break;
|
||||
case 'simple_obfs_tls':
|
||||
$return['plugin'] = 'simple-obfs';
|
||||
$plugin_options .= 'obfs=tls;obfs-host=' . $item['obfs_param'];
|
||||
break;
|
||||
case 'v2ray':
|
||||
$return['plugin'] = 'v2ray';
|
||||
if ($item['net'] == 'ws') {
|
||||
$plugin_options .= 'mode=ws';
|
||||
}
|
||||
if ($item['tls'] == 'tls') {
|
||||
$plugin_options .= ';security=tls';
|
||||
} else {
|
||||
$plugin_options .= ';security=none';
|
||||
}
|
||||
$plugin_options .= ';path=' . $item['path'];
|
||||
if ($item['host'] != '') {
|
||||
$plugin_options .= ';host=' . $item['host'];
|
||||
} else {
|
||||
$plugin_options .= ';host=' . $item['address'];
|
||||
}
|
||||
break;
|
||||
}
|
||||
$return['plugin_opts'] = $plugin_options;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function getTrojanURI(array $item)
|
||||
{
|
||||
$return = null;
|
||||
switch ($item['type']) {
|
||||
case 'trojan':
|
||||
$return = ('trojan://' . $item['passwd'] . '@' . $item['address'] . ':' . $item['port']);
|
||||
$return .= ('?peer=' . $item['host'] . '#' . rawurlencode($item['remark']));
|
||||
break;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
@ -1,179 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utils;
|
||||
/**
|
||||
* Made By Leo
|
||||
* 黛米付接口
|
||||
* 2.1.4版本
|
||||
* 适用于 V1 API 黛米付面板V1
|
||||
* copyright all rights reserved
|
||||
*/
|
||||
|
||||
use App\Services\View;
|
||||
use App\Services\Auth;
|
||||
use App\Services\Config;
|
||||
use App\Models\User;
|
||||
use App\Models\Code;
|
||||
use App\Models\Paylist;
|
||||
use App\Models\Payback;
|
||||
|
||||
class DoiAMPay
|
||||
{
|
||||
|
||||
|
||||
public static function render()
|
||||
{
|
||||
return View::getSmarty()->assign('enabled', Config::get('doiampay')['enabled'])->fetch('user/doiam.tpl');
|
||||
}
|
||||
|
||||
public function handle($request, $response, $args)
|
||||
{
|
||||
$type = $request->getParam('type');
|
||||
$price = $request->getParam('price');
|
||||
if (Config::get('doiampay')['enabled'][$type] == 0) {
|
||||
return json_encode(['errcode' => -1, 'errmsg' => '非法的支付方式.']);
|
||||
}
|
||||
if ($price <= 0) {
|
||||
return json_encode(['errcode' => -1, 'errmsg' => '非法的金额.']);
|
||||
}
|
||||
$user = Auth::getUser();
|
||||
$settings = Config::get('doiampay')['mchdata'][$type];
|
||||
$pl = new Paylist();
|
||||
$pl->userid = $user->id;
|
||||
$pl->total = $price;
|
||||
$pl->save();
|
||||
$data = [
|
||||
'trade' => $pl->id,
|
||||
'price' => $price,
|
||||
'phone' => $settings['phone'],
|
||||
'mchid' => $settings['mchid'],
|
||||
'subject' => Config::get('appName') . '充值' . $price . '元',
|
||||
'body' => Config::get('appName') . '充值' . $price . '元',
|
||||
'type' => 'Mod',
|
||||
];
|
||||
$data = DoiAM::sign($data, $settings['token']);
|
||||
$ret = DoiAM::post('https://api.daimiyun.cn/v2/' . $type . '/create', $data);
|
||||
$result = json_decode($ret, true);
|
||||
if ($result and $result['errcode'] == 0) {
|
||||
$result['pid'] = $pl->id;
|
||||
return json_Encode($result);
|
||||
}
|
||||
|
||||
return json_encode([
|
||||
'errcode' => -1,
|
||||
'errmsg' => '接口调用失败!' . $ret,
|
||||
]);
|
||||
}
|
||||
|
||||
public function status($request, $response, $args)
|
||||
{
|
||||
return json_encode(Paylist::find($_POST['pid']));
|
||||
}
|
||||
|
||||
public function handle_return($request, $response, $args)
|
||||
{
|
||||
$money = $_GET['money'];
|
||||
echo "您已经成功支付 $money 元,正在跳转..";
|
||||
echo <<<HTML
|
||||
<script>
|
||||
location.href="/user/code";
|
||||
</script>
|
||||
HTML;
|
||||
}
|
||||
|
||||
public function handle_callback($request, $response, $args)
|
||||
{
|
||||
$order_data = $_POST;
|
||||
$status = $order_data['status']; //获取传递过来的交易状态
|
||||
$invoiceid = $order_data['out_trade_no']; //订单号
|
||||
$transid = $order_data['trade_no']; //转账交易号
|
||||
$amount = $order_data['money']; //获取递过来的总价格
|
||||
if (!DoiAM::checksign($_POST, Config::get('doiampay')['mchdata'][$args['type']]['token'])) {
|
||||
return json_encode(array('errcode' => 2333));
|
||||
}
|
||||
if ($status == 'success') {
|
||||
$p = Paylist::find($invoiceid);
|
||||
if ($p->status == 1) {
|
||||
return json_encode(['errcode' => 0]);
|
||||
}
|
||||
$p->status = 1;
|
||||
$p->save();
|
||||
$user = User::find($p->userid);
|
||||
$user->money += $p->total;
|
||||
$user->save();
|
||||
$codeq = new Code();
|
||||
$codeq->code = ['wepay' => '微信', 'qqpay' => 'QQ支付', 'alipay' => '支付宝'][$args['type']] . '充值';
|
||||
$codeq->isused = 1;
|
||||
$codeq->type = -1;
|
||||
$codeq->number = $p->total;
|
||||
$codeq->usedatetime = date('Y-m-d H:i:s');
|
||||
$codeq->userid = $user->id;
|
||||
$codeq->save();
|
||||
if ($user->ref_by != '' && $user->ref_by != 0 && $user->ref_by != null) {
|
||||
$gift_user = User::where('id', '=', $user->ref_by)->first();
|
||||
$gift_user->money += ($codeq->number * (Config::get('code_payback') / 100));
|
||||
$gift_user->save();
|
||||
$Payback = new Payback();
|
||||
$Payback->total = $codeq->number;
|
||||
$Payback->userid = $user->id;
|
||||
$Payback->ref_by = $user->ref_by;
|
||||
$Payback->ref_get = $codeq->number * (Config::get('code_payback') / 100);
|
||||
$Payback->datetime = time();
|
||||
$Payback->save();
|
||||
}
|
||||
return json_encode(['errcode' => 0]);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
class DoiAM
|
||||
{
|
||||
public static function sort(&$array)
|
||||
{
|
||||
ksort($array);
|
||||
}
|
||||
|
||||
public static function getsign($array, $key)
|
||||
{
|
||||
unset($array['sign']);
|
||||
self::sort($array);
|
||||
$sss = http_build_query($array);
|
||||
$sign = hash('sha256', $sss . $key);
|
||||
$sign = sha1($sign . hash('sha256', $key));
|
||||
return $sign;
|
||||
}
|
||||
|
||||
public static function sign($array, $key)
|
||||
{
|
||||
$array['sign'] = self::getSign($array, $key);
|
||||
return $array;
|
||||
}
|
||||
|
||||
public static function checksign($array, $key)
|
||||
{
|
||||
$new = $array;
|
||||
$new = self::sign($new, $key);
|
||||
if (!isset($array['sign'])) {
|
||||
return false;
|
||||
}
|
||||
return $array['sign'] == $new['sign'];
|
||||
}
|
||||
|
||||
public static function post($url, $data = null)
|
||||
{
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
if (!empty($data)) {
|
||||
curl_setopt($curl, CURLOPT_POST, 1);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
||||
}
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
$output = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utils;
|
||||
|
||||
use GeoIp2\Database\Reader;
|
||||
use GeoIp2\Exception\AddressNotFoundException;
|
||||
|
||||
|
||||
class GeoIP2
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->reader = new Reader(BASE_PATH . '/storage/GeoLite2-City.mmdb');
|
||||
}
|
||||
|
||||
public function getLocation($ip, $lang)
|
||||
{
|
||||
try {
|
||||
$record = $this->reader->city($ip);
|
||||
} catch (AddressNotFoundException $e) {
|
||||
if ($lang == 'zh-cn') {
|
||||
return "未知";
|
||||
} else {
|
||||
return "Unknow";
|
||||
}
|
||||
}
|
||||
|
||||
if ($lang == 'zh-cn') {
|
||||
$lang = 'zh-CN';
|
||||
}
|
||||
|
||||
if ($lang == 'en') {
|
||||
return $record->city->name. ', '.$record->country->name;
|
||||
} else if ($lang == 'zh-CN') {
|
||||
return $record->country->names[$lang]. ' '.$record->city->names[$lang];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,420 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utils;
|
||||
|
||||
/**
|
||||
* Socket communication class.
|
||||
*
|
||||
* Originally designed for use with DirectAdmin's API, this class will fill any HTTP socket need.
|
||||
*
|
||||
* Very, very basic usage:
|
||||
* $Socket = new HTTPSocket;
|
||||
* echo $Socket->get('http://user:pass@somesite.com/somedir/some.file?query=string&this=that');
|
||||
*
|
||||
* @author Phi1 'l0rdphi1' Stier <l0rdphi1@liquenox.net>
|
||||
* @package HTTPSocket
|
||||
* @version 2.7.2
|
||||
* 2.7.2
|
||||
* added x-use-https header check
|
||||
* added max number of location redirects
|
||||
* added custom settable message if x-use-https is found, so users can be told where to set their scripts
|
||||
* if a redirect host is https, add ssl:// to remote_host
|
||||
* 2.7.1
|
||||
* added isset to headers['location'], line 306
|
||||
*/
|
||||
class HTTPSocket
|
||||
{
|
||||
public $version = '2.7.2';
|
||||
|
||||
/* all vars are private except $error, $query_cache, and $doFollowLocationHeader */
|
||||
|
||||
public $method = 'GET';
|
||||
|
||||
public $remote_host;
|
||||
public $remote_port;
|
||||
public $remote_uname;
|
||||
public $remote_passwd;
|
||||
|
||||
public $result;
|
||||
public $result_header;
|
||||
public $result_body;
|
||||
public $result_status_code;
|
||||
|
||||
public $lastTransferSpeed;
|
||||
|
||||
public $bind_host;
|
||||
|
||||
public $error = array();
|
||||
public $warn = array();
|
||||
public $query_cache = array();
|
||||
|
||||
public $doFollowLocationHeader = true;
|
||||
public $redirectURL;
|
||||
public $max_redirects = 5;
|
||||
public $ssl_setting_message = 'DirectAdmin appears to be using SSL. Change your script to connect to ssl://';
|
||||
|
||||
public $extra_headers = array();
|
||||
|
||||
/**
|
||||
* Create server "connection".
|
||||
*
|
||||
*/
|
||||
public function connect($host, $port = '')
|
||||
{
|
||||
if (!is_numeric($port)) {
|
||||
$port = 80;
|
||||
}
|
||||
|
||||
$this->remote_host = $host;
|
||||
$this->remote_port = $port;
|
||||
}
|
||||
|
||||
public function bind($ip = '')
|
||||
{
|
||||
if ($ip == '') {
|
||||
$ip = $_SERVER['SERVER_ADDR'];
|
||||
}
|
||||
|
||||
$this->bind_host = $ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the method being used to communicate.
|
||||
*
|
||||
* @param string|null request method. supports GET, POST, and HEAD. default is GET
|
||||
*/
|
||||
public function set_method($method = 'GET')
|
||||
{
|
||||
$this->method = strtoupper($method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a username and password.
|
||||
*
|
||||
* @param string|null username. defualt is null
|
||||
* @param string|null password. defualt is null
|
||||
*/
|
||||
public function set_login($uname = '', $passwd = '')
|
||||
{
|
||||
if ($uname !== '') {
|
||||
$this->remote_uname = $uname;
|
||||
}
|
||||
|
||||
if ($passwd !== '') {
|
||||
$this->remote_passwd = $passwd;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the server
|
||||
*
|
||||
* @param string containing properly formatted server API. See DA API docs and examples. Http:// URLs O.K. too.
|
||||
* @param string|array query to pass to url
|
||||
* @param int if connection KB/s drops below value here, will drop connection
|
||||
*/
|
||||
public function query($request, $content = '', $doSpeedCheck = 0)
|
||||
{
|
||||
$this->error = $this->warn = array();
|
||||
$this->result_status_code = null;
|
||||
|
||||
// is our request a http:// ... ?
|
||||
if (preg_match('!^http://!i', $request) || preg_match('!^https://!i', $request)) {
|
||||
$location = parse_url($request);
|
||||
if (preg_match('!^https://!i', $request)) {
|
||||
$this->connect('ssl://' . $location['host'], $location['port']);
|
||||
} else {
|
||||
$this->connect($location['host'], $location['port']);
|
||||
}
|
||||
$this->set_login($location['user'], $location['pass']);
|
||||
|
||||
$request = $location['path'];
|
||||
$content = $location['query'];
|
||||
|
||||
|
||||
if ($request == '') {
|
||||
$request = '/';
|
||||
}
|
||||
}
|
||||
|
||||
$array_headers = array(
|
||||
'User-Agent' => "HTTPSocket/$this->version",
|
||||
'Host' => $this->remote_port == 80 ? $this->remote_host : "$this->remote_host:$this->remote_port",
|
||||
'Accept' => '*/*',
|
||||
'Connection' => 'Close');
|
||||
|
||||
foreach ($this->extra_headers as $key => $value) {
|
||||
$array_headers[$key] = $value;
|
||||
}
|
||||
|
||||
$this->result = $this->result_header = $this->result_body = '';
|
||||
|
||||
// was content sent as an array? if so, turn it into a string
|
||||
if (is_array($content)) {
|
||||
$pairs = array();
|
||||
|
||||
foreach ($content as $key => $value) {
|
||||
$pairs[] = "$key=" . urlencode($value);
|
||||
}
|
||||
|
||||
$content = implode('&', $pairs);
|
||||
unset($pairs);
|
||||
}
|
||||
|
||||
$OK = true;
|
||||
|
||||
// instance connection
|
||||
if ($this->bind_host) {
|
||||
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
||||
socket_bind($socket, $this->bind_host);
|
||||
|
||||
if (!@socket_connect($socket, $this->remote_host, $this->remote_port)) {
|
||||
$OK = false;
|
||||
}
|
||||
} else {
|
||||
$socket = @fsockopen($this->remote_host, $this->remote_port, $sock_errno, $sock_errstr, 10);
|
||||
}
|
||||
|
||||
if (!$socket || !$OK) {
|
||||
$this->error[] = "Can't create socket connection to $this->remote_host:$this->remote_port.";
|
||||
return 0;
|
||||
}
|
||||
|
||||
// if we have a username and password, add the header
|
||||
if (isset($this->remote_uname, $this->remote_passwd)) {
|
||||
$array_headers['Authorization'] = 'Basic ' . base64_encode("$this->remote_uname:$this->remote_passwd");
|
||||
}
|
||||
|
||||
// for DA skins: if $this->remote_passwd is NULL, try to use the login key system
|
||||
if (isset($this->remote_uname) && $this->remote_passwd == null) {
|
||||
$array_headers['Cookie'] = "session={$_SERVER['SESSION_ID']}; key={$_SERVER['SESSION_KEY']}";
|
||||
}
|
||||
|
||||
// if method is POST, add content length & type headers
|
||||
if ($this->method == 'POST') {
|
||||
$array_headers['Content-type'] = 'application/x-www-form-urlencoded';
|
||||
$array_headers['Content-length'] = strlen($content);
|
||||
} // else method is GET or HEAD. we don't support anything else right now.
|
||||
elseif ($content) {
|
||||
$request .= "?$content";
|
||||
}
|
||||
|
||||
// prepare query
|
||||
$query = "$this->method $request HTTP/1.0\r\n";
|
||||
foreach ($array_headers as $key => $value) {
|
||||
$query .= "$key: $value\r\n";
|
||||
}
|
||||
$query .= "\r\n";
|
||||
|
||||
// if POST we need to append our content
|
||||
if ($this->method == 'POST' && $content) {
|
||||
$query .= "$content\r\n\r\n";
|
||||
}
|
||||
|
||||
// query connection
|
||||
if ($this->bind_host) {
|
||||
socket_write($socket, $query);
|
||||
|
||||
// now load results
|
||||
while ($out = socket_read($socket, 2048)) {
|
||||
$this->result .= $out;
|
||||
}
|
||||
} else {
|
||||
fwrite($socket, $query, strlen($query));
|
||||
|
||||
// now load results
|
||||
$this->lastTransferSpeed = 0;
|
||||
$status = stream_get_meta_data($socket);
|
||||
$startTime = time();
|
||||
$length = 0;
|
||||
$prevSecond = 0;
|
||||
while (!feof($socket) && !$status['timed_out']) {
|
||||
$chunk = fgets($socket, 1024);
|
||||
$length += strlen($chunk);
|
||||
$this->result .= $chunk;
|
||||
|
||||
$elapsedTime = time() - $startTime;
|
||||
|
||||
if ($elapsedTime > 0) {
|
||||
$this->lastTransferSpeed = ($length / 1024) / $elapsedTime;
|
||||
}
|
||||
|
||||
if ($doSpeedCheck > 0 && $elapsedTime > 5 && $this->lastTransferSpeed < $doSpeedCheck) {
|
||||
$this->warn[] = 'kB/s for last 5 seconds is below 50 kB/s (~' . (($length / 1024) / $elapsedTime) . '), dropping connection...';
|
||||
$this->result_status_code = 503;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->lastTransferSpeed == 0) {
|
||||
$this->lastTransferSpeed = $length / 1024;
|
||||
}
|
||||
}
|
||||
|
||||
[$this->result_header, $this->result_body] = preg_split("/\r\n\r\n/", $this->result, 2);
|
||||
|
||||
if ($this->bind_host) {
|
||||
socket_close($socket);
|
||||
} else {
|
||||
fclose($socket);
|
||||
}
|
||||
|
||||
$this->query_cache[] = $query;
|
||||
|
||||
|
||||
$headers = $this->fetch_header();
|
||||
|
||||
// what return status did we get?
|
||||
if (!$this->result_status_code) {
|
||||
preg_match("#HTTP/1\.. (\d+)#", $headers[0], $matches);
|
||||
$this->result_status_code = $matches[1];
|
||||
}
|
||||
|
||||
// did we get the full file?
|
||||
if (!empty($headers['content-length']) && $headers['content-length'] != strlen($this->result_body)) {
|
||||
$this->result_status_code = 206;
|
||||
}
|
||||
|
||||
// now, if we're being passed a location header, should we follow it?
|
||||
if ($this->doFollowLocationHeader) {
|
||||
//dont bother if we didn't even setup the script correctly
|
||||
if (isset($headers['x-use-https']) && $headers['x-use-https'] == 'yes') {
|
||||
die($this->ssl_setting_message);
|
||||
}
|
||||
|
||||
if (isset($headers['location'])) {
|
||||
if ($this->max_redirects <= 0) {
|
||||
die('Too many redirects on: ' . $headers['location']);
|
||||
}
|
||||
|
||||
$this->max_redirects--;
|
||||
$this->redirectURL = $headers['location'];
|
||||
$this->query($headers['location']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getTransferSpeed()
|
||||
{
|
||||
return $this->lastTransferSpeed;
|
||||
}
|
||||
|
||||
/**
|
||||
* The quick way to get a URL's content :)
|
||||
*
|
||||
* @param string URL
|
||||
* @param boolean return as array? (like PHP's file() command)
|
||||
* @return string result body
|
||||
*/
|
||||
public function get($location, $asArray = false)
|
||||
{
|
||||
$this->query($location);
|
||||
|
||||
if ($this->get_status_code() == 200) {
|
||||
if ($asArray) {
|
||||
return explode("\n", $this->fetch_body());
|
||||
}
|
||||
|
||||
return $this->fetch_body();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last status code.
|
||||
* 200 = OK;
|
||||
* 403 = FORBIDDEN;
|
||||
* etc.
|
||||
*
|
||||
* @return int status code
|
||||
*/
|
||||
public function get_status_code()
|
||||
{
|
||||
return $this->result_status_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a header, sent with the next query.
|
||||
*
|
||||
* @param string header name
|
||||
* @param string header value
|
||||
*/
|
||||
public function add_header($key, $value)
|
||||
{
|
||||
$this->extra_headers[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears any extra headers.
|
||||
*
|
||||
*/
|
||||
public function clear_headers()
|
||||
{
|
||||
$this->extra_headers = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the result of a query.
|
||||
*
|
||||
* @return string result
|
||||
*/
|
||||
public function fetch_result()
|
||||
{
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the header of result (stuff before body).
|
||||
*
|
||||
* @param string (optional) header to return
|
||||
* @return array result header
|
||||
*/
|
||||
public function fetch_header($header = '')
|
||||
{
|
||||
$array_headers = preg_split("/\r\n/", $this->result_header);
|
||||
|
||||
$array_return = array(0 => $array_headers[0]);
|
||||
unset($array_headers[0]);
|
||||
|
||||
foreach ($array_headers as $pair) {
|
||||
[$key, $value] = explode(': ', $pair, 2);
|
||||
$array_return[strtolower($key)] = $value;
|
||||
}
|
||||
|
||||
if ($header != '') {
|
||||
return $array_return[strtolower($header)];
|
||||
}
|
||||
|
||||
return $array_return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the body of result (stuff after header).
|
||||
*
|
||||
* @return string result body
|
||||
*/
|
||||
public function fetch_body()
|
||||
{
|
||||
return $this->result_body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return parsed body in array format.
|
||||
*
|
||||
* @return array result parsed
|
||||
*/
|
||||
public function fetch_parsed_body()
|
||||
{
|
||||
parse_str($this->result_body, $x);
|
||||
return $x;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a specifc message on how to change the SSL setting, in the event that it's not set correctly.
|
||||
*/
|
||||
public function set_ssl_setting_message($str)
|
||||
{
|
||||
$this->ssl_setting_message = $str;
|
||||
}
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Utils;
|
||||
|
||||
|
||||
class Helper
|
||||
{
|
||||
public static function getParam($request, $queryString): ?string
|
||||
{
|
||||
return $request->getQueryParams()[$queryString] ?? null;
|
||||
}
|
||||
|
||||
public static function getData($request, $name)
|
||||
{
|
||||
return $request->getParsedBody()[$name];
|
||||
}
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utils;
|
||||
|
||||
class Pay
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
@ -1,88 +1,27 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Utils;
|
||||
|
||||
use App\Services\Config;
|
||||
use Zxing\QrReader;
|
||||
use ZBarCodeImage;
|
||||
use ZBarCodeScanner;
|
||||
|
||||
class QRcode
|
||||
{
|
||||
public static function decode($url)
|
||||
/**
|
||||
* Decode QR code
|
||||
*
|
||||
* @param string $source QR code source url/path
|
||||
*
|
||||
* @return string|null Decoded string, null for empty
|
||||
*/
|
||||
public static function decode(string $source)
|
||||
{
|
||||
switch (Config::get('qrcode')) {
|
||||
case 'phpzbar':
|
||||
return self::phpzbar_decode($url);
|
||||
case 'online':
|
||||
return self::online_decode($url);
|
||||
case 'zxing_local':
|
||||
return self::zxing_local_decode($url);
|
||||
default:
|
||||
return self::zxing_decode($url);
|
||||
}
|
||||
}
|
||||
|
||||
public static function online_decode($url)
|
||||
{
|
||||
$data = array();
|
||||
$data['fileurl'] = $url;
|
||||
$param = http_build_query($data, '', '&');
|
||||
|
||||
$sock = new HTTPSocket();
|
||||
$sock->connect('api.qrserver.com', 80);
|
||||
$sock->set_method('GET');
|
||||
$sock->query('/v1/read-qr-code/', $param);
|
||||
|
||||
$raw_text = $sock->fetch_body();
|
||||
$result_array = json_decode($raw_text, true);
|
||||
if (isset($result_array[0])) {
|
||||
return $result_array[0]['symbol'][0]['data'];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function phpzbar_decode($url)
|
||||
{
|
||||
$filepath = BASE_PATH . '/storage/' . time() . random_int(1, 100) . '.png';
|
||||
$img = file_get_contents($url);
|
||||
file_put_contents($filepath, $img);
|
||||
|
||||
/* Create new image object */
|
||||
$image = new ZBarCodeImage($filepath);
|
||||
|
||||
/* Create a barcode scanner */
|
||||
$scanner = new ZBarCodeScanner();
|
||||
|
||||
/* Scan the image */
|
||||
$barcode = $scanner->scan($image);
|
||||
|
||||
unlink($filepath);
|
||||
|
||||
return ($barcode[0]['data'] ?? null);
|
||||
}
|
||||
|
||||
public static function zxing_local_decode($url)
|
||||
{
|
||||
$filepath = BASE_PATH . '/storage/' . time() . random_int(1, 100) . '.png';
|
||||
$img = file_get_contents($url);
|
||||
file_put_contents($filepath, $img);
|
||||
|
||||
$qrcode = new QrReader($filepath);
|
||||
$text = $qrcode->text(); //return decoded text from QR Code
|
||||
|
||||
unlink($filepath);
|
||||
|
||||
if ($text == null || $text == '') {
|
||||
$img = file_get_contents($source);
|
||||
$qrcode = new QrReader($img, QrReader::SOURCE_TYPE_BLOB);
|
||||
$text = $qrcode->text();
|
||||
if ($text == false || $text == '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
public static function zxing_decode($url)
|
||||
{
|
||||
$raw_text = file_get_contents('https://zxing.org/w/decode?u=' . urlencode($url));
|
||||
return Tools::get_middle_text($raw_text, '<tr><td>Raw text</td><td><pre>', '</pre></td></tr><tr><td>Raw bytes</td><td><pre>');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utils;
|
||||
|
||||
class Response
|
||||
{
|
||||
public static function redirect($response, $to)
|
||||
{
|
||||
return $response->withStatus(302)->withHeader('Location', $to);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utils\Telegram\Callbacks;
|
||||
|
||||
use App\Utils\Telegram\TelegramTools;
|
||||
|
||||
class Callback
|
||||
{
|
||||
public static function CallbackQueryMethod($bot, $Callback)
|
||||
{
|
||||
// 触发用户
|
||||
$SendUser = [
|
||||
'id' => $Callback->getFrom()->getId(),
|
||||
'name' => $Callback->getFrom()->getFirstName() . ' ' . $Callback->getFrom()->getLastName(),
|
||||
'username' => $Callback->getFrom()->getUsername(),
|
||||
];
|
||||
|
||||
// 触发源消息发送时间
|
||||
$MessageSendTime = $Callback->getMessage()->getDate();
|
||||
|
||||
// 消息是否可编辑
|
||||
$AllowEditMessage = (time() < $MessageSendTime + 172800
|
||||
? true
|
||||
: false);
|
||||
|
||||
$Data = [
|
||||
'CallbackData' => $Callback->getData(), // 回调数据
|
||||
'ChatID' => $Callback->getMessage()->getChat()->getId(), // 消息会话 ID
|
||||
'MessageID' => $Callback->getMessage()->getMessageId(), // 触发源信息 ID
|
||||
'AllowEditMessage' => $AllowEditMessage, // 消息是否可编辑
|
||||
];
|
||||
|
||||
if ($Data['ChatID'] < 0 && $_ENV['telegram_group_quiet'] === true) {
|
||||
// 群组中不回应
|
||||
return;
|
||||
}
|
||||
|
||||
switch (true) {
|
||||
case (strpos($Data['CallbackData'], 'user.') === 0):
|
||||
// 用户相关
|
||||
UserCallback::handler($bot, $Callback, $Data, $SendUser);
|
||||
break;
|
||||
// case (strpos($Data['CallbackData'], 'admin.') === 0):
|
||||
// // 管理员
|
||||
// break;
|
||||
default:
|
||||
// 回调数据处理
|
||||
self::CallbackDataHandler($bot, $Callback, $Data, $SendUser);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getGuestIndexKeyboard()
|
||||
{
|
||||
$Keyboard = [
|
||||
[
|
||||
[
|
||||
'text' => '产品介绍',
|
||||
'callback_data' => 'general.pricing'
|
||||
],
|
||||
[
|
||||
'text' => '服务条款',
|
||||
'callback_data' => 'general.terms'
|
||||
]
|
||||
]
|
||||
];
|
||||
$text = '游客您好,以下是 BOT 菜单:' . PHP_EOL . PHP_EOL . '本站用户请前往用户中心进行 Telegram 绑定操作.';
|
||||
return [
|
||||
'text' => $text,
|
||||
'keyboard' => $Keyboard,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 回调数据处理
|
||||
*
|
||||
*/
|
||||
public static function CallbackDataHandler($bot, $Callback, $Data, $SendUser)
|
||||
{
|
||||
$CallbackDataExplode = explode('|', $Data['CallbackData']);
|
||||
switch ($CallbackDataExplode[0]) {
|
||||
case 'general.pricing':
|
||||
// 产品介绍
|
||||
$sendMessage = [
|
||||
'text' => $_ENV['telegram_general_pricing'],
|
||||
'disable_web_page_preview' => false,
|
||||
'reply_to_message_id' => null,
|
||||
'reply_markup' => json_encode(
|
||||
[
|
||||
'inline_keyboard' => self::getGuestIndexKeyboard()['keyboard']
|
||||
]
|
||||
),
|
||||
];
|
||||
break;
|
||||
case 'general.terms':
|
||||
// 服务条款
|
||||
$sendMessage = [
|
||||
'text' => $_ENV['telegram_general_terms'],
|
||||
'disable_web_page_preview' => false,
|
||||
'reply_to_message_id' => null,
|
||||
'reply_markup' => json_encode(
|
||||
[
|
||||
'inline_keyboard' => self::getGuestIndexKeyboard()['keyboard']
|
||||
]
|
||||
),
|
||||
];
|
||||
break;
|
||||
default:
|
||||
// 主菜单
|
||||
$temp = self::getGuestIndexKeyboard();
|
||||
$sendMessage = [
|
||||
'text' => $temp['text'],
|
||||
'disable_web_page_preview' => false,
|
||||
'reply_to_message_id' => null,
|
||||
'reply_markup' => json_encode(
|
||||
[
|
||||
'inline_keyboard' => $temp['keyboard']
|
||||
]
|
||||
),
|
||||
];
|
||||
break;
|
||||
}
|
||||
$sendMessage = array_merge(
|
||||
$sendMessage,
|
||||
[
|
||||
'chat_id' => $Data['ChatID'],
|
||||
'message_id' => $Data['MessageID'],
|
||||
'parse_mode' => 'HTML',
|
||||
]
|
||||
);
|
||||
return ($Data['AllowEditMessage']
|
||||
? TelegramTools::SendPost('editMessageText', $sendMessage)
|
||||
: $bot->sendMessage($sendMessage));
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utils\Telegram\Commands;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Utils\Telegram\TelegramTools;
|
||||
use Telegram\Bot\Actions;
|
||||
use Telegram\Bot\Commands\Command;
|
||||
|
||||
/**
|
||||
* Class CheckinCommand.
|
||||
*/
|
||||
class CheckinCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var string Command Name
|
||||
*/
|
||||
protected $name = 'checkin';
|
||||
|
||||
/**
|
||||
* @var string Command Description
|
||||
*/
|
||||
protected $description = '[群组/私聊] 每日签到.';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function handle($arguments)
|
||||
{
|
||||
$Update = $this->getUpdate();
|
||||
$Message = $Update->getMessage();
|
||||
|
||||
// 消息会话 ID
|
||||
$ChatID = $Message->getChat()->getId();
|
||||
|
||||
if ($ChatID < 0) {
|
||||
// 群组
|
||||
if ($_ENV['enable_delete_user_cmd'] === true) {
|
||||
TelegramTools::DeleteMessage([
|
||||
'chatid' => $ChatID,
|
||||
'messageid' => $Message->getMessageId(),
|
||||
]);
|
||||
}
|
||||
if ($_ENV['telegram_group_quiet'] === true) {
|
||||
// 群组中不回应
|
||||
return;
|
||||
}
|
||||
if ($ChatID != $_ENV['telegram_chatid']) {
|
||||
// 非我方群组
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 发送 '输入中' 会话状态
|
||||
$this->replyWithChatAction(['action' => Actions::TYPING]);
|
||||
|
||||
// 触发用户
|
||||
$SendUser = [
|
||||
'id' => $Message->getFrom()->getId(),
|
||||
'name' => $Message->getFrom()->getFirstName() . ' ' . $Message->getFrom()->getLastName(),
|
||||
'username' => $Message->getFrom()->getUsername(),
|
||||
];
|
||||
|
||||
$User = User::where('telegram_id', $SendUser['id'])->first();
|
||||
if ($User == null) {
|
||||
// 回送信息
|
||||
$response = $this->replyWithMessage(
|
||||
[
|
||||
'text' => $_ENV['user_not_bind_reply'],
|
||||
'parse_mode' => 'Markdown',
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$checkin = $User->checkin();
|
||||
// 回送信息
|
||||
$response = $this->replyWithMessage(
|
||||
[
|
||||
'text' => $checkin['msg'],
|
||||
'reply_to_message_id' => $Message->getMessageId(),
|
||||
'parse_mode' => 'Markdown',
|
||||
]
|
||||
);
|
||||
}
|
||||
if ($ChatID < 0) {
|
||||
// 消息删除任务
|
||||
TelegramTools::DeleteMessage([
|
||||
'chatid' => $ChatID,
|
||||
'messageid' => $response->getMessageId(),
|
||||
]);
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue