samkitano/stats

AWstats Parser for Laravel

dev-master 2017-01-04 08:46 UTC

This package is not auto-updated.

Last update: 2024-12-14 17:33:53 UTC


README

Reads your AWstats Log Files in Laravel 4 based applications.

AWstats is a well known open source application, designed to record and parse visitor statistics on your web site host. This Package makes those stats available for your Laravel application.

You should NOT use this package if you don't know what AWstats is, how it works, and how to configure it. You MUST, at the very least, know the location of your AWstats log files in your host.

Since AWstats provides a quite extensive set of data, I would recommend a visit to AWstats web page in order to get acquainted with it's features, setup and documentation.

Requirements

- PHP >= 5.4
- Laravel 4.2+.

Installation

Add the following to the require section in your composer.json file

{
    "require": {
        "samkitano/stats": "dev-master"
    }
}

Update your dependencies

$ php composer.phar update

Open app/config/app.php, and add a new item to the providers array:

'Samkitano\Stats\StatsServiceProvider',

Publish configuration file:

$ php artisan config:publish samkitano/stats

You must also Publish the assets files:

$ php artisan asset:publish samkitano/stats

Assets like AWstats native icons will be then available on your public/packages/Samkitano/Stats/assets folder.

Configuration

Package Settings are available in your app/config/packages/Samkitano/Stats/config.php file.

AWstats log files path

You must specify the path for the AWstats log files in your host. Usually something like /home/USER/tmp/awstats/ where USER should be your host's username.

'AWstats_path' => '/home/USER/tmp/awstats/',

Path to Icon images folder

Set to null if you don't intend to display AWstats native icons.

'icon_path' => 'packages/Samkitano/Stats/assets/images/icon/',

Icon Format

Set to 'url' if you want an url pointing to the icon files, or 'tag' (default) if you prefer an html tag. The html tag will include the base64 encoded icon.

'icon_format' => 'tag',

Units

Set to true if you want human readable units for bandwidths. Set to false (default) if you intend to perform further calculations based on this results.

'units' => false,

Usage

To obtain a list of available log files:

	<?php
	// Example
	$available_logs = Stats::AWlist();

Results will contain existing AWstats log files structured this way:

	\domain
		\year
			\month => file

Retrieve Data

Retrieve all available data on a given Log File

Access trough provided array list:

// Facade Example
$file = $available_logs['myhost.com']['2015']['January'];
$data = Stats::Read($file);

// Instantiation Example
$data = App::make('stats');
$data->Read($available_logs['myhost.com']['2015']['January']);

Manually, if you know which file to provide (do not include .txt extension):

// Facade Example
$file = '012015.myhost.com';
$data = Stats::Read($file);

// Instantiation Example
$data = App::make('stats');
$data->Read('awstats012015.myhost.com');

Retrieve Current month stats

// Facade Example
$data = Stats::Current()

##Methods

###General

// Retrieve General Section Data
$general = Stats::General($file);

Outputs

  • LastLine
    • Date of last record processed
    • Last record line number in last log
    • Last record offset in last log
    • Last record signature value
  • FirstTime
    • Date of first visit for history file
  • LastTime
    • Date of last visit for history file
  • LastUpdate
    • Date of last update
    • Nb of parsed records
    • Nb of parsed old records
    • Nb of parsed new records
    • Nb of parsed corrupted
    • Nb of parsed dropped
  • TotalVisits
    • Number of visits
  • TotalUnique
    • Number of unique visitors
  • MonthHostsKnown
    • Number of hosts known
  • MonthHostsUnKnown
    • Number of hosts unknown

###Misc

// Retrieve Misc Section Data
$misc = Stats::Misc($file);

Outputs

  • Rows:
    • QuickTimeSupport
    • JavaEnabled
    • JavascriptDisabled
    • PDFSupport
    • WindowsMediaPlayerSupport
    • AddToFavourites
    • RealPlayerSupport
    • TotalMisc
    • DirectorSupport
    • FlashSupport
  • Columns:
    • Misc ID
    • Pages
    • Hits
    • Bandwidth

###Time

// Retrieve Time Section Data
$time = Stats::Time($file);

Outputs

  • Rows:
    • Hour = 0 to 23
  • Columns:
    • Pages
    • Hits
    • Bandwidth
    • Not viewed Pages
    • Not viewed Hits
    • Not viewed Bandwidth
    • [Icon] Clock representing time period

###Domain

// Retrieve Domain Section Data
$domain = Stats::Domain($file);

Outputs

  • Rows:
    • Domain (up to 25 top visitor domains)
  • Columns:
    • Pages
    • Hits
    • Bandwidth
    • [Icon] country flag for known tld

###Cluster

// Retrieve Cluster Section Data
// Visit AWstats documentation page for instructions on how to configure and enalble this section
$cluster = Stats::Cluster($file);

Outputs

  • Rows:
    • Cluster ID
  • Columns:
    • Pages
    • Hits
    • Bandwidth

###Login

// Retrieve Login Section Data
$login = Stats::Login($file);

Outputs

  • Rows:
    • Login
  • Columns:
    • Pages
    • Hits
    • Bandwidth
    • Last visit

###Robot

// Retrieve Robot Section Data
$robot = Stats::Robot($file);

Outputs

  • Rows:
    • Robot ID
  • Columns:
    • Hits
    • Bandwidth
    • Last visit
    • Hits on robots.txt

