function actionPerform(&$skin, $moduleID) { $skin->main->controlVariables["exceptionViewer"]['exceptionList'] = ""; $skin->main->controlVariables["exceptionViewer"]['link'] = ""; $skin->main->controlVariables["exceptionViewer"]['tabId'] = $skin->main->selectedTab; $skin->main->controlVariables["exceptionViewer"]['logFiles'] = array(); $skin->main->controlVariables["exceptionViewer"]['displayList'] = true; if (isset($_POST["event"]) && $_POST["event"] == "exceptionViewer:SubmitReport") { for ($i = 0; $i < sizeof($_POST["errors"]); $i++) { $errorDetails = split("\\|", $_POST["errors"][$i]); $skin->main->controlVariables["exceptionViewer"]['link'] = $skin->main->logger->submitErrorReport($errorDetails[0], $errorDetails[3], $errorDetails[4], $errorDetails[5]); } } else { if (isset($_POST["event"]) && $_POST["event"] == "exceptionViewer:DeleteLog") { for ($i = 0; $i < sizeof($_POST["logs"]); $i++) { //Validate given file name if (ereg_replace("([0-9]{4})-([0-9]{2})-([0-9]{2})", "", $_POST["logs"][$i]) == "") { $this->deleteLogFile($_POST["logs"][$i]); } else { trigger_error("Unable to delete log file : Given file name '{$_POST['logs'][$i]}' is invalid"); } } } } if (!isset($_GET["log"])) { //Analyze logs directory $logs = array(); $dir = opendir(DIR_APPLICATION_BASE . 'logs'); while (false !== ($file = readdir($dir))) { if ($file != "." && $file != "..") { $file = str_replace(array("error_", ".xml"), "", $file); $logs[$file] = $file; } } closedir($dir); $skin->main->controlVariables["exceptionViewer"]['logFiles'] = $logs; $skin->main->controlVariables["exceptionViewer"]['displayList'] = true; } else { if (ereg_replace("([0-9]{4})-([0-9]{2})-([0-9]{2})", "", $_GET["log"]) == "") { $skin->main->controlVariables["exceptionViewer"]['displayList'] = false; $filename = DIR_APPLICATION_BASE . 'logs' . DIRECTORY_SEPARATOR . 'error_' . $_GET["log"] . '.xml'; if (is_file($filename)) { $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); fclose($handle); // Create new DOM documents for input, output and stylesheet data. $oDocument = new Document(); $oStylesheet = new Document(); $oOutDocument = new Document(); // Create object of class XML_Preprocessor. $oXml = XML_Preprocessor::create(&$oDocument); //$oXml->parseFile(DIR_APPLICATION_BASE.'logs'.DIRECTORY_SEPARATOR.'error_'.$_GET["log"].'.xml'); $oXml->parse("<errors>{$contents}</errors>"); $oStylesheet->parseFile(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'exceptionViewer.xsl'); // Create object myXPath. $oXPath =& myXPath::create(&$oDocument); // Create object myXSLT. $oXSLT = myXSLT::create(&$oDocument, &$oOutDocument, &$oStylesheet, &$oXPath); // Start translating. $oXSLT->translate(); $skin->main->controlVariables["exceptionViewer"]['exceptionList'] = $oOutDocument->toString(); } else { trigger_error("Unable to find log file : 'error_{$_GET['log']}.xml'"); } } else { trigger_error("Invalid log file name supplied : '{$_GET['log']}'"); } } }
/** * Constructor. * * @param object Document * @return object XML_Preprocessor * @access public * @static method */ function &create(&$dom) { $parser = new XML_Preprocessor(); $parser->PEAR('XML_Error'); $parser->setDOMDocument(&$dom); return $parser; }