Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-21-2005, 04:16 PM
Nullifi3d Nullifi3d is offline
 
Join Date: Apr 2004
Location: FL, USA
Posts: 215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default showthread_query hook sql

PHP Code:
$banner $db->query_first("SELECT userid, title, ext, width, height FROM " TABLE_PREFIX "banners WHERE status = 'active' AND available >= 1 ORDER BY RAND() LIMIT 1");
if(
ctype_digit($banner['userid'])) {
    
//show it
} else {
    
//show default

The above code works fine and prints out code when the user's status is active and their available impressions is at least 1. I want to modify it to also check if the user has posted within the past 24 hours. I don't know how to though as I am using my own table in the vbulletin database to store the banner information. As you see above the query that fetches the data I need is querying from the table banners. From my knowledge I would need to fetch the last post time from the lastpostdate column in the user table. But how would I add this to my query so all three of these are factored in when it gets the one random array ($banner[]) from the banners table?

As well I would like to setup the query to also not pick the row in the banners table that matches the vistor's userid (so users do not see their own banners being displayed).
Reply With Quote
  #2  
Old 10-21-2005, 04:31 PM
JTyson JTyson is offline
 
Join Date: Apr 2005
Location: This Thread
Posts: 140
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$vbulletin->userinfo['lastpost']

should give you that info
Reply With Quote
  #3  
Old 10-21-2005, 07:48 PM
Nullifi3d Nullifi3d is offline
 
Join Date: Apr 2004
Location: FL, USA
Posts: 215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by JTyson
$vbulletin->userinfo['lastpost']

should give you that info
Not enough info... Seems to be an array? This doesn't seem to answer my question very well.
Reply With Quote
  #4  
Old 10-21-2005, 08:48 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
if ($vbulletin->userinfo['lastpost'] > (TIMENOW-86400))
{
// User has posted in the last 24 hours

Reply With Quote
  #5  
Old 10-27-2005, 05:54 PM
Nullifi3d Nullifi3d is offline
 
Join Date: Apr 2004
Location: FL, USA
Posts: 215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Andreas
PHP Code:
if ($vbulletin->userinfo['lastpost'] > (TIMENOW-86400))
{
// User has posted in the last 24 hours

Wouldn't this be how to check if the user that is viewing the page has been online in the last 24 hours? That's not what I need if it is.
Reply With Quote
  #6  
Old 10-27-2005, 06:15 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Nullifi3d
Wouldn't this be how to check if the user that is viewing the page has been online in the last 24 hours? That's not what I need if it is.
I would imagine that 'lastpost' is exactly what it says, 'lastactivity' is what you are referring to.
Reply With Quote
  #7  
Old 10-27-2005, 07:50 PM
Nullifi3d Nullifi3d is offline
 
Join Date: Apr 2004
Location: FL, USA
Posts: 215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yea, but if you take a look at the code in my first post you'll see that I don't need to find out if the current visitor of the page has posted in the last 24 hours. Rather I need to find out if the random user that is generated has posted in the last 24 hours.

Basically my code is a random banner rotator built into vbulletin. I want to change my code which uses sql (in my first post) to randomly pick out a userid from the database so that it randomly picks one out that has posted within the last 24 hours.

Sorry if I'm wrong and just having a brain fart.
Reply With Quote
  #8  
Old 11-08-2005, 08:46 PM
Nullifi3d Nullifi3d is offline
 
Join Date: Apr 2004
Location: FL, USA
Posts: 215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Does anyone have any further comments or suggestions? I need this addition to my mod please.
Reply With Quote
  #9  
Old 11-08-2005, 10:22 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

[SQL]SELECT userid FROM user WHERE lastpost > UNIX_TIMESTAMP(NOW())-86400 ORDER BY RAND() LIMIT 1[/sql]

If that is what you want
Reply With Quote
  #10  
Old 11-09-2005, 10:20 AM
Nullifi3d Nullifi3d is offline
 
Join Date: Apr 2004
Location: FL, USA
Posts: 215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Andreas
If that is what you want
Yes that is part of what I want. This query would select 1 random user that has posted within the last 24 hours from the mysql table, but the only problem is that this needs to coincide with my sql from the first post which picks 1 random user from a different table in the database.

Is there a way to do this? Maybe having a query store all members that have posted within the last 24 hours in an array or something. Then another query pick 1 by random (according to calls from the query in my first post) from the array. Basically I need to combine these two sql queries together:
[sql]SELECT userid FROM " . TABLE_PREFIX . "user WHERE lastpost > UNIX_TIMESTAMP(NOW())-86400 ORDER BY RAND() LIMIT 1[/sql]
[sql]SELECT userid, title, ext, width, height FROM " . TABLE_PREFIX . "banners WHERE status = 'active' AND available >= 1 ORDER BY RAND() LIMIT 1[/sql]
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 03:52 AM.


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.04654 seconds
  • Memory Usage 2,265KB
  • 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
  • (3)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete