Location: PHPKode > projects > Esvon Personals > esvon-personals/inc/pages/sitemap.php
<?php

// --------------------------------------------------------------------------
//
// Esvon Classifieds v.4.0
// Copyright(C), Esvon LTD, 2001-2010, All Rights Reserved.
// E-mail: hide@address.com
//
// All forms of reproduction, including, but not limited to, internet posting, 
// printing, e-mailing, faxing and recording are strictly prohibited.
// One license required per site running Esvon Classifieds. 
// To obtain a license for using Esvon Classifieds, please register at
// http://www.esvon.com/pg/products/p_classifieds/
//
// --------------------------------------------------------------------------

if(!defined('SITE_PATH')) die('Access Denied');

define('SITEMAP_SHOW_ITEMS', 0);

$hw_num = 80; // Items per page, set 0 to display all in one page
$off = (ctype_digit($_GET['off']) && $_SERVER['REQUEST_METHOD']=='GET') ? $_GET['off'] : 0;

$off_min = $hw_num * $off;
$off_max = $off_min + $hw_num;
$off_cur = 0;

$cache = &Factory::singleton('Hw_Cache');
echo $cache->get("p_sitemap_{$off}_{$hw_num}_".$HW_LANG,"SiteMapGet");

function NewUrlStatus($amt = 0){
global $off_min,$off_max,$off_cur,$hw_num;
//echo "$off_cur, $off_min, $off_max, $amt<br>";
  if(!$hw_num) return 'OK';
  if(!$amt) $off_cur++;
  if($off_cur+$amt<=$off_min) return 'S';
  if($off_cur>$off_max) return 'E';
  return 'OK';
}

function SiteMapGet() {
global $off_cur,$off,$hw_num;
    $tpl = new HawkTpl;
    $tpl->InitArray('row');
    SiteMapGetItem($tpl,0);
    $tpl_v = array();
    $tpl_v['nav'] = GetNavigation($_SERVER['PHP_SELF'],$hw_num,10,$off_cur,$off,'&page=sitemap');
    if(EN_SE_URLS){ 
      $lng_add = $GLOBALS['HW_LANG']=='en' ? '' : '-'.$GLOBALS['HW_LANG'];
      $tpl_v['nav'] = preg_replace('/index.php.*?off=(\d+)/','sm-\\1'.$lng_add.'.html',$tpl_v['nav']);
    }
    return $tpl->Parse(TPL_PATH.'sitemap.htm',$tpl_v);
}

function SiteMapGetItem(&$tpl,$parent_id,$level=0) {
  global $db,$TITLE_FIELD;
  static $sql_cat;

  $level++;

  if(!isset($sql_cat)) $sql_cat = hwGetCatSQL('c.id,c.pid,c.name', '', TBL_CAT);
  
  $sql = $sql_cat." AND c.pid='$parent_id' ORDER BY c.weight DESC,name";
  $res = $db->query($sql);
  if (mysql_num_rows($res) > 0) {
    while($v = mysql_fetch_assoc($res)){
      
      $v['indention'] = $level;
      
      if ($level % 2) $v['list_style'] = 'square';
      else $v['list_style'] = 'circle';
      
      $v['cat_url'] = hwGetCatURL($v['id']);

      if(NewUrlStatus()=='OK') $tpl->AddCell('row',$v,'category');
      SiteMapGetItem($tpl,$v['id'],$level);
    }
  }
  elseif(SITEMAP_SHOW_ITEMS) {
    $sql = 'SELECT '.hwSQLFieldsGet()." FROM ".TBL_AD." WHERE catid='$parent_id'".hwFilterGetSQL();
    $res = $db->query($sql);
    $num_rows =  mysql_num_rows($res);
    if(NewUrlStatus($num_rows)!='OK') $num_rows = 0;
    if ($num_rows) { $v['indention'] = $level; $tpl->AddCell('row',$v,'ad_begin'); }
    $num = 0;
    while($v = mysql_fetch_assoc($res)){
      $v['indention'] = $level;
      $v['num'] = ++$num;
      if(NewUrlStatus()=='OK') $tpl->AddCell('row', hwSQLRowGet($v),'ad');
    }
    if($num_rows) $tpl->AddCell('row','','ad_end');
  }

}

?>
Return current item: Esvon Personals