variablen er tom
Jeg fandt dette lange script her på exp.<%@ Language = JavaScript %>
<html>
<head>
<title>Text editor v. 1.0</title>
<?
if ($action == "save") {
$filename = "/customers/kongeborgen.dk/kongeborgen.dk/httpd.www/sporskifte/admin/".$doc.".htm";
$somecontent = $teksten;
if ($somecontent == "") {
$somecontent = "ny tekst";
}
if (is_writable($filename)) {
print "somecontent = ".$somecontent;
if (!$handle = fopen($filename, 'a')) {
print "Cannot open file ($filename)";
exit;
} else {
print "Filen er åben";
}
if (!fwrite($handle, $somecontent)) {
print "Cannot write to file ($filename)";
exit;
}
print "Success, wrote ($somecontent) to file ($filename)";
fclose($handle);
} else {
print "The file $filename is not writable";
}
}
?>
<html>
<head>
<title>Gemmer</title>
</head>
<head>
<style type="text/css">
TABLE#tblCoolbar
{
background-color:threedface; padding:1px; color:menutext;
border-width:1px; border-style:solid;
border-color:threedhighlight threedshadow threedshadow threedhighlight;
}
.cbtn
{
height:18;
BORDER-LEFT: threedface 1px solid;
BORDER-RIGHT: threedface 1px solid;
BORDER-TOP: threedface 1px solid;
BORDER-BOTTOM: threedface 1px solid;
}
.txtbtn {font-family:tahoma; font-size:70%; color:menutext;}
.progress{TEXT-DECORATION: none;FONT-SIZE: 12px;FONT-FAMILY: Arial Narrow;color=red}
TABLE
{
FONT-WEIGHT: normal;
FONT-SIZE: 12px;
COLOR: black;
LINE-HEIGHT: 120%;
FONT-FAMILY: Verdana,Arial,sans-serif;
TEXT-DECORATION: none
}
INPUT
{
FONT-WEIGHT: normal;
FONT-SIZE: 9px;
COLOR: black;
LINE-HEIGHT: 120%;
FONT-FAMILY: Verdana,Arial,sans-serif;
TEXT-DECORATION: none;
style: "HEIGHT: 18px;
WIDTH: 150px"
}
</style>
<script LANGUAGE="JavaScript">
function button_over(eButton)
{
eButton.style.backgroundColor = "#B5BDD6";
eButton.style.borderColor = "darkblue darkblue darkblue darkblue";
}
function button_out(eButton)
{
eButton.style.backgroundColor = "threedface";
eButton.style.borderColor = "threedface";
}
function button_down(eButton)
{
eButton.style.backgroundColor = "#8494B5";
eButton.style.borderColor = "darkblue darkblue darkblue darkblue";
}
function button_up(eButton)
{
eButton.style.backgroundColor = "#B5BDD6";
eButton.style.borderColor = "darkblue darkblue darkblue darkblue";
eButton = null;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var isHTMLMode=false
function document.onreadystatechange()
{
try
{
idContent.document.designMode="On";
}
catch(e)
{
return;
}
}
function cmdExec(cmd,opt)
{
if (isHTMLMode){alert("Please uncheck 'Edit HTML'");return;}
idContent.document.execCommand(cmd,"",opt);idContent.focus();
}
function setMode(bMode)
{
var sTmp;
isHTMLMode = bMode;
if(isHTMLMode)
{
sTmp=idContent.document.body.innerHTML;
idContent.document.body.innerText=sTmp;
}
else
{
sTmp=idContent.document.body.innerText;
idContent.document.body.innerHTML=sTmp;
}
idContent.focus();
}
function createLink()
{
if (isHTMLMode){alert("Please uncheck 'Edit HTML'");return;}
cmdExec("CreateLink");
}
function insertImage()
{
{
var arr = showModalDialog("colorselector.htm","","font-family:Verdana; font-size:12; dialogWidth:30em; dialogHeight:34em" );
if (arr != null) cmdExec("ForeColor",arr);
}
//if (isHTMLMode){alert("Please uncheck 'Edit HTML'");return;}
//var sImgSrc=prompt("Insert Image File (You can use your local image file) : ", "http://www.aspalliance.com/Yusuf/Article10/sample.jpg");
//if(sImgSrc!=null) cmdExec("InsertImage",sImgSrc);
}
function Save()
{
if (isHTMLMode){alert("Please uncheck 'Edit HTML'");return;}
var sImgTag = idContent.document.body.all.tags("IMG");
var oImg;
for (var i = sImgTag.length - 1; i >= 0; i--)
{
oImg = sImgTag[i];
//alert("Add your code to Upload local image file here. Image Inserted : " + oImg.src );
}
//alert("Add your code to Save Document here");
//alert("Your Document : " + idContent.document.body.innerHTML);
SaveProcess(idContent.document.body.innerHTML); //##################
}
function foreColor()
{
var arr = showModalDialog("colorselector.htm","","font-family:Verdana; font-size:12; dialogWidth:30em; dialogHeight:34em" );
if (arr != null) cmdExec("ForeColor",arr);
}
</script>
Re123tter tekst for <? print $doc; ?>
<table id="tblCoolbar" width="542" cellpadding="0" cellspacing="0" align="center">
<tr valign="center">
<td colspan="15">
<select onchange="cmdExec('formatBlock',this[this.selectedIndex].value);this.selectedIndex=0" id="select1" name="select1">
<option selected>Style</option>
<option value="Normal">Normal</option>
<option value="Heading 1">Heading 1</option>
<option value="Heading 2">Heading 2</option>
<option value="Heading 3">Heading 3</option>
<option value="Heading 4">Heading 4</option>
<option value="Heading 5">Heading 5</option>
<option value="Address">Address</option>
<option value="Formatted">Formatted</option>
<option value="Definition Term">Definition Term</option>
</select>
<select onchange="cmdExec('fontname',this[this.selectedIndex].value);" id="select2" name="select2">
<option selected>Font</option>
<option value="Arial">Arial</option>
<option value="Arial Black">Arial Black</option>
<option value="Arial Narrow">Arial Narrow</option>
<option value="Comic Sans MS">Comic Sans MS</option>
<option value="Courier New">Courier New</option>
<option value="System">System</option>
<option value="Tahoma">Tahoma</option>
<option value="Times New Roman">Times New Roman</option>
<option value="Verdana">Verdana</option>
<option value="Wingdings">Wingdings</option>
</select>
<select onchange="cmdExec('fontsize',this[this.selectedIndex].value);" id="select3" name="select3">
<option selected>Size</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="10">10</option>
<option value="12">12</option>
<option value="14">14</option>
</select>
</td>
</tr>
<tr>
<td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('cut')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
<img hspace="1" vspace="1" align="absMiddle" src="gfx/editor/Cut.gif" alt="Cut" WIDTH="23" HEIGHT="22">
</div></td>
<td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('copy')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
<img hspace="1" vspace="1" align="absMiddle" src="gfx/editor/Copy.gif" alt="Copy" WIDTH="23" HEIGHT="22">
</div></td>
<td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('paste')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
<img hspace="1" vspace="1" align="absMiddle" src="gfx/editor/Paste.gif" alt="Paste" WIDTH="23" HEIGHT="22">
</div></td>
<td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('bold')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
<img hspace="1" vspace="1" align="absMiddle" src="gfx/editor/Bold.gif" alt="Bold" WIDTH="23" HEIGHT="22">
</div></td>
<td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('italic')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
<img hspace="1" vspace="1" align="absMiddle" src="gfx/editor/Italic.gif" alt="Italic" WIDTH="23" HEIGHT="22">
</div></td>
<td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('underline')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
<img hspace="1" vspace="1" align="absMiddle" src="gfx/editor/Under.gif" alt="Underline" WIDTH="23" HEIGHT="22">
</div></td>
<td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('justifyleft')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
<img hspace="1" vspace="1" align="absMiddle" src="gfx/editor/Left.gif" alt="Justify Left" WIDTH="23" HEIGHT="22">
</div></td>
<td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('justifycenter')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
<img hspace="1" vspace="1" align="absMiddle" src="gfx/editor/Center.gif" alt="Center" WIDTH="23" HEIGHT="22">
</div></td>
<td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('justifyright')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
<img hspace="1" vspace="1" align="absMiddle" src="gfx/editor/Right.gif" alt="Justify Right" WIDTH="23" HEIGHT="22">
</div></td>
<td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('insertorderedlist')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
<img hspace="2" vspace="1" align="absMiddle" src="gfx/editor/numlist.GIF" alt="Ordered List" WIDTH="23" HEIGHT="22">
</div></td>
<td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('insertunorderedlist')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
<img hspace="2" vspace="1" align="absMiddle" src="gfx/editor/bullist.GIF" alt="Unordered List" WIDTH="23" HEIGHT="22">
</div></td>
<td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('outdent')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
<img hspace="2" vspace="1" align="absMiddle" src="gfx/editor/deindent.gif" alt="Decrease Indent" WIDTH="23" HEIGHT="22">
</div></td>
<td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('indent')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
<img hspace="2" vspace="1" align="absMiddle" src="gfx/editor/inindent.gif" alt="Increase Indent" WIDTH="23" HEIGHT="22">
</div></td>
<td><div class="cbtn" onmousedown="button_down(this);" onClick="foreColor()" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
<img hspace="2" vspace="1" align="absMiddle" src="gfx/editor/fgcolor.gif" alt="Forecolor" WIDTH="23" HEIGHT="22">
</div></td>
<td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('createLink')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
<img hspace="2" vspace="1" align="absMiddle" src="gfx/editor/Link.gif" alt="Link" WIDTH="23" HEIGHT="22">
</div></td>
<td><div class="cbtn" onmousedown="button_down(this);" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
<img hspace="2" vspace="1" align="absMiddle" src="gfx/editor/Image.gif" alt="Disabled / slÂet fra!" WIDTH="23" HEIGHT="22">
</div></td>
<form method="POST" action="default.php?doc=<? print $doc ?>&action=save" name="saveresult" onClick="SaveProcess();">
<td width="200"><input type="hidden" name="doc" value="<? print $doc ?>"><input type="submit" value="Gem" name="save">
</td> </form>
</tr>
</table>
<table width="542" cellpadding="0" cellspacing="0" align="center">
<tr><td>
<iframe width="542" src="<? $doc.".htm"; ?>" id="idContent" height="350" align="center"></iframe>
</td></tr></table>
<script language="javascript" defer>
var WSDLURL = "Article12/edit.sdl";
var isFinish;
function initSVC()
{
service.use(WSDLURL, "FriendlyName");
}
function SaveProcess(sText)
{
isFinish=false;
document.saveresult.teksten.value = idContent.document.body.innerHTML;
}
function checkReadyState()
{
if(isFinish==false){AnimateWindowStatus();window.setTimeout("checkReadyState()", 50);}
}
function CallBackFunction(result)
{
isFinish=true;
idProgress.innerText = " ";
if(result.error)
{
var xfaultcode = result.errorDetail.code;
var xfaultstring = result.errorDetail.string;
var xfaultsoap = result.errorDetail.raw;
alert("Errors xfaultcode->" + xfaultcode + " xfaultstring->" + xfaultstring + " xfaultsoap->" + xfaultsoap);
}
else
{
var xmlResult = result.raw.xml;
//textarea1.value = result.raw.xml;
if (xmlResult != "" && xmlResult != null)
{
alert(result.raw.selectSingleNode("//result").text);
}
}
}
</script>
<meta name="site-config-URL" content="">
Men når jeg kører filen, så melder den fejl, og det er fordi variablen 'teksten' er tom. Men det burde den jo ikke være. Siden kan ses her:
http://www.kongeborgen.dk/sporskifte/admin/default.php?doc=test
