<?php
include("../../config.inc.php");
include($CommonPath."/admin/func/adm.inc.php");
include($CommonPath."/admin/func/common.inc.php");
include($CommonPath."/admin/func/db.inc.php");
$msql=new SHARP_SQL;
NeedAuth(0);
?>
<?php
if ($sAction == "上传") {
	if ($radiobutton == "upload") {
		if ($nlFile_size == 0) {
			echo "<script>alert ('请选择要上传的Flash文件！');
			self.location = 'uploadflash.php'</script>";
			exit;
		} elseif ($nlFile_type != "application/x-shockwave-flash"){
			echo "<script>alert ('选择文件不是Flash格式的文件！');
			self.location = 'uploadflash.php'</script>";
			exit;
		}
		$img_directory = "../../pic/swf/";
		$file_name = time () . ".swf";
		$flash_src = $img_directory . $file_name;
	} else {
		if($txtWidth=="" || $txtHeight==""){
			PopBack("请填写FLASH宽度和高度!","uploadflash.php");
		}
		if ($flash_src == "" || $flash_src == "http://") {
			PopBack("请输入Flash文件的网址！","uploadflash.php");

		}
	}
	$size = @GetImageSize( $nlFile );
	if ($size[0] > 0) {
		$txtWidth = $size[0];
		$txtHeight = $size[1];
	}
	if (!file_exists ($img_directory)){
		@mkdir ($img_directory,0777);
	}
	
	copy($nlFile,$flash_src);
	chmod($file_path,0666);
	echo "<script>
	function returnvar () {
		window.returnValue = \"" . str_replace ("../../", $SiteUrl, $flash_src) . "\" + \"*\" + \"" . $txtname . "\" + \"*\" + \"" . $txtborder . "\" + \"*\" + \"" . $txttitle . "\" + \"*\"+ \"" . $txtWidth . "\" + \"*\" + \"" . $WidthUnits . "\" + \"*\" + \"" . $txtHeight . "\" + \"*\" + \"" . $HeightUnits . "\" + \"*\" + \"" . $txthspace. "\" + \"*\" + \"" .
			$txtvspace . "\" + \"*\" + \"" . $chkplay . "\" + \"*\" + \"" . $chkmenu . "\" + \"*\" + \"" . $chkloop . "\" + \"*\" + \"" . $hkdevicefont . "\" + \"*\"+ \"" . $sltalign . "\" + \"*\" + \"" . $tmpquality . "\" + \"*\" + \"" . $tmpscale . "\";
		window.close();
	}
	returnvar ();
</script>";
}
?>
<HTML>
<HEAD>
<TITLE>插入Flash</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="style.css" type=text/css rel=stylesheet>
<script>
function chose_flash (){
	upload_flash.hiddenField.value = "2";
	upload_flash.flash_src.style.display = "block";
	upload_flash.nlFile.style.display = "none";
	var res = showModalDialog('slibFlash.php', null, 'dialogWidth: 700px; dialogHeight: 420px; center: yes; resizable: no; scroll: no; status: no;');
	if (res) {
		res = res.split("*");
		var file_src = res[0];
		var file_width = res[1];
		var file_height = res[2];
		upload_flash.flash_src.value = file_src;
		upload_flash.txtWidth.value = file_width;
		upload_flash.txtHeight.value = file_height;
	} else {
		window.location = "uploadflash.php";
	}
}

function flash_upload () {
	upload_flash.hiddenField.value = "1";
	upload_flash.flash_src.style.display = "none";
	upload_flash.nlFile.style.display = "block";
}

function flash_fill () {
	upload_flash.hiddenField.value = "2";
	upload_flash.flash_src.style.display = "block";
	upload_flash.nlFile.style.display = "none";
}

function check_form () {
	if (upload_flash.hiddenField.value == "1" || upload_flash.hiddenField.value == "") {
		if (upload_flash.nlFile.value == "") {
			alert ("请选择要上传的FLASH文件！");
			return false;
		}
	} else if (upload_flash.hiddenField.value == "2"){
		if (upload_flash.flash_src.value == "" || upload_flash.flash_src.value == "http://") {
		alert ("请输入Flash文件的网址！");
		return false;
		}
		if (upload_flash.txtWidth.value == "" || upload_flash.txtHeight.value == "" ) {
		alert ("请输入FLASH文件的宽度和高度！");
		return false;
		}

	}
	return true;
}
</script>
</HEAD>
<BODY leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" class="bodybackground">
<TABLE cellSpacing=12 cellPadding=0 width="100%">
  <FORM name="upload_flash" method=post encType=multipart/form-data onSubmit="return check_form ()">
    <TBODY>
      <TR align="center"> 
        <TD> <FIELDSET>
          <LEGEND>上传Flash</LEGEND>
          
        <table border="0" width="100%">
          <tr valign="baseline"> 
              <td colspan="4" nowrap> <input name="radiobutton" type="radio" value="upload" checked onClick="flash_upload ();">
                <a href="#" style="cursor:default;color:#000000;text-decoration: none;" onClick="upload_flash.radiobutton[0].checked=true;flash_upload ();">上传Flash</a>
