<?php
	include("../pages/vars.php");
	include("../pages/db.php");
	include("password.php");
	
	session_start();
	$s_secure = $_SESSION['s_secure'];			
	$admin_access = "no";
	$msg = "gverdi dablokilia";

if($s_secure == $u_secure && isset($_SESSION['s_secure']))
{
	$admin_access = "yes";
	$msg = "";
	if(!$cur_page)
	{
		$cur_page = 1;
	}
	$next_cur_page = $cur_page + 1;
	$back_cur_page = $cur_page - 1;
	if($type==1)
	{
		$query = "SELECT * FROM sms_book ORDER BY sms_date DESC";
	}
	//
	if($type==2)
	{
		$query = "SELECT * FROM sms_book WHERE sms_status = 0 ORDER BY sms_date DESC";
	}
	//
	if($type==3)
	{
		$query = "SELECT * FROM sms_book WHERE sms_status = 1 ORDER BY sms_date DESC";
	}
	//
	if($u_event == "hide" && $user_id)
	{
		mysql_query("UPDATE sms_book SET sms_status = '0' WHERE id = '$user_id'");
		$msg = "arqivirebulia";
	}
	//
	if($u_event == "show" && $user_id)
	{
		mysql_query("UPDATE sms_book SET sms_status = '1' WHERE id = '$user_id'");
		$msg = "gamoCenilia";
	}
	//
	if($u_event == "delete" && $user_id)
	{
		mysql_query("DELETE FROM sms_book WHERE id = '$user_id'");
		$msg = "waSlilia";
	}
}
?>
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Georgiansms.com | Admin</title>
<link rel="shortcut icon" href="../js_css/favicon.ico">
<link href="../js_css/iframe.css" rel="stylesheet">
</head>

<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0" bgcolor="#1AB9F1">
<script language="javascript" src="../js_css/admin.js"></script>
<form name="form1" action="<?=$_SERVER['REQUEST_URI']?>" method="POST">
<table border="0" width="797" id="table1" cellspacing="0" cellpadding="0">
	<tr>
		<td width="120" class="geo" align="right">&nbsp;</td>
		<td width="10">&nbsp;</td>
		<td width="667" class="geo">&nbsp;</td>
	</tr>
	<tr>
		<td width="120" class="geo" align="right">&nbsp;</td>
		<td width="10">&nbsp;</td>
		<td width="667" class="geo"><b>admin zona (mza <font face='Tahoma,Arial,Verdana' size='1'>SMS</font>-ebi)</b>&nbsp;</td>
	<tr>
<?php
	if($admin_access == "yes")
	{
?>
	<tr>
		<td width="120" class="geo" align="right">&nbsp;</td>
		<td width="10">&nbsp;</td>
		<td width="667" class="geo"><a href="admin_book.php?u_secure=<?=$u_secure?>" class="eng">Back to menu</a>&nbsp;<a href="sms_book.php?u_secure=<?=$u_secure?>&type=<?=$type?>&cur_page=<?=$back_cur_page?>" class="eng">Back page</a>&nbsp;<a href="sms_book.php?u_secure=<?=$u_secure?>&type=<?=$type?>&cur_page=<?=$next_cur_page?>" class="eng">Next page</a></td>
	</tr>
	<tr>
		<td width="120" class="geo" align="right">&nbsp;</td>
		<td width="10">&nbsp;</td>
		<td width="667" class="geo">&nbsp;</td>
	</tr>
<?php
		$result = mysql_query($query,$db);
		if($myrow = mysql_fetch_array($result))
		{
			$icount = 0;
			do
			{	
				$icount = $icount + 1;
				$ic = $cur_page * $page_counter;
				$ic = $ic - $page_counter;
				$ice = $ic + $page_counter;
				if($icount > $ic && $icount <= $ice)
				{
					if($myrow['sms_status'] == 1)
					{
						$show_status = '<a href="javascript:hide_sms(\''.$myrow["id"].'\',\''.$u_secure.'\',\'hide\',\''.$type.'\',\''.$cur_page.'\');" class="eng"><font color="green">show</font></a>';
					}
					else
					{
						$show_status = '<a href="javascript:show_sms(\''.$myrow["id"].'\',\''.$u_secure.'\',\'show\',\''.$type.'\',\''.$cur_page.'\');" class="eng"><font color="red">hide</font></a>';
					}
					echo("<tr>");
					echo('<td width="120" class="geo" align="right">&nbsp;</td>');
					echo('<td width="10">&nbsp;</td>');
					echo('<td width="667" class="geo">'.$icount.'. teqsti: '.$myrow['sms_text'].'<br>TariRi: '.$myrow['sms_date'].'<br>avtori: '.$myrow['sms_author'].'<br><font face=\'Tahoma,Arial,Verdana\' size=\'1\'>SMS</font> tipi: '.$myrow['sms_type'].'<br>statusi: '.$show_status.'&nbsp;<br><a href="javascript:delete_sms(\''.$myrow["id"].'\',\''.$u_secure.'\',\'delete\',\''.$type.'\',\''.$cur_page.'\');" class="eng">Delete</a><br>&nbsp;</td>');
					echo("</tr>");
				}
			}
			while($myrow = mysql_fetch_array($result));
		}
?>
	<tr>
		<td width="120" class="geo" align="right">&nbsp;</td>
		<td width="10">&nbsp;</td>
		<td width="667" class="geo">&nbsp;</td>
	</tr>
<?php
	}
?>
	<tr>
		<td height="19" colspan="3" width="297" class="geo" align="center">&nbsp;</td>
	</tr>
	<tr>
		<td height="19" colspan="3" width="297" class="geo" align="center">&nbsp;<?=$msg?></td>
	</tr>
</table>
</form>
</body>

</html>