Browse Source

figured out how to ensure correct html wrapper used when script is required from outside its cwd

pull/81/head
Chris 8 years ago
parent
commit
a0daf5c44c
  1. 2
      composer.json
  2. 25
      public/embed.php
  3. 29
      public/index.php
  4. 7
      src/bibtexbrowser.php

2
composer.json

@ -19,7 +19,7 @@
}
},
"scripts": {
"serve": "@php -S localhost:8080 -t public/"
"serve": "@php -S localhost:29896 -t public/"
},
"require-dev": {
"monolog/monolog": "^1.23",

25
public/embed.php

@ -0,0 +1,25 @@
<?PHP
print <<<HTML
<!doctype html>
<html>
<head></head>
<body>
HTML;
$_GET['library']=1;
require_once('../src/bibtexbrowser.php');
$db = new BibDataBase();
$db->load('bibacid-utf8.bib');
$query = array('year'=>'1997');
$entries=$db->multisearch($query);
uasort($entries, 'compare_bib_entries');
foreach ($entries as $bibentry) {
print $bibentry->toHTML()."<br/>";
}
print <<<HTML
</body>
</html>
HTML;
exit;

29
public/index.php

@ -1,27 +1,16 @@
<?PHP
// have this assume same directory as thing
$_GET['bib'] = "bibacid-utf8.bib";
// first step is to get relative reference correct
require_once "../src/bibtexbrowser.php";
//require_once "../vendor/autoload.php";
// use Monperrus\BibtexBrowser\Bibliography;
require_once "../vendor/autoload.php";
use Monperrus\BibtexBrowser\Bibliography;
// $config = array("bib" => "bibacid-utf8.bib",
// "all" => 1,
// "author" => "",
// "academic" => 1
// );
$config = array("bib" => "bibacid-utf8.bib",
"all" => 1,
"author" => "",
"academic" => 1
);
// $_GET['menu']=1;
// $browser = new Monperrus\BibtexBrowser\Bibliography($config);
// $browser->print();
//s($_SERVER);
$browser = new Bibliography($config);
$browser->print();

7
src/bibtexbrowser.php

@ -328,7 +328,7 @@ function _zetDB($bibtex_filenames) {
// to automate dectection of faulty links with tools such as webcheck
header('HTTP/1.1 404 Not found');
// escape $bib to prevent XSS
$escapedBib = htmlEntities($bib, ENT_QUOTES);
htmlEntities($bib, ENT_QUOTES);
die('<b>the bib file '.$escapedBib.' does not exist !</b>');
}
} // end for each
@ -4531,7 +4531,7 @@ class Dispatcher {
}
// should call method display() on $x
$fun = $this->wrapper;
$fun = BIBTEXBROWSER_DEFAULT_TEMPLATE;//$this->wrapper;
$fun($x);
$this->clearQuery();
@ -4668,7 +4668,8 @@ class Dispatcher {
function menu() {
$menu = createMenuManager();
$menu->setDB($this->getDB());
$fun = $this->wrapper;
// why does //$this->wrapper; = no wrapper?
$fun = BIBTEXBROWSER_DEFAULT_TEMPLATE;
$fun($menu);
return 'END_DISPATCH';
}

Loading…
Cancel
Save