FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
SSRPanel/app/Http/Controllers/Controller.php at master · attackgithub/SSRPanel · GitHub
attackgithub
SSRPanel
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
SSRPanel
/
app
/
Http
/
Controllers
/
Controller.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
186 lines (163 loc) · 4.91 KB
Breadcrumbs
SSRPanel
/
app
/
Http
/
Controllers
/
Controller.php
Copy path
File metadata and controls
186 lines (163 loc) · 4.91 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php
namespace
App
\
Http
\
Controllers
;
use
App
\
Http
\
Models
\
ReferralLog
;
use
App
\
Http
\
Models
\
SensitiveWords
;
use
App
\
Http
\
Models
\
UserBalanceLog
;
use
App
\
Http
\
Models
\
UserScoreLog
;
use
App
\
Http
\
Models
\
UserSubscribe
;
use
Illuminate
\
Foundation
\
Bus
\
DispatchesJobs
;
use
Illuminate
\
Routing
\
Controller
as
BaseController
;
use
Illuminate
\
Foundation
\
Validation
\
ValidatesRequests
;
use
Illuminate
\
Foundation
\
Auth
\
Access
\
AuthorizesRequests
;
class
Controller
extends
BaseController
{
use
AuthorizesRequests, DispatchesJobs, ValidatesRequests;
// 生成随机密码
public
function
makePasswd
()
{
exit
(
makeRandStr
());
}
// 生成VmessId
public
function
makeVmessId
()
{
exit
(
createGuid
());
}
// 类似Linux中的tail命令
public
function
tail
(
$
file
,
$
n
,
$
base
=
5
)
{
$
fileLines
=
$
this
->
countLine
(
$
file
);
if
(
$
fileLines
<
15000
) {
return
false
;
}
$
fp
=
fopen
(
$
file
,
"
r+
"
);
assert
(
$
n
>
0
);
$
pos
=
$
n
+
1
;
$
lines
= [];
while
(
count
(
$
lines
) <=
$
n
) {
try
{
fseek
(
$
fp
, -
$
pos
,
SEEK_END
);
}
catch
(
\
Exception
$
e
) {
fseek
(
0
);
break
;
}
$
pos
*=
$
base
;
while
(!
feof
(
$
fp
)) {
array_unshift
(
$
lines
,
fgets
(
$
fp
));
}
}
return
array_slice
(
$
lines
,
0
,
$
n
);
}
/**
* 计算文件行数
*/
public
function
countLine
(
$
file
)
{
$
fp
=
fopen
(
$
file
,
"
r
"
);
$
i
=
0
;
while
(!
feof
(
$
fp
)) {
//每次读取2M
if
(
$
data
=
fread
(
$
fp
,
1024
*
1024
*
2
)) {
//计算读取到的行数
$
num
=
substr_count
(
$
data
,
"\n"
);
$
i
+=
$
num
;
}
}
fclose
(
$
fp
);
return
$
i
;
}
/**
* 记录余额操作日志
*
* @param int $userId 用户ID
* @param string $oid 订单ID
* @param int $before 记录前余额
* @param int $after 记录后余额
* @param int $amount 发生金额
* @param string $desc 描述
*
* @return int
*/
public
function
addUserBalanceLog
(
$
userId
,
$
oid
,
$
before
,
$
after
,
$
amount
,
$
desc
=
''
)
{
$
log
=
new
UserBalanceLog
();
$
log
->
user_id
=
$
userId
;
$
log
->
order_id
=
$
oid
;
$
log
->
before
=
$
before
;
$
log
->
after
=
$
after
;
$
log
->
amount
=
$
amount
;
$
log
->
desc
=
$
desc
;
$
log
->
created_at
=
date
(
'
Y-m-d H:i:s
'
);
return
$
log
->
save
();
}
/**
* 添加返利日志
*
* @param int $userId 用户ID
* @param int $refUserId 返利用户ID
* @param int $oid 订单ID
* @param int $amount 发生金额
* @param int $refAmount 返利金额
*
* @return int
*/
public
function
addReferralLog
(
$
userId
,
$
refUserId
,
$
oid
,
$
amount
,
$
refAmount
)
{
$
log
=
new
ReferralLog
();
$
log
->
user_id
=
$
userId
;
$
log
->
ref_user_id
=
$
refUserId
;
$
log
->
order_id
=
$
oid
;
$
log
->
amount
=
$
amount
;
$
log
->
ref_amount
=
$
refAmount
;
$
log
->
status
=
0
;
return
$
log
->
save
();
}
/**
* 添加积分日志
*
* @param int $userId 用户ID
* @param int $before 记录前余额
* @param int $after 记录后余额
* @param int $score 发生值
* @param string $desc 描述
*
* @return int
*/
public
function
addUserScoreLog
(
$
userId
,
$
before
,
$
after
,
$
score
,
$
desc
=
''
)
{
$
log
=
new
UserScoreLog
();
$
log
->
user_id
=
$
userId
;
$
log
->
before
=
$
before
;
$
log
->
after
=
$
after
;
$
log
->
score
=
$
score
;
$
log
->
desc
=
$
desc
;
$
log
->
created_at
=
date
(
'
Y-m-d H:i:s
'
);
return
$
log
->
save
();
}
// 获取敏感词
public
function
sensitiveWords
()
{
return
SensitiveWords
::
query
()->
get
()->
pluck
(
'
words
'
)->
toArray
();
}
// 将Base64图片转换为本地图片并保存
function
base64ImageSaver
(
$
base64_image_content
)
{
// 匹配出图片的格式
if
(
preg_match
(
'
/^(data:\s*image\/(\w+);base64,)/
'
,
$
base64_image_content
,
$
result
)) {
$
type
=
$
result
[
2
];
$
directory
=
date
(
'
Ymd
'
);
$
path
=
'
/assets/images/qrcode/
'
.
$
directory
.
'
/
'
;
if
(!
file_exists
(
public_path
(
$
path
))) {
// 检查是否有该文件夹,如果没有就创建,并给予最高权限
mkdir
(
public_path
(
$
path
),
0755
,
true
);
}
$
fileName
=
makeRandStr
(
18
,
true
) .
"
.
{
$
type
}"
;
if
(
file_put_contents
(
public_path
(
$
path
.
$
fileName
),
base64_decode
(
str_replace
(
$
result
[
1
],
''
,
$
base64_image_content
)))) {
chmod
(
public_path
(
$
path
.
$
fileName
),
0744
);
return
$
path
.
$
fileName
;
}
else
{
return
''
;
}
}
else
{
return
''
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL