Compare commits
1003 Commits
Author | SHA1 | Date | |
---|---|---|---|
ae3db05649 | |||
fa45d5f4b5 | |||
895bb26b02 | |||
a5affdb674 | |||
238fc03d03 | |||
cf8e23ae88 | |||
b9132082e5 | |||
ee63abb618 | |||
060718dfda | |||
651969924c | |||
a40b2cbea3 | |||
fc73a83732 | |||
6763fe09d8 | |||
0ea9de70fc | |||
c7ec8e2d27 | |||
822acef6d8 | |||
892c6bf7f5 | |||
c0c857e735 | |||
49794b99de | |||
126212f4c2 | |||
e3de07d435 | |||
2f551b1755 | |||
f766393e52 | |||
0bd587522a | |||
47c6e90624 | |||
fc0ef5b41a | |||
dff3970ff4 | |||
4c4fe4e99f | |||
2ed3dc991a | |||
be43a5b385 | |||
61bd042b15 | |||
b6fde35eb6 | |||
980af58eb1 | |||
f7deb828ac | |||
4c1e5da601 | |||
9712d411f5 | |||
8dc7707b3a | |||
18bdf185d6 | |||
2a70236576 | |||
7b40fc850e | |||
ad411e2223 | |||
45a6085205 | |||
91fe5a4b46 | |||
c0cd197df2 | |||
3e89efcf46 | |||
31b710e03c | |||
4d6041f614 | |||
fbaf9dbe3f | |||
a4f5c1d422 | |||
d08137e0c3 | |||
961f4770c0 | |||
2d6fe9526c | |||
bebc20e39f | |||
964c141668 | |||
88bbf3ed35 | |||
bf00b21786 | |||
0e81db5ada | |||
c0382c569a | |||
c32542afda | |||
8d17cd3f90 | |||
6dafd549d9 | |||
20c4be9121 | |||
2f757f1006 | |||
0ce112dc70 | |||
ea3f5caf59 | |||
5a5032bbcc | |||
0d44fec338 | |||
7396c2f1d4 | |||
73cf67b4cb | |||
9e0f74926c | |||
09af3474a9 | |||
9b8f1fedf8 | |||
05c77df315 | |||
e88f662d8c | |||
2956cc2315 | |||
3c8b2c906d | |||
acded8eb29 | |||
b63aeb5298 | |||
115a5c81a7 | |||
ad565c15ca | |||
a0c5cec31e | |||
fb4901be9f | |||
a164b345b6 | |||
8f07c7640c | |||
8891cd5aaa | |||
854fd54834 | |||
21876601ba | |||
6955d3fd8b | |||
d6510dffa7 | |||
419595554b | |||
bcc84aed9a | |||
05caee1193 | |||
071feb3a48 | |||
a5774fe335 | |||
92a2690ec6 | |||
519bef21e0 | |||
1a40606720 | |||
eff79df39a | |||
425ed2362b | |||
1fdf1d9573 | |||
b893827463 | |||
aa756fceb1 | |||
186dd5571f | |||
14067f2917 | |||
887a0185fa | |||
88969526be | |||
eb18eebc8c | |||
e274ca82b0 | |||
9ec8b54435 | |||
9dba708c2c | |||
cbbb77b636 | |||
1733472ad1 | |||
11c111805d | |||
4c35e79a16 | |||
fc1cc54378 | |||
f62e7707a1 | |||
bab56be9c7 | |||
0422c1e9bb | |||
1f5033b471 | |||
53a309fee8 | |||
766ba59734 | |||
2e3e5d2b84 | |||
e285e53887 | |||
afd75d757e | |||
006693982b | |||
71437b9a0e | |||
eba6048abf | |||
f97651695d | |||
72c3ff6750 | |||
787f666efe | |||
5db8df0c3e | |||
f77c96f3c3 | |||
ffd9f2e524 | |||
366208d6d1 | |||
db28570610 | |||
feaf88fc00 | |||
4bd5e399de | |||
76047a6b39 | |||
68c9ab0b2e | |||
198dfee3cc | |||
5161874cf2 | |||
254fd4ccf7 | |||
ee73621c85 | |||
4bf6f9c0ac | |||
3a2e7c9192 | |||
dcbb9434d6 | |||
faca5d0359 | |||
aeddc86796 | |||
c34a34ee8e | |||
7b0bc12e98 | |||
8ff84b2c01 | |||
954a49978c | |||
773cfe0139 | |||
7eae86d861 | |||
ea9974f668 | |||
eda1750608 | |||
9a1c264173 | |||
6865b388d0 | |||
ef15ec0ae2 | |||
e0d21e6284 | |||
37a7da614e | |||
e11ab5ba01 | |||
0767c6ab23 | |||
8e90cf933b | |||
a5ffee688c | |||
36a24238ef | |||
7eda29d02c | |||
e709ea4353 | |||
18967b59e2 | |||
3c2ca66b48 | |||
63c364a6c5 | |||
338861a630 | |||
90f72852ca | |||
5426d9f35f | |||
58c4037d8c | |||
04a21d3eb2 | |||
273d98f3ad | |||
177cdef1cd | |||
ffe913cb8f | |||
75955de6c5 | |||
11d97c153f | |||
44cded581a | |||
b8ae562367 | |||
d6bcb4edfc | |||
5d16ff9484 | |||
c1f815535d | |||
37a8187f5a | |||
ec5aeedd1b | |||
7dd27e3080 | |||
93ca9fa586 | |||
de302d2656 | |||
4d8cec1a88 | |||
477dd11caa | |||
36eb5ebd3b | |||
6e2e907d85 | |||
c460cdd2d6 | |||
5b7683ae30 | |||
ea743b6db6 | |||
1a165662ca | |||
21058d5c4e | |||
af3995b421 | |||
e9240f462d | |||
5b3be79420 | |||
8f595af9a1 | |||
393a1195a5 | |||
0dd12b717d | |||
d7d6709944 | |||
ef187817cf | |||
24e45db017 | |||
0a67ea25b5 | |||
f27964dde6 | |||
5b0e782efd | |||
865df09116 | |||
f44d800400 | |||
aae5b58d57 | |||
19d60da919 | |||
7be8552784 | |||
b92efe3d30 | |||
f769e7b798 | |||
15ae5c844f | |||
0aff5f437a | |||
605fbb73a6 | |||
3d2af75e5b | |||
130451e1ae | |||
d36f39af8f | |||
518917aac6 | |||
dbc3a2623c | |||
d31edde9d6 | |||
32943b40be | |||
23790d3258 | |||
ffa55cdee5 | |||
6f5d49cd2f | |||
850581d328 | |||
1d0d3f13ab | |||
c82b6b6acf | |||
532fbf7337 | |||
c4afd6da7f | |||
a812e3a3e0 | |||
a15510e62a | |||
78d1634470 | |||
cc8d810d45 | |||
68d3c9181c | |||
e206a583fd | |||
ca27c47b75 | |||
2c67108cf1 | |||
dee4c78e93 | |||
a6c004e1cb | |||
8318bb4e6b | |||
b27e0adca9 | |||
2925d3a1e3 | |||
add28c2fca | |||
afbab3dd42 | |||
b68e4d2e68 | |||
c8f4574984 | |||
60c573821b | |||
e6e993cf21 | |||
ca0edb4e17 | |||
ed9a411095 | |||
c69fb1cae2 | |||
d30aadc5e4 | |||
b732cfd90e | |||
46a56c12e3 | |||
9b2d42610a | |||
ef85bdb02f | |||
23763ed308 | |||
9fcdf04005 | |||
60babfa7b5 | |||
4cdde32cb1 | |||
538850b323 | |||
47393b4da9 | |||
87167b7770 | |||
81572a61a4 | |||
3412ecc7de | |||
3ab38897f9 | |||
8c2471d1d2 | |||
b0937a424a | |||
171b938d3a | |||
61c1d25096 | |||
f885b8e8a3 | |||
2bb664e241 | |||
c9058769ce | |||
6d15437333 | |||
7c5958c8c1 | |||
1a4a0f2c10 | |||
629d9e8ed4 | |||
b9e987570c | |||
b95788262d | |||
3bb55320e3 | |||
7a9f937a9e | |||
c00e51adda | |||
0cc526e29a | |||
16f0642007 | |||
e1f7b324cb | |||
8f0ff3e786 | |||
9023f89456 | |||
140b756994 | |||
ca59c89e1d | |||
4e23918999 | |||
758a0a99a9 | |||
b6cf9bec0b | |||
6e07c3ae85 | |||
ef76aadc16 | |||
8e960107fc | |||
c4e702ee2f | |||
08790e7295 | |||
cfefd38a31 | |||
37a5ee8566 | |||
e5c8aae758 | |||
99d393d0c0 | |||
e6280d597b | |||
18db9cd280 | |||
6aab647f48 | |||
b8b4623078 | |||
6a79cff233 | |||
4c02283fd0 | |||
403de91fba | |||
4ee3743cf3 | |||
77e48dae8b | |||
0745532951 | |||
b53116d22a | |||
f7df824145 | |||
f154322f99 | |||
a76ba6ee8b | |||
61b3f5b5f5 | |||
b153e5b595 | |||
9ab0b6a0fa | |||
a7f191f058 | |||
012a1ecfab | |||
dc70a49f52 | |||
bc7380eab7 | |||
f4da09a26e | |||
de3312055a | |||
699289662b | |||
bae079f71c | |||
28f4624e8d | |||
fbd215e741 | |||
2437096473 | |||
dfeee540cf | |||
a0b9e85f38 | |||
08153e6ec1 | |||
2660f5d2d0 | |||
82e67f0b83 | |||
41dd0d86e7 | |||
c8004f1a27 | |||
61edfb932a | |||
747a67b691 | |||
b938db9e5d | |||
1ec8049068 | |||
848dcb5caf | |||
afe6b34fd6 | |||
fceb79bdc3 | |||
83457fd9fc | |||
cdd5da757d | |||
c6086c615f | |||
0cad73a17f | |||
d2fa9be8d1 | |||
617e628b04 | |||
35d679ed2c | |||
8824489704 | |||
a7502aa8fb | |||
375403135e | |||
db49d0f4b5 | |||
c4fb99479b | |||
091f4fb638 | |||
8db3d6c679 | |||
ddd7fb49fe | |||
c6a203b1f0 | |||
6de63bed63 | |||
9552a14de5 | |||
9d379b3fbd | |||
4f3e5972b0 | |||
be65976310 | |||
8728af4332 | |||
07870d05ad | |||
cee6f8949c | |||
3bdf44ddbe | |||
17c1675b4a | |||
54d1c4439d | |||
e710bd2862 | |||
5309cb26db | |||
8072fe40eb | |||
702f2b443c | |||
a44190c1c2 | |||
3871b51f0f | |||
d9a20f7213 | |||
a70b954981 | |||
95e79439a2 | |||
7ea118ec1e | |||
ae83cbeef4 | |||
8047ed9555 | |||
c907a4044f | |||
f12c7724fd | |||
c8696f8d1a | |||
63bba0efb0 | |||
2063ae4159 | |||
349a1d3250 | |||
cfb81596ae | |||
91c90f05f8 | |||
abefcf4a73 | |||
f9ad13b746 | |||
fe082258cd | |||
ade714e2ae | |||
ce649220f5 | |||
de4a783dba | |||
f550af257a | |||
2c16bb289e | |||
61060c4173 | |||
e7c715f1b3 | |||
aa8fa3f436 | |||
941c723193 | |||
cb23ddb912 | |||
e1272ec531 | |||
8e3e715c8c | |||
850ae079f4 | |||
21bea606c3 | |||
11c226caf5 | |||
98fb853591 | |||
d17c434c7b | |||
a06d7db0b1 | |||
84138bd02e | |||
9d1f05735f | |||
c91cc0470b | |||
459b9b30f1 | |||
8baf977a9a | |||
1022674780 | |||
3c9b05468e | |||
e9f5d56f91 | |||
792b1367d3 | |||
bf6ec9d4cd | |||
9543ee6e34 | |||
66432eda56 | |||
92eee8245d | |||
f62f07d102 | |||
671154d146 | |||
ac84e4b235 | |||
db7c6014dc | |||
21b57ef471 | |||
79e5c72ca2 | |||
5921fef67e | |||
1e0b246d74 | |||
009c890ab6 | |||
f3d7687cdb | |||
80cecabfb0 | |||
00ac91903f | |||
500f3de6a9 | |||
6c2658bf03 | |||
59de353353 | |||
d5ea56d078 | |||
7cc8034b8c | |||
c3a76bab90 | |||
8f32a7cfa9 | |||
cbe2602b69 | |||
771bc9d8d9 | |||
788e558171 | |||
4ab32bc68d | |||
bba09ca647 | |||
adbac642ca | |||
7e7b70ba75 | |||
72fbc27f97 | |||
d386dc5eec | |||
41481880ab | |||
f8a879dc0f | |||
da44e3f6da | |||
afdd7edafa | |||
4e1a10d814 | |||
7046aa5ed1 | |||
d81ba5d5fb | |||
a35506db1b | |||
96945ab813 | |||
2b8ca5fd85 | |||
2d095aef08 | |||
c906d47674 | |||
5dd430f9b2 | |||
7c88be8865 | |||
b45f5a5587 | |||
10e788e9a2 | |||
7ceb883826 | |||
80e78d9796 | |||
534d62d944 | |||
1857c145d1 | |||
12cdef4f66 | |||
b4bec8964d | |||
64f52d6c1c | |||
b504723e7c | |||
470c219e61 | |||
5867a0c9ca | |||
f38da8d3c0 | |||
7e0e09f9bf | |||
90e6283426 | |||
24df116003 | |||
db240131e2 | |||
2fdc3c9567 | |||
a953157b68 | |||
4ba38485a0 | |||
dfef6807a5 | |||
5ef0520c74 | |||
263a1b6722 | |||
f4c5b6a8bb | |||
05ed37d3d8 | |||
055b855bc1 | |||
b862a759d0 | |||
41cc04cffb | |||
1d29f8111e | |||
081dd1b1b9 | |||
9804bcb9e8 | |||
19e39dbefc | |||
b5c29f6c3d | |||
fe94ae3011 | |||
a25112a37f | |||
9d1d287e9a | |||
4bddaf0260 | |||
43ed5e452e | |||
12c339898c | |||
d087c9625d | |||
98223c1abe | |||
402660e3e1 | |||
f42f410867 | |||
df28e2b1c2 | |||
74b5c47640 | |||
5f5213527f | |||
5e76c3e214 | |||
e2c0fa5690 | |||
3afb7b9954 | |||
13b448da69 | |||
017518b308 | |||
4ae19849a1 | |||
d666e052f4 | |||
c1f04c17a5 | |||
9c22c22f6c | |||
518fe7563e | |||
adc2c808e2 | |||
a7a0f84df5 | |||
b7c663f4ee | |||
dd4329ad3d | |||
41b981cb70 | |||
431c971f3a | |||
653580722e | |||
6a0ad7f178 | |||
9d79121696 | |||
8e84c32616 | |||
486e22f020 | |||
21d83268f7 | |||
e886249091 | |||
d5ab0e1b44 | |||
05aca0356f | |||
cced38527b | |||
452642831c | |||
69ea0d0b7f | |||
4b596d91bd | |||
9c5e3007a2 | |||
d3893d88a4 | |||
1ed55103a3 | |||
bd8dd87384 | |||
9190660c1c | |||
d241b2cec6 | |||
80c76cd6dc | |||
a1648a4178 | |||
c8d19a859f | |||
90cfc3e6d9 | |||
88a3e2d205 | |||
0039f47947 | |||
c2f1f07cfc | |||
f61ebb642e | |||
77e7a96f96 | |||
5c57c5df11 | |||
9e09611816 | |||
09ead77d7b | |||
703f9a7463 | |||
ef25633275 | |||
02a68589a1 | |||
25cd07e975 | |||
4e7a60aa6f | |||
baca2d706f | |||
4f975fbf0d | |||
cded80a632 | |||
f0d130b6b9 | |||
a18c07ba42 | |||
36b47a3e8d | |||
37f72d881e | |||
e99108a34a | |||
ddb3b8a718 | |||
3c4920f958 | |||
e2da5b67bf | |||
49c8fe5d55 | |||
9402da311c | |||
51ab4a35c5 | |||
d037b2bef4 | |||
d95e4d1d84 | |||
7ebf95f4be | |||
8cbe32e313 | |||
0d27503e8d | |||
1ae687bda2 | |||
d59f696fde | |||
b9537d4a4b | |||
e88d1f02a6 | |||
eda7967f66 | |||
55f25a5b7f | |||
7094555f9f | |||
a5a5969642 | |||
0c0d7a963e | |||
3fb61d6a8c | |||
c69b43dbf6 | |||
1583068f57 | |||
67ec8f2f7a | |||
915108a1ae | |||
f806960ead | |||
700e861197 | |||
bc763b476e | |||
3ae81d0105 | |||
a54df9bdab | |||
6a6434b39c | |||
92f072a861 | |||
6884701de1 | |||
7e4c638b07 | |||
f9e62202c0 | |||
03d3462f49 | |||
1e80e5d929 | |||
88aca9bac5 | |||
718b47ac49 | |||
492ea5985c | |||
747e28e07c | |||
a1d9b63dcf | |||
95097e4512 | |||
7e00feb02f | |||
8df79c6454 | |||
0b7408f5b9 | |||
113d4ce6b1 | |||
48583c869b | |||
e19423471f | |||
77f21ece61 | |||
5024df9c0b | |||
b9828210ce | |||
5bbf9bf09a | |||
9479ee6cc6 | |||
68e4557172 | |||
c76aefb7e0 | |||
1a48bfa0ff | |||
fe81d0c62e | |||
071df91de0 | |||
1861358415 | |||
1891dee6b2 | |||
0bb20d4a16 | |||
b2a99def98 | |||
087c5ab515 | |||
0ee60eff3d | |||
e87623d918 | |||
6d835620f5 | |||
7a524a50e3 | |||
78cbb105aa | |||
efc0ba93b6 | |||
ce01771800 | |||
9e33a5740b | |||
6e3df253c6 | |||
3b87630986 | |||
d002ed2286 | |||
dc19583d95 | |||
690584ee90 | |||
321ac3a35a | |||
a313d45b03 | |||
0bb1563641 | |||
9842bca5cb | |||
8d83763b62 | |||
106aaf827f | |||
c51f04747d | |||
97a5c54e24 | |||
04fcd77da0 | |||
4df15819dd | |||
caad968655 | |||
1832332d99 | |||
c9eeefcf3d | |||
c5b96df43f | |||
529b9c84bd | |||
56bcbd810e | |||
c3fd8536eb | |||
b3057bd59e | |||
e64f27bc63 | |||
64a9e38cce | |||
6acc342b26 | |||
e59bf71230 | |||
b98d0b230d | |||
00cc448230 | |||
a67a470a06 | |||
58d5ca7040 | |||
e88c678f2f | |||
eca64ef81e | |||
3c711115ec | |||
d4bffaf220 | |||
f69885d358 | |||
50ab20e68e | |||
e494570807 | |||
b0cb79eeac | |||
95a8eaeadb | |||
aab2282e78 | |||
609cf4b69d | |||
84cd66ea9a | |||
3142e93d52 | |||
6102637d7b | |||
c754338599 | |||
a85ccf06fa | |||
e64527cee2 | |||
fc5aa083a1 | |||
53eb817de4 | |||
309bbc0059 | |||
5fc2190f4a | |||
f292da9d8d | |||
28fcabd1fd | |||
4bbb98fb98 | |||
ee2e67f490 | |||
e3ec8b18fa | |||
f396d7183b | |||
b5ddf37649 | |||
c57bbeace3 | |||
eeae60d88e | |||
14ed0236d0 | |||
3833afb3be | |||
593ca31f18 | |||
7cc8d6f5e3 | |||
11a2fb8fc0 | |||
537623130c | |||
910be1946b | |||
e23abc1377 | |||
b912dd05d0 | |||
5c9a0d8ea6 | |||
b7eca582a6 | |||
b460e862e8 | |||
a33705c0c4 | |||
183a5ab242 | |||
04c480cafa | |||
8be8737236 | |||
a8515b7d60 | |||
d71eb37f48 | |||
8fcca70ead | |||
59f6c180cf | |||
d53c4cf8c8 | |||
6c45ef730e | |||
620bfaeb29 | |||
863dd65145 | |||
4de849fe34 | |||
18d68d68c8 | |||
1b15da5c04 | |||
51416626fb | |||
5a10c19853 | |||
44cdd8f594 | |||
00cf90e6ea | |||
341e26f4d6 | |||
717b21e65e | |||
d0cebe7458 | |||
6dadb7040c | |||
fe1310bd57 | |||
1dd03168f0 | |||
3eefec6e21 | |||
3b4e3c7789 | |||
b4f5cf8954 | |||
51ac162642 | |||
d680548eba | |||
fd2c9b08e0 | |||
cad57760bd | |||
d51edefc10 | |||
faab21bccf | |||
19d5daf5b8 | |||
6166dd6768 | |||
a175f96039 | |||
15b9744b18 | |||
75cbe2b1ec | |||
774b9e3f94 | |||
4fd8165d89 | |||
a09dc57495 | |||
74ac7f3eb4 | |||
8e45ac40c4 | |||
51565ad173 | |||
54ff67fa49 | |||
27a2938534 | |||
cefc6c0365 | |||
136b7be164 | |||
46e0f981b0 | |||
1cb5d9236f | |||
9f30e7f0f6 | |||
60c37615ea | |||
59e1cf7798 | |||
4b96e2c311 | |||
4403a48dda | |||
ac4c98ca63 | |||
2c7d0a321e | |||
4c8f0b27a1 | |||
e23b2464b8 | |||
62cc7bf8a5 | |||
4f57da8b7d | |||
2f92cdce0b | |||
2431aa2eb5 | |||
5f632fce72 | |||
4238345622 | |||
aa72b3d8fd | |||
455ce90a45 | |||
9c35962264 | |||
7c41ebfb62 | |||
6f6fc05d16 | |||
b315e3dba1 | |||
3fe9111824 | |||
091275f380 | |||
0dd4e39c8f | |||
d682d20035 | |||
499a32015a | |||
68f9399357 | |||
db2b5edff5 | |||
8cb277f6d2 | |||
ad0f4599e7 | |||
783b541645 | |||
7e78c5db40 | |||
af0b2cda28 | |||
e27c0da2aa | |||
a5a959eade | |||
e5f18ec7e4 | |||
942552e9ac | |||
43590211a2 | |||
3b85e752af | |||
d9bda444e9 | |||
5b7e84fb75 | |||
4fcb4342ab | |||
f770126f8c | |||
1904e5e8a0 | |||
aeeb04fd67 | |||
759331105d | |||
e3b736e222 | |||
56cea36a33 | |||
3fbd5b2eb1 | |||
0d0f59a9a0 | |||
755e857979 | |||
a33b299811 | |||
abc1447ce5 | |||
11b54bdcc5 | |||
f901da2b5f | |||
5b077f7773 | |||
62c3002152 | |||
1111ea986e | |||
25a6491932 | |||
72146a3afa | |||
5059c4dd3b | |||
e0eed484e9 | |||
1f4bd28045 | |||
1515a44ae5 | |||
6aa4fe8b96 | |||
18834a7276 | |||
4e86f4cb02 | |||
39d3c683bc | |||
5e474e4bf7 | |||
dea73fb2a6 | |||
7e203eaa11 | |||
d31a37cf4d | |||
05a5b784aa | |||
670223f7e2 | |||
2c75499a13 | |||
c3f1df05b8 | |||
ab01de68b7 | |||
001bc1e479 | |||
ff2ec20400 | |||
e8b428c330 | |||
877c7a29f0 | |||
3f1262236e | |||
d9dbc817c4 | |||
44084a764c | |||
406f0f594d | |||
e79abb004e | |||
7d98844690 | |||
8ec7b6f080 | |||
12e06a51e4 | |||
a9d10d330f | |||
a660ec5ddb | |||
dfbd7df367 | |||
ee840d2b75 | |||
c1c3ce08cd | |||
a256e1eb42 | |||
1b51881f9b | |||
c194b6a8a5 | |||
54ec065e98 | |||
0d30aaf8fa | |||
cf0725e6a5 | |||
52d3e49d67 | |||
cad7a4723f | |||
39b840ffd0 | |||
476c838de1 | |||
7283ca9749 | |||
80e86ef6cc | |||
9115d1c41b | |||
d9cda04f7d | |||
41352479d1 | |||
6db447d79f | |||
f35c591b80 | |||
6f20e3f97f | |||
75f10ef50a | |||
33cf1413db | |||
5f07adf0ac | |||
0c3386f0d1 | |||
a0af30c12b | |||
f6e5bac86a | |||
9f09909616 | |||
bbc830de26 | |||
b0cac9510d | |||
36d7a8a0a4 | |||
b0542ab8be | |||
2155c3adae | |||
51984401d2 | |||
fc6a5a26eb | |||
ec45d59a68 | |||
ba85ed6d0e | |||
41c3628eeb | |||
26be14bf0e | |||
1315621259 | |||
b10cfa2a8e | |||
3130310d9c | |||
6042538d8e | |||
976300bac7 | |||
d526ceb6bc | |||
d5f29a5c74 | |||
50e55744ec | |||
b69552b44a | |||
51b5dbd6f7 | |||
ada4bc8b51 | |||
f3363856f3 | |||
376a3448b6 | |||
660f186004 | |||
35667e9459 | |||
4fe47612eb | |||
d777921fbd | |||
fdbef99985 | |||
7651697ae7 | |||
1afa84e36f | |||
a2a3a7f0a6 | |||
a7e8335297 | |||
9015d519c1 | |||
98fe44d8aa | |||
79c7ad1d98 | |||
565f481a65 | |||
658aa73540 | |||
d7bdec6f29 | |||
4f300df828 | |||
e477bc90cc | |||
6033901886 | |||
0ca2dc2029 | |||
ef7d122464 | |||
89e0dd9380 | |||
d7d9d9efa1 | |||
e7e32475cc | |||
3ff2e31ccf | |||
d5c3c23794 | |||
335c5e524b | |||
ac813ca132 | |||
e6f8826490 | |||
742e0df1f2 | |||
1c63cd674c | |||
b943a73cb4 | |||
0b02b070d3 | |||
a502919165 | |||
3f92e39185 | |||
6c69dacdef | |||
1c18f6091d | |||
b6204a5f94 | |||
061224b469 | |||
0bd6c9e3c7 | |||
665e05deed | |||
3fa4282848 | |||
4906768a02 | |||
a860708a10 | |||
cef6e2a2f6 | |||
8a8c7f897f | |||
48350941e9 | |||
4067f3fa9a | |||
3653fcbf87 | |||
9ca2933b5d | |||
98b592c8a9 | |||
4d84efcf83 | |||
9154c10c45 | |||
a7fd02df12 | |||
4a6ea093c1 | |||
5ce70b972b | |||
71e8b8e22f | |||
dd46273a04 | |||
e9d67ce220 | |||
46e534af6c | |||
8d7b1c6ff0 | |||
65666ac998 | |||
99f9f73a70 | |||
6afcdfe1fa | |||
4fa341d854 | |||
464f41ef16 | |||
19f79680ff | |||
6c64d0944f | |||
40d77bba7b | |||
b7394762b3 | |||
a84095b13b | |||
8b7001b5ef | |||
41aa9f74ea | |||
deecd28cf7 | |||
9dd85dc38e | |||
e6eff99632 | |||
ba83833e94 | |||
a0dc6c7274 | |||
dd116ee248 | |||
719e7deb93 | |||
15ecd120e1 | |||
eb3c84d333 | |||
6eaede3c6e | |||
90a08cb731 | |||
5df998874a |
4
.github/FUNDING.yml
vendored
Normal file
4
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: ibnux
|
||||
custom: ['https://paypal.me/ibnux','https://trakteer.id/ibnux']
|
30
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
30
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ibnux
|
||||
|
||||
---
|
||||
|
||||
Please Remember, this project is free and open source, and @ibnux don't get any money from this project, and if you post something not a bug, just you dont understand how to install it, you will get blocked from this Repository.
|
||||
Post it in Discussion if you don't understand. Except you pay for $50 for support
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is. Error connecting to router is not a bug, is your router port is not accessable, ask community for help, go to discussion or telegram group
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
22
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
22
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
Please Remember, this project is free and open source, and @ibnux don't get any money from this project, any Feature Request will cost you $50-$5000
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
40
.gitignore
vendored
40
.gitignore
vendored
@ -1,6 +1,42 @@
|
||||
system/config.php
|
||||
config.php
|
||||
.DS_Store
|
||||
.vscode/
|
||||
ui/ui/compiled
|
||||
ui/compiled/*.php
|
||||
ui/cache/*.php
|
||||
test.php
|
||||
test.php
|
||||
sms.php
|
||||
pages/
|
||||
system/cache/**
|
||||
system/plugin/*
|
||||
!system/cache/index.html
|
||||
!system/plugin/index.html
|
||||
system/paymentgateway/ui/**
|
||||
system/paymentgateway/**
|
||||
!system/paymentgateway/ui/
|
||||
!system/paymentgateway/ui/index.html
|
||||
!system/paymentgateway/index.html
|
||||
!system/plugin/ui/
|
||||
system/plugin/ui/*
|
||||
!system/plugin/ui/index.html
|
||||
ui/ui_custom/**
|
||||
!ui/ui_custom/index.html
|
||||
!ui/ui_custom/README.md
|
||||
system/uploads/**
|
||||
!system/uploads/*.default.png
|
||||
system/uploads/sms/**
|
||||
!system/uploads/sms/index.html
|
||||
system/uploads/system/**
|
||||
!system/uploads/system/index.html
|
||||
ui/themes/**
|
||||
!ui/themes/index.html
|
||||
!ui/themes/README.md
|
||||
scanLang.php
|
||||
system/lan/**
|
||||
!system/lan/index.html
|
||||
!system/lan/indonesia.json
|
||||
!system/lan/spanish.json
|
||||
!system/lan/turkish.json
|
||||
!system/lan/english.json
|
||||
!system/lan/country.json
|
||||
*.zip
|
14
.htaccess_firewall
Normal file
14
.htaccess_firewall
Normal file
@ -0,0 +1,14 @@
|
||||
<Files *.php>
|
||||
Order Deny,Allow
|
||||
Deny from all
|
||||
</Files>
|
||||
|
||||
<Files index.php>
|
||||
Order Allow,Deny
|
||||
Allow from all
|
||||
</Files>
|
||||
|
||||
<Files update.php>
|
||||
Order Allow,Deny
|
||||
Allow from all
|
||||
</Files>
|
476
CHANGELOG.md
Normal file
476
CHANGELOG.md
Normal file
@ -0,0 +1,476 @@
|
||||

|
||||
|
||||
# CHANGELOG
|
||||
|
||||
## 2024.5.14
|
||||
|
||||
- Show Plan and Location on expired list
|
||||
- Customizeable payment for recharge
|
||||
|
||||
## 2024.5.8
|
||||
|
||||
- Fix bugs burst by @Gerandonk
|
||||
- Fix sync for burst by @Gerandonk
|
||||
|
||||
## 2024.5.7
|
||||
|
||||
- Fix time for period Days
|
||||
- Fix Free radius attributes by @agstrxyz
|
||||
- Add Numeric Voucher Code by @pro-cms
|
||||
|
||||
## 2024.4.30
|
||||
|
||||
- CRITICAL UPDATE: last update Logic recharge not check is status on or off, it make expired customer stay in expired pool
|
||||
- Prevent double submit for recharge balance
|
||||
|
||||
## 2024.4.29
|
||||
|
||||
- Maps Pagination
|
||||
- Maps Search
|
||||
- Fix extend logic
|
||||
- Fix logic customer recharge to not delete when customer not change the plan
|
||||
|
||||
## 2024.4.23
|
||||
|
||||
- Fix Pagination Voucher
|
||||
- Fix Languange Translation
|
||||
- Fix Alert Confirmation for requesting Extend
|
||||
- Send Telegram Notification when Customer request to extend expiration
|
||||
- prepaid users export list by @freeispradius
|
||||
- fix show voucher by @agstrxyz
|
||||
|
||||
## 2024.4.21
|
||||
|
||||
- Restore old cron
|
||||
|
||||
## 2024.4.15
|
||||
|
||||
- Postpaid Customer can request extends expiration day if it enabled
|
||||
- Some Code Fixing by @ahmadhusein17 and @agstrxyz
|
||||
|
||||
## 2024.4.4
|
||||
|
||||
- Data Tables for Customers List by @Focuslinkstech
|
||||
- Add Bills to Reminder
|
||||
- Prevent double submit for recharge and renew
|
||||
|
||||
## 2024.4.3
|
||||
|
||||
- Export logs to CSV by @agstrxyz
|
||||
- Change to Username if Country code empty
|
||||
|
||||
## 2024.4.2
|
||||
|
||||
- Fix REST API
|
||||
- Fix Log IP Cloudflare by @Gerandonk
|
||||
- Show Personal or Business in customer dashboard
|
||||
|
||||
## 2024.3.26
|
||||
|
||||
- Change paginator, to make easy customization using pagination.tpl
|
||||
|
||||
## 2024.3.25
|
||||
|
||||
- Fix maps on HTTP
|
||||
- Fix Cancel payment
|
||||
|
||||
## 2024.3.23
|
||||
|
||||
- Maps full height
|
||||
- Show Get Directions instead Coordinates
|
||||
- Maps Label always show
|
||||
|
||||
## 2024.3.22
|
||||
|
||||
- Fix Broadcast Message by @Focuslinkstech
|
||||
- Add Location Picker
|
||||
|
||||
## 2024.3.20
|
||||
|
||||
- Fixing some bugs
|
||||
|
||||
## 2024.3.19
|
||||
|
||||
- Add Customer Type Personal or Bussiness by @pro-cms
|
||||
- Fix Broadcast Message by @Focuslinkstech
|
||||
- Add Customer Geolocation by @Focuslinkstech
|
||||
- Change Customer Menu
|
||||
|
||||
## 2024.3.18
|
||||
|
||||
- Add Broadcasting SMS by @Focuslinkstech
|
||||
- Fix Notification with Bills
|
||||
|
||||
## 2024.3.16
|
||||
|
||||
- Fix Zero Charging
|
||||
- Fix Disconnect Customer from Radius without loop by @Gerandonk
|
||||
|
||||
## 2024.3.15
|
||||
|
||||
- Fix Customer View to list active Plan
|
||||
- Additional Bill using Customer Attributes
|
||||
|
||||
## 2024.3.14
|
||||
|
||||
- Add Note to Invoices
|
||||
- Add Additional Bill
|
||||
- View Invoice from Customer side
|
||||
|
||||
## 2024.3.13
|
||||
|
||||
- Postpaid System
|
||||
- Additional Cost
|
||||
|
||||
## 2024.3.12
|
||||
|
||||
- Check if Validity Period, so calculate price will not affected other validity
|
||||
- Add firewall using .htaccess for apache only
|
||||
- Multiple Payment Gateway by @Focuslinkstech
|
||||
- Fix Logic Multiple Payment gateway
|
||||
- Fix delete Attribute
|
||||
- Allow Delete Payment Gateway
|
||||
- Allow Delete Plugin
|
||||
|
||||
## 2024.3.6
|
||||
|
||||
- change attributes view
|
||||
|
||||
## 2024.3.4
|
||||
|
||||
- add [[username]] for reminder
|
||||
- fix agent show when editing
|
||||
- fix password admin when sending notification
|
||||
- add file exists for pages
|
||||
|
||||
## 2024.3.3
|
||||
|
||||
- Change loading button by @Focuslinkstech
|
||||
- Add Customer Announcements by @Gerandonk
|
||||
- Add PPPOE Period Validity by @Gerandonk
|
||||
|
||||
## 2024.2.29
|
||||
|
||||
- Fix Hook Functionality
|
||||
- Change Customer Menu
|
||||
|
||||
## 2024.2.28
|
||||
|
||||
- Fix Buy Plan with Balance
|
||||
- Add Expired date for reminder
|
||||
|
||||
## 2024.2.27
|
||||
|
||||
- fix path notification
|
||||
- redirect to dashboard if already login
|
||||
|
||||
## 2024.2.26
|
||||
|
||||
- Clean Unused JS and CSS
|
||||
- Add some Authorization check
|
||||
- Custom Path for folder
|
||||
- fix some bugs
|
||||
|
||||
## 2024.2.23
|
||||
|
||||
- Integrate with PhpNuxBill Printer
|
||||
- Fix Invoice
|
||||
- add admin ID in transaction
|
||||
|
||||
## 2024.2.22
|
||||
|
||||
- Add Loading when click submit
|
||||
- link to settings when hide widget
|
||||
|
||||
## 2024.2.21
|
||||
|
||||
- Fix SQL Installer
|
||||
- remove multiple space in language
|
||||
- Change Phone Number require OTP by @Focuslinkstech
|
||||
- Change burst Form
|
||||
- Delete Table Responsive, first Column Freeze
|
||||
|
||||
## 2024.2.20
|
||||
|
||||
- Fix list admin
|
||||
- Burst Limit
|
||||
- Pace Loading by @Focuslinkstech
|
||||
|
||||
## 2024.2.19
|
||||
|
||||
- Start API Development
|
||||
- Multiple Admin Level
|
||||
- Customer Attributes by @Focuslinkstech
|
||||
- Radius Menu
|
||||
|
||||
## 2024.2.13
|
||||
|
||||
- Auto translate language
|
||||
- change language structur to json
|
||||
- save collapse menu
|
||||
|
||||
## 2024.2.12
|
||||
|
||||
- Admin Level : SuperAdmin,Admin,Report,Agent,Sales
|
||||
- Export Customers to CSV
|
||||
- Session using Cookie
|
||||
|
||||
## 2024.2.7
|
||||
|
||||
- Hide Dashboard content
|
||||
|
||||
## 2024.2.6
|
||||
|
||||
- Cache graph for faster opening graph
|
||||
|
||||
## 2024.2.5
|
||||
|
||||
- Admin Dashboard Update
|
||||
- Add Monthly Registered Customers
|
||||
- Total Monthly Sales
|
||||
- Active Users
|
||||
|
||||
## 2024.2.2
|
||||
|
||||
- Fix edit plan for user
|
||||
|
||||
## 2024.1.24
|
||||
|
||||
- Add Send test for SMS, Whatsapp and Telegram
|
||||
|
||||
## 2024.1.19
|
||||
|
||||
- Paid Plugin, Theme, and payment gateway marketplace using codecanyon.net
|
||||
- Fix Plugin manager List
|
||||
|
||||
## 2024.1.18
|
||||
|
||||
- fix(mikrotik): set pool $poolId always empty
|
||||
|
||||
## 2024.1.17
|
||||
|
||||
- Add minor change, for plugin, menu can have notifications by @Focuslinkstech
|
||||
|
||||
## 2024.1.16
|
||||
|
||||
- Add yellow color to table for plan not allowed to purchase
|
||||
- Fix Radius pool select
|
||||
- add price to reminder notification
|
||||
- Support thermal printer for invoice
|
||||
|
||||
## 2024.1.15
|
||||
|
||||
- Fix cron job for Plan only for admin by @Focuslinkstech
|
||||
|
||||
## 2024.1.11
|
||||
|
||||
- Add Plan only for admin by @Focuslinkstech
|
||||
- Fix Plugin Manager
|
||||
|
||||
## 2024.1.9
|
||||
|
||||
- Add Prefix when generate Voucher
|
||||
|
||||
## 2024.1.8
|
||||
|
||||
- User Expired Order by Expired Date
|
||||
|
||||
## 2024.1.2
|
||||
|
||||
- Pagination User Expired by @Focuslinkstech
|
||||
|
||||
## 2023.12.21
|
||||
|
||||
- Modern AdminLTE by @sabtech254
|
||||
- Update user-dashboard.tpl by @Focuslinkstech
|
||||
|
||||
## 2023.12.19
|
||||
|
||||
- Fix Search Customer
|
||||
- Disable Registration, Customer just activate voucher Code, and the voucher will be their password
|
||||
- Remove all used voucher codes
|
||||
|
||||
## 2023.12.18
|
||||
|
||||
- Split sms to 160 characters only for Mikrotik Modem
|
||||
|
||||
## 2023.12.14
|
||||
|
||||
- Can send SMS using Mikrotik with Modem Installed
|
||||
- Add Customer Type, so Customer can only show their PPPOE or Hotspot Package or both
|
||||
|
||||
## 2023.11.17
|
||||
|
||||
- Error details not show in Customer
|
||||
|
||||
## 2023.11.15
|
||||
|
||||
- Customer Multi Router package
|
||||
- Fix edit package, Admin can change Customer to another router
|
||||
|
||||
## 2023.11.9
|
||||
|
||||
- fix bug variable in cron
|
||||
- fix update plan
|
||||
|
||||
## 2023.10.27
|
||||
|
||||
- Backup and restore database
|
||||
- Fix checking radius client
|
||||
|
||||
## 2023.10.25
|
||||
|
||||
- fix wrong file check in cron, error only for newly installed
|
||||
|
||||
## 2023.10.24
|
||||
|
||||
- Fix logic cronjob
|
||||
- assign router to NAS, but not yet used
|
||||
- Fix Pagination
|
||||
- Move Alert from hardcode
|
||||
|
||||
## 2023.10.20
|
||||
|
||||
- View Invoice
|
||||
- Resend Invoice
|
||||
- Custom Voucher
|
||||
|
||||
## 2023.10.17
|
||||
|
||||
- Happy Birthday To Me 🎂 \(^o^)/
|
||||
- Support FreeRadius with Mysql
|
||||
- Bring back Themes support
|
||||
- Log Viewer
|
||||
|
||||
## 2023.9.21
|
||||
|
||||
- Customer can extend Plan
|
||||
- Customer can Deactivate active plan
|
||||
- add variable nux-router to select only plan from that router
|
||||
- Show user expired until 30 items
|
||||
|
||||
## 2023.9.20
|
||||
|
||||
- Fix Customer balance header
|
||||
- Deactivate Customer active plan
|
||||
- Sync Customer Plan to Mikrotik
|
||||
- Recharge Customer from Customer Details
|
||||
- Add Privacy Policy and Terms and Conditions Pages
|
||||
|
||||
## 2023.9.13
|
||||
|
||||
- add Current balance in notification
|
||||
- Buy Plan for Friend
|
||||
- Recharge Friend plan
|
||||
- Fix recharge Plan
|
||||
- Show Customer active plan in Customer list
|
||||
- Fix Customer counter in dashboard
|
||||
- Show Customer Balance in header
|
||||
- Fix Plugin Manager using Http::Get
|
||||
- Show Some error page when crash
|
||||
## 2023.9.7
|
||||
|
||||
- Fix PPPOE Delete Customer
|
||||
- Remove active Customer before deleting
|
||||
- Show IP and Mac even if it not Hotspot
|
||||
|
||||
## 2023.9.6
|
||||
|
||||
- Expired Pool
|
||||
Customer can be move to expired pool after plan expired by cron
|
||||
- Fix Delete customer
|
||||
- tbl_language removed
|
||||
|
||||
## 2023.9.1.1
|
||||
|
||||
- Fix cronjob Delete customer
|
||||
- Fix reminder text
|
||||
|
||||
## 2023.9.1
|
||||
|
||||
- Critical bug fixes, bug happen when user buy package, expired time will be calculated from last expired, not from when they buy the package
|
||||
- Time not change after user buy package for extending
|
||||
- Add Cancel Button to user dashboard when it show unpaid package
|
||||
- Fix username in user dashboard
|
||||
|
||||
## 2023.8.30
|
||||
|
||||
- Upload Logo from settings
|
||||
- Fix Print value
|
||||
- Fix Time when editing prepaid
|
||||
|
||||
## 2023.8.28
|
||||
|
||||
- Extend expiration if buy same package
|
||||
- Fix calendar
|
||||
- Add recharge time
|
||||
- Fix allow balance transfer
|
||||
|
||||
## 2023.8.24
|
||||
|
||||
- Balance transfer between Customer
|
||||
- Optimize Cronjob
|
||||
- View Customer Info
|
||||
- Ajax for select customer
|
||||
|
||||
## 2023.8.18
|
||||
|
||||
- Fix Auto Renewall Cronjob
|
||||
- Add comment to Mikrotik User
|
||||
|
||||
## 2023.8.16
|
||||
|
||||
- Admin Can Add Balance to Customer
|
||||
- Show Balance in user
|
||||
- Using Select2 for Dropdown
|
||||
|
||||
## 2023.8.15
|
||||
|
||||
- Fix PPPOE Delete Customer
|
||||
- Fix Header Admin and Customer
|
||||
- Fix PDF Export by Period
|
||||
- Add pppoe_password for Customer, this pppoe_password only admin can change
|
||||
- Country Code Number Settings
|
||||
- Customer Meta Table for Customers Attributess
|
||||
- Fix Add and Edit Customer Form for admin
|
||||
- add Notification Message Editor
|
||||
- cron reminder
|
||||
- Balance System, Customer can deposit money
|
||||
- Auto renewal when package expired using Customer Balance
|
||||
|
||||
|
||||
## 2023.8.1
|
||||
|
||||
- Add Update file script, one click updating PHPNuxBill
|
||||
- Add Custom UI folder, to custome your own template
|
||||
- Delete debug text
|
||||
- Fix Vendor JS
|
||||
|
||||
## 2023.7.28
|
||||
|
||||
- Fix link buy Voucher
|
||||
- Add email field to registration form
|
||||
- Change registration design Form
|
||||
- Add Setting to disable Voucher
|
||||
- Fix Title for PPPOE plans
|
||||
- Fix Plugin Cache
|
||||
## 2023.6.20
|
||||
|
||||
- Hide time for Created date.
|
||||
Because the first time phpmixbill created, plan validity only for days and Months, many request ask for minutes and hours, i change it, but not the database.
|
||||
## 2023.6.15
|
||||
|
||||
- Customer can connect to internet from Customer Dashboard
|
||||
- Fix Confirm when delete
|
||||
- Change Logo PHPNuxBill
|
||||
- Using Composer
|
||||
- Fix Search Customer
|
||||
- Fix Customer check, if not found will logout
|
||||
- Customer password show but hidden
|
||||
- Voucher code hidden
|
||||
|
||||
## 2023.6.8
|
||||
|
||||
- Fixing registration without OTP
|
||||
- Username will not go to phonenumber if OTP registration is not enabled
|
||||
- Fix Bug PPOE
|
102
README.md
102
README.md
@ -1,86 +1,102 @@
|
||||
# PHP Mikrotik Billing
|
||||
----
|
||||
[](https://s.id/standwithpalestine)
|
||||
|
||||

|
||||
# PHPNuxBill - PHP Mikrotik Billing
|
||||
|
||||
----
|
||||

|
||||
|
||||
This project maintained by [@ibnux](https://twitter.com/ibnux)
|
||||
## Feature
|
||||
|
||||
Aplikasi ini dikelola oleh [@ibnux](https://twitter.com/ibnux)
|
||||
|
||||
----
|
||||
|
||||
Download [Mikrotik Login Template](https://github.com/ibnux/phpmixbill-mikrotik-login-template)
|
||||
|
||||
|
||||
|
||||
Features:
|
||||
----
|
||||
- Voucher Generator and Print
|
||||
- Self registration, user must have voucher before registration
|
||||
- FreeRadius
|
||||
- Self registration
|
||||
- User Balance
|
||||
- Auto Renewal Package using Balance
|
||||
- Multi Router Mikrotik
|
||||
- Hotspot & PPPOE
|
||||
- Easy Installation
|
||||
- Multi Language
|
||||
- Payment Gateway
|
||||
- SMS validation for login
|
||||
- Whatsapp Notification to Consumer
|
||||
- Telegram Notification for Admin
|
||||
|
||||
TODOS:
|
||||
----
|
||||
See [How it Works / Cara Kerja](https://github.com/hotspotbilling/phpnuxbill/wiki/How-It-Works---Cara-kerja)
|
||||
|
||||
- SMS Notification to user
|
||||
- send receipt via SMS or EMAIL
|
||||
- Social Media Login
|
||||
## Payment Gateway And Plugin
|
||||
|
||||
Installation
|
||||
----
|
||||
See [WIKI](https://github.com/ibnux/phpmixbill/wiki/Instalation)
|
||||
- [Payment Gateway List](https://github.com/orgs/hotspotbilling/repositories?q=payment+gateway)
|
||||
- [Plugin List](https://github.com/orgs/hotspotbilling/repositories?q=plugin)
|
||||
|
||||
baca [WIKI](https://github.com/ibnux/phpmixbill/wiki/Instalation)
|
||||
You can download payment gateway and Plugin from Plugin Manager
|
||||
|
||||
System Requirements
|
||||
----
|
||||
Most current web servers with PHP & MySQL installed will be capable of running PHPMixBill
|
||||
## System Requirements
|
||||
|
||||
Most current web servers with PHP & MySQL installed will be capable of running PHPNuxBill
|
||||
|
||||
Minimum Requirements
|
||||
|
||||
- Linux or Windows OS
|
||||
- PHP Version 5.3+
|
||||
- Minimum PHP Version 7.4
|
||||
- Both PDO & MySQLi Support
|
||||
- GD2 Image Library
|
||||
- PHP-GD2 Image Library
|
||||
- PHP-CURL
|
||||
- PHP-ZIP
|
||||
- PHP-Mbstring
|
||||
- MySQL Version 4.1.x and above
|
||||
|
||||
can be Installed in Raspberry Pi Device.
|
||||
|
||||
The problem with windows is hard to set cronjob, better Linux
|
||||
JASA
|
||||
----
|
||||
|
||||
Terima jasa instalasi PHPMIXBILL beserta mikrotiknya.
|
||||
## Changelog
|
||||
|
||||
Via Team Viewer maupun Barang dibeli dari saya dan tinggal pakai.
|
||||
[CHANGELOG.md](CHANGELOG.md)
|
||||
## Installation
|
||||
|
||||
1. Unit Mikrotik Router
|
||||
2. Raspberry Pi Server (RasPi + Casing + Memory 4GB + Adaptor)
|
||||
[Installation instructions](https://github.com/hotspotbilling/phpnuxbill/wiki)
|
||||
|
||||
Jasa kurang lebih Rp. 500.000, belum termasuk ongkir dan harga perangkat, Gratis Tanya Jawab via Messenger (Jika lagi senggang).
|
||||
## Docker Version
|
||||
|
||||
hubungi ibnux di [Twitter](https://twitter.com/ibnux) atau di [facebook](https://facebook.com/ibnumaksum)
|
||||
[Docker Repository](https://github.com/animegasan/phpnuxbill)
|
||||
|
||||
## Freeradius
|
||||
|
||||
License
|
||||
----
|
||||
Support [Freeradius with Database](https://github.com/hotspotbilling/phpnuxbill/wiki/FreeRadius)
|
||||
|
||||
## Community Support
|
||||
|
||||
- [Github Discussion](https://github.com/hotspotbilling/phpnuxbill/discussions)
|
||||
- [Telegram Group](https://t.me/phpmixbill)
|
||||
|
||||
## Technical Support
|
||||
|
||||
Start from Rp 500.000 or $50
|
||||
|
||||
If you chat me for any technical support, you need to pay, except for Donors, ask anything for free in the [discussion](/hotspotbilling/phpnuxbill/discussions) page
|
||||
|
||||
[Telegram](https://t.me/ibnux)
|
||||
|
||||
[Website](https://ibnux.net/layanan)
|
||||
|
||||
## License
|
||||
|
||||
GNU General Public License version 2 or later
|
||||
|
||||
see LICENSE file
|
||||
|
||||
## [CHANGELOG](CHANGELOG.md)
|
||||
|
||||
Donate to ibnux
|
||||
----
|
||||
## Donate to ibnux
|
||||
|
||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6RBNGRJMZVV7C)
|
||||
[](https://paypal.me/ibnux)
|
||||
|
||||
BCA: 5410454825
|
||||
|
||||
Mandiri: 163-000-1855-793
|
||||
|
||||
a.n Ibnu Maksum
|
||||
|
||||
## SPONSORS
|
||||
|
||||
- [mlink.id](https://mlink.id)
|
||||
- [https://github.com/sonyinside](https://github.com/sonyinside)
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 178 KiB |
Binary file not shown.
Before Width: | Height: | Size: 48 KiB |
@ -1,11 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
|
||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||
* by https://t.me/ibnux
|
||||
**/
|
||||
|
||||
|
||||
* @copyright Copyright (C) 2014-2015 PHP Mikrotik Billing
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
|
||||
**/
|
||||
|
||||
header('location: ../index.php?_route=admin/');
|
16
composer.json
Normal file
16
composer.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "hotspotbilling/phpnuxbill",
|
||||
"type": "template",
|
||||
"description": "PHPNuxBill a Hotspot Billing Software.",
|
||||
"keywords": ["template","PHPMixBill","PHPnuxBill","Mikrotik","Hotspot","Billing"],
|
||||
"homepage": "https://github.com/hotspotbilling/phpnuxbill",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "ibnux",
|
||||
"email": "me@ibnux.net",
|
||||
"homepage": "https://ibnux.net",
|
||||
"role": "Developer"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
$db_host = "localhost"; # Database Host
|
||||
$db_port = ""; # Database Port. Keep it blank if you are un sure.
|
||||
$db_user = "root"; # Database Username
|
||||
$db_password = ""; # Database Password
|
||||
$db_name = "phpmixbill"; # Database Name
|
||||
define('APP_URL', 'http://localhost/phpmixbill'); # Application URL.
|
||||
#Please include http and do not use trailing slash after the url. For example use in this format- http://www.example.com Or http://www.example.com/finance
|
||||
<?php
|
||||
$db_host = "localhost"; # Database Host
|
||||
$db_port = ""; # Database Port. Keep it blank if you are un sure.
|
||||
$db_user = "root"; # Database Username
|
||||
$db_password = ""; # Database Password
|
||||
$db_name = "phpnuxbill"; # Database Name
|
||||
define('APP_URL', 'http://localhost/phpnuxbill'); # Application URL.
|
||||
#Please include http and do not use trailing slash after the url. For example use in this format- http://www.example.com Or http://www.example.com/finance
|
||||
$_app_stage = 'Live'; # Do not change this
|
@ -1,72 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>PHPMIXBILL - Voucher management for Mikrotik Hotspot</title>
|
||||
|
||||
<!-- Latest compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
||||
|
||||
<!-- Optional theme -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
|
||||
<style>
|
||||
@-ms-viewport { width: device-width; }
|
||||
@-o-viewport { width: device-width; }
|
||||
@viewport { width: device-width; }
|
||||
|
||||
body {
|
||||
padding-top: 50px;
|
||||
}
|
||||
.starter-template {
|
||||
padding: 40px 15px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<div class="starter-template">
|
||||
<h1>PHP PHPMIXBILL</h1>
|
||||
<p class="lead">Aplikasi manajemen Voucher Hotspot untuk Mikrotik</p>
|
||||
<div class="btn-group btn-group-justified" role="group">
|
||||
<a href="https://github.com/ibnux/phpmixbill/releases" class="btn btn-primary">Download</a>
|
||||
<a href="https://github.com/ibnux/phpmixbill" class="btn btn-success">Source</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="panel panel-hovered mb20 panel-default">
|
||||
<div class="panel-heading">Public Disquss</div>
|
||||
<div class="panel-body">
|
||||
<div id="disqus_thread"></div>
|
||||
<script>
|
||||
var disqus_config = function () {
|
||||
this.page.url = "https://ibnux.github.io/phpmixbill/diskusi.html"; // Replace PAGE_URL with your page's canonical URL variable
|
||||
this.page.identifier = "phpmixbill"; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
|
||||
};
|
||||
(function() { // DON'T EDIT BELOW THIS LINE
|
||||
var d = document, s = d.createElement('script');
|
||||
s.src = 'https://phpmixbill.disqus.com/embed.js';
|
||||
s.setAttribute('data-timestamp', +new Date());
|
||||
(d.head || d.body).appendChild(s);
|
||||
})();
|
||||
</script>
|
||||
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div><!-- /.container -->
|
||||
</body>
|
||||
</html>
|
@ -1,50 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>PHPMIXBILL - Voucher management for Mikrotik Hotspot</title>
|
||||
|
||||
<!-- Latest compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
||||
|
||||
<!-- Optional theme -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
|
||||
<style>
|
||||
@-ms-viewport { width: device-width; }
|
||||
@-o-viewport { width: device-width; }
|
||||
@viewport { width: device-width; }
|
||||
|
||||
body {
|
||||
padding-top: 50px;
|
||||
}
|
||||
.starter-template {
|
||||
padding: 40px 15px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div class="starter-template">
|
||||
<h1>PHPMIXBILL</h1>
|
||||
<p class="lead">Aplikasi manajemen Voucher Hotspot untuk Mikrotik</p>
|
||||
<div class="btn-group btn-group-justified" role="group">
|
||||
<a href="https://github.com/ibnux/phpmixbill/releases" class="btn btn-primary">Download</a>
|
||||
<a href="https://github.com/ibnux/phpmixbill" class="btn btn-success">Source</a>
|
||||
<a href="https://ibnux.github.io/phpmixbill/diskusi.html" class="btn btn-info">Disquss</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div><!-- /.container -->
|
||||
</body>
|
||||
</html>
|
BIN
favicon.ico
Normal file
BIN
favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
25
index.php
25
index.php
@ -1,14 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
|
||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||
* by https://t.me/ibnux
|
||||
**/
|
||||
|
||||
session_start();
|
||||
|
||||
* @copyright Copyright (C) 2014-2015 PHP Mikrotik Billing
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
if(isset($_GET['nux-mac']) && !empty($_GET['nux-mac'])){
|
||||
$_SESSION['nux-mac'] = $_GET['nux-mac'];
|
||||
}
|
||||
|
||||
**/
|
||||
//ini_set('display_errors', 1);
|
||||
//ini_set('display_startup_errors', 1);
|
||||
//error_reporting(E_ALL);
|
||||
require ('system/boot.php');
|
||||
if(isset($_GET['nux-ip']) && !empty($_GET['nux-ip'])){
|
||||
$_SESSION['nux-ip'] = $_GET['nux-ip'];
|
||||
}
|
||||
|
||||
if(isset($_GET['nux-router']) && !empty($_GET['nux-router'])){
|
||||
$_SESSION['nux-router'] = $_GET['nux-router'];
|
||||
}
|
||||
|
||||
require_once 'system/vendor/autoload.php';
|
||||
require_once 'system/boot.php';
|
||||
App::_run();
|
||||
|
324
init.php
Normal file
324
init.php
Normal file
@ -0,0 +1,324 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||
* by https://t.me/ibnux
|
||||
**/
|
||||
|
||||
if (realpath(__FILE__) == realpath($_SERVER['SCRIPT_FILENAME'])) {
|
||||
header('HTTP/1.0 403 Forbidden', TRUE, 403);
|
||||
header('location: ../');
|
||||
die();
|
||||
}
|
||||
$root_path = realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR;
|
||||
if (!isset($isApi)) {
|
||||
$isApi = false;
|
||||
}
|
||||
// on some server, it getting error because of slash is backwards
|
||||
function _autoloader($class)
|
||||
{
|
||||
global $root_path;
|
||||
if (strpos($class, '_') !== false) {
|
||||
$class = str_replace('_', DIRECTORY_SEPARATOR, $class);
|
||||
if (file_exists($root_path . DIRECTORY_SEPARATOR . 'system' . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) {
|
||||
include $root_path . DIRECTORY_SEPARATOR . 'system' . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
|
||||
} else {
|
||||
$class = str_replace("\\", DIRECTORY_SEPARATOR, $class);
|
||||
if (file_exists($root_path . DIRECTORY_SEPARATOR . 'system' . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'))
|
||||
include $root_path . DIRECTORY_SEPARATOR . 'system' . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
|
||||
}
|
||||
} else {
|
||||
if (file_exists($root_path . DIRECTORY_SEPARATOR . 'system' . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) {
|
||||
include $root_path . DIRECTORY_SEPARATOR . 'system' . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
|
||||
} else {
|
||||
$class = str_replace("\\", DIRECTORY_SEPARATOR, $class);
|
||||
if (file_exists($root_path . DIRECTORY_SEPARATOR . 'system' . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'))
|
||||
include $root_path . DIRECTORY_SEPARATOR . 'system' . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
|
||||
}
|
||||
}
|
||||
}
|
||||
spl_autoload_register('_autoloader');
|
||||
|
||||
if (!file_exists($root_path . 'config.php')) {
|
||||
$root_path .= '..' . DIRECTORY_SEPARATOR;
|
||||
if (!file_exists($root_path . 'config.php')) {
|
||||
r2('install');
|
||||
}
|
||||
}
|
||||
|
||||
if (!file_exists($root_path . File::pathFixer('system/orm.php'))) {
|
||||
die($root_path . "orm.php file not found");
|
||||
}
|
||||
|
||||
$UPLOAD_PATH = $root_path . File::pathFixer('system/uploads');
|
||||
$CACHE_PATH = $root_path . File::pathFixer('system/cache');
|
||||
$PAGES_PATH = $root_path . File::pathFixer('pages');
|
||||
$PLUGIN_PATH = $root_path . File::pathFixer('system/plugin');
|
||||
$PAYMENTGATEWAY_PATH = $root_path . File::pathFixer('system/paymentgateway');
|
||||
$UI_PATH = 'ui';
|
||||
|
||||
if (!file_exists($UPLOAD_PATH . File::pathFixer('/notifications.default.json'))) {
|
||||
die($UPLOAD_PATH . File::pathFixer("/notifications.default.json file not found"));
|
||||
}
|
||||
|
||||
require_once $root_path . 'config.php';
|
||||
require_once $root_path . File::pathFixer('system/orm.php');
|
||||
require_once $root_path . File::pathFixer('system/autoload/PEAR2/Autoload.php');
|
||||
include $root_path . File::pathFixer('system/autoload/Hookers.php');
|
||||
|
||||
ORM::configure("mysql:host=$db_host;dbname=$db_name");
|
||||
ORM::configure('username', $db_user);
|
||||
ORM::configure('password', $db_password);
|
||||
ORM::configure('return_result_sets', true);
|
||||
if ($_app_stage != 'Live') {
|
||||
ORM::configure('logging', true);
|
||||
}
|
||||
if ($isApi) {
|
||||
define('U', APP_URL . '/system/api.php?r=');
|
||||
} else {
|
||||
define('U', APP_URL . '/index.php?_route=');
|
||||
}
|
||||
|
||||
// notification message
|
||||
if (file_exists($UPLOAD_PATH . DIRECTORY_SEPARATOR . "notifications.json")) {
|
||||
$_notifmsg = json_decode(file_get_contents($UPLOAD_PATH . DIRECTORY_SEPARATOR . 'notifications.json'), true);
|
||||
}
|
||||
$_notifmsg_default = json_decode(file_get_contents($UPLOAD_PATH . DIRECTORY_SEPARATOR . 'notifications.default.json'), true);
|
||||
|
||||
//register all plugin
|
||||
foreach (glob(File::pathFixer($PLUGIN_PATH . DIRECTORY_SEPARATOR . '*.php')) as $filename) {
|
||||
try {
|
||||
include $filename;
|
||||
} catch (Throwable $e) {
|
||||
//ignore plugin error
|
||||
} catch (Exception $e) {
|
||||
//ignore plugin error
|
||||
}
|
||||
}
|
||||
|
||||
$result = ORM::for_table('tbl_appconfig')->find_many();
|
||||
foreach ($result as $value) {
|
||||
$config[$value['setting']] = $value['value'];
|
||||
}
|
||||
$_c = $config;
|
||||
if (empty($http_proxy) && !empty($config['http_proxy'])) {
|
||||
$http_proxy = $config['http_proxy'];
|
||||
if (empty($http_proxyauth) && !empty($config['http_proxyauth'])) {
|
||||
$http_proxyauth = $config['http_proxyauth'];
|
||||
}
|
||||
}
|
||||
date_default_timezone_set($config['timezone']);
|
||||
|
||||
if ((!empty($radius_user) && $config['radius_enable']) || _post('radius_enable')) {
|
||||
ORM::configure("mysql:host=$radius_host;dbname=$radius_name", null, 'radius');
|
||||
ORM::configure('username', $radius_user, 'radius');
|
||||
ORM::configure('password', $radius_pass, 'radius');
|
||||
ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'), 'radius');
|
||||
ORM::configure('return_result_sets', true, 'radius');
|
||||
}
|
||||
|
||||
|
||||
if (empty($config['language'])) {
|
||||
$config['language'] = 'english';
|
||||
}
|
||||
$lan_file = $root_path . File::pathFixer('system/lan/' . $config['language'] . '.json');
|
||||
if (file_exists($lan_file)) {
|
||||
$_L = json_decode(file_get_contents($lan_file), true);
|
||||
$_SESSION['Lang'] = $_L;
|
||||
} else {
|
||||
$_L['author'] = 'Auto Generated by iBNuX Script';
|
||||
$_SESSION['Lang'] = $_L;
|
||||
file_put_contents($lan_file, json_encode($_L));
|
||||
}
|
||||
|
||||
|
||||
function safedata($value)
|
||||
{
|
||||
$value = trim($value);
|
||||
return $value;
|
||||
}
|
||||
|
||||
function _post($param, $defvalue = '')
|
||||
{
|
||||
if (!isset($_POST[$param])) {
|
||||
return $defvalue;
|
||||
} else {
|
||||
return safedata($_POST[$param]);
|
||||
}
|
||||
}
|
||||
|
||||
function _get($param, $defvalue = '')
|
||||
{
|
||||
if (!isset($_GET[$param])) {
|
||||
return $defvalue;
|
||||
} else {
|
||||
return safedata($_GET[$param]);
|
||||
}
|
||||
}
|
||||
|
||||
function _req($param, $defvalue = '')
|
||||
{
|
||||
if (!isset($_REQUEST[$param])) {
|
||||
return $defvalue;
|
||||
} else {
|
||||
return safedata($_REQUEST[$param]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function _auth($login = true)
|
||||
{
|
||||
if (User::getID()) {
|
||||
return true;
|
||||
} else {
|
||||
if ($login) {
|
||||
r2(U . 'login');
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _admin($login = true)
|
||||
{
|
||||
if (Admin::getID()) {
|
||||
return true;
|
||||
} else {
|
||||
if ($login) {
|
||||
r2(U . 'login');
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function _log($description, $type = '', $userid = '0')
|
||||
{
|
||||
$d = ORM::for_table('tbl_logs')->create();
|
||||
$d->date = date('Y-m-d H:i:s');
|
||||
$d->type = $type;
|
||||
$d->description = $description;
|
||||
$d->userid = $userid;
|
||||
if (!empty($_SERVER['HTTP_CF_CONNECTING_IP'])) //to check ip is pass from cloudflare tunnel
|
||||
{
|
||||
$d->ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
|
||||
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
|
||||
{
|
||||
$d->ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
} elseif (!empty($_SERVER['HTTP_CLIENT_IP'])) //to check ip from share internet
|
||||
{
|
||||
$d->ip = $_SERVER['HTTP_CLIENT_IP'];
|
||||
} else {
|
||||
$d->ip = $_SERVER["REMOTE_ADDR"];
|
||||
}
|
||||
$d->save();
|
||||
}
|
||||
|
||||
function Lang($key)
|
||||
{
|
||||
return Lang::T($key);
|
||||
}
|
||||
|
||||
function alphanumeric($str, $tambahan = "")
|
||||
{
|
||||
return Text::alphanumeric($str, $tambahan);
|
||||
}
|
||||
|
||||
function showResult($success, $message = '', $result = [], $meta = [])
|
||||
{
|
||||
header("Content-Type: Application/json");
|
||||
$json = json_encode(['success' => $success, 'message' => $message, 'result' => $result, 'meta' => $meta]);
|
||||
echo $json;
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
function generateUniqueNumericVouchers($totalVouchers, $length = 8)
|
||||
{
|
||||
// Define characters allowed in the voucher code
|
||||
$characters = '0123456789';
|
||||
$charactersLength = strlen($characters);
|
||||
$vouchers = array();
|
||||
|
||||
// Attempt to generate unique voucher codes
|
||||
for ($j = 0; $j < $totalVouchers; $j++) {
|
||||
do {
|
||||
$voucherCode = '';
|
||||
// Generate the voucher code
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$voucherCode .= $characters[rand(0, $charactersLength - 1)];
|
||||
}
|
||||
// Check if the generated voucher code already exists in the array
|
||||
$isUnique = !in_array($voucherCode, $vouchers);
|
||||
} while (!$isUnique);
|
||||
|
||||
$vouchers[] = $voucherCode;
|
||||
}
|
||||
|
||||
return $vouchers;
|
||||
}
|
||||
|
||||
function sendTelegram($txt)
|
||||
{
|
||||
Message::sendTelegram($txt);
|
||||
}
|
||||
|
||||
function sendSMS($phone, $txt)
|
||||
{
|
||||
Message::sendSMS($phone, $txt);
|
||||
}
|
||||
|
||||
function sendWhatsapp($phone, $txt)
|
||||
{
|
||||
Message::sendWhatsapp($phone, $txt);
|
||||
}
|
||||
|
||||
function r2($to, $ntype = 'e', $msg = '')
|
||||
{
|
||||
global $isApi;
|
||||
if ($isApi) {
|
||||
showResult(
|
||||
($ntype == 's') ? true : false,
|
||||
$msg
|
||||
);
|
||||
}
|
||||
if ($msg == '') {
|
||||
header("location: $to");
|
||||
exit;
|
||||
}
|
||||
$_SESSION['ntype'] = $ntype;
|
||||
$_SESSION['notify'] = $msg;
|
||||
header("location: $to");
|
||||
exit;
|
||||
}
|
||||
|
||||
function _alert($text, $type = 'success', $url = "home", $time = 3)
|
||||
{
|
||||
global $ui, $isApi;
|
||||
if ($isApi) {
|
||||
showResult(
|
||||
($type == 'success') ? true : false,
|
||||
$text
|
||||
);
|
||||
}
|
||||
if (!isset($ui)) return;
|
||||
if (strlen($url) > 4) {
|
||||
if (substr($url, 0, 4) != "http") {
|
||||
$url = U . $url;
|
||||
}
|
||||
} else {
|
||||
$url = U . $url;
|
||||
}
|
||||
$ui->assign('text', $text);
|
||||
$ui->assign('type', $type);
|
||||
$ui->assign('time', $time);
|
||||
$ui->assign('url', $url);
|
||||
$ui->display('alert.tpl');
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
if (!isset($api_secret)) {
|
||||
$api_secret = $db_password;
|
||||
}
|
BIN
install/img/favicon.png
Normal file
BIN
install/img/favicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.1 KiB |
BIN
install/img/logo.png
Normal file
BIN
install/img/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 52 KiB |
57
install/index.php
Normal file
57
install/index.php
Normal file
@ -0,0 +1,57 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>PHPNuxBill Installer</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="img/favicon.png">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<link type='text/css' href='css/style.css' rel='stylesheet' />
|
||||
<link href="css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body style='background-color: #FBFBFB;'>
|
||||
<div id='main-container'>
|
||||
<img src="img/logo.png" class="img-responsive" alt="Logo" />
|
||||
<hr>
|
||||
<!-- contents area start -->
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h4> PHPNuxBill Installer </h4>
|
||||
<h5>Please Read Before Continue</h5>
|
||||
<p><strong>Informasi Aplikasi</strong><br>
|
||||
Application Name: PHPNuxBill <br>
|
||||
Release Date: 30/10/2015<br>
|
||||
By: PHPNuxBill [ <a href="https://github.com/hotspotbilling/phpnuxbill" target="_blank">https://github.com/hotspotbilling/phpnuxbill</a> ]<br>
|
||||
Donasi Paypal: <b>me@ibnux.et</b><br>
|
||||
<br>
|
||||
<strong>Syarat Penggunaan:</strong><br>
|
||||
Syarat Penggunaan ini berlaku untuk semua versi.<br><br>
|
||||
<ul>
|
||||
<li>Silahkan Anda menggunakan aplikasi ini dengan bijak, Anda dapat mendesain ulang script maupun tampilan pada
|
||||
aplikasi ini sesuai dengan kebutuhan anda, memperbayak jumlah copy atau mendistribusikan aplikasi ini.
|
||||
Dengan catatan tidak menghapus link developer.</li>
|
||||
<li>Tidak ada garansi dari kami jika anda mengalami error atau merasa rugi ketika menggunakan aplikasi ini,
|
||||
Anda hanya dapat memberikan feedback yang berisi laporan error, dengan syarat dan ketentuan yang berlaku.</li>
|
||||
<li>Semua yang terkait biaya atau donasi apapun versi-nya, Anda dapat update seumur hidup atau selama aplikasi
|
||||
ini masih dikembangkan. Mohon jangan salah pengertian bahwa kami tim pengembang mengkomersilkan produk ini
|
||||
dan anda membeli produk kami.</li>
|
||||
<li>Aplikasi ini bersifat sosial untuk dapat dikembangkan bersama. Karena itu kami juga mengundang relawan-relawan
|
||||
yang mau menjadi pengembangkan aplikasi ini.</li>
|
||||
<li>Penulis berhak setiap saat untuk mengubah ketentuan Syarat Penggunaan tanpa pemberitahuan sebelumnya.</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-md-12"><br>
|
||||
<a href="step2.php" class="btn btn-primary">Accept & Continue</a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- contents area end -->
|
||||
</div>
|
||||
<div class="footer">Copyright © 2021 PHPNuxBill. All Rights Reserved<br /><br /></div>
|
||||
</body>
|
||||
|
||||
</html>
|
324
install/phpnuxbill.sql
Normal file
324
install/phpnuxbill.sql
Normal file
@ -0,0 +1,324 @@
|
||||
|
||||
DROP TABLE IF EXISTS `tbl_appconfig`;
|
||||
CREATE TABLE `tbl_appconfig` (
|
||||
`id` int(11) NOT NULL,
|
||||
`setting` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`value` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
DROP TABLE IF EXISTS `tbl_bandwidth`;
|
||||
CREATE TABLE `tbl_bandwidth` (
|
||||
`id` int(10) UNSIGNED NOT NULL,
|
||||
`name_bw` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`rate_down` int(10) UNSIGNED NOT NULL,
|
||||
`rate_down_unit` enum('Kbps','Mbps') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`rate_up` int(10) UNSIGNED NOT NULL,
|
||||
`rate_up_unit` enum('Kbps','Mbps') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
DROP TABLE IF EXISTS `tbl_customers`;
|
||||
CREATE TABLE `tbl_customers` (
|
||||
`id` int(10) NOT NULL,
|
||||
`username` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`password` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`pppoe_password` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'For PPPOE Login',
|
||||
`fullname` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`address` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
|
||||
`phonenumber` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0',
|
||||
`email` varchar(128) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '1',
|
||||
`coordinates` VARCHAR(50) NOT NULL DEFAULT '' COMMENT 'Latitude and Longitude coordinates',
|
||||
`balance` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT 'For Money Deposit',
|
||||
`service_type` ENUM('Hotspot','PPPoE','Others') DEFAULT 'Others' COMMENT 'For selecting user type',
|
||||
`account_type` ENUM('Business', 'Personal') DEFAULT 'Personal' COMMENT 'For selecting account type',
|
||||
`auto_renewal` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Auto renewall using balance',
|
||||
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`last_login` datetime DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `tbl_logs`;
|
||||
CREATE TABLE `tbl_logs` (
|
||||
`id` int(10) NOT NULL,
|
||||
`date` datetime DEFAULT NULL,
|
||||
`type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`description` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`userid` int(10) NOT NULL,
|
||||
`ip` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
DROP TABLE IF EXISTS `tbl_message`;
|
||||
CREATE TABLE `tbl_message` (
|
||||
`id` int(10) NOT NULL,
|
||||
`from_user` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`to_user` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`title` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`message` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`status` enum('0','1') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0',
|
||||
`date` datetime NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
DROP TABLE IF EXISTS `tbl_payment_gateway`;
|
||||
CREATE TABLE `tbl_payment_gateway` (
|
||||
`id` int(11) NOT NULL,
|
||||
`username` varchar(32) COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`gateway` varchar(32) COLLATE utf8mb4_general_ci NOT NULL COMMENT 'xendit | midtrans',
|
||||
`gateway_trx_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`plan_id` int(11) NOT NULL,
|
||||
`plan_name` varchar(40) COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`routers_id` int(11) NOT NULL,
|
||||
`routers` varchar(32) COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`price` varchar(40) COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`pg_url_payment` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`payment_method` varchar(32) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`payment_channel` varchar(32) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`pg_request` text COLLATE utf8mb4_general_ci,
|
||||
`pg_paid_response` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
|
||||
`expired_date` datetime DEFAULT NULL,
|
||||
`created_date` datetime NOT NULL,
|
||||
`paid_date` datetime DEFAULT NULL,
|
||||
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '1 unpaid 2 paid 3 failed 4 canceled'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
DROP TABLE IF EXISTS `tbl_plans`;
|
||||
CREATE TABLE `tbl_plans` (
|
||||
`id` int(10) NOT NULL,
|
||||
`name_plan` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`id_bw` int(10) NOT NULL,
|
||||
`price` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`type` enum('Hotspot','PPPOE','Balance') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`typebp` enum('Unlimited','Limited') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`limit_type` enum('Time_Limit','Data_Limit','Both_Limit') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`time_limit` int(10) UNSIGNED DEFAULT NULL,
|
||||
`time_unit` enum('Mins','Hrs') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`data_limit` int(10) UNSIGNED DEFAULT NULL,
|
||||
`data_unit` enum('MB','GB') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`validity` int(10) NOT NULL,
|
||||
`validity_unit` enum('Mins','Hrs','Days','Months','Period') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`shared_users` int(10) DEFAULT NULL,
|
||||
`routers` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`is_radius` tinyint(1) NOT NULL DEFAULT '0' COMMENT '1 is radius',
|
||||
`pool` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`pool_expired` varchar(40) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT '0 disabled',
|
||||
`allow_purchase` enum('yes','no') DEFAULT 'yes' COMMENT 'allow to show package in buy package page',
|
||||
`plan_type` ENUM('Business', 'Personal') DEFAULT 'Personal' COMMENT 'For switching plan according to user type'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
DROP TABLE IF EXISTS `tbl_pool`;
|
||||
CREATE TABLE `tbl_pool` (
|
||||
`id` int(10) NOT NULL,
|
||||
`pool_name` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`range_ip` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`routers` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
DROP TABLE IF EXISTS `tbl_routers`;
|
||||
CREATE TABLE `tbl_routers` (
|
||||
`id` int(10) NOT NULL,
|
||||
`name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`ip_address` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`password` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`description` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT '0 disabled'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
DROP TABLE IF EXISTS `tbl_transactions`;
|
||||
CREATE TABLE `tbl_transactions` (
|
||||
`id` int(10) NOT NULL,
|
||||
`invoice` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`username` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`plan_name` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`price` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`recharged_on` date NOT NULL,
|
||||
`recharged_time` time NOT NULL DEFAULT '00:00:00',
|
||||
`expiration` date NOT NULL,
|
||||
`time` time NOT NULL,
|
||||
`method` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`routers` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`type` enum('Hotspot','PPPOE','Balance') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
DROP TABLE IF EXISTS `tbl_users`;
|
||||
CREATE TABLE `tbl_users` (
|
||||
`id` int(10) UNSIGNED NOT NULL,
|
||||
`username` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`fullname` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`password` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`user_type` enum('SuperAdmin','Admin','Report','Agent','Sales') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`status` enum('Active','Inactive') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'Active',
|
||||
`last_login` datetime DEFAULT NULL,
|
||||
`creationdate` datetime NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
DROP TABLE IF EXISTS `tbl_user_recharges`;
|
||||
CREATE TABLE `tbl_user_recharges` (
|
||||
`id` int(10) NOT NULL,
|
||||
`customer_id` int(10) NOT NULL,
|
||||
`username` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`plan_id` int(10) NOT NULL,
|
||||
`namebp` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`recharged_on` date NOT NULL,
|
||||
`recharged_time` time NOT NULL DEFAULT '00:00:00',
|
||||
`expiration` date NOT NULL,
|
||||
`time` time NOT NULL,
|
||||
`status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`method` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`routers` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`type` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
DROP TABLE IF EXISTS `tbl_voucher`;
|
||||
CREATE TABLE `tbl_voucher` (
|
||||
`id` int(10) NOT NULL,
|
||||
`type` enum('Hotspot','PPPOE') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`routers` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`id_plan` int(10) NOT NULL,
|
||||
`code` varchar(55) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`user` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`status` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
DROP TABLE IF EXISTS `tb_languages`;
|
||||
CREATE TABLE `tb_languages` (
|
||||
`id` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
ALTER TABLE `tbl_appconfig`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
ALTER TABLE `tbl_bandwidth`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
ALTER TABLE `tbl_customers`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
ALTER TABLE `tbl_logs`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
ALTER TABLE `tbl_message`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
ALTER TABLE `tbl_payment_gateway`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
ALTER TABLE `tbl_plans`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
ALTER TABLE `tbl_pool`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
ALTER TABLE `tbl_routers`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
ALTER TABLE `tbl_transactions`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
ALTER TABLE `tbl_users`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
ALTER TABLE `tbl_user_recharges`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
ALTER TABLE `tbl_voucher`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
|
||||
ALTER TABLE `tbl_appconfig`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `tbl_bandwidth`
|
||||
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `tbl_customers`
|
||||
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `tbl_logs`
|
||||
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `tbl_message`
|
||||
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `tbl_payment_gateway`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `tbl_plans`
|
||||
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `tbl_pool`
|
||||
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `tbl_routers`
|
||||
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `tbl_transactions`
|
||||
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `tbl_users`
|
||||
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `tbl_user_recharges`
|
||||
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `tbl_voucher`
|
||||
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
|
||||
-- Dumping data untuk tabel `tbl_appconfig`
|
||||
|
||||
--
|
||||
|
||||
INSERT INTO
|
||||
`tbl_appconfig` (`id`, `setting`, `value`)
|
||||
VALUES (1, 'CompanyName', 'PHPNuxBill'), (2, 'currency_code', 'Rp.'), (3, 'language', 'english'), (4, 'show-logo', '1'), (5, 'nstyle', 'blue'), (6, 'timezone', 'Asia/Jakarta'), (7, 'dec_point', ','), (8, 'thousands_sep', '.'), (9, 'rtl', '0'), (10, 'address', ''), (11, 'phone', ''), (12, 'date_format', 'd M Y'), (13, 'note', 'Thank you...');
|
||||
|
||||
--
|
||||
|
||||
-- Dumping data untuk tabel `tbl_users`
|
||||
|
||||
--
|
||||
|
||||
INSERT INTO
|
||||
`tbl_users` (
|
||||
`id`,
|
||||
`username`,
|
||||
`fullname`,
|
||||
`password`,
|
||||
`user_type`,
|
||||
`status`,
|
||||
`last_login`,
|
||||
`creationdate`
|
||||
)
|
||||
VALUES (
|
||||
1,
|
||||
'admin',
|
||||
'Administrator',
|
||||
'd033e22ae348aeb5660fc2140aec35850c4da997',
|
||||
'SuperAdmin',
|
||||
'Active',
|
||||
'2022-09-06 16:09:50',
|
||||
'2014-06-23 01:43:07'
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS `tbl_customers_fields`;
|
||||
CREATE TABLE tbl_customers_fields (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
customer_id INT NOT NULL,
|
||||
field_name VARCHAR(255) NOT NULL,
|
||||
field_value VARCHAR(255) NOT NULL,
|
||||
FOREIGN KEY (customer_id) REFERENCES tbl_customers(id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
ALTER TABLE `tbl_voucher` ADD `generated_by` INT NOT NULL DEFAULT '0' COMMENT 'id admin' AFTER `status`;
|
||||
ALTER TABLE `tbl_users` ADD `root` INT NOT NULL DEFAULT '0' COMMENT 'for sub account' AFTER `id`;
|
||||
ALTER TABLE `tbl_users` CHANGE `password` `password` VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;
|
||||
ALTER TABLE `tbl_users` ADD `phone` VARCHAR(32) NOT NULL DEFAULT '' AFTER `password`, ADD `email` VARCHAR(128) NOT NULL DEFAULT '' AFTER `phone`, ADD `city` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'kota' AFTER `email`, ADD `subdistrict` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'kecamatan' AFTER `city`, ADD `ward` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'kelurahan' AFTER `subdistrict`;
|
||||
ALTER TABLE `tbl_customers` ADD `created_by` INT NOT NULL DEFAULT '0' AFTER `auto_renewal`;
|
||||
ALTER TABLE `tbl_plans` ADD `list_expired` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'address list' AFTER `pool_expired`;
|
||||
ALTER TABLE `tbl_bandwidth` ADD `burst` VARCHAR(128) NOT NULL DEFAULT '' AFTER `rate_up_unit`;
|
||||
ALTER TABLE `tbl_transactions` ADD `admin_id` INT NOT NULL DEFAULT '1' AFTER `type`;
|
||||
ALTER TABLE `tbl_user_recharges` ADD `admin_id` INT NOT NULL DEFAULT '1' AFTER `type`;
|
||||
ALTER TABLE `tbl_plans` CHANGE `allow_purchase` `prepaid` ENUM('yes','no') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'yes' COMMENT 'is prepaid';
|
||||
ALTER TABLE `tbl_transactions` ADD `note` VARCHAR(256) NOT NULL DEFAULT '' COMMENT 'for note' AFTER `type`;
|
||||
ALTER TABLE `tbl_payment_gateway` ADD `trx_invoice` VARCHAR(25) NOT NULL DEFAULT '' COMMENT 'from tbl_transactions' AFTER `paid_date`;
|
182
install/radius.sql
Normal file
182
install/radius.sql
Normal file
@ -0,0 +1,182 @@
|
||||
|
||||
DROP TABLE IF EXISTS `nas`;
|
||||
CREATE TABLE `nas` (
|
||||
`id` int(10) NOT NULL,
|
||||
`nasname` varchar(128) COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`shortname` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`type` varchar(30) COLLATE utf8mb4_general_ci DEFAULT 'other',
|
||||
`ports` int(5) DEFAULT NULL,
|
||||
`secret` varchar(60) COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'secret',
|
||||
`server` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`community` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`description` varchar(200) COLLATE utf8mb4_general_ci DEFAULT 'RADIUS Client',
|
||||
`routers` varchar(32) COLLATE utf8mb4_general_ci NOT NULL DEFAULT ''
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
DROP TABLE IF EXISTS `radacct`;
|
||||
CREATE TABLE `radacct` (
|
||||
`radacctid` bigint(21) NOT NULL,
|
||||
`acctsessionid` varchar(64) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`acctuniqueid` varchar(32) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`username` varchar(64) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`realm` varchar(64) COLLATE utf8mb4_general_ci DEFAULT '',
|
||||
`nasipaddress` varchar(15) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`nasportid` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`nasporttype` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`acctstarttime` datetime DEFAULT NULL,
|
||||
`acctupdatetime` datetime DEFAULT NULL,
|
||||
`acctstoptime` datetime DEFAULT NULL,
|
||||
`acctinterval` int(12) DEFAULT NULL,
|
||||
`acctsessiontime` int(12) UNSIGNED DEFAULT NULL,
|
||||
`acctauthentic` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`connectinfo_start` varchar(128) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`connectinfo_stop` varchar(128) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`acctinputoctets` bigint(20) DEFAULT NULL,
|
||||
`acctoutputoctets` bigint(20) DEFAULT NULL,
|
||||
`calledstationid` varchar(50) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`callingstationid` varchar(50) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`acctterminatecause` varchar(32) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`servicetype` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`framedprotocol` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`framedipaddress` varchar(15) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`framedipv6address` varchar(45) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`framedipv6prefix` varchar(45) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`framedinterfaceid` varchar(44) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`delegatedipv6prefix` varchar(45) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`class` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
DROP TABLE IF EXISTS `radcheck`;
|
||||
CREATE TABLE `radcheck` (
|
||||
`id` int(11) UNSIGNED NOT NULL,
|
||||
`username` varchar(64) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`attribute` varchar(64) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`op` char(2) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '==',
|
||||
`value` varchar(253) COLLATE utf8mb4_general_ci NOT NULL DEFAULT ''
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
DROP TABLE IF EXISTS `radgroupcheck`;
|
||||
CREATE TABLE `radgroupcheck` (
|
||||
`id` int(11) UNSIGNED NOT NULL,
|
||||
`groupname` varchar(64) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`attribute` varchar(64) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`op` char(2) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '==',
|
||||
`value` varchar(253) COLLATE utf8mb4_general_ci NOT NULL DEFAULT ''
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
DROP TABLE IF EXISTS `radgroupreply`;
|
||||
CREATE TABLE `radgroupreply` (
|
||||
`id` int(11) UNSIGNED NOT NULL,
|
||||
`groupname` varchar(64) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`attribute` varchar(64) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`op` char(2) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '=',
|
||||
`value` varchar(253) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`plan_id` int(11) NOT NULL DEFAULT '0'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
DROP TABLE IF EXISTS `radpostauth`;
|
||||
CREATE TABLE `radpostauth` (
|
||||
`id` int(11) NOT NULL,
|
||||
`username` varchar(64) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`pass` varchar(64) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`reply` varchar(32) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`authdate` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
|
||||
`class` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
DROP TABLE IF EXISTS `radreply`;
|
||||
CREATE TABLE `radreply` (
|
||||
`id` int(11) UNSIGNED NOT NULL,
|
||||
`username` varchar(64) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`attribute` varchar(64) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`op` char(2) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '=',
|
||||
`value` varchar(253) COLLATE utf8mb4_general_ci NOT NULL DEFAULT ''
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
DROP TABLE IF EXISTS `radusergroup`;
|
||||
CREATE TABLE `radusergroup` (
|
||||
`id` int(11) UNSIGNED NOT NULL,
|
||||
`username` varchar(64) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`groupname` varchar(64) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`priority` int(11) NOT NULL DEFAULT '1'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `nasreload`;
|
||||
CREATE TABLE `nasreload` (
|
||||
nasipaddress varchar(15) NOT NULL,
|
||||
reloadtime datetime NOT NULL,
|
||||
PRIMARY KEY (nasipaddress)
|
||||
) ENGINE = INNODB;
|
||||
|
||||
ALTER TABLE `nas`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `nasname` (`nasname`);
|
||||
|
||||
ALTER TABLE `radacct`
|
||||
ADD PRIMARY KEY (`radacctid`),
|
||||
ADD UNIQUE KEY `acctuniqueid` (`acctuniqueid`),
|
||||
ADD KEY `username` (`username`),
|
||||
ADD KEY `framedipaddress` (`framedipaddress`),
|
||||
ADD KEY `framedipv6address` (`framedipv6address`),
|
||||
ADD KEY `framedipv6prefix` (`framedipv6prefix`),
|
||||
ADD KEY `framedinterfaceid` (`framedinterfaceid`),
|
||||
ADD KEY `delegatedipv6prefix` (`delegatedipv6prefix`),
|
||||
ADD KEY `acctsessionid` (`acctsessionid`),
|
||||
ADD KEY `acctsessiontime` (`acctsessiontime`),
|
||||
ADD KEY `acctstarttime` (`acctstarttime`),
|
||||
ADD KEY `acctinterval` (`acctinterval`),
|
||||
ADD KEY `acctstoptime` (`acctstoptime`),
|
||||
ADD KEY `nasipaddress` (`nasipaddress`),
|
||||
ADD KEY `class` (`class`);
|
||||
|
||||
ALTER TABLE `radcheck`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `username` (`username`(32));
|
||||
|
||||
ALTER TABLE `radgroupcheck`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `groupname` (`groupname`(32));
|
||||
|
||||
ALTER TABLE `radgroupreply`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `groupname` (`groupname`(32));
|
||||
|
||||
ALTER TABLE `radpostauth`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `username` (`username`),
|
||||
ADD KEY `class` (`class`);
|
||||
|
||||
ALTER TABLE `radreply`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `username` (`username`(32));
|
||||
|
||||
ALTER TABLE `radusergroup`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `username` (`username`(32));
|
||||
|
||||
|
||||
ALTER TABLE `nas`
|
||||
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `radacct`
|
||||
MODIFY `radacctid` bigint(21) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `radcheck`
|
||||
MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `radgroupcheck`
|
||||
MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `radgroupreply`
|
||||
MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `radpostauth`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `radreply`
|
||||
MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `radusergroup`
|
||||
MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
|
||||
SET FOREIGN_KEY_CHECKS=1;
|
67
install/step2.php
Normal file
67
install/step2.php
Normal file
@ -0,0 +1,67 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>PHPNuxBill Installer</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<link type='text/css' href='css/style.css' rel='stylesheet' />
|
||||
<link type='text/css' href="css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body style='background-color: #FBFBFB;'>
|
||||
<div id='main-container'>
|
||||
<img src="img/logo.png" class="img-responsive" alt="Logo" />
|
||||
<hr>
|
||||
|
||||
<div class="span12">
|
||||
<h4> PHPNuxBill Installer </h4>
|
||||
<?php
|
||||
$passed = '';
|
||||
$ltext = '';
|
||||
if (version_compare(PHP_VERSION, '7.2.0') >= 0) {
|
||||
$ltext .= 'To Run PHPNuxBill You need at least PHP version 7.2.0, Your PHP Version is: ' . PHP_VERSION . " Tested <strong>---PASSED---</strong><br/>";
|
||||
$passed .= '1';
|
||||
} else {
|
||||
$ltext .= 'To Run PHPNuxBill You need at least PHP version 7.2.0, Your PHP Version is: ' . PHP_VERSION . " Tested <strong>---FAILED---</strong><br/>";
|
||||
$passed .= '0';
|
||||
}
|
||||
|
||||
if (extension_loaded('PDO')) {
|
||||
$ltext .= 'PDO is installed on your server: ' . "Tested <strong>---PASSED---</strong><br/>";
|
||||
$passed .= '1';
|
||||
} else {
|
||||
$ltext = 'PDO is installed on your server: ' . "Tested <strong>---FAILED---</strong><br/>";
|
||||
$passed .= '0';
|
||||
}
|
||||
|
||||
if (extension_loaded('pdo_mysql')) {
|
||||
$ltext .= 'PDO MySQL driver is enabled on your server: ' . "Tested <strong>---PASSED---</strong><br/>";
|
||||
$passed .= '1';
|
||||
} else {
|
||||
$ltext .= 'PDO MySQL driver is not enabled on your server: ' . "Tested <strong>---FAILED---</strong><br/>";
|
||||
$passed .= '0';
|
||||
}
|
||||
|
||||
if ($passed == '111') {
|
||||
echo ("<br/> $ltext <br/> Great! System Test Completed. You can run PHPNuxBill on your server. Click Continue For Next Step.
|
||||
<br><br>
|
||||
<a href=\"step3.php\" class=\"btn btn-primary\">Continue</a><br><br><a href=\"update.php\" class=\"btn btn-primary\">Update System</a>");
|
||||
} else {
|
||||
echo ("<br/> $ltext <br/> Sorry. The requirements of PHPNuxBill is not available on your server.
|
||||
Contact with us at Telegram <a href=\"https://t.me/phpnuxbill\">@phpnuxbill</a> with this code- $passed Or contact with your server administrator
|
||||
<br><br>
|
||||
<a href=\"#\" class=\"btn btn-primary disabled\">Correct The Problem To Continue</a>");
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer">Copyright © 2021 PHPNuxBill. All Rights Reserved<br /><br /></div>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,72 +1,74 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>PHPMixBill Installer</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<link type='text/css' href='css/style.css' rel='stylesheet'/>
|
||||
<link type='text/css' href="css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body style='background-color: #FBFBFB;'>
|
||||
<div id='main-container'>
|
||||
<div class='header'>
|
||||
<div class="header-box wrapper">
|
||||
<div class="hd-logo"><a href="#"><img src="img/logo.png" alt="Logo"/></a></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="span12">
|
||||
<h4> PHPMixBill Installer </h4>
|
||||
<?php
|
||||
if (isset($_GET['_error']) && ($_GET['_error']) == '1') {
|
||||
echo '<h4 style="color: red;"> Unable to Connect Database, Please make sure database info is correct and try again ! </h4>';
|
||||
}
|
||||
|
||||
$cururl = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||
$appurl = str_replace('/install/step3.php', '', $cururl);
|
||||
$appurl = str_replace('?_error=1', '', $appurl);
|
||||
$appurl = str_replace('/system', '', $appurl);
|
||||
?>
|
||||
|
||||
<form action="step4.php" method="post">
|
||||
<fieldset>
|
||||
<legend>Database Connection & Site config</legend>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="appurl">Application URL</label>
|
||||
<input type="text" class="form-control" id="appurl" name="appurl" value="<?php echo $appurl; ?>">
|
||||
<span class='help-block'>Application url without trailing slash at the end of url (e.g. http://172.16.10.10). Please keep default, if you are unsure.</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="dbhost">Database Host</label>
|
||||
<input type="text" class="form-control" id="dbhost" name="dbhost">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="dbuser">Database Username</label>
|
||||
<input type="text" class="form-control" id="dbuser" name="dbuser">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="dbpass">Database Password</label>
|
||||
<input type="text" class="form-control" id="dbpass" name="dbpass">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="dbname">Database Name</label>
|
||||
<input type="text" class="form-control" id="dbname" name="dbname">
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer">Copyright © 2021 PHPMixBill. All Rights Reserved<br/><br/></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>PHPNuxBill Installer</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<link type='text/css' href='css/style.css' rel='stylesheet'/>
|
||||
<link type='text/css' href="css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body style='background-color: #FBFBFB;'>
|
||||
<div id='main-container'>
|
||||
<img src="img/logo.png" class="img-responsive" alt="Logo" />
|
||||
<hr>
|
||||
|
||||
<div class="span12">
|
||||
<h4> PHPNuxBill Installer </h4>
|
||||
<?php
|
||||
if (isset($_GET['_error']) && ($_GET['_error']) == '1') {
|
||||
echo '<h4 style="color: red;"> Unable to Connect Database, Please make sure database info is correct and try again ! </h4>';
|
||||
}//
|
||||
|
||||
$cururl = (((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')|| $_SERVER['SERVER_PORT'] == 443)?'https':'http').'://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||
$appurl = str_replace('/install/step3.php', '', $cururl);
|
||||
$appurl = str_replace('?_error=1', '', $appurl);
|
||||
$appurl = str_replace('/system', '', $appurl);
|
||||
?>
|
||||
|
||||
<form action="step4.php" method="post">
|
||||
<fieldset>
|
||||
<legend>Database Connection & Site config</legend>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="appurl">Application URL</label>
|
||||
<input type="text" class="form-control" id="appurl" name="appurl" value="<?php echo $appurl; ?>">
|
||||
<span class='help-block'>Application url without trailing slash at the end of url (e.g. http://172.16.10.10). Please keep default, if you are unsure.</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="dbhost">Database Host</label>
|
||||
<input type="text" class="form-control" id="dbhost" name="dbhost">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="dbuser">Database Username</label>
|
||||
<input type="text" class="form-control" id="dbuser" name="dbuser">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="dbpass">Database Password</label>
|
||||
<input type="text" class="form-control" id="dbpass" name="dbpass">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="dbname">Database Name</label>
|
||||
<input type="text" class="form-control" id="dbname" name="dbname">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="dbname"><input type="checkbox" class="form-control" id="radius" name="radius" value="yes"> Install Radius Table?</label>
|
||||
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer">Copyright © 2021 PHPNuxBill. All Rights Reserved<br/><br/></div>
|
||||
</body>
|
||||
</html>
|
||||
|
148
install/step4.php
Normal file
148
install/step4.php
Normal file
@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||
* by https://t.me/ibnux
|
||||
**/
|
||||
|
||||
//error_reporting (0);
|
||||
$appurl = $_POST['appurl'];
|
||||
$db_host = $_POST['dbhost'];
|
||||
$db_user = $_POST['dbuser'];
|
||||
$db_password = $_POST['dbpass'];
|
||||
$db_name = $_POST['dbname'];
|
||||
$cn = '0';
|
||||
try {
|
||||
$dbh = new pdo(
|
||||
"mysql:host=$db_host;dbname=$db_name",
|
||||
"$db_user",
|
||||
"$db_password",
|
||||
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
);
|
||||
$cn = '1';
|
||||
} catch (PDOException $ex) {
|
||||
$cn = '0';
|
||||
}
|
||||
|
||||
if ($cn == '1') {
|
||||
if (isset($_POST['radius']) && $_POST['radius'] == 'yes') {
|
||||
$input = '<?php
|
||||
|
||||
define(\'APP_URL\', \'' . $appurl . '\');
|
||||
$_app_stage = \'Live\';
|
||||
|
||||
// Database PHPNuxBill
|
||||
$db_host = \'' . $db_host . '\';
|
||||
$db_user = \'' . $db_user . '\';
|
||||
$db_password = \'' . $db_password . '\';
|
||||
$db_name = \'' . $db_name . '\';
|
||||
|
||||
// Database Radius
|
||||
$radius_host = \'' . $db_host . '\';
|
||||
$radius_user = \'' . $db_user . '\';
|
||||
$radius_pass = \'' . $db_password . '\';
|
||||
$radius_name = \'' . $db_name . '\';
|
||||
|
||||
if($_app_stage!=\'Live\'){
|
||||
error_reporting(E_ERROR);
|
||||
ini_set(\'display_errors\', 1);
|
||||
ini_set(\'display_startup_errors\', 1);
|
||||
}else{
|
||||
error_reporting(E_ERROR);
|
||||
ini_set(\'display_errors\', 0);
|
||||
ini_set(\'display_startup_errors\', 0);
|
||||
}
|
||||
';
|
||||
} else {
|
||||
$input = '<?php
|
||||
|
||||
define(\'APP_URL\', \'' . $appurl . '\');
|
||||
$_app_stage = \'Live\';
|
||||
|
||||
// Database PHPNuxBill
|
||||
$db_host = \'' . $db_host . '\';
|
||||
$db_user = \'' . $db_user . '\';
|
||||
$db_password = \'' . $db_password . '\';
|
||||
$db_name = \'' . $db_name . '\';
|
||||
|
||||
if($_app_stage!=\'Live\'){
|
||||
error_reporting(E_ERROR);
|
||||
ini_set(\'display_errors\', 1);
|
||||
ini_set(\'display_startup_errors\', 1);
|
||||
}else{
|
||||
error_reporting(E_ERROR);
|
||||
ini_set(\'display_errors\', 0);
|
||||
ini_set(\'display_startup_errors\', 0);
|
||||
}
|
||||
';
|
||||
}
|
||||
$wConfig = "../config.php";
|
||||
$fh = fopen($wConfig, 'w') or die("Can't create config file, your server does not support 'fopen' function,
|
||||
please create a file named - config.php with following contents- <br/>$input");
|
||||
fwrite($fh, $input);
|
||||
fclose($fh);
|
||||
$sql = file_get_contents('phpnuxbill.sql');
|
||||
$qr = $dbh->exec($sql);
|
||||
if (isset($_POST['radius']) && $_POST['radius'] == 'yes') {
|
||||
$sql = file_get_contents('radius.sql');
|
||||
$qrs = $dbh->exec($sql);
|
||||
}
|
||||
} else {
|
||||
header("location: step3.php?_error=1");
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>PHPNuxBill Installer</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<link type='text/css' href='css/style.css' rel='stylesheet' />
|
||||
<link type='text/css' href="css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body style='background-color: #FBFBFB;'>
|
||||
<div id='main-container'>
|
||||
<img src="img/logo.png" class="img-responsive" alt="Logo" />
|
||||
<hr>
|
||||
|
||||
<div class="span12">
|
||||
<h4> PHPNuxBill Installer </h4>
|
||||
<?php
|
||||
if ($cn == '1') {
|
||||
?>
|
||||
<p><strong>Config File Created and Database Imported.</strong><br></p>
|
||||
<form action="step5.php" method="post">
|
||||
<fieldset>
|
||||
<legend>Click Continue</legend>
|
||||
<button type='submit' class='btn btn-primary'>Continue</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
<?php
|
||||
} elseif ($cn == '2') {
|
||||
?>
|
||||
<p> MySQL Connection was successfull. An error occured while adding data on MySQL. Unsuccessfull
|
||||
Installation. Please refer manual installation in the website github.com/ibnux/phpnuxbill/wiki or Contact Telegram @ibnux for
|
||||
helping on installation</p>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<p> MySQL Connection Failed.</p>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer">Copyright © 2021 PHPNuxBill. All Rights Reserved<br /><br /></div>
|
||||
</body>
|
||||
|
||||
</html>
|
55
install/step5.php
Normal file
55
install/step5.php
Normal file
@ -0,0 +1,55 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>PHPNuxBill Installer</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<link type='text/css' href='css/style.css' rel='stylesheet' />
|
||||
<link type='text/css' href="css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<?php if (!file_exists('../pages')) rename('../pages_template', '../pages'); ?>
|
||||
|
||||
<body style='background-color: #FBFBFB;'>
|
||||
<div id='main-container'>
|
||||
<img src="img/logo.png" class="img-responsive" alt="Logo" />
|
||||
<hr>
|
||||
<div class="span12">
|
||||
<h4> PHPNuxBill Installer </h4>
|
||||
<p>
|
||||
<strong>Congratulations!</strong><br>
|
||||
You have just install PHPNuxBill !<br><br>
|
||||
<span class="text-danger">But wait!!<br>
|
||||
<ol>
|
||||
<li>Don't forget to rename folder <b>pages_example</b> to <b>pages</b>.<br>
|
||||
if it not yet renamed</li>
|
||||
<li>Activate <a href="https://github.com/hotspotbilling/phpnuxbill/wiki/Cron-Jobs" target="_blank">Cronjob</a> for Expired and Reminder.</li>
|
||||
<li>Check <a href="https://github.com/hotspotbilling/phpnuxbill/wiki/How-It-Works---Cara-kerja" target="_blank">how PHPNuxbill Works</a></li>
|
||||
<li><a href="https://github.com/hotspotbilling/phpnuxbill/wiki#login-page-mikrotik" target="_blank">how to link Mikrotik Login to PHPNuxBill</a></li>
|
||||
<li>or use <a href="https://github.com/hotspotbilling/phpnuxbill-mikrotik-login-template" target="_blank">Mikrotik Login Template for PHPNuxBill</a></li>
|
||||
</ol>
|
||||
</span><br><br>
|
||||
To Login Admin Portal:<br>
|
||||
Use this link -
|
||||
<?php
|
||||
$cururl = (((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||
$appurl = str_replace('/install/step5.php', '', $cururl);
|
||||
$appurl = str_replace('/system', '', $appurl);
|
||||
echo '<a href="' . $appurl . '/admin">' . $appurl . '/admin</a>';
|
||||
?>
|
||||
<br>
|
||||
Username: admin<br>
|
||||
Password: admin<br>
|
||||
For security, Delete the <b>install</b> directory inside system folder.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer">Copyright © 2021 PHPNuxBill. All Rights Reserved<br /><br /></div>
|
||||
</body>
|
||||
|
||||
</html>
|
106
install/update.php
Normal file
106
install/update.php
Normal file
@ -0,0 +1,106 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>PHPNuxBill Updaters</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<link type='text/css' href='css/style.css' rel='stylesheet' />
|
||||
<link type='text/css' href="css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body style='background-color: #FBFBFB;'>
|
||||
<div id='main-container'>
|
||||
<img src="img/logo.png" class="img-responsive" alt="Logo" />
|
||||
<hr>
|
||||
|
||||
<div class="span12">
|
||||
<h4> PHPNuxBill Updater </h4>
|
||||
<pre><?php
|
||||
include '../config.php';
|
||||
try{
|
||||
$dbh = new pdo( "mysql:host=$db_host;dbname=$db_name",
|
||||
"$db_user",
|
||||
"$db_password",
|
||||
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
|
||||
|
||||
echo "CREATE TABLE `tbl_payment_gateway` (
|
||||
`id` int(11) NOT NULL,
|
||||
`username` varchar(32) COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`gateway` varchar(32) COLLATE utf8mb4_general_ci NOT NULL COMMENT 'xendit | midtrans',
|
||||
`gateway_trx_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`plan_id` int(11) NOT NULL,
|
||||
`plan_name` varchar(40) COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`routers_id` int(11) NOT NULL,
|
||||
`routers` varchar(32) COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`price` varchar(40) COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`pg_url_payment` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`payment_method` varchar(32) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`payment_channel` varchar(32) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`pg_request` text COLLATE utf8mb4_general_ci,
|
||||
`pg_paid_response` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
|
||||
`expired_date` datetime DEFAULT NULL,
|
||||
`created_date` datetime NOT NULL,
|
||||
`paid_date` datetime DEFAULT NULL,
|
||||
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '1 unpaid 2 paid 3 failed 4 canceled'
|
||||
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci;\n\n";
|
||||
$dbh->exec("CREATE TABLE
|
||||
`tbl_payment_gateway` (
|
||||
`id` int(11) NOT NULL,
|
||||
`username` varchar(32) COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`gateway` varchar(32) COLLATE utf8mb4_general_ci NOT NULL COMMENT 'xendit | midtrans',
|
||||
`gateway_trx_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`plan_id` int(11) NOT NULL,
|
||||
`plan_name` varchar(40) COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`routers_id` int(11) NOT NULL,
|
||||
`routers` varchar(32) COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`price` varchar(40) COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`pg_url_payment` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`payment_method` varchar(32) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`payment_channel` varchar(32) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`pg_request` text COLLATE utf8mb4_general_ci,
|
||||
`pg_paid_response` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
|
||||
`expired_date` datetime DEFAULT NULL,
|
||||
`created_date` datetime NOT NULL,
|
||||
`paid_date` datetime DEFAULT NULL,
|
||||
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '1 unpaid 2 paid 3 failed 4 canceled'
|
||||
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci;");
|
||||
|
||||
echo "ALTER TABLE `tbl_payment_gateway` ADD PRIMARY KEY (`id`);\n\n";
|
||||
$dbh->exec("ALTER TABLE `tbl_payment_gateway` ADD PRIMARY KEY (`id`);");
|
||||
echo "ALTER TABLE `tbl_payment_gateway` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;\n\n";
|
||||
$dbh->exec("ALTER TABLE `tbl_payment_gateway` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;");
|
||||
|
||||
echo "ALTER TABLE `tbl_customers` ADD `email` VARCHAR(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' AFTER `phonenumber`;\n\n";
|
||||
$dbh->exec("ALTER TABLE `tbl_customers` ADD `email` VARCHAR(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' AFTER `phonenumber`;");
|
||||
|
||||
echo "ALTER TABLE `tbl_plans` CHANGE `validity_unit` `validity_unit` ENUM('Mins','Hrs','Days','Months') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;\n\n";
|
||||
$dbh->exec("ALTER TABLE `tbl_plans` CHANGE `validity_unit` `validity_unit` ENUM('Mins','Hrs','Days','Months') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL");
|
||||
echo "ALTER TABLE `tbl_plans` ADD `enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT '0 disabled' AFTER `pool`;\n\n";
|
||||
$dbh->exec("ALTER TABLE `tbl_plans` ADD `enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT '0 disabled' AFTER `pool`;");
|
||||
|
||||
echo "ALTER TABLE `tbl_routers` ADD `enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT '0 disabled' AFTER `description`;\n\n";
|
||||
$dbh->exec("ALTER TABLE `tbl_routers` ADD `enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT '0 disabled' AFTER `description`;");
|
||||
echo "ALTER TABLE `tbl_routers` CHANGE `description` `description` VARCHAR(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL;";
|
||||
$dbh->exec("ALTER TABLE `tbl_routers` CHANGE `description` `description` VARCHAR(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL;");
|
||||
|
||||
echo "ALTER TABLE `tbl_user_recharges` CHANGE `method` `method` VARCHAR(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '';\n\n";
|
||||
$dbh->exec("ALTER TABLE `tbl_user_recharges` CHANGE `method` `method` VARCHAR(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '';");
|
||||
echo "ALTER TABLE `tbl_transactions` CHANGE `method` `method` VARCHAR(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;\n\n";
|
||||
$dbh->exec("ALTER TABLE `tbl_transactions` CHANGE `method` `method` VARCHAR(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;");
|
||||
echo "Success update database for new system <a href='/admin/'>Back To Home</a>";
|
||||
}catch(PDOException $ex){
|
||||
echo "Error Failed to connect to database: ".$ex->getMessage()."\n";
|
||||
}
|
||||
?></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer">Copyright © 2021 PHPNuxBill. All Rights Reserved<br /><br /></div>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,31 +0,0 @@
|
||||
|
||||
<center><strong style="font-size:38px">{$_c['CompanyName']}</strong></center>
|
||||
<table width="100%" border="1" cellspacing="0" cellpadding="4" bordercolor="#757575">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="top" align="left">Pendaftaran dan Informasi Billing buka <b>billing.ibnux.net</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" align="left">Wireless Hotspot:
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="2">
|
||||
<tr>
|
||||
<td>iBNuXnet</td>
|
||||
<td>iBNuXnet-P</td>
|
||||
<td>iBNuXnet-Q</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>CitraGadingBlokP 3/4</td>
|
||||
<td>CitraGadingBlokQ 2/3/4/5/6</td>
|
||||
<td>iBNuXnet 5Ghz</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" align="left">Voucher yang sudah dibeli tidak dapat dikembalikan</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" align="center"><b>hotspot.ibnux.net</b></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
@ -1 +1,3 @@
|
||||
Pengumuman!!<br>Besok libur<br><br>Announcement!!<br>Tomorrow holiday<br>
|
||||
Pengumuman!!<br>Besok libur<br><br>Announcement!!<br>Tomorrow holiday<br><br>
|
||||
<br>
|
||||
This Announcement is for Login Page.
|
8
pages_template/Announcement_Customer.html
Normal file
8
pages_template/Announcement_Customer.html
Normal file
@ -0,0 +1,8 @@
|
||||
Pengumuman Pelanggan!!<br>
|
||||
Besok libur<br>
|
||||
<br>
|
||||
Customer Announcement!!<br>
|
||||
Tomorrow holiday<br>
|
||||
<br>
|
||||
<br>
|
||||
This Announcement is for Customer Dashboard
|
62
pages_template/Privacy_Policy.html
Normal file
62
pages_template/Privacy_Policy.html
Normal file
@ -0,0 +1,62 @@
|
||||
<h1>Privacy Policy for PHPNuxBill</h1>
|
||||
|
||||
<p>At PHPNuxBill, accessible from https://github.com/hotspotbilling/phpnuxbill, one of our main priorities is the
|
||||
privacy of our visitors. This Privacy Policy document contains types of information that is collected and recorded
|
||||
by PHPNuxBill and how we use it.</p>
|
||||
|
||||
<p>If you have additional questions or require more information about our Privacy Policy, do not hesitate to contact us.
|
||||
</p>
|
||||
|
||||
<h2>Log Files</h2>
|
||||
|
||||
<p>PHPNuxBill follows a standard procedure of using log files. These files log visitors when they visit websites. All
|
||||
hosting companies do this and a part of hosting services' analytics. The information collected by log files include
|
||||
internet protocol (IP) addresses, browser type, Internet Service Provider (ISP), date and time stamp, referring/exit
|
||||
pages, and possibly the number of clicks. These are not linked to any information that is personally identifiable.
|
||||
The purpose of the information is for analyzing trends, administering the site, tracking users' movement on the
|
||||
website, and gathering demographic information. Our Privacy Policy was created with the help of the <a
|
||||
href="https://www.privacypolicyonline.com/privacy-policy-generator/">Privacy Policy Generator</a>.</p>
|
||||
|
||||
|
||||
|
||||
|
||||
<h2>Privacy Policies</h2>
|
||||
|
||||
<P>You may consult this list to find the Privacy Policy for each of the advertising partners of PHPNuxBill.</p>
|
||||
|
||||
<p>Third-party ad servers or ad networks uses technologies like cookies, JavaScript, or Web Beacons that are used in
|
||||
their respective advertisements and links that appear on PHPNuxBill, which are sent directly to users' browser. They
|
||||
automatically receive your IP address when this occurs. These technologies are used to measure the effectiveness of
|
||||
their advertising campaigns and/or to personalize the advertising content that you see on websites that you visit.
|
||||
</p>
|
||||
|
||||
<p>Note that PHPNuxBill has no access to or control over these cookies that are used by third-party advertisers.</p>
|
||||
|
||||
<h2>Third Party Privacy Policies</h2>
|
||||
|
||||
<p>PHPNuxBill's Privacy Policy does not apply to other advertisers or websites. Thus, we are advising you to consult the
|
||||
respective Privacy Policies of these third-party ad servers for more detailed information. It may include their
|
||||
practices and instructions about how to opt-out of certain options. </p>
|
||||
|
||||
<p>You can choose to disable cookies through your individual browser options. To know more detailed information about
|
||||
cookie management with specific web browsers, it can be found at the browsers' respective websites. What Are
|
||||
Cookies?</p>
|
||||
|
||||
<h2>Children's Information</h2>
|
||||
|
||||
<p>Another part of our priority is adding protection for children while using the internet. We encourage parents and
|
||||
guardians to observe, participate in, and/or monitor and guide their online activity.</p>
|
||||
|
||||
<p>PHPNuxBill does not knowingly collect any Personal Identifiable Information from children under the age of 13. If you
|
||||
think that your child provided this kind of information on our website, we strongly encourage you to contact us
|
||||
immediately and we will do our best efforts to promptly remove such information from our records.</p>
|
||||
|
||||
<h2>Online Privacy Policy Only</h2>
|
||||
|
||||
<p>This Privacy Policy applies only to our online activities and is valid for visitors to our website with regards to
|
||||
the information that they shared and/or collect in PHPNuxBill. This policy is not applicable to any information
|
||||
collected offline or via channels other than this website.</p>
|
||||
|
||||
<h2>Consent</h2>
|
||||
|
||||
<p>By using our website, you hereby consent to our Privacy Policy and agree to its Terms and Conditions.</p>
|
119
pages_template/Terms_and_Conditions.html
Normal file
119
pages_template/Terms_and_Conditions.html
Normal file
@ -0,0 +1,119 @@
|
||||
<h2><strong>Terms and Conditions</strong></h2>
|
||||
|
||||
<p>Welcome to PHPNuxBill!</p>
|
||||
|
||||
<p>These terms and conditions outline the rules and regulations for the use of PHPNuxBill's Website, located at https://github.com/hotspotbilling/phpnuxbill.</p>
|
||||
|
||||
<p>By accessing this website we assume you accept these terms and conditions. Do not continue to use PHPNuxBill if you do not agree to take all of the terms and conditions stated on this page.</p>
|
||||
|
||||
<p>The following terminology applies to these Terms and Conditions, Privacy Statement and Disclaimer Notice and all Agreements: "Client", "You" and "Your" refers to you, the person log on this website and compliant to the Company’s terms and conditions. "The Company", "Ourselves", "We", "Our" and "Us", refers to our Company. "Party", "Parties", or "Us", refers to both the Client and ourselves. All terms refer to the offer, acceptance and consideration of payment necessary to undertake the process of our assistance to the Client in the most appropriate manner for the express purpose of meeting the Client’s needs in respect of provision of the Company’s stated services, in accordance with and subject to, prevailing law of Netherlands. Any use of the above terminology or other words in the singular, plural, capitalization and/or he/she or they, are taken as interchangeable and therefore as referring to same. Our Terms and Conditions were created with the help of the <a href="https://www.privacypolicyonline.com/terms-conditions-generator/">Terms & Conditions Generator</a>.</p>
|
||||
|
||||
<h3><strong>Cookies</strong></h3>
|
||||
|
||||
<p>We employ the use of cookies. By accessing PHPNuxBill, you agreed to use cookies in agreement with the PHPNuxBill's Privacy Policy.</p>
|
||||
|
||||
<p>Most interactive websites use cookies to let us retrieve the user's details for each visit. Cookies are used by our website to enable the functionality of certain areas to make it easier for people visiting our website. Some of our affiliate/advertising partners may also use cookies.</p>
|
||||
|
||||
<h3><strong>License</strong></h3>
|
||||
|
||||
<p>Unless otherwise stated, PHPNuxBill and/or its licensors own the intellectual property rights for all material on PHPNuxBill. All intellectual property rights are reserved. You may access this from PHPNuxBill for your own personal use subjected to restrictions set in these terms and conditions.</p>
|
||||
|
||||
<p>You must not:</p>
|
||||
<ul>
|
||||
<li>Republish material from PHPNuxBill</li>
|
||||
<li>Sell, rent or sub-license material from PHPNuxBill</li>
|
||||
<li>Reproduce, duplicate or copy material from PHPNuxBill</li>
|
||||
<li>Redistribute content from PHPNuxBill</li>
|
||||
</ul>
|
||||
|
||||
<p>This Agreement shall begin on the date hereof.</p>
|
||||
|
||||
<p>Parts of this website offer an opportunity for users to post and exchange opinions and information in certain areas of the website. PHPNuxBill does not filter, edit, publish or review Comments prior to their presence on the website. Comments do not reflect the views and opinions of PHPNuxBill,its agents and/or affiliates. Comments reflect the views and opinions of the person who post their views and opinions. To the extent permitted by applicable laws, PHPNuxBill shall not be liable for the Comments or for any liability, damages or expenses caused and/or suffered as a result of any use of and/or posting of and/or appearance of the Comments on this website.</p>
|
||||
|
||||
<p>PHPNuxBill reserves the right to monitor all Comments and to remove any Comments which can be considered inappropriate, offensive or causes breach of these Terms and Conditions.</p>
|
||||
|
||||
<p>You warrant and represent that:</p>
|
||||
|
||||
<ul>
|
||||
<li>You are entitled to post the Comments on our website and have all necessary licenses and consents to do so;</li>
|
||||
<li>The Comments do not invade any intellectual property right, including without limitation copyright, patent or trademark of any third party;</li>
|
||||
<li>The Comments do not contain any defamatory, libelous, offensive, indecent or otherwise unlawful material which is an invasion of privacy</li>
|
||||
<li>The Comments will not be used to solicit or promote business or custom or present commercial activities or unlawful activity.</li>
|
||||
</ul>
|
||||
|
||||
<p>You hereby grant PHPNuxBill a non-exclusive license to use, reproduce, edit and authorize others to use, reproduce and edit any of your Comments in any and all forms, formats or media.</p>
|
||||
|
||||
<h3><strong>Hyperlinking to our Content</strong></h3>
|
||||
|
||||
<p>The following organizations may link to our Website without prior written approval:</p>
|
||||
|
||||
<ul>
|
||||
<li>Government agencies;</li>
|
||||
<li>Search engines;</li>
|
||||
<li>News organizations;</li>
|
||||
<li>Online directory distributors may link to our Website in the same manner as they hyperlink to the Websites of other listed businesses; and</li>
|
||||
<li>System wide Accredited Businesses except soliciting non-profit organizations, charity shopping malls, and charity fundraising groups which may not hyperlink to our Web site.</li>
|
||||
</ul>
|
||||
|
||||
<p>These organizations may link to our home page, to publications or to other Website information so long as the link: (a) is not in any way deceptive; (b) does not falsely imply sponsorship, endorsement or approval of the linking party and its products and/or services; and (c) fits within the context of the linking party's site.</p>
|
||||
|
||||
<p>We may consider and approve other link requests from the following types of organizations:</p>
|
||||
|
||||
<ul>
|
||||
<li>commonly-known consumer and/or business information sources;</li>
|
||||
<li>dot.com community sites;</li>
|
||||
<li>associations or other groups representing charities;</li>
|
||||
<li>online directory distributors;</li>
|
||||
<li>internet portals;</li>
|
||||
<li>accounting, law and consulting firms; and</li>
|
||||
<li>educational institutions and trade associations.</li>
|
||||
</ul>
|
||||
|
||||
<p>We will approve link requests from these organizations if we decide that: (a) the link would not make us look unfavorably to ourselves or to our accredited businesses; (b) the organization does not have any negative records with us; (c) the benefit to us from the visibility of the hyperlink compensates the absence of PHPNuxBill; and (d) the link is in the context of general resource information.</p>
|
||||
|
||||
<p>These organizations may link to our home page so long as the link: (a) is not in any way deceptive; (b) does not falsely imply sponsorship, endorsement or approval of the linking party and its products or services; and (c) fits within the context of the linking party's site.</p>
|
||||
|
||||
<p>If you are one of the organizations listed in paragraph 2 above and are interested in linking to our website, you must inform us by sending an e-mail to PHPNuxBill. Please include your name, your organization name, contact information as well as the URL of your site, a list of any URLs from which you intend to link to our Website, and a list of the URLs on our site to which you would like to link. Wait 2-3 weeks for a response.</p>
|
||||
|
||||
<p>Approved organizations may hyperlink to our Website as follows:</p>
|
||||
|
||||
<ul>
|
||||
<li>By use of our corporate name; or</li>
|
||||
<li>By use of the uniform resource locator being linked to; or</li>
|
||||
<li>By use of any other description of our Website being linked to that makes sense within the context and format of content on the linking party's site.</li>
|
||||
</ul>
|
||||
|
||||
<p>No use of PHPNuxBill's logo or other artwork will be allowed for linking absent a trademark license agreement.</p>
|
||||
|
||||
<h3><strong>iFrames</strong></h3>
|
||||
|
||||
<p>Without prior approval and written permission, you may not create frames around our Webpages that alter in any way the visual presentation or appearance of our Website.</p>
|
||||
|
||||
<h3><strong>Content Liability</strong></h3>
|
||||
|
||||
<p>We shall not be hold responsible for any content that appears on your Website. You agree to protect and defend us against all claims that is rising on your Website. No link(s) should appear on any Website that may be interpreted as libelous, obscene or criminal, or which infringes, otherwise violates, or advocates the infringement or other violation of, any third party rights.</p>
|
||||
|
||||
<h3><strong>Reservation of Rights</strong></h3>
|
||||
|
||||
<p>We reserve the right to request that you remove all links or any particular link to our Website. You approve to immediately remove all links to our Website upon request. We also reserve the right to amen these terms and conditions and it's linking policy at any time. By continuously linking to our Website, you agree to be bound to and follow these linking terms and conditions.</p>
|
||||
|
||||
<h3><strong>Removal of links from our website</strong></h3>
|
||||
|
||||
<p>If you find any link on our Website that is offensive for any reason, you are free to contact and inform us any moment. We will consider requests to remove links but we are not obligated to or so or to respond to you directly.</p>
|
||||
|
||||
<p>We do not ensure that the information on this website is correct, we do not warrant its completeness or accuracy; nor do we promise to ensure that the website remains available or that the material on the website is kept up to date.</p>
|
||||
|
||||
<h3><strong>Disclaimer</strong></h3>
|
||||
|
||||
<p>To the maximum extent permitted by applicable law, we exclude all representations, warranties and conditions relating to our website and the use of this website. Nothing in this disclaimer will:</p>
|
||||
|
||||
<ul>
|
||||
<li>limit or exclude our or your liability for death or personal injury;</li>
|
||||
<li>limit or exclude our or your liability for fraud or fraudulent misrepresentation;</li>
|
||||
<li>limit any of our or your liabilities in any way that is not permitted under applicable law; or</li>
|
||||
<li>exclude any of our or your liabilities that may not be excluded under applicable law.</li>
|
||||
</ul>
|
||||
|
||||
<p>The limitations and prohibitions of liability set in this Section and elsewhere in this disclaimer: (a) are subject to the preceding paragraph; and (b) govern all liabilities arising under the disclaimer, including liabilities arising in contract, in tort and for breach of statutory duty.</p>
|
||||
|
||||
<p>As long as the website and the information and services on the website are provided free of charge, we will not be liable for any loss or damage of any nature.</p>
|
27
pages_template/Voucher.html
Normal file
27
pages_template/Voucher.html
Normal file
@ -0,0 +1,27 @@
|
||||
<table border="0" cellspacing="0" cellpadding="2">
|
||||
<tr>
|
||||
<td valign="middle">
|
||||
<center><strong style="font-size:38px">[[company_name]]</strong></center>
|
||||
<table width="100%" border="1" cellspacing="0" cellpadding="1" bordercolor="#757575">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td rowspan="4" width="1">[[qrcode]]
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle" align="center" style="font-size:25px">
|
||||
[[price]]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle" align="center" style="font-size:20px">
|
||||
[[voucher_code]]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle" align="center" style="font-size:15px">
|
||||
[[plan]]</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
@ -4,14 +4,13 @@
|
||||
*
|
||||
* Config file, feel free to modify
|
||||
*/
|
||||
|
||||
|
||||
define('QR_CACHEABLE', true); // use cache - more disk reads but less CPU power, masks and format templates are stored there
|
||||
define('QR_CACHE_DIR', dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR); // used when QR_CACHEABLE === true
|
||||
define('QR_LOG_DIR', dirname(__FILE__).DIRECTORY_SEPARATOR); // default error logs dir
|
||||
|
||||
//define('QR_LOG_DIR', dirname(__FILE__).DIRECTORY_SEPARATOR); // default error logs dir
|
||||
|
||||
define('QR_FIND_BEST_MASK', true); // if true, estimates best mask (spec. default, but extremally slow; set to false to significant performance boost but (propably) worst quality code
|
||||
define('QR_FIND_FROM_RANDOM', false); // if false, checks all masks available, otherwise value tells count of masks need to be checked, mask id are got randomly
|
||||
define('QR_DEFAULT_MASK', 2); // when QR_FIND_BEST_MASK === false
|
||||
|
||||
|
||||
define('QR_PNG_MAXIMUM_SIZE', 1024); // maximum allowed png image width (in pixels), tune to make sure GD and PHP can handle such big images
|
||||
|
19
system/.htaccess
Normal file
19
system/.htaccess
Normal file
@ -0,0 +1,19 @@
|
||||
<Files *.php>
|
||||
Order Deny,Allow
|
||||
Deny from all
|
||||
</Files>
|
||||
|
||||
<Files cron.php>
|
||||
Order Allow,Deny
|
||||
Allow from all
|
||||
</Files>
|
||||
|
||||
<Files api.php>
|
||||
Order Allow,Deny
|
||||
Allow from all
|
||||
</Files>
|
||||
|
||||
<Files cron_reminder.php>
|
||||
Order Allow,Deny
|
||||
Allow from all
|
||||
</Files>
|
127
system/api.php
Normal file
127
system/api.php
Normal file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||
* by https://t.me/ibnux
|
||||
*
|
||||
* This File is for API Access
|
||||
**/
|
||||
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === "OPTIONS" || $_SERVER['REQUEST_METHOD'] === "HEAD") {
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method, Access-Control-Request-Headers, Authorization");
|
||||
header("HTTP/1.1 200 OK");
|
||||
die();
|
||||
}
|
||||
|
||||
$isApi = true;
|
||||
|
||||
include "../init.php";
|
||||
|
||||
// Dummy Class
|
||||
$ui = new class($key)
|
||||
{
|
||||
var $assign = [];
|
||||
function display($key)
|
||||
{
|
||||
global $req;
|
||||
showResult(true, $req, $this->getAll());
|
||||
}
|
||||
function assign($key, $value)
|
||||
{
|
||||
$this->assign[$key] = $value;
|
||||
}
|
||||
function get($key)
|
||||
{
|
||||
if (isset($this->assign[$key])) {
|
||||
return $this->assign[$key];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
function getTemplateVars($key)
|
||||
{
|
||||
if (isset($this->assign[$key])) {
|
||||
return $this->assign[$key];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
function getAll()
|
||||
{
|
||||
return $this->assign;
|
||||
}
|
||||
};
|
||||
|
||||
$req = _get('r');
|
||||
# a/c.id.time.md5
|
||||
# md5(a/c.id.time.$api_secret)
|
||||
$token = _req('token');
|
||||
$routes = explode('/', $req);
|
||||
$handler = $routes[0];
|
||||
|
||||
if (!empty($token)) {
|
||||
if ($token == $config['api_key']) {
|
||||
$admin = ORM::for_table('tbl_users')->where('user_type', 'SuperAdmin')->find_one($id);
|
||||
if (empty($admin)) {
|
||||
$admin = ORM::for_table('tbl_users')->where('user_type', 'Admin')->find_one($id);
|
||||
if (empty($admin)) {
|
||||
showResult(false, Lang::T("Token is invalid"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# validate token
|
||||
list($tipe, $uid, $time, $sha1) = explode('.', $token);
|
||||
if (trim($sha1) != sha1($uid . '.' . $time . '.' . $api_secret)) {
|
||||
showResult(false, Lang::T("Token is invalid"));
|
||||
}
|
||||
|
||||
#cek token expiration
|
||||
// 3 bulan
|
||||
if ($time != 0 && time() - $time > 7776000) {
|
||||
die("$time != " . (time() - $time));
|
||||
showResult(false, Lang::T("Token Expired"), [], ['login' => true]);
|
||||
}
|
||||
|
||||
if ($tipe == 'a') {
|
||||
$_SESSION['aid'] = $uid;
|
||||
$admin = Admin::_info();
|
||||
} else if ($tipe == 'c') {
|
||||
$_SESSION['uid'] = $uid;
|
||||
} else {
|
||||
showResult(false, Lang::T("Unknown Token"), [], ['login' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($handler) || empty($handler)) {
|
||||
showResult(true, Lang::T("Token is valid"));
|
||||
}
|
||||
|
||||
|
||||
if ($handler == 'isValid') {
|
||||
showResult(true, Lang::T("Token is valid"));
|
||||
}
|
||||
|
||||
if ($handler == 'me') {
|
||||
$admin = Admin::_info();
|
||||
if (!empty($admin['id'])) {
|
||||
showResult(true, "", $admin);
|
||||
} else {
|
||||
showResult(false, Lang::T("Token is invalid"));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
unset($_COOKIE);
|
||||
unset($_SESSION);
|
||||
}
|
||||
|
||||
try {
|
||||
$sys_render = File::pathFixer($root_path . 'system/controllers/' . $handler . '.php');
|
||||
if (file_exists($sys_render)) {
|
||||
include($sys_render);
|
||||
showResult(true, $req, $ui->getAll());
|
||||
} else {
|
||||
showResult(false, Lang::T('Command not found'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
showResult(false, $e->getMessage());
|
||||
}
|
@ -1,17 +1,61 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
|
||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||
* by https://t.me/ibnux
|
||||
**/
|
||||
|
||||
|
||||
* @copyright Copyright (C) 2014-2015 PHP Mikrotik Billing
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
class Admin
|
||||
{
|
||||
|
||||
**/
|
||||
|
||||
Class Admin{
|
||||
public static function _info(){
|
||||
$id = $_SESSION['aid'];
|
||||
$d = ORM::for_table('tbl_users')->find_one($id);
|
||||
return $d;
|
||||
public static function getID()
|
||||
{
|
||||
global $db_password;
|
||||
if (isset($_SESSION['aid'])) {
|
||||
return $_SESSION['aid'];
|
||||
} else if (isset($_COOKIE['aid'])) {
|
||||
// id.time.sha1
|
||||
$tmp = explode('.', $_COOKIE['aid']);
|
||||
if (sha1($tmp[0] . '.' . $tmp[1] . '.' . $db_password) == $tmp[2]) {
|
||||
if (time() - $tmp[1] < 86400 * 7) {
|
||||
$_SESSION['aid'] = $tmp[0];
|
||||
return $tmp[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static function setCookie($aid)
|
||||
{
|
||||
global $db_password;
|
||||
if (isset($aid)) {
|
||||
$time = time();
|
||||
$token = $aid . '.' . $time . '.' . sha1($aid . '.' . $time . '.' . $db_password);
|
||||
setcookie('aid', $token, time() + 86400 * 7);
|
||||
return $token;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
public static function removeCookie()
|
||||
{
|
||||
if (isset($_COOKIE['aid'])) {
|
||||
setcookie('aid', '', time() - 86400);
|
||||
}
|
||||
}
|
||||
|
||||
public static function _info($id = 0)
|
||||
{
|
||||
if (empty($id) && $id == 0) {
|
||||
$id = Admin::getID();
|
||||
}
|
||||
if ($id) {
|
||||
return ORM::for_table('tbl_users')->find_one($id);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
|
||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||
* by https://t.me/ibnux
|
||||
**/
|
||||
|
||||
|
||||
* @copyright Copyright (C) 2014-2015 PHP Mikrotik Billing
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
|
||||
**/
|
||||
|
||||
Class App{
|
||||
class App{
|
||||
public static function _run(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getToken(){
|
||||
return md5(microtime());
|
||||
}
|
||||
|
||||
public static function setToken($token, $value){
|
||||
$_SESSION[$token] = $value;
|
||||
}
|
||||
|
||||
public static function getTokenValue($key){
|
||||
if(isset($_SESSION[$key])){
|
||||
return $_SESSION[$key];
|
||||
}else{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
64
system/autoload/Balance.php
Normal file
64
system/autoload/Balance.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||
* by https://t.me/ibnux
|
||||
**/
|
||||
/**
|
||||
* This script is for managing user balance
|
||||
**/
|
||||
|
||||
class Balance
|
||||
{
|
||||
|
||||
public static function plus($id_customer, $amount)
|
||||
{
|
||||
$c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one();
|
||||
$c->balance = $amount + $c['balance'];
|
||||
$c->save();
|
||||
}
|
||||
|
||||
public static function transfer($id_customer, $phoneTarget, $amount)
|
||||
{
|
||||
global $config;
|
||||
if (Balance::min($id_customer, $amount)) {
|
||||
return Balance::plusByPhone($phoneTarget, $amount);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function min($id_customer, $amount)
|
||||
{
|
||||
$c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one();
|
||||
if ($c && $c['balance'] >= $amount) {
|
||||
$c->balance = $c['balance'] - $amount;
|
||||
$c->save();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function plusByPhone($phone_customer, $amount)
|
||||
{
|
||||
$c = ORM::for_table('tbl_customers')->where('username', $phone_customer)->find_one();
|
||||
if ($c) {
|
||||
$c->balance = $amount + $c['balance'];
|
||||
$c->save();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function minByPhone($phone_customer, $amount)
|
||||
{
|
||||
$c = ORM::for_table('tbl_customers')->where('username', $phone_customer)->find_one();
|
||||
if ($c && $c['balance'] >= $amount) {
|
||||
$c->balance = $c['balance'] - $amount;
|
||||
$c->save();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
108
system/autoload/File.php
Normal file
108
system/autoload/File.php
Normal file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||
* by https://t.me/ibnux
|
||||
**/
|
||||
class File
|
||||
{
|
||||
|
||||
public static function copyFolder($from, $to, $exclude = [])
|
||||
{
|
||||
$files = scandir($from);
|
||||
foreach ($files as $file) {
|
||||
if (is_file($from . $file) && !in_array($file, $exclude)) {
|
||||
if (file_exists($to . $file)) unlink($to . $file);
|
||||
rename($from . $file, $to . $file);
|
||||
} else if (is_dir($from . $file) && !in_array($file, ['.', '..'])) {
|
||||
if (!file_exists($to . $file)) {
|
||||
mkdir($to . $file);
|
||||
}
|
||||
File::copyFolder($from . $file . DIRECTORY_SEPARATOR, $to . $file . DIRECTORY_SEPARATOR, $exclude);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function deleteFolder($path)
|
||||
{
|
||||
$files = scandir($path);
|
||||
foreach ($files as $file) {
|
||||
if (is_file($path . $file)) {
|
||||
unlink($path . $file);
|
||||
} else if (is_dir($path . $file) && !in_array($file, ['.', '..'])) {
|
||||
File::deleteFolder($path . $file . DIRECTORY_SEPARATOR);
|
||||
rmdir($path . $file);
|
||||
}
|
||||
}
|
||||
rmdir($path);
|
||||
}
|
||||
|
||||
public static function resizeCropImage($source_file, $dst_dir, $max_width, $max_height, $quality = 80)
|
||||
{
|
||||
$imgsize = getimagesize($source_file);
|
||||
$width = $imgsize[0];
|
||||
$height = $imgsize[1];
|
||||
$mime = $imgsize['mime'];
|
||||
|
||||
switch ($mime) {
|
||||
case 'image/gif':
|
||||
$image_create = "imagecreatefromgif";
|
||||
$image = "imagegif";
|
||||
break;
|
||||
|
||||
case 'image/png':
|
||||
$image_create = "imagecreatefrompng";
|
||||
$image = "imagepng";
|
||||
$quality = 7;
|
||||
break;
|
||||
|
||||
case 'image/jpeg':
|
||||
$image_create = "imagecreatefromjpeg";
|
||||
$image = "imagejpeg";
|
||||
$quality = 80;
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
if ($max_width == 0) {
|
||||
$max_width = $width;
|
||||
}
|
||||
|
||||
if ($max_height == 0) {
|
||||
$max_height = $height;
|
||||
}
|
||||
|
||||
$widthRatio = $max_width / $width;
|
||||
$heightRatio = $max_height / $height;
|
||||
$ratio = min($widthRatio, $heightRatio);
|
||||
$nwidth = (int)$width * $ratio;
|
||||
$nheight = (int)$height * $ratio;
|
||||
|
||||
$dst_img = imagecreatetruecolor($nwidth, $nheight);
|
||||
$white = imagecolorallocate($dst_img, 255, 255, 255);
|
||||
imagefill($dst_img, 0, 0, $white);
|
||||
$src_img = $image_create($source_file);
|
||||
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nwidth, $nheight, $width, $height);
|
||||
|
||||
$image($dst_img, $dst_dir, $quality);
|
||||
|
||||
if ($dst_img) imagedestroy($dst_img);
|
||||
if ($src_img) imagedestroy($src_img);
|
||||
return file_exists($dst_dir);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* file path fixer
|
||||
*
|
||||
* @access public
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public static function pathFixer($path)
|
||||
{
|
||||
return str_replace("/", DIRECTORY_SEPARATOR, $path);
|
||||
}
|
||||
}
|
57
system/autoload/Hookers.php
Normal file
57
system/autoload/Hookers.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||
* by https://t.me/ibnux
|
||||
**/
|
||||
|
||||
$menu_registered = array();
|
||||
|
||||
/**
|
||||
* Register for global menu
|
||||
* @param string name Name of the menu
|
||||
* @param bool admin true if for admin and false for customer
|
||||
* @param string function function to run after menu clicks
|
||||
* @param string position position of menu, use AFTER_ for root menu |
|
||||
* Admin/Sales menu: AFTER_DASHBOARD, CUSTOMERS, PREPAID, SERVICES, REPORTS, VOUCHER, AFTER_ORDER, NETWORK, SETTINGS, AFTER_PAYMENTGATEWAY
|
||||
* | Customer menu: AFTER_DASHBOARD, ORDER, HISTORY, ACCOUNTS
|
||||
* @param string icon from ion icon, ion-person, only for AFTER_
|
||||
* @param string label for showing label or number of notification or update
|
||||
* @param string color Label color
|
||||
* @param string auth authorization ['SuperAdmin', 'Admin', 'Report', 'Agent', 'Sales'] will only show in this user, empty array for all users
|
||||
*/
|
||||
function register_menu($name, $admin, $function, $position, $icon = '', $label = '', $color = 'success', $auth = [])
|
||||
{
|
||||
global $menu_registered;
|
||||
$menu_registered[] = [
|
||||
"name" => $name,
|
||||
"admin" => $admin,
|
||||
"position" => $position,
|
||||
"icon" => $icon,
|
||||
"function" => $function,
|
||||
"label" => $label,
|
||||
"color" => $color,
|
||||
"auth" => $auth
|
||||
];
|
||||
}
|
||||
|
||||
$hook_registered = array();
|
||||
|
||||
function register_hook($action, $function){
|
||||
global $hook_registered;
|
||||
$hook_registered[] = [
|
||||
'action' => $action,
|
||||
'function' => $function
|
||||
];
|
||||
}
|
||||
|
||||
function run_hook($action){
|
||||
global $hook_registered;
|
||||
foreach($hook_registered as $hook){
|
||||
if($hook['action'] == $action){
|
||||
if(function_exists($hook['function'])){
|
||||
call_user_func($hook['function']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
117
system/autoload/Http.php
Normal file
117
system/autoload/Http.php
Normal file
@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||
* by https://t.me/ibnux
|
||||
**/
|
||||
|
||||
/**
|
||||
* using proxy, add this variable in config.php
|
||||
* $http_proxy = '127.0.0.1:3128';
|
||||
* if proxy using authentication, use this parameter
|
||||
* $http_proxyauth = 'user:password';
|
||||
**/
|
||||
|
||||
class Http
|
||||
{
|
||||
public static function getData($url, $headers = [])
|
||||
{
|
||||
global $http_proxy, $http_proxyauth, $admin;
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, 0);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
|
||||
if(is_array($headers) && count($headers)>0){
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
if (!empty($http_proxy)) {
|
||||
curl_setopt($ch, CURLOPT_PROXY, $http_proxy);
|
||||
if (!empty($http_proxyauth)) {
|
||||
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $http_proxyauth);
|
||||
}
|
||||
}
|
||||
$server_output = curl_exec($ch);
|
||||
if (curl_errno($ch)) {
|
||||
$error_msg = curl_error($ch);
|
||||
}
|
||||
curl_close($ch);
|
||||
if($admin && $error_msg){
|
||||
r2(U . 'dashboard', 'd', $error_msg);
|
||||
}
|
||||
return ($server_output) ? $server_output : $error_msg;
|
||||
}
|
||||
|
||||
public static function postJsonData($url, $array_post, $headers = [], $basic = null)
|
||||
{
|
||||
global $http_proxy, $http_proxyauth, $admin;
|
||||
$headers[] = 'Content-Type: application/json';
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
|
||||
curl_setopt($ch, CURLOPT_VERBOSE, false);
|
||||
curl_setopt($ch, CURLINFO_HEADER_OUT, false);
|
||||
if (!empty($http_proxy)) {
|
||||
curl_setopt($ch, CURLOPT_PROXY, $http_proxy);
|
||||
if (!empty($http_proxyauth)) {
|
||||
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $http_proxyauth);
|
||||
}
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($array_post));
|
||||
if(is_array($headers) && count($headers)>0){
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
}
|
||||
if (!empty($basic)) {
|
||||
curl_setopt($ch, CURLOPT_USERPWD, $basic);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$server_output = curl_exec($ch);
|
||||
if (curl_errno($ch)) {
|
||||
$error_msg = curl_error($ch);
|
||||
}
|
||||
curl_close($ch);
|
||||
if($admin && $error_msg){
|
||||
r2(U . 'dashboard', 'd', $error_msg);
|
||||
}
|
||||
return ($server_output) ? $server_output : $error_msg;
|
||||
}
|
||||
|
||||
|
||||
public static function postData($url, $array_post, $headers = [], $basic = null)
|
||||
{
|
||||
global $http_proxy, $http_proxyauth, $admin;
|
||||
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
|
||||
curl_setopt($ch, CURLOPT_VERBOSE, false);
|
||||
curl_setopt($ch, CURLINFO_HEADER_OUT, false);
|
||||
if (!empty($http_proxy)) {
|
||||
curl_setopt($ch, CURLOPT_PROXY, $http_proxy);
|
||||
if (!empty($http_proxyauth)) {
|
||||
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $http_proxyauth);
|
||||
}
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array_post));
|
||||
if(is_array($headers) && count($headers)>0){
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
}
|
||||
if (!empty($basic)) {
|
||||
curl_setopt($ch, CURLOPT_USERPWD, $basic);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$server_output = curl_exec($ch);
|
||||
if (curl_errno($ch)) {
|
||||
$error_msg = curl_error($ch);
|
||||
}
|
||||
curl_close($ch);
|
||||
if($admin && $error_msg){
|
||||
r2(U . 'dashboard', 'd', $error_msg);
|
||||
}
|
||||
return ($server_output) ? $server_output : $error_msg;
|
||||
}
|
||||
}
|
248
system/autoload/Lang.php
Normal file
248
system/autoload/Lang.php
Normal file
@ -0,0 +1,248 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||
* by https://t.me/ibnux
|
||||
**/
|
||||
|
||||
|
||||
class Lang
|
||||
{
|
||||
public static function T($key)
|
||||
{
|
||||
global $_L, $lan_file, $config;
|
||||
if(is_array($_SESSION['Lang'])){
|
||||
$_L = array_merge($_L, $_SESSION['Lang']);
|
||||
}
|
||||
$key = preg_replace('/\s+/', ' ', $key);
|
||||
if (!empty($_L[$key])) {
|
||||
return $_L[$key];
|
||||
}
|
||||
$val = $key;
|
||||
$key = Lang::sanitize($key);
|
||||
if (isset($_L[$key])) {
|
||||
return $_L[$key];
|
||||
} else if (isset($_L[$key])) {
|
||||
return $_L[$key];
|
||||
} else {
|
||||
$iso = Lang::getIsoLang()[$config['language']];
|
||||
if (empty($iso)) {
|
||||
return $val;
|
||||
}
|
||||
if (!empty($iso) && !empty($val)) {
|
||||
$temp = Lang::translate($val, $iso);
|
||||
if (!empty($temp)) {
|
||||
$val = $temp;
|
||||
}
|
||||
}
|
||||
$_L[$key] = $val;
|
||||
$_SESSION['Lang'][$key] = $val;
|
||||
file_put_contents($lan_file, json_encode($_SESSION['Lang'], JSON_PRETTY_PRINT));
|
||||
return $val;
|
||||
}
|
||||
}
|
||||
|
||||
public static function sanitize($str)
|
||||
{
|
||||
return preg_replace("/[^A-Za-z0-9]/", '_', $str);;
|
||||
}
|
||||
|
||||
public static function getIsoLang()
|
||||
{
|
||||
global $isolang;
|
||||
if (empty($isolang) || count($isolang) == 0) {
|
||||
$isolang = json_decode(file_get_contents(File::pathFixer("system/lan/country.json")), true);
|
||||
}
|
||||
return $isolang;
|
||||
}
|
||||
|
||||
public static function htmlspecialchars($var)
|
||||
{
|
||||
return htmlspecialchars($var);
|
||||
}
|
||||
|
||||
public static function moneyFormat($var)
|
||||
{
|
||||
global $config;
|
||||
return $config['currency_code'] . ' ' . number_format($var, 0, $config['dec_point'], $config['thousands_sep']);
|
||||
}
|
||||
|
||||
public static function phoneFormat($phone)
|
||||
{
|
||||
global $config;
|
||||
if (Validator::UnsignedNumber($phone) && !empty($config['country_code_phone'])) {
|
||||
return preg_replace('/^0/', $config['country_code_phone'], $phone);
|
||||
} else {
|
||||
return $phone;
|
||||
}
|
||||
}
|
||||
|
||||
public static function dateFormat($date)
|
||||
{
|
||||
global $config;
|
||||
return date($config['date_format'], strtotime($date));
|
||||
}
|
||||
|
||||
public static function dateTimeFormat($date)
|
||||
{
|
||||
global $config;
|
||||
if (strtotime($date) < strtotime("2000-01-01 00:00:00")) {
|
||||
return "";
|
||||
} else {
|
||||
return date($config['date_format'] . ' H:i', strtotime($date));
|
||||
}
|
||||
}
|
||||
|
||||
public static function dateAndTimeFormat($date, $time)
|
||||
{
|
||||
global $config;
|
||||
return date($config['date_format'] . ' H:i', strtotime("$date $time"));
|
||||
}
|
||||
|
||||
public static function timeElapsed($datetime, $full = false)
|
||||
{
|
||||
$now = new DateTime;
|
||||
$ago = new DateTime($datetime);
|
||||
$diff = $now->diff($ago);
|
||||
|
||||
$diff->w = floor($diff->d / 7);
|
||||
$diff->d -= $diff->w * 7;
|
||||
|
||||
$string = array(
|
||||
'y' => Lang::T('year'),
|
||||
'm' => Lang::T('month'),
|
||||
'w' => Lang::T('week'),
|
||||
'd' => Lang::T('day'),
|
||||
'h' => Lang::T('hour'),
|
||||
'i' => Lang::T('minute'),
|
||||
's' => Lang::T('second'),
|
||||
);
|
||||
foreach ($string as $k => &$v) {
|
||||
if ($diff->$k) {
|
||||
$v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : '');
|
||||
} else {
|
||||
unset($string[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$full)
|
||||
$string = array_slice($string, 0, 1);
|
||||
return $string ? implode(', ', $string) . ' ago' : 'just now';
|
||||
}
|
||||
|
||||
public static function nl2br($text)
|
||||
{
|
||||
return nl2br($text);
|
||||
}
|
||||
|
||||
public static function arrayCount($arr)
|
||||
{
|
||||
if (is_array($arr)) {
|
||||
return count($arr);
|
||||
} else if (is_object($arr)) {
|
||||
return count($arr);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getNotifText($key)
|
||||
{
|
||||
global $_notifmsg, $_notifmsg_default;
|
||||
if (isset($_notifmsg[$key])) {
|
||||
return $_notifmsg[$key];
|
||||
} else {
|
||||
return $_notifmsg_default[$key];
|
||||
}
|
||||
}
|
||||
|
||||
public static function ucWords($text)
|
||||
{
|
||||
return ucwords(str_replace('_', ' ', $text));
|
||||
}
|
||||
|
||||
public static function randomUpLowCase($text)
|
||||
{
|
||||
$jml = strlen($text);
|
||||
$result = '';
|
||||
for ($i = 0; $i < $jml; $i++) {
|
||||
if (rand(0, 99) % 2) {
|
||||
$result .= strtolower(substr($text, $i, 1));
|
||||
} else {
|
||||
$result .= substr($text, $i, 1);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* $pad_type
|
||||
* 0 Left
|
||||
* 1 right
|
||||
* 2 center
|
||||
* */
|
||||
public static function pad($text, $pad_string = ' ', $pad_type = 0)
|
||||
{
|
||||
global $config;
|
||||
$cols = 37;
|
||||
if ($config['printer_cols']) {
|
||||
$cols = $config['printer_cols'];
|
||||
}
|
||||
$text = trim($text);
|
||||
$texts = explode("\n", $text);
|
||||
if (count($texts) > 1) {
|
||||
$text = '';
|
||||
foreach ($texts as $t) {
|
||||
$text .= self::pad(trim($t), $pad_string, $pad_type) . "\n";
|
||||
}
|
||||
return $text;
|
||||
} else {
|
||||
return str_pad(trim($text), $cols, $pad_string, $pad_type);
|
||||
}
|
||||
}
|
||||
|
||||
public static function pads($textLeft, $textRight, $pad_string = ' ')
|
||||
{
|
||||
global $config;
|
||||
$cols = 37;
|
||||
if ($config['printer_cols']) {
|
||||
$cols = $config['printer_cols'];
|
||||
}
|
||||
return $textLeft . str_pad($textRight, $cols - strlen($textLeft), $pad_string, 0);
|
||||
}
|
||||
|
||||
public static function translate($txt, $to = 'id')
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, "https://translate.google.com/m?hl=en&sl=en&tl=$to&ie=UTF-8&prev=_m&q=" . urlencode($txt));
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; CPU OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/28.1 Mobile/15E148 Safari/605.1.15");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
$hasil = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
$temp = explode('<div class="result-container">', $hasil);
|
||||
if (count($temp) > 0) {
|
||||
$temp = explode("</div", $temp[1]);
|
||||
if (!empty($temp[0])) {
|
||||
return $temp[0];
|
||||
}
|
||||
}
|
||||
return $txt;
|
||||
}
|
||||
|
||||
public static function maskText($text){
|
||||
$len = strlen($text);
|
||||
if($len < 3){
|
||||
return "***";
|
||||
}else if($len<5){
|
||||
return substr($text,0,1)."***".substr($text,-1,1);
|
||||
}else if($len<8){
|
||||
return substr($text,0,2)."***".substr($text,-2,2);
|
||||
}else{
|
||||
return substr($text,0,4)."******".substr($text,-3,3);
|
||||
}
|
||||
}
|
||||
}
|
32
system/autoload/Log.php
Normal file
32
system/autoload/Log.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||
* by https://t.me/ibnux
|
||||
**/
|
||||
|
||||
|
||||
class Log{
|
||||
public static function put($type, $description, $userid = '', $username = '')
|
||||
{
|
||||
$d = ORM::for_table('tbl_logs')->create();
|
||||
$d->date = date('Y-m-d H:i:s');
|
||||
$d->type = $type;
|
||||
$d->description = $description;
|
||||
$d->userid = $userid;
|
||||
$d->ip = (empty($username)) ? $_SERVER["REMOTE_ADDR"] : $username;
|
||||
$d->save();
|
||||
}
|
||||
|
||||
public static function arrayToText($array, $start = '', $result = '')
|
||||
{
|
||||
foreach ($array as $k => $v) {
|
||||
if (is_array($v)) {
|
||||
$result = Log::arrayToText($v, "$start$k.", $result);
|
||||
} else {
|
||||
$result .= $start.$k ." : ". strval($v) ."\n";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
212
system/autoload/Message.php
Normal file
212
system/autoload/Message.php
Normal file
@ -0,0 +1,212 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||
* by https://t.me/ibnux
|
||||
**/
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
use PHPMailer\PHPMailer\SMTP;
|
||||
require $root_path . 'system/autoload/mail/Exception.php';
|
||||
require $root_path . 'system/autoload/mail/PHPMailer.php';
|
||||
require $root_path . 'system/autoload/mail/SMTP.php';
|
||||
|
||||
class Message
|
||||
{
|
||||
|
||||
public static function sendTelegram($txt)
|
||||
{
|
||||
global $config;
|
||||
run_hook('send_telegram'); #HOOK
|
||||
if (!empty($config['telegram_bot']) && !empty($config['telegram_target_id'])) {
|
||||
return Http::getData('https://api.telegram.org/bot' . $config['telegram_bot'] . '/sendMessage?chat_id=' . $config['telegram_target_id'] . '&text=' . urlencode($txt));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function sendSMS($phone, $txt)
|
||||
{
|
||||
global $config;
|
||||
if(empty($txt)){
|
||||
return "";
|
||||
}
|
||||
run_hook('send_sms'); #HOOK
|
||||
if (!empty($config['sms_url'])) {
|
||||
if (strlen($config['sms_url']) > 4 && substr($config['sms_url'], 0, 4) != "http") {
|
||||
if (strlen($txt) > 160) {
|
||||
$txts = str_split($txt, 160);
|
||||
try {
|
||||
$mikrotik = Mikrotik::info($config['sms_url']);
|
||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||
foreach ($txts as $txt) {
|
||||
Mikrotik::sendSMS($client, $phone, $txt);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// ignore, add to logs
|
||||
_log("Failed to send SMS using Mikrotik.\n" . $e->getMessage(), 'SMS', 0);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$mikrotik = Mikrotik::info($config['sms_url']);
|
||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||
Mikrotik::sendSMS($client, $phone, $txt);
|
||||
} catch (Exception $e) {
|
||||
// ignore, add to logs
|
||||
_log("Failed to send SMS using Mikrotik.\n" . $e->getMessage(), 'SMS', 0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$smsurl = str_replace('[number]', urlencode($phone), $config['sms_url']);
|
||||
$smsurl = str_replace('[text]', urlencode($txt), $smsurl);
|
||||
return Http::getData($smsurl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendWhatsapp($phone, $txt)
|
||||
{
|
||||
global $config;
|
||||
if(empty($txt)){
|
||||
return "";
|
||||
}
|
||||
run_hook('send_whatsapp'); #HOOK
|
||||
if (!empty($config['wa_url'])) {
|
||||
$waurl = str_replace('[number]', urlencode(Lang::phoneFormat($phone)), $config['wa_url']);
|
||||
$waurl = str_replace('[text]', urlencode($txt), $waurl);
|
||||
return Http::getData($waurl);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendEmail($to, $subject, $body)
|
||||
{
|
||||
global $config;
|
||||
if(empty($body)){
|
||||
return "";
|
||||
}
|
||||
run_hook('send_email'); #HOOK
|
||||
if (empty($config['smtp_host'])) {
|
||||
$attr = "";
|
||||
if (!empty($config['mail_from'])) {
|
||||
$attr .= "From: " . $config['mail_from'] . "\r\n";
|
||||
}
|
||||
if (!empty($config['mail_reply_to'])) {
|
||||
$attr .= "Reply-To: " . $config['mail_reply_to'] . "\r\n";
|
||||
}
|
||||
mail($to, $subject, $body, $attr);
|
||||
} else {
|
||||
$mail = new PHPMailer();
|
||||
$mail->isSMTP();
|
||||
$mail->SMTPDebug = SMTP::DEBUG_SERVER;
|
||||
$mail->Host = $config['smtp_host'];
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = $config['smtp_user'];
|
||||
$mail->Password = $config['smtp_pass'];
|
||||
$mail->SMTPSecure = $config['smtp_ssltls'];
|
||||
$mail->Port = $config['smtp_port'];
|
||||
if (!empty($config['mail_from'])) {
|
||||
$mail->setFrom($config['mail_from']);
|
||||
}
|
||||
if (!empty($config['mail_reply_to'])) {
|
||||
$mail->addReplyTo($config['mail_reply_to']);
|
||||
}
|
||||
$mail->isHTML(false);
|
||||
$mail->addAddress($to);
|
||||
$mail->Subject = $subject;
|
||||
$mail->Body = $body;
|
||||
$mail->send();
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendPackageNotification($customer, $package, $price, $message, $via)
|
||||
{
|
||||
global $ds;
|
||||
if(empty($message)){
|
||||
return "";
|
||||
}
|
||||
$msg = str_replace('[[name]]', $customer['fullname'], $message);
|
||||
$msg = str_replace('[[username]]', $customer['username'], $msg);
|
||||
$msg = str_replace('[[plan]]', $package, $msg);
|
||||
$msg = str_replace('[[package]]', $package, $msg);
|
||||
$msg = str_replace('[[price]]', Lang::moneyFormat($price), $msg);
|
||||
list($bills, $add_cost) = User::getBills($customer['id']);
|
||||
if($add_cost>0){
|
||||
$note = "";
|
||||
foreach ($bills as $k => $v) {
|
||||
$note .= $k . " : " . Lang::moneyFormat($v) . "\n";
|
||||
}
|
||||
$note .= "Total : " . Lang::moneyFormat($add_cost+$price) . "\n";
|
||||
$msg = str_replace('[[bills]]', $note, $msg);
|
||||
}else{
|
||||
$msg = str_replace('[[bills]]', '', $msg);
|
||||
}
|
||||
if ($ds) {
|
||||
$msg = str_replace('[[expired_date]]', Lang::dateAndTimeFormat($ds['expiration'], $ds['time']), $msg);
|
||||
}else{
|
||||
$msg = str_replace('[[expired_date]]', "", $msg);
|
||||
}
|
||||
if (
|
||||
!empty($customer['phonenumber']) && strlen($customer['phonenumber']) > 5
|
||||
&& !empty($message) && in_array($via, ['sms', 'wa'])
|
||||
) {
|
||||
if ($via == 'sms') {
|
||||
echo Message::sendSMS($customer['phonenumber'], $msg);
|
||||
} else if ($via == 'wa') {
|
||||
echo Message::sendWhatsapp($customer['phonenumber'], $msg);
|
||||
}
|
||||
}
|
||||
return "$via: $msg";
|
||||
}
|
||||
|
||||
public static function sendBalanceNotification($phone, $name, $balance, $balance_now, $message, $via)
|
||||
{
|
||||
$msg = str_replace('[[name]]', $name, $message);
|
||||
$msg = str_replace('[[current_balance]]', Lang::moneyFormat($balance_now), $msg);
|
||||
$msg = str_replace('[[balance]]', Lang::moneyFormat($balance), $msg);
|
||||
if (
|
||||
!empty($phone) && strlen($phone) > 5
|
||||
&& !empty($message) && in_array($via, ['sms', 'wa'])
|
||||
) {
|
||||
if ($via == 'sms') {
|
||||
Message::sendSMS($phone, $msg);
|
||||
} else if ($via == 'wa') {
|
||||
Message::sendWhatsapp($phone, $msg);
|
||||
}
|
||||
}
|
||||
return "$via: $msg";
|
||||
}
|
||||
|
||||
public static function sendInvoice($cust, $trx)
|
||||
{
|
||||
global $config;
|
||||
$textInvoice = Lang::getNotifText('invoice_paid');
|
||||
$textInvoice = str_replace('[[company_name]]', $config['CompanyName'], $textInvoice);
|
||||
$textInvoice = str_replace('[[address]]', $config['address'], $textInvoice);
|
||||
$textInvoice = str_replace('[[phone]]', $config['phone'], $textInvoice);
|
||||
$textInvoice = str_replace('[[invoice]]', $trx['invoice'], $textInvoice);
|
||||
$textInvoice = str_replace('[[date]]', Lang::dateAndTimeFormat($trx['recharged_on'], $trx['recharged_time']), $textInvoice);
|
||||
if (!empty($trx['note'])) {
|
||||
$textInvoice = str_replace('[[note]]', $trx['note'], $textInvoice);
|
||||
}
|
||||
$gc = explode("-", $trx['method']);
|
||||
$textInvoice = str_replace('[[payment_gateway]]', trim($gc[0]), $textInvoice);
|
||||
$textInvoice = str_replace('[[payment_channel]]', trim($gc[1]), $textInvoice);
|
||||
$textInvoice = str_replace('[[type]]', $trx['type'], $textInvoice);
|
||||
$textInvoice = str_replace('[[plan_name]]', $trx['plan_name'], $textInvoice);
|
||||
$textInvoice = str_replace('[[plan_price]]', Lang::moneyFormat($trx['price']), $textInvoice);
|
||||
$textInvoice = str_replace('[[name]]', $cust['fullname'], $textInvoice);
|
||||
$textInvoice = str_replace('[[note]]', $cust['note'], $textInvoice);
|
||||
$textInvoice = str_replace('[[user_name]]', $trx['username'], $textInvoice);
|
||||
$textInvoice = str_replace('[[user_password]]', $cust['password'], $textInvoice);
|
||||
$textInvoice = str_replace('[[username]]', $trx['username'], $textInvoice);
|
||||
$textInvoice = str_replace('[[password]]', $cust['password'], $textInvoice);
|
||||
$textInvoice = str_replace('[[expired_date]]', Lang::dateAndTimeFormat($trx['expiration'], $trx['time']), $textInvoice);
|
||||
$textInvoice = str_replace('[[footer]]', $config['note'], $textInvoice);
|
||||
|
||||
if ($config['user_notification_payment'] == 'sms') {
|
||||
Message::sendSMS($cust['phonenumber'], $textInvoice);
|
||||
} else if ($config['user_notification_payment'] == 'wa') {
|
||||
Message::sendWhatsapp($cust['phonenumber'], $textInvoice);
|
||||
}
|
||||
}
|
||||
}
|
562
system/autoload/Mikrotik.php
Normal file
562
system/autoload/Mikrotik.php
Normal file
@ -0,0 +1,562 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||
* by https://t.me/ibnux
|
||||
**/
|
||||
|
||||
use PEAR2\Net\RouterOS;
|
||||
|
||||
class Mikrotik
|
||||
{
|
||||
public static function info($name)
|
||||
{
|
||||
return ORM::for_table('tbl_routers')->where('name', $name)->find_one();
|
||||
}
|
||||
|
||||
public static function getClient($ip, $user, $pass)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$iport = explode(":", $ip);
|
||||
return new RouterOS\Client($iport[0], $user, $pass, ($iport[1]) ? $iport[1] : null);
|
||||
}
|
||||
|
||||
public static function isUserLogin($client, $username)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$printRequest = new RouterOS\Request(
|
||||
'/ip hotspot active print',
|
||||
RouterOS\Query::where('user', $username)
|
||||
);
|
||||
return $client->sendSync($printRequest)->getProperty('.id');
|
||||
}
|
||||
|
||||
public static function logMeIn($client, $user, $pass, $ip, $mac)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$addRequest = new RouterOS\Request('/ip/hotspot/active/login');
|
||||
$client->sendSync(
|
||||
$addRequest
|
||||
->setArgument('user', $user)
|
||||
->setArgument('password', $pass)
|
||||
->setArgument('ip', $ip)
|
||||
->setArgument('mac-address', $mac)
|
||||
);
|
||||
}
|
||||
|
||||
public static function logMeOut($client, $user)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$printRequest = new RouterOS\Request(
|
||||
'/ip hotspot active print',
|
||||
RouterOS\Query::where('user', $user)
|
||||
);
|
||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
||||
$removeRequest = new RouterOS\Request('/ip/hotspot/active/remove');
|
||||
$client->sendSync(
|
||||
$removeRequest
|
||||
->setArgument('numbers', $id)
|
||||
);
|
||||
}
|
||||
|
||||
public static function addHotspotPlan($client, $name, $sharedusers, $rate)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/profile/add');
|
||||
$client->sendSync(
|
||||
$addRequest
|
||||
->setArgument('name', $name)
|
||||
->setArgument('shared-users', $sharedusers)
|
||||
->setArgument('rate-limit', $rate)
|
||||
);
|
||||
}
|
||||
|
||||
public static function setHotspotPlan($client, $name, $sharedusers, $rate)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$printRequest = new RouterOS\Request(
|
||||
'/ip hotspot user profile print .proplist=.id',
|
||||
RouterOS\Query::where('name', $name)
|
||||
);
|
||||
$profileID = $client->sendSync($printRequest)->getProperty('.id');
|
||||
if (empty($profileID)) {
|
||||
Mikrotik::addHotspotPlan($client, $name, $sharedusers, $rate);
|
||||
} else {
|
||||
$setRequest = new RouterOS\Request('/ip/hotspot/user/profile/set');
|
||||
$client->sendSync(
|
||||
$setRequest
|
||||
->setArgument('numbers', $profileID)
|
||||
->setArgument('shared-users', $sharedusers)
|
||||
->setArgument('rate-limit', $rate)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static function setHotspotExpiredPlan($client, $name, $pool)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$printRequest = new RouterOS\Request(
|
||||
'/ip hotspot user profile print .proplist=.id',
|
||||
RouterOS\Query::where('name', $name)
|
||||
);
|
||||
$profileID = $client->sendSync($printRequest)->getProperty('.id');
|
||||
if (empty($profileID)) {
|
||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/profile/add');
|
||||
$client->sendSync(
|
||||
$addRequest
|
||||
->setArgument('name', $name)
|
||||
->setArgument('shared-users', 3)
|
||||
->setArgument('address-pool', $pool)
|
||||
->setArgument('rate-limit', '512K/512K')
|
||||
);
|
||||
} else {
|
||||
$setRequest = new RouterOS\Request('/ip/hotspot/user/profile/set');
|
||||
$client->sendSync(
|
||||
$setRequest
|
||||
->setArgument('numbers', $profileID)
|
||||
->setArgument('shared-users', 3)
|
||||
->setArgument('address-pool', $pool)
|
||||
->setArgument('rate-limit', '512K/512K')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static function removeHotspotPlan($client, $name)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$printRequest = new RouterOS\Request(
|
||||
'/ip hotspot user profile print .proplist=.id',
|
||||
RouterOS\Query::where('name', $name)
|
||||
);
|
||||
$profileID = $client->sendSync($printRequest)->getProperty('.id');
|
||||
|
||||
$removeRequest = new RouterOS\Request('/ip/hotspot/user/profile/remove');
|
||||
$client->sendSync(
|
||||
$removeRequest
|
||||
->setArgument('numbers', $profileID)
|
||||
);
|
||||
}
|
||||
|
||||
public static function removeHotspotUser($client, $username)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$printRequest = new RouterOS\Request(
|
||||
'/ip hotspot user print .proplist=.id',
|
||||
RouterOS\Query::where('name', $username)
|
||||
);
|
||||
$userID = $client->sendSync($printRequest)->getProperty('.id');
|
||||
$removeRequest = new RouterOS\Request('/ip/hotspot/user/remove');
|
||||
$client->sendSync(
|
||||
$removeRequest
|
||||
->setArgument('numbers', $userID)
|
||||
);
|
||||
}
|
||||
|
||||
public static function addHotspotUser($client, $plan, $customer)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
||||
if ($plan['typebp'] == "Limited") {
|
||||
if ($plan['limit_type'] == "Time_Limit") {
|
||||
if ($plan['time_unit'] == 'Hrs')
|
||||
$timelimit = $plan['time_limit'] . ":00:00";
|
||||
else
|
||||
$timelimit = "00:" . $plan['time_limit'] . ":00";
|
||||
$client->sendSync(
|
||||
$addRequest
|
||||
->setArgument('name', $customer['username'])
|
||||
->setArgument('profile', $plan['name_plan'])
|
||||
->setArgument('password', $customer['password'])
|
||||
->setArgument('comment', $customer['fullname'])
|
||||
->setArgument('email', $customer['email'])
|
||||
->setArgument('limit-uptime', $timelimit)
|
||||
);
|
||||
} else if ($plan['limit_type'] == "Data_Limit") {
|
||||
if ($plan['data_unit'] == 'GB')
|
||||
$datalimit = $plan['data_limit'] . "000000000";
|
||||
else
|
||||
$datalimit = $plan['data_limit'] . "000000";
|
||||
$client->sendSync(
|
||||
$addRequest
|
||||
->setArgument('name', $customer['username'])
|
||||
->setArgument('profile', $plan['name_plan'])
|
||||
->setArgument('password', $customer['password'])
|
||||
->setArgument('comment', $customer['fullname'])
|
||||
->setArgument('email', $customer['email'])
|
||||
->setArgument('limit-bytes-total', $datalimit)
|
||||
);
|
||||
} else if ($plan['limit_type'] == "Both_Limit") {
|
||||
if ($plan['time_unit'] == 'Hrs')
|
||||
$timelimit = $plan['time_limit'] . ":00:00";
|
||||
else
|
||||
$timelimit = "00:" . $plan['time_limit'] . ":00";
|
||||
if ($plan['data_unit'] == 'GB')
|
||||
$datalimit = $plan['data_limit'] . "000000000";
|
||||
else
|
||||
$datalimit = $plan['data_limit'] . "000000";
|
||||
$client->sendSync(
|
||||
$addRequest
|
||||
->setArgument('name', $customer['username'])
|
||||
->setArgument('profile', $plan['name_plan'])
|
||||
->setArgument('password', $customer['password'])
|
||||
->setArgument('comment', $customer['fullname'])
|
||||
->setArgument('email', $customer['email'])
|
||||
->setArgument('limit-uptime', $timelimit)
|
||||
->setArgument('limit-bytes-total', $datalimit)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$client->sendSync(
|
||||
$addRequest
|
||||
->setArgument('name', $customer['username'])
|
||||
->setArgument('profile', $plan['name_plan'])
|
||||
->setArgument('comment', $customer['fullname'])
|
||||
->setArgument('email', $customer['email'])
|
||||
->setArgument('password', $customer['password'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static function setHotspotUser($client, $user, $pass)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
|
||||
$printRequest->setArgument('.proplist', '.id');
|
||||
$printRequest->setQuery(RouterOS\Query::where('name', $user));
|
||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
||||
|
||||
$setRequest = new RouterOS\Request('/ip/hotspot/user/set');
|
||||
$setRequest->setArgument('numbers', $id);
|
||||
$setRequest->setArgument('password', $pass);
|
||||
$client->sendSync($setRequest);
|
||||
}
|
||||
|
||||
public static function setHotspotUserPackage($client, $user, $plan)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
|
||||
$printRequest->setArgument('.proplist', '.id');
|
||||
$printRequest->setQuery(RouterOS\Query::where('name', $user));
|
||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
||||
|
||||
$setRequest = new RouterOS\Request('/ip/hotspot/user/set');
|
||||
$setRequest->setArgument('numbers', $id);
|
||||
$setRequest->setArgument('profile', $plan);
|
||||
$client->sendSync($setRequest);
|
||||
}
|
||||
|
||||
public static function removeHotspotActiveUser($client, $username)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$onlineRequest = new RouterOS\Request('/ip/hotspot/active/print');
|
||||
$onlineRequest->setArgument('.proplist', '.id');
|
||||
$onlineRequest->setQuery(RouterOS\Query::where('user', $username));
|
||||
$id = $client->sendSync($onlineRequest)->getProperty('.id');
|
||||
|
||||
$removeRequest = new RouterOS\Request('/ip/hotspot/active/remove');
|
||||
$removeRequest->setArgument('numbers', $id);
|
||||
$client->sendSync($removeRequest);
|
||||
}
|
||||
|
||||
public static function removePpoeUser($client, $username)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$printRequest = new RouterOS\Request('/ppp/secret/print');
|
||||
//$printRequest->setArgument('.proplist', '.id');
|
||||
$printRequest->setQuery(RouterOS\Query::where('name', $username));
|
||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
||||
$removeRequest = new RouterOS\Request('/ppp/secret/remove');
|
||||
$removeRequest->setArgument('numbers', $id);
|
||||
$client->sendSync($removeRequest);
|
||||
}
|
||||
|
||||
public static function addPpoeUser($client, $plan, $customer)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$addRequest = new RouterOS\Request('/ppp/secret/add');
|
||||
if (!empty($customer['pppoe_password'])) {
|
||||
$pass = $customer['pppoe_password'];
|
||||
} else {
|
||||
$pass = $customer['password'];
|
||||
}
|
||||
$client->sendSync(
|
||||
$addRequest
|
||||
->setArgument('name', $customer['username'])
|
||||
->setArgument('service', 'pppoe')
|
||||
->setArgument('profile', $plan['name_plan'])
|
||||
->setArgument('comment', $customer['fullname'] . ' | ' . $customer['email'])
|
||||
->setArgument('password', $pass)
|
||||
);
|
||||
}
|
||||
|
||||
public static function setPpoeUser($client, $user, $pass)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$printRequest = new RouterOS\Request('/ppp/secret/print');
|
||||
$printRequest->setArgument('.proplist', '.id');
|
||||
$printRequest->setQuery(RouterOS\Query::where('name', $user));
|
||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
||||
|
||||
$setRequest = new RouterOS\Request('/ppp/secret/set');
|
||||
$setRequest->setArgument('numbers', $id);
|
||||
$setRequest->setArgument('password', $pass);
|
||||
$client->sendSync($setRequest);
|
||||
}
|
||||
|
||||
public static function setPpoeUserPlan($client, $user, $plan)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$printRequest = new RouterOS\Request('/ppp/secret/print');
|
||||
$printRequest->setArgument('.proplist', '.id');
|
||||
$printRequest->setQuery(RouterOS\Query::where('name', $user));
|
||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
||||
|
||||
$setRequest = new RouterOS\Request('/ppp/secret/set');
|
||||
$setRequest->setArgument('numbers', $id);
|
||||
$setRequest->setArgument('profile', $plan);
|
||||
$client->sendSync($setRequest);
|
||||
}
|
||||
|
||||
public static function removePpoeActive($client, $username)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$onlineRequest = new RouterOS\Request('/ppp/active/print');
|
||||
$onlineRequest->setArgument('.proplist', '.id');
|
||||
$onlineRequest->setQuery(RouterOS\Query::where('name', $username));
|
||||
$id = $client->sendSync($onlineRequest)->getProperty('.id');
|
||||
|
||||
$removeRequest = new RouterOS\Request('/ppp/active/remove');
|
||||
$removeRequest->setArgument('numbers', $id);
|
||||
$client->sendSync($removeRequest);
|
||||
}
|
||||
|
||||
public static function removePool($client, $name)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$printRequest = new RouterOS\Request(
|
||||
'/ip pool print .proplist=.id',
|
||||
RouterOS\Query::where('name', $name)
|
||||
);
|
||||
$poolID = $client->sendSync($printRequest)->getProperty('.id');
|
||||
|
||||
$removeRequest = new RouterOS\Request('/ip/pool/remove');
|
||||
$client->sendSync(
|
||||
$removeRequest
|
||||
->setArgument('numbers', $poolID)
|
||||
);
|
||||
}
|
||||
|
||||
public static function addPool($client, $name, $ip_address)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$addRequest = new RouterOS\Request('/ip/pool/add');
|
||||
$client->sendSync(
|
||||
$addRequest
|
||||
->setArgument('name', $name)
|
||||
->setArgument('ranges', $ip_address)
|
||||
);
|
||||
}
|
||||
|
||||
public static function setPool($client, $name, $ip_address)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$printRequest = new RouterOS\Request(
|
||||
'/ip pool print .proplist=.id',
|
||||
RouterOS\Query::where('name', $name)
|
||||
);
|
||||
$poolID = $client->sendSync($printRequest)->getProperty('.id');
|
||||
|
||||
if (empty($poolID)) {
|
||||
self::addPool($client, $name, $ip_address);
|
||||
} else {
|
||||
$setRequest = new RouterOS\Request('/ip/pool/set');
|
||||
$client->sendSync(
|
||||
$setRequest
|
||||
->setArgument('numbers', $poolID)
|
||||
->setArgument('ranges', $ip_address)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function addPpoePlan($client, $name, $pool, $rate)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$addRequest = new RouterOS\Request('/ppp/profile/add');
|
||||
$client->sendSync(
|
||||
$addRequest
|
||||
->setArgument('name', $name)
|
||||
->setArgument('local-address', $pool)
|
||||
->setArgument('remote-address', $pool)
|
||||
->setArgument('rate-limit', $rate)
|
||||
);
|
||||
}
|
||||
|
||||
public static function setPpoePlan($client, $name, $pool, $rate)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$printRequest = new RouterOS\Request(
|
||||
'/ppp profile print .proplist=.id',
|
||||
RouterOS\Query::where('name', $name)
|
||||
);
|
||||
$profileID = $client->sendSync($printRequest)->getProperty('.id');
|
||||
if (empty($profileID)) {
|
||||
self::addPpoePlan($client, $name, $pool, $rate);
|
||||
} else {
|
||||
$setRequest = new RouterOS\Request('/ppp/profile/set');
|
||||
$client->sendSync(
|
||||
$setRequest
|
||||
->setArgument('numbers', $profileID)
|
||||
->setArgument('local-address', $pool)
|
||||
->setArgument('remote-address', $pool)
|
||||
->setArgument('rate-limit', $rate)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static function removePpoePlan($client, $name)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$printRequest = new RouterOS\Request(
|
||||
'/ppp profile print .proplist=.id',
|
||||
RouterOS\Query::where('name', $name)
|
||||
);
|
||||
$profileID = $client->sendSync($printRequest)->getProperty('.id');
|
||||
|
||||
$removeRequest = new RouterOS\Request('/ppp/profile/remove');
|
||||
$client->sendSync(
|
||||
$removeRequest
|
||||
->setArgument('numbers', $profileID)
|
||||
);
|
||||
}
|
||||
|
||||
public static function sendSMS($client, $to, $message)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$smsRequest = new RouterOS\Request('/tool sms send');
|
||||
$smsRequest
|
||||
->setArgument('phone-number', $to)
|
||||
->setArgument('message', $message);
|
||||
$client->sendSync($smsRequest);
|
||||
}
|
||||
|
||||
public static function getIpHotspotUser($client, $username){
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$printRequest = new RouterOS\Request(
|
||||
'/ip hotspot active print',
|
||||
RouterOS\Query::where('user', $username)
|
||||
);
|
||||
return $client->sendSync($printRequest)->getProperty('address');
|
||||
}
|
||||
|
||||
public static function addIpToAddressList($client, $ip, $listName, $comment = '')
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$addRequest = new RouterOS\Request('/ip/firewall/address-list/add');
|
||||
$client->sendSync(
|
||||
$addRequest
|
||||
->setArgument('address', $ip)
|
||||
->setArgument('comment', $comment)
|
||||
->setArgument('list', $listName)
|
||||
);
|
||||
}
|
||||
|
||||
public static function removeIpFromAddressList($client, $ip)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return null;
|
||||
}
|
||||
$printRequest = new RouterOS\Request(
|
||||
'/ip firewall address-list print .proplist=.id',
|
||||
RouterOS\Query::where('address', $ip)
|
||||
);
|
||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
||||
$removeRequest = new RouterOS\Request('/ip/firewall/address-list/remove');
|
||||
$client->sendSync(
|
||||
$removeRequest
|
||||
->setArgument('numbers', $id)
|
||||
);
|
||||
}
|
||||
}
|
@ -1,22 +1,87 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Standard Autoloader for PEAR2
|
||||
*
|
||||
* PEAR2_Autoload is the standard method of class loading for development and
|
||||
* low-volume web sites using PEAR2 packages.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PEAR2
|
||||
* @package PEAR2_Autoload
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @author Brett Bieber <saltybeagle@php.net>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
|
||||
* @version 0.3.0
|
||||
* @link http://pear2.php.net/PEAR2_Autoload
|
||||
*/
|
||||
namespace PEAR2;
|
||||
|
||||
if (!class_exists('\PEAR2\Autoload', false)) {
|
||||
/**
|
||||
* Standard Autoloader for PEAR2
|
||||
*
|
||||
* PEAR2_Autoload is the standard method of class loading for development
|
||||
* and low-volume web sites using PEAR2 packages.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PEAR2
|
||||
* @package PEAR2_Autoload
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @author Brett Bieber <saltybeagle@php.net>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD
|
||||
* New BSDLicense
|
||||
* @link http://pear2.php.net/PEAR2_Autoload
|
||||
*/
|
||||
class Autoload
|
||||
{
|
||||
/**
|
||||
* Used at {@link initialize()} to specify that the load function, path
|
||||
* and map should be appended to the respective lists.
|
||||
*/
|
||||
const APPEND = 0;
|
||||
|
||||
/**
|
||||
* Used at {@link initialize()} to specify that the load function should
|
||||
* be prepended on the autoload stack, instead of being appended.
|
||||
*/
|
||||
const PREPEND_LOAD = 1;
|
||||
|
||||
/**
|
||||
* Used at {@link initialize()} to specify that the path should be
|
||||
* prepended on the list of paths, instead of being appended.
|
||||
*/
|
||||
const PREPEND_PATH = 2;
|
||||
|
||||
/**
|
||||
* Used at {@link initialize()} to specify that the map should be
|
||||
* prepended on the list of maps, instead of being appended.
|
||||
*/
|
||||
const PREPEND_MAP = 4;
|
||||
|
||||
/**
|
||||
* Used at {@link initialize()} to specify that the load function, path
|
||||
* and map should be prepended on their respective lists, instead of
|
||||
* being appended.
|
||||
*/
|
||||
const PREPEND = 7;
|
||||
|
||||
/**
|
||||
* Whether the autoload class has been spl_autoload_register-ed
|
||||
*
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected static $registered = false;
|
||||
|
||||
/**
|
||||
* Array of PEAR2 autoload paths registered
|
||||
*
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $paths = array();
|
||||
|
||||
|
||||
/**
|
||||
* Array of classname-to-file mapping
|
||||
*
|
||||
@ -45,86 +110,124 @@ if (!class_exists('\PEAR2\Autoload', false)) {
|
||||
*/
|
||||
protected static $unmapped = array();
|
||||
|
||||
/**
|
||||
* Array of functions to be checked in exception traces.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $checkFunctions = array(
|
||||
'class_exists', 'interface_exists'
|
||||
);
|
||||
|
||||
/**
|
||||
* Initialize the PEAR2 autoloader
|
||||
*
|
||||
* @param string $path Directory path to register
|
||||
*
|
||||
*
|
||||
* @param string $path Directory path(s) to register.
|
||||
* @param string $mapfile Path to a mapping file to register.
|
||||
* @param int $flags A bitmaks with options for the autoloader.
|
||||
* See the PREPEND(_*) constants for details.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
static function initialize($path, $mapfile = null)
|
||||
{
|
||||
self::register();
|
||||
self::addPath($path);
|
||||
self::addMap($mapfile);
|
||||
public static function initialize(
|
||||
$path,
|
||||
$mapfile = null,
|
||||
$flags = self::APPEND
|
||||
) {
|
||||
self::register(0 !== $flags & self::PREPEND_LOAD);
|
||||
self::addPath($path, 0 !== ($flags & self::PREPEND_PATH));
|
||||
self::addMap($mapfile, 0 !== ($flags & self::PREPEND_MAP));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the PEAR2 autoload class with spl_autoload_register
|
||||
*
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the load function to the
|
||||
* autoload stack instead of appending it.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function register()
|
||||
protected static function register($prepend = false)
|
||||
{
|
||||
if (!self::$registered) {
|
||||
// set up __autoload
|
||||
$autoload = spl_autoload_functions();
|
||||
spl_autoload_register('PEAR2\Autoload::load');
|
||||
spl_autoload_register('PEAR2\Autoload::load', true, $prepend);
|
||||
if (function_exists('__autoload') && ($autoload === false)) {
|
||||
// __autoload() was being used, but now would be ignored, add
|
||||
// it to the autoload stack
|
||||
// __autoload() was being used, but now would be ignored,
|
||||
// add it to the autoload stack
|
||||
spl_autoload_register('__autoload');
|
||||
}
|
||||
if (function_exists('trait_exists')) {
|
||||
self::$checkFunctions[] = 'trait_exists';
|
||||
}
|
||||
self::$registered = true;
|
||||
}
|
||||
self::$registered = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a path
|
||||
*
|
||||
* @param string $path The directory to add to the set of PEAR2 paths
|
||||
*
|
||||
*
|
||||
* @param string $paths The folder(s) to add to the set of paths.
|
||||
* @param bool $prepend Whether to prepend the path to the list of
|
||||
* paths instead of appending it.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function addPath($path)
|
||||
protected static function addPath($paths, $prepend = false)
|
||||
{
|
||||
if (!in_array($path, self::$paths)) {
|
||||
self::$paths[] = $path;
|
||||
foreach (explode(PATH_SEPARATOR, $paths) as $path) {
|
||||
if (!in_array($path, self::$paths)) {
|
||||
if ($prepend) {
|
||||
self::$paths = array_merge(array($path), self::$paths);
|
||||
} else {
|
||||
self::$paths[] = $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a classname-to-file map
|
||||
*
|
||||
* @param string $mapfile The filename of the classmap
|
||||
* @param string $mapfile The filename of the classmap.
|
||||
* @param bool $prepend Whether to prepend the map to the list of maps
|
||||
* instead of appending it.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function addMap($mapfile)
|
||||
protected static function addMap($mapfile, $prepend = false)
|
||||
{
|
||||
if (! in_array($mapfile, self::$maps)) {
|
||||
|
||||
if (!in_array($mapfile, self::$maps)) {
|
||||
// keep track of specific map file loaded in this
|
||||
// instance so we can update it if necessary
|
||||
// instance so we can update it if necessary
|
||||
self::$mapfile = $mapfile;
|
||||
|
||||
if (file_exists($mapfile)) {
|
||||
|
||||
if (is_file($mapfile)) {
|
||||
$map = include $mapfile;
|
||||
if (is_array($map)) {
|
||||
// mapfile contains a valid map, so we'll keep it
|
||||
self::$maps[] = $mapfile;
|
||||
self::$map = array_merge(self::$map, $map);
|
||||
if ($prepend) {
|
||||
self::$maps = array_merge(
|
||||
array($mapfile),
|
||||
self::$maps
|
||||
);
|
||||
self::$map = array_merge($map, self::$map);
|
||||
} else {
|
||||
self::$maps[] = $mapfile;
|
||||
self::$map = array_merge(self::$map, $map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the class is already defined in a classmap
|
||||
*
|
||||
*
|
||||
* @param string $class The class to look for
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected static function isMapped($class)
|
||||
@ -141,18 +244,18 @@ if (!class_exists('\PEAR2\Autoload', false)) {
|
||||
|
||||
/**
|
||||
* Load a PEAR2 class
|
||||
*
|
||||
*
|
||||
* @param string $class The class to load
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
static function load($class)
|
||||
public static function load($class)
|
||||
{
|
||||
// need to check if there's a current map file specified ALSO.
|
||||
// this could be the first time writing it.
|
||||
$mapped = self::isMapped($class);
|
||||
if ($mapped) {
|
||||
require self::$map[$class];
|
||||
if ($mapped && is_file(self::$map[$class])) {
|
||||
include self::$map[$class];
|
||||
if (!self::loadSuccessful($class)) {
|
||||
// record this failure & keep going, we may still find it
|
||||
self::$unmapped[] = $class;
|
||||
@ -161,34 +264,59 @@ if (!class_exists('\PEAR2\Autoload', false)) {
|
||||
}
|
||||
}
|
||||
|
||||
$file = str_replace(array('_', '\\'), DIRECTORY_SEPARATOR, $class) . '.php';
|
||||
$file = '';
|
||||
$className = $class;
|
||||
if (false !== $lastNsPos = strrpos($class, '\\')) {
|
||||
$namespace = substr($class, 0, $lastNsPos);
|
||||
$className = substr($class, $lastNsPos + 1);
|
||||
$file = str_replace(
|
||||
'\\',
|
||||
DIRECTORY_SEPARATOR,
|
||||
$namespace
|
||||
) . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
$file .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
|
||||
foreach (self::$paths as $path) {
|
||||
if (file_exists($path . DIRECTORY_SEPARATOR . $file)) {
|
||||
require $path . DIRECTORY_SEPARATOR . $file;
|
||||
if (is_file($path . DIRECTORY_SEPARATOR . $file)) {
|
||||
include $path . DIRECTORY_SEPARATOR . $file;
|
||||
if (!self::loadSuccessful($class)) {
|
||||
throw new \Exception('Class ' . $class . ' was not present in ' .
|
||||
if (count(spl_autoload_functions()) > 1) {
|
||||
return false;
|
||||
}
|
||||
throw new \Exception(
|
||||
'Class ' . $class . ' was not present in ' .
|
||||
$path . DIRECTORY_SEPARATOR . $file .
|
||||
'") [PEAR2_Autoload-0.2.4]');
|
||||
'") [PEAR2_Autoload-@PACKAGE_VERSION@]'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (in_array($class, self::$unmapped)) {
|
||||
self::updateMap($class, $path . DIRECTORY_SEPARATOR . $file);
|
||||
self::updateMap(
|
||||
$class,
|
||||
$path . DIRECTORY_SEPARATOR . $file
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$e = new \Exception('Class ' . $class . ' could not be loaded from ' .
|
||||
$file . ', file does not exist (registered paths="' .
|
||||
implode(PATH_SEPARATOR, self::$paths) .
|
||||
'") [PEAR2_Autoload-0.2.4]');
|
||||
$trace = $e->getTrace();
|
||||
if (isset($trace[2]) && isset($trace[2]['function']) &&
|
||||
in_array($trace[2]['function'], array('class_exists', 'interface_exists'))) {
|
||||
if (count(spl_autoload_functions()) > 1) {
|
||||
return false;
|
||||
}
|
||||
if (isset($trace[1]) && isset($trace[1]['function']) &&
|
||||
in_array($trace[1]['function'], array('class_exists', 'interface_exists'))) {
|
||||
$e = new \Exception(
|
||||
'Class ' . $class . ' could not be loaded from ' .
|
||||
$file . ', file does not exist (registered paths="' .
|
||||
implode(PATH_SEPARATOR, self::$paths) .
|
||||
'") [PEAR2_Autoload-@PACKAGE_VERSION@]'
|
||||
);
|
||||
$trace = $e->getTrace();
|
||||
if (isset($trace[2]) && isset($trace[2]['function'])
|
||||
&& in_array($trace[2]['function'], self::$checkFunctions)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (isset($trace[1]) && isset($trace[1]['function'])
|
||||
&& in_array($trace[1]['function'], self::$checkFunctions)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
throw $e;
|
||||
@ -196,31 +324,36 @@ if (!class_exists('\PEAR2\Autoload', false)) {
|
||||
|
||||
/**
|
||||
* Check if the requested class was loaded from the specified path
|
||||
*
|
||||
*
|
||||
* @param string $class The name of the class to check.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected static function loadSuccessful($class)
|
||||
{
|
||||
if (!class_exists($class, false) && !interface_exists($class, false)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return class_exists($class, false)
|
||||
|| interface_exists($class, false)
|
||||
|| (in_array('trait_exists', self::$checkFunctions, true)
|
||||
&& trait_exists($class, false));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If possible, update the classmap file with newly-discovered
|
||||
* If possible, update the classmap file with newly-discovered
|
||||
* mapping.
|
||||
*
|
||||
* @param string $class Class name discovered
|
||||
*
|
||||
*
|
||||
* @param string $class Class name discovered
|
||||
* @param string $origin File where class was found
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function updateMap($class, $origin)
|
||||
{
|
||||
if (is_writable(self::$mapfile) || is_writable(dirname(self::$mapfile))) {
|
||||
if (is_writable(self::$mapfile)
|
||||
|| is_writable(dirname(self::$mapfile))
|
||||
) {
|
||||
self::$map[$class] = $origin;
|
||||
file_put_contents(self::$mapfile,
|
||||
file_put_contents(
|
||||
self::$mapfile,
|
||||
'<'."?php\n"
|
||||
. "// PEAR2\Autoload auto-generated classmap\n"
|
||||
. "return " . var_export(self::$map, true) . ';',
|
||||
@ -228,16 +361,16 @@ if (!class_exists('\PEAR2\Autoload', false)) {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* return the array of paths PEAR2 autoload has registered
|
||||
*
|
||||
* Return the array of paths PEAR2 autoload has registered
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function getPaths()
|
||||
public static function getPaths()
|
||||
{
|
||||
return self::$paths;
|
||||
}
|
||||
}
|
||||
}
|
||||
Autoload::initialize(dirname(__DIR__));
|
||||
Autoload::initialize(dirname(__DIR__));
|
||||
|
@ -1,18 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ~~summary~~
|
||||
*
|
||||
* ~~description~~
|
||||
*
|
||||
* Wrapper for shared memory and locking functionality across different extensions.
|
||||
|
||||
*
|
||||
* Allows you to share data across requests as long as the PHP process is running. One of APC or WinCache is required to accomplish this, with other extensions being potentially pluggable as adapters.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
*
|
||||
* @category Caching
|
||||
* @package PEAR2_Cache_SHM
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2011 Vasil Rangelov
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version 0.1.3
|
||||
* @version 0.2.0
|
||||
* @link http://pear2.php.net/PEAR2_Cache_SHM
|
||||
*/
|
||||
|
||||
@ -38,9 +39,9 @@ use PEAR2\Cache\SHM\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Main class for this package.
|
||||
*
|
||||
*
|
||||
* Automatically chooses an adapter based on the available extensions.
|
||||
*
|
||||
*
|
||||
* @category Caching
|
||||
* @package PEAR2_Cache_SHM
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
@ -50,18 +51,20 @@ use PEAR2\Cache\SHM\InvalidArgumentException;
|
||||
abstract class SHM implements IteratorAggregate
|
||||
{
|
||||
/**
|
||||
* @var array An array of adapter names that meet their requirements.
|
||||
* An array of adapter names that meet their requirements.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_adapters = array();
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new shared memory storage.
|
||||
*
|
||||
* Estabilishes a separate persistent storage. Adapter is automatically
|
||||
*
|
||||
* Establishes a separate persistent storage. Adapter is automatically
|
||||
* chosen based on the available extensions.
|
||||
*
|
||||
*
|
||||
* @param string $persistentId The ID for the storage.
|
||||
*
|
||||
*
|
||||
* @return static|SHM A new instance of an SHM adapter (child of this
|
||||
* class).
|
||||
*/
|
||||
@ -79,28 +82,28 @@ abstract class SHM implements IteratorAggregate
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the adapter meets its requirements.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public static function isMeetingRequirements()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Registers an adapter.
|
||||
*
|
||||
*
|
||||
* Registers an SHM adapter, allowing you to call it with {@link factory()}.
|
||||
*
|
||||
*
|
||||
* @param string $adapter FQCN of adapter. A valid adapter is one that
|
||||
* extends this class. The class will be autoloaded if not already
|
||||
* present.
|
||||
* @param bool $prepend Whether to prepend this adapter into the list of
|
||||
* possible adapters, instead of appending to it.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
final public static function registerAdapter($adapter, $prepend = false)
|
||||
@ -121,244 +124,244 @@ abstract class SHM implements IteratorAggregate
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a value to the shared memory storage.
|
||||
*
|
||||
*
|
||||
* Adds a value to the storage if it doesn't exist, or fails if it does.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to associate the value with.
|
||||
* @param mixed $value Value for the specified key.
|
||||
* @param int $ttl Seconds to store the value. If set to 0 indicates no
|
||||
* time limit.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function __invoke($key, $value, $ttl = 0)
|
||||
{
|
||||
return $this->add($key, $value, $ttl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets a value from the shared memory storage.
|
||||
*
|
||||
*
|
||||
* This is a magic method, thanks to which any property you attempt to get
|
||||
* the value of will be fetched from the adapter, treating the property name
|
||||
* as the key of the value to get.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to get.
|
||||
*
|
||||
*
|
||||
* @return mixed The current value of the specified key.
|
||||
*/
|
||||
public function __get($key)
|
||||
{
|
||||
return $this->get($key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets a value in the shared memory storage.
|
||||
*
|
||||
*
|
||||
* This is a magic method, thanks to which any property you attempt to set
|
||||
* the value of will be set by the adapter, treating the property name as
|
||||
* the key of the value to set. The value is set without a TTL.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to associate the value with.
|
||||
* @param mixed $value Value for the specified key.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function __set($key, $value)
|
||||
{
|
||||
return $this->set($key, $value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if a specified key is in the storage.
|
||||
*
|
||||
*
|
||||
* This is a magic method, thanks to which any property you call isset() on
|
||||
* will be checked by the adapter, treating the property name as the key
|
||||
* of the value to check.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to check.
|
||||
*
|
||||
* @return bool TRUE if the key is in the storage, FALSE otherwise.
|
||||
*
|
||||
* @return bool TRUE if the key is in the storage, FALSE otherwise.
|
||||
*/
|
||||
public function __isset($key)
|
||||
{
|
||||
return $this->exists($key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deletes a value from the shared memory storage.
|
||||
*
|
||||
*
|
||||
* This is a magic method, thanks to which any property you attempt to unset
|
||||
* the value of will be unset by the adapter, treating the property name as
|
||||
* the key of the value to delete.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to delete.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function __unset($key)
|
||||
{
|
||||
return $this->delete($key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new shared memory storage.
|
||||
*
|
||||
* Estabilishes a separate persistent storage.
|
||||
*
|
||||
*
|
||||
* Establishes a separate persistent storage.
|
||||
*
|
||||
* @param string $persistentId The ID for the storage. The storage will be
|
||||
* reused if it exists, or created if it doesn't exist. Data and locks
|
||||
* are namespaced by this ID.
|
||||
*/
|
||||
abstract public function __construct($persistentId);
|
||||
|
||||
|
||||
/**
|
||||
* Obtains a named lock.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of the key to obtain. Note that $key may
|
||||
* repeat for each distinct $persistentId.
|
||||
* @param double $timeout If the lock can't be immediatly obtained, the
|
||||
* @param double $timeout If the lock can't be immediately obtained, the
|
||||
* script will block for at most the specified amount of seconds.
|
||||
* Setting this to 0 makes lock obtaining non blocking, and setting it
|
||||
* to NULL makes it block without a time limit.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
abstract public function lock($key, $timeout = null);
|
||||
|
||||
|
||||
/**
|
||||
* Releases a named lock.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of the key to release. Note that $key may
|
||||
* repeat for each distinct $persistentId.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
abstract public function unlock($key);
|
||||
|
||||
|
||||
/**
|
||||
* Checks if a specified key is in the storage.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to check.
|
||||
*
|
||||
* @return bool TRUE if the key is in the storage, FALSE otherwise.
|
||||
*
|
||||
* @return bool TRUE if the key is in the storage, FALSE otherwise.
|
||||
*/
|
||||
abstract public function exists($key);
|
||||
|
||||
|
||||
/**
|
||||
* Adds a value to the shared memory storage.
|
||||
*
|
||||
*
|
||||
* Adds a value to the storage if it doesn't exist, or fails if it does.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to associate the value with.
|
||||
* @param mixed $value Value for the specified key.
|
||||
* @param int $ttl Seconds to store the value. If set to 0 indicates no
|
||||
* time limit.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
abstract public function add($key, $value, $ttl = 0);
|
||||
|
||||
|
||||
/**
|
||||
* Sets a value in the shared memory storage.
|
||||
*
|
||||
*
|
||||
* Adds a value to the storage if it doesn't exist, overwrites it otherwise.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to associate the value with.
|
||||
* @param mixed $value Value for the specified key.
|
||||
* @param int $ttl Seconds to store the value. If set to 0 indicates no
|
||||
* time limit.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
abstract public function set($key, $value, $ttl = 0);
|
||||
|
||||
|
||||
/**
|
||||
* Gets a value from the shared memory storage.
|
||||
*
|
||||
*
|
||||
* Gets the current value, or throws an exception if it's not stored.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to get the value of.
|
||||
*
|
||||
*
|
||||
* @return mixed The current value of the specified key.
|
||||
*/
|
||||
abstract public function get($key);
|
||||
|
||||
|
||||
/**
|
||||
* Deletes a value from the shared memory storage.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to delete.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
abstract public function delete($key);
|
||||
|
||||
|
||||
/**
|
||||
* Increases a value from the shared memory storage.
|
||||
*
|
||||
*
|
||||
* Increases a value from the shared memory storage. Unlike a plain
|
||||
* set($key, get($key)+$step) combination, this function also implicitly
|
||||
* performs locking.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to increase.
|
||||
* @param int $step Value to increase the key by.
|
||||
*
|
||||
*
|
||||
* @return int The new value.
|
||||
*/
|
||||
abstract public function inc($key, $step = 1);
|
||||
|
||||
|
||||
/**
|
||||
* Decreases a value from the shared memory storage.
|
||||
*
|
||||
*
|
||||
* Decreases a value from the shared memory storage. Unlike a plain
|
||||
* set($key, get($key)-$step) combination, this function also implicitly
|
||||
* performs locking.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to decrease.
|
||||
* @param int $step Value to decrease the key by.
|
||||
*
|
||||
*
|
||||
* @return int The new value.
|
||||
*/
|
||||
abstract public function dec($key, $step = 1);
|
||||
|
||||
/**
|
||||
* Sets a new value if a key has a certain value.
|
||||
*
|
||||
*
|
||||
* Sets a new value if a key has a certain value. This function only works
|
||||
* when $old and $new are longs.
|
||||
*
|
||||
*
|
||||
* @param string $key Key of the value to compare and set.
|
||||
* @param int $old The value to compare the key against.
|
||||
* @param int $new The value to set the key to.
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
abstract public function cas($key, $old, $new);
|
||||
|
||||
|
||||
/**
|
||||
* Clears the persistent storage.
|
||||
*
|
||||
*
|
||||
* Clears the persistent storage, i.e. removes all keys. Locks are left
|
||||
* intact.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract public function clear();
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve an external iterator
|
||||
*
|
||||
*
|
||||
* Returns an external iterator.
|
||||
*
|
||||
*
|
||||
* @param string|null $filter A PCRE regular expression.
|
||||
* Only matching keys will be iterated over.
|
||||
* Setting this to NULL matches all keys of this instance.
|
||||
* @param bool $keysOnly Whether to return only the keys,
|
||||
* or return both the keys and values.
|
||||
*
|
||||
*
|
||||
* @return \Traversable An array with all matching keys as array keys,
|
||||
* and values as array values. If $keysOnly is TRUE, the array keys are
|
||||
* numeric, and the array values are key names.
|
||||
@ -368,4 +371,5 @@ abstract class SHM implements IteratorAggregate
|
||||
|
||||
SHM::registerAdapter('\\' . __NAMESPACE__ . '\SHM\Adapter\Placebo');
|
||||
SHM::registerAdapter('\\' . __NAMESPACE__ . '\SHM\Adapter\Wincache');
|
||||
SHM::registerAdapter('\\' . __NAMESPACE__ . '\SHM\Adapter\APCu');
|
||||
SHM::registerAdapter('\\' . __NAMESPACE__ . '\SHM\Adapter\APC');
|
||||
|
@ -1,18 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ~~summary~~
|
||||
*
|
||||
* ~~description~~
|
||||
*
|
||||
* Wrapper for shared memory and locking functionality across different extensions.
|
||||
|
||||
*
|
||||
* Allows you to share data across requests as long as the PHP process is running. One of APC or WinCache is required to accomplish this, with other extensions being potentially pluggable as adapters.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
*
|
||||
* @category Caching
|
||||
* @package PEAR2_Cache_SHM
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2011 Vasil Rangelov
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version 0.1.3
|
||||
* @version 0.2.0
|
||||
* @link http://pear2.php.net/PEAR2_Cache_SHM
|
||||
*/
|
||||
/**
|
||||
@ -32,7 +33,7 @@ use ArrayObject;
|
||||
|
||||
/**
|
||||
* Shared memory adapter for the APC extension.
|
||||
*
|
||||
*
|
||||
* @category Caching
|
||||
* @package PEAR2_Cache_SHM
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
@ -42,32 +43,39 @@ use ArrayObject;
|
||||
class APC extends SHM
|
||||
{
|
||||
/**
|
||||
* @var string ID of the current storage.
|
||||
* ID of the current storage.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $persistentId;
|
||||
|
||||
|
||||
/**
|
||||
* List of persistent IDs.
|
||||
*
|
||||
*
|
||||
* A list of persistent IDs within the current request (as keys) with an int
|
||||
* (as a value) specifying the number of instances in the current request.
|
||||
* Used as an attempt to ensure implicit lock releases even on errors in the
|
||||
* critical sections, since APC doesn't have an actual locking function.
|
||||
* @var array
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $requestInstances = array();
|
||||
|
||||
|
||||
/**
|
||||
* @var array Array of lock names (as values) for each persistent ID (as
|
||||
* key) obtained during the current request.
|
||||
* Array of lock names for each persistent ID.
|
||||
*
|
||||
* Array of lock names (as values) for each persistent ID (as key) obtained
|
||||
* during the current request.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $locksBackup = array();
|
||||
|
||||
/**
|
||||
* Creates a new shared memory storage.
|
||||
*
|
||||
* Estabilishes a separate persistent storage.
|
||||
*
|
||||
*
|
||||
* Establishes a separate persistent storage.
|
||||
*
|
||||
* @param string $persistentId The ID for the storage. The storage will be
|
||||
* reused if it exists, or created if it doesn't exist. Data and locks
|
||||
* are namespaced by this ID.
|
||||
@ -87,35 +95,36 @@ class APC extends SHM
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the adapter meets its requirements.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public static function isMeetingRequirements()
|
||||
{
|
||||
return extension_loaded('apc')
|
||||
&& version_compare(phpversion('apc'), '3.0.13', '>=')
|
||||
&& version_compare(phpversion('apc'), '3.1.1', '>=')
|
||||
&& ini_get('apc.enabled')
|
||||
&& ('cli' !== PHP_SAPI || ini_get('apc.enable_cli'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Releases all locks in a storage.
|
||||
*
|
||||
*
|
||||
* This function is not meant to be used directly. It is implicitly called
|
||||
* by the the destructor and as a shutdown function when the request ends.
|
||||
* One of these calls ends up releasing any unreleased locks obtained
|
||||
* during the request. A lock is also implicitly released as soon as there
|
||||
* are no objects left in the current request using the same persistent ID.
|
||||
*
|
||||
*
|
||||
* @param string $internalPersistentId The internal persistent ID, the locks
|
||||
* of which are being released.
|
||||
* @param bool $isAtShutdown Whether the function was executed at
|
||||
* shutdown.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public static function releaseLocks($internalPersistentId, $isAtShutdown)
|
||||
@ -127,7 +136,7 @@ class APC extends SHM
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Releases any locks obtained by this instance as soon as there are no more
|
||||
* references to the object's persistent ID.
|
||||
@ -137,18 +146,18 @@ class APC extends SHM
|
||||
static::$requestInstances[$this->persistentId]--;
|
||||
static::releaseLocks($this->persistentId, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Obtains a named lock.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of the key to obtain. Note that $key may
|
||||
* repeat for each distinct $persistentId.
|
||||
* @param double $timeout If the lock can't be immediatly obtained, the
|
||||
* @param double $timeout If the lock can't be immediately obtained, the
|
||||
* script will block for at most the specified amount of seconds.
|
||||
* Setting this to 0 makes lock obtaining non blocking, and setting it
|
||||
* to NULL makes it block without a time limit.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function lock($key, $timeout = null)
|
||||
@ -164,13 +173,13 @@ class APC extends SHM
|
||||
static::$locksBackup[$this->persistentId] = $key;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Releases a named lock.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of the key to release. Note that $key may
|
||||
* repeat for each distinct $persistentId.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function unlock($key)
|
||||
@ -178,69 +187,71 @@ class APC extends SHM
|
||||
$lock = $this->persistentId . 'l ' . $key;
|
||||
$success = apc_delete($lock);
|
||||
if ($success) {
|
||||
unset(static::$locksBackup[$this->persistentId][array_search(
|
||||
$key,
|
||||
static::$locksBackup[$this->persistentId],
|
||||
true
|
||||
)]);
|
||||
unset(
|
||||
static::$locksBackup[$this->persistentId][array_search(
|
||||
$key,
|
||||
static::$locksBackup[$this->persistentId],
|
||||
true
|
||||
)]
|
||||
);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if a specified key is in the storage.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to check.
|
||||
*
|
||||
* @return bool TRUE if the key is in the storage, FALSE otherwise.
|
||||
*
|
||||
* @return bool TRUE if the key is in the storage, FALSE otherwise.
|
||||
*/
|
||||
public function exists($key)
|
||||
{
|
||||
return apc_exists($this->persistentId . 'd ' . $key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a value to the shared memory storage.
|
||||
*
|
||||
*
|
||||
* Adds a value to the storage if it doesn't exist, or fails if it does.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to associate the value with.
|
||||
* @param mixed $value Value for the specified key.
|
||||
* @param int $ttl Seconds to store the value. If set to 0 indicates no
|
||||
* time limit.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function add($key, $value, $ttl = 0)
|
||||
{
|
||||
return apc_add($this->persistentId . 'd ' . $key, $value, $ttl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets a value in the shared memory storage.
|
||||
*
|
||||
*
|
||||
* Adds a value to the storage if it doesn't exist, overwrites it otherwise.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to associate the value with.
|
||||
* @param mixed $value Value for the specified key.
|
||||
* @param int $ttl Seconds to store the value. If set to 0 indicates no
|
||||
* time limit.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function set($key, $value, $ttl = 0)
|
||||
{
|
||||
return apc_store($this->persistentId . 'd ' . $key, $value, $ttl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets a value from the shared memory storage.
|
||||
*
|
||||
*
|
||||
* Gets the current value, or throws an exception if it's not stored.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to get the value of.
|
||||
*
|
||||
*
|
||||
* @return mixed The current value of the specified key.
|
||||
*/
|
||||
public function get($key)
|
||||
@ -260,29 +271,29 @@ class APC extends SHM
|
||||
}
|
||||
throw new SHM\InvalidArgumentException('No such key in cache', 101);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deletes a value from the shared memory storage.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to delete.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function delete($key)
|
||||
{
|
||||
return apc_delete($this->persistentId . 'd ' . $key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Increases a value from the shared memory storage.
|
||||
*
|
||||
*
|
||||
* Increases a value from the shared memory storage. Unlike a plain
|
||||
* set($key, get($key)+$step) combination, this function also implicitly
|
||||
* performs locking.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to increase.
|
||||
* @param int $step Value to increase the key by.
|
||||
*
|
||||
*
|
||||
* @return int The new value.
|
||||
*/
|
||||
public function inc($key, $step = 1)
|
||||
@ -300,17 +311,17 @@ class APC extends SHM
|
||||
}
|
||||
return $newValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decreases a value from the shared memory storage.
|
||||
*
|
||||
*
|
||||
* Decreases a value from the shared memory storage. Unlike a plain
|
||||
* set($key, get($key)-$step) combination, this function also implicitly
|
||||
* performs locking.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to decrease.
|
||||
* @param int $step Value to decrease the key by.
|
||||
*
|
||||
*
|
||||
* @return int The new value.
|
||||
*/
|
||||
public function dec($key, $step = 1)
|
||||
@ -331,27 +342,27 @@ class APC extends SHM
|
||||
|
||||
/**
|
||||
* Sets a new value if a key has a certain value.
|
||||
*
|
||||
*
|
||||
* Sets a new value if a key has a certain value. This function only works
|
||||
* when $old and $new are longs.
|
||||
*
|
||||
*
|
||||
* @param string $key Key of the value to compare and set.
|
||||
* @param int $old The value to compare the key against.
|
||||
* @param int $new The value to set the key to.
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function cas($key, $old, $new)
|
||||
{
|
||||
return apc_cas($this->persistentId . 'd ' . $key, $old, $new);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clears the persistent storage.
|
||||
*
|
||||
*
|
||||
* Clears the persistent storage, i.e. removes all keys. Locks are left
|
||||
* intact.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear()
|
||||
@ -366,18 +377,18 @@ class APC extends SHM
|
||||
apc_delete($key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve an external iterator
|
||||
*
|
||||
*
|
||||
* Returns an external iterator.
|
||||
*
|
||||
*
|
||||
* @param string|null $filter A PCRE regular expression.
|
||||
* Only matching keys will be iterated over.
|
||||
* Setting this to NULL matches all keys of this instance.
|
||||
* @param bool $keysOnly Whether to return only the keys,
|
||||
* or return both the keys and values.
|
||||
*
|
||||
*
|
||||
* @return ArrayObject An array with all matching keys as array keys,
|
||||
* and values as array values. If $keysOnly is TRUE, the array keys are
|
||||
* numeric, and the array values are key names.
|
||||
|
416
system/autoload/PEAR2/Cache/SHM/Adapter/APCu.php
Normal file
416
system/autoload/PEAR2/Cache/SHM/Adapter/APCu.php
Normal file
@ -0,0 +1,416 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Wrapper for shared memory and locking functionality across different extensions.
|
||||
|
||||
*
|
||||
* Allows you to share data across requests as long as the PHP process is running. One of APC or WinCache is required to accomplish this, with other extensions being potentially pluggable as adapters.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Caching
|
||||
* @package PEAR2_Cache_SHM
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2011 Vasil Rangelov
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version 0.2.0
|
||||
* @link http://pear2.php.net/PEAR2_Cache_SHM
|
||||
*/
|
||||
/**
|
||||
* The namespace declaration.
|
||||
*/
|
||||
namespace PEAR2\Cache\SHM\Adapter;
|
||||
|
||||
/**
|
||||
* Throws exceptions from this namespace, and extends from this class.
|
||||
*/
|
||||
use PEAR2\Cache\SHM;
|
||||
|
||||
/**
|
||||
* {@link APC::getIterator()} returns this object.
|
||||
*/
|
||||
use ArrayObject;
|
||||
|
||||
/**
|
||||
* Shared memory adapter for the APC extension.
|
||||
*
|
||||
* @category Caching
|
||||
* @package PEAR2_Cache_SHM
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @link http://pear2.php.net/PEAR2_Cache_SHM
|
||||
*/
|
||||
class APCu extends SHM
|
||||
{
|
||||
/**
|
||||
* ID of the current storage.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $persistentId;
|
||||
|
||||
/**
|
||||
* List of persistent IDs.
|
||||
*
|
||||
* A list of persistent IDs within the current request (as keys) with an int
|
||||
* (as a value) specifying the number of instances in the current request.
|
||||
* Used as an attempt to ensure implicit lock releases even on errors in the
|
||||
* critical sections, since APC doesn't have an actual locking function.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $requestInstances = array();
|
||||
|
||||
/**
|
||||
* Array of lock names for each persistent ID.
|
||||
*
|
||||
* Array of lock names (as values) for each persistent ID (as key) obtained
|
||||
* during the current request.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $locksBackup = array();
|
||||
|
||||
/**
|
||||
* Creates a new shared memory storage.
|
||||
*
|
||||
* Establishes a separate persistent storage.
|
||||
*
|
||||
* @param string $persistentId The ID for the storage. The storage will be
|
||||
* reused if it exists, or created if it doesn't exist. Data and locks
|
||||
* are namespaced by this ID.
|
||||
*/
|
||||
public function __construct($persistentId)
|
||||
{
|
||||
$this->persistentId = __CLASS__ . ' ' . $persistentId;
|
||||
if (isset(static::$requestInstances[$this->persistentId])) {
|
||||
static::$requestInstances[$this->persistentId]++;
|
||||
} else {
|
||||
static::$requestInstances[$this->persistentId] = 1;
|
||||
static::$locksBackup[$this->persistentId] = array();
|
||||
}
|
||||
register_shutdown_function(
|
||||
get_called_class() . '::releaseLocks',
|
||||
$this->persistentId,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the adapter meets its requirements.
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public static function isMeetingRequirements()
|
||||
{
|
||||
return extension_loaded('apcu')
|
||||
&& version_compare(phpversion('apcu'), '5.0.0', '>=')
|
||||
&& ini_get('apc.enabled')
|
||||
&& ('cli' !== PHP_SAPI || ini_get('apc.enable_cli'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases all locks in a storage.
|
||||
*
|
||||
* This function is not meant to be used directly. It is implicitly called
|
||||
* by the the destructor and as a shutdown function when the request ends.
|
||||
* One of these calls ends up releasing any unreleased locks obtained
|
||||
* during the request. A lock is also implicitly released as soon as there
|
||||
* are no objects left in the current request using the same persistent ID.
|
||||
*
|
||||
* @param string $internalPersistentId The internal persistent ID, the locks
|
||||
* of which are being released.
|
||||
* @param bool $isAtShutdown Whether the function was executed at
|
||||
* shutdown.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public static function releaseLocks($internalPersistentId, $isAtShutdown)
|
||||
{
|
||||
$hasInstances = 0 !== static::$requestInstances[$internalPersistentId];
|
||||
if ($isAtShutdown === $hasInstances) {
|
||||
foreach (static::$locksBackup[$internalPersistentId] as $key) {
|
||||
apcu_delete($internalPersistentId . 'l ' . $key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases any locks obtained by this instance as soon as there are no more
|
||||
* references to the object's persistent ID.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
static::$requestInstances[$this->persistentId]--;
|
||||
static::releaseLocks($this->persistentId, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains a named lock.
|
||||
*
|
||||
* @param string $key Name of the key to obtain. Note that $key may
|
||||
* repeat for each distinct $persistentId.
|
||||
* @param double $timeout If the lock can't be immediately obtained, the
|
||||
* script will block for at most the specified amount of seconds.
|
||||
* Setting this to 0 makes lock obtaining non blocking, and setting it
|
||||
* to NULL makes it block without a time limit.
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function lock($key, $timeout = null)
|
||||
{
|
||||
$lock = $this->persistentId . 'l ' . $key;
|
||||
$hasTimeout = $timeout !== null;
|
||||
$start = microtime(true);
|
||||
while (!apcu_add($lock, 1)) {
|
||||
if ($hasTimeout && (microtime(true) - $start) > $timeout) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
static::$locksBackup[$this->persistentId] = $key;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases a named lock.
|
||||
*
|
||||
* @param string $key Name of the key to release. Note that $key may
|
||||
* repeat for each distinct $persistentId.
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function unlock($key)
|
||||
{
|
||||
$lock = $this->persistentId . 'l ' . $key;
|
||||
$success = apcu_delete($lock);
|
||||
if ($success) {
|
||||
unset(
|
||||
static::$locksBackup[$this->persistentId][array_search(
|
||||
$key,
|
||||
static::$locksBackup[$this->persistentId],
|
||||
true
|
||||
)]
|
||||
);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a specified key is in the storage.
|
||||
*
|
||||
* @param string $key Name of key to check.
|
||||
*
|
||||
* @return bool TRUE if the key is in the storage, FALSE otherwise.
|
||||
*/
|
||||
public function exists($key)
|
||||
{
|
||||
return apcu_exists($this->persistentId . 'd ' . $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a value to the shared memory storage.
|
||||
*
|
||||
* Adds a value to the storage if it doesn't exist, or fails if it does.
|
||||
*
|
||||
* @param string $key Name of key to associate the value with.
|
||||
* @param mixed $value Value for the specified key.
|
||||
* @param int $ttl Seconds to store the value. If set to 0 indicates no
|
||||
* time limit.
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function add($key, $value, $ttl = 0)
|
||||
{
|
||||
return apcu_add($this->persistentId . 'd ' . $key, $value, $ttl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a value in the shared memory storage.
|
||||
*
|
||||
* Adds a value to the storage if it doesn't exist, overwrites it otherwise.
|
||||
*
|
||||
* @param string $key Name of key to associate the value with.
|
||||
* @param mixed $value Value for the specified key.
|
||||
* @param int $ttl Seconds to store the value. If set to 0 indicates no
|
||||
* time limit.
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function set($key, $value, $ttl = 0)
|
||||
{
|
||||
return apcu_store($this->persistentId . 'd ' . $key, $value, $ttl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a value from the shared memory storage.
|
||||
*
|
||||
* Gets the current value, or throws an exception if it's not stored.
|
||||
*
|
||||
* @param string $key Name of key to get the value of.
|
||||
*
|
||||
* @return mixed The current value of the specified key.
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
$fullKey = $this->persistentId . 'd ' . $key;
|
||||
if (apcu_exists($fullKey)) {
|
||||
$value = apcu_fetch($fullKey, $success);
|
||||
if (!$success) {
|
||||
throw new SHM\InvalidArgumentException(
|
||||
'Unable to fetch key. ' .
|
||||
'Key has either just now expired or (if no TTL was set) ' .
|
||||
'is possibly in a race condition with another request.',
|
||||
100
|
||||
);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
throw new SHM\InvalidArgumentException('No such key in cache', 101);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a value from the shared memory storage.
|
||||
*
|
||||
* @param string $key Name of key to delete.
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function delete($key)
|
||||
{
|
||||
return apcu_delete($this->persistentId . 'd ' . $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increases a value from the shared memory storage.
|
||||
*
|
||||
* Increases a value from the shared memory storage. Unlike a plain
|
||||
* set($key, get($key)+$step) combination, this function also implicitly
|
||||
* performs locking.
|
||||
*
|
||||
* @param string $key Name of key to increase.
|
||||
* @param int $step Value to increase the key by.
|
||||
*
|
||||
* @return int The new value.
|
||||
*/
|
||||
public function inc($key, $step = 1)
|
||||
{
|
||||
$newValue = apcu_inc(
|
||||
$this->persistentId . 'd ' . $key,
|
||||
(int) $step,
|
||||
$success
|
||||
);
|
||||
if (!$success) {
|
||||
throw new SHM\InvalidArgumentException(
|
||||
'Unable to increase the value. Are you sure the value is int?',
|
||||
102
|
||||
);
|
||||
}
|
||||
return $newValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decreases a value from the shared memory storage.
|
||||
*
|
||||
* Decreases a value from the shared memory storage. Unlike a plain
|
||||
* set($key, get($key)-$step) combination, this function also implicitly
|
||||
* performs locking.
|
||||
*
|
||||
* @param string $key Name of key to decrease.
|
||||
* @param int $step Value to decrease the key by.
|
||||
*
|
||||
* @return int The new value.
|
||||
*/
|
||||
public function dec($key, $step = 1)
|
||||
{
|
||||
$newValue = apcu_dec(
|
||||
$this->persistentId . 'd ' . $key,
|
||||
(int) $step,
|
||||
$success
|
||||
);
|
||||
if (!$success) {
|
||||
throw new SHM\InvalidArgumentException(
|
||||
'Unable to decrease the value. Are you sure the value is int?',
|
||||
103
|
||||
);
|
||||
}
|
||||
return $newValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a new value if a key has a certain value.
|
||||
*
|
||||
* Sets a new value if a key has a certain value. This function only works
|
||||
* when $old and $new are longs.
|
||||
*
|
||||
* @param string $key Key of the value to compare and set.
|
||||
* @param int $old The value to compare the key against.
|
||||
* @param int $new The value to set the key to.
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function cas($key, $old, $new)
|
||||
{
|
||||
return apcu_cas($this->persistentId . 'd ' . $key, $old, $new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the persistent storage.
|
||||
*
|
||||
* Clears the persistent storage, i.e. removes all keys. Locks are left
|
||||
* intact.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
foreach (new APCIterator(
|
||||
'user',
|
||||
'/^' . preg_quote($this->persistentId, '/') . 'd /',
|
||||
APC_ITER_KEY,
|
||||
100,
|
||||
APC_LIST_ACTIVE
|
||||
) as $key) {
|
||||
apcu_delete($key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an external iterator
|
||||
*
|
||||
* Returns an external iterator.
|
||||
*
|
||||
* @param string|null $filter A PCRE regular expression.
|
||||
* Only matching keys will be iterated over.
|
||||
* Setting this to NULL matches all keys of this instance.
|
||||
* @param bool $keysOnly Whether to return only the keys,
|
||||
* or return both the keys and values.
|
||||
*
|
||||
* @return ArrayObject An array with all matching keys as array keys,
|
||||
* and values as array values. If $keysOnly is TRUE, the array keys are
|
||||
* numeric, and the array values are key names.
|
||||
*/
|
||||
public function getIterator($filter = null, $keysOnly = false)
|
||||
{
|
||||
$result = array();
|
||||
foreach (new APCUIterator(
|
||||
'/^' . preg_quote($this->persistentId, '/') . 'd /',
|
||||
APC_ITER_KEY,
|
||||
100,
|
||||
APC_LIST_ACTIVE
|
||||
) as $key) {
|
||||
$localKey = strstr($key, $this->persistentId . 'd ');
|
||||
if (null === $filter || preg_match($filter, $localKey)) {
|
||||
if ($keysOnly) {
|
||||
$result[] = $localKey;
|
||||
} else {
|
||||
$result[$localKey] = apcu_fetch($key);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ArrayObject($result);
|
||||
}
|
||||
}
|
@ -1,18 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ~~summary~~
|
||||
*
|
||||
* ~~description~~
|
||||
*
|
||||
* Wrapper for shared memory and locking functionality across different extensions.
|
||||
|
||||
*
|
||||
* Allows you to share data across requests as long as the PHP process is running. One of APC or WinCache is required to accomplish this, with other extensions being potentially pluggable as adapters.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
*
|
||||
* @category Caching
|
||||
* @package PEAR2_Cache_SHM
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2011 Vasil Rangelov
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version 0.1.3
|
||||
* @version 0.2.0
|
||||
* @link http://pear2.php.net/PEAR2_Cache_SHM
|
||||
*/
|
||||
/**
|
||||
@ -31,10 +32,10 @@ use PEAR2\Cache\SHM;
|
||||
use ArrayObject;
|
||||
|
||||
/**
|
||||
* This adapter is not truly persistent. It is intended to emulate persistency
|
||||
* This adapter is not truly persistent. It is intended to emulate persistence
|
||||
* in non persistent environments, so that upper level applications can use a
|
||||
* single code path for persistent and non persistent code.
|
||||
*
|
||||
*
|
||||
* @category Caching
|
||||
* @package PEAR2_Cache_SHM
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
@ -44,42 +45,50 @@ use ArrayObject;
|
||||
class Placebo extends SHM
|
||||
{
|
||||
/**
|
||||
* @var string ID of the current storage.
|
||||
* ID of the current storage.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $persistentId;
|
||||
|
||||
|
||||
/**
|
||||
* List of persistent IDs.
|
||||
*
|
||||
*
|
||||
* A list of persistent IDs within the current request (as keys) with an int
|
||||
* (as a value) specifying the number of instances in the current request.
|
||||
* Used as an attempt to ensure implicit lock releases on destruction.
|
||||
* @var array
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $requestInstances = array();
|
||||
|
||||
|
||||
/**
|
||||
* @var array Array of lock names (as values) for each persistent ID (as
|
||||
* Array of lock names for each persistent ID.
|
||||
*
|
||||
* Array of lock names (as values) for each persistent ID (as
|
||||
* key) obtained during the current request.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $locksBackup = array();
|
||||
|
||||
|
||||
/**
|
||||
* The data storage.
|
||||
*
|
||||
*
|
||||
* Each persistent ID is a key, and the value is an array.
|
||||
* Each such array has data keys as its keys, and an array as a value.
|
||||
* Each such array has as its elements the value, the timeout and the time
|
||||
* the data was set.
|
||||
* @var array
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $data = array();
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new shared memory storage.
|
||||
*
|
||||
* Estabilishes a separate persistent storage.
|
||||
*
|
||||
*
|
||||
* Establishes a separate persistent storage.
|
||||
*
|
||||
* @param string $persistentId The ID for the storage. The storage will be
|
||||
* reused if it exists, or created if it doesn't exist. Data and locks
|
||||
* are namespaced by this ID.
|
||||
@ -95,9 +104,9 @@ class Placebo extends SHM
|
||||
}
|
||||
$this->persistentId = $persistentId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Releases any unreleased locks.
|
||||
* Releases any unreleased locks.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
@ -105,23 +114,23 @@ class Placebo extends SHM
|
||||
static::$locksBackup[$this->persistentId] = array();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the adapter meets its requirements.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public static function isMeetingRequirements()
|
||||
{
|
||||
return 'cli' === PHP_SAPI;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pretends to obtain a lock.
|
||||
*
|
||||
*
|
||||
* @param string $key Ignored.
|
||||
* @param double $timeout Ignored.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function lock($key, $timeout = null)
|
||||
@ -133,12 +142,12 @@ class Placebo extends SHM
|
||||
static::$locksBackup[$this->persistentId][] = $key;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pretends to release a lock.
|
||||
*
|
||||
*
|
||||
* @param string $key Ignored
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function unlock($key)
|
||||
@ -147,36 +156,38 @@ class Placebo extends SHM
|
||||
if (!in_array($key, static::$locksBackup[$this->persistentId], true)) {
|
||||
return false;
|
||||
}
|
||||
unset(static::$locksBackup[$this->persistentId][array_search(
|
||||
$key,
|
||||
static::$locksBackup[$this->persistentId],
|
||||
true
|
||||
)]);
|
||||
unset(
|
||||
static::$locksBackup[$this->persistentId][array_search(
|
||||
$key,
|
||||
static::$locksBackup[$this->persistentId],
|
||||
true
|
||||
)]
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if a specified key is in the storage.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to check.
|
||||
*
|
||||
* @return bool TRUE if the key is in the storage, FALSE otherwise.
|
||||
*
|
||||
* @return bool TRUE if the key is in the storage, FALSE otherwise.
|
||||
*/
|
||||
public function exists($key)
|
||||
{
|
||||
return array_key_exists($key, static::$data[$this->persistentId]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a value to the shared memory storage.
|
||||
*
|
||||
*
|
||||
* Adds a value to the storage if it doesn't exist, or fails if it does.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to associate the value with.
|
||||
* @param mixed $value Value for the specified key.
|
||||
* @param int $ttl Because "true" adapters purge the cache at the next
|
||||
* request, this setting is ignored.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function add($key, $value, $ttl = 0)
|
||||
@ -186,17 +197,17 @@ class Placebo extends SHM
|
||||
}
|
||||
return $this->set($key, $value, $ttl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets a value in the shared memory storage.
|
||||
*
|
||||
*
|
||||
* Adds a value to the storage if it doesn't exist, overwrites it otherwise.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to associate the value with.
|
||||
* @param mixed $value Value for the specified key.
|
||||
* @param int $ttl Because "true" adapters purge the cache at the next
|
||||
* request, this setting is ignored.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function set($key, $value, $ttl = 0)
|
||||
@ -204,14 +215,14 @@ class Placebo extends SHM
|
||||
static::$data[$this->persistentId][$key] = $value;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets a value from the shared memory storage.
|
||||
*
|
||||
*
|
||||
* Gets the current value, or throws an exception if it's not stored.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to get the value of.
|
||||
*
|
||||
*
|
||||
* @return mixed The current value of the specified key.
|
||||
*/
|
||||
public function get($key)
|
||||
@ -224,12 +235,12 @@ class Placebo extends SHM
|
||||
200
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deletes a value from the shared memory storage.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to delete.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function delete($key)
|
||||
@ -240,17 +251,17 @@ class Placebo extends SHM
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Increases a value from the shared memory storage.
|
||||
*
|
||||
*
|
||||
* Increases a value from the shared memory storage. Unlike a plain
|
||||
* set($key, get($key)+$step) combination, this function also implicitly
|
||||
* performs locking.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to increase.
|
||||
* @param int $step Value to increase the key by.
|
||||
*
|
||||
*
|
||||
* @return int The new value.
|
||||
*/
|
||||
public function inc($key, $step = 1)
|
||||
@ -265,17 +276,17 @@ class Placebo extends SHM
|
||||
}
|
||||
return $this->get($key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decreases a value from the shared memory storage.
|
||||
*
|
||||
*
|
||||
* Decreases a value from the shared memory storage. Unlike a plain
|
||||
* set($key, get($key)-$step) combination, this function also implicitly
|
||||
* performs locking.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to decrease.
|
||||
* @param int $step Value to decrease the key by.
|
||||
*
|
||||
*
|
||||
* @return int The new value.
|
||||
*/
|
||||
public function dec($key, $step = 1)
|
||||
@ -293,46 +304,46 @@ class Placebo extends SHM
|
||||
|
||||
/**
|
||||
* Sets a new value if a key has a certain value.
|
||||
*
|
||||
*
|
||||
* Sets a new value if a key has a certain value. This function only works
|
||||
* when $old and $new are longs.
|
||||
*
|
||||
*
|
||||
* @param string $key Key of the value to compare and set.
|
||||
* @param int $old The value to compare the key against.
|
||||
* @param int $new The value to set the key to.
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function cas($key, $old, $new)
|
||||
{
|
||||
return $this->exists($key) && ($this->get($key) === $old)
|
||||
&& is_int($new) && $this->set($key, $new);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clears the persistent storage.
|
||||
*
|
||||
*
|
||||
* Clears the persistent storage, i.e. removes all keys. Locks are left
|
||||
* intact.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
static::$data[$this->persistentId] = array();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve an external iterator
|
||||
*
|
||||
*
|
||||
* Returns an external iterator.
|
||||
*
|
||||
*
|
||||
* @param string|null $filter A PCRE regular expression.
|
||||
* Only matching keys will be iterated over.
|
||||
* Setting this to NULL matches all keys of this instance.
|
||||
* @param bool $keysOnly Whether to return only the keys,
|
||||
* or return both the keys and values.
|
||||
*
|
||||
*
|
||||
* @return ArrayObject An array with all matching keys as array keys,
|
||||
* and values as array values. If $keysOnly is TRUE, the array keys are
|
||||
* numeric, and the array values are key names.
|
||||
@ -346,7 +357,7 @@ class Placebo extends SHM
|
||||
: static::$data[$this->persistentId]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$result = array();
|
||||
foreach (static::$data[$this->persistentId] as $key => $value) {
|
||||
if (preg_match($filter, $key)) {
|
||||
|
@ -1,18 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ~~summary~~
|
||||
*
|
||||
* ~~description~~
|
||||
*
|
||||
* Wrapper for shared memory and locking functionality across different extensions.
|
||||
|
||||
*
|
||||
* Allows you to share data across requests as long as the PHP process is running. One of APC or WinCache is required to accomplish this, with other extensions being potentially pluggable as adapters.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
*
|
||||
* @category Caching
|
||||
* @package PEAR2_Cache_SHM
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2011 Vasil Rangelov
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version 0.1.3
|
||||
* @version 0.2.0
|
||||
* @link http://pear2.php.net/PEAR2_Cache_SHM
|
||||
*/
|
||||
/**
|
||||
@ -32,7 +33,7 @@ use ArrayObject;
|
||||
|
||||
/**
|
||||
* Shared memory adapter for the WinCache extension.
|
||||
*
|
||||
*
|
||||
* @category Caching
|
||||
* @package PEAR2_Cache_SHM
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
@ -42,30 +43,35 @@ use ArrayObject;
|
||||
class Wincache extends SHM
|
||||
{
|
||||
/**
|
||||
* @var string ID of the current storage.
|
||||
* ID of the current storage.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $persistentId;
|
||||
|
||||
|
||||
/**
|
||||
* List of persistent IDs.
|
||||
*
|
||||
*
|
||||
* A list of persistent IDs within the current request (as keys) with an int
|
||||
* (as a value) specifying the number of instances in the current request.
|
||||
* Used as an attempt to ensure implicit lock releases on destruction.
|
||||
* @var array
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $requestInstances = array();
|
||||
|
||||
|
||||
/**
|
||||
* @var array Array of lock names obtained during the current request.
|
||||
* Array of lock names obtained during the current request.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $locksBackup = array();
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new shared memory storage.
|
||||
*
|
||||
* Estabilishes a separate persistent storage.
|
||||
*
|
||||
*
|
||||
* Establishes a separate persistent storage.
|
||||
*
|
||||
* @param string $persistentId The ID for the storage. The storage will be
|
||||
* reused if it exists, or created if it doesn't exist. Data and locks
|
||||
* are namespaced by this ID.
|
||||
@ -81,28 +87,29 @@ class Wincache extends SHM
|
||||
static::$locksBackup[$this->persistentId] = array();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Encodes a lock name
|
||||
*
|
||||
*
|
||||
* Encodes a lock name, so that it can be properly obtained. The scheme used
|
||||
* is a subset of URL encoding, with only the "%" and "\" characters being
|
||||
* escaped. The encoding itself is necessary, since lock names can't contain
|
||||
* the "\" character.
|
||||
*
|
||||
*
|
||||
* @param string $name The lock name to encode.
|
||||
*
|
||||
*
|
||||
* @return string The encoded name.
|
||||
*
|
||||
* @link http://msdn.microsoft.com/en-us/library/ms682411(VS.85).aspx
|
||||
*/
|
||||
protected static function encodeLockName($name)
|
||||
{
|
||||
return str_replace(array('%', '\\'), array('%25', '%5C'), $name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the adapter meets its requirements.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public static function isMeetingRequirements()
|
||||
@ -112,7 +119,7 @@ class Wincache extends SHM
|
||||
&& ini_get('wincache.ucenabled')
|
||||
&& ('cli' !== PHP_SAPI || ini_get('wincache.enablecli'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Releases any locks obtained by this instance as soon as there are no more
|
||||
* references to the object's persistent ID.
|
||||
@ -128,15 +135,15 @@ class Wincache extends SHM
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Obtains a named lock.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of the key to obtain. Note that $key may
|
||||
* repeat for each distinct $persistentId.
|
||||
* @param double $timeout Ignored with WinCache. Script will always block if
|
||||
* the lock can't be immediatly obtained.
|
||||
*
|
||||
* the lock can't be immediately obtained.
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function lock($key, $timeout = null)
|
||||
@ -149,13 +156,13 @@ class Wincache extends SHM
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Releases a named lock.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of the key to release. Note that $key may
|
||||
* repeat for each distinct $persistentId.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function unlock($key)
|
||||
@ -164,68 +171,70 @@ class Wincache extends SHM
|
||||
$this->persistentId . static::encodeLockName($key)
|
||||
);
|
||||
if ($result) {
|
||||
unset(static::$locksBackup[$this->persistentId][array_search(
|
||||
$key,
|
||||
static::$locksBackup[$this->persistentId],
|
||||
true
|
||||
)]);
|
||||
unset(
|
||||
static::$locksBackup[$this->persistentId][array_search(
|
||||
$key,
|
||||
static::$locksBackup[$this->persistentId],
|
||||
true
|
||||
)]
|
||||
);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if a specified key is in the storage.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to check.
|
||||
*
|
||||
* @return bool TRUE if the key is in the storage, FALSE otherwise.
|
||||
*
|
||||
* @return bool TRUE if the key is in the storage, FALSE otherwise.
|
||||
*/
|
||||
public function exists($key)
|
||||
{
|
||||
return wincache_ucache_exists($this->persistentId . $key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a value to the shared memory storage.
|
||||
*
|
||||
*
|
||||
* Sets a value to the storage if it doesn't exist, or fails if it does.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to associate the value with.
|
||||
* @param mixed $value Value for the specified key.
|
||||
* @param int $ttl Seconds to store the value. If set to 0 indicates no
|
||||
* time limit.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function add($key, $value, $ttl = 0)
|
||||
{
|
||||
return wincache_ucache_add($this->persistentId . $key, $value, $ttl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets a value in the shared memory storage.
|
||||
*
|
||||
*
|
||||
* Adds a value to the storage if it doesn't exist, overwrites it otherwise.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to associate the value with.
|
||||
* @param mixed $value Value for the specified key.
|
||||
* @param int $ttl Seconds to store the value. If set to 0 indicates no
|
||||
* time limit.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function set($key, $value, $ttl = 0)
|
||||
{
|
||||
return wincache_ucache_set($this->persistentId . $key, $value, $ttl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets a value from the shared memory storage.
|
||||
*
|
||||
*
|
||||
* Gets the current value, or throws an exception if it's not stored.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to get the value of.
|
||||
*
|
||||
*
|
||||
* @return mixed The current value of the specified key.
|
||||
*/
|
||||
public function get($key)
|
||||
@ -239,29 +248,29 @@ class Wincache extends SHM
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deletes a value from the shared memory storage.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to delete.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function delete($key)
|
||||
{
|
||||
return wincache_ucache_delete($this->persistentId . $key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Increases a value from the shared memory storage.
|
||||
*
|
||||
*
|
||||
* Increases a value from the shared memory storage. Unlike a plain
|
||||
* set($key, get($key)+$step) combination, this function also implicitly
|
||||
* performs locking.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to increase.
|
||||
* @param int $step Value to increase the key by.
|
||||
*
|
||||
*
|
||||
* @return int The new value.
|
||||
*/
|
||||
public function inc($key, $step = 1)
|
||||
@ -279,17 +288,17 @@ class Wincache extends SHM
|
||||
}
|
||||
return $newValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decreases a value from the shared memory storage.
|
||||
*
|
||||
*
|
||||
* Decreases a value from the shared memory storage. Unlike a plain
|
||||
* set($key, get($key)-$step) combination, this function also implicitly
|
||||
* performs locking.
|
||||
*
|
||||
*
|
||||
* @param string $key Name of key to decrease.
|
||||
* @param int $step Value to decrease the key by.
|
||||
*
|
||||
*
|
||||
* @return int The new value.
|
||||
*/
|
||||
public function dec($key, $step = 1)
|
||||
@ -310,27 +319,27 @@ class Wincache extends SHM
|
||||
|
||||
/**
|
||||
* Sets a new value if a key has a certain value.
|
||||
*
|
||||
*
|
||||
* Sets a new value if a key has a certain value. This function only works
|
||||
* when $old and $new are longs.
|
||||
*
|
||||
*
|
||||
* @param string $key Key of the value to compare and set.
|
||||
* @param int $old The value to compare the key against.
|
||||
* @param int $new The value to set the key to.
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function cas($key, $old, $new)
|
||||
{
|
||||
return wincache_ucache_cas($this->persistentId . $key, $old, $new);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clears the persistent storage.
|
||||
*
|
||||
*
|
||||
* Clears the persistent storage, i.e. removes all keys. Locks are left
|
||||
* intact.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear()
|
||||
@ -344,18 +353,18 @@ class Wincache extends SHM
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve an external iterator
|
||||
*
|
||||
*
|
||||
* Returns an external iterator.
|
||||
*
|
||||
*
|
||||
* @param string|null $filter A PCRE regular expression.
|
||||
* Only matching keys will be iterated over.
|
||||
* Setting this to NULL matches all keys of this instance.
|
||||
* @param bool $keysOnly Whether to return only the keys,
|
||||
* or return both the keys and values.
|
||||
*
|
||||
*
|
||||
* @return ArrayObject An array with all matching keys as array keys,
|
||||
* and values as array values. If $keysOnly is TRUE, the array keys are
|
||||
* numeric, and the array values are key names.
|
||||
|
@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ~~summary~~
|
||||
* Wrapper for shared memory and locking functionality across different extensions.
|
||||
|
||||
*
|
||||
* ~~description~~
|
||||
* Allows you to share data across requests as long as the PHP process is running. One of APC or WinCache is required to accomplish this, with other extensions being potentially pluggable as adapters.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@ -12,7 +13,7 @@
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2011 Vasil Rangelov
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version 0.1.3
|
||||
* @version 0.2.0
|
||||
* @link http://pear2.php.net/PEAR2_Cache_SHM
|
||||
*/
|
||||
/**
|
||||
|
@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ~~summary~~
|
||||
* Wrapper for shared memory and locking functionality across different extensions.
|
||||
|
||||
*
|
||||
* ~~description~~
|
||||
* Allows you to share data across requests as long as the PHP process is running. One of APC or WinCache is required to accomplish this, with other extensions being potentially pluggable as adapters.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@ -12,7 +13,7 @@
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2011 Vasil Rangelov
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version 0.1.3
|
||||
* @version 0.2.0
|
||||
* @link http://pear2.php.net/PEAR2_Cache_SHM
|
||||
*/
|
||||
/**
|
||||
|
@ -59,6 +59,7 @@ class CommandLine
|
||||
* Error messages.
|
||||
*
|
||||
* @var array $errors Error messages
|
||||
*
|
||||
* @todo move this to PEAR2\Console\CommandLine\MessageProvider
|
||||
*/
|
||||
public static $errors = array(
|
||||
@ -130,7 +131,7 @@ class CommandLine
|
||||
/**
|
||||
* The command line parser renderer instance.
|
||||
*
|
||||
* @var object that implements PEAR2\Console\CommandLine\Renderer interface
|
||||
* @var PEAR2\Console\CommandLine\Renderer a renderer
|
||||
*/
|
||||
public $renderer = false;
|
||||
|
||||
@ -144,7 +145,7 @@ class CommandLine
|
||||
/**
|
||||
* The command line message provider instance.
|
||||
*
|
||||
* @var PEAR2\Console\CommandLine\MessageProvider A message provider instance
|
||||
* @var PEAR2\Console\CommandLine\MessageProvider A message provider
|
||||
*/
|
||||
public $message_provider = false;
|
||||
|
||||
@ -191,6 +192,7 @@ class CommandLine
|
||||
* convenience.
|
||||
*
|
||||
* @var PEAR2\Console\CommandLine The parent instance
|
||||
*
|
||||
* @todo move CommandLine::parent to CommandLine\Command
|
||||
*/
|
||||
public $parent = false;
|
||||
@ -272,7 +274,7 @@ class CommandLine
|
||||
* </code>
|
||||
*
|
||||
* @var array
|
||||
* @see PEAR2\Console\CommandLine\MessageProvider_Default
|
||||
* @see PEAR2\Console\CommandLine\MessageProvider\DefaultProvider
|
||||
*/
|
||||
public $messages = array();
|
||||
|
||||
@ -286,6 +288,9 @@ class CommandLine
|
||||
*/
|
||||
private $_dispatchLater = array();
|
||||
|
||||
private $_lastopt = false;
|
||||
private $_stopflag = false;
|
||||
|
||||
// }}}
|
||||
// __construct() {{{
|
||||
|
||||
@ -345,7 +350,7 @@ class CommandLine
|
||||
// set default instances
|
||||
$this->renderer = new CommandLine\Renderer_Default($this);
|
||||
$this->outputter = new CommandLine\Outputter_Default();
|
||||
$this->message_provider = new CommandLine\MessageProvider_Default();
|
||||
$this->message_provider = new CommandLine\MessageProvider\DefaultProvider();
|
||||
}
|
||||
|
||||
// }}}
|
||||
@ -481,6 +486,7 @@ class CommandLine
|
||||
* @param array $params An array containing the argument attributes
|
||||
*
|
||||
* @return PEAR2\Console\CommandLine\Argument the added argument
|
||||
*
|
||||
* @see PEAR2\Console\CommandLine\Argument
|
||||
*/
|
||||
public function addArgument($name, $params = array())
|
||||
@ -842,6 +848,7 @@ class CommandLine
|
||||
* @param array $params An array of search=>replaces entries
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @todo remove Console::triggerError() and use exceptions only
|
||||
*/
|
||||
public static function triggerError($msgId, $level, $params=array())
|
||||
@ -912,7 +919,7 @@ class CommandLine
|
||||
// Check if an invalid subcommand was specified. If there are
|
||||
// subcommands and no arguments, but an argument was provided, it is
|
||||
// an invalid subcommand.
|
||||
if ( count($this->commands) > 0
|
||||
if (count($this->commands) > 0
|
||||
&& count($this->args) === 0
|
||||
&& count($args) > 0
|
||||
) {
|
||||
@ -925,7 +932,7 @@ class CommandLine
|
||||
}
|
||||
// if subcommand_required is set to true we must check that we have a
|
||||
// subcommand.
|
||||
if ( count($this->commands)
|
||||
if (count($this->commands)
|
||||
&& $this->subcommand_required
|
||||
&& !$result->command_name
|
||||
) {
|
||||
@ -989,23 +996,21 @@ class CommandLine
|
||||
*/
|
||||
protected function parseToken($token, $result, &$args, $argc)
|
||||
{
|
||||
static $lastopt = false;
|
||||
static $stopflag = false;
|
||||
$last = $argc === 0;
|
||||
if (!$stopflag && $lastopt) {
|
||||
if (!$this->_stopflag && $this->_lastopt) {
|
||||
if (substr($token, 0, 1) == '-') {
|
||||
if ($lastopt->argument_optional) {
|
||||
$this->_dispatchAction($lastopt, '', $result);
|
||||
if ($lastopt->action != 'StoreArray') {
|
||||
$lastopt = false;
|
||||
if ($this->_lastopt->argument_optional) {
|
||||
$this->_dispatchAction($this->_lastopt, '', $result);
|
||||
if ($this->_lastopt->action != 'StoreArray') {
|
||||
$this->_lastopt = false;
|
||||
}
|
||||
} else if (isset($result->options[$lastopt->name])) {
|
||||
} else if (isset($result->options[$this->_lastopt->name])) {
|
||||
// case of an option that expect a list of args
|
||||
$lastopt = false;
|
||||
$this->_lastopt = false;
|
||||
} else {
|
||||
throw CommandLine\Exception::factory(
|
||||
'OPTION_VALUE_REQUIRED',
|
||||
array('name' => $lastopt->name),
|
||||
array('name' => $this->_lastopt->name),
|
||||
$this,
|
||||
$this->messages
|
||||
);
|
||||
@ -1015,8 +1020,8 @@ class CommandLine
|
||||
// is to consider that if there's already an element in the
|
||||
// array, and the commandline expects one or more args, we
|
||||
// leave last tokens to arguments
|
||||
if ($lastopt->action == 'StoreArray'
|
||||
&& !empty($result->options[$lastopt->name])
|
||||
if ($this->_lastopt->action == 'StoreArray'
|
||||
&& !empty($result->options[$this->_lastopt->name])
|
||||
&& count($this->args) > ($argc + count($args))
|
||||
) {
|
||||
if (!is_null($token)) {
|
||||
@ -1024,22 +1029,22 @@ class CommandLine
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!is_null($token) || $lastopt->action == 'Password') {
|
||||
$this->_dispatchAction($lastopt, $token, $result);
|
||||
if (!is_null($token) || $this->_lastopt->action == 'Password') {
|
||||
$this->_dispatchAction($this->_lastopt, $token, $result);
|
||||
}
|
||||
if ($lastopt->action != 'StoreArray') {
|
||||
$lastopt = false;
|
||||
if ($this->_lastopt->action != 'StoreArray') {
|
||||
$this->_lastopt = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!$stopflag && substr($token, 0, 2) == '--') {
|
||||
if (!$this->_stopflag && substr($token, 0, 2) == '--') {
|
||||
// a long option
|
||||
$optkv = explode('=', $token, 2);
|
||||
if (trim($optkv[0]) == '--') {
|
||||
// the special argument "--" forces in all cases the end of
|
||||
// option scanning.
|
||||
$stopflag = true;
|
||||
$this->_stopflag = true;
|
||||
return;
|
||||
}
|
||||
$opt = $this->findOption($optkv[0]);
|
||||
@ -1072,14 +1077,14 @@ class CommandLine
|
||||
);
|
||||
}
|
||||
// we will have a value next time
|
||||
$lastopt = $opt;
|
||||
$this->_lastopt = $opt;
|
||||
return;
|
||||
}
|
||||
if ($opt->action == 'StoreArray') {
|
||||
$lastopt = $opt;
|
||||
$this->_lastopt = $opt;
|
||||
}
|
||||
$this->_dispatchAction($opt, $value, $result);
|
||||
} else if (!$stopflag && substr($token, 0, 1) == '-') {
|
||||
} else if (!$this->_stopflag && substr($token, 0, 1) == '-') {
|
||||
// a short option
|
||||
$optname = substr($token, 0, 2);
|
||||
if ($optname == '-') {
|
||||
@ -1100,7 +1105,7 @@ class CommandLine
|
||||
// in short: handle -f<value> and -f <value>
|
||||
$next = substr($token, 2, 1);
|
||||
// check if we must wait for a value
|
||||
if ($next === false) {
|
||||
if (!$next) {
|
||||
if ($opt->expectsArgument()) {
|
||||
if ($last && !$opt->argument_optional) {
|
||||
throw CommandLine\Exception::factory(
|
||||
@ -1111,7 +1116,7 @@ class CommandLine
|
||||
);
|
||||
}
|
||||
// we will have a value next time
|
||||
$lastopt = $opt;
|
||||
$this->_lastopt = $opt;
|
||||
return;
|
||||
}
|
||||
$value = false;
|
||||
@ -1136,7 +1141,7 @@ class CommandLine
|
||||
}
|
||||
}
|
||||
if ($opt->action == 'StoreArray') {
|
||||
$lastopt = $opt;
|
||||
$this->_lastopt = $opt;
|
||||
}
|
||||
$value = substr($token, 2);
|
||||
}
|
||||
@ -1145,8 +1150,8 @@ class CommandLine
|
||||
// We have an argument.
|
||||
// if we are in POSIX compliant mode, we must set the stop flag to
|
||||
// true in order to stop option parsing.
|
||||
if (!$stopflag && $this->force_posix) {
|
||||
$stopflag = true;
|
||||
if (!$this->_stopflag && $this->force_posix) {
|
||||
$this->_stopflag = true;
|
||||
}
|
||||
if (!is_null($token)) {
|
||||
$args[] = $token;
|
||||
|
@ -11,14 +11,15 @@
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
namespace PEAR2\Console\CommandLine;
|
||||
|
@ -11,14 +11,15 @@
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
namespace PEAR2\Console\CommandLine\Action;
|
||||
|
@ -11,14 +11,15 @@
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
@ -46,7 +47,7 @@ use PEAR2\Console\CommandLine;
|
||||
* <code>
|
||||
* $ script.php -v -v -v
|
||||
* </code>
|
||||
* or:
|
||||
* or:
|
||||
* <code>
|
||||
* $ script.php -vvv
|
||||
* </code>
|
||||
|
@ -11,14 +11,15 @@
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
|
@ -11,21 +11,22 @@
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version CVS: $Id: List.php,v 1.2 2009/02/27 08:03:17 izi Exp $
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
namespace PEAR2\Console\CommandLine;
|
||||
|
||||
/**
|
||||
* Class that represent the List action, a special action that simply output an
|
||||
* Class that represent the List action, a special action that simply output an
|
||||
* array as a list.
|
||||
*
|
||||
* @category Console
|
||||
@ -43,10 +44,10 @@ class Action_List extends Action
|
||||
/**
|
||||
* Executes the action with the value entered by the user.
|
||||
* Possible parameters are:
|
||||
* - message: an alternative message to display instead of the default
|
||||
* - message: an alternative message to display instead of the default
|
||||
* message,
|
||||
* - delimiter: an alternative delimiter instead of the comma,
|
||||
* - post: a string to append after the message (default is the new line
|
||||
* - post: a string to append after the message (default is the new line
|
||||
* char).
|
||||
*
|
||||
* @param mixed $value The option value
|
||||
@ -57,8 +58,8 @@ class Action_List extends Action
|
||||
public function execute($value = false, $params = array())
|
||||
{
|
||||
$list = isset($params['list']) ? $params['list'] : array();
|
||||
$msg = isset($params['message'])
|
||||
? $params['message']
|
||||
$msg = isset($params['message'])
|
||||
? $params['message']
|
||||
: $this->parser->message_provider->get('LIST_DISPLAYED_MESSAGE');
|
||||
$del = isset($params['delimiter']) ? $params['delimiter'] : ', ';
|
||||
$post = isset($params['post']) ? $params['post'] : "\n";
|
||||
|
@ -11,14 +11,15 @@
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
@ -27,8 +28,8 @@ namespace PEAR2\Console\CommandLine\Action;
|
||||
use PEAR2\Console\CommandLine;
|
||||
|
||||
/**
|
||||
* Class that represent the Password action, a special action that allow the
|
||||
* user to specify the password on the commandline or to be prompted for
|
||||
* Class that represent the Password action, a special action that allow the
|
||||
* user to specify the password on the commandline or to be prompted for
|
||||
* entering it.
|
||||
*
|
||||
* @category Console
|
||||
@ -62,7 +63,8 @@ class Password extends CommandLine\Action
|
||||
* Prompts the password to the user without echoing it.
|
||||
*
|
||||
* @return string
|
||||
* @todo not echo-ing the password does not work on windows is there a way
|
||||
*
|
||||
* @todo not echo-ing the password does not work on windows is there a way
|
||||
* to make this work ?
|
||||
*/
|
||||
private function _promptPassword()
|
||||
|
@ -11,14 +11,15 @@
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
@ -29,7 +30,7 @@ use PEAR2\Console\CommandLine;
|
||||
/**
|
||||
* Class that represent the StoreArray action.
|
||||
*
|
||||
* The execute method appends the value of the option entered by the user to
|
||||
* The execute method appends the value of the option entered by the user to
|
||||
* the result option array entry.
|
||||
*
|
||||
* @category Console
|
||||
|
@ -11,14 +11,15 @@
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
@ -30,7 +31,7 @@ use PEAR2\Console\CommandLine;
|
||||
* Class that represent the StoreFalse action.
|
||||
*
|
||||
* The execute method store the boolean 'false' in the corrsponding result
|
||||
* option array entry (the value is true if the option is not present in the
|
||||
* option array entry (the value is true if the option is not present in the
|
||||
* command line entered by the user).
|
||||
*
|
||||
* @category Console
|
||||
|
@ -11,14 +11,15 @@
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
|
@ -11,14 +11,15 @@
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
@ -30,7 +31,7 @@ use PEAR2\Console\CommandLine;
|
||||
* Class that represent the StoreInt action.
|
||||
*
|
||||
* The execute method store the value of the option entered by the user as an
|
||||
* integer in the result option array entry, if the value passed is not an
|
||||
* integer in the result option array entry, if the value passed is not an
|
||||
* integer an Exception is raised.
|
||||
*
|
||||
* @category Console
|
||||
|
@ -11,14 +11,15 @@
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
@ -29,7 +30,7 @@ use PEAR2\Console\CommandLine;
|
||||
/**
|
||||
* Class that represent the StoreString action.
|
||||
*
|
||||
* The execute method store the value of the option entered by the user as a
|
||||
* The execute method store the value of the option entered by the user as a
|
||||
* string in the result option array entry.
|
||||
*
|
||||
* @category Console
|
||||
|
@ -11,14 +11,15 @@
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
@ -30,7 +31,7 @@ use PEAR2\Console\CommandLine;
|
||||
* Class that represent the StoreTrue action.
|
||||
*
|
||||
* The execute method store the boolean 'true' in the corrsponding result
|
||||
* option array entry (the value is false if the option is not present in the
|
||||
* option array entry (the value is false if the option is not present in the
|
||||
* command line entered by the user).
|
||||
*
|
||||
* @category Console
|
||||
|
@ -11,14 +11,15 @@
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
|
@ -16,9 +16,10 @@
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
@ -65,6 +66,7 @@ class Argument extends Element
|
||||
*
|
||||
* @return void
|
||||
* @throws PEAR2\Console\CommandLine\Exception
|
||||
*
|
||||
* @todo use exceptions
|
||||
*/
|
||||
public function validate()
|
||||
|
@ -11,14 +11,15 @@
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
@ -27,7 +28,7 @@ namespace PEAR2\Console\CommandLine;
|
||||
/**
|
||||
* Class that represent a command with option and arguments.
|
||||
*
|
||||
* This class exist just to clarify the interface but at the moment it is
|
||||
* This class exist just to clarify the interface but at the moment it is
|
||||
* strictly identical to PEAR2\Console\CommandLine class, it could change in the
|
||||
* future though.
|
||||
*
|
||||
@ -60,7 +61,7 @@ class Command extends \PEAR2\Console\CommandLine
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($params = array())
|
||||
public function __construct($params = array())
|
||||
{
|
||||
if (isset($params['aliases'])) {
|
||||
$this->aliases = $params['aliases'];
|
||||
|
@ -20,6 +20,7 @@
|
||||
* @version CVS: $Id: CustomMessageProvider.php 282427 2009-06-19 10:22:48Z izi $
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 1.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
@ -56,8 +57,9 @@ interface CustomMessageProvider
|
||||
* indexes are message codes.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @see PEAR2\Console\CommandLine_MessageProvider
|
||||
* @see PEAR2\Console\CommandLine_MessageProvider_Default
|
||||
* @see PEAR2\Console\CommandLine_MessageProvider\DefaultProvider
|
||||
*/
|
||||
public function getWithCustomMessages(
|
||||
$code, $vars = array(), $messages = array()
|
||||
|
@ -16,9 +16,10 @@
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
@ -92,7 +93,7 @@ abstract class Element
|
||||
* </code>
|
||||
*
|
||||
* @var array
|
||||
* @see PEAR2\Console\CommandLine_MessageProvider_Default
|
||||
* @see PEAR2\Console\CommandLine_MessageProvider\DefaultProvider
|
||||
*/
|
||||
public $messages = array();
|
||||
|
||||
@ -124,6 +125,7 @@ abstract class Element
|
||||
* Returns the string representation of the element.
|
||||
*
|
||||
* @return string The string representation of the element
|
||||
*
|
||||
* @todo use __toString() instead
|
||||
*/
|
||||
public function toString()
|
||||
|
@ -11,14 +11,15 @@
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
|
@ -11,14 +11,15 @@
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
@ -42,14 +43,15 @@ interface MessageProvider
|
||||
|
||||
/**
|
||||
* Retrieves the given string identifier corresponding message.
|
||||
* For a list of identifiers please see the provided default message
|
||||
* For a list of identifiers please see the provided default message
|
||||
* provider.
|
||||
*
|
||||
* @param string $code The string identifier of the message
|
||||
* @param array $vars An array of template variables
|
||||
*
|
||||
* @return string
|
||||
* @see PEAR2\Console\CommandLine_MessageProvider_Default
|
||||
*
|
||||
* @see PEAR2\Console\CommandLine\MessageProvider\DefaultProvider
|
||||
*/
|
||||
public function get($code, $vars=array());
|
||||
|
||||
|
@ -16,13 +16,17 @@
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
namespace PEAR2\Console\CommandLine;
|
||||
namespace PEAR2\Console\CommandLine\MessageProvider;
|
||||
|
||||
use PEAR2\Console\CommandLine\MessageProvider;
|
||||
use PEAR2\Console\CommandLine\CustomMessageProvider;
|
||||
|
||||
/**
|
||||
* Lightweight class that manages messages used by PEAR2\Console\CommandLine package,
|
||||
@ -37,7 +41,7 @@ namespace PEAR2\Console\CommandLine;
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since Class available since release 0.1.0
|
||||
*/
|
||||
class MessageProvider_Default
|
||||
class DefaultProvider
|
||||
implements MessageProvider,
|
||||
CustomMessageProvider
|
||||
{
|
@ -16,9 +16,10 @@
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
@ -173,6 +174,7 @@ class Option extends Element
|
||||
* @param string $delim Delimiter to use between short and long option
|
||||
*
|
||||
* @return string The string representation of the option
|
||||
*
|
||||
* @todo use __toString() instead
|
||||
*/
|
||||
public function toString($delim = ", ")
|
||||
@ -269,6 +271,7 @@ class Option extends Element
|
||||
*
|
||||
* @return void
|
||||
* @throws PEAR2\Console\CommandLine\Exception
|
||||
*
|
||||
* @todo use exceptions instead
|
||||
*/
|
||||
public function validate()
|
||||
|
@ -11,14 +11,15 @@
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
|
@ -11,14 +11,15 @@
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
|
@ -11,14 +11,15 @@
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*/
|
||||
|
@ -11,14 +11,15 @@
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
|
@ -11,20 +11,24 @@
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.3
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
*
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
namespace PEAR2\Console\CommandLine;
|
||||
|
||||
use PEAR2\Console\CommandLine;
|
||||
use DOMDocument;
|
||||
use DOMNode;
|
||||
use Phar;
|
||||
|
||||
/**
|
||||
* Parser for command line xml definitions.
|
||||
@ -49,7 +53,7 @@ class XmlParser
|
||||
*
|
||||
* @return PEAR2\Console\CommandLine A parser instance
|
||||
*/
|
||||
public static function parse($xmlfile)
|
||||
public static function parse($xmlfile)
|
||||
{
|
||||
if (!is_readable($xmlfile)) {
|
||||
CommandLine::triggerError(
|
||||
@ -58,7 +62,7 @@ class XmlParser
|
||||
array('{$file}' => $xmlfile)
|
||||
);
|
||||
}
|
||||
$doc = new \DomDocument();
|
||||
$doc = new DOMDocument();
|
||||
$doc->load($xmlfile);
|
||||
self::validate($doc);
|
||||
$nodes = $doc->getElementsByTagName('command');
|
||||
@ -77,9 +81,9 @@ class XmlParser
|
||||
*
|
||||
* @return PEAR2\Console\CommandLine A parser instance
|
||||
*/
|
||||
public static function parseString($xmlstr)
|
||||
public static function parseString($xmlstr)
|
||||
{
|
||||
$doc = new \DomDocument();
|
||||
$doc = new DOMDocument();
|
||||
$doc->loadXml($xmlstr);
|
||||
self::validate($doc);
|
||||
$nodes = $doc->getElementsByTagName('command');
|
||||
@ -93,27 +97,48 @@ class XmlParser
|
||||
/**
|
||||
* Validates the xml definition using Relax NG.
|
||||
*
|
||||
* @param DomDocument $doc The document to validate
|
||||
* @param DOMDocument $doc The document to validate
|
||||
*
|
||||
* @return boolean Whether the xml data is valid or not.
|
||||
* @throws PEAR2\Console\CommandLine\Exception
|
||||
*
|
||||
* @todo use exceptions only
|
||||
*/
|
||||
public static function validate($doc)
|
||||
public static function validate(DOMDocument $doc)
|
||||
{
|
||||
$rngfile = __DIR__
|
||||
. '/../../../../data/pear2.php.net/PEAR2_Console_CommandLine/xmlschema.rng';
|
||||
if (!is_file($rngfile)) {
|
||||
$rngfile = __DIR__ . '/../../../../data/xmlschema.rng';
|
||||
$paths = array();
|
||||
if (!class_exists('Phar', false) || !Phar::running()) {
|
||||
// Pyrus
|
||||
$paths[]
|
||||
= 'D:\Vasko\WEB\PHP\_shared\PEAR2\data/pear2.php.net/PEAR2_Console_CommandLine/xmlschema.rng';
|
||||
// PEAR
|
||||
$pearDataDirEnv = getenv('PHP_PEAR_DATA_DIR');
|
||||
if ($pearDataDirEnv) {
|
||||
$paths[] = $pearDataDirEnv .
|
||||
'/PEAR2_Console_CommandLine/xmlschema.rng';
|
||||
}
|
||||
$paths[] = 'D:\Vasko\WEB\PHP\_shared\PEAR2\data/PEAR2_Console_CommandLine/xmlschema.rng';
|
||||
}
|
||||
if (!is_readable($rngfile)) {
|
||||
CommandLine::triggerError(
|
||||
'invalid_xml_file',
|
||||
E_USER_ERROR,
|
||||
array('{$file}' => $rngfile)
|
||||
);
|
||||
$pkgData = __DIR__ . '/../../../../data/';
|
||||
// PHAR dep
|
||||
$paths[] = $pkgData .
|
||||
'pear2.php.net/PEAR2_Console_CommandLine/xmlschema.rng';
|
||||
$paths[] = $pkgData . 'PEAR2_Console_CommandLine/xmlschema.rng';
|
||||
$paths[] = $pkgData . 'pear2/console_commandline/xmlschema.rng';
|
||||
// Git/Composer
|
||||
$paths[] = $pkgData . 'xmlschema.rng';
|
||||
$paths[] = 'xmlschema.rng';
|
||||
|
||||
foreach ($paths as $path) {
|
||||
if (is_readable($path)) {
|
||||
return $doc->relaxNGValidate($path);
|
||||
}
|
||||
}
|
||||
return $doc->relaxNGValidate($rngfile);
|
||||
CommandLine::triggerError(
|
||||
'invalid_xml_file',
|
||||
E_USER_ERROR,
|
||||
array('{$file}' => $path)
|
||||
);
|
||||
}
|
||||
|
||||
// }}}
|
||||
@ -124,14 +149,15 @@ class XmlParser
|
||||
* constructed PEAR2\Console\CommandLine or PEAR2\Console\CommandLine_Command
|
||||
* instance.
|
||||
*
|
||||
* @param DomDocumentNode $node The node to parse
|
||||
* @param bool $isRootNode Whether it is a root node or not
|
||||
* @param DOMNode $node The node to parse
|
||||
* @param bool $isRootNode Whether it is a root node or not
|
||||
*
|
||||
* @return mixed PEAR2\Console\CommandLine or PEAR2\Console\CommandLine_Command
|
||||
* @return CommandLine|CommandLine\Command An instance of CommandLine for
|
||||
* root node, CommandLine\Command otherwise.
|
||||
*/
|
||||
private static function _parseCommandNode($node, $isRootNode = false)
|
||||
private static function _parseCommandNode(DOMNode $node, $isRootNode = false)
|
||||
{
|
||||
if ($isRootNode) {
|
||||
if ($isRootNode) {
|
||||
$obj = new CommandLine();
|
||||
} else {
|
||||
$obj = new CommandLine\Command();
|
||||
@ -184,11 +210,11 @@ class XmlParser
|
||||
* Parses an option node and returns the constructed
|
||||
* PEAR2\Console\CommandLine_Option instance.
|
||||
*
|
||||
* @param DomDocumentNode $node The node to parse
|
||||
* @param DOMNode $node The node to parse
|
||||
*
|
||||
* @return PEAR2\Console\CommandLine\Option The built option
|
||||
*/
|
||||
private static function _parseOptionNode($node)
|
||||
private static function _parseOptionNode(DOMNode $node)
|
||||
{
|
||||
$obj = new CommandLine\Option($node->getAttribute('name'));
|
||||
foreach ($node->childNodes as $cNode) {
|
||||
@ -221,14 +247,14 @@ class XmlParser
|
||||
// _parseArgumentNode() {{{
|
||||
|
||||
/**
|
||||
* Parses an argument node and returns the constructed
|
||||
* Parses an argument node and returns the constructed
|
||||
* PEAR2\Console\CommandLine_Argument instance.
|
||||
*
|
||||
* @param DomDocumentNode $node The node to parse
|
||||
* @param DOMNode $node The node to parse
|
||||
*
|
||||
* @return PEAR2\Console\CommandLine\Argument The built argument
|
||||
*/
|
||||
private static function _parseArgumentNode($node)
|
||||
private static function _parseArgumentNode(DOMNode $node)
|
||||
{
|
||||
$obj = new CommandLine\Argument($node->getAttribute('name'));
|
||||
foreach ($node->childNodes as $cNode) {
|
||||
@ -260,7 +286,7 @@ class XmlParser
|
||||
|
||||
/**
|
||||
* Returns a boolean according to true/false possible strings.
|
||||
*
|
||||
*
|
||||
* @param string $str The string to process
|
||||
*
|
||||
* @return boolean
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
/**
|
||||
* RouterOS API client implementation.
|
||||
|
||||
*
|
||||
* RouterOS is the flag product of the company MikroTik and is a powerful router software. One of its many abilities is to allow control over it via an API. This package provides a client for that API, in turn allowing you to use PHP to control RouterOS hosts.
|
||||
*
|
||||
@ -12,27 +13,31 @@
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2011 Vasil Rangelov
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version 1.0.0b5
|
||||
* @version 1.0.0b6
|
||||
* @link http://pear2.php.net/PEAR2_Net_RouterOS
|
||||
*/
|
||||
/**
|
||||
* The namespace declaration.
|
||||
*/
|
||||
|
||||
namespace PEAR2\Net\RouterOS;
|
||||
|
||||
/**
|
||||
* Refers to transmitter direction constants.
|
||||
*/
|
||||
|
||||
use PEAR2\Net\Transmitter\Stream as S;
|
||||
|
||||
/**
|
||||
* Refers to the cryptography constants.
|
||||
*/
|
||||
|
||||
use PEAR2\Net\Transmitter\NetworkStream as N;
|
||||
|
||||
/**
|
||||
* Catches arbitrary exceptions at some points.
|
||||
*/
|
||||
|
||||
use Exception as E;
|
||||
|
||||
/**
|
||||
@ -64,38 +69,55 @@ class Client
|
||||
const FILTER_ALL = 3;
|
||||
|
||||
/**
|
||||
* @var Communicator The communicator for this client.
|
||||
* The communicator for this client.
|
||||
*
|
||||
* @var Communicator
|
||||
*/
|
||||
protected $com;
|
||||
|
||||
/**
|
||||
* @var int The number of currently pending requests.
|
||||
* The number of currently pending requests.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $pendingRequestsCount = 0;
|
||||
|
||||
/**
|
||||
* @var array An array of responses that have not yet been extracted or
|
||||
* passed to a callback. Key is the tag of the request, and the value
|
||||
* is an array of associated responses.
|
||||
* An array of responses that have not yet been extracted
|
||||
* or passed to a callback.
|
||||
*
|
||||
* Key is the tag of the request, and the value is an array of
|
||||
* associated responses.
|
||||
*
|
||||
* @var array<string,Response[]>
|
||||
*/
|
||||
protected $responseBuffer = array();
|
||||
|
||||
/**
|
||||
* @var array An array of callbacks to be executed as responses come.
|
||||
* Key is the tag of the request, and the value is the callback for it.
|
||||
* An array of callbacks to be executed as responses come.
|
||||
*
|
||||
* Key is the tag of the request, and the value is the callback for it.
|
||||
*
|
||||
* @var array<string,callback>
|
||||
*/
|
||||
protected $callbacks = array();
|
||||
|
||||
/**
|
||||
* @var Registry A registry for the operations. Particularly helpful at
|
||||
* persistent connections.
|
||||
* A registry for the operations.
|
||||
*
|
||||
* Particularly helpful at persistent connections.
|
||||
*
|
||||
* @var Registry
|
||||
*/
|
||||
protected $registry = null;
|
||||
|
||||
/**
|
||||
* @var bool Whether to stream future responses.
|
||||
* Stream response words that are above this many bytes.
|
||||
* NULL to disable streaming completely.
|
||||
*
|
||||
* @var int|null
|
||||
*/
|
||||
private $_streamingResponses = false;
|
||||
private $_streamingResponses = null;
|
||||
|
||||
/**
|
||||
* Creates a new instance of a RouterOS API client.
|
||||
@ -103,24 +125,25 @@ class Client
|
||||
* Creates a new instance of a RouterOS API client with the specified
|
||||
* settings.
|
||||
*
|
||||
* @param string $host Hostname (IP or domain) of the RouterOS server.
|
||||
* @param string $username The RouterOS username.
|
||||
* @param string $password The RouterOS password.
|
||||
* @param int|null $port The port on which the RouterOS server provides
|
||||
* the API service. You can also specify NULL, in which case the port
|
||||
* will automatically be chosen between 8728 and 8729, depending on the
|
||||
* value of $crypto.
|
||||
* @param bool $persist Whether or not the connection should be a
|
||||
* @param string $host Hostname (IP or domain) of RouterOS.
|
||||
* @param string $username The RouterOS username.
|
||||
* @param string $password The RouterOS password.
|
||||
* @param int|null $port The port on which the RouterOS host
|
||||
* provides the API service. You can also specify NULL, in which case
|
||||
* the port will automatically be chosen between 8728 and 8729,
|
||||
* depending on the value of $crypto.
|
||||
* @param bool $persist Whether or not the connection should be a
|
||||
* persistent one.
|
||||
* @param float $timeout The timeout for the connection.
|
||||
* @param string $crypto The encryption for this connection. Must be one
|
||||
* of the PEAR2\Net\Transmitter\NetworkStream::CRYPTO_* constants. Off
|
||||
* by default. RouterOS currently supports only TLS, but the setting is
|
||||
* provided in this fashion for forward compatibility's sake. And for
|
||||
* the sake of simplicity, if you specify an encryption, don't specify a
|
||||
* context and your default context uses the value "DEFAULT" for
|
||||
* ciphers, "ADH" will be automatically added to the list of ciphers.
|
||||
* @param resource $context A context for the socket.
|
||||
* @param double|null $timeout The timeout for the connection.
|
||||
* @param string $crypto The encryption for this connection.
|
||||
* Must be one of the PEAR2\Net\Transmitter\NetworkStream::CRYPTO_*
|
||||
* constants. Off by default. RouterOS currently supports only TLS, but
|
||||
* the setting is provided in this fashion for forward compatibility's
|
||||
* sake. And for the sake of simplicity, if you specify an encryption,
|
||||
* don't specify a context and your default context uses the value
|
||||
* "DEFAULT" for ciphers, "ADH" will be automatically added to the list
|
||||
* of ciphers.
|
||||
* @param resource|null $context A context for the socket.
|
||||
*
|
||||
* @see sendSync()
|
||||
* @see sendAsync()
|
||||
@ -131,15 +154,10 @@ class Client
|
||||
$password = '',
|
||||
$port = 8728,
|
||||
$persist = false,
|
||||
$timeout = 10,
|
||||
$timeout = null,
|
||||
$crypto = N::CRYPTO_OFF,
|
||||
$context = null
|
||||
) {
|
||||
if(strpos($host,":")>-1){
|
||||
$part = explode(":",$host);
|
||||
$host = $part[0];
|
||||
$port = $part[1];
|
||||
}
|
||||
$this->com = new Communicator(
|
||||
$host,
|
||||
$port,
|
||||
@ -154,7 +172,7 @@ class Client
|
||||
: (int) $timeout;
|
||||
//Login the user if necessary
|
||||
if ((!$persist
|
||||
|| !($old = $this->com->getTransmitter()->lock(S::DIRECTION_ALL)))
|
||||
|| !($old = $this->com->getTransmitter()->lock(S::DIRECTION_ALL)))
|
||||
&& $this->com->getTransmitter()->isFresh()
|
||||
) {
|
||||
if (!static::login($this->com, $username, $password, $timeout)) {
|
||||
@ -183,7 +201,7 @@ class Client
|
||||
* the class is invoked and its returned value is returned by this function.
|
||||
*
|
||||
* @param mixed $arg Value can be either a {@link Request} to send, which
|
||||
* would be sent asynchoniously if it has a tag, and synchroniously if
|
||||
* would be sent asynchronously if it has a tag, and synchronously if
|
||||
* not, a number to loop with or NULL to complete all pending requests.
|
||||
* Any other value is converted to string and treated as the tag of a
|
||||
* request to complete.
|
||||
@ -210,7 +228,7 @@ class Client
|
||||
* @param string $username The RouterOS username.
|
||||
* @param string $password The RouterOS password.
|
||||
* @param int|null $timeout The time to wait for each response. NULL
|
||||
* waits indefinetly.
|
||||
* waits indefinitely.
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
@ -220,7 +238,8 @@ class Client
|
||||
$password = '',
|
||||
$timeout = null
|
||||
) {
|
||||
if (null !== ($remoteCharset = $com->getCharset($com::CHARSET_REMOTE))
|
||||
if (
|
||||
null !== ($remoteCharset = $com->getCharset($com::CHARSET_REMOTE))
|
||||
&& null !== ($localCharset = $com->getCharset($com::CHARSET_LOCAL))
|
||||
) {
|
||||
$password = iconv(
|
||||
@ -243,8 +262,8 @@ class Client
|
||||
$com->getTransmitter()->lock($old, true);
|
||||
}
|
||||
throw ($e instanceof NotSupportedException
|
||||
|| $e instanceof UnexpectedValueException
|
||||
|| !$com->getTransmitter()->isDataAwaiting()) ? new SocketException(
|
||||
|| $e instanceof UnexpectedValueException
|
||||
|| !$com->getTransmitter()->isDataAwaiting()) ? new SocketException(
|
||||
'This is not a compatible RouterOS service',
|
||||
SocketException::CODE_SERVICE_INCOMPATIBLE,
|
||||
$e
|
||||
@ -263,7 +282,7 @@ class Client
|
||||
* @param string $password The RouterOS password. Potentially parsed
|
||||
* already by iconv.
|
||||
* @param int|null $timeout The time to wait for each response. NULL
|
||||
* waits indefinetly.
|
||||
* waits indefinitely.
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
@ -274,15 +293,48 @@ class Client
|
||||
$timeout = null
|
||||
) {
|
||||
$request = new Request('/login');
|
||||
// Update Mikrotik Versi terbaru
|
||||
// sayangnya ini ngga aman, bagusnya di setup ke port SSL
|
||||
$request->setArgument('name', $username);
|
||||
$request->setArgument('password', $password);
|
||||
$request->send($com);
|
||||
$oldCharset = $com->getCharset($com::CHARSET_ALL);
|
||||
$com->setCharset(null, $com::CHARSET_ALL);
|
||||
$request->verify($com)->send($com);
|
||||
$com->setCharset($oldCharset, $com::CHARSET_ALL);
|
||||
$response = new Response($com, false, $timeout);
|
||||
return $response->getType() === Response::TYPE_FINAL;
|
||||
null === $response->getProperty('ret');
|
||||
}
|
||||
if (
|
||||
$response->getType() === Response::TYPE_FINAL
|
||||
&& null === $response->getProperty('ret')
|
||||
) {
|
||||
// version >= 6.43
|
||||
return null === $response->getProperty('message');
|
||||
} elseif ($response->getType() === Response::TYPE_FINAL) {
|
||||
// version < 6.43
|
||||
$request->setArgument('password', '');
|
||||
$request->setArgument(
|
||||
'response',
|
||||
'00' . md5(
|
||||
chr(0) . $password
|
||||
. pack(
|
||||
'H*',
|
||||
is_string($response->getProperty('ret'))
|
||||
? $response->getProperty('ret')
|
||||
: stream_get_contents($response->getProperty('ret'))
|
||||
)
|
||||
)
|
||||
);
|
||||
$request->verify($com)->send($com);
|
||||
$response = new Response($com, false, $timeout);
|
||||
if ($response->getType() === Response::TYPE_FINAL) {
|
||||
return null === $response->getProperty('ret');
|
||||
}
|
||||
}
|
||||
while (
|
||||
$response->getType() !== Response::TYPE_FINAL
|
||||
&& $response->getType() !== Response::TYPE_FATAL
|
||||
) {
|
||||
$response = new Response($com, false, $timeout);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the charset(s) for this connection.
|
||||
@ -293,7 +345,7 @@ class Client
|
||||
* {@link Communicator::CHARSET_REMOTE}, and when receiving,
|
||||
* {@link Communicator::CHARSET_REMOTE} is converted to
|
||||
* {@link Communicator::CHARSET_LOCAL}. Setting NULL to either charset will
|
||||
* disable charset convertion, and data will be both sent and received "as
|
||||
* disable charset conversion, and data will be both sent and received "as
|
||||
* is".
|
||||
*
|
||||
* @param mixed $charset The charset to set. If $charsetType is
|
||||
@ -307,6 +359,7 @@ class Client
|
||||
* @return string|array The old charset. If $charsetType is
|
||||
* {@link Communicator::CHARSET_ALL}, the old values will be returned as
|
||||
* an array with the types as keys, and charsets as values.
|
||||
*
|
||||
* @see Communicator::setDefaultCharset()
|
||||
*/
|
||||
public function setCharset(
|
||||
@ -326,6 +379,7 @@ class Client
|
||||
* @return string|array The current charset. If $charsetType is
|
||||
* {@link Communicator::CHARSET_ALL}, the current values will be
|
||||
* returned as an array with the types as keys, and charsets as values.
|
||||
*
|
||||
* @see setCharset()
|
||||
*/
|
||||
public function getCharset($charsetType)
|
||||
@ -336,16 +390,18 @@ class Client
|
||||
/**
|
||||
* Sends a request and waits for responses.
|
||||
*
|
||||
* @param Request $request The request to send.
|
||||
* @param callback $callback Optional. A function that is to be executed
|
||||
* when new responses for this request are available. The callback takes
|
||||
* two parameters. The {@link Response} object as the first, and the
|
||||
* {@link Client} object as the second one. If the function returns
|
||||
* TRUE, the request is canceled. Note that the callback may be executed
|
||||
* one last time after that with a response that notifies about the
|
||||
* canceling.
|
||||
* @param Request $request The request to send.
|
||||
* @param callback|null $callback Optional. A function that is to be
|
||||
* executed when new responses for this request are available.
|
||||
* The callback takes two parameters. The {@link Response} object as
|
||||
* the first, and the {@link Client} object as the second one. If the
|
||||
* callback returns TRUE, the request is canceled. Note that the
|
||||
* callback may be executed at least two times after that. Once with a
|
||||
* {@link Response::TYPE_ERROR} response that notifies about the
|
||||
* canceling, plus the {@link Response::TYPE_FINAL} response.
|
||||
*
|
||||
* @return $this The client object.
|
||||
*
|
||||
* @see completeRequest()
|
||||
* @see loop()
|
||||
* @see cancelRequest()
|
||||
@ -354,7 +410,7 @@ class Client
|
||||
{
|
||||
//Error checking
|
||||
$tag = $request->getTag();
|
||||
if ('' == $tag) {
|
||||
if ('' === (string)$tag) {
|
||||
throw new DataFlowException(
|
||||
'Asynchonous commands must have a tag.',
|
||||
DataFlowException::CODE_TAG_REQUIRED
|
||||
@ -392,10 +448,11 @@ class Client
|
||||
* pending request and/or has responses that are not yet extracted.
|
||||
*
|
||||
* @param string $tag The tag of the request to look for.
|
||||
* @param int $filter One of the FILTER_* consntants. Limits the search
|
||||
* @param int $filter One of the FILTER_* constants. Limits the search
|
||||
* to the specified places.
|
||||
*
|
||||
* @return bool TRUE if the request is active, FALSE otherwise.
|
||||
*
|
||||
* @see getPendingRequestsCount()
|
||||
* @see completeRequest()
|
||||
*/
|
||||
@ -417,6 +474,7 @@ class Client
|
||||
* @param Request $request The request to send.
|
||||
*
|
||||
* @return ResponseCollection The received responses as a collection.
|
||||
*
|
||||
* @see sendAsync()
|
||||
* @see close()
|
||||
*/
|
||||
@ -437,8 +495,8 @@ class Client
|
||||
* Starts an event loop for the RouterOS callbacks and finishes when a
|
||||
* specified request is completed.
|
||||
*
|
||||
* @param string $tag The tag of the request to complete. Setting NULL
|
||||
* completes all requests.
|
||||
* @param string|null $tag The tag of the request to complete.
|
||||
* Setting NULL completes all requests.
|
||||
*
|
||||
* @return ResponseCollection A collection of {@link Response} objects that
|
||||
* haven't been passed to a callback function or previously extracted
|
||||
@ -452,7 +510,7 @@ class Client
|
||||
$result = $hasNoTag ? array()
|
||||
: $this->extractNewResponses($tag)->toArray();
|
||||
while ((!$hasNoTag && $this->isRequestActive($tag))
|
||||
|| ($hasNoTag && 0 !== $this->getPendingRequestsCount())
|
||||
|| ($hasNoTag && 0 !== $this->getPendingRequestsCount())
|
||||
) {
|
||||
$newReply = $this->dispatchNextResponse(null);
|
||||
if ($newReply->getTag() === $tag) {
|
||||
@ -464,8 +522,8 @@ class Client
|
||||
$result = array_merge(
|
||||
$result,
|
||||
$this->isRequestActive($tag)
|
||||
? $this->extractNewResponses($tag)->toArray()
|
||||
: array()
|
||||
? $this->extractNewResponses($tag)->toArray()
|
||||
: array()
|
||||
);
|
||||
}
|
||||
break;
|
||||
@ -481,11 +539,13 @@ class Client
|
||||
* Gets all new responses for a request that haven't been passed to a
|
||||
* callback and clears the buffer from them.
|
||||
*
|
||||
* @param string $tag The tag of the request to extract new responses for.
|
||||
* @param string|null $tag The tag of the request to extract
|
||||
* new responses for.
|
||||
* Specifying NULL with extract new responses for all requests.
|
||||
*
|
||||
* @return ResponseCollection A collection of {@link Response} objects for
|
||||
* the specified request.
|
||||
*
|
||||
* @see loop()
|
||||
*/
|
||||
public function extractNewResponses($tag = null)
|
||||
@ -526,12 +586,13 @@ class Client
|
||||
* are no more pending requests or when a specified timeout has passed
|
||||
* (whichever comes first).
|
||||
*
|
||||
* @param int $sTimeout Timeout for the loop. If NULL, there is no time
|
||||
* limit.
|
||||
* @param int $usTimeout Microseconds to add to the time limit.
|
||||
* @param int|null $sTimeout Timeout for the loop.
|
||||
* If NULL, there is no time limit.
|
||||
* @param int $usTimeout Microseconds to add to the time limit.
|
||||
*
|
||||
* @return bool TRUE when there are any more pending requests, FALSE
|
||||
* otherwise.
|
||||
*
|
||||
* @see extractNewResponses()
|
||||
* @see getPendingRequestsCount()
|
||||
*/
|
||||
@ -544,7 +605,8 @@ class Client
|
||||
}
|
||||
} else {
|
||||
list($usStart, $sStart) = explode(' ', microtime());
|
||||
while ($this->getPendingRequestsCount() !== 0
|
||||
while (
|
||||
$this->getPendingRequestsCount() !== 0
|
||||
&& ($sTimeout >= 0 || $usTimeout >= 0)
|
||||
) {
|
||||
$this->dispatchNextResponse($sTimeout, $usTimeout);
|
||||
@ -581,6 +643,7 @@ class Client
|
||||
* Gets the number of pending requests.
|
||||
*
|
||||
* @return int The number of pending requests.
|
||||
*
|
||||
* @see isRequestActive()
|
||||
*/
|
||||
public function getPendingRequestsCount()
|
||||
@ -592,22 +655,23 @@ class Client
|
||||
* Cancels a request.
|
||||
*
|
||||
* Cancels an active request. Using this function in favor of a plain call
|
||||
* to the "/cancel" command is highly reccomended, as it also updates the
|
||||
* to the "/cancel" command is highly recommended, as it also updates the
|
||||
* counter of pending requests properly. Note that canceling a request also
|
||||
* removes any responses for it that were not previously extracted with
|
||||
* {@link static::extractNewResponses()}.
|
||||
*
|
||||
* @param string $tag Tag of the request to cancel. Setting NULL will cancel
|
||||
* all requests.
|
||||
* @param string|null $tag Tag of the request to cancel.
|
||||
* Setting NULL will cancel all requests.
|
||||
*
|
||||
* @return $this The client object.
|
||||
*
|
||||
* @see sendAsync()
|
||||
* @see close()
|
||||
*/
|
||||
public function cancelRequest($tag = null)
|
||||
{
|
||||
$cancelRequest = new Request('/cancel');
|
||||
$hasTag = !('' == $tag);
|
||||
$hasTag = !('' === (string)$tag);
|
||||
$hasReg = null !== $this->registry;
|
||||
if ($hasReg && !$hasTag) {
|
||||
$tags = array_merge(
|
||||
@ -663,32 +727,39 @@ class Client
|
||||
/**
|
||||
* Sets response streaming setting.
|
||||
*
|
||||
* Sets whether future responses are streamed. If responses are streamed,
|
||||
* the argument values are returned as streams instead of strings. This is
|
||||
* particularly useful if you expect a response that may contain one or more
|
||||
* very large words.
|
||||
* Sets when future response words are streamed. If a word is streamed,
|
||||
* the property value is returned a stream instead of a string, and
|
||||
* unrecognized words are returned entirely as streams instead of strings.
|
||||
* This is particularly useful if you expect a response that may contain
|
||||
* one or more very large words.
|
||||
*
|
||||
* @param bool $streamingResponses Whether to stream future responses.
|
||||
* @param int|null $threshold Threshold after which to stream
|
||||
* a word. That is, a word less than this length will not be streamed.
|
||||
* If set to 0, effectively all words are streamed.
|
||||
* NULL to disable streaming altogether.
|
||||
*
|
||||
* @return bool The previous value of the setting.
|
||||
* @see isStreamingResponses()
|
||||
* @return $this The client object.
|
||||
*
|
||||
* @see getStreamingResponses()
|
||||
*/
|
||||
public function setStreamingResponses($streamingResponses)
|
||||
public function setStreamingResponses($threshold)
|
||||
{
|
||||
$oldValue = $this->_streamingResponses;
|
||||
$this->_streamingResponses = (bool) $streamingResponses;
|
||||
return $oldValue;
|
||||
$this->_streamingResponses = $threshold === null
|
||||
? null
|
||||
: (int) $threshold;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets response streaming setting.
|
||||
*
|
||||
* Gets whether future responses are streamed.
|
||||
* Gets when future response words are streamed.
|
||||
*
|
||||
* @return int|null The value of the setting.
|
||||
*
|
||||
* @return bool The value of the setting.
|
||||
* @see setStreamingResponses()
|
||||
*/
|
||||
public function isStreamingResponses()
|
||||
public function getStreamingResponses()
|
||||
{
|
||||
return $this->_streamingResponses;
|
||||
}
|
||||
@ -758,12 +829,13 @@ class Client
|
||||
* @param Request $request The request to send.
|
||||
*
|
||||
* @return $this The client object.
|
||||
*
|
||||
* @see sendSync()
|
||||
* @see sendAsync()
|
||||
*/
|
||||
protected function send(Request $request)
|
||||
{
|
||||
$request->send($this->com, $this->registry);
|
||||
$request->verify($this->com)->send($this->com, $this->registry);
|
||||
$this->pendingRequestsCount++;
|
||||
return $this;
|
||||
}
|
||||
@ -774,12 +846,13 @@ class Client
|
||||
* Dispatches the next response in queue, i.e. it executes the associated
|
||||
* callback if there is one, or places the response in the response buffer.
|
||||
*
|
||||
* @param int $sTimeout If a response is not immediatly available, wait
|
||||
* this many seconds. If NULL, wait indefinetly.
|
||||
* @param int $usTimeout Microseconds to add to the waiting time.
|
||||
* @param int|null $sTimeout If a response is not immediately available,
|
||||
* wait this many seconds.
|
||||
* If NULL, wait indefinitely.
|
||||
* @param int $usTimeout Microseconds to add to the waiting time.
|
||||
*
|
||||
* @return Response The dispatched response.
|
||||
* @throws SocketException When there's no response within the time limit.
|
||||
* @return Response The dispatched response.
|
||||
*/
|
||||
protected function dispatchNextResponse($sTimeout = 0, $usTimeout = 0)
|
||||
{
|
||||
@ -802,10 +875,18 @@ class Client
|
||||
$this->pendingRequestsCount--;
|
||||
}
|
||||
|
||||
if ('' != $tag) {
|
||||
if ('' !== (string)$tag) {
|
||||
if ($this->isRequestActive($tag, self::FILTER_CALLBACK)) {
|
||||
if ($this->callbacks[$tag]($response, $this)) {
|
||||
$this->cancelRequest($tag);
|
||||
try {
|
||||
$this->cancelRequest($tag);
|
||||
} catch (DataFlowException $e) {
|
||||
if (
|
||||
$e->getCode() !== $e::CODE_UNKNOWN_REQUEST
|
||||
) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
} elseif ($isLastForRequest) {
|
||||
unset($this->callbacks[$tag]);
|
||||
}
|
||||
|
@ -2,17 +2,18 @@
|
||||
|
||||
/**
|
||||
* RouterOS API client implementation.
|
||||
*
|
||||
|
||||
*
|
||||
* RouterOS is the flag product of the company MikroTik and is a powerful router software. One of its many abilities is to allow control over it via an API. This package provides a client for that API, in turn allowing you to use PHP to control RouterOS hosts.
|
||||
*
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
*
|
||||
* @category Net
|
||||
* @package PEAR2_Net_RouterOS
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2011 Vasil Rangelov
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version 1.0.0b5
|
||||
* @version 1.0.0b6
|
||||
* @link http://pear2.php.net/PEAR2_Net_RouterOS
|
||||
*/
|
||||
/**
|
||||
@ -27,13 +28,13 @@ use PEAR2\Net\Transmitter as T;
|
||||
|
||||
/**
|
||||
* A RouterOS communicator.
|
||||
*
|
||||
*
|
||||
* Implementation of the RouterOS API protocol. Unlike the other classes in this
|
||||
* package, this class doesn't provide any conviniences beyond the low level
|
||||
* package, this class doesn't provide any conveniences beyond the low level
|
||||
* implementation details (automatic word length encoding/decoding, charset
|
||||
* translation and data integrity), and because of that, its direct usage is
|
||||
* strongly discouraged.
|
||||
*
|
||||
*
|
||||
* @category Net
|
||||
* @package PEAR2_Net_RouterOS
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
@ -47,67 +48,76 @@ class Communicator
|
||||
* Used when getting/setting all (default) charsets.
|
||||
*/
|
||||
const CHARSET_ALL = -1;
|
||||
|
||||
|
||||
/**
|
||||
* Used when getting/setting the (default) remote charset.
|
||||
*
|
||||
*
|
||||
* The remote charset is the charset in which RouterOS stores its data.
|
||||
* If you want to keep compatibility with your Winbox, this charset should
|
||||
* match the default charset from your Windows' regional settings.
|
||||
*/
|
||||
const CHARSET_REMOTE = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Used when getting/setting the (default) local charset.
|
||||
*
|
||||
*
|
||||
* The local charset is the charset in which the data from RouterOS will be
|
||||
* returned as. This charset should match the charset of the place the data
|
||||
* will eventually be written to.
|
||||
*/
|
||||
const CHARSET_LOCAL = 1;
|
||||
|
||||
|
||||
/**
|
||||
* @var array An array with the default charset types as keys, and the
|
||||
* default charsets as values.
|
||||
* An array with the default charset.
|
||||
*
|
||||
* Charset types as keys, and the default charsets as values.
|
||||
*
|
||||
* @var array<string,string|null>
|
||||
*/
|
||||
protected static $defaultCharsets = array(
|
||||
self::CHARSET_REMOTE => null,
|
||||
self::CHARSET_LOCAL => null
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* @var array An array with the current charset types as keys, and the
|
||||
* current charsets as values.
|
||||
* An array with the current charset.
|
||||
*
|
||||
* Charset types as keys, and the current charsets as values.
|
||||
*
|
||||
* @var array<string,string|null>
|
||||
*/
|
||||
protected $charsets = array();
|
||||
|
||||
/**
|
||||
* @var T\TcpClient The transmitter for the connection.
|
||||
* The transmitter for the connection.
|
||||
*
|
||||
* @var T\TcpClient
|
||||
*/
|
||||
protected $trans;
|
||||
|
||||
/**
|
||||
* Creates a new connection with the specified options.
|
||||
*
|
||||
* @param string $host Hostname (IP or domain) of the RouterOS server.
|
||||
* @param int|null $port The port on which the RouterOS server provides
|
||||
* the API service. You can also specify NULL, in which case the port
|
||||
* will automatically be chosen between 8728 and 8729, depending on the
|
||||
* value of $crypto.
|
||||
* @param bool $persist Whether or not the connection should be a
|
||||
*
|
||||
* @param string $host Hostname (IP or domain) of RouterOS.
|
||||
* @param int|null $port The port on which the RouterOS host
|
||||
* provides the API service. You can also specify NULL, in which case
|
||||
* the port will automatically be chosen between 8728 and 8729,
|
||||
* depending on the value of $crypto.
|
||||
* @param bool $persist Whether or not the connection should be a
|
||||
* persistent one.
|
||||
* @param float $timeout The timeout for the connection.
|
||||
* @param string $key A string that uniquely identifies the
|
||||
* @param double|null $timeout The timeout for the connection.
|
||||
* @param string $key A string that uniquely identifies the
|
||||
* connection.
|
||||
* @param string $crypto The encryption for this connection. Must be one
|
||||
* of the PEAR2\Net\Transmitter\NetworkStream::CRYPTO_* constants. Off
|
||||
* by default. RouterOS currently supports only TLS, but the setting is
|
||||
* provided in this fashion for forward compatibility's sake. And for
|
||||
* the sake of simplicity, if you specify an encryption, don't specify a
|
||||
* context and your default context uses the value "DEFAULT" for
|
||||
* ciphers, "ADH" will be automatically added to the list of ciphers.
|
||||
* @param resource $context A context for the socket.
|
||||
*
|
||||
* @param string $crypto The encryption for this connection.
|
||||
* Must be one of the PEAR2\Net\Transmitter\NetworkStream::CRYPTO_*
|
||||
* constants. Off by default. RouterOS currently supports only TLS, but
|
||||
* the setting is provided in this fashion for forward compatibility's
|
||||
* sake. And for the sake of simplicity, if you specify an encryption,
|
||||
* don't specify a context and your default context uses the value
|
||||
* "DEFAULT" for ciphers, "ADH" will be automatically added to the list
|
||||
* of ciphers.
|
||||
* @param resource|null $context A context for the socket.
|
||||
*
|
||||
* @see sendWord()
|
||||
*/
|
||||
public function __construct(
|
||||
@ -126,7 +136,16 @@ class Communicator
|
||||
if (!isset($opts['ssl']['ciphers'])
|
||||
|| 'DEFAULT' === $opts['ssl']['ciphers']
|
||||
) {
|
||||
stream_context_set_option($context, 'ssl', 'ciphers', 'ADH');
|
||||
stream_context_set_option(
|
||||
$context,
|
||||
array(
|
||||
'ssl' => array(
|
||||
'ciphers' => 'ADH',
|
||||
'verify_peer' => false,
|
||||
'verify_peer_name' => false
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
// @codeCoverageIgnoreStart
|
||||
@ -158,31 +177,31 @@ class Communicator
|
||||
self::CHARSET_ALL
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A shorthand gateway.
|
||||
*
|
||||
*
|
||||
* This is a magic PHP method that allows you to call the object as a
|
||||
* function. Depending on the argument given, one of the other functions in
|
||||
* the class is invoked and its returned value is returned by this function.
|
||||
*
|
||||
* @param string $string A string of the word to send, or NULL to get the
|
||||
* next word as a string.
|
||||
*
|
||||
*
|
||||
* @param string|null $string A string of the word to send, or NULL to get
|
||||
* the next word as a string.
|
||||
*
|
||||
* @return int|string If a string is provided, returns the number of bytes
|
||||
* sent, otherwise retuns the next word as a string.
|
||||
* sent, otherwise returns the next word as a string.
|
||||
*/
|
||||
public function __invoke($string = null)
|
||||
{
|
||||
return null === $string ? $this->getNextWord()
|
||||
: $this->sendWord($string);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks whether a variable is a seekable stream resource.
|
||||
*
|
||||
*
|
||||
* @param mixed $var The value to check.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE if $var is a seekable stream, FALSE otherwise.
|
||||
*/
|
||||
public static function isSeekableStream($var)
|
||||
@ -193,16 +212,16 @@ class Communicator
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Uses iconv to convert a stream from one charset to another.
|
||||
*
|
||||
*
|
||||
* @param string $inCharset The charset of the stream.
|
||||
* @param string $outCharset The desired resulting charset.
|
||||
* @param resource $stream The stream to convert. The stream is assumed
|
||||
* to be seekable, and is read from its current position to its end,
|
||||
* after which, it is seeked back to its starting position.
|
||||
*
|
||||
*
|
||||
* @return resource A new stream that uses the $out_charset. The stream is a
|
||||
* subset from the original stream, from its current position to its
|
||||
* end, seeked at its start.
|
||||
@ -216,22 +235,25 @@ class Communicator
|
||||
'convert.iconv.' . $inCharset . '.' . $outCharset,
|
||||
STREAM_FILTER_WRITE
|
||||
);
|
||||
|
||||
|
||||
flock($stream, LOCK_SH);
|
||||
while (!feof($stream)) {
|
||||
$bytes += stream_copy_to_stream($stream, $result, 0xFFFFF);
|
||||
$reader = new T\Stream($stream, false);
|
||||
$writer = new T\Stream($result, false);
|
||||
$chunkSize = $reader->getChunk(T\Stream::DIRECTION_RECEIVE);
|
||||
while ($reader->isAvailable() && $reader->isDataAwaiting()) {
|
||||
$bytes += $writer->send(fread($stream, $chunkSize));
|
||||
}
|
||||
fseek($stream, -$bytes, SEEK_CUR);
|
||||
flock($stream, LOCK_UN);
|
||||
|
||||
|
||||
stream_filter_remove($iconvFilter);
|
||||
rewind($result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the default charset(s) for new connections.
|
||||
*
|
||||
*
|
||||
* @param mixed $charset The charset to set. If $charsetType is
|
||||
* {@link self::CHARSET_ALL}, you can supply either a string to use for
|
||||
* all charsets, or an array with the charset types as keys, and the
|
||||
@ -239,10 +261,11 @@ class Communicator
|
||||
* @param int $charsetType Which charset to set. Valid values are the
|
||||
* CHARSET_* constants. Any other value is treated as
|
||||
* {@link self::CHARSET_ALL}.
|
||||
*
|
||||
*
|
||||
* @return string|array The old charset. If $charsetType is
|
||||
* {@link self::CHARSET_ALL}, the old values will be returned as an
|
||||
* array with the types as keys, and charsets as values.
|
||||
*
|
||||
* @see setCharset()
|
||||
*/
|
||||
public static function setDefaultCharset(
|
||||
@ -263,17 +286,18 @@ class Communicator
|
||||
return $oldCharsets;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the default charset(s).
|
||||
*
|
||||
*
|
||||
* @param int $charsetType Which charset to get. Valid values are the
|
||||
* CHARSET_* constants. Any other value is treated as
|
||||
* {@link self::CHARSET_ALL}.
|
||||
*
|
||||
*
|
||||
* @return string|array The current charset. If $charsetType is
|
||||
* {@link self::CHARSET_ALL}, the current values will be returned as an
|
||||
* array with the types as keys, and charsets as values.
|
||||
*
|
||||
* @see setDefaultCharset()
|
||||
*/
|
||||
public static function getDefaultCharset($charsetType)
|
||||
@ -284,12 +308,12 @@ class Communicator
|
||||
|
||||
/**
|
||||
* Gets the length of a seekable stream.
|
||||
*
|
||||
*
|
||||
* Gets the length of a seekable stream.
|
||||
*
|
||||
*
|
||||
* @param resource $stream The stream to check. The stream is assumed to be
|
||||
* seekable.
|
||||
*
|
||||
*
|
||||
* @return double The number of bytes in the stream between its current
|
||||
* position and its end.
|
||||
*/
|
||||
@ -302,17 +326,17 @@ class Communicator
|
||||
fseek($stream, $streamPosition, SEEK_SET);
|
||||
return $streamLength;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the charset(s) for this connection.
|
||||
*
|
||||
*
|
||||
* Sets the charset(s) for this connection. The specified charset(s) will be
|
||||
* used for all future words. When sending, {@link self::CHARSET_LOCAL} is
|
||||
* converted to {@link self::CHARSET_REMOTE}, and when receiving,
|
||||
* {@link self::CHARSET_REMOTE} is converted to {@link self::CHARSET_LOCAL}.
|
||||
* Setting NULL to either charset will disable charset convertion, and data
|
||||
* Setting NULL to either charset will disable charset conversion, and data
|
||||
* will be both sent and received "as is".
|
||||
*
|
||||
*
|
||||
* @param mixed $charset The charset to set. If $charsetType is
|
||||
* {@link self::CHARSET_ALL}, you can supply either a string to use for
|
||||
* all charsets, or an array with the charset types as keys, and the
|
||||
@ -320,10 +344,11 @@ class Communicator
|
||||
* @param int $charsetType Which charset to set. Valid values are the
|
||||
* CHARSET_* constants. Any other value is treated as
|
||||
* {@link self::CHARSET_ALL}.
|
||||
*
|
||||
*
|
||||
* @return string|array The old charset. If $charsetType is
|
||||
* {@link self::CHARSET_ALL}, the old values will be returned as an
|
||||
* array with the types as keys, and charsets as values.
|
||||
*
|
||||
* @see setDefaultCharset()
|
||||
*/
|
||||
public function setCharset($charset, $charsetType = self::CHARSET_ALL)
|
||||
@ -342,17 +367,18 @@ class Communicator
|
||||
return $oldCharsets;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the charset(s) for this connection.
|
||||
*
|
||||
*
|
||||
* @param int $charsetType Which charset to get. Valid values are the
|
||||
* CHARSET_* constants. Any other value is treated as
|
||||
* {@link self::CHARSET_ALL}.
|
||||
*
|
||||
*
|
||||
* @return string|array The current charset. If $charsetType is
|
||||
* {@link self::CHARSET_ALL}, the current values will be returned as an
|
||||
* array with the types as keys, and charsets as values.
|
||||
*
|
||||
* @see getDefaultCharset()
|
||||
* @see setCharset()
|
||||
*/
|
||||
@ -364,7 +390,7 @@ class Communicator
|
||||
|
||||
/**
|
||||
* Gets the transmitter for this connection.
|
||||
*
|
||||
*
|
||||
* @return T\TcpClient The transmitter for this connection.
|
||||
*/
|
||||
public function getTransmitter()
|
||||
@ -374,12 +400,13 @@ class Communicator
|
||||
|
||||
/**
|
||||
* Sends a word.
|
||||
*
|
||||
*
|
||||
* Sends a word and automatically encodes its length when doing so.
|
||||
*
|
||||
*
|
||||
* @param string $word The word to send.
|
||||
*
|
||||
*
|
||||
* @return int The number of bytes sent.
|
||||
*
|
||||
* @see sendWordFromStream()
|
||||
* @see getNextWord()
|
||||
*/
|
||||
@ -407,16 +434,17 @@ class Communicator
|
||||
|
||||
/**
|
||||
* Sends a word based on a stream.
|
||||
*
|
||||
*
|
||||
* Sends a word based on a stream and automatically encodes its length when
|
||||
* doing so. The stream is read from its current position to its end, and
|
||||
* then returned to its current position. Because of those operations, the
|
||||
* supplied stream must be seekable.
|
||||
*
|
||||
*
|
||||
* @param string $prefix A string to prepend before the stream contents.
|
||||
* @param resource $stream The seekable stream to send.
|
||||
*
|
||||
*
|
||||
* @return int The number of bytes sent.
|
||||
*
|
||||
* @see sendWord()
|
||||
*/
|
||||
public function sendWordFromStream($prefix, $stream)
|
||||
@ -441,31 +469,31 @@ class Communicator
|
||||
$stream
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
flock($stream, LOCK_SH);
|
||||
$totalLength = strlen($prefix) + self::seekableStreamLength($stream);
|
||||
static::verifyLengthSupport($totalLength);
|
||||
|
||||
$bytes = $this->trans->send(self::encodeLength($totalLength) . $prefix);
|
||||
$bytes += $this->trans->send($stream);
|
||||
|
||||
|
||||
flock($stream, LOCK_UN);
|
||||
return $bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the length is supported.
|
||||
*
|
||||
*
|
||||
* Verifies if the specified length is supported by the API. Throws a
|
||||
* {@link LengthException} if that's not the case. Currently, RouterOS
|
||||
* supports words up to 0xFFFFFFFF in length, so that's the only check
|
||||
* performed.
|
||||
*
|
||||
*
|
||||
* @param int $length The length to verify.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function verifyLengthSupport($length)
|
||||
public static function verifyLengthSupport($length)
|
||||
{
|
||||
if ($length > 0xFFFFFFFF) {
|
||||
throw new LengthException(
|
||||
@ -478,10 +506,10 @@ class Communicator
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the length as requred by the RouterOS API.
|
||||
*
|
||||
* Encodes the length as required by the RouterOS API.
|
||||
*
|
||||
* @param int $length The length to encode.
|
||||
*
|
||||
*
|
||||
* @return string The encoded length.
|
||||
*/
|
||||
public static function encodeLength($length)
|
||||
@ -519,11 +547,12 @@ class Communicator
|
||||
|
||||
/**
|
||||
* Get the next word in queue as a string.
|
||||
*
|
||||
*
|
||||
* Get the next word in queue as a string, after automatically decoding its
|
||||
* length.
|
||||
*
|
||||
*
|
||||
* @return string The word.
|
||||
*
|
||||
* @see close()
|
||||
*/
|
||||
public function getNextWord()
|
||||
@ -541,7 +570,7 @@ class Communicator
|
||||
'word'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (null !== ($remoteCharset = $this->getCharset(self::CHARSET_REMOTE))
|
||||
&& null !== ($localCharset = $this->getCharset(self::CHARSET_LOCAL))
|
||||
) {
|
||||
@ -551,17 +580,18 @@ class Communicator
|
||||
$word
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return $word;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next word in queue as a stream.
|
||||
*
|
||||
*
|
||||
* Get the next word in queue as a stream, after automatically decoding its
|
||||
* length.
|
||||
*
|
||||
*
|
||||
* @return resource The word, as a stream.
|
||||
*
|
||||
* @see close()
|
||||
*/
|
||||
public function getNextWordAsStream()
|
||||
@ -575,7 +605,7 @@ class Communicator
|
||||
$remoteCharset . '.' . $localCharset . '//IGNORE//TRANSLIT'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ($this->trans->isPersistent()) {
|
||||
$old = $this->trans->lock(T\Stream::DIRECTION_RECEIVE);
|
||||
$stream = $this->trans->receiveStream(
|
||||
@ -591,20 +621,21 @@ class Communicator
|
||||
'stream word'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return $stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the lenght of the incoming message.
|
||||
*
|
||||
* Decodes the lenght of the incoming message, as specified by the RouterOS
|
||||
* Decodes the length of the incoming message.
|
||||
*
|
||||
* Decodes the length of the incoming message, as specified by the RouterOS
|
||||
* API.
|
||||
*
|
||||
*
|
||||
* @param T\Stream $trans The transmitter from which to decode the length of
|
||||
* the incoming message.
|
||||
*
|
||||
* @return int The decoded length.
|
||||
*
|
||||
* @return int|double The decoded length.
|
||||
* Is of type "double" only for values above "2 << 31".
|
||||
*/
|
||||
public static function decodeLength(T\Stream $trans)
|
||||
{
|
||||
@ -618,18 +649,19 @@ class Communicator
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the lenght of the incoming message.
|
||||
*
|
||||
* Decodes the lenght of the incoming message, as specified by the RouterOS
|
||||
* Decodes the length of the incoming message.
|
||||
*
|
||||
* Decodes the length of the incoming message, as specified by the RouterOS
|
||||
* API.
|
||||
*
|
||||
*
|
||||
* Difference with the non private function is that this one doesn't perform
|
||||
* locking if the connection is a persistent one.
|
||||
*
|
||||
*
|
||||
* @param T\Stream $trans The transmitter from which to decode the length of
|
||||
* the incoming message.
|
||||
*
|
||||
* @return int The decoded length.
|
||||
*
|
||||
* @return int|double The decoded length.
|
||||
* Is of type "double" only for values above "2 << 31".
|
||||
*/
|
||||
private static function _decodeLength(T\Stream $trans)
|
||||
{
|
||||
@ -661,7 +693,7 @@ class Communicator
|
||||
|
||||
/**
|
||||
* Closes the opened connection, even if it is a persistent one.
|
||||
*
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure.
|
||||
*/
|
||||
public function close()
|
||||
|
@ -2,17 +2,18 @@
|
||||
|
||||
/**
|
||||
* RouterOS API client implementation.
|
||||
*
|
||||
|
||||
*
|
||||
* RouterOS is the flag product of the company MikroTik and is a powerful router software. One of its many abilities is to allow control over it via an API. This package provides a client for that API, in turn allowing you to use PHP to control RouterOS hosts.
|
||||
*
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
*
|
||||
* @category Net
|
||||
* @package PEAR2_Net_RouterOS
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2011 Vasil Rangelov
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version 1.0.0b5
|
||||
* @version 1.0.0b6
|
||||
* @link http://pear2.php.net/PEAR2_Net_RouterOS
|
||||
*/
|
||||
/**
|
||||
@ -27,7 +28,7 @@ use RuntimeException;
|
||||
|
||||
/**
|
||||
* Exception thrown when the request/response cycle goes an unexpected way.
|
||||
*
|
||||
*
|
||||
* @category Net
|
||||
* @package PEAR2_Net_RouterOS
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
|
@ -2,17 +2,18 @@
|
||||
|
||||
/**
|
||||
* RouterOS API client implementation.
|
||||
*
|
||||
|
||||
*
|
||||
* RouterOS is the flag product of the company MikroTik and is a powerful router software. One of its many abilities is to allow control over it via an API. This package provides a client for that API, in turn allowing you to use PHP to control RouterOS hosts.
|
||||
*
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
*
|
||||
* @category Net
|
||||
* @package PEAR2_Net_RouterOS
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2011 Vasil Rangelov
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version 1.0.0b5
|
||||
* @version 1.0.0b6
|
||||
* @link http://pear2.php.net/PEAR2_Net_RouterOS
|
||||
*/
|
||||
/**
|
||||
@ -22,7 +23,7 @@ namespace PEAR2\Net\RouterOS;
|
||||
|
||||
/**
|
||||
* Generic exception class of this package.
|
||||
*
|
||||
*
|
||||
* @category Net
|
||||
* @package PEAR2_Net_RouterOS
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
|
@ -2,17 +2,18 @@
|
||||
|
||||
/**
|
||||
* RouterOS API client implementation.
|
||||
*
|
||||
|
||||
*
|
||||
* RouterOS is the flag product of the company MikroTik and is a powerful router software. One of its many abilities is to allow control over it via an API. This package provides a client for that API, in turn allowing you to use PHP to control RouterOS hosts.
|
||||
*
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
*
|
||||
* @category Net
|
||||
* @package PEAR2_Net_RouterOS
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2011 Vasil Rangelov
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version 1.0.0b5
|
||||
* @version 1.0.0b6
|
||||
* @link http://pear2.php.net/PEAR2_Net_RouterOS
|
||||
*/
|
||||
/**
|
||||
@ -24,7 +25,7 @@ use InvalidArgumentException as I;
|
||||
|
||||
/**
|
||||
* Exception thrown when there's something wrong with message arguments.
|
||||
*
|
||||
*
|
||||
* @category Net
|
||||
* @package PEAR2_Net_RouterOS
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
|
@ -2,17 +2,18 @@
|
||||
|
||||
/**
|
||||
* RouterOS API client implementation.
|
||||
*
|
||||
|
||||
*
|
||||
* RouterOS is the flag product of the company MikroTik and is a powerful router software. One of its many abilities is to allow control over it via an API. This package provides a client for that API, in turn allowing you to use PHP to control RouterOS hosts.
|
||||
*
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
*
|
||||
* @category Net
|
||||
* @package PEAR2_Net_RouterOS
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2011 Vasil Rangelov
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version 1.0.0b5
|
||||
* @version 1.0.0b6
|
||||
* @link http://pear2.php.net/PEAR2_Net_RouterOS
|
||||
*/
|
||||
/**
|
||||
@ -25,9 +26,14 @@ namespace PEAR2\Net\RouterOS;
|
||||
*/
|
||||
use LengthException as L;
|
||||
|
||||
/**
|
||||
* Used in $previous
|
||||
*/
|
||||
use Exception as E;
|
||||
|
||||
/**
|
||||
* Exception thrown when there is a problem with a word's length.
|
||||
*
|
||||
*
|
||||
* @category Net
|
||||
* @package PEAR2_Net_RouterOS
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
@ -36,30 +42,31 @@ use LengthException as L;
|
||||
*/
|
||||
class LengthException extends L implements Exception
|
||||
{
|
||||
|
||||
|
||||
const CODE_UNSUPPORTED = 1200;
|
||||
const CODE_INVALID = 1300;
|
||||
const CODE_BEYOND_SHEME = 1301;
|
||||
|
||||
/**
|
||||
* The problematic length.
|
||||
*
|
||||
* @var mixed The problematic length.
|
||||
* @var int|double|null
|
||||
*/
|
||||
private $_length;
|
||||
|
||||
/**
|
||||
* Creates a new LengthException.
|
||||
*
|
||||
* @param string $message The Exception message to throw.
|
||||
* @param int $code The Exception code.
|
||||
* @param \Exception $previous The previous exception used for the exception
|
||||
* chaining.
|
||||
* @param number $length The length.
|
||||
*
|
||||
* @param string $message The Exception message to throw.
|
||||
* @param int $code The Exception code.
|
||||
* @param E|null $previous The previous exception used for the
|
||||
* exception chaining.
|
||||
* @param int|double|null $length The length.
|
||||
*/
|
||||
public function __construct(
|
||||
$message,
|
||||
$code = 0,
|
||||
$previous = null,
|
||||
E $previous = null,
|
||||
$length = null
|
||||
) {
|
||||
parent::__construct($message, $code, $previous);
|
||||
@ -68,8 +75,8 @@ class LengthException extends L implements Exception
|
||||
|
||||
/**
|
||||
* Gets the length.
|
||||
*
|
||||
* @return number The length.
|
||||
*
|
||||
* @return int|double|null The length.
|
||||
*/
|
||||
public function getLength()
|
||||
{
|
||||
@ -81,7 +88,7 @@ class LengthException extends L implements Exception
|
||||
|
||||
/**
|
||||
* Returns a string representation of the exception.
|
||||
*
|
||||
*
|
||||
* @return string The exception as a string.
|
||||
*/
|
||||
public function __toString()
|
||||
|
@ -2,17 +2,18 @@
|
||||
|
||||
/**
|
||||
* RouterOS API client implementation.
|
||||
*
|
||||
|
||||
*
|
||||
* RouterOS is the flag product of the company MikroTik and is a powerful router software. One of its many abilities is to allow control over it via an API. This package provides a client for that API, in turn allowing you to use PHP to control RouterOS hosts.
|
||||
*
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
*
|
||||
* @category Net
|
||||
* @package PEAR2_Net_RouterOS
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2011 Vasil Rangelov
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version 1.0.0b5
|
||||
* @version 1.0.0b6
|
||||
* @link http://pear2.php.net/PEAR2_Net_RouterOS
|
||||
*/
|
||||
/**
|
||||
@ -31,13 +32,13 @@ use Countable;
|
||||
use IteratorAggregate;
|
||||
|
||||
/**
|
||||
* Requred for IteratorAggregate::getIterator() to work properly with foreach.
|
||||
* Required for IteratorAggregate::getIterator() to work properly with foreach.
|
||||
*/
|
||||
use ArrayObject;
|
||||
|
||||
/**
|
||||
* Represents a RouterOS message.
|
||||
*
|
||||
*
|
||||
* @category Net
|
||||
* @package PEAR2_Net_RouterOS
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
@ -48,27 +49,32 @@ abstract class Message implements IteratorAggregate, Countable
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array An array with message attributes. Each array key is the the
|
||||
* name of an attribute, and the correspding array value is the value
|
||||
* for that attribute.
|
||||
* An array with message attributes.
|
||||
*
|
||||
* Each array key is the the name of an attribute,
|
||||
* and the corresponding array value is the value for that attribute.
|
||||
*
|
||||
* @var array<string,string|resource>
|
||||
*/
|
||||
protected $attributes = array();
|
||||
|
||||
/**
|
||||
* @var string An optional tag to associate the message with.
|
||||
* An optional tag to associate the message with.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_tag = null;
|
||||
|
||||
|
||||
/**
|
||||
* A shorthand gateway.
|
||||
*
|
||||
*
|
||||
* This is a magic PHP method that allows you to call the object as a
|
||||
* function. Depending on the argument given, one of the other functions in
|
||||
* the class is invoked and its returned value is returned by this function.
|
||||
*
|
||||
* @param string $name The name of an attribute to get the value of, or NULL
|
||||
* to get the tag.
|
||||
*
|
||||
*
|
||||
* @param string|null $name The name of an attribute to get the value of,
|
||||
* or NULL to get the tag.
|
||||
*
|
||||
* @return string|resource The value of the specified attribute,
|
||||
* or the tag if NULL is provided.
|
||||
*/
|
||||
@ -82,9 +88,9 @@ abstract class Message implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Sanitizes a name of an attribute (message or query one).
|
||||
*
|
||||
*
|
||||
* @param mixed $name The name to sanitize.
|
||||
*
|
||||
*
|
||||
* @return string The sanitized name.
|
||||
*/
|
||||
public static function sanitizeAttributeName($name)
|
||||
@ -103,10 +109,10 @@ abstract class Message implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Sanitizes a value of an attribute (message or query one).
|
||||
*
|
||||
*
|
||||
* @param mixed $value The value to sanitize.
|
||||
*
|
||||
* @return string The sanitized value.
|
||||
*
|
||||
* @return string|resource The sanitized value.
|
||||
*/
|
||||
public static function sanitizeAttributeValue($value)
|
||||
{
|
||||
@ -119,8 +125,9 @@ abstract class Message implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Gets the tag that the message is associated with.
|
||||
*
|
||||
*
|
||||
* @return string The current tag or NULL if there isn't a tag.
|
||||
*
|
||||
* @see setTag()
|
||||
*/
|
||||
public function getTag()
|
||||
@ -130,13 +137,14 @@ abstract class Message implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Sets the tag to associate the request with.
|
||||
*
|
||||
*
|
||||
* Sets the tag to associate the message with. Setting NULL erases the
|
||||
* currently set tag.
|
||||
*
|
||||
*
|
||||
* @param string $tag The tag to set.
|
||||
*
|
||||
*
|
||||
* @return $this The message object.
|
||||
*
|
||||
* @see getTag()
|
||||
*/
|
||||
protected function setTag($tag)
|
||||
@ -147,11 +155,12 @@ abstract class Message implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Gets the value of an attribute.
|
||||
*
|
||||
*
|
||||
* @param string $name The name of the attribute.
|
||||
*
|
||||
*
|
||||
* @return string|resource|null The value of the specified attribute.
|
||||
* Returns NULL if such an attribute is not set.
|
||||
*
|
||||
* @see setAttribute()
|
||||
*/
|
||||
protected function getAttribute($name)
|
||||
@ -165,9 +174,10 @@ abstract class Message implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Gets all arguments in an array.
|
||||
*
|
||||
*
|
||||
* @return ArrayObject An ArrayObject with the keys being argument names,
|
||||
* and the array values being argument values.
|
||||
*
|
||||
* @see getArgument()
|
||||
* @see setArgument()
|
||||
*/
|
||||
@ -177,40 +187,30 @@ abstract class Message implements IteratorAggregate, Countable
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the number of arguments.
|
||||
*
|
||||
* @param int $mode The counter mode.
|
||||
* Either COUNT_NORMAL or COUNT_RECURSIVE.
|
||||
* When in normal mode, counts the number of arguments.
|
||||
* When in recursive mode, counts the number of API words
|
||||
* (including the empty word at the end).
|
||||
*
|
||||
* @return int The number of arguments/words.
|
||||
* Counts the number of attributes.
|
||||
*
|
||||
* @return int The number of attributes.
|
||||
*/
|
||||
public function count($mode = COUNT_NORMAL)
|
||||
public function count()
|
||||
{
|
||||
$result = count($this->attributes);
|
||||
if ($mode !== COUNT_NORMAL) {
|
||||
$result += 2/*first+last word*/
|
||||
+ (int)(null !== $this->getTag());
|
||||
}
|
||||
return $result;
|
||||
return count($this->attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an attribute for the message.
|
||||
*
|
||||
*
|
||||
* @param string $name Name of the attribute.
|
||||
* @param string|resource|null $value Value of the attribute as a string or
|
||||
* seekable stream.
|
||||
* Setting the value to NULL removes an argument of this name.
|
||||
* If a seekable stream is provided, it is sent from its current
|
||||
* posistion to its end, and the pointer is seeked back to its current
|
||||
* position to its end, and the pointer is seeked back to its current
|
||||
* position after sending.
|
||||
* Non seekable streams, as well as all other types, are casted to a
|
||||
* string.
|
||||
*
|
||||
*
|
||||
* @return $this The message object.
|
||||
*
|
||||
* @see getArgument()
|
||||
*/
|
||||
protected function setAttribute($name, $value = '')
|
||||
@ -226,7 +226,7 @@ abstract class Message implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Removes all attributes from the message.
|
||||
*
|
||||
*
|
||||
* @return $this The message object.
|
||||
*/
|
||||
protected function removeAllAttributes()
|
||||
|
@ -2,17 +2,18 @@
|
||||
|
||||
/**
|
||||
* RouterOS API client implementation.
|
||||
*
|
||||
|
||||
*
|
||||
* RouterOS is the flag product of the company MikroTik and is a powerful router software. One of its many abilities is to allow control over it via an API. This package provides a client for that API, in turn allowing you to use PHP to control RouterOS hosts.
|
||||
*
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
*
|
||||
* @category Net
|
||||
* @package PEAR2_Net_RouterOS
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2011 Vasil Rangelov
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version 1.0.0b5
|
||||
* @version 1.0.0b6
|
||||
* @link http://pear2.php.net/PEAR2_Net_RouterOS
|
||||
*/
|
||||
/**
|
||||
@ -28,7 +29,7 @@ use Exception as E;
|
||||
/**
|
||||
* Exception thrown when encountering something not supported by RouterOS or
|
||||
* this package.
|
||||
*
|
||||
*
|
||||
* @category Net
|
||||
* @package PEAR2_Net_RouterOS
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
@ -40,24 +41,30 @@ class NotSupportedException extends E implements Exception
|
||||
|
||||
const CODE_CONTROL_BYTE = 1601;
|
||||
|
||||
const CODE_MENU_MISMATCH = 60000;
|
||||
|
||||
const CODE_ARG_PROHIBITED = 60001;
|
||||
|
||||
/**
|
||||
* @var mixed The unsuppported value.
|
||||
* The unsupported value.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
private $_value;
|
||||
|
||||
/**
|
||||
* Creates a new NotSupportedException.
|
||||
*
|
||||
* @param string $message The Exception message to throw.
|
||||
* @param int $code The Exception code.
|
||||
* @param \Exception $previous The previous exception used for the exception
|
||||
*
|
||||
* @param string $message The Exception message to throw.
|
||||
* @param int $code The Exception code.
|
||||
* @param E|null $previous The previous exception used for the exception
|
||||
* chaining.
|
||||
* @param mixed $value The unsupported value.
|
||||
* @param mixed $value The unsupported value.
|
||||
*/
|
||||
public function __construct(
|
||||
$message,
|
||||
$code = 0,
|
||||
$previous = null,
|
||||
E $previous = null,
|
||||
$value = null
|
||||
) {
|
||||
parent::__construct($message, $code, $previous);
|
||||
@ -66,7 +73,7 @@ class NotSupportedException extends E implements Exception
|
||||
|
||||
/**
|
||||
* Gets the unsupported value.
|
||||
*
|
||||
*
|
||||
* @return mixed The unsupported value.
|
||||
*/
|
||||
public function getValue()
|
||||
@ -79,7 +86,7 @@ class NotSupportedException extends E implements Exception
|
||||
|
||||
/**
|
||||
* Returns a string representation of the exception.
|
||||
*
|
||||
*
|
||||
* @return string The exception as a string.
|
||||
*/
|
||||
public function __toString()
|
||||
|
43
system/autoload/PEAR2/Net/RouterOS/ParserException.php
Normal file
43
system/autoload/PEAR2/Net/RouterOS/ParserException.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* RouterOS API client implementation.
|
||||
|
||||
*
|
||||
* RouterOS is the flag product of the company MikroTik and is a powerful router software. One of its many abilities is to allow control over it via an API. This package provides a client for that API, in turn allowing you to use PHP to control RouterOS hosts.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Net
|
||||
* @package PEAR2_Net_RouterOS
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2011 Vasil Rangelov
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version 1.0.0b6
|
||||
* @link http://pear2.php.net/PEAR2_Net_RouterOS
|
||||
*/
|
||||
/**
|
||||
* The namespace declaration.
|
||||
*/
|
||||
namespace PEAR2\Net\RouterOS;
|
||||
|
||||
/**
|
||||
* Base of this class.
|
||||
*/
|
||||
use DomainException;
|
||||
|
||||
/**
|
||||
* Exception thrown when a value can't be parsed properly.
|
||||
*
|
||||
* @category Net
|
||||
* @package PEAR2_Net_RouterOS
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @link http://pear2.php.net/PEAR2_Net_RouterOS
|
||||
*/
|
||||
class ParserException extends DomainException implements Exception
|
||||
{
|
||||
const CODE_DATETIME = 1;
|
||||
const CODE_DATEINTERVAL = 2;
|
||||
const CODE_ARRAY = 3;
|
||||
}
|
@ -2,17 +2,18 @@
|
||||
|
||||
/**
|
||||
* RouterOS API client implementation.
|
||||
*
|
||||
|
||||
*
|
||||
* RouterOS is the flag product of the company MikroTik and is a powerful router software. One of its many abilities is to allow control over it via an API. This package provides a client for that API, in turn allowing you to use PHP to control RouterOS hosts.
|
||||
*
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
*
|
||||
* @category Net
|
||||
* @package PEAR2_Net_RouterOS
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2011 Vasil Rangelov
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version 1.0.0b5
|
||||
* @version 1.0.0b6
|
||||
* @link http://pear2.php.net/PEAR2_Net_RouterOS
|
||||
*/
|
||||
/**
|
||||
@ -27,7 +28,7 @@ use PEAR2\Net\Transmitter as T;
|
||||
|
||||
/**
|
||||
* Represents a query for RouterOS requests.
|
||||
*
|
||||
*
|
||||
* @category Net
|
||||
* @package PEAR2_Net_RouterOS
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
@ -41,31 +42,35 @@ class Query
|
||||
* Checks if the property exists.
|
||||
*/
|
||||
const OP_EX = '';
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the property does not exist.
|
||||
*/
|
||||
const OP_NEX = '-';
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the property equals a certain value.
|
||||
*/
|
||||
const OP_EQ = '=';
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the property is less than a certain value.
|
||||
*/
|
||||
const OP_LT = '<';
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the property is greather than a certain value.
|
||||
* Checks if the property is greater than a certain value.
|
||||
*/
|
||||
const OP_GT = '>';
|
||||
|
||||
/**
|
||||
* @var array An array of the words forming the query. Each value is an
|
||||
* array with the first member being the predicate (operator and name),
|
||||
* and the second member being the value for the predicate.
|
||||
* An array of the words forming the query.
|
||||
*
|
||||
* Each value is an array with the first member being the predicate
|
||||
* (operator and name), and the second member being the value
|
||||
* for the predicate.
|
||||
*
|
||||
* @var array<string,string|null>[]
|
||||
*/
|
||||
protected $words = array();
|
||||
|
||||
@ -73,16 +78,16 @@ class Query
|
||||
* This class is not to be instantiated normally, but by static methods
|
||||
* instead. Use {@link static::where()} to create an instance of it.
|
||||
*/
|
||||
private function __construct()
|
||||
protected function __construct()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitizes the operator of a condition.
|
||||
*
|
||||
*
|
||||
* @param string $operator The operator to sanitize.
|
||||
*
|
||||
*
|
||||
* @return string The sanitized operator.
|
||||
*/
|
||||
protected static function sanitizeOperator($operator)
|
||||
@ -107,18 +112,18 @@ class Query
|
||||
|
||||
/**
|
||||
* Creates a new query with an initial condition.
|
||||
*
|
||||
*
|
||||
* @param string $name The name of the property to test.
|
||||
* @param string|resource|null $value Value of the property as a string
|
||||
* or seekable stream. Not required for existence tests.
|
||||
* If a seekable stream is provided, it is sent from its current
|
||||
* posistion to its end, and the pointer is seeked back to its current
|
||||
* position to its end, and the pointer is seeked back to its current
|
||||
* position after sending.
|
||||
* Non seekable streams, as well as all other types, are casted to a
|
||||
* string.
|
||||
* @param string $operator One of the OP_* constants.
|
||||
* Describes the operation to perform.
|
||||
*
|
||||
*
|
||||
* @return static A new query object.
|
||||
*/
|
||||
public static function where(
|
||||
@ -132,7 +137,7 @@ class Query
|
||||
|
||||
/**
|
||||
* Negates the query.
|
||||
*
|
||||
*
|
||||
* @return $this The query object.
|
||||
*/
|
||||
public function not()
|
||||
@ -143,18 +148,18 @@ class Query
|
||||
|
||||
/**
|
||||
* Adds a condition as an alternative to the query.
|
||||
*
|
||||
*
|
||||
* @param string $name The name of the property to test.
|
||||
* @param string|resource|null $value Value of the property as a string
|
||||
* or seekable stream. Not required for existence tests.
|
||||
* If a seekable stream is provided, it is sent from its current
|
||||
* posistion to its end, and the pointer is seeked back to its current
|
||||
* position to its end, and the pointer is seeked back to its current
|
||||
* position after sending.
|
||||
* Non seekable streams, as well as all other types, are casted to a
|
||||
* string.
|
||||
* @param string $operator One of the OP_* constants.
|
||||
* Describes the operation to perform.
|
||||
*
|
||||
*
|
||||
* @return $this The query object.
|
||||
*/
|
||||
public function orWhere($name, $value = null, $operator = self::OP_EX)
|
||||
@ -165,18 +170,18 @@ class Query
|
||||
|
||||
/**
|
||||
* Adds a condition in addition to the query.
|
||||
*
|
||||
*
|
||||
* @param string $name The name of the property to test.
|
||||
* @param string|resource|null $value Value of the property as a string
|
||||
* or seekable stream. Not required for existence tests.
|
||||
* If a seekable stream is provided, it is sent from its current
|
||||
* posistion to its end, and the pointer is seeked back to its current
|
||||
* position to its end, and the pointer is seeked back to its current
|
||||
* position after sending.
|
||||
* Non seekable streams, as well as all other types, are casted to a
|
||||
* string.
|
||||
* @param string $operator One of the OP_* constants.
|
||||
* Describes the operation to perform.
|
||||
*
|
||||
*
|
||||
* @return $this The query object.
|
||||
*/
|
||||
public function andWhere($name, $value = null, $operator = self::OP_EX)
|
||||
@ -187,9 +192,9 @@ class Query
|
||||
|
||||
/**
|
||||
* Sends the query over a communicator.
|
||||
*
|
||||
*
|
||||
* @param Communicator $com The communicator to send the query over.
|
||||
*
|
||||
*
|
||||
* @return int The number of bytes sent.
|
||||
*/
|
||||
public function send(Communicator $com)
|
||||
@ -205,12 +210,12 @@ class Query
|
||||
|
||||
/**
|
||||
* Sends the query over a communicator.
|
||||
*
|
||||
*
|
||||
* The only difference with the non private equivalent is that this one does
|
||||
* not do locking.
|
||||
*
|
||||
*
|
||||
* @param Communicator $com The communicator to send the query over.
|
||||
*
|
||||
*
|
||||
* @return int The number of bytes sent.
|
||||
*/
|
||||
private function _send(Communicator $com)
|
||||
@ -239,20 +244,53 @@ class Query
|
||||
return $bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies the query.
|
||||
*
|
||||
* Verifies the query against a communicator, i.e. whether the query
|
||||
* could successfully be sent (assuming the connection is still opened).
|
||||
*
|
||||
* @param Communicator $com The Communicator to check against.
|
||||
*
|
||||
* @return $this The query object itself.
|
||||
*
|
||||
* @throws LengthException If the resulting length of an API word is not
|
||||
* supported.
|
||||
*/
|
||||
public function verify(Communicator $com)
|
||||
{
|
||||
foreach ($this->words as $queryWord) {
|
||||
list($predicate, $value) = $queryWord;
|
||||
if (null === $value) {
|
||||
$com::verifyLengthSupport(strlen('?' . $predicate));
|
||||
} elseif (is_string($value)) {
|
||||
$com::verifyLengthSupport(
|
||||
strlen('?' . $predicate . '=' . $value)
|
||||
);
|
||||
} else {
|
||||
$com::verifyLengthSupport(
|
||||
strlen('?' . $predicate . '=') +
|
||||
$com::seekableStreamLength($value)
|
||||
);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a condition.
|
||||
*
|
||||
*
|
||||
* @param string $name The name of the property to test.
|
||||
* @param string|resource|null $value Value of the property as a string
|
||||
* or seekable stream. Not required for existence tests.
|
||||
* If a seekable stream is provided, it is sent from its current
|
||||
* posistion to its end, and the pointer is seeked back to its current
|
||||
* position to its end, and the pointer is seeked back to its current
|
||||
* position after sending.
|
||||
* Non seekable streams, as well as all other types, are casted to a
|
||||
* string.
|
||||
* @param string $operator One of the ACTION_* constants.
|
||||
* Describes the operation to perform.
|
||||
*
|
||||
*
|
||||
* @return $this The query object.
|
||||
*/
|
||||
protected function addWhere($name, $value, $operator)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user