###Worms

// Retrieve Worms Section Data
$worm = Stats::Worm($file);

Outputs

  • Rows:
    • Worm ID
  • Columns:
    • Hits
    • Bandwidth
    • Last visit

###Emailsender

// Retrieve Email Sender Section Data
// Visit AWstats documentation page for instructions on how to configure and enalble this section
$emailsender = Stats::Emailsender($file);

Outputs

  • Rows:
    • EMail
  • Columns:
    • Hits
    • Bandwidth
    • Last visit

###Emailreceiver

// Retrieve Email Receiver Section Data
// Visit AWstats documentation page for instructions on how to configure and enalble this section
$emailreceiver = Stats::Emailreceiver($file);

Outputs

  • Rows:
    • EMail
  • Columns:
    • Hits
    • Bandwidth
    • Last visit

###File Types

// Retrieve File Types Section Data
$file_types = Stats::Filetype($file);

Outputs

  • Rows:
    • Files type
  • Columns:
    • Hits
    • Bandwidth
    • Bandwidth without compression
    • Bandwidth after compression
    • [Icon] file type

##Downloads

// Retrieve Downloads Section Data
$downloads = Stats::Download($file);

Outputs

  • Rows:
    • Downloads
  • Columns:
    • Hits
    • Bandwidth

###Operative Systems

// Retrieve Os Section Data
$os = Stats::Os($file);

Outputs

  • Rows:
    • OS ID
  • Columns:
    • Hits
    • [Icon] OS logo

###Browsers

// Retrieve Browsers Section Data
$browsers = Stats::Browser($file);

Outputs

  • Rows:
    • Browser ID
  • Columns:
    • Hits
    • Pages
    • [Icon] Browser logo

###Screen Size

// Retrieve Screen Size Section Data
// Visit AWstats documentation page for instructions on how to configure and enalble this section
$screensize = Stats::ScreenSize($file);

Outputs

  • Rows:
    • Screen size
  • Columns:
    • Hits

###Unknown Referer Os

// Retrieve Unknown Referer Section Data
$unknown_referer = Stats::UnknownReferer($file);

Outputs

  • Rows:
    • Unknown referer OS
  • Columns:
    • Last visit date

###Unknown Referer Browser

// Retrieve Unknown Referer Browser Section Data
$unknown_referer_browser = Stats::UnknownRefererBrowser($file);

Outputs

  • Rows:
    • Unknown referer Browser
  • Columns:
    • Last visit date

###Origin

// Retrieve Origin Section Data
$origin = Stats::Origin($file);

Outputs

  • Rows:
    • Origin
      • From0 = Direct access / Bookmark / Link in email...
      • From1 = Unknown Origin
      • From2 = Links from an Internet Search Engine
      • From3 = Links from an external page (other web sites except search engines)
      • From4 = Links from an internal page (other page on same site)
      • From5 = Links from a NewsGroup
  • Columns:
    • Pages
    • Hits

###Search Engine Referrals

// Retrieve Search Engine Referrals Section Data
$sereferrals = Stats::Sereferrals($file);

Outputs

  • Rows:
    • Search engine referers ID
  • Columns:
    • Pages
    • Hits

###External Page Referers

// Retrieve External Page Referers Section Data
$external_page_referers = Stats::Pagerefs($file);

Outputs

  • Rows:
    • External page referers
  • Columns:
    • Pages
    • Hits

###Search Keyphrases

// Retrieve Search Keyphrases Section Data
$search_keyphrases = Stats::Searchwords($file);

Outputs

  • Rows:
    • Search keyphrases
  • Columns:
    • Number of search

###Search Keywords

// Retrieve Search Keywords Section Data
$search_keywords = Stats::Keywords($file);

Outputs

  • Rows:
    • Search keywords
  • Columns:
    • Number of search

###Errors

// Retrieve Errors Section Data
$errors = Stats::Errors($file);

Outputs

  • Rows:
    • Errors (HTTP code)
  • Columns:
    • Hits
    • Bandwidth

###Sider 404 Errors

// Retrieve 404 Errors Section Data
$page_not_found_errors = Stats::Sider404($file);

Outputs

  • Rows:
    • URL with 404 errors
  • Columns:
    • Hits
    • Last URL referer

##Visitor

// Retrieve Visitor Section Data
$visitors = Stats::Visitor($file);

Outputs

  • Rows:
    • Host
  • Columns:
    • Pages
    • Hits
    • Bandwidth
    • Last visit date
    • [Start date of last visit]
    • [Last page of last visit]

##Day

// Retrieve Day Section Data
$days = Stats::Day($file);

Outputs

  • Rows:
    • Date
  • Columns:
    • Pages
    • Hits
    • Bandwidth
    • Visits

###Session

// Retrieve Session Section Data
$sessions = Stats::Session($file);

Outputs

  • Rows:
    • Session range
  • Columns:
    • Number of visits

###Sider (Internal links)

// Retrieve Sider Section Data
$internal_links = Stats::Sider($file);

Outputs

  • Rows:
    • URL
  • Columns:
    • Pages
    • Bandwidth
    • Entry
    • Exit

###Best Day

// Retrieve Best day of month (by hits)
$best_day = Stats::Bestday($file);

Outputs

  • Rows:
    • Date
  • Columns:
    • Hits

#License Open Source software under MIT License