<?php
session_start(); 
header('Access-Control-Allow-Origin "https://www.bigmint.co"');
header('Access-Control-Allow-Credentials "true"');  
header('Access-Control-Allow-Methods "GET, POST, OPTIONS, PUT, PATCH, DELETE"');  
header('Access-Control-Allow-Headers "Origin, Content-Type, x-csrf-token, Authorization, X-Requested-With, Accept"');  

$post_id = $_REQUEST['post_id'];
$post_date = $_REQUEST['post_date'];
$cat_name = $_REQUEST['cat_name'];
$maxCount = $_REQUEST['maxCount'];

include_once('inc/config1.php');
include_once(DIR_APPLICATION . 'cf.php');
	ini_set('display_errors',1);

$from_web_host='steelmint.com';
if(isset($_REQUEST['from_web_host']) && ($_REQUEST['from_web_host']=="www.coalmint.com" || strpos($_REQUEST['from_web_host'], 'coalmint.com')!==false)){
	if(isset($_REQUEST['usessid']) && $_REQUEST['usessid']!='' && !isset($_COOKIE['uid'])){
		echo $usessid = encrypt_decrypt('decrypt', $_REQUEST['usessid']);
		$retArr = getUserServices($usessid);
		$_SESSION = $retArr; 			
		//$maxCount = getTakenServicesByUser($item, $at_palce='popup', $post_date);
	}	
	$maxCount = getTakenServicesByUser('', $at_palce='steelnews', $post_date);
	$from_web_host="coalmint.com";
}

include_once(DIR_APPLICATION . 'hf.php');
include_once(DIR_APPLICATION . 'wp_hf.php');
$open_news_list_ids = qryToCommaSepString("select GROUP_CONCAT(news_id) as news_ids from tbl_open_news where opentill > '".$currDateTime."'");
$open_news_list=array();
if($open_news_list_ids){
	$open_news_list = explode(',',$open_news_list_ids); 
}
///echo '<br>mxcnt:'.$maxCount;

$news = get_news_by_id($post_id);
$newsPrevNext = getPrevNextNews($post_id, $from_web_host);

//$content = strip_tags(htmlspecialchars_decode($news['post_content'] , ENT_QUOTES));
//$maxlength = 150;
//$content = substr($content, 0, ($spos = strpos($content, '.', $lcount = count($content) > $maxlength ? $lcount : $maxlength)) ? $spos : $lcount ).'.';
//$news['post_content'] = $content;



/* include_once(DIR_APPLICATION . 'inc/desconfig.php');	
	
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); 
require_once(DIR_APPLICATION . 'wp_hf.php'); */

//$from_web_host = isset($_REQUEST['from_web_host'])? str_replace("mint", "", strtolower($_REQUEST['from_web_host'])):'steel';

//if(intval($post_id))
//{
	//define('WP_USE_THEMES', true);
	/* define('WP_USE_THEMES', false);
	require_once(DIR_APPLICATION . 'news/wp-blog-header.php');
	header("HTTP/1.0 200 OK");
	query_posts('p='.$post_id); */
?>
<style type="text/css">
.img-circle  img{
    border-radius: 50% !important;
	max-width: none;
}
 </style>

	<!-- <link rel='stylesheet' id='upprev-css-css'  href='https://www.steelmint.com/news/wp-content/plugins/upprev/styles/upprev.css?ver=3.3.22' type='text/css' media='all' />
	<script type="text/javascript">
var iworks_upprev = { animation: 'flyout', position: 'left', offset_percent:75, offset_element: '#comments', css_width: 360, css_side: 5, compare: 'simple', url_new_window: 0, ga_track_views: 1, ga_track_clicks: 1, ga_opt_noninteraction: 1, title: 'Structure Manufacturers imposed Gauge Difference for Heavy Structure in Central India' };
</script> -->

<!--<link rel="stylesheet" href="https://www.steelmint.com/news/wp-content/plugins/rj-quickcharts/css/jquery.jqplot.css" />
<link rel="stylesheet" href="https://www.steelmint.com/news/wp-content/plugins/rj-quickcharts/css/jquery.jqplot.min.css" />
<script type='text/javascript' src='https://www.steelmint.com/news/wp-content/plugins/rj-quickcharts/js/min/rjqc-frontend-full.min.js?ver=3.8.1'></script>-->
<!--<script src="//www.google.com/jsapi" type="text/javascript"></script> -->

