(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("
\n"); if( 0 ) { // DISABLE for NOW printf(" ACCESS to Publications is CURRENTLY unavailable please RETRY later. \n"); exit(0); } get_pubs($doc["name"],$w); //connect to server,get matching pubs include("pubs-tail.html"); } function get_pubs($ptype, $w) { //connect to server, get matching pubs global $RootUrl; Sconnect(); if( strncmp($w, "latest", 6 ) == 0 ) { printf("(For other Publications, select a category above or use the search field)\n"); $stamp = time() - 360 * (60 * 60 * 24); // 360 days ago $now = date("Ymd", $stamp); $where = "WHERE sort_order_ > $now "; } else if( strcmp($ptype, "any") == 0 ) { // A Search (KeyWord) $where = "WHERE authors like \"%$w%\" OR title like \"%$w%\" OR cdate like \"%$w%\""; } else { // A specific DocType $where = "WHERE doctype like \"%$w%\" "; } $query = sprintf("SELECT * FROM rec %s ORDER by sort_order_ desc", $where ); // ORDER by SUBSTRING(cdate, LENGTH(cdate) - 3, 4) desc", // $s = mysql_query("SELECT ID,CDATE,title FROM rec") //

// 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]; <> the ID (in SQL) was getting chopped !! //print_r($row); if( $row['pdfsize_'] < 0 ) { continue; } $fn = $row['filename_']; printf("

\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
", strpos($kw, "SearchFor")); if( strpos($kw, "SearchFor") !== false ) { // called from an HTML FORM $kw = $_GET['SearchFor']; } // printf(" ($kw)\n"); // exit; switch ($kw) { case "dump-xml": printf("*** see pubs-list\n"); break; default: main($kw); } exit(0); // //-------- k e e p -vanni, 23 Apr 2001 // local variables: // compile-command: "php pubs-search.php" // end: ?>