function PHPReportPage($sXMLOutputFile = null) { $this->_sTemp = getPHPReportsTmpPath(); $this->_sName = "PAGE LAYER"; $this->_sTag = "PG"; $this->_bOpen = false; $this->_iPageNum = 0; $this->_iSize = 50; $this->_iRow = 1; $this->_iLimit = 2500; $this->_sBuffer = ""; $this->_iBcount = 0; $this->_fHandle = null; $this->_iCurBehaviour = $this->_iBUFFER; $this->_iPosition = 1; $this->_iWidth = -1; $this->_iHeight = -1; $this->_iCellPadding = -1; $this->_iCellSpacing = -1; $this->_iBorder = -1; $this->_sAlign = "LEFT"; $this->_oGroups = null; $this->_sFile = $sXMLOutputFile; $this->_bReprintHeader = true; $this->_oDoc = null; $this->_sClass = null; $this->_oError = new PHPReportsErrorTr(); $this->createFileName(); }
function run() { $sPath = getPHPReportsFilePath(); $sTmp = getPHPReportsTmpPath(); $sXSLT = $sPath . "/output/txtfc/txtfc.xsl"; $sXML = $this->getInput(); $this->proc_rows($sXML); // create a new filename if its empty if (is_null($this->getOutput())) { $sOut = tempnam($sTmp, "txt"); unlink($sOut); $sOut .= ".txt"; } else { $sOut = $this->getOutput(); } // XSLT processor $oProcFactory = new XSLTProcessorFactory(); $oProc = $oProcFactory->get(); $oProc->setXML($sXML); $oProc->setXSLT($sXSLT); $oProc->setOutput($sOut); $oProc->setParms(array("body" => $this->getBody() ? "true" : "false")); $sRst = $oProc->run(); /* Read file to pre-processing, replacing the __formfeed__ indicator for a chr(12), and write it again */ $fHand = fopen($sOut, "rb"); $sText = fread($fHand, filesize($sOut)); fclose($fHand); if (strpos($sText, "__formfeed__")) { $sText = str_replace("__formfeed__", chr(12), $sText); $sText = str_replace(chr(160), " ", $sText); $fHand = fopen($sOut, "wb"); fwrite($fHand, $sText); fclose($fHand); } // if needs to jump to show the file, show it if ($this->isJumping()) { print $sText; } // check if needs to clean the XML data file if ($this->isCleaning()) { unlink($sXML); } }
<?php include_once "PHPReportMaker.php"; include_once "PHPReportsUtil.php"; /****************************************************************************** * * * Use this file to check how the output plugins works. * * Please see outmenu.php also. * * It need to be placed on a directory reached by the web server. * * * ******************************************************************************/ $sOut = $_REQUEST["output"]; $sURL = realpath(getPHPReportsTmpPath() . "/" . $_REQUEST["file"]); if (empty($sOut) || empty($sURL)) { return; } $oRpt = new PHPReportMaker(); $oOut = $oRpt->createOutputPlugin($sOut); $oOut->setInput($sURL); $oOut->setClean(false); $oOut->run();
// database password $sData = "./tests/sales.sqlite3"; // database name $sInte = "sqlite3"; // database interface $sConn = "sqlite3"; // database connection // check them if (strlen($sUser) < 1 || strlen($sPass) < 1 || strlen($sInte) < 1 || strlen($sConn) < 1) { print "ERROR: please configure this script before run!"; return; } // check paths $sIncPath = getPHPReportsIncludePath(); $sFilPath = getPHPReportsFilePath(); $sTmpPath = getPHPReportsTmpPath(); print "Checking paths ...\n"; if (is_null($sIncPath) || strlen(trim($sIncPath)) <= 0) { print "ERROR: No INCLUDE path defined."; return; } if (is_null($sFilPath) || strlen(trim($sFilPath)) <= 0) { print "ERROR: No FILE path defined."; return; } if (is_null($sTmpPath) || strlen(trim($sTmpPath)) <= 0) { print "ERROR: No TEMP path defined."; return; } print "Include path : {$sIncPath}\n"; print "File path : {$sFilPath}\n";
function PHPReportMaker() { $this->_sPath = getPHPReportsFilePath(); $this->_sTmp = getPHPReportsTmpPath(); $this->sXML = null; $this->sXSLT = $this->_sPath . "/xslt/PHPReport.xsl"; $this->sUser = null; $this->sPass = null; $this->sCon = null; $this->sDataI = null; $this->sSQL = null; $this->_oParm = array(); $this->sDatabase = null; $this->sCodeOut = null; $this->sOut = null; $this->bDebug = false; $this->_sNoDataMsg = ""; $this->_sNoDataFunc = ""; $this->_sOutputPlugin = "default"; $this->_oOutputPlugin = null; $this->_sSaveTo = null; $this->_aEnv = array(); $this->_sClassName = "PHPReport"; $this->_iPageSize = 0; $this->_aBench = array(); $this->_sLang = "default"; $this->_bBody = true; $this->_bDeleteXML = false; $this->_oError = new PHPReportsErrorTr(); $this->_oInput = array(); $this->_sDecSep = null; $this->_sThoSep = null; /* Now we get the XSLT processor new code on the 0.2.8 version, because PHP5 have XSL support with libxslt, by default */ $oProcFactory = new XSLTProcessorFactory(); $this->_oProc = $oProcFactory->get(); if (is_null($this->_oProc)) { $this->_oError->showMsg("NOXSLT"); } // check path stuff if (is_null(getPHPReportsFilePath())) { $this->_oError->showMsg("NOPATH"); } }
<?php require_once "PHPReportMaker.php"; require_once "PHPReportsUtil.php"; /****************************************************************************** * * * Use this file to check how the output plugins works. * * Please see PHPReportConvert.php also. * * It need to be placed on a directory reached by the web server. * * * ******************************************************************************/ $sXML = tempnam(getPHPReportsTmpPath(), "phprpt") . ".xml"; $sBase = basename($sXML); $oRpt = new PHPReportMaker(); $oRpt->setUser("taq"); $oRpt->setPassword("******"); $oRpt->setXML("sales.xml"); $oRpt->setXMLOutputFile($sXML); $oOut = $oRpt->createOutputPlugin("default"); $oOut->setClean(false); $oOut->setOutput("/dev/null"); $oRpt->setOutputPlugin($oOut); $oRpt->run(); ?> <html> <head> <title>PHPReports exchanging formats</title> <link rel="stylesheet" type="text/css" href="css/phpreports.css"> </head> <body> <p class="REGULAR" style="margin:15px;">
function loadFrom($sPath_ = null) { if (is_null($sPath_)) { return; } if (!file_exists($sPath_)) { $oError = new PHPReportsErrorTr(); $oError->showMsg("NOLOAD", array($sPath_)); } $sTemp = tempnam(getPHPReportsTmpPath(), "xml"); $fIn = fopen("compress.zlib://" . $sPath_, "r"); $fOut = fopen($sTemp, "w"); // read the md5sum $sMD5 = trim(fread($fIn, 50)); while ($sStr = fread($fIn, 1024)) { fwrite($fOut, $sStr); } fclose($fOut); fclose($fIn); $sMD5chk = md5_file($sTemp); if (strcmp($sMD5, $sMD5chk) != 0) { unlink($sTemp); print "<b>ERROR</b>: the report stored in {$sPath_} is corrupted."; return; } //$sTemp = substr(strrchr($sTemp,"/"),1); $this->setInput($sTemp); $this->run(); }