Pre Time

Started by swizzles, September 12, 2012, 09:42:21 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Kristoffer

Where can i find a good pre-time url?

Cheers

swizzles

This was requested by xxandeer, here is what was posted back in the day

"Posted 22 February 2010 - 08:36 PM
SQL:

ALTER TABLE `torrents` ADD `pretime` INT( 11 ) DEFAULT '0' NOT NULL ;




torrenttable_functions.php (You can add this anywhere.)

function get_pretime($st) {
   $secs = $st;
   $mins = floor($st / 60);
   $hours = floor($mins / 60);
   $days = floor($hours / 24);
   $week = floor($days / 7);
   $month = floor($week / 4);

   $week_elapsed = floor(($st - ($month * 4 * 7 * 24 * 60 * 60)) / (7 * 24 * 60 * 60));
   $days_elapsed = floor(($st - ($week * 7 * 24 * 60 * 60)) / (24 * 60 * 60));
   $hours_elapsed = floor(($st - ($days * 24 * 60 * 60)) / (60 * 60));
   $mins_elapsed = floor(($st - ($hours * 60 * 60)) / 60);
   $secs_elapsed = floor($st - $mins * 60);

   $pretime = "";

   if($secs_elapsed > 0)
      $pretime = "$secs_elapsed Secs. " .$pretime;
   if($mins_elapsed > 0)
      $pretime = "$mins_elapsed Mins, " .$pretime;
   if($hours_elapsed > 0)
      $pretime = "$hours_elapsed Hrs., " .$pretime;
   if($days_elapsed > 0)
      $pretime = "$days_elapsed Days, " .$pretime;
   if($week_elapsed > 0)
      $pretime = "$week_elapsed Weeks, " .$pretime;
   if($month > 0)
      $pretime = "$month Months, " .$pretime;
return "$pretime";
}



Find:

$dispname = htmlspecialchars($row["name"]);



Add Below:

        $pre = $row["pretime"];
        if($pre == '0')
        {
        $pretime = "";
        } else {
        $preline = get_pretime($pre);
        $pretime = " ".$preline." after pre.";
        }



Find: (Should be similar)

$htmlout .= "'><b>$dispname</b></a> $sticky</td>\n";



Change to something like this:

$htmlout .= "'><b>$dispname</b></a> $sticky<br>$pretime</td>\n";



browse.php
Find the big query and add:

torrents.pretime,



takeupload.php
find:

$lang = array_merge( load_language('global'), load_language('takeupload') );


Add Below:

function get_pretime($st) {
   $secs = $st;
   $mins = floor($st / 60);
   $hours = floor($mins / 60);
   $days = floor($hours / 24);
   $week = floor($days / 7);
   $month = floor($week / 4);

   $week_elapsed = floor(($st - ($month * 4 * 7 * 24 * 60 * 60)) / (7 * 24 * 60 * 60));
   $days_elapsed = floor(($st - ($week * 7 * 24 * 60 * 60)) / (24 * 60 * 60));
   $hours_elapsed = floor(($st - ($days * 24 * 60 * 60)) / (60 * 60));
   $mins_elapsed = floor(($st - ($hours * 60 * 60)) / 60);
   $secs_elapsed = floor($st - $mins * 60);

   $pretime = "";

   if($secs_elapsed > 0)
      $pretime = "$secs_elapsed Secs. " .$pretime;
   if($mins_elapsed > 0)
      $pretime = "$mins_elapsed Mins, " .$pretime;
   if($hours_elapsed > 0)
      $pretime = "$hours_elapsed Hrs., " .$pretime;
   if($days_elapsed > 0)
      $pretime = "$days_elapsed Days, " .$pretime;
   if($week_elapsed > 0)
      $pretime = "$week_elapsed Weeks, " .$pretime;
   if($month > 0)
      $pretime = "$month Months, " .$pretime;
return "$pretime";
}


(I load this function in 2 places because I don't want to bother loading the whole torrenttable_functions.php in takeupload. You could just do an include for the torrenttable_functions if you really want to.)

find:

    // Replace punctuation characters with spaces

    $torrent = str_replace("_", " ", $torrent);



Below Add: (Notice: you need to provide your own database.....)

        $pretime = 0 + @file_get_contents('http://yourpredburlhere/gettime.php?name='.trim($torrent));
        if ($pretime > 0){
        $preline = get_pretime($pretime);
        } else {
        $pretime = '0';
        }



In the big query in takeupload.php add:

pretime,


And:

$pretime


This post has been edited by MelvinMeow: 22 February 2010 - 08:48 PM"

I hope this helps you  ;)