<?php 
/*
##################################################################
#                       PHP 4&5 MySQL 4&5                        #
##################################################################
#           Copyright (c) 2004-2008 Armia Systems Inc            #
##################################################################
#               This file is part of Cybermatch site             #
##################################################################
#    Developed By: simi (simi@armia.com)                         #

##################################################################
#               Developed On:   03-04-2008                       #
##################################################################
#               Modified By:                                     #
##################################################################
#               Modified On:                                     #
##################################################################
# This script may not be distributed, sold, given away for free  #
# to third party, or used as a part of any internet services 	 #
# such as webdesign etc.                                         #
##################################################################
*/
//checking installed or not
$configfile = "config.inc.php";
$configcontents = @fread(@fopen($configfile, 'r'), @filesize($configfile));
$pos = strpos($configcontents,"INSTALLED");
if($pos === false)
{
	header("Location:install/install.php");
	exit();
}//end if

require_once ("config.inc.php");
require_once ("includes/mysql.inc.php");
require_once ("includes/arrays.inc.php");
require_once ("classes/miscellaneous.class.php");

$message	= "";
$msg		= isset($_REQUEST['msg'])	?	trim($_REQUEST['msg'])	:	"";
$array		= array();
if (!$objDB) {
	$message	= "Unable to Locate Database Server.";
} else {
	$objM		= new miscellaneous($objDB);
	$array		= $objM->get_cms(1);
}
$user_gender	= (isset($_SESSION['user_gender'])&&$_SESSION['user_gender']<>"")	?	$_SESSION['user_gender']	:	"Male";
$age_from		= (isset($_SESSION['age_from'])&&$_SESSION['age_from']<>"")	?	$_SESSION['age_from']		:	"18";
$age_to			= $age_from	+ 22;
if ($age_to > 99) $age_to	= 99;
if ($msg == "s") {
	$message	= "You have been logged out as same user name has logged in from another computer.";
}
//include_once ("title.inc.php");
?>
<?php
require_once ("includes/mysql.inc.php");
require_once ("classes/settings.class.php");
$objST	= new settings($objDB);

$siteSettings=$objST->select();

$PG_TITLE=$objST->ClientFilePathName($_SERVER['PHP_SELF']);

define('CURRENCY_CODE',$siteSettings['currency']);
define('PAYMENT_CURRENCY_CODE',$siteSettings['currencycode']);

//fetch corresponding value for each page
$pagName=$objST->ClientFilePathName($_SERVER['PHP_SELF']);

$condition="where vPageName='".$pagName."'";
$pkey=$objST->fetchSingleValue($objST->select_rows(TABLEPREFIX.'MetaTags','vKeywords',$condition),'vKeywords');
$pDes=$objST->fetchSingleValue($objST->select_rows(TABLEPREFIX.'MetaTags','vDescription',$condition),'vDescription');
//page title
$condition="where vPageName='".$pagName."'";
$metaTitle=$objST->fetchSingleValue($objST->select_rows(TABLEPREFIX.'MetaTags','vTitle',$condition),'vTitle');


if(trim($pkey)!='')
{
	$keyword=$pkey;
}//end if
else
{
	//meta keywords for common
	$keyword=$siteSettings['metatagKey'];
}//end else

if(trim($pDes)!='')
{
	$description=$pDes;
}//end if
else
{
	//meta description for common
	$description=$siteSettings['metatagDes'];
}//end else

if(trim($metaTitle)!='')
{
	$siteTitle=$metaTitle;
}//end if
else
{
	$siteTitle=$siteSettings['sitename'];
}//end else

//checking user login status
if (isset($_SESSION['userlogged']) && $_SESSION['userlogged']=="YES") 
{
	$shwLink='myprofile.php';
}//end if
else
{
	$shwLink='index.php';
}//end else

if($PG_TITLE=='search.php')
{
 	$onBodyLoad='onLoad="getCountyList_First(\'ALABAMA\');"';
}//end if
if($PG_TITLE=='register.php')
{
 	//$onBodyLoad='onLoad="getCountyList_First(\'ALABAMA\');"';
}//end if
if($PG_TITLE=='chatbox.php')
{
 	$onBodyLoad='onLoad="timers();timersOne();" onUnload="closeAllchildren();"';
}//end if
if($PG_TITLE=='chatboxsession.php')
{
 	$onBodyLoad='onLoad="timers();moveToBottom();"';
}//end if

