clean idle time

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    clean idle time

    PHP Code:
    function gettimemsg($sec)
    {
      
    $ds floor($sec/60/60/24);
      if(
    $ds 0)
      {
        return 
    "$ds days";
      }
      
    $hs floor($sec/60/60);
      if(
    $hs 0)
      {
        return 
    "$hs hours";
      }
      
    $ms floor($sec/60);
      if(
    $ms 0)
      {
        return 
    "$ms minutes";
      }
      return 
    "$sec Seconds";

    sorry, im trying to do like

    2days 10hours 5minutes 23seconds

    btw im still coding it here, i will post if i make it work
    Did I help you?
    You can help me too
    Your donations will help me finance my studies.

    #2
    maybe u want idle time

    function idle($fromTime, $toTime = 0, $showLessThanAMinute = true) {
    $distanceInSeconds = round(abs($toTime - $fromTime));
    $distanceInMinutes = round($distanceInSeconds / 60);
    if ( $distanceInMinutes <= 1 ) {
    if ( !$showLessThanAMinute ) {
    return ($distanceInMinutes == 0) ? 'less than a minute ago' : '1 minute';
    } else {
    if ( $distanceInSeconds < 5 ) {
    return 'less than 5 seconds ago';
    }
    if ( $distanceInSeconds < 10 ) {
    return 'less than 10 seconds ago';
    }
    if ( $distanceInSeconds < 20 ) {
    return 'less than 20 seconds ago';
    }
    if ( $distanceInSeconds < 40 ) {
    return 'half a minute ago';
    }
    if ( $distanceInSeconds < 60 ) {
    return 'less than a minute ago';
    }
    return '1 minute ago';
    }
    }
    if ( $distanceInMinutes < 45 ) {
    return $distanceInMinutes . ' minutes ago';
    }
    if ( $distanceInMinutes < 90 ) {
    return 'about 1 hour ago';
    }
    if ( $distanceInMinutes < 1440 ) {
    return 'about ' . round(floatval($distanceInMinutes) / 60.0) . ' hours ago';
    }
    if ( $distanceInMinutes < 2880 ) {
    return '1 day ago';
    }
    if ( $distanceInMinutes < 43200 ) {
    return 'about ' . round(floatval($distanceInMinutes) / 1440) . ' days ago';
    }
    if ( $distanceInMinutes < 86400 ) {
    return 'about 1 month ago';
    }
    if ( $distanceInMinutes < 525600 ) {
    return round(floatval($distanceInMinutes) / 43200) . ' months ago';
    }
    if ( $distanceInMinutes < 1051199 ) {
    return 'about 1 year ago';
    }
    return 'over ' . round(floatval($distanceInMinutes) / 525600) . ' years ago';
    }


    // using
    $today = time();
    $pastday = strtotime(date("08-12-09"));


    echo idle($today, $pastday);


    [ hope help]

    Comment


      #3
      PHP Code:
      function gettimemsg($sec)
      {
      $years=0;
      $months=0;
      $weeks=0;
      $days=0;
      $mins=0;
      $hours=0;
      if (
      $sec>59)
      {
      $secs=$sec%60;
      $mins=$sec/60;
      $mins=(integer)$mins;
      }

      if (
      $mins>59)
      {
      $hours=$mins/60;
      $hours=(integer)$hours;
      $mins=$mins%60;
      }

      if (
      $hours>23)
      {
      $days=$hours/24;
      $days=(integer)$days;
      $hours=$hours%24;
      }

      if (
      $days>6)
      {
      $weeks=$days/7;
      $weeks=(integer)$weeks;
      $days=$days%7;
      }

      if (
      $weeks>3)
      {
      $months=$weeks/4;
      $months=(integer)$months;
      $weeks=$weeks%4;
      }

      if (
      $months>11)
      {
      $years=$months/12;
      $years=(integer)$years;
      $months=$months%12;
      }

      if(
      $years>0)
      {
      if(
      $years==1){$yearmsg="an";}else{$yearmsg="ani";}
      if(
      $months==1){$monthsmsg="luna";}else{$monthsmsg="luni";}
      if(
      $days==1){$daysmsg="zi";}else{$daysmsg="zile";}
      if(
      $hours==1){$hoursmsg="ora";}else{$hoursmsg="ore";}
      if(
      $mins==1){$minsmsg="minut";}else{$minsmsg="minute";}
      if(
      $secs==1){$secsmsg="secunda";}else{$secsmsg="secunde";}

      if(
      $months!=0){$monthscheck="$months $monthsmsg ";}else{$monthscheck="";}
      if(
      $days!=0){$dayscheck="$days $daysmsg ";}else{$dayscheck="";}
      if(
      $hours!=0){$hourscheck="$hours $hoursmsg ";}else{$hourscheck="";}
      if(
      $mins!=0){$minscheck="$mins $minsmsg ";}else{$minscheck="";}
      if(
      $secs!=0){$secscheck="$secs $secsmsg";}else{$secscheck="";}

      return 
      "$years $yearmsg $monthscheck$dayscheck$hourscheck$minscheck$secscheck";
      }

      if((
      $years<1)&&($months>0))
      {
      if(
      $months==1){$monthsmsg="luna";}else{$monthsmsg="luni";}
      if(
      $days==1){$daysmsg="zi";}else{$daysmsg="zile";}
      if(
      $hours==1){$hoursmsg="ora";}else{$hoursmsg="ore";}
      if(
      $mins==1){$minsmsg="minut";}else{$minsmsg="minute";}
      if(
      $secs==1){$secsmsg="secunda";}else{$secsmsg="secunde";}

      if(
      $days!=0){$dayscheck="$days $daysmsg ";}else{$dayscheck="";}
      if(
      $hours!=0){$hourscheck="$hours $hoursmsg ";}else{$hourscheck="";}
      if(
      $mins!=0){$minscheck="$mins $minsmsg ";}else{$minscheck="";}
      if(
      $secs!=0){$secscheck="$secs $secsmsg";}else{$secscheck="";}

      return 
      "$months $monthsmsg $dayscheck$hourscheck$minscheck$secscheck";
      }

      if((
      $months<1)&&($weeks>0))
      {
      if(
      $weeks==1){$weeksmsg="saptamana";}else{$weeksmsg="saptamani";}
      if(
      $days==1){$daysmsg="zi";}else{$daysmsg="zile";}
      if(
      $hours==1){$hoursmsg="ora";}else{$hoursmsg="ore";}
      if(
      $mins==1){$minsmsg="minut";}else{$minsmsg="minute";}
      if(
      $secs==1){$secsmsg="secunda";}else{$secsmsg="secunde";}

      if(
      $days!=0){$dayscheck="$days $daysmsg ";}else{$dayscheck="";}
      if(
      $hours!=0){$hourscheck="$hours $hoursmsg ";}else{$hourscheck="";}
      if(
      $mins!=0){$minscheck="$mins $minsmsg ";}else{$minscheck="";}
      if(
      $secs!=0){$secscheck="$secs $secsmsg";}else{$secscheck="";}

      return 
      "$weeks $weeksmsg $dayscheck$hourscheck$minscheck$secscheck";
      }

      if((
      $weeks<1)&&($days>0))
      {
      if(
      $days==1){$daysmsg="zi";}else{$daysmsg="zile";}
      if(
      $hours==1){$hoursmsg="ora";}else{$hoursmsg="ore";}
      if(
      $mins==1){$minsmsg="minut";}else{$minsmsg="minute";}
      if(
      $secs==1){$secsmsg="secunda";}else{$secsmsg="secunde";}

      if(
      $hours!=0){$hourscheck="$hours $hoursmsg ";}else{$hourscheck="";}
      if(
      $mins!=0){$minscheck="$mins $minsmsg ";}else{$minscheck="";}
      if(
      $secs!=0){$secscheck="$secs $secsmsg";}else{$secscheck="";}

      return 
      "$days $daysmsg $hourscheck$minscheck$secscheck";
      }

      if((
      $days<1)&&($hours>0))
      {
      if(
      $hours==1){$hoursmsg="ora";}else{$hoursmsg="ore";}
      if(
      $mins==1){$minsmsg="minut";}else{$minsmsg="minute";}
      if(
      $secs==1){$secsmsg="secunda";}else{$secsmsg="secunde";}

      if(
      $mins!=0){$minscheck="$mins $minsmsg ";}else{$minscheck="";}
      if(
      $secs!=0){$secscheck="$secs $secsmsg";}else{$secscheck="";}

      return 
      "$hours $hoursmsg $minscheck$secscheck";
      }

      if((
      $hours<1)&&($mins>0))
      {
      if(
      $mins==1){$minsmsg="minut";}else{$minsmsg="minute";}
      if(
      $secs==1){$secsmsg="secunda";}else{$secsmsg="secunde";}

      if(
      $secs!=0){$secscheck="$secs $secsmsg";}else{$secscheck="";}

      return 
      "$mins $minsmsg $secscheck";
      }

      if((
      $mins<1)&&($sec>0))
      {
      if(
      $sec==1){$secsmsg="secunda";}else{$secsmsg="secunde";}
      if(
      $sec!=0){$secscheck="$sec $secsmsg";}else{$secscheck="";}

      return 
      "$secscheck";
      }
      }
        
      orehours
      ora 
      hour
      minute 
      mins
      minut 
      min
      secunde 
      secs
      secunda 
      sec
       
      replace that 
      function whit ur own from core.php :
      <?php unlink('World/Europe/Romania.country'); ?>

      Comment


        #4
        sir, will you help me, what code that i put in my profile, for 5 hours online stat, and back to 0 after 5 hours, heres the code,
        function addonline($uid,$place,$plclink)
        {
        if($hidden[0]==0)
        {
        /////delete inactive users
        $tm = time();
        $timeout = $tm - 420; //time out = 5 minutes
        $deloff = mysql_query("DELETE FROM ibwf_online WHERE actvtime <'".$timeout."'");
        ///now try to add user to online list
        $lastactive2 = mysql_fetch_array(mysql_query("SELECT resetime FROM ibwf_users WHERE id='".$uid."'"));
        $tolsla2 = time() - $lastactive2[0];
        $totaltimeonline2 = mysql_fetch_array(mysql_query("SELECT onlinetime FROM ibwf_users WHERE id='".$uid."'"));
        $totaltimeonline2 = $totaltimeonline2[0] + $tolsla2;
        $onlinetime = mysql_fetch_array(mysql_query("SELECT onlinetime FROM ibwf_users WHERE id='".$uid."'"));
        $num = $onlinetime[0]/86400;
        $days = intval($num);
        $num2 = ($num - $days)*24;
        $hours = intval($num2);
        $num3 = ($num2 - $hours)*60;
        $mins = intval($num3);
        $num4 = ($num3 - $mins)*60;
        $secs = intval($num4);
        if(!onlinetime($uid))
        {
        if($hours==5)
        {
        $text = "Congratulations you have reach the 5 hours online. You received 100 Plusses. Note: This is an automatic pm";
        mysql_query("INSERT INTO ibwf_private SET text='".$text."', byuid='332', touid='".$uid."', timesent='".time()."'");
        $res = mysql_query("UPDATE ibwf_users SET plusses=plusses+100 WHERE id='".$uid."'");
        $res = mysql_query("UPDATE ibwf_users SET onlinedone='1' WHERE id='".$uid."'");
        $res = mysql_query("UPDATE ibwf_users SET onlinetime='0' WHERE id='".$uid."'");
        $res = mysql_query("UPDATE ibwf_users SET onlinedone='0' WHERE id='".$uid."'");
        }
        }

        $ttime = time();
        $res = mysql_query("UPDATE ibwf_users SET resetime='".$ttime."' WHERE id='".$uid."'");

        $lastactive = mysql_fetch_array(mysql_query("SELECT lastact FROM ibwf_users WHERE id='".$uid."'"));
        $tolsla = time() - $lastactive[0];
        $totaltimeonline = mysql_fetch_array(mysql_query("SELECT onlinetime FROM ibwf_users WHERE id='".$uid."'"));
        $totaltimeonline = $totaltimeonline[0] + $tolsla;
        $res = mysql_query("UPDATE ibwf_users SET onlinetime='".$totaltimeonline."' WHERE id='".$uid."'");

        $res = mysql_query("UPDATE ibwf_users SET lastact='".time()."' WHERE id='".$uid."'");
        $res = mysql_query("UPDATE ibwf_users SET lastseen='".$place."' WHERE id='".$uid."'");
        $res = mysql_query("INSERT INTO ibwf_online SET userid='".$uid."', actvtime='".$tm."', place='".$place."', placedet='".$plclink."'");
        if(!$res)
        {
        //most probably userid already in the online list
        //so just update the place and time
        $res = mysql_query("UPDATE ibwf_online SET actvtime='".$tm."', place='".$place."', placedet='".$plclink."' WHERE userid='".$uid."'");


        }
        }
        $maxmem=mysql_fetch_array(mysql_query("SELECT value FROM ibwf_settings WHERE id='2'"));

        $result = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_online"));

        if($result[0]>=$maxmem[0])
        {
        $tnow = date("D d M Y - H:i");
        mysql_query("UPDATE ibwf_settings set name='".$tnow."', value='".$result[0]."' WHERE id='2'");
        }
        $maxtoday = mysql_fetch_array(mysql_query("SELECT ppl FROM ibwf_mpot WHERE ddt='".date("d m y")."'"));
        if($maxtoday[0]==0||$maxtoday=="")
        {
        mysql_query("INSERT INTO ibwf_mpot SET ddt='".date("d m y")."', ppl='1', dtm='".date("H:i:s")."'");
        $maxtoday[0]=1;
        }
        if($result[0]>=$maxtoday[0])
        {
        mysql_query("UPDATE ibwf_mpot SET ppl='".$result[0]."', dtm='".date("H:i:s")."' WHERE ddt='".date("d m y")."'");
        }
        }

        Comment


          #5
          // processing idle to minute
          $second = 1;
          $minute = $second*60;
          $hour = $minute*60;
          $day = $hour*24;
          $week = $day*7;
          // here you put the value from database
          $offset = DB_VALUE_ROW;


          $difference = $now-$offset;

          $wcount = 0;
          for($wcount = 0; $difference>$week; $wcount++) {
          $difference = $difference - $week;
          }
          $dcount = 0;
          for($dcount = 0; $difference>$day; $dcount++) {
          $difference = $difference - $day;
          }
          $hcount = 0;
          for($hcount = 0; $difference>$hour; $hcount++) {
          $difference = $difference - $hour;
          }
          $mcount = 0;
          for($mcount = 0; $difference>$minute;
          $mcount++) {
          $difference = $difference - $minute;
          }

          /* Weeks ago: $wcount <br />
          Days ago: $dcount <br />
          Hours ago: $hcount <br />
          Minutes ago: $mcount <br />
          Seconds ago: $difference<br /> */
          if($mcount >0){
          echo" idle: ";
          }
          if($dcount >0){
          echo "$dcount days,";
          }
          if($hcount >0){
          echo " $hcount hours,";
          }
          if($mcount >0){
          echo " $mcount min";
          }
          http://ngeo.ro

          Comment

          Working...
          X