#!/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'); $pagenum = param('pagenum'); if ($pagenum eq "") {$pagenum = "1";} my $sth = $dbh->prepare("select large_graphic, title, subtitle, article_text, affiliations, footnotes, status from article where id = '$id' "); $sth->execute(); while (my $ref = $sth->fetchrow_hashref()) { $large_graphic = $ref->{'large_graphic'}; $article_title = $ref->{'title'}; $article_subtitle = $ref->{'subtitle'}; $article_text = $ref->{'article_text'}; $footnotes = $ref->{'footnotes'}; $affiliations = $ref->{'affiliations'}; $status = $ref->{'status'}; } $sth->finish(); $all_article_text = $article_text; if ($footnotes ne "") { $all_article_text = $all_article_text . "

Footnotes


\n" . $footnotes; } if ($affiliations ne "") { $all_article_text = $all_article_text . "

Author Bio


\n" . $affiliations . "\n
\n"; } $all_article_text =~ s/\n/ /g; $all_article_text = undbquote($all_article_text); $all_article_text_length = length($all_article_text); if ($all_article_text =~ m/....manual_page_break.../) { #we've got manual page breaks $all_article_text = $all_article_text . ""; $pages = 0; while ($all_article_text =~ m/manual_page_break/g) { $pages++ } if ($pagenum eq "1") { $all_article_text =~ m/^(.*?)....manual_page_break.../; $display_article_text = $1; if ($pagenum < $pages) {$display_article_text = $display_article_text . "

Continue to page 2 of $pages >

";} } if ($pagenum eq "2") { $all_article_text =~ m/^.*?....manual_page_break...(.*?)....manual_page_break.../; $display_article_text = $1; if ($pagenum == $pages) {$display_article_text = $display_article_text . "

< Back to page 1 of $pages

";} if ($pagenum < $pages) {$display_article_text = $display_article_text . "

< Back to page 1 of $pagesContinue to page 3 of $pages >

";} } if ($pagenum eq "3") { $all_article_text =~ m/^.*?....manual_page_break....*?....manual_page_break...(.*?)....manual_page_break.../; $display_article_text = $1; if ($pagenum == $pages) {$display_article_text = $display_article_text . "

< Back to page 2 of $pages

";} if ($pagenum < $pages) {$display_article_text = $display_article_text . "

< Back to page 2 of $pagesContinue to page 4 of $pages >

";} } if ($pagenum eq "4") { $all_article_text =~ m/^.*?....manual_page_break....*?....manual_page_break....*?....manual_page_break...(.*?)....manual_page_break.../; $display_article_text = $1; if ($pagenum == $pages) {$display_article_text = $display_article_text . "

< Back to page 3 of $pages

";} if ($pagenum < $pages) {$display_article_text = $display_article_text . "

< Back to page 3 of $pagesContinue to page 5 of $pages >

";} } if ($pagenum eq "5") { $all_article_text =~ m/^.*?....manual_page_break....*?....manual_page_break....*?....manual_page_break....*?....manual_page_break...(.*?)....manual_page_break.../; $display_article_text = $1; if ($pagenum == $pages) {$display_article_text = $display_article_text . "

< Back to page 4 of $pages

";} if ($pagenum < $pages) {$display_article_text = $display_article_text . "

< Back to page 4 of $pagesContinue to page 6 of $pages >

";} } if ($pagenum eq "6") { $all_article_text =~ m/^.*?....manual_page_break....*?....manual_page_break....*?....manual_page_break....*?....manual_page_break....*?....manual_page_break...(.*?)....manual_page_break.../; $display_article_text = $1; if ($pagenum == $pages) {$display_article_text = $display_article_text . "

< Back to page 5 of $pages

";} if ($pagenum < $pages) {$display_article_text = $display_article_text . "

< Back to page 5 of $pagesContinue to page 7 of $pages >

