1#!/usr/bin/perl 2 3# /**************************************************************************** 4# * 5# * sapouni.cgi - CGI SOAP interface to diatheke 6# * 7# * $Id: sapouni.cgi 2833 2013-06-29 06:40:28Z chrislit $ 8# * 9# * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org) 10# * CrossWire Bible Society 11# * P. O. Box 2528 12# * Tempe, AZ 85280-2528 13# * 14# * This program is free software; you can redistribute it and/or modify it 15# * under the terms of the GNU General Public License as published by the 16# * Free Software Foundation version 2. 17# * 18# * This program is distributed in the hope that it will be useful, but 19# * WITHOUT ANY WARRANTY; without even the implied warranty of 20# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21# * General Public License for more details. 22# * 23# */ 24 25#version 1.0 26 27package sapouni; 28$sapouni = "nice /usr/bin/diatheke"; # location of diatheke command line program -- if you are using a MS Windows server, you might need to remove the "nice" 29 30$sword_path = "/home/sword"; # SWORD_PATH environment variable you want to use 31$maxverses = 0; # maximum number of verses diatheke will return per query (prevents people from asking for Gen1:1-Rev22:21; 0 for unlim.) 32$defversion = "KJV"; # book to query when none is selected, but a verse/search is entered 33$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 locael=<locale> in the GET URL 34 35 36############################################################################### 37## You should not need to edit anything below this line. 38## Unless you want to modify functionality of course. :) 39############################################################################### 40 41$ENV{'SWORD_PATH'} = $sword_path; 42 43use SOAP::Transport::HTTP; 44 45SOAP::Transport::HTTP::CGI 46 -> dispatch_to('sapouni') 47 -> handle; 48 49package sapouni; 50 51sub biblequery { 52 my ($class, $books, $key, $options, $encoding, $markup, $searchtype, $locale, $script, $max) = @_; 53 54 if ($key eq "") { 55 $key = "Jn 3:16"; 56 } 57 58 @booklist = split ' ', $books; 59 60 $n = scalar(@booklist); 61 if ($n == 0) { 62 @booklist[0] = $defversion; 63 $n++; 64 } 65 66 $query = ""; 67 68 if ($options ne "") { 69 $query .= " -o \"$options\""; 70 } 71 72 if ($encoding ne "") { 73 $query .= " -e \"$encoding\""; 74 } 75 else { 76 $query .= " -e UTF8"; 77 } 78 79 if ($markup ne "") { 80 $query .= " -f \"$markup\""; 81 } 82 else { 83 $query .= " -f ThML"; 84 } 85 86 if ($searchtype ne "") { 87 $query .= " -s \"$searchtype\""; 88 } 89 90 if ($locale ne "") { 91 $query .= " -l \"$locale\""; 92 } 93 else { 94 $query .= " -l $deflocale"; 95 } 96 97 if ($script ne "") { 98 $query .= " -t \"$script\""; 99 } 100 101 if ($max ne "" && $max ne 0) { 102 $query .= " -m \"$max\""; 103 } 104 105 $rval = ""; 106 for ($i = 0; $i < $n; $i++) { 107 $line = "$sapouni $query -b $booklist[$i] -k \"$key\" 2> /dev/null"; 108 109 # uncomment to print the command line send to Diatheke (for debugging) 110 # $rval .= "$line\n"; 111 112 $line = `$line`; 113 chomp($line); 114 115 $rval .= "$line\n"; 116 } 117 118 return "$rval"; 119} 120