Jump to content

Only 1hour time.. :) PHP TIME help, Thanks!


Gayner

Recommended Posts



  $last_draw=$plot['last_draw'];
        
                     
        $time_now=time();
        
        
        $next_draw=$last_draw+($plot['draw_days']*(3600*24));
        
        $plot['next_draw_time']=$next_draw;
                
        $sec_left=$next_draw-$time_now;
        
        $plot['next_draw']  =   date("dS of F Y h:i A",$next_draw);
        $plot['last_draw']  =   date("dS of F Y h:i A",$last_draw);

 

I need to edit

    $next_draw=$last_draw+($plot['draw_days']*(3600*24));
        

so it's only 1hour, what do I times it by using *? thx

Link to comment
Share on other sites

SO what is my *24 doing in there? Thanks in advance for ur help

Your code is 1 hour * 24 hours, which is one day.

$next_draw=$last_draw+($plot['draw_days']*(3600*24));

It should be this to be an hour:

$next_draw=$last_draw+($plot['draw_days']*(60*60));

 

Why are you doing draw_days when you want hours? or is it supposed to be one hour->day for your program?

Link to comment
Share on other sites

HMm now it took away the Day and made it 6hours, lol

 

 

0 days 6 hrs 49 mins and 36 secs

 

This is weird.

 

 

I think ur missing some more scripts to find out problem but I dont really want to post a 5000 line php code.. lol

 

We fixed the day tho.. now it's by hours, that's good but my draw_days  varchar(6)  field is set to 1.. and it shows 6hours because we edited that codes,

 

should i try my draw days field to like 0.01? then will it go to 1hour ? lol

 

EDIT: I tryed to make it 0.10 and my time went to 5hours lol if i put anything below that it messes it up

Link to comment
Share on other sites

Sorry I meant to say this line

$next_draw = $last_draw + 3600;

 

replaces this

$next_draw=$last_draw+($plot['draw_days']*(3600*24));

 

If it still doesn't work then please tell us, what your script is supposed to do and you're trying to. Post all relevant code here.

Link to comment
Share on other sites

Sorry I meant to say this line

$next_draw = $last_draw + 3600;

 

replace this

$next_draw=$last_draw+($plot['draw_days']*(3600*24));

 

If it still doesn't work then please tell us, what your script is supposed to do and you're trying to. Post all relevant code here.

 

Once I Did that, now it turns into:

1 day 4 hrs 15 mins and 45 secs

 

