From c95f4db6b89d790116c56380879c365c9d5b6ef3 Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Fri, 6 Apr 2012 15:01:58 +0000 Subject: [PATCH] syntaxer run git-svn-id: http://www.observium.org/svn/observer/trunk@2973 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/billing-graph.php | 3 +- html/index.php | 1 + html/map.php | 6 +- html/pdf.php | 217 +++++++++++++++++++++-------------------- 4 files changed, 117 insertions(+), 110 deletions(-) diff --git a/html/billing-graph.php b/html/billing-graph.php index 83579a9cf2..ee04d8af88 100755 --- a/html/billing-graph.php +++ b/html/billing-graph.php @@ -23,6 +23,7 @@ include("../config.php"); include("../includes/functions.php"); include("includes/functions.inc.php"); include("includes/authenticate.inc.php"); + if ($_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR']) { if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; } } require("includes/jpgraph/src/jpgraph.php"); include("includes/jpgraph/src/jpgraph_line.php"); @@ -160,8 +161,6 @@ $graph->xaxis->title->Set($type); $graph->yaxis->title->Set("Bits per second"); $graph->yaxis->SetLabelFormatCallback("format_si"); - - function TimeCallback($aVal) { global $dur; diff --git a/html/index.php b/html/index.php index 4e0759a96a..6966dfa94b 100755 --- a/html/index.php +++ b/html/index.php @@ -277,6 +277,7 @@ if ($_SESSION['authenticated']) } else { ## Not Authenticated. Print login. include("pages/logon.inc.php"); + exit; } ?> diff --git a/html/map.php b/html/map.php index 6c827a3b66..bc17a01e5b 100755 --- a/html/map.php +++ b/html/map.php @@ -61,7 +61,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) $links = dbFetch("SELECT * from ports AS I, links AS L WHERE I.device_id = ? AND L.local_interface_id = I.interface_id ORDER BY L.remote_hostname", array($device['device_id'])); if (count($links)) { - if(!isset($locations[$device['location']])) { $locations[$device['location']] = $loc_count; $loc_count++; } + if (!isset($locations[$device['location']])) { $locations[$device['location']] = $loc_count; $loc_count++; } $loc_id = $locations[$device['location']]; $map .= "\"".$device['hostname']."\" [fontsize=20, fillcolor=\"lightblue\", group=".$loc_id." URL=\"{$config['base_url']}/device/device=".$device['device_id']."/tab=map/\" shape=box3d]\n"; @@ -112,8 +112,8 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) $dif['label'] = $link['remote_port']; $dif['interface_id'] = $link['remote_hostname'] . $link['remote_port']; } - - if($where == "") + + if ($where == "") { $map .= "\"$src\" -> \"" . $dst . "\" [weight=500000, arrowsize=0, len=0];\n"; $ifdone[$src][$sif['interface_id']] = 1; diff --git a/html/pdf.php b/html/pdf.php index fcf603fa47..94a7ea82d7 100644 --- a/html/pdf.php +++ b/html/pdf.php @@ -1,113 +1,120 @@ SetY(-15); + // Set Font + $this->SetFont('helvetica', 'N', 8); + // Set Footer text + $this->Cell(0, 0, 'Created by Observium (www.observium.org)', 0, false, 'L', 0, 'http://www.observium.org/', 0, false, 'M', 'M'); + $this->Cell(10, 0, 'Page '.$this->getAliasNumPAge().' of '.$this->getAliasNbPages(), 0, false, 'R', 0, '', 0, false, 'M', 'M'); + } +} + +// create new PDF document +$pdf = new ObsPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); + +// set document security +$protection['permissions'] = array('modify', 'copy', 'annot-forms', 'fill-forms'); +$protection['userpass'] = null; +//$protection['ownerpass'] = "6q49qp783sqo8p3o45q30nno51q01q35"; +$protection['ownerpass'] = str_rot13(md5(str_rot13(pow(rand(), rand(0, 1000))))); +$protection['mode'] = 3; +$protection['pubkey'] = null; +$pdf->SetProtection($protection['permissions'], $protection['userpass'], $protection['ownerpass'], $protection['mode'], $protection['pubkey']); + +// disable header +$pdf->setPrintHeader(false); + +// set header and footer fonts +$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); +$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); + +// set default monospaced font +$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); + +//set margins +$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); +$pdf->SetHeaderMargin(PDF_MARGIN_HEADER); +$pdf->SetFooterMargin(PDF_MARGIN_FOOTER); + +//set auto page breaks +$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); + +//set image scale factor +$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); + +//set some language-dependent strings +$pdf->setLanguageArray($l); + +// --------------------------------------------------------- + +// set default font subsetting mode +$pdf->setFontSubsetting(true); + +// Set font +// dejavusans is a UTF-8 Unicode font, if you only need to +// print standard ASCII chars, you can use core fonts like +// helvetica or times to reduce file size. +$pdf->SetFont('dejavusans', '', 10, '', true); + +// Add a page +// This method has several options, check the source code documentation for more information. +$pdf->AddPage(); + +if ($_SESSION['authenticated']) +{ + if ($type == "billing") + { + if ($report == "history") + { + include("pages/bill/pdf_history.inc.php"); } + } +} - $filename = "observium-report.pdf"; - $html = ""; +// Print text using writeHTMLCell() +$pdf->writeHTML($html, $ln=true, $fill=false, $reseth=true, $cell=false, $align=''); - $type = (isset($_GET['type']) ? $_GET['type'] : ""); - $report = (isset($_GET['report']) ? $_GET['report'] : ""); +// --------------------------------------------------------- - include("../includes/defaults.inc.php"); - include("../config.php"); - include("../includes/functions.php"); - include("includes/functions.inc.php"); - include("includes/authenticate.inc.php"); - if (!$_SESSION['authenticated']) { $html .= "unauthenticated"; } - require_once("includes/tcpdf/config/lang/eng.php"); - require_once("includes/tcpdf/tcpdf.php"); - - // Extend TCPDF to use custom footer - class ObsPDF extends TCPDF { - public function Footer() { - // Posistion at 15mm from bottom - $this->SetY(-15); - // Set Font - $this->SetFont('helvetica', 'N', 8); - // Set Footer text - $this->Cell(0, 0, 'Created by Observium (www.observium.org)', 0, false, 'L', 0, 'http://www.observium.org/', 0, false, 'M', 'M'); - $this->Cell(10, 0, 'Page '.$this->getAliasNumPAge().' of '.$this->getAliasNbPages(), 0, false, 'R', 0, '', 0, false, 'M', 'M'); - } - } - - // create new PDF document - $pdf = new ObsPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); - - // set document security - $protection['permissions'] = array('modify', 'copy', 'annot-forms', 'fill-forms'); - $protection['userpass'] = null; - //$protection['ownerpass'] = "6q49qp783sqo8p3o45q30nno51q01q35"; - $protection['ownerpass'] = str_rot13(md5(str_rot13(pow(rand(), rand(0, 1000))))); - $protection['mode'] = 3; - $protection['pubkey'] = null; - $pdf->SetProtection($protection['permissions'], $protection['userpass'], $protection['ownerpass'], $protection['mode'], $protection['pubkey']); - - // disable header - $pdf->setPrintHeader(false); - - // set header and footer fonts - $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); - $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - - // set default monospaced font - $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); - - //set margins - $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); - $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); - $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); - - //set auto page breaks - $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - - //set image scale factor - $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - - //set some language-dependent strings - $pdf->setLanguageArray($l); - - // --------------------------------------------------------- - - // set default font subsetting mode - $pdf->setFontSubsetting(true); - - // Set font - // dejavusans is a UTF-8 Unicode font, if you only need to - // print standard ASCII chars, you can use core fonts like - // helvetica or times to reduce file size. - $pdf->SetFont('dejavusans', '', 10, '', true); - - // Add a page - // This method has several options, check the source code documentation for more information. - $pdf->AddPage(); - - if ($_SESSION['authenticated']) { - if ($type == "billing") { - if ($report == "history") { - include("pages/bill/pdf_history.inc.php"); - } - } - } - - // Print text using writeHTMLCell() - $pdf->writeHTML($html, $ln=true, $fill=false, $reseth=true, $cell=false, $align=''); - - // --------------------------------------------------------- - - // Close and output PDF document - // This method has several options, check the source code documentation for more information. - $pdf->Output($filename, 'I'); +// Close and output PDF document +// This method has several options, check the source code documentation for more information. +$pdf->Output($filename, 'I'); ?>