Viewing file: blogSender.php (1.74 KB) -rw-rw-rw- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?PHP
$un = $_COOKIE['user'];
if(strlen($un)==0)
{
header("Location: index.php");
exit();
}
$name = $_POST['theName'];
$message = stripslashes($_POST['theMessage']);
if($myFile = fopen("blog.xml","r"))
{
$myFile = file("blog.xml");
$length = sizeof($myFile);
for($i=0;$i<($length-1);$i++){
$myString .= $myFile[$i];
}
print($myString);
}
if($myFile = fopen("blog.xml","w"))//this time write the file
{
fwrite($myFile,$myString);
fwrite($myFile,"<blog title='". $name . "' entry='" . $message . "' video='0' />\n");
fwrite($myFile,"</blog>");
fclose($myFile);
$sentOk1 = true;
}
$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";
}
$myString .= "</entry>\n";
}
$myString .= "<entry>\n\n";
$myString .= "</entry>\n";
$myString .= "</comments>";
if($myFile = fopen("comments.xml","w"))
{
fwrite($myFile,$myString);
$sentOk2 = true;
}
if($sentOk1 && sentOk2)
{
echo "sentOk=true&something=123";
}
?>
|