Statistics: Blog

Comments Posted By _ck_

Displaying 0 To 0 Of 0 Comments

WP-Polls & WP-UserOnline Updates

Before I forget, we need to take a look at doing a little overhaul on the next version to stop using the wp_options table.

WP_polls needs it’s own table for faster loading of WP in general. You have like a dozen entries in there (per poll?) set to autoload.

Sounds trivial but it all adds up if there are many other plugins.

(also note that most plugins do not remove their entries from the wp_options table on deactivation so it gets busy in there)

» Posted By _ck_ On 22nd August 2006 @ 02:04

I just thought of something else.
A visitor could be clever and get a double vote in if they wanted to, by first voting logged out and then logging in. It will pass the current tests, even with my little fix above (which I have now tested working).

What we should do is see if any cookies exist for wordpress members on that’s visitor’s browser, even if they are not logged in.

The problem with that is, someone that knows what they are doing can fake the cookie for any other user without logging in, and then they can vote via the previous logic.

It’s a complete logic problem with no clear solution.
I guess just double checking the IP is okay for now.

I might have to take a look at other voting solutions to see how they handle it, though I guess most solve it by not allowing you to vote at all if you are not a registered member, and we don’t want that.

By the way, why are you even bothering to store $pollip_host ?
It’s really of no use beyond the IP.
The gethostbyaddr($pollip_ip) call takes a relatively long time to do and is really not used at any future point (other than to make the logs pretty). You could make the IP’s a link and do a whois or something if the admin wants to know more later on while looking at the logs.

Thanks for keeping up with my fixes/suggestions 😉

» Posted By _ck_ On 18th August 2006 @ 18:19

Okay I think I traced the bug, though this is just after a brief overview, no actual testing.

When the ability is set to “username” you direct send the check to
function check_voted_username($poll_id)
The problem with this is that inside that function you do NOT check to see if $user_ID is 0 or not. So if ANY guest votes, I think it’s storing their transaction as user #0 and then no other guest can vote?

So within the check by username, you need to have a fallover for $user_ID===0 and then go back to checking by check_voted_ip($poll_id).

This is a total guess on my part but perhaps this might work:

function check_voted_username($poll_id) {
global $wpdb, $user_ID;
$pollsip_userid = intval($user_ID);
if ($user_ID==0) {return check_voted_ip($poll_id);}

Though I’d rather fall back to ip+cookie.

» Posted By _ck_ On 18th August 2006 @ 14:52

Is anyone else experiencing problems with users being shown results instead of the option to vote even if their IP is unique and they have no membership?

I’ve had various people look at the site and many of them just see the results without the option to vote.

I’m running the 2.12alpha from last week. I’ll try to trace the bug but just wanted to check first if this is happening elsewhere or just me.

» Posted By _ck_ On 18th August 2006 @ 14:29

5 Plugins Updated

Hi, after studying how you are doing useronline for a bit, I have to suggest that you are making a serious mistake by not storing either the member login name (ie. user_login) or the user_id and instead storing the preferred name.

The problem is that the preferred name is NOT unique. Any number of members could have the same.

I don’t think it would take much to fix this, you could either replace the currently used field with the user_login and translate to the preferred name if the useronline name list is printed out.

Or you could simply add an additional field to store the unique user_id when it is first identified (or user_login). Guests would have id’s of zero so that’s easy to spot.

Here’s an example of why it’s a growing problem. I tried to create a simple function to detect if a specific member is online for their author profile page.

function is_online($user_login) { global $wpdb;
return intval($wpdb->get_var("SELECT COUNT(*) FROM $wpdb->useronline WHERE username = '$user_login' LIMIT 1"));

Looks simple and could work – but the username you store is never unique so there can be multiple matches (and the function won’t work as is with “user_login” sent to it). I was going to make it fancy and have it auto-detect if it was passed a user_id vs a user_login but the point is mute for now.

Hope you’ll consider the (easy) improvement and feel free to use my is_online() function if you wish.

ps. my next wish is to store when the user was last online but that would require a table for all members and probably exceeds the scope of “useronline”. It’s more for your stats program.

» Posted By _ck_ On 6th August 2006 @ 01:35

Simple enhancement for useronline.php:

function get_users_browsing_site($display = true) {
function get_users_browsing_page($display = true) {

then insert this extra line here in both functions:

$total_users = ($total_guests+$total_bots+$total_members);

if (!$display) {return array ($total_users, $total_members, $total_guests, $total_bots);}

// Nice Text For Members

That way we can access the user counts and display the results as we wish:

currently users online
members and guests

Also, please consider make all AJAX additions completely optional. I have to comment out all the extra .js and other addfilters stuff.
Some of us still like flat pages since alot of novices browser with javascript turned off for security (out of ignorance). AJAX could be just a fad.

» Posted By _ck_ On 1st August 2006 @ 14:17

WP-Polls 2.11 Released

Your blog keeps eating code statements.
You need the “preserve code formating” plugin here to fix that:

» Posted By _ck_ On 7th August 2006 @ 16:48

I made a speed improvement in WP-Polls by using CSS and div’s for the pollbars instead of loading three small images which bogs down browser loading time, even on broadband, especially for first time visitors. I doubt I am the first to think of this but just in case, here’s how it’s done:

Your templates makes it easy, I just changed the results to something like this:


and then stuck in my template css something like this:

.pollbar {margin:1px; padding:1px; font-size:6px; line-height:8px; height:8px; background: #AAAA8A; border:1px solid #444;}

The nice thing about using css is that you can change make the .pollbar class change colors or sizes based on where it’s being show automagically, ie. #menu .pollbar {} and #content .pollbar {}

You could even make the css style the default and still use images if you so desire by placing the image as the background of the div and let it fill.

Last but not least, because it’s a true DIV in there, you can now inject either the vote count or percentage right into the DIV as text and put text-align:center in the CSS, change the text color with color: of course.

CSS div’s can be made to look almost as pretty as images by using various border styles for each side.

» Posted By _ck_ On 7th August 2006 @ 16:46

The array idea is good, I decided to make it simpler just to see if ANY poll was already displayed on the page:


function display_pollvote($poll_id) {
global $wpdb, $poll_on_page;

return $temp_pollvote;

function display_pollresult($poll_id, $user_voted = 0) {
global $wpdb, $poll_on_page;

return $temp_pollresult;

and in the sidebar
if (function_exists(‘vote_poll’) && !$GLOBALS[‘poll_on_page’])

I hope WP doesn’t eat my code but I think you have the idea anyway.
Doesn’t seem like the smoothest technique but it works.

» Posted By _ck_ On 2nd August 2006 @ 22:49

Great job you’ve done, as always.

Can you think of any variable I can check to determine if a poll is already showing on the page via one of the posts as to not repeat showing a poll in the sidebar? Since the content runs through php before the sidebar is called up, technically this should be possible?

Thank you.

» Posted By _ck_ On 1st August 2006 @ 01:14

«« Back To Stats Page
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 1.00 out of 5)

22 thoughts on “Statistics: Blog”

  1. Благодарю ВаÑ? за напиÑ?ание Ñ?криптов !

  2. Pingback: WP???????WP-Stats

Comments are closed.