vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   [SLOVED] The difference between today's date and the date of the creation of Thread (https://vborg.vbsupport.ru/showthread.php?t=296636)

omardealo 03-29-2013 03:10 PM

[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 !

kh99 03-29-2013 04:45 PM

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.

omardealo 03-29-2013 05:07 PM

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)
                            "
);
                            



kh99 03-29-2013 05:20 PM

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.

omardealo 03-29-2013 05:28 PM

Quote:

Originally Posted by kh99 (Post 2412964)
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


All times are GMT. The time now is 06:14 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.01171 seconds
  • Memory Usage 1,734KB
  • 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_code_printable
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete