Slettet bruger
16. oktober 1999 - 21:17
Der er
3 kommentarer og 1 løsning
Må ikke overwrites...
Hvad skal jeg gøre, for at dette script ikke overskriver dlfile.txt, men istedet tilføjer mere HTML dertil? <? $dlfile = "dlfile.txt"; $html = 0; function write_dlfile($navn, $overskrift, $url, $beskrivelse, $html, $dlfile) { $otag = @file($dlfile); if(!$html) { $navn = html_nice($navn); $overskrift = html_nice($overskrift); $url = html_nice($url); $beskrivelse = html_nice($url); } $ftag = "<div align=\"center\"><center><table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" bgcolor=\"#808080\" bordercolor=\"#FFFFFF\"> <tr> <td width=\"100%\"><div align=\"center\"><center><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"> <tr> <td width=\"4%\"><a href=\"download.cgi?$url\"><img src=\"icon.gif\" alt=\"Download!\" WIDTH=\"16\" HEIGHT=\"16\"></a></td> <td width=\"96%\"><font face=\"Verdana\" color=\"#FFFFFF\"><small>$overskrift</small></font></td> </tr> </table> </center></div></td> </tr> <tr> <td width=\"100%\"><div align=\"center\"><center><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"> <tr> <td width=\"5%\"> <p> </td> <td width=\"95%\" valign=\"top\"><font face=\"Verdana\" color=\"#FFFFFF\"><small>$beskrivelse</small></font><p><font face=\"Verdana\" color=\"#FFFFFF\"><em><small>Oprettet af: $navn</small></em></font></td> </tr> </table> </center></div></td> </tr> </table> </center></div><hr size=\"1\" color=\"#C0C0C0\">"; for( $i=0 ; $i<$maxtags-1 ; $i++ ) $ftag .= $otag[$i]; $fp = fopen($dlfile, "w"); fwrite($fp, $ftag); fclose($fp); } function html_nice($string) { $string = ereg_replace( '<', "<", $string); $string = ereg_replace( '>', ">", $string); $string = ereg_replace( '&', "&", $string); $string = stripslashes($string); return $string; } ?> <? write_dlfile($navn, $overskrift, $url, $beskrivelse, $html, $dlfile); echo "<font face=\"Verdana\"><br>Dit download er oprettet!<br></font>"; echo "</body></html>"; exit; } ?> Help me!!!
Annonceindlæg fra Cognizant
16. oktober 1999 - 23:12
#1
Linien : $fp = fopen($dlfile, "w"); skal ændres til : $fp = fopen($dlfile, "a"); eller : fopen($dlfile, "a+"); a : Åben for SKRIV, hvis filen ikke findes så oprettes den. Ny tekst bliver tilføjet til enden af filen. a+ : Åben for LÆS & SKRIV, ellers det samme som oventstående. Så det skulle være det du skal bruge.
17. oktober 1999 - 00:33
#2
Du kan gemme på den her måde: function write_dlfile($navn, $overskrift, $url, $beskrivelse, $html, $dlfile) { $otag = @file($dlfile); if(!$html) { $navn = html_nice($navn); $overskrift = html_nice($overskrift); $url = html_nice($url); $beskrivelse = html_nice($url); } $ftag = "$navn."|".$overskrift."|".$url."|".$beskrivelse."|".$html."|".$dlfile."\n"; for( $i=0 ; $i<$maxtags-1 ; $i++ ) $ftag .= $otag[$i]; $fp = fopen($dlfile, "w"); fwrite($fp, $ftag); fclose($fp); } så kan du læse på der her måde: $file = "dinfil.txt"; $fp = fopen($file, r); while($str = fgets($fp, 4000)) { $split = split( "\|", $str); <div align=\"center\"><center><table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" bgcolor=\"#808080\" bordercolor=\"#FFFFFF\"> <tr> <td width=\"100%\"><div align=\"center\"><center><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"> <tr> <td width=\"4%\"><a href=\"download.cgi?".$split[2]."\"><img src=\"icon.gif\" alt=\"Download!\" WIDTH=\"16\" HEIGHT=\"16\"></a></td> <td width=\"96%\"><font face=\"Verdana\" color=\"#FFFFFF\"><small>".$split[1]."</small></font></td> </tr> </table> </center></div></td> </tr> <tr> <td width=\"100%\"><div align=\"center\"><center><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"> <tr> <td width=\"5%\"> <p> </td> <td width=\"95%\" valign=\"top\"><font face=\"Verdana\" color=\"#FFFFFF\"><small>".$split[3]."</small></font><p><font face=\"Verdana\" color=\"#FFFFFF\"><em><small>Oprettet af: ".$split[0]."</small></em></font></td> </tr> </table> </center></div></td> </tr> </table> </center></div><hr size=\"1\" color=\"#C0C0C0\">"; } Det skulle virke ??? - Andreas
17. oktober 1999 - 00:35
#3
arrrggg fejl i den måde med at læse.... her: $file = "dinfil.txt"; $fp = fopen($file, r); while($str = fgets($fp, 4000)) { $split = split( "\|", $str); echo "<div align=\"center\"><center><table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" bgcolor=\"#808080\" bordercolor=\"#FFFFFF\"> <tr> <td width=\"100%\"><div align=\"center\"><center><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"> <tr> <td width=\"4%\"><a href=\"download.cgi?".$split[2]."\"><img src=\"icon.gif\" alt=\"Download!\" WIDTH=\"16\" HEIGHT=\"16\"></a></td> <td width=\"96%\"><font face=\"Verdana\" color=\"#FFFFFF\"><small>".$split[1]."</small></font></td> </tr> </table> </center></div></td> </tr> <tr> <td width=\"100%\"><div align=\"center\"><center><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"> <tr> <td width=\"5%\"> <p> </td> <td width=\"95%\" valign=\"top\"><font face=\"Verdana\" color=\"#FFFFFF\"><small>".$split[3]."</small></font><p><font face=\"Verdana\" color=\"#FFFFFF\"><em><small>Oprettet af: ".$split[0]."</small></em></font></td> </tr> </table> </center></div></td> </tr> </table> </center></div><hr size=\"1\" color=\"#C0C0C0\">"; }
Slettet bruger
17. oktober 1999 - 09:29
#4
Åhhh, Tusind tak!
Se scriptet i funktion på:
http://download.cht.dk Mvh,
Christian
Thuner
Vi tilbyder markedets bedste kurser inden for webudvikling