<?php if ($mod==""){
	header('location:../../404.php');
}else{
?>
<!-- 
*******************************************************
	Include Header Template
******************************************************* 
-->
<?php include_once "po-content/$folder/header.php"; ?>

<!-- 
*******************************************************
	Main Content Template
******************************************************* 
-->
<?php
	$dbhostsql = DATABASE_HOST;
	$dbusersql = DATABASE_USER;
	$dbpasswordsql = DATABASE_PASS;
	$dbnamesql = DATABASE_NAME;
	$connection = mysql_connect($dbhostsql, $dbusersql, $dbpasswordsql) or die(mysql_error());
	mysql_select_db($dbnamesql, $connection) or die(mysql_error());

	$detail=mysql_query("SELECT * FROM post,users,category WHERE users.id_user = post.editor AND category.id_category = post.id_category AND category.active = 'Y' AND post.active = 'Y' AND post.id_post = '".abs((int)$_GET[id])."'");
	$d = mysql_fetch_array($detail);
	$dcari = mysql_num_rows($detail);

	$tabledet = mysql_query("SELECT title, seotitle FROM post WHERE id_post = '$d[id_post]'");
	$det = mysql_fetch_array($tabledet);
	$contentdet = html_entity_decode($d['content']);
	$biodet = html_entity_decode($d['bio']);

	$tabledetcat = mysql_query("SELECT * FROM category WHERE id_category = '$d[id_category]'");
	$detcat = mysql_fetch_array($tabledetcat);

	$tabledcom = new PoTable('comment');
	$totaldcom = $tabledcom->numRowByAnd(id_post, $d['id_post'], active, 'Y');
?>
<?php if ($dcari > 0){ ?>
	<div id="content" class="container">
		<div id="main" class="row-fluid">
			<div id="main-left" class="span8">
				<article class="post">
					<h2 class="entry-title">
						<a href="<?php echo "detailpost-$d[id_post]-$det[seotitle].html"; ?>" title="<?php echo $det['title']; ?>" rel="bookmark"><?php echo $det['title']; ?></a>
						<span class="entry-cat"><a href="<?php echo "category-$detcat[id_category]-$detcat[seotitle].html"; ?>" title="<?php echo $detcat['title']; ?>" rel="category tag"><?php echo $detcat['title']; ?></a></span>
					</h2>
					<div class="entry-meta row-fluid">
						<ul class="clearfix">
							<li><img src="po-content/<?php echo $folder; ?>/images/gravatar.png" height="15" width="15" alt=""><a href="#" title="Di Tulis Admin" rel="author"><?php echo $d['nama_lengkap']; ?></a></li>
							<li><img src="po-content/<?php echo $folder; ?>/images/time.png" alt=""><?php echo tgl_indo($d['date']); ?></li>
							<li><img src="po-content/<?php echo $folder; ?>/images/komen.png" alt=""><a href="#" title="<?php echo $totaldcom; ?> Komentar"><?php echo $totaldcom; ?> Komentar</a></li>
						</ul>
					</div>
					<div class="entry-content">
						<a href="<?php echo "detailpost-$d[id_post]-$det[seotitle].html"; ?>" title="<?php echo $det[title]; ?>" rel="bookmark">
							<img src="po-content/po-upload/<?php echo $d['picture']; ?>" alt="<?php echo $d['title']; ?>" style="width:100%;" />
						</a>
						<p><?php echo $contentdet; ?></p>
						<p>&nbsp;</p>
						<p class="moretag">
							<?php
								$tabletag = new PoTable('tag');
								$tags = $tabletag->findAll(id_tag, DESC);
								$_arrNilai = explode(',', $d['tag']);
								foreach($tags as $tag){
									$_ck = (array_search($tag->tag_seo, $_arrNilai) != false)? '' : 'display:none;';
									echo "<a href='#' title='$tag->tag_title' style='$_ck'>$tag->tag_title</a> ";
								}
							?>
						</p>
					</div>
				</article>

				<!-- #profil penulis -->

				<div class="post">
					<h3 class="title"><span>Profil Penulis</span></h3>
					<?php
						$filename = "po-content/po-upload/user-$d[id_user].jpg";
						if (file_exists("$filename")){
							echo "<img src='po-content/po-upload/user-$d[id_user].jpg' alt='$d[nama_lengkap]' class='imgauthor' />";
						}else{
							echo "<img src='po-content/po-upload/user-editor.jpg' alt='$d[nama_lengkap]' class='imgauthor' />";
						}
					?>
					<p><b><?php echo $d['nama_lengkap']; ?></b><br /><?php echo $biodet; ?></p>
					<p>&nbsp;</p>
				</div>

				<!-- #artikel terkait -->

				<div id="home-top">
					<h3 class="title"><span>Artikel Terkait</span></h3>
					<ul class="bxslider">
						<?php
							$pisah_kata  = explode(",",$d['tag']);
							$jml_katakan = (integer)count($pisah_kata);
							$jml_kata = $jml_katakan-1; 
							$ambil_id = substr($val->validasi($_GET['id'],'sql'),0,4);

							$cari = "SELECT * FROM post WHERE (id_post<'$ambil_id') AND (id_post!='$ambil_id') AND (" ;
							for ($i=0; $i<=$jml_kata; $i++){
								$cari .= "tag LIKE '%$pisah_kata[$i]%'";
								if ($i < $jml_kata ){
									$cari .= " OR ";
								}
							}
							$cari .= ") AND active='Y' ORDER BY id_post DESC LIMIT 5";
							$hasil  = mysql_query($cari);
							while($h=mysql_fetch_array($hasil)){
						?>
							<li><a class="image_thumb_zoom" href="<?php echo "detailpost-$h[id_post]-$h[seotitle].html"; ?>" title="<?php echo $h['title']; ?>" rel="bookmark">
								<img width="225" height="136" src="po-content/po-upload/medium-<?php echo $h['picture']; ?>" alt="<?php echo $h['title']; ?>" />
								</a>
								<h4 class="post-title clearfix">
									<img class="post-icon" alt="Text post" src="<?php echo "po-content/$folder/images/text.png"; ?>">
									<a href="<?php echo "detailpost-$h[id_post]-$h[seotitle].html"; ?>" title="<?php echo $h['title']; ?>" rel="bookmark"><?php echo cuthighlight('title', $h['title'], '20'); ?>...</a>
								</h4>
							</li>
						<?php } ?>
					</ul>
					<div class="relatedpost_rules"></div>
				</div>

				<!-- #daftar komentar -->

				<div class="post comment">
					<ol class="commentlist">
					<?php
						mysql_query("UPDATE post SET hits = $d[hits]+1 WHERE id_post = '".$val->validasi($_GET['id'],'sql')."'"); 
						$komentar = mysql_query("SELECT count(comment.id_comment) AS jml FROM comment WHERE id_post = '".$val->validasi($_GET['id'],'sql')."' AND active = 'Y'");
						$k = mysql_fetch_array($komentar);
						$sql = mysql_query("SELECT * FROM comment WHERE id_post = '".$val->validasi($_GET['id'],'sql')."' AND active = 'Y' ORDER BY id_comment DESC");
						$jml = mysql_num_rows($sql);
					?>
					<h3 class="title"><span><?php echo $k[jml]; ?> Komentar Pada Artikel Ini</span></h3>
					<?php
						if ($jml > 0){
					?>
					<?php
						while ($s = mysql_fetch_array($sql)){
						$isian = nl2br($s[comment]);
					?>
						<li>
							<div class="avatar"><img src="po-content/chingsy/images/avatar.jpg" alt="<?php echo $s[name]; ?>" /></div>
							<div class="bypostauthor">
								<?php if ($s[url]!=''){ ?>
									<a href="<?php echo addhttp($s[url]); ?>" target="_blank" class="fn"><span><?php echo $s[name]; ?></span></a>
								<?php }else{ ?>
									<a href="#" class="fn"><span><?php echo $s[name]; ?></span></a>
								<?php } ?>
							</div>
							<time><?php echo "$s[date] | $s[time]"; ?></time>
							<p class="text"><?php echo autolink($isian); ?></p>
						</li>
					<?php } ?>
					<?php } ?>
					</ol> <!-- End Comment-Lists -->
					<p>&nbsp;</p>
				</div>

				<!-- #form komentar -->

				<div class="post">
					<h3 class="title"><span>Tinggalkan Komentar</span></h3>
					<form class="contact-form" action="po-postcom.php" method="post">
						<div class="cform name">
							<input type="text" name="name" id="cf_name" size="50" maxlength="50" value="" placeholder="Nama *" />
						</div>
						<div class="cform email">
							<input type="text" name="email" id="cf_email" size="50" maxlength="50" value="" placeholder="E-mail *" />
						</div>
						<div class="cform website">
							<input type="text" name="url" id="cf_subject" size="50" maxlength="50" value="" placeholder="Website *" />
						</div>
						<div class="clearfix"></div>
						<div>
							<textarea name="comment" id="cf_message" cols="50" rows="3" placeholder="Isi pesan *"></textarea>
						</div>
						<div>
							<?php
								require_once('po-library/recaptchalib.php');
								$publickey = "6LeogOISAAAAACFiZE820X0RN5jOj0s7TNkJw2Ph";
								echo recaptcha_get_html($publickey);
								$idpcom = mysql_real_escape_string(stripslashes(strip_tags(htmlspecialchars($_GET['id'],ENT_QUOTES))));
							?>
							<input type="hidden" name="id" value="<?php echo $idpcom; ?>" />
							<input type="hidden" name="seotitle" value="<?php echo $det['seotitle']; ?>" />
							<input type="submit" value="Komentar" name="submit" id="cf_send" />
						</div>
					</form>
				</div>

			</div><!-- #main-left -->

			<!-- 
			*******************************************************
				Include Sidebar Template
			******************************************************* 
			-->
			<?php include_once "po-content/$folder/sidebar.php"; ?>

			<div class="clearfix"></div>
		</div><!-- #main -->
	</div><!-- #content -->
<?php }else{ ?>
	<div id="content" class="container">
		<div id="main" class="row-fluid">
			<div align="center">
				<header class="not-found-header">
					<h1>404</h1>
					<h2>Whoops! Terjadi kesalahan...
				</header><!-- .entry-header -->
				<article id="post-0" class="post not-found">
					<div class="entry-content">
						<p>Maaf halaman yang dicari tidak ditemukan,<br /> atau sudah dihapus. Kembali ke <a href="<?php echo $website_url; ?>" title="<?php echo $website_name; ?>" rel="home">halaman utama</a>.</p>
					</div><!-- .entry-content -->
				</article><!-- #post-0 -->
			</div>
			<div class="clearfix"></div>
		</div><!-- #main -->
	</div><!-- #content -->
<?php } ?>


<!-- 
*******************************************************
	Include Footer Template
******************************************************* 
-->
<?php include_once "po-content/$folder/footer.php"; ?>
<?php } ?>