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