| 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/ |
Upload File : |
<?php include("header.php");
$id = $mysqli->escape_string($_GET['id']);
if (!isset($_SESSION['username'])) {
} else {
$username1 = $_SESSION['username'];
$user1 = $mysqli->query("SELECT * FROM users WHERE username='$username1' LIMIT 1");
$userrow1 = mysqli_fetch_array($user1);
}
$catname = $mysqli->query("SELECT c_name FROM categories WHERE id='$id'");
$getcatname = mysqli_fetch_array($catname)
?>
<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>";
}
?>
<?php // include("right_all.php");
?>
<div class="other-box">
<div class="title" style="display: none;">
<h3>::ข่าวกิจกรรม:: <?php echo $getcatname['c_name']; ?> </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 and cat_id='$id' ORDER BY id 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 and cat_id='$id' ORDER BY id 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=\"category.php?id=$id&page=$prev\">« 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=\"category.php?id=$id&page=$counter\">$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=\"category.php?id=$id&page=$counter\">$counter</a>";
}
$pagination .= "...";
$pagination .= "<a href=\"category-$id-$lpm1.html\">$lpm1</a>";
$pagination .= "<a href=\"category-$id-$lastpage.html\">$lastpage</a>";
}
//in middle; hide some front and some back
elseif ($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) {
$pagination .= "<a href=\"category-$id-1.html\">1</a>";
$pagination .= "<a href=\"category-$id-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=\"category-$id-$counter.html\">$counter</a>";
}
$pagination .= "...";
$pagination .= "<a href=\"category-$id-$lpm1.html\">$lpm1</a>";
$pagination .= "<a href=\"category-$id-$lastpage.html\">$lastpage</a>";
}
//close to end; only hide early pages
else {
$pagination .= "<a href=\"category-$id-1.html\">1</a>";
$pagination .= "<a href=\"category-$id-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=\"category-$id-$counter.html\">$counter</a>";
}
}
}
//next button
if ($page < $counter - 1)
$pagination .= "<a href=\"category.php?id=$id&page=$next\">next »</a>";
else
$pagination .= "<span class=\"disabled\">next »</span>";
$pagination .= "</div>\n";
}
$q = $mysqli->query("SELECT * FROM posts WHERE active=1 and cat_id='$id' ORDER BY id DESC limit $start,$limit");
$numr = mysqli_num_rows($q);
if ($numr == 0) {
echo '<div class="msg"><font color="red">ไม่พบข้อมูล!!</font></div>';
}
while ($row = mysqli_fetch_assoc($q)) {
$description = stripslashes($row['description']);
$desc = strlen($description);
if ($desc > 140) {
$sdec = substr($description, 0, 500) . '..';
} else {
$sdec = $description;
}
?>
<div class="story">
<div class="right-thumb">
<?php /*
$today=date("dmY");
$oldday=substr($row['image'], 0, 8);
if ($today>=$oldday){
*/
?>
<?php
if ($row['id'] > 4430) {
?>
<img src="uploads/<?php echo $row['image']; ?>" width="220" alt="<?php echo $row['title']; ?>" align="absmiddle">
<?php } else { ?>
<img src="<?php echo $row['image']; ?>" height="90" width="120" alt="<?php echo $row['title']; ?>" align="absmiddle">
<?php } ?>
<h2><a href="story.php?id=<?php echo $row['id']; ?>"><?php echo stripslashes($row['title']); ?></a></h2>
</div><!--smcategory-$id-thumb by max-->
<p><?php echo strip_tags($sdec); ?></p>
<?php
$userid = $row['uid'];
$user = $mysqli->query("SELECT * FROM users WHERE id='$userid' LIMIT 1");
$userrow = mysqli_fetch_array($user);
?>
<?php if (!isset($_SESSION['username'])) { ?>
<?php } elseif ($userrow['id'] == "$userrow1[id]") {
?>
<div align="right" style="display: none;">
<a href="edit_news.php?id=<?php echo $row['id']; ?>">แก้ไข</a>
<a class="red-button" href="delete_news.php?id=<?php echo $row['id']; ?>">ลบ</a>
</div>
<?php } ?>
<div class="look-up-story" style="display: none;">
<p>เขียนโดย : <a href="category.php?id=<?php echo $row['cat_id']; ?>"><?php echo $userrow['school']; ?></a> เปิดอ่าน<?php echo $row['views']; ?> ครั้ง เขียนเมื่อ<?php echo $row['date']; ?></p>
</div><!--look-up-->
</div><!--story-->
<?php } ?>
<center>นำ code ไปติดเว็บ <br>
<font color="#FF9900">ปรับปรุงใหม่เพื่อให้แต่ละโรงเรียนสามารถปรับแต่งเองได้</font><br>
<a href="<?php echo $code_url; ?>njson.php?scid=<?php echo $id; ?>" target="_blank"><img src="json.png" alt="RSS" height="40" border="0" /></a>
<textarea name="textarea" cols="80" rows="1"><iframe src="<?php echo $code_url; ?>news.php?school=<?php echo $id; ?>&limit=4" scrolling="no" frameborder="0" width="550" height="500"></iframe></textarea> <a target="_blank" href="<?php echo $code_url; ?>news.php?school=<?php echo $id; ?>&limit=4" scrolling="no" frameborder="0" width="550" height="500"">ตัวอย่าง</a><br>
<textarea name=" textarea" cols="80" rows="2"><iframe src="<?php echo $code_url; ?>news_front.php?school=<?php echo $id; ?>&limit=6&thum_width=180&thum_hight=120&col=3" scrolling="no" frameborder="0" width="100%" height="395"></iframe></textarea><a target="_blank" href="<?php echo $code_url; ?>news_front.php?school=<?php echo $id; ?>&limit=6&thum_width=180&thum_hight=120&col=3">ตัวอย่าง</a><br><br><br><img src="images/cco.png">
</center>
<div class="id"><?php echo $pagination;
?></div>
</div><!--news-box-->
<?php //include("footer.php");
?>