* @since PHP 4.3.8 * @version 1.0 */ class MekiAction extends Action { // コンストラクタ function MekiAction() { // 親クラスのコンストラクタを呼び出す。 // ログインチェックを行わない。 parent::Action(new MekiForm(), false); $this->form->keywords = '最寄駅検索,IP,アドレス,住所,地域,都市,緯度,経度,検索,Google,Map,フォーム,WEB,ツール'; $this->form->description = '現在位置から最寄駅を検索するフォームです。位置を指定して最寄駅検索ボタンをクリックしてください。'; } //------------------------------------------------------------------------ // 非公開メソッド //------------------------------------------------------------------------ /** * 入力チェックを行う。 * * @return チェックOKの場合は TRUE、 * チェックNGの場合は FALSE。 */ function validate() { $success = TRUE; // 緯度 $success = $this->validateProperty('lat') && $success; // 経度 $success = $this->validateProperty('lon') && $success; // 距離 $success = $this->validateProperty('rad') && $success; return $success; } /** * IPアドレス位置情報を取得 */ function geoip() { $ip = $this->form->ip; $ip = gethostbyname($ip); include("geoipcity.inc"); include("geoipregionvars.php"); $gi = geoip_open(GEOIP_DIR . "GeoLiteCity.dat",GEOIP_STANDARD); $record = geoip_record_by_addr($gi, $ip); $this->form->lat = $record->latitude; $this->form->lon = $record->longitude; geoip_close($gi); } //------------------------------------------------------------------------ // 表示系メソッド('disp'からはじめ、非公開メソッドとして扱うこと) //------------------------------------------------------------------------ // 入力 function dispEntryForm() { $this->form->sub_title = '最寄駅検索'; $this->forward('meki_entry.html'); } //------------------------------------------------------------------------ // 制御系メソッド('do'からはじめ、公開メソッドとして扱うこと) //------------------------------------------------------------------------ // 入力 function doInit() { $this->form->ip = $_SERVER['REMOTE_ADDR']; $this->geoip(); $this->dispEntryForm(); } } //---------------------------------------------------------------------------- // メインルーチン //---------------------------------------------------------------------------- // アクションクラスを生成する。 $APP = new MekiAction(); $APP->doInit(); ?>