SlimStat Plugin for MODx

Author: Zaigham Rana | Posted on 22-Jan-2006 at 12:31 pm

Mark Kaplan and I spent less than an hour working on an alternate statistics implementation for MODx, as the current one is starting to show its age and is not as efficient as it could be. We developed our solution around the light weight and smart SlimStat statistics package from Stephen Wettone.

Here is how to get it up and running:

  1. Download SlimStat
  2. Extract files to local drive and then upload them to /assets/plugins/ of your web-space.
  3. Now point your browser to its location e.g. http://mydomain.com/assets/plugins/slimstat/.
  4. Follow the installation process through their nice simple installer.
  5. When installed, login to your MODx manager.
  6. Go to Resources -> Manage Resources and click on Plugins tab.
  7. Create new Plugin
  8. Enter this code inside it:
    @include_once( $_SERVER["DOCUMENT_ROOT"]."/assets/plugins/slimstat/inc.stats.php" );
  9. Click on System Events tab.
  10. Select/Mark the OnWebPagePrerender checkbox
  11. Hit Save.

THAT'S IT!

Now you might ask your MSN/Yahoo/AOL buddies to visit your site, and you should see hits in your SlimStat statistics pages. You can access your stats by pointing your browser to http://mydomain.com/assets/plugins/slimstat/.

Until next time, good bye and take good care of yourself and the people around you.

Comments

Please login to comment.

Close ]

1
Turn off built in stats, too by rthrash 23-Jan-06 10:11 AM
You shoud probably turn off the built-in stats prior to installing this plugin or you might run into some performance issues. And the next version of SlimStats should be super cool with a rolling database feature to keep things nice and managable. :D
2
lol by MadeMyDay 23-Jan-06 10:46 AM
"as the current one is starting to show it's age and is not as efficient as it could be."

LOL, just have to wipe the coffee off my screen after reading your age note. Regarding the built in stats of Mambo/Joomla, modX is way better... ;) Once more surprised by you guys!
3
The blog is definitely a gold mine :) by davidm 23-Jan-06 05:12 PM
Well, amazing how many gems you can find around here :)

I'll definitely try this !
4
a rolling database feature by edge 24-Jan-06 11:29 AM
Thats sounds too fantastic. There is not a day goes by when something exciting does not happen with Modx...

I just wish there were more than 24 hours in a day There is just so much I want to get stuck into, learn and make use of
5
a rolling database feature by edge 24-Jan-06 11:30 AM
Thats sounds too fantastic. There is not a day goes by when something exciting does not happen with Modx...

I just wish there were more than 24 hours in a day There is just so much I want to get stuck into, learn and make use of
6
Tried : it works flawlessly :) by davidm 25-Jan-06 06:42 AM
I've just installed the slimstat plugin as instructed, works perfectly :-)

Just had to use the path as instructed in Slimstat, the code provided above got me a MODx parse error... Probably a path problem with my particular server configuration.
7
Path issues? by zi 25-Jan-06 01:39 PM
Thanks for all appreciations :) ... and David, What was the issue by the way ?
8
Conflict with 'zlib output compression' by grad 01-Jun-06 04:49 AM
I get an error message: "Warning: ob_start(): output handler 'ob_gzhandler' conflicts with 'zlib output compression' in (path here)assets\plugins\slimstat\index.php on line 27".

I'm running MODx 0.9.2.1 on WindowsXP SP2, with Apache 2 and PHP 4.4.0.
9
Slimstat Plugins by ghosty 30-Jun-06 03:42 AM
If you're looking for some extra plugins for this plugin. I've written a few.

This one is to update the ip-to-country data:
http://reverb.madstatic.com/blog/2006/04/02/countryupdate-my-first-plugin-for-slimstat/

This one is to allow ip-to-city tracking:
http://reverb.madstatic.com/blog/2006/06/09/tracking-cities-with-slimstat/

This one is to plot visitors onto a google map (requires city tracking):
http://reverb.madstatic.com/blog/2006/06/09/gmapped-mapping-plugin-for-slimstat/
10
Conflict with 'zlib output compression' by zi 30-Jun-06 06:29 AM
Hi grad,
Please check SlimStat's Google Group
Thanks.
11
zlib compression error by arphaus 13-Sep-06 01:49 PM
i posted in the Google Group and didn't get any useful response. is there something in the plugin that i can comment out? it doesn't seem to be keeping track of search strings, referrers and search domains.

i presume this has something to do with the server since all the sites i've installed this on my servers work fine - this is on a client's server.
12
dif site, dif problem by arphaus 25-Sep-06 07:50 PM
2 posts in a row makes me think of user error. on a dif site on our server where this has worked perfectly, i just converted a static site to modx and had slimstat already installed & working. converted to modx, installed the slimstat plug using the same db info, assuming that the stats would just pick up where they left off and .. nothing.

trying to check the stats yields a page telling me to add the code to the pages, which i have, following the instructions above. do i need create a new db rather than use the old one? maybe add a prefix to the tables for this install?

