// -------------------------------------------------------------------------- // // Esvon Classifieds v.3.0 // Copyright(C), Esvon LTD, 2001-2005, All Rights Reserved. // E-mail: products@esvon.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/ // // 13.05.2005 10:57 // // -------------------------------------------------------------------------- @set_time_limit(0); require './config.php'; require './functions.php'; require './tpl.inc.php'; define('EN_DEBUG_INFO', 0); if(EN_DEBUG_INFO){ $HwTimer =& HwTimer::getInstance(); $HwTimer->startTimer(); } if (ini_get('register_globals') != 1){ $a_v = array('_SERVER','_GET','_POST','_COOKIE'); foreach($a_v as $_s) { if($$_s) hw_gpc_extract($$_s, $GLOBALS); } unset($a_v); } $_ARR = ReadCache(); $tpl = new tpl(); $tpl->set('SITE_URL', SITE_URL); $tpl->set('WS_NAME', WS_NAME); function GetCatPath($cid){ global $_ARR; $s = $_ARR['CATEGORY'][$pid]['NAME']; $pid = $cid; while($pid){ $s = ' > '.''.$_ARR['CATEGORY'][$_ARR['CATEGORY'][$pid]['ID']]['NAME'].''.$s; $pid = $_ARR['CATEGORY'][$_ARR['CATEGORY'][$pid]['ID']]['PID']; } return $s; } $cid = $_REQUEST['cid']; $id = $_REQUEST['id']; function GetDaughterCats($arr){ global $_ARR; if(!$arr) return array(); $a_s = $arr; foreach($arr as $cid){ if($_ARR['CATEGORY_PID'][$cid]) $a_s = array_merge($a_s,GetDaughterCats($_ARR['CATEGORY_PID'][$cid])); } return $a_s; } function GetTotalAds($arr){ static $A_AMT; if(!$arr) return 0; if(!isset($A_AMT)){ global $_ARR; foreach($_ARR['ITEM'] as $item) $A_AMT[$item['CATID']]++; } $amt = 0; foreach($arr as $catid) $amt+=$A_AMT[$catid]; return $amt; } switch ($_REQUEST['page']) { case 'details': $a_item = $_ARR['ITEM'][$id]; $tpl->set('link_id', $id); $tpl->set('cat_path', GetCatPath($a_item['CATID'])); $tpl->set('category', $_ARR['CATEGORY'][$a_item['CATID']]['NAME']); foreach($a_item['FIELD'] as $key=>$val){ $tpl->set($key, $val['VALUE']); } // $tpl->set('title', $a_item['FIELD']['f_title']['VALUE']); $tpl->set('IMAGES', $a_item['IMAGES']?$a_item['IMAGES']:array()); //$a_item['FIELD']['f_price']['VALUE'] = '$'.number_format($a_item['FIELD']['f_price']['VALUE'],2,'.',','); $tpl->set('FIELDS', $a_item['FIELD']); $tpl->set('PAGE_TITLE', $a_item['FIELD']['f_title']['VALUE']); $tpl_f = file_exists(TPL_PATH.'details_'.$a_item['FSETID'].'.htm') ? 'details_'.$a_item['FSETID'].'.htm' : 'details.htm'; $buf = $tpl->fetch(TPL_PATH.$tpl_f); break; default: if(EN_BROWSE){ if(!$cid) $cid = 0; // cid init //print_r($_ARR['CATEGORY_PID'][$cid]); if($_ARR['CATEGORY_PID'][$cid?$cid:'0']) foreach($_ARR['CATEGORY_PID'][$cid?$cid:'0'] as $v){ $_ARR['CATEGORY'][$v]['TOTAL'] = GetTotalAds(GetDaughterCats(array($_ARR['CATEGORY'][$v]['ID']))); $cats[] = $_ARR['CATEGORY'][$v]; } $tpl->set('IS_CATS', $cats, true); } else{ $tpl->set('IS_CATS', false, true); } $cats = array(); $tpl->set('CATS', $cats); $cat_path = $cid ? GetCatPath($cid) : ''; $tpl->set('cat_path', $cat_path); if(!$_REQUEST['off'] || !is_numeric($_REQUEST['off']) || $_REQUEST['off']<0) $_REQUEST['off'] = 0; $num = $_REQUEST['off'] * DISP_ROWS; // $row) { $a_sort[$key] = $_REQUEST['s_by']=='images'?($row['IMAGES'][0]?1:0):$row['FIELD'][$_REQUEST['s_by']]['VALUE']; } array_multisort($a_sort, ($_REQUEST['asc']!='asc'?SORT_DESC:SORT_ASC), $_ARR['ITEM']); } //..sorting if(EN_BROWSE) foreach($_ARR['ITEM'] as $k=>$v){ if($_ARR['ITEM'][$k]['CATID']!=$cid) unset($_ARR['ITEM'][$k]); } $num_rows = count($_ARR['ITEM']); $nav = GetNavigation($_SERVER['PHP_SELF'],DISP_ROWS,10,$num_rows,$_REQUEST['off'],"&cid=".$cid."&s_by=".$_REQUEST['s_by']."&asc=".$_REQUEST['asc'].""); $tpl->set('nav', $nav); $tpl->set('num_rows', $num_rows); $tpl->set('from', $num+1); $tpl->set('to', $num+DISP_ROWS>$num_rows?$num_rows:$num+DISP_ROWS); $_ARR['ITEM'] = array_slice_key($_ARR['ITEM'],$num,DISP_ROWS); if($_ARR['ITEM']) foreach($_ARR['ITEM'] as $k=>$v){ $items[$k]['link_id'] = $v['LINK_ID']; $items[$k]['num'] = ++$num; foreach($v['FIELD'] as $key=>$val){ $items[$k][$key] = $val['VALUE']; } // $items[$k]['f_price'] = '$'.number_format($items[$k]['f_price'],2,'.',','); $items[$k]['images'] = $v['IMAGES'][0]?'':'—'; $items[$k]['f_descr'] = $v['FIELD']['f_descr']['VALUE']; } $tpl->set('IS_ITEMS', $items, true); $tpl->set('ITEMS', $items); $tpl->set('PAGE_TITLE', $cid ? substr(strip_tags($cat_path),3) : hwLng('home') ); $tpl->set('href', "index.php?cid=$cid&asc=".($_REQUEST['asc']=='asc'?'desc':'asc')."&s_by="); $tpl_f = file_exists(TPL_PATH.'rows_'.$v['FSETID'].'.htm') ? 'rows_'.$a_item['FSETID'].'.htm' : 'rows.htm'; $buf = $tpl->fetch(TPL_PATH.$tpl_f); } echo $tpl->fetch(TPL_PATH.'header.htm'); echo $buf; echo $tpl->fetch(TPL_PATH.'footer.htm'); if(EN_DEBUG_INFO){ $HwTimer =& HwTimer::getInstance(); echo '
[ Page generation time: '. sprintf( '%.4f',$HwTimer->endTimer() ). ' s ]
'; } ?>