Exemple #1
0
    $action = 'ajax_' . $_REQUEST["action"];
    $data = $_REQUEST["data"];
    $data = str_replace("\\\"", "\"", $data);
    $func_output = call_user_func(array($panoptes, $action), json_decode($data, true));
    print json_encode($func_output);
    exit(0);
}
$dojo_url = $panoptes->config()->getConfigValue('web.dojo-url');
if (!$dojo_url) {
    echo "No dojo url defined!";
    exit(-1);
}
$user = new userEntry();
$user->db = $panoptes->getDb();
$user->getByName($panoptes_current_user);
$userPrefs = new userPrefs();
$userPrefs->db = $panoptes->getDb();
$theme = $userPrefs->getPref($user->id, 'general', 'general_prefs_theme');
if (is_null($theme)) {
    $theme = $panoptes->config()->getConfigValue('web.default_theme');
}
$theme_css = $dojo_url . '/dijit/themes/' . $theme . '/' . $theme . '.css';
$theme_grid_css = $dojo_url . '/dojox/grid/resources/' . $theme . 'Grid.css';
$theme_e_grid_css = $dojo_url . '/dojox/grid/enhanced/resources/' . $theme . 'EnhancedGrid.css';
$chart_theme = $userPrefs->getPref($user->id, 'general', 'general_prefs_chart_theme');
if (is_null($chart_theme)) {
    $chart_theme = $panoptes->config()->getConfigValue('web.default_chart_theme');
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 /**
  * renderUserWidget
  *
  * @param entry dashboardUserWidget object
  * @throws PDOException
  * @return none
  */
 public function renderUserWidget(dashboardUserWidget $entry)
 {
     global $panoptes_current_user;
     try {
         $rtn = array();
         $rtn['type'] = 'js';
         $rtn['value'] = '';
         require_once dirname(realpath(__FILE__)) . '/../deviceGroup.php';
         require_once dirname(realpath(__FILE__)) . '/../deviceEntry.php';
         require_once dirname(realpath(__FILE__)) . '/../userEntry.php';
         require_once dirname(realpath(__FILE__)) . '/../userPrefs.php';
         // get group name from id
         $prms = $entry->params;
         $grp = new deviceGroup($this->db);
         $grp->getById($prms['group_id']);
         if ($grp) {
             $counts = array();
             $counts['ok'] = 0;
             $counts['warn'] = 0;
             $counts['critical'] = 0;
             // get status for children
             foreach ($grp->children() as $c) {
                 $dev = new deviceEntry($this->db);
                 $dev->getById($c);
                 if ($dev->id) {
                     $status = $dev->maxStatus();
                     if (array_key_exists($status, $counts)) {
                         $counts[$status]++;
                     } else {
                         $counts[$status] = 1;
                     }
                 }
             }
         }
         $str = 'var groupStatusPieData = [';
         $i = 1;
         foreach ($counts as $k => $v) {
             $str .= '{ "x": "' . $i . '", "y": "' . $v . '", "text": "' . $k . '"},';
             $i++;
         }
         $str .= ']; ';
         // load user prefs for chart theme
         $user = new userEntry();
         $user->db = $this->db;
         $user->getByName($panoptes_current_user);
         $userPrefs = new userPrefs($this->db);
         $userPrefs->db = $this->db;
         $theme = $userPrefs->getPref($user->id, 'general', 'general_prefs_chart_theme');
         if (is_null($theme)) {
             require_once dirname(realpath(__FILE__)) . '/../panoptes.php';
             $panoptes = new panoptes();
             $theme = $panoptes->config()->getConfigValue('web.default_chart_theme');
         }
         $rtn['value'] .= $str;
         $rtn['value'] .= "var dv = document.createElement('div'); dv.id = '" . $prms['group_id'] . "' + '_gs_div'; dv.style.height = '200px'; dv.style.width = '200px'; node.appendChild(dv); var GS_pieChart = new dojox.charting.Chart2D('" . $prms['group_id'] . "' + '_gs_div', { title: '" . $grp->name . " summary', titleFont: 'normal normal bold 12pt Helvetica', titleGap: 5 }); GS_pieChart.setTheme(dojox.charting.themes." . $theme . "); GS_pieChart.addPlot('default', { type: 'Pie', labels: true, labelOffset: -30, radius: 50, fontColor: 'black'}); GS_pieChart.addSeries('" . $grp->name . "' + ' Summary', groupStatusPieData); new dojox.charting.action2d.MoveSlice(GS_pieChart, 'default'); GS_pieChart.render()";
     } catch (PDOException $e) {
         throw $e;
     }
     return $rtn;
 }
Exemple #3
0
 /**
  * getAllPrefs
  *
  * @param args json params converted into an array
  *                  scope scope of preferences being saved
  *                  prefs name value pairs of preferences to update
  * @throws none
  * @return array containing result and possible error messages
  */
 public function ajax_getAllPrefs($args)
 {
     global $panoptes_current_user;
     $result = 'success';
     $error = '';
     try {
         require_once 'userEntry.php';
         require_once 'userPrefs.php';
         $user = new userEntry();
         $user->db = $this->db;
         $user->getByName($panoptes_current_user);
         $userPrefs = new userPrefs($this->db);
         $userPrefs->db = $this->db;
         $data = $userPrefs->getAllPrefs($user->id);
         // load any default prefs that haven't been overriden
         if (!$userPrefs->getPref($user->id, 'general', 'general_prefs_chart_theme')) {
             $data[] = array('pref_name' => 'general_prefs_chart_theme', 'pref_scope' => 'general', 'pref_value' => $panoptes->config()->getConfigValue('web.default_chart_theme'));
         }
     } catch (Exception $e) {
         return array('result' => 'failure', 'error' => $e->getMessage());
     }
     return array('result' => $result, 'error' => $error, 'data' => $data);
 }
Exemple #4
0
$CONF['log']['logActions'] = array(2 => "Pilot", 4 => "Waypoint", 8 => "NAC / Club  / Group", 16 => "League / Event ", 32 => "Area  ");
$CONF['log']['logActionsType'] = array(1 => "Add", 2 => "Edit", 4 => "Delete", 8 => "Score", 16 => "Rename TrackLog", 32 => "Create Map");
$CONF['comments']['guestComments'] = true;
// we over ride the config values with our custom ones here
@(include_once dirname(__FILE__) . "/site/config_custom.php");
@(include_once dirname(__FILE__) . "/site/config_ranks.php");
@(include_once dirname(__FILE__) . "/site/config_servers.php");
$CONF_tmp_path = $CONF_abs_path . '/' . $CONF['paths']['tmpigc'];
// was  '/files/tmp';
// this loads predefined settings for userDB and  settings
// to bridge to the users table of different forum/portal/cms systems
require_once dirname(__FILE__) . "/site/predefined/{$opMode}/config.php";
setLeonardoPaths();
// time to load the user prefs from cookie
require_once dirname(__FILE__) . "/CL_user_prefs.php";
$PREFS = new userPrefs();
if (!$PREFS->getFromCookie() || !$PREFS->themeName || !$PREFS->itemsPerPage) {
    // echo "NO user prefs cookie found : puting default values<br>";
    $PREFS->themeName = $CONF_defaultThemeName;
    $PREFS->language = $nativeLanguage;
    $PREFS->viewCat = $CONF_default_cat_view;
    $PREFS->viewCountry = 0;
    $PREFS->itemsPerPage = $CONF_itemsPerPage;
    $PREFS->metricSystem = $CONF_metricSystem;
    $PREFS->nameOrder = $CONF_defaultNameOrder;
    $PREFS->googleMaps = $CONF_googleMapsShow;
    $PREFS->useEditor = $CONF['default_user_prefs']['useEditor'];
}
if ($PREFS->showNews == -1) {
    $PREFS->showNews = $CONF['userPrefs']['defaults']['showNews'];
}
 /**
  * renderUserWidget
  *
  * @param entry dashboardUserWidget object
  * @throws PDOException
  * @return none
  */
 public function renderUserWidget(dashboardUserWidget $entry)
 {
     global $panoptes_current_user;
     try {
         $rtn = array();
         $rtn['type'] = 'js';
         // make sure rrd extension is loaded
         if (!extension_loaded('RRDTool') && function_exists('rrd_fetch')) {
             // throw error for now
             // could just run cli though
             $rtn['error'] = 'php rrd extension missing';
             return $rtn;
         }
         require_once dirname(realpath(__FILE__)) . '/../panoptes.php';
         require_once dirname(realpath(__FILE__)) . '/../userEntry.php';
         require_once dirname(realpath(__FILE__)) . '/../userPrefs.php';
         $pan = new panoptes();
         // load user prefs for chart theme
         $user = new userEntry();
         $user->db = $this->db;
         $user->getByName($panoptes_current_user);
         $userPrefs = new userPrefs($this->db);
         $userPrefs->db = $this->db;
         $theme = $userPrefs->getPref($user->id, 'general', 'general_prefs_chart_theme');
         if (is_null($theme)) {
             $theme = $pan->config()->getConfigValue('web.default_chart_theme');
         }
         // draw rrd graph from params field of widget render last 30 minutes
         $start = sprintf("--start=%d", time() - 1800);
         $prms = $entry->params;
         $data = array();
         $rrd_params = array();
         $devices = array();
         $count = 0;
         $max_y = 0;
         foreach ($prms as $a) {
             preg_match('/^(\\d+):(.*)/', $a, $matches);
             $dev = $pan->getDevice($matches[1]);
             $short_name = preg_replace('/([^\\.]+)\\..*/', '\\1', $dev->name);
             array_push($devices, $short_name);
             $rrd_info = $pan->getRRDInfo($matches[1], $matches[2], false, $count);
             $ret = rrd_fetch($rrd_info['rrd_file'], array("AVERAGE", $start), 2);
             if (!is_array($ret)) {
                 $rtn['error'] = rrd_error();
                 return $rtn;
             } else {
                 // parse response and load data for this device into array
                 $data['_']['step'] = $ret['step'];
                 $data['_']['start'] = $ret['start'];
                 $data['_']['end'] = $ret['end'];
                 $data[$short_name] = array();
                 foreach ($ret['data'] as $k => $v) {
                     if ($v == 'NAN') {
                         $v = 0;
                     }
                     $v = round($v, 5);
                     // keep track of max value for y-axis
                     if ($v > $max_y) {
                         $max_y = $v;
                     }
                     $data[$short_name][] = array('x' => $data['_']['start'] + $k * $data['_']['step'], 'y' => $v, 'tooltip' => $v);
                 }
                 $data['_'][$short_name]['info'] = $rrd_info['datas'];
             }
             $count++;
         }
         // make title out of device names
         $devices = array_unique($devices);
         if (count($devices) > 1) {
             $last = array_pop($devices);
             $first = implode(',', $devices);
             $title = $first . ' & ' . $last;
         } else {
             $title = $devices[0];
         }
         // select a font size that will fit number of characters within 200px
         // div on most user screens
         // assume avg is 90 px/inch
         // 200px = 2.22 in
         // 72 pts/in
         // pts avail = 72 / 2.22 = 32
         $font_width = round(32 / strlen($title));
         // send back code to draw chart
         $ret = "var dv = document.createElement('div'); dv.id = '" . $entry->id . "' + '_perf_div'; dv.style.height = '175px'; dv.style.width = '200px'; node.appendChild(dv); var chrt = new dojox.charting.Chart2D('" . $entry->id . "_perf_div', { title: '" . $title . "', titleGap: 5, titleFont: 'normal normal bold " . $font_width . "pt Helvetica' }); chrt.setTheme(dojox.charting.themes." . $theme . "); chrt.addPlot('default', { type: 'Lines', markers: true }); f = new dojox.charting.action2d.Tooltip(chrt, 'default'); chrt.addAxis('x', { natural: true, htmlLabels: true, labelFunc: function(value) { var v = value; var dt = new Date(); dt.setTime(v.replace(/\\,/g,'') * 1000); var h = dt.getHours(); h = (h < 10 ? '0' + h : h); var m = dt.getMinutes(); m = (m < 10 ? '0' + m : m); return(h + ':' + m); }, microTicks: false, min: " . $data['_']['start'] . ", max: " . $data['_']['end'] . ", minorTickSpan: " . $data['_']['step'] . " }); chrt.addAxis('y', { vertical: true, min: 0, max: " . $max_y . ", includeZero: true, title: '" . $rrd_info['datas'][0]['vlabel'] . "', font: 'normal normal bold 8pt Helvetica', titleGap: 5 });";
         // go through each requested rrd and add series to chart
         foreach ($data as $k => $v) {
             if ($k != '_') {
                 $ret .= " var foo = " . json_encode($v) . "; chrt.addSeries('" . $data['_'][$k]['info'][0]['label'] . "', foo);";
             }
         }
         $ret .= " f = new dojox.charting.action2d.Tooltip(chrt, 'default'); chrt.render(); var w_lg_dv = document.createElement('div'); w_lg_dv.id = '" . $entry->id . "_legend_div'; w_lg_dv.style.height = '25px'; w_lg_dv.style.width = '200px'; node.appendChild(w_lg_dv); f = new dojox.charting.widget.Legend({ chart: chrt }, '" . $entry->id . "_legend_div');";
         $rtn['value'] = $ret;
     } catch (PDOException $e) {
         throw $e;
     }
     return $rtn;
 }