From 06653abddb801782ef2fc9c7bd2ea097fd4c61c6 Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Thu, 28 Nov 2019 11:44:18 +0530 Subject: added static files in app --- website/static/awstats/awstats.php | 84 ++++++++++++ website/static/awstats/class.awfile.php | 221 ++++++++++++++++++++++++++++++++ 2 files changed, 305 insertions(+) create mode 100644 website/static/awstats/awstats.php create mode 100644 website/static/awstats/class.awfile.php (limited to 'website/static/awstats') diff --git a/website/static/awstats/awstats.php b/website/static/awstats/awstats.php new file mode 100644 index 0000000..cb3a707 --- /dev/null +++ b/website/static/awstats/awstats.php @@ -0,0 +1,84 @@ +Error()) die($aw->GetError()); + $total_visit += $aw->GetVisits(); + $unique_visit += $aw->GetUniqueVisits(); + // echo " Unique" . $unique_visit . "
"; + foreach ($aw->GetDays() as $day=>$pages) + $page_loads += $pages; + + } + } + } + $output = array('unique_visit' => $unique_visit, 'total_visit' => $total_visit, 'total_page_loads' => $page_loads); +// var_dump($output); + echo json_encode($output); + return $output; +/* + $aw = new awfile($file); + if ($aw->Error()) die($aw->GetError()); + + echo "Showing contents [".$file."]
"; + + echo "The site first visit in the month: ".$aw->GetFirstVisit()."

"; + echo "Total visits this month: ".$aw->GetVisits()."

"; + echo "Total unique visits this month: ".$aw->GetUniqueVisits()."

"; + /*echo "Pages viewed / hours:
"; + foreach ($aw->GetHours() as $hour=>$pages) + echo "    ".str_pad($hour, 2, "0", STR_PAD_LEFT).": ".$pages." pages viewed.
"; + + echo "Pages viewed / days:
"; + foreach ($aw->GetDays() as $day=>$pages) + echo "    ".$day.": ".$pages." pages viewed.
"; + echo "
"; + + $betterDay = $aw->GetBetterDay(); + echo "The day with more visitors(".$betterDay[1].") was the ".$betterDay[0].".

"; + + echo "hits / os:
"; + foreach ($aw->GetOs() as $os=>$hits) + echo "    ".$os.": ".$hits." hits.
"; + echo "
"; + + echo "hits / browser:
"; + foreach ($aw->GetBrowser() as $browser=>$hits) + echo "    ".$browser.": ".$hits." hits.
"; + echo "
"; + + echo "Distinct Referers:
"; + foreach ($aw->GetReferers() as $referer=>$hits) + echo "    ".$referer.": ".$hits." hits.
"; + echo "
"; + + echo "Visits / Session Ranges:
"; + foreach ($aw->GetRanges() as $range=>$visits) + echo "    ".$range.": ".$visits." visits.
"; + echo "
";*/ + +?> diff --git a/website/static/awstats/class.awfile.php b/website/static/awstats/class.awfile.php new file mode 100644 index 0000000..79ed4d0 --- /dev/null +++ b/website/static/awstats/class.awfile.php @@ -0,0 +1,221 @@ +"file not found.", + 2=>"File not readable"); + var $_positions = array( + "POS_GENERAL"=>0, + "POS_TIME"=>0, + "POS_OS"=>0, + "POS_BROWSER"=>0, + "POS_PAGEREFS"=>0, + "POS_DAY"=>0, + "POS_SESSION"=>0, + "POS_SIDER"=>0); + + function awfile($fich) { + if (!file_exists($fich)) + $this->error = 1; + else { + $this->fich = $fich; + $this->__proc(); + } + } + + function __proc() { + if (!$fd = fopen($this->fich,"r")) + $this->error = 2; + else { + + do { + $str = trim(fgets($fd)); + if ($str{0} ==" ") continue; + + list($elem,$pos) = explode(" ",$str); + if (isset($this->_positions[$elem])) + $this->_positions[$elem] = $pos; + else continue; + } while ($str!="END_MAP"); + + + fseek($fd,$this->_positions["POS_GENERAL"]); + list(,$n) = explode(" ",trim(fgets($fd))); + $pendientes = 3; + while ($n>0) { + list($elem,$num) = explode(" ",trim(fgets($fd))); + switch($elem) { + case "FirstTime": + $this->first_visit = $num; + $pendientes--; + break; + case "TotalVisits": + $this->visits = $num; + $pendientes--; + break; + + case "TotalUnique": + $this->uniquevisits = $num; + $pendientes--; + break; + default: continue; + } + if ($pendientes==0) break; + $n--; + } + + + fseek($fd,$this->_positions["POS_TIME"]); + list(,$n) = explode(" ",trim(fgets($fd))); + while ($n>0) { + list($elem,$num,,,,,) = explode(" ",trim(fgets($fd))); + $this->aHours[$elem] = $num; + $n--; + } + + fseek($fd,$this->_positions["POS_OS"]); + list(,$n) = explode(" ",trim(fgets($fd))); + while ($n>0) { + list($elem,$num) = explode(" ",trim(fgets($fd))); + $this->aOs[$elem] = $num; + $n--; + } + + fseek($fd,$this->_positions["POS_BROWSER"]); + list(,$n) = explode(" ",trim(fgets($fd))); + while ($n>0) { + list($elem,$num) = explode(" ",trim(fgets($fd))); + $this->aBrowser[$elem] = $num; + $n--; + } + + fseek($fd,$this->_positions["POS_PAGEREFS"]); + list(,$n) = explode(" ",trim(fgets($fd))); + while ($n>0) { + list($elem,$num,) = explode(" ",trim(fgets($fd))); + $this->aReferes[$elem] = $num; + $n--; + } + + fseek($fd,$this->_positions["POS_DAY"]); + list(,$n) = explode(" ",trim(fgets($fd))); + while ($n>0) { + list($elem,,,,$num) = explode(" ",trim(fgets($fd))); + $this->aDays[$elem] = $num; + $n--; + } + + fseek($fd,$this->_positions["POS_SESSION"]); + list(,$n) = explode(" ",trim(fgets($fd))); + while ($n>0) { + list($elem,$num) = explode(" ",trim(fgets($fd))); + $this->aRange[$elem] = $num; + $n--; + } + + fseek($fd,$this->_positions["POS_SIDER"]); + list(,$n) = explode(" ",trim(fgets($fd))); + while ($n>0) { + list($elem,$num,,,) = explode(" ",trim(fgets($fd))); + $this->aSections[$elem] = $num; + $n--; + } + + } + + } + + + function GetFirstVisit() { + return $this->first_visit; + } + + function GetVisits() { + return $this->visits; + } + + function GetUniqueVisits() { + return $this->uniquevisits; + } + + function GetHours() { + return $this->aHours; + } + + function GetDays() { + return $this->aHours; + } + + function GetOs() { + return $this->aOs; + } + + function GetBrowser() { + return $this->aBrowser; + } + + function GetReferers() { + return $this->aReferes; + } + + function GetRanges() { + return $this->aRange; + } + + function GetSections() { + return $this->aSections; + } + + function Error() { + return $this->error; + } + + function GetError() { + return $this->ErrorStr[$this->error]; + } + + function GetBetterDay() { + $max = 0; + foreach ($this->aDays as $day => $num) { + if ($num>$max) { + $max = $num; + $date = $day; + } + } + return array($date,$max); + } + +} + +?> -- cgit