Просмотр файла admin.php

Размер файла: 7.98Kb
<?php
#[-------------------------------------------]
#[=]                                       [=]
#[=]     Wap - Голосования                 [=]
#[=]                                       [=]
#[=]    Версия    -   2.0                  [=]
#[=]    Автор     -   chezz                [=]
#[=]    Мыло      -   [email protected]     [=]
#[=]    ICQ       -   29-48-48             [=]
#[=]                                       [=]
#[-------------------------------------------]
Error_Reporting(E_ALL & ~E_NOTICE);
Error_Reporting (ERROR | WARNING);

define('VOTES','1');

require_once ("config.php");/////Подключаем настройки
require_once ("connect.php");////Подключаемся к БД
require_once ("func.php");/////Подключаем функции
require_once ("lang.ini.php");/////Подключаем lang-файл

if(isset($_GET['log']) AND isset($_GET['pass']))
{
$log=filtr($_GET['log']);
$pass=filtr($_GET['pass']);
if ($log==$login && $pass==$password)
{
body_begin();
if(isset($_GET['do']))
{
	$do=filtr($_GET['do']);

	if($do=="del")
	{
		if (isset($_GET['id']))
		{	
			$id=filtr($_GET['id']);
			$querry=@mysql_query("DELETE FROM `".$prefix."count` WHERE `id` =".$id);
			$querry2=@mysql_query("DELETE FROM `".$prefix."votes` WHERE `id` =".$id);
			
			if ($querry AND $querry2)
			{
				echo "$lang[complete]<br/>";
			} else die("error with db!</body></html>");
		}
		else
		{
		die("error in id!</body></html>");
		}
	echo "<a href=\"admin.php?log=$log&amp;pass=$pass&amp;$m\">$lang[back]</a><br/>";
	}
	
	if($do=="add")
	{		
		if (isset($go))
		{	
			$go=filtr($go);
			$r3=@mysql_query("SELECT * FROM ".$prefix."votes");	
			$id=mysql_num_rows($r3)+1;	
				
			
			$querry=@mysql_query("INSERT INTO `".$prefix."votes` VALUES (".$id.", '".$que."', '".$q1."', '".$q2."', '".$q3."', '".$q4."', '".$q5."', '".$q6."', '".$q7."', '".$q8."', '".$q9."', '".$q10."');");
			$querry2=@mysql_query("INSERT INTO `".$prefix."count` VALUES (".$id.", '', '', '', '', '', '', '', '', '', '', '');");
		
			if ($querry AND $querry2)
			{
				echo "$lang[complete]<br/>\n";
				echo "<a href=\"admin.php?log=$log&amp;pass=$pass&amp;$m\">$lang[back]</a><br/>\n";
			} else die("error!</body></html>");
		}
		else
		{
			echo "<u>$lang[addvote]</u><br/><br/>\n";
			echo "$lang[que]<br/>\n";
			
			if(!$wml) {echo "<form method=\"post\" action=\"admin.php?do=add&amp;go&amp;log=$log&amp;pass=$pass&amp;$m\">\n"; }
			
			echo "<input name=\"que\" maxlength=\"300\" title=\"question\" emptyok=\"false\"/><br/>\n";
			echo "Варианты ответов:<br/>\n";     
			echo "1-<input name=\"q1\" maxlength=\"300\" title=\"answer\" emptyok=\"false\"/><br/>\n";
			echo "2-<input name=\"q2\" maxlength=\"300\" title=\"answer\" emptyok=\"false\"/><br/>\n";
			echo "3-<input name=\"q3\" maxlength=\"300\" title=\"answer\" emptyok=\"false\"/><br/>\n";
			echo "4-<input name=\"q4\" maxlength=\"300\" title=\"answer\" emptyok=\"false\"/><br/>\n";
			echo "5-<input name=\"q5\" maxlength=\"300\" title=\"answer\" emptyok=\"false\"/><br/>\n";
			echo "6-<input name=\"q6\" maxlength=\"300\" title=\"answer\" emptyok=\"false\"/><br/>\n";
			echo "7-<input name=\"q7\" maxlength=\"300\" title=\"answer\" emptyok=\"false\"/><br/>\n";
			echo "8-<input name=\"q8\" maxlength=\"300\" title=\"answer\" emptyok=\"false\"/><br/>\n";
			echo "9-<input name=\"q9\" maxlength=\"300\" title=\"answer\" emptyok=\"false\"/><br/>\n";
			echo "10-<input name=\"q10\" maxlength=\"300\" title=\"answer\" emptyok=\"false\"/><br/>\n";
			
			
			if($wml) {
			echo "<anchor title=\"go\">$lang[create]<go href=\"admin.php?do=add&amp;go&amp;log=$log&amp;pass=$pass&amp;$m\" 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"; } else {
			
			echo "<input value=\"$lang[create]\" name=\"do\" type=\"submit\"/>\n"; 
			echo "</form><br />\n";}
			
			echo "<a href=\"admin.php?log=$log&amp;pass=$pass&amp;$m\">$lang[back]</a><br/>";
		}		
	}
}
else
{

if (isset($p)) 
{
$p=filtr($p);
$z=filtr($z);
if(!isset($z)) $z="";
} else {
$z=""; }

$r3=@mysql_query("SELECT * FROM ".$prefix."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 ".$prefix."votes ORDER BY `id` DESC LIMIT $start, $na_stranice");
$r2=@mysql_query("SELECT countall FROM ".$prefix."count ORDER BY `id` DESC LIMIT  $start, $na_stranice");

		echo "<p><b>$lang[apanel]:</b></p>\n";
		
		//echo "<a href=\"admin.php?do=logs&amp;log=$log&amp;pass=$pass&amp;$m\">Логи</a><br/>\n";
		
		echo "<a href=\"admin.php?do=add&amp;log=$log&amp;pass=$pass&amp;$m\">$lang[addvote]</a><br/>\n";
		
		echo "<p>$lang[delvote]</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&amp;id='.$id.'&amp;log='.$log.'&amp;pass='.$pass.'&amp;'.$m.'">'.$lang[del].'</a><br/>'."\n";					
		}
	
		if (mysql_num_rows($r3)>$na_stranice) 
		{
			if ($page=="first")
			{
				$z=2;
				echo "<a href=\"admin.php?log=$log&amp;pass=$pass&amp;p=next&amp;z=$z&amp;$m\">$lang[next]</a>";
			}
			elseif ($page=="last")
			{
				$z=$thispage-1;
				echo "<a href=\"admin.php?log=$log&amp;pass=$pass&amp;p=prev&amp;z=$z&amp;$m\">$lang[prev]</a>";
			}
			else 
			{
				$z=$thispage-1;
				echo "<a href=\"admin.php?log=$log&amp;pass=$pass&amp;p=prev&amp;z=$z&amp;$m\">$lang[prev]</a>";
				$z=$thispage+1;
				echo "<a href=\"admin.php?log=$log&amp;pass=$pass&amp;p=next&amp;z=$z&amp;$m\">$lang[next]</a>";
			}
		}
		xmllink("admin");//Ссылка на xhtml или на wml
		}
		
		echo "<br/><a href=\"index.php\">$lang[invotes]</a>\n";
		echo "<br/><a href=\"http://$main_link\">$lang[main_name]</a>\n";
		
		} else {
		body_begin();
	echo "wrong login or password!<br/>\n";
	echo "<a href=\"admin.php?$m\">$lang[back]</a><br/>";
	body_end();
	exit;
	}	
}

else
{
body_begin();
echo "$lang[apanel]<br/>\n";
echo "$lang[login]:<br/>\n";

if(!$wml) { echo "<form method=\"get\" action=\"admin.php\">\n"; }
echo "<input name=\"log\" maxlength=\"50\" title=\"log\" emptyok=\"false\"/><br/>\n";
echo "$lang[password]:<br/>\n";
echo "<input name=\"pass\"  maxlength=\"50\" title=\"pass\" emptyok=\"false\"/><br/>\n";

if($wml) {
echo "<anchor title=\"go\">$lang[ok]<go href=\"admin.php\" method=\"get\">\n";
echo "<postfield name=\"log\" value=\"$(log)\"/>\n";
echo "<postfield name=\"pass\" value=\"$(pass)\"/>\n";
echo "<postfield name=\"$m\" value=\"\"/>\n";
echo "</go></anchor><br/>\n"; } else {
			echo "<input type=\"hidden\" name=\"$m\" value=\"\" />";
			echo "<input value=\"$lang[ok]\" name=\"ok\" type=\"submit\"/>\n"; 
			echo "</form>\n";}

echo "<br/><a href=\"http://$main_link\">$lang[main_name]</a>\n\r";
}
mysql_close($connect);
body_end();

?>