<?php require_once('includes/searchlecture.inc.php'); require_once('includes/category.inc.php'); $keywords=TGET("kw"); $since=TGET('since'); $upto=TGET('upto'); $minutes=TGET('minutes'); $mb_id_owner=TGET("cs_owner_id"); $CPID=compere_id_requested(); $lang=language_requested(); list($offset,$pagesize,$pageno)=decide_page_range(TGET("p"),TGET("ps")); $timezone_bias_seconds=get_user_time_zone()*60; $dataset['since']=$since; $dataset['upto']=$upto; $dataset['minutes']=$minutes; $dataset['keywords']=$keywords; $DBConn->connect(true); $dataset+=prepare_region_dataset($DBConn); $addon_condmap_eq=array( 'mb_id'=>current_mb_id() ); $since_utc=bias_datetime($since,-$timezone_bias_seconds); $upto_utc=bias_datetime($upto,-$timezone_bias_seconds); $results=search_course($DBConn,$keywords,$since,$upto,$minutes,$offset,$pagesize+1,$addon_condmap_eq); if (!$results) { unset($addon_condmap_eq['zc_country']); $results=search_course($DBConn,$keywords,$since,$upto,$minutes,$offset,$pagesize+1,$addon_condmap_eq); $dataset['NO-RESULT']=array( array( 'COMPERE-SPECIFIED'=>$CPID?array(0):array(), 'COMPERE-UNSPECIFIED'=>$CPID?array():array(0) ) ); } if ($results) { $dataset+=prepare_paging_dataset($pageno,$pagesize,$results); $localCurrencyNameMap=loadLocalCurrencyNameMap(); $cs_ids=array_projection($results,'cs_id'); $places=db_load_course_places($DBConn,$cs_ids); $cs2places=rowset2multimap($places,'cs_id'); $now_utc=seconds_to_datetime(); $currenynames=loadCurrencyNames(); $dataset['RESULT']=array(); foreach ($results as $result) { if ($result['cs_desc_type']=='PLAINTEXT') $result['PLAINDESC']=array(0); else if ($result['cs_desc_type']=='HTML') $result['HTMLDESC']=array(0); $since_max=max(array_select_keyprefix($result,'since_')); $expire_min=min(array_select_keyprefix($result,'expire_')); $result+=array_key_prepend(split_datetime($since_max,$timezone_bias_seconds),'since_'); $result+=array_key_prepend(split_datetime($expire_min,$timezone_bias_seconds),'expire_'); if ($result['since_year']!=$result['expire_year'] || $result['since_month']!=$result['expire_month'] || $result['since_day']!=$result['expire_day']) $result['DAY-DIFFERRED']=array(0); else $result['DAY-SAME']=array(0); $result['since_weekday']=datetime_to_weekday($since_max,$timezone_bias_seconds); $result['expire_weekday']=datetime_to_weekday($expire_min,$timezone_bias_seconds); $result['cs_currency_name']=$currenynames[$result['cs_currency']]; $result['PLACE']=$cs2places[$result['cs_id']]; $result['THUMBNAIL']=$result['cs_thumbnail_url']?array(0):array(); $result['NO-THUMBNAIL']=$result['cs_thumbnail_url']?array():array(0); $result['local_currency_unit']=mapCurrencyLocalName($localCurrencyNameMap,$result['cs_currency'],$lang); $result['popularity']=calculate_course_popularity($result['crct_count'],load_course_viewcount($result['cs_id'])); array_push($dataset['RESULT'],$result); } } if (!$keywords) $dataset['SEARCH-GUIDE']=array(0); if ($CPID) { $dataset['COMPERE']=array(db_load_compere($DBConn,$CPID)); $dataset['META-KEYWORD-TRAIL']=','.$dataset['COMPERE'][0]['cp_name']; } else $dataset['SEARCH-FORM']=array(0); if ($CPID) $compereinfo=get_compere_info_requested($DBConn,$CPID); else $compereinfo=get_compere_info_default(); $rss_url=$compereinfo['rss_url']; $homepage_url=$compereinfo['homepage_url']; $dataset['rss_url']=$rss_url; $dataset['cpi_rss_hide_title']=$compereinfo['rss_hide_title']; $dataset['DISPLAY-RSS']=$rss_url?array(0):array(); $dataset['homepage_url']=$homepage_url; $dataset['HOMEPAGE-AVAIL']=$homepage_url?array(0):array(); $dataset['HOMEPAGE-UNAVAIL']=$homepage_url?array():array(0); if ($CPID && !$REMOTE_IS_SEARCHENGINE) { $dataset['compere.view.count']=1+load_compere_viewcount($CPID); $dataset['COMPERE-VIEW-COUNT']=array(0); if (!COOKIE('reserv_compere_view_counted')) { SET_COOKIE('reserv_compere_view_counted',1,$Config->CountingInterval); @mkdir($Config->Paths['counter.compere'],0755,true); save_compere_viewcount($CPID,$dataset['compere.view.count']); } } ?>