PDA

View Full Version : Miscellaneous Hacks - Countdown to Dates Plugin


jamoss
09-15-2007, 10:00 PM
Based on Sinclair's hack: https://vborg.vbsupport.ru/showthread.php?t=40557

I modified it to make it a plug-in for 3.6 +

Usage:
Users enter the code y,m,d

Example:
2007,12,25 Christmas!

ONLY ONE STEP: EASY!

Go to your admin panel and CREATE NEW PLUGIN.

- Hook Location: BBCODE_PARSE_COMPLETE

- Enter this code in the PHP code box:

preg_match("/(\[)(countdown)(])(\r\n)*([^\"]*)(\[\/countdown\])/siU", $text, $datum);

$dato=$datum[0];

$datr=explode(",",$dato);

$datr[0]=str_replace("[countdown]", "", $datr[0]);
$jahr=intval($datr[0]);
$monat=intval($datr[1]);
$tag=intval($datr[2]);
$stunde=intval($datr[3]);
$minute=intval($datr[4]);
$sekunde=intval($datr[5]);
$target = mktime($stunde,$minute,$sekunde,$monat,$tag,$jahr) ;
$todayo = mktime(0,0,0,date("m"),date("d"),date("Y"));
$diff = ($target - $todayo)/86400;
if ($todayo==$target) { $out= "TODAY "; }
else if ($diff==1) { $out = "1 day until "; }
else if ($diff==(-1)) { $out = "1 day since "; }
else {
if ($diff>0) {
$diff=round($diff,0);
$out="$diff days until ";
}
if ($diff<0) {
$diff=round(-$diff, 0);
$out="$diff days since ";
}
}

$text = preg_replace("/(\[)(countdown)(])(\r\n)*([^\"]*)(\[\/countdown\])/siU", $out, $text);


That's it! Now announce to your users they can use that code.

FreshFroot
09-16-2007, 09:29 PM
interesting stuff, will have to try it and see.

thanks.

El Burro
09-16-2007, 10:32 PM
Installed and working.

Just difficult to explain use as [countdown] still works inside [code]

Thanks

SMO
09-17-2007, 02:06 AM
how hard you think it is to make this a vba module?

Floris
09-17-2007, 05:59 AM
Small question, if I visit the thread where [countdown] has been used a few days later, will it then say instead of 14 days until October ... 12 days until october? Or is it a one time thing?

Floris
09-17-2007, 07:05 AM
When I go back to the thread at a later time, it stops working .. it becomes plaintext again. I think this mod is super alpha, and hasn't been fully tested, I am sorry .. but I feel I have to uninstall it right now and wait a few updates before using it again.

El Burro
09-17-2007, 07:34 AM
I'm uninstalling too.
Sorry it's no good if it doesn't keep changing the countdown.

bazzup
09-17-2007, 10:08 AM
looks a good prospect i just use the sig countdown timer at the moment but will use this if it gets sorted

stonner
09-17-2007, 06:04 PM
can anyone provide a screeshot or demolink?

thank you

thincom2000
09-17-2007, 07:35 PM
Why isn't this a bb-code? That would fix a lot of issues, and I would install it if it was.

Check out /includes/class_bbcode.php (particularly the end) for some ideas. You would make this a function and add it to the bbcode_create hook (trust me, don't use the bbcode_fetch_tags hook -- it would conflict with many mods). Then use the 'external_callback' field to connect the function to your bbcode. Oh, and you will need to disable post caching (even in your current code).

Add to your bbcode function: $parser->options['cachable'] = false;

jamoss
09-17-2007, 07:45 PM
Thanks for the feedback! I'll check out the bugs.

Hornstar
09-18-2007, 07:44 AM
I'll keep an eye on this. thanks.

PinkDaisy
09-29-2007, 11:50 AM
Can this work in a sigature??

wickedstangs
09-29-2007, 12:16 PM
Installed and seems to be working fine on vBulletin® Version 3.6.8

Masiello
09-30-2007, 09:05 PM
When I go back to the thread at a later time, it stops working .. it becomes plaintext again. I think this mod is super alpha, and hasn't been fully tested, I am sorry .. but I feel I have to uninstall it right now and wait a few updates before using it again.
Same here damn, it's be good for my board when code is fixed.
vB 3.6.8

HellBoy
11-12-2007, 11:38 AM
Having the same issues as Floris on Masiello. vB 3.6.8 patch level 2.
Seems like a nice little add on, so I will be keeping an eye out for future updates.

Mum
12-06-2007, 11:33 PM
Same as the others, the next day this changes to plain text. So doesn't work.

Mum
01-26-2008, 06:46 AM
Any update to fix this?

Goomzee
10-08-2008, 08:13 AM
Plz Update for 3.7.3