<?
      if  ($month=="Jan") $mon="01";
      if  ($month=="Feb") $mon="02";
      if  ($month=="Mar") $mon="03";
      if  ($month=="Apr") $mon="04";
      if  ($month=="Mai") $mon="05";
      if  ($month=="Jun") $mon="06";
      if  ($month=="Jul") $mon="07";
      if  ($month=="Aug") $mon="08";
      if  ($month=="Sep") $mon="09";
      if  ($month=="Okt") $mon="10";
      if  ($month=="Nov") $mon="11";
      if  ($month=="Des") $mon="12";      
if ($day<10) $day="0".($day +0);
$f7=fopen("users.txt","a");

 fwrite($f7,
 
escapeshellcmd($day."/".$mon." ".$year
." Server:".$HTTP_HOST." Klient:"
.gethostbyaddr($REMOTE_ADDR)
."\(".$REMOTE_ADDR."\) "
.$HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"] 
." "
.$_SERVER['PHP_AUTH_USER']
."\n"
));

 
$f8=fopen(("lesere/lest-".$year."-"
.$mon."-".$day."-"
.$_SERVER['PHP_AUTH_USER']),"w"); 
?>

<html>
<head>
<title>Marius & Kajas dagbok</title>
</head>
<body>

<table width="100%"><tr><td>
<h1>
<? $datetime=strtotime($year.$mon.$day);
$wday=date("w",$datetime);
if ($wday=="0") echo "S&oslash;ndag ";
if ($wday=="1") echo "Mandag ";
if ($wday=="2") echo "Tirsdag ";
if ($wday=="3") echo "Onsdag ";
if ($wday=="4") echo "Torsdag ";
if ($wday=="5") echo "Fredag ";
if ($wday=="6") echo "L&oslash;rdag ";
echo $day; echo ". "; 
if ($month=="Jan") echo "januar ";
if ($month=="Feb") echo "februar ";
if ($month=="Mar") echo "mars ";
if ($month=="Apr") echo "april ";
if ($month=="Mai") echo "mai ";
if ($month=="Jun") echo "juni ";
if ($month=="Jul") echo "juli ";
if ($month=="Aug") echo "august ";
if ($month=="Sep") echo "september ";
if ($month=="Okt") echo "oktober ";
if ($month=="Nov") echo "november ";
if ($month=="Des") echo "desember ";
echo $year; echo "\n";
echo "</h1>\n";
$sara=strtotime("-497 days",$datetime);
$saray=date("Y",$sara);
$saram=date("m",$sara);
$sarad=date("d",$sara);
if ($saram=="01") $saramon="Jan";
if ($saram=="02") $saramon="Feb";
if ($saram=="03") $saramon="Mar";
if ($saram=="04") $saramon="Apr";
if ($saram=="05") $saramon="Mai";
if ($saram=="06") $saramon="Jun";
if ($saram=="07") $saramon="Jul";
if ($saram=="08") $saramon="Aug";
if ($saram=="09") $saramon="Sep";
if ($saram=="10") $saramon="Okt";
if ($saram=="11") $saramon="Nov";
if ($saram=="12") $saramon="Des";
if ($datetime >= strtotime("26 May 2004")) echo "<a href=?day=$sarad&month=$saramon&year=$saray>Da Sara var s&aring; gammel som Ruth er n&aring;</a><br>"; 
echo "<a href=\"mnd.php3?year=$year&month=$month\">Tilbake til hele ";

if ($month=="Jan") echo "januar";
if ($month=="Feb") echo "februar";
if ($month=="Mar") echo "mars";
if ($month=="Apr") echo "april";
if ($month=="Mai") echo "mai";
if ($month=="Jun") echo "juni";
if ($month=="Jul") echo "juli";
if ($month=="Aug") echo "august";
if ($month=="Sep") echo "september";
if ($month=="Okt") echo "oktober";
if ($month=="Nov") echo "november";
if ($month=="Des") echo "desember";
echo" $year</a> <a href=index.php3>Tilbake til hovedsiden</a>\n";

echo " <a href=alle2.php3?day=$day&month=$month&year=";
echo $year-1;
echo ">Ett år siden</a>";

