source: branches/dev/html/input_zip_json.php @ 12982

Revision 12982, 2.0 KB checked in by nakanishi, 15 years ago (diff)
Line 
1<?php
2/*
3 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7
8require_once("./require.php");
9header("Content-Type: text/json; charset=utf-8");
10class 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}
20
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// ÆþÎÏ¥¨¥é¡¼¤Î¾ì¹ç¤Ï½ªÎ»
29if(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    ¡¦¡Ê£±¢·£±£¹ÃúÌÜ¡Ë
50    ¡¦°Ê²¼¤Ë·ÇºÜ¤¬¤Ê¤¤¾ì¹ç
51*/
52$town = ereg_replace("¡Ê.*¡Ë$","",$town);
53$town = ereg_replace("°Ê²¼¤Ë·ÇºÜ¤¬¤Ê¤¤¾ì¹ç","",$town);
54$objPage->tpl_town = $town;
55
56// ͹ÊØÈֹ椬ȯ¸«¤µ¤ì¤¿¾ì¹ç
57if(count($data_list) > 0) {
58    mb_http_output ( 'UTF-8' );
59    echo "{ 'POST' : '$town' , 'GET' : 'test' }";
60    //$func = "fnPutAddress('" . $_GET['input1'] . "','" . $_GET['input2']. "');";
61    //$objPage->tpl_onload = "$func";
62    //$objPage->tpl_start = "window.close();";
63} else {
64    $objPage->tpl_message = "³ºÅö¤¹¤ë½»½ê¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó¤Ç¤·¤¿¡£";
65}
66
67/* ÆþÎÏ¥¨¥é¡¼¤Î¥Á¥§¥Ã¥¯ */
68function fnErrorCheck() {
69    // ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸ÇÛÎó¤Î½é´ü²½
70    $objErr = new SC_CheckError();
71   
72    // ͹ÊØÈÖ¹æ
73    $objErr->doFunc( array("͹ÊØÈÖ¹æ1",'zip1',ZIP01_LEN ) ,array( "NUM_COUNT_CHECK" ) );
74    $objErr->doFunc( array("͹ÊØÈÖ¹æ2",'zip2',ZIP02_LEN ) ,array( "NUM_COUNT_CHECK" ) );
75   
76    return $objErr->arrErr;
77}
78
79?>
Note: See TracBrowser for help on using the repository browser.