trb - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of trb.php

  1. header("Content-type: text/plain");
  2. date_default_timezone_set('UTC');
  3.  
  4.  
  5. /* EDITABLE CODE */
  6. $date = new DateTime('2021-1-6'); //input day
  7. $plusHours = 0;         //input hours
  8. $neededRP = 300000;  // input amount of RP you need to create
  9. /* END EDITABLE CODE */
  10.  
  11.  
  12. /* DO NOT EDIT CODE from this line */
  13. createFileDay($date, $neededRP, $plusHours);
  14. function createFileDay($date, $neededRP = 300000, $plusHours = 0){
  15.         $startTime = $date->getTimestamp();
  16.         //echo $date->format('D');
  17.         if($plusHours > 0){
  18.                 $startTime+=$plusHours*60*60 + 10*60;
  19.         }
  20.         $startTime+=27;
  21.         $fullString = '{
  22.   "transactions": [
  23.         allRace
  24.   ]
  25. }';
  26.         $count = floor($neededRP/829);
  27. $lastRP=$neededRP-$count*829;
  28.         //829 RP for each loop
  29.         $raceString = '{
  30.       "action": "CashEarned",
  31.       "timestamp": tz,
  32.       "isUploading": false,
  33.       "increase": 3250,
  34.       "boost": 163,
  35.       "reason": "RaceRewardWithBonus"
  36.     },
  37.     {
  38.       "action": "CashEarned",
  39.       "timestamp": tz,
  40.       "isUploading": false,
  41.       "increase": 35,
  42.       "reason": "RaceReward"
  43.     },
  44.     {
  45.       "action": "RacesInCrewEarned",
  46.       "timestamp": tz,
  47.       "isUploading": false,
  48.       "increase": 1,
  49.       "reason": "RacedWhileInACrew"
  50.     },
  51.     {
  52.       "action": "RPEarned",
  53.       "timestamp": tz,
  54.       "isUploading": false,
  55.       "increase": 637,
  56.       "reason": "RaceWin",
  57.       "boost": 192
  58.     }';
  59. $lastRace = '{
  60.       "action": "CashEarned",
  61.       "timestamp": tz,
  62.       "isUploading": false,
  63.       "increase": 3250,
  64.       "boost": 163,
  65.       "reason": "RaceRewardWithBonus"
  66.     },
  67.     {
  68.       "action": "CashEarned",
  69.       "timestamp": tz,
  70.       "isUploading": false,
  71.       "increase": 35,
  72.       "reason": "RaceReward"
  73.     },
  74.     {
  75.       "action": "RacesInCrewEarned",
  76.       "timestamp": tz,
  77.       "isUploading": false,
  78.       "increase": 1,
  79.       "reason": "RacedWhileInACrew"
  80.     },
  81.     {
  82.       "action": "RPEarned",
  83.       "timestamp": tz,
  84.       "isUploading": false,
  85.       "increase": '.$lastRP.',
  86.       "reason": "RaceWin",
  87.       "boost": 0
  88.     }';
  89.         $abc = "";
  90.         for($i=0;$i<$count;$i++){
  91.                 if($i> 0){
  92.                         $abc = $abc.",".str_replace("tz",$startTime,$raceString); 
  93.                 } else {
  94.                         $abc = str_replace("tz",$startTime,$raceString); 
  95.                 }
  96.                 $startTime= $startTime + 25;
  97.         }
  98. $abc = $abc.",".str_replace("tz",$startTime,$lastRace);
  99.  
  100.  
  101.         $fullString = str_replace("allRace",$abc,$fullString); 
  102.         if($plusHours){
  103.                 $file = 'trb'.$date->format('md').'_2.txt';
  104.                 header("Content-Disposition: attachment; filename=$file");
  105.                 // Write the contents back to the file
  106.                 echo $fullString;
  107.         } else {
  108.                 $file = 'trb'.$date->format('md').'.txt';
  109.                 header("Content-Disposition: attachment; filename=$file");
  110.                 // Write the contents back to the file
  111.                 echo $fullString;
  112.         }
  113. }
File Description
  • trb
  • PHP Code
  • 06 Jan-2021
  • 3.09 Kb
You can Share it: