Recent Topics

1 May 23, 2006 12:55    

Basically, I'd like a little plugin (or hack) that shows the following in the sidebar...

Mini-Stats:
This blog contains 418 posts,
spanning a rage from
June 3, 2002 to May 23, 2006
There have been 5448 visitors,
leaving a total of 217 comments.

Think this could be done?

Thanks in advance.

2 May 23, 2006 17:48

You'd have trouble with the visitor count as the sttas are prunned (by default they only include the last 30 days), but the rest of it is fairly easy to achieve (I have something similar running on my blog except it also counts spam attempts).

¥

3 May 23, 2006 18:19

Cuddles,

I've got your plugin request underway. You can see it in the sidebar here:
http://www.brendoman.com/dbc

What version of b2evolution are you using? This will be an actual plugin for 1.6+, but if you're using something older, I can port it back as a hack for you.

4 May 23, 2006 18:28

They're using Dawn ;)

¥

5 May 23, 2006 19:42

¥åßßå is right. I just upgraded to Dawn (still getting my time/date stamps fixed on the import, ¥åßßå).

As for the visitor count, no biggie. I've got a visitor counter on my site now. It's external, but it works.

So how long until that plugin is ready person?

:)

6 May 23, 2006 20:28

12/31/69
Permalink 05:59:59 pm, Categories: Original Posts

Damn, your 4 years of life stretches back a tad!!!

Sorry about that, I only looked at the data from a few entries to see what I had to work with.

¥

7 May 23, 2006 21:14

Ok, the plugin is done. The date format and a few other things can be set by passing params to the plugin. Now to make a Dawn hack version . . .

8 May 23, 2006 21:33

This little hack adds a section to your sidebar with some simple stats like this:

Mini-Stats:
This blog contains 418 posts,
spanning a rage from
June 3, 2002 to May 23, 2006
There have been 5448 visitors,
leaving a total of 217 comments.

Here are install instructions for 0.9.x:

1) Download this file: [url=http://brendoman.com/dev/091-blogs/skins/custom/_ministats.txt]_ministats.txt[/url]

2) Replace the .txt with a .php and put it in your skin's directory. (e.g., if you're using custum, put this file in /skins/custom/)

3) Add this code to your _main.php file where ever you want the stats to show:

<?php // Mini Stats:
require( dirname(__FILE__).'/_ministats.php' );
 ?>

Bonus:
If you want to change the date format, then find the line that says:

if(!isset($params['date_format'])) $params['date_format'] = locale_datefmt();


and change it to:

if(!isset($params['date_format'])) $params['date_format'] = 'F j, Y';


If you don't change that, it uses the default date format for your locale.

9 May 24, 2006 13:34

¥åßßå: That it does. :) Thought about shutting it down several times over the years, but then I think of all the spammers who keep offering to buy the domain from me. Besides, it's therapeutic.

personman: Thanks! I'll test it out right now.

Just tested it, and it works great! Thanks again!

10 May 24, 2006 15:49

Cuddles,
I'm glad it works for you. I think it was a great idea and I'm using this on my site now, too.

11 May 24, 2006 19:58

personman, I've just seen it on your site:

[...] spanning a range from May 5, 2003 to May 5, 2006 .

Congrats to exactly 3 years..
But it does not appear to be correct, because the last post is from May 23.

12 May 24, 2006 20:32

Oops, I used 'F n, Y' instead of 'F j, Y' for the date format. Thanks for catching that. So, I guess my first post was May 30, 2003. I haven't missed my blog's birthday after all.

13 May 25, 2006 15:58

Working fine on my site. :) And thanks again!

14 May 25, 2006 16:27

Yeah, the mistake was just on my site. The code in the _ministats.php file is good. I just messed up the date format when I was passing it to the plugin on my site. I corrected the post above, too, when I told you how to change the date format.

15 May 30, 2006 22:11

Hey this is pretty cool. The only problem I've encountered is that it only looks at the posts under a given blog under the all-blogs blog. Is there any way that it could pull al of the stats from all of the blogs on this blog?

16 May 30, 2006 22:38

NealO, you're absolutely right. I just fixed that and updated the link above for the 0.9.x version. Thanks for catching that.

18 May 31, 2006 03:47

mrdav, what version of b2evolution are you using? This is for 0.9.x.

19 May 31, 2006 04:01

Oh, I forgot I upgraded this blog to 1.6.

sheesh

:oops:

It's this glacial wait for 1.8 that caused it. I can't even remember if it was this century that I updated it. :yawn:

Not that I am complaining about free software. :lol:

20 May 31, 2006 04:02

