I am almost finished polishing it off....
What is left to do is make it so that the script displays the last N number of lines of tag.txt, but with the option of displaying the number of pages, and links to them in a drop-down list. I can imagine this would be something not too difficult, but I can't figure out how.
All help is appreciated
And here's the script:
Code: Select all
<?php
// tagboard 1.0
// only works on *nix with commands rm, touch, and echo installed.
/*
this file is protected under the GPL: http://www.gnu.org/copyleft/gpl.html
i dont know why it does some of the things it does, but it works
admin mode coming soon
*/
$randstr = RandomString(5);
if(!isset($write)) {
system("rm .*");
system("touch .$randstr"); }
//check if tag.txt exists, if not, create it.
if (file_exists("tag.txt")) {}
else { system("touch tag.txt");chmod("tag.txt", 0666); }
//thanks to xentrik.net for these bits of maliciousness stripping code.
$msg = str_replace("<","<",$msg);
$msg = str_replace(">",">",$msg);
$msg = str_replace("\r\n"," ",$msg);
$msg = str_replace("\n"," ",$msg);
$msg = str_replace("|","l",$msg);
$msg = stripslashes($msg);
$name = str_replace("<","<",$name);
$name = str_replace(">",">",$name);
$name = str_replace("\r\n"," ",$name);
$name = str_replace("\n"," ",$name);
$name = str_replace("|","l",$name);
$name = stripslashes($name);
$file = "tag.txt";
$Array = file($file);
// print the tagboard
// TODO: limit # of tags output, create a list of pages
if (!isset($write)) {
foreach ($Array as $key => $val) {
echo $val;
echo "<br />";
}
}
//write the tag
if(isset($write)) {
if($ver=="") { echo "enter the verification code. <a href=\"javascript:history.go(-1)\">back</a>";exit; } else {
// if you've entered the right code
if (file_exists(".".$ver)) {
system("rm .*");
echo "<h4>success!</h4><a href=\"javascript:history.go(-1)\">back</a>";
//add the string to tag.txt
system("echo \"<strong>$name</strong>: $msg\">>tag.txt");
} else { echo "enter the verification code. <a href=\"javascript:history.go(-1)\">back</a>";exit; }
}
exit;
} else {}
?>
<hr />
<em>note: you may have to refresh your page to view your new tag.</em><br />
<form method="post" action="tag.php?write"><div>
<input type="text" name="name" value="name" /><br />
<input type="text" name="msg" value="message" /><br />
enter: <code><?php echo $randstr ?></code><br />
<input type="text" name="ver" value="" /><br />
<input type="submit" value="submit" />
</div></form>
<?php
// function to generate random strings
function RandomString($length=32)
{
$randstr='';
srand((double)microtime()*1000000);
//our array add all letters and numbers if you wish
$chars = array ( 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');
for ($rand = 0; $rand <= $length; $rand++)
{
$random = rand(0, count($chars) -1);
$randstr .= $chars[$random];
}
return $randstr;
}
?>