<?php
include 'core.php';
include SAXUE_WEB_PATH . '/header.php';
$saxueTset['saxue_page_template'] = SAXUE_THEME_PATH . '/index.html';
if ( SAXUE_USE_CACHE ) {
		$saxueTpl -> setcaching( 1 );
} else {
		$saxueTpl -> setcaching( 0 );
} 
if ( !SAXUE_USE_CACHE || !$saxueTpl -> is_cached( $saxueTset['saxue_page_template'] ) ) {
		saxue_getconfigs( "friendlink" );
		$saxueTpl -> assign_by_ref( "friendlink", $saxueFriendlink );
} 
if ( !empty( $_REQUEST['apipass'] ) && $_REQUEST['apipass'] == SAXUE_API_PASS ) {
		$saxueTpl -> setcaching( 0 );
		$file = saxue_htmlstr( trim( $_REQUEST['file'] ) );
		if ( isset( $_REQUEST['client'] ) && $_REQUEST['client'] == 'mobile' ) {
				if ( empty( $file ) ) $file = 'index.htm';
				if ( SAXUE_MSKIN_SET == '' ) $saxueTpl -> assign( "saxue_skin_url", SAXUE_SKIN_SERVER . '/m' );
				else $saxueTpl -> assign( "saxue_skin_url", SAXUE_SKIN_SERVER . '/' . SAXUE_MSKIN_SET );
				if ( SAXUE_MTHEME_SET == '' ) {
						$template = SAXUE_ROOT_PATH . '/templates/m/index.html';
				} else {
						$template = SAXUE_ROOT_PATH . '/templates/' . SAXUE_MTHEME_SET . '/index.html';
				}
				$url = SAXUE_MURL . '/' . $file;
		} else {
				if ( empty( $file ) ) $file = 'index.html';
				$template = SAXUE_THEME_PATH . '/index.html';
				$url = SAXUE_URL . '/' . $file;
		}
		$ret = saxue_writefile( SAXUE_WEB_PATH . '/' . $file, $saxueTpl -> fetch( $template ) );
		saxue_freeresource();
		if ( $ret ) {
				saxue_msgwin( LANG_DO_SUCCESS, '恭喜您，静态页面已经重新生成！<br /><br /><a href="' . $url . '" target="_blank">点击这里查看</a>' );
		} else {
				saxue_printfail( '对不起，静态页面生成失败，清检查 ' . SAXUE_WEB_PATH . '/' . $file . ' 是否有写权限！' );
		} 
} 
include SAXUE_WEB_PATH . "/footer.php";