habe versucht einen kalender zu basteln, in den sich auch user eintragen können, was sogar funktioniert hat,
allerdings klappt das löschen und bearbeiten irgendwie nicht ...
Weiß / sieht jemand (m)einen Fehler?
function del_event( $id2del )
{
GLOBAL $EFILE;
$temp_file = "temp_filed.txt";
$temp_h = fopen($temp_file,"w+");
$file_array = file($EFILE);
foreach($file_array as $fline)
{
$line_length = strlen($fline);
if($line_length > 30)
{
list($fid,$fdatestamp,$fstimestamp,$fetimestamp,$flocation,$fdescr) = explode("|",$fline);
if($fid != $id2del)
{
fputs($temp_h,$fline);
}
}
}
fclose($temp_h);
unlink($EFILE);
rename($temp_file,$EFILE);
return 1;
}
function purge_old( $boundstamp )
{
GLOBAL $EFILE;
$tempfile = "temp_file_purge.txt";
$temph = fopen($tempfile,"w+");
$file_array = file($EFILE);
foreach($file_array as $fline)
{
$line_length = strlen($fline);
if($line_length > 30)
{
list($fid,$fdatestamp,$fstimestamp,$fetimestamp,$flocation,$fdescr) = explode("|",$fline);
if($fdatestamp >= $boundstamp)
{
fputs($temph,$fline);
}
}
}
fclose($temph);
unlink($EFILE);
rename($tempfile,$EFILE);
return 1;
}
function mod_event( $oldid, $newline )
{
GLOBAL $EFILE;
$temp_file = "temp_filed.txt";
$temp_h = fopen($temp_file,"w+");
$file_array = file($EFILE);
foreach($file_array as $fline)
{
$line_length = strlen($fline);
if($line_length > 30)
{
list($fid,$fdatestamp,$fstimestamp,$fetimestamp,$flocation,$fdescr) = explode("|",$fline);
if($fid != $oldid)
{
fputs($temp_h,$fline);
}
}
}
fputs($temp_h, "\r\n".$newline);
fclose($temp_h);
unlink($EFILE);
rename($temp_file,$EFILE);
return 1;
}
function get_event( $id )
{
GLOBAL $EFILE;
$file_array = file($EFILE);
foreach($file_array as $line)
{
$line_length = strlen($line);
if($line_length > 30)
{
$chunked = explode("|",$line);
$fid = $chunked[0];
if($fid == $id)
{
//array_push($day_array,$line);
$foundline = trim($line);
return $foundline;
}
}
}
return 0;
}