<?php
include("../common.php");
include("common.php");
//============
//$menu_blog = "<img src='/images/menu_this.jpg' border='0'>";
$titleHeader = $this_section;
//============
$user = $sys["user"];
$subject = "";
$content = "";
$step = $_REQUEST["Submit"];
request("userID","postDate","keyword","catID");
$msg = "";
if($catID){
	$t = mysql_query("select parent.title as parentTitle,child.title as catTitle
	from  $table_cats parent, {$tpre}blog_cats child where parent.ID=child.parentID and child.ID=$catID");
	if($row=mysql_fetch_array($t)){
		$catTitle = $row["catTitle"];
		$parentTitle = $row["parentTitle"];
		$nav = "<a href='/'>$site_name home &gt;&gt;</a>  <a  href='".BLOG_PATH."'>".$this_section." &gt;&gt; </a> $parentTitle <a  href='".BLOG_PATH."$catID/'>$catTitle</a>";
	}
}
else{
	$nav = "<a href='/'>$site_name home &gt;&gt;</a> <a c href='<?=BLOG_PATH?>'>".$this_section." &gt;&gt;";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Pragma" content="no-cache" />
<META name="description" content="<?=$_meta_des?>">
<META name="keywords" content="<?=$_meta_keyword?>">
<meta name="robots" content="follow,index">
<title><?=$titleHeader?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<? include($tps."elements/meta.inc")?>
<link rel="stylesheet" href="<?=BLOG_PATH?>include/style.css" type="text/css">
<script language="javascript">
var max_len = 450;
function resize(elem) {
  if (elem == undefined || elem == null) return false;
  if (elem.width > max_len) elem.width = max_len;  
}
</script>
</HEAD>
<BODY>
	<div id="main_body"> 
    <? include($tps."elements/header.php")?>		
	 <div id="main_body2">       
      		<div id="col_l">
         	<? include("panel_more.htm")?>
	  		</div>		  
            <div id="col_r">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
           
            <td  valign="top"><table width="100%" border="0" cellpadding="5" cellspacing="0">
                <tr> 
                  <td valign="top"> <table width="100%"  border="0" cellpadding="0" cellspacing="0">
                      <tr> 
                        <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr> 
                              <td height="18" align="left"> 
                                <?=$nav?>
                              </td>
                            </tr>
                          </table></td>
                      </tr>
                      <tr> 
                        <td align="center"> 
                          <?=$msg1?>
                        </td>
                      </tr>
                      <tr> 
                        <td valign="top"> 
                          <!------- search result start ------>
                          <table width="100%" height="50"  border="0" cellpadding= "cellspacing=0">
                            <tr> 
                              <td height="30" align="left" valign="middle"> 
<?
$condStr = " where parentID='0'";
if($catID)
  $condStr .= "and catID='$catID'";
if($keyword){
	$ccc = " and (";
	$count = 0;
	$arr = split(" ",$keyword);
	for($i=0;$i<count($arr);$i++){
		$cc = $arr[$i];
		$cc = trim($cc);
		if($cc){
			if($count==0)
				$ccc .= " subject like '%$cc%' || content like '%$cc%'";
			else	
				$ccc .= " || subject like '%$cc%'  || content like '%$cc%'";
			$count++;
		}	
	}
	$ccc .= ")";
	$condStr .= $ccc;	
}
if($userID){
	$condStr .= " and userID='$userID' ";
}
if($postDate){
	$condStr .= " and postDate='$postDate' ";
}
$sortStr = "";
If($sortBy) $sortStr = " order by $sortBy"; else  $sortStr = " order by ID desc"; 	
if (!isset($step)) $step = 20;
if (!isset($from)) $from = 0;
//===========================================================================
$goto = $_REQUEST["goto"];
$count = $_REQUEST["count"];	
if($goto!=""){
	if($goto<=0) $from = 0;
	else if($goto>$count/$step)  $from = (int)(($count - 1) / $step) * $step;	
	else $from = ($step*$goto)-$step;		
}
//===========================================================================
$sql="SELECT * FROM $table_details $condStr $sortStr limit ".$from.",".$step;
$tsql = "SELECT count(ID) as total from $table_details $condStr";
$result = mysql_query($sql) or die(mysql_error());
$tquery = mysql_query($tsql) or die(mysql_error());
$trows = mysql_fetch_array($tquery);
$count = $trows['total'];
if($count == "0") echo "Your search yielded no result.<br>";
$param="count=$count&st=s&sortBy=$sortBy".getPara($fields_search)."&tag=".urlencode($tag)."&sections=$sections";	
	$colspan=1;
	$pageStr = pages($from,$step,$count,$param);
?>
                                <div class="head"><?php echo $msg?> </div>
                                <? if($count>0){?>
                                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                  <tr> 
                                    <td> 
                                      <?=search_results($from,$step,$count);?>
                                    </td>
                                    <td> <?php echo $pageStr;?> </td>
                                  </tr>
                                </table>
                                <? }?>
                                <table width="100%" cellspacing="5" cellpadding="0" align-"left">
<?php
$swapC = "";
$c1 = 0;
$bgcolorC = 0;
$caching_date = "";
while ($i = mysql_fetch_array($result)) {
	if($c1 % 2 ==0) $swapC = "";else $swapC="";
	$c1++;
	$ID = $i["ID"];
	$subject = $i["subject"];
	$user = $i["user"];$user = "Posted by: $user";
	$pDate = "<font class='small'>".$i["postDate"]."</font>";  
	$hotnet = BLOG_PATH.hotnet_url($ID,$subject);
	$subject = "<a class='link_title' href='$hotnet'>$subject</a>";
	//---------------------------------------
	$postDate = substr($i["postDate"],0,10);
	$postDate = date("l M d, Y",strtotime($postDate));
	if($caching_date!=$postDate){
		$caching_date = $postDate;
		$dis_date = "<div class='title'>".$caching_date."</div>";
	}
	else{
		$dis_date = "";
	}
	//---------------------------------------
	if($bgcolorC % 2 == 0) $bgcolor=""; else  $bgcolor=""; 	
		echo "<tr $bgcolor><td class='listing_div'>$dis_date<div>$subject <br>$user $pDate</div></td></tr>";
	$bgcolorC++;   
}
?>
                                </table>
                                <? if($count>0){?>
                                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                  <tr> 
                                    <td> 
                                      <?=search_results($from,$step,$count);?>
                                    </td>
                                    <td> <?php echo $pageStr;?> </td>
                                  </tr>
                                </table>
                                <? }?>
                              </td>
                            </tr>
                          </table>
                          <!------- search result end ------>
                        </td>
                      </tr>
                    </table></td>
                </tr>
              </table></td>
          </tr>
        </table>
      </div>
	  <!--col_r end-->
	  <div style="clear: both;">&nbsp;</div>		     
    </div>	 
</div>
<? include($tps."elements/footer.php")?>
</body>
</html>