<?php
/**
 * cms_maintenance_check - check about maintenance mode
 *
 * @author $Author: dtong $
 * @version $Id: Cms_maintenance_check.php,v 1.5 2011/05/18 05:36:25 dtong Exp $
 * @copyright Copyright (c) 2011, Tiller Software Co., Ltd.
*/

class Cms_maintenance_check {

	private $CI=NULL;

	function __construct() {
		$this->CI =& get_instance();
	}

	function is_passthrough(){
		if ( empty($_POST['password']) ) {
			return FALSE;
		}
		if ( !$this->CI->config->item('cms_magic_password') ) {
			return FALSE;
		}
		$post_password = osa_des_decrypt($_POST['password']);
		if ( !$post_password ) {
			return FALSE;
		}
		require_once (APPPATH . 'models/auth/auth_local.php');
		$auth_local = new auth_local();
		$auth_local->setconfig($this->CI->config);
		$check_auth = $auth_local->authenticate('', $post_password, FALSE);
		if ( $check_auth ){
			return TRUE;
		}
		return FALSE;
	}

}