<?php
//page_begin.htm
?>
</td>
<td width=25px style="background:white">
<nobr>
<a href=#   class=menu onclick="tabtop(this)" title="In the window for printing">
<IMG height=14  border=0 src="../d~e~f/tables_103.gif"></a>&nbsp;&nbsp;
<a href=#   class=menu onclick="zaLL()" title="Page Only">
<IMG height=14  border=0 src="../d~e~f/minus.gif"></a>&nbsp;&nbsp;
<a href=# height=9 class=menu onclick="zaLL2()" title="Cancel 'Page Only'">
<IMG height=14  border=0 src="../d~e~f/plus.gif"></a>&nbsp;&nbsp;
<a href=# class=menu onclick="top1()" title="To the beginning, click me or the page title.">
<IMG  height=14 border=0 src="../d~e~f/arrow-up.gif">&nbsp;</a>&nbsp;&nbsp;&nbsp;
</nobr>
</td>
</tr>
</tbody></table>
<!----  ------>
<?php
echo '<DIV  id=k2 onclick=k2f(event)  style="OVERFLOW: auto; color:';
if (file_exists($ifa."pod/ck-c.txt")) {include "plan/pod/ck-c.txt";}
echo ';background:'; 
if (file_exists($ifa."ck-b.txt")) {include "plan/pod/ck-b.txt";} else {echo " silver";}
echo '">';
// ***************************************voit*************************************************************
$aa=str_replace('.php','',$a);                       // 
$aa=str_replace('/gidra/pages/','',$aa);             // 
$rep="";
if (file_exists('../otd/1251')) 
{$utf8=0;} else {$utf8=1;}                           // 
if (isset ($_REQUEST['V']) or isset ($_REQUEST['VR']) )
{$tf='/tv/'.trim($_REQUEST['file']). '.htm';         // 
$ifg = wu(getcwd ( ).'/'.$aa.$tf,$utf8);             // 
  if (file_exists($ifg)) 					         // 
   {$ip=trim($_SERVER["REMOTE_ADDR"]);               // 
$tf1='/tv/'.trim($_REQUEST['file']). '.txt';         // 
$ifg1 = wu(getcwd ( ).'/'.$aa.$tf1,$utf8);
if (file_exists($ifg1))
{}
else
{$rw=file_put_contents($ifg1,'/');                   // 
}
$sip= trim(file_get_contents($ifg1));                // 
if     (strpos(" ".$sip,'/'.$ip.'/')>0)                 // 
{$da=false; 
}
else                                                 // 
{$len=2000;                                          // 
if (strlen($sip)>$len)                               // 
{$sip=substr($sip,0,$len);
}
$rw=file_put_contents($ifg1,'/'.$ip.$sip);            // 
$da=true;
} 
if ($da)
{$l = file($ifg);                                     // 
$k=0;                                                 // 
$s=0;                                                 // 
$sk=1;
$arr=array();
foreach ($l as $li => $lin)                          //  
{if (trim($lin)=='<span>' or trim($lin)=='<SPAN>'  )                           // 
 { $arr[++$li]=trim($l[$li]); 
 ++$k; }
}
foreach ($_REQUEST as $i => $z)                      // 
{if (is_numeric ($i))                                // 
{
$kk=1;                                               // 
$kkt=1;                                              // 
foreach ($arr as $ii => $iin)                        // 
{if ($kk==4) {$kk=1;++$kkt;}
if ($kkt==$z) 
{if ($kk==1) {$arr[$ii]=$arr[$ii]+1;}                // 
}
++$kk;
}}}
// 
$su=0;                                                //
$kk=1; //
foreach ($arr as $ii => $iin)                         // 
{if ($kk==4) {$kk=1;}
if ($kk++==1) {$su=$su+$iin;}                         // 
}
$rep1="";
if ($su==0)
{$rep1= '<b id=rep style="background:blue;color:yellow;display:none">You did not vote! There was no choice.</b>';
}
else
{$kk=1;                                              //
$sp=0;                                               //
foreach ($arr as $ii => $iin)                        //
{if ($kk==4) {$kk=1;}
if ($kk==1)                                          //
{$zn=$iin;
}
if ($kk==2)                                          // %
{$arr[$ii]=round((100/$su)*$zn);
$sp=$sp+$arr[$ii];
if ($sp>100) {$d=$sp-100; if ($arr[$ii]>0) { $arr[$ii]=$arr[$ii]-$d;}}
$kur=$arr[$ii]/2;                                  //
}
if ($kk==3)                                        //
{$arr[$ii]=str_repeat("&nbsp;", $kur);
}
++$kk;
}
$w =fopen($ifg, 'w') or exit;  	                   //
foreach ($l as $li => $lin)                        //
{if (array_key_exists ( $li,$arr))                 //
{fwrite($w,$arr[$li]."\r\n");
}
else
{fwrite($w,$lin);
}}
fclose($w);
}}
if ($rep1=="")
{echo '<b id=rep style="background:blue;color:yellow;display:none">Thanks for voting! Your vote has been counted.</b>';
}
else
{echo $rep1;
}}
else
{echo '<b id=rep style="background:blue;color:yellow;display:none">No voting file! Contact the developer.</b>';
}}
//*****************************************  ************************************************


