![]() |
The idea is from SitePoint Forums.
I think a lot of people really want this hack, and I've even seen a released version of it here, but it used cronjobs and stuff like that I'm sure not all of use want to mess with. :) So, here's my version of the hack, completely crobjob-less and 100% working. :D The hack also includes an easy way for the admins to change the member of the day at any given time. (see note below) You can see it in action in this board, on the main page in the stats box. To install this hack download the attached file (memberofday.hack.php), upload to your /admin folder and use vbHacker. A couple of notes:
That's it, have fun. :D |
If anyone would like to know how this hack works, here you go.
Every time index.php is accessed, the current date (in a yyyy-mm-dd format) is generated (according to the server time, like I mentioned above). Then the data is pulled from a special template ("memberoftheday") and the date in the template is checked against the date that was just generated. If the dates match, then the data is ok (since it was created today, otherwise the date would be different), and nothing special needs to be done (other than assigning the data to new, easy-to-understand variables). If the dates do not match, the current member of the day is from a different day (probably yesterday, unless no one visited your forum for more than a day ;)). A new random user is selected from the database, while making sure it's not the same one that is already selected, a new data template is created and the database is updated. The above procedure also occurs if $resetmember is set to 1 (through the URL) and the user is an admin. So, the member of the day is only updated once a day, by the first member that visits your forum on a new day. Quite nice, no? :) |
Very nice, well done. :up:
|
Great hack! Thanks mate :D
|
very good! easy install and worked a charm!!
|
Awesome Chen, I'll put this up on my forums when I get a few more members! :)
|
Nice hack, I'm using it on my Forums. :D
|
I just installed and my first member of the day is someone who has not visited yet...
|
Sounds suspiciously like how birthdays work ;)
|
another wonderful release!
|
Cool :)
|
actually, I have a question, I can not find
$permissions=getpermissions(); if (!$permissions['canview']) { show_nopermission(); } IN my index.php? I am running 2.2.1, is there a difference? what line is it on thanks! |
Once I get things set back up, I am going to be using this, great job on yet another hack FireFly.
|
great job FireFly~~
i'll be use it~:D:D:D:D |
how do i intergrate this with the hack
[RELEASE newsfader for all vb version.(11* to 2.0*)] |
Quote:
|
Nice! Installed :D
|
Chen
it's a nice hack :) i was thinking about it :( "member of the month " next time i have to work faster then now :D thanks :) |
About 5 members here said they installed it, I visited their site, but couldn't see the hack installed..guys: where can I find an installed version? ..
Sounds like a great hack :) |
Quote:
|
Add the hack after require('./global.php');
|
that's a great hack, but i think it would be much more better if we limit only members have to post say, 100 posts before he can enter to the member of the day automatically, how can we do that? =)
|
Sure ckevin, just replace this in the code:
Code:
WHERE userid<>$daybits[1] Code:
WHERE userid<>$daybits[1] AND posts>99 |
wonderful, FireFly! :D
Thanks, Kevin |
What about having activity recently...say, the active within the past 2 weeks?
|
Huh? You mean only to select members that were active in the last 2 weeks?
|
Yes...that way it won't have a MoTD that hasn't been to the forums in 6 months :)
|
Replace:
Code:
WHERE userid<>$daybits[1] Code:
WHERE userid<>$daybits[1] AND lastactivity>".time()-(86400*14)." By the way, I'm not sure myself whether it's lastactivity or lastvisit we need to check, so I'm open for corrections here. :) |
Works. Thumbs up.
|
Great work my friend!
|
Quote:
|
how would you make this user of the week?
|
Quote:
where is it on the forum? |
Nice!
I was going to do something like this and I like the way you handled it. It's exactly how I handled it for my ubb homepage except you've taken advantage of the templates table, which I love. Used it to store random member id and random link id of the day and calling them to my homepage instead of the forum homepage. Featured link is already working. need to make a tiny profile summary box for the featured member. Will probably expand this for of features of the day like random trivia question of the day. I'll just add 2 more fields with todays trivia id and yesterdays trivia id. that way I can have todays question and the answer to yesterdays. (before you ask about the trivia. it's not a real hack. just added a table with 3 fields, id, question, & answer. then just grabbing the text. No admin form to edit them or anything. just phpmyadmin for now.) thanks again, it will get used alot. PS - was trying to think of a nice way to make it member of the week instead of day. I mean I know I could change it every 7 days, but it seems like I'd eventally knock it off by reseting it in the middle of the week or something. plus you'd need a check for end of the month / end of the year. anybody got a nice idea? the easy answer would be to just make it feature of the month bu that would be too long of a time period. |
It's possible to make this member of the week, just use the date() function (http://www.us2.php.net/manual/en/function.date.php) with W as the format... unless your forum won't be visited for a year (;)) you should be fine.
|
Quote:
|
Quote:
Though I am still using my original design and it uses a cronjob and doesn't store it in the text file. Though if I wanted to I could use my Member of the Day anywhere and it could automatically generate MOTD, MOTW, MOTM, and MOTY in one run. Also it isn't tied into any user accessing the forum so it happens when I want it to. |
Quote:
and hey about the memeber of the week thing, I am a little confused (beging to leran php) would I change it to something like this date('Y-m-W') ?? thanks for the help |
No, change it to date('W') only, and also only store that number (should give you a number from 1-52). Then compare the number in the template with the number you just got from the date() call.
If you want I can post the modified code here, but you should give it a try, it's not very hard. :) |
Apparently, I have done something wrong. I keep getting an SQL error. It seems to be on the "Order by RAND()" line.
I did the insert with no problems. Added the hack below the correct section and now index.php crashes. Even tried the reset for member of the day and it still crashed. Any ideas? Chris |
All times are GMT. The time now is 04:46 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|