<?php header('Content-Type: text/html; charset=windows-1251'); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<META http-equiv=Content-Type content="text/html; charset=windows-1251">
<html>
<head>
</head>
<body style="background:#fffacd">
<form id=feg  method="POST" enctype="multipart/form-data" action="eg.php" style="position:absolute;top:0;left:0;width:100%">

<b id=ppas style="color:#316290">Password&nbsp;&nbsp;
<input type="password" name="eg_pass" size="10" value="<?php  echo $_REQUEST['eg_pass'];?>"></b>
<input name=eg0 type="button" style="background:#c0c0c0;color:yellow;display:none" onclick=eg_v(0) title="Get records" value="V">
<input name=eg1 type="button" style="background:#c0c0c0;color:yellow;display:none" onclick=eg_v(1) title="Get record" value=" ? ">
<input name=eg_red type="button" style="background:#c0c0c0;FONT-WEIGHT: bold" onclick=eg_v(2) title="Edit record" value="Edit">
<input name=eg_sav  type="button" style="background:#c0c0c0;FONT-WEIGHT: bold;display:none" onclick=eg_v(3) title="Save" value="Save">
<input name=eg_open   type="button" style="background:#c0c0c0;FONT-WEIGHT: bold;" onclick=eg_v(5) title="Open in big window" value="Open">
<input type="hidden" name=eg_m value="<?php echo $_REQUEST['eg_m']; ?>">
<input type="hidden" name=eg_tip value="<?php echo $_REQUEST['eg_tip']; ?>">
<input type="submit" value="send" name="eg_sub" style="width:50px;background:transparent;visibility:hidden"> 
<div id=eg_sz style="overflow:scroll;HEIGHT:190px"  width=80%>
<?php
if (isset($_REQUEST['eg_tip']))    // 
{$egtip=$_REQUEST['eg_tip'];}
else
{$egtip="";die("No request type.");}
$l = file(getcwd ( ).'/p.html'); 	//
foreach ($l as $li => $lin)         //
{if ($li==0)                        //
{$pass=$lin;}}
if ($pass=="")
{echo "NO PASSWORD!";die;}
if (isset($_REQUEST['eg_pass']))   // 
{$pass1=trim($_REQUEST['eg_pass']);}

