require_once("conn.php");
if(isset($_POST[s1]))
{
require_once("access.php");
$q1 = "insert into domain_vote set
domainid = '$_POST[DomainID]',
vote = '$_POST[rate]',
voterid = '$_SESSION[MemberID]' ";
mysql_query($q1) or die(mysql_error());
$RatedDomain = $_POST[DomainName];
$YourPrice = $_POST[rate];
$q1 = "select sum(vote)/count(voterid) as AvaragePrice, count(voterid) as other from domain_vote where domainid = '$_POST[DomainID]' ";
$r1 = mysql_query($q1) or die(mysql_error());
$a1 = mysql_fetch_array($r1);
$OtherNumber = $a1[other];
$OtherRate = number_format($a1[AvaragePrice], 2, ".", "");
}
$va = array();
//get the domains rated by this user
$qr = "select domainid from domain_vote where voterid = '$_SESSION[MemberID]' ";
$rr = mysql_query($qr) or die(mysql_error());
while($ar = mysql_fetch_array($rr))
{
$va[] = $ar[domainid];
}
if(!empty($va))
{
array_unique($va);
$for2 = implode("', '", $va);
}
//get the domains, but without forbidden domains
$q1 = "select domainid from domain_domains where memberid != '$_SESSION[MemberID]' and domainid not in ('$for2') ";
$r1 = mysql_query($q1) or die(mysql_error());
if(mysql_num_rows($r1) > '0')
{
while($a1 = mysql_fetch_array($r1))
{
$rArray[] = $a1[0];
}
srand ((float) microtime() * 10000000);
$MyKey = array_rand($rArray, 1);
$DomainID = $rArray[$MyKey];
//get the domain
$q2 = "select * from domain_domains where domainid = '$DomainID' ";
$r2 = mysql_query($q2) or die(mysql_error());
$a2 = mysql_fetch_array($r2);
$ShowDomain = "$a2[domainname]";
$DomainName = $a2[domainname];
//create the select menu
$qs = "select * from domain_prices order by PriceValue";
$rs = mysql_query($qs) or die(mysql_error());
$SelectMenu = "";
require_once("templates/header.php");
require_once("templates/IndexTemplate.php");
}
else
{
// no new domains
require_once("templates/header.php");
require_once("templates/NoDomains.php");
}
require_once("templates/footer.php");
?>