<?php
/*
filter.php
auth: Graham McCarthy @ Ryerson University Library
date: June 28th 2007
desc: connecting page between parseCatalogue.php and the catalogue
      Receives form fields, and puts them into a URL that facebook redirects to. 
*/

//Includes
require_once 'appinclude.php';
require 'dashboard.php';


//Accounts for both GET and POST methods.
if(isset($_POST["searchtype"]) && isset($_POST["searcharg"]))
{
	//Write a string URL
	if ($_POST["searchtype"] == "1") {
	$url = 'http://uclid.uc.edu/search/X?(' . urlencode($_POST["searcharg"])
												 . ')&b=&l=&Da=&Db=&m=&s=&v=&c=&SORT=D&searchscope=39';
	}
			
	if ($_POST["searchtype"] == "2") {
	$url = 'http://proxy.libraries.uc.edu/login?url=http://aj2vr6xy7z.cs.ssc.proxy.libraries.uc.edu/results?SS_LibHash=AJ2VR6XY7Z&dbIDList=&searchType=basic&action=start&catGroupList=default&searchBy=Category&field=Keyword&term=' . urlencode($_POST["searcharg"])
													 . '&&catID=19851';
	}
	if ($_POST["searchtype"] == "3") {
	$url = 'http://aj2vr6xy7z.search.serialssolutions.com/?V=1.0&N=100&L=AJ2VR6XY7Z&S=AC_T_B&C=' . urlencode($_POST["searcharg"]);
	}
	
	if ($_POST["searchtype"] == "4") {
	$url = 'http://journals.ohiolink.edu./lsearch/search.do?query=' . urlencode($_POST["searcharg"])
													 . '&field=contents';
	}
	if ($_POST["searchtype"] == "5") {
	$url = 'http://olc1.ohiolink.edu/search/~?searchtype=X&searcharg=' . urlencode($_POST["searcharg"])
													 . '&SORT=D';
	}
	if ($_POST["searchtype"] == "6") {
	$url = 'http://www.googlesyndicatedsearch.com/u/UCincinnati?q=' . urlencode($_POST["searcharg"]);
	}
	
	if ($_POST["searchtype"] == "7") {
	$url = 'http://scholar.google.com/scholar?q=' . urlencode($_POST["searcharg"])
													 . '&hl=en&lr=';
	}
	if ($_POST["searchtype"] == "8") {
	$url = 'http://catalog.cincinnatilibrary.org/uhtbin/cgisirsi/x/0/0/123?searchdata1=' . urlencode($_POST["searcharg"])
													 . '&srchfield1=GENERAL%5ESUBJECT%5EGENERAL%5E%5Ewords+org+phrase';
	}		
													 
	echo '<h1>Redirecting you to the <a href="' . $url . '" >University of Cincinnati Search Tool</a></h1>';
		
	//redirect facebook to url										 
	$facebook->redirect($url);													 
}

//Accounts for both GET and POST methods
if(isset($_GET["searchtype"]) && isset($_GET["searcharg"]))
{
		if ($_GET["searchtype"] == "1") {
	$url = 'http://uclid.uc.edu/search/X?(' . urlencode($_GET["searcharg"])
												 . ')&b=&l=&Da=&Db=&m=&s=&v=&c=&SORT=D&searchscope=39';
	}
			
	if ($_GET["searchtype"] == "2") {
	$url = 'http://proxy.libraries.uc.edu/login?url=http://aj2vr6xy7z.cs.ssc.proxy.libraries.uc.edu/results?SS_LibHash=AJ2VR6XY7Z&dbIDList=&searchType=basic&action=start&catGroupList=default&searchBy=Category&field=Keyword&term=' . urlencode($_GET["searcharg"])
													 . '&&catID=19851';
	}
	if ($_GET["searchtype"] == "3") {
	$url = 'http://aj2vr6xy7z.search.serialssolutions.com/?V=1.0&N=100&L=AJ2VR6XY7Z&S=AC_T_B&C=' . urlencode($_GET["searcharg"]);
	}
	
	if ($_GET["searchtype"] == "4") {
	$url = 'http://journals.ohiolink.edu./lsearch/search.do?query=' . urlencode($_GET["searcharg"])
													 . '&field=contents';
	}
	if ($_GET["searchtype"] == "5") {
	$url = 'http://olc1.ohiolink.edu/search/~?searchtype=X&searcharg=' . urlencode($_GET["searcharg"])
													 . '&SORT=D';
	}
	if ($_GET["searchtype"] == "6") {
	$url = 'http://www.googlesyndicatedsearch.com/u/UCincinnati?q=' . urlencode($_GET["searcharg"]);
	}
	
	if ($_GET["searchtype"] == "7") {
	$url = 'http://scholar.google.com/scholar?q=' . urlencode($_GET["searcharg"])
													 . '&hl=en&lr=';
	}
	if ($_GET["searchtype"] == "8") {
	$url = 'http://catalog.cincinnatilibrary.org/uhtbin/cgisirsi/x/0/0/123?searchdata1=' . urlencode($_GET["searcharg"])
													 . '&srchfield1=GENERAL%5ESUBJECT%5EGENERAL%5E%5Ewords+org+phrase';
	}	
	
	
	
	echo '<h1>Redirecting you to the <a href="' . $url . '" >University of Cincinnati Search Tool</a></h1>';
												 
	$facebook->redirect($url);													 
}

?>