Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 您可以轻松地进行查询查找顶级域后,您会做些什么@KA_linDetermining什么是“顶级域”是非常重要的。请参阅。如果您颠倒了域名,即com.example,com.exanple.a,则查找明显相关的域名可能并不“困难”。?将这些标记为已处理,然后_Php_Mysql_Bigdata - Fatal编程技术网

Php 您可以轻松地进行查询查找顶级域后,您会做些什么@KA_linDetermining什么是“顶级域”是非常重要的。请参阅。如果您颠倒了域名,即com.example,com.exanple.a,则查找明显相关的域名可能并不“困难”。?将这些标记为已处理,然后

Php 您可以轻松地进行查询查找顶级域后,您会做些什么@KA_linDetermining什么是“顶级域”是非常重要的。请参阅。如果您颠倒了域名,即com.example,com.exanple.a,则查找明显相关的域名可能并不“困难”。?将这些标记为已处理,然后,php,mysql,bigdata,Php,Mysql,Bigdata,您可以轻松地进行查询查找顶级域后,您会做些什么@KA_linDetermining什么是“顶级域”是非常重要的。请参阅。如果您颠倒了域名,即com.example,com.exanple.a,则查找明显相关的域名可能并不“困难”。?将这些标记为已处理,然后开始处理更“有趣”的案例?大声思考:是否可以直接使用域名系统进行查询并获取信息?好的,它可能没有那么快,但它可以增量完成。如果您自己存储结果,那么最终将更加完整。在短时间内对DNS进行如此多的查询可能需要花费金钱。 CREATE TABLE `


您可以轻松地进行查询查找顶级域后,您会做些什么@KA_linDetermining什么是“顶级域”是非常重要的。请参阅。如果您颠倒了域名,即
com.example
com.exanple.a
,则查找明显相关的域名可能并不“困难”。?将这些标记为已处理,然后开始处理更“有趣”的案例?大声思考:是否可以直接使用
域名系统
进行查询并获取信息?好的,它可能没有那么快,但它可以增量完成。如果您自己存储结果,那么最终将更加完整。在短时间内对DNS进行如此多的查询可能需要花费金钱。
CREATE TABLE `domain` (
  `domain_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `domain_name` varchar(255) COLLATE utf8_turkish_ci NOT NULL,
  PRIMARY KEY (`domain_id`),
  UNIQUE KEY `dn` (`domain_name`),
  KEY `ind_domain_name` (`domain_name`)
) ENGINE=InnoDB AUTO_INCREMENT=78364364 DEFAULT CHARSET=utf8 COLLATE=utf8_turkish_ci;
domain_id | domain_name

1         | a.example.com

2         | b.example.com 

3         | example.com

4         | facebook.com

5         | a.facebook.com

6         | google.com
select domain_id, domain_name, reverse(domain_name) as reversed
from domain
order by 
rpad(reverse(domain_name),130,' '),
length(domain_name),
reverse(domain_name), 
domain_id
        google.com -> moc.elgoog, 
      a.google.com -> moc.elgoog.a
   xy.a.google.com -> moc.elgoog.a.yx
      b.google.com -> moc.elgoog.a
  $currentDomains = array(); 
  /*
     array domainpart => id
     moc     => 0
     elgoog  => id of google.com as long as we are in subdomains of google.com
     a       => id of a.google.com as long as we are in subdomains of a.google.com

     this gets never longer then the number of domainparts, so usually a very
     short array!
   */

  $sql = "select domain_id, domain_name, reverse(domain_name) as reversed\n"
      . " from domain \n"
      . " order by  \n"
      . " rpad(reverse(domain_name),130,' '), \n"
      . " length(domain_name), \n"
      . " reverse(domain_name),  \n"
      . " domain_id"
      ;

  doSelect($sql);

  while($row = getRow()){
    $parts = preg_split('/\./', $row["reversed"]);
    # print("parts = \n");print_r($parts);
    $rid = $row["domain_id"];

    $matchedDomains = array();
    $parentId = $rid; // if no parent, show to yourself

    $i = 0;
    // 1. match identical parts
    //     php is funny, the array is a key=>value but with 
    //     foreach it restores the key-values in the inserted order.
    foreach($currentDomains as $name => $cid){
      # print("> check $i '$name' '{$parts[$i]}'\n");
      if($parts[$i] == $name){
        $matchedDomains[$name] = $cid;
        if($cid > 0){
          $parentId = $cid;
        }
        $i++;
      }
      else{
        break;
      }
    }
    // 2.
    // new parts
    while ($i < count($parts)-1){
      # print("> store '{$parts[$i]}' \n");
      $matchedDomains[$parts[$i]] = 0; // no row matches those
      $i++;
    }
    $matchedDomains[$parts[count($parts)-1]] = $rid;
    $currentDomains = $matchedDomains;
    print(" update domain set parent_id = $parentId where id = $rid\n"); // use PDO
  }