Location: PHPKode > projects > RAMUI WEBBLOG > fw_blog/include/page.php
<?php
class clspage
{
protected $prefix;
function __construct($prefix){$this->prefix=$prefix;}}
class map extends clspage
{
public function page($d)
{
        $list_perpage=50;
        $map=array('title'=>$d, 'description'=>'List of pages in directory '.$d, 'defaultstyle'=>'Y', 'keywords'=>'', 'content'=>'', 'heads'=>'');
        $str='<h1>List of pages: '.substr($d,0,-1).'</h1><ul style="list-style-type:none;">';
//No. of pages.
        $query= sprintf("SELECT id FROM ".$this->prefix."pageinf WHERE pagename LIKE \"%s%%\" AND indexed = 'Y' AND publish = 'Y'",mysql_real_escape_string($d));
        $result= @mysql_query($query);
        $num_page = @mysql_num_rows($result);
//No. of posts.
        $query= sprintf("SELECT id FROM ".$this->prefix."postinf WHERE pagename LIKE \"%s%%\" AND indexed = 'Y' AND publish = 'Y'",mysql_real_escape_string($d));
        $result= @mysql_query($query);
        $num_post = @mysql_num_rows($result);
//Total page to be displayed.
        $totalpages=fw_total_page(($num_page+$num_post), $list_perpage);
//Get current page.
        $current_page=fw_get_querydata('fw_pageno');
        if((!(is_numeric($current_page)))||($current_page===false)){$current_page=1;}
        $start_pagecount=$list_perpage*($current_page-1);

        $num_rows=0;
        if($num_page>$start_pagecount){
                $query= sprintf("SELECT pagename, title, description FROM ".$this->prefix."pageinf WHERE pagename LIKE \"%s%%\" AND indexed = 'Y' AND publish = 'Y' ORDER BY pagename LIMIT $start_pagecount, $list_perpage",mysql_real_escape_string($d));
                $result= @mysql_query($query);
                $num_rows=@mysql_num_rows($result);
                while($row= @mysql_fetch_array($result, MYSQL_ASSOC)){
                            $str.='<li><a href="http://'.getenv("HTTP_HOST").fw_get_docroot().fw_encode_pagename($row['pagename']).'">'.$row['title']. '</a><br />'. $row['description'].'</li>';
                }}

        $end_postcount=$list_perpage-$num_rows;
        $start_postcount=(($num_rows==0)? ($start_pagecount-$num_page) : 0);
        if($end_postcount>0){
                $query= sprintf("SELECT pagename, title, description, date FROM ".$this->prefix."postinf WHERE pagename LIKE \"%s%%\" AND indexed = 'Y' AND publish = 'Y' ORDER BY pagename LIMIT $start_postcount, $end_postcount",mysql_real_escape_string($d));
                $result= @mysql_query($query);
                while($row= @mysql_fetch_array($result, MYSQL_ASSOC)){
                            $str.='<li><a href="http://'.getenv("HTTP_HOST").fw_get_docroot().fw_encode_pagename($row['pagename']).'"><b>'.$row['title']. '</b></a><br />Date last modified: <span style="text-decoration:underline;">'. gmdate("M d, H:i", $row['date']).'</span><br />'.$row['description'].'</li>';}}
        $str.='</ul><div id="fw_pageblock"><b>Total no. of pages: '.$totalpages.'</b>&nbsp;&nbsp;';
        for($i=1; $i<=$totalpages; $i++){
                $str.=(($i==$current_page)? '<span class="fw_pageblock">'.$i.'</span>' : '<a href="http://'.getenv("HTTP_HOST").fw_get_docroot().$d.'index.html?fw_pageno='.$i.'">'.$i.'</a>');}
        $map['content']=$str.'</div>';
        return $map;
}
}
class sitemap extends clspage
{
public function page($sitename)
{
        $list_perpage=50;
        $sitemap=array('title'=>'Sitemap', 'description'=>'', 'defaultstyle'=>'Y', 'keywords'=>'', 'content'=>'', 'heads'=>'');
        $str='<h1>Sitemap : '.$sitename.'</h1><hr/><ul style="list-style-type:none;">';
//No. of pages.
        $query= "SELECT id FROM ".$this->prefix."pageinf WHERE indexed = 'Y' AND publish = 'Y'";
        $result= @mysql_query($query);
        $num_page = @mysql_num_rows($result);
//No. of posts.
        $query= "SELECT id FROM ".$this->prefix."postinf WHERE indexed = 'Y' AND publish = 'Y'";
        $result= @mysql_query($query);
        $num_post = @mysql_num_rows($result);
//Total page to be displayed.
        $totalpages=fw_total_page(($num_page+$num_post), $list_perpage);
//Get current page.
        $current_page=fw_get_querydata('fw_pageno');
        if((!(is_numeric($current_page)))||($current_page===false)){$current_page=1;}
        $start_pagecount=$list_perpage*($current_page-1);

        $num_rows=0;
        if($num_page>$start_pagecount){
                $query= "SELECT pagename, title, description FROM ".$this->prefix."pageinf WHERE indexed = 'Y' AND publish = 'Y' ORDER BY pagename LIMIT $start_pagecount, $list_perpage";
                $result= @mysql_query($query);
                $num_rows=@mysql_num_rows($result);
                while($row= @mysql_fetch_array($result, MYSQL_ASSOC)){
                            $str.='<li><a href="http://'.getenv("HTTP_HOST").fw_get_docroot().fw_encode_pagename($row['pagename']).'">'.$row['title']. '</a><br />'. $row['description'].'</li>';
                }}

        $end_postcount=$list_perpage-$num_rows;
        $start_postcount=(($num_rows==0)? ($start_pagecount-$num_page) : 0);
        if($end_postcount>0){
                $query= "SELECT pagename, title, description, date FROM ".$this->prefix."postinf WHERE indexed = 'Y' AND publish = 'Y' ORDER BY pagename LIMIT $start_postcount, $end_postcount";
                $result= @mysql_query($query);
                while($row= @mysql_fetch_array($result, MYSQL_ASSOC)){
                            $str.='<li><a href="http://'.getenv("HTTP_HOST").fw_get_docroot().fw_encode_pagename($row['pagename']).'"><b>'.$row['title']. '</b></a><br />Date last modified: <span style="text-decoration:underline;">'. gmdate("M d, H:i", $row['date']).'</span><br />'.$row['description'].'</li>';}}
        $str.='</ul><div id="fw_pageblock"><b>Total no. of pages: '.$totalpages.'</b>&nbsp;&nbsp;';
        for($i=1; $i<=$totalpages; $i++){
                $str.=(($i==$current_page)? '<span class="fw_pageblock">'.$i.'</span>' : '<a href="http://'.getenv("HTTP_HOST").fw_get_docroot().'sitemap.html?fw_pageno='.$i.'">'.$i.'</a>');}
        $sitemap['content']=$str.'</div>';
        return $sitemap;
}
}

?>
Return current item: RAMUI WEBBLOG