16. marts 2006 - 08:27
Der er
6 kommentarer og
1 løsning
Open et .php doc og rediger på siden.
Hej jeg vil gerne hvide hvordan jeg opner et dokument på min hjemmeside i et textareal. alså koden i dokumentet. så jeg kan redigere det og gemme det igen. men hvad er komandoerne til sådan noget.
Nick
16. marts 2006 - 08:53
#3
Oki... Hvordan gemmer jeg så det den henter ind i text feltet?!
<?
session_start();
include("setup/server.php");
DB::Conn("open");
?>
<html>
<head>
<title>Untitled Document</title>
<script>
function pokazi(dir){
x=document.getElementById(dir);
if(x.style.display == "none"){
x.style.display = "";
}else{
x.style.display = "none";
}
}
</script>
</head>
<body>
<center>
<table width="800" height="600" border="1" cellspacing="0" cellpadding="0">
<tr>
<td height="25" colspan="4">
1
</td>
</tr>
<tr>
<td bgcolor="#CCCCCC" colspan="2" rowspan="3" height="575">
<table width="200" height="575" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="200" height="575" valign="top">
<?php
$path= "../test/";
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if(is_dir("$path".$file)){
echo "<div style=\"padding-left: 2px; margin: 0px; \" >";
echo "|-<b><a href=\"#\" onClick=pokazi(\"$file\")>$file</a></b><br />\n";
$id="$file";
dirT("$path$file/",$id);
}else{
?><a href="/<? echo "$file\n"; ?>"><? echo "$file<br />\n";?></a><?
}
}
}
echo "</div>";
closedir($handle);
}
function dirT($path,$id){
echo "<div style=\"padding-left: 2px; margin: 2px; display:none \" id=\"$id\">";
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if(is_dir("$path".$file)){
echo "<div style=\"padding-left: 10px; margin: 2px; \" >";
echo "|-<a href=\"#\" onClick=pokazi(\"$file\")>$file</a><br />\n";
$id="$file";
dirT("$path$file/",$id);
}else{
?><a href="upload/<? echo " --$file<br />\n"; ?>"><? echo " --$file<br />\n";?></a><?
}
}
}
echo "</div>";
closedir($handle);
}
echo "</div>";
}
?>
</td>
</tr>
</table>
</td>
<td colspan="2" height="25">
3
</td>
</tr>
<tr>
<td height="525" colspan="2" align="center" bgcolor="#CCCCCC">
<textarea style="border:0px; background:#CCCCCC" rows="32" cols="71">
<?
$counter_file = 'index.php';
clearstatcache();
ignore_user_abort(true); ## prevent refresh from aborting file operations and hosing file
$fh = fopen($counter_file, 'r+b'); ## use 'r+b' so file can be read and written
if ($fh)
{
if (flock($fh, LOCK_EX)) ## don't do anything unless lock is successful
{
$count = fread($fh, filesize($counter_file));
rewind($fh);
$count++;
fwrite($fh, $count);
fflush($fh);
ftruncate($fh, ftell($fh)); ## better than truncating to 0 before writing, per 04-Mar-2003 comment below
flock($fh, LOCK_UN);
} else echo "Could not lock counter file '$counter_file'";
fclose($fh);
} else echo "Could not open counter file '$counter_file'";
ignore_user_abort(false); ## put things back to normal
echo "counter is at $count";
?>
</textarea>
</td>
</tr>
<tr bgcolor="#CCCCCC">
<form action="?do=upload" method="post" enctype="multipart/form-data">
<td width="461" height="25" valign="middle">
<input type="hidden" name="MAX_FILE_SIZE" value="99999999">
Select file<input type="file" accept="image/jpeg" name="userfile">
Dir/<select name="dir">
<option value="/">@Home</option>
<option value="pages/">@Home/Pages</option>
<option value="setup/">@Home/Setup</option>
<option value="upload/">@Home/Upload</option>
</select><br>
<center><input style="font-size:12;" name="submit" type="submit" value=">>> Upload <<<"></center>
</td>
</form>
<td width="131" height="25" align="center">
<?
if($_GET['do'] == 'upload')
{
if(!(copy($_FILES['userfile']['tmp_name'], $_POST['dir'] . $_FILES['userfile']['name']))) die("Cannot upload files.");
echo "Upload Complete!";
} else{?>
Information here
<?
}
?>
</td>
</tr>
</table>
</center>
</body>
</html>