示例#1
0
 /**
  * Method:extractText
  */
 public function findText($doc, $page, $searchterm, $numPages = -1)
 {
     $output = array();
     if (strlen($searchterm) == 0) {
         return "[{\"page\":-1, \"position\":-1}]";
     }
     try {
         $swf_file = $this->configManager->getConfig('path.swf') . $doc . "_" . $page . ".swf";
         if (!file_exists($swf_file)) {
             return "[{\"page\":-1, \"position\":-1}]";
         }
         // check for directory traversal & access to non pdf files and absurdely long params
         $pdfFilePath = $this->configManager->getConfig('path.pdf') . $doc;
         if ($numPages == -1) {
             $pagecount = count(glob($this->configManager->getConfig('path.swf') . $doc . "*"));
         } else {
             $pagecount = $numPages;
         }
         if (!validPdfParams($pdfFilePath, $doc, $page)) {
             return;
         }
         $command = $this->configManager->getConfig('cmd.searching.extracttext');
         $command = str_replace("{swffile}", $this->configManager->getConfig('path.swf') . $doc . "_" . $page . ".swf", $command);
         $return_var = 0;
         exec($command, $output, $return_var);
         $pos = strpos(strtolower(arrayToString($output)), strtolower($searchterm));
         if ($return_var == 0 && $pos > 0) {
             return "[{\"page\":" . $page . ", \"position\":" . $pos . "}]";
         } else {
             if ($page < $pagecount) {
                 $page++;
                 return $this->findText($doc, $page, $searchterm, $pagecount);
             } else {
                 return "[{\"page\":-1, \"position\":-1}]";
             }
         }
     } catch (Exception $ex) {
         return $ex;
     }
 }
示例#2
0
 /**
  * Method:convert
  */
 public function convert($doc, $page)
 {
     $output = array();
     $pdfFilePath = $this->configManager->getConfig('path.pdf') . $doc;
     $swfFilePath = $this->configManager->getConfig('path.swf') . $doc . $page . ".swf";
     // traversal and file name check
     if (!validPdfParams($pdfFilePath, $doc, $page)) {
         $s = "Incorrect document file specified, file may not exist or insufficient permissions to read file" . $configManager->getDocUrl();
         return $s;
     }
     if (strlen($page) > 0) {
         $command = $this->configManager->getConfig('cmd.conversion.splitpages');
     } else {
         $command = $this->configManager->getConfig('cmd.conversion.singledoc');
     }
     $command = str_replace("{path.pdf}", $this->configManager->getConfig('path.pdf'), $command);
     $command = str_replace("{path.swf}", $this->configManager->getConfig('path.swf'), $command);
     $command = str_replace("{pdffile}", $doc, $command);
     try {
         if (!$this->isNotConverted($pdfFilePath, $swfFilePath)) {
             array_push($output, utf8_encode("[Converted]"));
             return arrayToString($output);
         }
     } catch (Exception $ex) {
         array_push($output, "Error," . utf8_encode($ex->getMessage()));
         return arrayToString($output);
     }
     $return_var = 0;
     exec($command, $output, $return_var);
     if ($return_var == 0) {
         $s = "[Converted]";
     } else {
         $s = "Error converting document, make sure the conversion tool is installed and that correct user permissions are applied to the SWF Path directory" . $configManager->getDocUrl();
     }
     return $s;
 }
示例#3
0
* When purchasing a commercial license, its terms substitute this license.
* Please see http://flexpaper.devaldi.com/ for further details.
* 
*/
require_once "../lib/common.php";
require_once "../lib/pdf2swf_php5.php";
$doc = $_GET["doc"];
$page = "";
if (isset($_GET["page"])) {
    $page = $_GET["page"];
}
$pos = strpos($doc, "/");
$configManager = new Config();
$swfFilePath = $configManager->getConfig('path.swf') . $doc . $page . ".swf";
$pdfFilePath = $configManager->getConfig('path.pdf') . $doc;
if (!validPdfParams($pdfFilePath, $doc, $page)) {
    echo "[Incorrect file specified]";
} else {
    $pdfconv = new pdf2swf();
    $output = $pdfconv->convert($doc, $page);
    if (rtrim($output) === "[Converted]") {
        if ($configManager->getConfig('allowcache')) {
            setCacheHeaders();
        }
        if (!$configManager->getConfig('allowcache') || $configManager->getConfig('allowcache') && endOrRespond()) {
            header('Content-type: application/x-shockwave-flash');
            header('Accept-Ranges: bytes');
            header('Content-Length: ' . filesize($swfFilePath));
            echo file_get_contents($swfFilePath);
        }
    } else {
示例#4
0
* Please see http://flexpaper.devaldi.com/ for further details.
* 
*/
require_once "../lib/config.php";
require_once "../lib/common.php";
require_once "../lib/pdf2swf_php5.php";
$configManager = new Config();
$doc = $_GET["doc"];
$page = "1";
$swfFilePath = $configManager->getConfig('path.swf') . $doc . $page . ".swf";
$pdfFilePath = $configManager->getConfig('path.pdf') . $doc;
$output = "";
if (glob($configManager->getConfig('path.swf') . $doc . "*") != false) {
    $pagecount = count(glob($configManager->getConfig('path.swf') . $doc . "*"));
} else {
    $pagecount = 0;
}
if ($pagecount == 0 && validPdfParams($pdfFilePath, $doc, $page)) {
    $pdfconv = new pdf2swf();
    $output = $pdfconv->convert($doc, $page);
    if (rtrim($output) === "[Converted]") {
        $pagecount = count(glob($configManager->getConfig('path.swf') . $doc . "*"));
    }
} else {
    $output = "Incorrect document file specified, file may not exist or insufficient permissions to read file" . $configManager->getDocUrl();
}
if ($pagecount != 0) {
    echo $pagecount;
} else {
    echo $output;
}
示例#5
0
    <body> 
	    <?php 
// Setting current document from parameter or defaulting to 'Paper.pdf'
$doc = "Paper.pdf";
if (isset($_GET["doc"])) {
    $doc = $_GET["doc"];
}
$pdfFilePath = $configManager->getConfig('path.pdf') . $doc;
$swfFilePath = $configManager->getConfig('path.swf');
?>
 
    	<div style="position:absolute;left:10px;top:60px;">
	        <p id="viewerPlaceHolder" style="width:660px;height:553px;display:block">Document loading..</p>
	        
			<?php 
if (validPdfParams($pdfFilePath, $doc, null) && is_dir($swfFilePath)) {
    ?>
	        	<script type="text/javascript"> 
				var doc = '<?php 
    print $doc;
    ?>
';
			
				var fp = new FlexPaperViewer(	
						 'FlexPaperViewer',
						 'viewerPlaceHolder', { config : {
						 SwfFile : escape('services/view.php?doc='+doc),
						 Scale : 0.6, 
						 ZoomTransition : 'easeOut',
						 ZoomTime : 0.5,
						 ZoomInterval : 0.2,