";} } if ($pagenum eq "7") { $all_article_text =~ m/^.*?....manual_page_break....*?....manual_page_break....*?....manual_page_break....*?....manual_page_break....*?....manual_page_break....*?....manual_page_break...(.*?)....manual_page_break.../; $display_article_text = $1; if ($pagenum == $pages) {$display_article_text = $display_article_text . "

< Back to page 6 of $pages

";} if ($pagenum < $pages) {$display_article_text = $display_article_text . "

< Back to page 6 of $pagesContinue to page 8 of $pages >

";} } if ($pagenum eq "8") { $all_article_text =~ m/^.*?....manual_page_break....*?....manual_page_break....*?....manual_page_break....*?....manual_page_break....*?....manual_page_break....*?....manual_page_break....*?....manual_page_break...(.*?)....manual_page_break.../; $display_article_text = $1; if ($pagenum == $pages) {$display_article_text = $display_article_text . "

< Back to page 7 of $pages

";} if ($pagenum < $pages) {$display_article_text = $display_article_text . "

< Back to page 7 of $pagesContinue to page 9 of $pages >

";} } if ($pagenum eq "9") { $all_article_text =~ m/^.*?....manual_page_break....*?....manual_page_break....*?....manual_page_break....*?....manual_page_break....*?....manual_page_break....*?....manual_page_break....*?....manual_page_break....*?....manual_page_break...(.*?)....manual_page_break.../; $display_article_text = $1; if ($pagenum == $pages) {$display_article_text = $display_article_text . "

< Back to page 8 of $pages

";} if ($pagenum < $pages) {$display_article_text = $display_article_text . "

< Back to page 8 of $pagesContinue to page 10 of $pages >

";} } if ($pagenum eq "10") { $all_article_text =~ m/^.*?....manual_page_break....*?....manual_page_break....*?....manual_page_break....*?....manual_page_break....*?....manual_page_break....*?....manual_page_break....*?....manual_page_break....*?....manual_page_break....*?....manual_page_break...(.*?)....manual_page_break.../; $display_article_text = $1; if ($pagenum == $pages) {$display_article_text = $display_article_text . "

< Back to page 9 of $pages

";} } } #end of manual page break processing else { # no manual page breaks, so do automatic page breaks instead $pages = $all_article_text_length/3400; $pages =~ s/\..*$//; $pages = $pages + 1; #$display_article_text = "[ length: $all_article_text_length, page $page of $pages ] " . $all_article_text; if ($pagenum eq "1") { $all_article_text =~ m/^(.{1,3400})([^ ]*)/; $display_article_text = $1 . $2; if ($pagenum < $pages) {$display_article_text = $display_article_text . "...

Continue to page 2 of $pages >

";} } if ($pagenum eq "2") { if ($pages eq "2") { $all_article_text =~ m/^.{3300}[^ ]*(.*)/; $text_start = $1; $text_start =~ s/^[^<]{1,50}>//; $text_start =~ s/^[^>]{1,50}<\/[^>]*>//; $display_article_text = "

..." . $text_start . $2; } else { $all_article_text =~ m/^.{3300}[^ ]*(.{3350})([^ ]*)/; $text_start = $1; $text_start =~ s/^[^<]{1,50}>//; $text_start =~ s/^[^>]{1,50}<\/[^>]*>//; $display_article_text = "

..." . $text_start . $2; } if ($pagenum == $pages) {$display_article_text = $display_article_text . "

< Back to page 1 of $pages

";} if ($pagenum < $pages) {$display_article_text = $display_article_text . "...

< Back to page 1 of $pagesContinue to page 3 of $pages >

";} } if ($pagenum eq "3") { if ($pages eq "3") { $all_article_text =~ m/^.{6400}[^ ]*(.*)/; $text_start = $1; $text_start =~ s/^[^<]{1,50}>//; $text_start =~ s/^[^>]{1,50}<\/[^>]*>//; $display_article_text = "

