Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Thursday, October 15, 2026

Diff for scripts/php/sk-nic/SK-NIC.php between version 1.16 and 1.17

version 1.16, 2017/09/23 00:53:31 version 1.17, 2017/10/07 09:33:42
Line 11 
Line 11 
  * Changelog:   * Changelog:
  * 2007-03-09 - created   * 2007-03-09 - created
  * 2017-09-12 - implemented new SK-NIC-EPP/CentralNic export   * 2017-09-12 - implemented new SK-NIC-EPP/CentralNic export
    * 2017-10-07 - added import of expired domains (droplist)
  */   */
   
 /* $Platon: scripts/php/sk-nic/SK-NIC.php,v 1.15 2017/09/19 02:20:11 nepto Exp $ */  /* $Platon: scripts/php/sk-nic/SK-NIC.php,v 1.16 2017/09/23 00:53:31 nepto Exp $ */
   
 require_once 'DB.php';  require_once 'DB.php';
   
Line 56  class SK_NIC
Line 57  class SK_NIC
                                 $this->table_current = 'sknic_domains';                                  $this->table_current = 'sknic_domains';
                                 $this->table_import  = 'sknic_domains_import';                                  $this->table_import  = 'sknic_domains_import';
                                 $this->table_history = 'sknic_domains_history';                                  $this->table_history = 'sknic_domains_history';
                                   $this->pk_header_del = 'domena';
                                   break;
                           case 'droplist':
                                   $this->context       = 'droplist';
                                   $this->primary_key   = 'domain';
                                   $this->table_current = 'sknic_droplist';
                                   $this->table_import  = 'sknic_droplist_import';
                                   $this->table_history = 'sknic_droplist_history';
                                   $this->pk_header_del = 'Domain_Name';
                                 break;                                  break;
                         case 'registrar':                          case 'registrar':
                                 $this->context       = 'registrar';                                  $this->context       = 'registrar';
Line 63  class SK_NIC
Line 73  class SK_NIC
                                 $this->table_current = 'sknic_registrars';                                  $this->table_current = 'sknic_registrars';
                                 $this->table_import  = 'sknic_registrars_import';                                  $this->table_import  = 'sknic_registrars_import';
                                 $this->table_history = 'sknic_registrars_history';                                  $this->table_history = 'sknic_registrars_history';
                                   $this->pk_header_del = 'Reg ID';
                                 break;                                  break;
                         default:                          default:
                                 die(sprintf("%s() ERROR: unknown context: %s\n", __FUNCTION__, $context));                                  die(sprintf("%s() ERROR: unknown context: %s\n", __FUNCTION__, $context));
Line 74  class SK_NIC
Line 85  class SK_NIC
                 $basefile = basename($filename);                  $basefile = basename($filename);
                 if (preg_match('/^domain/', $basefile)) {                  if (preg_match('/^domain/', $basefile)) {
                         return $this->setContext('domain');                          return $this->setContext('domain');
                   } elseif (preg_match('/^droplist/', $basefile)) {
                           return $this->setContext('droplist');
                 } elseif (preg_match('/^registrar/', $basefile)) {                  } elseif (preg_match('/^registrar/', $basefile)) {
                         return $this->setContext('registrar');                          return $this->setContext('registrar');
                 }                  }
