<?php
//
//*************************************
//
//************************************
if ($os=="")
{
$mmtip=explode("```",$l1[0]);          // 
$kst=count($mmtip);                     //
// 
$stip=" 0,t,d,i,$,L,a,";               //
foreach ($mmtip as $tipi => $tipl)     //
{$tipl1=str_replace("\r\n","",$tipl);
if (strpos($stip,$tipl1)==0)    
 {$os="ERROR: INVALID COLUMN DATA TYPE ".$tipl1."!";break;}
}}

//******************************************************************
// 
//******************************************************************
if ($os=="")
{
$l = file(getcwd ( ).'/'.$tabl); 

for ($i = 0; $i <= count($l)-1; $i++) 
{$kst1=count(explode("```",$l[$i]));
//echo $l[$i]."====".$kst1."<br>";
if ($kst!=$kst1)
{$os="*<br>ERROR: INCORRECT NUMBER OF COLUMNS IN THE ROW OF THE OPENED TABLE!".$kst."!=".$kst1;break;}
 }} 

 
 //********************************************
// 
//********************************************
$tt=explode("```",str_replace("\r\n","",$l[0]));
foreach ($tt as $ti => $tin)
{if ($tin=="L")
{$imspis=getcwd ( )."/".$_2s."/1-".$ti.".txt";    // 
//echo "000";
if  (file_exists($imspis))                             // 
{$sp = file($imspis); 	                               // 
if (count($sp)<=4)
{$os="ERROR: incomplete combo box file in opened table <br>".$imspis."<br>  RESTORE IT FROM SAVED ARCHIVE AND RETRIEVE!";break;
}
$tt2=count(explode("```",$sp[3]));
for ($ii = 5; $ii <= count($sp)-1; $ii++) 
{if (count(explode("```",$sp[$ii]))!=$tt2)
{$os="<br>ERROR: INCORRECT NUMBER OF COLUMNS  LINE! ".($ii-3)." IN LIST!".$imspis;break;}
}}
else
{$otkuda=$abs1.'sampl/baza1/1s/1-4.txt';
if (copy($otkuda,$imspis)) 
{} else 
{$os=$os. "<b>Copy error ".$z."</b>";}
echo "ERROR: The combo box file was deleted, restored from the template to be functional. <br>".
"RESTORE FILE ".$imspis." FROM THE SAVED ARCHIVE AND REPEAT!";break;
}}}

if ($os!="")                                                            // 
{echo '<body  background="../../../../d~e~f/bkg.gif"  leftMargin=0 id=bod topMargin=0 style="overflow:auto;" >';
echo $sss;
if (substr($os, 0, 1)=="*" )  
{$oz=str_replace('<br>'," ",$l[0]); 
$oz=str_replace('<BR>'," ",$oz); 
echo "<table width=100% height=100% border=1><tr ><td><b>";
echo $os."<hr><b style=background:silver>Must:</b> ".$oz."<hr><b style=background:silver>There is:</b> ".$l[$i];
echo "<hr>Should be ".count(explode("```",$oz)).", in fact ".count(explode("```",$l[$i]));
echo "</b></td></tr>";
echo '<tr height=100%><td align=center>
<form id="form" action="'.$pz.'&v=10" method="post" enctype="multipart/form-data" >
<input type=hidden name="com"  value="4">
<b>FILE TABLE:</b>&nbsp;&nbsp;&nbsp;'.getcwd ( ).'/'.$tabl. 
'&nbsp;&nbsp;&nbsp;<button style=background:white onclick=ossav() title="Click me if you want to fix all the wrong lines. Extra columns will be removed at the end, missing columns will be added to the end! ">
correct</button>&nbsp;&nbsp;&nbsp;<br>
<input type=submit  value="" name=submit id=submit style="display:none">
<textarea  name=errors rows=20 style="width:100%;height:100%">';
echo file_get_contents ($ft);// =getcwd ( ).'/'.$tabl;
echo "</textarea></form></td></tr></table>";
echo $ft;
}
else
{echo "<table width=100% height=100%><tr><td valign=center align=center><b>".$os;
echo "</b></big></td></tr></table>";
}
echo '<script type="text/javascript">';
echo 'window.top.document.getElementById("jd").style.display="none";';
echo 'if (window.top.document.getElementById("jd1")!=undefined)';
echo '{window.top.document.getElementById("jd1").style.display="none";}';
echo 'if (window.top.document.getElementById("jd2")!=undefined)';
echo '{window.top.document.getElementById("jd2").style.display="none";}'."\r\n";
echo 'function ossav()';
echo '{
par=document.getElementById("form").action
mpar=par.split(".txt")
form.elements["submit"].click()
}';
echo '</script>';
echo "</body></html>";
die;
}