| version 1.2, 2007/03/11 03:54:40 |
version 1.3, 2007/03/12 03:50:10 |
|
|
| * |
* |
| */ |
*/ |
| |
|
| /* $Platon: scripts/php/sk-nic/SK-NIC.php,v 1.1 2007-03-11 03:49:48 nepto Exp $ */ |
/* $Platon: scripts/php/sk-nic/SK-NIC.php,v 1.2 2007-03-11 03:54:40 nepto Exp $ */ |
| |
|
| require_once 'DB.php'; |
require_once 'DB.php'; |
| |
|
| class SK_NIC |
class SK_NIC |
| { |
{ |
| |
var $input_dt_format_sql = '%d.%m.%Y'; |
| var $_dsn = null; |
var $_dsn = null; |
| var $_db = null; |
var $_db = null; |
| |
|
|
|
| $changed_date = $this->_getChangedDateFromFilename($filename); |
$changed_date = $this->_getChangedDateFromFilename($filename); |
| } |
} |
| $this->_cleanImport(); |
$this->_cleanImport(); |
| $this->_writeImport($filename, $changed_date); |
$this->_writeImportWithLoadData($filename, $changed_date); |
| } /* }}} */ |
} /* }}} */ |
| |
|
| function _cleanImport() /* {{{ */ |
function _cleanImport() /* {{{ */ |
|
|
| DB::isError($result) && $this->error($result); |
DB::isError($result) && $this->error($result); |
| } /* }}} */ |
} /* }}} */ |
| |
|
| function _writeImport($filename, $changed_date) /* {{{ */ |
function _writeImportWithInserts($filename, $changed_date) /* {{{ */ |
| { |
{ |
| if (($f = fopen($filename, 'r')) == false) { |
if (($f = fopen($filename, 'r')) == false) { |
| $this->error('unable to open: '.$filename); |
$this->error('unable to open: '.$filename); |
|
|
| fclose($f); |
fclose($f); |
| } /* }}} */ |
} /* }}} */ |
| |
|
| |
function _writeImportWithLoadData($filename, $changed_date) /* {{{ */ |
| |
{ |
| |
$query = sprintf('load data local infile %s' |
| |
.' into table sknic_domains_import' |
| |
.' fields terminated by ";"' |
| |
.' ignore 11 lines' |
| |
.' (domain,id_reg,id_owner,flag,status,ns1,ns2,ns3,ns4,ico_owner,@dt_valid)' |
| |
.' SET dt_valid = STR_TO_DATE(@dt_valid, %s), dt_changed = %s', |
| |
$this->_db->quote($filename), |
| |
$this->_db->quote($this->input_dt_format_sql), |
| |
$this->_db->quote($changed_date)); |
| |
$result = $this->_db->query($query); |
| |
DB::isError($result) && $this->error($result); |
| |
} /* }}} */ |
| |
|
| function _writeDomainHistory($rec, $deleted = 0) /* {{{ */ |
function _writeDomainHistory($rec, $deleted = 0) /* {{{ */ |
| { |
{ |
| static $dt_deleted = null; |
static $dt_deleted = null; |