0){ $this->anketa = $anketa; SurveyStatusProfiles :: Init($this->anketa); } else{ echo 'Invalid Survey ID!'; exit(); } } function setParaGraphFilter($pgf) { $this->paraGraph_filter = $pgf; } function DisplayParaGraph(){ global $lang; global $site_path; global $admin_type; // Nastavimo filter $this->paraGraphSetFilter(); // Popravimo stare ankete -> v bazo vnesemo browser, os, device, popravljen js $this->paraGraphFixOld(); // Zberemo podatke vseh userjev $paraData = $this->collectParaGraphDataNew(); echo '
'.$lang['srv_para_graph_text'].'
'; // PC, tablica, mobi echo ''; // Browser echo ''; // Operacijski sistem echo ''; } function collectParaGraphData(){ global $lang; SurveySetting::getInstance()->Init($this->anketa); // Preberemo tabelo s podatki za izbrane filtre (ce ze obstaja) $filterString = implode('_', $this->paraGraph_filter); $paraData = unserialize(SurveySetting::getInstance()->getSurveyMiscSetting('para_graph_data_'.$filterString)); // Pogledamo kdaj je bila kreirana datoteka (ce imamo nove podatke) $sqlTime = sisplet_query("SELECT UNIX_TIMESTAMP(last_update) AS last_update FROM srv_data_files WHERE sid='".$this->anketa."'"); $rowTime = mysqli_fetch_array($sqlTime); $time = $rowTime['last_update']; $status = ($this->paraGraph_filter['status'] == 1) ? ' AND last_status>\'4\'' : ' AND last_status>\'2\''; $sqlu = sisplet_query("SELECT useragent FROM srv_user WHERE ank_id='".$this->anketa."' ".$status." AND preview='0' AND deleted='0'"); // Ce se nimamo shranjenih izracunov (timestamp datoteke se ne ujema), racunamo na novo if(!isset($paraData['allCount']) || $paraData['timestamp'] != $time || $_GET['refresh'] == 1){ $sqlu2 = sisplet_query("SELECT id FROM srv_user WHERE ank_id='".$this->anketa."' AND last_status>'2' AND u.preview='0' AND u.deleted='0'"); $paraData = array( 'timestamp' => $time, 'unfilteredCount' => mysqli_num_rows($sqlu2), 'allCount' => 0, 'pcCount' => 0, 'mobiCount' => 0, 'tabletCount' => 0, 'robotCount' => 0, 'browser' => array(), 'os' => array() ); $detect = New Mobile_Detect(); // Loop cez vse ustrezne respondente while($rowu = mysqli_fetch_array($sqlu)){ // Detect mobilnikov in tablic $detect->setUserAgent($rowu['useragent']); // Detect z browscap $browserDetect = get_browser($rowu['useragent'], true); // Filtriranje po napravi if( ($this->paraGraph_filter['pc'] != 0 || $detect->isMobile() || $browserDetect['crawler'] == 1) && ($this->paraGraph_filter['tablet'] != 0 || !$detect->isTablet()) && ($this->paraGraph_filter['mobi'] != 0 || !$detect->isMobile() || $detect->isTablet()) && ($this->paraGraph_filter['robot'] != 0 || $browserDetect['crawler'] != 1) ){ // Naprava if($detect->isMobile()) { if($detect->isTablet()) $paraData['tabletCount']++; else $paraData['mobiCount']++; } elseif($browserDetect['crawler'] == 1) $paraData['robotCount']++; else $paraData['pcCount']++; // Browser if($browserDetect['browser'] == 'Default Browser') $browser = $lang['srv_para_graph_other']; else $browser = $browserDetect['browser'].' '.$browserDetect['version']; $paraData['browser'][$browser]++; // OS if($browserDetect['platform'] == 'unknown') $os = $lang['srv_para_graph_other']; else $os = $browserDetect['platform']; $paraData['os'][$os]++; $paraData['allCount']++; } } // Na koncu shranimo nove izracune v bazo SurveySetting::getInstance()->setSurveyMiscSetting('para_graph_data_'.$filterString, serialize($paraData)); } return $paraData; } function collectParaGraphDataNew(){ global $lang; $paraData = array( /*'timestamp' => $time,*/ 'unfilteredCount' => 0, 'allCount' => 0, 'pcCount' => 0, 'mobiCount' => 0, 'tabletCount' => 0, 'robotCount' => 0, 'browser' => array(), 'os' => array() ); // Filter za status $status_filter = ($this->paraGraph_filter['status'] == 1) ? ' AND last_status>\'4\' AND lurker=\'0\'' : ' AND last_status>\'2\''; // Filter za napravo $device_filter = ' AND ('; $device_filter .= ($this->paraGraph_filter['pc'] != 0) ? 'device=\'0\' OR ' : ''; $device_filter .= ($this->paraGraph_filter['mobi'] != 0) ? 'device=\'1\' OR ' : ''; $device_filter .= ($this->paraGraph_filter['tablet'] != 0) ? 'device=\'2\' OR ' : ''; $device_filter .= ($this->paraGraph_filter['robot'] != 0) ? 'device=\'3\' OR ' : ''; $device_filter = substr($device_filter, 0, -4) . ')'; // Prestejemo vse $sql = sisplet_query("SELECT id FROM srv_user WHERE ank_id='".$this->anketa."' AND last_status>'2' AND useragent!='' AND preview='0' AND deleted='0'"); $paraData['unfilteredCount'] = mysqli_num_rows($sql); // Prestejemo vse filtrirane $sql = sisplet_query("SELECT id FROM srv_user WHERE ank_id='".$this->anketa."' ".$status_filter." ".$device_filter." AND useragent!='' AND preview='0' AND deleted='0'"); $paraData['allCount'] = mysqli_num_rows($sql); // Prestejemo naprave $sql = sisplet_query("SELECT device, count(*) FROM srv_user WHERE ank_id='".$this->anketa."' ".$status_filter." ".$device_filter." AND useragent!='' AND preview='0' AND deleted='0' GROUP BY device"); while($row = mysqli_fetch_array($sql)){ if($row['device'] == 0) $paraData['pcCount'] = $row['count(*)']; elseif($row['device'] == 1) $paraData['mobiCount'] = $row['count(*)']; elseif($row['device'] == 2) $paraData['tabletCount'] = $row['count(*)']; elseif($row['device'] == 3) $paraData['robotCount'] = $row['count(*)']; } // Prestejemo browserje $sql = sisplet_query("SELECT browser, count(*) FROM srv_user WHERE ank_id='".$this->anketa."' ".$status_filter." ".$device_filter." AND useragent!='' AND preview='0' AND deleted='0' AND browser!='' GROUP BY browser"); while($row = mysqli_fetch_array($sql)){ $paraData['browser'][$row['browser']] = $row['count(*)']; } // Prestejemo os $sql = sisplet_query("SELECT os, count(*) FROM srv_user WHERE ank_id='".$this->anketa."' ".$status_filter." ".$device_filter." AND useragent!='' AND preview='0' AND deleted='0' AND os!='' GROUP BY os"); while($row = mysqli_fetch_array($sql)){ $paraData['os'][$row['os']] = $row['count(*)']; } return $paraData; } function paraGraphSetFilter(){ // Nastavimo filter po statusu (vsi ali ustrezni) $this->paraGraph_filter['status'] = (SurveyStatusProfiles::getDefaultProfile() == 2) ? 1 : 0; /*if(isset($_GET['status'])) $this->paraGraph_filter['status'] = $_GET['status']; else $this->paraGraph_filter['status'] = 0;*/ // Nastavimo filter po napravi (pc, mobi, tablica, crawler) $this->paraGraph_filter['pc'] = (isset($_GET['pc'])) ? $_GET['pc'] : 1; $this->paraGraph_filter['tablet'] = (isset($_GET['tablet'])) ? $_GET['tablet'] : 1; $this->paraGraph_filter['mobi'] = (isset($_GET['mobi'])) ? $_GET['mobi'] : 1; $this->paraGraph_filter['robot'] = (isset($_GET['robot'])) ? $_GET['robot'] : 1; } // Se pozene za stare ankete ki imajo v bazi samo useragent (samo prvic ko gledamo staro anketo) oz. ce hocemo na novo zracunat vse ($_GET['refresh'] == 1) function paraGraphFixOld(){ global $lang; if(isset($_GET['refresh']) && $_GET['refresh'] == 1) $sqlu = sisplet_query("SELECT id, useragent FROM srv_user WHERE ank_id='".$this->anketa."' AND last_status>'2' AND useragent!='' AND preview='0' AND deleted='0'"); else $sqlu = sisplet_query("SELECT id, useragent FROM srv_user WHERE ank_id='".$this->anketa."' AND last_status>'2' AND useragent!='' AND browser='' AND preview='0' AND deleted='0'"); if(mysqli_num_rows($sqlu) > 0){ $detect = New Mobile_Detect(); $cnt = 0; while($rowu = mysqli_fetch_array($sqlu)){ // Detect mobilnikov in tablic $detect->setUserAgent($rowu['useragent']); // Detect z browscap $browserDetect = get_browser($rowu['useragent'], true); // Naprava if($detect->isMobile()) { if($detect->isTablet()) $device = 2; else $device = 1; } elseif($browserDetect['crawler'] == 1) $device = 3; else $device = 0; // Browser if($browserDetect['browser'] == 'Default Browser') $browser = $lang['srv_para_graph_other']; else $browser = $browserDetect['browser'].' '.$browserDetect['version']; // OS if($browserDetect['platform'] == 'unknown') $os = $lang['srv_para_graph_other']; else $os = $browserDetect['platform']; $sqlu2 = sisplet_query("UPDATE srv_user SET device='$device', browser='$browser', os='$os' WHERE ank_id='".$this->anketa."' AND id='$rowu[id]'"); if (!$sqlu2) echo mysqli_error($GLOBALS['connect_db']); $cnt++; } echo '