<!--<script src="https://www.steelmint.com/news/wp-content/plugins/visualizer/js/render.js?ver=1.4.1.1" type="text/javascript"></script>-->
<?PHP
//if ( have_posts() )   : // Check for posts
//while (have_posts() )  : the_post(); // Loop through post
//	ob_start();
	$cururl	= $news['href'];
	$ctitle	= stripslashes($news['post_title']);
	/* if($_SESSION['mid']==56350){
			echo '<pre>';print_r($newsPrevNext);echo '</pre>';
			} */
	
?>
<div class="row margin-bottom-10">
	<div class="row">
		<div class="col-sm-2 col-sm-2 padding-top-10 margin-left-30">
			<?php if($newsPrevNext['previousNews']) { ?>
				<a class="btn btn-default btn-warning" href="<?php echo $newsPrevNext['previousNews']['href']; ?>"><span>&laquo;</span> Prev News</a>
			<?php } ?>
		</div>
		<div class="col-sm-8 col-sm-8 padding-top-10 margin-left-30">			
		</div>
		<div class="col-sm-2 col-sm-2 padding-top-10 margin-left-30">
			<?php if($newsPrevNext['nextNews']) { ?>
				<a class="btn btn-default btn-warning" href="<?php echo $newsPrevNext['nextNews']['href']; ?>">Next News <span>&raquo;</span></a>
			<?php } ?>
		</div>
	</div>
	<div class="row">
		<div class="col-md-11 col-sm-10 padding-top-50 margin-left-30">
			<?php
			
				$date = $news['post_date'] . ' ' . $news['post_time'];
				$date = date("d M Y H:i", strtotime($date));
				/* $myDateTime = new DateTime($date, new DateTimeZone('GMT'));
				$myDateTime->setTimezone(new DateTimeZone('Asia/Kolkata'));
				$date  =  $myDateTime->format('jS F Y H:i A'); */
			?>
			<div class="blog-post-tags"> 
			<ul class="list-inline posted-info">
				<li>&nbsp;&nbsp;&nbsp;By <a href="mailto:info@steelmint.com<?php ?>"><?php echo $news['author_name']; ?></a>
				</li>			
				<li>Posted on&nbsp;<time datetime="<?php echo $date;//the_time(); ?>"><?php echo $date; ?></time></li>
				<li>
					<a style="" href="https://www.steelmint.com/<?php echo strtolower(str_replace(" ", "", $news['category'])) ?>-news">
						<?php echo ucwords(strtolower(trim($news['category']))); ?>
					</a>
				</li>
			</ul>                   
			</div>
		</div>	
	</div>	
</div>

<h2><a href="#"><?php echo $title_name= $news['post_title']; ?></a></h2>
<?PHP //the_tags( '<ul class="list-unstyled list-inline blog-tags"><li><i class="fa fa-tags"></i>', '', '</li></ul>'); ?>

<?php
$medium_image_url = $news['medium_image'];
$medium = $news['medium_image'];
$medium = $news['image'];
?>
<article class="entry clearfix">
<p></p>
<div style="float: left; padding: 0px 9px 20px 0px;">
	<img src="<?php echo $medium ?>"/> 
</div>
<div>