Line 144  class SK_NIC
Line 157  class SK_NIC
                 $query = 'SELECT COUNT(*) FROM '.$this->table_import;                  $query = 'SELECT COUNT(*) FROM '.$this->table_import;
                 $count = $this->_db->getOne($query);                  $count = $this->_db->getOne($query);
                 DB::isError($count) && $this->error($count);                  DB::isError($count) && $this->error($count);
                   // here droplist shares limits with registrars (1000/9900)
                 $min_count = ($this->context == 'domain') ? 100000 : 1000;                  $min_count = ($this->context == 'domain') ? 100000 : 1000;
                 $max_count = ($this->context == 'domain') ? 900000 : 9000;                  $max_count = ($this->context == 'domain') ? 900000 : 9900;
                 if ($count < $min_count) {                  if ($count < $min_count) {
                         die(sprintf("%s() ERROR: too less imported records: %d (must be min %d)\n",                          die(sprintf("%s() ERROR: too less imported %s records: %d (must be min %d)\n",
                                                 __FUNCTION__, $count, $min_count));                                                  __FUNCTION__, $this->context, $count, $min_count));
                 }                  }
                 if ($count > $max_count) {                  if ($count > $max_count) {
                         die(sprintf("%s() ERROR: too much imported records: %d (must be max 600000)\n",                          die(sprintf("%s() ERROR: too much imported %s records: %d (must be max 600000)\n",
                                                 __FUNCTION__, $count, $max_count));                                                  __FUNCTION__, $this->context, $count, $max_count));
                 }                  }
                 return true;                  return true;
         } /* }}} */          } /* }}} */
Line 186  class SK_NIC
Line 200  class SK_NIC
         {       /* Sorts by:          {       /* Sorts by:
                  * 1. length - shorter hostname first                   * 1. length - shorter hostname first
                  * 2. alphabeticaly                   * 2. alphabeticaly
                  * Sorted exmaple:                   * Properly sorted example:
                  * - ns.platon.sk                   * - ns.platon.sk
                  * - dns.platon.sk                   * - dns.platon.sk
                  * - ns.platon.org                   * - ns.platon.org
Line 204  class SK_NIC
Line 218  class SK_NIC
         } /* }}} */          } /* }}} */
   
         function _writeImportWithInserts($filename, $changed_date) /* {{{ */          function _writeImportWithInserts($filename, $changed_date) /* {{{ */
         {          { // DELETEME 1Q/2018
                 if (($f = fopen($filename, 'r')) == false) {                  if (($f = fopen($filename, 'r')) == false) {
                         $this->error('unable to open: '.$filename);                          $this->error('unable to open: '.$filename);
                 }                  }
Line 256  class SK_NIC
Line 270  class SK_NIC
                                         $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);
                   } elseif ($this->context == 'droplist') {
                           $query = sprintf('LOAD DATA LOCAL INFILE %s'
                                           .' INTO TABLE %s'
                                           .' CHARACTER SET UTF8'
                                           .' FIELDS TERMINATED BY ","' // note different separator
                                           .' (domain,date_entered,date_leaves,date_purged)'
                                           .' SET dt_changed = %s',
                                           $this->_db->quote($filename),
                                           $this->table_import,
                                           $this->_db->quote($changed_date));
                           $result = $this->_db->query($query);
                           DB::isError($result) && $this->error($result);
                 } elseif ($this->context == 'registrar') {                  } elseif ($this->context == 'registrar') {
                         $this->_db->query('SET NAMES UTF8');                          $this->_db->query('SET NAMES UTF8');
                         $query = sprintf('LOAD DATA LOCAL INFILE %s'                          $query = sprintf('LOAD DATA LOCAL INFILE %s'
Line 273  class SK_NIC
Line 299  class SK_NIC
                         die(sprintf("%s() ERROR: unknown context: %s\n", __FUNCTION__, $context));                          die(sprintf("%s() ERROR: unknown context: %s\n", __FUNCTION__, $context));
                 }                  }
   
                 $query = "DELETE FROM $this->table_import WHERE $this->primary_key LIKE '-- %'";                  // Remove all lines started with "--"
                   $query = sprintf('DELETE FROM %s WHERE %s LIKE "-- %%"',
                                   $this->table_import, $this->primary_key);
                   $result = $this->_db->query($query);
                   DB::isError($result) && $this->error($result);
                   // Remove table headers (we want just data)
                   $query = sprintf('DELETE FROM %s WHERE %s = %s LIMIT 1',
                                   $this->table_import, $this->primary_key,
                                   $this->_db->quote($this->pk_header_del));
                 $result = $this->_db->query($query);                  $result = $this->_db->query($query);
                 DB::isError($result) && $this->error($result);                  DB::isError($result) && $this->error($result);
         } /* }}} */          } /* }}} */

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top