Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-23-2008, 05:05 PM
gpc10347 gpc10347 is offline
 
Join Date: May 2008
Posts: 180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Update A Users Birthday - Nightly as Task

I know I'll probably be quickly told that I must gnarfle the garthok for even asking such a silly question, but (there's always a but), I'd like to create a Scheduled Task to run specifically to update a users date of birth to the day coming (Each day would then be the users' birthday)...

I gather from reading the manual, I'd need to set the task to run before the Birthday Message task and all that for the following day. I also need to create a PHP file to update the user record by the userID -

The questions I have are regarding where one would put the PHP file in order to prevent a bot or user from being able to run in (inadvertantly) and, if anyone has a snippet that would do this safely...

(Call it Groudhog Day...)
Thanks for any assistance with this rather oddball inquiry
Reply With Quote
  #2  
Old 07-23-2008, 05:46 PM
calorie calorie is offline
 
Join Date: May 2003
Posts: 2,804
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The untested snippet below should update the birth date for userids 1, 2, and 3. Edit the code as desired and then use the ACP to set up a new cron job that runs once a day:
Code:
<?php

// ########################## SET PHP ENVIRONMENT ###############################
error_reporting(E_ALL & ~E_NOTICE);

// ###################### PREVENT UNAUTHORIZED ACCESS ###########################
if (!is_object($vbulletin->db))
{
	exit();
}

// ############################ SET NEEDED DATES ################################
$birthday = date('m-d-Y', TIMENOW);
$birthday_search = date('Y-m-d', TIMENOW);

// ################# UPDATE BIRTHDAY FOR USERID 1, 2 AND 3 ######################
$birthdays = $vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user
	SET birthday = '" . $vbulletin->db->escape_string($birthday) . "',
	birthday_search = '" . $vbulletin->db->escape_string($birthday_search) . "'
	WHERE userid IN (1,2,3)
");

// ############################ LOG CRON ACTION #################################
log_cron_action('', $nextitem, 1);

?>
Reply With Quote
  #3  
Old 07-23-2008, 07:07 PM
gpc10347 gpc10347 is offline
 
Join Date: May 2008
Posts: 180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This oughtta be a great addition to what is already an silly place..

I'll report back with the results!

Thanks loads!!

--------------- Added [DATE]1216844527[/DATE] at [TIME]1216844527[/TIME] ---------------

Awesome. the system now says it's their birthday...

What's the format to make them say perpetually 29 years old though instead of zero? (I"m concerned they won't be able to see the threads!)

; )


Got it! I likely didn't put the conversion in as nicely as some but I managed to make the user's birthday today less 29 years... Perfect! Thanks again!
Reply With Quote
  #4  
Old 07-26-2008, 01:37 PM
gpc10347 gpc10347 is offline
 
Join Date: May 2008
Posts: 180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is what I attempted to use and, it's likely wrong and watching it work doesn't error but my confidence isn't good...

What's the best way to keep a user 29 for the rest of her life?

PHP Code:
$birthday1 mktime(010date("m"), date("d"), date("Y")-29);
$birthday date('m-d-Y'$birthday1);
$birthday_search date('Y-m-d'TIMENOW); 
Reply With Quote
  #5  
Old 07-29-2008, 03:44 PM
gpc10347 gpc10347 is offline
 
Join Date: May 2008
Posts: 180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have to go to the Usergroup Manager for the usergroup this user is in and re-save the page where "Birthdays Viewable " is located to have it appear within the Today's Borthdays module in CMPS... (I know: Not A vBulletin issue but you have to admit, it's an interesting oddity: I named the task Groundhog Day)

PHP Code:
<?php

// ########################## SET PHP ENVIRONMENT ###############################
error_reporting(E_ALL & ~E_NOTICE);

// ###################### PREVENT UNAUTHORIZED ACCESS ###########################
if (!is_object($vbulletin->db))
{
    exit();
}

// ############################ SET NEEDED DATES ################################
$birthday date('m-d-Y'strtotime("-29 years"));
$birthday_search date('Y-m-d'strtotime("-29 years"));

// ################# UPDATE BIRTHDAY FOR USERID 1, 2 AND 3 ######################
$birthdays $vbulletin->db->query_write("UPDATE " TABLE_PREFIX "user
    SET birthday = '" 
$vbulletin->db->escape_string($birthday) . "',
    birthday_search = '" 
$vbulletin->db->escape_string($birthday_search) . "'
    WHERE userid IN (7,46)
"
);

// ############################ LOG CRON ACTION #################################
log_cron_action(''$nextitem1);

?>
Anything telltale about that?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:10 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
  • Page Generation 0.04069 seconds
  • Memory Usage 2,212KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete