Changeset 16174 for branches/feature-module-update/html/input_zip.php
- Timestamp:
- 2007/09/29 22:01:49 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/feature-module-update/html/input_zip.php
r15532 r16174 6 6 */ 7 7 8 // {{{ requires 8 9 require_once("./require.php"); 10 require_once(CLASS_PATH . "page_extends/LC_Page_InputZip_Ex.php"); 9 11 10 class LC_Page { 11 var $tpl_state; 12 var $tpl_city; 13 var $tpl_town; 14 var $tpl_onload; 15 var $tpl_message; 16 function CPage() { 17 $this->tpl_message = "住所を検索しています。"; 18 } 19 } 12 // }}} 13 // {{{ generate page 20 14 21 $conn = new SC_DBconn(ZIP_DSN); 22 $objPage = new LC_Page(); 23 $objView = new SC_SiteView(false); 24 25 // 入力エラーチェック 26 $arrErr = fnErrorCheck(); 27 28 // 入力エラーの場合は終了 29 if(count($arrErr) > 0) { 30 $objPage->tpl_start = "window.close();"; 31 } 32 33 // 郵便番号検索文作成 34 $zipcode = $_GET['zip1'].$_GET['zip2']; 35 $zipcode = mb_convert_kana($zipcode ,"n"); 36 $sqlse = "SELECT state, city, town FROM mtb_zip WHERE zipcode = ?"; 37 38 $data_list = $conn->getAll($sqlse, array($zipcode)); 39 40 // インデックスと値を反転させる。 41 $arrREV_PREF = array_flip($arrPref); 42 43 $objPage->tpl_state = $arrREV_PREF[$data_list[0]['state']]; 44 $objPage->tpl_city = $data_list[0]['city']; 45 $town = $data_list[0]['town']; 46 /* 47 総務省からダウンロードしたデータをそのままインポートすると 48 以下のような文字列が入っているので 対策する。 49 ・(1~19丁目) 50 ・以下に掲載がない場合 51 */ 52 $town = ereg_replace("(.*)$","",$town); 53 $town = ereg_replace("以下に掲載がない場合","",$town); 54 $objPage->tpl_town = $town; 55 56 // 郵便番号が発見された場合 57 if(count($data_list) > 0) { 58 $func = "fnPutAddress('" . $_GET['input1'] . "','" . $_GET['input2']. "');"; 59 $objPage->tpl_onload = "$func"; 60 $objPage->tpl_start = "window.close();"; 61 } else { 62 $objPage->tpl_message = "該当する住所が見つかりませんでした。"; 63 } 64 65 /* ページの表示 */ 66 $objView->assignobj($objPage); 67 $objView->display("input_zip.tpl"); 68 69 /* 入力エラーのチェック */ 70 function fnErrorCheck() { 71 // エラーメッセージ配列の初期化 72 $objErr = new SC_CheckError(); 73 74 // 郵便番号 75 $objErr->doFunc( array("郵便番号1",'zip1',ZIP01_LEN ) ,array( "NUM_COUNT_CHECK" ) ); 76 $objErr->doFunc( array("郵便番号2",'zip2',ZIP02_LEN ) ,array( "NUM_COUNT_CHECK" ) ); 77 78 return $objErr->arrErr; 79 } 80 15 $objPage = new LC_Page_InputZip_Ex(); 16 $objPage->init(); 17 $objPage->process(); 18 register_shutdown_function(array($objPage, "destroy")); 81 19 ?>
Note: See TracChangeset
for help on using the changeset viewer.