<!DOCTYPE html>
<html lang="en">

<?php
$canonical = '<link rel="canonical" href="http://www.twinsbaseballclub.de/index.php" />';

include('includes/page_start.php');
?>

<?php
try {
    #$conn = new PDO( 'mysql:host=localhost;dbname=twins', 'root', '', #local
    $conn = new PDO( 'mysql:host=localhost;dbname=twinsweb_twins', 'twinsweb_twins', 'giselita', #produktiv
    array( PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8' ) );

    //the default error mode for PDO is PDO::ERRMODE_SILENT so lets change that to see errors
    $conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$query =  'SELECT ID, DATE_FORMAT(PUBLISH_DATE,"%d %b %Y") as date, 
HITS, HEADLINE, SECOND_HEADLINE, NEW_FULL, FRIENDLY_URL, PICTURE, AUTHOR, 
TAGS, FACEBOOK_OPEN_GRAPH_TAGS_AND_TWITTER_CARDS FROM news WHERE FRIENDLY_URL ="saison-2018-endet-mit-einem-sieg.html" ORDER BY ID LIMIT 1';				
#echo $query;	

	$stmt = $conn->prepare( $query );
    $stmt->execute();
	$count  = $stmt->rowCount();


	while( $row = $stmt->fetch() ) {
        $ID = $row['ID'];
								$date = $row['date'];
								$HEADLINE = $row['HEADLINE'];
								$SECOND_HEADLINE = $row['SECOND_HEADLINE'];
								$NEW_FULL = $row['NEW_FULL'];
								$FRIENDLY_URL = $row['FRIENDLY_URL'];
								$PICTURE = $row['PICTURE'];
								$AUTHOR = $row['AUTHOR'];
								$TAGS = $row['TAGS'];
								$FACEBOOK_OPEN_GRAPH_TAGS_AND_TWITTER_CARDS = $row['FACEBOOK_OPEN_GRAPH_TAGS_AND_TWITTER_CARDS'];
								$HITS = $row['HITS'];
}
	#Update hits
	$new_hits = ++$HITS;
	$update_hits = 'UPDATE news SET `HITS` = ' . $new_hits .  ' WHERE `news`.`ID` = "'. $ID .'" LIMIT 1';
	$stmt = $conn->prepare( $update_hits );
    $stmt->execute();

} catch( PDOException $e ) {
    echo 'ERROR: ' . $e->getMessage();
}
								
?>

<?php
include('functions/all.php');
?>

<?php
include('includes/head_section.php');
?>

<body class="homepage">

<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/de_DE/sdk.js#xfbml=1&version=v2.6";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<?php
include('includes/header.php');
?>

<?php
include('includes/slider.php');
?>
	
<?php
include('includes/boxes.php');
?>
    
        <section id="blog">
			<div class="container">
				<div class="blog">
				
					<div class="row">
						<div class="col-md-8">
						<?php
							
						echo '
						<div class="blog-item">
<div class="row">
<div class="col-sm-2 text-center">
	<div class="entry-meta"> 
		<span id="publish_date">'.$date.'</span>
		
		<span><i class="fa fa-comment"></i><a href="news/'.$FRIENDLY_URL.'#comments">'. $count .' Comments</a></span>
		<!-- <span><i class="fa fa-heart"></i><a href="#">56 Likes</a></span> -->
		<span><i class="fa fa-user"></i> <a href="news/'.$FRIENDLY_URL.'">'.$HITS.' Views</a></span>
	</div>
</div>
<div class="col-sm-10 blog-content">
	<a rel="prettyPhoto" href="images/news/'.str_replace('.jpg','-min.jpg',$PICTURE).'"><img class="img-responsive img-blog" src="images/news/'.str_replace('.jpg','-min.jpg',$PICTURE).'" width="100%" alt="" /></a>
	<h1><a href="news/'.$FRIENDLY_URL.'#blog">'.$HEADLINE.'</a></h1>
	<h2><a href="news/'.$FRIENDLY_URL.'#blog">'.$SECOND_HEADLINE.'</a></h2>
	<br/><span class="news_info">'.$AUTHOR.'</span> - <span class="news_date">'.$date.'</span><br/>
	<h3 style="text-align:justify;">'.$NEW_FULL.'</h3>';

hashtags($TAGS);

echo '
</div>
</div>
</div>';


	

	?>	
		
	
	
						</div><!--/.col-md-8-->

						<aside class="col-md-4">
						<?php
						#include('PHP_Version_5_or_lower/includes/right_bar.php'); #comment out if PHP Version is greater than 7
						include('PHP_Version_7_or_higher/includes/right_bar.php'); #comment out if PHP Version is lower than 7
						?>
  				
						</aside><!--/.col-md-4-->  
				</div><!--/ END .row-->
			</div><!--/ END .blog-->
		</div><!--/ END .container-->
    </section><!--/END #blog-->


<?php
include('includes/bottom.php');
?>

<?php
include('includes/footer.php');
?>
   
</body>
</html>