<?php ob_start(); 
include ("config/db.php"); 

define("StartRec", "start", true);
define("SessionTblStartRec", "start", true);
$sSrchWhere = "";
$nStartRec = 0;
$nStopRec = 0;
$nTotalRecs = 0;
$nRecCount = 0;
$nRecActual = 0;
$nDisplayRecs = 10;
$nRecRange = 10;

$conn = db_connect(HOST, USER, PASS, DB, PORT);

function limit_words($string, $word_limit)
{
$words = explode(" ",$string);
return implode(" ",array_splice($words,0,$word_limit));
}

$cat = @$_GET["cat"];
if (empty($cat)) {
	$cat = @$_POST["cat"];
}
$x_cat= @$_GET["x_cat"];
if (empty($x_cat)) {
	$x_cat = @$_POST["x_cat"];
}
$id = @$_GET["id"];
if (empty($id)) {
	$id = @$_POST["id"];
}
$x_id = @$_GET["x_id"];
if (empty($x_id)) {
	$x_id = @$_POST["x_id"];
}
$start = @$_GET["start"];
if (empty($start)) {
	$start = @$_POST["start"];
}
if (empty($start)) {
	$start = '1';
}
?>

<?php
$sSql = "select * FROM news WHERE cat='$cat' ORDER by newslevel ASC, ID DESC";
$rs = query($sSql,$conn) or die("Failed to execute query" . error() . ' SQL:' . $sSql);
$nTotalRecs = num_rows($rs);
if ($nDisplayRecs <= 0) { 
	$nDisplayRecs = $nTotalRecs;
}
$nStartRec = 1;
SetUpStartRec();

