Jul 9, 2008

Major Problems With Php Script - Hold on for this one!

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

Major Problems With Php Script - Hold on for this one!

wild20
Okay, so I got a php script for my site called php Bible. So I get it and go to install it, and then the problems start. You see it uses php, dud, to search and view scripture. So here are the instructions:

QUOTE

1) Upload the files to a useful place inside your web server's document tree.
2) Change the things that look wrong in config.php.
3) Make sure "AcceptPathInfo ON" (or analogous) is somewhere in your PHP file section of your web server config.
4) Go over steps 2 and 3 again, because you probably missed something for lack of documentation.


So I do this, you get a whole bunch of files for each chapter in the Bible. see this code below to explain more. Look at the files at the bottom and it shows what each book of the bible is named:

CODE

<?
/*
* config.php - The configuration for a simple web program written by Alex Markley to display chunks of the Holy Bible.
*/

/*
This file is part of PHPScripture (Formally Alex's PHPBible).

PHPScripture is Copyright © 2003, Alex Markley

PHPScripture is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

//Headerless?
$config["headerless"] = FALSE; //Can be TRUE or FALSE. (Probably FALSE.)

//Theme? (Only takes effect if headerless is false.) (It is the name of a folder within the themes folder.)
$config["theme"] = "plain"; //No theme at all.
//$config["theme"] = "eternity"; //Green and forresty.
//$config["theme"] = "forest_bed"; //Green and forresty.
//$config["theme"] = "aquatic_geometry"; //Blue, watery, etc.

//Searching Stuff (Searching requires a sane version of GREP, and a sane shell to both be installed.)
$config["good_shell"] = "/bin/sh"; //Full path to borne or bash or something similar.
$config["grep_command"] = "egrep"; //Search command.
$config["disable_searching"] = FALSE; //Can be TRUE or FALSE. (Probably FALSE.)

//This stuff probably needs changed. ALL OF THESE VALUES SHOULD END IN A '/', EXCEPT IN VERY RARE CIRCUMSTANCES.
$config["URI_prefix"] = "http://my.domain.org/path/to/script/"; //Where the script lives on the web.
$config["script_suffix"] = "bible.php/"; //The name of the main script. (It may seem strange that this should end in a '/', but that is indeed the case.)
$config["local_prefix"] = "/path/to/config/and/things/"; //Where the script lives on the disk.
$config["bible_midfix"] = "bible/"; //The directory that the bible data is in. ($config["local_prefix"] . $config["bible_midfix"])
$config["themes_midfix"] = "themes/"; //The directory that the bible data is in. ($config["local_prefix"] . $config["bible_midfix"])

//This stuff doesn't need changed, but it's useful.
$config["title"] = "Holy Bible"; //Title of the page.
$config["element_wrap"] = 5; //Wrap every 5 things.
$config["search_results_per_page"] = 20; // 20 search results to a page

//Don't change the things below this line.
$config["version"]["major"] = 1;
$config["version"]["minor"] = 2;
$config["version"]["subminor"] = 3;

$bible_books[0]["long"] = "Genesis";        $bible_books[0]["short"] = "Ge";
$bible_books[1]["long"] = "Exodus";        $bible_books[1]["short"] = "Ex";
$bible_books[2]["long"] = "Leviticus";        $bible_books[2]["short"] = "Le";
$bible_books[3]["long"] = "Numbers";        $bible_books[3]["short"] = "Nu";
$bible_books[4]["long"] = "Deuteronomy";    $bible_books[4]["short"] = "De";
$bible_books[5]["long"] = "Joshua";        $bible_books[5]["short"] = "Jos";
$bible_books[6]["long"] = "Judges";        $bible_books[6]["short"] = "Jud";
$bible_books[7]["long"] = "Ruth";        $bible_books[7]["short"] = "Ru";
$bible_books[8]["long"] = "1 Samuel";        $bible_books[8]["short"] = "1Sa";
$bible_books[9]["long"] = "2 Samuel";        $bible_books[9]["short"] = "2Sa";
$bible_books[10]["long"] = "1 Kings";        $bible_books[10]["short"] = "1Ki";
$bible_books[11]["long"] = "2 Kings";        $bible_books[11]["short"] = "2Ki";
$bible_books[12]["long"] = "1 Chronicles";    $bible_books[12]["short"] = "1Ch";
$bible_books[13]["long"] = "2 Chronicles";    $bible_books[13]["short"] = "2Ch";
$bible_books[14]["long"] = "Ezra";        $bible_books[14]["short"] = "Ezr";
$bible_books[15]["long"] = "Nehemiah";        $bible_books[15]["short"] = "Ne";
$bible_books[16]["long"] = "Esther";        $bible_books[16]["short"] = "Es";
$bible_books[17]["long"] = "Job";        $bible_books[17]["short"] = "Job";
$bible_books[18]["long"] = "Psalms";        $bible_books[18]["short"] = "Ps";
$bible_books[19]["long"] = "Proverbs";        $bible_books[19]["short"] = "Pr";
$bible_books[20]["long"] = "Ecclesiastes";    $bible_books[20]["short"] = "Ec";
$bible_books[21]["long"] = "Song of Songs";    $bible_books[21]["short"] = "So";
$bible_books[22]["long"] = "Isaiah";        $bible_books[22]["short"] = "Isa";
$bible_books[23]["long"] = "Jeremiah";        $bible_books[23]["short"] = "Jer";
$bible_books[24]["long"] = "Lamentations";    $bible_books[24]["short"] = "La";
$bible_books[25]["long"] = "Ezekial";        $bible_books[25]["short"] = "Eze";
$bible_books[26]["long"] = "Daniel";        $bible_books[26]["short"] = "Da";
$bible_books[27]["long"] = "Hosea";        $bible_books[27]["short"] = "Ho";
$bible_books[28]["long"] = "Joel";        $bible_books[28]["short"] = "Joe";
$bible_books[29]["long"] = "Amos";        $bible_books[29]["short"] = "Am";
$bible_books[30]["long"] = "Obadiah";        $bible_books[30]["short"] = "Ob";
$bible_books[31]["long"] = "Jonah";        $bible_books[31]["short"] = "Jon";
$bible_books[32]["long"] = "Micah";        $bible_books[32]["short"] = "Mic";
$bible_books[33]["long"] = "Nahum";        $bible_books[33]["short"] = "Na";
$bible_books[34]["long"] = "Habakkuk";        $bible_books[34]["short"] = "Hab";
$bible_books[35]["long"] = "Zephaniah";        $bible_books[35]["short"] = "Zep";
$bible_books[36]["long"] = "Haggai";        $bible_books[36]["short"] = "Hag";
$bible_books[37]["long"] = "Zechariah";        $bible_books[37]["short"] = "Zec";
$bible_books[38]["long"] = "Malachi";        $bible_books[38]["short"] = "Mal";
$bible_books[39]["long"] = "Matthew";        $bible_books[39]["short"] = "Mt";
$bible_books[40]["long"] = "Mark";        $bible_books[40]["short"] = "Mr";
$bible_books[41]["long"] = "Luke";        $bible_books[41]["short"] = "Lu";
$bible_books[42]["long"] = "John";        $bible_books[42]["short"] = "Joh";
$bible_books[43]["long"] = "Acts";        $bible_books[43]["short"] = "Ac";
$bible_books[44]["long"] = "Romans";        $bible_books[44]["short"] = "Ro";
$bible_books[45]["long"] = "1 Corinthians";    $bible_books[45]["short"] = "1Co";
$bible_books[46]["long"] = "2 Corinthians";    $bible_books[46]["short"] = "2Co";
$bible_books[47]["long"] = "Galatians";        $bible_books[47]["short"] = "Ga";
$bible_books[48]["long"] = "Ephesians";        $bible_books[48]["short"] = "Eph";
$bible_books[49]["long"] = "Philippians";    $bible_books[49]["short"] = "Php";
$bible_books[50]["long"] = "Colossians";    $bible_books[50]["short"] = "Col";
$bible_books[51]["long"] = "1 Thessalonians";    $bible_books[51]["short"] = "1Th";
$bible_books[52]["long"] = "2 Thessalonians";    $bible_books[52]["short"] = "2Th";
$bible_books[53]["long"] = "1 Timothy";        $bible_books[53]["short"] = "1Ti";
$bible_books[54]["long"] = "2 Timothy";        $bible_books[54]["short"] = "2Ti";
$bible_books[55]["long"] = "Titus";        $bible_books[55]["short"] = "Tit";
$bible_books[56]["long"] = "Philemon";        $bible_books[56]["short"] = "Phm";
$bible_books[57]["long"] = "Hebrews";        $bible_books[57]["short"] = "Heb";
$bible_books[58]["long"] = "James";        $bible_books[58]["short"] = "Jas";
$bible_books[59]["long"] = "1 Peter";        $bible_books[59]["short"] = "1Pe";
$bible_books[60]["long"] = "2 Peter";        $bible_books[60]["short"] = "2Pe";
$bible_books[61]["long"] = "1 John";        $bible_books[61]["short"] = "1Jo";
$bible_books[62]["long"] = "2 John";        $bible_books[62]["short"] = "2Jo";
$bible_books[63]["long"] = "3 John";        $bible_books[63]["short"] = "3Jo";
$bible_books[64]["long"] = "Jude";        $bible_books[64]["short"] = "Jude";
$bible_books[65]["long"] = "Revelation";    $bible_books[65]["short"] = "Re";

?>


What you just saw was the config.php files. All files are uploaded into the directory http://inneed.mxweb.co.uk/bible. The main file is called index.php, but used to be called bible.php. So I do this, and then it says to edit the config, see the above code it shows instructions near the top, and the urls to edit. So I go to test it out, and guess what? It doesn't work. I worked on it for two whole hours, and it still doesn't work. I need to know how to edit those files, if the index.php file, config.php file, and all the other files are located only in http://inneed.mxweb.co.uk. For the book, I am also including the bible.php code, which I changed to index.php. In case you are wondering, I did change in both these files that the bible.php, is now index.php.
CODE

<?
/*
* bible.php - A simple web program written by Alex Markley to display chunks of the Holy Bible.
*/

