trb 300 k 12 - 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 300 k 12.php

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