<?php

/* FIRESHOP: Advanced Content Market System                         */

/* ============================================                         */

/*                                                                      */

/* Copyright (c) 2012 by Mohamad Porhaji                                */

/* http://Firedesign.ir                                                   */

/*                                                                      */

/* This program is free software.  */

/************************************************************************/

/* $Id: static_page.php,v 1.0.0.1 2012/02/18 By Mohamad Porhaji $ */

if (stristr(htmlentities($_SERVER["PHP_SELF"]), "static_page.php")) {
    Header("Location: index.php");
    die();
}

if(isset($_POST['static_edit'])){$id=$_POST['id'];
$datasql = $db->sql_query("SELECT * FROM fireshop_static WHERE `id`='$id'") or die(mysql_error());
$mydata = $db->sql_fetchrow($datasql);$static_id  	= $mydata['id'];$static_title  	= $mydata['title'];$static_des  	= $mydata['des'];
echo"

<div style='padding:10px'  align='center' >
<form action='admin.php?do=static_page' method='post'>
<table width='100%' dir='rtl' cellpadding='0' cellspacing='0'><tr><td>
عنوان : <input type='text' size='30' name='title_page' value='$static_title' /><br/><br/>
متن : 
<br/><br/>";

wysiwyg_textarea('des_page', "$static_des", 'FireShopAdmin', 50, 15);

echo"<br/></td>
</tr></table><div align='left' style='margin-left:20px;'><input  type='hidden' size='50' name='id'  value='$static_id'/>
<input  type='submit' name='static_e_ok' value='ويرايش صفحه'/>&nbsp;&nbsp;&nbsp;
<button onclick='javascript:history.go(-1)' class='button'>بازگشت</button>
</div></form></div></BODY>";}else{
echo"<table dir=\"rtl\" style=\"width: 670px;border: 1px solid #C0C0C0\"><tr>
<td style=\"width: 48px; border-left-style: solid; border-left-width: 1px; border-left-color: #C0C0C0;\">آيدي</td>
<td style=\"width: 480px; border-left-style: solid; border-left-width: 1px; border-left-color: #C0C0C0;\">عنوان</td>
<td style=\"width: 206px\">اختيارات</td></tr>";
$datasql = $db->sql_query("SELECT * FROM fireshop_static  ORDER BY `time_stamp` DESC ") or die(mysql_error());
while ($mydata = $db->sql_fetchrow($datasql)) {$static_id  	= $mydata['id'];$static_title  	= $mydata['title'];$static_des  	= $mydata['des'];$static_date 	= $mydata['date'];$is_system 	= $mydata['is_system'];echo"<tr>
<td style=\"width: 48px; border-left-style: solid; border-left-width: 1px; border-left-color: #C0C0C0;border-top-style: solid; border-top-width: 1px; border-top-color: #C0C0C0;\">$static_id</td>
<td style=\"width: 405px; border-left-style: solid; border-left-width: 1px; border-left-color: #C0C0C0;border-top-style: solid; border-top-width: 1px; border-top-color: #C0C0C0;\">$static_title | <a href='static.php?id=$static_id'>لينك مستقيم صفحه</a></td>
<td style=\"width: 226px;border-top-style: solid; border-top-width: 1px; border-top-color: #C0C0C0;\">";

if($is_system==0){echo"
<form style='float:right;' action=\"admin.php?do=static_page_del\" method=\"post\">
<input  type='hidden' size='10' name='id'  value='$static_id'/>
<input  type='submit' name='static_del' value='حذف'/></form>";}else{}


echo"<form style='float:right;' action=\"admin.php?do=view_static\" method=\"post\">
<input  type='hidden' size='10' name='id'  value='$static_id'/>
<input  type='submit' name='static_view' value='مشاهده'/></form>
<form style='float:right;' action='admin.php?do=static_page' method='post'>
<input  type='hidden' size='50' name='id'  value='$static_id'/>
<input  type='submit' name='static_edit' value='ويرايش صفحه'/></form>
<div class=\"clear\"></div></td></tr>";}echo"</table>";}
if(isset($_POST['static_e_ok'])){$id=$_POST['id'];$title_page =@$_POST['title_page'];$des_page =@$_POST['des_page'];
$query = mysql_query("UPDATE `fireshop_static` SET `title`='$title_page',`des`='$des_page'  WHERE id='$id' LIMIT 1");
if($query){print('<div class="contact_active">صفحه با موفقيت ويرايش شد</div><br/><br/>');}else{
print('<div class="failed"><div class="MsgBody">خطا</div></div>');}}
?>