// simulate register_globals for the five parameters passed from the form via GET
// from the query string, get a string for each parameter
$parts=explode("\\&",$_SERVER['QUERY_STRING_UNESCAPED']);
foreach ($parts as $parameter) {
$p=explode('=',$parameter);
$key=$p[0];
$value=$p[1];
if ($key==="pub") { $pub=$value; }
if ($key==="action") { $action=$value; }
if ($key==="query_author") { $query_author=$value; }
if ($key==="query_title") { $query_title=$value; }
if ($key==="query_year") { $query_year=$value; }
if ($key==="query_pubtype") { $query_pubtype=$value; }
}
//This is the base adress that reach LCAV lab in infoscience db
$baseurl="https://infoscience.epfl.ch/export.py?charset=latin-1&style=lcav&c=Infoscience%2FResearch%2FIC%2FIVRG";
//output format
$format="&fm=html";
//maximal number of records per page
$maxnumber=25;
//just the right variable that will be send in infoscience for $maxnumber
$resnumber="&rg=".$maxnumber;
//True if there is problem in the text form (like the year is not a number...)
$bad_format=false;
//If the total recorded for a given query is more than maxnumber we need a link to follow the next results
$jrec="";
//sortfunction, by default : year
$sortfunct="&sf=year";
//for author, title and year
//$restquery="&p=-affiliation%3A%22OTHER%22+keyword%3Aivrg";
$restquery="&p=-affiliation%3A%22OTHER%22";
if(isset($action)){
//then find the directories to search for
switch($query_pubtype){
case "all" :
break;
case "Journal paper":
$restquery.="+collection%3AARTICLE";
break;
case "Conference paper":
$restquery.="+collection%3ACONF";
break;
case "PhD Thesis":
$restquery.="+collection%3ATHESIS";
break;
case "Technical report":
$restquery.="+collection%3AREPORT";
break;
case "Book chapters":
$restquery.="+collection%3ACHAPTER";
break;
case "Books":
$restquery.="+collection%3ABOOK";
break;
default :
}
//now check if at least there is one of the three text fields that aren't empty
if((!empty($query_author))||(!empty($query_title))||(!empty($query_year))){
//$restquery="&p=";
if(!empty($query_author)){
$restquery.="+author%3A";
$restquery.=urlencode(utf8_encode($query_author));
}
if(!empty($query_title)){
$restquery.="+title%3A";
$restquery.=urlencode(utf8_encode($query_title));
}
if(!empty($query_year)){
if(is_numeric($query_year)){
$restquery.="+year%3A";
$restquery.=urlencode(utf8_encode($query_year));
}
else
$bad_format=true;
}
}
}
else{ //just all articles
if(isset($pub)){
switch ($pub){
case "article":
$restquery.="+collection%3AARTICLE";
break;
case "inproceedings":
$restquery.="+collection%3ACONF";
break;
case "phdthesis":
$restquery.="+collection%3ATHESIS";
break;
case "techreport":
$restquery.="+collection%3AREPORT";
break;
case "bookchapters":
$restquery.="+collection%3ACHAPTER";
break;
case "books":
$restquery.="+collection%3ABOOK";
break;
default :
$restquery.="+collection%3AARTICLE";
}
}
else{
$pub="article";
//$restquery.="+collection%3AARTICLE";
}
}
//when the jrec is not "" than this file must receive that variable to create a link that will follow
// other records
if(!(isset($startrec)))
$startrec=1;
else
$jrec="&jrec=".$startrec;
//now create the query that will be exported to infoscience
$wholeurl=$baseurl.$restquery.$format.$jrec.$sortfunct;
//now print the result
if($bad_format==false){
$html_output=fopen("$wholeurl","r");
if ($html_output !== false) { // correct PLM
//echo $wholeurl;
//first check the number of result:
$buffer=$buffer = fgets($html_output, 4096);
echo $buffer;
//ok we print the results
while (!feof($html_output)) {
$buffer = fgets($html_output, 4096);
echo $buffer;
}
echo "
";
//now print the bibtex file
$format="&fm=bibtex";
$jrec="&jrec=".$startrec;
$wholeurl=$baseurl.$restquery.$format.$jrec.$sortfunct;
echo " BibTex for all references found ";
fclose($html_output);
}
}
else
echo "Error in the form posted (maybe a wrong numeric format)";
?>