api creating task files

This commit is contained in:
schrom01 2023-09-25 12:43:51 +02:00
parent 2f5232e1c7
commit de681f37b0
2 changed files with 11 additions and 4 deletions

11
api.php
View File

@ -1,7 +1,7 @@
<?php <?php
include 'zefixAPI.php'; include 'zefixAPI.php';
$taskDir = 'tasks';
/* /*
* Request Types: * Request Types:
@ -63,14 +63,17 @@ $taskdata = Array();
$taskdata['requests'] = $requests_to_do; $taskdata['requests'] = $requests_to_do;
$taskdata['email'] = 'roman.schenk37@gmail.com'; $taskdata['email'] = 'roman.schenk37@gmail.com';
$taskString = json_encode($taskdata); $taskString = json_encode($taskdata);
$taskfilename = 'tasks/'.time().'-'.bin2hex(random_bytes(4)).'.txt'; if(!is_dir($taskDir)){
mkdir($taskDir, 0755, true);
}
$taskfilename = $taskDir.'/'.time().'-'.bin2hex(random_bytes(4)).'.txt';
$taskfile = fopen($taskfilename, 'w'); $taskfile = fopen($taskfilename, 'w');
if($taskfile){ if($taskfile){
echo "writing to file"; echo "Task written to file";
fwrite($taskfile, $taskString); fwrite($taskfile, $taskString);
fclose($taskfile); fclose($taskfile);
} else { } else {
echo "not writing to file"; echo "Task not written to file";
} }
//$constructed_response = $response; //$constructed_response = $response;

4
taskExecuter.php Normal file
View File

@ -0,0 +1,4 @@
<?php
>