<?php

//载入全局配置和函数包
require(dirname(__FILE__)."/../../include/global.php");

//登录检查
checker_login();

//图片地址
$picurl = $_GET["picurl"];

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $Project["charset"];?>" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title>图片裁减</title>

	<style>
	html,body{ margin:0; padding:0; text-align:center; }
	
	#save{ padding:10px;}
		#save img{ border:none; cursor:pointer; }
	
	#info{ border:#ffcc00 solid 3px; margin:20px; padding:20px; line-height:30px; font-size:14px; text-align:center; }
	
	</style>
	<script type="text/javascript" src="crop/swfobject.js"></script>
	
</head>
<body>

	<?php
	
	if( !$picurl ){
	
		echo '<div id="info">		参数错误，请传入图片地址	</div>';
		
	}else{
	
		/*
		echo VI_BASE;
		
		echo '<hr />';
		
		echo VI_ROOT.$Project["upload"].basename($picurl);

		echo '<hr />';

		echo str_replace( VI_BASE , "../../" , $picurl );
		
		echo '<hr />';

		echo str_replace( "\/" ,"/" , $Project["base"].$picurl );
	
		//echo dirname($picurl);
		
		*/
	
	?>

		<script>
			// 获取页面上的flash实例。
			// @param flashID 这个参数是：flash 的 ID 。本例子的flash ID是 "myFlashID" ，在本页面搜索一下 "myFlashID" 可看到。
			function getFlash(flashID){
				// 判断浏览器类型
				if (navigator.appName.indexOf("Microsoft") != -1) 
				{
					return window[flashID];
				} 
				else 
				{
					return document[flashID];
				}
			}
	
			function uploadfile() {
				getFlash('myFlashID').upload();
			}
	
			function uploadComplete(s){
				alert('图片成功保存!');
	
				//关闭编辑器
				try{			
					parent.__PE__.Remove();		
				}catch(e){			
					return;				
				}
	
			}
	
			var swfVersionStr = "10.0.0";
			var xiSwfUrlStr = "crop/image/playerProductInstall.swf";
	
			var flashvars = {};
	
			//图片地址
			flashvars.picurl = "<? echo $_GET["picurl"];?>";
	
			//.urlencode($_GET["picurl"])
	
			//上传地址，使用了 base64 加密
			flashvars.uploadurl = "<?=base64_encode("image.php?m=attachment&c=attachments&a=crop_upload&file=".urlencode($picurl))?>";
	
			//http://localhost/VERYIDE/APPS/4.0/veryide/source/piceditor/image.php?m=attachment&c=attachments&a=crop_upload&file=%2FVERYIDE%2FAPPS%2F4.0%2Ffiles%2Fimage%2F2010%2F1104%2F13-26-53-46232206.jpg&width=739&height=535
	
			//image.php?m=attachment&c=attachments&a=crop_upload&catid=6&file=%2Fuploadfile%2F442981383.jpg
	
			var params = {};
			params.quality = "high";
			params.bgcolor = "#ffffff";
			params.allowscriptaccess = "always";
			params.allowfullscreen = "true";
			var attributes = {};
			attributes.id = "myFlashID";
			attributes.name = "myFlashID";
			attributes.align = "middle";
			swfobject.embedSWF(
				"crop/image/Main.swf", "flashContent", 
				"680", "480", 
				swfVersionStr, xiSwfUrlStr, 
				flashvars, params, attributes);
			swfobject.createCSS("#flashContent", "display:block;text-align:left;");
		</script>
		<div id="flashContent">
		  <p> To view this page ensure that Adobe Flash Player version 
			10.0.0 or greater is installed. </p>
		  <script type="text/javascript"> 
						var pageHost = ((document.location.protocol == "https:") ? "https://" :	"http://"); 
						document.write("<a href='http://www.adobe.com/go/getflashplayer'><img src='" 
										+ pageHost + "www.adobe.com/image/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player' /></a>" ); 
					</script> 
		</div>
		<noscript>
			<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="680" height="480" id="myFlashID">
			  <param name="movie" value="crop/image/Main.swf" />
			  <param name="quality" value="high" />
			  <param name="bgcolor" value="#ffffff" />
			  <param name="allowScriptAccess" value="always" />
			  <param name="allowFullScreen" value="true" />
			  <!--[if !IE]>-->
			  <object type="application/x-shockwave-flash" data="crop/image/Main.swf" width="680" height="480">
				<param name="quality" value="high" />
				<param name="bgcolor" value="#ffffff" />
				<param name="allowScriptAccess" value="always" />
				<param name="allowFullScreen" value="true" />
				<!--<![endif]--> 
				<!--[if gte IE 6]>-->
				<p> Either scripts and active content are not permitted to run or Adobe Flash Player version
				  10.0.0 or greater is not installed. </p>
				<!--<![endif]--> 
				<a href="http://www.adobe.com/go/getflashplayer"> <img src="http://www.adobe.com/image/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash Player" /> </a> 
				<!--[if !IE]>-->
			  </object>
			  <!--<![endif]-->
			</object>
		</noscript>
	
		<div id="save">	
			<img src="image/save.png" onclick="uploadfile();" />	
		</div>
	

	<?php

	}

	?>

</body>
</html>
