// search the PUBLICATIONs via mySQL -vanni, 17 Nov 2003 // // REMEMBER to enable mysql in -- /etc/php4/apache2/php.ini // was /etc/php4/apache2/php.ini // //phpinfo(); $RootDir = "/xfs/web/external/pubs/posted";// Used By Server(php)ONLY $RootUrl = "http://allegro.mit.edu/pubs/posted"; function Sconnect() { // to our SQL server // "localhost:3306","ro",'ro' // $SQLserver = "forte.sia.mit.edu"; $SQLserver = "localhost"; $SQLuser = "ro"; $SQLpw = "ro"; $conn=mysql_connect($SQLserver,$SQLuser,$SQLpw); if (!$conn) { printf("ERROR: could not connect to server\n"); mysql_error($conn); exit(1); } $qp = mysql_query("USE pubs") or die("Invalid query: " . mysql_error()); } function main($w) { /* * nil - post the form * Special - conference/journal/.... it's a TYPE * word - search for keyword -> (keyword) */ if( strlen($w) < 1 ) { $w = "latest"; } $doc = get_type($w); // fill the structure ...... /* NB -- for this to work Includes must be enabled -> /etc/php5/apache2/php.ini include_path = ".:/xfs/web/external/pubs/include" FAIL: include("http://allegro.mit.edu/pubs/include/pubs-head.html"); */ /* printf("Type: (%s)\n", $doc["type"]); include("pubs-search.html"); */ include("pubs-head.html"); printf("
%s\n", 37, $doc["type"]); printf(" | \n"); include("pubs-search.html"); printf(" |
// JOURNAL ARTICLES & CONFERENCE PAPERS //
// ORDER by cdate // $header = strtoupper($w); //echo $query; $qp = mysql_query($query) or die("Invalid query: " . mysql_error()); $count=0; // mysql_fetch_array($qp, MYSQL_NUM) --> $row[1] ... while ($row = mysql_fetch_array($qp, MYSQL_ASSOC)) { // $fn = $row[0]; <\n"); // Aut Title printf("%s, %s,\n %s, %s.\n", $row['authors'], do_title($fn, $row['pdfsize_'], $row['doctype'], $row['title']), $row['presented'], // where $row['cdate'], // do_date($row['cdate']), "nil"); if(strlen($row['note']) > 0 ) { printf("(%s)\n", $row['note']); } $count++; printf("
\n"); } printf("
%d matches\n", $count);
mysql_free_result( $qp );
}
function get_type($w) { // return the element of a document
$DOCs = array("journal" => array("name" => "journal",
"format" => "%s",
"quoted" => 1,
"type" => "JOURNAL ARTICLES"),
"conference" => array("name" => "conference",
"format" => "%s",
"quoted" => 1,
"type" => "CONFERENCE PAPERS"),
"doctoral" => array("name" => "doctoral",
"format" => "%s,",
"quoted" => 0,
"type" => "DOCTORAL THESES"),
"latest" => array("name" => "latest",
"format" => "%s,",
"quoted" => 0,
"type" => "SELECTED RECENT PUBLICATIONS"),
"any" => array("name" => "any",
"format" => "%s",
"quoted" => 1,
"type" => "($w)"),
);
// printf("--($w)=?=
\n");
if (array_key_exists("$w", $DOCs) ) {
return($DOCs[$w]);
}
$DOCs["any"]["type"] = "$w";
return($DOCs["any"]);
}
function do_date_test($s) {
if( strpos($s, "9333") ) {
return("");
}
return($s);
}
function do_title($fn, $pdfsize, $dtype, $title){
global $RootUrl;
$q='';
$doc = get_type($dtype);
$format = $doc["format"];
if( $doc["quoted"] > 0) { $q = '"'; }
if( $pdfsize == 0 ) { // an Empty PDF existed
// printf(" ===== UUPS .. size SEZO
\n");
return($q . $title . $q);
}
return( $q .
sprintf("$format",
pdf_name($fn), $title )
. $q );
}
function pdf_name($fn)
{
// $pdf = sprintf("%s/%s.pdf", dirname($fn), basename($fn, ".html"));
// $pdf = sprintf("%s/%s.pdf", dirname($fn), basename($fn, ".xml"));
$pdf = sprintf("%s/%s.pdf", dirname($fn), basename($fn, ".pdf"));
return($pdf);
}
/*
* ---------------------------------------------------------------------
*/
if( ! chdir($RootDir) ) {
printf("
Unable to CHDIR (%s)
\n", $RootDir); exit(1); } /* $kw = $_SERVER["argv"][0]; // RH8 $kw = $QUERY_STRING; // RH7 if( strlen($kw) == 0 ) { */ $kw = $_SERVER["QUERY_STRING"]; // debian 6.0 03/28/11 // printf("($kw)..%d