Hej "jwradhe". Begriper ju inte var i scriptet jag ska peta in koden bara, för att kunna testa? Kan nada om php....
mvh E
så här ser Maltes "spara.php" ut (och jag förmodar att det är där det hela ska in)
_____________________________________________________________________
nä fy jag är verkligen en högs förvirrad person. Nu har jag testat 100 gr och har 101 "spara.php" filer. Givetvis la jag in fel. Ursäkta mej Malte.
Så här ska det va (hoppas jag).....
<?php
require ("config.php");
include "strfunc.inc.php";
if($RegGlobal == 0){
while (list ($key, $val) = each ($HTTP_POST_VARS)) {
$$key = $val; }
$REMOTE_ADDR = $HTTP_SERVER_VARS['REMOTE_ADDR'];
$HTTP_HOST = $HTTP_SERVER_VARS['HTTP_HOST'];
$PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
}
if (isset($tillbaka)){
header("Location: retur.php");
exit;
} elseif (!isset($HTTP_POST_VARS['namn'])){
header("Location: forum.php");
exit;
} elseif (empty($namn)||empty($nyttinlagg)||empty($amne)){
$poster=array(1,$namn,$epost,$amne,$nyttinlagg);
$return=implode("|",$poster);
if($RegGlobal == 1){
session_register("return");
} else {
session_start();
$HTTP_SESSION_VARS['return']=$return;
}
$url = "inlagg.php?retur=1&id=$index";
if(isset($sida)) $url.= "&sida=".$sida."#retur";
header("Location: $url");
exit;
}
$forumfil=$filkatalog."/forum.txt";
$inlaggfil=$filkatalog."/".$index.".txt";
$indexfil=$filkatalog."/index.txt";
$nyttinlagg=cleanText($nyttinlagg);
$namn=cleanText($namn);
$epost=cleanText($epost);
$amne=cleanText($amne);
$tid=time();
$id=$index;
if($index==0){
//Här börjar avsnitt för nytt inlägg
if (!file_exists($indexfil)){
if($fd=fopen($indexfil, "w")){
$index=10000001;
fwrite($fd,$index);
fclose ($fd);
} else $mail_inlagg[]=3;
} else {
if($fd=fopen($indexfil, "r+")){
$index=fread($fd,filesize($indexfil));
(int) $index=$index;
$index++;
rewind($fd);
ftruncate ($fd, 0);
fwrite($fd,$index);
fclose ($fd);
} else $mail_inlagg[]=3;
}
$poster=array($tid,$index,$amne,$namn,$tid,"0","\n");
$gpost=implode("|",$poster);
if (!file_exists($forumfil)){
if($fd=fopen($forumfil, "w")){
fwrite($fd, $gpost);
fclose ($fd);
} else $mail_inlagg[]=1;
} else {
if($fd=fopen($forumfil, "r+")){
$innehall = filesize($forumfil) > 0 ? fread ($fd, filesize ($forumfil)) : '';
$innehall=$gpost.$innehall;
rewind($fd);
fwrite($fd, $innehall);
fclose ($fd);
} else $mail_inlagg[]=1;
}
$poster=array($index,$amne,"0","\n");
$gpost=implode("|",$poster);
$poster=array($namn,$epost,$tid,$nyttinlagg,$REMOTE_ADDR,"\n");
$gpost.=implode("|",$poster);
$filnamn=$filkatalog."/".$index.".txt";
if($fd=fopen($filnamn, "w")){
fwrite($fd, $gpost);
fclose($fd);
} else $mail_inlagg[]=2;
//Här slutar avsnitt för nytt inlägg
} else {
// Här börjar avsnitt för svar på inlägg
$innehall=file($forumfil);
for ($i=0;$i<sizeof($innehall);$i++){
$innehall[$i]=explode("|",$innehall[$i]);
if ($innehall[$i][1]==$index){
$amne=$innehall[$i][2];
$innehall[$i][0]=$tid;
$temp=$innehall[$i][5];
$temp++;
$innehall[$i][5]=$temp;
}
$innehall[$i][6]="\n";
}
rsort($innehall);
for ($i=0;$i<sizeof($innehall);$i++) $innehall[$i]=implode("|",$innehall[$i]);
if ($fd=fopen($forumfil, "w")){
for ($i=0;$i<sizeof($innehall);$i++) fwrite($fd, $innehall[$i]);
fclose ($fd);
} else $mail_inlagg[]=1;
$poster=array($namn,$epost,$tid,$nyttinlagg,$REMOTE_ADDR,"\n");
$gpost=implode("|",$poster);
if ($fd2=(fopen($inlaggfil, "a"))){
fwrite($fd2, $gpost);
fclose($fd2);
} else $mail_inlagg[]=2;
} // slut avsnitt för svar på inlägg
$nyttinlagg = str_replace("<br>", "\n", $nyttinlagg);
$nyttinlagg = str_replace(""", "\"", $nyttinlagg);
if($id!=0){
$gpost="Svar ämne: ".$amne."\n";
} else $gpost="Nytt ämne: ".$amne."\n";
$gpost.="Inlägg av: ".$namn."\n";
$gpost.="Inlagg:\n".$nyttinlagg."\n";
$gpost.="\nFör att svara, gå till:\n";
$gpost.="http://".$HTTP_HOST.dirname($PHP_SELF)."/inlagg.php?id=".$index."\n\n";
if(isset($mail_inlagg)){
if(in_array(1)) $gpost.="OBS !!! Kunde ej spara till forum.txt\n";
if(in_array(2)) $gpost.="OBS !!! Kunde ej spara till id.txt\n";
if(in_array(3)) $gpost.="OBS !!! Kunde ej spara till index.txt\n";
}
if ($skickamail==1){
$huvud = "From: Mitt forum <".$mailavsandare.">\n";
$huvud .= "Return-Path: <".$mailavsandare.">\n";
mail($mailmottagare, "Nytt inlagg i Forumet", $gpost, $huvud);
}
if(isset($sida)){
$url = "inlagg.php?id=".$id."&sida=".$sida;
} else $url = "forum.php";
header("Location: $url");
?>