| version 1.18, 2023/01/05 19:45:21 |
version 1.19, 2023/12/01 13:01:24 |
|
|
| * 2017-10-07 - added import of expired domains (droplist) |
* 2017-10-07 - added import of expired domains (droplist) |
| */ |
*/ |
| |
|
| /* $Platon: scripts/php/sk-nic/SK-NIC.php,v 1.17 2017/10/07 09:33:42 nepto Exp $ */ |
/* $Platon: scripts/php/sk-nic/SK-NIC.php,v 1.18 2023/01/05 19:45:21 nepto Exp $ */ |
| |
|
| require_once 'DB.php'; |
require_once 'DB.php'; |
| |
|
|
|
| function _writeImportWithLoadData($filename, $changed_date) /* {{{ */ |
function _writeImportWithLoadData($filename, $changed_date) /* {{{ */ |
| { |
{ |
| if ($this->context == 'domain') { |
if ($this->context == 'domain') { |
| |
/* SK-NIC changed format of domains.txt at Autumn/2023 |
| $query = sprintf('LOAD DATA LOCAL INFILE %s' |
$query = sprintf('LOAD DATA LOCAL INFILE %s' |
| .' INTO TABLE %s' |
.' INTO TABLE %s' |
| .' CHARACTER SET UTF8' |
.' CHARACTER SET UTF8' |
|
|
| $this->_db->quote($filename), |
$this->_db->quote($filename), |
| $this->table_import, |
$this->table_import, |
| $this->_db->quote($this->input_dt_format_sql), |
$this->_db->quote($this->input_dt_format_sql), |
| |
$this->_db->quote($changed_date)); */ |
| |
$query = sprintf('LOAD DATA LOCAL INFILE %s' |
| |
.' INTO TABLE %s' |
| |
.' CHARACTER SET UTF8' |
| |
.' FIELDS TERMINATED BY ";"' |
| |
.' IGNORE 8 LINES' |
| |
.' (domain,id_reg,id_owner,@ns,@dt_valid)' |
| |
.' SET dt_valid = STR_TO_DATE(@dt_valid, %s), dt_changed = %s,' |
| |
.' ns1 = SUBSTRING_INDEX(SUBSTRING_INDEX(@ns, ",", 1), ",", -1),' |
| |
.' ns2 = SUBSTRING_INDEX(SUBSTRING_INDEX(@ns, ",", 2), ",", -1),' |
| |
.' ns3 = SUBSTRING_INDEX(SUBSTRING_INDEX(@ns, ",", 3), ",", -1),' |
| |
.' ns4 = SUBSTRING_INDEX(SUBSTRING_INDEX(@ns, ",", 4), ",", -1)', |
| |
$this->_db->quote($filename), |
| |
$this->table_import, |
| |
$this->_db->quote($this->input_dt_format_sql), |
| $this->_db->quote($changed_date)); |
$this->_db->quote($changed_date)); |
| $result = $this->_db->query($query); |
$result = $this->_db->query($query); |
| DB::isError($result) && $this->error($result); |
DB::isError($result) && $this->error($result); |
| |
// fixing duplicate of NS |
| |
$query = sprintf('UPDATE %s SET ns4 = NULL WHERE ns4 IN (ns1, ns2, ns3)', |
| |
$this->table_import); |
| |
$result = $this->_db->query($query); |
| |
DB::isError($result) && $this->error($result); |
| |
$query = sprintf('UPDATE %s SET ns3 = NULL WHERE ns3 IN (ns1, ns2)', |
| |
$this->table_import); |
| |
$result = $this->_db->query($query); |
| |
DB::isError($result) && $this->error($result); |
| |
$query = sprintf('UPDATE %s SET ns2 = NULL WHERE ns2 = ns1', |
| |
$this->table_import); |
| |
$result = $this->_db->query($query); |
| |
DB::isError($result) && $this->error($result); |
| |
$query = sprintf('UPDATE %s SET ns1 = NULL WHERE LENGTH(ns1) <= 0', |
| |
$this->table_import); |
| |
$result = $this->_db->query($query); |
| |
DB::isError($result) && $this->error($result); |
| } elseif ($this->context == 'droplist') { |
} elseif ($this->context == 'droplist') { |
| $query = sprintf('LOAD DATA LOCAL INFILE %s' |
$query = sprintf('LOAD DATA LOCAL INFILE %s' |
| .' INTO TABLE %s' |
.' INTO TABLE %s' |