<?php
ob_start();
session_start();

function check_session($sess_name,$REDIRECT_URL){
	if(!strlen($_SESSION[$sess_name])){
		header("Location:$REDIRECT_URL");
		exit;
	}
}

function admin_header($sitetitle=""){ //admin_full_header..
	?>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	 <title><?=WEBSITE_NAME.' '.ucfirst(ADMIN_DIR);?></title>
	 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
            <meta name="viewport" content="width=device-width, initial-scale=1">
	 <link href="styles.css" rel="stylesheet" type="text/css" />	 
        	 <link href="css/font-awesome.min.css" rel="stylesheet" type="text/css" />	 
	 <link href="css/bootstrap.css" rel="stylesheet" type="text/css" />	 
	 <script type="text/javascript" src="<?=SITE_URL_PATH;?>/js/validation.js"></script>
	 <script type="text/javascript" src="<?=SITE_URL_PATH;?>/js/showHint.js"></script>
	 <script type="text/javascript" src="<?=SITE_URL_PATH;?>/js/common.js"></script>
	 <script language="javascript" src="js/admin.js"></script>
	 <!-- <script type="text/javascript" src="fckeditor/fckeditor.js"></script> -->
	 <script src="./ckeditor/ckeditor.js"></script>	 
	 <script src="./ckfinder/ckfinder.js"></script>	 
	 <script type="text/javascript" src="js/bootstrap.min.js"></script>	 
	</head>
	<body>
	<div id="header">
	 <table cellspacing=0 cellpadding=0 width="100%" border=0>
	  <tr bgcolor="rgb(70, 59, 37);"><td colspan=2 style="height:12px;"></td></tr>
	  <tr><td colspan=2 height=1></td></tr>
	  <tr><td style="padding-right: 0px; padding-left: 25px; background: #468cd2 no-repeat right 50%; padding-bottom: 10px; padding-top: 25px; white-space: nowrap; height: 40px; text-align: left" align=middle colspan=2><marquee><a style="text-decoration: none" href="welcome.php"><strong><h4><?=WEBSITE_NAME;?></h4></strong></a></marquee>
		  
		  <a style="text-decoration: none" href="<?=SITE_URL_PATH;?>"><strong><h4>Click Here To visit Website</h4></strong></a></td></tr>
	  <tr><td colspan=2 height=1></td></tr>
	  <tr bgcolor="rgb(70, 59, 37);"><td colspan=2 style="height:8px;"></td></tr>
	  <tr><td colspan=2 height=1></td></tr>
	  <tr>
	   <td background="images/top_bg.gif" height=66><img alt="Control Panel" hspace=20 src="images/control_panel.gif"></td>
	   <td valign="top" background="images/top_bg.gif" height=66>
	    <table cellspacing=0 cellpadding=0 width="100%" border=0>
	     <?php
	     if(!empty($_SESSION['MyCpanel'])){
		     ?>
		     <tr><td align="right" height=25><a href="index.php?id1=Logout"><img alt="Administrator Logout!" hspace=10 src="images/log_out.gif" border=0></a></td></tr>
		 <?php
	     }
	     ?>
	     <tr><td align="right" height=41>&nbsp; </td></tr>
	    </table>
	   </td>
	  </tr>
	 </table>
	</div>
	<table  border="0" cellspacing=0 cellpadding=0 width="100%">
	<tr>
	<?php
	if(isset($_SESSION['MyCpanel'])){
	$uriSegments = explode("/", parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
$lastUriSegment = array_pop($uriSegments);

                    $disble_link_user = [
                              'manage_locations.php',
                              'manage_location_content.php',
                              'addeditlocation.php',
                              'manage_scontent_new.php',
                              'manage_scontent.php',
                              'manage_scontent.php',
                              'manage_subdomainmetatag.php',
                              'manage_categories.php',
                              'addeditcategory.php',
                              'page-content.php'
                    ];


                    if(($_SESSION['MyAdminUserType'] == "user") && (in_array($lastUriSegment,$disble_link_user)))
                    {
                  echo "<script>alert('You are not allowed view this page')
                  window.location.href = '/wps-admin/welcome.php';
                  </script>";
                  exit;


               
                               
                    }

                    
		?>
		<td id="leftnav" valign="top">
		 <div id="leftnav">
		  <ul>
		   <?php
		   if ($_SESSION['MyAdminUserType'] == "admin") {
			   ?>
			<!--    <li><b><span class="sublinkshead">Manage Stores</span></b></li>
			 <li><a href="<?=SITE_ADMIN_URL;?>/manage_brands.php">Manage Stores</a></li>-->
			
				
				<li><br/><b><span class="sublinkshead">Manage Categories</span></b></li>
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_categories.php">Manage Categories</a></li>
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_scontent.php">Manage Subdomain Content</a></li>
				
				<li><br/><b><span class="sublinkshead">Manage Product</span></b></li>
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_products.php">Manage Product</a></li>
              
              <li><br/><b><span class="sublinkshead">Manage Gallery</span></b></li>
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_catalogue.php">Manage Catalogue</a></li>
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_certificate.php">Manage Photo Gallery</a></li>
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_video.php">Manage Video Gallery</a></li>
              
              	<li><br/><b><span class="sublinkshead">Manage Blog</span></b></li>
				
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_blog.php">Manage Blog Article</a></li>

				<li><br/><b><span class="sublinkshead">Manage Clients</span></b></li>
				
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_client.php">Manage Clients</a></li>

				<li><br/><b><span class="sublinkshead">Manage FAQ'S</span></b></li>
				
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_faq.php">Manage FAQ'S</a></li>
			
				
				<!--	<li><br/><b><span class="sublinkshead">Manage Blogs</span></b></li>-->
				
				<!--<li><a href="<?=SITE_ADMIN_URL;?>/manage_blog.php">Manage Blogs</a></li>-->
              
    <!--          <li><br/><b><span class="sublinkshead">Manage category Video</span></b></li>-->
              
    <!--          <li><a href="<?=SITE_ADMIN_URL;?>/manage_categoryvideo.php">Manage category Video</a></li>-->
              
				
				<!--	<li><br/><b><span class="sublinkshead">Manage Promotional Categories</span></b></li>
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_procategories.php">Manage Promotional Categories</a></li>
				
			<li><br/><b><span class="sublinkshead">Manage Blog</span></b></li>
				
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_blog.php">Manage collars</a></li>
				
				-->
				<!--<li><br/><b><span class="sublinkshead">Manage Team</span></b></li>-->
				<!--<li><a href="<?=SITE_ADMIN_URL;?>/manage_team_group.php">Manage Team Groups</a></li>-->
				<!--<li><a href="<?=SITE_ADMIN_URL;?>/manage_team_member.php">Manage Team Members</a></li>-->

				<li><br/><b><span class="sublinkshead">Manage Banners</span></b></li>
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_banners.php">Manage Banners</a></li>
			  
				<!--<li><br/><b><span class="sublinkshead">Manage Result Gallery</span></b></li>-->
				<!--<li><a href="<?=SITE_ADMIN_URL;?>/manage_gallery.php">Manage Celebrity Hair Transplant Result</a></li>-->
    <!--          <li><a href="<?=SITE_ADMIN_URL;?>/manage_hair_transplant_result.php">Manage Hair Transplant Result</a></li>-->
              
              <!--<li><a href="<?=SITE_ADMIN_URL;?>/manage_video.php">Manage Video</a></li>-->
              <!--<li><a href="<?=SITE_ADMIN_URL;?>/manage_faq.php?category_id=0">Manage FAQ's</a></li>-->
             
				
	                        
				
				<!--<li><br/><b><span class="sublinkshead">Manage Social Links</span></b></li>-->
				<!--<li><a href="<?=SITE_ADMIN_URL;?>/manage_slinks.php">Manage Social Links</a></li>-->
				
				<!--<li><br/><b><span class="sublinkshead">Manage Locations</span></b></li>-->
				<!--<li><a href="<?=SITE_ADMIN_URL;?>/manage_locations.php">Manage Locations</a></li>-->
				<!--<li><a href="<?=SITE_ADMIN_URL;?>/manage_clinic_locations.php">Manage Clinic Locations</a></li>-->
				
				<li><br/><b><span class="sublinkshead">Manage Sub Domain Homepage Content</span></b></li>
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_location_content.php?location_id=0">Home Content</a></li>
				
				<li><br/><b><span class="sublinkshead">Manage Enquiry</span></b></li>
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_enquiry.php">Manage Enquiry</a></li>
				<!--<li><a href="<?=SITE_ADMIN_URL;?>/manage_collaboration_enquiry.php">Manage Collaboration Enquiry</a></li>-->
				<!--<li><a href="<?=SITE_ADMIN_URL;?>/manage_appointments.php">Manage Appointments</a></li>-->
				
			<!--	<li><br/><b><span class="sublinkshead">Manage Bulk Order</span></b></li>
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_bulkorder.php">Manage Bulk Order</a></li>
			  
			   <li><br/><b><span class="sublinkshead">Manage Newsletter</span></b>
			   <li><a href="<?=SITE_ADMIN_URL;?>/manage-mails-active.php">Create Mailers</a></li>
			   <li><a href="<?=SITE_ADMIN_URL;?>/manage-mails-inprocess.php">Email Sending Inprocess</a></li>-->
		   
			   <li><br/><b><span class="sublinkshead">Manage Static Pages</span></b>
			   <?php
			   $spQry=db_query("select pageID, pageTitle from static_pages");
			   while ($spRes=mysqli_fetch_array($spQry)) {
				   $spRes=ms_htmlentities_decode($spRes);
				   ?>
				   <li><a href="<?=SITE_ADMIN_URL;?>/page-content.php?cid=<?=$spRes['pageID'];?>"><?=$spRes['pageTitle'];?></a></li>
				   <?php
			   }
			   ?>
			   
			   <li><br/><b><span class="sublinkshead">Standard Meta Tags</span></b></li>

				<li><a href="<?=SITE_ADMIN_URL;?>/manage_standardmetatags.php">Manage Standard Meta Tags</a></li>
				
				
				<li><br/><b><span class="sublinkshead">Standard Subdomain Meta Tags</span></b></li>

				<li><a href="<?=SITE_ADMIN_URL;?>/manage_subdomainmetatag.php">Manage Subdomain Standard Meta Tags</a></li>

				
				<li><br/><b><span class="sublinkshead">Homepage Pointer</span></b></li>

				<li><a href="<?=SITE_ADMIN_URL;?>/home-pointer.php">Homepage Pointer</a></li>
			   <li><a href="<?=SITE_ADMIN_URL;?>/manage_sucess_story.php">Manage Success Story</a></li>
			   <li><br/><b><span class="sublinkshead">Admin Section</span></b></li>
			   <li><a href="<?=SITE_ADMIN_URL;?>/myaccount.php">Manage Admin Details</a></li>
			   <li><a href="<?=SITE_ADMIN_URL;?>/admin_change_pass.php">Change Username & Password</a></li>
			   <li><a href="<?=SITE_ADMIN_URL;?>/index.php?id1=Logout">Logout</a></li>
		   
		   <?php
                            } else {
                            ?>
                            
                            <!-- <li><br/><b><span class="sublinkshead">Manage Categories</span></b></li>
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_categories.php">Manage Categories</a></li>
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_scontent.php">Manage Subdomain Content</a></li> -->
				
				<li><br/><b><span class="sublinkshead">Manage Product</span></b></li>
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_products.php">Manage Product</a></li>
              
              <!-- <li><br/><b><span class="sublinkshead">Manage Gallery</span></b></li>
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_catalogue.php">Manage Catalogue</a></li>
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_certificate.php">Manage Photo Gallery</a></li>
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_video.php">Manage Video Gallery</a></li> -->
              
              	<li><br/><b><span class="sublinkshead">Manage Blog</span></b></li>
				
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_blog.php">Manage Blog Article</a></li>

				<li><br/><b><span class="sublinkshead">Manage Clients</span></b></li>
				
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_client.php">Manage Clients</a></li>

				<!-- <li><br/><b><span class="sublinkshead">Manage FAQ'S</span></b></li>
				
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_faq.php">Manage FAQ'S</a></li> -->
			
				
				<!--	<li><br/><b><span class="sublinkshead">Manage Blogs</span></b></li>-->
				
				<!--<li><a href="<?=SITE_ADMIN_URL;?>/manage_blog.php">Manage Blogs</a></li>-->
              
    <!--          <li><br/><b><span class="sublinkshead">Manage category Video</span></b></li>-->
              
    <!--          <li><a href="<?=SITE_ADMIN_URL;?>/manage_categoryvideo.php">Manage category Video</a></li>-->
              
				
				<!--	<li><br/><b><span class="sublinkshead">Manage Promotional Categories</span></b></li>
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_procategories.php">Manage Promotional Categories</a></li>
				
			<li><br/><b><span class="sublinkshead">Manage Blog</span></b></li>
				
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_blog.php">Manage collars</a></li>
				
				-->
				<!--<li><br/><b><span class="sublinkshead">Manage Team</span></b></li>-->
				<!--<li><a href="<?=SITE_ADMIN_URL;?>/manage_team_group.php">Manage Team Groups</a></li>-->
				<!--<li><a href="<?=SITE_ADMIN_URL;?>/manage_team_member.php">Manage Team Members</a></li>-->

				<li><br/><b><span class="sublinkshead">Manage Banners</span></b></li>
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_banners.php">Manage Banners</a></li>
			  
				<!--<li><br/><b><span class="sublinkshead">Manage Result Gallery</span></b></li>-->
				<!--<li><a href="<?=SITE_ADMIN_URL;?>/manage_gallery.php">Manage Celebrity Hair Transplant Result</a></li>-->
    <!--          <li><a href="<?=SITE_ADMIN_URL;?>/manage_hair_transplant_result.php">Manage Hair Transplant Result</a></li>-->
              
              <!--<li><a href="<?=SITE_ADMIN_URL;?>/manage_video.php">Manage Video</a></li>-->
              <!--<li><a href="<?=SITE_ADMIN_URL;?>/manage_faq.php?category_id=0">Manage FAQ's</a></li>-->
             
				
	                        
				
				<!--<li><br/><b><span class="sublinkshead">Manage Social Links</span></b></li>-->
				<!--<li><a href="<?=SITE_ADMIN_URL;?>/manage_slinks.php">Manage Social Links</a></li>-->
				
				<!--<li><br/><b><span class="sublinkshead">Manage Locations</span></b></li>-->
				<!--<li><a href="<?=SITE_ADMIN_URL;?>/manage_locations.php">Manage Locations</a></li>-->
				<!--<li><a href="<?=SITE_ADMIN_URL;?>/manage_clinic_locations.php">Manage Clinic Locations</a></li>-->
				
				<!-- <li><br/><b><span class="sublinkshead">Manage Sub Domain Homepage Content</span></b></li>
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_location_content.php?location_id=0">Home Content</a></li> -->
				
				<li><br/><b><span class="sublinkshead">Manage Enquiry</span></b></li>
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_enquiry.php">Manage Enquiry</a></li>
				<!--<li><a href="<?=SITE_ADMIN_URL;?>/manage_collaboration_enquiry.php">Manage Collaboration Enquiry</a></li>-->
				<!--<li><a href="<?=SITE_ADMIN_URL;?>/manage_appointments.php">Manage Appointments</a></li>-->
				
			<!--	<li><br/><b><span class="sublinkshead">Manage Bulk Order</span></b></li>
				<li><a href="<?=SITE_ADMIN_URL;?>/manage_bulkorder.php">Manage Bulk Order</a></li>
			  
			   <li><br/><b><span class="sublinkshead">Manage Newsletter</span></b>
			   <li><a href="<?=SITE_ADMIN_URL;?>/manage-mails-active.php">Create Mailers</a></li>
			   <li><a href="<?=SITE_ADMIN_URL;?>/manage-mails-inprocess.php">Email Sending Inprocess</a></li>-->
		   
			   <!-- <li><br/><b><span class="sublinkshead">Manage Static Pages</span></b>
			   <?php
			   $spQry=db_query("select pageID, pageTitle from static_pages");
			   while ($spRes=mysqli_fetch_array($spQry)) {
				   $spRes=ms_htmlentities_decode($spRes);
				   ?>
				   <li><a href="<?=SITE_ADMIN_URL;?>/page-content.php?cid=<?=$spRes['pageID'];?>"><?=$spRes['pageTitle'];?></a></li>
				   <?php
			   }
			   ?> -->
			   
			   <!-- <li><br/><b><span class="sublinkshead">Standard Meta Tags</span></b></li>

				<li><a href="<?=SITE_ADMIN_URL;?>/manage_standardmetatags.php">Manage Standard Meta Tags</a></li>
				
				
				<li><br/><b><span class="sublinkshead">Standard Subdomain Meta Tags</span></b></li>

				<li><a href="<?=SITE_ADMIN_URL;?>/manage_subdomainmetatag.php">Manage Subdomain Standard Meta Tags</a></li> -->

				
				<li><br/><b><span class="sublinkshead">Homepage Pointer</span></b></li>

				<!-- <li><a href="<?=SITE_ADMIN_URL;?>/home-pointer.php">Homepage Pointer</a></li>
			   <li><a href="<?=SITE_ADMIN_URL;?>/manage_sucess_story.php">Manage Success Story</a></li> -->
			   <li><br/><b><span class="sublinkshead">Admin Section</span></b></li>
			   <li><a href="<?=SITE_ADMIN_URL;?>/myaccount.php">Manage Admin Details</a></li>
			   <li><a href="<?=SITE_ADMIN_URL;?>/admin_change_pass.php">Change Username & Password</a></li>
			   <li><a href="<?=SITE_ADMIN_URL;?>/index.php?id1=Logout">Logout</a></li>
		   
		   
		   <?php
		   }
		   ?>
		   		   
		  </ul>
		  
		  
		 </div>
		</td>
		<td valign="top" id="tdRight" align="center" width="2%">&nbsp;</td>
		<?php
	}
	?>
	<td valign="top" style="    padding: 10px;
">
	<?php
}
function admin_footer(){//footer for control panel...
  ?>
  </td>
  </tr>
	</table>
	<div id="footer">
	 <table cellspacing=0 cellpadding=0 width="100%" border=0>
	  <tr><td width="100%" height=1></td></tr>
	  <tr bgcolor="rgb(70, 59, 37);"><td height=6></td></tr>
	  <tr bgcolor="#AAAAAA"><td class="gray_txt" height=50>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Copyright &copy; <?=date("Y");?> &nbsp; <?=WEBSITE_NAME;?>&nbsp;All Rights Reserved. <br /></td></tr>
	 </table>
	</div>
	 <script type="text/javascript" src="<?=SITE_URL_PATH;?>/cmadmin/js/jquery.js"></script>
	 <script type="text/javascript">
	$(function(){
		$textarea = $('textarea');
		$.each($textarea, function(index, value){
			let id = $(this).attr('id');
			let ckeditor = CKEDITOR.replace(id);
			// let ckeditor = CKEDITOR.replace(id, {
			// 	filebrowserBrowseUrl: '/ckfinder/ckfinder.html',
   //  			filebrowserUploadUrl: '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
   //  			// extraPlugins : 'filebrowser'

			// });
			// CKFinder.setupCKEditor( ckeditor );
		});
	})
</script>
	</body></html>
	<?php
}

function pop_header($title){
	?>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	 <title><?=$title;?></title>
	 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	 <link href="<?=SITE_ADMIN_URL;?>/admin.css" rel="stylesheet" type="text/css" />
	 <script language="javascript" src="admin_js.js"></script>
	</head>
	<body>
	<p bgcolor="#f1f1f1" align="center"><br><a href="javascript:void(0);" OnClick="javascript:window.close();">Close Window</a>&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" OnClick="javascript:window.print();">Print Details</a></p>
	<?php
}

function pop_footer(){
	?>
	<br /><br />
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
	 <tr>
	  <td align="center" bgcolor="#f1f1f1"><strong>Copyright <?=date('Y');?> &copy; <?=WEBSITE_NAME;?></strong></td>
	 </tr>
	</table>
	<p bgcolor="#f1f1f1" align="center"><br><a href="javascript:void(0);" OnClick="javascript:window.close();">Close Window</a>&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" OnClick="javascript:window.print();">Print Details</a></p>
	</body>
	</html>
	<?php
}

function admin_change_pass(){
	$res=getResult("admin_details"," where user_id='".$_SESSION['MyAdminUserID']."' and user_type='".$_SESSION['MyAdminUserType']."'");
	?>
	<script type="text/javascript">
	function validate_form() {
		var frm=document.chgPwd;
		if (frm.username.value==0) {
			alert("Please enter username");
			frm.username.focus();
			return false;
		}
		if (frm.old_password.value==0) {
			alert("Please enter your current password");
			frm.old_password.focus();
			return false;
		}
		if (frm.password.value==0) {
			alert("Please enter your new password");
			frm.password.focus();
			return false;
		}
		if (frm.repassword.value==0) {
			alert("Please confirm your new password");
			frm.repassword.focus();
			return false;
		}
		if (frm.password.value != frm.repassword.value) {
			alert("Password and Confirm Password mismatched");
			frm.repassword.focus();
			return false;
		}
	}
	</script>
	<form action="" method="post" name="chgPwd" id="chgPwd" onsubmit="return validate_form();">
	<table width="550" border="0" align="center" cellpadding="0" cellspacing="0" class="tableForm"> 
	 <tr>
	  <td class="tdLabel" colspan="2" align="center">
	   <?php
	   if($_SESSION[session_message]!=''){
		   echo '<font color="#C05813">'.print_message().'</font><br>';
	   }
	   ?>
	  </td>
	 </tr>
	 <tr>
	  <td width="120" class="tdLabel">Username:<font color="red">*</font></td>
	  <td><input type="text" name="username" value="<?=$res[user_id];?>" class="textfield"></td>
	 </tr>
	 <tr>
	  <td width="120" class="tdLabel">Current Password:<font color="red">*</font></td>
	  <td><input type="password" name="old_password" class="textfield" /></td>
	 </tr>
	 <tr>
	  <td class="tdLabel">New Password:<font color="red">*</font></td>
	  <td><input type="password" name="password" class="textfield"></td>
	 </tr>
	 <tr>
	  <td class="tdLabel">Confirm Password:<font color="red">*</font></td>
	  <td><input type="password" name="repassword" class="textfield"></td>
	 </tr>
	 <tr>
	  <td class="label">&nbsp;</td>
	  <td>
	   <input type="image" name="imageField" src="images/buttons/submit.gif" />
	   <input type="hidden" name="action" value="Update">
	  </td>
	 </tr> 
	</table> 
	</form>
	<?php
}

function login_frm(){
	?>
	<table width="368"  border="0" align="center" cellpadding="0" cellspacing="0">
	 <tr><td width="368" align="left"><img src="images/secure_login.gif" alt="Main Administrator Login" /></td></tr>
	 <tr><td valign="top">&nbsp;</td></tr>
	 <tr>
	  <td>
	   <table width="100%"  border="0" cellpadding="15" cellspacing="1" bgcolor="#cfcfcf">
	    <tr>
	     <td bgcolor="#f5f5f5">
	      <table width="100%"  border="0" cellspacing="0" cellpadding="0">
	       <tr>
	        <td width="13%" align="left"><img src="images/icons/keys.gif" width="32" height="32" /></td>
	        <td width="87%" align="left" valign="top"><span style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; color:#1E518F; font-weight:bold">Welcome to <?=WEBSITE_NAME;?> Control Panel</span></td>
	       </tr>
	       <tr>
	        <td  valign="top" align="center">&nbsp;</td>
	        <td  valign="top" align="center"><font color="#d0601c">
	         <?php
	         if($_SESSION['session_message']!=''){
		         echo print_message();
		         echo "<br/><br/>";
	         }
	         ?>
	         </font>
	        </td>
	       </tr>
	       <tr>
	        <td colspan="2" align="left">
	         <table width="100%"  border="0" cellspacing="0" cellpadding="0">
	          <tr>
	           <td width="34%" valign="top" class="txtLight">Please enter a valid username and password to gain access to the administration console.</td>
	           <td width="66%" align="right" valign="top">
	            <table width="80%"  border="0" cellpadding="7" cellspacing="1" bgcolor="#cfcfcf">
	             <tr>
	              <td bgcolor="#efefef">
	               <script type="text/javascript">
	               function validate_user(){
		               var frm=document.loginFrm;
		               if(frm.login_id.value==""){
			               alert("Enter Username!!");
			               frm.login_id.focus();
			               return false;
		               }
		               if(frm.password.value==""){
			               alert("Enter Password!!");
			               frm.password.focus();
			               return false;
		               }
	               }
	               </script>
	               <form name="loginFrm" action="" method="post" onsubmit="return validate_user();">
	               <table width="100%"  border="0" cellspacing="0" cellpadding="1">
	                <tr><td align="left"><strong>Username</strong></td></tr>
	                <tr><td align="left"><input name="login_id" type="text" class="textfield" id="login_id" value="<?=$adm_login_id?>" size="30" /></td></tr>
	                <tr><td align="left"><strong>Password</strong></td></tr>
	                <tr><td align="left"><input name="password" type="password" class="textfield" value="<?=$_POST['password']?>" size="30" /></td></tr>
	               
	                <tr>
	                 <td align="left">
	                  <input name="user_type" type="hidden" value="admin"  />
	              
	                 </td>
	                </tr>
	                <tr>
	                 <td align="right" style="padding-top:5px">
	                  <input type="image" src="images/buttons/submit.gif" alt="Submit" border="0" />
	                  <input type="hidden" name="id1" value="login" />
	                 </td>
	                </tr>
	               </table>
	               </form>
	              </td>
	             </tr>
	            </table>
	           </td>
	          </tr>
	         </table>
	        </td>
	       </tr>
	      </table>
	     </td>
	    </tr>
	   </table>
	  </td>
	 </tr>
	</table> 
	<?php
}

function welcome(){
	$q=getResult("admin_details"," where user_id='".$_SESSION['MyAdminUserID']."' and user_type='".$_SESSION['MyAdminUserType']."'");	
	?>
	<div align="left"><font color="red"><strong>Last Login At ::</font>  <?=showdatetime($q[last_login]);?></strong></div>
	<hr size="2" width="100%" color="#92B2D6">
	<br/><br/><br/>
	<table width="80%" align="center" cellpadding="5" cellspacing="0" border="0">
	 <tr><td align="center"><marquee behavior="alternate"><font color="navy" size="3"><?=WEBSITE_NAME;?><br/><br/>Administrator Work Area</font></marquee></td></tr>
	</table> 
	<?php	
}

function addEditLinks($id){
	$num=getCount("static_pages"," where pageID='$id'");
	if($num>0){
		$res=getResult("static_pages"," where pageID='$id'");		
		echo '<script type="text/javascript">document.getElementById("pgtitle _Container").innerHTML="'.$res[pageTitle].'";</script>';
		$var1='
		
		
		<form method="post" action="" name="faqfrm" enctype="multipart/form-data">
		 <table width="99%" cellpadding="2" cellspacing="0" border="0">
		  <tr>
		   <td align="center" width="100%">
		    <hr size=1 color="maroon" width="100%">
		    <table width="100%" cellpadding="2" cellspacing="0" border="0" align="center">
		     <tr><td colspan="3" align="right">(<font color="red">*</font>) mandatory fields</td></tr>		     
		     <tr>
		      <td width="10%" align="left" valign="top"><b><font color="red">*</font>Content</b></td>
		      <td width="1%" valign="top">:&nbsp;</td>
		      <td align="left"><textarea name="pageDesc" id="pageDesc" rows=10 cols=100  class="txtfieldadmin">'. $res[pageDesc].'</textarea></td>
		     </tr>
			
	 <tr>
		      <td width="10%" align="left" valign="top"><b><font color="red">*</font>Content-Desc1</b></td>
		      <td width="1%" valign="top">:&nbsp;</td>
		      <td align="left"><textarea name="pageDesc1" id="pageDesc1" rows=10 cols=100  class="txtfieldadmin">'. $res[pageDesc1].'</textarea></td>
		     </tr>
			 
			 <tr>
		      <td width="10%" align="left" valign="top"><b><font color="red"></font>Meta Title</b></td>
		      <td width="1%" valign="top">:&nbsp;</td>
		      <td align="left"><textarea name="mtitle"  rows=10 cols=100  class="txtfieldadmin">'. $res[page_metatitle].'</textarea></td>
		     </tr>
			 
			 
			 <tr>
		      <td width="10%" align="left" valign="top"><b><font color="red"></font>Meta Keyword</b></td>
		      <td width="1%" valign="top">:&nbsp;</td>
		      <td align="left"><textarea name="mkeyword" rows=10 cols=100  class="txtfieldadmin">'. $res[page_keyword].'</textarea></td>
		     </tr>
			 
			 
			 <tr>
		      <td width="10%" align="left" valign="top"><b><font color="red"></font>Meta Desc</b></td>
		      <td width="1%" valign="top">:&nbsp;</td>
		      <td align="left"><textarea name="mdesc" rows=10 cols=100  class="txtfieldadmin">'. $res[page_metadesc].'</textarea></td>
		     </tr>
			  <tr><td colspan="3" align="center">&nbsp;</td></tr>
		      <tr>

		      <td width="10%" align="left" valign="top"><b><font color="red">*</font>Page Banner</b></td>

		      <td width="1%" valign="top">:&nbsp;</td>

		      <td align="left"><input type="file" name="banner" />';
		      	if($res['pageBanner'] != ''){
		      		  $banner=SITE_DIR_PATH."/uploaded-files/page-banners/".$res[pageBanner];
	   if(file_exists($banner)) {
		   $dimens=GetImageSize($banner);
		   if($dimens[0]>130) {
			   $dimens[0]=$dimens[0]+50;
			   $dimens[1]=$dimens[1]+80;
		   }
		   else{
			   $dimens[0]=200;
			   $dimens[1]=200;
		   }
		   $var1.= "&nbsp;<a href=\"javascript:void(0);\" onClick=\"openwin('".SITE_ADMIN_URL."/popup_new.php?img=page-banners/".$res[pageBanner]."', '$dimens[0]', '$dimens[1]')\" class=\"linkgray fontbold\"><b>View Image</b></a>&nbsp; <strong><a href=".SITE_ADMIN_URL."/page-content.php?cid=".$id."&id=remove_image&field=pageBanner\">Remove</a></strong>"; 
	   }
		      	}

		      $var1.=' </td>

		     </tr>
		     <tr><td colspan="3" align="center">&nbsp;</td></tr>
			 
			 <tr><td colspan="3" align="center">&nbsp;</td></tr>
		      <tr>

		      <td width="10%" align="left" valign="top"><b><font color="red">*</font>Page Image</b></td>

		      <td width="1%" valign="top">:&nbsp;</td>

		      <td align="left"><input type="file" name="image" />';
		      	if($res['pageImage'] != ''){
		      		  $banner=SITE_DIR_PATH."/uploaded-files/page-images/".$res[pageImage];
	   if(file_exists($banner)) {
		   $dimens=GetImageSize($banner);
		   if($dimens[0]>130) {
			   $dimens[0]=$dimens[0]+50;
			   $dimens[1]=$dimens[1]+80;
		   }
		   else{
			   $dimens[0]=200;
			   $dimens[1]=200;
		   }
		   $var1.= "&nbsp;<a href=\"javascript:void(0);\" onClick=\"openwin('".SITE_ADMIN_URL."/popup_new.php?img=page-images/".$res[pageImage]."', '$dimens[0]', '$dimens[1]')\" class=\"linkgray fontbold\"><b>View Image</b></a>"; 
	   }
		      	}

		      $var1.=' </td>

		     </tr>
		     <tr><td colspan="3" align="center">&nbsp;</td></tr>
			 
			 
			 
		     <tr><td colspan="3" align="center">&nbsp;</td></tr>
		     <tr>
		      <td colspan="3" align="left" style="padding-left:95px;">
		       <input type="hidden" name="st_id" value="'.$id.'">
		       <input type="submit" name="add_ct" value="Save" class="button">
		      </td>
		     </tr>
		    </table>
		   </td>
		  </tr>
		 </table>
		</form>';
		
		$var1.='
		<script type="text/javascript">
		 var oFCKeditor = new FCKeditor(\'pageDesc\');
		 oFCKeditor.BasePath = "fckeditor/";
		 oFCKeditor.ReplaceTextarea() ;
		</script>';	
		
		$var1.='
		<script type="text/javascript">
		 var oFCKeditor = new FCKeditor(\'pageDesc1\');
		 oFCKeditor.BasePath = "fckeditor/";
		 oFCKeditor.ReplaceTextarea() ;
		</script>';	
	}
	else {
		echo '<script type="text/javascript">document.getElementById("pgtitle _Container").innerHTML="????";</script>';
		$var1='<br><br><center>No Record Found</center>';
	}
					
	return $var1;	
}

function validate_session(){
	$mem=explode("~",$_SESSION[SessionId]);
	$res=getResult("admin_details"," where adminId='$mem[0]'");
	$un1= substr(md5($res[username]), 0, 10);
	$pn1= substr(md5($res[pwd]), 0, 10);	
	if($un1==$mem[1] && $pn1==$mem[2]){
		return "V";
	}else{
		return "I";
	}
}

function adminName(){
	$mem=explode("~",$_SESSION[SessionId]);
	$res=getResult("admin_details"," where user_id='".$_SESSION['MyAdminUserID']."' and user_type='".$_SESSION['MyAdminUserType']."'");
	if($res[name]!=""){
		echo $res[name].",";
	}else{
		echo "Admin,";
	}
}

function required(){
	$mem=explode("~",$_SESSION[SessionId]);
	$res=getResult("admin_details"," where user_id='".$_SESSION['MyAdminUserID']."' and user_type='".$_SESSION['MyAdminUserType']."'");
	if(($res[name]=="" || $res[email]=="" || $res[website]=="")&& $_SESSION[SessionId]!=""){
		return "<br /><center><font style='color:#ee0000;'>Some Required Fields are empty.Please enter this fields by <a href='<?=SITE_ADMIN_URL;?>/myaccount.php'>clicking here</a></font></center>";
	}else{
		return 0;
	}
}

function showdatetime($date){
	$split_time=explode(" ",$date);
	$cdate=explode("-",$split_time[0]);
	$month=$cdate[1];
	$day=$cdate[2];
	$year=$cdate[0];

	$ctime=explode(":",$split_time[1]);
	$hours=$ctime[0];
	$minutes=$ctime[1];
	$seconds=$ctime[2];
	return date('d F, Y G:i:s', mktime($hours, $minutes, $seconds, $month, $day, $year));
}

function date_format_only($date){
	$cdate=explode("-",$date);
	$month=$cdate[1];
	$day=$cdate[2];
	$year=$cdate[0];
	return date('d/m/Y', mktime(0, 0, 0, $month, $day, $year));
}

function showdate($date){
	$cdate=explode("-",$date);
	$month=$cdate[1];
	$day=$cdate[2];
	$year=$cdate[0];

	if($date!="" && $date!="0000-00-00") {
		return date('d-m-Y', mktime($hours, $minutes, $seconds, $month, $day, $year));
	}
	else {
		return "";
	}
}

function adminheader_popup($title1) {
	?>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	 <title><?=$title?></title>
	 <link href="<?=SITE_ADMIN_URL;?>/css/admin.css" rel="stylesheet" type="text/css" />
	 <link href="<?=SITE_ADMIN_URL;?>/css/styles_dg.css" rel="stylesheet" type="text/css" />
	 <link href="<?=SITE_URL_PATH;?>/css/redapple-preet.css" rel="stylesheet" type="text/css" />
	<link href="<?=SITE_URL_PATH;?>/css/additional.css" rel="stylesheet" type="text/css" />
	<script src="<?=SITE_URL_PATH;?>/js/common.js" type="text/javascript"></script>
	<script src="<?=SITE_URL_PATH;?>/js/validation.js" type="text/javascript"></script>
	 <script language="JavaScript1.2" src="<?=SITE_ADMIN_URL;?>/js/admin.js" type="text/javascript"></script>	 
	 <script type="text/javascript" src="<?=SITE_URL_PATH;?>/js/showHint.js"></script>
	 <link rel="stylesheet" href="<?=SITE_URL_PATH;?>/css/lightbox.css" type="text/css" media="screen" />
	 <script src="<?=SITE_URL_PATH;?>/js/prototype.js" type="text/javascript"></script>
	 <script src="<?=SITE_URL_PATH;?>/js/lightbox.js" type="text/javascript"></script>
	 <script src="<?=SITE_URL_PATH;?>/js/scriptaculous.js?load=effects" type="text/javascript">
		</script>
	
	</head>
	<body>
	<center>
	<div id="Body_Area">
	<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
	<td valign="top" id="Container">
	<table width="100%"  border="0" cellpadding="0" cellspacing="0" class="Margin_top_five" id="Forum_Area">
	<tr>
	<td align="left" width="4" height="4"><img src="images/gray_top-lt-cor.gif" alt="" width="5" height="6" /></td>
	<td width="4" height="4"><img src="images/spacer.gif" alt="" width="1" height="1" /></td>
	<td width="4" height="4" align="right"><img src="images/gray_top-rt-cor.gif" alt="" width="6" height="5" /></td>
	</tr>
	<tr>
	<td><img src="<?php echo SITE_ADMIN_URL;?>/images/spacer.gif" alt="" width="1" height="1" /></td>
	<td style="width:100%;">
	<table width="100%"  border="0" cellpadding="0" cellspacing="0" class="lightBorder">
	<tr  valign="top" >
	<td height="25" valign="middle" class="Bluebg Head2"><?=$title1?></td>
	<td class="Bluebg PadFive white" align="right"><b>Close</b><a href="javascript:window.close()"> <img src="<?=SITE_ADMIN_URL; ?>/images/logout.gif" align="absmiddle" border=0 title="Close Window"></a></td>
	</tr>
	<tr>
	<td bgcolor="#FFFFFF" valign="top" colspan="2"><br />
	<?php
}

function adminfooter_popup(){
	?>
	<br />
	</td></tr></table></td>
	<td width="4" align="right"><img src="<?php echo SITE_URL_PATH;?>/images/spacer.gif" alt="" width="1" height="1" /></td>
	</tr>
	<tr>
	 <td width="4" height="4" align="left" valign="bottom"><img src="<?php echo SITE_URL_PATH;?>/images/gray_bot-lt-cor.gif" alt="" width="6" height="5" /></td>
	 <td width="4" height="4"><img src="<?php echo SITE_URL_PATH;?>/images/spacer.gif" alt="" width="1" height="1" /></td>
	 <td width="4" height="4" align="right" valign="bottom"><img src="<?php echo SITE_URL_PATH;?>/images/gray_bot-rt-cor.gif" alt="" width="5" height="6" /></td>
	</tr>
	</table>
	</td>
	</tr>
	</table>
	</div>
	</center>	
	</body>
	</html>
	<?php 
}

function table_offset($pageno,$num,$wcnt,$num3,$num31,$link2) {
	if (substr($link2,-1)!="?") {
		$link2 = "$link2&";
	}
	if (!strlen($pageno)) {
		$pageno=1;
	}
	$num1 = ($num%$num3);
	$num2 = intval($num/$num3);
	if ($num1>0) {
		$num2=$num2+1;
	}
	if ($wcnt>=$num31) {
		$num5 = ($wcnt%$num31);
		if ($num31>0){
			$num51 = intval($wcnt/$num31);
		}
		$num51=$num51+1;
		if (!strlen($pageno)) {
			$pageno1 = ($wcnt%$num3);
			$pageno = intval($wcnt/$num3);
			if ($pageno1>0) {
				$pageno++;
			}
		}
	}
	$gotopage = "<table width=\"100%\" border=0 cellpadding=1 cellspacing=2 align=center class=\"lightGrayBg\"><tr><td width=\"79%\" align=\"center\">";
	if (empty($offset)) {
		$offset=1;
	}
	$offset_1  = $wcnt+$num3;
	if ($offset_1 >  $num) {
		$offset_1=$num;
	}
	
	//Search Result display - 1 - 20 of 2938
	if ($num2>=1) {
		$gotopage .= SEARCH_RESULT." ". ($wcnt+1) ." - ". $offset_1 ." ".OF." ".$num." &nbsp;&nbsp;</td><td height=\"30\" align=\"right\" class=\"jobsby\" id=\"paging\">";
	}
	else {
		//$gotopage .= "</td><td height=\"30\" align=\"right\" class=\"jobsby\" id=\"paging\">";
	}
	$offset1=0;
	if ($num51<1) {
		$wcnt5=0;
	}
	elseif ($num51==1) {
		$wcnt5=0;
	}
	else {
		$wcnt5=($num51-1)*10;
	}
	if ($wcnt5==0) {
		$offset1=0;
	}
	else {
		$offset1=$wcnt5*$num3;
	}
	
	//$gotopage  .= "PAGE : ";
	for ($iv=$wcnt5+1;$iv<=$wcnt5+10;$iv++) {
		if ($pageno == $iv) {
			$gotopage  .= "<span class=\"navBarTxtCurrent\">$iv</span>";
		}
		else {
			$gotopage  .= " <a class=\"navBarTxt\" href=\"$link2"."offset=$offset1&pageno=$iv#a1\">$iv</a> ";
		}
		$offset1=$iv*$num3;
		if ($num<=$offset1) {
			break;
		}
	}
	$pageno=$wcnt5+10+1;
	$gotopage .= '</td>';
	if ($wcnt>$num31) {
		$pageno1=(($num51-1)*10);
		$offset1=(($num51-1)*$num31)-$num3;
		$gotopage .= "<td width=\"13%\"><a href=\"$link2"."offset=$offset1&pageno=$pageno1#a1\"><img src=\"../".$cimageFolder."/previous.gif\" width=\"68\" height=\"18\" border=\"0\" class=\"lightBorder2\"></a></td>";
	}
	if ($num>$offset1) {
		$gotopage .= "<td width=\"8%\" align=\"right\"><a href=\"$link2"."offset=$offset1&pageno=$pageno1#a1\" class=\"red1\"><img src=\"../".$cimageFolder."\" width=\"47\" height=\"18\" border=\"0\" class=\"lightBorder2\"></a></td>";
	}
	$gotopage .='</td></tr></table>';
	return $gotopage;
}

function rss_write() {
	$pgnm=SITE_DIR_PATH."/rss/news_feed.rss";
	$fp=fopen("$pgnm","w");
	
	$newsCnt=getCount("news_tbl"," where status='Y'");
	if ($newsCnt > 0) {
		$rss_content='<?xml version="1.0" encoding="iso-8859-1" ?> '."\n".'<rss version="2.0">'."\n".'<channel>'."\n".'<title>Red Apple</title>'."\n".'<link>'.$link_rss.'</link>'."\n".'<description>Latest '.$categoryRes['categoryName'].' Articles</description>'."\n".'<language>en-us</language>'."\n".'<generator>Weblinkindia.Net</generator>'."\n";
		$newsQry=db_query("select * from news_tbl where status='Y'");
		while ($newsRes=mysqli_fetch_array($newsQry)) {
			$newsRes=ms_htmlentities_decode($newsRes);
			$rss_content.='<item>'."\n";
			$look=array('\'','"','&','<','>');
			$replace=array('&quot;', '&quot;', '&amp;', '&lt;', '&gt;');
			$newsHeading=str_replace($look, $replace, $newsRes['newsHeading']);
			$newsDescription=str_replace($look, $replace, $newsRes['newsDescription']);
			$rss_content.='<title>'.$newsHeading.'</title>'."\n";
			$rss_content.='<link>'.$link1.'</link>'."\n";
			$rss_content.='<description>'."\n\t\t".$newsDescription."\n".'</description>'."\n";
			$rss_content.='</item>'."\n";
		}
		$rss_content.='</channel>'."\n";
		$rss_content.='</rss>'."\n";
	}	
	fwrite($fp,$rss_content);
	fclose($fp);	
}

function get_team_group_name($id){
	$sql = mysqli_query($GLOBALS['dbcon'],"SELECT * FROM team_group_tbl where id= $id");
	$team_group = mysqli_fetch_array($sql);
	if(is_array($team_group)){
		return $team_group['group_name'];
	}else{
		return "";
	}
}

function get_category_name($id){
	$sql = mysqli_query($GLOBALS['dbcon'],"SELECT * FROM category_tbl where catID= $id");
	$team_group = mysqli_fetch_array($sql);
	if(is_array($team_group)){
		return $team_group['catName'];
	}else{
		return "";
	}
}
function get_location_name($id){
	$sql = mysqli_query($GLOBALS['dbcon'],"SELECT * FROM location_tbl where locationID= $id");
	$team_group = mysqli_fetch_array($sql);
	if(is_array($team_group)){
		return $team_group['locationName'];
	}else{
		return "";
	} }
    function get_category_count(){
	return mysqli_num_rows(mysqli_query($GLOBALS['dbcon'],"SELECT * FROM category_tbl"));
}
function get_enquiry_count(){
	return mysqli_num_rows(mysqli_query($GLOBALS['dbcon'],"SELECT * FROM tbl_enquiry"));
}
function get_blog_count(){
	return mysqli_num_rows(mysqli_query($GLOBALS['dbcon'],"SELECT * FROM blog_tbl"));
}
function get_location_count(){
	return mysqli_num_rows(mysqli_query($GLOBALS['dbcon'],"SELECT * FROM location_tbl"));
}
?>