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

Размер файла: 3.59Kb
<?php
	#=====================================================#
	#             Programmed By Giga                      #
	#             (c) 2006 Votes xhtml mp v 0.1           #
	#             site http://gwap.net.ru                 #
	#             example http://gwap.net.ru              #
	#             elaboration xhmtl mp scripts            #
	#                     [email protected]                      #
	#=====================================================#

	Error_Reporting(E_ALL & ~E_NOTICE);
include 'head.php';
echo '<p class="p1">ОПРОС</p>';
	$result = file("vote.txt");
	$name_answer = trim($result[0]);
    $result1 = trim($result[1]);
    $result1 = explode('|',$result1);
    $a1 = $result1[0];
    $result1 = $result1[1];
    $result2 = trim($result[2]);
    $result2 = explode('|',$result2);
    $a2 = $result2[0];
    $result2 = $result2[1];
    $result3 = trim($result[3]);
    $result3 = explode('|',$result3);
    $a3 = $result3[0];
    $result3 = $result3[1];
    $result4 = trim($result[4]);
    $result4 = explode('|',$result4);
    $a4 = $result4[0];
    $result4 = $result4[1];
    $result5 = trim($result[5]);
    $result5 = explode('|',$result5);
    $a5 = $result5[0];
    $result5 = $result5[1];

if(!$op)
{
  echo "<form action=\"vote.php\" method=\"post\"><p class=\"p2\">
  $name_answer<br />
  	  <select name=\"op\">
  <option value=\"1\">$a1</option>
  <option value=\"2\">$a2</option>
  <option value=\"3\">$a3</option>
  <option value=\"4\">$a4</option>
  <option value=\"5\">$a5</option>
  	  </select>
  	  <br />
  	  <input type=\"submit\" value=\"голосовать\" />
  	  </p>
  	  </form>";
}
else
{
$hours=date("H");
$othertime = date(".i-d.m.y");
$timer = "$hours$othertime";
$user=getenv("HTTP_USER_AGENT")."<br />$REMOTE_ADDR";
$userlist = file("userlist.txt");
$totaluser = count($userlist);
   for ($i = 0; $i <= $totaluser; $i++)
   {
$detect_user = explode('|',$userlist[$i]);
$detect_user = $detect_user[0];
$detect_user = "$detect_user|";
$detect_user = explode('|',$detect_user);
    $result  =  false ; 
			foreach ($detect_user as $key => $string) 
				{ 
				if($user==trim(array_shift($detect_user))) 
					{
					$time_vote = trim($userlist[$i]);
					$time_vote = explode('|',$time_vote);
					$time_vote = $time_vote[1]; 
			$error = "<br /><span class=\"s1\">В опросе включена защита, нельзя головать более одного раза!<br /> Ваш браузер и ip  <br /><u>$user</u><br /> соответствует тому с которого голосовали <br />$time_vote</span>\n" ;
					 $result  =  true ;
					  }}}

if (!$error)
{
	$fileuser = fopen("userlist.txt","a");
    fputs($fileuser,"$user|$timer"."\r\n");
    fclose($fileuser);
    $num_str = $op;
    $bufstr = file("vote.txt");
    $wrstr1 = trim($bufstr[$num_str]);
    $set = explode('|',$wrstr1);
    $answer = $set[0];
    $set_result = $set[1];
    $wrstr2 = $set_result+1;
    $buf = @file_get_contents("vote.txt");
    $buf =str_replace("$wrstr1\r\n","$answer|$wrstr2\r\n",$buf);
	$filevote = fopen("vote.txt","w");
    fputs($filevote,"$buf");
    fclose($filevote);

}
else
{
	echo "<p class=\"p2\">$error</p>";
}
}
echo "<p class=\"p1\">Результат опроса по теме:<br />$name_answer</p>";

echo "<p class=\"p3\">
	<li>$a1: $result1</li>
    <li>$a2: $result2</li>
    <li>$a3: $result3</li>
    <li>$a4: $result4</li>
    <li>$a5: $result5</li>
</p>";
echo "<p class=\"p1\"><a href=\"/\">главная</a></p>";

include 'foot.php';
?>