<?php
session_start();
//if($_SESSION[city]!="")
//{
include ('dbf.php');
if (isset($_POST['ok']))
{
	include_once ('jdf.php');
	$t=jdate('Y/m/d');
	if ($_POST['topic']=="" or $_POST['matn']=="")
	echo"<script>window.alert('اطلاعات به صورت کامل درج نگردیده و امکان ذخیره وجود ندارد');</script>";
	else
	{
	mysql_query("insert into `matnozv` (ozv_ip,ozv_name,date,topic,matn,city)
	VALUES ('{$_SESSION['id']}','{$_SESSION['user']}','{$t}','{$_POST['topic']}','{$_POST['matn']}','{$_SESSION['city']}')");

	echo"<script>window.alert('مطالب ذخیره شد ، پس از تایید نمایش داده خواهد شد');</script>";
	}
}
?>
<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>
 <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="80%" border="0" dir="rtl">
			<?php
			if (isset($_GET['ipmatn']))
			{
			$fg33=mysql_query("select * from matnozv where (ip='{$_GET['ipmatn']}' and ok_manager='1') order by ip ");
			$v33=mysql_fetch_assoc($fg33);
			?>
			<form name="ee" action="book4.php?phf=6" method="post">
			<tr>
				<td colspan="12" align="center">
					<span  style="color:black;font-size:18px;font-family:B Nazanin">
					<b>
					موضوع:
					<span  style="color:red;font-size:18px;font-family:B Nazanin">
					<?php echo $v33['topic']; ?>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<span  style="color:black;font-size:18px;font-family:B Nazanin">
					نام نویسنده مطلب:
					<span  style="color:red;font-size:18px;font-family:B Nazanin">
					<?php echo $v33['ozv_name']; ?>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<span  style="color:black;font-size:18px;font-family:B Nazanin">
					تاریخ ارائه مطلب:
					<span  style="color:red;font-size:18px;font-family:B Nazanin">
					<?php echo $v33['date']; ?>
					<br/>
					<textarea readonly name="matn" cols="114" rows="8"  style="font-family:B Nazanin;font-size:15pt"><?php echo $v33['matn']; ?></textarea>
					<br/>
					<button tabindex="1" title="بازگشت" name="cancel" type="submit"><img src="images/r1.png"  name="eslah"  border="0" width="30" height="30" ></button>
				</td>

			</tr>
			</form>
			<?
			}
			elseif (isset($_POST['new']))
			{
			?>
			<form name="ee" action="book4.php?phf=6" method="post">
			<tr>
				<td colspan="12" align="center">
					<span  style="font-size:19px;font-weight:700;font-family:tahoma">
					كاربر گرامي :
					&nbsp;
					آقای/خانم :&nbsp;
					<b style="color:red">
					<?php  echo $_SESSION[user]; ?>
					</b>
					&nbsp;
					&nbsp;
					به شماره عضویت: &nbsp;
					<b style="color:red">
					<?php  echo $_SESSION[id]; ?>
					</b>
					<br/>
					بابت درج مطالب آموزنده از شما سپاس گزاریم.
			</span>
				</td>
			</tr>
			<tr>
				<td colspan="12" align="right">
					<span  style="font-size:15px;font-family:tahoma">
					موضوع:
					<input name="topic" tabindex="1" type="text" size="45">
				</td>
			</tr>
			<tr>
				<td colspan="12" align="right">
					<span  style="font-size:15px;font-family:tahoma">
					متن:
					<br/>
					<textarea tabindex="1" name="matn" cols="114" rows="8"  style="font-size:13pt"></textarea>
				</td>
			</tr>
			<tr>
				<td colspan="12" align="center">
					<button tabindex="1" title="ارسال جهت تاٌیید" name="ok" type="submit"><img src="images/sabtf2.png"  name="eslah"  border="0" width="30" height="30" ></button>
					<button tabindex="1" title="بازگشت" name="cancel" type="submit"><img src="images/r1.png"  name="eslah"  border="0" width="30" height="30" ></button>
				</td>
			</tr>
			</form>
			<?php
			}
			else
			{
			?>
			<form name="ee" action="book4.php?phf=6" method="post">
			<tr>
				<td colspan="12" align="center">
					<button tabindex="1" title="درج مطلب" name="new" type="submit"><img src="images/sabt2.png"  name="eslah"  border="0" width="30" height="30" ></button>
				</td>
			</tr>
			</form>
			<?php
			}
			?>
			<form name="ee" action="book4.php?phf=6" method="post">
			<input name="kind" type="hidden" value="<?php echo $kin; ?>">
			<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="date" style="font-size: 9pt;font-family:tahoma">تاریخ</option>
					<option value="ozv_name" style="font-size: 9pt;font-family:tahoma">نام عضو</option>
					<option value="topic" style="font-size: 9pt;font-family:tahoma">موضوع</option>
					<option value="matn" 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="2%"><b>رديف</td>
			 	<td width="5%" align="center"><b><a href="book4.php?forder=date&&phf=6" style="color:black;text-decoration:none">تاریخ</td>
			 	<td width="8%" align="center"><b><a href="book4.php?forder=ozv_name&&phf=6" style="color:black;text-decoration:none">نام عضو</td>
			 	<td width="17%" align="center"><b><a href="book4.php?forder=topic&&phf=6" style="color:black;text-decoration:none">موضوع</td>
			 	<td width="40%" align="center"><b><a href="book4.php?forder=matn&&phf=6" style="color:black;text-decoration:none">متن</td>
 			</tr>
 			<?php
 				$color=array($_SESSION['bgcolor'],$_SESSION['bgcolor1']); $a=0;
 				$forder=$_GET['forder'];
				$start=$_GET['start'];
				$page_name="book4.php";
                if(strlen($start) > 0 and !is_numeric($start)){
                 echo "Data Error";
                 exit;
                 }
               	 $eu = ($start - 0);
                 $limit = 50;
                 $this1 = $eu + $limit;
   	             $back = $eu - $limit;
       	         $next = $eu + $limit;

				$fg=mysql_query("select * from `matnozv` where (ok_manager='1')  order by date");
				$nume=mysql_num_rows($fg);

				if (isset($_POST['sear']))
				{
					$qq=$_POST['sear'];

					if ($_POST['seerch']=='date')
					{
					$q='date';
					$fg=mysql_query("select * from matnozv where ($q='{$qq}' and ok_manager='1') order by $q DESC");
					}
					if ($_POST['seerch']=='ozv_name' or  $_POST['seerch']=='topic' or  $_POST['seerch']=='matn')
					{
					if ($_POST['seerch']=='ozv_name')
					$q='ozv_name';
					if ($_POST['seerch']=='topic')
					$q='topic';
					if ($_POST['seerch']=='matn')
					$q='matn';

					$fg=mysql_query("select * from matnozv where ($q like'%$qq%' and ok_manager='1') order by $q ");
					}
				}
				else
				$fg=mysql_query("select * from matnozv where (ok_manager='1') order by date DESC");

				$i=1;
				while($v=mysql_fetch_assoc($fg))
				{
				?>
			<tr align="center"  style="font-family:B Nazanin;font-size:15pt" onmouseover="this.style.backgroundColor='<?php echo $_SESSION[backheader];?>';" onmouseout="this.style.backgroundColor='<?php echo $color[$a]; ?>';"  bgcolor=<?php echo $color[$a]; ?>>
				<?php
				$txt11=substr($v['matn'],0,190);

				echo "<td>$i</td>
				<td><span class:blacktext>".$v['date']."</td>
				<td style='font-family:B Nazanin;font-size:13pt'><span class:blacktext>".$v['ozv_name']."</td>
				<td style='font-family:B Nazanin;font-size:19pt'><span class:blacktext><b>".$v['topic']."</b></td>
				<td><span class:blacktext>".$txt11;
				?>
				<a style="color:blue" href="book4.php?ipmatn=<?php echo $v['ip']; ?>&&phf=6">ادامه مطلب...</a>
				<?php
				echo "</td>
				</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>
  <tr>
   <td id="header" ><?php  include ('foteer.php');?></td>
 </tr>
</table>
<?php
//}
//else
//include('index.php');
?>
