fopen($file,"w") setzt nicht mecht auf 0 byte zurück

Security

Erfahrenes Mitglied
Hallo ihr,
ich bin total am Ende, ich kann den Fehler einfach nicht finden.

Mein Problem ist das ich eine IP und eine Zeitangabe Löschen will, dies geht eigentlich auch, aber bei diesem Script irgendwie nicht.

Guckt euch den Quellcode einfach mal an.
PHP:
<html>
<head>
<title>Bitte warten ...</title>
<meta http-equiv="Refresh" content="200; URL=../index.php">
<style type="text/css">
body {
background-color: #FAFAFA;
color:#323232;
}
.cella {
background-color: #FAFAFA;
	 }
a:link		 { color:#1B6ECC; text-decoration: none }
a:visited	 { color:#1B6ECC; text-decoration: none }
a:active	 { color:#1B6ECC; text-decoration: none }
a:hover		{ color:#69B271; text-decoration: none }
.stdfont { font-family: Verdana, Helvetica; font-size: 10pt }
.smallfont { font-family: Verdana, Helvetica; font-size: 8pt }
</style>
</head>
<body bgcolor="#FAFAFA" text="#323232">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="500">
<tr>
	<td align="center" valign="middle">
	 <table width="100%" height="64" border="0" cellspacing="1" cellpadding="3" bgcolor="#DEDEDE">
		<tr class="cella">
		 <td align="center"><span class="stdfont">
<?php
error_reporting(E_ALL);
$counter_path = "";
$i = 0;
$j = 0;
$del_control = 0;
$filearray = file($counter_path . "ip.php");
foreach($filearray as $num => $line)
{
$ip_timestamp_array = split("( |-)",$line);
$ip[$i] = $ip_timestamp_array[0];
$timestamp[$j] = $ip_timestamp_array[1];
 
$REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];
if(($ip[$i] == $REMOTE_ADDR) AND ($timestamp[$j]==$timestamp[$j]))
{ 
	$search_toremove = $ip[$i] . "-" . $timestamp[$j];
	$datei = fopen($counter_path . "ip.php", "r");
	$size = filesize($counter_path . "ip.php");
	$contents = fread($datei, $size);
	fclose($datei);
$insert = "";
	$massreplace = preg_replace("/$search_toremove/", $insert, $contents);
	$datei = fopen($counter_path . "ip.php", "w");
flock($datei, 2);
fputs($datei, $massreplace);
flock($datei, 3);
	fclose($datei);
echo $massreplace;
$del_control = 1;
};
$i++;
$j++;
};
$to_test = implode("", @file($counter_path . "ip.php"));
if (!strstr($to_test, $REMOTE_ADDR))
{
$file = fopen("ip.php","a");
fputs($file,$REMOTE_ADDR . "-" . time());
fclose($file);
echo ?>
<b>Sie wurden erfolgreich ausgeloggt, bitte warten ...</b><br></span><span class="smallfont">
			<a href="../index.php">Klicken Sie hier, falls ihr Browser keine automatische 
			 Weiterleitung unterst&uuml;tzt.</a></span></td>
<?php
;}
else
{
echo
?>
<b>Beim ausloggen ist ein Fehler aufgetreten, bitte warten ...</b><br></span><span class="smallfont">
			<a href="../index.php">Klicken Sie hier, falls ihr Browser keine automatische 
			 Weiterleitung unterst&uuml;tzt.</a></span></td>
<?php ;} ?>
		</tr>
	 </table>
	</td>
</tr>
</table>
</body>
</html>
 
Zuletzt bearbeitet:
Hm... ich hab jetzt einfach noch n bisschen Quatsch forher in die datei ip.php geschrieben und schon gehts.
Kanns sein das ich keinen Lehren String einfügen kann
 
Ich finde die Fehler immer erst wenn ich sie gepostet.
Naja vür alle die sich das noch angucken:
PHP:
$to_test = implode("", @file($counter_path . "ip.php"));
if (!strstr($to_test, $REMOTE_ADDR))
{
$file = fopen("ip.php","a");
fputs($file,$REMOTE_ADDR . "-" . time());
fclose($file);
echo ?>
Da hab ich Idiot die IP wieder eingefügt, und den Timestamp quasie nur aktualiesiert.
 
Zurück