Преобразовать PHP в файл Bat или создать автономную команду - PullRequest
0 голосов
/ 29 апреля 2020

Все, что я хотел бы знать, можно ли преобразовать этот код в файл bat, и что я могу отредактировать, чтобы это произошло

<?php
header("Content-type: text/plain");
date_default_timezone_set('UTC');

$date = new DateTime('2020-04-26'); //input day
$plusHours = 5;     //input hours
$neededRP = 300000;  // input amount of RP you need to create
createFileDay($date, $neededRP, $plusHours);

function createFileDay($date, $neededRP = 300000, $plusHours = 5){
        $startTime = $date->getTimestamp();
       //echo $date->format('D');
       if($plusHours > 0){
               $startTime+=$plusHours*60*60 + 10*60;
       }
       $startTime+=27;
       $fullString = '{
  "transactions": [
        allRace
  ]
}';
        $count = floor($neededRP/800);
       //800 RP for each loop
       $raceString = '{
"action": "CashEarned",
"timestamp": tz,
"isUploading": false,
"increase": 3250,
"boost": 163,
"reason": "RaceRewardWithBonus"
},
{
"action": "RPEarned",
"timestamp": tz,
"isUploading": false,
"increase": 637,
"reason": "RaceWin",
"boost": 192
}';
  $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;
}

$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;
}

}

Я попытался добавить еще подробнее, я собираюсь попытаться добавить полный сценарий, я пропустил несколько вещей, но это весь код, в меру, который я мог

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...