:(

 

herE is my code :( :

 

 

function make_countdown(){
        global $ibforums,$plot; 
        
        $last_draw=$plot['last_draw'];
        
                     
        $time_now=time();
        
        
   $next_draw=$last_draw+($plot['draw_days']*(3600*24));
        
        $plot['next_draw_time']=$next_draw;
                
        $sec_left=$next_draw-$time_now;
        
        $plot['next_draw']  =   date("dS of F Y h:i A",$next_draw);
        $plot['last_draw']  =   date("dS of F Y h:i A",$last_draw);


        
        if($sec_left <= '0'){
           $this->do_drawing();


           exit;
        }
       
        return  $sec_left;
        
   }
    
   function do_drawing(){
        
        global $ibforums,$plot,$INFO,$DB; 
   
        $count=0;
    $winning_numbers=array();        
    while($count < $plot['total_picks']){
            
        $this_num  = mt_rand ( $plot['min_number'], $plot['max_number']); 
        if(!in_array($this_num, $winning_numbers)){
            array_push($winning_numbers,$this_num);
            $count++;
        }
            
    }
    
   	    
    
    $db_pre=$INFO['sql_tbl_prefix'];
        $db_tickets = "$db_pre"."p_lottery_tickets";
        
        //delete old tickets
        $DB->query("delete FROM $db_tickets WHERE status != 'Pending'") or print mysql_error();
        
        $DB->query("SELECT * FROM $db_tickets WHERE status='Pending'") or print mysql_error();

	while($row = $DB->fetch_row()){  
	    
	    $picks=explode(',',$row['picks']);
        
        $matched=0;
        foreach($picks as $pick){
            
            if(in_array($pick,$winning_numbers)){
                $matched++;
            }   
        
        }
        
        
        if($matched >> '0'){
    	        
    	        if(!is_array($all_matched[$matched])){$all_matched[$matched]=array();}
                
                array_push($all_matched[$matched],$row);
                
            }
        
        }
       
        ##make this draw time today at the set time 
            
            $b_day=date("d");
            $b_month=date("m");
            $b_year=date("Y");
            
            $b_time=explode(':',$plot['draw_time']);
            
            
            
            $bought=mktime ( $b_time['0'], $b_time['1'], 0, $b_month, $b_day, $b_year);
       
        
        
        
        //go through all matches of wins
        foreach($plot['payouts'] as $mc){
           
            //do we have any with this no. of matches?
            if(is_array($all_matched[$mc['match']])){
                //yes there is atleast 1 match
                $count_match=count($all_matched[$mc['match']]);
                
                //is this a percentage?
                if($mc['type']=='percent'){
                    
                    $won=round( ($plot['pot']/100) * $mc['pays']);
                    
                    $plot['pot']=$plot['pot']-$won;
                    
                }else{
                
                    $won=$mc['pays'];
                
                }
                //do we divide it?
                if($mc['divide']=='1'){
                    
                    $won=$won/$count_match;
                    $plot['pot']=$plot['pot']-$mc['pays'];
                    
                }else{
                    
                    $plot['pot']=$plot['pot']-($mc['pays']*$count_match);
                
                }    
                
                $status='Winner';
                $matched=$mc['match'];
                
                
                $where='WHERE (id=-99 ';
                foreach($all_matched[$mc['match']] as $m){
                    
                    $where .= 'OR id='.$m['id'].' ';
                    
                    
                }
                $where.=')';
                //make the update query
                $query= "UPDATE $db_tickets set
                 `status`='$status',
                 `won`='$won',
                 `matched`='$matched',
                 `bought_time`='$bought'
                 
                 
                  $where";
                 
                  $DB->query($query) or print mysql_error();
                  
                 
                  
                  
               
            }
            
            
            
        }
        
        //make the rest losers
            $query= "UPDATE $db_tickets set
                 `status`='Loser',
                 `won`='n/a',
                 `matched`='n/a',
                 `bought_time`='$bought'
                 
                 
                  WHERE `status` != 'winner'";
                $DB->query($query) or print mysql_error();



         //update lottery settings
         sort($winning_numbers);
         $winning_numbers=implode('-',$winning_numbers);
            $db_pre = $INFO['sql_tbl_prefix'];
            $db_settings = "$db_pre" . "p_lottery"; 
            
            if($plot['pot'] <= $plot['pot_start']){$plot['pot']=$plot['pot_start'];}
          $DB->query( "UPDATE $db_settings set

			`pot`	        =		'{$plot['pot']}',
			`ticket_count`	=		'0',
			`last_draw`     =       '$bought',
			`last_numbers`  =       '$winning_numbers' 
		" ) or print mysql_error();
       
        $this->give_winners_points();
        $loc =  $this->base_url;
        header("location:$loc");
         
   
   }

Link to comment
Share on other sites

 function p_show_front($message=''){
        
        global $ibforums,$plot; 
        
        $cd             =  $this->make_countdown();
        
        $last_draw      =  $this->make_last_draw();
        
        $next_draw      = $this->next_draw();
        
	$form           = $this->make_form();
	$records        = $this->make_records();

	if($plot['action']=='settings'){

	    $your_tickets   = $this->p_settings();

	}elseif($plot['action']=='payouts'){

	    $your_tickets   = $this->p_payouts();
	    

	}elseif($plot['action']=='holders'){

	    $your_tickets   = $this->p_holders();

	      
	}else{

	    $your_tickets   = $this->make_your_tickets();

	}


	$this->output     =   $this->html->front_page($form,$your_tickets,$message,$next_draw,$last_draw,$cd,$records);    	
        
        
  	
  	}

 

This one ? it shows $this->make_countdown();

 

 

I know what u mean tho, this is all i can find of make_countdown do i need to find more for u

 

Im trying im best to help u help me. dont worry :P

Link to comment
Share on other sites

WTF! This script is terrible. Where on earth did you get this crap! Sorry but I'm not going to help you any further. You should dump the script and find something else.

:facewall: :facewall:

 

What do u mean? This script is a wonderful lottery script man..

 

It works fine, I know i need to add mysqlreal escape to secure it but other then that it's fine bro.. just little dirty i guess?  I just want to make it so it's not 1 day 24 hours 59 min and 59 seconds I want it to be 0 days 1 hour.. lol that's all :)

 

 

Then $cd is for:

 

<script language='JavaScript' type="text/javascript">countdown($cd);</script>

 

which is:

 

function countdown(Time_Left)
         {
         Today = new Date();
       
         
         if(Time_Left < 0)
            Time_Left = 0;
            time_left2=Time_Left;
        
                    days = Math.floor(Time_Left / (60 * 60 * 24));
                    Time_Left %= (60 * 60 * 24);
                    hours = Math.floor(Time_Left / (60 * 60));
                    Time_Left %= (60 * 60);
                    minutes = Math.floor(Time_Left / 60);
                    Time_Left %= 60;
                    seconds = Time_Left;
                    
                    dps = 's'; hps = 's'; mps = 's'; sps = 's';
                    //ps is short for plural suffix.
                    if(days == 1) dps ='';
                    if(hours == 1) hps ='';
                    if(minutes == 1) mps ='';
                    if(seconds == 1) sps ='';
                    
                    document.getElementById("countdown").innerHTML = days + ' day' + dps + ' ';
                    document.getElementById("countdown").innerHTML += hours + ' hr' + hps + ' ';
                    document.getElementById("countdown").innerHTML += minutes + ' min' + mps + ' and ';
                    document.getElementById("countdown").innerHTML += seconds + ' sec' + sps;
               
               
         //Recursive call, keeps the clock ticking.
         time_left2--;
         setTimeout('countdown('+time_left2+');', 1000);
         }

 

But that's client side htat has nothing to do with, the php is the part that makes that javascript work that's what I need help on the php part :)

 

There is some more code u might find useful sir, please help!

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.