<?php
if ( !defined( "SAXUE_CORE_INCLUDE" ) ) {
		include "../core.php";
} 
saxue_checkpower( 'blocks' );
include SAXUE_ADMIN_PATH . "/header.php";
if ( isset( $_POST['dosubmit'] ) ) {
		$_POST['classname'] = 'BlockSystemSql';
		$_POST['sql'] = trim( $_POST['sql'] );
		$_POST['pagenum'] = intval( $_POST['pagenum'] );
		$_POST['page'] = intval( $_POST['page'] );
		$_POST['template'] = trim( $_POST['template'] );
		$ret = array();
		$ret['block_temp'] = '{?block classname="BlockSystemSql" sql="' . $_POST['sql'] . '"';
		$ret['eloop_temp'] = '{?eloop name="i" loop="$items" classname="BlockSystemSql" sql="' . $_POST['sql'] . '"';
		if ( $_POST['pagenum'] > 0 ) {
				$ret['block_temp'] .= ' pagenum="' . $_POST['pagenum'] . '"';
				$ret['eloop_temp'] .= ' pagenum="' . $_POST['pagenum'] . '"';
		}
		if ( $_POST['page'] > 1 ) {
				$ret['block_temp'] .= ' page="' . $_POST['page'] . '"';
				$ret['eloop_temp'] .= ' page="' . $_POST['page'] . '"';
		}
		$ret['block_temp'] .= ' template="' . $_POST['template'] . '"?}';
		$ret['eloop_temp'] .= "\n...\nHTML代码\n...\n{?/eloop?}";
		$data = saxue_get_eloop( $_POST );
		if ( !$data ) {
				$ret['eloop_data'] = 'Array()';
		} else {
				$ret['eloop_data'] = var_export( $data, true );
		}
		$ret['block_data'] = saxue_get_block( $_POST, 1 );
		exit( json_encode( $ret ) );
}
$saxueTset['saxue_contents_template'] = SAXUE_ADMIN_PATH . "/templates/block_sql.html";
include SAXUE_ADMIN_PATH . "/footer.php";
