// Login/logout // // Saves the URL used to access the website if (!isset($_SESSION['first_input']) && isset($input['action']) && $input['action'] != 'logout' && $input['action'] != 'login' && $input['action'] != 'client_trace') { $_SESSION['first_input'] = array_merge($_GET, $_POST); } // Saves user's web browser information if (!isset($_SESSION['browser_name']) || !isset($_SESSION['browser_version']) || !isset($_SESSION['user_os'])) { Autoloader::register(); $browser = new Browser(); $os = new Os(); $_SESSION['browser_name'] = $browser->getName(); $_SESSION['browser_version'] = $browser->getVersion(); $user_agent = $browser->getUserAgent(); $_SESSION['browser_full'] = $user_agent->getUserAgentString(); $_SESSION['user_os'] = $os->getName(); } // If we're not logged in, we try to log in or display the login form if (!user_logged_in()) { // if the url contains the parameter 'anon' the session is assumed as anonymous if (isset($input['anon']) && $input['anon'] == true) { user_anonymous_session(); } else { if (isset($input['action']) && $input['action'] == 'login') { // The user continues without any authentication if (isset($_POST['anonymous_session'])) { user_anonymous_session(); // The user want to authenticate } else { if (!isset($input['login']) || !isset($input['passwd'])) { error_print_message(template_get_message('empty_username_password', get_lang()));
function showOutputStatisticsPlatform() { if (loadvar(DATA_OUTPUT_TYPEDATA) != "") { if (loadvar(DATA_OUTPUT_TYPEDATA) == DATA_TEST) { $_SESSION[SURVEY_EXECUTION_MODE] = SURVEY_EXECUTION_MODE_TEST; } else { $_SESSION[SURVEY_EXECUTION_MODE] = SURVEY_EXECUTION_MODE_NORMAL; } } else { $_SESSION[SURVEY_EXECUTION_MODE] = SURVEY_EXECUTION_MODE_NORMAL; } $survey = new Survey($_SESSION['SUID']); $headers[] = array('link' => setSessionParamsHref(array('page' => 'sysadmin.output'), Language::headerOutput()), 'label' => Language::headerOutputData()); $headers[] = array('link' => setSessionParamsHref(array('page' => 'sysadmin.output.statistics'), Language::headerOutputStatistics()), 'label' => Language::headerOutputStatistics()); $headers[] = array('link' => '', 'label' => Language::headerOutputStatisticsPlatform()); $returnStr = $this->showOutputHeader($headers); $surveys = new Surveys(); $surveys = $surveys->getSurveys(); $returnStr .= '<form id=surveyform method="post">'; $returnStr .= '<span class="label label-default">' . Language::headerOutputStatisticsPlatform() . '</span>'; $returnStr .= '<div class="well well-sm">'; $returnStr .= '<table>'; //if (sizeof($surveys) > 0) { $returnStr .= $this->displayComboBox(); $returnStr .= '<tr><td>' . Language::labelOutputScreenDumpsSurvey() . '</td><td>' . $this->displaySurveys("survey", "survey", $_SESSION["SUID"]) . '</td></tr>'; $returnStr .= '<script type=text/javascript> $(document).ready(function(){ $("#survey").on("change", function(event) { document.getElementById("surveyform").submit(); }); }); </script>'; //} $returnStr .= '<tr><td>' . Language::labelOutputDataType() . '</td><td>'; $returnStr .= "<select id='typedata' class='selectpicker show-tick' name=" . DATA_OUTPUT_TYPEDATA . ">"; //$returnStr .= "<option></option>"; $selected = array('', ''); if (loadvar(DATA_OUTPUT_TYPEDATA) != "") { $selected[loadvar(DATA_OUTPUT_TYPEDATA)] = "selected"; } //print_r($selected); $returnStr .= "<option " . $selected[0] . " value=" . DATA_REAL . ">" . Language::optionsDataReal() . "</option>"; $returnStr .= "<option " . $selected[1] . " value=" . DATA_TEST . ">" . Language::optionsDataTest() . "</option>"; $returnStr .= "</select>"; $returnStr .= "</td></tr>"; $returnStr .= '<script type=text/javascript> $(document).ready(function(){ $("#typedata").on("change", function(event) { document.getElementById("surveyform").submit(); }); }); </script>'; $returnStr .= '</table><br/>'; $returnStr .= "</form>"; // high chart $returnStr .= '<script src="js/highcharts.js"></script>'; $returnStr .= '<script src="js/modules/exporting.js"></script>'; $returnStr .= '<script src="js/export-csv.js"></script>'; $data = new Data(); $data = $data->getPlatformData($_SESSION['SUID']); // determine devices $devices = array(); require_once "detection_bootstrap.php"; $detect = new Mobile_Detect(); $total = sizeof($data); if ($total == 0) { $total = 1; } $mobilecount = 0; $tabletcount = 0; $othercount = 0; $browsercounts = array(); $oscounts = array(); foreach ($data as $d) { $detect->setUserAgent($d); if ($detect->isMobile() && !$detect->isTablet()) { $mobilecount++; } else { if ($detect->isTablet()) { $tabletcount++; } else { $othercount++; } } $browser = new Browser($d); $name = $browser->getName(); if ($name == 'Navigator') { // rename if android mobile browser $name = "Android browser"; } if (isset($browsercounts[ucwords($name)])) { $browsercounts[ucwords($name)]++; } else { $browsercounts[ucwords($name)] = 1; } $os = new Os($d); $name = $os->getName(); if (isset($oscounts[ucwords($name)])) { $oscounts[ucwords($name)]++; } else { $oscounts[ucwords($name)] = 1; } } // high chart for device pie chart $returnStr .= '<div id="chart1" style="min-width: 310px; height: 400px; margin: 0 auto"></div>'; $returnStr .= $this->getDeviceData($survey->getName(), '{name: "Mobile", y: ' . round($mobilecount / $total, 2) * 100 . '}, {name: "Tablet", y: ' . round($tabletcount / $total, 2) * 100 . '}, {name: "Laptop/desktop/other", y: ' . round($othercount / $total, 2) * 100 . '}'); // high chart for browsers $returnStr .= '<br/><br/><div id="chart2" style="min-width: 310px; height: 400px; margin: 0 auto"></div>'; $browsers = ''; //print_r($browsercounts); ksort($browsercounts); foreach ($browsercounts as $b => $count) { if ($browsers != '') { $browsers .= ","; } $browsers .= '{name: "' . $b . '", y: ' . round($count / $total, 2) * 100 . '}'; } $returnStr .= $this->getBrowserData($survey->getName(), $browsers); // high chart for operating system $returnStr .= '<br/><br/><div id="chart3" style="min-width: 310px; height: 400px; margin: 0 auto"></div>'; $os = ''; //print_r($oscounts); ksort($oscounts); foreach ($oscounts as $b => $count) { if ($os != '') { $os .= ","; } $os .= '{name: "' . $b . '", y: ' . round($count / $total, 2) * 100 . '}'; } $returnStr .= $this->getOSData($survey->getName(), $os); // $returnStr .= '</div> </div>'; //container and wrap $returnStr .= $this->showFooter(false); return $returnStr; }
public function removeOsFromOsGroups(Os &$os) { if ($os == null || $os->getId() == -1) { Utils::log(LOG_DEBUG, "Exception", __FILE__, __LINE__); throw new Exception("Os object is not valid or Os.id is not set"); } Utils::log(LOG_DEBUG, "Removing the os from all os groups [os=" . $os->getName() . "]", __FILE__, __LINE__); $this->getPakiti()->getDao("OsGroup")->removeOsFromOsGroups($os->getId()); }
public function update(Os &$os) { $this->db->query("update Os set\n \tname='" . $this->db->escape($os->getName()) . "\n where id=" . $os->getId()); }