File size: 4.62Kb
<?php
###########################################################################
## -=FERNUS=- ##
## --------------- ##
## http://sekis.us ##
## *-*-*-* ##
## *Колян* ##
## ICQ: 42-11-04-014 ##
## - - - - - ##
## Скрипт: Опроса/Голосований ##
## - - - - - ##
## Любые изменения кода скрипта, его перепродажа (СКРИПТ ВЫЛОЖЕН ##
## БЕСПЛАТНО)-ЗАПРЕЩЕННО и приследуется Мной и Законом об ##
## Авторских Правах!!! ##
###########################################################################
//START TIMER
list($msec, $sec) = explode(chr(32), microtime());
$headtime = $sec + $msec;
//ERROR REPORTING LEVEL
error_reporting(0);
//MySQL
include("cfg.php");
//TITLE
$title = "Опрос";
@$id = intval($_GET['id']);
@$mod = $_GET['mod'];
$REMOTE_ADDR = htmlspecialchars(addslashes(trim(getenv("REMOTE_ADDR"))));
$HTTP_USER_AGENT = htmlspecialchars(addslashes(trim(getenv("HTTP_USER_AGENT"))));
///////////////////////////////////////////////////////
//WML VERSION
///////////////////////////////////////////////////////
header("Content-type: text/vnd.wap.wml; charset=utf-8");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-relative");
echo "<?xml version='1.0' encoding='UTF-8'?>\n";
echo "<!DOCTYPE wml PUBLIC '-//WAPFORUM//DTD WML 1.3//EN' 'http://www.wapforum.org/DTD/wml13.dtd'><wml>\n";
echo "<head><meta http-equiv='Cache-Control' content='no-cache' forua='true'/></head>\n";
echo "<card id='catalogue' title='".$title."'>\n<p align='left'><small>\n";
if (empty($mod)) $mod="index";
switch ($mod) {
case "index";
echo "<b>Отдай свой голос!</b><br/>";
echo "<u>$vopros</u>:<br/><br/>";
$sql = mysql_query("SELECT * FROM `".$opros."` ORDER BY `id` ASC, `id` ASC;");
if(mysql_affected_rows() == 0)
{
echo "Контендентов нет!<br/>\n";
}
while($opr = mysql_fetch_array($sql))
{
$name = $opr['name'];
$id = $opr['id'];
echo "<a href=\"./index.php?mod=golos&id=".$id."\">".$name."</a><br/>";
}
echo "- - -<br/><a href=\"./rating.php\">Рейтинг</a><br/>";
echo "<a href=\"http://$site\">$site</a><br/>";
break;
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
case "golos";
$sql = mysql_query("SELECT * FROM `".$opros."` WHERE `id`='".$id."';");
if(mysql_affected_rows() == 0)
{
echo "Ошибка!<br/>\n";
//STOP TIMER
list($msec, $sec) = explode(chr(32), microtime());
echo "<small>[".round(($sec + $msec) - $headtime, 5)."]</small><br/>\n";
echo "</small></p></card></wml>";
exit();
}
///////////////////////////////////////////////////////
$sql = mysql_query("SELECT * FROM `".$gols."` WHERE `ip` = INET_ATON('".$REMOTE_ADDR."') AND `time` > '".(time() - 3600)."';");
if(mysql_affected_rows() == 0)
{
mysql_query("UPDATE `".$opros."` SET `golos` = `golos` + 1 WHERE `id` = ".$id.";");
mysql_query("INSERT INTO `".$gols."` SET `ip` = INET_ATON('".$REMOTE_ADDR."'), `time` = '".time()."', `browser` = '".$HTTP_USER_AGENT."', `id` = '".$id."';");
echo "Ваш голос учтён!<br/>- - -<br/>\n";
}else{
echo "Ваш голос учтён ранее!<br/>- - -<br/>\n";
}
///////////////////////////////////////////////////////
$sql2 = mysql_query("SELECT * FROM `".$opros."` ORDER BY `golos` DESC;");
$sql3 = mysql_query("SELECT SUM(`golos`) FROM `".$opros."`;");
$a = mysql_result($sql3, 0);
if(mysql_affected_rows() == 0)
{
echo "Контендентов нет!<br/>\n";
}
while($opr2 = mysql_fetch_array($sql2))
{
$name = $opr2['name'];
$gl = $opr2['golos'];
$pro = $gl/$a*100;
$pro = round($pro, 1);
echo "<u>".$name."</u>: <b>".$gl."</b> / <b>".$pro."%</b><br/>";
}
echo "- - -<br/><a href=\"./index.php\">Назад</a><br/>";
break;
}
//STOP TIMER
list($msec, $sec) = explode(chr(32), microtime());
echo "<small>[".round(($sec + $msec) - $headtime, 5)."]</small><br/>\n";
echo "</small></p></card></wml>";
?>