<?php
/* if(isset($_REQUEST['from_web_host'])){
	if( $maxCount == 10){
		$news['post_content'] = strip_tags(htmlspecialchars_decode($news['post_content'] , ENT_QUOTES));
		$news['post_content'] = login_text_cm($news['post_content']);
	}
	elseif( !isset($_COOKIE['uid'])){
		$news['post_content'] = strip_tags(htmlspecialchars_decode($news['post_content'] , ENT_QUOTES));
		$news['post_content'] = login_text_cm($news['post_content']);
	}	
	elseif($maxCount == 0 || $maxCount == 30){
		$news['post_content'] = strip_tags(htmlspecialchars_decode($news['post_content'] , ENT_QUOTES));
		$news['post_content'] = upgrade_text_cm($news['post_content']);
	}
	else
		$news['post_content'] = (htmlspecialchars_decode($news['post_content'] , ENT_QUOTES));
	
}
else */if(count($open_news_list)>0 && in_array($post_id, $open_news_list, true)){//open news with id = 33356 to all
	$startdate = $_SESSION['W']['startdate'];	
	$_enddate = $_SESSION['W']['enddate'];	
} 
else
{
	$startdate = $_SESSION['W']['startdate'];	
	$_enddate = $_SESSION['W']['enddate'];	

	$startdate = strtotime($startdate); // or your date as well
	$_enddate = strtotime($_enddate);
	$datediff = $_enddate - $startdate;
	$days = floor($datediff/(60*60*24));

	if( $maxCount == 10){
		$news['post_content'] = strip_tags(htmlspecialchars_decode($news['post_content'] , ENT_QUOTES));
		$news['post_content'] = login_text($news['post_content'], $from_web_host);
	}elseif($days == 1){
		$news['post_content'] = upgrade_text_FTFT($news['post_content']);
	}elseif( !isset($_COOKIE['uid']) && !isset($_REQUEST['usessid'])){
		$news['post_content'] = strip_tags(htmlspecialchars_decode($news['post_content'] , ENT_QUOTES));
		$news['post_content'] = login_text($news['post_content'], $from_web_host);
	}	
	elseif($maxCount == 0 || $maxCount == 30){
		$news['post_content'] = strip_tags(htmlspecialchars_decode($news['post_content'] , ENT_QUOTES));
		$news['post_content'] = upgrade_text($news['post_content'], $from_web_host);
	}
	else
		$news['post_content'] = (htmlspecialchars_decode($news['post_content'] , ENT_QUOTES));
}

	
$content = $news['post_content'];
echo $content;
// Paginate pages when <!--nextpage--> is used
/* wp_link_pages( array(
	'before'		=>	'<div id="paginate-post" class="clearfix">',
	'after'			=>	'</div>',
	'link_before'	=>	'<span>',
	'link_after'	=>	'</span>',
) ); */


/* if($edited_by = get_post_meta($post_id , 'edited_by', true)){
	list($_name, $edited_by_email) = explode('(', trim($edited_by, ')'));
	$author_email = get_the_author_meta('user_email');
	if(trim($author_email) != $edited_by_email)
		echo '<br><br><p style="">Edited By : <a style="color: #000;font-style: italic;" href="mailto:'.$edited_by_email.'">'.$edited_by.'</a></p>';
}


// Show button on link posts
if ( get_post_format() == 'link' ) {
	echo '<a href="'. get_post_meta( get_the_ID(), 'wpex_post_url', true) .'" title="'. get_the_title() .'" target="_blank" class="theme-button" id="post-link-button">'. __('visit website','wpex') .'</a>';
} */ ?>
</div>
</article>

<?php
/* endwhile; // end posts loop
else:
	echo '<font style="color:red">No News</font>';
endif; */ // end have_posts check
?>

<?php
	/* $result = ob_get_contents();
	$result = str_replace('news.steelmint.com', 'www.steelmint.com/news', $result);
	$result = str_replace('news.steelmint.com', 'www.steelmint.com/news', $result);
	$result = str_replace('news/tag/', 'steelnews?keywords=', rtrim($result,'/'));
	ob_end_clean();   */      
	
	//$content = add_lazyload($result);
	/*  require_once(DIR_APPLICATION . "news/wp-content/plugins/rj-quickcharts/shortcode/init.php");
	$RJ_Quickcharts_Shortcode = new RJ_Quickcharts_Shortcode();
	$chartHTML =  $RJ_Quickcharts_Shortcode->show_rjqc_function(array('id' => 5));
	$content = str_replace('<div id="rjqc_container_5" style="height:300px"></div>', $chartHTML, $content); */
	
	//echo "<p>".$content."</p>";

	
?>
 
<!--<script type='text/javascript' src='https://www.steelmint.com/news/wp-content/plugins/upprev/scripts/upprev.js?ver=3.3.22'></script>-->

<script type="text/javascript">
  (function() {
	var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
	po.src = 'https://apis.google.com/js/platform.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();
</script>
<script src="//platform.linkedin.com/in.js" type="text/javascript">
 lang: en_US
</script>
<?php //wp_footer(); ?>