Commit 1cceb9f9 by san58

обвязка логированием

1 parent 4c88ee32
......@@ -60,9 +60,12 @@ class ScanController extends Controller
$filters = ['1'=>Collection::get_filter(Filter::TYPE_1), '2'=>Collection::get_filter(Filter::TYPE_2), '3'=>Collection::get_filter(Filter::TYPE_3)];
$csv_datatime = '';
$progress = 0;
while (($csv_data = fgetcsv($csv_handle, 1024, ';')) !== false)
$time_start = 0;
while (($csv_data = fgetcsv($csv_handle, 1024, ';')) !== false && $csv_row<2920)
{
if ($csv_row === 2900){ $time_cuttent = microtime(true); echo "\n".'t1 '.($time_cuttent - $time_start)."\n";$time_start = $time_cuttent;}
$file_pos = ftell($csv_handle);
if ($csv_row === 2900){ $time_cuttent = microtime(true); echo 't2 '.($time_cuttent - $time_start)."\n";$time_start = $time_cuttent;}
if ($file_pos !== false && $file_size>0)
{
$progress_current = (int)round(10*$file_pos/$file_size);
......@@ -74,6 +77,7 @@ class ScanController extends Controller
unset($progress_current);
}
if ($csv_row === 2900){ $time_cuttent = microtime(true); echo 't3 '.($time_cuttent - $time_start)."\n";$time_start = $time_cuttent;}
$csv_row++;
if ($csv_row===1)
$csv_datatime = date(
......@@ -84,17 +88,24 @@ class ScanController extends Controller
);
elseif (isset($csv_data[1])===true)
{
if ($csv_row === 2901){ $time_cuttent = microtime(true); echo 't4 '.($time_cuttent - $time_start)."\n";$time_start = $time_cuttent;}
$host = Collection::domain_filter($csv_data[1]);
if ($csv_row === 2901){ $time_cuttent = microtime(true); echo 't5 '.($time_cuttent - $time_start)."\n";$time_start = $time_cuttent;}
if ($host === false)
{
$csv_skip_row++;
}
else
{
if ($csv_row === 2901){ $time_cuttent = microtime(true); echo 't6 '.($time_cuttent - $time_start)."\n";$time_start = $time_cuttent;}
$status = [
'1'=>(Collection::apply_filter($host, $filters['1'])===false?Host::STATUS_OFF:Host::STATUS_ON),
'2'=>(Collection::apply_filter($host, $filters['2'])===false?Host::STATUS_OFF:Host::STATUS_ON),
'3'=>(Collection::apply_filter($host, $filters['3'])===false?Host::STATUS_OFF:Host::STATUS_ON)
];
if ($csv_row === 2901){ $time_cuttent = microtime(true); echo 't7 '.($time_cuttent - $time_start)."\n";$time_start = $time_cuttent;}
$db_request = Yii::$app->db->createCommand();
if ($csv_row === 2901){ $time_cuttent = microtime(true); echo 't8 '.($time_cuttent - $time_start)."\n";$time_start = $time_cuttent;}
if ($db_request)
{
$host_bd = (new Query())
......@@ -103,6 +114,7 @@ class ScanController extends Controller
->where('domain=:host', array(':host'=>$host))
->limit(1)
->one();
if ($csv_row === 2901){ $time_cuttent = microtime(true); echo 't9 '.($time_cuttent - $time_start)."\n";$time_start = $time_cuttent;}
if ( $host_bd === false )
{
$db_request->insert(
......@@ -118,9 +130,11 @@ class ScanController extends Controller
]
)->execute();
$rec['insert']++;
if ($csv_row === 2901){ $time_cuttent = microtime(true); echo 't10 '.($time_cuttent - $time_start)."\n";$time_start = $time_cuttent;}
}
elseif (isset($host_bd['csv_date']) && $host_bd['csv_date'] !== $csv_datatime)
{
if ($csv_row === 2901){ $time_cuttent = microtime(true); echo 't11 '.($time_cuttent - $time_start)."\n";$time_start = $time_cuttent;}
$db_request->update(
'{{%host}}',
[
......@@ -134,19 +148,24 @@ class ScanController extends Controller
]
)->execute();
$rec['update']++;
if ($csv_row === 2901){ $time_cuttent = microtime(true); echo 't12 '.($time_cuttent - $time_start)."\n";$time_start = $time_cuttent;}
}
unset($host_bd);
if ($csv_row === 2901){ $time_cuttent = microtime(true); echo 't13 '.($time_cuttent - $time_start)."\n";$time_start = $time_cuttent;}
}
else
echo PHP_EOL.$this->ansiFormat('! Error create DB request');
unset($db_request);
unset($status);
if ($csv_row === 2901){ $time_cuttent = microtime(true); echo 't14 '.($time_cuttent - $time_start)."\n";$time_start = $time_cuttent;}
}
unset($host);
if ($csv_row === 2901){ $time_cuttent = microtime(true); echo 't15 '.($time_cuttent - $time_start)."\n";$time_start = $time_cuttent;}
}
else
$csv_skip_row++;
unset($file_pos);
if ($csv_row === 2901){ $time_cuttent = microtime(true); echo 't16 '.($time_cuttent - $time_start)."\n";$time_start = $time_cuttent;}
}
unset($progress);
unset($csv_data);
......
......@@ -32,11 +32,11 @@ class Collection extends Component
$host_parts = array_reverse($host_parts);
$host_parts = array_slice($host_parts, 0, 2);
$host_parts = array_reverse($host_parts);
if (count($host_parts) === 2)
$out = $host;
$out = implode('.', $host_parts);
unset($host_parts);
}
unset($host);
return $out;
}
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!