Skip to content

Commit 179d051

Browse files
authored
Merge pull request #225 from 4x99/develop
v1.6.2
2 parents ff75270 + e12dd1c commit 179d051

16 files changed

+129
-21
lines changed

.env.docker-compose.example

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ MYSQL_PORT=3306
77
# MySQL 数据库名
88
MYSQL_DATABASE=code6
99

10-
# MySQL 用户名
10+
# MySQL 用户名(请使用非 root 用户)
1111
MYSQL_USER=
1212

1313
# MySQL 密码

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak;\
1919
echo 'deb http://mirrors.aliyun.com/debian buster main' >> /etc/apt/sources.list;\
2020
echo 'deb http://mirrors.aliyun.com/debian buster-updates main' >> /etc/apt/sources.list;\
2121
apt-get update;\
22-
apt-get install -y --allow-downgrades zip cron vim zlib1g=1:1.2.11.dfsg-1 zlib1g-dev libpng-dev;\
22+
apt-get install -y --allow-downgrades zip cron vim zlib1g=1:1.2.11.dfsg-1+deb10u1 zlib1g-dev libpng-dev;\
2323
rm -rf /var/lib/apt/lists/*;\
2424
# 安装 PHP 扩展
2525
docker-php-ext-install pdo_mysql;\

app/Console/Commands/JobRunCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public function handle()
9898
$lastResponse = ResponseMediator::getPagination($client->getLastResponse());
9999
} while ($lastResponse['next'] && (++$page <= $configJob->scan_page));
100100
$configJob->save();
101+
$job->delete();
101102
}
102103

103104
$this->log->info('Work done');
@@ -127,7 +128,6 @@ private function takeJob()
127128
if (!$job = QueueJob::orderBy('created_at')->first()) {
128129
return false;
129130
}
130-
$job->delete();
131131
return $job;
132132
}
133133

app/Http/Controllers/ConfigJobController.php

+15
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Http\Controllers;
44

55
use App\Models\ConfigJob;
6+
use App\Models\QueueJob;
67
use Cron\CronExpression;
78
use Illuminate\Http\Request;
89

@@ -111,6 +112,20 @@ public function batchDestroy(Request $request)
111112
}
112113
}
113114

115+
/**
116+
* 任务队列
117+
*
118+
* @return array
119+
*/
120+
public function queue()
121+
{
122+
$data = QueueJob::orderBy('created_at')->get();
123+
foreach ($data as $k => $v) {
124+
$data[$k]['status'] = $k == 0 ? 1 : 0;
125+
}
126+
return $data;
127+
}
128+
114129
/**
115130
* 下次扫描时间
116131
*

app/Services/GitHubService.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct()
4444
*/
4545
public function init()
4646
{
47-
$this->proxy = $this->testProxy($this->proxy) ? $this->proxy : null;
47+
$this->proxy = $this->proxy ? ($this->testProxy($this->proxy) ? $this->proxy : null) : null;
4848
$tokens = ConfigToken::inRandomOrder()->get()->pluck('token');
4949
foreach ($tokens as $token) {
5050
$client = ['token' => $token];

composer.lock

+19-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/deploy-docker-compose.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ MYSQL_PORT=3306
2424
# MySQL 数据库名
2525
MYSQL_DATABASE=code6
2626
27-
# MySQL 用户名
27+
# MySQL 用户名(请使用非 root 用户)
2828
MYSQL_USER=
2929
3030
# MySQL 密码

doc/deploy-source.md

-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ crontab -e -u <用户>
8787

8888
## 创建用户
8989
```
90-
docker exec -it code6-server /bin/bash
9190
php artisan code6:user-add <邮箱> <密码>
9291
```
9392

docker-compose.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: "3.9"
22
services:
33
mysql:
4-
image: mysql/mysql-server
4+
image: mysql/mysql-server:5.7
55
container_name: code6-mysql
66
restart: always
77
env_file:

docker-entrypoint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
# 项目配置
4-
cp .env.example .env
4+
cp -i .env.example .env
55
chmod -R 755 storage
66
chown -R www-data:www-data storage
77
php artisan key:generate

resources/views/codeLeak/index.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@
289289
flex: 1,
290290
align: 'center',
291291
renderer: function (value) {
292-
return value ? value : '-';
292+
return value ? Ext.String.htmlEncode(value) : '-';
293293
}
294294
},
295295
{

resources/views/configJob/index.blade.php

+79-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222
{value: 2, text: '一个仓库只记录一次', qtip: '一个仓库只记录一次'},
2323
];
2424
25+
var queue = {
26+
config: [
27+
{text: '待执行', color: 'gray'},
28+
{text: '执行中', color: 'green'},
29+
],
30+
tpl: new Ext.XTemplate('<div class="tag tag-{color}">{text}</div>'),
31+
}
32+
2533
var grid = Ext.create('plugin.grid', {
2634
store: Ext.data.StoreManager.lookup('store'),
2735
bufferedRenderer: false,
@@ -35,6 +43,12 @@
3543
handler: winHelp,
3644
},
3745
'->',
46+
{
47+
text: '任务队列',
48+
iconCls: 'icon-page-db',
49+
handler: winQueue,
50+
},
51+
'-',
3852
{
3953
text: '批量删除',
4054
iconCls: 'icon-cross',
@@ -98,6 +112,9 @@
98112
dataIndex: 'keyword',
99113
flex: 1,
100114
align: 'center',
115+
renderer: function (value) {
116+
return Ext.String.htmlEncode(value);
117+
}
101118
},
102119
{
103120
text: '扫描页数',
@@ -147,7 +164,7 @@
147164
flex: 1,
148165
align: 'center',
149166
renderer: function (value) {
150-
return value ? value : '-';
167+
return value ? Ext.String.htmlEncode(value) : '-';
151168
}
152169
},
153170
{
@@ -328,6 +345,67 @@ function winHelp() {
328345
}).removeCls('x-unselectable');
329346
}
330347
348+
var taskRunner = new Ext.util.TaskRunner();
349+
350+
function newTask(interval, run) {
351+
var task = taskRunner.newTask({
352+
run: run,
353+
interval: interval,
354+
fireOnStart: true,
355+
});
356+
task.start();
357+
return task;
358+
}
359+
360+
function winQueue() {
361+
var gridQueue = Ext.create('plugin.grid', {
362+
disableSelection: true,
363+
viewConfig: {
364+
loadMask: false,
365+
emptyText: '<div style="text-align:center;padding:20px;color:#AAA">任务队列为空..</div>'
366+
},
367+
store: {
368+
autoLoad: true,
369+
pageSize: 99999,
370+
proxy: {
371+
type: 'ajax',
372+
url: '/api/configJob/queue',
373+
},
374+
},
375+
columns: [
376+
{
377+
text: '关键字',
378+
dataIndex: 'keyword',
379+
align: 'center',
380+
flex: 2,
381+
},
382+
{
383+
text: '状态',
384+
dataIndex: 'status',
385+
align: 'center',
386+
flex: 1,
387+
renderer: function (value) {
388+
return queue.tpl.apply(queue.config[value]);
389+
},
390+
},
391+
]
392+
});
393+
394+
Ext.create('Ext.window.Window', {
395+
title: '任务队列',
396+
iconCls: 'icon-page-db',
397+
width: 800,
398+
height: 500,
399+
layout: 'fit',
400+
items: [gridQueue],
401+
}).show();
402+
403+
// 每 5 秒自动刷新
404+
newTask(5000, function () {
405+
gridQueue.store.reload();
406+
});
407+
}
408+
331409
Ext.create('Ext.container.Container', {
332410
renderTo: Ext.getBody(),
333411
height: '100%',

resources/views/configToken/index.blade.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@
9696
dataIndex: 'token',
9797
width: 380,
9898
align: 'center',
99+
renderer: function (value) {
100+
return Ext.String.htmlEncode(value);
101+
}
99102
},
100103
{
101104
text: '状态',
@@ -154,7 +157,7 @@
154157
align: 'center',
155158
flex: 1,
156159
renderer: function (value) {
157-
return value ? value : '-';
160+
return value ? Ext.String.htmlEncode(value) : '-';
158161
}
159162
},
160163
{

resources/views/configWhitelist/index.blade.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
flex: 1,
9797
align: 'center',
9898
renderer: function (value) {
99-
return value.split('/')[0];
99+
return Ext.String.htmlEncode(value.split('/')[0]);
100100
}
101101
},
102102
{
@@ -105,7 +105,7 @@
105105
flex: 1,
106106
align: 'center',
107107
renderer: function (value) {
108-
return value.split('/')[1];
108+
return Ext.String.htmlEncode(value.split('/')[1]);
109109
}
110110
},
111111
{

routes/web.php

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
Route::resource('/api/codeLeak', 'CodeLeakController');
4242

4343
Route::get('/configJob', 'ConfigJobController@view');
44+
Route::get('/api/configJob/queue', 'ConfigJobController@queue');
4445
Route::delete('/api/configJob/batchDestroy', 'ConfigJobController@batchDestroy');
4546
Route::resource('/api/configJob', 'ConfigJobController');
4647

version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.6.1
1+
1.6.2

0 commit comments

Comments
 (0)