vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   search.php - help needed - "getdaily" (https://vborg.vbsupport.ru/showthread.php?t=73834)

trevelyn1015 01-05-2005 06:41 PM

search.php - help needed - "getdaily"
 
PHP Code:

// #############################################################################
if ($_REQUEST['do'] == 'getnew' OR $_REQUEST['do'] == 'getdaily'

     
globalize($_REQUEST, array( 
          
'forumid' => INT
          
'days' => INT
          
'hours' => INT
          
'minutes' => INT,
          
'seconds' => 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
          } 
 
          if (!
$hours
          { 
               
$hours 24
          } 
 
          if (!
$minutes
          { 
               
$minutes 60
          } 
          
          if (!
$seconds
          { 
               
$seconds 60;
           }
          
$datecut TIMENOW - ($hours $minutes $seconds $days); 
     } 

why doesn't that work for getting daily posts by minutes?

hours and days work? but not minutes... why not?

for:

search.php?do=getdaily&minutes=15

search.php?do=getdaily&hours=1

search.php?do=getdaily&days=1

days work, hours, work, but minutes don't...

any help

15 minutes is pulling up last 6 hours
30 minutes is pulling up last 9 hours
45 minutes is pulling up last 18 hours

Zachery 01-05-2005 06:44 PM

Quote:

Originally Posted by trevelyn1015
PHP Code:

// #############################################################################
if ($_REQUEST['do'] == 'getnew' OR $_REQUEST['do'] == 'getdaily'

     
globalize($_REQUEST, array( 
          
'forumid' => INT
          
'days' => INT
          
'hours' => INT
          
'minutes' => INT,
          
'seconds' => 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
          } 
 
          if (!
$hours
          { 
               
$hours 24
          } 
 
          if (!
$minutes
          { 
               
$minutes 60
          } 
          
          if (!
$seconds
          { 
               
$seconds 60;
           }
          
$datecut TIMENOW - ($hours $minutes $seconds $days); 
     } 

why doesn't that work for getting daily posts by minutes?

hours and days work? but not minutes... why not?

for:

search.php?do=getdaily&minutes=15

search.php?do=getdaily&hours=1

search.php?do=getdaily&days=1

days work, hours, work, but minutes don't...

any help

where are you defining thoughs varibles ? :)

trevelyn1015 01-05-2005 06:48 PM

1 Attachment(s)
in the url...

with code's that look like this (ignore the "month" one)

trevelyn1015 01-05-2005 07:59 PM

well? :)

Zachery 01-05-2005 08:03 PM

Quote:

Originally Posted by trevelyn1015
well? :)

What code where?

trevelyn1015 01-05-2005 08:09 PM

the attached thumbnail image... showing how i edited the navbar template for the links...

there is more editing done than that, of course... i just took a screenshot of the links

Zachery 01-05-2005 08:11 PM

Quote:

Originally Posted by trevelyn1015
the attached thumbnail image... showing how i edited the navbar template for the links...

there is more editing done than that, of course... i just took a screenshot of the links

Where are you defining thoughs varibles in THE PHP

trevelyn1015 01-05-2005 08:23 PM

i don't understand what you are saying...

do you have aol instant messenger?

sabret00the 01-05-2005 08:48 PM

the $days variable isn't defined either, so i don't think it needs to be deined i think the issue is the the TIMENOW() fucntion, he's gotta work out which is for which.

trevelyn1015 01-05-2005 11:20 PM

yeah... anyone know what to do here? :)

amykhar 01-06-2005 12:46 AM

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.

trevelyn1015 01-06-2005 01:34 AM

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

www.ranger-forums.com/forum2

amykhar 01-06-2005 02:07 AM

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.

trevelyn1015 01-06-2005 02:43 AM

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


sabret00the 01-06-2005 08:40 AM

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 :)

Dean C 01-06-2005 10:21 AM

You can't default the variables to 0, that'll make it TIMENOW - 0 when you multiply anything by it. :)

amykhar 01-06-2005 10:53 AM

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.

amykhar 01-06-2005 01:02 PM

my site's back up, and it seems like it works as I posted it.

trevelyn1015 01-06-2005 05:11 PM

amykhar is my hero!!!

sabret00the 01-06-2005 05:13 PM

Quote:

Originally Posted by amykhar
my site's back up, and it seems like it works as I posted it.

your smarts >>>>>>>>>>> mine :p

trevelyn1015 01-06-2005 05:21 PM

you were very kind, though, sabre, to help me...

thanks alot...

trevelyn1015 01-06-2005 05:40 PM

hack released: https://vborg.vbsupport.ru/showthread.php?t=73893


All times are GMT. The time now is 10:24 AM.

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.01245 seconds
  • Memory Usage 1,806KB
  • 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
  • (2)bbcode_code_printable
  • (3)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (22)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