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;
}
自动跑code,往数据库里存好多唯一code
最新推荐文章于 2021-03-08 05:31:58 发布