..." . $text_start . $2; } else { $all_article_text =~ m/^.{6400}[^ ]*(.{3350})([^ ]*)/; $text_start = $1; $text_start =~ s/^[^<]{1,50}>//; $text_start =~ s/^[^>]{1,50}<\/[^>]*>//; $display_article_text = "

..." . $text_start . $2; } if ($pagenum == $pages) {$display_article_text = $display_article_text . "

< Back to page 2 of $pages

";} if ($pagenum < $pages) {$display_article_text = $display_article_text . "...

< Back to page 2 of $pagesContinue to page 4 of $pages >

";} } if ($pagenum eq "4") { if ($pages eq "4") { $all_article_text =~ m/^.{9500}[^ ]*(.*)/; $text_start = $1; $text_start =~ s/^[^<]{1,50}>//; $text_start =~ s/^[^>]{1,50}<\/[^>]*>//; $display_article_text = "

..." . $text_start . $2; } else { $all_article_text =~ m/^.{9500}[^ ]*(.{3350})([^ ]*)/; $text_start = $1; $text_start =~ s/^[^<]{1,50}>//; $text_start =~ s/^[^>]{1,50}<\/[^>]*>//; $display_article_text = "

..." . $text_start . $2; } if ($pagenum == $pages) {$display_article_text = $display_article_text . "

< Back to page 3 of $pages

";} if ($pagenum < $pages) {$display_article_text = $display_article_text . "...

< Back to page 3 of $pagesContinue to page 5 of $pages >

";} } if ($pagenum eq "5") { if ($pages eq "5") { $all_article_text =~ m/^.{12600}[^ ]*(.*)/; $text_start = $1; $text_start =~ s/^[^<]{1,50}>//; $text_start =~ s/^[^>]{1,50}<\/[^>]*>//; $display_article_text = "

..." . $text_start . $2; } else { $all_article_text =~ m/^.{12600}[^ ]*(.{3350})([^ ]*)/; $text_start = $1; $text_start =~ s/^[^<]{1,50}>//; $text_start =~ s/^[^>]{1,50}<\/[^>]*>//; $display_article_text = "

..." . $text_start . $2; } if ($pagenum == $pages) {$display_article_text = $display_article_text . "

< Back to page 4 of $pages

";} if ($pagenum < $pages) {$display_article_text = $display_article_text . "...

< Back to page 4 of $pagesContinue to page 6 of $pages >

";} } if ($pagenum eq "6") { if ($pages eq "6") { $all_article_text =~ m/^.{15700}[^ ]*(.*)/; $text_start = $1; $text_start =~ s/^[^<]{1,50}>//; $text_start =~ s/^[^>]{1,50}<\/[^>]*>//; $display_article_text = "

..." . $text_start . $2; } else { $all_article_text =~ m/^.{15700}[^ ]*(.{3350})([^ ]*)/; $text_start = $1; $text_start =~ s/^[^<]{1,50}>//; $text_start =~ s/^[^>]{1,50}<\/[^>]*>//; $display_article_text = "

..." . $text_start . $2; } if ($pagenum == $pages) {$display_article_text = $display_article_text . "

< Back to page 5 of $pages

";} if ($pagenum < $pages) {$display_article_text = $display_article_text . "...

< Back to page 5 of $pagesContinue to page 7 of $pages >

";} } if ($pagenum eq "7") { if ($pages eq "7") { $all_article_text =~ m/^.{18800}[^ ]*(.*)/; $text_start = $1; $text_start =~ s/^[^<]{1,50}>//; $text_start =~ s/^[^>]{1,50}<\/[^>]*>//; $display_article_text = "

..." . $text_start . $2; } else { $all_article_text =~ m/^.{18800}[^ ]*(.{3350})([^ ]*)/; $text_start = $1; $text_start =~ s/^[^<]{1,50}>//; $text_start =~ s/^[^>]{1,50}<\/[^>]*>//; $display_article_text = "

