Пример #1
0
 /**
  * Gera um arquivo ZIP contendo as classes geradas
  * @author Hugo Ferreira da Silva
  * @link http://www.hufersil.com.br/
  * @return void
  */
 private function generateZip()
 {
     Lumine_Log::debug('Gerando arquivo ZIP');
     $raiz = $this->cfg->getProperty('class_path') . '/';
     $zipname = $this->cfg->getProperty('class_path') . '/lumine.zip';
     if (!is_writable($raiz)) {
         Lumine_Log::error('Nao e possivel criar arquivos em "' . $raiz . '". Verifique as permissoes.');
         exit;
     }
     $zip = new dZip($zipname);
     $sufix = $this->cfg->getOption('class_sufix');
     if (!empty($sufix)) {
         $sufix = '.' . $sufix;
     }
     $filename = str_replace('.', DIRECTORY_SEPARATOR, $this->cfg->getProperty('package'));
     $filename .= DIRECTORY_SEPARATOR;
     reset($this->files);
     foreach ($this->files as $classname => $content) {
         Lumine_Log::debug('Adicionando ' . $classname . ' ao ZIP');
         $name = $filename . $classname . $sufix . '.php';
         $zip->addFile($content, $name, 'Lumine Reverse', $content);
     }
     // adiciona os dto's
     reset($this->dto_files);
     // 2010-11-05
     // permite configurar a pasta para gravar os dto's
     $dtopath = '';
     if ($this->cfg->getOption('dto_package') != '') {
         $dtopath = str_replace('.', '/', $this->cfg->getOption('dto_package'));
     }
     foreach ($this->dto_files as $classname => $content) {
         Lumine_Log::debug('Adicionando DTO ' . $classname . ' ao ZIP');
         $name = $filename . 'dto/' . $dtopath . $classname . $sufix . '.php';
         $zip->addFile($content, $name, 'Lumine Reverse DTO', $content);
     }
     // models
     $path = $this->cfg->getOption('model_path') . '/';
     foreach ($this->models as $item) {
         Lumine_Log::debug('Adicionando Model ' . $classname . ' ao ZIP');
         $filename = $path . $item->getFileName();
         $content = $item->getContent();
         $zip->addFile($content, $filename, 'Lumine Reverse Model', $content);
     }
     // adiciona os controles
     $path = 'controls' . DIRECTORY_SEPARATOR;
     foreach ($this->controls as $classname => $content) {
         Lumine_Log::debug('Adicionando controle ' . $classname . ' ao ZIP');
         $name = $path . $classname . '.php';
         $zip->addFile($content, $name, 'Lumine Reverse Control', $content);
     }
     $zip->addFile($this->config, 'lumine-conf.php', 'Configuration File', $this->config);
     $zip->save();
     // altera as permissoes do arquivo
     chmod($zipname, 0777);
     Lumine_Log::debug('Arquivo ZIP gerado com sucesso em ' . $zipname);
     /*
     $fp = @fopen($zipname, "wb+");
     if($fp)
     {
     	fwrite($fp, $zip->getZippedfile());
     	fclose($fp);
     	
     	chmod($zipname, 0777);
     	
     	Lumine_Log::debug('Arquivo ZIP gerado com sucesso em '.$zipname);
     } else {
     	Lumine_Log::error('Falha ao gerar ZIP em '.$obj->getClassname().'. Verifique se a pasta existe e se tem direito de escrita.');
     	exit;
     }
     */
 }
Пример #2
0
    // get data from table
    $result = mysql_query("SELECT * FROM `{$table}`", $mysql_link);
    while (($row = mysql_fetch_assoc($result)) !== FALSE) {
        $row = array_map('format_insert_value', $row);
        $sql = "INSERT INTO `{$table}` VALUES (" . implode(',', $row) . ");\n";
        fwrite($fp, $sql);
    }
    mysql_free_result($result);
}
fclose($fp);
// zipfile
require_once 'dZip.inc.php';
// change this if you put dZip.inc.php on other place
$zip = new dZip($file);
$zip->addFile("backup/db_backup.sql", "db_backup.sql");
$zip->save();
//	$ZipName = "MyFiles/MyZip.zip";
//	require_once("dZip.inc.php"); // include Class
//	$zip = new dZip($ZipName); // New Class
//	$zip->addFile("thaicreate1.txt", "thaicreate1.txt"); // Source,Destination
//	$zip->addFile("thaicreate2.txt", "thaicreate2.txt");
//	$zip->addDir("MySub"); // Add Folder
//	$zip->addFile("thaicreate3.txt", "MySub/thaicreate3.txt"); // Add file to Sub
//	$zip->addFile("thaicreate4.txt", "MySub/thaicreate4.txt");
//	$zip->save();
//	echo "Zip Successful Click <a href=$ZipName>here</a> to Download";
@unlink($sql_file) or die("Database backup finished");
?>
<body>
	<TABLE cellSpacing=0 cellPadding=0 width=820 border=0>
      <TBODY>