@ personman
First, thanks for Mini Stats
I just uploaded your "revised" ministats.php and it drastically reduced my stats.
I don't have multiple blogs, apart from a linkblog.
Seems as though it's missing categories.
The original script gave me...
"767 posts and 582 comments from 02 May 2002 to 31 May 2006 ."
This updated script gives me...
"140 posts and 118 comments spanning a range from 19 May 2002 to 22 May 2002 "

21 May 31, 2006 15:55

John,
Can you check to see which of those numbers is accurate? If you go to the browse tab in your backoffice, it should tell you the number of posts in the blog. Do you put posts in more than one category? I think it may be counting some of my posts twice. I need to work on that, but I'm not able to replicate the problem that you're having.

22 May 31, 2006 16:08

The 767 number is the correct number
I tested this twice and got the same result

Version is 0.92 Sparkle

23 May 31, 2006 16:14

I didn't keep a copy of the first _ministats.txt. Can you give me the version that is working? I'll compare it to mine and try to see what I broke.

24 May 31, 2006 16:23

Slightly edited.. but only for the Headings, not the code

<?php
	if( !defined('DB_USER') ) die( 'Please, do not access this page directly.' );


		/**
		 * Default params:
		 */
		// This is what will enclose the block in the skin:
		if(!isset($params['block_start'])) $params['block_start'] = '<div>';
		if(!isset($params['block_end'])) $params['block_end'] = "</div>\n";

		// Title:
		if(!isset($params['title']))
			$params['title'] = '<h2><label title="Mini Stats for Wow">'.T_(':: MINISTATS. &nbsp;').'</label></h2>';
		

			// This is what will enclose the category list:
		if(!isset($params['list_start'])) $params['before_number'] = '<em>';
		if(!isset($params['list_end'])) $params['after_number'] = "</em>\n";

		// Before text:
		if(!isset($params['before_text'])) $params['before_text'] = '<p>';
		if(!isset($params['after_text'])) $params['after_text'] = "</p>\n";

		// Blog to use.  Default is the current blog being displayed.
		if(!isset($params['blog'])) $params['blog'] = $blog;

		// The date format:  
		if(!isset($params['date_format'])) $params['date_format'] = locale_datefmt();
		
		// Start display
		
		echo $params['block_start'];
		echo $params['title'];
		echo $params['before_text'];
		$sql = 'SELECT DISTINCT COUNT(ID) AS count
                FROM T_posts
                INNER JOIN T_postcats ON ID = postcat_post_ID
                INNER JOIN T_categories ON postcat_cat_ID = cat_ID
                WHERE cat_blog_ID = '.$params['blog'];

		$postcount = $DB->get_var($sql);
		echo "".$params['before_number'].$postcount.$params['after_number']." posts and ";
		$sql = 'SELECT COUNT(comment_post_ID)
		FROM T_comments, T_posts
                INNER JOIN T_postcats ON ID = postcat_post_ID
                INNER JOIN T_categories ON postcat_cat_ID = cat_ID
		WHERE T_posts.ID = T_comments.comment_post_ID AND 
                cat_blog_ID = '.$params['blog'];
		$commentcount = $DB->get_var($sql);
		echo $params['before_number'].$commentcount.$params['after_number'];
		
		echo 'comments from ';

		$sql = 'SELECT post_issue_date
		FROM T_posts
		INNER JOIN T_postcats ON ID = postcat_post_ID
		INNER JOIN T_categories ON postcat_cat_ID = cat_ID
		WHERE cat_blog_ID = '.$params['blog']. '
		ORDER BY post_issue_date ASC
		LIMIT 1';
		$firstpost = $DB->get_var($sql);
		echo $params['before_number'].mysql2date( $params['date_format'], $firstpost).$params['after_number'];
		echo ' to ';
		
		$sql = 'SELECT post_issue_date
		FROM T_posts
		INNER JOIN T_postcats ON ID = postcat_post_ID
		INNER JOIN T_categories ON postcat_cat_ID = cat_ID
		WHERE cat_blog_ID = '.$params['blog']. '
		ORDER BY post_issue_date DESC
		LIMIT 1';
		$lastpost = $DB->get_var($sql);
		echo $params['before_number'].mysql2date( $params['date_format'], $lastpost).$params['after_number'].'.';
			
		
		echo $params['after_text'];
		echo $params['block_end'];
		return true;



?>

25 May 31, 2006 16:27

Thanks.

* Wanders off to look it over *

26 May 31, 2006 16:50

Ok, try it now. Same link as before. I think it will be more accurate now.

27 May 31, 2006 17:24

Mmm!!

