vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.6 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=194)
-   -   Miscellaneous Hacks - Countdown to Dates Plugin (https://vborg.vbsupport.ru/showthread.php?t=157995)

jamoss 09-15-2007 10:00 PM

Countdown to Dates Plugin
 
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 [countdown]y,m,d[/countdown]

Example:
[countdown]2007,12,25[/countdown] 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:
Quote:

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;


All times are GMT. The time now is 03:55 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01270 seconds
  • Memory Usage 1,728KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete