<?php

/* FIRESHOP: Advanced Content Market System                         */
/* ============================================                         */
/*                                                                      */
/* Copyright (c) 2012 by Mohamad Porhaji                                */
/* http://Firedesign.ir                                                   */
/*                                                                      */
/* This program is free software.  */
/************************************************************************/
/* $Id: content.php,v 1.0.0.1 2012/02/18 By Mohamad Porhaji $ */

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




function themecontent() {
  global $db,$title_page_over,$pro_limit;


if (defined('HOME_FILE'))
{

echo"

<div class=\"main_warp\">
<table>
<tr align=\"center\">
<td width=\"270\" valign=\"top\">
<div class=\"mini_slider\">
<div class=\"mini_slider_top\">&nbsp;&nbsp;&nbsp;اخبار فروشگاه</div>
<div class=\"mini_slider_bg\">
<div class=\"content_mini\">

<!-- Loop content -->";
$sql = $db->sql_query("SELECT * FROM fireshop_news ORDER BY `time_stamp` DESC Limit 10");
while ($row = $db->sql_fetchrow($sql)) {
$title = $row['title'];
$title = substr($title, 0,70);
$id= $row['id'];
echo"
<div align=\"right\" class=\"news\"><a href=\"news.php?id=$id\"><img src=\"template/fireshop_default/images/arrow000.gif\"/>&nbsp; 

$title</a></div>";}

echo"<!--  End Loop content -->


</div></div>
<div class=\"mini_slider_bt\"></div>
</div>
<br/>
<div class=\"mini_slider\">
<div class=\"mini_slider_top\">&nbsp;&nbsp;&nbsp;دسته بندي فروشگاه</div>
<div class=\"mini_slider_bg\">
<div class=\"content_mini\">";

$sql = $db->sql_query("SELECT * FROM fireshop_category where `is_active`> 0 ORDER BY `id` ASC");
while ($row = $db->sql_fetchrow($sql)) {
$title = $row['title'];
$id= $row['id'];
echo"
<div align=\"right\" class=\"news\"><a href='category.php?id=$id'><img src=\"template/fireshop_default/images/news-bul.jpg\"/> $title</a></div>
";
}



echo"</div></div>
<div class=\"mini_slider_bt\"></div>
</div>
<br/>
<div class=\"mini_slider\">
<div class=\"mini_slider_top\">&nbsp;&nbsp;&nbsp;محصول تصادفي</div>
<div class=\"mini_slider_bg\">
<div class=\"content_mini\">";

$numrows =  $db->sql_numrows($db->sql_query("SELECT * FROM fireshop_product WHERE `is_active` >0 "));
mt_srand((double)microtime()*1000000);
$id_product = mt_rand(1,$numrows);

$sql = $db->sql_query("SELECT * FROM fireshop_product where `id`='$id_product'");
if($db->sql_numrows($sql)<1){$sql = $db->sql_query("SELECT * FROM fireshop_product where `id`='1'");}else{$sql = $db->sql_query("SELECT * FROM fireshop_product where `id`='$id_product'");}


$row = $db->sql_fetchrow($sql);
$product_title = $row['product_title'];
$product_title = substr($product_title, 0,70);
$product_pic = $row['product_pic'];
$id= $row['id'];
$product_price = $row['product_price'];
$product_price = number_format($product_price, 0);
echo"

<div align=\"center\">
<img src=\"$product_pic\" height=\"145\" width=\"190\"/>
<br/><br/>
<div class=\"cust_pro\">$product_price&nbsp; تومان</div>
<div align=\"center\" style=\"width: 180px; margin-top: 5px;\">
<form action='buy.php' method='post'>
<input type='hidden' name='id' value='$id'/>
<input type='hidden' name='buy'/>
<div class=\"buy_pro\"><a><input type=\"image\" src=\"template/fireshop_default/images/buy_p.png\"  onmouseover=this.src='template/fireshop_default/images/buy_p_hover.png' onmouseout=this.src='template/fireshop_default/images/buy_p.png' ></a></div></form>
<div class=\"more_pro\"><a href=\"product.php?id=$id\"></a></div>
</div>
<div class=\"clear\"></div>
</div>";




echo"</div></div>
<div class=\"mini_slider_bt\"></div>
</div>
<br/>
<div class=\"mini_slider\">
<div class=\"mini_slider_top\">&nbsp;&nbsp;&nbsp;آمار فروشگاه</div>
<div class=\"mini_slider_bg\">
<div class=\"content_mini\">

<div align=\"right\">";
$sql = $db->sql_query("SELECT * FROM fireshop_counter where id=1;");
$row = $db->sql_fetchrow($sql);
$todaycounts  = number_format($row['todaycounts'], 0);
$yescounts  = number_format($row['yescounts'], 0);
$total   = number_format($row['total'], 0);
$month  = number_format($row['month'], 0);
$year  = number_format($row['year'], 0);
$num_product = $db->sql_numrows($db->sql_query("SELECT * FROM fireshop_product "));
$online = $db->sql_numrows($db->sql_query("SELECT * FROM fireshop_onlines "));

echo"
<img src=\"template/fireshop_default/images/news-bul.jpg\"/> بازديد امروز : $todaycounts<br/>
<img src=\"template/fireshop_default/images/news-bul.jpg\"/> بازديد ديروز : $yescounts <br/>
<img src=\"template/fireshop_default/images/news-bul.jpg\"/> بازديد كل : $total<br/>
<img src=\"template/fireshop_default/images/news-bul.jpg\"/> بازديد اين ماه : $month<br/>
<img src=\"template/fireshop_default/images/news-bul.jpg\"/> تعداد كل محصولات : $num_product<br/>
<img src=\"template/fireshop_default/images/news-bul.jpg\"/> افراد آنلاين : $online<br/>
</div>

</div></div>
<div class=\"mini_slider_bt\"></div>
</div>
<br/>
<div class=\"mini_slider\">
<div class=\"mini_slider_top\">&nbsp;&nbsp;&nbsp;رهگيري سفارش</div>
<div class=\"mini_slider_bg\">
<div class=\"content_mini\">
<form method='POST' action='rahgiri.php' target='_blank'>
	<div style='margin-bottom:5px;'>برای رهگیری کلیک کنید :</div>
	<div style='margin:10px auto'><input type='submit' value='رهگیری سفارش' name='B4' style='-moz-border-radius:5px;background:#fff;border:1px solid #DFDBD0;font: normal 1.0em/1.6 tahoma;height:30px;color:#cc0000'></div>
</form>

</div></div>
<div class=\"mini_slider_bt\"></div>
</div>



</td>
<td width=\"690\" valign=\"top\">";




$sql = $db->sql_query("SELECT * FROM fireshop_product ORDER BY `product_time_stamp` DESC Limit $pro_limit");
while ($row = $db->sql_fetchrow($sql)) {
$product_title = $row['product_title'];
$product_title = substr($product_title, 0,70);
$product_pic = $row['product_pic'];
$id= $row['id'];
$product_price = $row['product_price'];
$product_price = number_format($product_price, 0);
echo"
<div class=\"product_self\">
<table>
<tr>
<td width=\"223\" valign=\"top\">
<div class=\"product\">
<div class=\"product_top\">&nbsp;&nbsp;$product_title</div>
<div class=\"product_bg\">
<div class=\"product_content\">
<div align=\"center\">
<img src=\"$product_pic\" height=\"145\" width=\"190\"/>
<br/><br/>
<div class=\"cust_pro\">$product_price&nbsp; تومان</div>
<div align=\"center\" style=\"width: 180px; margin-top: 5px;\">
<form action='buy.php' method='post'>
<input type='hidden' name='id' value='$id'/>
<input type='hidden' name='buy'/>
<div class=\"buy_pro\"><a><input type=\"image\" src=\"template/fireshop_default/images/buy_p.png\"  onmouseover=this.src='template/fireshop_default/images/buy_p_hover.png' onmouseout=this.src='template/fireshop_default/images/buy_p.png' ></a></div></form>
<div class=\"more_pro\"><a href=\"product.php?id=$id\"></a></div>
</div>
<div class=\"clear\"></div>
</div>
</div></div>
<div class=\"product_bt\"></div>
</div>
</td>
</tr>
</table>
</div>
";
}


pagination();

echo"</td>
</tr>
</table>


</div>\n";







}else{
echo"
<div class=\"main_warp\">
<table>
<tr align=\"center\">
<td width=\"270\" valign=\"top\">
<div class=\"mini_slider\">
<div class=\"mini_slider_top\">&nbsp;&nbsp;&nbsp;اخبار فروشگاه</div>
<div class=\"mini_slider_bg\">
<div class=\"content_mini\">

<!-- Loop content -->";
$sql = $db->sql_query("SELECT * FROM fireshop_news ORDER BY `time_stamp` DESC Limit 10");
while ($row = $db->sql_fetchrow($sql)) {
$title = $row['title'];
$title = substr($title, 0,70);
$id= $row['id'];
echo"
<div align=\"right\" class=\"news\"><a href=\"news.php?id=$id\"><img src=\"template/fireshop_default/images/arrow000.gif\"/>&nbsp; 

$title</a></div>";}

echo"<!--  End Loop content -->


</div></div>
<div class=\"mini_slider_bt\"></div>
</div>
<br/>
<div class=\"mini_slider\">
<div class=\"mini_slider_top\">&nbsp;&nbsp;&nbsp;دسته بندي فروشگاه</div>
<div class=\"mini_slider_bg\">
<div class=\"content_mini\">";
$sql = $db->sql_query("SELECT * FROM fireshop_category where `is_active`> 0 ORDER BY `id` ASC");
while ($row = $db->sql_fetchrow($sql)) {
$title = $row['title'];
$id= $row['id'];
echo"
<div align=\"right\" class=\"news\"><a href='category.php?id=$id'><img src=\"template/fireshop_default/images/news-bul.jpg\"/> $title</a></div>
";
}
echo"
</div></div>
<div class=\"mini_slider_bt\"></div>
</div>
<br/>
<div class=\"mini_slider\">
<div class=\"mini_slider_top\">&nbsp;&nbsp;&nbsp;محصول تصادفي</div>
<div class=\"mini_slider_bg\">
<div class=\"content_mini\">
";

$numrows =  $db->sql_numrows($db->sql_query("SELECT * FROM fireshop_product WHERE `is_active` >0 "));
mt_srand((double)microtime()*1000000);
$id_product = mt_rand(1,$numrows);

$sql = $db->sql_query("SELECT * FROM fireshop_product where `id`='$id_product'");
if($db->sql_numrows($sql)<1){$sql = $db->sql_query("SELECT * FROM fireshop_product where `id`='1'");}else{$sql = $db->sql_query("SELECT * FROM fireshop_product where `id`='$id_product'");}

$sql = $db->sql_query("SELECT * FROM fireshop_product where `id`='$id_product'");
$row = $db->sql_fetchrow($sql);
$product_title = $row['product_title'];
$product_title = substr($product_title, 0,70);
$product_pic = $row['product_pic'];
$id= $row['id'];
$product_price = $row['product_price'];
$product_price = number_format($product_price, 0);
echo"

<div align=\"center\">
<img src=\"$product_pic\" height=\"145\" width=\"190\"/>
<br/><br/>
<div class=\"cust_pro\">$product_price&nbsp; تومان</div>
<div align=\"center\" style=\"width: 180px; margin-top: 5px;\">
<form action='buy.php' method='post'>
<input type='hidden' name='id' value='$id'/>
<input type='hidden' name='buy'/>
<div class=\"buy_pro\"><a><input type=\"image\" src=\"template/fireshop_default/images/buy_p.png\"  onmouseover=this.src='template/fireshop_default/images/buy_p_hover.png' onmouseout=this.src='template/fireshop_default/images/buy_p.png' ></a></div></form>
<div class=\"more_pro\"><a href=\"product.php?id=$id\"></a></div>
</div>
<div class=\"clear\"></div>
</div>";




echo"

</div></div>
<div class=\"mini_slider_bt\"></div>
</div>
<br/>
<div class=\"mini_slider\">
<div class=\"mini_slider_top\">&nbsp;&nbsp;&nbsp;رهگيري سفارش</div>
<div class=\"mini_slider_bg\">
<div class=\"content_mini\">
<form method='POST' action='rahgiri.php' target='_blank'>
	<div style='margin-bottom:5px;'>برای رهگیری کلیک کنید :</div>
	<div style='margin:10px auto'><input type='submit' value='رهگیری سفارش' name='B4' style='-moz-border-radius:5px;background:#fff;border:1px solid #DFDBD0;font: normal 1.0em/1.6 tahoma;height:30px;color:#cc0000'></div>
</form>

</div></div>
<div class=\"mini_slider_bt\"></div>
</div>



</td>
<td width=\"690\" valign=\"top\">
<div class=\"slider\">
<div class=\"slider_top\">&nbsp;&nbsp;&nbsp; $title_page_over</div>
<div class=\"slider_bg\">
<div class=\"content_slider\">\n";


content();

echo"</div></div>
<div class=\"slider_bt\"></div>

</div>\n";

if (defined('ORDER_FILE'))
{global $db,$subtotal;

echo"<br/>
<div class=\"slider\">
<div class=\"slider_top\">&nbsp;&nbsp;&nbsp; ثبت نهايي سفارش</div>
<div class=\"slider_bg\">
<div class=\"content_slider\">
<br/>
<div align='center' dir='rtl' style='padding:10px'>
<table style='background-color: #333333; font-family: tahoma; font-size: 11px; text-decoration: none; color: #CCCCCC'>
<tr>
<td style='width: 390px; border-left-style: solid; border-left-width: 1px; border-left-color: #CCCCCC;'>
طريقه ارسال</td>
<td style='width: 80px; border-left-style: solid; border-left-width: 1px; border-left-color: #CCCCCC;'>
ماليات</td>
<td style='width: 80px; border-left-style: solid; border-left-width: 1px; border-left-color: #CCCCCC;'>

هزينه پستي</td>
<td style='width: 80px;'>

قابل پرداخت</td>

</tr>
</table>";

$sql = $db->sql_query("SELECT * FROM fireshop_sendway Where is_active=1");
while ($row = $db->sql_fetchrow($sql)) {
$id = $row['id'];
$title = $row['title'];
$maliyat=$row['maliyat'];
$hazine=$row['hazine'];
$maliyat_s= number_format($maliyat, 0);
$hazine_s= number_format($hazine, 0);
$total_price_send=($maliyat+$hazine);
$total_price_send_s= number_format($total_price_send, 0);
echo"
<table style='background-color: #CCCCCC; font-family: tahoma; font-size: 11px; text-decoration: none; color: #333333'>
<tr>
<td style='width: 390px; border-left-style: solid; border-left-width: 1px; border-left-color: #ffffff;border-top-style: solid; border-top-width: 1px; border-top-color: #ffffff;'>

<input type='radio' name='sendway' value='$id'/>      $title</td>
<td style='width: 80px; border-left-style: solid; border-left-width: 1px; border-left-color: #ffffff;border-top-style: solid; border-top-width: 1px; border-top-color: #ffffff;'>

$maliyat_s  تومان</td>
<td style='width: 80px; border-left-style: solid; border-left-width: 1px; border-left-color: #ffffff;border-top-style: solid; border-top-width: 1px; border-top-color: #ffffff;'>
$hazine_s  تومان
</td>
<td style='width: 80px; border-top-style: solid; border-top-width: 1px; border-top-color: #ffffff;'>
$total_price_send_s تومان
</td>





</tr>
</table>
";
}


echo"</div></div></div>
<div class=\"slider_bt\"></div>

</div>
<br/>";

}
if (defined('BUY_FILE'))
{

echo"<br/>

<div class=\"slider\">
<div class=\"slider_top\">&nbsp;&nbsp;&nbsp; راهنماي خريد</div>
<div class=\"slider_bg\">
<div class=\"content_slider\">

<div align='right' dir='rtl' style='padding:10px'>";

$sql = $db->sql_query("SELECT * FROM fireshop_help_order limit 1");
$row = $db->sql_fetchrow($sql); 
$des=$row['des'];
echo"<br/>$des<br/>";
echo"</div></div></div>
<div class=\"slider_bt\"></div>

</div>

";
}


if (defined('PRODUCT_FILE'))
{

in_model();
}

echo"</td>
</tr>
</table>


</div>\n";


}
}
?>