//$rep=""; // 
$tf=""; // 
$tt=""; // 

if (isset ($_REQUEST['Q']))
{
echo '<b id=rep style="background:blue;color:yellow;display:none">Your question is accepted! The answer will be given soon.</b>';
$rep="1";
//$rep="<center><b style=background:blue;color:yellow></b></center>";
$tf='/tq/tq.txt'; // 
$tt='question';
$tt1='Questions and Answers';
}

if (isset ($_REQUEST['C']))
{
echo '<b id=rep style="background:blue;color:yellow;display:none">Your comment is accepted! It will be inserted on the page after moderation.</b>';
$rep="2";
$tf='/tc/tc.txt'; // 
$tt='Comment';
$tt1='Comments';
}
if (isset ($_REQUEST['G']))
{
echo '<b id=rep style="background:blue;color:yellow;display:none">Your entry has been accepted! It will be published in the guest after moderation.</b>';
$rep="4";
//$rep="
$tf='/tg/tg.txt'; // 
$tt=' Guestbook';
$tt1=' Guestbook2';
}
$pub="-";
// 
if (isset ($_REQUEST['QN']))
{
echo '<b id=rep style="background:blue;color:yellow;display:none">Your question has been posted! The answer will be given soon.</b>';
$rep="5";
//$rep=
$tf='/tq/tq.txt'; //
$tt='question';
$tt1='Questions and Answers';
$pub="+";
}

if (isset ($_REQUEST['CN']))
{
echo '<b id=rep style="background:blue;color:yellow;display:none">Your comment has been published!</b>';
$rep="6";
//$rep='
$tf='/tc/tc.txt'; // 
$tt='Comment';
$tt1='Comments';
$pub="+";
}
if (isset ($_REQUEST['GN']))
{
echo '<b id=rep style="background:blue;color:yellow;display:none">Your entry has been posted!</b>';
$rep="8";
//$rep='
$tf='/tg/tg.txt'; // 
$tt=' Guestbook';
$tt1=' Guestbook2';
$pub="+";
}

