<?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);
$objPage->arrIP = $objFormParam->getHashArray();
sfprintr($objPage->arrIP);
switch ($_POST['mode']) {
    
    case 'regist':

        $objPage->arrErr = lfErrorcheck();
        if(count($objPage->arrErr) <= 0) {
            lfDelete();
            lfRegist();
        }
    break;
    
    
    default:
        
        $objPage->arrIP = lfGetIP();
}

$objPage->mode = 'regist';

$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 lfErrorcheck() {
    
    global $objFormParam;
    
    $arrList = $objFormParam->getHashArray();
    $objErr = new SC_CheckError($arrList);
    $arrErr->arrErr = $objFormParam->checkError();

    return $arrErr->arrErr;
    
}

function lfRegist() {
    
    global $objQuery;
    global $objFormParam;
    
    $arrPost = $objFormParam->getHashArray();
    $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']);
    
    $arrRet[blayn_ip01] = $arrRet[0];
    $arrRet[blayn_ip02] = $arrRet[1];
    $arrRet[blayn_ip03] = $arrRet[2];
    $arrRet[blayn_ip04] = $arrRet[3];
        
    return $arrRet;
    
}

?>
