Page
[ class tree: Page ] [ index: Page ] [ all elements ]

Source for file LC_Page_Admin_Basis_ZipInstall.php

Documentation is available at LC_Page_Admin_Basis_ZipInstall.php

  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
  25. require_once(CLASS_PATH "pages/LC_Page.php");
  26.  
  27. /** CSV ファイルの最大行数 */
  28. define("ZIP_CSV_LINE_MAX"8192);
  29.  
  30. /** 画像の表示個数 */
  31. define("IMAGE_MAX"680);
  32.  
  33. /** 郵便番号CSV ファイルのパス */
  34. define("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.  */
  43.  
  44.     // }}}
  45.     // {{{ functions
  46.  
  47.     /**
  48.      * Page を初期化する.
  49.      *
  50.      * @return void 
  51.      */
  52.     function init({
  53.         parent::init();
  54.     }
  55.  
  56.     /**
  57.      * Page のプロセス.
  58.      *
  59.      * @return void 
  60.      */
  61.     function process({
  62.         $objQuery new SC_Query();
  63.         $objSess new SC_Session();
  64.  
  65.         // 認証可否の判定
  66.         SC_Utils_Ex::sfIsSuccess($objSess);
  67.  
  68.         $fp fopen(ZIP_CSV_FILE_PATH"r");
  69.         $img_path USER_URL "packages/" TEMPLATE_NAME "/img/";
  70.  
  71.         // 一部のIEは256バイト以上受け取ってから表示を開始する。
  72.         for($i 0$i 256$i++{
  73.             print(" ");
  74.         }
  75.         print("\n");
  76.         $this->myFlush();
  77.  
  78.         if(!$fp{
  79.             SC_Utils_Ex::sfErrorHeader(">> " ZIP_CSV_FILE_PATH "の取得に失敗しました。");
  80.         else {
  81.             print("<img src='"$img_path "install/main_w.jpg'><br>");
  82.             $this->myFlush();
  83.  
  84.             // CSVの件数を数える
  85.             $line 0;
  86.             while(!feof($fp)) {
  87.                 fgets($fpZIP_CSV_LINE_MAX);
  88.                 $line++;
  89.             }
  90.  
  91.             print("<img src='"$img_path ."install/space_w.gif'>");
  92.             $this->myFlush();
  93.  
  94.             // ファイルポインタを戻す
  95.             fseek($fp0);
  96.  
  97.             // 画像を一個表示する件数を求める。
  98.             $disp_line intval($line IMAGE_MAX);
  99.  
  100.             // 既に書き込まれたデータを数える
  101.             $end_cnt $objQuery->count("mtb_zip");
  102.             $cnt 1;
  103.             $img_cnt 0;
  104.             while (!feof($fp)) {
  105.                 $arrCSV fgetcsv($fpZIP_CSV_LINE_MAX);
  106.  
  107.                 // すでに書き込まれたデータを飛ばす。
  108.                 if($cnt $end_cnt{
  109.                     $sqlval['code'$arrCSV[0];
  110.                     $sqlval['old_zipcode'$arrCSV[1];
  111.                     $sqlval['zipcode'$arrCSV[2];
  112.                     $sqlval['state_kana'$arrCSV[3];
  113.                     $sqlval['city_kana'$arrCSV[4];
  114.                     $sqlval['town_kana'$arrCSV[5];
  115.                     $sqlval['state'$arrCSV[6];
  116.                     $sqlval['city'$arrCSV[7];
  117.                     $sqlval['town'$arrCSV[8];
  118.                     $sqlval['flg1'$arrCSV[9];
  119.                     $sqlval['flg2'$arrCSV[10];
  120.                     $sqlval['flg3'$arrCSV[11];
  121.                     $sqlval['flg4'$arrCSV[12];
  122.                     $sqlval['flg5'$arrCSV[13];
  123.                     $sqlval['flg6'$arrCSV[14];
  124.                     $objQuery->insert("mtb_zip"$sqlval);
  125.                 }
  126.  
  127.                 $cnt++;
  128.                 // $disp_line件ごとに進捗表示する
  129.                 if($cnt $disp_line == && $img_cnt IMAGE_MAX{
  130.                     print("<img src='"$img_path ."install/graph_1_w.gif'>");
  131.                     $this->myFlush();
  132.                     $img_cnt++;
  133.                 }
  134.             }
  135.             fclose($fp);
  136.  
  137.             print("<img src='"$img_path ."install/space_w.gif'><br>\n");
  138.             print("<table width='700' height='50' border='0' cellpadding='0' cellspacing='0' bgcolor='#494E5F'>\n");
  139.             print("<tr>\n");
  140.             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");
  141.             print("</tr>\n");
  142.             print("</table>\n");
  143.         }
  144.     }
  145.  
  146.     /**
  147.      * デストラクタ.
  148.      *
  149.      * @return void 
  150.      */
  151.     function destroy({
  152.         parent::destroy();
  153.     }
  154.  
  155.     /**
  156.      * 出力バッファをフラッシュし, バッファリングを開始する.
  157.      *
  158.      * @return void 
  159.      */
  160.     function myFlush({
  161.         flush();
  162.         ob_end_flush();
  163.         ob_start();
  164.     }
  165. }
  166. ?>

Documentation generated on Fri, 24 Feb 2012 13:58:30 +0900 by Seasoft