Changeset 729 for trunk/Modules/Export/ProcessTask.php
- Timestamp:
- Jan 8, 2014, 12:17:23 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Export/ProcessTask.php
r708 r729 2 2 3 3 ini_set('memory_limit', '100M'); 4 5 $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; 6 $_SERVER['REQUEST_URI'] = __FILE__; 4 7 5 8 include_once(dirname(__FILE__).'/../../includes/global.php'); … … 24 27 $File->CreateFile(dirname(__FILE__).'/../../'.$System->Config['Web']['TempFolder'].'ProcessTask'); 25 28 $File->WriteLine(1); 29 } 30 31 function DeleteOldFiles($deldir) 32 { 33 if(file_exists($deldir.'/')) 34 { 35 $Dir = opendir($deldir.'/') ; 36 while(($File = readdir($Dir)) !== false) 37 { 38 if(($File != '..') and ($File != '.') and (!is_dir("$File"))) unlink($deldir.'/'.$File); 39 } 40 closedir($Dir); 41 } 42 43 } 44 45 function rcopy($src, $dst) { 46 // echo $src.' '.$dst."\n"; 47 if (file_exists($dst)) DeleteOldFiles($dst); 48 if (is_dir($src)) { 49 if (!file_exists($dst)) mkdir($dst); 50 $files = scandir($src); 51 foreach ($files as $file) 52 if ($file != "." && $file != ".." and (!is_dir("$src/$file"))) rcopy("$src/$file", "$dst/$file"); 53 } 54 else if (file_exists($src)) copy($src, $dst); 55 } 56 57 function GetWinZPatch($patch) { 58 //TMP="Z:\\a\\www\\wowpreklad\\tmp\\Export\\${EXPORTID}\\" 59 $patch = str_replace(DIRECTORY_SEPARATOR,'\\',$patch); 60 $patch = 'Z:'.$patch; 61 return $patch; 62 } 63 64 function MPQPack($packdir) { 65 66 if(file_exists($packdir.DIRECTORY_SEPARATOR)) 67 { 68 $Dir = opendir($packdir.DIRECTORY_SEPARATOR) ; 69 while(($File = readdir($Dir)) !== false) 70 { 71 if(($File != '..') and ($File != '.')) { 72 $File = str_replace('/',DIRECTORY_SEPARATOR,$File); 73 $InDir = ''; 74 if (strpos($packdir,'dbc') !== false) { 75 $InDir = 'DBFilesClient\\'; 76 if (DIRECTORY_SEPARATOR == '/') // linux 77 $InDir = 'DBFilesClient\\\\'; 78 } 79 if (strpos($packdir.$File,'luaGlobal') !== false) { 80 $InDir = 'Interface\\FrameXML\\'; 81 if (DIRECTORY_SEPARATOR == '/') // linux 82 $InDir = 'Interface\\\\FrameXML\\\\'; 83 } 84 if (strpos($packdir.$File,'luaGlue') !== false) { 85 $InDir = 'Interface\\GlueXML\\'; 86 if (DIRECTORY_SEPARATOR == '/') // linux 87 $InDir = 'Interface\\\\GlueXML\\\\'; 88 } 89 90 if (DIRECTORY_SEPARATOR == '/') // linux 91 echo exec('wine cmd /C mpq.exe "'.GetWinZPatch($packdir.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR).'patch-5.MPQ" '.$InDir.basename($File).' "'.GetWinZPatch($packdir.DIRECTORY_SEPARATOR).$File.'" '); 92 93 if (DIRECTORY_SEPARATOR == '\\') // windows 94 echo exec('mpq.exe "'.$packdir.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'patch-5.MPQ" '.$InDir.basename($File).' "'.$packdir.DIRECTORY_SEPARATOR.$File.'" '); 95 96 echo "\n"; 97 } 98 } 99 closedir($Dir); 100 } 26 101 } 27 102 … … 49 124 50 125 // Delete old files 51 if(file_exists($Export->TempDir.'dbc/')) 52 { 53 $Dir = opendir($Export->TempDir.'dbc/') ; 54 while(($File = readdir($Dir)) !== false) 55 { 56 if(($File != '..') and ($File != '.')) unlink($Export->TempDir.'dbc/'.$File); 57 } 58 closedir($Dir); 59 } 126 DeleteOldFiles($Export->TempDir.'dbc'); 60 127 if(file_exists($Export->TempDir.'CzWoW_DBC.zip')) unlink($Export->TempDir.'CzWoW_DBC.zip'); 61 128 … … 90 157 if($DbRow['ExportId'] != '') 91 158 { 92 echo shell_exec('"'.dirname(__FILE__).'./client_cz_export.sh" '.$DbRow['ExportId'].''); 93 $System->Database->query('UPDATE `ExportTask` SET `TimeFinish`=NOW() WHERE `Export`='.$DbRow['Export']); 159 // echo shell_exec('"'.dirname(__FILE__).'./client_cz_export.sh" '.$DbRow['ExportId'].''); 160 161 162 $Export = new ExportAddon($System); 163 $Export->Id = $DbRow['ExportId']; 164 $Export->Init(); 165 $Export->LoadFilters(); 166 167 $nsifile = 'install.nsi'; 168 169 // Delete old files 170 SetProgres($Export,5); 171 echo('Delete old files...'."\n"); 172 DeleteOldFiles($Export->TempDir.'dbc'); 173 DeleteOldFiles($Export->TempDir.'lua'); 174 DeleteOldFiles($Export->TempDir.'CzWoW'); 175 176 //copy need files 177 SetProgres($Export,10); 178 echo('Copy files...'."\n"); 179 rcopy('files/'.$Export->ClientVersion['Version'].'/patch-5.MPQ', $Export->TempDir.'patch-5.MPQ'); 180 rcopy('files/'.$Export->ClientVersion['Version'].'/'.$nsifile, $Export->TempDir.$nsifile); 181 rcopy('files/'.$Export->ClientVersion['Version'].'/WowLua.exe', $Export->TempDir.'WowLua.exe'); 182 rcopy('files/'.$Export->ClientVersion['Version'].'/CzWoW/', $Export->TempDir.'CzWoW/'); 183 rcopy('files/WoW.ico', $Export->TempDir.'WoW.ico'); 184 rcopy('files/Fonts/', $Export->TempDir.'Fonts/'); 185 186 SetProgres($Export,15); 187 echo('Export lua...'."\n"); 188 $Export->ExportToLua(); 189 SetProgres($Export,20); 190 echo('Export CzWoW...'."\n"); 191 $Export->MakeAddon(); 192 SetProgres($Export,30); 193 echo('Export dbc...'."\n"); 194 $Export->ExportToDBC(); 195 196 echo('Create readme...'."\n"); 197 SetProgres($Export,60); 198 $File = new FileStream(); 199 $File->CreateFile($Export->TempDir.'ReadMe.htm'); 200 $File->WriteLine($Export->GetReadme()); 201 $File->CloseFile(); 202 203 echo('Packing files...'."\n"); 204 SetProgres($Export,70); 205 $workdir = str_replace('/',DIRECTORY_SEPARATOR,$Export->TempDir); 206 MPQPack($workdir.'lua'); 207 SetProgres($Export,80); 208 MPQPack($workdir.'dbc'); 209 210 SetProgres($Export,90); 211 echo('Creating instalator...'."\n"); 212 if (DIRECTORY_SEPARATOR == '/') // linux 213 echo exec('makensis '.$workdir.$nsifile); 214 215 if (DIRECTORY_SEPARATOR == '\\') // windows 216 echo exec('"'.$workdir.$nsifile.'" '); //"c:\Program Files (x86)\NSIS\makensisw.exe" /Xscriptcmd 217 218 SetProgres($Export,100); 219 echo ("\n"."Hotovo"."\n") 220 $System->Database->query('UPDATE `ExportTask` SET `TimeFinish`=NOW() WHERE `Export`='.$DbRow['Export']); 94 221 } else 95 222 {
Note:
See TracChangeset
for help on using the changeset viewer.