<?
include_once("req.php");

array_walk($_REQUEST,"format_string");   
array_walk($_POST,"format_string");   
array_walk($_GET,"format_string");   

include_once("config.php");
include_once("session_class.php");
include_once("persinfo_class.php");
error_reporting(E_ALL ^ E_NOTICE);
session_start();
$session = new Sessions;

if ($session->is_session(session_id())) {

$myinfo =new Persinfo($session->id_person);
$myinfo->get_chat_params();
		$res=db_use('array',"select roomtype from room where id_room='".$myinfo->id_room."'");
		$roomtype=$res['roomtype'];
		#header("Location: dvoretz.php");
		#die;
	if ($roomtype!=17) {
		header("Location: main.php"); 
		die;
	}else{
	
if ($_REQUEST['pojer']){
$_REQUEST['money']=(0+$_REQUEST['money']);
	if ($_REQUEST['money']>$myinfo->money) {$mess="У вас нет столько денег";}
	elseif ($_REQUEST['money']>=0.01) {
		db_use('query',"insert into pojer (id_person,id_room,money,`timestamp`,coment) values ('".$myinfo->id_person."','24','".($_REQUEST['money']+0)."','".time()."','".addslashes($_REQUEST['coment'])."')");
		db_use('query',"update person set money=money-'".($_REQUEST['money']+0)."' where id_person='".$myinfo->id_person."'");$mess='Вы пожертвовали '.(0+$_REQUEST['money']).' кр.';
	}
}
$res=db_use('array',"select id_person from atop18 where id_person='".$myinfo->id_person."';");
$imtop=($res['id_person']?true:false);

	echo "
<HTML><HEAD>
<link rel=stylesheet type=\"text/css\" href=\"../i/main.css\">
<meta content=\"text/html; charset=windows-1251\" http-equiv=Content-type>
<META Http-Equiv=Cache-Control Content=no-cache>
<meta http-equiv=PRAGMA content=NO-CACHE>
<META Http-Equiv=Expires Content=0>
<SCRIPT>
function closehint3(){document.all(\"hint3\").style.visibility=\"hidden\";}
</SCRIPT>
<SCRIPT src='../i/commoninf.js'></SCRIPT>
</HEAD>
<body leftmargin=5 topmargin=5 marginwidth=5 marginheight=5 bgcolor=e2e0e0>

<TABLE width=100% cellspacing=0 cellpadding=0>
<FORM action=\"city.php\" method=POST>
<tr><td width=100%><h3>Дворец Мироздателя</td><td>
<link href=\"../i/move/design4.css\" rel=\"stylesheet\" type=\"text/css\">
<script language=\"javascript\" type=\"text/javascript\">
function fastshow2 (content) {
	var el = document.getElementById(\"mmoves\");
	var o = window.event.srcElement;
	if (content!='' && el.style.visibility != \"visible\") {el.innerHTML = '<small>'+content+'</small>';}
	var x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft - el.offsetWidth + 5;
	var y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop+20;
	el.style.left = x + \"px\";
	el.style.top  = y + \"px\";
	if (el.style.visibility != \"visible\") {
		el.style.visibility = \"visible\";
	}
}
function hideshow () {
	document.getElementById(\"mmoves\").style.visibility = 'hidden';
}
</script>
<font color=red>".$mess24324234."</font>
<table  border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
	<tr align=\"right\" valign=\"top\">
		<td>

			</td>
		<td>
			
			<table width=\"80\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
            	<tr>
            		<td width=\"0\" valign=\"bottom\" align=\"left\"><a href=\"?rnd=0.122974956635421\"><img src=\"../i/move/rel_1.gif\" width=\"15\" height=\"16\" alt=\"Обновить\" border=\"0\" /></a></td>
					<td><table width=\"80\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
                    	<tr>
                    		<td colspan=\"3\" align=\"center\"><img src=\"../i/move/navigatin_462.gif\" width=\"80\" height=\"4\" /></td>
                    		</tr>
                    	<tr>
                    		<td colspan=\"3\" align=\"center\"><table width=\"80\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
                    				<tr>
                    					<td><img src=\"../i/move/navigatin_481.gif\" width=\"9\" height=\"8\" /></td>
                    					<td width=\"100%\" bgcolor=\"#000000\"><table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
                    							<tr>
                    								<td nowrap=\"nowrap\" align=\"center\"><div align=\"center\" style=\"font-size:4px;padding:0px;border:solid black 0px; text-align:center\" id=\"prcont\"></div>
                        									<script language=\"javascript\" type=\"text/javascript\">
												var s=\"\";for (i=1; i<=32; i++) {s+='<span id=\"progress'+i+'\">&nbsp;</span>';if (i<32) {s+='&nbsp;'};}document.getElementById('prcont').innerHTML=s;
								  				</script>
                    									</td>
                    								</tr>
                    							</table></td>
                    					<td><img src=\"../i/move/navigatin_50.gif\" width=\"7\" height=\"8\" /></td>
                    					</tr>
                    				</table></td>
                    		</tr>
	
	<tr>
		<td colspan=\"3\"><img src=\"../i/move/navigatin_tt1_532.gif\" width=\"80\" height=\"5\" /></td>
	</tr>
	
                   	</table></td>
           		</tr>
          	</table>
			
			<table  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
				<tr>
					<td nowrap=\"nowrap\" id=\"moveto\">
						<table width=\"100%\"  border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#DEDEDE\">
							
							<tr>
								<td bgcolor=\"#D3D3D3\"><img src=\"../i/move/links.gif\" width=\"9\" height=\"7\" /></td>";#print_r($_REQUEST);
$in_r[8]=getinroom($room,$myinfo->id_city); $r_name[8]="Центральная площадь";
$num=8;echo"<td bgcolor=\"#D3D3D3\" nowrap><a href=\"main.php?rnd=0.122974956635421&pathbkbk=1.100&path=8\" onclick=\"return check_access();\" class=\"menutop\" title=\"Время перехода: 15 сек.
Сейчас в комнате ".$in_r[$num]." чел.\">".$r_name[$num]."</a></td></tr>
							
						</table>
					</td>
				</tr>
			</table>
			
			<!-- <br /><span class=\"menutop\"><nobr>Дворец Мироздателя</nobr></span>-->
			</td>
	</tr>
</table>
<div id=\"mmoves\" style=\"background-color:#FFFFCC; visibility:hidden; overflow:visible; position:absolute; border-color:#666666; border-style:solid; border-width: 1px; padding: 2px; white-space: nowrap;\"></div>
<script language=\"javascript\" type=\"text/javascript\">
var progressEnd = 32;		// set to number of progress <span>'s.
var progressColor = '#00CC00';	// set to progress bar color
var mtime = parseInt('-15');
if (!mtime || mtime<=0) {mtime=0;}
var progressInterval = Math.round(mtime*1000/progressEnd);	// set to time between updates (milli-seconds)
var is_accessible = true;
var progressAt = progressEnd;
var progressTimer;
function progress_clear() {
	for (var i = 1; i <= progressEnd; i++) document.getElementById('progress'+i).style.backgroundColor = 'transparent';
	progressAt = 0;
	
	is_accessible = false;
	set_moveto(true);
}
function progress_update() {
	progressAt++;
	//if (progressAt > progressEnd) progress_clear();
	if (progressAt > progressEnd) {
		
		is_accessible = true;
		if (window.solo_store && solo_store) { solo(solo_store); } // go to stored
		set_moveto(false);
	} else {document.getElementById('progress'+progressAt).style.backgroundColor = progressColor;
		progressTimer = setTimeout('progress_update()',progressInterval);
	}
}
function set_moveto (val) {
	document.getElementById('moveto').disabled = val;
	if (document.getElementById('bmoveto')) {
		document.getElementById('bmoveto').disabled = val;
	}
}
function progress_stop() {
	clearTimeout(progressTimer);
	progress_clear();
}
function check(it) {
	return is_accessible;
}
function check_access () {
	return is_accessible;
}
function ch_counter_color (color) {
	progressColor = color;
	for (var i = 1; i <= progressAt; i++) {
		document.getElementById('progress'+i).style.backgroundColor = progressColor;
	}
}
// brrr
if (mtime>0) {
	progress_clear();
	progress_update();
} else {
	for (var i = 1; i <= progressEnd; i++) {
		document.getElementById('progress'+i).style.backgroundColor = progressColor;
	}
}
</script>

</td></tr>
</FORM>
</table>






<TABLE width=100% cellspacing=0 cellpadding=4>
<TR>
    <FORM METHOD=POST ACTION=\"dvoretz.php\">
	<INPUT TYPE=hidden name=sid value=\"\">
	<INPUT TYPE=hidden name=id value=\"1\">
	<INPUT TYPE=hidden name=sd4 value=\"1152918974\">
	<TD valign=top align=left>
<!--Магазин-->
<TABLE width=100% cellspacing=0 cellpadding=0 bgcolor=A5A5A5>
<TR>
	<TD align=center><B></B>


	</TD>
</TR>
<TR><TD>
<table><tr><td><div style=\"background-color:#d2d0d0;padding:1\"><center><B>Трон Мироздателя</B></center><br />
	
	<center><img src=../i/images/";
$res=db_use('array',"select id_person from person where id_room=24 and id_person=12");
if ($res['id_person']==12) {echo "tron21";}else{echo "tron";}
echo".gif></center><br>
<br>
В этой комнате вы защищены от нападений других персонажей.<br>
<br />
    <FORM METHOD=POST ACTION=\"dvoretz.php\">
	Отблагодарить за создание игры: <INPUT TYPE=TEXT name=money> кр <br />
Ваше пожелание: <INPUT TYPE=TEXT name=coment maxlength=200> <input type=submit name=pojer value='Пожертвовать креды'>
	</FORM></td></tr></table>


</div>

</TD><td>";

if ($_REQUEST['bog']) {
echo"<div valign=top style=\"background-color:#d2d0d0;padding:1;\"><center><B>Богачи АНТИБК</B></center><br />";
echo"<table>";
$res=db_use('query',"select u.login,p.level,p.align,c.clanname,p.id_person,p.money,p1.sum,p2.sum,p1.sum+p2.sum+ p.money as sumall from person p 
left join users u on u.id_person=p.id_person
left join clans c on c.id_clan=p.id_clan
left join person_inv_price p1 on p1.id_person=p.id_person
left join person_puton_price p2 on p2.id_person=p.id_person order by sumall desc
 limit 20;");
unset($i);while($i<mysql_num_rows($res)){
	$i++;$s=mysql_fetch_array($res);
	echo "<tr><td><nobr><small><SCRIPT>drwfl(\"".$s['login']."\",".$s['id_person'].",\"".$s['level']."\",'".$s['align']."',\"".$s['clanname']."\")</SCRIPT></font></nobr></td><td><nobr> <small>".(((int)(($s['sumall']+0)*100))/100)." кр.</nobr></small></td></tr>";
}
echo"</table><br />
<a href='dvoretz.php'>Самые большие пожертвования</a></div>";


}else{
echo"<div valign=top style=\"background-color:#d2d0d0;padding:1;\"><center><B>Самые большие пожертвования</B></center><br />";
echo"<table>";
$res=db_use('query',"select * from atop17 limit 20;");
unset($i);while($i<mysql_num_rows($res)){
	$i++;$s=mysql_fetch_array($res);
	echo "<tr><td><nobr><small><SCRIPT>drwfl(\"".$s['login']."\",".$s['id_person'].",\"".$s['level']."\",'".$s['align']."',\"".$s['clanname']."\")</SCRIPT></font></nobr></td><td><nobr> <small>".(((int)(($s['summ']+0)*100))/100)." кр.</nobr></small></td></tr>";
}
echo"</table><br />
<a href='dvoretz.php?bog=1'>Богачи АНТИБК</a></div>";
}
echo"</td></TR>
</TABLE>

	</TD>
";echo
"
    </FORM>
</TR>
</TABLE>
";

echo"

	<CENTER><B>Масса всех ваших вещей: ".$myinv->weight."/".(($myinfo->sumall('sil'))*4)."<BR>
	У вас в наличии: <FONT COLOR=339900>".str_pad(((int)($myinfo->money*100)/100),'.00',STR_PAD_RIGHT)."</FONT> кр.</B></CENTER>
	<div style=\"MARGIN-LEFT:15px; MARGIN-TOP: 10px;\">
	
	
<div style=\"background-color:#d2d0d0;padding:1\"><center><B>Пожертвования</B></center></div>

";

echo"

	</div>
<div id=hint3 class=ahint></div>
";
echo"<br />
Последние 20 пожеланий: <br />
";
$res=db_use('query',"select pj.*,u.login,p.align,p.id_clan,p.level,c.clanname from pojer pj left join person p on p.id_person=pj.id_person left join users u on u.id_person=p.id_person left join clans c on c.id_clan=p.id_clan where pj.id_room=24 order by pj.timestamp desc limit 50;");
unset($i);while($i<mysql_num_rows($res)){
	$i++;$s=mysql_fetch_array($res);
	echo "<nobr><FONT CLASS=sysdate>".date("d.m H:i",$s['timestamp'])."</font>  <SCRIPT>drwfl(\"".$s['login']."\",".$s['id_person'].",\"".$s['level']."\",'".$s['align']."',\"".$s['clanname']."\")</SCRIPT></font> ".$s['money']." кр.</nobr>".($s['coment']?"<small style=\"background-color=#F3F0D9;\"> ".htmlspecialchars($s['coment'])."</small>":'')."<br />";
}
echo"


</BODY>
</HTML>	";	
		die;
	}
}else {

header("Location: totop.htm"); die;
}
?>