1. $id = md5(time().microtime()+$_SERVER['HTTP_USER_AGENT']);
  2. $i = 4;
  3. while($i<32){
  4. $i++;
  5. $k2 = substr($id,0,$i);
  6. $q = "SELECT count(id) FROM url where id = '$k2';";
  7. $res = $c->q($q);
  8. $fetch = mysql_fetch_array($res);
  9. if($fetch[0] == 0){
  10. $id = $k2;
  11. break;
  12. }
  13. }