<?php
    require_once "C:/Inetpub/charlotteparent/cmsAdmin/lib/viewer_functions.php";
	if (!$CURRENT_USER) { websiteLogin_redirectToLogin(); }

   list($menu_newRecords, $menu_newMetaData) = getRecords(array(
    'tableName'   => 'menu_new',
    'allowSearch' => '0',
    'limit'       => '1',
  ));
  $menu_newRecord = @$menu_newRecords[0]; // get first record
  
  list($directories_menuRecords, $directories_menuMetaData) = getRecords(array(
    'tableName'   => 'directories_menu',
  ));
  
  list($publicationsmenuRecords, $publicationsmenuMetaData) = getRecords(array(
    'tableName'   => 'publicationsmenu',
  ));
   
  list($globalRecords, $globalMetaData) = getRecords(array(
    'tableName'   => 'global',
    'allowSearch' => '0',
    'limit'       => '1',
  ));
  $globalRecord = @$globalRecords[0]; // get first record
  
   list($advertiser_resmainRecords, $advertiser_resmainMetaData) = getRecords(array(
    'tableName'   => 'advertiser_resmain',
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $advertiser_resmainRecord = @$advertiser_resmainRecords[0]; // get first record
  
  list($advertiser_pageRecords, $advertiser_pageMetaData) = getRecords(array(
    'tableName'   => 'advertiser_page',
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $advertiser_pageRecord = @$advertiser_pageRecords[0]; // get first record
  
  
  
 ########################################################################################
  ##   
  
  $errorsAndAlerts = "";
  
  
  // process account form
  if (@$_REQUEST['updateAccount']) {
    
   
    // error checking
     if (!@$_REQUEST['fullname'])            	{ $errorsAndAlerts .= "You must enter your full name!<br/>\n"; }
    if (!@$_REQUEST['business_name'])          { $errorsAndAlerts .= "You must enter your Business Name!<br/>\n"; }
    if (!@$_REQUEST['phone'])            	{ $errorsAndAlerts .= "You must enter your phone number!<br/>\n"; }
    if (!@$_REQUEST['zip'])                	{ $errorsAndAlerts .= "You must enter your zip code!<br/>\n"; }
    if (!@$_REQUEST['username'])                                { $errorsAndAlerts .= "You must choose a username!<br/>\n"; }
    if (!@$_REQUEST['email'])                   		{ $errorsAndAlerts .= "You must enter your email!<br/>\n"; }
    else if(!isValidEmail(@$_REQUEST['email'])) 		{ $errorsAndAlerts .= "Please enter a valid email (example: user@example.com)<br/>\n"; }

    // new password checking
    if (@$_REQUEST['oldPassword'] || $_REQUEST['newPassword1'] || $_REQUEST['newPassword2']) {
      $oldPasswordHash = (@$SETTINGS['advanced']['encryptPasswords']) ? getPasswordDigest(@$_REQUEST['oldPassword']) : @$_REQUEST['oldPassword'];
      if (!@$_REQUEST['oldPassword'])                                 { $errorsAndAlerts .= "Please enter a value for: Current Password<br/>\n"; }
      elseif ($oldPasswordHash != $CURRENT_USER['password'])          { $errorsAndAlerts .= "Current password isn't correct!<br/>\n"; }
      elseif (!@$_REQUEST['newPassword1'])                            { $errorsAndAlerts .= "Please enter a value for: New Password<br/>\n"; }
      elseif (!@$_REQUEST['newPassword2'])                            { $errorsAndAlerts .= "Please enter a value for: Confirm New Password<br/>\n"; }
      elseif ($_REQUEST['newPassword1'] != $_REQUEST['newPassword2']) { $errorsAndAlerts .= "New passwords don't match!<br/>\n"; }
    }

    // check for duplicate usernames and emails
    if (@$_REQUEST['username'] != $CURRENT_USER['username']) {
      $count = mysql_count($GLOBALS['WSM_ACCOUNTS_TABLE'], "`username` = '".mysql_escape(@$_REQUEST['username'])."'");
      if ($count > 0 && @$_REQUEST['username']) { $errorsAndAlerts .= "That username is already in use, please choose another!<br/>\n"; }
    }
    if (@$_REQUEST['email'] != $CURRENT_USER['email']) {
      $count = mysql_count($GLOBALS['WSM_ACCOUNTS_TABLE'], "'".mysql_escape(@$_REQUEST['email'])."' IN (email, username)");
      if ($count > 0) { $errorsAndAlerts .= "That email is already in use, please choose another!<br/>\n"; }
    }

    // update user
    if (!$errorsAndAlerts) {
      mysqlStrictMode(false);   // disable Mysql strict errors for when a field isn't defined below (can be caused when fields are added later)
      if (@$_REQUEST['newPassword2']) { $CURRENT_USER['password'] = $_REQUEST['newPassword2']; } // update password
  
      // update password if needed
      $password         = @$_REQUEST['newPassword2'] ? @$_REQUEST['newPassword2'] : $CURRENT_USER['password'];
      if (@$SETTINGS['advanced']['encryptPasswords']) { $passwordHash = getPasswordDigest($password); }
      else                                            { $passwordHash = $password; }
  
      //
      $query = "UPDATE `{$TABLE_PREFIX}" . @$GLOBALS['WSM_ACCOUNTS_TABLE'] . "` SET
                        fullname				       = '".mysql_escape( @$_REQUEST['fullname'] )."',
                        email					   = '".mysql_escape( @$_REQUEST['email'] )."',
                        username				       = '".mysql_escape( @$_REQUEST['username'] )."',
                        password                  = '".mysql_escape( @$passwordHash )."',
                        
                       business_name 				= '".mysql_escape( @$_REQUEST['business_name'] )."',																	
		      		     phone 						= '".mysql_escape( @$_REQUEST['phone'] )."',
		     			 zip 							= '".mysql_escape( @$_REQUEST['zip'] )."',
    
                        updatedByUserNum                            = '".mysql_escape( $CURRENT_USER['num'] )."',
                        updatedDate                                 = NOW()
                 
                        WHERE num = '".mysql_escape( $CURRENT_USER['num'] )."'";
      mysql_query($query) or die("MySQL Error:<br/>\n". htmlspecialchars(mysql_error()) . "\n");
      $userNum = mysql_insert_id();
  
      // on success
      unset($_REQUEST['oldPassword'], $_REQUEST['newPassword1'], $_REQUEST['newPassword2']); // clear password fields
      print "<script> window.location.href ='?' </script>";
      }
}
  

 ?>
  
<!doctype html>
<!--[if lt IE 7]> <html class="ie6 oldie"> <![endif]-->
<!--[if IE 7]>    <html class="ie7 oldie"> <![endif]-->
<!--[if IE 8]>    <html class="ie8 oldie"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="">
<!--<![endif]-->
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<title><?php echo $advertiser_resmainRecord['page_title'] ?></title>
<meta name="description" content="<?php echo $advertiser_resmainRecord['page_description'] ?> " />
<meta name="keywords" content="<?php echo $advertiser_resmainRecord['page_keywords'] ?> " />
<link href="../../css/boilerplate.css" rel="stylesheet" type="text/css">
<link href="../../css/main.css" rel="stylesheet" type="text/css">
<link href="../../css/new.css" rel="stylesheet" type="text/css">
<link href="../../css/meganizr.css" rel="stylesheet" type="text/css">
<!--[if lt IE 9]><link href="responsive/meganizr-ie.css" rel="stylesheet" type="text/css"><![endif]-->

<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

<script src="../../jsnew/respond.min.js"></script>
<script type="text/javascript" src="//use.typekit.net/lzt6wua.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
<script src="../../js/google.js" type="text/javascript"></script>
</head>
<body>
<div class="gridContainer clearfix">
  <div id="headertop">
  <div id="news"><? include "C:/Inetpub/charlotteparent/templates/headernews.php"; ?> <!--End news--></div>
    <div id="info-social"><? include "C:/Inetpub/charlotteparent/templates/headerinfo-social.php"; ?><!--End info-social--></div>
    <div id="search"> <?php  include "C:/Inetpub/charlotteparent/templates/search.php"; ?></div>
  <!--End headertop--></div>
  
  <div id="header">
    <div id="adres"><? include "C:/Inetpub/charlotteparent/templates/headeradres.php"; ?><!--End adres--></div>
    <div id="logo"><? include "C:/Inetpub/charlotteparent/templates/headerlogo.php"; ?><!--End logo--></div>
    <div id="ad"><?php echo $advertiser_resmainRecord['banner_ad'] ?><!--End ad--></div>
  <!--End header--></div>
  <div id="logo-res"><? include "C:/Inetpub/charlotteparent/templates/headerlogores.php"; ?><!--End logo-res--></div>
  
 <div id="nav"><? include "C:/Inetpub/charlotteparent/templates/newnavigation.php"; ?> <!--End nav--></div>
 <div id="tablet-nav"><? include "C:/Inetpub/charlotteparent/templates/tabletnav.php"; ?> <!--End res-nav--></div>
  <div id="responsive-nav"><? include "C:/Inetpub/charlotteparent/templates/resnav.php"; ?> <!--End res-nav--></div>

  
<div id="article">
<div id="breadcrumb"><script type="text/javascript" src="../../js/MPBackLinks.js"></script></div>
<div id="page-header"><h1><?php echo $advertiser_resmainRecord['title'] ?></h1></div>
<div id="divider"><img src="../../imagesnew/newdivider1.jpg" alt="divider"></div>

<div id="content" >
  <?php echo $advertiser_pageRecord['account_content']; ?>
  <br><br><br>
 
 <?php if (@$errorsAndAlerts): ?>
    <div style="color: red; font-weight: bold; font-size: 14px; font-family: arial;"><br/>
      <?php echo $errorsAndAlerts; ?><br/>
    </div>
  <?php endif ?>

 <form action="?" method="post">
  <input type="hidden" name="updateAccount" value="1">
  <input type="hidden" name="tab" value="5">
    
   <div id="divider">
 <h3 class="diagonal-header"><span>Personal Details</span></h3> </div>
 
<div class="form-label">Full Name:&nbsp;*</div>
<div class="form-field"> <input name="fullname" style="width: 200px;" type="text" value="<?php echo @$CURRENT_USER['fullname']; ?>" /></div>

<div class="form-label">Business Name:&nbsp;*</div>
<div class="form-field"> <input name="business_name" style="width: 290px;" type="text" value="<?php echo @$CURRENT_USER['business_name']; ?>" /></div>

<div class="form-label">Phone:&nbsp;*</div>
<div class="form-field"> <input name="phone" style="width: 290px;" type="text" value="<?php echo @$CURRENT_USER['phone']; ?>" /></div>

<div class="form-label">Zip:&nbsp;*</div>
<div class="form-field"> <input name="zip" style="width: 290px;" type="text" value="<?php echo @$CURRENT_USER['zip']; ?>" /></div>
  
 <div id="divider">
<h3 class="diagonal-header"><span>Account Details</span></h3></div>

<div class="form-label">Email:&nbsp;*</div>
<div class="form-field"> <input name="email" style="width: 290px;" type="text" value="<?php echo @$CURRENT_USER['email']; ?>" /></div>

 <div class="form-label">Username:</div>
  <div class="form-field">   <input type="text" name="username" value="<?php echo htmlspecialchars(@$CURRENT_USER['username']); ?>" size="50" /></div>
  
  <div class="form-label">Current Password:</div>
  <div class="form-field">    <input type="password" name="oldPassword" value="<?php echo htmlspecialchars(@$_REQUEST['oldPassword']); ?>" size="50" /></div>
  
  <div class="form-label">New Password:</div>
  <div class="form-field">    <input type="password" name="newPassword1" value="<?php echo htmlspecialchars(@$_REQUEST['newPassword1']); ?>" size="50" /></div>
  
  <div class="form-label">New Password (again):</div>
  <div class="form-field">    <input type="password" name="newPassword2" value="<?php echo htmlspecialchars(@$_REQUEST['newPassword2']); ?>" size="50" /></div>
  
    <div class="form-field-full"><input name="submit" type="submit" value="Update" /></div>
</form>

 <!--  END content--></div>

<div id="deleteacc">
<span class="red">Delete Account</span>
  <p>If you want to delete your account you can do so here.<br/>
  Please note that all data will be lost and this is irreversible.<br><br></p>

  <form method="post" action="?" onsubmit="return confirm('Are you sure you want to delete your account?')">
  <input type="submit" name="deleteAccount" value="Delete Account" />
  </form>
</div>
  <!--End article--></div>
   
    <div id="aside">
  <div id="sponsor-adres">
<img src="http://www.charlotteparent.com/imagesnew/advertisement.jpg"  alt=""/><br><br>
<?php echo $advertiser_resmainRecord['mobilead_1'] ?>
   <?php echo $advertiser_resmainRecord['mobilead_2'] ?>
   <?php echo $advertiser_resmainRecord['mobilead_3'] ?>
   <div class="ad-divider">&nbsp;</div></div>   
   
 <div id="toggle">
	  <h3><a href="#"><?php echo $menu_newRecord['sidebar_directoriestext'] ?></a></h3>
		<div><ul class="toggle-list">
                        <?php foreach ($directories_menuRecords as $record): ?>
                            <li><a href="<?php echo $record['dirurl'] ?>"><?php echo $record['title'] ?></a></li>
                          <?php endforeach; ?>                           
                        </ul></div></div>
    <div id="toggle">
		<h3><a href="#"><?php echo $menu_newRecord['sidebar_publicationstext'] ?></a></h3>
		<div><ul class="toggle-list">
                       <?php foreach ($publicationsmenuRecords as $record): ?>
                            <li><a href="<?php echo $record['puburl'] ?>"><?php echo $record['title'] ?></a></li>
                            <?php endforeach; ?>                            
                        </ul></div></div>
                        
 <!----Ads---->                       
    <div class="aside-ads">

<?php echo $advertiser_resmainRecord['tower_ad1'] ?>
<?php echo $advertiser_resmainRecord['tower_ad2'] ?>
<?php echo $advertiser_resmainRecord['tower_ad3'] ?></div>

  
 <!----Global Text Area---->
<div class="container">
 <h3 class="green"><?php echo $globalRecord['title_text'] ?></h3>
<div class="container-content">
		<?php foreach ($globalRecord['photo'] as $upload): ?>
          <?php if ($upload['isImage']): ?> 
            <div class="center"><img src="<?php echo $upload['urlPath'] ?>" title="<?php echo $upload['info1'] ?>" /></div><br/><br />

          <?php endif ?>
        <?php endforeach ?>
        <p><?php echo $globalRecord['content_text'] ?></p>
       
</div></div> 

<div id="newsres"><? include "C:/Inetpub/charlotteparent/templates/headernewsressec.php"; ?> <!--End newsres--></div>
 <div id="info-socialres">
<a  href="https://www.facebook.com/cltparent"><img src="../../imagesnew/facebook-icon.png" class="info-icon"></a>
<a href="https://twitter.com/CharlotteParent"><img src="../../imagesnew/twitter-icon.png" class="info-icon" ></a>
<a  href="http://pinterest.com/charlotteparent/"><img src="../../imagesnew/pinterest-icon.png" class="info-icon"></a>

<!--End info-social--></div>
  <!--End aside--></div>
    <!--End grid--></div>
    
 <div id="footerwrapper">
<div class="gridContainer clearfix">
    <div id="footer">
    	<div id="footerlft"><? include "C:/Inetpub/charlotteparent/templates/footerlft.php"; ?></div>
     	<div id="footerrgt"><? include "C:/Inetpub/charlotteparent/templates/footerrgt.php"; ?></div>
     	<div id="footerrgttab"><? include "C:/Inetpub/charlotteparent/templates/footerrgttab.php"; ?></div>
    <!--End footer--></div>
    <div id="responsive-footer"><? include "C:/Inetpub/charlotteparent/templates/resfooter.php"; ?> <!--End res-footer--></div>
    
    <div id="copyright"><?php echo $globalRecord['copyright'] ?> <!--End copyright--></div>
    
 <!--End grid--></div>
<!--End footerwrapper--></div>

<!-- Share This Scripts -->
<script type="text/javascript">var switchTo5x=true;</script>
<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
<script type="text/javascript">stLight.options({publisher: "19f48c6c-364e-4e0a-9e27-f4b71609270b", doNotHash: false, doNotCopy: false, hashAddressBar: false});</script>

<!-- Meganizr Scripts -->
<script src="../../jsnew/meganizr.js"></script>

<!-- jquery -->	
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="../../jsnew/jquery.ui-custom.js"></script>
<script src="../../jsnew/jquery.easing.1.3.js"></script>
<script src="../../jsnew/scripts.js"></script>

	<!-- easing plugin ( optional ) -->
	<script src="../../jsnew/easing.js" type="text/javascript"></script>
	<!-- UItoTop plugin -->
	<script src="../../jsnew/jquery.ui.totop.js" type="text/javascript"></script>
	<!-- Starting the plugin -->
	<script type="text/javascript">
		$(document).ready(function() {
			/*
			var defaults = {
	  			containerID: 'toTop', // fading element id
				containerHoverID: 'toTopHover', // fading element hover id
				scrollSpeed: 1200,
				easingType: 'linear' 
	 		};
			*/
			
			$().UItoTop({ easingType: 'easeOutQuart' });
			
		});
	</script>

 <script type="text/javascript"> 
var $buoop = {} 
$buoop.ol = window.onload; 
window.onload=function(){ 
 try {if ($buoop.ol) $buoop.ol();}catch (e) {} 
 var e = document.createElement("script"); 
 e.setAttribute("type", "text/javascript"); 
 e.setAttribute("src", "http://browser-update.org/update.js"); 
 document.body.appendChild(e); 
} 
</script> 
</body>
</html>