File size: 7.67Kb
<?php
////////////////////////////////////////////
//
// Скрипт Голосований на MySql
//
// Версия - 1.0 (wap1.1)
// Автор - CHEZZ
// гМыло :) - [email protected]
// wap-сайт - http://underwap.net
//
////////////////////////////////////////////
Error_Reporting(E_ALL & ~E_NOTICE); //// Нет ошибок
header("Pragma: no-cache");
header ("Content-type:text/vnd.wap.wml;charset=utf-8");///Выводим Хеадэр
include "config.php";/////Подключаем настройки
include "connect.php";////Подключаемся к БД
include "func.php";/////Подключаем функции
body_begin();
if(isset($log) AND isset($pass))
{
//$r=mysql_query("SELECT login, password FROM vote_admin");
//$row = mysql_fetch_array($r);
//$login=$row['login'];
//$password=$row['password'];
$log=filtr($log);
$pass=filtr($pass);
if ($log==$login AND $pass==$password)
{
if(isset($do))
{
$do=filtr($do);
if($do=="del")
{
if (isset($id))
{
$querry=@mysql_query("DELETE FROM `vote_count` WHERE `id` ="."$id"."");
$querry2=@mysql_query("DELETE FROM `vote_votes` WHERE `id` ="."$id"."");
if ($querry AND $querry2)
{
echo "Успешно!<br/>";
}
}
else
{
echo "Ошибка!<br/>";
}
echo "<a href=\"admin.php?log=$log&pass=$pass\">Назад</a><br/>";
}
if($do=="add")
{
if (isset($go))
{
$go=filtr($go);
$r3=mysql_query("SELECT * FROM vote_votes");
$id=mysql_num_rows($r3)+1;
$querry=@mysql_query("INSERT INTO `vote_votes` VALUES (".$id.", '".$que."', '".$q1."', '".$q2."', '".$q3."', '".$q4."', '".$q5."', '".$q6."', '".$q7."', '".$q8."', '".$q9."', '".$q10."');");
$querry2=@mysql_query("INSERT INTO `vote_count` VALUES (".$id.", '', '', '', '', '', '', '', '', '', '', '');");
if ($querry AND $querry2)
{
echo "Успешно!<br/>\n";
echo "<a href=\"admin.php?log=$log&pass=$pass\">Назад в Админку</a><br/>\n";
}
}
else
{
echo "<u>Новое Голосование</u><br/><br/>\n";
echo "Вопрос:<br/>\n";
echo "<input name=\"que\" maxlength=\"100\" title=\"question\" emptyok=\"false\"/><br/>\n";
echo "Варианты ответов:<br/>\n";
echo "1-<input name=\"q1\" maxlength=\"100\" title=\"answer\" emptyok=\"false\"/><br/>\n";
echo "2-<input name=\"q2\" maxlength=\"100\" title=\"answer\" emptyok=\"false\"/><br/>\n";
echo "3-<input name=\"q3\" maxlength=\"100\" title=\"answer\" emptyok=\"false\"/><br/>\n";
echo "4-<input name=\"q4\" maxlength=\"100\" title=\"answer\" emptyok=\"false\"/><br/>\n";
echo "5-<input name=\"q5\" maxlength=\"100\" title=\"answer\" emptyok=\"false\"/><br/>\n";
echo "6-<input name=\"q6\" maxlength=\"100\" title=\"answer\" emptyok=\"false\"/><br/>\n";
echo "7-<input name=\"q7\" maxlength=\"100\" title=\"answer\" emptyok=\"false\"/><br/>\n";
echo "8-<input name=\"q8\" maxlength=\"100\" title=\"answer\" emptyok=\"false\"/><br/>\n";
echo "9-<input name=\"q9\" maxlength=\"100\" title=\"answer\" emptyok=\"false\"/><br/>\n";
echo "10-<input name=\"q10\" maxlength=\"100\" title=\"answer\" emptyok=\"false\"/><br/>\n";
echo "<anchor title=\"go\">Создать<go href=\"admin.php?do=add&go&log=$log&pass=$pass\" method=\"post\">\n";
echo "<postfield name=\"q1\" value=\"$(q1)\"/>\n";
echo "<postfield name=\"q2\" value=\"$(q2)\"/>\n";
echo "<postfield name=\"q3\" value=\"$(q3)\"/>\n";
echo "<postfield name=\"q4\" value=\"$(q4)\"/>\n";
echo "<postfield name=\"q5\" value=\"$(q5)\"/>\n";
echo "<postfield name=\"q6\" value=\"$(q6)\"/>\n";
echo "<postfield name=\"q7\" value=\"$(q7)\"/>\n";
echo "<postfield name=\"q8\" value=\"$(q8)\"/>\n";
echo "<postfield name=\"q9\" value=\"$(q9)\"/>\n";
echo "<postfield name=\"q10\" value=\"$(q10)\"/>\n";
echo "<postfield name=\"que\" value=\"$(que)\"/>\n";
echo "</go></anchor><br/>\n";
echo "<a href=\"admin.php?log=$log&pass=$pass\">Назад</a><br/>";
}
}
}
else
{
if (isset($p))
{
$p=filtr($p);
$z=filtr($z);
if(!isset($z)) $z="";
} else {
$z=""; }
$r3=mysql_query("SELECT * FROM vote_votes");
if ($z==false OR $z==1) { $start=0; $page="first"; }
else
{
$pg=mysql_num_rows($r3)/$na_stranice;
if ($p="next") $start=$z*$na_stranice-$na_stranice;
else $start=$z*$na_stranice+$na_stranice;
$pg=ceil($pg);
$minpage=1;
$maxpage=$pg;
}
if (!isset($page))
{
if ($z == $maxpage) $page="last";
else $page="some";
}
$thispage=$z;
$r=mysql_query("SELECT * FROM vote_votes ORDER BY `id` DESC LIMIT $start, $na_stranice");
$r2=mysql_query("SELECT countall FROM vote_count ORDER BY `id` DESC LIMIT $start, $na_stranice");
echo "<p><b>Админка:</b></p>\n";
echo "<a href=\"admin.php?do=add&log=$log&pass=$pass\">Добавить Голосование</a><br/>\n";
echo "<p>Удалить Голосование:</p>\n";
for($i = 0;$i < mysql_num_rows($r);$i++)
{
if(!isset($num))
{
if(isset($p))
{
$num=$start+1;
}
else $num=1;
}
else $num++;
$row = mysql_fetch_array($r);
$row2 = mysql_fetch_array($r2);
$id = $row['id'];
$count = $row2['countall'];
if(!$count) $count="0";
$name = $row['name'];
echo $num.') '.$name.' ['.$count.'] <a href="admin.php?do=del&id='.$id.'&log='.$log.'&pass='.$pass.'">[X]</a><br/>'."\n";
}
if (mysql_num_rows($r3)>$na_stranice)
{
if ($page=="first")
{
$z=2;
echo "<anchor title=\"next\">$next<go href=\"admin.php?p=next&log=$log&pass=$pass\" method=\"post\">\n";
echo "<postfield name=\"z\" value=\"$z\"/>\n";
echo "</go></anchor><br/>\n";
}
elseif ($page=="last")
{
$z=$thispage-1;
echo "<anchor title=\"prev\">$prev<go href=\"admin.php?p=prev&log=$log&pass=$pass\" method=\"post\">\n";
echo "<postfield name=\"z\" value=\"$z\"/>\n";
echo "</go></anchor><br/>\n";
}
else
{
$z=$thispage-1;
echo "<anchor title=\"prev\">$prev<go href=\"admin.php?p=prev&log=$log&pass=$pass\" method=\"post\">\n";
echo "<postfield name=\"z\" value=\"$z\"/>\n";
echo "</go></anchor>/";
$z=$thispage+1;
echo "<anchor title=\"next\">$next<go href=\"admin.php?p=next&log=$log&pass=$pass\" method=\"post\">\n";
echo "<postfield name=\"z\" value=\"$z\"/>\n";
echo "</go></anchor><br/>\n";
}
}
echo "<br/><a href=\"index.php\">В Голосования</a>\n\r";
echo "<br/><a href=\"http://$main_link\">$main_name</a>\n\r";
}
}
else
{
header("Location: http://$main_link");
exit();
}
}
else
{
echo "Админ Панель<br/>\n";
echo "Логин:<br/>\n";
echo "<input name=\"log\" maxlength=\"50\" title=\"log\" emptyok=\"false\"/><br/>\n";
echo "Пароль:<br/>\n";
echo "<input name=\"pass\" maxlength=\"50\" title=\"pass\" emptyok=\"false\"/><br/>\n";
echo "<anchor title=\"go\">OK<go href=\"admin.php\" method=\"post\">\n";
echo "<postfield name=\"log\" value=\"$(log)\"/>\n";
echo "<postfield name=\"pass\" value=\"$(pass)\"/>\n";
echo "</go></anchor><br/>\n";
echo "<br/><a href=\"http://$main_link\">На Главную</a>\n\r";
}
mysql_close($connect);
body_end();
?>