#!/usr/bin/perl use CGI qw(:standard); use DBI; # Connecting to the database $drh = DBI->install_driver("mysql"); #$dsn = "DBI:mysql:database=bewellcontentdb;host=bewellcontentdb.db.2081014.hostedresource.com"; #$dbh = DBI->connect($dsn,"bewellcontentdb","BeW3!!DB"); $dsn = "DBI:mysql:database=beweezfy_bewellworld;host=localhost"; $dbh = DBI->connect($dsn,"beweezfy_bewell","B3W3!!$"); require "./cgi/print_header_footer.cgi"; require "./cgi/shared_ads2.cgi"; $id = param('id'); $from = param('from'); if ($id =~ /^P/) { $directory_type = "practitioner"; $directory_type_uc = "Practitioner"; } else { $directory_type = "business referral"; $directory_type_uc = "Business Referral"; } if ($from eq "browse") { $browse_return = "

Browse more " . $directory_type . "s

\n"; } if ($from eq "search") { $browse_return = "

Return to $directory_type search results

\n"; } my $sth = $dbh->prepare("select * from practitioner where id = '$id'"); $sth->execute(); while (my $ref = $sth->fetchrow_hashref()) { $id_from_db = $ref->{'id'}; $firstname = $ref->{'firstname'}; $lastname = $ref->{'lastname'}; $suffix = $ref->{'suffix'}; $business_name = $ref->{'business_name'}; $street_address = $ref->{'street_address'}; $city = $ref->{'city'}; $county = $ref->{'county'}; $state = $ref->{'state'}; $zipcode = $ref->{'zipcode'}; $online_description = $ref->{'online_description'}; $print_description = $ref->{'print_description'}; $phone = $ref->{'phone'}; $email = $ref->{'email'}; $website = $ref->{'website'}; $website_length = length ($website); $status_practitioner = $ref->{'status_practitioner'}; $status_site = $ref->{'status_site'}; $gift_certificate = $ref->{'gift_certificate'}; } $sth->finish(); my $sth = $dbh->prepare("select modality from modality where article_id = '$id' and modality_type = 3 "); $sth->execute(); while (my $ref = $sth->fetchrow_hashref()) { $modality_from_db = $ref->{'modality'}; push(@modalities, $modality_from_db); } $sth->finish(); print "Content-type: text/html\n\n"; print "\n\n"; print "\n"; print "\n"; if ($from eq "preview") { print <<"preview_style_end"; preview_style_end } $practitioner_name = "$firstname $lastname"; if ($suffix ne "") { $practitioner_name = $practitioner_name . ", $suffix"; } if ($practitioner_name ne "") { $practitioner_title = "$practitioner_name"; $practitioner_short_title = "$practitioner_name"; if ($business_name ne "") { $practitioner_title = $practitioner_title . " ($business_name)"; } } else { $practitioner_title = $business_name; $practitioner_short_title = $practitioner_title; } if ($practitioner_name ne "") { $practitioner_display = "

$practitioner_name"; if ($business_name ne "") { $practitioner_display = $practitioner_display . "

$business_name

"; } else { $practitioner_display = $practitioner_display . "\n"; } } else { $practitioner_display = "

$business_name

\n"; } if ($online_description ne "") { $online_description =~ s/\n/
/g; $practitioner_data = $practitioner_data . "

$online_description

\n"; } $practitioner_data = $practitioner_data . "

\n"; if ($street_address ne "") { $practitioner_data = $practitioner_data . "$street_address
\n"; } if ($city ne "") { $practitioner_data = $practitioner_data . "$city "; if ($state ne "") { $practitioner_data = $practitioner_data . ", "; } } if ($state ne "") { $practitioner_data = $practitioner_data . "$state \n"; } if ($zipcode ne "") { $practitioner_data = $practitioner_data . "$zipcode\n"; } $practitioner_data = $practitioner_data . "

\n

\n"; if ($phone ne "") { $practitioner_data = $practitioner_data . "$phone
\n"; } if ($email ne "") { ($user,$host) = split(/@/,$email); $practitioner_data = $practitioner_data . "
\n"; } if (($website ne "") && ($website ne "http://")) { if ($website_length < 60) { $practitioner_data = $practitioner_data . "$website
\n"; } else { $practitioner_data = $practitioner_data . "Visit the ". $directory_type_uc . "'s Website
\n"; } } $practitioner_data = $practitioner_data . "

\n

\n"; if ($modalities[0] ne "") { $practitioner_data = $practitioner_data . "Relevant areas:\n

\n"; } $practitioner_data = $practitioner_data . "

\n\n"; if ($gift_certificate eq "1") { $practitioner_data = $practitioner_data . "

Gift Certificates are available!

\n"; } if ($id_from_db eq "") { $practitioner_title = "$directory_type_uc $id is not a valid entry"; $practitioner_data = ""; $practitioner_display = "

$directory_type_uc $id is not a valid entry

"; } elsif ((($status_practitioner ne "1") || ($status_site ne "1")) && ($from ne "preview")) { $practitioner_title = "$directory_type_uc $id is not available"; $practitioner_data = ""; $practitioner_display = "

$directory_type_uc $id is not available

"; } $page_title = "$practitioner_title | Be Well World"; print "$page_title\n"; if ($directory_type eq "practitioner") { &print_in_head("Find Practitioners"); } else { &print_in_head("Find Business Referrals"); } &get_ads("a"); print "\n"; if ($directory_type eq "practitioner") { &print_header("Find Practitioners", "$practitioner_short_title"); } else { &print_header("Find Business Referrals", "$practitioner_short_title"); } $practitioner_display = undbquote($practitioner_display); $practitioner_data = undbquote($practitioner_data); if ($from eq "preview") { print "
PREVIEW
\n"; } print <<"END2";
$browse_return $practitioner_display $practitioner_data
END2 $random_ad_number = int(rand(3)); $random_ad_number = $random_ad_number + 1; if ($random_ad_number eq "1") { print <<"A-1-END";
A-1-END } #end of a-1 if ($random_ad_number eq "2") { print <<"A-2-END";
A-2-END } #end of a-2 if ($random_ad_number eq "3") { print <<"A-3-END";
A-3-END } #end of a-3 &print_footer(); # Disconnect from the database. $dbh->disconnect(); sub undbquote { my($str) = @_; $str =~ s/\\"/"/g; $str =~ s/\\\\/\\/g; $str =~ s/\\//g; $str =~ s/\\'/'/g; return $str; }