<input type="radio" name="radiobutton" value="fill" onClick="flash_fill ();">
              <a href="#" style="cursor:default;color:#000000;text-decoration: none;" onClick="upload_flash.radiobutton[1].checked=true;flash_fill ();">填入Flash网址 
              </a> 
              <input type="radio" name="radiobutton" value="3" onClick="chose_flash ()">
                <a href="#" style="cursor:default;color:#000000;text-decoration: none;" onClick="upload_flash.radiobutton[2].checked=true;chose_flash ();">从Flash库选择 </a>
                <input type="hidden" name="hiddenField">
                <lable></td>
            </tr>
            <tr valign="baseline"> 
              <td width="81" align="right" nowrap><lable>FLASH文件：</td>
              <td colspan="3" align="left" nowrap><INPUT name=nlFile type=file size="27">
                <input name="flash_src" type="text" style="display: none" value="http://" size="38"></td>
            </tr>
            <tr valign="baseline"> 
              <td align="right" nowrap><label>名称：</label></td>
              <td width="95"  align="left" nowrap><input name="txtname" type="text" size="7"> 
              </td>
              <td width="60" align="right" nowrap>边框：</td>
              <td width="107" align="left" nowrap><input name="txtborder" type="text" size="7" maxlength="5"></td>
            </tr>
            <tr valign="baseline"> 
              <td align="right" nowrap><label>标题：</label></td>
              <td colspan="3"  align="left" nowrap><input type="text" name="txttitle" style="width:195px"></td>
            </tr>
            <tr> 
              <td align="right" valign="baseline" nowrap>宽度：</td>
              <td colspan="3" valign="baseline" nowrap> <input name="txtWidth" type="text" size="8" > 
                <select name="WidthUnits">
                  <option value="%" name="percent">百分比</option>
                  <option value="px" selected name="pixels" nowrap>像素</option>
                </select> </td>
            </tr>
            <tr> 
              <td align="right" valign="baseline" nowrap>高度：</td>
              <td colspan="3" valign="baseline" nowrap> <input name="txtHeight" type="text" size="8" > 
                <select name="HeightUnits">
                  <option value="%" name="percent">百分比</option>
                  <option value="px" selected name="pixels" nowrap>像素</option>
                </select> </td>
            </tr>
            <tr> 
              <td align="right" valign="baseline" nowrap>水平间踞：</td>
              <td valign="baseline" nowrap><input type="text" name="txthspace" size="8" > 
              </td>
              <td align="right" valign="baseline" nowrap>垂直间踞：</td>
              <td valign="baseline" nowrap><input type="text" name="txtvspace" size="8" ></td>
            </tr>
            <tr> 
              <td align="right" valign="top" nowrap>播放：</td>
              <td colspan="3" valign="baseline" nowrap><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr> 
                    <td><input name="chkplay" type="checkbox" value="-1" checked>
                      自动 </td>
                    <td><input name="chkmenu" type="checkbox" value="-1" checked>
                      显示菜单 </td>
                  </tr>
                  <tr> 
                    <td><input name="chkloop" type="checkbox" value="-1" checked>
                      循环 </td>
                    <td><input type="checkbox" name="chkdevicefont" value="0">
                      字体 </td>
                  </tr>
                </table></td>
            </tr>
            <tr valign="baseline"> 
              <td align="right" nowrap><label>对齐：</label></td>
              <td colspan="3"  align="left" nowrap><select name="sltalign" style="width:150px">
                <option value="" selected>默认</option>
                <option value="top">顶部</option>
                <option value="middle">居中</option>
                <option value="bottom">底部</option>
                <option value="left">居左</option>
                <option value="center">水平居中</option>
                <option value="right">居右</option>
              </select></td>
            </tr>
            <tr valign="baseline"> 
              <td align="right" nowrap><label>品质：</label></td>
              <td colspan="3"  align="left" nowrap><select name="tmpquality" style="width:150px">
                  <option value="Low">低</option>
                  <option value="AutoLow">自动低</option>
                  <option value="AutoHigh">自动高</option>
                  <option value="Medium">中</option>
                  <option value="High" selected>高</option>
                  <option value="Best">最佳</option>
                </select></td>
            </tr>
            <tr valign="baseline"> 
              <td align="right" nowrap><label>比例：</label></td>
              <td colspan="3"  align="left" nowrap><select name="tmpscale" style="width:150px">
                  <option>默认(显示全部)</option>
                  <option value="noborder">无边框</option>
                  <option value="exactfit">严格匹配</option>
                  <option value="noscale">无比例</option>
                </select></td>
            </tr>
          </table>
          </FIELDSET></TD>
      </TR>
      <TR> 
        <TD align=right><INPUT  type=submit value=上传 name=sAction> <INPUT name="button" type=button onclick="javascript: window.close();" value=取消></TD>
      </TR>
  </FORM>
</TABLE>
</body>
</html>
