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

Reply
 
Thread Tools Display Modes
  #11  
Old 01-06-2005, 12:46 AM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

For one thing, your equation is wrong. If you were trying to find posts from 2 days and 3 hours ago, which is possible to do, you would end up with
2*3*60*60, which isn't right.

What you need to do is to say that if hours, minutes, days, etc. aren't set, they are equal to 0.

Then, your math looks like (days *24*60*60) + (hours *60*60) + (minutes*60) + seconds.
Reply With Quote
  #12  
Old 01-06-2005, 01:34 AM
trevelyn1015 trevelyn1015 is offline
 
Join Date: Dec 2004
Posts: 147
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

so, amy, why does everything work fine, but minutes?

www.ranger-forums.com/forum2
Reply With Quote
  #13  
Old 01-06-2005, 02:07 AM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It won't work for seconds.

You got lucky with hours, because days is set to 1.

The equation for hours is TIMENOW - ($hours *60*60)

because there are 60 minutes in an hour and 60 seconds in a minute.

Anything bigger than an hour isn't a problem because your math holds true. The problem is with the minutes and seconds.
Reply With Quote
  #14  
Old 01-06-2005, 02:43 AM
trevelyn1015 trevelyn1015 is offline
 
Join Date: Dec 2004
Posts: 147
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

so what should i do, amy?

the original string of code for that section looked like this:

Code:
// #############################################################################
if ($_REQUEST['do'] == 'getnew' OR $_REQUEST['do'] == 'getdaily')
{
	globalize($_REQUEST, array(
		'forumid' => INT,
		'days' => INT,
		'exclude' => STR
	));

	// get date:
	if ($_REQUEST['do'] == 'getnew' AND $bbuserinfo['lastvisit'] != 0)
	{
		// if action = getnew and last visit date is set
		$datecut = $bbuserinfo['lastvisit'];
	}
	else
	{
		$_REQUEST['do'] = 'getdaily';
		if ($days < 1)
		{
			$days = 1;
		}
		$datecut = TIMENOW - (24 * 60 * 60 * $days);
	}
Reply With Quote
  #15  
Old 01-06-2005, 08:40 AM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
     if ($_REQUEST['do'] == 'getnew' AND $bbuserinfo['lastvisit'] != 0)
     {
          
// if action = getnew and last visit date is set
          
$datecut $bbuserinfo['lastvisit'];
     }
     else
     {
          
$_REQUEST['do'] = 'getdaily';
          if (
$days 1)
          {
               
$days 1;
          }

          if (!
$hours)
          {
               
$hours 0;
          }

          if (!
$minutes)
          {
               
$minutes 0;
          }
          
$datecut TIMENOW - ($hours $minutes $days);
     } 
ok if i half understood what amy's saying, she's saying try that
Reply With Quote
  #16  
Old 01-06-2005, 10:21 AM
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Location: England
Posts: 9,071
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can't default the variables to 0, that'll make it TIMENOW - 0 when you multiply anything by it.
Reply With Quote
  #17  
Old 01-06-2005, 10:53 AM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dean C
You can't default the variables to 0, that'll make it TIMENOW - 0 when you multiply anything by it.
Exactly, Dean. That's what you want to happen.

And, no Saber. That's not what I was saying My board is down right now so I can't test this, but I imagine it would look like this:

Code:
	else
	{
		$_REQUEST['do'] = 'getdaily';
		if (($days < 1)AND(!$hours)AND(!$minutes)AND(!$seconds))
		{
			$days = 1;
                        $hours = 0;
                         $minutes = 0;
                         $seconds = 0;
			
		}
		elseif($days < 1) {
                       $days = 0;
                }
		$datecut = TIMENOW - (($days*24*60*60) + ($hours*60*60) + ($minutes*60) + $seconds);
		
	}
Doing it this way doesn't mess up the original usage - if no variables are set, it should default to 1 day. If any combination of days, hours or minutes are set though, it should work.

Within that elseif block, you should check to see if the hours, minutes and seconds are properly set and initialize them to 0 if not.
Reply With Quote
  #18  
Old 01-06-2005, 01:02 PM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

my site's back up, and it seems like it works as I posted it.
Reply With Quote
  #19  
Old 01-06-2005, 05:11 PM
trevelyn1015 trevelyn1015 is offline
 
Join Date: Dec 2004
Posts: 147
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

amykhar is my hero!!!
Reply With Quote
  #20  
Old 01-06-2005, 05:13 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by amykhar
my site's back up, and it seems like it works as I posted it.
your smarts >>>>>>>>>>> mine
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 09:15 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.04350 seconds
  • Memory Usage 2,285KB
  • Queries Executed 14 (?)
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
  • (2)bbcode_code
  • (1)bbcode_php
  • (2)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
  • (2)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