Post number is correct
Comments show "201" when they really are 583 .

Numbers also checked via the mySql database

28 May 31, 2006 17:59

I think I know what's happening. [url=http://www.wow-factor.com/?blog=1&skin=custom_wow]Check this page out.[/url] That's your Blog All. It shows the full number of comments for all blogs: 583. If you view your normal site (blog 2) it says there are 201 comments. You've probably had a bunch of comments (382, to be exact) get posted to blog 1.

There are two ways to fix this.

A. Run a SQL query to move all of those comments from blog 1 to blog 2, then make sure that the users can't post comments to blog 1.

or,

B. Change the param['blog'] to be 1 instead of $blog and you'll trick mini stats into thinking your on blog 1, thereby making it show you a count of all posts and all comments.

29 May 31, 2006 18:09

Option B. worked fine. Thanks mate :)

30 May 31, 2006 18:11

My pleasure. Thanks for helping me track down those bugs.

31 Jun 04, 2006 10:30

I wanted to implement this code too, but found an error in the SQL.
The amount of comments seems to calculate something different, namely the amount of posts which have comments.


      $sql = 'SELECT COUNT(DISTINCT comment_post_ID)
      FROM T_comments, T_posts
                INNER JOIN T_postcats ON ID = postcat_post_ID
                INNER JOIN T_categories ON postcat_cat_ID = cat_ID
      WHERE T_posts.ID = T_comments.comment_post_ID AND
                cat_blog_ID = '.$params['blog'];

This is because of the "DISTINCT comment_post_ID". This should be "DISTINCT comment_ID".

Then the number ALMOST corresponds to the exact amount of comments my weblog has. I am still missing two. (Out of 8745 comments, that is not bad :-))

I managed to write a new query that returns the exact amount of comments:


$sql = 'SELECT COUNT(DISTINCT comment_ID)
FROM T_comments
INNER JOIN T_posts ON T_posts.ID = T_comments.comment_post_ID
INNER JOIN T_postcats ON T_posts.post_category = T_postcats.postcat_cat_ID
INNER JOIN T_categories ON T_postcats.postcat_cat_ID = T_categories.cat_ID
WHERE T_categories.cat_blog_ID = '.$params['blog'];

When I look at it I see that it does an unnecessary step. The first join includes the Posts table, but the post ID is already known. But when I remove this join the query again returns two comments less.

Boggles me...

