0
点赞
收藏
分享

微信扫一扫

自动跑code,往数据库里存好多唯一code

九点韶留学 2023-01-12 阅读 47


public function run(){

$t = (int)time();
$stop = $t + 5;

for ($i = 1; ; $i++) {
if ((int)time() > $stop) {
break;
}

$id = $this->index();
if($i == 1 ){
$first = $id;
}
}

echo "<h1>";
echo $first;
echo "<br>";
echo $id;
echo "</h1>";
echo "5秒钟跑了".(int)$id-(int)$first; */
}

public function index(){

$code = $this->create_code();

$data['code'] = $code;
$data['codeurl'] = "http://".$code.".ma.lang100.com/";
$url = "http://".$code.".ma.lang100.com/";

$codecode = M('ma')->data(array('code'=>$code,'url'=>$url))->add();

return $codecode;
}



private function create_code($namespace = '') {
static $guid = '';
$uid = uniqid("", true);
$data = $namespace;
$data .= $_SERVER['REQUEST_TIME'];
$data .= $_SERVER['HTTP_USER_AGENT'];
$data .= $_SERVER['LOCAL_ADDR'];
$data .= $_SERVER['LOCAL_PORT'];
$data .= $_SERVER['REMOTE_ADDR'];
$data .= $_SERVER['REMOTE_PORT'];
$hash = strtolower(hash('ripemd128', $uid . $guid . md5($data)));
$guid = substr($hash, 0, 8).substr($hash, 8, 4).substr($hash, 12, 4).substr($hash, 16, 4).substr($hash, 20, 12);
return $guid;
}


举报

相关推荐

0 条评论