..." . $text_start . $2; } if ($pagenum == $pages) {$display_article_text = $display_article_text . "

< Back to page 6 of $pages

";} if ($pagenum < $pages) {$display_article_text = $display_article_text . "...

< Back to page 6 of $pagesContinue to page 8 of $pages >

";} } if ($pagenum eq "8") { if ($pages eq "8") { $all_article_text =~ m/^.{21900}[^ ]*(.*)/; $text_start = $1; $text_start =~ s/^[^<]{1,50}>//; $text_start =~ s/^[^>]{1,50}<\/[^>]*>//; $display_article_text = "

..." . $text_start . $2; } else { $all_article_text =~ m/^.{21900}[^ ]*(.{3350})([^ ]*)/; $text_start = $1; $text_start =~ s/^[^<]{1,50}>//; $text_start =~ s/^[^>]{1,50}<\/[^>]*>//; $display_article_text = "

..." . $text_start . $2; } if ($pagenum == $pages) {$display_article_text = $display_article_text . "

< Back to page 7 of $pages

";} if ($pagenum < $pages) {$display_article_text = $display_article_text . "...

< Back to page 7 of $pagesContinue to page 9 of $pages >

";} } if ($pagenum eq "9") { if ($pages eq "9") { $all_article_text =~ m/^.{25000}[^ ]*(.*)/; $text_start = $1; $text_start =~ s/^[^<]{1,50}>//; $text_start =~ s/^[^>]{1,50}<\/[^>]*>//; $display_article_text = "

..." . $text_start . $2; } else { $all_article_text =~ m/^.{25000}[^ ]*(.{3350})([^ ]*)/; $text_start = $1; $text_start =~ s/^[^<]{1,50}>//; $text_start =~ s/^[^>]{1,50}<\/[^>]*>//; $display_article_text = "

..." . $text_start . $2; } if ($pagenum == $pages) {$display_article_text = $display_article_text . "

< Back to page 8 of $pages

";} if ($pagenum < $pages) {$display_article_text = $display_article_text . "...

< Back to page 8 of $pagesContinue to page 10 of $pages >

";} } if ($pagenum eq "10") { if ($pages eq "10") { $all_article_text =~ m/^.{28100}[^ ]*(.*)/; $text_start = $1; $text_start =~ s/^[^<]{1,50}>//; $text_start =~ s/^[^>]{1,50}<\/[^>]*>//; $display_article_text = "

..." . $text_start . $2; } else { $all_article_text =~ m/^.{28100}[^ ]*(.{3350})([^ ]*)/; $text_start = $1; $text_start =~ s/^[^<]{1,50}>//; $text_start =~ s/^[^>]{1,50}<\/[^>]*>//; $display_article_text = "

..." . $text_start . $2; } if ($pagenum == $pages) {$display_article_text = $display_article_text . "

< Back to page 9 of $pages

