Viewing file: commentSystem.php (1.3 KB) -rw-rw-rw- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?
if($_GET['type'] == "newComment"){
$message = stripslashes($_POST['message']);
$name = $_POST['name'];
$number = 1 + $_POST['number'];
$number -= 1;
$myString = "";
$xml = simplexml_load_file('comments.xml');
$entries = $xml->entry;
$myString .= "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>";
$myString .= "\n";
$myString .= "<comments>\n";
for($i=0;$i<sizeof($entries);$i++){
$comments = $xml->entry[$i]->comment;
$myString .= "<entry>\n";
for($r=0;$r<sizeof($comments);$r++){
$myString .= "<comment>";
$string = (string)$xml->entry[$i]->comment[$r];
$string = str_replace("&","&",$string);
$string = str_replace("%","%",$string);
$string = str_replace("<","<",$string);
$string = str_replace(">",">",$string);
$string = str_replace("'","'",$string);
$string = str_replace("\"",""",$string);
$myString .= $string;
$myString .= "</comment>\n";
}
if($i == $number){
$myString .= "<comment>";
$myString .= $name . ": " . $message;
$myString .= "</comment>\n";
}
$myString .= "</entry>\n";
}
$myString .= "</comments>";
//echo $myString;
if($myFile = fopen("comments.xml","w"))
{
fwrite($myFile,$myString);
echo "sentOk=true&testing=123";
}
}
?>
|