📄 insert_flash.php
字号:
<?php
error_reporting(0);
require_once("de_lang/language.php");
/*//////////////////////////////////////////////////////
/ /
/ The $DOCUMENT_ROOT variable is used to specify the /
/ location of the image directory. If you are having /
/ problems uploading or deleting images, then you /
/ will need to change the variable below to the full /
/ path to your document root on your web server, such /
/ as /htdocs/www/jdoe /
/ /
//////////////////////////////////////////////////////*/
$DOCUMENT_ROOT = @$_SERVER["DOCUMENT_ROOT"];
$statusText = "";
$dt = @$_REQUEST["dt"];
$tn = @$_REQUEST["tn"];
$dd = @$_REQUEST["dd"];
$du = @$_REQUEST["du"];
$validFlashTypes = array("application/x-shockwave-flash");
// Added for v5.0
$validFlashExts = array("swf");
$isValidExt = false;
$FlashDirectory = @$_REQUEST["flashDir"];
$HideWebFlash = $_REQUEST["wi"];
$URL = $_SERVER["HTTP_HOST"];
$scriptName = dirname($_SERVER["SCRIPT_NAME"]) . "/de/class.devedit.php";
// Workout the location of class.devedit.php
$url = $_SERVER["SERVER_NAME"];
$scriptName = "class.devedit.php";
$scriptDir = strrev(@$_SERVER["PATH_INFO"]);
$slashPos = strpos($scriptDir, "/");
$scriptDir = strrev(substr($scriptDir, $slashPos, strlen($scriptDir)));
if(@$_GET["flashSrc"] != "")
{
// Delete the flash file
$flashPath = str_replace("//", "/", $DOCUMENT_ROOT . "/" . $FlashDirectory . "/" . $_GET["flashSrc"]);
$flashExt = strrev(substr(strrev($flashPath), 0, strpos(strrev($flashPath), ".")));
// Is this a valid file type?
if(in_array($flashExt, $validFlashExts))
$isValidExt = true;
else
$isValidExt = false;
if($isValidExt)
{
if(@unlink($flashPath))
{
// Deleted OK
$statusText = sTxtFlashDeleted;
}
else
{
// Couldn't delete the imagefile
$statusText = sTxtCantDelete;
}
}
else
{
// Invalid file type
$statusText = sTxtFlashErr;
}
}
if(@$_GET["ToDo"] == "UploadFlash")
{
//Data for first file upload
$newFileName = @$_FILES["upload"]["name"];
$newFileType = @$_FILES["upload"]["type"];
$newFileLocation = @$_FILES["upload"]["tmp_name"];
$newFileSize = @$_FILES["upload"]["size"];
//---------------------------------------------------------
//Is the first image a valid file type?
$validFileType = false;
$errorText = "";
if($newFileName != "")
{
// Is this a valid file type?
if(in_array($newFileType, $validFlashTypes))
$validFileType = true;
if($validFileType == false)
{
// Invalid file type
$statusText = sTxtFlashErr;
}
else
{
$uploadSuccess = @copy($newFileLocation, $DOCUMENT_ROOT . $FlashDirectory . "/" . $newFileName);
if($uploadSuccess)
{
$statusText = $newFileName . " " . sTxtUploadSuccess . "!";
}
else
{
$statusText = sTxtCantUpload;
}
}
}
}
$dirHandle = @opendir(realpath($DOCUMENT_ROOT . $FlashDirectory)) or die(sTxtFlashDirNotConfigured);
//Get all flash files into a JavaScript array so that we can workout whether or not
//uploading an image would overwrite an existing one
$flashJS = "var flashFiles = Array(";
while(false !== ($file = readdir($dirHandle)))
{
$flashJS = $flashJS . "'" . $file . "',";
}
//Reload the directory contents
$dirHandle = @opendir(realpath($DOCUMENT_ROOT . $FlashDirectory)) or die(sTxtFlashDirNotConfigured);
if(substr(strrev($flashJS), 0, 1) == ",")
$flashJS = substr($flashJS, 0, strlen($flashJS)-1);
$flashJS = $flashJS . ")";
$counter = 0;
?>
<title><?php echo sTxtInsertFlash; ?></title>
<link rel="stylesheet" href="de_includes/de_styles.css" type="text/css">
<script defer>
if (window.opener.flashEdit) {
selectedFlash = window.opener.selectedFlash
previewModify()
}
</script>
<script language=JavaScript>
window.onload = this.focus
var selectedFlash
var selectedFlashFile
var flashAlign
var flashLoop
<?php echo $flashJS; ?>
if (window.opener.flashEdit) {
flashAlign = window.opener.selectedFlash.align
flashLoop = window.opener.selectedFlash.loop
}
function outputFlashLibraryOptions()
{
document.write(opener.flashLibs);
// Loop through all of the image libraries and find the selected one
for(i = 0; i < selFlashLib.options.length; i++)
{
if(selFlashLib.options[i].value == "<?php echo $FlashDirectory; ?>")
{
selFlashLib.selectedIndex = i;
break;
}
}
}
function switchFlashLibrary(thePath)
{
// Change the path of the flash library
document.location.href = '<?php echo $HTTPStr . "://" . $url . $_SERVER["PHP_SELF"]; ?>?ToDo=InsertFlash&DEP=<?php echo @$_GET["DEP"]; ?>&DEP1=<?php echo @$_GET["DEP1"]; ?>&flashDir='+thePath+'&dd=<?php echo $_GET["dd"]; ?>&du=<?php echo $_GET["du"]; ?>&wi=<?php echo $_GET["wi"]; ?>&tn=<?php echo $_GET["tn"]; ?>&dt=<?php echo $_GET["dt"]; ?>&wi=<?php echo $HideWebFlash; ?>';
}
function printAlign() {
if ((flashAlign != undefined) && (flashAlign != "")) {
document.write('<option selected>' + flashAlign)
document.write('<option>')
} else {
document.write('<option selected>')
}
}
function printLoop() {
if (flashLoop != undefined) {
document.write('<option value="' + flashLoop + '" selected>' + flashLoop + '</option>')
document.write('<option value=""></option>')
}
}
var selectedFlashEmbed
function previewModify() {
objectTag = /(<(object|\/object)([\s\S]*?)>)/gi
paramTag = /(<param([\s\S]*?)>)/gi
code = selectedFlash.outerHTML.replace(objectTag,"")
code = code.replace(paramTag,"")
tempFrame.document.write("<html><head></head><body>" + code + "</body></html>")
tempFrame.document.close()
selectedFlashEmbed = tempFrame.document.embeds[0]
selectedFlashFile = selectedFlash.movie
document.getElementById("previewWindow").innerHTML = "<embed src='" + selectedFlash.movie + "' quality='high' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='236' height='176' bgcolor='#009933' WMODE=transparent></embed>"
image_width.value = selectedFlash.width
image_height.value = selectedFlash.height
hspace.value = selectedFlash.hspace
vspace.value = selectedFlash.vspace
insertButton.value = "<?php echo sTxtImageModify; ?>"
document.title = "<?php echo sTxtModifyFlash; ?>"
previewButton.disabled = false
insertButton.disabled = false
}
function deleteFlash(flashSrc)
{
var delImg = confirm("<?php echo sTxtImageDelete; ?>");
if (delImg == true) {
document.location.href = '<?php echo $HTTPStr . "://" . $url . $_SERVER["PHP_SELF"]; ?>?ToDo=DeleteFlash&DEP=<?php echo @$_GET["DEP"]; ?>&DEP1=<?php echo @$_GET["DEP1"]; ?>&flashDir=<?php echo $FlashDirectory; ?>&tn=<?php echo $_GET["tn"]; ?>&dt=<?php echo $_GET["dt"]; ?>&wi=<?php echo $HideWebFlash; ?>&du=<?php echo $_GET["du"]; ?>&dd=<?php echo $dd; ?>&flashSrc='+flashSrc;
}
}
function viewImage(flashSrc)
{
var sWidth = screen.availWidth;
var sHeight = screen.availHeight;
window.open(flashSrc, 'image', 'width=500, height=500,scrollbars=yes,resizable=yes,left='+(sWidth/2-250)+',top='+(sHeight/2-250));
}
function grey(tr) {
tr.className = 'b4';
}
function ungrey(tr) {
tr.className = '';
}
function insertImage(flashSrc) {
var error = 0;
imageWidth = image_width.value
imageHeight = image_height.value
imageHspace = hspace.value
imageVspace = vspace.value
if (isNaN(imageWidth) || imageWidth < 0) {
alert("<?php echo sTxtFlashWidthErr; ?>")
error = 1
image_width.select()
image_width.focus()
} else if (isNaN(imageHeight) || imageHeight < 0) {
alert("<?php echo sTxtFlashHeightErr; ?>")
error = 1
image_height.select()
image_height.focus()
} else if (isNaN(imageHspace) || imageHspace < 0) {
alert("<?php echo sTxtHorizontalSpacingErr; ?>")
error = 1
hspace.select()
hspace.focus()
} else if (isNaN(vspace.value) || vspace.value < 0) {
alert("<?php echo sTxtVerticalSpacingErr; ?>")
error = 1
vspace.select()
vspace.focus()
}
if (error != 1) {
var sel = window.opener.foo.document.selection;
if (sel!=null) {
var rng = sel.createRange();
if (rng!=null) {
// Are we modifying or inserting?
if (window.opener.flashEdit) {
if (imageWidth != "") {
selectedFlash.width = imageWidth
selectedFlashEmbed.width = imageWidth
} else {
selectedFlash.removeAttribute("width")
selectedFlashEmbed.removeAttribute("width")
}
if (imageHeight != "") {
selectedFlash.height = imageHeight
selectedFlashEmbed.height = imageHeight
} else {
selectedFlash.removeAttribute("height")
selectedFlashEmbed.removeAttribute("height")
}
if (vspace.value != "") {
selectedFlash.vspace = vspace.value
selectedFlashEmbed.vspace = vspace.value
} else {
selectedFlash.removeAttribute("vspace")
selectedFlashEmbed.removeAttribute("vspace")
}
if (hspace .value != "") {
selectedFlash.hspace = hspace.value
selectedFlashEmbed.hspace = vspace.value
} else {
selectedFlash.removeAttribute("hspace")
selectedFlashEmbed.removeAttribute("hspace")
}
if (align[align.selectedIndex].text != "") {
selectedFlash.align = align[align.selectedIndex].text
} else {
selectedFlash.removeAttribute("align")
}
selectedFlash.movie = flashSrc
if (loop[loop.selectedIndex].value != "") {
selectedFlash.loop = loop[loop.selectedIndex].value
selectedFlashEmbed.loop = loop[loop.selectedIndex].value
} else {
selectedFlash.removeAttribute("loop")
selectedFlashEmbed.removeAttribute("loop")
}
embedTag = /(<embed([\s\S]*?)>)/gi
closeEmbedTag = /(<\/embed([\s\S]*?)>)/gi
originalFlash = selectedFlash.outerHTML
code = originalFlash.replace(closeEmbedTag, "")
code = code.replace(embedTag, selectedFlashEmbed.outerHTML + "</embed>")
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -