#!/usr/bin/perl # index # my $testing = 0; # $testing = 1; # Uncomment if testing # $testing = 1 if $ENV{'SERVER_NAME'} =~ /^wt\d*.demoweb/ ; # Uncomment if testing # $testing = 1 if $ENV{'SERVER_NAME'} eq 'demosearch.web4-u.co.uk'; # Uncomment if testing # $testing = 1 if $ENV{'SERVER_NAME'} eq 'angleseyvisitor.com'; # Uncomment if testing # $testing = 1 if $ENV{'SERVER_NAME'} eq 'visit-north-wales.co.uk'; # Uncomment if testing print "Content-type: text/html\n\n"; print '

New Testing In Progress

' if $testing; print '

Thank you for your patience

' if $testing; require $ENV{'DOCUMENT_ROOT'}."/cgi-bin/vars1.pl"; require $ENV{'DOCUMENT_ROOT'}."/cgi-bin/site1.pl"; require $ENV{'DOCUMENT_ROOT'}."/cgi-bin/commonpublic.cgi"; use vars qw{ $htmlseoanalysiscompleted $cgi $dbh $inforef $homepageref $htmlmetadescription $htmlmetakeywords $htmlpagetitle $testing }; use DBI; use LWP::UserAgent; use IO::Socket; use Time::Local; use CGI; use CGI::Cookie; use strict; use URI::Escape; use HTML::Entities; use Image::Magick; my $cgi = new CGI; my $debug; my $html = ''; my $htmlseoanalysiscompleted = 0; my $htmlpagetitle = ''; my $htmlmetakeywords = ''; my $htmlmetadescription = ''; # print "OK2
"; # foreach ($cgi->param) { print " -- OK : $_
"; } # print "OK3
"; # print " --- : ", $cgi->param('categoryname'), "
"; # print "OK3
"; my $dbh = database_connect(); my $websiteref = get_system_website_which($dbh,$ENV{'SERVER_NAME'}); print " --- $ENV{'SERVER_NAME'} " if $testing; $debug .= "
\n" if $testing; # foreach (sort keys %{$websiteref}) { $debug .= " WEBSITEREF : $_ = $websiteref->{$_}
\n" if $testing; } # foreach (sort keys %{$websiteref}) { $debug .= " WEBSITEREF : $_ = $websiteref->{$_}
\n"; } if ( $websiteref->{websiteredirectredirectid} ) { $html .= get_system_website_default_redirect_display($dbh,$websiteref); } elsif ($websiteref->{displaytemplate} || $websiteref->{demodisplaytemplate}) { $html .= get_system_website_creation($dbh,$websiteref); } else { $html .= get_system_website_default_startup_display($dbh,$ENV{'SERVER_NAME'}); } foreach (keys %ENV) { $html =~ s/\$\bENV_$_\b/$ENV{$_}/gi; # $debug .= "$_ = $ENV{$_}
"; # print "$_ = $ENV{$_}
"; } print $html; print $debug; ########################################################################## ########################################################################## sub get_system_website_creation { my $dbh = shift; my $websiteref = shift; my $html = ''; # print " DEBUG London 1 - ($websiteref->{id} - $websiteref->{name} - $websiteref->{website})
"; # foreach (sort keys %{$websiteref}) { print " WEBSITEREF : $_ = $websiteref->{$_}
\n"; } ################################### # Find if the new 26-8-2007 template system is being used # print "DEBUG 28238 : $websiteref->{displaytemplate} (ID = $websiteref->{displaytemplateid})
"; # print "DEBUG 28238 : $websiteref->{demodisplaytemplate} (ID = $websiteref->{demodisplaytemplateid})
"; if ($websiteref->{liveversion} && $websiteref->{displaytemplateid}) { # Must be Live && a displaytemplateid available $websiteref->{wtdisplay} = get_web4udisplay_default_template($dbh,$websiteref->{displaytemplateid}); # print " BOB # 8282 - websiteref wtpage count : ", (scalar keys %{$websiteref->{wtdisplay}}), "
"; # foreach my $field (sort keys %{$websiteref->{wtdisplay}}) { print " --- $field : $websiteref->{wtdisplay}->{$field}
"; } $websiteref->{wtpage} = get_web4udisplay_webpage($dbh,$websiteref->{wtdisplay}->{websiteid}); # print " BOB 8282 - websiteref wtpage count : ", (scalar keys %{$websiteref->{wtpage}}), "
"; # foreach my $field (sort keys %{$websiteref->{wtpage}}) { print " --- $field : $websiteref->{wtpage}->{$field}
\n"; } $websiteref->{wtproduct} = get_web4udisplay_product($dbh,$websiteref->{wtdisplay}->{memberid}); # foreach my $field (sort keys %{$websiteref->{wtproduct}}) { print " --- $field : $websiteref->{wtproduct}->{$field}
"; } # $websiteref->{wtwebpage} = } elsif (!$websiteref->{liveversion} && $websiteref->{demodisplaytemplateid}) { # Must not be Live && a demodisplaytemplateid available $websiteref->{wtdisplay} = get_web4udisplay_default_template($dbh,$websiteref->{demodisplaytemplateid}); $websiteref->{wtpage} = get_web4udisplay_webpage($dbh,$websiteref->{wtdisplay}->{websiteid}); $websiteref->{wtproduct} = get_web4udisplay_product($dbh,$websiteref->{wtdisplay}->{memberid}); # print " BOB 8282 - websiteref wtpage count : ", (scalar keys %{$websiteref->{wtpage}}), "
"; # foreach my $field (sort keys %{$websiteref->{wtpage}}) { print " --- $field : $websiteref->{wtpage}->{$field}
\n"; } } # ################################### ################################### # Get and load template $html .= get_website_template_choice($websiteref); # ################################### my $original_dir = $inforef->{imageurl}.$websiteref->{memberusername}; my $wtemplate_dir = $websiteref->{wtdisplay}->{memberusername} ? $inforef->{imageurl}.$websiteref->{wtdisplay}->{memberusername} : $inforef->{imageurl}.$websiteref->{memberusername}; my $webpageref = get_system_website_webspage_all($dbh,$websiteref); # if ($testing) { # print " --- CATEGORYNAME : ", $cgi->param('categoryname'), "
"; # foreach my $rowid (sort keys %{$webpageref}) { # dprint(" WEBPAGEREF : $rowid = $webpageref->{$rowid} \n"); # foreach (sort keys %{$webpageref->{$rowid}}) { # dprint(" WEBPAGEREF : $rowid : $_ : $webpageref->{$rowid}->{$_} \n"); # } # } # } # print " -- OK
"; # foreach ($cgi->param()) { print " -- OK : $_ = ", $cgi->param($_),"
"; } my $homepageref = get_system_website_webpage_homepage_ref($dbh,$websiteref); $homepageref->{displayname} = get_businessname_or_name($homepageref); # print " DEBUG 23922 : $homepageref->{id} -- --- $homepageref->{displayname} ($websiteref->{id} -- $websiteref->{website})
"; ##################################################### # Content retrevial # foreach (sort keys %{$websiteref}) { print " WEBSITEREF : $_ = $websiteref->{$_}
\n"; } if ($cgi->param('web4usearch')) { # print " --- Search : web4usearch : ", $cgi->param('web4usearch'), "
"; ($websiteref->{_WEBSITEcontent},$websiteref->{_WEBSITEpagetitle},$websiteref->{_WEBSITEmetadescription},$websiteref->{_WEBSITEmetakeywords}) = ('Default','Search for ..','Search for ..','Search for ..'); my $formref = translate_cgiparam($cgi); if ($cgi->param('web4usearch') eq 'accommodation_facility_list') { # print " --- Search : web4usearch (accommodation_facility_list) : ", $cgi->param('web4usearch'), "
"; $websiteref->{_WEBSITEcontent} = get_system_search_accommodation_facility($dbh,$webpageref,$websiteref,$formref); } else { # print " --- Search : web4usearch (initial) : ", $cgi->param('web4usearch'), "
"; ($websiteref->{_WEBSITEcontent}) = get_system_search($dbh,$webpageref,$websiteref,$formref); } } else { # print " --- htmlseoanalysiscompleted = $htmlseoanalysiscompleted ($websiteref->{_WEBSITEpagetitle})
"; ($websiteref->{_WEBSITEcontent},$websiteref->{_WEBSITEpagetitle},$websiteref->{_WEBSITEmetadescription},$websiteref->{_WEBSITEmetakeywords},$htmlseoanalysiscompleted) = get_system_website_webpage_content($dbh,$websiteref,$cgi,$htmlseoanalysiscompleted); # print " --- htmlseoanalysiscompleted = $htmlseoanalysiscompleted ($websiteref->{_WEBSITEpagetitle})
"; } ##################### # Note: Content regexp $html =~ s/\$\b\_WEBSITEcontent\b/$websiteref->{_WEBSITEcontent}/gi; # ##################################################### foreach (keys %{$homepageref}) { # dprint(" homepageref : $_ = $homepageref->{$_} "); $html =~ s/\$\b$_\b/$homepageref->{$_}/gi; $html =~ s/\$\b\_ACTIVE\_$_\b/get_active_element_replacement($_,$homepageref->{$_},$homepageref)/egi; } my $homepagebasetextref = translate_basetext_to_html($homepageref->{basetext}); $homepagebasetextref = get_product_public_display_changes($homepagebasetextref); foreach (keys %{$homepagebasetextref}) { # dprint(" homepagebasetextref : $_ = $homepagebasetextref->{$_} "); $homepageref->{$_} = $homepagebasetextref->{$_}; $html =~ s/\$\b$_\b/$homepagebasetextref->{$_}/gi; $html =~ s/\$\b\_ACTIVE\_$_\b/get_active_element_replacement($_,$homepagebasetextref->{$_},$homepageref)/egi; } if ($html =~ /\$\_MENU\_ITEM\d+/i) { # $websiteref->{'_MENU_ITEM1'} = 'ccccc'; foreach my $rowid (sort keys %{$webpageref}) { $websiteref->{'_MENU_ITEM'.$rowid.'_TITLE'} = $webpageref->{$rowid}->{title}; $websiteref->{'_MENU_ITEM'.$rowid.'_FILENAME'} = $webpageref->{$rowid}->{filename}; } } $html =~ s/\$\b\_MENU_DEFAULTLIST_DISPLAY_ALL\b/get_menu_defaultlist_display_all($webpageref)/egi; $html =~ s/\$\b\_MENU_SPECIFICLIST_DISPLAY_ALL\b/get_menu_specificlist_display_all($websiteref,$webpageref)/egi; foreach (keys %{$websiteref}) { # dprint(" JUYG WEBSITEREF : $_ = $websiteref->{$_} \n"); $html =~ s/\$\b$_\b/$websiteref->{$_}/gi; } $html =~ s/\$\_MENU\_ITEM\d+\_\w+//gi; ######################################################################## # SEO if not completed previously # print " homepageref : htmlpagetitle = $homepageref->{htmlpagetitle}
"; # print " homepageref : htmlautomateseo = $homepageref->{htmlautomateseo}
"; if (!$htmlseoanalysiscompleted) { if ($homepageref->{htmlautomateseo} eq 'checked') { $htmlpagetitle = create_seo_htmlpagetitle_for_single_business($homepageref,$homepagebasetextref); $htmlmetadescription = create_seo_htmldescription_for_single_business($homepageref,$homepagebasetextref); $htmlmetakeywords = create_seo_htmlpagetitle_for_single_business($homepageref,$homepagebasetextref); } else { $htmlpagetitle = $homepageref->{htmlpagetitle}; $htmlmetadescription = $homepageref->{htmlmetadescription}; $htmlmetakeywords = $homepageref->{htmlmetakeywords}; } $htmlseoanalysiscompleted = 1; } else { $htmlpagetitle = $websiteref->{_WEBSITEpagetitle}; $htmlmetadescription = $websiteref->{_WEBSITEmetadescription}; $htmlmetakeywords = $websiteref->{_WEBSITEmetakeywords}; } # ######################################################################## $html =~ s/\£/£/gi; # $html =~ s/\$\b\_MENU_(vertical|horezontal)\b/get_system_website_menu($dbh,$1,$webpageref)/egi; $html =~ s/\$\b\_WEB4U\_SPECIFIC\_PROCESS\b\((.*?)\)/getweb4u_specific_process($dbh,$webpageref,$websiteref,$1)/egi; $html =~ s/\$\b\_JS\b/$original_dir/gi; $html =~ s/\$\b\_DESIGNJS\b/$wtemplate_dir/gi; $html =~ s/\$\b\_CSS\b/$original_dir/gi; $html =~ s/\$\b\_DESIGNCSS\b/$wtemplate_dir/gi; $html =~ s/\$\b\_IMAGE\b/$original_dir/gi; $html =~ s/\$\b\_DESIGNIMAGE\b/$wtemplate_dir/gi; $html =~ s/\$\b\_SEARCH_(.+?)_FORM_LIST\b\((.*?)\)/get_search_form_list($dbh,$1,$2)/egi; $html =~ s/\$\b\_FACILITES_FORM_LIST\b\((.*?)\)/get_facilites_form_list($1)/egi; $html =~ s/\$\b\_FACILITES_DISPLAY_LIST\b/get_facilites_display_list($homepagebasetextref,'text')/egi; $html =~ s/\$\b\_FACILITES_DISPLAY_PICTURES\b/get_facilites_display_list($homepagebasetextref,'picture')/egi; $html =~ s/\$\b\_FACILITES_DISPLAY_ALL_(\w+)\b/get_facilites_display_all_list($dbh,$1)/egi; $html =~ s/\$\b\_HTMLPAGETITLE\b/$htmlpagetitle/gi; $html =~ s/\$\b\_HTMLMETAKEYWORDS\b/$htmlmetakeywords/gi; $html =~ s/\$\b\_HTMLMETADESCRIPTION\b/$htmlmetadescription/gi; $html =~ s/\$\b\_ListAll3rdPartyItems\b/get_ListAll3rdPartyItems($dbh,$websiteref)/ge; $html =~ s/\$\b\_B4U_securebookinglink\b/get_b4u_securebookinglink($dbh,$websiteref,$homepageref,$homepagebasetextref)/egi; if ($html =~ /\$\_BUSINESSITEM/i) { $html = get_different_business_page_aspect($dbh,$websiteref,$html); } ############################################################### # Sort all the pictures out $html = get_the_public_images_needed_for_display($dbh,$html,$homepageref); # ############################################################### $html =~ s/\$\b.+?\b//g; # $html =~ s/AMPERSAND/&/gi; return $html; } sub getweb4u_specific_process_param_list { my %f = (); foreach (split /,/, shift) { my ($field,$value) = split /=/, $_; # print " -- getweb4u_specific_process_param_list : OK : $field = ($value)
\n"; $f{$field} = $value; } return \%f; } sub getweb4u_specific_process { my $dbh = shift; my $webpageref = shift; my $websiteref = shift; my $formref = getweb4u_specific_process_param_list(shift); my $html = ''; ############################################################# # if ($formref->{web4usearch}) { if ($formref->{web4usearch} eq 'get_system_product_list') { $html .= get_system_product_list($dbh,$webpageref,$websiteref,$formref); } else { $html .= get_system_search($dbh,$webpageref,$websiteref,$formref); } } # ############################################################# return $html; } sub get_system_product_list { my $dbh = shift; my $webpageref = shift; my $websiteref = shift; my $formref = shift; my $html = '$BODY'; my $sql_x = ''; if ($formref->{condition}) { # print " DEBUG CONDITION (get_system_product_list) : $formref->{condition}
"; foreach (split /&/, $formref->{condition}) { if (/^(\w+)\{(.+)\}/) { my ($fieldname,$fieldvaluelist,$fieldvalue) = ($1,$2,''); # print " DEBUG CONDITION (get_system_product_list) : fieldname = $fieldname
"; # print " DEBUG CONDITION (get_system_product_list) : fieldvaluelist = $fieldvaluelist
"; foreach (split /~/, $fieldvaluelist) { $fieldvalue .= ',"'.$_.'"'; } $fieldvalue =~ s/^,//; # print " DEBUG CONDITION (get_system_product_list) : fieldvalue = $fieldvalue
"; $sql_x .= ' and '.$fieldname.' in ('.$fieldvalue.')'; } } } if ($formref->{templatelistparent}) { $html = loadspecificfile($inforef->{imagedir}.$websiteref->{memberusername}.'/'.$formref->{'templatelistparent'}); } # print '
DEBUG HTML get_system_product_list : '.$html.'EOF
'; my $template = 'No template : templatelistitem provided'; if ($formref->{templatelistitem}) { $template = loadspecificfile($inforef->{imagedir}.$websiteref->{memberusername}.'/'.$formref->{'templatelistitem'}); } # print '
DEBUG TEMPLATE get_system_product_list : '.$template.'EOF
'; my $body = ''; my $sql = ' select '.$formref->{wantedfield}.' , count(*) "count" from product where categoryname like "'.$formref->{categoryname}.'" and public = 1 and rowstatusid = 1 '.$sql_x.' group by '.$formref->{wantedfield}.' limit 10000 '; # print " --- DEBUG (get_search_form_list) SQL : $sql
"; my $ref; $dbh->{PrintError} = 0; # disable # $ref = $dbh->selectall_hashref($sql, $formref->{wantedfield}) || warn "Database No Problem Error : ". $DBI::errstr; $ref = $dbh->selectall_hashref($sql, $formref->{wantedfield}); $dbh->{PrintError} = 1; # enable # print " --- DEBUG (get_search_form_list) SQL Error : ", $DBI::errstr ,"
"; if ($DBI::errstr =~ /Unknown column/) { # $sql = ' # select # substr( # substr(basetext,locate("'.$formref->{wantedfield}.'=",basetext)), # 1 + '.length($formref->{wantedfield}).' + 1, # locate("&",substr(basetext,locate("'.$formref->{wantedfield}.'=",basetext))) - 1 - '.length($formref->{wantedfield}).' - 1 # ) "'.$formref->{wantedfield}.'", # count(*) "count" # from product # where categoryname like "'.$formref->{categoryname}.'" # and public = 1 # and rowstatusid = 1 # group by '.$formref->{wantedfield}.' # limit 10000 # '; $sql = ' select substring_index( substring_index(basetext,"activitytype=",-1) , "&", 1 ) "'.$formref->{wantedfield}.'", count(*) "count" from product where categoryname like "'.$formref->{categoryname}.'" and public = 1 and rowstatusid = 1 '.$sql_x.' group by '.$formref->{wantedfield}.' limit 10000 '; # print "SQL : DEBUG 28402903 : $sql
"; $ref = $dbh->selectall_hashref($sql,$formref->{wantedfield}); } my %which = (); foreach (sort keys %{$ref}) { next if ! $ref->{$_}->{$formref->{wantedfield}}; # print " --- Blob 1 : $_ :
"; LOOP2: foreach my $j (split /,/, basetext_urldecode($ref->{$_}->{$formref->{wantedfield}})) { my $tmp = $template; # print " --- Blob 2 : $j :
"; next LOOP2 if exists $which{$j}; $tmp =~ s/\$\bNAME\b/$j/gi; $tmp =~ s/\$\bURLNAME\b/get_url_name($j)/egi; $body .= $tmp; $which{$j} = 1; } } $html =~ s/\$\bBODY\b/$body/gi; $html =~ s/\$\bFIELD\b/$formref->{wantedfield}/gi; return $html; } ##### # eof