<?php
require_once '../core/system.php';

// генерируем уникальный id
$random_val1 = mt_rand(1000, 999999);
$unique = base_convert($random_val1, 10, 11);
if(mysql_result(mysql_query("SELECT COUNT(*)  FROM `forum_topic` WHERE `id` = '$unique'"),0) == true) {
$random_val2 = mt_rand(1000, 999999);
$unique1 = base_convert($random_val2, 10, 11);
}
if(mysql_result(mysql_query("SELECT COUNT(*)  FROM `forum_topic` WHERE `id` = '$unique1'"),0) == true) {
$random_val3 = mt_rand(1000, 999999);
$unique2 = base_convert($random_val3, 10, 11);
}
if (!isset($unique2) && !isset($unique1)){
$ready_id = $unique;
}elseif (isset($unique1)){
$ready_id = $unique1;
}Elseif(isset($unique2)){
$ready_id = $unique2;
}
?>