#!/usr/bin/perl # Typical Linux/Unix settings $err = "2> /dev/null"; $sword_path = "/home/sword"; # SWORD_PATH environment variable you want to use $diatheke = "nice /usr/bin/diatheke"; # location of diatheke command line program # Typical Windows settings #$err = ""; #$sword_path = "C:\\Program Files\\CrossWire\\The SWORD Project"; # SWORD_PATH environment variable you want to use #$diatheke = "$sword_path\\diatheke.exe"; # location of diatheke command line program $cgiurl = "http:\/\/bible.gotjesus.org\/cgi-bin"; $scriptname = "diatheke.pl"; $defaultfontface = "Times New Roman, Times, Roman, serif"; # default font name $maxverses = 50; # maximum number of verses diatheke will return per query (prevents people from asking for Gen1:1-Rev22:21) $defaultbook = "KJV"; # book to query when none is selected, but a verse/search is entered $deflocale = "abbr"; # this is just the default for cases where user has not selected a locale and his browser does not reveal one -- you can also set locale using locale= in the GET URL ############################################################################### ## You should not need to edit anything below this line. ## Unless you want to modify functionality of course. :) ############################################################################### $version = "4.2"; sub plussifyaddress { ($p_ver = @_[0]) =~ tr/ /+/; $p_newline = ""; return $p_newline; } sub urlvers { $u_verse = @_[0]; $u_version = @_[1]; $u_oldverse = $u_verse; $u_verse =~ tr/ /+/; $u_newline = "$u_oldverse"; return $u_newline; } $ENV{'SWORD_PATH'} = $sword_path; print "Content-type: text/html\n\n"; if ($ENV{'HTTP_COOKIE'}) { $cookie = $ENV{'HTTP_COOKIE'}; $cookie =~ s/\; /=/g; %cookiedata = split(/=/, $cookie); $defversion = $cookiedata{DEFTRANS}; $locale = $cookiedata{LOCALE}; } if ($defversion eq "") { $defversion = 'KJV'; } if ($locale eq "") { $locale = $ENV{'HTTP_ACCEPT_LANGUAGE'}; $locale =~ s/(..).*/$1/; if ($locale eq "") { $locale = $deflocale; } elsif ($locale eq "en") { $locale = "abbr"; } } $hostname = $ENV{'REMOTE_ADDR'}; @values = split(/\&/,$ENV{'QUERY_STRING'}); $n = 0; $palm = 0; $latinxlit = ""; $optionfilters = ""; $debug=0; foreach $i (@values) { ($varname, $mydata) = split(/=/,$i); if ($varname ne "Submit" && $varname ne "lookup") { if ($varname eq "verse") { $verse = $mydata; $verse =~ tr/+/ /; $verse =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; } elsif ($varname eq "search" && $mydata ne "" && $mydata ne "off") { $search = "-s $mydata"; } elsif ($varname eq "strongs") { $optionfilters .= "n"; } elsif ($varname eq "footnotes") { $optionfilters .= "f"; } elsif ($varname eq "headings") { $optionfilters .= "h"; } elsif ($varname eq "morph") { $optionfilters .= "m"; } elsif ($varname eq "hebcant") { $optionfilters .= "c"; } elsif ($varname eq "hebvowels") { $optionfilters .= "v"; } elsif ($varname eq "grkacc") { $optionfilters .= "a"; } elsif ($varname eq "lemmas") { $optionfilters .= "l"; } elsif ($varname eq "scriprefs") { $optionfilters .= "s"; } elsif ($varname eq "arshape") { $optionfilters .= "r"; } elsif ($varname eq "bidi") { $optionfilters .= "b"; } elsif ($varname eq "latinxlit") { $latinxlit = "-t Latin"; } elsif ($varname eq "palm") { $palm = 1; } elsif ($varname eq "debug") { $debug = 1; } elsif ($varname eq "locale") { $locale = $mydata; } elsif ($varname eq "maxverses") { $maxverses = $mydata; } elsif ($mydata eq "on" || $mydata eq "ON") { $versions[$n] = $varname; $n++; } } } if ($optionfilters ne "") { $optionfilters = "-o " . $optionfilters; } if ($n == 0) { $versions[0] = $defaultbook; $n++; } if ($verse eq "") { @versionlist = `$diatheke -b system -k modulelist $err`; @versionlist2 = @versionlist; @localelist = `$diatheke -b system -k localelist $err`; print < Diatheke Online Bible

