コード例 #1
0
ファイル: export.php プロジェクト: laiello/punchcms
<?php

require_once 'includes/init.php';
$accountId = Request::get("eid", 0);
$exportFiles = Request::get("files", true);
$blnError = false;
$objAccount = Account::selectByPk($accountId);
$strZipFile = ImpEx::export($accountId, $exportFiles);
if (is_object($objAccount) && $strZipFile !== false) {
    header("HTTP/1.1 200 OK");
    header("Pragma: public");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: private", false);
    header('Content-Type: application/octetstream; charset=utf-8');
    header("Content-Length: " . (string) filesize($strZipFile));
    header('Content-Disposition: attachment; filename="' . date("Y-m-d") . '_' . $objAccount->getUri() . '.zip"');
    header("Content-Transfer-Encoding: binary\n");
    readfile($strZipFile);
    exit;
} else {
    ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Downloader</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>
<h2>Sorry, File not found</h2>
コード例 #2
0
ファイル: class.account.php プロジェクト: laiello/punchcms
 public function makeBackup($intMax = 5)
 {
     global $_PATHS;
     $strZipFile = ImpEx::export($this->id);
     copy($strZipFile, $_PATHS['backup'] . $this->punchId . "_" . strftime("%Y%m%d%H%M%S") . ".zip");
     //*** Remove old backups.
     $arrFiles = scandir($_PATHS['backup'], 1);
     $intCount = 1;
     foreach ($arrFiles as $strFileName) {
         if (substr($strFileName, 0, strlen($this->punchId) + 1) == $this->punchId . "_") {
             if ($intCount > $intMax) {
                 @unlink($_PATHS['backup'] . $strFileName);
             }
             $intCount++;
         }
     }
     @unlink($strZipFile);
 }