if ($pass==md5("1",false) or (strlen($pass)<32 and $egtip!=3))        //
{$pp=true;}
else
{$pass1=md5($pass1,false);        // 
if (strlen($pass)==32)            // 
{}
else                              // 
{$pass1=substr($pass1,3);}
if (trim($pass1) == trim($pass)) 
{
$pp=true;
}
else
{
if (trim($_REQUEST['eg_pass'])!="")
{echo "ENTER THE CORRECT PASSWORD!";$pp=false;}
else
{
if ($egtip==3) 
{echo "Enter your password to edit!";$pp=false;}
else
{echo "To access, enter the password!";$pp=false;}
}
}}
if ($pp)
{
if (isset($_REQUEST['eg_m']))   //  
{$m=$_REQUEST['eg_m'];}
else
{$m="";die("There is no parameter m (date).");}
list($egd, $egm,$egg) = explode(".",$m);  // 

//***********************
// 
//***********************
if ($egtip==0)
{$l = file(getcwd ( ).'/'.$egm.'.html'); 	//
foreach ($l as $li => $lin9)                //
{
if ($li==0)
{
echo '<textarea name="eghtml" rows=8  id=eg_e style="background:#e0ffff;width:95%;OVERFLOW: scroll;height:165;display:none"></textarea>';
$egstr=trim($lin9);
list($qw,$rw2)=explode('<b>',$egstr); 
list($qw2,$rw3)=explode('</b>',$rw2); 
$rw2=str_replace("\r",'',$qw2);
$rw2=str_replace("\n",'',$rw2);
$rw2=str_replace("*",' ',$rw2);
$egstr=str_replace("*","All dates ",$egstr);
echo $egstr;   
}
else
{
//
echo "<b style='background:#4682b4;color:white'>".$li." ".$rw2.":</b><br>".trim($lin9)."<hr>";

}}
}
//***********************************
// 
//***********************************
if ($egtip==1)
{

$l = file(getcwd ( ).'/'.$egm.'.html'); 	// 
foreach ($l as $li => $lin)                 //
{
if ($li==0)
{
$egstr=trim($lin);
$egstr=str_replace("*",$egd." ",$egstr);
echo $egstr;   
}
if ($li==$egd)
{
$egstr=trim($lin);
echo '<textarea name="eghtml" rows=8  id=eg_e style="background:#e0ffff;width:95%;OVERFLOW: scroll;height:165;display:none">';
echo $egstr;   
echo '</textarea>'."\r\n";
echo $egstr;   
break;
}
}
}
//*************************************
// 
//*************************************
if ($egtip==3)
{
// 
if (isset ($_REQUEST['eghtml'])) 
{
$tex=stripslashes ($_REQUEST['eghtml']);
}
else
{$tex="";}
$tex=str_replace("\r\n","",$tex);
$l = file(getcwd ( ).'/'.$egm.'.html'); 	            // 
$w = fopen(getcwd ( ).'/'.$egm.'.html',"w") or exit; 	// 
 foreach ($l as $li => $lin)                            // 
 {
  if ($li==$egd)     //
  {
  fwrite($w,$tex."\r\n");
  }
  else               
  { fwrite($w,$lin); } //
  } 
    fclose($w);
$l = file(getcwd ( ).'/'.$egm.'.html'); 	//
foreach ($l as $li => $lin)                 //
{
if ($li==0)
{
$egstr=trim($lin);
$egstr=str_replace("*",$egd." ",$egstr);
echo $egstr;   
}
if ($li==$egd)
{
$egstr=trim($lin);
echo '<textarea name="eghtml" rows=8  id=eg_e style="background:#e0ffff;width:95%;OVERFLOW: scroll;height:165;display:none">';
echo $egstr;   
echo '</textarea>'."\r\n";
echo $egstr;   
}}}
}
?>
</div>
</form>
</body>
<script type="text/javascript">
rewscr=0
function eg_v(p)
{
//***************************
// 
//***************************
if (p==0)
{
window.top.document.getElementById('cbgip').style.visibility="hidden"
window.top.document.getElementById('gip12').style.visibility="hidden"
window.top.document.getElementById('gip10').style.visibility="hidden"
feg.elements["eg_m"].value=window.top.document.getElementById('eg_td1').title
feg.elements["eg_tip"].value="0"   // 
feg.elements["eg_sub"].click()     //
}
if (p==1)
{
//************************
//
//************************
feg.elements["eg_m"].value=window.top.document.getElementById('eg_td1').title
feg.elements["eg_tip"].value="1"   // 
feg.elements["eg_sub"].click()     // 
}
if (p==2)
//************************
// 
//************************
{
if (document.all["eg_e"]!=undefined) 
{
document.getElementById('eg_sz').scrollTop=0
feg.elements["eg_sav"].style.display=""
feg.elements["eghtml"].style.display=""
feg.elements["eg_tip"].value="2"
}
else
{alert("No date selected!");}
}
if (p==3)
{
//************************
// 
//************************
if (document.all["eg_e"]!=undefined) 
{
if (feg.elements["eghtml"].style.display=="none")
{alert("Save only after editing!");}else{
feg.elements["eg_m"].value=window.top.document.getElementById('eg_td1').title
feg.elements["eg_tip"].value="3"   // 
feg.elements["eg_sub"].click()     // 
}}
else
{alert("No date selected!")}
}
if (p==5)
{
if (document.all["eg_e"]==undefined) return;
if (window.top.mob)    // 
{
window.top.knn=window.top.document.getElementById('bod').scrollTop
window.top.document.getElementById('bod').scrollTop=0
window.top.document.getElementById('zii').style.top=0
window.top.document.getElementById('zip').style.top=0
window.top.document.getElementById('gii').style.top=0
window.top.document.getElementById('gip').style.top=0
}
//
if (document.all["eg_e"]!=undefined && document.getElementById('eg_e').style.display=="")  //
{
window.top.document.getElementById('giiza').innerHTML=feg.elements["eg_m"].value;
window.top.document.getElementById('gii').style.display="";  //
window.top.document.getElementById('ppp').style.visibility="visible";
window.top.document.getElementById('giir').value=document.getElementById('eg_e').value;
window.top.document.getElementById('but').click()
}
else
{
if (feg.elements["eg_tip"].value==0)   //
{
window.top.document.getElementById('cbgip').style.visibility="hidden"
window.top.document.getElementById('gip12').style.visibility="hidden"
window.top.document.getElementById('gip10').style.visibility="hidden"
window.top.document.getElementById('gip').style.display="";  //
window.top.document.getElementById('ppp').style.visibility="visible";
if (window.top.document.getElementById('gip1').innerHTML=document.getElementById('eg_sz')!=undefined) 
{window.top.document.getElementById('gip1').innerHTML=document.getElementById('eg_sz').innerHTML;
window.top.document.getElementById('tde').innerHTML=document.getElementById('eg_sz').getElementsByTagName("B")[0].innerHTML
}
}
if (feg.elements["eg_tip"].value==1 || feg.elements["eg_tip"].value==3)  //
{
window.top.document.getElementById('cbgip').style.visibility="visible"
window.top.document.getElementById('gip12').style.visibility="visible"
window.top.document.getElementById('gip10').style.visibility="visible"
window.top.document.getElementById('gip').style.display="";  //
window.top.document.getElementById('ppp').style.visibility="visible";
if (window.top.document.getElementById('gip1').innerHTML=document.getElementById('eg_sz')!=undefined) 
{
window.top.document.getElementById('gip1').innerHTML=document.getElementById('eg_sz').innerHTML;
window.top.document.getElementById('tde').innerHTML=document.getElementById('eg_sz').getElementsByTagName("B")[0].innerHTML
}
}
}
}
}

//********************************************
//  
window.onload=function ()
{<?php
if ($pass==md5("1",false))        // 
{echo 'document.getElementById("ppas").style.display="none";';}
if ($egtip==0)
{echo 'feg.elements["eg_red"].style.display="none";';}
?>

}
</script>

<body></html>
