Файл: public_html/category.php
Строк: 77
<?php
include 'admin/config.php';
echo dbconn();
include_once('pagination.class.php');
if (!isset($_GET["id"])) {
header('Location: '.$configsiteurl.'404.php');
}
if (!isset($_GET["cat"])) {
header('Location: '.$configsiteurl.'404.php');
}
$cid = $_GET["id"];
$cat = $_GET["cat"];
$queryexists = mysql_query("SELECT * FROM cats WHERE id='$cid'");
if(mysql_num_rows($queryexists) != 0)
{
}
else
{
header('Location: 404.php');
}
if (isset($_POST["search"])) {
$searchterm = $_POST["search"];
header('Location: '.$configsiteurl.'search/'.$searchterm.'/1');
}
include_once ('head.php');
?>
<div class="container" style="margin-top:80px">
<div class="row" id="main">
<div class="span12" id="content">
<?php
$items = 20;
$page = 1;
if(isset($_GET['page']) and is_numeric($_GET['page']) and $page = $_GET['page'])
$limit = " LIMIT ".(($page-1)*$items).",$items";
else
$limit = " LIMIT $items";
$sqlStr = "SELECT * FROM rssarticles WHERE item_status='1' AND item_category_id = '$cat' ORDER BY item_date DESC ";
$sqlStrAux = "SELECT count(*) as total FROM rssarticles WHERE item_status='1' AND item_category_id = '$cat'";
$aux = Mysql_Fetch_Assoc(mysql_query($sqlStrAux));
$query = mysql_query($sqlStr.$limit);
if($aux['total']>0){
$p = new pagination;
$p->Items($aux['total']);
$p->limit($items);
$p->urlFriendly();
$p->target("%");//#page/1/
$p->currentPage($page);
$p->calculate();
$p->changeClass("pagination");
$ad_sql=mysql_query("Select * from ads WHERE placement='2'");
$ad_count=mysql_num_rows($ad_sql);
if($ad_count!=0) {
$current_row = 1;
}
while($row = mysql_fetch_assoc($query)){
if($ad_count!=0) {
if($current_row % rand(8, 20) == 0) {
$resultad = mysql_query("SELECT * FROM ads WHERE placement='2' ORDER BY RAND() LIMIT 1");
while($rowad = mysql_fetch_array( $resultad )) {
$adid = $rowad["id"];
$adtype = mysql_result(mysql_query("SELECT type FROM ads WHERE id = '$adid'"), 0);
if ($adtype == '1') {
echo '<div class="box photo col3">';
echo '<h5 style="text-align:center">' . $rowad["title"] . '</h5>';
echo $rowad["code"];
echo '</div>';
} else {
echo '<div class="box photo col3">';
echo '<a style="color:black" href="' . $rowad["link"] . '" target="_blank"><h5 style="text-align:center">' . $rowad["title"] . '</h5></a>';
echo '<a href="' . $rowad["link"] . '" target="_blank">';
echo '<img src="'.$configsiteurl.'admin/uploads/'.$rowad["image"].'">';
echo '</a>';
echo '</div>';
}
}
}
}
$itemtitle = $row['item_title'];
$itemtitle2 = str_replace("-"," ",$itemtitle);
$itemimage = $row['item_image'];
echo '<div class="box photo col3">';
echo '<a style="color:black" href="'.$configsiteurl.'article/'.$row['id'].'/'. $itemtitle .'"><h5 style="text-align:center">' . $itemtitle2 . '</h5></a>';
echo '<a href="'.$configsiteurl.'article/'.$row['id'].'/'. $itemtitle .'">';
echo $row['item_image'];
echo '</a>';
echo '<p style="text-align:center;margin-bottom:0px;margin-top:10px;font-size:14px">Posted <abbr class="timeago" title="'.$row["item_date"].'">'.$row["item_date"].'</abbr></p>';
echo '</div>';
if($ad_count!=0) {
$current_row++;
}
}
echo '</div>';
echo '<div class="row">';
echo '<div class="span12" style="text-align:center">';
$p->show();
echo '</div>';
echo '</div>';
} else {
echo"There no are records to paginate.";
}
?>
</div><!-- /container -->
</div>
</div>
<?
include ('foot.php');
?>