<?php
/*
	Copyright(c) 2010 Shift Tech Inc. All Rights Reserved.
 	http://www.shift-tech.jp/

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

/** 
* 基本Modelクラス
* @author     Nishino
* @copyright  Shift Tech Inc.
*/ 
class Model {

    //リクエストデータ
    var $request = array();
	//エラーメッセージ
	var $error_str = null;
	
	/**
     * コンストラクタ（PHP5対応）
	 * @author   Nobuo Nishino
	 * @param    
	 */
	function Model()
	{
		$this->__construct();
	}
	function __construct()
	{
		$this->setRequest();
        $session = new Session();
	}

	/**
     * デストラクタ（PHP5対応）
	 * @author   Nobuo Nishino
	 * @param    
	 
    public function __destruct()
    {
        
    }*/

	/**
     * リクエスト取込（POST・GET)
	 * @author   Nobuo Nishino
	 * @param    
	 */
    function setRequest()
    {
        if(is_array($_REQUEST)) {
            foreach($_REQUEST as $name => $value) {
                $this->addRequest($name, $value);
            }
        }
    }

	/**
     * リクエストデータ追加
	 * @author   Nobuo Nishino
	 * @param    $name String 変数名
	 * @param    $data String 値
	 */
    function addRequest($name, $data)
    {
        $this->request[$name] = $data;
    }

	/**
     * リクエストデータ取得
	 * @author   Nobuo Nishino
	 * @param    $name String 変数名
	 * @return   String 値
	 */
    function getRequest($name)
    {
        return isset($this->request[$name]) ? $this->request[$name] : "";
    }
	
	function getToken() {
    	mt_srand((double)microtime()*1000000);
    	$token = sha1(uniqid(mt_rand(),1));
    	$_SESSION["bAdmin_token"] = $token;
    	return $token;
    }
    
	function clrToken() {
    	unset($_SESSION["bAdmin_token"]);
    }
    
    function putTokenError() {
    	die('<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><p>不正なページ遷移の為処理を停止しました。管理トップよりやり直してください。</p></body></html>');
    }

}

?>