Count filedownloads with AWstats

Submitting your vote...
Not rated yet. Be the first who rates this item!
Click the rating bar to rate this item.

Add following extra section to typo3conf/ext/cc_awstats/awstats/awstats.conf

 

ExtraSectionName1="Top Downloads"

ExtraSectionCodeFilter1="200"

ExtraSectionCondition1="URL,\.(pdf|doc|zip|xls|ppt|csv|jpg)$"

ExtraSectionFirstColumnTitle1="URL"

ExtraSectionFirstColumnValues1="URL,(.*)"

ExtraSectionStatTypes1=PHB

MaxNbOfExtra1=100

MinHitExtra1=1

 

 

Add to your typoscript setup following for the content type text

 

tt_content.text.20.parseFunc.tags {
  link.stripNL = 0
  link = PHP_SCRIPT 
  link.file = fileadmin/scripts/tags.php
   
}

 

 

file file leadmin/scripts/tags.php, rewrites all links to fileadmin

<?

$GLOBALS["TSFE"]->set_no_cache();

$params=explode(' ',$this->parameters['allParams']);

$link['parameter']=$params[0];

$link['target']=$params[1];

$this->linkCounter++;

if(substr($params[0],0,10)=='fileadmin/'){

$link['parameter']='fileadmin/count.php?f='.urlencode($params[0]);;

}

$content.=$this->typolink($this->getCurrentVal(),$link);

?>

 

 

file fileadmin/count.php, writes download to log file. logFile is the same as the file in config.stat_apache_logfile.

<?

$logFile='stat_apache.log';

$fileName=urldecode($_GET['f']);

$referer=getEnv('HTTP_REFERER');

$ua=getEnv('HTTP_USER_AGENT');

$remoteHost=getEnv('REMOTE_HOST')?getEnv('REMOTE_HOST'):getEnv('REMOTE_ADDR');

$LogLine = $remoteHost.' - - '.Date('[d/M/Y:H:i:s +0000]').' "GET /'.$fileName.' HTTP/1.1" 200 '.filesize('../'.$fileName);

$LogLine.= ' "'.$referer.'" "'.$ua.'"';

$logfilehandle = fopen($logFile, 'a');

fputs($logfilehandle, $LogLine."\n");

@fclose($logfilehandle);

header("Location:".$fileName);

?>

more informations

Awstats Dokumentation

Typoscript by Example - Userdefined tags

TSRef tags

TSRef parseFunc

 



Comments


Martin, 19-02-06 13:42:
tags.php extracts the target for external links. Fix:
add this line
$link['extTarget']=$params[1];

Martin
Bing, 17-04-07 20:03:
Hi,

I'm trying to add an extra section in the AWStats config file using the above example. But it's not clear how fileadmin/count.php should be used? Would you clarify?

Thanks,

Bing
Bing, 18-04-07 13:50:
Hi,

I'm trying to add an extra section in the AWStats config file using the above example. But it's not clear how fileadmin/count.php should be used? Would you clarify?

Thanks,

Bing
Bing, 18-04-07 15:29:
Sorry, I didn't see $link['parameter']='fileadmin/count.php?f='.urlencode($params[0]);; in the tags.php script.

I can see Top Downloads section at the bottom of the AWStats report. But it's empty. The log file still just shows regular page (html) visits. No other file types.

Bing
Chris, 31-05-11 20:28:
This works, and most people can ignore the PHP scripts, which are specific to Typoscript users I guess.

If your web server isn't logging file downloads, of course, awstats won't be able to find them in the log file. But that's rare!
Aundre, 03-07-11 17:17:
HHIS I sholud have thought of that!

Add comment

* - required field

*



*
*

Top 10 Updates

Useful Links geändert am  24-Apr-2013 06:31:20
Nice fonts using Google font API geändert am  20-May-2010 14:36:47
TS-based Searchbox for Indexed Search  geändert am  18-May-2010 16:27:15
TYPO3 SEO geändert am  30-Apr-2010 07:44:22
Search engine friendly graphical headers in TYPO3 geändert am  30-Apr-2010 07:33:44
Creating a simple Infocenter using TYPO3 geändert am  17-Nov-2009 11:12:52
Making the Section Menu work correctly with TemplaVoila geändert am  05-May-2009 10:27:17
Show pages with type "Not in Menu" in a sitemap geändert am  05-May-2009 10:11:17
Implementation of the DHTML menu from brainjar.com  geändert am  01-Feb-2009 13:02:48
Sample DHTML menu geändert am  01-Feb-2009 12:51:25

Latest comments

05-Apr-2016 08:50:14
sabine deeken schrieb: plugin.feadmin.dmailsubscription.create.fields needs "hidden" for double opt-in
Dmail newsletter
22-Feb-2016 09:42:27
Steve Rhea schrieb: Thanks for detailed explanation! Unfortunately, many program codes are not well-secured and besides...
Copyright notice with current year
14-Sep-2015 09:45:19
Siviwe Mdudo schrieb: lib.search_form = COA_INT lib.search_form { 10 = TEXT 10 { typolink.parameter =...
TS-based Searchbox for Indexed Search
Deutsch
Search: