Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 03-29-2013, 03:10 PM
omardealo's Avatar
omardealo omardealo is offline
 
Join Date: Nov 2008
Location: egypt
Posts: 235
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default [SLOVED] The difference between today's date and the date of the creation of Thread

HELLO ...

i make new filed in table thread .. and i want SET or UPDATE data of this filed After some days

LIKE THIS :

PHP Code:
if (today's date (TIMENOW) - creation of Thread (dateline) >= 30 days)
{
SET or UPDATE thisfiled in thread table to (new data)


Do I need to use SQL QUERY OR there is a simple code for that
and what's name of hook to this plugin ...

i use this code but not work ... in global_start hook
PHP Code:
$vbulletin->db->query_write("UPDATE " TABLE_PREFIX " thread 
                                SET user_contact = 'anything' 
                                WHERE
dateline <= ' . intval(TIMENOW - (60 * 60 * 24 * "
.$vbulletin->options['user_contact_time'].")).'
                            "
); 

I have another question here about same filed
https://vborg.vbsupport.ru/showthread.php?t=296543


Thank you !
Reply With Quote
  #2  
Old 03-29-2013, 04:45 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You have a couple of problems with that code. Try this:

Code:
$cutoff = TIMENOW - (60 * 60 * 24 * $vbulletin->options['user_contact_time']);
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "thread 
                                SET user_contact = 'anything' 
                                WHERE dateline <= $cutoff
                            ");

As for where to put it, it might work at global_start, but I don't think you want it to run every time anyone accesses any page. You could use cron_script_cleanup_hourly and have it run once per hour, if that works for you.
Reply With Quote
  #3  
Old 03-29-2013, 05:07 PM
omardealo's Avatar
omardealo omardealo is offline
 
Join Date: Nov 2008
Location: egypt
Posts: 235
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Exactly , I do not want it running SQL QUERY all day , that's Will happen over load to Server
but I do not know much about the cron of vb ... can u help me for that (Is there any thread link talk about explanation run this code once every 24 hours or every hour)
and i Ask from you to consider on this topic, there is simple question but important for me
https://vborg.vbsupport.ru/showthread.php?t=296543

thnx u very much the code now Works well


PHP Code:
if ($vbulletin->options['user_contact_onoff'])
{  
$cutoff TIMENOW - (60 60 24 $vbulletin->options['user_contact_time']);
$vbulletin->db->query_write("UPDATE " TABLE_PREFIX "thread 
                                SET user_contact = 'anything' 
                                WHERE dateline <= 
$cutoff
                                AND
                                (user_contact != 'anything' OR user_contact IS NOT NULL)
                            "
);
                            

Reply With Quote
  #4  
Old 03-29-2013, 05:20 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You should be able to have it run once per hour or day just by changing the hook location of your plugin: cron_script_cleanup_daily = once per day, cron_script_cleanup_hourly = once per hour. Note that those don't run at exact times, it will depend on how much activity your forum has.
Reply With Quote
  #5  
Old 03-29-2013, 05:28 PM
omardealo's Avatar
omardealo omardealo is offline
 
Join Date: Nov 2008
Location: egypt
Posts: 235
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
You should be able to have it run once per hour or day just by changing the hook location of your plugin: cron_script_cleanup_daily = once per day, cron_script_cleanup_hourly = once per hour. Note that those don't run at exact times, it will depend on how much activity your forum has.
I understand now, sorry I thought you speak for cron system in vbulletin ...
Well, i will use this hooks ... Thanks again
Do not forget to consider this topic
https://vborg.vbsupport.ru/showthread.php?t=296543
Reply With Quote
Reply

Thread Tools
Display Modes

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 08:22 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07014 seconds
  • Memory Usage 2,210KB
  • Queries Executed 13 (?)
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
  • (3)bbcode_php
  • (1)bbcode_quote
  • (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_postinfo_query
  • fetch_postinfo
  • 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