0) { if(strpos(strtolower($val),'.j2l') > -1) {$file[] = strtolower($val);$noJ2L=false;} elseif(strpos(strtolower($val),'levellist.ini') > -1) {$gotLL=true;$LLfile=strtolower($val);} } } if($noJ2L==true && $gotLL==false) { echo "You must specify a j2l file!\n\nPress enter to close"; Pause(); exit; } elseif($gotLL) { echo "Reading Level List...\n"; echo $LLfile."\n\n"; $LL = new_parse_ini($LLfile); echo "Please specify gamemode: "; $gm=Pause(); echo "\n"; $keys=array_keys($LL); $key=""; for($i=0;$i < count($keys);$i++) { if(strtolower($keys[$i])==strtolower($gm)) { $key=$keys[$i]; break; } } if($key=="") { echo "Specified gamemode was not found!\n\nClick enter to close"; Pause(); exit; } echo "Gamemode: ".$key."\n"; $file=null; $err=false; $tmperr=true; $notfound=null; for($i=0;$i < count($LL[$key]);$i++) { $tmperr=true; if(file_exists(dirname($LLfile)."\\".$LL[$key][$i+1])) { $file[]=dirname($LLfile)."\\".$LL[$key][$i+1]; $tmperr=false; continue; } for($j=1;$j <= count($settings['ReadFrom']); $j++) { if(file_exists($settings['ReadFrom'][$j]."\\".$LL[$key][$i+1])) { $file[]=$settings['ReadFrom'][$j]."\\".$LL[$key][$i+1]; $tmperr=false; break; } } if($tmperr) { $notfound[]=$LL[$key][$i+1]; $err=true; } } if($err) { echo "\nFollowing levels was not found:\n\n"; for($i=0;$i < count($notfound);$i++) { echo " ".$notfound[$i]."\n"; } echo "\nPress enter to continue anyway"; Pause(); } echo "\n"; if($file==null) { echo "Error: No files was found!\n\nPress enter to close"; Pause(); exit; } $settings['Settings']['includeNextLevels']=false; } if(strtolower($settings['Settings']['includeNextLevels'])==true) { echo "Including next-levels...\n\n"; } $filename=null; $nextL=null; $tileset=null; $music=null; $tilesetExists=null; $musicExists=null; $nextLExists=null; $levelVersion=null; $tilesetName=null; $tilesetVersion=null; $path=""; include "classZip.php"; include "classLevel.php"; for($key=0;$key < count($file); $key++) { if(strpos(strtolower(basename($file[$key])),".j2l") === false) continue; $l=construct($file[$key]); $filename[$key]=$file[$key]; $path=$filename[$key]; $tileset[$key]=$l['Tileset']; $music[$key]=$l['MusicFile']; $nextL[$key]=$l['NextLevel']; if(strpos(strtolower($nextL[$key]),".j2l") === false && $nextL[$key]!="") $nextL[$key].=".j2l"; $tilesetExists[$key]=false; $musicExists[$key]=false; $nextLExists[$key]=false; $levelVersion[$key]=($sVersion==514)?"1.23":"TSF"; echo "Level: ".basename($filename[$key])." - ".$l['LevelName']." - ".$levelVersion[$key]."\n"; if(strpos($music[$key],".") === false && $music[$key]!="") $music[$key].=".j2b"; for($i=1;$i <= count($settings['ReadFrom']); $i++) { if($settings['ReadFrom'][$i]!="" && substr($settings['ReadFrom'][$i],-1)!="\\") $settings['ReadFrom'][$i].="\\"; if($tilesetExists[$key]==null && file_exists($settings['ReadFrom'][$i]."".$tileset[$key])) $tilesetExists[$key]=$settings['ReadFrom'][$i]."".$tileset[$key]; if($music[$key]!="") { if($musicExists[$key]==null && file_exists($settings['ReadFrom'][$i]."".$music[$key])) $musicExists[$key]=$settings['ReadFrom'][$i]."".$music[$key]; } if($nextL[$key]!="") { if($nextLExists[$key]==null && file_exists($settings['ReadFrom'][$i]."".$nextL[$key])) $nextLExists[$key]=$settings['ReadFrom'][$i]."".$nextL[$key]; } } echo "Tileset: ".(($tilesetExists[$key])?"yes":"no ")." (".$tileset[$key].")"; if($tilesetExists[$key]) { $fp = @fopen($tilesetExists[$key],"r"); if($fp==null) {echo " - Error reading";} else { $header = fread($fp, 262); $tilesetName[$key] = trim(substr($header,188,32)); list(,$ver) = unpack('v',substr($header,220,2)); $tilesetVersion[$key]=($ver==512)?"1.23":"TSF"; echo " - ".$tilesetName[$key]." - ".$tilesetVersion[$key]; fclose($fp); } unset($fp); } echo "\n"; if($music[$key]!="") { echo "Music: ".(($musicExists[$key])?"yes":"no ")." (".$music[$key].")\n"; } if($nextL[$key]!="" && $nextLExists[$key] && strtolower($nextL[$key])!=strtolower(basename($filename[$key])) && strtolower($settings['Settings']['includeNextLevels'])==true) { echo "Next: ".(($nextLExists[$key])?"yes":"no ")." (".$nextL[$key].")\n"; $nextNotExists=true; for($k=0;$k < count($file);$k++) { if(strpos(strtolower($file[$k]),strtolower($nextL[$key])) !== FALSE) { $nextNotExists=false; } } if($nextNotExists) {array_push($file,$nextLExists[$key]);} } else $nextLExists[$key]=true; echo "\n"; $l=null; } $tilesetError=false; if(in_array(false,$musicExists)) { echo "Following files was not found:\n\n"; if(in_array(false,$tilesetExists)) { echo " Tileset files:\n"; for($key=0;$key < count($tilesetExists); $key++) { if($tilesetExists[$key]==false) echo " ".$tileset[$key]."\n"; } echo "\n"; $tilesetError=true; } if(in_array(false,$musicExists)) { echo " Music files:\n"; for($key=0;$key < count($musicExists); $key++) { if($musicExists[$key]==false) echo " ".$music[$key]."\n"; } echo "\n"; } if($tilesetError) { echo "You must find these before you can pack them."; Pause(); exit; } } echo "Output files: ".$outputstr."\n\n"; echo "What do you want to call the pack? (max 32) "; $name=substr(Pause(),0,32); if($name=="") { echo "\nYou must enter a name!\n\nPress enter to close"; Pause(); exit; } echo "\nName: ".$name.".zip\nTrying to copy files...\n"; $exists=(file_exists($name.".zip") || file_exists($settings['SaveTo']['path']."/".$name.".zip")); $overwrite=true; if($exists) { echo "Archive already exists! Do you want to overwrite? y/n: "; $overwrite=(strtolower(substr(Pause(),0,1))=="y")? true: false; echo "\n"; } if($overwrite) { $ziper = new zipfile(); $addedSets=array(); $addedMusic=array(); $read=false; for($key=0;$key < count($file); $key++) { if($outputType=="all" || $outputType=="levels" || $outputType=="levelstilesets") { $ziper->addFile(fread(fopen($filename[$key],"r"),filesize($filename[$key])),basename($filename[$key]),filemtime($filename[$key])); echo " added ".basename($filename[$key])."\n"; } if(($outputType=="all" || $outputType=="tilesets" || $outputType=="levelstilesets") && !in_array($tileset[$key],$addedSets)) { $read=false; if($read=@fread(@fopen($tilesetExists[$key],"r"),@filesize($tilesetExists[$key]))) { $ziper->addFile($read,$tileset[$key],filemtime($tilesetExists[$key])); } if($read!=false && $read!="") echo " added ".$tileset[$key]."\n"; else { echo " failed to add ".$tileset[$key]."\n"; } } if(($outputType=="all" || $outputType=="music") && $music[$key]!="" && !in_array($music[$key],$addedMusic)) { $read=false; if($read=@fread(@fopen($musicExists[$key],"r"),@filesize($musicExists[$key]))) { $ziper->addFile($read,$music[$key],filemtime($musicExists[$key])); } if($read!=false && $read!="") echo " added ".$music[$key]."\n"; else { echo "! failed to add ".$music[$key]."\n"; } } $addedSets[$key]=$tileset[$key]; $addedMusic[$key]=$music[$key]; } echo "\nCreating archive..."; $check=false; $outpath=""; if($settings['SaveTo']['path']!="" && is_dir($settings['SaveTo']['path'])) { $check=@$ziper->output($settings['SaveTo']['path']."/".$name.".zip"); $outpath=$settings['SaveTo']['path']."/".$name.".zip"; echo " done\n\n"; } else { $outpath=$name.".zip"; echo "\n\nWarning: SaveTo folder does not exist!\nZIP file will be saved to the folder where the levels are.\n\n"; $check=@$ziper->output($name.".zip"); } if($check) { echo "ZIP archive was created successfully!\nFilesize: ".byteConvert(filesize(realpath($outpath)))."\n\nYou can close this window now"; exec("explorer /select,".realpath($outpath)); } else echo "There was an error while copying, please report the bug to Dany!"; } else { echo "Operation was canceled!\nYou can close this window now"; } Pause(); ?>