Heres는 오래 전에에서 (내가 생각하는 것) 작업 솔루션 내가 과거에 일을 말할 수 있습니다하지만 난 여전히 현재의 시스템과 호환된다는 보장도하지 않습니다.
특징
- 비밀번호 로그인 (매우 안전하지하지만 멀리 유지합니다 일반 사용자)
- 백 버튼을 눌렀을 오래된 코드 변경 사항을 덮어 쓰는 것을 방지 (아마도 타임 스탬프를 사용하는 $ 랜드를 업데이트 할 수 무작위 대신에)
아마도 많은 업데이트가있을 수 있습니다.
이
은 사업부로 readdir은 나 (빠른 뭔가를) 위해 scandir의 결과를 출력 시도해 볼 수도 있습니다, 당신은 또한 파일을 나열하는 데 필요한 경우 단지
작업 뭔가를 얻기 위해 주로 신속하고 더러운 솔루션이었습니다. 또한, @Hipny은 자신의
코드를 구축하는 방법에 관한 올바른 생각을 가지고
<?
$rand = mt_rand(0, 65535);
setcookie("check", $rand);
if ($_POST['pass'] != ""){
setCookie ("auth", hash("sha512", $_POST['pass']));
echo "<meta http-equiv='refresh' content='0;" . $_SERVER["SCRIPT_NAME"] . "'>";
}
if ($_GET['logout'] == "1"){
setCookie("auth","");
echo "<meta http-equiv='refresh' content='0;" . $_SERVER["SCRIPT_NAME"] . "'>";
}
if ($_COOKIE['auth'] != "!!!! INSERT YOUR OWN SHA512 HASH HERE !!!!"){
echo "<center><h1>Authentication required</h1><br /><form action='" . $_SERVER["SCRIPT_NAME"]. "?" . $_SERVER["QUERY_STRING"] . "' method='post'><input type='password' name='pass'><input type='submit' value='Authenticate'></form></center>";
die();
}
$rand = mt_rand(0, 65535);
setcookie("check", $rand);
?>
<html>
<head>
<script language="javascript" type="text/javascript">
function reloadFile(){
var query = window.location.search.substring(1);
var vars = query.split("&");
var redir = "?";
for (var i=0;i<vars.length;i++){
if (vars[i].indexOf("file=") == -1 && vars[i].indexOf("save=1") == -1){
if (redir == "") redir = "?" + vars[i];
else redir += "&" + vars[i];
}
}
while (redir.indexOf("&&") != -1) redir = redir.replace("&&", "&");
document.location.href = document.location.href.substring(0, document.location.href.indexOf("?")) + redir + "&file=" + document.getElementById("newfile").value;
}
</script>
<title>Editing file: <? echo $_GET['file']; ?></title>
</head>
<body>
<table cellspacing="0" cellpadding="0">
<tr>
<td colspan=2">
<input id="newfile" type="text" size="135" onkeydown="if (event.keyCode == 13) document.getElementById('load').click()"><input id="load" type="button" value="Load" onClick="if (confirm('Discard changes?')) reloadFile();">
</td>
</tr>
<tr>
<td colspan="2">
<?php
function ex($message){
throw new Exception($message);
}
function read($file){
try{
@$handle = fopen($file, "rb") or ex("Read Error!");
$contents = stream_get_contents($handle);
fclose($handle);
return htmlspecialchars($contents);
} catch (Exception $e) {
return "Creating new file.";
}
}
function save(){
$data = htmlspecialchars_decode($_POST['data']);
if($_GET['file'] != "") {
$fp=fopen($_GET['file'], "w");
fwrite($fp, $_POST['data']);
fclose($fp);
}
}
//echo strlen ($_POST['data']);
if ($_POST['data'] != "" && $_COOKIE['check'] == $_POST['checksum']) save();
else if ($_GET['save'] == 1) echo "<div id='abort'><h1><font color='FF0000'>Save checksum did not match: save aborted!</font> <a href=\"javascript:void(document.getElementById('abort').style.display = 'none')\" style='color: #000000;text-decoration:none;'>X</a></h1></div>";
?>
<form name="dataform" id="dataform" method="post" action="<? echo $_SERVER["SCRIPT_NAME"] . "?" . $_SERVER['QUERY_STRING']; if (strpos($_SERVER['QUERY_STRING'],"&save=1") === false) echo "&save=1"; ?>" onSubmit="return confirm('Do you want to save?');">
<textarea name="data" wrap="off" id="data"<? if ($_POST['h'] != "") echo " rows='" . $_POST['h'] . "'"; else if ($_GET['h'] != "") echo " rows='" . $_GET['h'] . "'";
<?
if ($_GET['file'] != "") echo read($_GET['file']);
?></textarea><br />
<input type="hidden" value="<? echo $rand ?>" id="checksum" name="checksum">
<script language="javascript" type="text/javascript">
</script>
</td>
</tr>
<tr>
<td>
<input type="submit" Value="Save">
<input type="button" Value="Revert" onClick="if (confirm('Are you sure you want to revert?')) document.location.href = document.location.href;">
<input type="button" Value="Logout" onClick="if (confirm('Are you sure you want to logout?')) document.location.href = '<? echo $_SERVER["SCRIPT_NAME"] ?>?logout=1';">
</td>
<td align="right">
<input name="h" id="h" onKeyUp='document.getElementById("data").rows = this.value'> x <input name="w" id="w" onKeyUp='document.getElementById("data").cols = this.value'>
<script language="javascript" type="text/javascript">
document.getElementById("data").style.width = document.body.clientWidth * .9;
document.getElementById("data").style.height = document.body.clientHeight * .8;
</script>
</td>
</tr>
</table>
</form>
</body>
</html>
감사 Hipny는 정말 SyntaxHighlighter 사용에 대한 여러분의 도움과 좋은 생각을 주셔서 감사합니다! :-) –
나의 기쁨! ;) – Hipny