if ($rep!="") // 
{

$fg = wu(getcwd ( ).'/'.$aa.$tf,$utf8);   // 
//echo getcwd ( );
if (file_exists($fg))
{
$l = file($fg);  // 
if (isset ($_REQUEST['img']))
{$img=trim($_REQUEST['img']);} else {$img="";}
if ($img=="")
{$img="s1.gif";}

$text=trim(stripslashes ($_REQUEST['text'])); // 
$name=trim(stripslashes ($_REQUEST['name'])); // 
$text=htmlspecialchars($text, ENT_QUOTES,"cp1251");  // 
$name=htmlspecialchars($name, ENT_QUOTES,"cp1251");  // 


$text=str_replace("\r\n","&nbsp;&nbsp;&nbsp;&nbsp;<br>",$text);  // 
$name=str_replace("\r\n","<br>",$name);  //
$name=str_replace('//'," ",$name);
$text=str_replace('//'," ",$text);
if ($text=="" or $name=="")
{
echo '<b id=rep style="background:blue;color:yellow;display:none">Your comment has been published!</b>';
//echo 
}
else
{
if ($tt1=='Questions and Answers') // 
{$str=$_SERVER["REMOTE_ADDR"].'//'.$img.'//'.$name.'//'.date("d-m-Y").'//'.$text.
'//Moderator//Wait for an answer!//'.$pub."\r\n";}
else
{$str=$_SERVER["REMOTE_ADDR"].'//'.$img.'//'.$name.'//'.date("d-m-Y").'//'.$text.'//'.$pub."\r\n";}
$w =fopen($fg, 'w') or exit;   	//
fwrite($w,$str);    			//
foreach ($l as $li => $lin)     //
{
fwrite($w,$lin);
}
fclose($w);
//*******************************************************************************************************************
if ($pub=="+")  // 
//*******************************************************************************************************************
{
if ($tt1=='Questions and Answers')
{
$fhtml=wu(getcwd().'/'.$aa.'/tq/tq.htm',$utf8);  		//
$wh=fopen($fhtml, 'w') or exit; 					// 
$l = file($fg); 		   					 	// 
// 
fwrite($wh,'<h2 style="background:#b0c4de;text-align:center" align=center>Questions and Answers</h2><table border=0 width=100%><tbody>');

$ii=1; // 
// 
foreach ($l as $li => $lin)        	//
{
if (substr($lin,0,1)!="*")  // 
{
list($ip,$ka,$im,$d,$t,$ab,$ot,$p)=explode("//",$lin);
if (trim($p)=="+")  // 
{
$ww='<tr style="background:#e0ffff">
<td width=10px><b>'.$ii++.'</b></td>
<td width=20px><img src="../d~e~f/'.trim($ka).'"></td>'.
'<td width=70px><nobr><b>'.trim($d).'</nobr></b></td>'.
'<td width=80% colspan=2><b>'.trim($im).'</b><b>,&nbsp;QUESTION:</b></td></tr>'.
'<tr><td></td><td colspan=4>'.trim($t).'</td></tr>'.
'<tr ><td></td><td></td><td style="background:#e0ffff" colspan=3><b>'.$ab.'</b><b>,&nbsp;ANSWERS:</b></td></tr>'.
'<tr><td></td><td></td><td colspan=3>'.$ot.'<hr></td></tr>';
fwrite($wh,$ww);
}
}
}
fwrite($wh,"</tbody></table>");
fclose($wh);  // 
}
//******************************
if ($tt1=='Comments')
{
$fhtml=getcwd().'/'.$aa.'/tc/tc.htm';  		// html
$wh=fopen($fhtml, 'w') or exit; 					// html 
$l = file($fg); 		   					 	//
fwrite($wh,'<h2 style="background:#b0c4de;text-align:center" align=center>Comments</h2><table border=0 width=100%><tbody>');
$ii=1; // 
// 
foreach ($l as $li => $lin)        	//
{
if (substr($lin,0,1)!="*")  //
{
list($ip,$ka,$im,$d,$t,$p)=explode('//',$l[$li]);

if (trim($p)=="+")  // 
{
$ww='<tr style="background:#f5f5dc;">
<td width=10px><b>'.trim($ii++).'</b></td>
<td width=10px><img src="../d~e~f/'.$ka.'"></td>
<td width=70px><b>'.$d.'</b></td>
<td width=85%><b>'.$im. '</b></td></tr><tr><td></td><td colspan=3>'.str_replace('  ','&nbsp;&nbsp;',$t)."</td></tr>";
fwrite($wh,$ww);
}}}
fwrite($wh,"</tbody></table>");
fclose($wh);  // 
}
//***************************
if ($tt1==' Guestbook2')
{
$fhtml=wu(getcwd().'/'.$aa.'/tg/tg.htm',$utf8);  		// html 
$wh=fopen($fhtml, 'w') or exit; 					// html 
$l = file($fg); 		   					 	//  txt 
fwrite($wh,'<h2 style="background:#b0c4de;text-align:center" align=center>Guest book</h2><table border=0 width=100%><tbody>');
$ii=1; // 
// 
foreach ($l as $li => $lin)        	//
{
if (substr($lin,0,1)!="*")  // 
{
list($ip,$ka,$im,$d,$t,$p)=explode("//",$l[$li]);
if (trim($p)=="+")  // 
{
$ww='<tr style="background:#e6e6fa;">
<td width=10px><b>'.trim($ii++).'</b></td>
<td width=10px><img src="../d~e~f/'.$ka.'"></td>
<td width=70px><b>'.$d.'</b></td>
<td width=85%><b>'.$im. '</b></td></tr><tr><td></td><td colspan=3>'.str_replace('  ','&nbsp;&nbsp;',$t)."</td></tr>";
fwrite($wh,$ww);
}
}}
fwrite($wh,"</tbody></table>");
fclose($wh);  // 
}
//****************************

}
//echo $rep;
}
}
else
{
echo "<b id=rep1 style=background:red;color:yellow>Mistake ! Missing file ".$tf." Put on page ". $tt1." and repeat.</b>";
}
}
?>