(The above query is not optimized, but shouldn't be too slow).

32 Jun 05, 2006 21:08

You're right about the comment_ID vs. comment_post_ID. I thought I had that fixed, but I guess not. Now it's sorted out. Thanks for your help.

33 Jun 07, 2006 22:56

Thanks for the hack. It works great for me except it doesn't show the total number of visitors. Should it do so or was that just an example of what the hack was planned to do?

35 Aug 22, 2006 01:06

Re the version referred to by Danny here...
http://plugins.b2evolution.net/index.php/2006/05/30/mini_stats#c724

This works fine as a plugin in v1.6 up to v1.8.1 but does require a small edit
find:

// Before text:
		if(!isset($params['before_text'])) $params['before_text'] = '<p>';
		if(!isset($params['after_text'])) $params['after_text'] = "</li>\n";

You have to decide if this plugin is to be enclosed as a paragraph or a list item and match the opening and closing tags to suit.
example:

// Before text:
		if(!isset($params['before_text'])) $params['before_text'] = '<p>';
		if(!isset($params['after_text'])) $params['after_text'] = "</p>\n";

and to call the plugin you have to use something like the following within your html in your .main.php

<?php // Mini Stats:
$Plugins->call_by_code( 'ministats', array(	// Add parameters below:
			) );
 ?>

Cheers

38 Jan 08, 2008 17:22

Is this confirmed to be working with 2.3? It is broken here, but it could be my issue...

39 Jan 08, 2008 17:24

I'm using it in 2.3.0. What issues are you having?

40 Jan 08, 2008 17:26

I don't remember. Let me re D/L reinstall and report back. Sorry (not helpful, I know).

41 Jan 08, 2008 17:33

Plugin class file [plugins/_ministats.plugin.php] is not readable! I redid the D/L upload. Permissions look OK.

42 Jan 08, 2008 17:35

the path should be plugins/ministats_plugin/_ministats.plugin.php

But the not readable message sounds like a server problem.

43 Jan 08, 2008 17:37

Hmmm. It was working before under 2.2. I did not notice the path. Strange.

44 Jan 08, 2008 17:39

Did you uninstall the plugin? That can't hurt. Try that and double check that the files are in the right spots.

45 Jan 08, 2008 17:47

Yep -- did uninstall, re-D/L and reinstall. No joy.

If I copy the files into the plugin dir (instead of the ministats dir) it installs, but the black dot on the plugin screen is hollow, it does not see the README file, and it is not available as a widget.

Weird.

46 Jan 08, 2008 17:51

Hang on -- I understand what the hollow dot means now...

47 Jan 08, 2008 17:53

If I click the hollow dot to enable the plugin, it appears to be installed correctly (even though it is in the wrong directory) -- but it does not appear in the widget list.

48 Jan 09, 2008 15:36

OK -- so I am sure that this is not working on my install.

Can you tell me how the plugin path is set/determined? I wonder if I broke something with my multi-blog multi-domain install.

49 Jan 09, 2008 15:45

I'm using the plugin on a multi-domain install. What happens if you delete all of the ministats files from your site, uninstall it and upload the plugin again so that it is like this:

plugins/ministats_plugin/_ministats.plugin.php

Do that and tell me what error you are getting.

50 Jan 09, 2008 16:29

OK. Here you go. Lots of detail and screen shots too.
Thanks for looking at this.
Mark

1. Un-installed ministats plugin
2. Deleted /public_html/blogs/plugins/_ministats_plugin
3. D/L zip file from SF (ministats_plugin-2.2.1.zip)
4. put the zip file in /public_html/blogs/plugins/
5. Unizp. /public_html/blogs/plugins/_ministats_plugin is created
6. /public_html/blogs/plugins/_ministats_plugin is 0755
7. Three files in /public_html/blogs/plugins/_ministats_plugin are 0644
8. Delete /public_html/blogs/plugins/ministats_plugin-2.2.1.zip
9. Go to b2evo admin glabal settings-> plugins install->Install new
10. See Mini Stats in the Astonish Me group with a description of Brief stats for a blog
11. Click Install
12. See Installed plugin «ministats_plugin». BUT
13. See that group is not set and description is "No desc available"
14. Click plugin link in list to edit plugin settings
15. See Warning Plugin class file [plugins/_ministats.plugin.php] is not readable!

http://www.preciousonpaper.com/masonworld/public/Slide1.PNG
http://www.preciousonpaper.com/masonworld/public/Slide2.PNG
http://www.preciousonpaper.com/masonworld/public/Slide3.PNG

51 Jan 09, 2008 16:49

Thanks for the details. I'm looking at the file that generates the message. The reason it's trying plugins/_ministats.plugin.php is this bit in inc/plugins/model/_plugins.class.php:


			if( ! is_readable( $classfile_path ) )
			{ // Look directly in $plugins_path
				$classfile_path = $this->plugins_path.$plugin_filename;
			}

So, it tries the normal, correct path, it fails is_readable, then it looks directly in the plugins dir, the file isn't there at all, so it returns false for is_readable as well, triggering the error you see.

Just for laughs, try chmodding all of the ministats files to 755. If that doesn't work, pm or email me if you want me to log in to your server and try something else.

52 Jan 09, 2008 17:01

755 does not fix it. :(
I'll PM you.

53 Feb 26, 2008 05:05

@texasag90: if you haven't fixed this you might want to make absolutely certain that (a) the path to the plugin is correct on the server and (b) there are no copies accidentally uploaded to a different plugins/a_plugin/ folder. Oddly enough, b2evo can find that there is *something* there somewhere, but can't actually use it so it chokes. (Had it bug the crap out of me until I found out I had (b) ;) )

How hard will it be to have this link to the posts it speaks shows in the comments & views & words sections?

54 Feb 26, 2008 05:32

Okay never mind. If I change the (stupid) "link the title to the permalink and completely ignore anything in the "link to URL" field unless I want a stupid 'link: foo' text in my post" setting back to that then most of the posts in the widget link to their page. But since I set that nonsense back to "link to URL if any" I get no linkage out of this particular plugin when I leave all the bits checked and showing. Oh well! Reckon I'll see what I can do about this conflict of interests with creative skin work, but I have this feeling I'm stuck with one or the other :(

55 Feb 26, 2008 07:05

So if you set the back office to "title = permalink no matter what" you can also set it back to "link to URL" in your index.main.php with

<?php $Item->title( array( 'link_type' => 'linkto_url' ) ); ?>

Then I did find a little problem with the ministats plugin. The param "after_text" gets set but never used. I figured it belonged after the $summary_text so this is what I did:

			echo $summary_text;
			echo $params['after_text'];
		}

I also changed the summary_text setting to "html_textarea" so I could use lists for those bits to keep with the whole 'sidebar as list items' thing.

Nice! me like!!!


Form is loading...