Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace Piwik\Plugins\ImageGraph; use Exception; use Piwik\API\Request; use Piwik..

Decoded Output download

<?php
 namespace Piwik\Plugins\ImageGraph; use Exception; use Piwik\API\Request; use Piwik\Archive\DataTableFactory; use Piwik\Common; use Piwik\Container\StaticContainer; use Piwik\DataTable\Map; use Piwik\DataTable\Simple; use Piwik\Exception\InvalidDimensionException; use Piwik\Filesystem; use Piwik\Period; use Piwik\Piwik; use Piwik\SettingsServer; class API extends \Piwik\Plugin\API { const FILENAME_KEY = "filename"; const TRUNCATE_KEY = "truncate"; const WIDTH_KEY = "width"; const HEIGHT_KEY = "height"; const MAX_WIDTH = 2048; const MAX_HEIGHT = 2048; private static $DEFAULT_PARAMETERS = array(StaticGraph::GRAPH_TYPE_BASIC_LINE => array(self::FILENAME_KEY => "BasicLine", self::TRUNCATE_KEY => 6, self::WIDTH_KEY => 1044, self::HEIGHT_KEY => 290), StaticGraph::GRAPH_TYPE_VERTICAL_BAR => array(self::FILENAME_KEY => "BasicBar", self::TRUNCATE_KEY => 6, self::WIDTH_KEY => 1044, self::HEIGHT_KEY => 290), StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR => array(self::FILENAME_KEY => "HorizontalBar", self::TRUNCATE_KEY => null, self::WIDTH_KEY => 800, self::HEIGHT_KEY => 290), StaticGraph::GRAPH_TYPE_3D_PIE => array(self::FILENAME_KEY => "3DPie", self::TRUNCATE_KEY => 5, self::WIDTH_KEY => 1044, self::HEIGHT_KEY => 290), StaticGraph::GRAPH_TYPE_BASIC_PIE => array(self::FILENAME_KEY => "BasicPie", self::TRUNCATE_KEY => 5, self::WIDTH_KEY => 1044, self::HEIGHT_KEY => 290)); private static $DEFAULT_GRAPH_TYPE_OVERRIDE = array("Referrers_getReferrerType" => array(false => StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR)); const GRAPH_OUTPUT_INLINE = 0; const GRAPH_OUTPUT_FILE = 1; const GRAPH_OUTPUT_PHP = 2; const DEFAULT_ORDINATE_METRIC = "nb_visits"; const FONT_DIR = "/plugins/ImageGraph/fonts/"; const DEFAULT_FONT = "tahoma.ttf"; const UNICODE_FONT = "unifont.ttf"; const DEFAULT_FONT_SIZE = 9; const DEFAULT_LEGEND_FONT_SIZE_OFFSET = 2; const DEFAULT_TEXT_COLOR = "222222"; const DEFAULT_BACKGROUND_COLOR = "FFFFFF"; const DEFAULT_GRID_COLOR = "CCCCCC"; const DEFAULT_NB_ROW_EVOLUTIONS = 5; const MAX_NB_ROW_LABELS = 10; public function get($idSite, $period, $date, $apiModule, $apiAction, $graphType = false, $outputType = API::GRAPH_OUTPUT_INLINE, $columns = false, $labels = false, $showLegend = true, $width = false, $height = false, $fontSize = API::DEFAULT_FONT_SIZE, $legendFontSize = false, $aliasedGraph = true, $idGoal = false, $colors = false, $textColor = API::DEFAULT_TEXT_COLOR, $backgroundColor = API::DEFAULT_BACKGROUND_COLOR, $gridColor = API::DEFAULT_GRID_COLOR, $idSubtable = false, $legendAppendMetric = true, $segment = false, $idDimension = false) { $idSite = (int) $idSite; Piwik::checkUserHasViewAccess($idSite); if (!SettingsServer::isGdExtensionEnabled()) { throw new Exception("Error: To create graphs in Matomo, please enable GD php extension (with Freetype support) in php.ini,\xa            and restart your web server."); } $useUnicodeFont = array("am", "ar", "el", "fa", "fi", "he", "ja", "ka", "ko", "te", "th", "zh-cn", "zh-tw"); $languageLoaded = StaticContainer::get("Piwik\Translation\Translator")->getCurrentLanguage(); $font = self::getFontPath(self::DEFAULT_FONT); if (in_array($languageLoaded, $useUnicodeFont)) { $unicodeFontPath = self::getFontPath(self::UNICODE_FONT); $font = file_exists($unicodeFontPath) ? $unicodeFontPath : $font; } $savedGET = $_GET; try { $apiParameters = array(); if (!empty($idGoal)) { $apiParameters = array("idGoal" => $idGoal); } if (!empty($idDimension)) { $apiParameters = array("idDimension" => $idDimension); } $parameters = array("idSite" => $idSite, "apiModule" => $apiModule, "apiAction" => $apiAction, "apiParameters" => $apiParameters, "language" => $languageLoaded, "period" => $period, "date" => $date, "hideMetricsDoc" => false, "showSubtableReports" => true); $metadata = Request::processRequest("API.getMetadata", $parameters); if (!$metadata) { throw new Exception("Invalid API Module and/or API Action"); } $metadata = $metadata[0]; $reportHasDimension = !empty($metadata["dimension"]); $constantRowsCount = !empty($metadata["constantRowsCount"]); $isMultiplePeriod = Period::isMultiplePeriod($date, $period); if (!$reportHasDimension && !$isMultiplePeriod) { throw new Exception("The graph cannot be drawn for this combination of 'date' and 'period' parameters."); } if (empty($legendFontSize)) { $legendFontSize = (int) $fontSize + self::DEFAULT_LEGEND_FONT_SIZE_OFFSET; } if (empty($graphType)) { if ($isMultiplePeriod) { $graphType = StaticGraph::GRAPH_TYPE_BASIC_LINE; } else { if ($constantRowsCount) { $graphType = StaticGraph::GRAPH_TYPE_VERTICAL_BAR; } else { $graphType = StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR; } } $reportUniqueId = $metadata["uniqueId"]; if (isset(self::$DEFAULT_GRAPH_TYPE_OVERRIDE[$reportUniqueId][$isMultiplePeriod])) { $graphType = self::$DEFAULT_GRAPH_TYPE_OVERRIDE[$reportUniqueId][$isMultiplePeriod]; } } else { $availableGraphTypes = StaticGraph::getAvailableStaticGraphTypes(); if (!in_array($graphType, $availableGraphTypes)) { throw new Exception(Piwik::translate("General_ExceptionInvalidStaticGraphType", array($graphType, implode(", ", $availableGraphTypes)))); } } $width = (int) $width; $height = (int) $height; if (empty($width)) { $width = self::$DEFAULT_PARAMETERS[$graphType][self::WIDTH_KEY]; } if (empty($height)) { $height = self::$DEFAULT_PARAMETERS[$graphType][self::HEIGHT_KEY]; } $width = min($width, self::MAX_WIDTH); $height = min($height, self::MAX_HEIGHT); $reportColumns = array_merge(!empty($metadata["metrics"]) ? $metadata["metrics"] : array(), !empty($metadata["processedMetrics"]) ? $metadata["processedMetrics"] : array(), !empty($metadata["metricsGoal"]) ? $metadata["metricsGoal"] : array(), !empty($metadata["processedMetricsGoal"]) ? $metadata["processedMetricsGoal"] : array()); $ordinateColumns = array(); if (empty($columns)) { if (!empty($reportColumns[self::DEFAULT_ORDINATE_METRIC])) { $ordinateColumns[] = self::DEFAULT_ORDINATE_METRIC; } else { if (!empty($metadata["metrics"])) { $ordinateColumns[] = key($metadata["metrics"]); } else { throw new Exception(Piwik::translate("ImageGraph_ColumnOrdinateMissing", array(self::DEFAULT_ORDINATE_METRIC, implode(",", array_keys($reportColumns))))); } } } else { $ordinateColumns = explode(",", $columns); foreach ($ordinateColumns as $column) { if (empty($reportColumns[$column])) { throw new Exception(Piwik::translate("ImageGraph_ColumnOrdinateMissing", array($column, implode(",", array_keys($reportColumns))))); } } } $ordinateLabels = array(); foreach ($ordinateColumns as $column) { $ordinateLabels[$column] = $reportColumns[$column]; } $defaultFilterTruncate = self::$DEFAULT_PARAMETERS[$graphType][self::TRUNCATE_KEY]; switch ($graphType) { case StaticGraph::GRAPH_TYPE_3D_PIE: case StaticGraph::GRAPH_TYPE_BASIC_PIE: if (count($ordinateColumns) > 1) { throw new Exception("Pie charts do not currently support multiple series"); } $_GET["filter_sort_column"] = reset($ordinateColumns); $this->setFilterTruncate($defaultFilterTruncate); break; case StaticGraph::GRAPH_TYPE_VERTICAL_BAR: case StaticGraph::GRAPH_TYPE_BASIC_LINE: if (!$isMultiplePeriod && !$constantRowsCount) { $this->setFilterTruncate($defaultFilterTruncate); } break; } $ordinateLogos = array(); if ($isMultiplePeriod && $reportHasDimension) { $plottedMetric = reset($ordinateColumns); if (!$labels) { $savedFilterSortColumnValue = Common::getRequestVar("filter_sort_column", ''); $_GET["filter_sort_column"] = $plottedMetric; $savedFilterLimitValue = Common::getRequestVar("filter_limit", -1, "int"); if ($savedFilterLimitValue == -1 || $savedFilterLimitValue > self::MAX_NB_ROW_LABELS) { $_GET["filter_limit"] = self::DEFAULT_NB_ROW_EVOLUTIONS; } } $parameters = array("idSite" => $idSite, "period" => $period, "date" => $date, "apiModule" => $apiModule, "apiAction" => $apiAction, "label" => $labels, "segment" => $segment, "column" => $plottedMetric, "language" => $languageLoaded, "idGoal" => $idGoal, "idDimension" => $idDimension, "legendAppendMetric" => $legendAppendMetric, "labelUseAbsoluteUrl" => false); $processedReport = Request::processRequest("API.getRowEvolution", $parameters); if (!$processedReport) { throw new Exception(Piwik::translate("General_NoDataForGraph")); } if (!$labels) { $_GET["filter_sort_column"] = $savedFilterSortColumnValue; if ($savedFilterLimitValue != -1) { $_GET["filter_limit"] = $savedFilterLimitValue; } } $metrics = $processedReport["metadata"]["metrics"]; $ordinateLabels = array(); if (!array_key_exists($plottedMetric, $metrics)) { $ordinateColumns = array(); $i = 0; foreach ($metrics as $metric => $info) { $ordinateColumn = $plottedMetric . "_" . $i++; $ordinateColumns[] = $metric; $ordinateLabels[$ordinateColumn] = $info["name"]; if (isset($info["logo"])) { $ordinateLogo = $info["logo"]; if (!strstr($ordinateLogo, ".gif")) { $absoluteLogoPath = self::getAbsoluteLogoPath($ordinateLogo); if (file_exists($absoluteLogoPath)) { $ordinateLogos[$ordinateColumn] = $absoluteLogoPath; } } } } } else { $ordinateLabels[$plottedMetric] = $processedReport["label"] . " (" . $metrics[$plottedMetric]["name"] . ")"; } } else { $parameters = array("idSite" => $idSite, "period" => $period, "date" => $date, "apiModule" => $apiModule, "apiAction" => $apiAction, "segment" => $segment, "apiParameters" => false, "idGoal" => $idGoal, "idDimension" => $idDimension, "language" => $languageLoaded, "showTimer" => true, "hideMetricsDoc" => false, "idSubtable" => $idSubtable, "showRawMetrics" => false); $processedReport = Request::processRequest("API.getProcessedReport", $parameters); } $abscissaSeries = array(); $abscissaLogos = array(); $ordinateSeries = array(); $reportData = $processedReport["reportData"]; $hasData = false; $hasNonZeroValue = false; if (!$isMultiplePeriod || !$reportData instanceof Map) { $reportMetadata = $processedReport["reportMetadata"]->getRows(); $i = 0; foreach ($reportData->getRows() as $row) { $rowData = $row->getColumns(); $abscissaSeries[] = Common::unsanitizeInputValue($rowData["label"]); foreach ($ordinateColumns as $column) { $parsedOrdinateValue = $this->parseOrdinateValue($rowData[$column]); $hasData = true; if ($parsedOrdinateValue != 0) { $hasNonZeroValue = true; } $ordinateSeries[$column][] = $parsedOrdinateValue; } if (isset($reportMetadata[$i])) { $rowMetadata = $reportMetadata[$i]->getColumns(); if (isset($rowMetadata["logo"])) { $absoluteLogoPath = self::getAbsoluteLogoPath($rowMetadata["logo"]); if (file_exists($absoluteLogoPath)) { $abscissaLogos[$i] = $absoluteLogoPath; } } } $i++; } } else { $periodsData = array_values($reportData->getDataTables()); $periodsCount = count($periodsData); for ($i = 0; $i < $periodsCount; $i++) { if (empty($periodsData[$i])) { continue; } $rows = $periodsData[$i]->getRows(); if (array_key_exists(0, $rows)) { $rowData = $rows[0]->getColumns(); foreach ($ordinateColumns as $column) { if (!isset($rowData[$column])) { continue; } $ordinateValue = $rowData[$column]; $parsedOrdinateValue = $this->parseOrdinateValue($ordinateValue); $hasData = true; if (!empty($parsedOrdinateValue)) { $hasNonZeroValue = true; } $ordinateSeries[$column][] = $parsedOrdinateValue; } } else { foreach ($ordinateColumns as $column) { $ordinateSeries[$column][] = 0; } } $rowId = $periodsData[$i]->getMetadata(DataTableFactory::TABLE_METADATA_PERIOD_INDEX)->getLocalizedShortString(); $abscissaSeries[] = Common::unsanitizeInputValue($rowId); } } if (!$hasData || !$hasNonZeroValue) { throw new Exception(Piwik::translate("General_NoDataForGraph")); } $graph = StaticGraph::factory($graphType); $graph->setWidth($width); $graph->setHeight($height); $graph->setFont($font); $graph->setFontSize($fontSize); $graph->setLegendFontSize($legendFontSize); $graph->setOrdinateLabels($ordinateLabels); $graph->setShowLegend($showLegend); $graph->setAliasedGraph($aliasedGraph); $graph->setAbscissaSeries($abscissaSeries); $graph->setAbscissaLogos($abscissaLogos); $graph->setOrdinateSeries($ordinateSeries); $graph->setOrdinateLogos($ordinateLogos); $graph->setColors(!empty($colors) ? explode(",", $colors) : array()); $graph->setTextColor($textColor); $graph->setBackgroundColor($backgroundColor); $graph->setGridColor($gridColor); if ($period == "day" && $isMultiplePeriod) { $graph->setForceSkippedLabels(6); } $graph->renderGraph(); } catch (InvalidDimensionException $e) { throw $e; } catch (\Exception $e) { $graph = new \Piwik\Plugins\ImageGraph\StaticGraph\Exception(); $graph->setWidth($width); $graph->setHeight($height); $graph->setFont($font); $graph->setFontSize($fontSize); $graph->setBackgroundColor($backgroundColor); $graph->setTextColor($textColor); $graph->setException($e); $graph->renderGraph(); } $_GET = $savedGET; switch ($outputType) { case self::GRAPH_OUTPUT_FILE: if ($idGoal != '') { $idGoal = "_" . $idGoal; } if ($idDimension != '') { $idDimension = "__" . $idDimension; } $fileName = self::$DEFAULT_PARAMETERS[$graphType][self::FILENAME_KEY] . "_" . $apiModule . "_" . $apiAction . $idGoal . $idDimension . " " . str_replace(",", "-", $date) . " " . $idSite . ".png"; $fileName = str_replace(array(" ", "/"), "_", $fileName); if (!Filesystem::isValidFilename($fileName)) { throw new Exception("Error: Image graph filename " . $fileName . " is not valid."); } return $graph->sendToDisk($fileName); case self::GRAPH_OUTPUT_PHP: return $graph->getRenderedImage(); case self::GRAPH_OUTPUT_INLINE: default: $graph->sendToBrowser(); die; } } private function setFilterTruncate($default) { $_GET["filter_truncate"] = Common::getRequestVar("filter_truncate", $default, "int"); } private static function parseOrdinateValue($ordinateValue) { $ordinateValue = @str_replace(",", ".", $ordinateValue); if (preg_match("/([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\.[0-9]{2})?)/", $ordinateValue, $matches)) { $hour = $matches[1]; $min = $matches[2]; $sec = $matches[3]; $ordinateValue = $hour * 3600 + $min * 60 + $sec; } $ordinateValue = preg_replace("/[^0-9.]/", '', $ordinateValue); return $ordinateValue; } private static function getFontPath($font) { return PIWIK_INCLUDE_PATH . self::FONT_DIR . $font; } protected static function getAbsoluteLogoPath($relativeLogoPath) { return PIWIK_INCLUDE_PATH . "/" . $relativeLogoPath; } } ?>