//if logo empty shows site title in the logo place
if(trim($siteSettings['sitelogo'])!='')
{
	//checking logo default or not
	switch($siteSettings['sitelogo'])
	{
		case "logo_default.gif":
			if($PG_TITLE=='index.php')
			{
				$sqlBannersChk = $objST->select_rows(TABLEPREFIX.'Banners','*,min(nCount)',"where vActive='1' and vLocation='Home'
								GROUP BY nBId order by rand(),nPosition desc limit 0,1");
				if(mysql_num_rows($sqlBannersChk)>0)
				{
					$showLogoTop='52';
				}//end if
				else
				{
					$showLogoTop='24';
				}//end else
			}//end if
			else
			{
				$showLogoTop='24';
			}//end else
		break;

		default:
			$showLogoTop='3';
		break;
	}//end swich
	
	//checking image size
	@list($width,$height)=@getimagesize('images/'.$siteSettings['sitelogo']);
	if($width>510)
	{
		$width='510';
	}//end if
	else
	{
		$width=$width;
	}//end else

	if($height>118)
	{
		$height='118';
	}//end if
	else
	{
		$height=$height;
	}//end else

	$showLogoImgTtl='<img src="images/'.$siteSettings['sitelogo'].'" width="'.$width.'" height="'.$height.'" alt="'.$siteTitle.'" title="'.$siteTitle.'" border="0">';
}//end if
else
{
	$showLogoTop='24';
	$showLogoImgTtl=$siteTitle;
}//end else

//homepage banners only for index.php
switch($PG_TITLE)
{
	case "index.php":
			$sqlBanners = $objST->select_rows(TABLEPREFIX.'Banners','*,min(nCount)',"where vActive='1' and vLocation='Home'
							GROUP BY nBId order by rand(),nPosition desc limit 0,1");
	
			if(mysql_num_rows($sqlBanners)>0)
			{
				$Newbannerwidth=(mysql_result($sqlBanners,0,'vWidth')!='')?mysql_result($sqlBanners,0,'vWidth'):'200';
				$Newbannerheight=(mysql_result($sqlBanners,0,'vHeight')!='')?mysql_result($sqlBanners,0,'vHeight'):'150';
			
				if(mysql_result($sqlBanners,0,'nType')=='OpenX')
				{
					$showBannerCode='<div style="overflow:auto; width:'.$Newbannerwidth.'px;height:'.$Newbannerheight.'px;">'.mysql_result($sqlBanners,0,'vOpenxDes').'</div>';
				}//end if
				else
				{
					if(mysql_result($sqlBanners,0,'vImg')!='')
					{
						$showBannerCode='<a href="'.mysql_result($sqlBanners,0,'vlocUrl').'" target="_blank"><img src="./banners/'.mysql_result($sqlBanners,0,'vImg').'" name="img1" width="'.$Newbannerwidth.'" height="'.$Newbannerheight.'" border="0" alt="'.mysql_result($sqlBanners,0,'vName').'"></a>';
					}//end if
				}//end else
			
				mysql_query("update ".TABLEPREFIX."Banners set nCount=nCount+1 where nBId='".mysql_result($sqlBanners,0,'nBId')."'") or die(mysql_error());
			}//end if
	break;

	default:
		$showBannerCode='&nbsp;';
	break;
}//end switch
$objL	= new settings($objDB);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title><?php echo $siteTitle;?></title>
<meta name="keywords" content="<?php echo $keyword;?>">
<meta name="description" content="<?php echo $description;?>">
<meta name="copyright" content="Copyright (C) www.iScripts.com, 2007. All rights reserved.">
<meta name="author" content="www.armia.com">
<!--<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="PRAGMA" content="no-cache">-->
<meta http-equiv="Expires" content="Mon, 04 Dec 1999 21:29:02 GMT">
<link rel="shortcut icon" href="favicon.ico" >
<link href="styles/<?php echo $siteSettings['styles'];?>" rel="stylesheet" type="text/css">
<style type="text/css">

<!--
.style1 {color: #FFFFFF}
-->
</style>
</head>
<body <?php echo $onBodyLoad;?>>
<div id="Layer1" style="position:absolute; left:2px; top:<?php echo $showLogoTop;?>px; width:725px; height:120px; z-index:1">
  <table width="100%"  border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td class="logoo"><a href="<?php echo $shwLink;?>"><?php echo $showLogoImgTtl;?></a></td>
    </tr>
  </table>
</div>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="79%" valign="middle" class="logo">&nbsp;</td>
    <td width="21%" align="right" valign="top"><?php echo $showBannerCode;?></td>
  </tr>
</table>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td class="y">&nbsp;</td>
  </tr>
</table>
<table width="100%"  border="0" cellspacing="0" cellpadding="2">
      <tr>
        <td width="72%" valign="bottom"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="66%"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td bgcolor="#FFFFFF">
                            <table width="100%"  border="0" cellspacing="0" cellpadding="0">
								<tr><td height="150">&nbsp;</td></tr>
                              	<tr>
                                	<td class="maintext" align="center" valign="middle"><div style="overflow:auto; height:80px;">
										Invalid License. Please contact <b><?php echo $siteSettings['adminmail'];?></b></div></td>
                              	</tr>
								<tr><td height="100">&nbsp;</td></tr>
                          	</table>
						</td>
                      </tr>
                  </table></td>
                </tr>
            </table></td>
          </tr>
        </table>          </td>
      </tr>
    </table>
<?php
require_once ("classes/userside.class.php");
?>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td class="bar">&nbsp;</td>
  </tr>
</table>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="44%" align="left" class="footer">Powered by <a rel="nofollow" href="http://www.iscripts.com/cybermatch/" target="_blank">iScripts Cybermatch</a>.A premium product from <a rel="nofollow" href="http://www.iscripts.com" target="_blank">iScripts.com</a></td>
  </tr>
</table>
<?php include_once('track_code.inc.php');?>
</body>
</html>
