﻿<?php
/* FIRESHOP: Advanced Content Market System                         */
/* ============================================                         */
/*                                                                      */
/* Copyright (c) 2012 by Mohamad Porhaji                                */
/* http://Firedesign.ir                                                   */
/*                                                                      */
/* This program is free software.  */
/************************************************************************/
/* $Id: mainfile.php,v 1.0.0.1 2012/02/18 By Mohamad Porhaji $ */
@session_start();
if (stristr(htmlentities($_SERVER["PHP_SELF"]), "mainfile.php")) {
    Header("Location: index.php");
    die();
}
//Absolute FireShop directory
define('PHOENIX_BASE_DIR', dirname(__FILE__) . '/');
// Get php version
$phpver = phpversion();
//// Set IRAN Time
if ($phpver >= '5.1.0') {
date_default_timezone_set('Asia/Tehran');
}
// Error reporting, to be set in config.php
error_reporting(E_ALL^E_NOTICE);
if($display_errors) {
  @ini_set('display_errors', 1);
} else {
  @ini_set('display_errors', 0);
}
@require_once("config.php");
if(!$dbname) {
    die("<span dir='rtl'><br><br><center><br><br><b>&#1587;&#1610;&#1587;&#1578;&#1605;&#32;&#1601;&#1585;&#1608;&#1588;&#1711;&#1575;&#1607;&#1610;&#32;&#1601;&#1600;&#1600;&#1600;&#1575;&#1610;&#1585;&#1588;&#1575;&#1662;&#32;&#1607;&#1606;&#1608;&#1586;&#32;&#1606;&#1589;&#1576;&#32;&#1606;&#1588;&#1583;&#1607;&#32;&#1575;&#1587;&#1578;<br>(&#1583;&#1575;&#1583;&#1607;&#32;&#1607;&#1575;&#1610;&#32;&#1601;&#1575;&#1610;&#1604;&#32;&#99;&#111;&#110;&#102;&#105;&#103;&#46;&#112;&#104;&#112;&#32;&#1607;&#1606;&#1608;&#1586;&#32;&#1583;&#1585;&#32;&#1581;&#1575;&#1604;&#1578;&#32;&#1662;&#1610;&#1588;&#1601;&#1585;&#1590;&#32;&#1607;&#1587;&#1578;&#1606;&#1583;)<br><br><a href='./install/index.php'>&#1576;&#1585;&#1575;&#1610;&#32;&#1606;&#1589;&#1576;&#32;&#1587;&#1610;&#1587;&#1578;&#1605;&#32;&#1575;&#1610;&#1606;&#1580;&#1575;&#32;&#1603;&#1604;&#1610;&#1603;&#32;&#1603;&#1606;&#1610;&#1583;</a><br/>
</center></b></span>");
}else{
if (file_exists('install/index.php')){
die("<table dir=\"rtl\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#ffffff\" width=\"100%\" bgcolor=\"#f6f6f6\" height=\"35\">
<tr>
<td width=\"100%\" align=\"center\"><font color=000000><font face=\"Tahoma\"><font size=\"2\">نصب فايرشاپ به اتمام رسیده است لازم است که پوشه install را حذف نمائید وجود این پوشه یک ریسک امنیتی محسوب میشود</font></td>
</tr>
</table>");
}
}

@require_once("db/db.php");


function wysiwyg_textarea($name, $value, $config = 'FireShopAdmin', $cols = 50, $rows = 10)
{
include_once("includes/fckeditor/fckeditor.php") ;
$rows = $rows + 2;  // Add extra space for toolbars
$oFCKeditor = new FCKeditor($name) ;
$oFCKheight = $rows * 20;
$oFCKeditor->Height = $oFCKheight;
$oFCKeditor->BasePath = 'includes/fckeditor/' ;
$oFCKeditor->ToolbarSet = $config;
$oFCKeditor->Value = $value;
$oFCKeditor->Create() ;
}





$sql = $db->sql_query("SELECT * FROM fireshop_general where id='1'");
$row = $db->sql_fetchrow($sql);
$ThemeSel=$row['default_theme'];
@require_once("template/template.php");
$sql = $db->sql_query("SELECT * FROM fireshop_general where id='1'");
$row = $db->sql_fetchrow($sql);
$pro_limit=$row['pro_limit'];
function counter_face(){
require_once("includes/jdf.php");
require_once("counter.php");
}

function pagination(){ 
global $db,$pro_limit;
echo "<link href=\"template/pagination.css\" rel=\"stylesheet\" type=\"text/css\" >\n";
if (defined('HOME_FILE')){
counter_face();
$total_pro = $db->sql_numrows($db->sql_query('SELECT * FROM fireshop_product'));
$page_num=ceil($total_pro/$pro_limit);
if($page_num>0){
echo"<br/><table dir=\"rtl\" width=\"690\">
<tr align=\"center\">
<td >
<div class=\"pagination\">
<div class=\"this_page\"><a>1</a></div>";
for($i = 2;$i<=$page_num;$i++){
if($i<=8){
echo"<div class=\"page_nav\"><a href=\"page.php?id=$i\">$i</a></div>";}
}echo"<div class=\"page_t\"><a>تعداد كل صفحات : $page_num</a></div><div class=\"clear\"></div></div></td></tr></table>";}
}else{
$total_pro = $db->sql_numrows($db->sql_query('SELECT * FROM fireshop_product'));
$page_num=ceil($total_pro/$pro_limit);
if($page_num>0){
echo"<br/><table dir=\"rtl\" width=\"690\">
<tr align=\"center\">
<td >
<div class=\"pagination\">
<div class=\"this_page\"><a>$last_id_page</a></div>";
for($i = 2;$i<=$page_num;$i++){
if($i<=8){echo"<div class=\"page_nav\"><a href=\"page.php?id=$i\">$i</a></div>";}
}echo"<div class=\"page_t\"><a>تعداد كل صفحات : $page_num</a></div><div class=\"clear\"></div></div></td></tr></table>";}
}}
$sql = $db->sql_query("SELECT * FROM fireshop_general where id='1'");
$row = $db->sql_fetchrow($sql);
$site_title=$row['site_title'];
$description=$row['description'];
$keywords=$row['keywords'];
if (defined('HOME_FILE')){
global $keywords,$description,$site_title;
$page_title="صفحه اصلي";
theme();}
function formloginadmin(){include("admin/template/login_tpl.php");}
function loginADMIN(){global $db;

if(@$_SESSION['LogedIn_fireshop_ADMIN'] == true){
Header("Location: admin.php");
die();
}else{

formloginadmin();
if(isset($_POST['loginADMIN'])){
if(empty($_POST['pass'])
or empty($_POST['useradmin'])){
echo"پركردن همه ي فيلدها الزامي است";
die();}else{
$useradmin = strtolower($_POST['useradmin']);
$password = $_POST['pass'];
$sql = "SELECT password FROM fireshop_admin WHERE `username` = '$useradmin' Limit 0,1";
$result = $db->sql_query($sql) or die(sql_error());
if($db->sql_numrows($result) == 1){
$mydata = $db->sql_fetchrow($result); 
$password_org = $mydata['password'];
if($password == $password_org){
$_SESSION['LogedIn_fireshop_ADMIN'] = true;
echo"<style type='text/css'>
a {color: #FFFFFF;}
a:link {color: #FFFFFF;}
a:visited {color: #FFFFFF;}</style>


<div style='color:#ffffff;' align='center'><br/><a href='admin.php'>ورود موفقيت آميز بود براي ورود به پنل كليك 
كنيد</a></div>";
Header("Location: admin.php");
die();
exit();}else{
print("<div style='color:#ffffff;' align='center'>نام كاربري و يا رمز عبور اشتباه مي باشد</div>");} }else{
print("<div style='color:#ffffff;' align='center'>نام كاربري و يا رمز عبور اشتباه مي باشد</div>");} }
} }}

if (defined('ADMIN_FILE'))
{
$sql = $db->sql_query("SELECT * FROM fireshop_general where id='1'");
$row = $db->sql_fetchrow($sql);
$site_title=$row['site_title'];
$description=$row['description'];
$keywords=$row['keywords'];
$page_title="پنل مديريت فروشگاه";



if(isset($_SESSION['LogedIn_fireshop_ADMIN'])){
if(@$_SESSION['LogedIn_fireshop_ADMIN'] == true){
require_once("admin/template/template.php");
global $db;
$new_contact = $db->sql_numrows($db->sql_query("SELECT * FROM fireshop_contact where `is_read` > 0"));
$new_order= $db->sql_numrows($db->sql_query("SELECT * FROM fireshop_order where `is_view` < 1 AND `is_end`>0 "));
$new_pay= $db->sql_numrows($db->sql_query("SELECT * FROM fireshop_pay where `is_view` < 1  "));

function ADMIN(){
require_once("admin/case/case.php");
}theme_admin();}}else{loginADMIN();die();}



}

function Module(){global $db;require_once("admin/module/index.php");}

function sql_quote($value,$type='0'){
if( get_magic_quotes_gpc()){
$value = stripslashes( $value );}
$value = mysql_real_escape_string( $value );
if($type == '1'){
$value = str_replace("<", "&lt;", str_replace(">", "&gt;", str_replace("'", "&#39;", str_replace("&#1740;","&#1610;",str_replace("'", "&#39;",str_replace("&amp;","&",str_replace("&#1756;","&#1610;",$value)))))));}
return $value;}

?>