コード例 #1
0
 /**
  * @dataProvider dpBadDomainValue
  */
 public function testBadDomainValue($para)
 {
     $dn = new LtDomainParser();
     $dn->init();
     $this->assertNull($dn->getRootDomain($para));
 }
コード例 #2
0
ファイル: iPHP.class.php プロジェクト: World3D/iCMS
 public static function domain($url)
 {
     self::import(iPHP_LIB . '/DomainParser.php');
     return LtDomainParser::getRootDomain($url);
 }
コード例 #3
0
 /**
  * -------------------------------------------------------------------
  * 本测试用例期望效果:
  * 使用getRootDomain()方法,正确解析网站域名
  */
 public function testMostUsedWay()
 {
     /**
      * Lotus组件初始化三步曲
      */
     // 1. 实例化
     $dn = new LtDomainParser();
     // 2. 设置属性
     // 3. 调init()方法
     $dn->init();
     //初始化完毕,测试其效果
     $this->assertEquals("example.com", $dn->getRootDomain("example.com"));
     $this->assertEquals("example.com", $dn->getRootDomain("www.example.com"));
     $this->assertEquals("google.com.hk", $dn->getRootDomain("image.google.com.hk"));
     $this->assertEquals("online.sh.cn", $dn->getRootDomain("www.online.sh.cn"));
     $this->assertEquals("sina.com.cn", $dn->getRootDomain("www.blog.user1.sina.com.cn"));
     $this->assertEquals("www.sh.cn", $dn->getRootDomain("www.sh.cn"));
     $this->assertEquals("www.sh.cn", $dn->getRootDomain("blog.www.sh.cn"));
     $this->assertEquals("z.cn", $dn->getRootDomain("deal.z.cn"));
     $this->assertEquals("tv.ch", $dn->getRootDomain("tv.ch"));
 }
コード例 #4
0
ファイル: install.php プロジェクト: sunhk25/iCMS
 } else {
     iDB::connect();
 }
 iDB::pre_set();
 iDB::select_db(true) or iPHP::alert("不能链接到数据库" . iPHP_DB_NAME, 'js:top.callback("#DB_NAME");');
 $config = iPATH . 'config.php';
 $content = iFS::read($config, false);
 $content = preg_replace("/define\\(\\'iPHP_DB_HOST\\',\\'.*?\\'\\)/is", "define('iPHP_DB_HOST','" . iPHP_DB_HOST . "')", $content);
 $content = preg_replace("/define\\(\\'iPHP_DB_USER\\',\\'.*?\\'\\)/is", "define('iPHP_DB_USER','" . iPHP_DB_USER . "')", $content);
 $content = preg_replace("/define\\(\\'iPHP_DB_PASSWORD\\',\\'.*?\\'\\)/is", "define('iPHP_DB_PASSWORD','" . iPHP_DB_PASSWORD . "')", $content);
 $content = preg_replace("/define\\(\\'iPHP_DB_NAME\\',\\'.*?\\'\\)/is", "define('iPHP_DB_NAME','" . iPHP_DB_NAME . "')", $content);
 $content = preg_replace("/define\\(\\'iPHP_DB_PREFIX\\',\\'.*?\\'\\)/is", "define('iPHP_DB_PREFIX','" . iPHP_DB_PREFIX . "')", $content);
 $content = preg_replace("/define\\(\\'iPHP_KEY\\',\\'.*?\\'\\)/is", "define('iPHP_KEY','" . random(32) . "')", $content);
 $parse_url = parse_url($router_url);
 $host = $parse_url['host'];
 $COOKIE_DOMAIN = '.' . LtDomainParser::getRootDomain($host);
 preg_match("/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\$/", $host) && ($COOKIE_DOMAIN = '');
 $content = preg_replace("/define\\(\\'iPHP_COOKIE_DOMAIN\\',\\s*\\'.*?\\'\\)/is", "define('iPHP_COOKIE_DOMAIN','{$COOKIE_DOMAIN}')", $content);
 iFS::write($config, $content, false);
 //开始安装 数据库
 $sql_file = dirname(strtr(__FILE__, '\\', '/')) . '/iCMS.V6.sql';
 is_readable($sql_file) or iPHP::alert('数据库文件不存在或者读取失败', 'js:top.callback();');
 //require_once ($config);
 $sql = iFS::read($sql_file);
 // $sql = str_replace('#iCMS@__',$db_prefix,$sql);
 //
 //
 run_query($sql);
 //设置超级管理员
 $admin_password = md5($admin_password);
 iDB::query("\n\t\tUPDATE `#iCMS@__members`\n\t\tSET `username` = '{$admin_name}', `password` = '{$admin_password}'\n\t\tWHERE `uid` = '1';\n\t");