- Timestamp:
- 2010/03/11 10:35:11 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tmp/version-2_5-test/data/class/pages/LC_Page_InputZip.php
r17682 r18609 53 53 */ 54 54 function process() { 55 $conn = new SC_DBconn(ZIP_DSN);56 55 $objView = new SC_SiteView(false); 57 56 … … 60 59 // 入力エラーの場合は終了 61 60 if(count($arrErr) > 0) { 62 $this->tpl_start = "window.close();"; 63 SC_Utils::sfDispSiteError(CUSTOMER_ERROR); 61 $tpl_message = ""; 62 foreach($arrErr as $key => $val) { 63 $tpl_message .= preg_replace("/<br \/>/", "\n", $val); 64 } 65 echo $tpl_message; 66 67 // エラー無し 68 } else { 69 // 郵便番号検索文作成 70 $zipcode = $_GET['zip1'].$_GET['zip2']; 71 $zipcode = mb_convert_kana($zipcode ,"n"); 72 73 // 郵便番号検索 74 $data_list = SC_Utils_Ex::sfGetAddress($zipcode); 75 76 // 郵便番号が発見された場合 77 if(!empty($data_list)) { 78 $data = $data_list[0]['state']. "|". $data_list[0]['city']. "|". $data_list[0]['town']; 79 echo $data; 80 81 // 該当無し 82 } else { 83 echo "該当する住所が見つかりませんでした。"; 84 } 64 85 } 65 66 // 郵便番号検索文作成67 $zipcode = $_GET['zip1'].$_GET['zip2'];68 $zipcode = mb_convert_kana($zipcode ,"n");69 $sqlse = "SELECT state, city, town FROM mtb_zip WHERE zipcode = ?";70 71 $data_list = $conn->getAll($sqlse, array($zipcode));72 if (empty($data_list)) $data_list = array();73 74 $masterData = new SC_DB_MasterData_Ex();75 $arrPref = $masterData->getMasterData("mtb_pref", array("pref_id", "pref_name", "rank"));76 // インデックスと値を反転させる。77 $arrREV_PREF = array_flip($arrPref);78 79 if (!empty($data_list)) {80 $this->tpl_state = isset($arrREV_PREF[$data_list[0]['state']])81 ? $arrREV_PREF[$data_list[0]['state']] : "";82 $this->tpl_city = isset($data_list[0]['city']) ? $data_list[0]['city'] : "";83 $town = isset($data_list[0]['town']) ? $data_list[0]['town'] : "";84 } else {85 $town = "";86 }87 88 /*89 総務省からダウンロードしたデータをそのままインポートすると90 以下のような文字列が入っているので 対策する。91 ・(1~19丁目)92 ・以下に掲載がない場合93 */94 $town = ereg_replace("(.*)$","",$town);95 $town = ereg_replace("以下に掲載がない場合","",$town);96 $this->tpl_town = $town;97 98 // 郵便番号が発見された場合99 if(!empty($data_list)) {100 $func = "fnPutAddress('" . $_GET['input1'] . "','" . $_GET['input2']. "');";101 $this->tpl_onload = "$func";102 $this->tpl_start = "window.close();";103 } else {104 $this->tpl_message = "該当する住所が見つかりませんでした。";105 }106 107 /* ページの表示 */108 $objView->assignobj($this);109 $objView->display("input_zip.tpl");110 86 } 111 87 … … 121 97 122 98 /* 入力エラーのチェック */ 123 function fnErrorCheck( ) {99 function fnErrorCheck($array) { 124 100 // エラーメッセージ配列の初期化 125 101 $objErr = new SC_CheckError($array); 126 102 127 103 // 郵便番号 128 $objErr->doFunc( array("郵便番号1",'zip1',ZIP01_LEN ) ,array( "NUM_COUNT_CHECK" ) );129 $objErr->doFunc( array("郵便番号2",'zip2',ZIP02_LEN ) ,array( "NUM_COUNT_CHECK" ) );104 $objErr->doFunc( array("郵便番号1",'zip1',ZIP01_LEN ) ,array( "NUM_COUNT_CHECK", "NUM_CHECK" ) ); 105 $objErr->doFunc( array("郵便番号2",'zip2',ZIP02_LEN ) ,array( "NUM_COUNT_CHECK", "NUM_CHECK" ) ); 130 106 // 親ウィンドウの戻り値を格納するinputタグのnameのエラーチェック 131 107 if (!$this->lfInputNameCheck($array['input1'])) { … … 138 114 return $objErr->arrErr; 139 115 } 140 141 142 * エラーチェック143 *144 * @param string $value145 * @return エラーなし:true エラー:false146 */116 117 /** 118 * エラーチェック 119 * 120 * @param string $value 121 * @return エラーなし:true エラー:false 122 */ 147 123 function lfInputNameCheck($value) { 148 124 // 半角英数字と_(アンダーバー)以外の文字を使用していたらエラー … … 150 126 return false; 151 127 } 152 128 153 129 return true; 154 130 } 155 156 131 } 157 132 ?>
Note: See TracChangeset
for help on using the changeset viewer.