Esempio n. 1
0
	print $buffer;
	}
	return fclose($handle);
}
if (!function_exists('mime_content_type'))
{
	function mime_content_type($f)
	{
		$f = escapeshellarg($f);
		return trim( `file -bi $f` );
	}
}

if($Path != "")
{
	if(isset($_GET["Zip"]) && $_GET["Zip"] == 1 && $NeedZip) die(ZipDir($lsdir));
	if(isset($_GET["Info"]) && $_GET["Info"] == 1) die(FileInfo($Path));
	if(isset($_GET["Img"]) && $_GET["Img"] == 1) die(CreateThumbnail($Path));
	if(isset($_GET["DownLoad"]) && $_GET["DownLoad"] == 1) die(Download($Path));
}

if(isset($_GET['Delete']))
{
	$file = base64_decode($_GET['Delete']);
	if(isset($_GET['Confirm']) && $_GET['Confirm'])
	{
		unlink($ExploreDir.'/'.$file);
		die(header('Location: ./?Path='.base64_encode($Path)));
	}
	else
	{
function ZipDir($dir, $zip, $relative_path = DIRECTORY_SEPARATOR)
{
    //$dir = rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
    if ($handle = opendir($dir)) {
        while (false !== ($file = readdir($handle))) {
            if (file === '.' || $file === '..') {
                continue;
            }
            if (is_file($dir . $file)) {
                $zip->addFile($dir . $file, $file);
            } else {
                if (is_dir($dir . $file)) {
                    ZipDir($dir . $file, $zip, $relative_path . $file);
                }
            }
        }
    }
    closedir($handle);
}
Esempio n. 3
0
            $src_coll = geoODS2xml($coll);
        } else {
        }
        $result = ExtCollGeoByTax($result, $tax_names, $src_coll, $src_geo, $control);
    }
    $res_collections = MakeCollIndex($src_path['collections'], $result['coll']);
    //load the base
    $basedir = $upl_path . '/' . $set[$nset]['name'];
    if (is_dir($basedir)) {
        rm_rf($basedir);
    } else {
    }
    mkdir($basedir);
    $base_index = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><base></base>');
    $base_index->addChild('title', $set[$nset]['title']);
    $base_index->addChild('description', $set[$nset]['description']);
    $base_index->addChild('collection', $set[$nset]['collection']);
    $base_index->addChild('geodata', $set[$nset]['geodata']);
    $base_index->addChild('taxonomy', $set[$nset]['taxonomy']);
    $base_index->asXML($basedir . '/index.xml');
    $tax_xml->asXML($basedir . '/' . $set[$nset]['taxonomy']);
    $result['geo']->asXML($basedir . '/' . $set[$nset]['geodata']);
    $result['coll']->asXML($basedir . '/' . $set[$nset]['collection']);
    $res_collections->asXML($basedir . '/collections.xml');
    copy($src_path['map'] . '/' . $set[$nset]['map'] . '/blank.jpg', $basedir . '/blank.jpg');
    copy($src_path['map'] . '/' . $set[$nset]['map'] . '/blank.kml', $basedir . '/blank.kml');
    ZipDir($upl_path, $set[$nset]['name']);
    print '<p>Генерация завершена. Архив с базой данных: <a href="' . $basedir . '/' . $set[$nset]['name'] . '.zip">' . $set[$nset]['name'] . '</a></p>';
}
//===============================================================================
print '</body></html>';
 public function backup($root, $dirs, $files)
 {
     ignore_user_abort(true);
     @set_time_limit(2400);
     if (!class_exists('ZipArchive')) {
         $re = $this->langTxt('er_zip');
     } else {
         function ZipAddDir($dir, $zip, $zipPath, $files = [])
         {
             if ($dir != rtrim($_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . '/' . BK_DIR, '/')) {
                 //if not  backup folder
                 global $bk_exc;
                 $nrf = count($files);
                 $d = opendir($dir);
                 $zipPath = str_replace('//', '/', $zipPath);
                 if ($zipPath && $zipPath != '/') {
                     $zip->addEmptyDir($zipPath);
                 }
                 while (($f = readdir($d)) !== false) {
                     if ($f == '.' || $f == '..') {
                         continue;
                     } else {
                         if ($nrf == 0 || in_array($f, $files)) {
                             $f_ex = explode('.', $f);
                             $f_ex = end($f_ex);
                             //file-extension
                             $filePath = str_replace('//', '/', $dir . '/' . $f);
                             if (is_file($filePath) && !in_array($f_ex, $bk_exc)) {
                                 $zip->addFile($filePath, ($zipPath ? $zipPath . '/' : '') . $f);
                             } else {
                                 if (is_dir($filePath)) {
                                     ZipAddDir($filePath, $zip, ($zipPath ? $zipPath . '/' : '') . $f);
                                 }
                             }
                         }
                     }
                 }
                 closedir($d);
             }
         }
         //create object with ZIP, call ZipAddDir() to add passed $dirs/$files from $root
         function ZipDir($root, $dirs, $files, $zipFile, $zipPath = '')
         {
             $nrd = count($dirs);
             $zip = new ZipArchive();
             $zip->open($zipFile, ZIPARCHIVE::OVERWRITE);
             if (count($files) > 0) {
                 ZipAddDir($root, $zip, $zipPath, $files);
             }
             //add the files from root in ZIP
             if ($nrd > 0) {
                 //add the $dirs
                 for ($i = 0; $i < $nrd; $i++) {
                     ZipAddDir(str_replace('//', '/', $root . '/' . $dirs[$i]), $zip, $dirs[$i]);
                 }
             }
             $zip->close();
         }
         //set zip name (last part from $root)
         $name = explode('/', $root);
         $name = end($name);
         $zip_nm = 'dir-' . ($name == '' ? 'root' : $name) . '.zip';
         try {
             $zipPath = rtrim($this->bk_dir, '/') . '/' . $zip_nm;
             ZipDir($root, $dirs, $files, $zipPath);
             $re = '-' . sprintf($this->langTxt('ok_saved'), $zip_nm) . '-';
         } catch (Exception $ex) {
             $re = sprintf($this->langTxt('er_saved'), $zip_nm);
         }
     }
     return $re;
 }