thank you.
13
Warning by trelane 10-Mar-07 12:18 AM
I followed the above instructions and it crashed my mysql server completely. I have no idea what went wrong, but something obviously did. So take caution when installing this add-on for modx.
14
Warning by trelane 10-Mar-07 03:20 AM
I followed the above instructions and it crashed my mysql server completely. I have no idea what went wrong, but something obviously did. So take caution when installing this add-on for modx.
15
Very nice by arty 20-Apr-07 03:28 PM
Beautiful!
16
Excellent! by digitalmaster 28-Jun-07 10:36 PM
Luv this pluggin..

Easy to use, and very easy to intergrate into modx. Luv it..

If only we it could show document titles instead of (index.php?id=X) that would have been everything u could ever want in a stat plugin.

But yea we cant have it all can we? ^_^
17
Server doesn't work by kassa 09-Jul-07 03:51 AM
Hi,
the download server (http://wettone.com/code/slimstat#download) doesn't work... Is there any other place to get the plugin from? It's very importent to me, so I'll be very thankful for any halp.
18
Server doesn't work by kassa 09-Jul-07 03:52 AM
Hi,
the download server (http://wettone.com/code/slimstat#download) doesn't work... Is there any other place to get the plugin from? It's very importent to me, so I'll be very thankful for any halp.
19
path incorrect by BBloke 26-Jul-07 04:42 PM
I found the leading slash had to be removed to make it correct with DOCUMENT_ROOT
20
restrict access by highlander 20-Nov-07 07:44 AM
this is a superb plugin but is it possible to restrict access to only modx managers? or at least restrict access to the admin page where the db can be blitzed?
21
adding pagetitle by okieh 23-Nov-07 05:48 AM
hi!

I did a little work to have the pagetitle and id instead of the "/webpage/index.php?id=3" slimstat resource string.

First, add the following lines of code into slimstat's "_config.php":

/** modx variables */
var $modx_table_prefix = 'modx_'; // table prefix
var $modx_home = 1; // id of start-page


The id of your start page is necessary since this is called without the id!

Then add the following code in "inc.stats.php" after line 56 or so (right after where the resource string was fetched):

// make resource string a more readable modx pagetitle
$pos = strpos($stat["resource"], '=');
if ($pos == 0) {
$page = $this->config->modx_home;
}
else
{
$pos2 = strpos($stat["resource"], '&',$pos);
if ($pos2 > 0) {
$len = $pos2 - $pos -1;
$page = substr($stat["resource"], $pos+1, $len);
}
else {
$page = substr($stat["resource"], $pos+1);
}
}

if ($page > 0) {
$modx_query = "SELECT `pagetitle` FROM ".SlimStat::my_esc( $this->config->database )."`.`".SlimStat::my_esc( $this->config->modx_table_prefix )."site_content"."`";
$modx_query .= " WHERE `id` = ".$page;
if ( $result = mysql_query( $modx_query ) ) {
if ( list( $pagetitle ) = mysql_fetch_row( $result ) ) {
$stat["resource"] = $pagetitle." (".$page.")";
}
}
}


Let's say your page with index 6 has a pagetitle called "Contactpage". This results in entries like "Contactpage (6)" instead of "/webpage/index.php?id=6"

Use under your own risk, no warranties!!!

Regards
Heiko
22
adding pagetitle (2) by okieh 23-Nov-07 05:54 AM
Be aware that by applying the above changes, links in slimstats "Resources" don't work anymore, but I can live with that!

Best...
Heiko
23
private stat? by sinbad 21-Dec-07 05:37 PM
like highlander, me too hope for a way to make the stat page private. any workarounds for that ?
24
Work around by 2wistd 24-Jan-08 12:24 PM
It didn't work for me. It didnt break anything but it isn't showing what it should. I updated the configuration and also I tried on line 56 before and after the }
Any help?
25
titles... by vr_driver 08-Feb-08 04:07 PM
Yeah, I haven't had the work around work either... pitty. I'd like to have the labels shown. This would be really good.

Is there a customised MODX version of this?
26
No logging for managers by michalc 08-Apr-08 06:23 AM
Hi,

Taking this straight from the page for Mint integration, I think you can turn off logging for users who are logged into the manager by:

if (!isset($_SESSION['mgrValidated'])) {
@include_once( $_SERVER["DOCUMENT_ROOT"]."/assets/plugins/slimstat/inc.stats.php" );
}

(Although it seems to work for me, I'm never sure about these things...)
27
Slimstats in module :) it Rocks by Crash1hd 18-Oct-08 04:05 PM
So I just added slimstats to my site and I created a new module and added the following in the php code :)

header('Location: http://www.websiteaddress.com/assets/plugins/slimstat/');

Its great cause now it looks like its in the backend :)
Now to lock access from outside??? hmmm
28
by Daedalus 11-Feb-09 05:16 AM
I wrote a small snippet, restrict page access to authorized managers:
http://dae.cyberic.ru/en/blog/restrict-page-access-to-authorized-modx-managers-only
29
Access to managers only by lesur 13-Feb-09 05:53 AM
That's pretty nifty Daedalus. For now I am good with just a .htaccess file in the directory, but I'll definately keep your page bookmarked for when I need more functionality.
 
 
 

Contact Us | Team Blog | FAQ | Site Credits

© 2005-2009 the MODx CMS project. All rights reserved. Privacy Policy | Terms of Service