200, 'ddos_memcache_host' => '127.0.0.1', // 需要重启apache生效 'ddos_memcache_port' => 11211, // 需要重启apache生效 'ddos_memcache_expire' => 2, ); return $c_arr[$key];}/** * @brief isddos 判断是否为过快速的ddos攻击 * * @param $index_arr * * @return */function isddos($index_arr){ $persistent_id = mt_rand(1, c('ddos_memcache_persistent_id_count')); $m = new memcached($persistent_id); if(!$m->getserverlist()) { $m->addserver(c('ddos_memcache_host'), c('ddos_memcache_port')); } $key = md5(http_build_query($index_arr)); $ret = $m->get($key) === 1 ? true : false; $m->set($key, 1, c('ddos_memcache_expire')); return $ret;}if(isddos(array('tjx', 'fdf'))){ echo 'ddos'; die();}sleep(2);echo 'return value';
