<?php
/**
 *      [Dzz!] (C)2010-2011 dzz.cc
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: market_ajax.php 1000 2011-6-31 15:41:43 by angelrain $
 */
 /**
 * ============================================================================
 * 版权所有 2010-2011 Dzz!Desktop，并保留所有权利。
 * 网站地址: http://dzz.cc；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式、任何目的的再发布。
 * ============================================================================
*/
if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}
define('CURRENT_PATH','dzz/system');
$do = empty($_GET['do'])?'':$_GET['do'];
//判断数据唯一
$refer=dreferer();
$txtexts=array('DZZDOC','HTM','HTML','SHTM','SHTML','HTA','HTC','XHTML','STM','SSI','JS','JSON','AS','ASC','ASR','XML','XSL','XSD','DTD','XSLT','RSS','RDF','LBI','DWT','ASP','ASA','ASPX','ASCX','ASMX','CONFIG','CS','CSS','CFM','CFML','CFC','TLD','TXT','PHP','PHP3','PHP4','PHP5','PHP-DIST','PHTML','JSP','WML','TPL','LASSO','JSF','VB','VBS','VTM','VTML','INC','SQL','JAVA','EDML','MASTER','INFO','INSTALL','THEME','CONFIG','MODULE','PROFILE','ENGINE');
	$icoid=intval($_GET['icoid']);
	if(!$icoarr=DB::fetch_first("select icoid,url,name,ext from ".DB::table('dzz_icos')." where icoid='{$icoid}'")){
			include dzztemplate('header_common');
			echo "<script type=\"text/javascript\">";	
			echo "top.showDialog('".dzzlang('message','file_not_exist')."');";
			echo "</script>";	
			include dzztemplate('footer');
			exit();
	}
	if(!in_array(strtoupper($icoarr['ext']),$txtexts)){
			include dzztemplate('header_common');
			echo "<script type=\"text/javascript\">";	
			echo "top.showDialog('".dzzlang('message','file_ext_not_support')."');";
			echo "</script>";	
			include dzztemplate('footer');
			exit();
	}
	$type=intval($_GET['type']);
	if(!$icoarr){
		$str='&nbsp;';
	}else{
		$str=(file_get_contents(DISCUZ_ROOT.$icoarr['url']));
		require_once DISCUZ_ROOT.'./dzz/class/class_encode.php';
		$p=new Encode_Core();
		$code=$p->get_encoding($str);
	//echo 'wwwwwwwww='.$code;
	//$haha= mb_detect_encoding($str);echo 'vvvvvv='.$haha.'<br>';
		$str=preg_replace("/<script[^>]*>.*?<\/script>/ims",'',$str);
		//$str=preg_replace("/<!--\{.*?\}-->/i",'',$str);
		  $str = preg_replace("/>[\n\r\t]+([ ]{4})+/",'>',$str);
		  $str =preg_replace("/[\n\r\t]+([ ]{4})+</",'<',$str);
		  $str =preg_replace("/>[\n\r\t]+</",'><',$str);
		  $str =preg_replace("/\t/",'&nbsp;&nbsp;&nbsp;&nbsp;',$str);
		  $str =preg_replace("/\r\n/",'<br>',$str);
		 if($code) $str=diconv($str,$code, 'UTF-8'); 
	}
include dzztemplate('ueditor/view_txt');

?>