Commit a5ae7b05 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

fixed missing obj and mtl in zip for _all

parent 64205f9f
...@@ -20,6 +20,7 @@ $TEXTURE_EXTENSIONS = ['png','jpeg','jpg','tif','tiff','gif']; ...@@ -20,6 +20,7 @@ $TEXTURE_EXTENSIONS = ['png','jpeg','jpg','tif','tiff','gif'];
if (!isset($_GET['file'])) die("-1"); if (!isset($_GET['file'])) die("-1");
$file = $_GET['file']; $file = $_GET['file'];
$filestring = $file;
$patterns = ['/(\.)+\//','/^\//']; $patterns = ['/(\.)+\//','/^\//'];
$replacements = ['','']; $replacements = ['',''];
...@@ -33,7 +34,11 @@ $path = $pathinfo['dirname']; ...@@ -33,7 +34,11 @@ $path = $pathinfo['dirname'];
$tmp = explode("/",$path); $tmp = explode("/",$path);
$zipfile = $tmp[1]."_".$tmp[2].".zip"; if ($tmp[1]=="_all"){
$zipfile = $tmp[2]."_".$tmp[3].".zip";
}else{
$zipfile = $tmp[1]."_".$tmp[2].".zip";
}
// alright, there's this file // alright, there's this file
$contents = file_get_contents($file); $contents = file_get_contents($file);
...@@ -43,20 +48,18 @@ preg_match_all('/url="([^\s]+('.implode('|',$TEXTURE_EXTENSIONS).'))"/i',$conten ...@@ -43,20 +48,18 @@ preg_match_all('/url="([^\s]+('.implode('|',$TEXTURE_EXTENSIONS).'))"/i',$conten
// make a string // make a string
foreach($matches[1] as $v){ foreach($matches[1] as $v){
$file .= " $path/$v"; $filestring .= " $path/$v";
} }
// add obj // add obj
$objfile = $path."/".$tmp[1].".obj"; $objfile = substr($file,0,-3)."obj";
if (is_file($objfile)) $file .= " $objfile"; if (is_file($objfile)) $filestring .= " $objfile";
// add mtl // add mtl
$mtlfile = $path."/".$tmp[1].".mtl"; $mtlfile = substr($file,0,-3)."mtl";
if (is_file($mtlfile)) $file .= " $mtlfile"; if (is_file($mtlfile)) $filestring .= " $mtlfile";
$zipped_data = `zip -qj - $file `; $zipped_data = `zip -qj - $filestring `;
header('Content-type: application/zip'); header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="'.$zipfile.'"'); header('Content-Disposition: attachment; filename="'.$zipfile.'"');
echo $zipped_data; echo $zipped_data;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment