[pmwiki-users] New Cookbook : CurrentVisitors

Patrick R. Michaud pmichaud at pobox.com
Mon Aug 1 18:53:19 CDT 2005


Another hint:  Use PmWiki's mkdirp() function instead of
mkdir() to create the directory.  This will make sure that 
the CurrentVisitors directory exists with the appropriate 
permissions (as well as prompt the administrator to create the 
directory if it's needed).

Also, instead of using fopen/fclose to mark the files, just
use PHP's touch() function:

    $file = "$CurrentVisitorsDirectory/" . 
            preg_replace('/\D/', '_', $_SERVER['REMOTE_ADDR']);
    touch($file);

Pm


On Mon, Aug 01, 2005 at 08:04:59PM +0200, Daniel Scheibler wrote:
> Hi Christophe,
> 
> the script looks nice.
> I have only one hint to you:
> use
> SDV($MaximumNumberOfSecondsToConsiderAVisitorAsCurrent, 1800);
> SDV($CurrentVisitorsDirectory, $WorkDir . '/' . 'CurrentVisitors');
> 
> instead of
> $MaximumNumberOfSecondsToConsiderAVisitorAsCurrent = 1800;
> $CurrentVisitorsDirectory                          = $WorkDir . '/' .
> 'CurrentVisitors';
> 
> so a user could change the values in local/config.php before 
>    include_once('cookbook/CurrentVisitors.php');
> 
> Greets,
> 
> scheiby
> -- 
> Daniel Scheibler     ========:}       student at
> eMail: scheibi at gmail.com              BTU Cottbus/Germany
> WWW:   http://www.scheiby.de
> 
> 2005/8/1, Christophe David <pmwiki at christophedavid.org>:
> > 
> > http://www.pmwiki.org/wiki/Cookbook/CurrentVisitors
> > 
> > Question
> > 
> > Can I know how many visitors are currently surfing on my site ?
> > 
> > Answer
> > 
> > Copy CurrentVisitors.php&#916; to the cookbook directory and add
> > include_once("local/CurrentVisitors.php"); to config.php.
> > 
> > Notes and Comments
> > 
> > In your wiki pages, add the markup (:CurrentVisitors:) to display the
> > number of visitors (strictly speaking "different IP addresses") that came
> > to your site during the last
> > $MaximumNumberOfSecondsToConsiderAVisitorAsCurrent .
> > 
> > The counter will update only when action=browse.
> > 
> >     * This recipe was last tested on PmWiki version: 2.0 beta 52
> >     * This recipe requires at least PmWiki version: 2.0
> > 
> > Comments and suggestions welcome.
> > 
> > Christophe
> 
> _______________________________________________
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
> http://host.pmichaud.com/mailman/listinfo/pmwiki-users
> 




More information about the pmwiki-users mailing list