hi guys,
i made a week ago a little news system with a little help from a friend… but i missed somthing, a edit and delete news item function… but now if i think about it… is that even posible??? i mean its a news system that uses NO MySql but a TXT document…
I used a simple $fp = fopen function to read the new items with a array() and foreach to view my items… it has filters to remove or alert user and there is a simple login system… it works fine…
is it even posible… here is the script:
<?
if($HTTP_POST_VARS['submit']) {
if($HTTP_POST_VARS['password'] == 'test') { //* verander passwoord *//
}
if($HTTP_POST_VARS['login'] == 'tester') { //* verander login *//
if(!$HTTP_POST_VARS['news']) {
echo "Error.. er is geen nieuws item ingevult..";
exit;
}
if(strstr($HTTP_POST_VARS['news'],"|")) {
echo "Error.. "|" het "pipe symbool" is niet toegestaan in DB.. verwijder deze..";
exit;
}
if(strstr($HTTP_POST_VARS['news'],"<")) {
echo "Error.. HTML is niet tegestaan in DB... verwijder deze "Tags < "..";
exit;
}
$fp = fopen('news.txt','a');
if(!$fp) {
echo "Error.. DB niet aanwezig.. of DB niet CHMOD 777.."></form><br>";
exit;
}
$line = date("m-d-y") . " " . date("H:i") . " " . "|" . $HTTP_POST_VARS['name']; //* datum en tijd *//
$line .= "|" . $HTTP_POST_VARS['news'];
$line = str_replace("
","<BR>",$line);
$line .= "
";
//* sluiten bestand *//
fwrite($fp, $line);
if(!fclose($fp)) {
echo "Error.. kan DB niet sluiten..";
exit;
}
} else {
echo "Error.. pasword niet ingevult..";
exit;
}
}
?>
This part is used to view the news items with (can be disabled) a function to show only the last added news line in the DB…
<?
//*leest db in html en plaats *//
$data = file('news.txt');
$data = array_reverse($data);
//* uit voor meer info *//
//$no = 1;
foreach($data as $element) {
$element = trim($element);
$pieces = explode("|", $element);
//* uit voor meer info *//
//if ($no == 1) {
//* $pieces[?] 1=image 0=datum 2=nieuws *//
echo "<table width=\"40%\" border=\"0\"><tr>";
echo "<td><font class=\"main_tekst\">" . " Datum: " . $pieces[0] . "<br>" . " Nieuws: " . $pieces[2] . "<BR><hr align=\"left\" width=\"50%\" size=\"1\" color=\"#000000\"></td>";
echo "</font></tr></table>";
}
//* uit voor meer info *//
//$no ++;
//}
?>
I made this script from scratch so if there are posible section that canbe modified please let me know… im not realy a wizz with PHP…
thank you for you time… let me know…