Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    May 2011
    Posts
    303
    Thanks
    29
    Thanked 0 Times in 0 Posts

    time since last submissions

    hi

    here is my whole submit function; http://pastebin.com/qdCGV4kD

    i wanna add a "time since last submit" feature to this bit:
    PHP Code:
                                          // 24 hour mod start, rewritten and optimized by Chris.
                                            //Get time and call for last 24 hr time stamp.
                                            
    $Time time();
                                            
    $Day = (60*60*24);
                                            
    $Time = ($Time $Day);
                                           
                                            
    $Site mysql_real_escape_string($_POST['sname']);
                                           
                                            
    //Lookup site and get its ID for next 2 queries
                                            
    $querySite = ("SELECT * FROM wcddl_sites WHERE name='$Site'");
                                            
    $resultSite mysql_query($querySite);
                                            
    $rowSite mysql_fetch_array($resultSite);
                                           
                                            
    //Get number of downloads already stored within last 24hrs
                                            
    $queryDownloads = ("SELECT * FROM wcddl_downloads WHERE sid='$rowSite[id]' and dat > '$Time'");
                                            
    $resultDownloads mysql_query($queryDownloads);
                                            
    $countDownloads mysql_num_rows($resultDownloads);
                                           
                                            
    //Get number of downloads in queue already stored within last 24hrs
                                            
    $queryQueue = ("SELECT * FROM wcddl_queue WHERE sid='$rowSite[id]'");
                                            
    $resultQueue mysql_query($queryQueue);
                                           
                                            if (!
    $countQueue mysql_num_rows($resultQueue)) {
                                                    
    //If nothing in queue and mysql_num_rows returns false, set to 0
                                                    
    $countQueue 0;
                                            }
                                           
                                            
    //Get total count of everything submitted in last 24 hrs (inc queued items that have been submitted anytime)
     
                                            
    $totalCount = ($countQueue $countDownloads);
                                           
                                            for(
    $i=0;$i<=count($titles)-1;$i++) { // loop thru the input fields
                                                    
    if(!$this->allow_dupes) { // check for dupe titles or urls
                                                            
    unset($downDupe);
                                                            
    $downDupe mysql_query("SELECT COUNT(*) FROM wcddl_downloads WHERE url = '".mysql_real_escape_string($urls[$i])."'");
                                                            
    $downDupe mysql_result($downDupe,0);
                                                            if(
    $downDupe 1)
                                                                    unset(
    $downDupe);
                                                    } 
    // dupe check end
                                                   
                                                    //Check each row of fields is set
                                                    
    if(!empty($titles[$i]) && !empty($urls[$i]) && !empty($types[$i]) && (in_array(strtolower($types[$i]),$this->allowed_types) || in_array($types[$i],$this->allowed_types)) && !isset($downDupe)) {
                                                           
                                                            
    //If total submitted items more than allowed.
                                                            
    if ($totalCount >= $this->Limit) {
                                                                    
    //Print error, break out and process no more
                                                                    
    $this->Output '<center><div class="error_message">You can not submit any more downloads as you have reached your daily limit.</div></center>';
                                                                    break;
                                                                    }
     
                                                            
    //All set so insert details.
                                                            
    mysql_query("INSERT INTO wcddl_queue (sid,title,type,url) VALUES ('".mysql_real_escape_string($sid)."','".mysql_real_escape_string($titles[$i])."','".mysql_real_escape_string($types[$i])."','".mysql_real_escape_string($urls[$i])."')");
                                                           
                                                            
    $totalCount++;
                                                           
                                                            
    $amountLeft = ($this->Limit $totalCount);
                                                            
    $this->Output '<center><div class="success_message">'.$totalCount.' downloads were successfully submitted in the last 24 hours!<br>
                                                            You have '
    .$amountLeft.' of '.$this->Limit.' submissions left.</div></center>';
                                                            
    // 24 hour mod end, rewritten and optimized by Chris. 
    thats my limit mod, i havee time fields in the queue n downloads table......

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,455
    Thanks
    8
    Thanked 1,084 Times in 1,075 Posts
    All I see on your pastebin is a "survey" box.

    Do you have a column in your database table where you can store a timestamp?
    Simply the time() value whenever they update the table.

    $timestamp=time();

    Then update that column in the table.

  • #3
    Regular Coder
    Join Date
    May 2011
    Posts
    303
    Thanks
    29
    Thanked 0 Times in 0 Posts
    srry bwt tht

    yea i ave timestap fields in DB, i need to store te tiimes so the user sees each time when they sbmit + the need to end when they reacch 24 hrs
    Last edited by Inigoesdr; 01-10-2012 at 09:18 PM. Reason: No.

  • #4
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,213
    Thanks
    12
    Thanked 338 Times in 334 Posts
    Quote Originally Posted by mlseim View Post
    Do you have a column in your database table where you can store a timestamp?
    Simply the time() value whenever they update the table.

    $timestamp=time();

    Then update that column in the table.
    for the more advanced SQL users, there is the possibility to make the DB track those times itself. for an INSERT query just define a default value (e.g. CURRENT_TIMESTAMP) then the current time is automatically assigned. for an UPDATE query it would probably be best to use a trigger.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #5
    Regular Coder
    Join Date
    May 2011
    Posts
    303
    Thanks
    29
    Thanked 0 Times in 0 Posts
    so can any1 hellp me?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •