Location: PHPKode > projects > Esvon Personals > esvon-personals/inc/pages/browse.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');

$cid = (int)$_GET['cid'];

if($cid){ 
  $has_subcats = $db->one_data('SELECT COUNT(*) FROM '.TBL_CAT.' WHERE pid='.$cid);
  // simple redirect if tree leaf
  if(!$has_subcats) SE_VerifyValidURL(hwGetBrowseURL($cid));
  // just duplicate URLs protection
  elseif(EN_SE_URLS && !$_GET['off']) SE_VerifyValidURL(hwGetCatURL($cid));
}

require_once SITE_PATH.'inc/class.categ_tree.php';

class HawkCategoryExt extends HawkCategory {
  function ShowCatPath($cid) {
      return GetCatPathCached($cid,1);
      // $s = preg_replace('/&cid=(\d+)/','&cid=\\1&lang='.$GLOBALS['HW_LANG'], $s);
      // return $s;
  }
}

class CachedHawkCategoryExt extends HawkCategoryExt {
  
  function Get_Initial_Amount_Array(){

    $MAX_EXP_TIME_SEC = 30*60;
    
    $o_cache = &Factory::singleton('Hw_Cache');
    $life_sec = $o_cache->getLifeTimeSec();
    if($life_sec>$MAX_EXP_TIME_SEC) $o_cache->setLifeTimeSec($MAX_EXP_TIME_SEC);
    
    $a_v = $o_cache->get('p_Browse_Cat_Amount_Array');
    if(is_null($a_v)){
      $a_v = parent::Get_Initial_Amount_Array();
      $o_cache->save('p_Browse_Cat_Amount_Array', $a_v);
    }
    
    // restore cache setting
    $o_cache->setLifeTimeSec($life_sec);
    return $a_v;
  }

}

// main code

// compatibility
if(!$cid && $_GET['cat']) $cid = (int)$_GET['cat'];

if(EN_U_BROWSE_CATS){ 
  $no_auth = false;
  if($cid && defined('TBL_CAT_EXTRA')) $no_auth = $db->one_data('SELECT COUNT(*) FROM '.TBL_CAT_EXTRA.' WHERE cid="'.$cid.'" AND type="A"');
  if(!$no_auth) CheckLoggedIn();
}

hwRealm('U_BROWSE_CATS');

$items_total = $db->one_data('SELECT COUNT(*) FROM '.TBL_AD);
$class_id = $items_total > 2000 ? 'CachedHawkCategoryExt' : 'HawkCategoryExt';

$o_cat = new $class_id(TBL_CAT,TBL_AD,'catid');
$o_cat->COL_NUM = 2;
$o_cat->HIDE_ZERO = EN_ZERO_CAT ? 0 : 1;

$o_cat->SQL_AMT = hwFilterGetSQL();
$o_cat->CAT_F = 'image,image_alt,descr';
$o_cat->CAT_ORDER = 'weight DESC,name';
$o_cat->TPL_SHOW = FALSE;
$o_cat->CAT_HREF = hwGetCatURL('$id');
$o_cat->NOCAT_HREF = hwGetBrowseURL('$id');

// hwGetCatURL

$buf = $o_cat->GetBrowsePage(TPL_PATH.'browse.htm',$cid,TRUE);
unset($o_cat);

// simple 301 redirect
if($buf===FALSE){ 
  if(!$cid) die('Internal Error');
  SE_VerifyValidURL(hwGetBrowseURL($cid));
}

// Meta Tags
if($cid) hwMetaTagsSetup( array('cid' => $cid) );

if($cid){ 
  $cat_name = GetCatPathCached($cid);
  $cat_url = hwGetBrowseURL($cid);
  $cat_descr = $db->one_data('SELECT descr FROM '.TBL_CAT.' WHERE id="'.$cid.'"');
}
else $cat_name = $cat_url = $cat_descr = '';

$cat = $cid; // older template compatibility
EvalBuffer($buf,'$cid,$cat,$cat_url,$cat_name,$cat_descr',1);

?>
Return current item: Esvon Personals