| Server IP : 172.67.187.206 / Your IP : 172.71.28.156 Web Server : Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30 System : Windows NT WIN-ECQAAA40806 6.2 build 9200 (Windows Server 2012 Standard Edition) i586 User : SYSTEM ( 0) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : E:/Inetpub/www/news/move/ |
Upload File : |
<?php include("header.php"); ?>
<?php include("right_all.php");?>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
left:25px;
top:10px;
width:100px;
height:99px;
z-index:1;
}
-->
</style>
<?php
// Create the function, so you can use it
function isMobile() {
return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
}
// If the user is on a mobile device, redirect them
if(isMobile()) {} else {
echo "<div id='Layer1'><a href='index.html'><img src='images/logo.png'></a> </div>";
}
?>
<div class="other-box">
<div class="title">
<h3>Most Popular</h3>
</div><!--title-->
<?php
error_reporting(E_ALL ^ E_NOTICE);
// How many adjacent pages should be shown on each side?
$adjacents = 5;
$query = $mysqli->query("select COUNT(*) as num FROM posts WHERE active=1 ORDER BY views DESC");
$total_pages = mysqli_fetch_array($query);
$total_pages = $total_pages['num'];
$limit = 10; //how many items to show per page
$page = $_GET['page'];
if($page)
$start = ($page - 1) * $limit; //first item to display on this page
else
$start = 0; //if no page var is given, set start to 0
/* Get data. */
$result = $mysqli->query("SELECT * FROM posts WHERE active=1 ORDER BY views DESC LIMIT $start, $limit");
/* Setup page vars for display. */
if ($page == 0) $page = 1; //if no page var is given, default to 1.
$prev = $page - 1; //previous page is page - 1
$next = $page + 1; //next page is page + 1
$lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up.
$lpm1 = $lastpage - 1; //last page minus 1
$pagination = "";
if($lastpage > 1)
{
$pagination .= "<div class=\"pagination\">";
//previous button
if ($page > 1)
$pagination.= "<a href=\"popular-$prev.html\">« previous</a>";
else
$pagination.= "<span class=\"disabled\">« previous</span>";
//pages
if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"popular-$counter.html\">$counter</a>";
}
}
elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some
{
//close to beginning; only hide later pages
if($page < 1 + ($adjacents * 2))
{
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"popular-$counter.html\">$counter</a>";
}
$pagination.= "...";
$pagination.= "<a href=\"popular-$lpm1.html\">$lpm1</a>";
$pagination.= "<a href=\"popular-$lastpage.html\">$lastpage</a>";
}
//in middle; hide some front and some back
elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
{
$pagination.= "<a href=\"popular-1.html\">1</a>";
$pagination.= "<a href=\"popular-2.html\">2</a>";
$pagination.= "...";
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"popular-$counter.html\">$counter</a>";
}
$pagination.= "...";
$pagination.= "<a href=\"popular-$lpm1.html\">$lpm1</a>";
$pagination.= "<a href=\"popular-$lastpage.html\">$lastpage</a>";
}
//close to end; only hide early pages
else
{
$pagination.= "<a href=\"popular-1.html\">1</a>";
$pagination.= "<a href=\"popular-2.html\">2</a>";
$pagination.= "...";
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"popular-$counter.html\">$counter</a>";
}
}
}
//next button
if ($page < $counter - 1)
$pagination.= "<a href=\"popular-$next.html\">next »</a>";
else
$pagination.= "<span class=\"disabled\">next »</span>";
$pagination.= "</div>\n";
}
$q = $mysqli->query("SELECT * FROM posts WHERE active=1 ORDER BY views DESC limit $start,$limit");
$numr = mysqli_num_rows($q);
if ($numr==0)
{
echo '<div class="msg">There are no stories to display at the moment. Check back again soon!!</div>';
}
while($row=mysqli_fetch_assoc($q)){
$description = stripslashes($row['description']);
$desc = strlen ($description);
if ($desc > 140) {
$sdec = substr($description,0,140).'..';
}else{
$sdec = $description;}
?>
<div class="story">
<div class="small-thumb">
<img src="timthumb.php?src=<?php echo $row['image'];?>&h=90&w=120&q=100" alt="<?php echo $row['title'];?>"/>
</div><!--smpopular-thumb-->
<h2><a class="stopy-pop-up" href="story-<?php echo $row['id'];?>.html"><?php echo stripslashes($row['title']);?></a></h2>
<p><?php echo strip_tags($sdec);?></p>
<div class="look-up-story">
<p><?php echo $row['views'];?> views | <?php echo $row['date'];?></p>
</div><!--look-up-->
</div><!--story-->
<?php }?>
<div class="id"><?php echo $pagination;?></div>
</div><!--news-box-->
<?php include("footer.php"); ?>