<?php
//#*************************************************************************************************************************
 if (isset ($_REQUEST['tmp1']))    //
//*************************************************************************************************************************
{// 
//

 if (isset ($_REQUEST['htm'])) 					    	 //
 {if ($_REQUEST['htm']!="")                              //
 {$fs=$_prhtm.'/_tmp.txt';    // 
//**********************************************************
$re=str_replace("\\","",$_REQUEST['htm']); 			 //
$re=str_replace('disabled=""',"disabled",$re); 		 //
//**********************************************************
 if (isset ($_REQUEST['pu']))                          // 
{ $re=str_replace('name=Q','name=QN',$re);             // 
 $re=str_replace('name=G','name=GN',$re);              // 
 $re=str_replace('name=C','name=CN',$re);              // 
 $re=str_replace('name=O','name=ON',$re);              // 
}
if ($from=="tmp")   //
{$otkuda=getcwd ( ).'/pages/'.$nam1.'/contents/01,01,01_tmp/';
 $re=str_replace('time=','fro='.$nam1.'/contents/01,01,01_tmp/ time=',$re);              // 
}
else if ($from=="apx")
{$otkuda=getcwd ( ).'/pages/'.$nam1.'/contents/01,01,01_apx/';
$re=str_replace('time=','fro='.$nam1.'/contents/01,01,01_apx/ time=',$re);              // 
}
else
{$otkuda=getcwd ( ).'/sampl/y';
}
//************************************
//
if (strpos($re,'id=eg ')>0) 
//************************************
{$scf="1.html,2.html,3.html,4.html,5.html,6.html,7.html,8.html,9.html,10.html,11.html,12.html,eg.php,p.html,eg.html";     //
$kuda=$_pohtm."/y";
if (file_exists($kuda))                               // 
{}
else
{mkdir($kuda);                                        // 
$tag1=explode(',',$scf);                              // 
foreach ($tag1 as $k => $z)                           // 
{if (copy($otkuda."/".$z,$kuda."/".$z))               // 
{}
else
 {$os=$os. "<b>Copy error ".$z."</b>";}}
//
}
if ($priz)    //
{$re=str_replace('~~~~~~~',str_replace(".htm","",$imf),$re);
}
else         // 
{$re=str_replace("~~~~~~~/","",$re);}
}
//*************************************
// 
if (strpos($re,'id=zk ')>0) 
//**************************************
{$scf="zk.php,p.html,zk.html,13.html,14.html,15.html,16.html,17.html,18.html,19.html,20.html,21.html,22.html,23.html,24.html,25.html,26.html,27.html,28.html,29.html,30.html,31.html,32.html,33.html,34.html,35.html,36.html,37.html,38.html,39.html,40.html,41.html,42.html";     //
//1.html,2.html,3.html,4.html,5.html,6.html,7.html,8.html,9.html,10.html,11.html,12.html,
$kuda=$_pohtm."/n";
if (file_exists($kuda))                               //
{}
else
{mkdir($kuda,0777);                                       // 
$tag1=explode(',',$scf);                              // 
foreach ($tag1 as $k => $z)                           // 
{if (copy($otkuda."/".$z,$kuda."/".$z))               // 
{}
else
{$os=$os. "<b>Copy error ".$z."</b>";}}
//
}
if ($priz)    //
{$re=str_replace('~~~~~~~',str_replace(".htm","",$imf),$re); // 
}
else         // 
{$re=str_replace("~~~~~~~/","",$re);}
}

//*************************************************************************************************************************************************
if ((strpos($re,'id=lin')>0 or strpos($re,'id="lin"')>0)  and isset ($_REQUEST['so'])) // 
{$re1=$re;
if (strpos($re,'.txt')>0  or strpos($re,'.htm')>0 or  strpos($re,'.php')>0  or strpos($re,'.html')>0)
{if (strpos($re,'outside')>0)                         // 
{//$os=htmlspecialchars($re, ENT_QUOTES);
if (strpos($re,'id="lin"')>0 || strpos($re,'id=lin')>0  )
{$re=str_replace('id="lin"','id="so"',$re);           // 
$re=str_replace('id=lin','id=so',$re);                // 
$re=str_replace('</u>',' - content</u>',$re);      // 
$re=str_replace('</U>',' - content</U>',$re);      // 
}
else
{$re=str_replace('id=lin','id=so',$re);               // 
$re=str_replace('</U>',' - content</U>',$re);      // 
}}
else if ((strpos($re,'/contents/')>0))                // 
{$re=str_replace('.php','.htm',$re); 
//$os=htmlspecialchars($re, ENT_QUOTES);
if (strpos($re,'id=lin')>0 || strpos($re,'id="lin"')>0 ) 
{$re=str_replace('id=lin','id=so',$re);                 //
$re=str_replace('id="lin"','id="so"',$re);              //
$re=str_replace('</U>',' - content</U>',$re);        //
$re=str_replace('</u>',' - content</u>',$re);        //
}
 // 
 // 
 list($be1,$en1)=explode('href="',$re); 
 list($be2,$en2)=explode('.htm"',$en1); 
 $ll = file(getcwd ( ).'/pages/'.$be2.".htm");   	 	//
 foreach ($ll as $lli => $llin)   	                    //
 {//echo htmlspecialchars($llin, ENT_QUOTES)."<hr>";
 if (strpos($llin,'<!--insert-->')>0 
 or strpos($llin,'/tc/tc.htm')>0 
 or strpos($llin,'/tg/tg.htm')>0  
 or strpos($llin,'/tq/tq.htm')>0 
 or strpos($llin,'/tv/')>0 
 or strpos($llin,'name=C')>0 
 or strpos($llin,'name=G')>0  
 or strpos($llin,'name=Q')>0 
 or strpos($llin,'id=eg ')>0 
 or strpos($llin,'id=zk ')>0 
 or strpos($llin,'name="C"')>0 
 or strpos($llin,'name="G"')>0  
 or strpos($llin,'name="Q"')>0 
 or strpos($llin,'id="eg"')>0 
 or strpos($llin,'id="zk"')>0 
 or strpos($llin,' href=')>0 
 or strpos($llin,'id="func"')>0   
 or strpos($llin,'id=func')>0)
   {$os='<b style="color:red">The inserted page itself contains: a link, a module, a diary, a note, an insert and / or a link to one of the tables: comments, entries in the guestbook, questions, voting! It is unacceptable ! The insert will be replaced with a link!</b>'; 
  $re=$re1;   //
  break;
  }}}
 else if (strpos($re,'click="q1(')>0)                  //
{
 $re=str_replace('title=""','',$re);
 $re=str_replace('href="#"','',$re);
$re=str_replace('id=lin','id=so',$re);                   // 
$re=str_replace('id="lin"','id="so"',$re);               // 
$re=str_replace('click="q1(','href=',$re);
 $re=str_replace(',this)"','',$re);
 list($be1,$en1)=explode("href='",$re); 
 list($be2,$en2)=explode(".php'",$en1); 
 $re=str_replace($be2,'../pages/'.$be2."/".$be2,$re);
 $re=str_replace('</U>',' - content</U>',$re);          //
 $re=str_replace('</u>',' - content</u>',$re);          //
 $re=str_replace("'",'"',$re);
 // 
 $ll = file(getcwd ( ).'/pages/'.$be2."/".$be2.".php"); 	//
 foreach ($ll as $lli => $llin)                          	//
 {// name=C name=G name=Q
 if (strpos($llin,'<!--insert-->')>0 
 or strpos($llin,'/tc/tc.htm')>0 
 or strpos($llin,'/tg/tg.htm')>0  
 or strpos($llin,'/tq/tq.htm')>0 
 or strpos($llin,'/tv/')>0 
 or strpos($llin,'name=C')>0 
 or strpos($llin,'name=G')>0  
 or strpos($llin,'name=Q')>0 
 or strpos($llin,'id=eg ')>0 
 or strpos($llin,'id=zk ')>0 
 or strpos($llin,' href=')>0  
 or strpos($llin,'id=func')>0
 or strpos($llin,'name="C"')>0 
 or strpos($llin,'name="G"')>0  
 or strpos($llin,'name="Q"')>0 
 or strpos($llin,'id="eg"')>0 
 or strpos($llin,'id="zk"')>0 
 or strpos($llin,'href=')>0  
 or strpos($llin,'id="func"')>0
)    // 
  {$os='<b style="color:red">The inserted page itself contains: a link; module, insert and / or link to one of the tables: comments, entries in the guestbook, questions, voting! It is unacceptable ! The insert will be replaced with a link! </b>'; 
  $re=$re1;                                                     //
  break;
  }}} 
 else
 {$os='<b style="color:red">Only the contents of files from the outside folder can be inserted into the page!</b>';
 }}
else
{$os='<b style="color:red">Only the contents of the file with the extension txt, htm, html can be inserted into the page!</b>';
}}
//************************************************************************************************************************************
if (strpos($re,'name=V')>0 or strpos($re,'name="V"')>0)         //
{if (isset ($_REQUEST['rez']))                                  //
{$re=str_replace('name=V','name=VR',$re);                       //
$re=str_replace('name="V"','name="VR"',$re);                    //
}
else                                                            //
{$re=str_replace('<TD width=40>','<TD width=40 style="visibility:hidden">',$re);
$re=str_replace('<TD width=35>','<TD width=35 style="visibility:hidden">',$re);
$re=str_replace('<TD width=80>','<TD width=80 style="visibility:hidden">',$re);
$re=str_replace('<td width="40px">','<td width="40px" style="visibility:hidden">',$re);
$re=str_replace('<td width="35px">','<td width="35px" style="visibility:hidden">',$re);
$re=str_replace('<td width="80px">','<td width="80px" style="visibility:hidden">',$re);
}}
//**********************************************************************************************************************************
if (strpos(' '.$re,'<LI>')>0 or strpos(' '.$re,'<li>')>0)   //
{$cou=(int) trim($_REQUEST['kol']);
$spi="";
for ($i =1 ;$i<$cou+1; $i++) 
{$spi=$spi."<li>?";
}
$re=str_replace("</LI>",$spi."</LI>",$re);
$re=str_replace("</li>",$spi."</li>",$re);
}
if (strpos(' '.$re,'<!---ss--->')>0)                          // 
{$re=str_replace("\r",'',trim($re));
$re=str_replace("\n",'',$re);
list($be,$me,$en)=explode("<!---ss--->",$re);
$inw="";
$cou=(int) trim($_REQUEST['kol']);
for ($i =1 ;$i<$cou+1; $i++) 
{$inw=$inw.str_replace('#1',$i,$me);                           // 
}
$re=str_replace($me,$inw,$re);
$re=str_replace("<!---ss--->","",$re);
}
$kb=file_put_contents($fs,$re);
}}}

