update
This commit is contained in:
parent
a11d6ed6f9
commit
d9573b122f
@ -29,6 +29,9 @@
|
||||
"fortawesome/font-awesome": "^6.5",
|
||||
"ext-zip": "*",
|
||||
"ext-rar": "*",
|
||||
"ext-json": "*",
|
||||
"ext-gmp": "*",
|
||||
"ext-bcmath": "*",
|
||||
"wapmorgan/unified-archive": "^1.2",
|
||||
"symfony/console": "^6.1",
|
||||
"gemorroj/archive7z": "^5.7",
|
||||
@ -36,7 +39,8 @@
|
||||
"npm-asset/plyr": "^3.7",
|
||||
"ext-fileinfo": "*",
|
||||
"npm-asset/ace-builds": "^1.32",
|
||||
"yiisoft/yii2-redis": "^2.0"
|
||||
"yiisoft/yii2-redis": "^2.0",
|
||||
"ramsey/uuid": "^4.7"
|
||||
},
|
||||
"require-dev": {
|
||||
"yiisoft/yii2-debug": "~2.1.0",
|
||||
|
@ -4,6 +4,8 @@ namespace app\controllers;
|
||||
|
||||
use app\models\CollectionTasks;
|
||||
use app\models\CollectionSearch;
|
||||
use app\models\CollectionUploaded;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Yii;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
@ -116,4 +118,40 @@ class CollectionController extends Controller
|
||||
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
|
||||
/**
|
||||
* 外部访问接口,接受参数id:收集文件任务id,secret:访问密钥,CollectionTasks[secret]:访问密钥(另一种形式)
|
||||
*
|
||||
* @param $id
|
||||
* @param $secret
|
||||
* @return string
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public function actionAccess($id = null, $secret = null)
|
||||
{
|
||||
$receive_secret = Yii::$app->request->get('CollectionTasks')['secret'] ?? null;
|
||||
if (!is_null($receive_secret)) {
|
||||
$secret = $receive_secret;
|
||||
}
|
||||
$model = CollectionTasks::findOne(['id' => $id]);
|
||||
if ($model === null) {
|
||||
throw new NotFoundHttpException('请求的文件收集任务不存在');
|
||||
} elseif ($secret === null) {
|
||||
return $this->render('gateway', [
|
||||
'model' => new CollectionTasks(),
|
||||
]);
|
||||
} elseif ($model->secret !== $secret) {
|
||||
Yii::$app->session->setFlash('error', '拒绝访问,凭证不正确');
|
||||
return $this->render('gateway', [
|
||||
'model' => new CollectionTasks(),
|
||||
]);
|
||||
} else {
|
||||
$model2 = new CollectionUploaded();
|
||||
$model2->subfolder_name = Uuid::uuid4()->toString();
|
||||
return $this->render('access', [
|
||||
'model' => $model,
|
||||
'model2' => $model2,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace app\controllers;
|
||||
|
||||
use app\models\CollectionTasks;
|
||||
use app\models\CollectionUploaded;
|
||||
use app\models\CollectionUploadedSearch;
|
||||
use yii\web\Controller;
|
||||
@ -30,16 +31,6 @@ class CollectionUploadedController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all CollectionUploaded models.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('index');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds the CollectionUploaded model based on its primary key value.
|
||||
|
@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
use app\models\CollectionUploaded;
|
||||
use yii\helpers\Html;
|
||||
use yii\helpers\Url;
|
||||
use yii\grid\ActionColumn;
|
||||
use yii\grid\GridView;
|
||||
|
||||
/** @var yii\web\View $this */
|
||||
/** @var app\models\CollectionUploadedSearch $searchModel */
|
||||
/** @var yii\data\ActiveDataProvider $dataProvider */
|
||||
|
||||
$this->title = '文件收集';
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="collection-uploaded-index">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
|
||||
</div>
|
26
views/collection/access.php
Normal file
26
views/collection/access.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/** @var yii\web\View $this */
|
||||
/** @var app\models\CollectionTasks $model */
|
||||
/** @var app\models\CollectionUploaded $model2 */
|
||||
|
||||
$this->title = '文件收集';
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="collection-access">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
<p>
|
||||
收集任务ID: <?= Html::encode($model->id) ?>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
访问密钥: <?= Html::encode($model->secret) ?>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
收集目标文件夹: <?= Html::encode($model2->subfolder_name) ?>
|
||||
</p>
|
||||
</div>
|
29
views/collection/gateway.php
Normal file
29
views/collection/gateway.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use yii\bootstrap5\ActiveForm;
|
||||
use yii\helpers\Html;
|
||||
use yii\helpers\Url;
|
||||
|
||||
/** @var yii\web\View $this */
|
||||
/** @var app\models\CollectionTasks $model */
|
||||
|
||||
$this->title = '请输入访问凭证';
|
||||
$this->params['breadcrumbs'][] = '文件收集';
|
||||
?>
|
||||
<div class="collection-gateway">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => Url::to(['collection/access', 'id' => Yii::$app->request->get('id')]),
|
||||
'method' => 'get',
|
||||
]); ?>
|
||||
|
||||
<?= $form->field($model, 'secret')->textInput(['maxlength' => true])->label('访问凭证:') ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('提交', ['class' => 'btn btn-primary']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user