Súbor: [Platon] / scripts / php / sk-nic / sk-nic.php (stiahnutie)
Revízia 1.17, Sat Dec 23 22:04:13 2023 UTC (2 years, 4 months ago) by nepto
Zmeny od 1.16: +25 -12 [lines]
Make --debug multi option (multiple options for more severity)
Use error() method for each failure within the SK-NIC class
Each DB::isError() call location now uses proper if()
|
<?php
/*
* sk-nic.php
*
* Developed by Ondrej Jombik <nepto@platon.sk>
* Copyright (c) 2007 Platon Group, http://platon.sk/
* Licensed under terms of GNU General Public License.
* All rights reserved.
*
* Changelog:
* 2007-03-09 - created
* 2017-09-12 - implemented new SK-NIC-EPP/CentralNic export
* 2017-10-07 - added import of expired domains (droplist)
* 2023-12-13 - implemented --debug multi option
*/
/* $Platon: scripts/php/sk-nic/sk-nic.php,v 1.16 2023/12/19 15:35:42 nepto Exp $ */
error_reporting(E_ALL);
ini_set('mysqli.allow_local_infile', true); // probably has no effect
$FILENAME = '';
$DO_DEBUG = 0;
for ($i = 1; ; $i++) {
$FILENAME = @$_SERVER['argv'][$i];
if ($FILENAME != '--debug') {
break;
}
$DO_DEBUG++;
}
if (strlen($FILENAME) <= 0) {
printf('Usage: %s [ --debug [ --debug ] ] <filename>'."\n", $_SERVER['argv'][0]);
exit;
}
if (! file_exists($FILENAME)) {
die("ERROR: file does not exist: $FILENAME\n");
}
if (! is_readable($FILENAME)) {
die("ERROR: file is not readable: $FILENAME\n");
}
$dsn = 'mysql://test:test@localhost/test';
if (file_exists(dirname(__FILE__).'/config.inc.php')) {
require_once dirname(__FILE__).'/config.inc.php';
}
require_once dirname(__FILE__).'/SK-NIC.php';
# This enables CLIENT_LOCAL_FILES flag, see:
# http://www.php.net/manual/en/mysql.constants.php
$dsn .= '?client_flags=128';
$sk_nic = new SK_NIC($dsn, $DO_DEBUG);
$sk_nic->setContextFromFilename($FILENAME);
$changed_date = $sk_nic->doImport($FILENAME);
if (empty($changed_date)) {
fprintf(STDERR, "ERROR: file is too old: $FILENAME\n");
fprintf(STDERR, " was this file already imported?\n");
exit(2);
} else {
if ($DO_DEBUG) {
echo "INFO: using changed_date: $changed_date\n";
}
}
if (! $sk_nic->checkImport()) {
fprintf(STDERR, "ERROR: imported data are not valid\n");
exit(3);
}
// only for domains
if ($sk_nic->context == 'domain') {
$sk_nic->_importedSetStatusOK();
$sk_nic->_importedNameserversReorder();
$sk_nic->writeStats();
}
$changed_records = $sk_nic->doComparison();
if ($sk_nic->context == 'domain') {
if ($changed_records <= 100) {
fprintf(STDERR, 'WARNING: too less changed domain records: %d'."\n", $changed_records);
} elseif ($changed_records >= 50000) {
fprintf(STDERR, 'WARNING: too many changed domain records: %d'."\n", $changed_records);
} else{
fprintf(STDERR, 'INFO: changed %s records: %d'."\n", $sk_nic->context, $changed_records);
}
} else {
fprintf(STDERR, 'INFO: changed %s records: %d'."\n", $sk_nic->context, $changed_records);
}
/* Modeline for ViM {{{
* vim: set ts=4:
* vim600: fdm=marker fdl=0 fdc=0:
* }}} */
?>
Platon Group <platon@platon.sk> http://platon.sk/
|