<?php
session_start();
//if($_SESSION[city]!="")
//{
include ('dbf.php');
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>نرم افزار كتابداري و كتابخواني نوين</title>
</head>
</html>
<table dir="ltr" align="center" border="0" style="padding-top:10px;background-repeat:no-repeat;width:100%"   >
 <tr>
   <td id="header"  valign="top" align="center"><?php  include_once ('header.php');?></td>
 </tr>
   	<div id="menu" align="center">
		  <?php
//		  if($_SESSION[onvan]=='عضو')
//			 include('menuozv.php');
//		  elseif($_SESSION[onvan]=='')
		  	 if($_SESSION[onvan]=='')
		     echo"<script>window.location='index.php'</script>";
		   ?>
	</div>
 <?php
 if (isset($_GET['matn']))
 {
 $fg15=mysql_query("select * from matn where (ip='{$_GET['matn']}' and city='{$_SESSION['city']}') order by id ");
 $v15=mysql_fetch_assoc($fg15);

 $fg16=mysql_query("select * from ketab where (city='{$_SESSION['city']}' and id='{$v15['id']}') order by id ");
 $v16=mysql_fetch_assoc($fg16);
	?>
	<tr>
	<td height="700" width="60%" align="center" valign="top"  style="padding-top:10px;border-style:ridge;border-width:thick;padding-right:5px;padding-left:5px;border-color:#6D3E06">
		<table align="center" width="90%" border="0" dir="rtl">
			<tr dir="rtl" style="font-family:tahoma" bgcolor="<?php echo $_SESSION[backheader]; ?>">
				<a href="textpage3.php?phf=3" title="بازگشت"><img src="images/r1.png" height="20" alt="نرم افزار کتابداری" width="20"></a>
				&nbsp;&nbsp;
				<span style="font-family:tahoma;">مشاهده متن صفحه: &nbsp;&nbsp;
				<span style="font-family:tahoma;color:red"><b><?php  echo $v15['paje']; ?></span></b>
				&nbsp;&nbsp;&nbsp;
				<span style="font-family:tahoma;">کتاب:
				&nbsp;&nbsp;&nbsp;
				<span style="font-family:tahoma;color:red"><b><?php  echo $v16['name']; ?></span></b>
 			</tr>
			<tr>
				<td>
					<textarea cols="170" rows="40"><?php  echo $v15['name']; ?></textarea>
				</td>
			</tr>
 		</table>
 	</td>
 	</tr>
	<?php
 }
 else
 {
 ?>
 <tr>
	<td height="700" width="100%" align="center" valign="top"  style="padding-top:10px;border-style:ridge;border-width:thick;padding-right:5px;padding-left:5px;border-color:#6D3E06">
		<span style="font-family:B Nazanin;font-size:17pt"><b>لیست پی دی اف ها</b></span><br/>
		<table align="center" width="70%" border="0" dir="rtl">
			<tr>
				<form name="ee" action="textpage3.php?phf=3" method="post">
				<td align="center" colspan="12" dir="rtl" width="45%">
				<select tabindex="1" name="seerch" style="font-size:10pt;font-family:tahoma">
					<option value="" style="font-size: 9pt;font-family:tahoma">جستجو براساس</option>
					<option value="id" style="font-size: 9pt;font-family:tahoma">شماره ثبت كتاب</option>
					<option value="bookname" style="font-size: 9pt;font-family:tahoma">نام کتاب</option>
					<option value="paje" style="font-size: 9pt;font-family:tahoma">شماره صفحه</option>
					<option value="name" style="font-size: 9pt;font-family:tahoma">متن</option>
				</select>
					<input tabindex="2" dir="rtl" name="sear" type="text" style="font-family:Tahoma;font-size:10pt" value="فیلد جستجو" onfocus="if(this.value=='فیلد جستجو')   {this.value='';}"   onblur="if(this.value=='')   {this.value='فیلد جستجو';}">
					<input tabindex="3" dir="rtl" name="search" value="جستجو" type="submit" style="font-family:Tahoma;font-size:9pt;width:90px">
				</td>
				</form>
			</tr>
			<tr style="font-family:B Nazanin;font-size:14pt" bgcolor="<?php echo $_SESSION[backheader]; ?>">
			 	<td align="center" width="5%"><b>رديف</td>
			 	<td align="center" width="10%"><b><a href="textpage3.php?forder=id&&phf=3" style="color:black;text-decoration:none">شماره ثبت كتاب</td>
			 	<td align="center" width="40%"><b><a href="textpage3.php?forder=book_name&&phf=3" style="color:black;text-decoration:none">نام کتاب</td>
			 	<td align="center" width="10%"><b><a href="textpage3.php?forder=up_book&&phf=3" style="color:black;text-decoration:none">PDF</td>
 			</tr>
 			<?php

 				$color=array($_SESSION['bgcolor'],$_SESSION['bgcolor1']); $a=0;
 				$forder=$_GET['forder'];
				$start=$_GET['start'];
				$page_name="textpage3.php";
                if(strlen($start) > 0 and !is_numeric($start)){
                 echo "Data Error";
                 exit;
                 }
               	 $eu = ($start - 0);
                 $limit = 10;
                 $this1 = $eu + $limit;
   	             $back = $eu - $limit;
       	         $next = $eu + $limit;

				$fg=mysql_query("select * from `matn` where (city='{$_SESSION['city']}'  and !(up_book=' ') )  order by id");
				$nume=mysql_num_rows($fg);

				if (isset($_POST['sear']))
				{
					$qq=$_POST['sear'];
					if ($_POST['seerch']=='id')
					{
					$q='id';
					$fg=mysql_query("select * from matn where ($q='{$qq}' and city='{$_SESSION['city']}'  and !(up_book=' ') ) order by id");
					}
					if ($_POST['seerch']=='bookname')
					{
						$q='book_name';
						$fg=mysql_query("select * from matn where ($q like'%$qq%' and city='{$_SESSION['city']}'  and !(up_book=' ') ) order by id");

//						$fg17=mysql_query("select * from ketab where (name like'%$qq%' and city='{$_SESSION['city']}'  and !(up_book=' ') ) order by id ");
//						$v17=mysql_fetch_assoc($fg17);
//						$q='id';
//						$qq=$v17['id'];
//						$fg=mysql_query("select * from matn where ($q like'%$qq%' and city='{$_SESSION['city']}'  and !(up_book=' ') ) order by id");
					}
					if ($_POST['seerch']=='paje')
					{
					$q='paje';
					$fg=mysql_query("select * from matn where ($q='{$qq}' and city='{$_SESSION['city']}'  and !(up_book=' ') ) order by id");
					}
					if ($_POST['seerch']=='name')
					{
					$q='name';
					$fg=mysql_query("select * from matn where ($q like'%$qq%' and city='{$_SESSION['city']}'  and !(up_book=' ') ) order by id");
					}
				}
				else
				{
				if($forder)
	 			$fg=mysql_query("select * from matn where (city='{$_SESSION['city']}'  and !(up_book=' ') ) order by $forder ");
	 			else
				$fg=mysql_query("select * from matn where (city='{$_SESSION['city']}'  and !(up_book=' ') ) order by id limit $eu, $limit");
				}
				$i=1;
				while($v=mysql_fetch_assoc($fg))
				{
				$ipp=$v['ip'];
				$fg1=mysql_query("select * from ketab where (city='{$_SESSION['city']}' and id='{$v['id']}') order by id ");
				$v11=mysql_fetch_assoc($fg1);
				?>
			<tr align="center"  style="font-family:B Nazanin;font-size:16pt" onmouseover="this.style.backgroundColor='<?php echo $_SESSION[backheader];?>';" onmouseout="this.style.backgroundColor='<?php echo $color[$a]; ?>';"  bgcolor=<?php echo $color[$a]; ?>>
				<?php
				echo "</td><td>$i</td>
				<td><span class:blacktext>".$v['id']."</td>
				<td><span class:blacktext>".$v11['name']."</td>";
				?>
				<td>
					<a target="_blank" href="books/<?php echo $v['up_book']; ?>" >
					<img src="images/pdf.png" height="20" alt="نرم افزار کتابداری" width="20">
				</td>
				<?php
				echo "</span>";

				if($a==1) $a=0;  else $a=1;
				$i++;
				}

				?>
			</tr>
			<tr  bgcolor="<?php echo $_SESSION[backheader]; ?>" >
				<td colspan="12" >
					<?php
					if(!isset($_POST['sear']) and !$forder)
					include ('paging3.php');
					?>
				</td>
			</tr>
		</table>
	</td>
 </tr>
 <?php
 }
 ?>
 <tr>
   <td id="header" ><?php  include ('foteer.php');?></td>
 </tr>
</table>
<?php
//}
//else
//include('index.php');
?>
