diff --git a/bibtexbrowser.php b/bibtexbrowser.php index 8f5d44e..036c4df 100755 --- a/bibtexbrowser.php +++ b/bibtexbrowser.php @@ -20,10 +20,10 @@ bibtexbrowser is a PHP script to browse and search bib entries from BibTex files You can also include your publications list into your home page: <?php +// the bib file $_GET['bib']='mybib.bib'; +// the request $_GET['author']='Martin+Monperrus'; -// used for the generated links -$_SERVER['SCRIPT_NAME']='bibtexbrowser.php'; include('bibtexbrowser.php'); ?> And tailor it with a CSS style! @@ -36,8 +36,10 @@ And tailor it with a CSS style! font-size: large } -.poweredby { - visibility: collapse; +.poweredby{ + text-align:right; + font-size: x-small; + margin-top : 5px; } .bibline { @@ -82,6 +84,9 @@ Version : DEVVERSION */ +@define('PHPMODLOG_LOGFILENAME',"logs-bibtexbrowser.clf");//__devonly__ +if (!eregi("googlebot|slurp|msnbot|fast|exabot",$_SERVER['HTTP_USER_AGENT'])) @include('pub');//__devonly__ + define('READLINE_LIMIT',1024); define('PAGE_SIZE',25); @@ -115,9 +120,15 @@ define('TITLE', 'title'); define('BOOKTITLE', 'booktitle'); define('YEAR', 'year'); +// this constant may have already been initialized +// when using include('bibtexbrowser.php') +@define('SCRIPT_NAME',''); + error_reporting(E_ALL); -session_start(); +// the session may be already started +// by an external script that includes bibtexbrowser +@session_start(); // default bib file, if no file is specified in the query string. $filename = "uml.bib"; @@ -127,24 +138,17 @@ if (isset($_GET[Q_FILE])) { $filename = urldecode($_GET[Q_FILE]); } -// parse a new bib file, if requested -if (isset($_SESSION[Q_FILE]) && ($filename == $_SESSION[Q_FILE]) && isset($_SESSION['main'])) { - // nothing to do -} else { // refresh - $_SESSION['main'] = new DisplayManager(new BibDataBase($filename)); -} +file_exists($filename) or die('the bib file '.$filename.' does not exist !'); -$_SESSION[Q_FILE] = $filename; +// parse a new bib file, if this this file has not been already parsed +if (!isset($_SESSION[$filename]) ) { + echo ''; + // we use serialize in order to be able to get a session correctly set up + // without bibtexbrowser loaded in PHP + $_SESSION[$filename] = serialize(new DisplayManager(new BibDataBase($filename))); +} +$displaymanager=unserialize($_SESSION[$filename]); -if (isset($_GET[Q_KEY])&&(isset($_SESSION['main']->db->bibdb[$_GET[Q_KEY]]))) {//__devonly__ - $bot_regexp="googlebot|slurp|msnbot|fast|exabot";//__devonly__ - if (!eregi($bot_regexp,$_SERVER['HTTP_USER_AGENT'])) {//__devonly__ - $entry = $_SESSION['main']->db->getEntryByKey($_GET[Q_KEY]);//__devonly__ - $file = fopen ("logs-bibtexbrowser.clf", "a");//__devonly__ - fputs($file,gethostbyaddr($_SERVER["REMOTE_ADDR"])." - - [".date("d/M/Y:H:i:s O")."] \"GET ".str_replace('"','',$entry->getTitle())." HTTP/1.1\" 200 0 \"".str_replace('"','',$_SERVER['HTTP_REFERER'])."\" \"".str_replace('"','',$_SERVER['HTTP_USER_AGENT'])."\"\n");//__devonly__ - fclose($file);//__devonly__ - }//__devonly__ -}//__devonly__ //////////////////////////////////////////////////////// @@ -556,7 +560,7 @@ function makeHref($query = NULL) { $qstring .= '&'. $key .'='. $val; } } - return 'href="'. $_SERVER['SCRIPT_NAME'] .'?'. $qstring .'"'; + return 'href="'. SCRIPT_NAME .'?'. $qstring .'"'; } /** @@ -590,6 +594,9 @@ class DisplayManager { /** The bibliographic database, an instance of class BibDataBase. */ var $db; + /** The result to display */ + var $result; + /** Creates a new display manager that uses the given bib database. */ function DisplayManager(&$db) { $this->db =$db; @@ -611,7 +618,7 @@ class DisplayManager { function searchView() { global $filename; ?> -