 <?php
   require_once "C:/Inetpub/charlotteparent/cmsAdmin/lib/viewer_functions.php";
   if (!$CURRENT_USER) { redirectBrowserToURL("/advertising/resources/advertiser-login.php"); }
   
    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 
  
   list($directory_membershipRecords, $directory_membershipMetaData) = getRecords(array(
    'tableName'   => 'directory_membership',
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $directory_membershipRecord = @$directory_membershipRecords[0]; // get first record
  
  list($dir_categoriesRecords, $dir_categoriesMetaData) = getRecords(array(
    'tableName'   => 'dir_categories',

	  ));
	  

	  
  // This form requires: CMSB v2.04 Build 1
 require_once "C:/Inetpub/charlotteparent/cmsAdmin/lib/viewer_functions.php";
  $tableName       = 'dir_listings';
  $recordNum       = null; // you must set either $recordNum or $preSaveTempId to null
  $preSaveTempId   = @$_REQUEST['preSaveTempId'] ? $_REQUEST['preSaveTempId'] : uniqid('x');
  $errorsAndAlerts = '';

  ### upload actions
  if (@$_REQUEST['submitForm'] && !preg_match("/multipart\/form-data/", @$_SERVER['CONTENT_TYPE'])) { die("Upload Error: &lt;form&gt; tag must have enctype=\"multipart/form-data\""); }
    foreach (getUploadInfoArrays() as $uploadInfo) { // add uploads
    $errorsAndAlerts .= saveUpload($tableName, $uploadInfo['_fieldname'], $recordNum, $preSaveTempId, $uploadInfo, $newUploadNums);
  }
  if (@$_REQUEST['removeUpload']) { // delete upload
    $uploadNum = @$_REQUEST['removeUpload'];
    removeUpload($uploadNum, $recordNum, $preSaveTempId);
  }

  ### insert record
  $onlyUploadAction = @$_REQUEST['submitUpload'] || @$_REQUEST['removeUpload']; // don't save the record when the user uploads a file
  if (@$_REQUEST['submitForm'] && !$onlyUploadAction) {

    // error checking
	
	if (!@$_REQUEST['title'])    { $errorsAndAlerts .= "*Required: Please specify a title!<br/>\n"; }
	if (!@$_REQUEST['address'])    { $errorsAndAlerts .= "*Required: Please specify a address!<br/>\n"; }
	if (!@$_REQUEST['url'])    { $errorsAndAlerts .= "*Required: Please specify a website!<br/>\n"; }
	if (!@$_REQUEST['phone'])    { $errorsAndAlerts .= "*Required: Please specify a phone number!<br/>\n"; }
	if (!@$_REQUEST['county'])    { $errorsAndAlerts .= "*Required: Please specify a county!<br/>\n"; }
	if (!@$_REQUEST['county'])    { $errorsAndAlerts .= "*Required: Please specify a county!<br/>\n"; }
	if (!@$_REQUEST['summary'])    { $errorsAndAlerts .= "*Required: Please enter a description!<br/>\n"; }
	if (!@$_REQUEST['email_address'])    { $errorsAndAlerts .= "*Required: Please specify an e-mail address!<br/>\n"; }
	if (!@$_REQUEST['contact_phone'])    { $errorsAndAlerts .= "*Required: Please specify a phone number!<br/>\n"; }
	if (@$_REQUEST['category'] == "Family Dining") 
		if (!@$_REQUEST['eat_free'])    { $errorsAndAlerts .= "*Required: Please specify Yes or No!<br/>\n"; }
	
	
	
    // update record
    if (!@$errorsAndAlerts) {
      mysqlStrictMode(false); // disable Mysql strict errors for when a field isn't defined below (can be caused when fields are added later)
      $query = "INSERT INTO `{$TABLE_PREFIX}$tableName` SET
                    createdDate      = NOW(),
                    createdByUserNum = '" .intval( @$CURRENT_USER['num'] ). "',
                    updatedDate      = NOW(),
                    updatedByUserNum = '" .intval( @$CURRENT_USER['num'] ). "',
					publishDate      = NOW(),
					date      = NOW(),
					hidden = '1',
					reg_listing = '1',
					url_link = '0',
					neverRemove = '1',
					
					category	 			= '" .mysql_escape( @$_REQUEST['category'] ). "',
					contact_name         	= '".mysql_escape(@$_REQUEST['contact_name'])."',
					contact_phone       	= '".mysql_escape(@$_REQUEST['contact_phone'])."',
					title         			= '".mysql_escape(@$_REQUEST['title'])."',
					address         		= '".mysql_escape(@$_REQUEST['address'])."',
					city         			= '".mysql_escape(@$_REQUEST['city'])."',
					state         			= '".mysql_escape(@$_REQUEST['state'])."',
					zipcode         		= '".mysql_escape(@$_REQUEST['zipcode'])."',
					phone         			= '".mysql_escape(@$_REQUEST['phone'])."',
					summary         		= '".mysql_escape(@$_REQUEST['summary'])."',
					email_address			= '".mysql_escape(@$_REQUEST['email_address'])."',
					county         		= '".mysql_escape(@$_REQUEST['county'])."',
					ages         			= '".mysql_escape(@$_REQUEST['ages'])."',
					fees        			= '".mysql_escape(@$_REQUEST['fees'])."',
					eat_free        		= '".mysql_escape(@$_REQUEST['eat_free'])."',
					hours         			= '".mysql_escape(@$_REQUEST['hours'])."',
					program_ed        	= '".mysql_escape(@$_REQUEST['program_ed'])."',
					days 					= '".mysql_escape(@$_REQUEST['days'])."',
					url         			= '".mysql_escape(@$_REQUEST['url'])."'";
									
					
					
					mysql_query($query) or die("MySQL Error:<br/>\n". htmlspecialchars(mysql_error()) . "\n");
      $recordNum = mysql_insert_id();

      // adopt temp uploads
      adoptUploads($tableName, $preSaveTempId, $recordNum);
      removeExpiredUploads(); // erase old expired uploads

   // display thanks message and clear form
      $errorsAndAlerts = "Thanks, we've added your record!";
      $preSaveTempId = uniqid('x');
      $recordNum     = null;
	  

 // send message

      $placeholders = array(
	'user.email'       => $_REQUEST['email_address'],
	'user.fullname'    => $_REQUEST['contact_name'],
	'category'          => $_REQUEST['category'],
	'title'          	  => $_REQUEST['title'],
	'summary'          => $_REQUEST['summary'],
	'directoryAdminUrl'  => $GLOBALS['SETTINGS']['adminUrl'] . "?menu=dir_listings",

      );

       // email admin

      $errors = sendMessage(wsc_emailTemplate_loadFromDB(array(
	'template_id'      => 'DIRECTORY-ENTRY-ADDED',
	'placeholders'     => $placeholders,

      )));

      if ($errors) { die("Error sending message: $errors\n\nPlease let us know about this error!"); }


    // send message

      $placeholders = array(
	'user.email'       => $_REQUEST['email_address'],
	'user.fullname'    => $_REQUEST['contact_name'],
	'category'          => $_REQUEST['category'],
	'title'          	  => $_REQUEST['title'],
	'summary'          => $_REQUEST['summary'],
	

      );

       // email admin

      $errors = sendMessage(wsc_emailTemplate_loadFromDB(array(
	'template_id'      => 'DIRECTORY-ENTRY-USER',
	'placeholders'     => $placeholders,

      )));

      if ($errors) { die("Error sending message: $errors\n\nPlease let us know about this error!"); }

  }

  }  
  
 
?>
<!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 $directory_membershipRecord['page_title'] ?></title>
<meta name="description" content="<?php echo $directory_membershipRecord['page_description'] ?>" />
<meta name="keywords" content="<?php echo $directory_membershipRecord['page_keywords'] ?>" />
<link href="boilerplate.css" rel="stylesheet" type="text/css">
<link href="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">
<link href="view.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>
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="hide.js"></script>
<script src="view.js"></script>

<script type="text/javascript" charset="utf-8" src="word.js"></script>
	<script type="text/javascript" charset="utf-8">
		$(document).ready(function()
		{
		  $('#demo1').simplyCountable();
		 		});
	</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"><? 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 $directory_membershipRecord['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>Free directory Listing Form</h1></div>
<div id="divider"><img src="../imagesnew/newdivider1.jpg" alt="divider"></div>

<div id="content">

   <?php if (@$errorsAndAlerts): ?>
   <div style="color: red; font-weight: bold; font-size: 16px;"><br/>
    <?php echo $errorsAndAlerts; ?>
  </div>
<?php endif ?>

<span class="red">* = Required</span><br />
<br /> 

<div class="content">
  <h3 class="diagonal-header"><span><img src="../imagesnew/step1_30.png" vertical-align="text-top" alt=""/> - Listing Details</span></h3><br> </div>

<form method="post" name="uploadForm"  action="?preSaveTempId=<?php echo $preSaveTempId ?>" enctype="multipart/form-data" class="appnitro" >
<p>

 
  <input type="hidden" name="submitForm" value="1" />
  <input type="hidden" name="num" value="<?php echo $recordNum ?>" />
  <input type="hidden" name="preSaveTempId" value="<?php echo $preSaveTempId ?>" />
  <input type="hidden" name="removeUpload" id="removeUpload" value="0" />
  
<div class="formcp"><div class="form-label"><span class="red">*</span>Listing Name:</div>
<div class="form-field"><input class="text-input medium-input" type="text" name="title" value="<?php echo htmlspecialchars(@$_REQUEST['title']) ?>" size="50" /></div></div>

<div class="form-label"><span class="red">*</span>Website:</div>
<div class="form-field"><input class="text-input medium-input" type="text" name="url" value="<?php echo htmlspecialchars(@$_REQUEST['url']) ?>" size="50" /></div>

<div class="form-label"><span class="red">*</span>Address:</div>
<div class="form-field"><input class="text-input medium-input" type="text" name="address" value="<?php echo htmlspecialchars(@$_REQUEST['address']) ?>" size="50" /></div>

<div class="form-label">City:</div>
<div class="form-field"><input class="text-input medium-input" type="text" name="city" value="<?php echo htmlspecialchars(@$_REQUEST['city']) ?>" size="50" /></div>

<div class="form-label">State:</div>
<div class="form-field"><input class="text-input medium-input" type="text" name="state" value="<?php echo htmlspecialchars(@$_REQUEST['state']) ?>" size="50" /></div>

<div class="form-label">Zipcode:</div>
<div class="form-field"><input class="text-input medium-input" type="text" name="zipcode" value="<?php echo htmlspecialchars(@$_REQUEST['zipcode']) ?>" size="50" /></div>

<div class="form-label"><span class="red">*</span>Phone:</div>
<div class="form-field"><input class="text-input medium-input" type="text" name="phone" value="<?php echo htmlspecialchars(@$_REQUEST['phone']) ?>" size="50" /></div>

<div class="form-label"><span class="red">*</span>County:</div>
<div class="form-field">
<select name="county">
<option value = "">-Select-</option>
<?php foreach (getListOptions($tableName, 'county') as $value => $label): ?>
<option value = "<?php echo htmlspecialchars($value);?>" <?php selectedIf($value, @$_REQUEST['county']);?>> <?php echo htmlspecialchars($label);?> </option>
<?php endforeach ?>
</select></div>

<div class="form-label"><span class="red">*</span>Brief Description:</div>
<div class="form-field">
<textarea id="demo1"  rows="5" cols="50" type="text" name="summary" value="<?php echo htmlspecialchars(@$_REQUEST['summary']) ?>" size="50" /></textarea><br>
<p>35 word limit. You have <span id="counter"></span> words left.</p></div>
<p class="guidelines" id="guide_5"><small>35 word limit. </small></p>



<div class="content"><br>
<h3 class="diagonal-header"><span><img src="../imagesnew/step2.png" alt=""/>  - Select a Category:</span></h3><br></div>

 <div class="form-label"><span class="red">*</span>Category:</div>
<div class="form-field" id="category">

<select name="category">
<option value = "">-Select-</option>
<?php foreach (getListOptions($tableName, 'category') as $value => $label): ?>
<option value = "<?php echo htmlspecialchars($value);?>" <?php selectedIf($value, @$_REQUEST['category']);?>> <?php echo htmlspecialchars($label);?> </option>
<?php endforeach ?>
</select> </div>


<div class="content"><br><br>
<h3 class="diagonal-header"><span><img src="../imagesnew/step3.png" alt=""/>  - Other</span></h3><br></div>

<div class="form-label"><span class="red">*</span>Contact Name:</div>
<div class="form-field"><input class="text-input medium-input" type="text" name="contact_name" value="<?php echo htmlspecialchars(@$_REQUEST['contact_name']) ?>" size="50" /></div>

<div class="form-label"><span class="red">*</span>Contact Email:</div>
<div class="form-field"><input class="text-input medium-input" type="text" name="email_address" value="<?php echo htmlspecialchars(@$_REQUEST['email_address']) ?>" size="50" /></div>

<div class="form-label"><span class="red">*</span>Contact Phone:</div>
<div class="form-field"><input class="text-input medium-input" type="text" name="contact_phone" value="<?php echo htmlspecialchars(@$_REQUEST['contact_phone']) ?>" size="50" /></div>

<div id="ages" style="display: none;">
 <div class="form-label">Ages:</div>
<div class="form-field"><input class="text-input medium-input" type="text" name="ages" value="<?php echo htmlspecialchars(@$_REQUEST['ages']) ?>"  size="50" /></div></div>

<div id="fees" style="display: none;">
 <div class="form-label">Fees:</div>
<div class="form-field"><input class="text-input medium-input" type="text" name="fees" value="<?php echo htmlspecialchars(@$_REQUEST['fees']) ?>"  size="50" /></div></div>

<div id="eat_free" style="display: none;">
 <div class="form-label"><span class="red">*</span>Program Type:</div>
<div class="form-field">
<select name="eat_free" > 
<option value = "">-Select-</option>
<?php foreach (getListOptions($tableName, 'eat_free') as $value => $label): ?>
<option value = "<?php echo htmlspecialchars($value);?>" <?php selectedIf($value, @$_REQUEST['eat_free']);?>> <?php echo htmlspecialchars($label);?> </option>
<?php endforeach ?>
</select> </div></div>

<div id="hours" style="display: none;">
 <div class="form-label">Hours:</div>
<div class="form-field"><input class="text-input medium-input" type="text" name="hours" value="<?php echo htmlspecialchars(@$_REQUEST['hours']) ?>"  size="50" /></div></div>

<div id="days" style="display: none;">
 <div class="form-label">Days of Week:</div>
<div class="form-field">

 

</div></div>



  <div class="form-label">&nbsp;</div>
<div class="form-divider"><input class="button" id="button" type="submit" name="submitForm" value="Submit" /> </div>
</form>


 <!--End content--></div>
    
  
  <!--End article--></div>
  
  <div id="aside">


 <div id="photosponsor-adres"><?php echo $directory_membershipRecord['mobilead_1'] ?>
   <?php echo $directory_membershipRecord['mobilead_2'] ?>
   <?php echo $directory_membershipRecord['mobilead_3'] ?></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 $directory_membershipRecord['tower_ad1'] ?>
<?php echo $directory_membershipRecord['tower_ad2'] ?>
<?php echo $directory_membershipRecord['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> 

<!----Tip---->
 <div class="container">
	 <h3 class="blue"><?php echo $globalRecord['title'] ?></h3>
      <div id="quote-container">
        <blockquote>
         <img class="leftquote" src="../images/leftquote.png"><?php echo $globalRecord['content'] ?><img class="rightquote" src="../images/rightquote.png">
        </blockquote>
 
        <p><a href="<?php echo $globalRecord['link_url'] ?>"><?php echo $globalRecord['link_title'] ?></a></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>
  <div id="mmlogo"><? include "C:/Inetpub/charlotteparent/templates/footerlogo.php"; ?></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>
<!-- end Meganizr Scripts -->

<!-- jquery -->	

<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>