mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-09-26 11:29:12 +02:00
* include/functions_menu.php, include/functions_html.php, include/functions_events.php, include/functions_messages.php, include/functions_modules.php, include/functions_exportserver.php, include/functions_reporting.php, include/functions_filemanager.php, include/pchart_graph.php, include/pandora_graph.php, include/auth/dev.php, include/auth/ldap.php, include/auth/mysql.php, include/config.inc.php, include/functions_networkmap.php, include/functions_servers.php, include/FusionCharts/FusionCharts_Gen.php, include/FusionCharts/FusionCharts.php, include/functions_network_profiles.php, include/gettext.php, include/functions_network_components.php, include/functions_visual_map.php, include/fgraph2.php, include/Image/image_functions.php, include/functions_config.php, include/help/en/help_plugin_parameters.php, include/help/en/help_snmpcommunity.php, include/help/en/help_wmiquery.php, include/help/en/help_postprocess.php, include/help/en/help_prediction_source_module.php, include/help/en/help_date_format.php, include/help/en/help_recontask.php, include/help/en/help_alert-matches.php, include/help/en/help_tcp_send.php, include/help/en/help_wmifield.php, include/help/en/help_duplicateconfig.php, include/help/en/help_agent_status.php, include/help/en/help_manage_alerts.php, include/help/en/help_wmikey.php, include/help/en/help_alert_type.php, include/help/en/help_network_component.php, include/help/en/help_time_stamp-comparation.php, include/help/en/help_eventview.php, include/help/en/help_timesource.php, include/help/en/help_alert_validation.php, include/help/en/help_map_builder.php, include/help/en/help_alert_recovery.php, include/help/en/help_module_type.php, include/help/en/help_planned_downtime.php, include/help/en/help_serverlag.php, include/help/en/help_alerts.php, include/help/en/help_snmpwalk.php, include/help/en/help_module_definition.php, include/help/en/help_plugin_definition.php, include/help/en/help_wminamespace.php, include/help/en/help_snmpoid.php include/help/en/help_manageconfig.php, include/help/es/help_alert_validation.php, include/help/es/help_plugin_parameters.php, include/help/es/help_snmpcommunity.php, include/help/es/help_wmiquery.php, include/help/es/help_map_builder.php, include/help/es/help_postprocess.php, include/help/es/help_date_format.php, include/help/es/help_alert_recovery.php, include/help/es/help_prediction_source_module.php, include/help/es/help_module_type.php, include/help/es/help_planned_downtime.php, include/help/es/help_alert-matches.php, include/help/es/help_recontask.php, include/help/es/help_alerts.php, include/help/es/help_serverlag.php, include/help/es/help_snmpwalk.php, include/help/es/help_module_definition.php, include/help/es/help_tcp_send.php, include/help/es/help_duplicateconfig.php, include/help/es/help_wmifield.php, include/help/es/help_manage_alerts.php, include/help/es/help_wmikey.php, include/help/es/help_plugin_definition.php, include/help/es/help_alert_type.php, include/help/es/help_snmpoid.php, include/help/es/help_wminamespace.php, include/help/es/help_network_component.php, include/help/es/help_time_stamp-comparation.php, include/help/es/help_manageconfig.php, include/help/es/help_timesource.php, include/config_process.php, include/functions_ui.php, include/htmlawed.php, include/functions_custom_graphs.php, include/fgraph.php, include/functions_incidents.php, include/functions.php, include/functions_agents.php, include/functions_db.php, include/functions_themes.php, include/streams.php, include/functions_fsgraph.php, include/functions_alerts.php, include/functions_reports.php, include/functions_extensions.php, include/functions_ui_renders.php: change comments blocks for delete the warnings to construct phpDoc Files, give a struct and order in the phpDoc files. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1881 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
150 lines
6.6 KiB
PHP
150 lines
6.6 KiB
PHP
<?php
|
|
/**
|
|
* @package Include/FusionCharts
|
|
*/
|
|
|
|
// Page: FusionCharts.php
|
|
// Author: InfoSoft Global (P) Ltd.
|
|
// This page contains functions that can be used to render FusionCharts.
|
|
|
|
|
|
/**
|
|
* encodeDataURL function encodes the dataURL before it's served to FusionCharts.
|
|
*If you've parameters in your dataURL, you necessarily need to encode it.
|
|
* Param: $strDataURL - dataURL to be fed to chart
|
|
* Param: $addNoCacheStr - Whether to add aditional string to URL to disable caching of data
|
|
*/
|
|
function encodeDataURL($strDataURL, $addNoCacheStr=false) {
|
|
//Add the no-cache string if required
|
|
if ($addNoCacheStr==true) {
|
|
// We add ?FCCurrTime=xxyyzz
|
|
// If the dataURL already contains a ?, we add &FCCurrTime=xxyyzz
|
|
// We replace : with _, as FusionCharts cannot handle : in URLs
|
|
if (strpos(strDataURL,"?")<>0)
|
|
$strDataURL .= "&FCCurrTime=" . Date("H_i_s");
|
|
else
|
|
$strDataURL .= "?FCCurrTime=" . Date("H_i_s");
|
|
}
|
|
// URL Encode it
|
|
return urlencode($strDataURL);
|
|
}
|
|
|
|
|
|
// datePart function converts MySQL database based on requested mask
|
|
// Param: $mask - what part of the date to return "m' for month,"d" for day, and "y" for year
|
|
// Param: $dateTimeStr - MySQL date/time format (yyyy-mm-dd HH:ii:ss)
|
|
function datePart($mask, $dateTimeStr) {
|
|
@list($datePt, $timePt) = explode(" ", $dateTimeStr);
|
|
$arDatePt = explode("-", $datePt);
|
|
$dataStr = "";
|
|
// Ensure we have 3 parameters for the date
|
|
if (count($arDatePt) == 3) {
|
|
list($year, $month, $day) = $arDatePt;
|
|
// determine the request
|
|
switch ($mask) {
|
|
case "m": return (int)$month;
|
|
case "d": return (int)$day;
|
|
case "y": return (int)$year;
|
|
}
|
|
// default to mm/dd/yyyy
|
|
return (trim($month . "/" . $day . "/" . $year));
|
|
}
|
|
return $dataStr;
|
|
}
|
|
|
|
|
|
// renderChart renders the JavaScript + HTML code required to embed a chart.
|
|
// This function assumes that you've already included the FusionCharts JavaScript class
|
|
// in your page.
|
|
|
|
// $chartSWF - SWF File Name (and Path) of the chart which you intend to plot
|
|
// $strURL - If you intend to use dataURL method for this chart, pass the URL as this parameter. Else, set it to "" (in case of dataXML method)
|
|
// $strXML - If you intend to use dataXML method for this chart, pass the XML data as this parameter. Else, set it to "" (in case of dataURL method)
|
|
// $chartId - Id for the chart, using which it will be recognized in the HTML page. Each chart on the page needs to have a unique Id.
|
|
// $chartWidth - Intended width for the chart (in pixels)
|
|
// $chartHeight - Intended height for the chart (in pixels)
|
|
function renderChart($chartSWF, $strURL, $strXML, $chartId, $chartWidth, $chartHeight) {
|
|
//First we create a new DIV for each chart. We specify the name of DIV as "chartId"Div.
|
|
//DIV names are case-sensitive.
|
|
|
|
// The Steps in the script block below are:
|
|
//
|
|
// 1)In the DIV the text "Chart" is shown to users before the chart has started loading
|
|
// (if there is a lag in relaying SWF from server). This text is also shown to users
|
|
// who do not have Flash Player installed. You can configure it as per your needs.
|
|
//
|
|
// 2) The chart is rendered using FusionCharts Class. Each chart's instance (JavaScript) Id
|
|
// is named as chart_"chartId".
|
|
//
|
|
// 3) Check whether we've to provide data using dataXML method or dataURL method
|
|
// save the data for usage below
|
|
if ($strXML=="")
|
|
$tempData = "//Set the dataURL of the chart\n\t\tchart_$chartId.setDataURL(\"$strURL\")";
|
|
else
|
|
$tempData = "//Provide entire XML data using dataXML method\n\t\tchart_$chartId.setDataXML(\"$strXML\")";
|
|
|
|
// Set up necessary variables for the RENDERCAHRT
|
|
$chartIdDiv = $chartId . "Div";
|
|
|
|
// create a string for outputting by the caller
|
|
$render_chart = <<<RENDERCHART
|
|
<!-- START Script Block for Chart $chartId -->
|
|
<div id="$chartIdDiv" align="center">
|
|
Chart.
|
|
</div>
|
|
<script type="text/javascript">
|
|
//Instantiate the Chart
|
|
var chart_$chartId = new FusionCharts("$chartSWF", "$chartId", "$chartWidth", "$chartHeight");
|
|
$tempData
|
|
//Finally, render the chart.
|
|
chart_$chartId.render("$chartIdDiv");
|
|
</script>
|
|
<!-- END Script Block for Chart $chartId -->
|
|
RENDERCHART;
|
|
|
|
return $render_chart;
|
|
}
|
|
|
|
|
|
//renderChartHTML function renders the HTML code for the JavaScript. This
|
|
//method does NOT embed the chart using JavaScript class. Instead, it uses
|
|
//direct HTML embedding. So, if you see the charts on IE 6 (or above), you'll
|
|
//see the "Click to activate..." message on the chart.
|
|
// $chartSWF - SWF File Name (and Path) of the chart which you intend to plot
|
|
// $strURL - If you intend to use dataURL method for this chart, pass the URL as this parameter. Else, set it to "" (in case of dataXML method)
|
|
// $strXML - If you intend to use dataXML method for this chart, pass the XML data as this parameter. Else, set it to "" (in case of dataURL method)
|
|
// $chartId - Id for the chart, using which it will be recognized in the HTML page. Each chart on the page needs to have a unique Id.
|
|
// $chartWidth - Intended width for the chart (in pixels)
|
|
// $chartHeight - Intended height for the chart (in pixels)
|
|
function renderChartHTML($chartSWF, $strURL, $strXML, $chartId, $chartWidth, $chartHeight) {
|
|
// Generate the FlashVars string based on whether dataURL has been provided
|
|
// or dataXML.
|
|
$strFlashVars = "&chartWidth=" . $chartWidth . "&chartHeight=" . $chartHeight ;
|
|
if ($strXML=="")
|
|
// DataURL Mode
|
|
$strFlashVars .= "&dataURL=" . $strURL;
|
|
else
|
|
//DataXML Mode
|
|
$strFlashVars .= "&dataXML=" . $strXML;
|
|
|
|
$HTML_chart = <<<HTMLCHART
|
|
<!-- START Code Block for Chart $chartId -->
|
|
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="$chartWidth" height="$chartHeight" id="$chartId">
|
|
<param name="allowScriptAccess" value="always" />
|
|
<param name="movie" value="$chartSWF"/>
|
|
<param name="FlashVars" value="$strFlashVars" />
|
|
<param name="quality" value="high" />
|
|
<embed src="$chartSWF" FlashVars="$strFlashVars" quality="high" width="$chartWidth" height="$chartHeight" name="$chartId" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
|
|
</object>
|
|
<!-- END Code Block for Chart $chartId -->
|
|
HTMLCHART;
|
|
|
|
return $HTML_chart;
|
|
}
|
|
|
|
// boolToNum function converts boolean values to numeric (1/0)
|
|
function boolToNum($bVal) {
|
|
return (($bVal==true) ? 1 : 0);
|
|
}
|
|
|
|
?>
|