Did this file decode correctly?

Original Code

<?php
 namespace Piwik\Plugins\ImageGraph; use Exception; use Piwik\API\Request; use Piwik\Archive\DataTableFactory; use Piwik\Common; use Piwik\Container\StaticContainer; use Piwik\DataTable\Map; use Piwik\DataTable\Simple; use Piwik\Exception\InvalidDimensionException; use Piwik\Filesystem; use Piwik\Period; use Piwik\Piwik; use Piwik\SettingsServer; class API extends \Piwik\Plugin\API { const FILENAME_KEY = "\x66\151\x6c\145\x6e\141\x6d\145"; const TRUNCATE_KEY = "\164\162\x75\156\143\141\164\x65"; const WIDTH_KEY = "\x77\151\144\164\150"; const HEIGHT_KEY = "\x68\145\151\147\150\164"; const MAX_WIDTH = 2048; const MAX_HEIGHT = 2048; private static $DEFAULT_PARAMETERS = array(StaticGraph::GRAPH_TYPE_BASIC_LINE => array(self::FILENAME_KEY => "\102\x61\x73\x69\143\x4c\151\x6e\x65", self::TRUNCATE_KEY => 6, self::WIDTH_KEY => 1044, self::HEIGHT_KEY => 290), StaticGraph::GRAPH_TYPE_VERTICAL_BAR => array(self::FILENAME_KEY => "\102\x61\x73\151\x63\102\141\162", self::TRUNCATE_KEY => 6, self::WIDTH_KEY => 1044, self::HEIGHT_KEY => 290), StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR => array(self::FILENAME_KEY => "\x48\x6f\x72\x69\x7a\x6f\156\164\141\x6c\x42\141\162", self::TRUNCATE_KEY => null, self::WIDTH_KEY => 800, self::HEIGHT_KEY => 290), StaticGraph::GRAPH_TYPE_3D_PIE => array(self::FILENAME_KEY => "\63\104\120\x69\145", self::TRUNCATE_KEY => 5, self::WIDTH_KEY => 1044, self::HEIGHT_KEY => 290), StaticGraph::GRAPH_TYPE_BASIC_PIE => array(self::FILENAME_KEY => "\102\x61\x73\151\x63\120\151\145", self::TRUNCATE_KEY => 5, self::WIDTH_KEY => 1044, self::HEIGHT_KEY => 290)); private static $DEFAULT_GRAPH_TYPE_OVERRIDE = array("\122\x65\146\145\x72\162\x65\x72\163\137\147\x65\x74\x52\x65\x66\145\x72\162\145\x72\x54\171\x70\x65" => array(false => StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR)); const GRAPH_OUTPUT_INLINE = 0; const GRAPH_OUTPUT_FILE = 1; const GRAPH_OUTPUT_PHP = 2; const DEFAULT_ORDINATE_METRIC = "\x6e\142\x5f\x76\x69\163\x69\164\163"; const FONT_DIR = "\x2f\x70\154\x75\x67\x69\x6e\x73\57\111\155\141\147\x65\107\162\x61\160\150\x2f\x66\x6f\x6e\164\163\x2f"; const DEFAULT_FONT = "\x74\141\150\x6f\x6d\x61\56\x74\164\146"; const UNICODE_FONT = "\165\x6e\x69\x66\157\x6e\164\56\164\164\146"; const DEFAULT_FONT_SIZE = 9; const DEFAULT_LEGEND_FONT_SIZE_OFFSET = 2; const DEFAULT_TEXT_COLOR = "\62\62\62\62\62\x32"; const DEFAULT_BACKGROUND_COLOR = "\x46\x46\x46\x46\x46\x46"; const DEFAULT_GRID_COLOR = "\103\103\103\x43\x43\103"; const DEFAULT_NB_ROW_EVOLUTIONS = 5; const MAX_NB_ROW_LABELS = 10; public function get($idSite, $period, $date, $apiModule, $apiAction, $graphType = false, $outputType = API::GRAPH_OUTPUT_INLINE, $columns = false, $labels = false, $showLegend = true, $width = false, $height = false, $fontSize = API::DEFAULT_FONT_SIZE, $legendFontSize = false, $aliasedGraph = true, $idGoal = false, $colors = false, $textColor = API::DEFAULT_TEXT_COLOR, $backgroundColor = API::DEFAULT_BACKGROUND_COLOR, $gridColor = API::DEFAULT_GRID_COLOR, $idSubtable = false, $legendAppendMetric = true, $segment = false, $idDimension = false) { $idSite = (int) $idSite; Piwik::checkUserHasViewAccess($idSite); if (!SettingsServer::isGdExtensionEnabled()) { throw new Exception("\x45\162\162\x6f\162\72\x20\x54\x6f\x20\x63\x72\145\x61\164\145\40\147\162\141\x70\150\163\x20\x69\x6e\x20\x4d\x61\x74\157\x6d\157\x2c\x20\x70\154\x65\141\163\x65\x20\x65\x6e\141\x62\x6c\x65\x20\x47\x44\x20\160\x68\160\40\x65\x78\164\145\x6e\163\151\157\x6e\x20\50\167\151\164\x68\x20\x46\162\x65\145\x74\x79\160\x65\40\163\165\160\160\157\x72\164\x29\40\x69\x6e\40\x70\150\160\x2e\x69\x6e\151\54\xa\40\x20\x20\40\x20\x20\x20\40\40\x20\40\x20\141\156\144\x20\162\145\163\164\x61\162\164\x20\171\157\165\162\x20\x77\145\x62\x20\163\145\x72\x76\x65\162\56"); } $useUnicodeFont = array("\141\x6d", "\x61\x72", "\145\x6c", "\146\x61", "\146\x69", "\x68\x65", "\x6a\141", "\153\x61", "\x6b\157", "\x74\x65", "\164\150", "\x7a\x68\x2d\143\x6e", "\172\x68\x2d\164\167"); $languageLoaded = StaticContainer::get("\120\151\x77\151\153\x5c\124\162\141\x6e\x73\x6c\x61\x74\151\157\x6e\x5c\x54\x72\x61\156\x73\154\x61\x74\157\162")->getCurrentLanguage(); $font = self::getFontPath(self::DEFAULT_FONT); if (in_array($languageLoaded, $useUnicodeFont)) { $unicodeFontPath = self::getFontPath(self::UNICODE_FONT); $font = file_exists($unicodeFontPath) ? $unicodeFontPath : $font; } $savedGET = $_GET; try { $apiParameters = array(); if (!empty($idGoal)) { $apiParameters = array("\x69\144\107\157\141\154" => $idGoal); } if (!empty($idDimension)) { $apiParameters = array("\x69\144\x44\151\155\x65\x6e\x73\151\157\x6e" => $idDimension); } $parameters = array("\x69\x64\x53\x69\x74\x65" => $idSite, "\x61\x70\x69\x4d\157\x64\165\x6c\x65" => $apiModule, "\141\x70\151\x41\x63\164\151\157\156" => $apiAction, "\x61\x70\x69\x50\x61\162\x61\155\145\164\145\162\x73" => $apiParameters, "\x6c\141\x6e\x67\165\x61\x67\x65" => $languageLoaded, "\160\x65\x72\151\157\144" => $period, "\144\x61\164\145" => $date, "\x68\151\144\x65\115\x65\x74\x72\x69\x63\x73\104\157\x63" => false, "\163\150\157\167\x53\165\142\x74\x61\142\x6c\145\x52\145\x70\x6f\x72\164\x73" => true); $metadata = Request::processRequest("\x41\120\x49\x2e\147\x65\x74\115\145\164\x61\144\141\164\x61", $parameters); if (!$metadata) { throw new Exception("\x49\x6e\x76\x61\x6c\x69\144\x20\101\120\x49\40\115\x6f\x64\165\x6c\x65\40\141\156\144\x2f\x6f\162\x20\x41\120\111\40\101\143\164\x69\157\x6e"); } $metadata = $metadata[0]; $reportHasDimension = !empty($metadata["\144\x69\155\x65\156\x73\x69\157\156"]); $constantRowsCount = !empty($metadata["\x63\x6f\x6e\163\164\141\x6e\164\122\157\x77\x73\103\157\165\x6e\x74"]); $isMultiplePeriod = Period::isMultiplePeriod($date, $period); if (!$reportHasDimension && !$isMultiplePeriod) { throw new Exception("\124\150\x65\40\147\x72\141\x70\150\x20\143\x61\x6e\156\x6f\x74\40\142\145\x20\144\162\141\x77\x6e\x20\x66\157\x72\40\x74\x68\x69\163\40\143\157\155\142\x69\156\x61\164\151\x6f\156\40\x6f\x66\40\x27\x64\141\x74\145\x27\x20\x61\x6e\144\40\47\x70\x65\x72\x69\x6f\144\x27\x20\160\x61\x72\141\155\x65\x74\145\162\163\56"); } if (empty($legendFontSize)) { $legendFontSize = (int) $fontSize + self::DEFAULT_LEGEND_FONT_SIZE_OFFSET; } if (empty($graphType)) { if ($isMultiplePeriod) { $graphType = StaticGraph::GRAPH_TYPE_BASIC_LINE; } else { if ($constantRowsCount) { $graphType = StaticGraph::GRAPH_TYPE_VERTICAL_BAR; } else { $graphType = StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR; } } $reportUniqueId = $metadata["\x75\x6e\151\161\165\145\x49\x64"]; if (isset(self::$DEFAULT_GRAPH_TYPE_OVERRIDE[$reportUniqueId][$isMultiplePeriod])) { $graphType = self::$DEFAULT_GRAPH_TYPE_OVERRIDE[$reportUniqueId][$isMultiplePeriod]; } } else { $availableGraphTypes = StaticGraph::getAvailableStaticGraphTypes(); if (!in_array($graphType, $availableGraphTypes)) { throw new Exception(Piwik::translate("\x47\145\156\145\162\x61\x6c\x5f\105\170\x63\x65\160\x74\x69\157\156\111\x6e\166\141\x6c\x69\144\123\x74\141\164\151\x63\107\x72\x61\x70\150\x54\171\x70\145", array($graphType, implode("\54\40", $availableGraphTypes)))); } } $width = (int) $width; $height = (int) $height; if (empty($width)) { $width = self::$DEFAULT_PARAMETERS[$graphType][self::WIDTH_KEY]; } if (empty($height)) { $height = self::$DEFAULT_PARAMETERS[$graphType][self::HEIGHT_KEY]; } $width = min($width, self::MAX_WIDTH); $height = min($height, self::MAX_HEIGHT); $reportColumns = array_merge(!empty($metadata["\155\x65\x74\162\x69\143\163"]) ? $metadata["\155\145\164\162\x69\143\163"] : array(), !empty($metadata["\x70\x72\x6f\x63\x65\x73\163\145\x64\x4d\145\164\x72\151\143\163"]) ? $metadata["\160\162\x6f\143\x65\x73\x73\145\144\115\x65\x74\x72\151\x63\163"] : array(), !empty($metadata["\155\x65\164\162\x69\143\163\x47\157\x61\x6c"]) ? $metadata["\155\x65\164\x72\x69\143\163\107\157\x61\154"] : array(), !empty($metadata["\160\x72\157\x63\x65\163\x73\x65\144\115\x65\x74\162\151\x63\x73\107\x6f\x61\154"]) ? $metadata["\160\162\x6f\143\x65\x73\x73\145\x64\115\145\164\x72\151\x63\x73\107\x6f\141\x6c"] : array()); $ordinateColumns = array(); if (empty($columns)) { if (!empty($reportColumns[self::DEFAULT_ORDINATE_METRIC])) { $ordinateColumns[] = self::DEFAULT_ORDINATE_METRIC; } else { if (!empty($metadata["\155\145\x74\162\x69\143\x73"])) { $ordinateColumns[] = key($metadata["\x6d\x65\x74\162\x69\143\x73"]); } else { throw new Exception(Piwik::translate("\111\155\141\147\x65\x47\x72\141\x70\x68\x5f\x43\x6f\154\165\x6d\x6e\117\x72\144\151\156\x61\x74\x65\115\x69\x73\x73\151\x6e\x67", array(self::DEFAULT_ORDINATE_METRIC, implode("\x2c", array_keys($reportColumns))))); } } } else { $ordinateColumns = explode("\x2c", $columns); foreach ($ordinateColumns as $column) { if (empty($reportColumns[$column])) { throw new Exception(Piwik::translate("\x49\x6d\141\x67\x65\x47\162\x61\160\150\x5f\x43\x6f\154\x75\x6d\x6e\x4f\x72\144\x69\x6e\x61\164\x65\115\151\x73\x73\x69\156\147", array($column, implode("\54", array_keys($reportColumns))))); } } } $ordinateLabels = array(); foreach ($ordinateColumns as $column) { $ordinateLabels[$column] = $reportColumns[$column]; } $defaultFilterTruncate = self::$DEFAULT_PARAMETERS[$graphType][self::TRUNCATE_KEY]; switch ($graphType) { case StaticGraph::GRAPH_TYPE_3D_PIE: case StaticGraph::GRAPH_TYPE_BASIC_PIE: if (count($ordinateColumns) > 1) { throw new Exception("\120\x69\x65\x20\x63\150\x61\162\164\x73\x20\x64\x6f\x20\156\157\164\x20\x63\x75\162\x72\145\156\x74\154\x79\x20\x73\x75\160\160\157\x72\164\x20\x6d\165\x6c\164\x69\160\154\x65\40\163\145\162\x69\145\163"); } $_GET["\146\x69\x6c\x74\145\162\137\x73\x6f\162\164\137\143\x6f\154\165\155\156"] = reset($ordinateColumns); $this->setFilterTruncate($defaultFilterTruncate); break; case StaticGraph::GRAPH_TYPE_VERTICAL_BAR: case StaticGraph::GRAPH_TYPE_BASIC_LINE: if (!$isMultiplePeriod && !$constantRowsCount) { $this->setFilterTruncate($defaultFilterTruncate); } break; } $ordinateLogos = array(); if ($isMultiplePeriod && $reportHasDimension) { $plottedMetric = reset($ordinateColumns); if (!$labels) { $savedFilterSortColumnValue = Common::getRequestVar("\x66\151\154\164\145\162\137\163\157\x72\x74\x5f\143\x6f\x6c\165\x6d\x6e", ''); $_GET["\x66\151\x6c\164\145\x72\x5f\163\x6f\162\x74\137\143\157\x6c\165\x6d\156"] = $plottedMetric; $savedFilterLimitValue = Common::getRequestVar("\146\x69\154\x74\145\x72\137\154\151\x6d\151\164", -1, "\151\x6e\164"); if ($savedFilterLimitValue == -1 || $savedFilterLimitValue > self::MAX_NB_ROW_LABELS) { $_GET["\146\151\x6c\x74\145\x72\x5f\x6c\x69\x6d\151\164"] = self::DEFAULT_NB_ROW_EVOLUTIONS; } } $parameters = array("\x69\x64\x53\151\x74\x65" => $idSite, "\x70\x65\162\151\x6f\144" => $period, "\x64\x61\164\145" => $date, "\141\x70\151\115\x6f\x64\x75\x6c\x65" => $apiModule, "\141\160\x69\x41\x63\x74\x69\157\x6e" => $apiAction, "\x6c\141\142\x65\x6c" => $labels, "\163\145\147\x6d\x65\x6e\164" => $segment, "\143\157\154\x75\155\156" => $plottedMetric, "\154\x61\x6e\147\x75\x61\147\x65" => $languageLoaded, "\151\144\107\x6f\141\154" => $idGoal, "\x69\x64\104\x69\155\145\156\x73\x69\157\156" => $idDimension, "\154\x65\147\145\x6e\144\101\160\160\x65\x6e\x64\x4d\145\x74\x72\151\143" => $legendAppendMetric, "\x6c\x61\142\x65\x6c\125\x73\145\x41\x62\x73\157\x6c\x75\164\145\x55\x72\x6c" => false); $processedReport = Request::processRequest("\101\120\111\56\147\145\164\122\157\x77\105\x76\157\154\x75\x74\x69\x6f\x6e", $parameters); if (!$processedReport) { throw new Exception(Piwik::translate("\107\x65\x6e\145\x72\x61\x6c\137\116\157\104\141\x74\x61\106\157\x72\107\x72\x61\x70\x68")); } if (!$labels) { $_GET["\146\x69\x6c\164\x65\x72\137\163\x6f\162\164\x5f\143\157\154\x75\155\x6e"] = $savedFilterSortColumnValue; if ($savedFilterLimitValue != -1) { $_GET["\x66\x69\154\x74\x65\x72\x5f\154\151\155\x69\164"] = $savedFilterLimitValue; } } $metrics = $processedReport["\155\145\164\141\144\141\164\141"]["\155\x65\164\x72\151\143\163"]; $ordinateLabels = array(); if (!array_key_exists($plottedMetric, $metrics)) { $ordinateColumns = array(); $i = 0; foreach ($metrics as $metric => $info) { $ordinateColumn = $plottedMetric . "\137" . $i++; $ordinateColumns[] = $metric; $ordinateLabels[$ordinateColumn] = $info["\x6e\x61\x6d\145"]; if (isset($info["\x6c\157\x67\x6f"])) { $ordinateLogo = $info["\154\x6f\x67\x6f"]; if (!strstr($ordinateLogo, "\56\x67\x69\146")) { $absoluteLogoPath = self::getAbsoluteLogoPath($ordinateLogo); if (file_exists($absoluteLogoPath)) { $ordinateLogos[$ordinateColumn] = $absoluteLogoPath; } } } } } else { $ordinateLabels[$plottedMetric] = $processedReport["\154\141\142\x65\x6c"] . "\x20\x28" . $metrics[$plottedMetric]["\x6e\x61\x6d\x65"] . "\x29"; } } else { $parameters = array("\x69\144\123\x69\164\x65" => $idSite, "\160\145\x72\151\157\144" => $period, "\144\x61\x74\145" => $date, "\x61\160\x69\x4d\x6f\144\x75\x6c\145" => $apiModule, "\x61\x70\151\101\143\164\x69\157\x6e" => $apiAction, "\x73\x65\147\155\145\x6e\x74" => $segment, "\141\x70\x69\120\141\162\141\x6d\145\x74\145\x72\163" => false, "\x69\x64\107\x6f\141\x6c" => $idGoal, "\151\x64\x44\151\155\x65\156\163\x69\x6f\156" => $idDimension, "\154\x61\x6e\x67\165\x61\x67\145" => $languageLoaded, "\163\150\x6f\167\124\151\155\145\162" => true, "\x68\x69\144\145\x4d\145\x74\x72\x69\143\163\104\157\x63" => false, "\x69\x64\123\x75\142\164\x61\142\x6c\x65" => $idSubtable, "\163\x68\157\x77\x52\141\167\115\x65\x74\x72\151\143\x73" => false); $processedReport = Request::processRequest("\101\120\x49\x2e\x67\x65\x74\120\x72\x6f\143\145\163\x73\x65\144\x52\145\160\x6f\x72\x74", $parameters); } $abscissaSeries = array(); $abscissaLogos = array(); $ordinateSeries = array(); $reportData = $processedReport["\x72\145\160\x6f\162\164\x44\141\x74\141"]; $hasData = false; $hasNonZeroValue = false; if (!$isMultiplePeriod || !$reportData instanceof Map) { $reportMetadata = $processedReport["\x72\x65\160\157\162\x74\115\145\x74\x61\x64\141\x74\141"]->getRows(); $i = 0; foreach ($reportData->getRows() as $row) { $rowData = $row->getColumns(); $abscissaSeries[] = Common::unsanitizeInputValue($rowData["\154\x61\142\x65\x6c"]); foreach ($ordinateColumns as $column) { $parsedOrdinateValue = $this->parseOrdinateValue($rowData[$column]); $hasData = true; if ($parsedOrdinateValue != 0) { $hasNonZeroValue = true; } $ordinateSeries[$column][] = $parsedOrdinateValue; } if (isset($reportMetadata[$i])) { $rowMetadata = $reportMetadata[$i]->getColumns(); if (isset($rowMetadata["\x6c\x6f\x67\x6f"])) { $absoluteLogoPath = self::getAbsoluteLogoPath($rowMetadata["\x6c\157\147\x6f"]); if (file_exists($absoluteLogoPath)) { $abscissaLogos[$i] = $absoluteLogoPath; } } } $i++; } } else { $periodsData = array_values($reportData->getDataTables()); $periodsCount = count($periodsData); for ($i = 0; $i < $periodsCount; $i++) { if (empty($periodsData[$i])) { continue; } $rows = $periodsData[$i]->getRows(); if (array_key_exists(0, $rows)) { $rowData = $rows[0]->getColumns(); foreach ($ordinateColumns as $column) { if (!isset($rowData[$column])) { continue; } $ordinateValue = $rowData[$column]; $parsedOrdinateValue = $this->parseOrdinateValue($ordinateValue); $hasData = true; if (!empty($parsedOrdinateValue)) { $hasNonZeroValue = true; } $ordinateSeries[$column][] = $parsedOrdinateValue; } } else { foreach ($ordinateColumns as $column) { $ordinateSeries[$column][] = 0; } } $rowId = $periodsData[$i]->getMetadata(DataTableFactory::TABLE_METADATA_PERIOD_INDEX)->getLocalizedShortString(); $abscissaSeries[] = Common::unsanitizeInputValue($rowId); } } if (!$hasData || !$hasNonZeroValue) { throw new Exception(Piwik::translate("\x47\x65\156\145\162\141\154\137\116\x6f\x44\141\x74\141\x46\157\x72\107\162\x61\160\x68")); } $graph = StaticGraph::factory($graphType); $graph->setWidth($width); $graph->setHeight($height); $graph->setFont($font); $graph->setFontSize($fontSize); $graph->setLegendFontSize($legendFontSize); $graph->setOrdinateLabels($ordinateLabels); $graph->setShowLegend($showLegend); $graph->setAliasedGraph($aliasedGraph); $graph->setAbscissaSeries($abscissaSeries); $graph->setAbscissaLogos($abscissaLogos); $graph->setOrdinateSeries($ordinateSeries); $graph->setOrdinateLogos($ordinateLogos); $graph->setColors(!empty($colors) ? explode("\54", $colors) : array()); $graph->setTextColor($textColor); $graph->setBackgroundColor($backgroundColor); $graph->setGridColor($gridColor); if ($period == "\144\141\171" && $isMultiplePeriod) { $graph->setForceSkippedLabels(6); } $graph->renderGraph(); } catch (InvalidDimensionException $e) { throw $e; } catch (\Exception $e) { $graph = new \Piwik\Plugins\ImageGraph\StaticGraph\Exception(); $graph->setWidth($width); $graph->setHeight($height); $graph->setFont($font); $graph->setFontSize($fontSize); $graph->setBackgroundColor($backgroundColor); $graph->setTextColor($textColor); $graph->setException($e); $graph->renderGraph(); } $_GET = $savedGET; switch ($outputType) { case self::GRAPH_OUTPUT_FILE: if ($idGoal != '') { $idGoal = "\137" . $idGoal; } if ($idDimension != '') { $idDimension = "\137\x5f" . $idDimension; } $fileName = self::$DEFAULT_PARAMETERS[$graphType][self::FILENAME_KEY] . "\137" . $apiModule . "\x5f" . $apiAction . $idGoal . $idDimension . "\x20" . str_replace("\x2c", "\x2d", $date) . "\40" . $idSite . "\56\160\x6e\x67"; $fileName = str_replace(array("\x20", "\57"), "\x5f", $fileName); if (!Filesystem::isValidFilename($fileName)) { throw new Exception("\x45\x72\x72\157\x72\x3a\40\111\x6d\141\x67\x65\x20\x67\x72\141\160\x68\40\x66\151\x6c\145\156\141\155\145\40" . $fileName . "\x20\151\x73\40\x6e\157\164\40\166\141\154\151\x64\x2e"); } return $graph->sendToDisk($fileName); case self::GRAPH_OUTPUT_PHP: return $graph->getRenderedImage(); case self::GRAPH_OUTPUT_INLINE: default: $graph->sendToBrowser(); die; } } private function setFilterTruncate($default) { $_GET["\146\x69\x6c\164\145\x72\137\164\x72\165\x6e\x63\141\x74\x65"] = Common::getRequestVar("\146\151\x6c\x74\x65\x72\137\164\162\x75\156\143\x61\164\x65", $default, "\151\156\164"); } private static function parseOrdinateValue($ordinateValue) { $ordinateValue = @str_replace("\54", "\56", $ordinateValue); if (preg_match("\x2f\50\x5b\60\x2d\x39\135\x7b\61\54\62\x7d\x29\72\50\133\x30\x2d\71\x5d\173\x31\x2c\x32\175\51\72\x28\133\60\55\71\135\x7b\61\54\x32\x7d\x28\134\x2e\133\x30\x2d\x39\135\x7b\x32\175\x29\x3f\x29\57", $ordinateValue, $matches)) { $hour = $matches[1]; $min = $matches[2]; $sec = $matches[3]; $ordinateValue = $hour * 3600 + $min * 60 + $sec; } $ordinateValue = preg_replace("\x2f\x5b\x5e\x30\55\x39\56\x5d\57", '', $ordinateValue); return $ordinateValue; } private static function getFontPath($font) { return PIWIK_INCLUDE_PATH . self::FONT_DIR . $font; } protected static function getAbsoluteLogoPath($relativeLogoPath) { return PIWIK_INCLUDE_PATH . "\57" . $relativeLogoPath; } }

Function Calls

None

Variables

None

Stats

MD5 e9c222344533dfe2d48020a86dcf388b
Eval Count 0
Decode Time 94 ms