Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/patientapps_beta/include/ |
Upload File : |
<?php
class pdfstuff {
private $filename;
private $directory;
private $_parents;
private $_depth;
private $root;
private $data;
private $debug = FALSE;
public function __construct() {
$this->directory = tempnam(sys_get_temp_dir(), 'pdf');
unlink($this->directory);
mkdir($this->directory);
}
public function getRoot() {
return $this->root;
}
public function getDirectory() {
return $this->directory;
}
public function Filename() {
if (func_num_args()) {
$this->filename = func_get_arg(0);
$this->basename = pathinfo($this->filename, PATHINFO_FILENAME);
return $this;
}
return $this->filename;
}
public function Data() {
if (func_num_args()) {
$this->data = func_get_arg(0);
return $this;
}
return $this->data;
}
public function Debug() {
if (func_num_args()) {
$this->debug = func_get_arg(0);
return $this;
}
return $this->debug;
}
public function Parse() {
$pdf = $this->basename . '.pdf';
if (!file_exists($this->directory . '/'. $pdf)) {
copy($this->filename, $this->directory . '/'. $pdf);
}
$ddir = escapeshellarg($this->directory);
$dfile = escapeshellarg($pdf);
`cd $ddir; /usr/bin/pdftohtml -q -c -xml $dfile`;
$glob = glob($this->directory . '/*');
$source = file_get_contents($this->directory . '/' . $this->basename . '.xml');
if ($this->Debug()) {
var_dump($pdf);
var_dump($glob);
echo "cd $ddir; /usr/bin/pdftohtml -q -c -xml $dfile\n\n";
var_dump($source);
}
$this->_parseXML($source);
}
protected function _content_start($parser, $name, $attrs) {
$node = new pdfnode;
$node->Attr($attrs)
->Name($name);
$this->_depth++;
if ($this->_depth == 1) {
$this->root->addChild($node);
} else {
$parent = $this->_parents[$this->_depth - 1];
$parent->addChild($node);
}
$this->_parents[$this->_depth] = $node;
}
protected function _content_end($parser, $name) {
unset($this->_parents[$this->_depth]);
$this->_depth--;
}
protected function _content_text($parser, $data) {
$this->_parents[$this->_depth]->Text($data);
}
private function _parseXML($content) {
$this->_parents = [];
$this->_depth = 0;
$this->root = new pdfnode;
$xml_parser = xml_parser_create();
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 0);
xml_set_element_handler($xml_parser, [$this, '_content_start'], [$this, '_content_end']);
xml_set_character_data_handler($xml_parser, [$this, '_content_text']);
if (!xml_parse($xml_parser, $content, TRUE)) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
xml_parser_free($xml_parser);
}
public function __destruct() {
if (!empty($this->directory) && file_exists($this->directory)) {
$dir = $this->directory;
`rm -rf $dir`;
}
}
}
class pdfnode {
private $name = '';
private $attr = [];
private $children = [];
private $text = FALSE;
public function Name() {
if (func_num_args()) {
$this->name = func_get_arg(0);
return $this;
}
return $this->name;
}
public function Attr() {
if (func_num_args()) {
$this->attr = func_get_arg(0);
return $this;
}
return $this->attr;
}
public function Text() {
if (func_num_args()) {
$this->text = func_get_arg(0);
return $this;
}
return $this->text;
}
public function Children() {
if (func_num_args()) {
$this->children = func_get_arg(0);
return $this;
}
return $this->children;
}
public function addChild($value) {
$this->children[] = $value;
}
}