-# Wishlist
+<?php
+# Shoutbox 1.0
+# by Andreas Beder
+# codejungle.org
+# mod for tinc wiki
+# by wopot
+# Licence GNU GPL 2
-###Drop oyur Ideas into this Box
-####(The Idea will stay for a while and will check form the dev. Team)
-danm no form
+//config
+$filename="wishlist.txt";
+
+// be sure the file have write permissions
+$url="http://tinc-vpn.org/wishlist/";
+
+//function
+
+function get_content(){
+global $filename;
+ $lines = file ($filename);
+ $start = count($lines)-12;
+ if ($start < 1) $start = 1;
+ for ($i = $start; $i < count ($lines); $i++){
+ $somecontent.=stripslashes($lines[$i]);
+ }
+return $somecontent;
+}
+
+function add_content(){
+global $filename;
+if($_POST[submit] and $_POST[nick] and $_POST[content]){
+//check content
+//add content
+ $_SESSION["nick"]=$_POST[nick];
+ $somecontent=strip_tags($_POST[nick]).": ".strip_tags($_POST[content])."<br/>n";
+ $handle = fopen($filename, 'a+');
+ fwrite($handle, $somecontent);
+}
+}
+
+function output_form(){
+
+echo '
+<form action="" method="post">
+Name:';
+if($_SESSION[nick]){
+ echo $_SESSION[nick].'<input type="hidden" name="nick" value="'.$_SESSION[nick].'"><br>';
+}
+else {
+ echo '<br><input name="nick" type="text" value="'.$_SESSION[nick].'"><br>';
+}
+echo'
+Your Wish/Idea for the tinc Project:<br>
+<textarea rows="5" cols="100" name="content"></textarea><br>
+<input type="submit" name="submit" value="save">
+</form>
+';
+
+}
+
+if($_GET[content]=="true"){
+echo get_content();
+die();
+}
+?>
+<html>
+<head>
+<title>shoutbox demo</title>
+<script type="text/javascript" language="javascript">
+
+ var http_request = false;
+
+ function macheRequest(url) {
+
+ http_request = false;
+
+ if (window.XMLHttpRequest) { // Mozilla, Safari,...
+ http_request = new XMLHttpRequest();
+ if (http_request.overrideMimeType) {
+ http_request.overrideMimeType('text/xml');
+ // zu dieser Zeile siehe weiter unten
+ }
+ } else if (window.ActiveXObject) { // IE
+ try {
+ http_request = new ActiveXObject("Msxml2.XMLHTTP");
+ } catch (e) {
+ try {
+ http_request = new ActiveXObject("Microsoft.XMLHTTP");
+ } catch (e) {}
+ }
+ }
+
+ if (!http_request) {
+ alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen');
+ return false;
+ }
+ http_request.onreadystatechange = alertInhalt;
+ http_request.open('GET', url, true);
+ http_request.send(null);
+
+ }
+
+ function alertInhalt() {
+
+ if (http_request.readyState == 4) {
+ if (http_request.status == 200) {
+ document.getElementById("shoutbox").innerHTML=http_request.responseText;
+ var objDiv = document.getElementById("shoutbox");
+ objDiv.scrollTop = objDiv.scrollHeight;
+ setTimeout('macheRequest("<?php echo $url; ?>?content=true")',2000);
+
+ } else {
+ alert('Bei dem Request ist ein Problem aufgetreten.');
+ }
+ }
+
+ }
+</script>
+</head>
+<body onload="macheRequest('<?php echo $url; ?>?content=true');">
+<h1>Wislist</h1>
+<h2>Drop your Ideas into this Box</h2>
+<h4>(The Idea will stay for a while and will check form the dev. Team)</h4>
+
+<?php add_content(); ?>
+<div style="border:1px solid #ccc; width:500px; height:300px; max-height:300px; overflow:auto;" name="shoutbox" id="shoutbox"></div>
+<?php output_form(); ?>
+
+</body>
+</html>