diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b94b0fd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM debian:buster + +RUN apt-get update && apt-get install -y --fix-missing apache2 php php-cli php-xml php-mbstring ffmpeg wget && apt-get autoremove -y && rm -rf /var/lib/apt/lists/* +RUN a2enmod rewrite + +RUN rm -r -f /var/www/html/* +RUN chown -R www-data:www-data /var/www/html + +ENV APACHE_RUN_USER www-data +ENV APACHE_RUN_GROUP www-data +ENV APACHE_LOG_DIR /tmp +ENV APACHE_RUN_DIR . +ENV APACHE_PID_FILE /tmp/apache.pid + +COPY index.php /var/www/html/index.php + +EXPOSE 80 + +CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"] \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 7b4d175..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# ImageService - diff --git a/bin/ffmpeg.exe b/bin/ffmpeg.exe new file mode 100644 index 0000000..fb8de16 Binary files /dev/null and b/bin/ffmpeg.exe differ diff --git a/bin/wget.exe b/bin/wget.exe new file mode 100644 index 0000000..0cce455 Binary files /dev/null and b/bin/wget.exe differ diff --git a/index.php b/index.php new file mode 100644 index 0000000..48b8f45 --- /dev/null +++ b/index.php @@ -0,0 +1,63 @@ +get_server_urlsuserID'.$userID.''; + $optionen = stream_context_create(array('http' => array('timeout' => 1, 'method' => 'POST', 'header' => 'Content-Type: application/xml', 'content' => $xml))); + $result = file_get_contents($homeURL, false, $optionen); + + $servers = new SimpleXMLElement($result); + + foreach ($servers->params->param->value->struct[0] as $serverEntry) + { + if($serverEntry->name == 'SRV_AssetServerURI') + return $serverEntry->value->string->__toString(); + } + } + + function getAssetData($assetServer, $assetUUID) + { + global $DATA; + @chdir("/var/www/html"); + + if(!is_file('./data/'.$assetUUID.'.png')) + { + if(is_file("/usr/bin/wget")) + $DATA['WGETCMD'] = '/usr/bin/wget '.$assetServer.'/assets/'.$assetUUID.'/data -O '.$assetUUID; + + if(is_file("/usr/bin/ffmpeg")) + $DATA['MPEGCMD'] = '/usr/bin/ffmpeg -i '.$assetUUID.' ./data/'.$assetUUID.'.png'; + + if(is_file("wget.exe")) + $DATA['WGETCMD'] = 'wget.exe '.$assetServer.'/assets/'.$assetUUID.'/data -O '.$assetUUID; + + if(is_file("ffmpeg.exe")) + $DATA['MPEGCMD'] = 'ffmpeg.exe -i '.$assetUUID.' ./data/'.$assetUUID.'.png'; + + $DATA['WGET'] = shell_exec($DATA['WGETCMD']); + $DATA['FFMPEG'] = shell_exec($DATA['MPEGCMD']); + + unlink($assetUUID); + } + + return $assetUUID.'.png'; + } + + if(@$_REQUEST['AssetID'] == "") + die("Need AssetID"); + + if($_REQUEST['AssetServer'] != "") + $DATA['AssetServer'] = $_REQUEST['AssetServer']; + + if(!is_dir("data")) + mkdir("data", 0777); + + $DATA['AssetPath'] = getAssetData($DATA['AssetServer'], $_REQUEST['AssetID']); + + header("Location: data/".$DATA['AssetPath']); + exit; +?> +