source: trunk/data/class/pages/admin/basis/LC_Page_Admin_Basis_ZipInstall.php @ 18758

Revision 18758, 5.2 KB checked in by kajiwara, 14 years ago (diff)

EC-CUBE Ver2.4.4 分コミット。詳細はこちら( http://www.ec-cube.net/release/detail.php?release_id=223

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id Revision Date
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23
24// {{{ requires
25require_once(CLASS_PATH . "pages/LC_Page.php");
26
27/** CSV ファイルの最大行数 */
28define("ZIP_CSV_LINE_MAX", 8192);
29
30/** 画像の表示個数 */
31define("IMAGE_MAX", 680);
32
33/** 郵便番号CSV ファイルのパス */
34define("ZIP_CSV_FILE_PATH", DATA_PATH . "downloads/KEN_ALL.CSV");
35
36/**
37 * 郵便番号DB登録 のページクラス.
38 *
39 * @package Page
40 * @author LOCKON CO.,LTD.
41 * @version $Id:LC_Page_Admin_Basis_ZipInstall.php 16741 2007-11-08 00:43:24Z adachi $
42 */
43class LC_Page_Admin_Basis_ZipInstall extends LC_Page {
44
45    // }}}
46    // {{{ functions
47
48    /**
49     * Page を初期化する.
50     *
51     * @return void
52     */
53    function init() {
54        parent::init();
55    }
56
57    /**
58     * Page のプロセス.
59     *
60     * @return void
61     */
62    function process() {
63        $objQuery = new SC_Query();
64        $objSess = new SC_Session();
65
66        // 認証可否の判定
67        SC_Utils_Ex::sfIsSuccess($objSess);
68
69        $fp = fopen(ZIP_CSV_FILE_PATH, "r");
70        $img_path = USER_URL . "packages/" . TEMPLATE_NAME . "/img/";
71
72        // 一部のIEは256バイト以上受け取ってから表示を開始する。
73        for($i = 0; $i < 256; $i++) {
74            print(" ");
75        }
76        print("\n");
77        $this->myFlush();
78
79        if(!$fp) {
80            SC_Utils_Ex::sfErrorHeader(">> " . ZIP_CSV_FILE_PATH . "の取得に失敗しました。");
81        } else {
82            print("<img src='". $img_path . "install/main_w.jpg'><br>");
83            $this->myFlush();
84
85            // CSVの件数を数える
86            $line = 0;
87            while(!feof($fp)) {
88                fgets($fp, ZIP_CSV_LINE_MAX);
89                $line++;
90            }
91
92            print("<img src='". $img_path ."install/space_w.gif'>");
93            $this->myFlush();
94
95            // ファイルポインタを戻す
96            fseek($fp, 0);
97
98            // 画像を一個表示する件数を求める。
99            $disp_line = intval($line / IMAGE_MAX);
100
101            // 既に書き込まれたデータを数える
102            $end_cnt = $objQuery->count("mtb_zip");
103            $cnt = 1;
104            $img_cnt = 0;
105            while (!feof($fp)) {
106                $arrCSV = fgetcsv($fp, ZIP_CSV_LINE_MAX);
107
108                // すでに書き込まれたデータを飛ばす。
109                if($cnt > $end_cnt) {
110                    $sqlval['code'] = $arrCSV[0];
111                    $sqlval['old_zipcode'] = $arrCSV[1];
112                    $sqlval['zipcode'] = $arrCSV[2];
113                    $sqlval['state_kana'] = $arrCSV[3];
114                    $sqlval['city_kana'] = $arrCSV[4];
115                    $sqlval['town_kana'] = $arrCSV[5];
116                    $sqlval['state'] = $arrCSV[6];
117                    $sqlval['city'] = $arrCSV[7];
118                    $sqlval['town'] = $arrCSV[8];
119                    $sqlval['flg1'] = $arrCSV[9];
120                    $sqlval['flg2'] = $arrCSV[10];
121                    $sqlval['flg3'] = $arrCSV[11];
122                    $sqlval['flg4'] = $arrCSV[12];
123                    $sqlval['flg5'] = $arrCSV[13];
124                    $sqlval['flg6'] = $arrCSV[14];
125                    $objQuery->insert("mtb_zip", $sqlval);
126                }
127
128                $cnt++;
129                // $disp_line件ごとに進捗表示する
130                if($cnt % $disp_line == 0 && $img_cnt < IMAGE_MAX) {
131                    print("<img src='". $img_path ."install/graph_1_w.gif'>");
132                    $this->myFlush();
133                    $img_cnt++;
134                }
135            }
136            fclose($fp);
137
138            print("<img src='". $img_path ."install/space_w.gif'><br>\n");
139            print("<table width='700' height='50' border='0' cellpadding='0' cellspacing='0' bgcolor='#494E5F'>\n");
140            print("<tr>\n");
141            print("<td align='center'><a href='javascript:window.close()'><img src='". $img_path ."install/close.gif' alt='CLOSE' width='85' height='22' border='0' /></a></td>\n");
142            print("</tr>\n");
143            print("</table>\n");
144        }
145    }
146
147    /**
148     * デストラクタ.
149     *
150     * @return void
151     */
152    function destroy() {
153        parent::destroy();
154    }
155
156    /**
157     * 出力バッファをフラッシュし, バッファリングを開始する.
158     *
159     * @return void
160     */
161    function myFlush() {
162        flush();
163        ob_end_flush();
164        ob_start();
165    }
166}
167?>
Note: See TracBrowser for help on using the repository browser.