Commit b036aba8 by san58

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

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