echo "</td><td><img src=kattokatt.jpg></td>";
if (file_exists("dyr/dagbok-2002-".$mon."-".$day.".inc"))
    {
    include "dyr/dagbok-2002-$mon-$day.inc";
    echo "
    </td><td align=right> 
    <table><tr><td>Dagens dyr: <br>".ucfirst($dyrenavn)."</td><td>
    <a href=\"/$dyr.html\">";
    if (file_exists("../".$dyr."-t.gif"))
    echo "
    <img src=\"/$dyr-t.gif\" height=90></a></td>\n";
    else
    echo "
    <img src=\"/$dyr-t.jpg\" height=90></a></td>\n";
    echo "</tr></table></td>\n";
  }
$hage="../jane/hage/frame-$year-$mon-$day-12-00.jpg";
if (file_exists($hage))
    {
    echo "
    </td><td align=right>
    <table><tr><td>Dagens hage: </td><td>
    <a href=\"$hage\">";
    echo "
    <img src=\"$hage\" height=90></a></td>\n";
    echo "</tr></table></td>\n";
  }
$temp=file("http://www2.easynet.no/temp-dagbok.php?year=$year&month=$mon&day=$day");
if (strlen($temp[0])>30)echo "<tr><td>$temp[0]</td></tr>";
  $fname=sprintf("dagbok-%s-%s-%s", $year, $mon, $day);
  if ($dir = @opendir("dager")) {
    while (($file = readdir($dir)) !== false) {
      if ($file!="." && $file!=".."){
        $list_of_all_files[] = $file;
     //   $list_of_file_times[] = filectime($file);
  }
      if (substr($file,0,strlen($fname))==$fname)
      {
         if (substr($file,strlen($file)-4,4)!="-txt")
         {
           $list_of_files[] = $file;
         } else
         {
           $list_of_textfiles[] = $file;
         }
      }  
    }  
    closedir($dir);

    sort($list_of_all_files);
    reset($list_of_all_files);
    $first=1;
    echo "<table width=\"100%\"><tr>";
    while (list ($key, $file) = each ($list_of_all_files)) 
    {
        //       echo $file."<br>";
       $newyear=substr($file,7,4);
       $newmonth=substr($file,12,2);
       $newday=substr($file,15,2);
      if  ($newmonth=="01") $newmon="Januar";
      if  ($newmonth=="02") $newmon="Februar";
      if  ($newmonth=="03") $newmon="Mars";
      if  ($newmonth=="04") $newmon="April";
      if  ($newmonth=="05") $newmon="Mai";
      if  ($newmonth=="06") $newmon="Juni";
      if  ($newmonth=="07") $newmon="Juli";
      if  ($newmonth=="08") $newmon="August";
      if  ($newmonth=="09") $newmon="September";
      if  ($newmonth=="10") $newmon="Oktober";
      if  ($newmonth=="11") $newmon="November";
      if  ($newmonth=="12") $newmon="Desember";
      if  ($newmonth=="01") $newmon2="Jan";
      if  ($newmonth=="02") $newmon2="Feb";
      if  ($newmonth=="03") $newmon2="Mar";
      if  ($newmonth=="04") $newmon2="Apr";
      if  ($newmonth=="05") $newmon2="Mai";
      if  ($newmonth=="06") $newmon2="Jun";
      if  ($newmonth=="07") $newmon2="Jul";
      if  ($newmonth=="08") $newmon2="Aug";
      if  ($newmonth=="09") $newmon2="Sep";
      if  ($newmonth=="10") $newmon2="Okt";
      if  ($newmonth=="11") $newmon2="Nov";
      if  ($newmonth=="12") $newmon2="Des";
//      echo "day $newday newmonth $newmonth newyear $newyear newuser $newuser newnr $newnr<br>";
      if ($oldyear!=$newyear || $oldmonth!=$newmonth ||$oldday!=$newday)
      {
        if ($oldyear==$year && $oldmonth==$mon && $oldday==$day)
        {  
           echo "<td align=right>";
           echo "
         <a href=\"alle2.php3?day=$newday&month=$newmon2&year=$newyear\">
           $newday. $newmon $newyear <img src=\"hoyre.jpg\" frame=0 
           border=0> </a><br>";
           echo "</td>";
        }
        if ($newyear==$year && $newmonth==$mon && $newday==$day)
        { 
           if ($first==1){ $first=0; } else {

           echo "<td>";
           echo " 
         <a href=\"alle2.php3?day=$oldday&month=$oldmon2&year=$oldyear\">
         <img src=\"venstre.jpg\" frame=0 border=0>
         $oldday. $oldmon $oldyear </a>";
           echo "</td>";
        echo "<td>";
        echo "<a href=http://www2.evang.no/galleri/dag.php?year=$year&month=$mon&day=$day>";
        readfile("http://www2.evang.no/finnesdag.php?year=".$year."&month=".$mon."&day=".$day);
        //echo "http://www2.evang.no/galleri/finnesdag.php?year=".$year."&month=".$mon."&day=".$day;
        echo "</a><br>";
include "dag-bilde.php3";
            if 
//(file_exists("../jane/".$day.strtolower($month).$year))
   (false)
     { 
       echo "<a href=../jane/".$day.
       strtolower($month).$year."/thumb.php3?day=$day&month=".strtolower($month)."&year=$year>Dagens bilder</a>    
";

       @include $fnavn."/title.txt";
       echo "<br>";}

        if (file_exists ("primstav/primstav-".$mon."-".$day.".php3")) {
	   echo "<a href=primstav/primstav-".$mon."-".$day.".php3>";
           if (file_exists("primstav/primstav-".$mon."-".$day.".jpg")) {
             echo "<img src=primstav/primstav-".$mon."-".$day.".jpg >";
           } else {
           echo "Dagens primstav";
           }
	   echo "</a>";
        }
        include "moon.php3";
        echo "</td>";
          }
        }
//        echo "<a href=\"alle2.php3?day=$day&month=$month&year=$year\">";
//        echo "$newday. $newmon $newyear</a>";
      }
      $oldoldmonth=$oldmonth; $oldoldyear=$oldyear;$oldoldday=$oldday;
      $oldmonth=$newmonth; $oldyear=$newyear;$oldday=$newday;
      $oldmon=$newmon;      
      $oldmon2=$newmon2;  
      $first=0;    
    }
        echo "</td></tr></table>";
    if ($list_of_files!="") {
    sort($list_of_files,SORT_NUMERIC);
    sort($list_of_files);
    reset($list_of_files);

    while (list ($key, $file) = each ($list_of_files)) 
    {
       unset($innleggovers);
       unset($musikk);
       unset($babybox);
       unset($husbox);
       unset($hundbox);
       unset($strikkingbox);
        unset($familiebox);
        unset($bilbox);
        unset($bokbox);
        unset($weightbox);
        unset($laptopbox);
        unset($matbox);
        unset($oppskriftbox);
        unset($scubabox);   
        unset($vinbox);
        unset($tegneseriebox);
        unset($vacuumbox);
        unset($webbox);
        unset($bursdagbox);
        unset($filosofibox);
        unset($gravidbox);
        unset($helsebox);
        unset($julbox);
        unset($toddlerbox);
        unset($efitbox); 
//       $sted="";$vaer="";$gjorDE="";$middag="";$overs="";
       include "dager/$file";
    }
    ?>
      <h2>
         <? echo $overs;?>
      </h2>
         <table>
           <? $gravdagnr=date("z",strtotime($year."-".$mon."-".$day));
	    if ($year==2003 && $gravdagnr>8 && $gravdagnr<289	) {
             $gravdagnr=date("z",strtotime($year."-".$mon."-".$day));
             $gravstart=8; 
             $gravdagnr-=$gravstart;
             $gravweek=ceil($gravdagnr / 7);
             $gravdag=$gravdagnr % 7;
             $gravweek2=$gravweek-1;
             $gravdag2=$gravdag; 
             if ($gravdag2==0) {$gravdag2=0; $gravweek2+=1;};
//             if ($gravdag2==-1) {$gravdag2=6;};
             ?>
             <tr><td>Magen: </td><td>Nå i <?=$gravweek?>. 
uke 
(<?=$gravweek2?>+<?=$gravdag2?>) </a></td></tr>
           <? } 
            if (($year==2004 && $gravdagnr>145) ||($year==2005 && $gravdagnr<56)   ) 
            {
             $gravdagnr=date("z",strtotime($year."-".$mon."-".$day));
             $gravstart=130;
             $gravdagnr-=$gravstart;
if ($gravdagnr<0) $gravdagnr=366+$gravdagnr;
             $gravweek=ceil($gravdagnr / 7);
             $gravdag=$gravdagnr % 7;
             $gravweek2=$gravweek-1;
             $gravdag2=$gravdag;
             if ($gravdag2==0) {$gravdag2=0; $gravweek2+=1;};
//             if ($gravdag2==-1) {$gravdag2=6;};
$lilydate=strtotime("14 february 2005");
$nowdate=strtotime("today");
$daydate=mktime(0,0,0,$mon, $day,$year);
//echo "daydatE ". date("ymd",$daydate); 
//echo "nowdate ". date("ymd",$nowdate);
//echo "lilydate". date("ymd",$lilydate);
//echo "$day $mon $year";
$lilyday=date("ymd",$lilydate-$daydate+$nowdate);

             ?>
             <tr><td>Magen: </td><td>Nå i <?=$gravweek?>.
uke
(<?=$gravweek2?>+<?=$gravdag2?>) </td><td><img 
src="http://lilypie.com/days/<?=$lilyday?>/2/7/1/+1" alt="Lilypie Baby Days" 
border="0" /></td></tr>
           <?  } 
if (($year==2010) && $gravdagnr>10 && $gravdagnr<257) 
{
  $gravstart=-23;
  $gravdagnr -=$gravstart;
  $gravweek=ceil($gravdagnr / 7);
  $gravdag=$gravdagnr % 7;
  $gravweek2=$gravweek-1;
  $gravdag2=$gravdag;
  if ($gravdag2==0) {$gravdag2=0; $gravweek2+=1;};
  
  $lilydate=strtotime("15 september 2010");
  $nowdate=strtotime("today");
  $daydate=mktime(0,0,0,$mon, $day,$year);
  $lilyday=date("ymd",$lilydate-$daydate+$nowdate);

             ?>
             <tr><td>Magen: </td><td>Nå i <?=$gravweek?>.
uke
(<?=$gravweek2?>+<?=$gravdag2?>) </td><td><img
src="http://lilypie.com/days/<?=$lilyday?>/2/7/1/+1" alt="Lilypie Baby Days"
border="0" /></td></tr>
<?
}


            if ($sted!="") {?>
             <tr><td>Sted: </td><td><? echo $sted; ?></td></tr>
           <? } ?>
           <? if ($vaer!="") {?>
             <tr><td>Vær: </td><td><? echo $vaer; ?></td></tr>
           <? } ?>
           <? if ($gjorde!="") {?>
             <tr><td>Gjorde: </td><td><? echo $gjorde; ?></td></tr>
           <? } ?>
           <? if ($middag!="") {?>
             <tr><td>Middag: </td><td><? echo $middag; ?></td></tr>
           <? } ?>
         </table>
    <table border=1 width="100%"><tr><td>
    <?
    $olduser="ikkenoen";
    reset($list_of_files);
    while (list ($key, $file) = each ($list_of_files)) 
    {
      unset($innleggovers);
      unset($musikk);
       unset($babybox);
       unset($husbox);
       unset($hundbox);
       unset($strikkingbox);
        unset($familiebox);
        unset($bilbox);
        unset($bokbox);
        unset($weightbox);
        unset($laptopbox);
        unset($matbox);
        unset($oppskriftbox);
        unset($scubabox);   
        unset($vinbox);
        unset($tegneseriebox);
        unset($vacuumbox);
        unset($webbox);
        unset($bursdagbox);
        unset($filosofibox);
        unset($gravidbox);
        unset($helsebox);
        unset($julbox);
        unset($toddlerbox);
        unset($efitbox);
//            $sted="";$vaer="";$gjorde="";$middag="";$overs="";
            include "dager/$file";
            if ($olduser!=$user)

      {
/*           if (filesize("dager/$file"."-txt")!=0)*/
{         echo " </td></tr><tr><td ";
         if ($user=="Marius")
           echo  " bgcolor=\"#bbbbff\">";
         if ($user=="Kaja")
           echo " bgcolor=\"#FFbbbb\">";
         echo "<h3>$user: </h3>";
}
         $bname="dagbok-".$year."-".$mon."-".$day."-".$user;
         if (file_exists("bilder/".$bname.".gif"))
         {
           echo "<a href=\"bilder/$bname.gif\"><img 
src=\"image.php3?ysize=90&file=bilder/$bname.gif\"
                 height=90 align=right></a>";
         } else
         {
           if (file_exists("bilder/".$bname.".jpg"))
             echo "<a href=\"bilder/bilde.php3?img=$bname.jpg\"><img 
src=\"image.php3?ysize=90&file=bilder/$bname.jpg\"
                 height=90 align=right></a>";
         }
       }


           $olduser=$user;
           if (filesize("dager/$file"."-txt")!=0)
         {

          if ($babybox=="on") {echo"<img src=IkonBaby.gif alt=\"Dette innlegget handler om baby\">";}
          if ($husbox=="on") {echo"<img src=IkonHus.gif alt=\"Dette innlegget handler om husjakt -kjøp, 
-salg, flytting\">";}
          if ($hundbox=="on") {echo"<img src=IkonHund.gif alt=\"Dette innlegget handler om hund\">";}
          if ($strikkingbox=="on") {echo"<img src=IkonStrikking.gif alt=\"Dette innlegget 
handler om h&aring;ndarbeid\">";}
          if ($familiebox=="on") {echo"<img src=Ikonfamilie.gif alt=\"Dette innlegget handler om familie\">";}
          if ($bilbox=="on") {echo"<img src=Ikonbil.gif alt=\"Dette innlegget handler om bil\">";}
          if ($bokbox=="on") {echo"<img src=Ikonbok.gif alt=\"Dette innlegget handler om bøker\">";}
          if ($weightbox=="on") {echo"<img src=IkonWeightWatcher.gif alt=\"Dette innlegget handler om 
slankekur\">";}
          if ($laptopbox=="on") {echo"<img src=IkonLaptop.gif alt=\"Dette innlegget handler om data-ting\">";}
          if ($matbox=="on") {echo"<img src=IkonMat.gif alt=\"Dette innlegget handler om mat\">";}
          if ($oppskriftbox=="on") {echo"<img src=IkonOppskrift.gif alt=\"Dette innlegget inneholder en 
oppskrift\">";}
          if ($scubabox=="on") {echo"<img src=Ikonscuba.gif alt=\"Dette innlegget handler om dykking\">";}
          if ($vinbox=="on") {echo"<img src=Ikonvin.gif alt=\"Dette innlegget handel om vin\">";}
          if ($tegneseriebox=="on") {echo"<img src=IkonTegneserie.gif alt=\"Dette innlegget handler om 
tegneserier\">";}
          if ($vacuumbox=="on") {echo"<img src=IkonVacuum.gif alt=\"Dette innlegget hander om husarbeid\">";}
          if ($webbox=="on") {echo"<img src=IkonWeb.gif alt=\"Dette innlegget inneholder URL(er)\">";}
          if ($bursdagbox=="on") {echo"<img src=IkonBursdag.jpg alt=\"Dette innlegget inneholder 
bursdagsgratulasjon\">";}
          if ($filosofibox=="on") {echo"<img src=Ikonphilosophy.gif alt=\"Dette innlegget hander om Kajas studier.\"
>";}
if ($gravidbox=="on") {echo"<img src=Ikongravid.jpg alt=\"Dette innlegget hander om graviditet.\"
>";}
if ($helsebox=="on") {echo"<img src=Ikonhelse.jpg alt=\"Dette innlegget hander om helse.\"
>";}
if ($julbox=="on") {echo"<img src=Ikonjul.jpg alt=\"Dette innlegget hander om jul.\"
>";}
if ($toddlerbox=="on") {echo"<img src=Ikontoddler.jpg alt=\"Dette innlegget hander om barn.\"
>";}
if ($efitbox=="on") {echo"<img src=IkonEfit.jpG alt=\"Dette  er et EFIT innlegg\"
><br><a href=http://www.evang.no/dagbok-admin/efit.php3>Andre EFIT-dager</a>";}

 echo "<h3>".$innleggovers."</h3>";
// +++++
  $bname="dagbok-".$year."-".$mon."-".$day."-".$user."-".$nr;
  unset(   $list_of_bilde_files);
  if ($dir = @opendir("bilder")) 
    while (($bfile = readdir($dir)) !== false) 
    {
      if ($bfile!="." && $bfile!="..")
        if (substr($bfile,0,strlen($bname))==$bname)
        {
          $list_of_bilde_files[] = $bfile;
//          echo "<a href=\"bilder/bilde.php3?img=$bfile\"><img 
//src=\"image.php3?ysize=90&file=bilder/$bfile\"
//                 height=90 align=right ";
//          $alt="";
//          @include "bildetekst/".$bfile.".inc";
//          echo "alt=\"$alt\"></a>";

        }  
    }
      
    closedir($dir);
    @reset($list_of_bilde_files);
    @rsort($list_of_bilde_files);
//$list_of_bilde_files=array_reverse($list_of_bilde_files);

    while (list ($key, $bfile) = @each ($list_of_bilde_files))
    {
          $alt="";
          @include "bildetekst/".$bfile.".inc";
          $ysize=90;
          if ($size>90) $ysize=$size;
          echo "<a href=\"bilder/bilde.php3?img=$bfile\"><img 
src=\"image.php3?ysize=$ysize&file=bilder/$bfile\"
                 height=$ysize align=right ";
          echo "alt=\"$alt\"></a>";
    }
// -----
/*         
$bname="bilder/dagbok-".$year."-".$mon."-".$day."-".$user."-".$nr;
         if (file_exists($bname.".gif"))
         {
           echo "<a href=\"$bname.gif\"><img 
src=\"image.php3?ysize=90&file=$bname.gif\"
                 height=90 align=right></a>";
         } else
         {
           if (file_exists($bname.".jpg"))
             echo "<a href=\"$bname.jpg\"><img 
src=\"image.php3?ysize=90&file=$bname.jpg\"
                 height=90 align=right></a>";
         }*/
// -----
           if (filesize("dager/$file"."-txt")!=0)
{
           ob_start();
           readfile("dager/$file"."-txt");
           $out=ob_get_contents();
           ob_end_clean();
	   if (strstr($out,"Ã")!=FALSE)
           echo utf8_decode($out); else echo $out;
           if ($musikk!="") echo "<br><br><i><b>Musikk</b>&nbsp;&nbsp; ".$musikk."</i>";
           echo "<hr></td></tr><tr><td"; 
 if ($user=="Marius")
           echo  " bgcolor=\"#bbbbff\">";
         if ($user=="Kaja")
           echo " bgcolor=\"#FFbbbb\">";

echo "<font color=\"#000000\">"; }
}
         }
echo "</td></tr>";


    }else{echo "Det finnes ingenting for denne dagen";}
echo "</table>";
}
//kommentarer
$first=1;
   { echo "<a href=\"http://www.evang.no/dagbok/kommentar.php3?year=$year&month=$month&day=$day\">
          Legg til kommentar</a>";
   }

  $fname=sprintf("dagbok-%s-%s-%s", $year, $mon, $day);
  if ($dir = @opendir("kommentar")) 
    {
    while (($file = readdir($dir)) !== false) {
      if ($file!="." && $file!="..")
      {
        if (substr($file,0,strlen($fname))==$fname)
        {
           $list_of_komment_files[] = $file;
        }  
      }  
    }
   }
    closedir($dir);
    if ($list_of_komment_files!="") {
      sort($list_of_komment_files);
      reset($list_of_komment_files);
      while (list ($key, $file) = each ($list_of_komment_files)) 
      {
        if ($first==1)
        {
          echo "<br><br><h3>Kommentarer til siden: </h3><font size=\"-1\">\n";
          $first=0;
        }
        if (filesize("kommentar/$file")!=0)
         {
           readfile("kommentar/".$file);
           echo " (".date("H:i j/n-y",filemtime("kommentar/".$file)).")";
         }
      }
   }

?>
