function ondemo(){
$i=0;
$ttt='';
$fff='';
while ($i<9999) {
$i++;
$ttt=$this->random(6);
if($_ENV['pay']->check_rand($ttt)){
$fff=$ttt;
if($_ENV['pay']->insert_rand($fff)) echo $fff;
break;
}
}
if(empty($fff)) echo 'error';
}
function random($length, $string = 'ABCDEFGHJKLMNPQRSTUVWXYZ')
{
$random = '';
$strlen = strlen($string);
for ($i=0; $i<$length; ++$i)
{
$random .= $string{mt_rand(0, $strlen-1)};
}
return $random;
}
model
function check_rand($char){
$data=$this->db->fetch_first("SELECT * FROM ".UC_DBTABLEPRE."random WHERE randchar='$char'");
if(empty($data)){
return true;
}else {
return false;
}
}
function insert_rand($char){
$this->db->query("INSERT INTO ".UC_DBTABLEPRE."random SET randchar='$char'");
return $this->db->insert_id();
}