Changeset 61 for trunk/download.php


Ignore:
Timestamp:
Feb 4, 2009, 9:51:34 PM (15 years ago)
Author:
george
Message:
  • Přidáno: Export překladů do českého WoW Addonu.
  • Upraveno: Export souborů se nyní ukládá samostatně do složek dle jmen uživatelů.
  • Přidáno: Zobrazování chyb dle konfigurace.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/download.php

    r60 r61  
    1010include('includes/zip.lib.php');
    1111include('export.php');   
    12 
     12include('addon/make.php');
    1313
    1414function CheckBox($Name, $Checked = false)
     
    4242}
    4343
    44 switch(@$_GET['action'])
     44function CreateZipFromDir(&$Zip, $Path, $ZipPath)
     45{
     46  //echo($Path.'<br />');
     47  $FileList = scandir($Path);
     48  foreach($FileList as $FileName)
     49  {
     50        if(file_exists($Path.$FileName) and ($FileName != '.') and ($FileName != '..'))
     51        {
     52      //echo($Path.$FileName.'<br />');
     53          if(is_dir($Path.$FileName)) CreateZipFromDir($Zip, $Path.$FileName.'/', $ZipPath.$FileName.'/');
     54      else $Zip->addFile(file_get_contents($Path.$FileName), $ZipPath.$FileName);       
     55        }         
     56  }
     57}
     58
     59if(!array_key_exists('action', $_GET)) $_GET['action'] = '';
     60switch($_GET['action'])
    4561{
    4662  case 'result':
     
    5167        if(function_exists('gzcompress'))
    5268        {
    53           $SaveFilename = 'tmp/SqlTranslate.zip';
    54           $SQLFilename = 'tmp/SqlTranslate.sql';       
     69                  $TempDir = 'tmp/'.$_SESSION['User'].'/';
     70                  if(!file_exists($TempDir)) mkdir($TempDir, 0777, true);
     71          $SaveFilename = $TempDir.'CzWoW_SQL.zip';
     72          $SQLFilename = $TempDir.'CzWoW_SQL.sql';       
    5573          $BufferZip = Export($ExportSetting);
    5674          $ZipFile = new zipfile();
    5775          $ZipFile->addFile($BufferZip, $SQLFilename);
    5876          $Buffer = $ZipFile->file();
    59 
    60           //  echo $Buffer.'<br><br><br>';
    61           $FileHandle = fopen($SaveFilename, 'w');
    62           $WriteResult = fwrite($FileHandle, $Buffer);
    63           fclose($FileHandle);
    64           //  header("Location: ".$save_filename);
     77          file_put_contents($SaveFilename, $Buffer);
    6578        } else echo('Funkce pro tvorbu Zip souboru není podporována!');
    6679        echo('<script type="text/javascript" language="JavaScript" charset="utf-8">'.
     
    92105                } else echo('Nemáte oprávnění.');
    93106            break;
     107          case 'Addon':
     108        if(function_exists('gzcompress'))
     109        {
     110          $TempDir = 'tmp/'.$_SESSION['User'].'/CzWoW/';
     111              echo('Generování addonu...<br />');
     112          MakeAddon($ExportSetting);
     113          $SaveFilename = 'tmp/'.$_SESSION['User'].'/CzWoW_Addon.zip';         
     114          $Zip = new zipfile();
     115                  CreateZipFromDir($Zip, $TempDir, 'CzWoW/');
     116          $Zip->addFile(file_get_contents('addon/CzWoW/OptionsFrame.xml'), 'CzWoW/OptionsFrame.xml');   
     117          $Zip->addFile(file_get_contents('addon/CzWoW/CzWoW.xml'), 'CzWoW/CzWoW.xml');
     118                  $Zip->addFile(file_get_contents('addon/CzWoW/CzWoW.toc'), 'CzWoW/CzWoW.toc');
     119          $Zip->addFile(file_get_contents('addon/CzWoW/CzWoW.lua'), 'CzWoW/CzWoW.lua');
     120                  $Zip->addFile(file_get_contents('addon/CzWoW/GameMenuFrame.xml'), 'CzWoW/GameMenuFrame.xml');
     121                  $Zip->addFile(file_get_contents('addon/CzWoW/Localization.lua'), 'CzWoW/Localization.lua');   
     122                  $Zip->addFile(file_get_contents('addon/ProffBot/ProffBot.toc'), 'ProffBot/ProffBot.toc');     
     123                  $Zip->addFile(file_get_contents('addon/ProffBot/ProffBot.xml'), 'ProffBot/ProffBot.xml');     
     124                  $Zip->addFile(file_get_contents('addon/ProffBot/ProffBot.lua'), 'ProffBot/ProffBot.lua');     
     125                  $Buffer = $Zip->file();
     126          file_put_contents($SaveFilename, $Buffer);
     127                  echo('Hotovo<br /><br />');
     128        } else echo('Funkce pro tvorbu Zip souboru není podporována!');
     129        echo('<script type="text/javascript" language="JavaScript" charset="utf-8">'.
     130          'setTimeout("parent.location.href=\''.$SaveFilename.'\'", 1000)'.
     131          '</script>');
     132     
     133        echo('Pokud nezačalo stahování, soubor by mělo jít stáhnout pomocí tohoto odkazu:'.
     134          '<a href="'.$SaveFilename.'">CzWoW_Addon.zip</a><br />'.
     135          'Pokud se vám zdá, že filtr na export nefunguje, vymažte si vyrovnávací paměť prohlížeče a zkuste stáhnout soubor znovu.');
     136            break;
    94137        }
    95138    WriteLog('Generování SQL výstupu: Typ exportu: <b>'.$ExportSetting['Export'].'</b>, Diakritika: <b>'.$ExportSetting['Diacritics'].'</b>', 2);
     
    103146    echo('<strong>Krok 3. - Typ výstupu</strong><br /><br />');
    104147    echo('<form action="?action=result" method="post">'.
    105           '<table width="100%"><tr><td>'.
     148          '<table width="100%"><tr><td width="50%">'.
    106149      '<fieldset><legend>Forma výstupu</legend>'.
    107150          RadioButton('Export', 'Zip', $ExportSetting['Export'] == 'Zip').'ZIP soubor<br />'.
    108           //RadioButton('Export', 'Addon', $ExportSetting['Export'] == 'Addon').'WoW klient addon<br />'.
     151          RadioButton('Export', 'Addon', $ExportSetting['Export'] == 'Addon').'WoW klient překládací addon<br />'.
    109152      RadioButton('Export', 'Display', $ExportSetting['Export'] == 'Display').'Přímo zobrazit<br />');
    110153    if(Licence(LICENCE_ADMIN))
Note: See TracChangeset for help on using the changeset viewer.