cache_sql=$s; $this->cache_file=$f; $this->distribution_id=$d; $this->pagestarttime=strtotime("now"); } } ?> logicengine = $logicengine; $this->r_url = $r_url; } public function export_html($html,$p_a=""){ if (!is_array($p_a)){ $p_a=$this->buffer_set; } if (stristr($html,"",$offset); $logic_string = substr($data,($offset+13),($endset-$offset-13)); $widget_replace = substr($data,$offset,($endset-$offset+5)); $page_widget=""; eval($logic_string); //should process a way to set $page_widget $data = str_replace($widget_replace,$page_widget,$data); $dlen=strlen($data); if ($dlen<=$offset){ return $data; } } return $data; } public function handlelogic($data,$stack_data){ $offset=0; $stack=0; $elogic_processed = Array(); if(stristr($data, '%elogic_if%') !== FALSE) { while($offset = strpos($data, "%elogic_if%", $offset + 1)){ $endset = strpos($data,"%elogic_end%",$offset); $logic_string = substr($data,($offset+11),($endset-$offset-11)); $tlogic_replace = substr($data,$offset,($endset-$offset+12)); $tlogic_do = strpos($logic_string,"%do%"); $tlogic_check = substr($logic_string,0,$tlogic_do); $tlogic_query = explode("=",$tlogic_check); $tlogic_query_required = substr($tlogic_query[1],1,(strlen($tlogic_query[1])-2)); if (stristr($tlogic_query_required,"|")){ $tlogic_query_required = explode("|",$tlogic_query_required); } $tlogic_query = $tlogic_query[0]; $tlogic_else = strpos($logic_string,"%else%"); $tlogic_if_true = substr($logic_string,($tlogic_do+4),($tlogic_else-$tlogic_do-4)); $tlogic_if_false= substr($logic_string,($tlogic_else+6),($endset-$tlogic_else-6)); $tlogic_query = substr($tlogic_query,1,(strlen($tlogic_query[1])-2)); $tlogic_magenta_stack = $stack_data; if (stristr($tlogic_query,"|") !== FALSE){ $tlogic_shell = explode("|",$tlogic_query); foreach($tlogic_shell as $extend_stack){ $tlogic_magenta_stack = $tlogic_magenta_stack[$extend_stack]; } } else { if (isset($tlogic_magenta_stack[$tlogic_query])){ $tlogic_magenta_stack = $tlogic_magenta_stack[$tlogic_query]; } else { $tlogic_magenta_stack = ""; } } $match=false; if (is_array($tlogic_query_required)){ if (in_array($tlogic_magenta_stack,$tlogic_query_required)){ $match=true; } } else { if ($tlogic_magenta_stack == $tlogic_query_required){ $match=true; } } if ($match){ $data = str_replace($tlogic_replace,$tlogic_if_true,$data); } else { $data = str_replace($tlogic_replace,$tlogic_if_false,$data); } $elogic_processed[$stack] = "@".$offset." - IF: (".$tlogic_check.") THEN: (".$tlogic_if_true.") ELSE: (".$tlogic_if_false.")"; // $offset = $endset; $stack++; } //print_r($elogic_processed); } return $data; } } ?> pclass=$prifunctions; $this->distribution_id = $prifunctions['distribution_id']; $this->rpath=substr($rpath,1); } public function get_page(){ if ($this->rpath==""){ $this->rpath="index.html"; } if ($this->rpath=="index.html"){ if ($this->pclass['settings']['site_mode'] == "random"){ $this->resource_meta_kw = $lx['page_meta_keywords']; $this->resource_meta_description = $lx['page_meta_description']; return $this->pclass['fb_products']->display_random_products(); } } $this->cms_location="index.html"; $result = $this->fb_sql_query("SELECT * FROM fb_admin_distribution_content WHERE dist_id=".$this->pclass['settings']['dist_id']." AND page_url='".$this->rpath."'",3600,"cms_".str_replace("/","-",$this->rpath)); if ($this->fb_sql_num_rows()==0){ return "404 File Not Found"; } $lx = $result[0]; $this->resource_title = $this->pclass['init_buffer']['page_title']." | ".$lx['page_title']; $this->resource_meta_kw = $lx['page_meta_keywords']; $this->resource_meta_description = $lx['page_meta_description']; $page = $this->process_page($lx['page_content']); return $page; } private function process_page($page=""){ $page = str_replace("",$this->pclass['fb_products']->display_random_products(10),$page); return $page; } public function open_blog(){ $bpath = str_replace("blog.vsp","",$this->rpath); $blog = "\n
\n"; switch (strtolower($bpath)){ case "/home": case "": case "/": $this->resource_title = $this->pclass['init_buffer']['page_title']." | Blog Home"; $result = $this->fb_sql_query("SELECT * FROM fb_admin_distribution_content WHERE dist_id=".$this->pclass['settings']['dist_id']." AND page_blog='y' AND page_published='y' ORDER BY page_modified DESC LIMIT 5",3600,"cms_blog"); foreach ($result AS $lx){ $pc = $lx['page_content']; $pl = preg_replace("/[^A-Za-z0-9_-]+/","-",$lx['page_title']); //if (strlen($pc) >400){ $pc = substr($pc,0,600)."...[read more]"; } $pc = $this->restoreTruncatedTags($this->truncateByWords($pc, 100, "...[read more]")); $mo = date("M",$lx['page_modified']); $d = date("jS",$lx['page_modified']); $y = date("Y",$lx['page_modified']); $t = date("G:i",$lx['page_modified']); $blog.="

".$lx['page_title']."

$mo $d, $y at $t by Listings Manager

".$pc."

 
\n\n"; } break; default: $link = explode("/",substr($bpath,1)); $lid = str_replace(".html","",$link[1]); $result = $this->fb_sql_query("SELECT * FROM fb_admin_distribution_content WHERE dist_id=".$this->pclass['settings']['dist_id']." AND page_blog='y' AND page_published='y' AND page_id=".$lid." ORDER BY page_modified DESC LIMIT 5",3600,"cms_".$lid); if ($this->fb_sql_num_rows()>0){ $lx = $result[0]; if (preg_replace("/[^A-Za-z0-9_-]+/","-",$lx['page_title']) == $link[0]){ $this->resource_title = $this->pclass['init_buffer']['page_title']." | ".$lx['page_title']; $this->resource_meta_kw = $lx['page_meta_keywords']; $this->resource_meta_description = $lx['page_meta_description']; $mo = date("M",$lx['page_modified']); $d = date("jS",$lx['page_modified']); $y = date("Y",$lx['page_modified']); $t = date("G:i",$lx['page_modified']); $blog.="« Back to Blog Home

".$lx['page_title']."

$mo $d, $y at $t by Listings Manager

".$lx['page_content']."

\n\n"; } else { $blog.="page not found"; } } else { $blog.="page not found"; } break; } $blog.="\n
\n"; return $blog; } /* truncate text by length */ private function truncateByLength($string, $limit, $break=" ", $pad="..."){ // return with no change if string is shorter than $limit if(strlen($string) <= $limit) return $string; $string = substr($string, 0, $limit); if(false !== ($breakpoint = strrpos($string, $break))) { $string = substr($string, 0, $breakpoint); } return $string . $pad; } /* truncate text by number of words */ private function truncateByWords($input, $numwords, $padding="..."){ $output = strtok($input, " \n"); while(--$numwords > 0) $output .= " " . strtok(" \n"); if($output != $input) $output .= $padding; return $output; } /* restore tags chopped during truncation */ private function restoreTruncatedTags($input){ $opened = array(); // loop through opened and closed tags in order if(preg_match_all("/<(\/?[a-z]+)>?/i", $input, $matches)) { foreach($matches[1] as $tag) { if(preg_match("/^[a-z]+$/i", $tag, $regs)) { // a tag has been opened if(strtolower($regs[0]) != 'br') $opened[] = $regs[0]; } elseif(preg_match("/^\/([a-z]+)$/i", $tag, $regs)) { // a tag has been closed //unset($opened[array_pop(array_keys($opened, $regs[1]))]); } } } // close tags that are still open if($opened) { $tagstoclose = array_reverse($opened); foreach($tagstoclose as $tag) $input .= ""; } return $input; } /* account options */ public function accountvsp(){ $bpath = str_replace("account.vsp/","",$this->rpath); $bpath = explode("/",$bpath,3); $buffer=""; $onetimekey=md5(strtotime("now").rand(0,99)); /* return this code if not logged in */ $nlc = "Not Logged in"; switch (strtolower($bpath[0])){ case "login": /* show the login page */ $r = "/account.vsp/".$bpath[1]."/".$bpath[2]; if (substr($bpath[2],0,8) == "Redirect"){ $r = substr($bpath[2],9)."?op=".$bpath[1]; } //$r = urlencode(base64_encode($r)); $this->fb_sql_query_nocache("UPDATE fb_sessions SET onetimekey='".$onetimekey."' WHERE session_id='".$this->pclass['session']."'"); $buffer = " "; break; case "postback": $onetimekey = $_REQUEST['otk']; $authprovider=$_REQUEST['authby']; break; case "dashboard": /* account home */ if ($this->pclass['auth_token']==0){ return $nlc; } $buffer="My Account"; break; case "home": if ($this->pclass['auth_token']==0){ return $nlc; } $buffer.="Logged in Wait a moment"; break; } //$r = "Account (".var_export($bpath,true).")"; return $buffer; } } ?> pclass=$t; $this->distribution_id = $t['distribution_id']; $this->publish_ids=$pids; if (isset($_REQUEST['facet'])){ $this->r_facet = $_REQUEST['facet']; } } public function search_form(){ $search = "
Search
Search for

".$this->search_form_facet_options()."
"; return $search; } private function search_form_facet_options($facet_type='global',$facet_fid=0){ $dg = Array(); if (isset($_REQUEST['disable_fg'])){ $dg = $_REQUEST['disable_fg']; } $rtn="
"; if ($facet_type=="global"){ /* apply facet searching to publishing point ids */ $plist="("; foreach ($this->publish_ids AS $p_id => $p_name){ $plist.="gf.pb_id=".$p_id." OR "; } $plist=substr($plist,0,-3).")"; $query = "SELECT * FROM global_facets AS gf LEFT JOIN global_facets_group AS gfg ON gf.fct_grp=gfg.fct_grp WHERE ".$plist." ORDER BY gf.fct_grp,gf.f_order ASC"; } else { /* apply facet searching to feed id */ $query = "SELECT * FROM global_feed_facets AS gf LEFT JOIN global_facets_group AS gfg ON gf.fct_grp=gfg.fct_grp WHERE feed_id=".$facet_fid." ORDER BY gf.fct_grp,gf.f_order ASC"; } $tfacet=""; $lfb=""; $lfc=0; $result = $this->fb_sql_query($query,3600,"sfo_".$facet_fid); foreach ($result AS $lx){ $lfb=""; if ($lx['fg_desc'] <> $tfacet && (!in_array($lx['fg_desc'],$dg))){ if ($lfc>0){ $rtn.=$lfb; } else { if ($tfacet<>""){ //$rtn.=""; } } $lfc=0; if ($lx['fg_desc'] <> $tfacet){ $tfacet=$lx['fg_desc']; $lfb= "
\n
"; } else { $lfb=""; } } $m = $lx['fc_req']; if (!is_numeric($m)){ $m="'".$m."'"; } $d = $lx['fct_id'].",".$lx['fc_field']." ".$lx['fc_match']." ".$lx['fc_req']; if ($lx['fc_match'] == "bt"){ $d.=" ".$lx['fc_req_2']; } $attq = "".$d.";"; $tl = ""; } if ($lfc>0){ $rtn.=$lfb; } return $rtn."
By ".$tfacet."
".$lx['facet']."
"; } /* standard search */ public function new_search($tml,$query=""){ if ($query == ""){ $query=$_GET['query']; } if ($query == ""){ return $this->search_form(); } $limitstart=0; if (isset($_REQUEST['from'])){ $limitstart = $_REQUEST['from']; } $this->buffer.="
"; $this->buffer.="
'".$query."'
"; if (isset($this->r_facet)){ foreach($this->r_facet AS $f){ $this->enable_facet_filters($f); } } $activefilters = $this->apply_facet_filters(); $this->buffer.= $this->display_facet_filters($activefilters,mysql_real_escape_string($query)); $facetsearch = $this->facet_search_query($activefilters,$query); $this->buffer.= $this->display_facet_filters($activefilters,$facetsearch[1]); $rescount = 0; if (isset($this->pclass['settings']['search_results'])){ $rescount = $this->pclass['settings']['search_results']; } else { $rescount = $this->pclass['settings']['similar_results']; } $pages = ceil($facetsearch[0] / $rescount); if ($facetsearch[0] == 0){ /* $this->buffer.= $load_catalogue[2]; */ } $this->buffer.="
"; $res=$this->display_product_list($facetsearch[1],$tml); $this->buffer = $res[0].$this->buffer; $this->buffer.= $res[1]."
"; return $this->buffer; } public function new_search_filter($tml,$_uri){ $uri = explode("/",$_uri); $field = $uri[2]; $filter= urldecode($uri[3]); $query = ""; switch ($field){ case "supplier_id": $query="f.feed_id=".($filter -0); break; case "brand_name": $query="fc.brand_name='".mysql_real_escape_string($filter)."'"; break; case "fieldA": $query="fm.fieldA='".mysql_real_escape_string($filter)."'"; break; default: return "failed"; break; } $limitstart=0; if (isset($this->r_facet)){ foreach($this->r_facet AS $f){ $this->enable_facet_filters($f,'local',$filter); } } $activefilters = $this->apply_facet_filters(); if ($activefilters==""){ $facetsearch = $this->filter_search_query($query); $res = $this->display_product_list($facetsearch[1],$tml); $facetlist = $this->display_facet_filters($activefilters,$facetsearch[1],'local',$filter); } else { $query = "select f.online_price,f.id,f.feed_id,f.image_url,f.image_url_2,p.product_id,p.image_path,f.product_name,f.description,f.product_code,fc.brand_name,s.weight,s.dlimage from feeddata_product AS f LEFT JOIN feeddata_misc AS fm ON fm.id = f.id LEFT JOIN feeddata_catalogue AS fc ON fc.id = f.id LEFT JOIN products AS p ON p.feeddata_id=f.id left join pp_item_to_cat AS p2c ON p2c.fid = f.id left join publishing_points AS pp on pp.pp_id = p2c.cat LEFT JOIN supplier as s ON s.supplier_id = f.feed_id where f.status_on='y' AND fm.dupe='n' AND ".$query." GROUP BY f.id"; //$facetsearch = $this->facet_search_query($activefilters,$query); $res = $this->display_product_list($query,$tml); $facetlist = $this->display_facet_filters($activefilters,$query,'local',$filter); } if (isset($_REQUEST['from'])){ $limitstart = $_REQUEST['from']; } $this->buffer.="
"; $this->buffer.="
'Search by Supplier'
"; /* if (isset($this->r_facet)){ foreach($this->r_facet AS $f){ $this->enable_facet_filters($f); } } $activefilters = $this->apply_facet_filters(); $this->buffer.= $this->display_facet_filters($activefilters,$query); */ //$this->buffer.=$facetsearch[1]; //$this->buffer.= $this->display_facet_filters($activefilters,$facetsearch[1]); $rescount = 0; if (isset($this->pclass['settings']['search_results'])){ $rescount = $this->pclass['settings']['search_results']; } else { $rescount = $this->pclass['settings']['similar_results']; } $pages = ceil($facetsearch[0] / $rescount); if ($facetsearch[0] == 0){ /* $this->buffer.= $load_catalogue[2]; */ } $this->buffer.="
"; $this->buffer.=$facetlist; $this->buffer.="
"; $this->buffer.="
"; $this->buffer ="
\n". $res[0]."\n
".$this->buffer; $this->buffer.= $res[1]."
"; return $this->buffer; } /* display a list of products by the category */ public function display_product_list($query,$tml){ $plist = $this->get_product_list($query); $filters="query=".$_REQUEST['query']."&"; $bfiltersize=strlen($filters); if (isset($_REQUEST['sort'])){ $sortby = $_REQUEST['sort']; /* ie: online_price,product_name,brand_name */ $filters.="sort=".$sortby."&"; if (isset($_REQUEST['sort_order'])){ $sortm = $_REQUEST['sort_order']; /* ie: asc, desc */ $filters.="sort_order=".$sortm."&"; } } if (isset($_REQUEST['sortby'])){ $sby = explode(".",$_REQUEST['sortby']); $sortm = $sby[1]; $sortby= $sby[0]; switch ($sortby){ case "unset": $filters.=""; break; case "price": $sortby = "online_price"; $filters.="sortby=".$_REQUEST['sortby']."&"; break; case "name": $sortby = "product_name"; $filters.="sortby=".$_REQUEST['sortby']."&"; break; case "brand": $sortby = "brand_name"; $filters.="sortby=".$_REQUEST['sortby']."&"; break; } } if (strlen($filters)>$bfiltersize){ $plist = $this->sort_multidimensional_array ($plist, $sortby, $sortm); } if (isset($_REQUEST['facet'])){ foreach($_REQUEST['facet'] AS $f){ $filters.="facet[]=".$f."&"; } } if (isset($_REQUEST['disable_fg'])){ foreach($_REQUEST['disable_fg'] AS $f){ if ($f<>""){ $filters.="disable_fg[]=".$f."&"; } } } $pcount= count($plist); $rescount = 0; if (isset($this->pclass['settings']['search_results'])){ $rescount = $this->pclass['settings']['search_results']; } else { $rescount = $this->pclass['settings']['similar_results']; } $pages = round($pcount / $rescount,0); $startat=0; if (isset($_REQUEST['from'])){ $startat=$_REQUEST['from']; } $pagin = $this->pclass['fb_products']->pagination($pages,$rescount,$startat,$pcount,"?".$filters,$pcount); $html=""; foreach(array_slice($plist,$startat,$rescount) AS $item){ $item['image_path'] = $this->pclass['settings']['cdn_url'].$item['image_path']; //i commented this out because it was causing issues with the thumbnails on search /* if (isset($item['dlimage']) && $item['dlimage'] == "y"){ $item['image_path'] = $this->pclass['settings']['cdn_url'].$item['image_path']; } else { $item['image_path'] = $item['image_url']; } */ $html.=$this->pclass['fb_template']->export_html($tml,$item); } return array($pagin,$html); } /* get the list of products base on a sql stattement, cache if possible */ private function get_product_list($query){ $plist = Array(); $dlimage = "on"; if (isset($this->pclass['settings']['download_image'])){ $dlimage = $this->pclass['settings']['download_image']; } $result = $this->fb_sql_query($query,3600,"search"); foreach ($result AS $lx){ $ld = Array(); $ld['path_local'] =$this->pclass['fb_products']->create_clear_link_to_product($this->get_product_path($lx['id']),$lx['id'],$lx['product_name'],false); if ($dlimage=="off" || (isset($lx['dlimage']) && $lx['dlimage']=="n")){ $ld['image_path'] = $lx['image_url']; $lx['image_path'] = $ld['image_path']; } else { //$lx['image_path'] = $this->pclass['settings']['cdn_url'].$lx['image_path']; } $lx['online_price'] = number_format($lx['online_price'],2); array_push($plist,array_merge($ld,$lx)); } if ($mlist = $this->facet_search_array($this->facetsenabled,$plist)){ return $mlist; } else { return $plist; } } /* get mpath of product */ private function get_product_path($fid){ $seopath = $this->pclass['settings']['seopath']; switch ($seopath){ case "vsp_sku_item": $mpath = "/feedbuilder.vsp/product/"; return $mpath; break; default: $mpath = "/"; break; } $result = $this->fb_sql_query("select f.id,pp.parent_id,pp.master_category,pp.catalogue_name from feeddata_product as f left join pp_item_to_cat AS p2c on p2c.fid = f.id left join publishing_points AS pp ON pp.pp_id = p2c.cat where f.id=".$fid." AND pp.enabled='y' limit 1",3600,"product_path_".$fid); if (count($result)==0){ return "/feedbuilder.vsp/product/"; } $lx = $result[0]; if ($lx['parent_id'] ==0){ $mpath="/".$lx['master_category']."/".$lx['catalogue_name']."/"; } else { $mpath= $this->get_inner_product_path($lx['parent_id'])."/".$lx['catalogue_name']."/"; } return str_replace("//","/","/".$mpath); } private function get_inner_product_path($parent_id){ $mpath="/"; $result = $this->fb_sql_query("select parent_id,catalogue_name,master_category FROM publishing_points WHERE pp_id=".$parent_id." AND enabled='y' limit 1",3600,"inner_path_".$parent_id); if ($this->fb_sql_num_rows()==0){ return $mpath; } $lx = $result[0]; if ($lx['parent_id'] >0){ $mpath = $this->get_inner_product_path($lx['parent_id'])."/".$lx['catalogue_name'].""; } else { $mpath = $lx['master_category']."/".$lx['catalogue_name']; } return $mpath; } /* facet product search query builder */ private function facet_search_query($mq,$sc=""){ $mc="AND ("; foreach ($this->publish_ids AS $p_id => $p_name){ $mc.="pp.master_category='".$p_name."' OR "; } $mc=substr($mc,0,-3).")"; $hv = ""; if (strlen($sc)>5 || $this->f_applied>0){ $hv = "having matchscore >0 "; } if (isset($this->pclass['settings']['feat_facet_s'])){ if ($this->pclass['settings']['feat_facet_s']=="n"){ $mc=" AND (".$this->pclass['feed_list'].")"; //limited to suppliers $hv = "having matchscore >10 "; //stricter search } } $fq = "select f.online_price,f.id,f.feed_id,p.product_id,f.image_url,p.image_path,f.product_name,f.description,f.product_code,fc.brand_name,(MATCH ( f.product_name, f.description ) AGAINST ('".$sc."')) * CASE WHEN f.product_name LIKE '%".$sc."%' THEN 7 WHEN f.description LIKE '%".$sc."%' THEN 3 ELSE 1 END AS matchscore from feeddata_product AS f LEFT JOIN feeddata_catalogue AS fc ON fc.id = f.id LEFT JOIN products AS p ON p.feeddata_id=f.id left join pp_item_to_cat AS p2c ON p2c.fid = f.id left join publishing_points AS pp on pp.pp_id = p2c.cat left join feeddata_misc AS fm ON fm.id = f.id where f.status_on='y' AND fm.dupe='n' ".$mc." ".$mq." GROUP BY f.id ".$hv."order by matchscore desc"; if (isset($_REQUEST['devmode'])){ echo $fq; } $fr = "select count(distinct(f.id)) from feeddata_product AS f left join feeddata_misc AS fm ON fm.id = f.id LEFT JOIN feeddata_catalogue AS fc ON fc.id = f.id LEFT JOIN catalogue_affinity AS ca ON (fc.level1=ca.level1 AND fc.level2=ca.level2 AND fc.level3=ca.level3 AND fc.level4 = ca.level4 AND fc.level5=ca.level5) LEFT JOIN products AS p ON p.feeddata_id=f.id left join pp_item_to_cat AS p2c ON p2c.fid = f.id left join publishing_points AS pp on pp.pp_id = p2c.cat where (MATCH ( f.product_name, f.description ) AGAINST ('".$sc."')) * CASE WHEN f.product_name LIKE '%".$sc."%' THEN 7 WHEN f.description LIKE '%".$sc."%' THEN 3 ELSE 1 END AND f.status_on='y' AND fm.dupe='n' ".$mc." ".$mq." ".$hv; $ctl=0; $result = $this->fb_sql_query($fr,1,"facet_count"); $ctl = $result; /* if (!$ctl = $this->pclass['fb_cache']->sql_count_load(9999999999,$fr)){ $fc = mysql_query($fr); $ctl = mysql_result($fc,0,0); $this->pclass['fb_cache']->sql_count_store($fr,$ctl); } */ return Array($fc,$fq); } /* apply filters for facet based functions */ private function apply_facet_filters($tq=""){ if (count($this->r_facet)>0){ foreach ($this->r_facet AS $f){ $tq .= "AND "; if (count($f)>1){ $tq.="("; } foreach($f AS $t){ $tq.=$t." AND "; } $tq = substr($tq,0,-4); if (count($f)>1){ $tq.=")"; } $tq.=" "; $this->f_applied++; } } return $tq; } /* enable facet filters */ private function enable_facet_filters($f,$facet_group='global',$facet_id=0){ $plist="("; foreach ($this->publish_ids AS $p_id => $p_name){ $plist.="gf.pb_id=".$p_id." OR "; } $plist=substr($plist,0,-3).")"; if ($facet_group=='global'){ $fq="SELECT * FROM global_facets AS gf LEFT JOIN global_facets_group AS gfg ON gf.fct_grp=gfg.fct_grp WHERE ".$plist." AND gf.fct_id=".$f." ORDER BY gf.fct_grp"; } else { $fq="SELECT * FROM global_feed_facets AS gf LEFT JOIN global_facets_group AS gfg ON gf.fct_grp=gfg.fct_grp WHERE gf.feed_id=".$facet_id." AND gf.fct_id=".$f." ORDER BY gf.fct_grp"; } $vv = mysql_query($fq); if (mysql_num_rows($vv)>0){ $lx=mysql_fetch_array($vv,MYSQL_ASSOC); $m = $lx['fc_req']; if (!is_numeric($m)){ $m="'".$m."'"; } $d = $lx['fct_id'].",".$lx['fc_field']." ".$lx['fc_match']." ".$lx['fc_req']; if ($lx['fc_match'] == "bt"){ $d.=" ".$lx['fc_req_2']; } $attq = "".$d.";"; if(stristr($this->facetsenabled, $attq) === FALSE) { $this->facetsenabled.=$attq; } } } /* display a list of facet filters */ private function display_facet_filters($mq,$sc,$facet_group="global",$facet_id=0,$products=Array()){ $dg = Array(); if (count($products)==0){ $products = $this->get_product_list($sc); } if (isset($_REQUEST['disable_fg'])){ $dg = $_REQUEST['disable_fg']; } $rtn=""; $plist="("; foreach ($this->publish_ids AS $p_id => $p_name){ $plist.="gf.pb_id=".$p_id." OR "; } $plist=substr($plist,0,-3).")"; if ($facet_group=='global'){ $fq="SELECT * FROM global_facets AS gf LEFT JOIN global_facets_group AS gfg ON gf.fct_grp=gfg.fct_grp WHERE ".$plist." ORDER BY gf.fct_grp,gf.f_order ASC"; } else { $fq="SELECT * FROM global_feed_facets AS gf LEFT JOIN global_facets_group AS gfg ON gf.fct_grp=gfg.fct_grp WHERE gf.feed_id=".$facet_id." ORDER BY gf.fct_grp,gf.f_order ASC"; $fq="SELECT * FROM global_feed_facets AS gff LEFT JOIN global_feed_to_facet AS gftf ON gff.fct_method = gftf.method_id LEFT JOIN global_facets_descriptions AS gfd ON gfd.fct_id = gftf.fct_id LEFT JOIN global_facets_group AS gfg ON gfg.fct_grp = gfd.fct_grp WHERE gftf.feed_id=".$facet_id." AND gfg.fg_desc IS NOT NULL GROUP BY gff.fc_req ORDER BY gfg.fg_desc ASC"; } if (isset($_REQUEST['devmode'])){ echo "
".$fq; } $result = $this->fb_sql_query($fq,3600,"filters_".$facet_group."_".$facet_id); $tfacet=""; $lfb=""; $lfc=0; foreach ($result AS $lx){ if ($lx['fg_desc'] <> $tfacet && (!in_array($lx['fg_desc'],$dg))){ if ($lfc>0){ $rtn.=$lfb; } else { if ($tfacet<>""){ //$rtn.=""; } } $lfc=0; $tfacet=$lx['fg_desc']; $lfb= ""; } $m = $lx['fc_req']; if (!is_numeric($m)){ $m="'".$m."'"; } $d = $lx['fct_id'].",".$lx['fc_field']." ".$lx['fc_match']." ".$lx['fc_req']; if ($lx['fc_match'] == "bt"){ $d.=" ".$lx['fc_req_2']; } $attq = "".$d.";"; $tl = ""; } } if ($lfc>0){ $rtn.=$lfb; } return $rtn."
By ".$tfacet."
"; $tc= $this->facet_search_count($products,$attq).""; if ($tc>0){ $lfc++; $lfb.= $tl." ".$tc."
"; } /* facet product search query builder */ private function filter_search_query($mq,$sc="",$hv=""){ $mc="("; foreach ($this->publish_ids AS $p_id => $p_name){ $mc.="pp.master_category='".$p_name."' OR "; } $mc=substr($mc,0,-3).") AND "; $mc=""; $fq = "select f.online_price,f.id,f.feed_id,f.image_url,f.image_url_2,p.product_id,p.image_path,f.product_name,f.description,f.product_code,fc.brand_name,s.dlimage,s.weight from feeddata_product AS f LEFT JOIN feeddata_catalogue AS fc ON fc.id = f.id LEFT JOIN feeddata_misc AS fm ON fm.id = f.id LEFT JOIN catalogue_affinity AS ca ON (fc.level1=ca.level1 AND fc.level2=ca.level2 AND fc.level3=ca.level3 AND fc.level4 = ca.level4 AND fc.level5=ca.level5) LEFT JOIN products AS p ON p.feeddata_id=f.id left join pp_item_to_cat AS p2c ON p2c.fid = f.id left join publishing_points AS pp on pp.pp_id = p2c.cat LEFT JOIN supplier as s ON s.supplier_id = f.feed_id where fm.dupe='n' AND f.status_on='y' AND ".$mc." ".$mq." GROUP BY f.id ".$hv.""; if (isset($_REQUEST['debugquery'])){ echo $fq; } $fr = "select count(distinct(f.id)) from feeddata_product AS f LEFT JOIN feeddata_catalogue AS fc ON fc.id = f.id LEFT JOIN catalogue_affinity AS ca ON (fc.level1=ca.level1 AND fc.level2=ca.level2 AND fc.level3=ca.level3 AND fc.level4 = ca.level4 AND fc.level5=ca.level5) LEFT JOIN feeddata_misc as fm ON fm.id =f.id LEFT JOIN products AS p ON p.feeddata_id=f.id left join pp_item_to_cat AS p2c ON p2c.fid = f.id left join publishing_points AS pp on pp.pp_id = p2c.cat where f.status_on='y' AND fm.dupe='n' AND ".$mc." ".$mq.""; $ctl=0; if (!$ctl = $this->pclass['fb_cache']->sql_count_load(9999999999,$fr)){ $fc = mysql_query($fr); $ctl = mysql_result($fc,0,0); $this->pclass['fb_cache']->sql_count_store($fr,$ctl); } return Array($fc,$fq); } /* sort array - may send this to a global functions file as it appears a few times*/ private function sort_multidimensional_array ($array, $index, $order, $natsort=FALSE, $case_sensitive=FALSE) { if(is_array($array) && count($array)>0) { foreach(array_keys($array) as $key) $temp[$key]=$array[$key][$index]; if(!$natsort) { if ($order=='asc') asort($temp); else arsort($temp); } else { if ($case_sensitive===true) natsort($temp); else natcasesort($temp); if($order!='asc') $temp=array_reverse($temp,TRUE); } foreach(array_keys($temp) as $key) if (is_numeric($key)) $sorted[]=$array[$key]; else $sorted[$key]=$array[$key]; return $sorted; } return $sorted; } } ?> dist_settings,$this->auth_token,$this->buffer_set,$this->publish_ids */ function __construct($dist_settings,$auth_token,$buffer_set,$pids,$pagetype,$dist_id){ $this->pclass=Array("dist_settings" =>$dist_settings, "auth_token"=>$auth_token, "buffer_set"=>$buffer_set, "publish_id"=>$pids); $this->dist_id=$dist_id; switch ($pagetype){ case "checkout": $this->buffer= $this->vspcheckout(); break; case "basket": $this->buffer= $this->mybasket(); break; } } /* checkout functions */ private function vspcheckout(){ $session_id = $this->pclass['buffer_set']['session_id']; $vv = mysql_query("SELECT * FROM fb_client_basket WHERE session_id='".$session_id."'"); if (mysql_num_rows($vv)==0){ return "Your basket is empty.(1)"; } $lx = mysql_fetch_array($vv,MYSQL_ASSOC); if ($lx['status'] <> "p"){ return "Your basket is not in the pending state."; } $basket_id=$lx['basket_id']; $basket_value=$lx['total']; if ($lx['paytoken'] > ""){ if ($lx['paymethod'] == "paypal"){ // paypal if (!INCLUDE("_codebase/_3rdparty/paypal_toolkit/paypalfunctions.class.php")){ return "Payment integration failed"; } if ($_GET['token'] == $lx['paytoken']){ $paypal = new PayPal(); $resArray = $paypal->GetShippingDetails( $lx['paytoken'] ); $email = $resArray['EMAIL']; $name = $resArray['FIRSTNAME']." ".$resArray['LASTNAME']; $address1 = $resArray['SHIPTONAME']; $address2 = $resArray['SHIPTOSTREET']; $address3 = $resArray['SHIPTOCITY']; $address4 = $resArray['SHIPTOSTATE']; $address5 = $resArray['SHIPTOZIP']; $country = $resArray['SHIPTOCOUNTRYNAME']; $a_status=$resArray['ADDRESSSTATUS']; $shiparray = $resArray; $pArray = Array( 'Token' => $lx['paytoken'], 'paymentType' => "Sale", 'currencyCodeType' => "GBP", 'payer_id' => $resArray['PAYERID'] ); $resArray = $paypal->ConfirmPayment ( $basket_value, $pArray ); $ack = strtoupper($resArray["ACK"]); if( $ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING" ){ $transactionId = $resArray["TRANSACTIONID"]; $transactionType= $resArray["TRANSACTIONTYPE"]; $paymentType = $resArray["PAYMENTTYPE"]; $orderTime = $resArray["ORDERTIME"]; $amt = $resArray["AMT"]; $currencyCode = $resArray["CURRENCYCODE"]; $feeAmt = $resArray["FEEAMT"]; $settleAmt = $resArray["SETTLEAMT"]; $taxAmt = $resArray["TAXAMT"]; $exchangeRate = $resArray["EXCHANGERATE"]; $paymentStatus = $resArray["PAYMENTSTATUS"]; $pendingReason = $resArray["PENDINGREASON"]; $reasonCode = $resArray["REASONCODE"]; $ack = serialize(array($shiparray,$resArray)); $user_id=0; $rr=mysql_query("SELECT user_id FROM fb_client_users WHERE email='".strtolower('email')."'"); if (mysql_num_rows($rr)==1){ $user_id=mysql_result($rr,0,0); } if (!is_numeric($feeAmt)){ $feeAmt=0; } $query = "INSERT INTO fb_client_orders (basket_id,dist_id,user_id,order_status,email,name,address1,address2,address3,address4,address5,country,address_status,paid_amt,vendor_chrg,ack) VALUES (".$basket_id.",".$this->dist_id.",".$user_id.",0,'".$email."','".$name."','".$address1."','".$address2."','".$address3."','".$address4."','".$address5."','".$country."','".$a_status."',".$basket_value.",".$feeAmt.",'".addslashes($ack)."')"; mysql_query($query) or print($query." ".mysql_error()); //$pt = var_export($resArray,true); $pt = "

Order Complete!

"; $vv=mysql_query("UPDATE fb_client_basket SET session_id='--ORDER COMPLETE-' WHERE basket_id=".$basket_id); $vv=mysql_query("UPDATE fb_client_basket SET status='c' WHERE basket_id=".$basket_id); } else { $pt = "Could not authorise payment."; $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); $pt.= "
GetExpressCheckoutDetails API call failed. "; $pt.= "
Detailed Error Message: " . $ErrorLongMsg; $pt.= "
Short Error Message: " . $ErrorShortMsg; $pt.= "
Error Code: " . $ErrorCode; $pt.= "
Error Severity Code: " . $ErrorSeverityCode; } } else { $pt = "Payment request does not match payment validation received. Contact us."; } } return $pt; } // paypal if (!INCLUDE("_codebase/_3rdparty/paypal_toolkit/paypalfunctions.class.php")){ return "Payment integration failed"; } $paypal = new PayPal(); $currencyCode = "GBP"; $paymentType = "Sale"; $returnURL = "http://www.buyerotica.co.uk/checkout.vsp/PaypalPaid"; $cancelURL = "http://www.buyerotica.co.uk/basket.vsp/Cancel"; $resArray = $paypal->CallShortcutExpressCheckout ($basket_value, $currencyCode, $paymentType, $returnURL, $cancelURL); $ack = strtoupper($resArray["ACK"]); if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING"){ $trans_url = $paypal->getRedirectURL( $resArray["TOKEN"] ); $vv = mysql_query("UPDATE fb_client_basket SET paytoken='".$resArray["TOKEN"]."' WHERE basket_id=".$basket_id); $vv=mysql_query("UPDATE fb_client_basket SET paymethod='paypal' WHERE basket_id=".$basket_id); HEADER("Location: ".$trans_url); } else { //Display a user friendly Error on the page using any of the following error information returned by PayPal $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); $res= "SetExpressCheckout API call failed. "; $res.="
Detailed Error Message: " . $ErrorLongMsg; $res.="
Short Error Message: " . $ErrorShortMsg; $res.="
Error Code: " . $ErrorCode; $res.="
Error Severity Code: " . $ErrorSeverityCode; return $res; } } /* basket functions */ private function mybasket(){ $basket="
"; $session_id = $this->pclass['buffer_set']['session_id']; $vv = mysql_query("SELECT * FROM fb_client_basket WHERE session_id='".$session_id."'"); if (mysql_num_rows($vv)==0){ return "Your basket is empty.(1)"; } $lx = mysql_fetch_array($vv,MYSQL_ASSOC); if ($lx['status'] <> "p"){ return "Your basket is not in the pending state."; } $basket_id=$lx['basket_id']; if ($lx['paytoken'] <> ""){ $r = mysql_query("UPDATE fb_client_basket SET paytoken='' WHERE basket_id=".$basket_id); } if (isset($_POST['basketline'])){ foreach ($_POST['basketline'] AS $bl => $qy){ $qy=round($qy); if ($qy==0){ $v = mysql_query("DELETE FROM fb_client_basket_items WHERE basket_id=".$basket_id." AND basket_item_id=".($bl -0)); } else { $v = mysql_query("UPDATE fb_client_basket_items SET qty=".($qy -0)." WHERE basket_id=".$basket_id." AND basket_item_id=".($bl -0)); } } } $vv = mysql_query("SELECT * FROM fb_client_basket_items AS bi LEFT JOIN feeddata AS f ON f.id = bi.item_id LEFT JOIN products AS p ON p.feeddata_id = f.id WHERE bi.basket_id=".$basket_id); if (mysql_num_rows($vv)==0){ return "Your basket is empty."; } $basket.=""; $subtotal = 0; $subtotal_rrp = 0; $shipping =10; while ($rx=mysql_fetch_array($vv,MYSQL_ASSOC)){ $extra_text=""; $product_attrib = $this->product_attributes($rx['item_id'],$rx['attrib']); $lt = $rx['qty'] * round(($rx['online_price'] + $product_attrib['price']),2); if ($product_promotion = $this->check_if_product_is_promoted($rx['promotion_id'],$rx['item_id'])){ $lt=0; if ($rx['qty']>1){ $v = mysql_query("UPDATE fb_client_basket_items SET qty=1 WHERE basket_id=".$basket_id." AND basket_item_id=".$rx['basket_item_id']); } $rx['qty']=1; $extra_text = "
This product is free as it is part of a promotion."; } $subtotal +=$lt; $subtotal_rrp += ($rx['qty'] * $rx['offline_price']); $img_src = $this->pclass['dist_settings']['cdn_url'].$rx['image_path']; $basket.=""; //$basket.=var_export($rx,true); } $basket.="
QtyProduct CodeDescriptionRRPOur Price EaLine Total

Update
".$rx['product_code']." ".$rx['product_name']."
".$product_attrib['detail']."".$extra_text; if ($p_text = $this->check_for_promotions_on_product($rx['item_id'])){ $basket.="
Promotion: ".$p_text[0].""; } $basket.="
".$rx['offline_price']." ".$this->price_format(($rx['online_price'] + $product_attrib['price']))." ".$this->price_format($lt)."

"; return $basket; } private function price_format($pval){ $sym = "£"; return $sym." ".number_format($pval,2); } private function product_attributes($item_id,$attribs){ $attribs = unserialize($attribs); $adjp = 0; if (count($attribs)==0){ return Array("detail"=>"","price"=>0); } $adata = ""; foreach ($attribs AS $a){ $vv = mysql_query("SELECT pid.attribute_name,pai.ai_title,pai.price_adjust FROM products_attributes_ids AS pid LEFT JOIN products_attributes_items AS pai ON pid.attribute_id = pai.attrib_id WHERE pid.attribute_id=".$a[0]." AND pai.ai_id=".$a[1]); while ($rx=mysql_fetch_array($vv,MYSQL_ASSOC)){ $adata.="".$rx['attribute_name'].": ".$rx['ai_title']." ".$rx['price_adjust']."
"; $adjp += substr($rx['price_adjust'],1); } } return Array("detail"=>$adata,"price"=>$adjp); } /* check if a product activates any promotions */ private function check_for_promotions_on_product($fid){ if ($this->unique_promotion_id >0){ return false; } $vv = mysql_query("SELECT * FROM global_merchandising_sets AS gms LEFT JOIN global_merchandising_item_to_set AS i2s ON i2s.set_id = gms.set_id LEFT JOIN global_merchandising_catalogues AS gmc ON gmc.merc_id = gms.merc_id LEFT JOIN fb_client_promotions AS fcp ON fcp.promotion_id = gms.promotion_id WHERE i2s.f_id=".$fid.""); if (mysql_num_rows($vv)==0){ return false; } $lx = mysql_fetch_array($vv,MYSQL_ASSOC); if ($lx['promotion_unique'] == "y"){ $this->unique_promotion_id = $lx['promotion_unique']; } return Array($lx['promotion_code'],$lx['promotion_text']); } /* check if the product is activated by another products promotion */ private function check_if_product_is_promoted($prd,$item_id){ if (!is_numeric($prd)){ return false; } $vv = mysql_query("SELECT * FROM fb_client_promotions WHERE promotion_id=".$prd." AND reward_product=".$item_id); if (mysql_num_rows($vv)==0){ return false; } return mysql_fetch_array($vv,MYSQL_ASSOC); } /* check if order qualifies for free delivery */ private function check_free_delivery($subtotal){ $vv = mysql_query("SELECT * FROM fb_client_promotions WHERE promotion_syntax='freedel' AND activating_value<=".$subtotal); if (mysql_num_rows($vv)==0){ return false; } return true; } } ?> shoplingerie.co.uk | Error 3: Invalid

shoplingerie.co.uk is not enabled currently

There does not appear to be a valid license in place for this domain. Your request can not continue.

Info:



magenta.license.valid = false magenta.access.domain = shoplingerie.co.uk

Powered By: Feedbuilder 1.3.7 (VMA) Framework