error_reporting(0);
IF($_POST['file']){
$file = $_POST['file'];
}
IF($_GET['file']){
$file = $_GET['file'];
}
$form = $_POST['form'];
$SearchNumber = $_POST['SearchNumber'];
$SearchString = $_POST['SearchString'];
$RString = $_POST['RString'];
$PrintBox = $_POST['PrintBox'];
$AllowSingle = $_POST['AllowSingle'];
//print "
";
//print "_POST
";
//print_r($_POST );
//print "
";
//print "
";
//
//print "";
//print "_GET
";
//print_r($_GET );
//print "
";
//print "
";
//Function prints a lookup input text box and a submit button, and requires 5 parameters:
//1. $file - This is the data file that contains the dates and serial numbers.
//2. $from - The name of the form to call when the submit button is clicked. This can
// be left blank and the form will recall itself.
//3. $SearchString is provided when a number is provided in the text box and submit
// is clicked. If blank the opening screen is printed.
//4. $RString - String to print for the results message.
//5. $PrintBox - Should be set to y or n, y will print the text box and submit button, n won't
//6. $AllowSingle - Should be set to y or n, y will allow single number searches
function MatchStringLeft($file, $form, $SearchString, $RString, $PrintBox, $AllowSingle)
{
$Match="n"; //Switch that is set to y if a match is found.
$file = trim ($file); //trim leading and trailing spaces from data file name
$InFile = "data/$file"; //adds data directory path to file name.
$fnl=strlen ($file); //Get length of the input file.
$sstrlen = strlen ($SearchString); //Get length of the search string.
$fp=fopen($InFile,'r') or die("Could not open $InFile"); // Opens data file for read.
while ( ! feof($fp))
{
$line=fgets($fp,1024); //Read in data file one line at a time, stores data in the $line array
$line = str_replace ("\",\"", "~", "$line"); //Replaces "," with ~
$line = str_replace ("\"", "", "$line"); //Replaces " with nothing
//search, replace, subject
if (trim($line)!="") //Store strings to be searched in $SNumbrs if the line is not blank
{
$SNumbrs[]=trim($line); //Stores each line of input in an array.
}
}
print "";
}
//Function prints a lookup input text box and a submit button, and requires 5 parameters:
//1. $file - This is the data file that contains the dates and serial numbers.
//2. $from - The name of the form to call when the submit button is clicked. This can
// be left blank and the form will recall itself.
//3. $SearchString is provided when a number is provided in the text box and submit
// is clicked. If blank the opening screen is printed.
//4. $Case - Should be blank u or l if set to u all search input is change to upper case.
// if set to l all search input is set to lower case. If blank search input case is not is changed.
//5. $RString - String to print for the results message.
//If the search number is matched function prints out the results
function MatchString($file, $form, $SearchString, $Case, $RString)
{
$Match="n"; //Switch that is set to y if a match is found.
$file = trim ($file); //trim leading and trailing spaces from data file name
$InFile = "data/$file"; //adds data directory path to file name.
$fnl=strlen ($file); //Get length of the input file.
$sstrlen = strlen ($SearchString); //Get length of the input file.
$fp=fopen($InFile,'r') or die("Could not open $InFile"); // Opens data file for read.
while ( ! feof($fp))
{
$line=fgets($fp,1024); //Read in datafile one line at a time, stores data in the $line array
$line = str_replace ("\",\"", "~", "$line"); //Replaces "," with ~
$line = str_replace ("\"", "", "$line"); //Replaces " with nothing
//search, replace, subject
if (trim($line)!="") //Store strings to be searched in $SNumbrs if the line is not blank
{
$SNumbrs[]=trim($line); //Stores each line of input in an array.
}
}
print "";
}
//This function prints a select button and a model list. The function requires
//three parameters:
//1. a catagory the following are catagory definitions:
// conversion = "c";
// hand gun = "h";
// hand gun double action = "hd";
// hand gun pocket = "hp";
// hand gun semi-auto = "hsemi";
// hand gun single action = "hs";
// long gun = "l";
// long gun bolt = "lb";
// long gun lever action = "ll";
// long gun$ pump = "lp";
// long gun semi-auto = "lsemi";
// long gun shotgun = "ls";
//2. a ModFile, which lists all modles for that brand in the following format:
// file name~model~category code
//mod files avaliable at this time are:
// winmods.dat
// milmods.dat
// savmods.dat
// cltmods.dat
//3. a call file name, this is the file that is called when submit is pressed.
//
//This function sends a file name ($file) to the form that it calls.
function PrintModLst($catagory, $ModFile, $CallFile)
{
$i=0;
$fp=fopen($ModFile,'r') or die("Could not open $ModFile"); // Opens data file for read.
while ( ! feof($fp)) //Read in datafile one line at a time.
{
$line=fgets($fp,1024);
$Mods[]=$line; //Stores each line of input in an array.
}
print "";
}
//Function prints a lookup input text box and a submit button, requires 3 parameters:
//1. $file - This is the data file to search it should contain the dates and serial numbers.
//2. $from - The name of the form to call when the submit button is clicked.
// If this is blank and the form will recall itself.
//3. $SearchNumber *Should be left blank* is passed to the function when a number is entered
// in the text box and the submit button is clicked.
// If $SearchNumber is blank the opening screen is printed.
function lookup($file, $form, $SearchNumber)
{
//print "Now inside lookup function.
";
//print "File =" . $file. "
";
//print "form =" .$form. "
";
//print "SearchNumber =" .$SearchNumber. "
";
$file = trim ($file); //trim leading and trailing spaces from data file name
$InFile = "data/$file"; //adds data directory path to file name.
$fnl=strlen ($file); //Get length of the input file.
// The following section looks up the model name form the file name in the ???mods.dat file and
// and prints it out in the results screen.
$type = substr ($file, 0,3);
if ($type == "win") { //Sets brand to Winchester.
$ModFile = "mods/winmods.dat"; //adds data directory path to file name.
$Brand = "Winchester";
}
elseif ($type == "us_") { //Sets brand to U.S Military.
$ModFile = "mods/milmods.dat"; //adds data directory path to file name.
$Brand = "U.S. Military";
}
elseif ($type == "brm") { //Sets brand to Mauser Pistol C-96 (Broomhandle).
$ModFile = "mods/singlemod.dat"; //adds data directory path to file name.
$Brand = "Mauser Pistol C-96 (Broomhandle)";
} // singlemod.dat is used if there is no modifle for this selection.
elseif ($type == "mar") { //Sets brand to "Marlin".
$ModFile = "mods/singlemod.dat"; //adds data directory path to file name.
$Brand = "Marlin"; // singlemod.dat is used if there is no modifle for this selection.
}
else { //Sets brand to blank.
$ModFile = "mods/singlemod.dat"; //adds data directory path to file name.
$Brand = ""; //This selection should be used if a brand name is not desired.
}; // singlemod.dat is used if there is no modifle for this selection.
$fp=fopen($ModFile,'r') or die("Could not open $ModFile"); // Opens correct mods data file for read.
while ( ! feof($fp)) //Read in datafile one line at a time.
{
$line=fgets($fp,1024);
if ($file == substr ($line, 0,$fnl)) {
$NameLine = $line;
}
}
$Name = explode ("~", $NameLine);
///////////////////// End of brand lookup section.
// The following code looks up a searial number match and prints out the results.
$fp=fopen($InFile,'r') or die("Could not open $InFile"); // Opens data file for read.
while ( ! feof($fp))
{
$line=fgets($fp,1024); //Read in datafile one line at a time, stores data in the $line array
$line = str_replace ("\",\"", "~", "$line"); //Replaces "," with ~
$line = str_replace ("\"", "", "$line"); //Replaces " with nothing
if (trim($line)!="") //Store serial numbers to be searched in $SNumbrs if the line is not blank
{
$SNumbrs[]=trim($line); //Stores each line of input in an array.
}
}
$size = count ($SNumbrs); //Get how many serial numbers are in the array.
$size = ($size-1); //Subtract 1 because array numbers start with 0
$first = explode ("~", $SNumbrs[0]); //Store the first serial number in $first
$last = explode ("~", $SNumbrs[$size]); //Store the last serial number in $last
$last[0]=trim($last[0]); //Remove leading & trailing white space from $last
if(!is_numeric ($first[0])) //Check to see if the first item in the data file is a number.
{ //If not a number it means that this model was not numbered.
print ("$Brand $Name[1]:
$first[3]
$first[2]
");
//Prints out information from position #4 in the data file
// if the model is not numbered.
}
else // If the model is numbered the following matches the serial number and prints out the results.
{
print "";
}
}
//print "File =" . $file. "
";
//print "form =" .$form. "
";
//print "SearchNumber =" .$SearchNumber. "
";
function lookupWin($file, $form, $SearchNumber)
{
$file = trim ($file); //trim leading and trailing spaces from data file name
$InFile = "data/$file"; //adds data directory path to file name.
$fnl=strlen ($file); //Get length of the input file.
// The following section looks up the model name form the file name in the ???mods.dat file and
// and prints it out in the results screen.
$type = substr ($file, 0,3);
if ($type == "win") { //Sets brand to Winchester.
$ModFile = "mods/winmods.dat"; //adds data directory path to file name.
$Brand = "Winchester";
}
elseif ($type == "us_") { //Sets brand to U.S Military.
$ModFile = "mods/milmods.dat"; //adds data directory path to file name.
$Brand = "U.S. Military";
}
elseif ($type == "brm") { //Sets brand to Mauser Pistol C-96 (Broomhandle).
$ModFile = "mods/singlemod.dat"; //adds data directory path to file name.
$Brand = "Mauser Pistol C-96 (Broomhandle)";
} // singlemod.dat is used if there is no modifle for this selection.
elseif ($type == "mar") { //Sets brand to "Marlin".
$ModFile = "mods/singlemod.dat"; //adds data directory path to file name.
$Brand = "Marlin"; // singlemod.dat is used if there is no modifle for this selection.
}
else { //Sets brand to blank.
$ModFile = "mods/singlemod.dat"; //adds data directory path to file name.
$Brand = ""; //This selection should be used if a brand name is not desired.
}; // singlemod.dat is used if there is no modifle for this selection.
$fp=fopen($ModFile,'r') or die("Could not open $ModFile"); // Opens correct mods data file for read.
while ( ! feof($fp)) //Read in datafile one line at a time.
{
$line=fgets($fp,1024);
if ($file == substr ($line, 0,$fnl)) {
$NameLine = $line;
}
}
$Name = explode ("~", $NameLine);
///////////////////// End of brand lookup section.
// The following code looks up a searial number match and prints out the results.
$fp=fopen($InFile,'r') or die("Could not open $InFile"); // Opens data file for read.
while ( ! feof($fp))
{
$line=fgets($fp,1024); //Read in datafile one line at a time, stores data in the $line array
$line = str_replace ("\",\"", "~", "$line"); //Replaces "," with ~
$line = str_replace ("\"", "", "$line"); //Replaces " with nothing
if (trim($line)!="") //Store serial numbers to be searched in $SNumbrs if the line is not blank
{
$SNumbrs[]=trim($line); //Stores each line of input in an array.
}
}
$size = count ($SNumbrs); //Get how many serial numbers are in the array.
$size = ($size-1); //Subtract 1 because array numbers start with 0
$first = explode ("~", $SNumbrs[0]); //Store the first serial number in $first
$last = explode ("~", $SNumbrs[$size]); //Store the lste serial number in $last
$last[0]=trim($last[0]); //Remove leading & trailing whitspace from $last
if(!is_numeric ($first[0])) //Check to see if the first item in the data file is a number.
{ //If not a number it means that this model was not numbered.
print ("$Brand $Name[1]:
$first[3]
$first[2]
");
//Prints out information from position #4 in the data file
// if the model is not numbered.
}
else // If the model is numbered the following matches the serial number and prints out the results.
{
print "";
}
}
?>