samkitano/stats

Laravel的AWstats解析器

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

This package is not auto-updated.

Last update: 2024-09-21 16:26:23 UTC


README

在基于Laravel 4的应用程序中读取您的AWstats日志文件。

AWstats是一个著名的开源应用程序,旨在记录和解析您的网站主机上的访问者统计信息。此包使这些统计数据可用于您的Laravel应用程序。

如果您不了解AWstats是什么、它是如何工作的以及如何配置它,请不要使用此包。您至少必须知道在您的主机上您的AWstats日志文件的位置。

由于AWstats提供了一套相当全面的数据,我建议您访问AWstats网页,以便了解其功能、设置和文档。

要求

- PHP >= 5.4
- Laravel 4.2+.

安装

将以下内容添加到您的composer.json文件中的require部分

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

更新您的依赖项

$ php composer.phar update

打开app/config/app.php,并将新项添加到providers数组中

'Samkitano\Stats\StatsServiceProvider',

发布配置文件

$ php artisan config:publish samkitano/stats

您还必须发布资产文件

$ php artisan asset:publish samkitano/stats

例如,AWstats原生图标等资产将可在您的public/packages/Samkitano/Stats/assets文件夹中找到。

配置

包设置在您的app/config/packages/Samkitano/Stats/config.php文件中可用。

AWstats日志文件路径

您必须指定在您的主机上的AWstats日志文件的路径。通常类似于/home/USER/tmp/awstats/,其中USER应该是您的主机用户名。

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

图标图像文件夹路径

如果您不打算显示AWstats原生图标,请将其设置为null

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

图标格式

如果您希望图标文件指向的url,请将其设置为'url',或如果您更喜欢一个 html标签(默认),请设置为'tag'。html 标签将包含base64编码的图标。

'icon_format' => 'tag',

单位

如果您想要带宽的可读单位,请将其设置为true。如果您打算基于此结果进行进一步计算,请将其设置为false(默认)。

'units' => false,

使用方法

要获取可用日志文件的列表

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

结果将包含现有AWstats日志文件,结构如下所示

	\domain
		\year
			\month => file

检索数据

检索给定日志文件上的所有可用数据

通过提供的数组列表访问

// 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']);

手动,如果您知道要提供哪个文件(不包括.txt扩展名)

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

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

检索当前月份的统计数据

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

##方法

###通用

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

输出

  • LastLine
    • 最后一条记录的处理日期
    • 最后一条记录在最后日志中的行号
    • 最后一条记录在最后日志中的偏移量
    • 最后一条记录的签名值
  • FirstTime
    • 历史文件的首次访问日期
  • LastTime
    • 历史文件的最后访问日期
  • LastUpdate
    • 最后更新日期
    • Nb of parsed records
    • Nb of parsed old records
    • Nb of parsed new records
    • Nb of parsed corrupted
    • Nb of parsed dropped
  • TotalVisits
    • 访问次数
  • TotalUnique
    • 独特访客数量
  • MonthHostsKnown
    • 已知主机数量
  • MonthHostsUnKnown
    • 主机数量未知

###杂项

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

输出

  • 行数
    • QuickTime 支持
    • Java 已启用
    • JavaScript 已禁用
    • PDF 支持
    • Windows 媒体播放器支持
    • 添加到收藏夹
    • RealPlayer 支持
    • 总杂项
    • Director 支持
    • Flash 支持
  • 列数
    • 杂项 ID
    • 页数
    • 点击量
    • 带宽

###时间

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

输出

  • 行数
    • 小时 = 0 到 23
  • 列数
    • 页数
    • 点击量
    • 带宽
    • 未查看的页面
    • 未查看的点击量
    • 未查看的带宽
    • [图标] 代表时间段的时钟

###域名

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

输出

  • 行数
    • 域名(最高25个顶级访问域名)
  • 列数
    • 页数
    • 点击量
    • 带宽
    • [图标] 已知顶级域的国家国旗

###集群

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

输出

  • 行数
    • 集群 ID
  • 列数
    • 页数
    • 点击量
    • 带宽

###登录

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

输出

  • 行数
    • 登录
  • 列数
    • 页数
    • 点击量
    • 带宽
    • 最后访问

###机器人

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

输出

  • 行数
    • 机器人 ID
  • 列数
    • 点击量
    • 带宽
    • 最后访问
    • robots.txt 上的点击量

###蠕虫

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

输出

  • 行数
    • 蠕虫 ID
  • 列数
    • 点击量
    • 带宽
    • 最后访问

###邮件发送者

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

输出

  • 行数
    • 电子邮件
  • 列数
    • 点击量
    • 带宽
    • 最后访问

###邮件接收者

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

输出

  • 行数
    • 电子邮件
  • 列数
    • 点击量
    • 带宽
    • 最后访问

###文件类型

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

输出

  • 行数
    • 文件类型
  • 列数
    • 点击量
    • 带宽
    • 未压缩的带宽
    • 压缩后的带宽
    • [图标] 文件类型

##下载

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

输出

  • 行数
    • 下载
  • 列数
    • 点击量
    • 带宽

###操作系统

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

输出

  • 行数
    • OS ID
  • 列数
    • 点击量
    • [图标] 操作系统标志

###浏览器

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

输出

  • 行数
    • 浏览器 ID
  • 列数
    • 点击量
    • 页数
    • [图标] 浏览器标志

###屏幕尺寸

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

输出

  • 行数
    • 屏幕尺寸
  • 列数
    • 点击量

###未知引用操作系统

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

输出

  • 行数
    • 未知引用操作系统
  • 列数
    • 最后访问日期

###未知引用浏览器

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

输出

  • 行数
    • 未知引用浏览器
  • 列数
    • 最后访问日期

###来源

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

输出

  • 行数
    • 来源
      • From0 = 直接访问 / 书签 / 邮件中的链接...
      • From1 = 未知来源
      • From2 = 来自搜索引擎的链接
      • From3 = 来自外部页面的链接(除搜索引擎外的其他网站)
      • From4 = 来自同一站点的其他页面的链接
      • From5 = 来自新闻组的链接
  • 列数
    • 页数
    • 点击量

###搜索引擎引用

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

输出

  • 行数
    • 搜索引擎引用者 ID
  • 列数
    • 页数
    • 点击量

###外部页面引用者

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

输出

  • 行数
    • 外部页面引用者
  • 列数
    • 页数
    • 点击量

###搜索关键词短语

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

输出

  • 行数
    • 搜索关键词短语
  • 列数
    • 搜索次数

###搜索关键词

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

输出

  • 行数
    • 搜索关键词
  • 列数
    • 搜索次数

###错误

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

输出

  • 行数
    • 错误(HTTP 状态码)
  • 列数
    • 点击量
    • 带宽

###404 错误页面

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

输出

  • 行数
    • 带有 404 错误的 URL
  • 列数
    • 点击量
    • 最后的 URL 引用者

##访客

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

输出

  • 行数
    • 主机
  • 列数
    • 页数
    • 点击量
    • 带宽
    • 最后访问日期
    • [最后访问的起始日期]
    • [最后访问的最后页面]

##日

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

输出

  • 行数
    • 日期
  • 列数
    • 页数
    • 点击量
    • 带宽
    • 访问次数

###会话

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

输出

  • 行数
    • 会话范围
  • 列数
    • 访问次数

###页面(内部链接)

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

输出

  • 行数
    • URL
  • 列数
    • 页数
    • 带宽
    • 入口
    • 出口

###最佳日

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

输出

  • 行数
    • 日期
  • 列数
    • 点击量

##开源软件许可受 MIT 许可证 支持