Пример #1
0
 /**
  * バックアップファイル作成.
  *
  * @param  string      $bkup_name
  * @param string $work_dir
  * @return boolean|int 結果。true:成功 int:失敗 FIXME 本来は int ではなく、エラーメッセージを戻すべき
  */
 public function lfCreateBkupData($bkup_name, $work_dir)
 {
     $objQuery = Application::alias('eccube.query');
     $csv_autoinc = '';
     $arrData = array();
     $success = mkdir($work_dir, 0777, true);
     if (!$success) {
         return __LINE__;
     }
     // 全テーブル取得
     $arrTableList = $objQuery->listTables();
     // 各テーブル情報を取得する
     foreach ($arrTableList as $table) {
         if ($table == 'dtb_bkup' || $table == 'mtb_zip') {
             continue;
         }
         // dataをCSV出力
         $csv_file = $work_dir . $table . '.csv';
         $this->fpOutput = fopen($csv_file, 'w');
         if (!$this->fpOutput) {
             return __LINE__;
         }
         // 全データを取得
         $sql = 'SELECT * FROM ' . $objQuery->conn->quoteIdentifier($table);
         $this->output_header = true;
         $success = $objQuery->doCallbackAll(array(&$this, 'cbOutputCSV'), $sql);
         fclose($this->fpOutput);
         if ($success === false) {
             return __LINE__;
         }
         // タイムアウトを防ぐ
         Utils::sfFlush();
     }
     // 自動採番型の構成を取得する
     $csv_autoinc = $this->lfGetAutoIncrement();
     $csv_autoinc_file = $work_dir . 'autoinc_data.csv';
     // CSV出力
     // 自動採番をCSV出力
     $fp = fopen($csv_autoinc_file, 'w');
     if ($fp) {
         if ($csv_autoinc != '') {
             $success = fwrite($fp, $csv_autoinc);
             if (!$success) {
                 return __LINE__;
             }
         }
         fclose($fp);
     }
     //圧縮フラグTRUEはgzip圧縮をおこなう
     $tar = new Archive_Tar($this->bkup_dir . $bkup_name . $this->bkup_ext, TRUE);
     //bkupフォルダに移動する
     chdir($work_dir);
     //圧縮をおこなう
     $zip = $tar->create('./');
     return true;
 }
Пример #2
0
    /**
     * DB登録
     *
     * @return void
     */
    public function insertMtbZip($start = 1)
    {
        $objQuery = Application::alias('eccube.query');
        $img_path = USER_URL . USER_PACKAGE_DIR . 'admin/img/basis/';
        // 画像パスは admin 固定
        ?>
        <html xmlns='http://www.w3.org/1999/xhtml' lang='ja' xml:lang='ja'>
        <head>
            <meta http-equiv='Content-Type' content='text/html; charset=<?php 
        echo CHAR_CODE;
        ?>
' />
        </head>
        <body>
        <p>DB 登録進捗状況</p>
        <div style='background-color: #494E5F;'>
        <?php 
        // 一部のIEは256バイト以上受け取ってから表示を開始する。
        Utils::sfFlush(true);
        echo '<img src="' . $img_path . 'zip_install_progress.gif"><br />';
        echo '<img src="' . $img_path . 'space_w.gif">';
        Utils::sfFlush();
        // 画像を一個表示する件数を求める。
        $line_all = $this->countZipCsv();
        $disp_line = intval($line_all / IMAGE_MAX);
        /** 現在行(CSV形式。空行は除く。) */
        $cntCurrentLine = 0;
        /** 挿入した行数 */
        $cntInsert = 0;
        $img_cnt = 0;
        $fp = $this->openZipCsv();
        while (!feof($fp)) {
            $arrCSV = fgetcsv($fp, ZIP_CSV_LINE_MAX);
            if (empty($arrCSV)) {
                continue;
            }
            $cntCurrentLine++;
            if ($cntCurrentLine >= $start) {
                $sqlval = array();
                $sqlval['zip_id'] = $cntCurrentLine;
                $sqlval['zipcode'] = $arrCSV[2];
                $sqlval['state'] = $arrCSV[6];
                $sqlval['city'] = $arrCSV[7];
                $sqlval['town'] = $arrCSV[8];
                $objQuery->insert('mtb_zip', $sqlval);
                $cntInsert++;
            }
            // $disp_line件ごとに進捗表示する
            if ($cntCurrentLine % $disp_line == 0 && $img_cnt < IMAGE_MAX) {
                echo '<img src="' . $img_path . 'graph_1_w.gif">';
                Utils::sfFlush();
                $img_cnt++;
            }
            Utils::extendTimeOut();
        }
        fclose($fp);
        echo '<img src="' . $img_path . 'space_w.gif">';
        ?>
        </div>
        <script type='text/javascript' language='javascript'>
            <!--
                // 完了画面
                function complete()
                {
                    document.open('text/html','replace');
                    document.clear();
                    document.write('<p>完了しました。<br />');
                    document.write("<?php 
        echo $cntInsert;
        ?>
 件を追加しました。</p>");
                    document.write("<p><a href='?' target='_top'>戻る</a></p>");
                    document.close();
                }
                // コンテンツを削除するため、タイムアウトで呼び出し。
                setTimeout('complete()', 0);
            // -->
        </script>
        </body>
        </html>
        <?php 
    }
Пример #3
0
 /**
  * モバイル端末以外ダウンロード処理
  *
  * @param string $realpath       ダウンロードファイルパス
  * @param string $sdown_filename ダウンロード時の指定ファイル名
  */
 public function lfDownload($realpath, $sdown_filename)
 {
     // 拡張子を取得
     $extension = pathinfo($realpath, PATHINFO_EXTENSION);
     $contentType = $this->defaultContentType;
     // 拡張ContentType判定(拡張子をキーに拡張ContentType対象か判断)
     if (isset($this->arrContentType[$extension])) {
         // 拡張ContentType対象の場合は、ContentTypeを変更
         $contentType = $this->arrContentType[$extension];
     }
     header('Content-Type: ' . $contentType);
     //ファイル名指定
     header('Content-Disposition: attachment; filename="' . $sdown_filename . '"');
     header('Content-Transfer-Encoding: binary');
     //キャッシュ無効化
     header('Expires: Mon, 26 Nov 1962 00:00:00 GMT');
     header('Last-Modified: ' . gmdate('D,d M Y H:i:s') . ' GMT');
     //IE6+SSL環境下は、キャッシュ無しでダウンロードできない
     header('Cache-Control: private');
     header('Pragma: private');
     //ファイルサイズ指定
     $zv_filesize = filesize($realpath);
     header('Content-Length: ' . $zv_filesize);
     //ファイル読み込み
     $handle = fopen($realpath, 'rb');
     if ($handle === false) {
         Utils::sfDispSiteError(DOWNFILE_NOT_FOUND, '', true);
         Application::alias('eccube.response')->actionExit();
     }
     while (!feof($handle)) {
         echo fread($handle, DOWNLOAD_BLOCK * 1024);
         Utils::sfFlush();
         Utils::extendTimeOut();
     }
     fclose($handle);
 }