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.
Result of php executing
Full code of trb.php
- <?php
- header("Content-type: text/plain");
- date_default_timezone_set('UTC');
- /* EDITABLE CODE */
- $date = new DateTime('2023-03-22'); //input day
- $plusHours = 0; //input hours
- $neededRP = 200000; // input amount of RP you need to create
- /* END EDITABLE CODE */
- /* DO NOT EDIT CODE from this line */
- createFileDay($date, $neededRP, $plusHours);
- function createFileDay($date, $neededRP = 200000, $plusHours = 0){
- $startTime = $date->getTimestamp();
- //echo $date->format('D');
- if($plusHours > 0){
- $startTime+=$plusHours*60*60 + 10*60;
- }
- $startTime+=27;
- $fullString = '{
- "transactions": [
- allRace
- ]
- }';
- $count = floor($neededRP/829);
- $lastRP=$neededRP-$count*829;
- //829 RP for each loop
- $raceString = '{
- "action": "CashEarned",
- "timestamp": tz,
- "isUploading": false,
- "increase": 3250,
- "boost": 163,
- "reason": "RaceRewardWithBonus"
- },
- {
- "action": "CashEarned",
- "timestamp": tz,
- "isUploading": false,
- "increase": 35,
- "reason": "RaceReward"
- },
- {
- "action": "RacesInCrewEarned",
- "timestamp": tz,
- "isUploading": false,
- "increase": 1,
- "reason": "RacedWhileInACrew"
- },
- {
- "action": "RPEarned",
- "timestamp": tz,
- "isUploading": false,
- "increase": 637,
- "reason": "RaceWin",
- "boost": 192
- }';
- $lastRace = '{
- "action": "CashEarned",
- "timestamp": tz,
- "isUploading": false,
- "increase": 3250,
- "boost": 163,
- "reason": "RaceRewardWithBonus"
- },
- {
- "action": "CashEarned",
- "timestamp": tz,
- "isUploading": false,
- "increase": 35,
- "reason": "RaceReward"
- },
- {
- "action": "RacesInCrewEarned",
- "timestamp": tz,
- "isUploading": false,
- "increase": 1,
- "reason": "RacedWhileInACrew"
- },
- {
- "action": "RPEarned",
- "timestamp": tz,
- "isUploading": false,
- "increase": '.$lastRP.',
- "reason": "RaceWin",
- "boost": 0
- }';
- $abc = "";
- for($i=0;$i<$count;$i++){
- if($i> 0){
- $abc = $abc.",".str_replace("tz",$startTime,$raceString);
- } else {
- $abc = str_replace("tz",$startTime,$raceString);
- }
- $startTime= $startTime + 25;
- }
- $abc = $abc.",".str_replace("tz",$startTime,$lastRace);
- $fullString = str_replace("allRace",$abc,$fullString);
- if($plusHours){
- $file = 'trb'.$date->format('md').'_2.txt';
- header("Content-Disposition: attachment; filename=$file");
- // Write the contents back to the file
- echo $fullString;
- } else {
- $file = 'trb'.$date->format('md').'.txt';
- header("Content-Disposition: attachment; filename=$file");
- // Write the contents back to the file
- echo $fullString;
- }
- }