LizardRob
07-06-2009, 11:29 AM
http://negre.jonanin.com/paste
index.php
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<title>Negre Paste</title>
</head>
<body>
<form id="pastetext" method="post" action="save.php">
Title:<input size="100" maxlength="100" name="title" /><br /><br />
<textarea id="pastearea" cols="100" maxlength="1000000" name="text" /></textarea><br />
<input type="submit" value="Submit" name="submit"></input><br />
</form>
</body>
</html>
display.php
<html>
<head>
<script type="text/javascript">
myHeight = 0;
if (typeof (window.innerWidth) == 'number') {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
}
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
function loaded(){
if(!isIE){
document.getElementsByName("text")[0].style.height = String(myHeight - 110) + "px";
}
document.getElementsByName("pastetext")[0].style.visibility = "visible"
}
</script>
<link rel="stylesheet" type="text/css" href="style.css" />
<title>
<?php
$filename = (int)$_GET['paste'] . ".txt";
if(!file_exists($filename)){
die("File does not exist yet.\n</title>\n</head>");
} else {
$file=fopen($filename,"r");
print(htmlspecialchars(fgets($file)) . " - Negre Paste</title>\n</head>\n<body onLoad=\"loaded();\">\n<p id=\"viewdownload\">\n<a href=\"$filename\">View/download text - $filename</a>\n</p>\n<br />\n<p class=\"hide\" name=\"pastetext\" id=\"pastetext\">\n<textarea id=\"pastearea\" maxlength=\"100000\" name=\"text\" wrap=\"off\">");
while(!(feof($file)))
{
$text = htmlspecialchars(fgets($file), ENT_QUOTES);
print($text);
}
print("\n</textarea>\n</p>\n</body>\n</html>");
}
?>
save.php
<?php
$text = $_POST['text'];
str_replace("\t",' ',$text);
$title = $_POST['title'];
if(strlen($title) == 0){
$title = "Untitled";
}
if(strlen($text) > 0 && strlen($text) < 100000){
$file = fopen("id.txt", "r");
$id = (int)fgets($file);
fclose($file);
$file = fopen("id.txt", "w");
fwrite($file, $id+1);
fclose($file);
$file = fopen("$id.txt", "x");
fwrite($file, "$title\n");
fwrite($file, "$text");
fclose($file);
print("<a href='display.php?paste=" . $id . "'>View your pasted text</a>");
} else {
print("You need to enter text to paste.");
}
?>
Problem: When I try to paste certain things, such as the entire code of display.php, it gives me an error 503 Service Temporarily Unavailable.
After some testing, I noticed that it doesn't happen when I remove all PHP function names from what I'm trying to paste, and it also doesn't happen when I remove semicolons.
I can't pinpoint what's making it do this, or why, and obviously I don't know how to fix it or work around it.
Any suggestions for a workaround or a simple fix would be nice. I want to keep it so that you can view the text which has been uploaded, and download it in .txt format, and I'd rather not manually replace certain strings and place them back when displaying.
index.php
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<title>Negre Paste</title>
</head>
<body>
<form id="pastetext" method="post" action="save.php">
Title:<input size="100" maxlength="100" name="title" /><br /><br />
<textarea id="pastearea" cols="100" maxlength="1000000" name="text" /></textarea><br />
<input type="submit" value="Submit" name="submit"></input><br />
</form>
</body>
</html>
display.php
<html>
<head>
<script type="text/javascript">
myHeight = 0;
if (typeof (window.innerWidth) == 'number') {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
}
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
function loaded(){
if(!isIE){
document.getElementsByName("text")[0].style.height = String(myHeight - 110) + "px";
}
document.getElementsByName("pastetext")[0].style.visibility = "visible"
}
</script>
<link rel="stylesheet" type="text/css" href="style.css" />
<title>
<?php
$filename = (int)$_GET['paste'] . ".txt";
if(!file_exists($filename)){
die("File does not exist yet.\n</title>\n</head>");
} else {
$file=fopen($filename,"r");
print(htmlspecialchars(fgets($file)) . " - Negre Paste</title>\n</head>\n<body onLoad=\"loaded();\">\n<p id=\"viewdownload\">\n<a href=\"$filename\">View/download text - $filename</a>\n</p>\n<br />\n<p class=\"hide\" name=\"pastetext\" id=\"pastetext\">\n<textarea id=\"pastearea\" maxlength=\"100000\" name=\"text\" wrap=\"off\">");
while(!(feof($file)))
{
$text = htmlspecialchars(fgets($file), ENT_QUOTES);
print($text);
}
print("\n</textarea>\n</p>\n</body>\n</html>");
}
?>
save.php
<?php
$text = $_POST['text'];
str_replace("\t",' ',$text);
$title = $_POST['title'];
if(strlen($title) == 0){
$title = "Untitled";
}
if(strlen($text) > 0 && strlen($text) < 100000){
$file = fopen("id.txt", "r");
$id = (int)fgets($file);
fclose($file);
$file = fopen("id.txt", "w");
fwrite($file, $id+1);
fclose($file);
$file = fopen("$id.txt", "x");
fwrite($file, "$title\n");
fwrite($file, "$text");
fclose($file);
print("<a href='display.php?paste=" . $id . "'>View your pasted text</a>");
} else {
print("You need to enter text to paste.");
}
?>
Problem: When I try to paste certain things, such as the entire code of display.php, it gives me an error 503 Service Temporarily Unavailable.
After some testing, I noticed that it doesn't happen when I remove all PHP function names from what I'm trying to paste, and it also doesn't happen when I remove semicolons.
I can't pinpoint what's making it do this, or why, and obviously I don't know how to fix it or work around it.
Any suggestions for a workaround or a simple fix would be nice. I want to keep it so that you can view the text which has been uploaded, and download it in .txt format, and I'd rather not manually replace certain strings and place them back when displaying.