?>
<?php date_default_timezone_set("Asia/kolkata");?>
<!doctype html>
<html class="no-js" lang="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>    <head>
        <meta http-equiv="x-ua-compatible" content="ie=edge">
        <title><?php echo SITE_TITLE;?></title>
    <meta name="description" content="<?php echo SITE_DESCRIPTION;?>">
	<meta name="keywords" content="<?php echo SITE_META;?>">
    <meta name="AUTHOR" content="<?php echo SITE_AUTHOR;?>">
	    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />

	  <!-- GoogleFonts -->
		<link href="https://fonts.googleapis.com/css?family=Ek+Mukta" rel="stylesheet">
        <!-- Normalize CSS -->
        <link rel="stylesheet" href="css/normalize.css">
        <!-- Main CSS -->
        <link rel="stylesheet" href="css/main.css">
        <!-- Bootstrap CSS -->
        <link rel="stylesheet" href="css/bootstrap.min.css">
        <!-- Animate CSS -->
        <link rel="stylesheet" href="css/animate.min.css">
        <!-- Font-awesome CSS-->
        <link rel="stylesheet" href="css/font-awesome.min.css">
        <!-- Owl Caousel CSS -->
        <link rel="stylesheet" href="vendor/OwlCarousel/owl.carousel.min.css">
        <link rel="stylesheet" href="vendor/OwlCarousel/owl.theme.default.min.css">
        <!-- Main Menu CSS -->
        <link rel="stylesheet" href="css/meanmenu.min.css">
        <!-- Magnific CSS -->
        <link rel="stylesheet" type="text/css" href="css/magnific-popup.css">
        <!-- Switch Style CSS -->
        <link rel="stylesheet" href="css/hover-min.css">
        <!-- Custom CSS -->
        <link rel="stylesheet" href="style.css">
        <!-- For IE -->
        <link rel="stylesheet" type="text/css" href="css/ie-only.css" />
		<!-- Nivo Slider CSS-->
        <link rel="stylesheet" href="vendor/slider/css/nivo-slider.css" type="text/css" />
        <link rel="stylesheet" href="vendor/slider/css/preview.css" type="text/css" media="screen" />
        <!-- Modernizr Js -->
        <script src="js/modernizr-2.8.3.min.js"></script>
    </head>

    <body>
        <!--[if lt IE 8]>
    <p class="browserupgrade">You are using an 
        <strong>outdated</strong> browser. Please 
        <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.
    </p>
    <![endif]-->
        <!-- Add your site or application content here -->

        <div id="wrapper">
            <!-- Header Area Start Here -->
            <header>
                <div id="header-layout2" class="header-style5">
                    <div class="header-top-bar">
                        <div class="top-bar-top bg-primarytextcolor box-layout">
                            <div class="container">
                                <div class="row">
                                    <div class="col-lg-9 col-md-12">
                                        <ul class="news-info-list text-center--md mask-content-sm">
                                            <li>
                                                <i class="fa fa-calendar" aria-hidden="true"></i><span id="current_date"></span></li>
                                        </ul>
                                    </div>
                                    <div class="col-lg-3 d-none d-lg-block">
                                        <ul class="header-social">
                                            <li>
                                                <a href="#" title="facebook">
                                                    <i class="fa fa-facebook" aria-hidden="true"></i>
                                                </a>
                                            </li>
                                            <li>
                                                <a href="#" title="twitter">
                                                    <i class="fa fa-twitter" aria-hidden="true"></i>
                                                </a>
                                            </li>
                                            <li>
                                                <a href="#" title="google-plus">
                                                    <i class="fa fa-google-plus" aria-hidden="true"></i>
                                                </a>
                                            </li>
                                            <li>
                                                <a href="#" title="linkedin">
                                                    <i class="fa fa-linkedin" aria-hidden="true"></i>
                                                </a>
                                            </li>
                                            <li>
                                                <a href="#" title="pinterest">
                                                    <i class="fa fa-pinterest" aria-hidden="true"></i>
                                                </a>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="container">
                            <div class="bg-body box-layout">
                                <div class="top-bar-bottom pt-20 pb-20 d-none d-lg-block">
                                    <div class="row d-flex align-items-center">
                                        <div class="col-lg-4">
                                            <div class="logo-area">
                                               <a href="index" class="img-fluid">
										<?php $sqlmain="SELECT  * FROM logo";
										$recsmain = query($sqlmain, $conn);
										while (($row = @fetch_array($recsmain)))
										{		
										?>
										 <img src="img/<?php echo htmlentities($row['image']); }?>" alt="logo" class="img-fluid">
                                        </a>
                                            </div>
                                        </div>
                                        <div class="col-lg-8 col-md-12">
                                            <div class="ne-banner-layout1 pull-right">
                                                <a href="#">
                                                    <img src="img/banner/banner2.jpg" alt="ad" class="img-fluid">
                                                </a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="main-menu-area" id="sticker">
                        <div class="container">
                            <div class="bg-body box-layout">
                                <div class="bg-primarytextcolor pl-15 pr-15">
                                    <div class="row no-gutters d-flex align-items-center">
                                        <div class="col-lg-12 col-md-12 d-none d-lg-block position-static min-height-none">
                                            <div class="ne-main-menu">
                                                <nav id="dropdown">
                                                    <ul>
                                                       <li class="active">  <a href="index">Home</a></li>
												<?php $sqlmain="SELECT  * FROM cat LIMIT 10";
												$recsmain = query($sqlmain, $conn);
												while (($row = @fetch_array($recsmain)))
												{		
												?>
                                                <li><a href="post?cat=<?php echo htmlentities($row['cat']); ?>">
												<?php echo htmlentities($row['mar']); ?></a></li>
												<?php }?>
                                                    </ul>
                                                </nav>
                                            </div>
                                        </div>
                                       
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </header>
            <!-- Header Area End Here -->
			<section class="container">
                <div class="bg-body box-layout"><br>

			<div class="ne-banner-layout1">
                               <div class="main-slider1">
                                <div class="bend niceties preview-1">
                                    <div id="ensign-nivoslider-1" class="slides">
									<?php $sqlmain="SELECT  * FROM advts where category='banner1_1200x100' ORDER BY ID DESC LIMIT 5";
								$recsmain = query($sqlmain, $conn);
								while (($row = @fetch_array($recsmain)))		
								{
								$x_id = $row["id"];
								$x_image = $row["image"];
								?>
                                        <img src="advts/<?php echo $x_image; ?>" alt="news" class="img-fluid width-100" />
                                       <?php }?>
                                    </div><br>

 								</div>
								 </div>
                            </div>
							</div>
							</section>

            
            <!-- Popular News Area Start Here -->
            <section class="container">
                <div class="bg-body box-layout"><br>
                    <div class="section-space-bottom-less30">
                        <div class="row">
                            <div class="col-lg-8 col-md-12">
                                <div class="mb-20-r ne-isotope">
                                    <div class="topic-border color-cinnabar mb-30">
                                        <div class="topic-box-lg color-cinnabar">
										<?php $sqlmain="SELECT  * FROM cat where cat='$cat'";
										$recsmain = query($sqlmain, $conn);
										while (($row = @fetch_array($recsmain)))
										{		
										$x_cat = $row["cat"];
										$x_mar = $row["mar"];
										?>
										<?php echo $x_mar; }?>
										</div>
                                    </div>
                                    <div class="row">
                                    <div class="col-lg-12 col-md-6 col-sm-12">
									<?php if ($nTotalRecs > 0) {  ?>
									<?php } ?>
									<?php
									if ($nStartRec > $nTotalRecs) {
									$nStartRec = $nTotalRecs;
									}
									$nStopRec = $nStartRec + $nDisplayRecs - 1;
									$nRecCount = $nStartRec - 1;
									if (num_rows($rs) > 0) {
									data_seek($rs, $nStartRec -1);
									}
									$nRecActual = 0;
									while (($row = @fetch_array($rs)) && ($nRecCount < $nStopRec)) {
									$nRecCount = $nRecCount + 1;
									if ($nRecCount >= $nStartRec) {
									$nRecActual = $nRecActual + 1;
									$x_id = $row["id"];
									$x_cat = $row["cat"];
									$x_youtubelink = $row["youtubelink"];
									$x_image = $row["image"];
									$x_newshead = $row["newshead"];
									$x_detail = $row["detail"];
									$x_tag = $row["tag"];
									$x_rname = $row["rname"];
									$x_views = $row["views"];
									$x_update = $row["update"];
									$timestamp = strtotime($x_update);
									?> 
                                        <div class="media media-none--md mb-30" >
                                            <div class="position-relative width-40" style="max-height:200px; overflow:hidden;">
                                                <?php if ($x_image == "") {?>
                               <a href="singlenews?id=<?php echo $x_id; ?>">
							    <img src="admin/sorry.jpg" alt="news" class="img-fluid width-100"></a>
								<?php } else {?>
								<a href="singlenews?id=<?php echo $x_id; ?>">
								<img src="upload/370x230/<?php echo $x_image; ?>" alt="news" class="img-fluid width-100"></a>
								<?php }?>
                                            </div>
                                            <div class="media-body p-mb-none-child media-margin30">
                                                <div class="post-date-dark">
                                                    <ul>
                                                      
                                                    <li>
                                                        <span>
                                                            <i class="fa fa-calendar" aria-hidden="true"></i>
                                                        </span><?php echo date('d M Y', $timestamp); ?></li>
                                                    </ul>
                                                </div>
                                                <h3 class="title-semibold-dark size-lg mb-15">
                                                 <a href="singlenews?id=<?php echo $x_id; ?>">
												<?php echo $x_newshead; ?>
												</a>
                                                </h3>
                                                <p><?php echo str_replace(chr(10), "<br>", limit_words($x_detail,30)); ?>...
                                                </p>
                                            </div>
                                        </div>
										<?php }}?>
                                    </div>
                                   
                                </div>
                                </div>
								
								
                                <div class="row mt-20-r mb-30">
                                <div class="col-sm-12 col-12">
                                    <div class="pagination-btn-wrapper text-center--xs mb15--xs">
                                        <ul>
                                  <?php
                                if ($nTotalRecs > 0) {
                                $rsEof = ($nTotalRecs < ($nStartRec + $nDisplayRecs));
                                if ($nTotalRecs > $nDisplayRecs) {
                                // Find out if there should be Prev/Next links
                                if ($nStartRec == 1) {
                                $isPrev = False;
                                } else {
                                $isPrev = True;
                                $PrevStart = $nStartRec - $nDisplayRecs;
                                if ($PrevStart < 1) { $PrevStart = 1; } ?>
								<li>
                                <a href="post?cat=<?php echo $x_cat; ?>&start=<?php echo $PrevStart; ?>">
								<i class="fa fa-angle-double-left"></i></i></a>
								</li>
                                <?php
                                }
                                if ($isPrev || (!$rsEof)) {
                                $x = 1;
                                $y = 1;
                                $dx1 = intval(($nStartRec-1)/($nDisplayRecs*$nRecRange))*$nDisplayRecs*$nRecRange+1;
                                $dy1 = intval(($nStartRec-1)/($nDisplayRecs*$nRecRange))*$nRecRange+1;
                                if (($dx1+$nDisplayRecs*$nRecRange-1) > $nTotalRecs) {
                                $dx2 = intval($nTotalRecs/$nDisplayRecs)*$nDisplayRecs+1;
                                $dy2 = intval($nTotalRecs/$nDisplayRecs)+1;
                                } else {
                                $dx2 = $dx1+$nDisplayRecs*$nRecRange-1;
                                $dy2 = $dy1+$nRecRange-1;
                                }
                                while ($x <= $nTotalRecs) {
                                if (($x >= $dx1) && ($x <= $dx2)) {
                                if ($nStartRec == $x) { ?>
								<li class="active">
                               <a class="active"><?php echo $y; ?></a>
							   </li>
                                <?php } else { ?>
								 <li>
                                <a href="post?cat=<?php echo $x_cat; ?>&start=<?php echo $x; ?>"><?php echo $y; ?></a>
								</li>
                                <?php }
                                $x += $nDisplayRecs;
                                $y += 1;
                                } elseif (($x >= ($dx1-$nDisplayRecs*$nRecRange)) && ($x <= ($dx2+$nDisplayRecs*$nRecRange))) {
                                if ($x+$nRecRange*$nDisplayRecs < $nTotalRecs) { ?>
								<li>
                                <a  href="post?cat=<?php echo $x_cat; ?>&start=<?php echo $x; ?>">
								<?php echo $y; ?>-<?php echo ($y+$nRecRange-1);?></a>
								</li>
                                <?php } else {
                                $ny=intval(($nTotalRecs-1)/$nDisplayRecs)+1;
                                if ($ny == $y) { ?>
								<li>
                                <a  href="post?cat=<?php echo $x_cat; ?>&start=<?php echo $x; ?>"><?php echo $y; ?></a>
								</li>
                                <?php } else { ?>
                               <li>
								<a href="post?cat=<?php echo $x_cat; ?>&start=<?php echo $x; ?>">
								<?php echo $y; ?>-<?php echo $ny; ?></a>
								</li>
                                <?php }
                                }
                                $x += $nRecRange*$nDisplayRecs;
                                $y += $nRecRange;
                                } else {
                                $x += $nRecRange*$nDisplayRecs;
                                $y += $nRecRange;
                                }
                                }
                                }
                                // Next link
                                if (!$rsEof) {
	                            $NextStart = $nStartRec + $nDisplayRecs;
                                $isMore = True;  ?>
								<li>
                                 <a href="post?cat=<?php echo $x_cat; ?>&start=<?php echo $NextStart; ?>">
								 <i class="fa fa-angle-double-right"></i></a>
								</li>
                                        </ul>
										 <?php } else {
                                 $isMore = False;
                                 } ?>
                                 
                                 <?php	}
                                 if ($nStartRec > $nTotalRecs) { $nStartRec = $nTotalRecs; }
                                 $nStopRec = $nStartRec + $nDisplayRecs - 1;
                                 $nRecCount = $nTotalRecs - 1;
                                 if ($rsEof) { $nRecCount = $nTotalRecs; }
                                 if ($nStopRec > $nRecCount) { $nStopRec = $nRecCount; } ?>
                                        <p class="mb-none col-sm-6 col-12 pagination-result text-right pt-10 text-center--xs"> <?php echo  $nStartRec;  ?> ते  <?php  echo $nStopRec; ?> एकूण रेकॉर्ड <?php echo  $nTotalRecs; ?>
                                 <?php } else { ?>
                                 एकही रेकॉर्ड उपलब्ध नाही</p>
                                  
								 <?php } ?> 
                                    </div>
                                </div>
                                
									</div>
									</div>
							
                            <div class="ne-sidebar sidebar-break-md col-lg-4 col-md-12">
                               
                                <div class="sidebar-box">
                                    <div class="ne-banner-layout1 text-center">
                                       <div class="main-slider1">
                                <div class="bend niceties preview-1">
                                    <div id="ensign-nivoslider-2" class="slides">
									<?php $sqlmain="SELECT  * FROM advts where category='right_400x400' ORDER BY ID DESC LIMIT 5";
								$recsmain = query($sqlmain, $conn);
								while (($row = @fetch_array($recsmain)))		
								{
								$x_id = $row["id"];
								$x_image = $row["image"];
								?>
                                        <img src="advts/<?php echo $x_image; ?>" alt="news" class="img-fluid width-100" />
                                       <?php }?>
                                    </div>
 								</div>
								 </div>
                                    </div>
                                </div>
                                <div class="sidebar-box">
                                    <div class="topic-border color-cod-gray mb-30">
                                        <div class="topic-box-lg color-cod-gray">
										<?php $sqlmain="SELECT  * FROM cat where catid='7'";
								$recsmain = query($sqlmain, $conn);
								while (($row = @fetch_array($recsmain)))
								{		
								$x_cat = $row["cat"];
								$x_mar = $row["mar"];
								?>
								<?php echo $x_mar; }?>
								</div>
                                    </div>
								<?php $sqlmain="SELECT  * FROM news where cat='$x_cat' ORDER BY newslevel ASC, ID DESC LIMIT 1";
								$recsmain = query($sqlmain, $conn);
								while (($row = @fetch_array($recsmain)))		
								{
								$x_id = $row["id"];
								$x_cat = $row["cat"];
								$x_newshead = $row["newshead"];
								$x_subhead = $row["subhead"];
								$x_update = $row["update"];
								$x_rname = $row["rname"];
								$x_image = $row["image"];
								$x_youtubelink = $row["youtubelink"];
								$x_views = $row["views"];
								$timestamp = strtotime($x_update);
								?>
                                    <div class="img-overlay-70 img-scale-animate">
                                        <?php if ($x_image == "") {?>
                               <a href="singlenews?id=<?php echo $x_id; ?>">
							    <img src="admin/sorry.jpg" alt="news" class="img-fluid width-100"></a>
								<?php } else {?>
								<a href="singlenews?id=<?php echo $x_id; ?>">
								<img src="upload/370x230/<?php echo $x_image; ?>" alt="news" class="img-fluid width-100"></a>
								<?php }?>
                                       
                                        <div class="mask-content-xs">
                                            <div class="post-date-light"><?php echo date('d M Y', $timestamp); ?></div>
                                            <h2 class="title-medium-light size-lg">
                                              <a href="singlenews?id=<?php echo $x_id; ?>"><?php echo $x_newshead; ?></a>
                                            </h2>
                                        </div>
                                    </div>
									<?php }?>
                                    <div class="row">
									<?php $sqlmain="SELECT  * FROM news where cat='$x_cat' ORDER BY newslevel ASC, ID DESC LIMIT 1,4";
								$recsmain = query($sqlmain, $conn);
								while (($row = @fetch_array($recsmain)))		
								{
								$x_id = $row["id"];
								$x_cat = $row["cat"];
								$x_newshead = $row["newshead"];
								$x_subhead = $row["subhead"];
								$x_update = $row["update"];
								$x_rname = $row["rname"];
								$x_image = $row["image"];
								$x_youtubelink = $row["youtubelink"];
								$x_views = $row["views"];
								$timestamp = strtotime($x_update);
								?>
                                        <div class="col-6">
                                            <div class="mt-30">
                                                <div class="position-relative" style="max-height:88px; overflow:hidden;">
                                                   <?php if ($x_image == "") {?>
                               <a href="singlenews?id=<?php echo $x_id; ?>">
							    <img src="admin/sorry.jpg" alt="news" class="img-fluid width-100"></a>
								<?php } else {?>
								<a href="singlenews?id=<?php echo $x_id; ?>">
								<img src="upload/124x88/<?php echo $x_image; ?>" alt="news" class="img-fluid width-100"></a>
								<?php }?>
                                                   
                                                </div>
                                                <h3 class="title-medium-dark size-md mb-none">
                                                 <a href="singlenews?id=<?php echo $x_id; ?>"><?php echo $x_newshead; ?></a>
                                                </h3>
                                            </div>
                                        </div>
										<?php }?>
										
                                       
                                    </div>
                                </div>
                            </div>
                        </div>
						
						 <div class="sidebar-box">
                                       <div id="div_1720190118110652">
<script>
var domain = (window.location != window.parent.location)? document.referrer : document.location.href;
if(domain==""){domain = (window.location != window.parent.location) ? window.parent.location: document.location.href;}
var scpt=document.createElement("script");
var GetAttribute = "afpftpPixel_"+(Math.floor((Math.random() * 500) + 1))+"_"+Date.now() ;
scpt.src="//adgebra.co.in/afpf/GetAfpftpJs?parentAttribute="+GetAttribute;
scpt.id=GetAttribute;
scpt.setAttribute("data-pubid","831");
scpt.setAttribute("data-slotId","1");
scpt.setAttribute("data-templateId","17");
scpt.setAttribute("data-accessMode","1");
scpt.setAttribute("data-domain",domain);
scpt.setAttribute("data-divId","div_1720190118110652");
document.getElementById("div_1720190118110652").appendChild(scpt);
</script>
</div>

                                    </div>
						
                    </div>
                </div>
            </section>
            <!-- Popular News Area End Here -->

           
            <!-- Footer Area Start Here -->
<?php include("sections/footer.php");?>
            <!-- Footer Area End Here -->
           
        <!-- jquery-->
        <script src="js/jquery-2.2.4.min.js " type="text/javascript"></script>
        <!-- Plugins js -->
        <script src="js/plugins.js " type="text/javascript"></script>
        <!-- Popper js -->
        <script src="js/popper.js " type="text/javascript"></script>
        <!-- Bootstrap js -->
        <script src="js/bootstrap.min.js " type="text/javascript"></script>
        <!-- WOW JS -->
        <script src="js/wow.min.js"></script>
        <!-- Owl Cauosel JS -->
        <script src="vendor/OwlCarousel/owl.carousel.min.js " type="text/javascript"></script>
        <!-- Meanmenu Js -->
        <script src="js/jquery.meanmenu.min.js " type="text/javascript"></script>
        <!-- Srollup js -->
        <script src="js/jquery.scrollUp.min.js " type="text/javascript"></script>
        <!-- jquery.counterup js -->
        <script src="js/jquery.counterup.min.js"></script>
        <script src="js/waypoints.min.js"></script>
		 <!-- Nivo slider js -->
        <script src="vendor/slider/js/jquery.nivo.slider.js" type="text/javascript"></script>
        <script src="vendor/slider/home.js" type="text/javascript"></script>

        <!-- Isotope js -->
        <script src="js/isotope.pkgd.min.js " type="text/javascript"></script>
        <!-- Magnific Popup -->
        <script src="js/jquery.magnific-popup.min.js"></script>
        <!-- Ticker Js -->
        <script src="js/ticker.js " type="text/javascript"></script>
        <!-- Custom Js -->
        <script src="js/main.js " type="text/javascript"></script>
    </body>

</html>
