Commit b036aba8 by san58

Обновление даты CSV у доменов

1 parent 2659413c
...@@ -7,7 +7,7 @@ use yii\console\Controller; ...@@ -7,7 +7,7 @@ use yii\console\Controller;
use yii\db\Expression; use yii\db\Expression;
use yii\helpers\Console; use yii\helpers\Console;
use app\components\Collection; use app\components\Collection;
use app\jobs\HostJob; use app\models\Host;
/** /**
* Парсинг запрещенных ресурсов в РФ. * Парсинг запрещенных ресурсов в РФ.
...@@ -40,18 +40,31 @@ class ScanController extends Controller ...@@ -40,18 +40,31 @@ class ScanController extends Controller
public function actionIndex() public function actionIndex()
{ {
$hosts = Collection::getHostsByCsv(Yii::$app->params['csv_url']); $hosts = Collection::getHostsByCsv(Yii::$app->params['csv_url']);
$grabUrls = Yii::$app->params['registrators_urls']; $csv_date = date("Y-m-d H:i:s",strtotime($hosts['csv_date']));
foreach ($hosts['data'] as $host) { foreach ($hosts['data'] as $host)
$res = Yii::$app->db->createCommand()->insert('{{%host}}', [ {
'domain' =>utf8($host), $host_utf8 = utf8_encode($host);
'created_at' => new Expression('NOW()'), $res = Yii::$app->db->createCommand();
'csv_date' => date("Y-m-d H:i:s",strtotime($hosts['csv_date'])), if ( Host::find()->where(['domain' =>$host_utf8])->count() )
])->execute(); $res->update(
/* $ids[] = (int)Yii::$app->queue->push(new HostJob([ '{{%host}}',
'host' => $host, [
'grabSource' => $grabUrls[array_rand($grabUrls)] 'csv_date' => $csv_date],
]));*/ [
} 'domain' => $host_utf8
]
);
else
$res->insert(
'{{%host}}',
[
'domain' =>$host_utf8,
'created_at' => new Expression('NOW()'),
'csv_date' => $csv_date,
]
);
$res->execute();
}
echo "\n".$this->ansiFormat('Количество полученных хостов', Console::FG_CYAN) . ' => ' . $this->ansiFormat(count($hosts['data']), Console::BOLD, Console::FG_GREEN) . "\n"; echo "\n".$this->ansiFormat('Количество полученных хостов', Console::FG_CYAN) . ' => ' . $this->ansiFormat(count($hosts['data']), Console::BOLD, Console::FG_GREEN) . "\n";
} }
......
...@@ -5,7 +5,7 @@ $db = require __DIR__ . '/db.php'; ...@@ -5,7 +5,7 @@ $db = require __DIR__ . '/db.php';
$config = [ $config = [
'id' => 'basic', 'id' => 'basic',
'name'=>'Новый проект', 'name'=>'РКН',
'basePath' => dirname(__DIR__), 'basePath' => dirname(__DIR__),
'bootstrap' => ['log'], 'bootstrap' => ['log'],
'language' => 'en-EN', 'language' => 'en-EN',
......
...@@ -67,12 +67,12 @@ class Host extends \yii\db\ActiveRecord ...@@ -67,12 +67,12 @@ class Host extends \yii\db\ActiveRecord
{ {
return [ return [
'id' => 'ID', 'id' => 'ID',
'domain' => 'Домен', 'domain' => 'Domain',
'created_at' => 'Дата записи', 'created_at' => 'Date',
'csv_date' => 'Дата CSV', 'csv_date' => 'Date CSV',
'wis_date' => 'Дата проверки домена', 'wis_date' => 'Date WHOIS',
'wis_status' => 'Статус', 'wis_status' => 'Status',
'tix' => 'Показатель', 'tix' => 'TIX',
]; ];
} }
...@@ -89,9 +89,9 @@ class Host extends \yii\db\ActiveRecord ...@@ -89,9 +89,9 @@ class Host extends \yii\db\ActiveRecord
public static function getStatus($status = false) public static function getStatus($status = false)
{ {
$arr = [ $arr = [
self::STATUS_NONE => 'Неизвестный', self::STATUS_NONE => 'No checked',
self::STATUS_FREE => 'Свободный', self::STATUS_FREE => 'FREE',
self::STATUS_BUSY => 'Занятый', self::STATUS_BUSY => 'BUSY',
]; ];
if (is_numeric($status)) { if (is_numeric($status)) {
if (array_key_exists($status, $arr)) { if (array_key_exists($status, $arr)) {
......
...@@ -8,16 +8,16 @@ use yii\widgets\Pjax; ...@@ -8,16 +8,16 @@ use yii\widgets\Pjax;
/* @var $searchModel app\models\HostSearch */ /* @var $searchModel app\models\HostSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */ /* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Hosts'; $this->title = 'List of domains';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<div class="host-index"> <div class="host-index">
<h1><?= Html::encode($this->title) ?></h1> <h1><?= Html::encode($this->title) ?></h1>
<p> <!--p>
<?= Html::a('Create Host', ['create'], ['class' => 'btn btn-success']) ?> <?= Html::a('Create Host', ['create'], ['class' => 'btn btn-success']) ?>
</p> </p-->
<?php Pjax::begin(); ?> <?php Pjax::begin(); ?>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?> <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
......
...@@ -38,8 +38,8 @@ AdminAsset::register($this); ...@@ -38,8 +38,8 @@ AdminAsset::register($this);
echo Nav::widget([ echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'], 'options' => ['class' => 'navbar-nav navbar-right'],
'items' => [ 'items' => [
['label' => 'Главная', 'url' => ['/site/index']], ['label' => 'Home', 'url' => ['/site/index']],
['label' => 'Выйти (' . Yii::$app->user->identity->name . ')', 'url' => ['/auth/logout']], ['label' => 'Logout (' . Yii::$app->user->identity->name . ')', 'url' => ['/auth/logout']],
], ],
]); ]);
NavBar::end(); NavBar::end();
...@@ -69,7 +69,7 @@ AdminAsset::register($this); ...@@ -69,7 +69,7 @@ AdminAsset::register($this);
<div class="container"> <div class="container">
<p class="pull-left">&copy; <?php echo Yii::$app->name; ?> <?php <p class="pull-left">&copy; <?php echo Yii::$app->name; ?> <?php
$d = date('Y'); $d = date('Y');
echo(($d - 2020) ? '2020 - ' . $d : $d); ?> echo(($d - 2021) ? '2021 - ' . $d : $d); ?>
</p> </p>
</div> </div>
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!