<?php
/**
 * 
 * @copyright   2000-2007 LOCKON CO.,LTD. All Rights Reserved.
 * @version CVS: $Id: 1.0 2006-06-04 06:38:01Z matsumura $
 * @link        http://www.lockon.co.jp/
 *
 */
 
class LC_Page {
    
    function LC_Page() {
        $this->tpl_mainpage = MODULE_PATH . "blayn/blayn.tpl";
        $this->tpl_title = "ブレインIP登録";
        $this->tpl_subtitle = "ブレインIP設定モジュール";
    }
}
$objPage = new LC_Page();
$objView = new SC_AdminView();
$objQuery = new SC_Query();
$objFormParam = new SC_FormParam;

lfIntiParam();

$objFormParam->setParam($_POST);
$arrForm = $objFormParam->getHashArray();

if($mode == 'regist') {
    $objPage->arrErr = lfCheckError();
    if(count($objPage->arrErr) <= 0) {
        lfDelete();
        lfRegist();
    }
}
$objPage->arrIP = lfGetIP();

$objView->assignobj($objPage);      //変数をテンプレートにアサインする
$objView->display($objPage->tpl_mainpage);      //テンプレートの出力

// ------------------------------------------------------------------------------------------------------

function lfIntiParam() {
    
    global $objFormParam;
    
        $objFormParam->addParam("IPアドレス1", "blayn_ip01", INT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
        $objFormParam->addParam("IPアドレス2", "blayn_ip02", INT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
        $objFormParam->addParam("IPアドレス3", "blayn_ip03", INT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
        $objFormParam->addParam("IPアドレス4", "blayn_ip04", INT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
        
}

function lfCheckError() {
    
    global $objFormParam;
    
    $arrList = $objFormParam->getHashArray();
    sfprintr($arrList);
    $objErr = new SC_CheckError($arrList);
    $objErr->arrErr = $objFormParam->checkError();
    
    return $arrErr->arrErr;
}

function lfRegist() {
    
    global $objQuery;
    global $objFormParam;
    
    $arrPost = $objFormParam->getHashArray();
    sfprintr($arrPost);
    $blayn_ip .= $arrPost['blayn_ip01'];
    $blayn_ip .= "." . $arrPost['blayn_ip02'];
    $blayn_ip .= "." . $arrPost['blayn_ip03'];
    $blayn_ip .= "." . $arrPost['blayn_ip04'];
    
    $sqlVal['blayn_ip'] = $blayn_ip;
    $objQuery->insert("dtb_blayn", $sqlVal);
}


function lfDelete() {
    
    global $objQuery;
    
    $objQuery->delete("dtb_blayn");
}


function lfGetIP() {
    
    global $objQuery;
    
    $arrSql = $objQuery->select("blayn_ip", "dtb_blayn");
    $arrRet = split("\.", $arrSql[0]['blayn_ip']);
    return $arrRet;
    
    $mode = 'regist';
}

?>
