WARNING: unlink(/home/users/web/b372/ipw.oxyscrip/public_html/public/templates_c///%%CC/CC4/CC4BC2E3%%inc_head.tpl.php.php) [function.unlink]: No such file or directory (on line 44 of file '/hermes/bosweb/web037/b372/ipw.oxyscrip/public_html/3rdparty/Smarty-2.6.11/libs/internals/core.write_file.php') Oxyscripts - PHP Development, tutorials, articles, news, programming, scripts and forums.
if($action == "edit" && isset($HTTP_POST_VARS['password'])) {
//obviously you should change this password on the next line
if($HTTP_POST_VARS['password'] == "editpass") {
//First let's recompile that line with the pipe symbols so we can reinsert it
$line = $HTTP_POST_VARS['date'] . "|" . $HTTP_POST_VARS['name'];
$line .= "|" . $HTTP_POST_VARS['news'];
$line = str_replace("rn"," ",$line);
$line .= "rn";
$data = file('news.txt');
$data[$id] = $line;
//the next line makes sure the $data array starts at the beginning
reset($data);
//now we open the file with mode 'w' which truncates the file
$fp = fopen('news.txt','w');
foreach($data as $element) {
fwrite($fp, $element);
}
fclose($fp);
echo "Item Edited!
n";
echo "Go Backn";
exit;
} else {
echo "Bad password!n";
exit;
}
}
if($action == "edit") {
$data = file('news.txt');
$element = trim($data[$id]);
$pieces = explode("|", $element);
//the next line is to reverse the process of turning the end of lines into breaking returns
$news = str_replace(" ","rn",$pieces[2]);
echo "Make the changes you would like and press save. n";
echo "n";
exit;
}
if($action == "delete" && isset($HTTP_POST_VARS['password'])) {
//obviously you should change this password on the next line
if($HTTP_POST_VARS['password'] == "deletepass") {
$data = file('news.txt');
//this next line will remove the single news item from the array
array_splice($data,$id,1);
//now we open the file with mode 'w' which truncates the file
$fp = fopen('news.txt','w');
foreach($data as $element) {
fwrite($fp, $element);
}
fclose($fp);
echo "Item deleted!