<?php if($url_blocker != "75726C00"){Header("Location: ./"); exit;}?>
<?
if($logcheck['Option1'] == 1 && $logcheck['Option4'] == 0 || $logcheck['Option1'] == 0 ){
include ("./functions.php");
//pick what the first 4 fields have and the records per page
$get_options = mysql_fetch_array(mysql_query("SELECT `Option1`,`Option2`,`Option3`,`Option4`, `Option5` FROM `config` WHERE config = 'm_field_config' LIMIT 1"));
$option1 = $get_options["Option1"];
$option2 = $get_options["Option2"];
$option3 = $get_options["Option3"];
$option4 = $get_options["Option4"];
$option5 = intval($get_options["Option5"]);
$title= addslashes($_REQUEST['title']);
$actors= addslashes($_REQUEST['actors']);
$director= addslashes($_REQUEST['director']);
$genre= addslashes($_REQUEST['genre']);
$titler= addslashes($_REQUEST['titler']);
$actorsr= addslashes($_REQUEST['actorsr']);
$directorr= addslashes($_REQUEST['directorr']);
$genrer= addslashes($_REQUEST['genrer']);
$fulltext= addslashes($_REQUEST['fulltext']);
$pagination = addslashes($_REQUEST['pagination']);
// builds a sql search string that is stored as $doing
if ($doing != "1"){
$doing = "";
if ($genrer == "is"){
If($doing != ""){
$doing .= " && ";
}
$doing .= "genre LIKE '%$genre%'";
}else if ( $genrer == "not"){
If($doing != ""){
$doing .= " && ";
}
$doing .= "genre NOT LIKE '%$genre%'";
}
if ($titler == "is"){
If($doing != ""){
$doing .= " && ";
}
$doing .= "title LIKE '%$title%'";
}else if ( $titler == "not"){
If($doing != ""){
$doing .= " && ";
}
$doing .= "title NOT LIKE '%$title%'";
}
if ($actorsr == "is"){
If($doing != ""){
$doing .= " && ";
}
$doing .= "actors LIKE '%$actors%'";
}else if ( $actorsr == "not"){
If($doing != ""){
$doing .= " && ";
}
$doing .= "actors NOT LIKE '%$actors%'";
}
if ($directorr == "is"){
If($doing != ""){
$doing .= " && ";
}
$doing .= "director LIKE '%$director%'";
}else if ( $directorr == "not"){
If($doing != ""){
$doing .= " && ";
}
$doing .= "director NOT LIKE '%$director%'";
}
If($doing != ""){
$doing = " AND $doing";
}
//checks usingsearch string
$list_records = mysql_query("SELECT visual.$option1, visual.$option2, visual.$option3, visual.$option4, callnum, visual.refurl, id_list.id FROM visual, id_list WHERE id_list.refurl = visual.refurl $doing") or die(mysql_error());
}else{
//checks the full text database
$list_records = mysql_query("SELECT visual.$option1, visual.$option2, visual.$option3, visual.$option4, callnum, visual.refurl, id_list.id, MATCH (title,actors,director,genre,outline,synopsis) AGAINST ('$fulltext') AS score FROM visual, id_list WHERE id_list.refurl = visual.refurl AND MATCH (title,actors,director,genre,outline,synopsis) AGAINST ('$fulltext' IN BOOLEAN MODE) order by score desc");
}
// begin list records
if ($row = mysql_fetch_array($list_records)) {
//if yhere will be formating:
//find out how many records to display on each page and format the paging
$reccount = mysql_num_rows($list_records);
if($reccount > $option5 && $paginate != 1 && $pagination == "on"){
$reccount = ceil($reccount/$option5);
for($x = 1; $reccount >= $x; $x++) {
$links .= "<a href=\"javascript:changepage('id_$x');\"> $lang_[page] $x </a>";
}
$x=0;
$i = 1;
}else{
$i = NULL;
//for less records than what option 5 is set to
print(" <table cellpadding=\"1\" cellspacing=\"1\" align=\"center\" width=\"95%\" summary=\"List of all records in the search\"><tr class=\"forTablesHead\"
align=\"center\"><td>".ucwords($option1)."</td><td>".ucwords($option2)."</td><td>".ucwords($option3)."</td><td>".ucwords($option4)."</td><td>Call
Number</td><td>Id</td> </tr>");
}
do{
//if there are multiple pages then give each set their own div and table.
if ($i == 1 && $i != NULL) {
++$x;
if($x == 1){
print("<div style=\"display: block;\" id=\"id_$x\">");
}else{
print("<div style=\"display: none;\" id=\"id_$x\">");
}
print(" <table cellpadding=\"1\" cellspacing=\"1\" align=\"center\" width=\"95%\" summary=\"List of a page of records from the search\">
<tr class=\"forTablesHead\" align=\"center\">
<td >".ucwords($option1)."</td><td>".ucwords($option2)."</td><td>".ucwords($option3)."</td><td>".ucwords($option4)."</td><td>Call Number</td><td>Id</td>
</tr> <tr class=\"forTables\"><td colspan=\"6\" align=\"center\"><div id=\"pages$x\">$links</div></td></tr>");
}
//print out the actual record
print ("<tr class=\"forTables\"><td align=\"center\" class=\"tblebor\">");
if ($row[$option1] == 7){print("DVD");}elseif ($row[$option1] == 8){print("VHS");}else{echo $row[$option1];}
print("</td><td align=\"center\" class=\"tblebor\">".truncate($row[$option2])."</td>
<td align=\"center\" class=\"tblebor\">".truncate($row[$option3])."</td>
<td align=\"center\" class=\"tblebor\">".truncate($row[$option4])."</td>
<td align=\"center\" class=\"tblebor\">".wrap($row[callnum])."</td>
<td align=\"center\" class=\"tblebor\">
<form action=\"index.php?mode=view\" method=\"post\">
<input type=\"hidden\" name=\"doing\" value=\"$row[id]\" />
<input type=\"submit\" value=\"$row[id]\" />
</form></td></tr>");
//if the end of the page is reached:
if ($i == $option5 ) {
print("</table></div>");
$i=1;
}else if ($i != NULL){
++$i;
}
} while ($row = mysql_fetch_array($list_records));
//just incase the last page misses it's divs.
if ($i == NULL){
print("</table>");
}elseif ($i < $option5 ) {
print("</table></div>");
}
} else {print "<tr><td align=\"center\" colspan=\"3\"><b>$lang_[nrecordsm]</b></td></tr>";}
//this will print out the javascript, it uses some of the php variables so it must be printed not just added to the end.
if($i != NULL){
?>
<script type="text/javascript">
function changepage(id) {
<?
for($x = 1; $reccount >= $x; $x++) {
print("document.getElementById('id_$x').style.display = 'none';");
}
$links = str_replace("'","\'",$links);
?>
document.getElementById(id).style.display = 'block';
var list = '<?=$links?>';
id = id.replace("id_", "")
var page = "<?=$lang_['page']?> " + id;
list = list.replace(page,'<u>'+ page + '<\/u>');
document.getElementById('pages' + id).innerHTML = list;
}
</script>
}
<?
}
}else{
Print("I'm sorry you do not have permission to perform this action. Please log in to do so.");
}
?>