<?php
   require_once "cmsAdmin/lib/viewer_functions.php";

 require_once('recaptchalib.php');
   $publickey  = "6LfoUdsSAAAAAIjgGaQQti4oZUG7pQkf9SDr9QcM";
   $privatekey = "6LfoUdsSAAAAAO5ACmDPhtZ9--N2kZTaJge5SUuZ";
   
 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',
  ));  
  
   $tmpQueryString          = $_SERVER['QUERY_STRING'];
$queryArray              = explode("&", $_SERVER['QUERY_STRING']); 
$_SERVER['QUERY_STRING'] = $queryArray[0]; 

  list($articlesRecords, $articlesMetaData) = getRecords(array(
    'tableName'   => 'articles',
   'where'       => whereRecordNumberInUrl(1),
    'limit'       => '1',
    'allowSearch' => true,
    //'debugSql'    => true
  ));
  $articlesRecord = @$articlesRecords[0]; // get first record
  
  $_SERVER['QUERY_STRING'] = $tmpQueryString;

  list($article_mainRecords, $article_mainMetaData) = getRecords(array(
    'tableName'   => 'article_main',
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $article_mainRecord = @$article_mainRecords[0]; // get first record
  /*
   list($articlesRecords, $articlesMetaData) = getRecords(array(
    'tableName'   => 'articles',
  ));
   */
   list($article_categoryRecords, $article_categoryMetaData) = getRecords(array(
    'tableName'   => 'article_category',
  ));
   
    $where = "";  
   $articleCategories = array();
   
   $articleCategories = explode("\t", trim($articlesRecord['category'], "\t"));
   
   foreach ($articleCategories as $category) {  
   $where .= " category LIKE '%\t$category\t%' OR"; 
   }    
   
   $where = rtrim($where, "OR"); //remove the last "OR" 
   
   if ($where) { 
   $where = "($where) AND num != '".intval($articlesRecord['num'])."'";  
   }
   else {   
   $where = "num != '".intval($articlesRecord['num'])."'"; 
   }   
   
   list($relatedArticle, $relatedArticlesMetaData) = getRecords(array(    
	  'tableName'   =>  'articles',    
	  'allowSearch' =>   false,   
	  'limit'       =>   5,    
	  'orderBy'     =>   'RAND()',   
	  'where'       =>   $where, 
	  ));
  
  list($globalRecords, $globalMetaData) = getRecords(array(
    'tableName'   => 'global',
    'allowSearch' => '0',
    'limit'       => '1',
  ));
  $globalRecord = @$globalRecords[0]; // get first record
  
#####

$errorsAndAlerts = "";


if (@$_REQUEST['addAnnonymousComment']) {
  
   
   // error checking
   if (!@$_REQUEST['name']) 					{ $errorsAndAlerts .= "You Must Enter Your Name<br/>"; }
   if (!@$_REQUEST['email']) 					{ $errorsAndAlerts .= "You Must Enter Your Email<br/>"; }
   else if(!isValidEmail(@$_REQUEST['email'])) 			{ $errorsAndAlerts .= "Please enter a valid email (example: user@example.com)<br/>\n"; }
   if (!@$_REQUEST['comment']) 					{ $errorsAndAlerts .= "You Must Enter A Comment<br/>"; }
   
    if (!@$_REQUEST['recaptcha_response_field'])          	{ $errorsAndAlerts .= "You Must Enter A Captcha Response<br/>\n"; }
    elseif (@$_REQUEST['recaptcha_response_field'])       {
      $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_REQUEST["recaptcha_challenge_field"], $_REQUEST["recaptcha_response_field"]);
      if (!$resp->is_valid) {
        $errorsAndAlerts .= "Incorrect Value For Captcha, Please Try Again.<br/>";
      }
      $captchaError = $resp->error;
    }

   // clear all errors for quicker testing
  // $errorsAndAlerts = "";
   
   // add annonymous comment
   if (!$errorsAndAlerts) {
      
    
     // name email comment createdDate createdByUserNum tableOrTag  recordNum
      
      $commentText = trim($_REQUEST['comment']) . "\n\nPosted By: ". $_REQUEST['name'];
      
     $commentNum =  mysql_insert('_wsc_comments', array(	      'name' 				 	=> @$_REQUEST['name'],
						      'email' 				 	=> @$_REQUEST['email'],
						      'comment'			       		=> @$commentText,
						      'tableOrTag' 			 	=> 'articles' ,
						      'recordNum' 			 	=> @$articlesRecord['num'],
						      'createdDate='		 	 	=> 'NOW()',
						      'posted_anonymously' 	         	=> '1',
						      'createdByUserNum'	 		=> '1'
							       ) );
     
     $tableOrTag = "articles";
     
     $pageURL = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
     
     $placeholders = array(
	 'user.email'       => @$_REQUEST['email'],
	 'user.name'        => @$_REQUEST['name'],
	 'commentPageName'  => @$blogsRecord['title'],
	 'commentPageUrl'   => "http://carolinaparent.com/newarticlemain.php?". $commentNum,
	 'commentAdminUrl'  => $GLOBALS['SETTINGS']['adminUrl'] . "?menu=_wsc_comments&action=edit&num=" . $commentNum,
	 'commentText'      => @$_REQUEST['comment'],
	 'unsubscribeUrl'   => array_value( explode('?', $pageURL), 0)
			  . wsc_thread_getLink($tableOrTag, $articlesRecord['num'], 'wsc_thread_unsubscribe', $pageURL),
      );
    
    
      // email admin
      $errors = sendMessage(emailTemplate_loadFromDB(array(
	    'template_id'      => 'ARTICLE-GUEST-COMMENT-ADDED',
	    'placeholders'     => $placeholders,
      )));
      if ($errors) { die("Error sending message: $errors\n\nPlease let us know about this error!"); }
	
        header ("Location: newarticlemain.php?commentAdded=1&". $articlesRecord['num']);   
        }
   
}



if (@$_REQUEST['commentAdded']) 			{$errorsAndAlerts = "Your Comment Has Been Added";}


?>
  
   <!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 $articlesRecord['title'] ?></title>
<meta name="description" content="<?php echo htmlentities(strip_tags($articlesRecord['summary']), ENT_COMPAT, 'cp1251') ?>" />
<meta name="keywords" content="<?php echo $article_mainRecord['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/pah5lhn.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/carolinaparent/templates/headernews.php"; ?> <!--End news--></div>
    <div id="info-social"><? include "C:/Inetpub/carolinaparent/templates/headerinfo-social.php"; ?><!--End info-social--></div>
<div id="search"><? include "C:/Inetpub/carolinaparent/templates/search.php"; ?></div>
  <!--End headertop--></div>
  
  <div id="header">
    <div id="adres"><? include "C:/Inetpub/carolinaparent/templates/headeradres.php"; ?><!--End adres--></div>
    <div id="logo"><? include "C:/Inetpub/carolinaparent/templates/headerlogo.php"; ?><!--End logo--></div>
    <div id="ad"><?php echo $article_mainRecord['banner_ad'] ?><!--End ad--></div>
  <!--End header--></div>
    <div id="logo-res"><? include "C:/Inetpub/carolinaparent/templates/headerlogores.php"; ?><!--End logo-res--></div>
    
   <div id="nav"><? include "C:/Inetpub/carolinaparent/templates/newnavigation.php"; ?> <!--End nav--></div>
 <div id="tablet-nav"><? include "C:/Inetpub/carolinaparent/templates/tabletnav.php"; ?> <!--End res-nav--></div>
  <div id="responsive-nav"><? include "C:/Inetpub/carolinaparent/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 $articlesRecord['title'] ?></h1></div>
<div id="divider"><img src="imagesnew/newdivider1.jpg" alt="divider"></div>


<div id="content">
 <?php if ($articlesRecord['author']): ?>  
 <strong>Written by:</strong>&nbsp;&nbsp;<?php echo $articlesRecord['author'] ?><br />
<?php endif ?>
<?php if ($articlesRecord['date']): ?> 
<strong>Date:</strong>&nbsp;<?php echo date("F j, Y ", strtotime($articlesRecord['date'])) ?><br><br>
<?php endif ?>


    <?php foreach ($articlesRecord['photo'] as $upload): ?>
          <?php if ($upload['isImage']): ?>
            <img class="backdropshadow" src="<?php echo $upload['urlPath'] ?>" title="<?php echo $upload['info1'] ?>" align="left"/><?php endif ?>
      <?php endforeach ?> <p><?php echo string_ireplace( '</p>', '<br />', $articlesRecord['content']); ?></p> 

      <br><br>

  <div id="social-printimg"><a href="http://www.carolinaparent.com/articleprint.php?-<?PHP echo $articlesRecord['num'] ?>"><img src="images/printericon.png" alt="print" /></a></div>
 <div id="social-print"><a href="http://www.carolinaparent.com/articleprint.php?-<?PHP echo $articlesRecord['num'] ?>">Print Article</a></div>   
 <div id="social-facebook">
 <span class='st_facebook_hcount' displayText='Facebook'></span></div>
 <div id="social-twitter"><span class='st_twitter_hcount' displayText='Tweet'></span></div>
 <div id="social-pinterest"><span class='st_pinterest_hcount' displayText='Pinterest'></span></div>
 <div id="social-open"></div>
<div id="social-google"><span class='st_googleplus_hcount' displayText='Google +'></span></div>
 <div id="social-email"><span class='st_email_hcount' displayText='Email'></span></div>
    <br><br><br><img src="images/middledivider.jpg"><br><br>
    <?php
    wsc_comments(array(
      'tableOrTag' => 'article',               				// Section these comments are associated with, such as: "articles", "blog", "about_us".
      'recordNum'  => $articlesRecord['num'],            		// Record num these comments are associated with, such as: $record['num'] or 1
      'themeName'  => 'custom',               		 	     	// HTML theme to display comments with, from /plugins/websiteComments/themes
      'pageName'   => $articlesRecord['title'],           		// Page name displayed in comment notification emails, such as: $record['title'] or "Custom Text"
      'pageUrl'    => realurl($articlesRecord['_link']), 		// Page URL displayed in comment notification emails, such as realurl($record['_link'])
    ));
  ?>
  <!-- /DISPLAY COMMENTS -->



<a name="topOfComments"></a>

  <!-- DISPLAY COMMENTS -->
   
   <?php if (!$CURRENT_USER): ?>
   
   
 
   
   
<h3>Add your comment:</h3><br/>

  Add your own comment using the guest form below , or <a href="/membership/article-user-login.php?articleNumber=<?php echo $articlesRecord['num']; ?>">login</a>
    /  <a href="/membership/article-user-signup.php?articleNumber=<?php echo $articlesRecord['num']; ?>">sign-up</a> to comment using a carolinaparent.com user account and subscribe to email updates for additional comments to this post.<br/><br/>

 
      <?php if (@$errorsAndAlerts): ?>
      <div style="color: red; font-weight: bold; font-size: 16px;"><br/>
	<?php echo $errorsAndAlerts; ?><br/><br/>
      </div>
   <?php endif ?>
 
    <form method="post" action="?#topOfComments">
      
	 <input type='hidden' name='addAnnonymousComment' value='1'>
	 <input type='hidden' name='tableOrTag'  value='article'>
	 
	 <table>
	    <tr>
	       <td>
		  Name:
	       </td>
	       <td>
		  <input type="text" name="name" value="<?php echo @$_REQUEST['name']; ?>">
	       </td>
	    </tr>
	    <tr>
	       <td>
		  Email:
	       </td>
	       <td>
		  <input type="text" name="email" value="<?php echo @$_REQUEST['email']; ?>">&nbsp; <em>Email address will not display on website.</em></td>
	    </tr>
	 </table>
	 <br/>
	 <textarea name="comment" rows="4" cols="55"><?php echo @$_REQUEST['comment']; ?></textarea><br/>
	 
	<?php echo recaptcha_get_html($publickey, @$captchaError); ?>
	 
	 <br/>
     
      <input type="submit" name="submitForm" value="Add Comment!"/>
	 <input type='hidden' name='articleRecord' value='<?php echo $articlesRecord['num']; ?>'>
	
    </form>

<br/>

  <?php if (!$CURRENT_USER): ?>
  

  <?php endif ?>
    
<?php endif ?>   <!--End content--></div>
  <!--End article--></div>
  
  <div id="aside">
 <div id="sponsor-adres">
	<img src="imagesnew/advertisement.jpg"  alt=""/><br><br>
     <?php echo $article_mainRecord['mobilead_1'] ?>
   <?php echo $article_mainRecord['mobilead_2'] ?>
   <?php echo $article_mainRecord['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 $article_mainRecord['tower_ad1'] ?>
<?php echo $article_mainRecord['tower_ad2'] ?>
<?php echo $article_mainRecord['tower_ad3'] ?></div>


 <!----Related Articles---->
 <div class="container">
 <h3 class="green">Related Articles</h3>
<div class="container-content">
 <?php foreach ($relatedArticle as $record): ?>
<ul class="related-list">
			<li><a href="<?php echo $record['_link'] ?>" class="linkstar"><?php echo $record['title'] ?></a></li>
	    	
</ul><?php endforeach; ?>
</div>
</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/carolinaparent/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/carolinaParent"><img src="../imagesnew/twitter-icon.png" class="info-icon" ></a>
<a  href="http://pinterest.com/carolinaparent/"><img src="../imagesnew/pinterest-icon.png" class="info-icon"></a>
<a  href="https://plus.google.com/u/0/111016494087538206990/posts"><img src="imagesnew/google-icon.jpg" 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/carolinaparent/templates/footerlft.php"; ?></div>
     	<div id="footerrgt"><? include "C:/Inetpub/carolinaparent/templates/footerrgt.php"; ?></div>
     	<div id="footerrgttab"><? include "C:/Inetpub/carolinaparent/templates/footerrgttab.php"; ?></div>
    <!--End footer--></div>
    <div id="responsive-footer"><? include "C:/Inetpub/carolinaparent/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="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="../jsnew/meganizr.js"></script>
<!-- end Meganizr Scripts -->

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