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());
 }
Beispiel #2
0
 public function setFileContent($file, $content)
 {
     $addToVcs = !file_exists($this->rootPath . $file);
     parent::setFileContent($file, $content);
     if ($addToVcs) {
         $this->launchCommand("add {$file}");
     }
 }
Beispiel #3
0
 /**
  * Determine if the user's operating system is BeOS.
  *
  * @param Os $os
  * @param UserAgent $userAgent
  *
  * @return bool
  */
 private static function checkBeOS(Os $os, UserAgent $userAgent)
 {
     if (stripos($userAgent->getUserAgentString(), 'BeOS') !== false) {
         $os->setVersion($os::VERSION_UNKNOWN);
         $os->setName($os::BEOS);
         return true;
     }
     return false;
 }
 public function osdeleteAction()
 {
     if ($this->_hasParam('id') && $this->tplVars['lvals']['canDelete']) {
         include_once 'os.php';
         $os = new Os();
         $os->delete($this->_getParam('id'));
         unset($os);
     }
     $this->_redirect('/products/os/');
 }
Beispiel #5
0
require_once 'lib_acl.php';
$input = array_merge($_GET, $_POST);
template_repository_path($template_folder . get_lang());
template_load_dictionnary('translations.xml');
//
// 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'])) {
Beispiel #6
0
 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 getHostFromReport(Host &$host, &$pkgs)
 {
     Utils::log(LOG_DEBUG, "Getting the host from the report", __FILE__, __LINE__);
     if ($host == null) {
         Utils::log(LOG_DEBUG, "Exception", __FILE__, __LINE__);
         throw new Exception("Host object is not valid or Host.id is not set");
     }
     # Get the osId
     $host->setOsName($this->guessOs($host, $pkgs));
     $osDao = $this->getPakiti()->getDao("Os");
     $osId = $osDao->getIdByName($host->getOsName());
     if ($osId == -1) {
         # Os is missing, so store it
         $os = new Os();
         $os->setName($host->getOsName());
         $osDao->create($os);
         $osId = $os->getId();
     } else {
         $os = $osDao->getById($osId);
     }
     $host->setOsId($osId);
     $host->setOs($os);
     # Get the archId
     $archDao = $this->getPakiti()->getDao("Arch");
     $archId = $archDao->getIdByName($host->getArchName());
     if ($archId == -1) {
         # Arch is missing, so store it
         $arch = new Arch();
         $arch->setName($host->getArchName());
         $archDao->create($arch);
         $archId = $arch->getId();
     } else {
         $arch = $archDao->getById($archId);
     }
     $host->setArchId($archId);
     $host->setArch($arch);
     # Get the domainId
     # Guess the domain name from the reporterHostname
     $domainName = $this->guessDomain($host->getHostname());
     $domainDao = $this->getPakiti()->getDao("Domain");
     $domainId = $domainDao->getIdByName($domainName);
     if ($domainId == -1) {
         # Domain is missing, so store it
         $domain = new Domain();
         $domain->setName($domainName);
         $domainDao->create($domain);
         $domainId = $domain->getId();
     } else {
         $domain = $domainDao->getById($domainId);
     }
     $host->setDomainId($domainId);
     $host->setDomain($domain);
     # Try to find the host in the DB
     $host->setId($this->getHostId($host));
     if ($host->getId() != -1) {
         # Update entries
         $this->getPakiti()->getDao("Host")->update($host);
         return $host;
     } else {
         return $this->storeHostFromReport($host);
     }
 }
Beispiel #8
0
 public function removeOsFromSubSourceDef(ISubSourceDef &$subSourceDef, Os $os)
 {
     $this->_db->query("delete from VdsSourceDefOs wherer vdsSubSourceId=" . $this->_db->escape($subSourceDef->getId()) . " and osId=" . $this->_db->escape($os->getId()) . "");
 }
Beispiel #9
0
 public function delete(Os &$os)
 {
     $this->db->query("delete from Os where id=" . $os->getId());
 }