Verse/Commentary Lookup                                                                 Verse or Search key:
Phrase Search
Multiple Word Search
Regular Expression Search
Show Strong's Numbers Show Section Headings
Show Footnotes Show Scripture Cross-References
Show Morphology Show Hebrew Vowels
Show Lemmas Show Hebrew Cantillation Marks
Latin Transliterate Show Greek Accents

DEF1 foreach $line (@versionlist) { chomp($line); if ($line eq "Biblical Texts:") { print ""; } elsif ($line eq "Commentaries:") { print ""; } elsif ($line eq "Dictionaries:") { print ""; } else { $line =~ s/([^:]+) : (.+)/
Biblical Texts:
Commentaries:
Dictionaries & Lexica:
$2 ($1)<\/font><\/td><\/tr>/; print "$line\n"; } } print <
Select default Bible version for cross-references: 

Select locale: 
DEF4 } else { if ($palm == 0) { print < Diatheke Interlinear Bible END } else { print < HANDiatheke END } for ($i = 0; $i < $n; $i++) { $line = "$diatheke $search $optionfilters $latinxlit -l $locale -m $maxverses -f cgi -b $versions[$i] -k \"$verse\" $err"; if ($debug) { print "command line: $line\n
"; } $line = `$line`; chomp($line); $line =~ s/!DIATHEKE_URL!/$scriptname\?/g; # Parse and link to Strong's references if present $info = `$diatheke -b info -k $versions[$i] $err`; $info =~ /([^\;]+)\;([^\;]+)/; $format = $1; $type = $2; if ($versions[$i] eq "StrongsHebrew") { $line =~ s/(see HEBREW for )([0-9]+)/$1$2\<\/a\>/g; } elsif($versions[$i] eq "StrongsGreek") { $line =~ s/(see GREEK for )([0-9]+)/$1$2\<\/a\>/g; } #case for searches elsif($search ne "") { $line =~ s/([^<]+)<\/entry>/urlvers($1, $versions[$i])/eg; } #case for non-ThML, non-Bible texts elsif($type ne "Biblical Texts") { $book = $verse; $book =~ s/^([A-Za-z0-9]+) [0-9]+:[0-9]+.*/$1/; $chapter = $verse; $chapter =~ s/[A-Za-z0-9]+ ([0-9]+):[0-9]+.*/$1/; $line =~ s/\#*([1-9]*[A-Z][a-z]+\.*) ([0-9]+):([0-9]+-*,*[0-9]*)\|*/$1 $2:$3\<\/a\>/g; $line =~ s/\#([0-9]+):([0-9]+-*,*[0-9]*)\|*/$book $1:$2\<\/a\>/g; $line =~ s/\#([0-9]+-*,*[0-9]*)\|*/$book $chapter:$1\<\/a\>/g; } if ($locale ne "abbr") { $line =~ s/href=\"$scriptname([^\"]+)\"/href=\"$scriptname$1&locale=$locale\"/g; } if ($palm == 1) { $line =~ s/href=\"$scriptname([^\"]+)\"/href=\"$cgiurl\/$scriptname$1&palm=on\"/g; } print "$line

\n"; } if ($palm == 1) { print "
Powered by Diatheke (http:\/\/www.gotjesus.org\/sword\/diatheke) and the SWORD Project (http:\/\/www.crosswire.org\/sword)."; } print "



"; }