array( 'text' => $this->renderChart(), 'caption' => $tp->toGlyph('fa-signal').' '.LAN_STATS), 1 => array('caption' =>$tp->toGlyph('fa-user').' '.LAN_ONLINE.' ('.$this->renderOnlineUsers('count').')', 'text'=>$this->renderOnlineUsers()), 2 => array( 'text' => $this->registered('user_new_thismonth'), 'caption' => $this->title), ); return $config; } private function renderChart() { if (e107::isInstalled('log')) { return $this->renderStats('log'); } else { return $this->renderStats('demo'); } } private function getStats($type) { if($type == 'demo') { $data = array(); $months = e107::getDate()->terms('month'); foreach($months as $month) { // We need only the first 6 months for demo. if (!empty($data['labels']) && count($data['labels']) >= 6) { continue; } $data['labels'][] = $month; } $data['datasets'][] = array( 'fillColor' => "rgba(220,220,220,0.5)", 'strokeColor' => "rgba(220,220,220,1)", 'pointColor ' => "rgba(220,220,220,1)", 'pointStrokeColor' => "#fff", 'data' => array(65,59,90,81,56,55,40), 'title' => ADLAN_168// "Visits" ); $data['datasets'][] = array( 'fillColor' => "rgba(151,187,205,0.5)", 'strokeColor' => "rgba(151,187,205,1)", 'pointColor ' => "rgba(151,187,205,1)", 'pointStrokeColor' => "#fff", 'data' => array(28,48,40,19,96,27,100), 'title' => ADLAN_169 //"Unique Visits" ); return $data; } $sql = e107::getDB(); $td = date("Y-m-j", time()); $dayarray[$td] = array(); $pagearray = array(); $qry = " SELECT * from #logstats WHERE log_id REGEXP('[[:digit:]]+\-[[:digit:]]+\-[[:digit:]]+') ORDER BY CONCAT(LEFT(log_id,4), SUBSTRING(log_id, 6, 2), LPAD(SUBSTRING(log_id, 9), 2, '0')) DESC LIMIT 0,9 "; if($amount = $sql->gen($qry)) { $array = $sql->db_getList(); $ttotal = 0; $utotal = 0; foreach($array as $key => $value) { $log_id = $value['log_id']; $log_data = $value['log_data']; // extract($value); $log_id = substr($log_id, 0, 4).'-'.substr($log_id, 5, 2).'-'.str_pad(substr($log_id, 8), 2, '0', STR_PAD_LEFT); if(is_array($log_data)) { $entries[0] = $log_data['host']; $entries[1] = $log_data['date']; $entries[2] = $log_data['os']; $entries[3] = $log_data['browser']; $entries[4] = $log_data['screen']; $entries[5] = $log_data['referer']; } else { $entries = explode(chr(1), $log_data); } $dayarray[$log_id]['daytotal'] = $entries[0]; $dayarray[$log_id]['dayunique'] = $entries[1]; unset($entries[0]); unset($entries[1]); foreach($entries as $entry) { if($entry) { list($url, $total, $unique) = explode("|", $entry); if(strstr($url, "/")) { $urlname = preg_replace("/\.php|\?.*/", "", substr($url, (strrpos($url, "/")+1))); } else { $urlname = preg_replace("/\.php|\?.*/", "", $url); } $dayarray[$log_id][$urlname] = array('url' => $url, 'total' => $total, 'unique' => $unique); if (!isset($pagearray[$urlname]['total'])) $pagearray[$urlname]['total'] = 0; if (!isset($pagearray[$urlname]['unique'])) $pagearray[$urlname]['unique'] = 0; $pagearray[$urlname]['total'] += $total; $pagearray[$urlname]['unique'] += $unique; $ttotal += $total; $utotal += $unique; } } } } $logfile = e_LOG.'logp_'.date('z.Y', time()).'.php'; // was logi_ ?? if(is_readable($logfile)) { require($logfile); } if(vartrue($pageInfo)) { foreach($pageInfo as $fkey => $fvalue) { $dayarray[$td][$fkey]['total'] += $fvalue['ttl']; $dayarray[$td][$fkey]['unique'] += $fvalue['unq']; $dayarray[$td]['daytotal'] += $fvalue['ttl']; $dayarray[$td]['dayunique'] += $fvalue['unq']; $pagearray[$fkey]['total'] += $fvalue['ttl']; $pagearray[$fkey]['unique'] += $fvalue['unq']; $ttotal += $fvalue['ttl']; $utotal += $fvalue['unq']; } } $visitors = array(); $unique = array(); ksort($dayarray); foreach($dayarray as $k=>$v) { $unix = strtotime($k); $visitors[] = intval(vartrue($v['daytotal'])); $unique[] = intval(vartrue($v['dayunique'])); $label[] = "'".date("D",$unix)."'"; } $data = array(); $data['labels'] = $label; //visitors $data['datasets'][] = array( 'fillColor' => "rgba(220,220,220,0.5)", 'strokeColor' => "rgba(220,220,220,1)", 'pointColor ' => "rgba(220,220,220,1)", 'pointStrokeColor' => "#fff", 'data' => $visitors ); //Unique Visitors $data['datasets'][] = array( 'fillColor' => "rgba(151,187,205,0.5)", 'strokeColor' => "rgba(151,187,205,1)", 'pointColor ' => "rgba(151,187,205,1)", 'pointStrokeColor' => "#fff", 'data' => $unique ); return $data; } private function renderStats($type) { $data = $this->getStats($type); $cht = e107::getChart(); $cht->setType('line'); $cht->setOptions(array( 'annotateDisplay' => true, 'annotateFontSize' => 8 )); $cht->setData($data,'canvas'); $text = $cht->render('canvas'); if($type == 'demo') { $text .= "
".LAN_TIMESTAMP." | ".LAN_USER." | ".LAN_IP." | ".LAN_PAGE." | ".LAN_AGENT." | "; $panelOnline .= (!empty($multilan)) ? "".LAN_LANG." | " : ""; $panelOnline .= "
---|---|---|---|---|---|
".e107::getDateConvert()->convert_date($val['user_currentvisit'],'%H:%M:%S')." | ".$this->renderOnlineName($val['online_user_id'])." | ".e107::getIPHandler()->ipDecode($val['user_ip'])." | ".$tp->html_truncate(basename($val['user_location']),50,"...")." | ".$this->browserIcon($val)." | "; $panelOnline .= (!empty($multilan)) ? "convert($val['user_language'])."\">".$val['user_language']." | " : ""; $panelOnline .= "