";} } if ($display_article_text =~ /div id=\"author_info\"/) { unless ($display_article_text =~ /div id=\"author_info\".* end author_info /) { $display_article_text = $display_article_text . ""; } } if ($display_article_text =~ / end author_info /) { unless ($display_article_text =~ /div id=\"author_info\".* end author_info /) { $display_article_text = "
" . $display_article_text; } } } #end check for manual vs. automatic page breaks my $sth = $dbh->prepare("select modality from modality where article_id = '$id' and modality_type = 1 "); $sth->execute(); while (my $ref = $sth->fetchrow_hashref()) { $modality = $ref->{'modality'}; } $sth->finish(); my $sth = $dbh->prepare("select * from author where article_id = '$id' "); $sth->execute(); while (my $ref = $sth->fetchrow_hashref()) { if ($ref->{'order'} eq"1") { $firstname1 = $ref->{'first_name'}; $lastname1 = $ref->{'last_name'}; $suffix1 = $ref->{'suffix'}; $practitioner1 = $ref->{'practitioner_id'}; $link1 = $ref->{'link'}; if ($link1 eq "1") {$link1_yes_selected = "checked";} if ($link1 eq "0") {$link1_no_selected = "checked";} } if ($ref->{'order'} eq"2") { $firstname2 = $ref->{'first_name'}; $lastname2 = $ref->{'last_name'}; $suffix2 = $ref->{'suffix'}; $practitioner2 = $ref->{'practitioner_id'}; $link2 = $ref->{'link'}; if ($link2 eq "1") {$link2_yes_selected = "checked";} if ($link2 eq "0") {$link2_no_selected = "checked";} } if ($ref->{'order'} eq"3") { $firstname3 = $ref->{'first_name'}; $lastname3 = $ref->{'last_name'}; $suffix3 = $ref->{'suffix'}; $practitioner3 = $ref->{'practitioner_id'}; $link3 = $ref->{'link'}; if ($link3 eq "1") {$link3_yes_selected = "checked";} if ($link3 eq "0") {$link3_no_selected = "checked";} } if ($ref->{'order'} eq"4") { $firstname4 = $ref->{'first_name'}; $lastname4 = $ref->{'last_name'}; $suffix4 = $ref->{'suffix'}; $practitioner4 = $ref->{'practitioner_id'}; $link4 = $ref->{'link'}; if ($link4 eq "1") {$link4_yes_selected = "checked";} if ($link4 eq "0") {$link4_no_selected = "checked";} } } $sth->finish(); if ($lastname1 ne "") { $author1 = ""; if (($practitioner1 ne "") && ($link1 eq "1")) { $author1 = $author1 . "$firstname1 $lastname1"; if ($suffix1 ne "") { $author1 = $author1 . ", $suffix1"; } } else { $author1 = $author1 . "$firstname1 $lastname1"; if ($suffix1 ne "") { $author1 = $author1 . ", $suffix1"; } } } if ($lastname2 ne "") { $author2 = "
"; if (($practitioner2 ne "") && ($link2 eq "1")) { $author2 = $author2 . "$firstname2 $lastname2"; if ($suffix2 ne "") { $author2 = $author2 . ", $suffix2"; } } else { $author2 = $author2 . "$firstname2 $lastname2"; if ($suffix2 ne "") { $author2 = $author2 . ", $suffix2"; } } } if ($lastname3 ne "") { $author3 = "
"; if (($practitioner3 ne "") && ($link3 eq "1")) { $author3 = $author3 . "$firstname3 $lastname3"; if ($suffix3 ne "") { $author3 = $author3 . ", $suffix3"; } } else { $author3 = $author3 . "$firstname3 $lastname3"; if ($suffix3 ne "") { $author3 = $author3 . ", $suffix3"; } } } if ($lastname4 ne "") { $author4 = "
"; if (($practitioner4 ne "") && ($link4 eq "1")) { $author4 = $author4 . "$firstname4 $lastname4"; if ($suffix4 ne "") { $author4 = $author4 . ", $suffix4"; } } else { $author4 = $author4 . "$firstname4 $lastname4"; if ($suffix4 ne "") { $author4 = $author4 . ", $suffix4"; } } } print "Content-type: text/html\n\n"; print "\n\n"; print "\n"; print "\n"; $page_title = "$article_title | $modality | Be Well World"; print "$page_title\n"; $image_id = $id; $image_id =~ s/\//_/g; print "\n"; &print_in_head("$modality"); print <<"END1"; END1 &get_ads("a"); $image_id = $id; $image_id =~ s/\//_/g; &print_header("$modality", "$article_title"); print <<"END2";
$article_title
$article_title

$article_subtitle

$author1 $author2 $author3 $author4
$display_article_text
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; # Map incompatible CP-1252 characters $str =~ s/\x82/,/g; $str =~ s/\x84/,,/g; $str =~ s/\x85/.../g; $str =~ s/\x88/^/g; $str =~ s/\x8B//g; $str =~ s/\x9C/oe/g; return $str; }