/*
This file is part of PHPScripture (Formally Alex's PHPBible).

PHPScripture is Copyright © 2003, Alex Markley

PHPScripture is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

include("config.php");

function is_valid_number($something)
    {
    if(preg_match("/^([0-9]+)$/", $something)) return(TRUE);
    else return(FALSE);
    }

//We try to _GET the infos.
if(isset($_GET["book"])) $config["book"] = $_GET["book"];
if(isset($_GET["chapter"])) $config["chapter"] = $_GET["chapter"];
if(isset($_GET["verse"])) $config["verse"] = $_GET["verse"];
if(isset($_GET["operation"])) $config["operation"] = $_GET["operation"];
if(isset($_GET["search"])) $config["search"] = $_GET["search"];
if(isset($_GET["page"])) $config["page"] = $_GET["page"];

if(isset($_POST["book"])) $config["book"] = $_POST["book"];
if(isset($_POST["chapter"])) $config["chapter"] = $_POST["chapter"];
if(isset($_POST["verse"])) $config["verse"] = $_POST["verse"];
if(isset($_POST["operation"])) $config["operation"] = $_POST["operation"];
if(isset($_POST["search"])) $config["search"] = $_POST["search"];
if(isset($_POST["page"])) $config["page"] = $_POST["page"];

if(isset($config["book"]) && strcmp($config["book"], "") == 0) unset($config["book"]);
if(isset($config["chapter"]) && strcmp($config["chapter"], "") == 0) unset($config["chapter"]);
if(isset($config["verse"]) && strcmp($config["verse"], "") == 0) unset($config["verse"]);
if(isset($config["operation"]) && strcmp($config["operation"], "") == 0) unset($config["operation"]);
if(isset($config["search"]) && strcmp($config["search"], "") == 0) unset($config["search"]);
if(isset($config["page"]) && strcmp($config["page"], "") == 0) unset($config["page"]);

if($config["disable_searching"] === TRUE)
    {
    if(isset($config["operation"]) && strcmp($config["operation"], "Search") == 0) unset($config["operation"]);
    unset($config["search"]);
    unset($config["page"]);
    }

//Now we assemble a correct URL to redirect to.
if(isset($config["book"]))
    {
    if(isset($config["book"]))
        {
        $stringbits[0] = ($config["book"]);
        if(isset($config["chapter"]))
            {
            $stringbits[1] = ("/" . $config["chapter"]);
            if(isset($config["verse"]))
                {
                $stringbits[2] = ("/" . $config["verse"]);
                }
            }
        }
    
    //Now assemble GET vars.
    unset($stringbits[3]); //Make sure is unset.
    if(isset($config["operation"]) && strcasecmp($config["operation"], "Go") != 0) //There is a special exception for operation "Go", because it's default anyway.
        {
        if(isset($stringbits[3]))
            $stringbits[3] = ($stringbits[3] . "&");
        else
            $stringbits[3] = ($stringbits[3] . "?");
        $stringbits[3] = ($stringbits[3] . "operation=" . $config["operation"]);
        }
    if(isset($config["search"]))
        {
        if(isset($stringbits[3]))
            $stringbits[3] = ($stringbits[3] . "&");
        else
            $stringbits[3] = ($stringbits[3] . "?");
        $stringbits[3] = ($stringbits[3] . "search=" . $config["search"]);
        }
    if(isset($config["page"]))
        {
        if(isset($stringbits[3]))
            $stringbits[3] = ($stringbits[3] . "&");
        else
            $stringbits[3] = ($stringbits[3] . "?");
        $stringbits[3] = ($stringbits[3] . "page=" . $config["page"]);
        }
    
    header("Location: " . $config["URI_prefix"] . $config["script_suffix"] . $stringbits[0] . $stringbits[1] . $stringbits[2] . $stringbits[3]);
    exit();
    }

if(isset($_SERVER["PATH_INFO"])) //The info from the path takes precedence.
    {
    $array = explode("/", $_SERVER["PATH_INFO"], 5);
    for($tint = 1;isset($array[$tint]);$tint++)
        {
        if($tint === 1)
            $config["book"] = $array[$tint];
        else if($tint === 2)
            $config["chapter"] = $array[$tint];
        else if($tint === 3)
            $config["verse"] = $array[$tint];
        }
    }

//echo(" \"" . $config["chapter"] . "\" \n");

?>
<?
if($config["headerless"] === FALSE)
    {
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
        <?
        if(!isset($config["operation"]) || !(strcmp($config["operation"], "print") == 0))
            {
            ?>
            <style type="text/css">
                <? include($config["local_prefix"] . $config["themes_midfix"] . $config["theme"] . "/theme.php"); ?>
            </style>
            <?
            }
            ?>
        <title><? echo($config["title"]); ?></title>
        </head>
    
    <body>
    <?
    }
?>

<div align="center"><h1><? echo($config["title"]); ?></h1></div>

<?
//Check for the validity of the input.
if(isset($config["chapter"]) && (is_valid_number($config["chapter"]) === FALSE))
    {
    if(strcmp($config["chapter"], "") != 0) echo("<h3>Sorry, Chapter needs to be a number.</h3>\n");
    unset($config["chapter"]); //Just get rid of it.
    }
if(isset($config["verse"]) && (is_valid_number($config["verse"]) === FALSE))
    {
    //There is a non-numerical character in verse. We /should/ be able to examine it for range.
    $temp_array = explode("-", $config["verse"], 2);
    if(isset($temp_array[0]) && isset($temp_array[1]) && is_valid_number($temp_array[0]) === TRUE && is_valid_number($temp_array[1]) === TRUE)
        {
        $config["verse"] = $temp_array[0];
        $config["verse_end"] = $temp_array[1];
        //echo("<h3>Verse Range \"" . $temp_array[0] . "\" - \"" . $temp_array[1] . "\"</h3>\n");
        if($config["verse_end"] <= $config["verse"])
            {
            echo("<h3>Sorry. With a verse range, ending Verse needs to be larger then begining Verse.</h3>\n");
            unset($config["verse"]);
            unset($config["verse_end"]);
            }
        }
    else
        {
        if(strcmp($config["verse"], "") != 0) echo("<h3>Sorry, Verse needs to be a number.</h3>\n");
        unset($config["verse"]); //Just get rid of it.
        }
    }
if(isset($config["verse"]) && !isset($config["chapter"]))
    {
    echo("<h3>Sorry, you need a chapter if you're going to have a verse.</h3>\n");
    unset($config["verse"]); //Just get rid of it.
    }

if(strstr($config["book"], "/") === FALSE)
    {
    $bookok = FALSE; //Assume the book is invalid.

    for($tint = 0;isset($bible_books[$tint]);$tint++)
        {
        //echo("<p> " . $tint . " " . $config["book"] . " " . $bible_books[$tint]["long"] . " " . $bible_books[$tint]["short"]);
        if(strcasecmp($config["book"], $bible_books[$tint]["long"]) == 0) //This is a ref to the long name.
            {
            $bookok = TRUE; //The book is valid.
            $bookindex = $tint;
            $config["book"] = $bible_books[$tint]["short"]; //But the name needs to be the short version.
            //echo(" &lt;-- This!\n");
            }
        else if(strcasecmp($config["book"], $bible_books[$tint]["short"]) == 0) //This is a ref to the short name.
            {
            $bookok = TRUE; //The book is valid.
            $bookindex = $tint;
            $config["book"] = $bible_books[$tint]["short"]; //Make sure the name is exact. (We checked case insensitive, the case does matter though, so it's fixed.)
            //echo(" &lt;-- This!\n");
            }
        }
    
    //If it's still okay.
    if($bookok === TRUE)
        {
        //echo("<p>Book still okay\n");
        $bookfilename = ($config["local_prefix"] . $config["bible_midfix"] . $config["book"]); //Generate the real filename.
        //echo("<p>\"" . $bookfilename . "\"\n");
        $bookfile = @fopen($bookfilename, "rb"); //Try to open the book.
        if($bookfile == FALSE)
            {
            $bookok = FALSE;
            //echo("<p>No such book! \"" . $bookfilename . "\"\n");
            }
        else
            {
            //echo("<p>Book Opened! \"" . $bible_books[$bookindex]["long"] . "\"\n");
            }
        //echo("<p>Book either opened or not.\n");
        }
    }
else
    {
    $bookok = FALSE;
    }

if($bookok === FALSE && strcasecmp($config["operation"], "Search") != 0) //We'll be displaying a list of availible books if the book is bad we're not searching.
    {
    if(strcmp($config["book"], "") != 0) echo("<h3>Sorry, can't find Book \"" . $config["book"] . "\"</h3>\n");
    ?>
<?
//Prepare the required vars.
$tint = 0;
$wrap = 0;
?>

<div align="center">
<h3>Old Testament</h3>
<h4>The Books of the Law</h4>
<p>
<table border="0"><tr align="center" valign="middle">
<?
$wrap = 0;
while($tint < 5)
    {
    if($wrap >= $config["element_wrap"])
        {
        $wrap = 0;
        echo("</tr><tr align=\"center\" valign=\"middle\">");
        }
    echo("<td><form ACTION=\"" . $config["URI_prefix"] . $config["script_suffix"] . $bible_books[$tint]["short"] . "/" . 1 . "/\" METHOD=\"post\"><input TYPE=\"submit\" VALUE=\"" . $bible_books[$tint]["long"] . "\"></form></td>\n");
    $tint++;
    $wrap++;
    }
?>
</tr></table>

<h4>The Books of History</h4>
<p>
<table border="0"><tr align="center" valign="middle">
<?
$wrap = 0;
while($tint < 17)
    {
    if($wrap >= $config["element_wrap"])
        {
        $wrap = 0;
        echo("</tr><tr align=\"center\" valign=\"middle\">");
        }
    echo("<td><form ACTION=\"" . $config["URI_prefix"] . $config["script_suffix"] . $bible_books[$tint]["short"] . "/" . 1 . "/\" METHOD=\"post\"><input TYPE=\"submit\" VALUE=\"" . $bible_books[$tint]["long"] . "\"></form></td>\n");
    $tint++;
    $wrap++;
    }
?>
</tr></table>

<h4>The Books of Wisdom</h4>
<p>
<table border="0"><tr align="center" valign="middle">
<?
$wrap = 0;
while($tint < 22)
    {
    if($wrap >= $config["element_wrap"])
        {
        $wrap = 0;
        echo("</tr><tr align=\"center\" valign=\"middle\">");
        }
    echo("<td><form ACTION=\"" . $config["URI_prefix"] . $config["script_suffix"] . $bible_books[$tint]["short"] . "/" . 1 . "/\" METHOD=\"post\"><input TYPE=\"submit\" VALUE=\"" . $bible_books[$tint]["long"] . "\"></form></td>\n");
    $tint++;
    $wrap++;
    }
?>
</tr></table>

<h4>The Books of the Prophets</h4>
<p>
<table border="0"><tr align="center" valign="middle">
<?
$wrap = 0;
while($tint < 39)
    {
    if($wrap >= $config["element_wrap"])
        {
        $wrap = 0;
        echo("</tr><tr align=\"center\" valign=\"middle\">");
        }
    echo("<td><form ACTION=\"" . $config["URI_prefix"] . $config["script_suffix"] . $bible_books[$tint]["short"] . "/" . 1 . "/\" METHOD=\"post\"><input TYPE=\"submit\" VALUE=\"" . $bible_books[$tint]["long"] . "\"></form></td>\n");
    $tint++;
    $wrap++;
    }
?>
</tr></table>

<h3>New Testament</h3>
<h4>Accounts of Christ's Life on Earth, and of the Early Church</h4>
<p>
<table border="0"><tr align="center" valign="middle">
<?
$wrap = 0;
while($tint < 44)
    {
    if($wrap >= $config["element_wrap"])
        {
        $wrap = 0;
        echo("</tr><tr align=\"center\" valign=\"middle\">");
        }
    echo("<td><form ACTION=\"" . $config["URI_prefix"] . $config["script_suffix"] . $bible_books[$tint]["short"] . "/" . 1 . "/\" METHOD=\"post\"><input TYPE=\"submit\" VALUE=\"" . $bible_books[$tint]["long"] . "\"></form></td>\n");
    $tint++;
    $wrap++;
    }
?>
</tr></table>

<h4>Letters from the Apostle Paul to Churches</h4>
<p>
<table border="0"><tr align="center" valign="middle">
<?
$wrap = 0;
while($tint < 53)
    {
    if($wrap >= $config["element_wrap"])
        {
        $wrap = 0;
        echo("</tr><tr align=\"center\" valign=\"middle\">");
        }
    echo("<td><form ACTION=\"" . $config["URI_prefix"] . $config["script_suffix"] . $bible_books[$tint]["short"] . "/" . 1 . "/\" METHOD=\"post\"><input TYPE=\"submit\" VALUE=\"" . $bible_books[$tint]["long"] . "\"></form></td>\n");
    $tint++;
    $wrap++;
    }
?>
</tr></table>

<h4>Letters from the Apostle Paul to Individuals</h4>
<p>
<table border="0"><tr align="center" valign="middle">
<?
$wrap = 0;
while($tint < 57)
    {
    if($wrap >= $config["element_wrap"])
        {
        $wrap = 0;
        echo("</tr><tr align=\"center\" valign=\"middle\">");
        }
    echo("<td><form ACTION=\"" . $config["URI_prefix"] . $config["script_suffix"] . $bible_books[$tint]["short"] . "/" . 1 . "/\" METHOD=\"post\"><input TYPE=\"submit\" VALUE=\"" . $bible_books[$tint]["long"] . "\"></form></td>\n");
    $tint++;
    $wrap++;
    }
?>
</tr></table>

<h4>Other Epistles</h4>
<p>
<table border="0"><tr align="center" valign="middle">
<?
$wrap = 0;
while($tint < 65)
    {
    if($wrap >= $config["element_wrap"])
        {
        $wrap = 0;
        echo("</tr><tr align=\"center\" valign=\"middle\">");
        }
    echo("<td><form ACTION=\"" . $config["URI_prefix"] . $config["script_suffix"] . $bible_books[$tint]["short"] . "/" . 1 . "/\" METHOD=\"post\"><input TYPE=\"submit\" VALUE=\"" . $bible_books[$tint]["long"] . "\"></form></td>\n");
    $tint++;
    $wrap++;
    }
?>
</tr></table>

<h4>Prophecy</h4>
<p>
<table border="0"><tr align="center" valign="middle">
<?
$wrap = 0;
while($tint < 66)
    {
    if($wrap >= $config["element_wrap"])
        {
        $wrap = 0;
        echo("</tr><tr align=\"center\" valign=\"middle\">");
        }
    echo("<td><form ACTION=\"" . $config["URI_prefix"] . $config["script_suffix"] . $bible_books[$tint]["short"] . "/" . 1 . "/\" METHOD=\"post\"><input TYPE=\"submit\" VALUE=\"" . $bible_books[$tint]["long"] . "\"></form></td>\n");
    $tint++;
    $wrap++;
    }
?>
</tr></table>

</div>
    <?
    }
else if(strcasecmp($config["operation"], "Search") == 0) //Not displaying the title page, but are searching.
    {
    if(!isset($config["search"]) || strcmp(trim($config["search"]), "") == 0) //If there's nothing in there.
        {
        echo("<h3>If I'm going to search, I need something to search for. (Regular Expressions are supported.)</h3>\n");
        }
    else
        {
        $config["search"] = addslashes(trim($config["search"]));
        $bdata_path = $config["local_prefix"] . $config["bible_midfix"];
        
        //if(!isset($config["book"]))
        if($bookok === FALSE)
            {
            unset($files); //Make sure is unset.
            foreach($bible_books as $bible_book)
                {
                $files = ($files . $bible_book["short"] . " ");
                }
            
            $command = ("'" . $config["search"] . "' " . $files);
            }
        else
            {
            $command = ("'" . $config["search"] . "' " . $config["book"]);
            }
        
        if(($search_results = popen($config["good_shell"] . " -c \"cd " . $bdata_path . "; env LANG=C " . $config["grep_command"] . " -H -i " . $command . "\"", "r")) == FALSE)
            {
            echo("<h3>Error! Error! Unable to read search results!</h3>\n");
            }
        else
            {
            echo("<div align=\"center\"><h3>Search Results</h3></div>\n");
            
            if(is_valid_number($config["page"]) === FALSE) $config["page"] = 1; //If we can't use it, it is probably nothing.
            
            $evaluate_verse_next = TRUE;
            $page = 0;
            $subpage = $config["search_results_per_page"] + 5;
            
            while($search_results != FALSE && !feof($search_results))
                {
                $buffer = fgets($search_results, 128);
                if($evaluate_verse_next === TRUE && strcmp(rtrim($buffer), "") == 0);//echo("<h3>Killed a buffer!</h3>\n");
                else
                    {
                    if($evaluate_verse_next === TRUE)
                        {
                        //Ok, this is a new verse, so we need to parse in and mark up the verse header.
                        $buffer = explode(" ", $buffer, 2); //Seperate the verse from the header.
                        $versedata = explode(":", $buffer[0]); //Explode the chunks of the header.
                        $buffer = $buffer[1]

I am including the rest of this in the next post.

 

 

 


Reply

wild20
And here is the rest:

CODE

//Let's do our page thing.
                        if($subpage >= $config["search_results_per_page"])
                            {
                            $page++;
                            $subpage = 1;
                            
                            if($page == $config["page"]) $display = TRUE; //Allowed to display.
                            else $display = FALSE;
                            }
                        else $subpage++;
                        
                        if($display === TRUE && $previous_book != $versedata[0]) //This is a new book.
                            {
                            if(isset($previous_book)) if($display === TRUE) { $output_buffer = $output_buffer . ("</ul></li>"); $started_book_list = FALSE; }
                            for($tint = 0;isset($bible_books[$tint]);$tint++)
                                {
                                if(strcasecmp($versedata[0], $bible_books[$tint]["short"]) == 0) //This is a ref to the short name.
                                    $tstring = $bible_books[$tint]["long"];
                                }
                            
                            if(!isset($tstring)) echo("<p><b>Error! \$tstring unset!</b></p>\n");
                            
                            if($display === TRUE) { $output_buffer = $output_buffer . ("<li>" . $tstring . "<ul>"); $started_book_list = TRUE; }
                            $previous_book = $versedata[0];
                            }
                        if($display === TRUE) $output_buffer = $output_buffer . ("<li><sup><a href=\"" . $config["URI_prefix"] . $config["script_suffix"] . $versedata[0] . "/" . $versedata[1] . "/" . $versedata[2] . "\">" . $versedata[1] . ":" . $versedata[2] . "</a></sup> ");
                        }
                    if($display === TRUE) $output_buffer = $output_buffer . (htmlentities($buffer));
                    $evaluate_verse_next = FALSE; //Assume that we're not going to evaluate the verse next time.
                    if(!(strpos($buffer, "\n") === FALSE)) //If there is a newline, then the verse is over.
                        {
                        $evaluate_verse_next = TRUE;
                        if($display === TRUE) $output_buffer = $output_buffer . ("</li>\n");
                        }
                    }
                }
            if(isset($started_book_list) && $started_book_list === TRUE) { $output_buffer = $output_buffer . ("</ul></li>"); $started_book_list = FALSE; } //Make sure we've closed the tags.
            
            if($page != 0)
                {
                echo("<div align=\"center\">\n");
                echo("<p>Page " . $config["page"] . " of " . $page . "</p>\n");
                
                /////PREVIOUS
                echo("<table border=\"0\" width=\"50%\"><tr>\n");
                echo("<td align=\"left\" valign=\"middle\">\n");
                echo("<form ACTION=\"" . $config["URI_prefix"] . $config["script_suffix"] . "\" METHOD=\"get\">\n");
                echo("<input type=\"hidden\" name=\"operation\" value=\"Search\">\n");
                if($bookok === TRUE) echo("<input type=\"hidden\" name=\"book\" value=\"" . $config["book"] . "\">\n");
                echo("<input type=\"hidden\" name=\"search\" value=\"" . $config["search"] . "\">\n");
                echo("<input type=\"hidden\" name=\"page\" value=\"" . ($config["page"] - 1) . "\">\n");
                if(($config["page"] - 1) < 1 || $config["page"] > $page || $config["page"] < 1) echo("<input type=\"submit\" value=\"&lt;&lt; Previous Page\" disabled>\n");
                else echo("<input type=\"submit\" value=\"&lt;&lt; Previous Page\">\n");
                echo("</form>\n");
                echo("</td>\n");
                
                /////SEEK
                echo("<td align=\"center\" valign=\"middle\">\n");
                echo("<form ACTION=\"" . $config["URI_prefix"] . $config["script_suffix"] . "\" METHOD=\"get\">\n");
                echo("<input type=\"hidden\" name=\"operation\" value=\"Search\">\n");
                if($bookok === TRUE) echo("<input type=\"hidden\" name=\"book\" value=\"" . $config["book"] . "\">\n");
                echo("<input type=\"hidden\" name=\"search\" value=\"" . $config["search"] . "\">\n");
                echo("Page: <input type=\"text\" name=\"page\" value=\"" . $config["page"] . "\" size=\"4\" maxlength=\"10\">\n");
                echo("<input type=\"submit\" value=\"Go\">\n");
                echo("</form>\n");
                
                /////NEXT
                echo("<td align=\"right\" valign=\"middle\">\n");
                echo("<form ACTION=\"" . $config["URI_prefix"] . $config["script_suffix"] . "\" METHOD=\"get\">\n");
                echo("<input type=\"hidden\" name=\"operation\" value=\"Search\">\n");
                if($bookok === TRUE) echo("<input type=\"hidden\" name=\"book\" value=\"" . $config["book"] . "\">\n");
                echo("<input type=\"hidden\" name=\"search\" value=\"" . $config["search"] . "\">\n");
                echo("<input type=\"hidden\" name=\"page\" value=\"" . ($config["page"] + 1) . "\">\n");
                if(($config["page"] + 1) > $page || $config["page"] > $page || $config["page"] < 1) echo("<input type=\"submit\" value=\"Next Page &gt;&gt;\" disabled>\n");
                else echo("<input type=\"submit\" value=\"Next Page &gt;&gt;\">\n");
                echo("</form>\n");
                echo("</td>\n");

                echo("</tr></table>\n");
                echo("</div>\n");
                }
            
            if(isset($output_buffer)) echo("<ul>\n" . $output_buffer . "</ul>\n");
            else if($page == 0) echo("<p>Sorry, no search results.</p>\n");
            else if($config["page"] > $page || $config["page"] < 1) echo("<p>Sorry, nothing in the requested page.</p>\n");
            else echo("<p>Phew, there's nothing to display, and I'm not sure why. (This is a bug.)\n");
            }
        }
    }
else //Not displaying the title page, or searching. (Display actual scripture.)
    {
    echo("<div align=\"center\"><h2>" . $bible_books[$bookindex]["long"]);
    if(isset($config["chapter"]) && !isset($config["verse"])) echo(", Chapter " . $config["chapter"]);
    else if(isset($config["chapter"]) && isset($config["verse"])) echo(" " . $config["chapter"] . ":" . $config["verse"]);
    if(isset($config["verse"]) && isset($config["verse_end"])) echo("-" . $config["verse_end"]);
    echo("</h2></div>\n");
    
    $evaluate_verse_next = TRUE;
    
    $previous_chapter_exists = FALSE;
    $next_chapter_exists = FALSE;
    $previous_verse_exists = FALSE;
    $next_verse_exists = FALSE;
    
    $ever_displayed = FALSE;
    
    if(isset($config["verse"]) && isset($config["verse_end"])) $range_error = TRUE;
    else $range_error = FALSE;
    
    $last_chapter = 0;
    
    $range_hit_start = FALSE;
    $range_hit_end = FALSE;
    
    if(!isset($config["chapter"]) && !isset($config["verse"]))
        {
        echo("<div align=\"center\"><h3>Please select a chapter.</h3><table border=\"0\"><tr align=\"center\" valign=\"middle\">\n");
        $wrap = 0;
        }
    
    while(!feof($bookfile))
        {
        $buffer = fgets($bookfile, 128);
        if($evaluate_verse_next === TRUE && strcmp(rtrim($buffer), "") == 0);//echo("<h3>Killed a buffer!</h3>\n");
        else //Buffer isn't killed.
            {
            if($evaluate_verse_next === TRUE) //Last thing we did was find the end of a verse.
                {
                for($tint = 0;isset($buffer[$tint]) == TRUE && $buffer[$tint] != ":";$tint++) {; }
                $current_chapter = substr($buffer, 0, $tint);
                $tint2 = $tint + 1;
                for($tint = 0;isset($buffer[$tint + $tint2]) == TRUE && $buffer[$tint + $tint2] != " ";$tint++) {; }
                $current_verse = substr($buffer, $tint2, $tint);
                
                $display = FALSE; //Assume that we're not to display the data.
                
                if(isset($config["chapter"]) && $current_chapter < $config["chapter"]) $previous_chapter_exists = TRUE;
                if(isset($config["chapter"]) && $current_chapter > $config["chapter"]) $next_chapter_exists = TRUE;
                if(isset($config["chapter"]) && isset($config["verse"]) && $current_chapter === $config["chapter"] && $current_verse < $config["verse"]) $previous_verse_exists = TRUE;
                if(isset($config["chapter"]) && isset($config["verse"]) && !isset($config["verse_end"]) && $current_chapter === $config["chapter"] && $current_verse > $config["verse"]) $next_verse_exists = TRUE;
                if(isset($config["chapter"]) && isset($config["verse"]) && isset($config["verse_end"]) && $current_chapter === $config["chapter"] && $current_verse > $config["verse_end"]) $next_verse_exists = TRUE;
                
                if(isset($config["chapter"]) && isset($config["verse"]) && $current_chapter === $config["chapter"] && $current_verse === $config["verse"]) $display = TRUE;
                else if(isset($config["chapter"]) && isset($config["verse"]) && isset($config["verse_end"]) && $current_chapter === $config["chapter"] && $current_verse >= $config["verse"] && $current_verse <= $config["verse_end"]) $display = TRUE;
                if(isset($config["chapter"]) && !isset($config["verse"]) && $current_chapter === $config["chapter"]) $display = TRUE;
                
                if(isset($config["chapter"]) && $current_chapter === $config["chapter"] && isset($config["verse"]) && isset($config["verse_end"]) && $current_verse === $config["verse"]) $range_hit_start = TRUE;
                if(isset($config["chapter"]) && $current_chapter === $config["chapter"] && isset($config["verse"]) && isset($config["verse_end"]) && $current_verse === $config["verse_end"]) $range_hit_end = TRUE;
                
                if(!isset($config["chapter"]) && !isset($config["verse"]))
                    {
                    if($last_chapter < $current_chapter)
                        {
                        if($wrap >= $config["element_wrap"])
                            {
                            $wrap = 0;
                            echo("</tr><tr align=\"center\" valign=\"middle\">");
                            }

                        echo("<td><form ACTION=\"" . $config["URI_prefix"] . $config["script_suffix"] . $bible_books[$bookindex]["short"] . "/" . $current_chapter . "/\" METHOD=\"post\"><input TYPE=\"submit\" VALUE=\"Chapter " . $current_chapter . "\"></form></td>\n");
                        $last_chapter = $current_chapter;
                        $wrap++;
                        }
                    }
                
                if($display === TRUE)
                    {
                    if($ever_displayed === FALSE) //Never displayed before.
                        {
                        if(!isset($config["operation"]) || !(strcmp($config["operation"], "print") == 0)) echo("<div align=\"center\"><p><table width=\"60%\" border=\"3\"><tr><td align=\"left\" valign=\"middle\">\n");
                        else echo("<div align=\"left\"><p>\n");
                        }
                    $ever_displayed = TRUE;
                    echo("<sup><a href=\"" . $config["URI_prefix"] . $config["script_suffix"] . $config["book"] . "/" . $current_chapter . "/" . $current_verse . "\">" . $current_chapter . ":" . $current_verse . "</a></sup> ");
                    }
                }
            if($display === TRUE) //We are supposed to be printing the data here.
                {
                if($evaluate_verse_next === TRUE) echo(htmlentities(substr($buffer, strlen($current_chapter) + strlen($current_verse) + 2), ENT_COMPAT)); //This line actually dumps the data.
                else echo(htmlentities($buffer, ENT_COMPAT)); //This line actually dumps the data.
                }
            $evaluate_verse_next = FALSE; //Assume that we're not going to evaluate the verse next time.
            if(!(strpos($buffer, "\n") === FALSE)) //If there is a newline, then the verse is over.
                {
                $evaluate_verse_next = TRUE;
                if($display === TRUE) echo("<br>\n");
                }
            }
        }
    
    if($range_hit_start === TRUE && $range_hit_end === TRUE) $range_error = FALSE;
    
    if($ever_displayed === TRUE)
        {
        if(!isset($config["operation"]) || !(strcmp($config["operation"], "print") == 0))
            {
            echo("</td></tr></table></div>\n");
            echo("<div align=\"right\"><p><a target=\"_blank\" href=\"" . $config["URI_prefix"] . $config["script_suffix"] . $config["book"] . "/" . $config["chapter"] . "/" . $config["verse"]);
            if(isset($config["verse"]) && isset($config["verse_end"])) echo("-" . $config["verse_end"]);
            echo("?operation=print\">Printable Mode</a></p></div>\n");
            }
        else
            {
            echo("</p></div>\n");
            }
        }
    
    if(isset($config["chapter"]) && isset($config["verse"]) && (!isset($config["operation"]) || !(strcmp($config["operation"], "print") == 0)))
        {
        echo("<div align=\"center\"><form ACTION=\"" . $config["URI_prefix"] . $config["script_suffix"] . $config["book"] . "/" . $config["chapter"] . "/\" METHOD=\"post\">\n");
        echo("<input TYPE=\"submit\" VALUE=\"Zoom Out\"></form></div>\n");
        }
    
    if(!isset($config["chapter"]) && !isset($config["verse"]))
        {
        echo("</tr></table></div>\n");
        }
    else if($ever_displayed === FALSE || $range_error === TRUE)
        {
        //Make sure we're sufficiently sorry.
        echo("<div align=\"center\"><h3>Sorry. One or more of the requested passages does not exist. " . $bible_books[$bookindex]["long"]);
        if(isset($config["chapter"]) && !isset($config["verse"])) echo(", Chapter " . $config["chapter"]);
        else if(isset($config["chapter"]) && isset($config["verse"])) echo(" " . $config["chapter"] . ":" . $config["verse"]);
        if(isset($config["verse"]) && isset($config["verse_end"])) echo("-" . $config["verse_end"]);
        echo("</h3></div>\n");

        $previous_chapter_exists = FALSE;
        $next_chapter_exists = FALSE;
        $previous_verse_exists = FALSE;
        $next_verse_exists = FALSE;
        }
    
    if(isset($config["verse_end"])) $next_verse_start = $config["verse_end"];
    else if(isset($config["verse"])) $next_verse_start = $config["verse"];
    else $next_verse_start = 0;
    
    fclose($bookfile);
    }

if(!isset($config["operation"]) || !(strcmp($config["operation"], "print") == 0))
    {
    ?>
    <div align="center">
        <table border="0" width="50%">
        <tr align="center" valign="middle">
        
            <td align="left"><form ACTION="<? echo($config["URI_prefix"] . $config["script_suffix"] . $config["book"] . "/" . ($config["chapter"] - 1) . "/" . $config["verse"]); ?>" METHOD="post"><input TYPE="submit" VALUE="<< Previous Chapter" <? if(isset($config["verse"]) || !isset($previous_chapter_exists) || $previous_chapter_exists != TRUE) echo("DISABLED"); ?> /></form></td>
    
            <td align="left"><form ACTION="<? echo($config["URI_prefix"] . $config["script_suffix"] . $config["book"] . "/" . $config["chapter"] . "/" . ($config["verse"] - 1)); ?>" METHOD="post"><input TYPE="submit" VALUE="<< Previous Verse" <? if(!isset($config["verse"]) || !isset($previous_verse_exists) || $previous_verse_exists != TRUE) echo("DISABLED"); ?> /></form></td>
    
            <td align="right"><form ACTION="<? echo($config["URI_prefix"] . $config["script_suffix"] . $config["book"] . "/" . $config["chapter"] . "/" . ($next_verse_start + 1)); ?>" METHOD="post"><input TYPE="submit" VALUE="Next Verse >>" <? if(!isset($config["verse"]) || !isset($next_verse_exists) || $next_verse_exists != TRUE) echo("DISABLED"); ?> /></form></td>
    
            <td align="right"><form ACTION="<? echo($config["URI_prefix"] . $config["script_suffix"] . $config["book"] . "/" . ($config["chapter"] + 1) . "/" . $config["verse"]); ?>" METHOD="post"><input TYPE="submit" VALUE="Next Chapter >>" <? if(isset($config["verse"]) || !isset($next_chapter_exists) || $next_chapter_exists != TRUE) echo("DISABLED"); ?> /></form></td>
        
        </tr></table>
        <p>Seek to any passage:
        <form ACTION="<? echo($config["URI_prefix"] . $config["script_suffix"]); ?>" METHOD="post">
            Book: <select NAME="book">
            <!-- <option VALUE="" SELECTED>All Books (for searching)</option> -->
                <?
                for($tint = 0;isset($bible_books[$tint]);$tint++)
                    {
                    if($bookok === TRUE && $tint === $bookindex) echo("<option VALUE=\"" . $bible_books[$tint]["short"] . "\" SELECTED>" . $bible_books[$tint]["long"] . "</option>\n");
                    else echo("<option VALUE=\"" . $bible_books[$tint]["short"] . "\">" . $bible_books[$tint]["long"] . "</option>\n");
                    }
                ?>
            </select>
            Chapter:
                <?
                if(isset($config["chapter"])) echo("<input TYPE=\"text\" NAME=\"chapter\" size=\"4\" maxlength=\"10\" value=\"" . $config["chapter"] . "\">");
                else echo("<input TYPE=\"text\" NAME=\"chapter\" size=\"4\" maxlength=\"10\">");
                ?>
            Verse:
                <?
                if(isset($config["verse"]) && !isset($config["verse_end"])) echo("<input TYPE=\"text\" NAME=\"verse\" size=\"4\" maxlength=\"10\" value=\"" . $config["verse"] . "\">");
                else if(isset($config["verse"]) && isset($config["verse_end"])) echo("<input TYPE=\"text\" NAME=\"verse\" size=\"4\" maxlength=\"10\" value=\"" . $config["verse"] . "-" . $config["verse_end"] . "\">");
                else echo("<input TYPE=\"text\" NAME=\"verse\" size=\"4\" maxlength=\"10\">");
                ?>
            <input type="hidden" name="operation" value="Go">
            <input type="submit" value="Go">
        </form>
        
        <? if($config["disable_searching"] != TRUE)
            {
            ?>
            <p>Search the text:
            <form ACTION="<? echo($config["URI_prefix"] . $config["script_suffix"]); ?>" METHOD="get">
                Search in: <select NAME="book">
                <option VALUE="">All Books</option>
                    <?
                    for($tint = 0;isset($bible_books[$tint]);$tint++)
                        {
                        if($bookok === TRUE && $tint === $bookindex) echo("<option VALUE=\"" . $bible_books[$tint]["short"] . "\" SELECTED>" . $bible_books[$tint]["long"] . "</option>\n");
                        else echo("<option VALUE=\"" . $bible_books[$tint]["short"] . "\">" . $bible_books[$tint]["long"] . "</option>\n");
                        }
                    ?>
                </select>
                    
                Terms: <input type="text" name="search" value="<? if(isset($config["search"])) echo($config["search"]); ?>">
                <input type="hidden" name="operation" value="Search">
                <input type="submit" value="Search">
            
            </form>
            <?
            }
        ?>
    </div>
    <?
    }
?>
    
<hr>

<div align="center">
<p>This is Alex Markley's <a href="http://bible.cyberMalex.com/">PHP<i>Script</i>ure</a> v<? echo($config["version"]["major"] . "." . $config["version"]["minor"] . "." . $config["version"]["subminor"]); ?>, displaying a copy of the <a href="http://WorldEnglishBible.org/">World English Bible.</a></p>

<p>This copy of the <a href="http://WorldEnglishBible.org/">World English Bible</a> is a draft version.
Updates are available at <a href="http://eBible.org">http://eBible.org</a>.</p>

<p><small>&quot;World English Bible&quot; and WorldEnglishBible.org are trademarks of Rainbow Missions, Inc. The World English Bible is not copyrighted. The domain name eBible.org is a trademark of <a href="http://WorldEnglishBible.org/mpj/">Michael Paul Johnson</a>.</small></p>

</div>

<?
if($config["headerless"] === FALSE && (!isset($config["operation"]) || !(strcmp($config["operation"], "print") == 0)))
    {
    ?>
    <div align="left">
    <p>
        <a <? if($theme_unset != TRUE) { ?>style="background:<? echo($config["color"]["body"]["background"]); ?>;color:<? echo($config["color"]["body"]["foreground"]); ?>;" <? } ?> href="http://validator.w3.org/check/referer"><img style="border:0;width:88px;height:31px" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" height="31" width="88"></a>
        <? if($theme_unset != TRUE) { ?><a style="background:<? echo($config["color"]["body"]["background"]); ?>;color:<? echo($config["color"]["body"]["foreground"]); ?>;" href="http://jigsaw.w3.org/css-validator/check/referer"><img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a> <? } ?>
    </p>
    </div>
    <?
    }
?>

<?
if($config["headerless"] === FALSE)
    {
    ?>
    </body>
    </html>
    <?
    }
?>


So what is suppose to happen is that the php pulls the requested text out and displays it, but when I click, lets say, 1 Choronicles, it tried to displ