<?php
//  ------------------------------------------------------------------------ //
//                   This module; Copyright (c) 2005 gusagi                  //
//                        <http://good-tea.ddo.jp/trpg>                      //
//  ------------------------------------------------------------------------ //

//*****************************************************************************/
// 初期処理
//*****************************************************************************/
require_once( dirname(dirname(__FILE__)) .'/init.php' );
require_once( XOOPS_ROOT_PATH .'/include/cp_header.php' );
require_once( XOOPS_ROOT_PATH .'/class/template.php' );
include_once( XOOPS_ROOT_PATH .'/modules/system/constants.php' ) ;
require_once( $mod_path .'/include/gtickets.php' );
require_once( $mod_path .'/include/adminbuf.inc.php' );

// check access right (needs system_admin of BLOCK)
$sysperm_handler =& xoops_gethandler('groupperm');
if (!$sysperm_handler->checkRight('system_admin', XOOPS_SYSTEM_BLOCK, $xoopsUser->getGroups())) redirect_header( XOOPS_URL.'/user.php' , 1 , _NOPERM ) ;

// カレントURLの取得
$current_url = $mod_url .'/admin/' .basename( __FILE__ );

// テンプレートの宣言
$awsslTpl =& new XoopsTpl;
$awsslTpl->error_reporting = error_reporting();
$awsslTpl->template_dir = $mod_path.'/admin/templates/';

// Anywheresslインスタンスの生成
include( $mod_path .'/class/anywheressl.class.php' );
$Anywheressl = new Anywheressl( $awssl_config );

//*****************************************************************************/
// XOOPSコア機能の強制SSL候補設定
//*****************************************************************************/
include_once( XOOPS_ROOT_PATH .'/modules/system/language/' .$xoopsConfig['language'] .'/blocks.php' ) ;
// XOOPS CubeでPMSGがコアから外されたことへの対応
$lang_global = XOOPS_ROOT_PATH .'/language/' .$xoopsConfig['language'] .'/global.php';
$lang_pmsg = XOOPS_ROOT_PATH .'/language/' .$xoopsConfig['language'] .'/pmsg.php';
if ( file_exists( $lang_global ) ) {
	include_once( $lang_global ) ;
}
if ( file_exists( $lang_pmsg ) ) {
	$pmsgInCore = true;
	include_once( $lang_pmsg ) ;
} else {
	$pmsgInCore = false;
}

$core_enforce = array(
	'admin' => array(
		'mid' => 0,
		'script_filename' => 'admin.php',
		'caption' => _MB_SYSTEM_ADMENU .'(admin.php)',
		'checked' => ( $Anywheressl->AwsslGetEnforcedScript('admin.php') ) ?
			'checked': ''
	),
	'edituser' => array(
		'mid' => 0,
		'script_filename' => 'edituser.php',
		'caption' => _MB_SYSTEM_EACNT .'(edituser.php)',
		'checked' => ( $Anywheressl->AwsslGetEnforcedScript('edituser.php') ) ?
			'checked': ''
	),
	'index' => array(
		'mid' => 0,
		'script_filename' => 'index.php',
		'caption' => _MB_SYSTEM_HOME .'(index.php)',
		'checked' => ( $Anywheressl->AwsslGetEnforcedScript('index.php') ) ?
			'checked': ''
	),
	'notification' => array(
		'mid' => 0,
		'script_filename' => 'notification.php',
		'caption' => _MB_SYSTEM_NOTIF .'(notification.php)',
		'checked' => ( $Anywheressl->AwsslGetEnforcedScript('notification.php') ) ?
			'checked': ''
	),
	'register' => array(
		'mid' => 0,
		'script_filename' => 'register.php',
		'caption' => _MB_SYSTEM_RNOW .'(register.php)',
		'checked' => ( $Anywheressl->AwsslGetEnforcedScript('register.php') ) ?
			'checked': ''
	),
	'search' => array(
		'mid' => 0,
		'script_filename' => 'search.php',
		'caption' => _MB_SYSTEM_SEARCH .'(search.php)',
		'checked' => ( $Anywheressl->AwsslGetEnforcedScript('search.php') ) ?
			'checked': ''
	),
	'user' => array(
		'mid' => 0,
		'script_filename' => 'user.php',
		'caption' => _MB_SYSTEM_VACNT .'&amp;' ._LOGIN .'(user.php)',
		'checked' => ( $Anywheressl->AwsslGetEnforcedScript('user.php') ) ?
			'checked': ''
	),
	'userinfo' => array(
		'mid' => 0,
		'script_filename' => 'userinfo.php',
		'caption' => _MB_SYSTEM_VACNT .'(userinfo.php)',
		'checked' => ( $Anywheressl->AwsslGetEnforcedScript('userinfo.php') ) ?
			'checked': ''
	)
);

//*****************************************************************************/
// プライベートメッセージがコア機能なら、コア機能の配列に追加
//*****************************************************************************/
if ( $pmsgInCore ) {
	$array_readpmsg = array(
		'mid' => 0,
		'script_filename' => 'readpmsg.php',
		'caption' => _PM_PRIVATEMESSAGE .'(readpmsg.php)',
		'checked' => ( $Anywheressl->AwsslGetEnforcedScript('readpmsg.php') ) ?
			'checked': ''
	);
	$array_viewpmsg = array(
		'mid' => 0,
		'script_filename' => 'viewpmsg.php',
		'caption' => _MB_SYSTEM_INBOX .'(viewpmsg.php)',
		'checked' => ( $Anywheressl->AwsslGetEnforcedScript('viewpmsg.php') ) ?
			'checked': ''
	);
	array_push( $core_enforce, $array_readpmsg, $array_viewpmsg );
}


//*****************************************************************************/
// モジュールごとの強制SSL候補設定
//*****************************************************************************/
$module_enforce = $Anywheressl->AwsslGetModules();

//*****************************************************************************/
// 画面表示
//*****************************************************************************/
// 管理画面用ヘッダの呼び出し
xoops_cp_header();
// 管理画面上部メニューの呼び出し
if( file_exists( './mymenu.php' ) ) include( './mymenu.php' );
// 更新を行うアクションのアサイン
$action = $mod_url .'/admin/submit.php';
$awsslTpl->assign( 'action', $action );
// XOOPSコア機能の候補アサイン
$awsslTpl->assign( 'core_enforce', $core_enforce );
// モジュールごとの候補アサイン
$awsslTpl->assign( 'module_enforce', $module_enforce );
// ワンタイムチケットのアサイン
$ticket = $xoopsGTicket->getTicketHtml( __LINE__ , 1800 , 'anywheressl' );
$awsslTpl->assign( 'ticket', $ticket );
// テンプレートの表示
$awsslTpl->display( 'anywheressl_enforce.html' );

//*****************************************************************************/
// 終了処理
//*****************************************************************************/
// セッションへの格納
$_SESSION['anywheressl_core_enforce'] = $core_enforce;
$_SESSION['anywheressl_module_enforce'] = $module_enforce;
$_SESSION['anywheressl_op'] = 'save_enforce';
// 管理画面用フッタの呼び出し
xoops_cp_footer();

?>
