<?php header('Content-Type: text/html; charset=windows-1251');
header('X-XSS-Protection: 1'); 
 ?>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>Uploading documents, creating external pages, databases</title>
<style>
b {color:#316290;}
td {color:#316290;font-family:tahoma;font-size:12px;font-weight:normal;}
th {color:#316290;font-family:tahoma;font-size:12px;font-weight:bold;}
a {color:#254A6C;font-family:tahoma;font-size:12px;font-weight:normal;}
.redlink {color:#B92327;font-family:tahoma;font-size:11px;font-weight:normal;}
.bluelink {color:#254A6C;font-family:tahoma;font-size:11px;font-weight:normal;}
a:hover {color:white;font-family:tahoma;font-size:12px;font-weight:normal;background:black}
</style>
</head>
<?PHP
//--------------
include "f.php";   //  
//--------------
if (file_exists(getcwd ( )."/otd/2.txt"))
{echo '<body leftMargin=0 id=bod topMargin=0  style="overflow:hidden;background:silver;">';
echo '<table id=monoz  border=0 style="width:100%;height:100%;
z-index:3;position:absolute;top:0px;left:0px;">
<tr ><td width=30%>&nbsp;</td><td width=30%  valign=center align=center>
<table border=0 width=400 style="background:white" >
<tr><td><IMG height=60 border=0 src="d~e~f/pas.jpg"></td>
<td  height=30px ><center><b style="color:red" >ATTENTION !'.
'</b></center><br>
<ol>
<li> THE ADMINISTRATOR closed the site to carry out work on its reorganization!
<li> The site will be available after completion of work!
<li> For information, contact your ADMINISTRATOR!
<li> Close site
<li> Check back later!</ol>
</td></tr>
</table>
</td><td width=30%>&nbsp;</td></tr></table></body></html>';
die;
}
?>
<body leftMargin=0 id=bod topMargin=0  onkeydown=kc(event.keyCode)  id=bod background="d~e~f/bkg4.gif" 
style="overflow:hidden;visibility:hidden"> 
<div id=ppp style="z-index:2;opacity:0.3;visibility:hidden;height:100%;width:100%;position:absolute;top:0;left:0;background:black;filter:alpha(opacity=30)"><h1 style="color:red;text-align:right">WAIT...</h1></div>
<TABLE id=cal1 style="position:absolute;top:40%;left:0;background:white;display:none" border=2 bordercolor="orange" >
<CAPTION style="BACKGROUND: #808080; COLOR: white">
<Big>THE CALENDAR</Big>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<button form="" title="hide" onclick="document.getElementById('cal1').style.display='none';">&nbsp;x&nbsp;</button>
</CAPTION>
<THEAD>
<TR style="BACKGROUND: silver; COLOR: white">
<TH onclick="cal3(2)">
<B>
<BUTTON form="" style="WIDTH: 40px; BACKGROUND: #808080; COLOR: white">«y</BUTTON>
</B>
</TH>
<TH onclick="cal3(4)">
<BUTTON form="" style="WIDTH: 40px; BACKGROUND: #808080; COLOR: white">«m</BUTTON>
</TH>
<TH style="WIDTH: 180px; BACKGROUND: #808080; COLOR: white" id=cal2_td colSpan=3 onclick="cal3(0)">
</TH>
<TH onclick="cal3(3)">
<BUTTON form="" style="WIDTH: 40px; BACKGROUND: #808080; COLOR: white">m»</BUTTON>
</TH>
<TH onclick="cal3(1)">
<BUTTON form="" style="WIDTH: 40px; BACKGROUND: #808080; COLOR: white">y»</BUTTON>
</TH>
</TR>
<TR style="BACKGROUND: silver; COLOR: black">
<TH style="WIDTH: 40px">Mon.</TH>
<TH style="WIDTH: 40px">Tue.</TH>
<TH style="WIDTH: 40px">Wed.</TH>
<TH style="WIDTH: 40px">Thu.</TH>
<TH style="WIDTH: 40px">Fri.</TH>
<TH style="WIDTH: 25px; BACKGROUND: #ffdead; COLOR: red;WIDTH: 40px">Sat.</TH>
<TH style="WIDTH: 25px; BACKGROUND: #ffdead; COLOR: red;WIDTH: 40px">San.</TH>
</TR>
</THEAD>
<TBODY id=cal2 onclick=zint(event)>
<TR>
<TD style="WIDTH: 40px">&nbsp;</TD>
<TD style="WIDTH: 40px">&nbsp;</TD>
<TD style="WIDTH: 40px">&nbsp;</TD>
<TD style="WIDTH: 40px">&nbsp;</TD>
<TD style="WIDTH: 40px">&nbsp;</TD>
<TD style="BACKGROUND: #ffdead; COLOR: red;WIDTH: 40px">&nbsp;</TD>
<TD style="BACKGROUND: #ffdead; COLOR: red;WIDTH: 40px">&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD style="BACKGROUND: #ffdead; COLOR: red">&nbsp;</TD>
<TD style="BACKGROUND: #ffdead; COLOR: red">&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD style="BACKGROUND: #ffdead; COLOR: red">&nbsp;</TD>
<TD style="BACKGROUND: #ffdead; COLOR: red">&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD style="BACKGROUND: #ffdead; COLOR: red">&nbsp;</TD>
<TD style="BACKGROUND: #ffdead; COLOR: red">&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD style="BACKGROUND: #ffdead; COLOR: red">&nbsp;</TD>
<TD style="BACKGROUND: #ffdead; COLOR: red">&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD style="BACKGROUND: #ffdead; COLOR: red">&nbsp;</TD>
<TD style="BACKGROUND: #ffdead; COLOR: red" id=cal2_td1>
&nbsp;</TD>
</TR>
</TBODY>
</TABLE><SCRIPT type="text/javascript">
//*********************************************************************
function zint(event) //
//*********************************************************************
{ev = event || window.event
var t5 = ev.target || ev.srcElement
if (t5.tagName=="TD")
{
mt5=t5.innerHTML.replace(/&nbsp;/g,"") 
if  (mt5=="") return
document.getElementById("d").value=mt5
mda5=document.getElementById("cal2_td").innerHTML.split(".")
document.getElementById("m").value=mda5[1]
document.getElementById("y").value=mda5[2].substr(2,2)
}
}
//***************************************************************************
function cal3(p)  // 
//***************************************************************************
{dat=new Date();
if (p==1)
{my=document.getElementById("cal2_td1").title.split(".");dat.setYear(parseInt(my[2])+1);}
if (p==2)
{my=document.getElementById("cal2_td1").title.split(".");dat.setYear(parseInt(my[2])-1);}
if (p==3)
{my=document.getElementById("cal2_td1").title.split(".");dat.setDate(1);
dat.setYear(parseInt(my[2]));
dat.setMonth(parseInt(my[1]));}
if (p==4)
{my=document.getElementById("cal2_td1").title.split(".");
dat.setDate(1);
dat.setYear(parseInt(my[2]));
dat.setMonth(parseInt(my[1])-2);}
if (p!=0)
{dat.setDate(1)}
var y="";
y=dat.getFullYear();
var m="";
m=dat.getMonth()+1;
var c="";
c=dat.getDate();
var d="";
d=dat.getDay();
var dp="";
dp=y+"-"+m+"-"+c+"-"+d;
dp1=c+"."+m+"."+y;
cc=c;mm=m;
if (parseInt(c)<10)
 {cc="0"+cc;}
if (parseInt(m)<10)
 {mm="0"+mm;}
dp11=cc+"."+mm+"."+y;
document.getElementById("cal2_td").innerHTML=dp11;
document.getElementById("cal2_td1").title=dp1;
dat.setDate(1);
na=dat.getDay()-1;
if (na<0) 
{na=6;}
mt5= document.getElementById("cal2").getElementsByTagName("TD")
k8=1;
lb="q,5,6,12,13,19,20,26,27,33,34,40,41,";
for(var ii=0; ii<mt5.length-4; ii++) 
{if (lb.indexOf(","+ii+",",0)>0)
{mt5[ii].style.background="#ffdead";
mt5[ii].style.color="red";
}
else
{mt5[ii].style.background="";
}
if (ii<na)
{mt5[ii].innerHTML="&nbsp;&nbsp;";}
else
{dat.setDate(k8);
if (m==dat.getMonth()+1)
{if (ii-na+1==c && p==0) 
{mt5[ii].style.background="red";
mt5[ii].style.color="black";}
if (k8<10)
{mk8="&nbsp;0"+k8}
else
{mk8="&nbsp;&nbsp;"+k8}
k8++
mt5[ii].innerHTML=mk8;}
else
{mt5[ii].innerHTML="&nbsp;&nbsp;";}
}}}
cal3(0)    //
</SCRIPT>


<?php 
if (isset ($_REQUEST['ext'])) 
{$ext=$_REQUEST['ext'];}  //
else
{$ext="";}
if (isset ($_GET['tip'])) 
{$tip=trim($_GET['tip']);}
else
{$tip=trim($_REQUEST['tip']);}
if (isset ($_GET['im'])) 
{$im=trim($_GET['im']);}
else
{$im=trim($_REQUEST['im']);}
$im1=$im;
$im=rtr($im);   // 
if (isset ($_GET['utf8'])) 
{$utf8=trim($_GET['utf8']);}
else
{$utf8=trim($_REQUEST['utf8']);}

if (isset ($_GET['fol'])) 
{$fol1=trim($_GET['fol']);}
else
{$fol1=trim($_REQUEST['fol']);}

if (isset ($_REQUEST['ggg'])) 
{$ggg=trim($_REQUEST['ggg']);}
else
{$ggg="";}

if (isset ($_REQUEST['pss2'])) 
{$pss2=trim($_REQUEST['pss2']);}
else
{$pss2="";}

if (isset ($_REQUEST['pss'])) 
{$pss=trim($_REQUEST['pss']);}
else
{$pss="";
}
$repo="";
if ($pss=="" and $pss2!="")
{$repo=$pss2." Refund from related!";
$pss2="";
}
else if ($pss!="" and $pss2!="")
{$repo=" Login related!";
}
if ($pss!="" and strpos($pss,"v")==0) {$pss=$pss."v";}
$fol=$fol1.'/contents';
$os="";
//********************************************************************************************
//                          
//*********************************************************************************************
if (isset ($_REQUEST['st5'])) 
{$num=$_REQUEST['num'];
$ms="s";                           //
if (substr($num, 0,3 ) =="000")    //
{$ms="s3";}
else
{if (substr($num, 0,2 ) =="00")   // 
{$ms="s2";}
else
{if (substr($num, 0,1 ) =="0")    // 
{$ms="s1";}
}}
$isp=getcwd().'/sampl/'.$ms;         //
if  (file_exists ($isp)) {full_del_dir ($isp);} 
mkdir($isp);			          //
dircpy('',getcwd().'/pages/'.$_REQUEST['href'],getcwd().'/sampl/'.$ms.'/',false);
$ispp=trim($_REQUEST['olda']);  // 
$ispp=tr($ispp);                // 
rename(getcwd().'/sampl/'.$ms.'/'.$ispp.'/',getcwd().'/sampl/'.$ms.'/'.$ms.'/');	 
$repo=rtr($ispp)." Template SAVED!";
}
//*********************************************************************************************
if (isset ($_REQUEST['kar']))                       //  
//*********************************************************************************************
{
//-----------------------------------------------------------------------
// IF  [$im1]0.php [$im]-card-file.php NO
//---------------------------------------------------------------------
//  [$im1].php -> [$im1]0.php
// kar-> [$im1] 
//  ~~~~kar -> [$im1]  kar.php
//---------------------------------------------------------------------------
//  
//-------------------------------------------------------------------------
//  [$im1].php ->[$im1]00.php
//  [$im1]0.php ->[$im1].php
//  [$im1]00.php ->[$im1]0.php
// 
 if (empty($_REQUEST['num']) or empty($_REQUEST['tex']) or empty($_REQUEST['oldi']))   //
  {$os='No row selected! Click it and repeat!';
  }
else
{$isf=trim($_REQUEST['oldi']); //
$isf=str_replace (" ","_",$isf);	
$isp=trim($_REQUEST['olda']); // 
$isp=tr($isp);                // 
$isf=tr($isf);                // 
$nf=getcwd().'/pages/'.$fol.'/'.$isp."/";
$isfp=$nf.$isf."0.php";  
$isfp1=$nf.$isf."-card-file.php";  
$isfp2=$nf.$isf."00.php";  
$isfp3=$nf.$isf.".php";  
if (file_exists ($nf.$isf.".htm"))
{$ll = file($nf.$isf.".htm");                // 
foreach ($ll as $lli => $llin)               // 
{
$llin=str_replace ('id="eg"',"id=eg",$llin);
$llin=str_replace ('id="zk"',"id=zk",$llin);
if (strstr($llin,"id=eg")  or  strstr($llin,"id=zk"))   // 
{
$os=rtr($isp)." <b style=color:red> contains a diary and / or a note, this is not allowed for card files!</b>";
break;}}






if ($os=="")
{if (file_exists ($isfp) and file_exists ($isfp1))  //
{$ll = file($isfp3); 			                    //
 foreach ($ll as $lli => $llin)                     //
 {if (strpos(" ".$llin,"<html>")>0)                 //
 {$repo= rtr($isp)." The card file has been converted to a page!";
break;}
else
{$repo=rtr($isp)." The page has been converted to a card file!";
}}
 //  
rename($isfp3, $isfp2);	  // 
rename($isfp, $isfp3);	  // 
rename($isfp2, $isfp);	  // 
unlink ($isfp);  
unlink ($isfp1);  
}
else                          // 
{if (copy(getcwd().'/sampl/kar1.php',$nf."kar1.php"))
{} else {$os="Error while copying file kar1.php";}
if (copy(getcwd().'/sampl/kar.php',$nf."kar.php"))
{} else {$os="Error while copying file kar.php";}
if ($os=="")
{$fi=$nf."kar.php";
 $l = file($fi); 			          //
$w = fopen($fi, 'w') or exit;  	      //
 $tc="~~~~kar";
 $tc1="kol=1";
 foreach ($l as $li => $lin)               //
 { if (strpos($lin,$tc)>0)                 //
  {fwrite($w,str_replace ($tc,$isf,$lin));
 }
  else
  {fwrite($w,$lin);                   //
  }} 
  fclose($w);
  rename($isfp3, $isfp);	          //
  rename($nf."kar.php", $isfp3);	  //
  rename($nf."kar1.php", $isfp1);	  //
  $repo=rtr($isp).' The card file has been formed!';
}}}}
else
{  $repo=rtr($isp)." <b style=color:red> this OBJECT cannot be card files!</b>".file_exists ($nf.$isf.".htm")."+++";}
}}
//********************************************************************************************
if (isset ($_REQUEST['zag']))                            //
//********************************************************************************************
{if (empty($_REQUEST['num']) or empty($_REQUEST['tex']) or !isset($_FILES['filename']['name']) )   //
  {$os= 'An error occurred while trying to create an object - all data was not entered. Come back fill in all the fields and repeat!';
 }
else
{$ki=$_REQUEST['num'].$_REQUEST['tex'];
$ndps=ktex($ki);
if ($ndps<>"")
{$os='Remove  "'.$ndps.'" From Number = '.$_REQUEST['num'].' or from Name = '.$_REQUEST['tex'];
}
else
{if (is_uploaded_file($_FILES['filename']['tmp_name']))
{if ($utf8!="")
{if (isset($_FILES['filename']['name']))
{if (strpos(strtoupper($_FILES['filename']['name']),".HTM")>0)		//
{$s = file_get_contents ($_FILES["filename"]["tmp_name"]);} 	    //
else
{$s="";}
if (strpos(strtoupper($s),"<SCRIPT")>0)
{$os="The document page could not be loaded! Remove scripts and other functionality from the page and repeat!"; }
else                                             //
{$kat=getcwd();		    		 				 //
$fn="";
$katw= getcwd().'/pages/'.$fol.'/contents/';
if ($_FILES['filename']['error']==0)			 //
 {$fn=$_FILES['filename']['name']; 				 //
  $l = file($kat."/otd/new.txt");     				 // 
  $ok=FALSE;
  for ($i = 1;$i<count($l); $i++)	// 
   {if (substr_count($fn,trim($l[$i]))>0 )  	 //
    {$ok=TRUE;  break;}}
    if ($ok)  		 										   //
    {if (empty($_REQUEST['num']) or empty($_REQUEST['tex']))   //
     {$os= 'All data has not been entered. Come back fill in all the fields and repeat! You do not know the date, enter the current one, do not know the number, enter - no.';  }
     else    														 //
     {$datw= $_REQUEST['d'].",".$_REQUEST['m'].",".$_REQUEST['y'];   //
      $ip=substr($_REQUEST['num'],0,12);  //
      $ip=str_replace ("/","",$ip);	  // 
      $ip=str_replace ("\\","",$ip); $ip=str_replace ("*","",$ip);	              
      $ip=str_replace ("?","",$ip);  $ip=str_replace ("#","",$ip);	              
      $ip=str_replace ("<","",$ip);  $ip=str_replace (">","",$ip);	              
      $ip=str_replace ("|","",$ip);  $ip=str_replace (":","",$ip);$ip=str_replace (" ","_",$ip);
	     $ks=ktex($_REQUEST['num'].$_REQUEST['tex']);
   if ($ks<>"")
   {
$repo= 'Remove "'.$ks.'" From Number = '.$_REQUEST['num'].' or from Name = '.$_REQUEST['tex'];
   } 
   else
   {  $ip=tr($ip);
	  $ip1=$datw.'_'.$ip;
      $ii=substr($_REQUEST['tex'],0,120);  //
      $ii=str_replace (".","",$ii);	   //
      $ii=str_replace ("/","",$ii); $ii=str_replace ("\\","",$ii);
      $ii=str_replace ("*","",$ii); $ii=str_replace ("?","",$ii);
      $ii=str_replace ("#","",$ii); $ii=str_replace ("<","",$ii);
      $ii=str_replace (">","",$ii); $ii=str_replace ("|","",$ii);
      $ii=str_replace (":","",$ii); $ii=str_replace ("$","",$ii);$ii=str_replace (" ","_",$ii);
      $ii=trim($ii);	              
      $ii=tr($ii);	              
	  $if=getcwd().'/pages/'.$fol1.'/contents/'.$ip.'/'.$ii.trim($l[$i]);  	// 
	  $ip=getcwd().'/pages/'.$fol1.'/contents/'.$ip1;
      if (file_exists ($ip) and  !isset($_REQUEST['pov']))    	    
       {$repo=rtr($ip1).' already on the page! Come back change the data and repeat. <br>
                To reload, check the "retry" box ';}
	   else
	    {if  (file_exists ($ip)) {full_del_dir (wu($ip,$utf8));} 
        mkdir($ip);				//
		if (strpos($fn,'.htm')>0)  		//
		{$ipp=$ip.'/'.$ip1;    			//
		 $if=$ipp.'/'.$ii.trim($l[$i]); //
		 mkdir($ipp); 					//
	     if (copy($_FILES["filename"]["tmp_name"],wu($if,$utf8)))       	//
         {$repo=rtr($ip1).' Object loaded!';
//-----------------------
include "fzag.php";   //  
//----------------------
		 }
         else
         {$os= "Error loading object! Contact the developer!";}
       }
	   else                             //
	   {$if=$ip.'/'.$ii.trim($l[$i]);  	//
	   if (copy($_FILES["filename"]["tmp_name"],wu($if,$utf8)))       	// 
         {$repo=rtr($ip1).' Object loaded!';}
         else
         {$os= "Error loading object! Contact the developer!";}
	   }}}}}
    else
    {$os='Invalid extension type for the selected file. Come back select a file with a valid extension and repeat!';
    }
   }  //
   else
   {$os='The file to download is not defined, or the download failed. Come back select the file and repeat!';
   } 
if ($os=="")  //
{if ($s!="")  //
{$repo=$repo.' additional loading of pictures is required';}
else
{if ($_GET['tip']=="docum.htm")
{echo '<b></b>';}	 //
elseif ($_GET['tip']=="new.htm")
{echo '<b></b>';}
elseif ($_GET['tip']=="dokl.htm")
{echo '<b></b>';}
}}}}
else {$os= "Unauthorized start of loading objects! Loading is not possible!";}
}}
else
{$os='The size of the downloaded file is over 2 MB! Make it smaller and repeat!';}
}}}
//***********************************************************************************************************************************
if (isset ($_REQUEST['del']))                  // 
//**********************************************************************************************************************************
{if ($_REQUEST['npp']!=0)
  {$katw= getcwd ( ). '/pages/'.$fol.'/';	   // 
  $katw=str_replace ("\\","/",$katw);
  $isp=trim($_REQUEST['olda']);                // 
  $isf=trim($_REQUEST['oldi']);                // 
  $isp=tr($isp);                               // 
  $isf=tr($isf);                               // 
  $old=$isp."_".$isf;                          //
  $isp=stripslashes($katw.$isp);               //
  list($s1, $s2) = explode("_",$isp);
  $s4="_".$s2."v";
  if (substr($s2,0,1)=="0")                     //
  {$files2 = scandir($katw, 1);		            //
  $yess=false;
  foreach ($files2 as &$value) 		            //
  {if ($value != "." && $value != "..")  
  {if  (!strstr($value, '.'))   				//
   {if (strpos(" ".$value,$s4)>0)              //
     {$yess=true;break;}
   }}}}
  if ($yess)
  {$misp=explode("/",$isp); 
$repo=rtr($misp[count($misp)-1]).' <b style=color:red> the table has linked pages! Delete them and repeat!</b>';
}
  else
  {full_del_dir ($isp);	
  $repo=rtr($old)." deleted!";
  }}
else
{$os='No object selected for deletion. Click the one you want and repeat.';
}}
//*****************************************************************************************
if (isset ($_REQUEST['bi']))  //
//*****************************************************************************************
{$isf=trim($_REQUEST['oldi']);                    // 
$isp=trim($_REQUEST['olda']);                    //
$isf=tr($isf);                                   //
$nf=getcwd().'/pages/'.$fol.'/'.$isp."/";
$isfp=$nf.$isf."0.php";  
if (file_exists ($isfp))                        // Click "File" and repeat!
{$repo=rtr($isp).' <b style=color:red> this card file! Click "card file" and repeat!</b> ';
}
else
{if ($_REQUEST['npp']!=0)
{$os=""; 										 //
 $kat=getcwd();		    		 				 //
 $fn="";
  $katw= getcwd ( ). '/pages/'.$fol.'/';	     //
 if (empty($_REQUEST['num']) or empty($_REQUEST['tex']))   //
  {$os='An error occurred while trying to create an object - all data was not entered. Come back fill in all the fields and repeat!';
  }
  else    													      //
  {$datw= $_REQUEST['d'].",".$_REQUEST['m'].",".$_REQUEST['y'];   //
   $datw=trim($datw);
   $ip=substr($_REQUEST['num'],0,12);  //
   $n=$ip;
   $ip=trim($ip);
   $ks=ktex($_REQUEST['num'].$_REQUEST['tex']);
   if ($ks<>"")
   {$os= 'Remove "'.$ks.'" of Number = '.$_REQUEST['num'].' or Name = '.$_REQUEST['tex'];
   } 
   else
   {$ip=str_replace ("/","",$ip);	  // 
   $ip=str_replace ("\\","",$ip); $ip=str_replace ("*","",$ip);	              
   $ip=str_replace ("?","",$ip);  $ip=str_replace ("#","",$ip);	              
   $ip=str_replace ("<","",$ip);  $ip=str_replace (">","",$ip);	              
   $ip=str_replace ("|","",$ip);  $ip=str_replace (":","",$ip);$ip=str_replace (" ","_",$ip);
   $ip=tr($ip);
   $ii=substr($_REQUEST['tex'],0,120);  // 
   $ii=trim($ii);
   $ii=str_replace (".","",$ii);	   //
   $ii=str_replace ("/","",$ii); $ii=str_replace ("\\","",$ii);
   $ii=str_replace ("*","",$ii); $ii=str_replace ("?","",$ii);
   $ii=str_replace ("#","",$ii); $ii=str_replace ("<","",$ii);
   $ii=str_replace (">","",$ii); $ii=str_replace ("|","",$ii);
   $ii=str_replace (":","",$ii); $ii=str_replace ("$","",$ii);$ii=str_replace (" ","_",$ii);
   $ii=tr($ii);
   $inp=$datw."_".$ip;               //
   $inf= stripslashes(trim($ii));  	 //
   $new=$inp."/".$inf;               //
   $isp=trim($_REQUEST['olda']);     //
   $isf=trim($_REQUEST['oldi']);     //
   $isp=tr($isp);                    //
   $isf=stripslashes(tr($isf));      //
   $old=$isp."/".$isf;               //
    if  ($isp=="01,01,01_tmp")   // 
   {$repo='01,01,01_tmp <b style=color:red>You cannot rename a template!</b>';
   }  
   else
   {if (file_exists ($katw.$inp))
//---------------------------------- 
//
//---------------------------------
   {if ($old!=$new)								  //
   {if ($ext=="htm")  //
   {if  ($isp=="01,01,01_tmp")   //
   {$repo='01,01,01_tmp <b style=color:red>You cannot rename a template!</b>';
   }  
   else
   {if  ($isp=="01,01,01_apx")   //
   {$repo='01,01,01_apx <b style=color:red>So to rename the archive you cannot, change the date and/or number</b>';
   }  
   else
   {$isfp1=$katw.$isp."/".$isp."/".$isf.".".$ext;  //
   $infp1=$katw.$isp."/".$isp."/".$inf.".".$ext;  //
   $isfp=$katw.$isp."/".$isf.".".$ext;    		 //
   $infp=$katw.$isp."/".$inf.".".$ext;    		 //
   if (file_exists ($isfp1))	  	   	         //
   {rename($isfp1, $infp1);	                     //
	$isfpoint=$katw.$isp."/".$isp."/point/mov_".$isf.".".$ext;  //
	 $infpoint=$katw.$isp."/".$isp."/point/mov_".$inf.".".$ext;  //
	 if (file_exists ($isfpoint))	  	   	//
	 {rename($isfpoint, $infpoint);}	  //
	 }
   	 if (file_exists ($isfp))	   	// 
	  {rename($isfp, $infp);	                         // 
	  $isfp2=$katw.$isp."/".$isf.".php";    		 //
   $infp2=$katw.$isp."/".$inf.".php";    		     //
   if (file_exists ($isfp2))	   	// 
	  {rename($isfp2, $infp2);
  	  }	  // 
if (substr($n,0,1)=="0" and strpos($n,'v')==0)     //
{}
else
{ if ($ext=="htm")
{$w = fopen($infp2, 'w') or exit;  //
fwrite($w, 	
'<?php '."\r\n".
' list($abs1, $s2) = explode("pages",getcwd( ));'."\r\n".
'include $abs1."abegin.php";'."\r\n".
'echo "'.rtr($ii).'";'."\r\n".
'include $abs1."abegin1.php";'."\r\n".
'$os="";'."\r\n".
'$ff=getcwd( ).'.'"/'.$ii.'.htm";'."\r\n".
'include $abs1."time.php";'."\r\n".
'include $abs1."aend.php";'."\r\n".
'?>');
    fclose($w);  //
 }}}
     $repo="Changed: ".substr(rtr($old),0,40) .'->'.	
 	 substr(rtr($new),0,40);
	}}}
	else   // 
	{ $isfp=$katw.$isp."/".$isf.".".$ext;    		 // 
	  if (file_exists ($isfp))	   	//  
	  {
	  $infp=$katw.$isp."/".$inf.".".$ext;    		 // 
	  rename($isfp, $infp);	  // 
	 rename($katw.$isp, $katw.$inp);   // 
     $repo= "Changed: ".substr(rtr($old),0,40) .'->'.	
 	 substr(rtr($new),0,40);
      }}}
   else
   {   $repo=rtr($inp)." <b style=color:red> - IS ON THE PAGE! Change the data and repeat.</b>";
   }}
   //******************************
   // 
   else
   {if ($old!=$new)								  //
	{if ($ext=="htm")   //
	{$isfp=$katw.$isp."/".$isp."/".$isf.".".$ext;  		 // 
	 if (file_exists ($isfp))	  	   	// 
     {$infp=$katw.$isp."/".$isp."/".$inf.".".$ext;  //
	  rename($isfp, $infp);	  //
	 // 
      $l1 = file($infp); 					 //
      $w1 = fopen($infp, 'w') or exit;  	 //
      foreach ($l1 as $li1 => $lin1)     // 
      {fwrite($w1,str_replace($isp,$inp,$lin1)); // 
      }
	 fclose($w1);  //
	 }
	  if (file_exists ($katw.$isp."/".$isp))  // 
	  {rename($katw.$isp."/".$isp, $katw.$isp."/".$inp);}   //
	  $isfp=$katw.$isp."/".$isf.".".$ext;    		 //
	  if (file_exists ($isfp))	   	//
	  {$infp=$katw.$isp."/".$inf.".".$ext;    		 //
	  rename($isfp, $infp);	  //
      $l1 = file($infp); 					 // 
      $w1 = fopen($infp, 'w') or exit;  	 // 
      foreach ($l1 as $li1 => $lin1)     // 
      {fwrite($w1,str_replace($isp,$inp,$lin1)); //
      }
	 fclose($w1);  //
     $isfp=$katw.$isp."/".$isf.".php";    		 // 
	 $infp=$katw.$isp."/".$inf.".php";    		 // 
	  rename($isfp, $infp);	  //
	 $w = fopen($infp, 'w') or exit;  // 
fwrite($w, 	
'<?php '."\r\n".
' list($abs1, $s2) = explode("pages",getcwd( ));'."\r\n".
'include $abs1."abegin.php";'."\r\n".
'echo "'.rtr($ii).'";'."\r\n".
'include $abs1."abegin1.php";'."\r\n".
'$os="";'."\r\n".
'$ff=getcwd( ).'.'"/'.$ii.'.htm";'."\r\n".
'include $abs1."time.php";'."\r\n".
'include $abs1."aend.php";'."\r\n".
'?>');
    fclose($w);  //
      }	 
	 rename($katw.$isp, $katw.$inp);                    //
	  $fex = file_get_contents ('otd/new.txt');  		//
     $repo="Changed: ".substr(rtr($old),0,40) .'->'.	
 	 substr(rtr($new),0,40);
	}
else	                                             //
	{$isfp=$katw.$isp."/".$isf.".".$ext;    		 //
	  if (file_exists ($isfp))	                    	// 
	  {$infp=$katw.$isp."/".$inf.".".$ext;    		 //
	  rename($isfp, $infp);	                         // 
	  rename($katw.$isp, $katw.$inp);                  // 
      }
     $repo="Changed: ". substr(rtr($old),0,40) .'->'.	
 	 substr(rtr($new),0,40);
	}}
    else
    {$os= '<b style="color:white; background:red">'.$old.'</b><b style="color:white;background:green"> = <br>'.	
 	$new.'</b><br><b style="color:white;background:blue"> Make changes and repeat!</b> \n';
    }}}}}}
else
{
$os='No object selected for modification. Click on the desired line and repeat.';
}}}
//**********************************************************************************************
//                                                        
//**********************************************************************************************
if (isset ($_REQUEST['bs']))             // 
{$os=""; 								  //
 $kat=getcwd();		    		 		  //
 $fn="";
 $katw= getcwd ( ). '/pages/'.$fol.'/';	//
  if (empty($_REQUEST['num']) or empty($_REQUEST['tex']))   //
  {$os= 'An error occurred while trying to create an object - all data was not entered. Come back fill in all the fields and repeat!';
  }
  else    														 //
  {$datw= $_REQUEST['d'].",".$_REQUEST['m'].",".$_REQUEST['y'];   //
   $datw=trim($datw);
   $ip=substr($_REQUEST['num'],0,12);  //
   $n=$ip;
   $ip=trim($ip);   //
   $ip=str_replace ("/","",$ip);	  // 
   $ip=str_replace ("\\","",$ip); $ip=str_replace ("*","",$ip);	              
   $ip=str_replace ("?","",$ip);  $ip=str_replace ("#","",$ip);	              
   $ip=str_replace ("<","",$ip);  $ip=str_replace (">","",$ip);	              
   $ip=str_replace ("|","",$ip);  $ip=str_replace (":","",$ip);$ip=str_replace (" ","_",$ip);
   $ks=ktex($_REQUEST['num'].$_REQUEST['tex']);
   if ($ks<>"")
   {$os= 'Remove "'.$ks.'" of Number = '.$_REQUEST['num'].' or Name = '.$_REQUEST['tex'];
   } 
   else
   {$ip=tr($ip);    // 
   $ipp=$datw."_".$ip;  //
   $irep=$ipp;
   $ip=$katw.$ipp;		//
   $ii=substr($_REQUEST['tex'],0,120);  // 
   $ii=trim($ii);
   $ii=str_replace (".","",$ii);	   //  /\*:?#<>|
   $ii=str_replace ("/","",$ii); $ii=str_replace ("\\","",$ii);
   $ii=str_replace ("*","",$ii); $ii=str_replace ("?","",$ii);
   $ii=str_replace ("#","",$ii); $ii=str_replace ("<","",$ii);
   $ii=str_replace (">","",$ii); $ii=str_replace ("|","",$ii);
   $ii=str_replace (":","",$ii); $ii=str_replace ("$","",$ii);$ii=str_replace (" ","_",$ii);
   $ii=tr($ii);    
   $if=$ip.'/'.$ii.'.htm';  	// 
   if (file_exists (wu($ip,$utf8)))    	    
//------------------------- ---------------
   {$repo=rtr($irep)."<b style=color:red> - IS ON THE PAGE!
    Change the data and repeat.</b>";}
   else 	 // 
   {// 
   //
   //
    $ipp2=$ipp;
    $ipp=$ip.'/'.$ipp;    		// 
	$if=$ipp.'/'.$ii.'.htm';  	// 
	$if0=$ip.'/'.$ii.'.htm';  	// 
	mkdir($ip);		        	// 
///////////////////////////////////////////////////////////
	$num=$_REQUEST['num'];
	$ms="s";                           //
    if (isset($_REQUEST['pr']))  //
    {if  ($_REQUEST['sab2']=="")
	{if (substr($num, 0,3 ) =="000")    //
	{$ms="s3";}
	else
	{if (substr($num, 0,2 ) =="00")   //
	{$ms="s2";}
	else
	{if (substr($num, 0,1 ) =="0")    //
	{$ms="s1";}
	}}}
	 dircpy('',getcwd().'/sampl/'.$ms.'/',$ip,false);	
     rename($ip.'/'.$ms.'/', $ip.'/'.$ipp2.'/');	          //
	 $repo= rtr($irep)." CREATED BY A TEMPLATE!";
	}
    else                             // 
    {///////////////////////////////////////////////
	if ($_REQUEST['copy2']!="")      // 
	{ dircpy('',getcwd()."/pages/".$_REQUEST['href'],$ip,true);	
     $t2=explode("/",$_REQUEST['href']); 
	 $ms=$t2[count($t2)-2];
     rename($ip.'/'.$ms.'/', $ip.'/'.$ipp2.'/');	          //
	 $repo= rtr($irep)." CREATED AS A COPY!";
	}
	else
	{$w = fopen($if0, 'w') or exit;  //
    fclose($w);                     // 
	$if0=$ip.'/'.$ii.'.php';  	    // 
    $w = fopen($if0, 'w') or exit;  // 
   $mmm=rtr($n);
//----------------------------------------
if ( substr($n,0,1)=="0" and strpos($n,'v')==0)   // 
{//
// 
list($abs1, $s2) = explode("pages",getcwd( ));
//$otkuda2=$abs1.'/sampl/baza1/sv.txt';
$imst="start.php";
mkdir($ip."/ren/");        //
 if ( substr($n,0,3)=="000")
{$kuda1=$ip;
 $otkuda=$abs1.'/sampl/baza1/1.txt';
 $kuda=$kuda1.'/1.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
 $otkuda=$abs1.'/sampl/baza1/1s/0.txt';
 $kuda1=$ip."/1s";          //
 mkdir($kuda1); 			//
 $kuda=$kuda1.'/0.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
 $otkuda=$abs1.'/sampl/baza1/1s/v.txt';
 $kuda=$kuda1.'/v.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
 $otkuda=$abs1.'/sampl/baza1/1s/sv.txt';
 $kuda=$kuda1.'/sv.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
 $otkuda=$abs1.'/sampl/baza1/1s/0.txt';
 $kuda1=$ip."/2s";          //
 mkdir($kuda1); 			//
 $kuda=$kuda1.'/0.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
 $otkuda=$abs1.'/sampl/baza1/1s/v.txt';
 $kuda=$kuda1.'/v.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
 $kuda=$kuda1.'/sv.txt';
 $otkuda=$abs1.'/sampl/baza1/1s/sv.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
 $otkuda=$abs1.'/sampl/baza1/1s/0.txt';
 $kuda1=$ip."/3s";          //
 mkdir($kuda1); 			//
 $kuda=$kuda1.'/0.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
 $otkuda=$abs1.'/sampl/baza1/1s/v.txt';
 $kuda=$kuda1.'/v.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
 $otkuda=$abs1.'/sampl/baza1/1s/sv.txt';
 $kuda=$kuda1.'/sv.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
 $kuda1=$ip."/1";
 mkdir($kuda1); 			//
 $otkuda=$abs1.'/sampl/baza3/1/1.txt';
 $kuda=$kuda1.'/1.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
 $kuda1=$ip."/1/1";
 mkdir($kuda1); 			//
 $otkuda=$abs1.'/sampl/baza3/1/1/1.txt';
 $kuda=$kuda1.'/1.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
 fwrite($w, 	   
'<?php'."\r\n".
'list($abs1, $s2) = explode("pages",getcwd( ));'."\r\n".
'include $abs1."sampl/baza1/start.php";'."\r\n".
'include $abs1."sampl/baza1/start3.php";'."\r\n".
'?>'."\r\n");
 }
else    //**************************************************************************
{if ( substr($n,0,2)=="00")
{ $kuda1=$ip;
 $otkuda=$abs1.'/sampl/baza1/1.txt';
 $kuda=$kuda1.'/1.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
 $otkuda=$abs1.'/sampl/baza1/1s/0.txt';
 $kuda1=$ip."/1s";          //
 mkdir($kuda1); 			//
 $kuda=$kuda1.'/0.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
 $otkuda=$abs1.'/sampl/baza1/1s/v.txt';
 $kuda=$kuda1.'/v.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
 $otkuda=$abs1.'/sampl/baza1/1s/sv.txt';
 $kuda=$kuda1.'/sv.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
 
 $otkuda=$abs1.'/sampl/baza1/1s/0.txt';
 $kuda1=$ip."/2s";          //
 mkdir($kuda1); 			//
 $kuda=$kuda1.'/0.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
 $otkuda=$abs1.'/sampl/baza1/1s/v.txt';
 $kuda=$kuda1.'/v.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
 $otkuda=$abs1.'/sampl/baza1/1s/sv.txt';
 $kuda=$kuda1.'/sv.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
 $kuda1=$ip."/1";
 mkdir($kuda1); 			//
 $otkuda=$abs1.'/sampl/baza2/1/1.txt';
 $kuda=$kuda1.'/1.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
 fwrite($w, 	   
'<?php'."\r\n".
'list($abs1, $s2) = explode("pages",getcwd( ));'."\r\n".
'include $abs1."sampl/baza1/start.php";'."\r\n".
'include $abs1."sampl/baza1/start2.php";'."\r\n".
'?>'."\r\n");
 }
else
{$imst="start.php";
 $kuda1=$ip;
 $otkuda=$abs1.'/sampl/baza1/1.txt';
 $kuda=$kuda1.'/1.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
 $otkuda=$abs1.'/sampl/baza1/1s/0.txt';
 $kuda1=$ip."/1s";          //
 mkdir($kuda1); 			//
 $kuda=$kuda1.'/0.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
  $otkuda=$abs1.'/sampl/baza1/1s/v.txt';
  $kuda=$kuda1.'/v.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
  $otkuda=$abs1.'/sampl/baza1/1s/sv.txt';
  $kuda=$kuda1.'/sv.txt';
 if (copy($otkuda,$kuda)) {} else {$os=$os. "<b>Copy error ".$z."</b>";}
 if ($ggg=="")
 { fwrite($w, 	   
'<?php'."\r\n".
'list($abs1, $s2) = explode("pages",getcwd( ));'."\r\n".
'include $abs1."sampl/baza1/start.php";'."\r\n".
'include $abs1."sampl/baza1/start1.php";'."\r\n".
'?>'."\r\n");
}
 if ($ggg=="1")
 {fwrite($w, 	   
'<?php'."\r\n".
'list($abs1, $s2) = explode("pages",getcwd( ));'."\r\n".
'include $abs1."sampl/baza1/start.php";'."\r\n".
'include $abs1."sampl/baza1/start1g1.php";'."\r\n".
'?>'."\r\n");
}
 if ($ggg=="2")
 {fwrite($w, 	   
'<?php'."\r\n".
'list($abs1, $s2) = explode("pages",getcwd( ));'."\r\n".
'include $abs1."sampl/baza1/start.php";'."\r\n".
'include $abs1."sampl/baza1/start1g2.php";'."\r\n".
'?>'."\r\n");
}}}
 fclose($w);  //
  //
	$if0=$ip.'/tables.php'; 
	$w = fopen($if0, 'w') or exit;  //  
    fwrite($w, 	   
'<?php'."\r\n".
'list($abs1, $s2) = explode("pages",getcwd( ));'."\r\n".
'$abs2=getcwd ( )."/do.php";'."\r\n".
'if  (file_exists($abs2)) {include $abs2;}'."\r\n".
'include $abs1."sampl/baza1/tables.php";'."\r\n".
'?>'."\r\n");
    fclose($w);  //
}
 	else
	{fwrite($w, 	
'<?php '."\r\n".
' list($abs1, $s2) = explode("pages",getcwd( ));'."\r\n".
'include $abs1."abegin.php";'."\r\n".
'echo "'.rtr($ii).'";'."\r\n".
'include $abs1."abegin1.php";'."\r\n".
'$os="";'."\r\n".
'$ff=getcwd( ).'.'"/'.$ii.'.htm";'."\r\n".
'include $abs1."time.php";'."\r\n".
'include $abs1."aend.php";'."\r\n".
'?>'
);
fclose($w);  //
}
	mkdir($ipp); 		        	// 
	$w = fopen($if, 'w') or exit;  //  
    fclose($w);  //
//----------------------------------------------------
// 
//----------------------------------------------------
	$repo=rtr($irep)." CREATED!";
}}}}}}
echo '<b style=color:red;font-family:tahoma;font-size:12px;font-weight:bold;>WEBSITE:&nbsp;&nbsp;&nbsp;</b>
<b style=color:#316290;font-family:tahoma;font-size:12px;font-weight:bold; id=sname2>';
include "plan/name.txt";
echo '</b></center>';

?>
<table border="0" height=80% id=tab3>
<tbody>
<tr><td colspan=2 height=20 align=center><font size="4" color=#316290>O B J E C T S &nbsp; P A G E S: loading, creating, deleting, changing.
</font>
</td></tr>
<tr><td valign="top">
<button form="" onclick=pss(1) style="width:70;<?php if ($pss!="") {echo "display:none";}?>" 
title="show only link pages of the selected table">show</button>&nbsp;
<button  form="" onclick=pss(2) style="width:70;<?php if ($pss=="") {echo "display:none";}?>" 
title="deselect link pages of the selected table" >cancel</button>
&nbsp;<b>Ascending</b>&nbsp;<img id=ksort onclick=izs(this) src='d~e~f/yes.gif' 
title="SORT BY: AGE: Mark me, click the title text in the header;
DESCENDING: Unmark me, click the title text in the header;">
&nbsp;&nbsp;&nbsp;
<button form="" title="To begin" onclick=tnd(0) style="background:white;width:30">&nbsp;&#8593;&nbsp;</button>&nbsp;&nbsp;
<button form="" style="background:white;width:30" onclick=tnd(9999999) title="To end">&nbsp;&#8595;&nbsp;</button>
&nbsp;&nbsp;&nbsp;
<button form="" style="background:white;width:30" onclick=topr(event) 
title="List of page objects in the window for printing">P</button>
&nbsp;&nbsp;&nbsp;
<b>PAGE&nbsp;&nbsp;&nbsp;&nbsp;</b>
<a style='background:yellow;color:brown'  href="<?php echo "pages/".$fol1.'.php'; ?>" target=_blank 
title="Click me to view the page!"><b id=imya>
<?php echo str_replace("_"," ",$im); ?></b></a> 
<?php  if ($pss!="") {echo "&nbsp;&nbsp;&nbsp;<b id=tabs style='background:yellow;color:brown'>Table ".
str_replace("v","",$pss)."</b>";}?>
<center>
<b>filter in <b id=zs>?</b> and by</b> &nbsp;
<input type="text" id=goto size="30" title="Filtering context">

<button  form="" onclick=got(3) 
title="Move to the line where the beginning of the cell matches the context.">
&nbsp;GO&nbsp;&nbsp;</button>

<button form="" onclick=got(0) 
title="Show only those rows that contain context anywhere in the text that is clicked on the column number.">
&nbsp;Select&nbsp;&nbsp;</button>
<button form="" onclick=got(2) 
title="Cancel selection">&nbsp;Cancel&nbsp;</button>
</b>
</center>
<center>
<?php

if ($os!="") {echo '<b id=soob2 style="color:red">'.$os.'</b>';}  // 
if ($repo!="") {echo '<b id=soob3 title="'.$repo.'" style="color:green">'.$repo.'</b>';} //
?>
<b id=soob style="color:brown">&nbsp;</b>
</center>
<table border="1" id=zag style="background:#eee8aa" width=655 onclick=clz(this)><THEAD>
<TR id=sort>
<TH title="Number in order" width="37" lang=0>N</TH>
<TH title="Date " width="72" lang=1>Date</TH>
<TH title="Number " width="98" lang=2>Number</TH>
<TH title="Name" lang=3>Name</TH>
<TH title="File size in Kilobytes" width="106" lang=4>KB</TH>
<TH title="File type" width="45" lang=5>Type</TH>
</TR>
<TR id=sel title='Click me to filter' >
<TH width="37" title=0>1</TH>
<TH width="72" title=1>2</TH>
<TH  width="98" title=2>3</TH>
<TH title=3>4</TH>
<TH width="106" title=4>5</TH>
<TH  width="45" title=5>6</TH>
</TR>
</THEAD></table>
<div id=k  style="OVERFLOW: scroll; WIDTH: 677;  HEIGHT:85% ;">
<table id=tab2 border="1" width="650">
<TBODY onclick=nclic(event)>
<?php
//----------begin --------
// 
if ($utf8!="") // 
{$kati= getcwd ( ). '/pages/'.$fol.'/';	// 
// 
if (!file_exists ($kati)) 	   	        //
{mkdir(wu($kati,$utf8));			    //
}
$files2 = scandir($kati, 1);		    //
$i=1;
foreach ($files2 as &$value) 		    //
{$da=false;  	      				    //
  if ($value != "." && $value != "..")  
  {if  (!strstr($value, '.'))   				//
   {if ($utf8)                                  //
    {$val = iconv("utf-8","Windows-1251",$value); } else {$val=$value;} //
     if (substr($val,2,1)=="," and substr($val,5,1)==",")  	//
     {$d=substr($val,0,8); 		    	// 
      $n=substr($val,9,12); 			// 
      if ($pss=="")      //
      {if (strpos($n,"v")>0) {$npok=true;}  else {$npok=false;} //
	  }
	  else               //
	  {
	  if (strpos(" ".$n,$pss)==1) {$npok=false;}  else {$npok=true;}
	  }
      if ($npok)  	    
      {}
	  else
	  {
	  $ipp=$kati.$value.'/'.$value;     //
      if (file_exists ($ipp.'/_begin.txt')) 	   	// 
      {$z=true; }  else {$z=false;}
	  if (file_exists ( $ipp))    	    //
	  {$filesp = scandir($ipp, 1);		//
      foreach ($filesp as &$va) 		//
     {if ($va != "." && $va != "..")  
     {if ($utf8) //  
      {$va1 = iconv("utf-8","Windows-1251",$va); } else {$va1 =$va;} //
	 if  (strpos($va1,".htm")>0)			 // 
      {$t=substr($va1,0);$da=true; break;
	   }	                                 // 
      }}}
	  else                                   // 
    {$ipp=$kati.$value;   			         // 
	  $filesp = scandir($ipp, 1);		     // 
      foreach ($filesp as &$va) 		     //
     {if ($va != "." && $va != "..")  
     {if ($utf8) // 
      {$va1 = iconv("utf-8","Windows-1251",$va); } else {$va1 =$va;} //
	  $t=substr($va1,0);$da=true; break;
      }}}	  
     if  (!$da) {}
     else
     {echo '<TR><TD id=n1 style="background:white" width="37" align=center>'.$i.'</TD>'."\r\n";  	//
      echo '<TD width="72">'.$d.'</TD>'."\r\n";		        //
      echo '<TD width="98">'.rtr($n).'</TD>'."\r\n";		//
      list($name, $ext) =explode(".",trim($t));	            //
	  $v=filesize( $ipp.'/'.$va)/1000;				        //
	  if ($ext=='htm')                                      //
	  {if ($z)                                              //
	  {
	  echo '<TD title='.rtr($name).'>&nbsp<a target=_blank  href="img1.php?fol='.$fol1.
	  '&foli='.$val.'&file='.$name.'&tip=spis&im='.$im.'&utf8='.$utf8.'">'.str_replace ("_"," ",rtr($name)).'</a></TD>'."\r\n";	
	  }
	  else   //
	  {if (substr($n,0,1)=="0" and strpos($n,'v')==0)   //
	  {echo '<TD ';
      if (substr($n,0,3)=="000")
      {echo ' title="3 linked tables"';}
	  else
	  {if (substr($n,0,2)=="00")
      { echo ' title="2 linked tables"'; }
	  else
	  {if (substr($n,0,1)=="0" and strpos($n,'v')==0)
      {echo ' title="1 table"'; }}}
      echo "><a target=_blank href=pages/".tr($im).'/contents/'.$val.'/'.str_replace(".htm",".php",$va1).">".str_replace ("_"," ",rtr($name))."</a>";	  
	  echo '</TD>'."\r\n";	
	  }
	  else
	  {//
$isfp1="pages/".tr($im).'/contents/'.$val.'/'.$name."0.php";  
if (file_exists ($isfp1))    	    // 
{echo '<TD title="Card file">*';}
else
{echo '<TD  title="Page">';}
 echo '&nbsp<a target=_blank  href="zsite.php?site='.tr($im).'/contents/'.$val.'/'.$val.'/'.$va1.
	  '&nam='.$val.' '.$va1.'&fol='.tr($im).'/contents/'.$val.'/'.$val.'&utf8='.$utf8.'">'. str_replace ("_"," ",rtr($name)).'</a></TD>'."\r\n";	
	  }}}
	  else   // 
	  {echo '<TD>&nbsp<a target=_blank  href="pages/'.$fol.'/'.$val.'/'.$va1.
	  '">'. str_replace ("_"," ",rtr($name)).'</a></TD>'."\r\n";	
	  }
      echo '<TD width="106" align=center>'.($z ? "'".$v:$v).'</TD>'."\r\n";		// 
      echo '<TD width="45" align=center>'.$ext.'</TD></TR>'."\r\n";	// 
      $i++;}}}}}}
echo '</tbody></table></div>';	// 
if ($pss=="")      //
{$repo="To related pages ";}
else
{$repo=$d."_".rtr(n)." Return";}
}
else
{
// 
echo '<font color=red size="4">Wrong start! Access is only possible through the main form
administrator!</font>';}
?>
</td>
<td id=spr valign=center>
<?php
  if ($tip=="new.htm")
 {echo '<a target=_blank href="pages/new.php"> - '.$im.'</a>'."\n";}
 elseif ($tip=="dokl.htm")
 {	echo '<a target=_blank target=_blank href="pages/dokl.php">-'.$im.'</a>'."\n";} 
 elseif ($tip=="docum.htm") 
 {echo '<a target=_blank href="pages/docum.php">-'.$im.'</a>'."\n";}
?>
</font>
<a  href="help/5.htm" target=_blank>&nbsp;Help&nbsp;</a>
<br><br> 
<b>
<u  style="color:red">This form is for:</u>
<div id=spra  style="OVERFLOW: scroll">
<li> creating an empty external page (a page that is not shown in the center of the main page of the site, but opens in a separate window),
opening of such a page is performed by clicking on the link that is placed on the constructed page, by the designer, in the form of a detached link or table of links
<li> changes (date, number, name) and deletion of uploaded documents or external pages,
<li> to fill a blank page with content or change a previously filled page.
<li> to create page databases.
<li> to create table pages.
<hr>
<b> Uploads of various documents to the site (including pages created by other means, for example Frontpage) are performed by system tools
to the outside folder. The contents of this folder in the form of links to downloaded files are available when working with any page. </b> <br>
<hr>
The list shows all uploaded and created objects in page format: published and unpublished!
<hr>
<li> To change external pages created in this form, click the link in the "Name" column in the line with the htm extension - the page builder will open </b>
<hr>
<b> To create a blank external page or load: </b>
<li> Enter the date of the document, its number (no more than 12 characters), and the name (no more than 120 characters);
<li> If the date is unknown, enter the current date;
<li> If the number is unknown, enter the text: "no";
<li> Text from "Name" will be shown as the text of the link to the document on the object page;
<hr>
<b> To create a blank external page: click New; </b>
<hr>
<li> <b> To create an empty external page archive: click Archive; </b>
<hr>
<li> <b> To create a blank MY TEMPLATES external page: click Templates; </b>
<hr>
<li> <b> Click "st1, st2, st3" to create external page tables; </b>
<hr>
<li> <b> To create table pages: click a table row click show and click +; </b>
<hr>
<li> <b> To download: </b> click Browse, select the file and click Download;
<li><?php include "otd/new.txt";?>
<hr>
<li> <b> To change by clicking in column N, select the line to be replaced,
in the data, make changes and click "Edit". </b>
<hr>
<li> <b> To delete an object by clicking in column N, select the object to be deleted,
and click "X". </b> <hr>
<li> <b> When you delete an object to which there is a link, this link becomes a bat. </b>
<li> <b> The * symbol is used to mark objects-filing cabinets. </b>

<li> <b> To create a table help page, click in column N to select the table and click "help". </b> <hr>
<li> <font color = "red"> <b> When changing the name of a document, a single link to this document does not change! Change the link manually.</b></font>
<hr>
<li> <font color = "red"> <b> Numbers starting with 0 define the database tables do not use them for your files !!! </b> </font>
<li> <font color = "red"> <b> All objects can be deleted by means of OS by deleting all folders in pages / [page name] / context !!! </b> </font>

<form id="form" action="reddoc.php
<?php if ($utf8!="") {echo '?utf8='.$utf8;} echo "&tip=".$_GET['tip']; echo "&im=".$_GET['im']; 
echo "&fol=".$_GET['fol'];echo "&ext=".$ext; ?>"
method="post" enctype="multipart/form-data" >
</div>

<button id=crea form="" onclick=sto(2) 
<?php if ($pss!="") {echo "display:none";}?>" 
title="Create a blank page, or from a template.
For the designer, click the Name column."
<?php if ($utf8=="") {echo 'disabled';} ?> style="
<?php if ($pss!="") {echo "display:none";}?>"  >Create</button>
<input style="display:none" type="submit"  name="bs" id="bs"   value="Create" >

<button form="" onclick=sto(4) href="#"
<?php if ($pss!="") {echo "display:none";}?>" 
title="Change the date, number, name of the selected object."  
<?php if ($utf8=="") {echo 'disabled';} ?>>Change</button>
<input style="display:none" type="submit"  name="bi" id=bi value="Change" >


<button form="" onclick=sto(1) id=46 href="#" style="background:red;color:white;" 
title="Delete selected object - click the line click me or press 'Delete'."  
<?php if ($utf8=="") {echo 'disabled';} ?>>&nbsp;&nbsp;X&nbsp;&nbsp;</button>



<input style="display:none" type="submit"  name="del" id=del value="Delete" >
<hr>
<button form="" onclick=apx1() id=53   
<?php if ($pss!="") {echo "display:none";}?>  
title="Create Archive Page - Click me or keyboard press '5' "  
<?php if ($utf8=="") {echo 'disabled';}?> style="
<?php if ($pss!="") {echo "display:none";}?>"  >Archive&nbsp;5</button>

<input style="display:none" type="submit"  name="apx" id=apx value="Archive" >
<button form="" onclick=tmp1() id=54 
<?php if ($pss!="") {echo "display:none";}?>" 
title="Create Templates Page - Click Me Or Press '6'"  
<?php if ($utf8=="") {echo 'disabled';} ?> style="
<?php if ($pss!="") {echo "display:none";}?>" >Template&nbsp;6</button>

<input style="display:none" type="submit"  name="tmp" id=tmp value="Template" >
<button form="" onclick=cop2() id=55 
title="Create a copy of pages, click me or press '7' on the keyboard"  
<?php if ($utf8=="") {echo 'disabled';} ?> style="
<?php if ($pss!="") {echo "display:none";}?>" >Copy&nbsp;7</button>
<input style="display:none" type="submit"  name="cop" id=cop value="Copy" >

<hr>
<!----<b style="<?php if ($pss!="") {echo " display:none";}?>">template</b>&nbsp;
<input style="width:15;<?php if ($pss!="") {echo " display:none";}?>"  type=checkbox  --->
<b style="">template</b>&nbsp;
<input type=checkbox   
title="Create from template - install me and click 'Create' or 'st1' or 'st2' or 'st3' or '+'"
 name="pr"  id=pr
<?php if ($utf8=="") {echo 'disabled';} ?> value="Z">&nbsp;&nbsp;
<b style=" <?php if ($pss!="") {echo " display:none";}?>">&nbsp;&nbsp;BASES:</b>&nbsp;
<button form=""  id=49 onclick=baza1(1) style="<?php if ($pss!="") {echo " display:none";}?>" 
title="Create a table or create from a template - click me or press on the keyboard '1' " 
<?php if ($utf8=="") {echo 'disabled';} ?> style=width:30 >St1</button>&nbsp;&nbsp;
<input style="display:none" type="submit" name="st1" id=st1 value="">
<button form="" id=50 onclick=baza2(1) style="<?php if ($pss!="") {echo " display:none";}?>" 
title="Create 2 linked tables or create from template - click me or keyboard press '2'" 
<?php if ($utf8=="") {echo 'disabled';} ?> style=width:30>St2</button>&nbsp;&nbsp;
<input style="display:none" type="submit" name="st2" id=st2 value="">
<button form="" id=51 onclick=baza3(1) style="<?php if ($pss!="") {echo " display:none";}?>" 
title="Create 3 linked tables or create from template - click me or keyboard press '3'" 
<?php if ($utf8=="") {echo 'disabled';} ?> style=width:30>St3</button>&nbsp;&nbsp;
<input style="display:none" type="submit" name="st3" id=st3 value="">
<button form="" onclick=baza0(1) style="<?php if ($pss=="") {echo " display:none";}?>" 
title="Add page to list of tables for link field" <?php if ($utf8=="") 
{echo 'disabled';} ?>style=width:30 >+</button>
<input style="display:none" type="submit" name="st0" id=st0 value="">
<input type="submit" style="display:none;background:red;color:white" name="pssc" id=pssc>

<hr>
<button form="" id=56 style="width:85;<?php if ($pss!="") {echo "display:none";}?>" onclick=kart(event)  
onclick=kart(1) 
title="Page to card file or card file to page - click the line click me or press '8' on the keyboard"  
<?php if ($utf8=="") {echo 'disabled';} ?>>Card file&nbsp;8</button>&nbsp;
<input style="display:none"  type="submit" name="kar" id=kar>

<button form="" id=52 style="<?php if ($pss!="") {echo "display:none";}?>" onclick=help(event)  
title="Create page and / or edit table description page -
click the table row, click me or press '4' on the keyboard">help&nbsp;4</button>&nbsp;

<button form="" id=57 style="<?php if ($pss!="") {echo "display:none";}?>" onclick=sab(event)   
title="Save the template; select a row with tables or a page and click me or on the keyboard press '9'"
  <?php if ($utf8=="") {echo 'disabled';} ?>>Save&nbsp;9</button>&nbsp;
<input style=display:none type="submit" name="st5" id=st5 value="S">

<?php
if  ($im=="100")
{
echo '&nbsp;&nbsp;&nbsp;<button  form="" title="Make the selected table a value insertion table" onclick=vpod() 
style="color:white">';
echo '<img height=17 src=d~e~f/arrow-up.gif></button>';
}
?>
</td></tr></tbody></table>
<b id=ff></b> <b>Row selected&nbsp;<input  type="text" value=0 name="npp" id=npp 
style="width:20;background:yellow">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<b style=color=#316290>Created or modified object data:&nbsp;&#8595;</b>
<table border="0"><THEAD><TR style="background:silver">
<TH title="Object date in the format: day month year"><nobr>Date(d.m.y)</nobr></TH>
<TH  title="The object number must not contain characters: /\*:?#<>|," width="75">Number&nbsp;
<button form="" id=clea form="" onclick=odk() 
 title="for cleaning 'Numbers' and 'Names'"
<?php if ($pss!="") {echo "disabled";}?> >
&nbsp;X&nbsp;</button></TH>
<TH title="The name of the object should not contain symbols: /\*:?#<>|">Name</TH>
</TR></THEAD><TBODY>
<TR>
<TD>
<nobr>
<input name="d" id=d style="width:30" readonly value="?">
<input name="m" id=m style="width:30" readonly value="?">
<input name="y" id=y style="width:30" readonly value="?">
<button form="" style="width:20" id=caz title="The calendar" onclick="document.getElementById('cal1').style.display='';">C</button>
</nobr>
</TD>
<TD><input type="text" name="num" id=num size="12" value="no" 
<?php if ($pss!="") {echo "readonly";}?> ></TD>
<TD><input type="text" name="tex" id=tex size="110">
</TD>
</TR>
</TR>
</tbody></table>
<input type="hidden" value="" name="href" id=href>
<input type="hidden" value="" name="olda" id=olda>
<input type="hidden" value="" name="oldi" id=oldi>
<input type="hidden" value="<?php echo $utf8; ?>" name="utf8" id=utf8>
<input type="hidden" value="<?php echo $tip; ?>" name="tip" id=tip>
<input type="hidden" value="<?php echo $im; ?>" name="im" id=im>
<input type="hidden" value="<?php echo $fol; ?>" name="fol" id=fol>
<input type="hidden" value="" name="ext" id=ext>
<input type="hidden" value="<?php echo $pss; ?>" name="pss" id=pss>
<input type="hidden" value="" name="copy2" id=copy2>
<input type="hidden" value="" name="sab2" id=sab2>
<input type="hidden" value="" name="ggg" id=ggg>
<input type="hidden" value="<?php echo $pss2; ?>" name="pss2" id=pss2>

<input type=hidden name="sd" id=sd value=" <?php include "otd/new.txt";?>">
Loading:
<input type="file"  name= "filename" id=filename size="95" value="12345" 
<?php if ($utf8=="" or $pss!="") {echo 'disabled';} ?> 
>&nbsp&nbsp  repeat <input title="Install to reload "  
type="checkbox" name="pov" id=pov value="repeat">&nbsp;&nbsp;&nbsp;
<input type="submit" language="JAVAScript" name="zag" id=zag  value="Download" 
<?php if ($utf8=="" or $pss!="") {echo 'disabled';} ?>>
</form>
<textarea id=nn style="visibility:hidden; HEIGHT: 0px" cols=0 rows=1 disabled>0</textarea>
<a target=_blank id=tohelp style="display:none"  href="#"></a>
<SCRIPT type="text/javascript">
// 
window.onload=function ()
{mtd=document.getElementById("cal2_td").innerHTML
document.getElementById("d").value=mtd.substr(0,2)
document.getElementById("m").value=mtd.substr(3,2)
document.getElementById("y").value=mtd.substr(8,2)
document.getElementById("tab3").style.height=document.getElementById("ppp").offsetHeight-270

obj9= document.getElementById("k")
obj9.style.height=document.getElementById("ppp").offsetHeight-270
document.getElementById("spra").style.height=document.getElementById("ppp").offsetHeight-350
if (document.getElementById("soob3")!=undefined)
{if (document.getElementById("soob3").innerHTML.indexOf("-&gt;")>0)   //
{dn2=document.getElementById("soob3").innerHTML.split("-&gt;")[1].split("/")[0].split("_")
dat3=dn2[0]
if (dn2.length>2)
{nom3=dn2[1]+"_"+dn2[2] }
else
{nom3=dn2[1]
}
da=false
mk=document.getElementById("k").getElementsByTagName("TR")   // 
for (var j2 = 0; j2 <= mk.length-1; j2++)
{mmk=mk[j2].getElementsByTagName("TD") 
if (mmk[1].innerHTML==dat3 && mmk[2].innerHTML==nom3)
{da=true 
break
}}
if (da)                                                       //
{document.getElementById("k").scrollTop=mmk[1].offsetTop      //
mmk[1].click()                                                //
}}
else
{mcp=document.getElementById("soob3").innerHTML.replace("<"," ")
dn2=mcp.split(" ")[0].split("_")
dat3=dn2[0]
if (dn2.length>2)
{nom3=dn2[1]+"_"+dn2[2] }
else
{nom3=dn2[1]
}
da=false
mk=document.getElementById("k").getElementsByTagName("TR")   // 
for (var j2 = 0; j2 <= mk.length-1; j2++)
{mmk=mk[j2].getElementsByTagName("TD") 
if (mmk[1].innerHTML==dat3 && mmk[2].innerHTML==nom3)
{da=true 
break
}}
if (da)                                                       //
{document.getElementById("k").scrollTop=mmk[1].offsetTop      //
mmk[1].click()                                                //
}}}
document.getElementById("bod").style.visibility="visible"
}

//**************************************************
function apx1()   //
//**************************************************
{document.getElementById("d").value="01"
 document.getElementById("m").value="01"
 document.getElementById("y").value="01"
 document.getElementById("num").value="apx"
 document.getElementById("tex").value="apx"
 document.getElementById("bs").click()
}
//******************************************************
 function tmp1()   //
//****************************************************** 
{document.getElementById("d").value="01"
 document.getElementById("m").value="01"
 document.getElementById("y").value="01"
 document.getElementById("num").value="tmp"
 document.getElementById("tex").value="tmp"
 document.getElementById("bs").click()
}
//************************************************
function cop2()   // 
//************************************************
{if (document.getElementById("npp").value==0)
{alert("No row selected for copying! Click to select and repeat!")
return
}
mhref=document.getElementById("href").value
if (mhref.indexOf(".php")<0)
{alert("Uploaded documents are not copied! Click to select a page  and repeat!")
return
}
num=document.getElementById("num").value
if (num.indexOf("_")>0)
{ alert("Copies are not copied! Click to select a page or tables and repeat!")
return
}
//

if (num.substr(0,1)=="0")
{
alert("Tables are not copied! \r\n To copy tables: \r\n 1. Create a template by clicking the 'Save' button. \r\n 2. Set the template flag. \r\n 3. Create a table by clicking one of the st1 buttons , st2, st3 according to the created template!")
return
}

document.getElementById("ppp").style.visibility="visible"	

document.getElementById("copy2").value="true"
if (mhref.indexOf("fol=")>0)                             //
{href2=mhref.split("fol=")
 href3=href2[1].split("&")
 href4=href3[0]
} 
else
{href2=split(mhref,"pages/")
href4=href2[1]
}
href5=href4.split("/")
href6=""
for (var j = 0; j <= href5.length-2; j++) 
{href6=href6 + href5[j] + "/"}
document.getElementById("href").value=href6                         //
if (mhref.indexOf("fol=")>0)                               //
{for (var j = 1; j <= 9999; j++) 
{nnew=document.getElementById("num").value + "_" + j
 da=false
mk=document.getElementById("k").getElementsByTagName("TR")
for (var j2 = 0; j2 <= mk.length-1; j2++)
{mmk=mk[j2].getElementsByTagName("TD") 
if (mmk[2].innerHTML==nnew && mmk[1].innerHTML==dat5.innerHTML)
{da=true 
break
}	
}
if (!da)                                                //
 {break}
}
 document.getElementById("num").value=nnew
// alert(document.getElementById("href").value)
document.getElementById("bs").click() 
}
}

//************************************************************
function sto(p)  // 
//************************************************************
{if (p==4 && obj2=="")
{alert("No line selected!")
return
}
if (p==2 || p==4)                            //
{im=document.getElementById("tex").value

if (im.length>200)
{alert("Name length is more than 200!")
return
}
if (document.getElementById("crea").style.display=="" )
{sto2=document.getElementById("num").value
if (sto2.indexOf("v")>=0 || sto2.indexOf("V")>=0)
{alert("The number should not contain symbols v, V! Please enter another number!" )
return
}
}

if (im.substr(im.length-1,1)=="0")
{alert("The name cannot end with the character 0! Change 0 or add a character!" )
return
}
else
{if (document.getElementById("num").value.substr(0,1)=="0" && p==2 )
{alert("The number with left zeros refers to tables! Please enter another number!" )
return
}
else
{ks=' (),_¸1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM'
mnum=document.getElementById("num").value.split("")
nedop=""
for (var j = 0; j <= mnum.length-1; j++)
{if (ks.indexOf(mnum[j])<0)
{nedop=nedop+" "+mnum[j]}
}
if (nedop!="")
{alert("Invalid characters in the Number: "+nedop)
return
}

nedop=""
mnum=document.getElementById("tex").value.split("")
for (var j = 0; j <= mnum.length-1; j++)
{if (ks.indexOf(mnum[j])<0)
{nedop=nedop+" "+mnum[j]}
}
if (nedop!="")
{alert("Invalid characters in the Name: "+nedop)
return
}



mmm=document.getElementById("tex").value
document.getElementById("tex").value=mmm.replace(/(^\s*)|(\s*)$/g, '')             //
document.getElementById("tex").value=document.getElementById("tex").value.replace(/ /g,"_")
document.getElementById("oldi").value=document.getElementById("oldi").value.replace(/ /g,"_")
if (p==2)                                    //
{if (document.getElementById("num").value=="" || document.getElementById("tex").value=="")
{alert("All required data has not been entered! Enter and repeat!")
return
}
document.getElementById("bs").click()}
else
{if (document.getElementById("npp").value==0)
{alert("No row selected! \r\n Click to select and repeat!")
return
}
document.getElementById("ppp").style.visibility="visible"
document.getElementById("bi").click()}
return
}}}
if (p==1)      //
{if (document.getElementById("npp").value==0)
{alert("No row selected! \r\n Click to select and repeat!")
return
}	
if (!confirm("Content will be permanently deleted, \r\n broken links may appear \r\nsure you want this? \r\n Think and make a decision!"))
{return}
else
{
document.getElementById("ppp").style.visibility="visible"
document.getElementById("del").click()
return
}
}
}
//*****************************************************************
function baza0(p)   // 
//*****************************************************************
{num=parseInt(0)
mtr=document.getElementById("k").getElementsByTagName("TR")  //
for(var j = 0; j <= mtr.length-1; j++)                       //
{mtd=mtr[j].getElementsByTagName("TD")                       //
 numtt=mtd[2].innerHTML                                      //
 mnum2=numtt.split("_")
 mnum3=mnum2[0].split("v")
 numt=parseInt(mnum3[1])
 if (!isNaN(numt) && numt>num)
 {num=numt}
}
mtd=document.getElementById("cal2_td").innerHTML.split(".")   //
document.getElementById("d").value=mtd[0]                     //
document.getElementById("m").value=mtd[1]                     //
document.getElementById("y").value=mtd[2].substr(2,2)         //
document.getElementById("num").value="0"+(num+1)
document.getElementById("tex").value="ENTER PAGE NAME"
document.getElementById("sab2").value="true"
document.getElementById("num").value=document.getElementById("pss").value+(num+1)
document.getElementById("bs").click()
}
//*****************************************************
function pss(p)  //
//*****************************************************
{if (document.getElementById("num").value=="")
{return}
if (p==2 && document.getElementById("pss").value!="")
 {document.getElementById("pss").value=""
  document.getElementById("pssc").click()
  return
 }
 if (p==2 && document.getElementById("pss").value=="")
{return}
 if  (document.getElementById("num").value.substr(0,1)=="0")
 {document.getElementById("pss").value= document.getElementById("num").value + "v" 
if (obj2!="")
{mtd=obj2.parentNode.getElementsByTagName("TD")
document.getElementById("pss2").value=mtd[1].innerHTML+"_"+mtd[2].innerHTML
document.getElementById("pssc").click()
}
else
{alert("Row not selected!")}
}
else
{alert("Row is not selected or the selected row is not a table!")}
}
//*****************************************************
function baza1(p)    //
//*****************************************************
{
document.getElementById("ppp").style.visibility="visible"	
num=parseInt(0,10)
mtr=document.getElementById("k").getElementsByTagName("TR")  //
for(var j = 0; j <= mtr.length-1; j++)                       //
{mtd=mtr[j].getElementsByTagName("TD")                       //
 numtt=mtd[2].innerHTML                                      //
if (numtt.substr(0,1)=="0" && numtt.substr(0,2)!="00" && numtt.substr(0,3)!="000")
{tek=parseInt(numtt,10)                                         //
if (!isNaN(tek) && tek>num)                                  //
{num=tek}
}}
mtd=document.getElementById("cal2_td").innerHTML.split(".")   //
document.getElementById("d").value=mtd[0]                     //
document.getElementById("m").value=mtd[1]                     //
document.getElementById("y").value=mtd[2].substr(2,2)         //
document.getElementById("num").value="0"+(num+1)
document.getElementById("tex").value="ENTER TABLE NAME"
 document.getElementById("bs").click()
}
//****************************************************
function baza2(p)    // 
//****************************************************
{
document.getElementById("ppp").style.visibility="visible"		
num=parseInt(0,10)
mtr=document.getElementById("k").getElementsByTagName("TR")  //
for(var j = 0; j <= mtr.length-1; j++)                       //
{mtd=mtr[j].getElementsByTagName("TD")                       //
 numtt=mtd[2].innerHTML                                      //
if (numtt.substr(0,2)=="00" && numtt.substr(0,3)!="000")
{tek=parseInt(numtt,10)                                         //
if (!isNaN(tek) && tek>num)                                  //
{num=tek}
}}
mtd=document.getElementById("cal2_td").innerHTML.split(".")   //
document.getElementById("d").value=mtd[0]                     //
document.getElementById("m").value=mtd[1]                     //
document.getElementById("y").value=mtd[2].substr(2,2)         //
document.getElementById("num").value="00"+(num+1)
document.getElementById("tex").value="ENTER TABLE NAME"
document.getElementById("bs").click()
}
//*********************************************************
function baza3(p)          //
//*********************************************************
{
document.getElementById("ppp").style.visibility="visible"	
num=parseInt(0,10)
mtr=document.getElementById("k").getElementsByTagName("TR")  //
for(var j = 0; j <= mtr.length-1; j++)                       //
{mtd=mtr[j].getElementsByTagName("TD")                       //
 numtt=mtd[2].innerHTML                                      //
if (numtt.substr(0,3)=="000")
{tek=parseInt(numtt,10)                                      //
if (!isNaN(tek) && tek>num)                                  //
{num=tek}
}}
mtd=document.getElementById("cal2_td").innerHTML.split(".")   //
document.getElementById("d").value=mtd[0]                     //
document.getElementById("m").value=mtd[1]                     //
document.getElementById("y").value=mtd[2].substr(2,2)         //
document.getElementById("num").value="000"+(num+1)
document.getElementById("tex").value="ENTER TABLE NAME"
document.getElementById("bs").click()
}
//*******************************************************************
function kart(p) //
//*******************************************************************
{if (document.getElementById("npp").value==0)
{alert("No row selected for card files! Click to select and repeat!")
return
}
opp=document.getElementById("num").value
opp.substr(0,1)
 if (opp.substr(0,1)=="0")
 {alert("The database cannot be converted to a card file!")
  return
 }
 if (opp=="apx" ||  opp=="tmp")
{ alert("The archive or templates cannot be converted in the card file!")
return
}
document.getElementById("kar").click()
}
//*****************************************************************
function sab(event)              //
//******************************************************************
{if (document.getElementById("npp").value==0)
{ alert("No row selected for template! Click to select and repeat!")
}
else
{mhref=document.getElementById("href").value
if (mhref.indexOf(".php")<0)
{alert("The document cannot be a template! Click to select a page and repeat!")
}
else
{if (mhref.indexOf("fol=")>0)
{href2=mhref.split("fol=")
 href3=href2[1].split("&")
 href4=href3[0]
}
 else
{ href2=mhref.split("pages/")
 href4=href2[1]
 document.getElementById("ppp").style.visibility="visible"	
}
href5=href4.split("/")
href6=""
for(var i=0; i<href5.length-1; i++)  
{href6=href6 + href5[i] + "/"
}
document.getElementById("href").value=href6
document.getElementById("st5").click()
}
}
}
obj2=""      //
dat5=""
//********************************************************
function nclic(event)  // 
//********************************************************
{event = event || window.event
var t = event.target || event.srcElement
if (t.tagName=="A")
{t=t.parentNode}
if (t.tagName=="TD" )                                   // 
{mst2=t.parentNode.getElementsByTagName("TD")           // 
if (obj2!="")
{obj2.style.background=""
}
t.style.background="yellow"                  // 
document.getElementById("npp").value=mst2[0].innerHTML
document.getElementById("num").value=mst2[2].innerHTML
if (mst2[2].innerHTML.substr(0,1)=="0")                 //
{document.getElementById("num").readOnly=true
document.getElementById("d").readOnly=true
document.getElementById("m").readOnly=true
document.getElementById("y").readOnly=true
//document.getElementById("caz").disabled=true
//document.getElementById("clea").disabled=true
}
else                                                    // 
{document.getElementById("num").readOnly=false
document.getElementById("d").readOnly=false
document.getElementById("m").readOnly=false
document.getElementById("y").readOnly=false
//document.getElementById("caz").disabled=false
//document.getElementById("clea").disabled=false
}
mdat=mst2[1].innerHTML.split(",")
d=mdat[0]
m=mdat[1]
y=mdat[2]
dat5=mst2[1]
document.getElementById("d").value=d                     //
document.getElementById("m").value=m
document.getElementById("y").value=y
document.getElementById("olda").value=d+","+m+","+y+"_"+mst2[2].innerHTML
document.getElementById("oldi").value=mst2[3].getElementsByTagName("A")[0].innerHTML
document.getElementById("href").value=mst2[3].getElementsByTagName("A")[0].href
document.getElementById("tex").value=mst2[3].getElementsByTagName("A")[0].innerHTML
document.getElementById("ext").value=mst2[5].innerHTML

obj2=t
}
}
//******************************************************************************
function vpod()    //
//******************************************************************************
{if (window.parent.document.getElementById('podstx')!=undefined)
{
num=document.getElementById("npp").value
if (num=="0")
{alert("No table selected or no table selected!")
return
}
if (document.getElementById("num").value.substr(0,1)!="0")
{
alert("Not a table selected!")
return
}
op=document.getElementById("href").value
mta=op.split("/pages/")   
mta2=mta[1].split("/")
nov="pages"
for(var ii=0; ii<mta2.length-1; ii++)  
{nov=nov+"/"+mta2[ii]
}
nov=nov+"/1.txt"
window.parent.document.getElementById('podstx').value=nov
delta=document.body.offsetHeight/10
for(var j = 0; j < 11; j++)
{window.parent.document.body.scrollTop=window.parent.document.body.scrollTop-delta
}
}
else
{alert("Only when administering a table!")
}
}
//**************************************************
function tnd(p)   //
//*************************************************
{document.getElementById('k').scrollTop=p}

//***********************************************************
function izs(p) //  
//***********************************************************
{if (p.src.indexOf('no.gif')>0) 
{p.src='d~e~f/yes.gif'}
else
{p.src='d~e~f/no.gif' }}

objsort=""
objselect=""
isort="no"

//*******************************************************************************************************
function clz(p,event) //
//*******************************************************************************************************
{ev = event || window.event
var t = ev.target || ev.srcElement
if (t.tagName!="TH") return

//obj2=""
if (t.parentNode.id=="sort")                       //
{if (objsort!="")                                  //
{if (t.style.background.indexOf("yellow")>=0)      //
{sort2(3)
return
}
objsort.style.background=""
objsort.style.color=""
}
isort=t.lang
t.style.background="yellow"
t.style.color="brown"
objsort=t
if (document.getElementById("ksort").src.indexOf('no.gif')>0)
{sort2(2)}
else
{sort2(1)}
objsort=t
}
else if (t.parentNode.id=="sel")            // 
{if (objselect!="")                         // 
{objselect.style.background=""
objselect.style.color=""}
t.style.background="yellow"
t.style.color="brown"
document.getElementById("zs").innerHTML=t.innerHTML
objselect=t
if (document.getElementById("soob2")!=undefined) document.getElementById("soob2").innerHTML=""
if (document.getElementById("soob3")!=undefined) document.getElementById("soob3").innerHTML=""
document.getElementById("soob").innerHTML="Column "+ t.innerHTML +" for filter is selected"
}
else
{return}
}
//********************************************************
function sort2(p)  // 
//********************************************************
{if (obj2!="")                // 
{obj2.style.background=""
document.getElementById("npp").value=0
obj2=""
}
//
var mss = new Array();        //
is=isort                      //
mas=document.getElementById("tab2").getElementsByTagName("TR")
if (document.getElementById("soob3")!=undefined)
{document.getElementById("soob3").innerHTML=""}
if (document.getElementById("soob2")!=undefined)
{document.getElementById("soob2").innerHTML=""}
if (p==3)        //
{p=1
is=0
isort="no"
objsort.style.background=""
objsort.style.color=""
document.getElementById("soob").innerHTML="Sorting canceled"
}
else if (p==1)
{document.getElementById("soob").innerHTML="Sort ascending, column "+(parseInt(is,10)+1)+" !"}
else if (p==2)
{document.getElementById("soob").innerHTML="Sort Descending, Column "+(parseInt(is,10)+1)+" !"}
//*********************************************
if (is==0)     //  
{for(var j = 0; j <mas.length ; j++)
{mas2=mas[j].getElementsByTagName("TD")
tt=mas2[0].innerHTML
tt2="0000000"+tt
tt2=tt2.substr(parseInt(tt.length))
mss[j]=tt2+"#"+(j)
}}
//**************************************
else if (is==1 )     //
{for(var j = 0; j <mas.length ; j++)
{mas2=mas[j].getElementsByTagName("TD")
mtt=mas2[1].innerHTML.split(",")
tt=mtt[2]+mtt[1]+mtt[0]
mss[j]=tt+"#"+(j)
}}
//**************************************
else if (is==2)  //
{
for(var j = 0; j <mas.length ; j++)
{mas2=mas[j].getElementsByTagName("TD")
tt=mas2[2].innerHTML
tt2=tt+"0000000"
tt2=tt2.substr(0,parseInt(tt.length))
mss[j]=tt2+"#"+(j)
}
}
//**************************************
else if (is==3)  //
{for(var j = 0; j <mas.length ; j++)
{mas2=mas[j].getElementsByTagName("A")
tt= mas2[0].innerHTML
tt=tt.substr(0,10)
tt2=tt+"0000000"
tt2=tt2.substr(0,parseInt(tt.length))
mss[j]=tt2+"#"+(j)
}
}
//**************************************
else if (is==4)  // 
{for(var j = 0; j <mas.length ; j++)
{mas2=mas[j].getElementsByTagName("TD")
tt= mas2[4].innerHTML
tt=tt.substr(0,10)
tt2=tt+"0000000"
tt2=tt2.substr(0,parseInt(tt.length))
mss[j]=tt2+"#"+(j)
}
}
//**************************************
else if (is==5)  // 
{for(var j = 0; j <mas.length ; j++)
{mas2=mas[j].getElementsByTagName("TD")
tt= mas2[0].innerHTML
tt=tt.substr(0,10)
tt2=tt+"0000000"
tt2=tt2.substr(0,parseInt(tt.length))
mss[j]=tt2+"#"+(j)
}
}


mss=mss.sort()
mtr="<table border=1 id=tab2 width=100%><TBODY onclick=nclic(event)>"
if (p==1)
{
for(var j = 0; j < mas.length; j++)
{sss=mss[j].split("#")
iii=parseInt(sss[1])
mtr=mtr+mas[iii].outerHTML
}}
else
{for(var j = mas.length-1; j>=0; j--)
{sss=mss[j].split("#")
iii=parseInt(sss[1])
mtr=mtr+mas[iii].outerHTML
}}
document.getElementById("tab2").outerHTML=mtr+"</TBODY></table>"
document.getElementById("k").scrollTop=0
}

//********************************************************************************
function help(p)   // 
//*********************************************************************************
{if (obj2=="")
{alert("There is NO selected row.")	
return	
}
if (obj2.parentNode.getElementsByTagName("TD")[2].innerHTML.substr(0,1)!="0")
{alert("The selected row is not a table!")	
return	
}
mas=document.getElementById("tab2").getElementsByTagName("TR")
mhref=obj2.parentNode.getElementsByTagName("A")[0].href.split("/")
im=mhref[mhref.length-1].replace(".php","")
im=im.replace("%5E","^")
pap2=mhref[mhref.length-2]
pap=mhref[mhref.length-4]
document.getElementById("tohelp").href='zsite.php?site='+pap+'/contents/'+pap2+'/'+pap2+'/'+im+'.htm&nam='+
pap2+" "+im+'.htm&fol='+pap+'/contents/'+pap2+'/'+pap2+'&utf8=2'
document.getElementById("tohelp").click()
}

//*******************************************************
function topr(event)   //
//*******************************************************
{newstr2="<b>Website: </b>"+document.getElementById("sname2").innerHTML
newstr2=newstr2+"<h2 style='text-align:center'>List of page objects «"+document.getElementById("imya").innerHTML+
"»"
if (document.getElementById('tabs')!=undefined)
{newstr2=newstr2+"&nbsp;&nbsp;&nbsp;"+document.getElementById('tabs').innerHTML
}
newstr2=newstr2+"</h2>"
is=""
if (isort!="no")
{if (document.getElementById("ksort").src.indexOf("yes.gif")>0)
{is="  sort by column N "+(parseInt(isort,10)+1)+ " Ascending "
}
else
{is=" sort by column N "+(parseInt(isort,10)+1)+" descending"
}}
if (fi2)
{newstr2=newstr2+ "Filter by '"+
document.getElementById("goto").value+"' in "+document.getElementById("zs").innerHTML+ is 
}
else
{newstr2=newstr2+is
}
mstr=document.getElementById("tab2").getElementsByTagName("TR")
newstr2=newstr2+"<table width=100% border=1><tr><th>N</th><th>Date</th><th>Number</th>"+
"<th>Name</th><th>KB</th><th>Type</th></tr>"+
"<tr><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th></tr>"
for(var j = 0; j <mstr.length; j++)  
{if (mstr[j].style.display!="none")
{newstr=""
mstrtd=mstr[j].getElementsByTagName("TD")
mstrtd2=mstr[j].getElementsByTagName("A")
newstr=newstr+"<tr><td>"+mstrtd[0].innerHTML+"</td>"
newstr=newstr+"<td>"+mstrtd[1].innerHTML+"</td>"
newstr=newstr+"<td>"+mstrtd[2].innerHTML+"</td>"
newstr=newstr+"<td>"+mstrtd2[0].innerHTML+"</td>"
newstr=newstr+"<td>"+mstrtd[4].innerHTML+"</td>"
newstr=newstr+"<td>"+mstrtd[5].innerHTML+"</td></tr>"
newstr2=newstr2+newstr
}}
newstr2=newstr2+"</table>"
dop=window.open("","","");
tnap="<HTML><HEAD><META http-equiv=Content-Type content='text/html; charset=windows-1251'></head>"
tnap=tnap+newstr2+"</html>"
dop.document.write(tnap)}

//************************************************************************************
function kc(p)   //
//************************************************************************************
{if (document.activeElement.tagName=="INPUT"|| document.activeElement.tagName=="TEXTAREA" ) 
{return}
if (p==46)
{document.getElementById("46").click()}
else if (p==49 || p==97)   // st1
{document.getElementById("49").click()}
else if (p==50 || p==98)   // st2
{document.getElementById("50").click()}
else if (p==51 || p==99)   // st3
{document.getElementById("51").click()}
else if (p==52 || p==100)   // help
{document.getElementById("52").click()}
else if (p==53 || p==101)   //
{document.getElementById("53").click()}
else if (p==54 || p==102)   //
{document.getElementById("54").click()}
else if (p==55 || p==103)   //
{document.getElementById("55").click()}
else if (p==56 || p==104)   //
{document.getElementById("56").click()}
else if (p==57 || p==105)   // s
{document.getElementById("57").click()}
}

fi2=false     // 
//****************************************************************************************
function got(p)   // 
//****************************************************************************************
{if (p==2 &&  !fi2)
{return	}	
mtr2=document.getElementById("k").getElementsByTagName("TR")  //
if (p==2)
{for(var j = 0; j <= mtr2.length-1; j++)
{mmtr2=mtr2[j].getElementsByTagName("TD")
mtr2[j].style.display=""
}
fi2=false	
document.getElementById("soob").innerHTML="Filter canceled!"
return
}
if (document.getElementById("goto").value=="" && p==0)
{alert("Enter the filter context!")	
return}
if (document.getElementById("zs").innerHTML=="?")
{alert("No column selection! Click the desired column in the table!")
return}
kont=document.getElementById("goto").value
mkont=kont.split("/")
for(var jj = 0; jj <= mkont.length-1; jj++)
{if (mkont[jj]=="")
{alert("Empty context in filter list!")
return
}}

//
fi=parseInt(document.getElementById("zs").innerHTML,10)-1
//
if (obj2!="")
{obj2.style.background=""
obj2=""
}
for(var j = 0; j <= mtr2.length-1; j++)
{mmtr2=mtr2[j].getElementsByTagName("TD")
if (fi==3)
{text2=mmtr2[3].getElementsByTagName("A")[0].innerHTML	
}
else
{text2=mmtr2[fi].innerHTML}
fi2=true
if (p==3)
{
for(var jj = 0; jj <= mkont.length-1; jj++)
{if  (true)    //(fi!=0)
{if (text2.indexOf(mkont[jj])==0)
{document.getElementById("k").scrollTop=mtr2[j].offsetTop
document.getElementById("soob").innerHTML="Jump"
return}
}
}
}	
else
{
for(var jj = 0; jj <= mkont.length-1; jj++)
{if (fi!=0)
{if (text2.indexOf(mkont[jj])>=0)
{mtr2[j].style.display="";break}
else
{mtr2[j].style.display="none"
}}
else
{if (text2==mkont[jj])
{mtr2[j].style.display="";break}
else
{mtr2[j].style.display="none"
}}}
}

}
document.getElementById("soob").innerHTML="Filtering!"
}
//********************************************************
function odk() //
//********************************************************
{document.getElementById("caz").disabled=false
document.getElementById("num").value=""
document.getElementById("num").readOnly=false
document.getElementById("tex").value=""
if (obj2!="")
{obj2.style.background=""
obj2=""
}
}

</script>
</body></html>