<?php header('Content-Type: text/html; charset=windows-1251'); ?>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>Moderation of Questions-Answers</title>
</head>
<?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, please contact the ADMINISTRATOR!
<li> Close site
<li> Check back later!
</ol>
</td></tr>
</table>
</td><td width=30%>&nbsp;</td></tr></table></body></html>';
die;
}
?>
<body background="d~e~f/bkg4.gif" topMargin=0 style="overflow:hidden" width=100% height=100%>
<div id=ppp style="z-index:2;opacity:0.3;visibility:hidden;height:100%;width:100%;position:absolute;top:0;left:10;background:black;filter:alpha(opacity=30)">&#160;&#160;&#160;</div>
<?php
include "f.php";                             //
if (isset($_GET['utf8']))
{$utf8=$_GET['utf8'];}
else
{$utf8="";}
if (isset ($_REQUEST['nam']))
{$nam=$_REQUEST['nam'];}
else
{$nam=$_GET['nam'];} 
if (isset ($_REQUEST['site']))
{$site=$_REQUEST['site'];}
else
{$site=$_GET['site'];} 
$fol=str_replace(".htm","",$site);              //
if  (strpos($site,'/contents/')>0)              //
{list($a1,$a2,$a3,$a4,$a5)=explode("/",$site);  //
$fol=$a1."/".$a2."/".$a3;}
else
{$fol=str_replace(".htm","",$site);             //
}
?>
<form id="form" method="POST" enctype="multipart/form-data" action="modtq.php
<?php echo '?site='.$site.'&utf8='.$utf8.'&nam='.$nam;?>
">
<b style="color:red;font-family:tahoma;font-size:12px;font-weight:bold;">WEBSITE:</b> 
<b style="color:#316290;font-family:tahoma;font-size:12px;font-weight:bold;" id=sname2>
<?php
include "plan/name.txt";
?>
</b>


<table border="0" width=100% height=100%><tbody>
<TR><td valign=top>
<table border="0" width=100% height=100%><tbody><TR>
<td valign=top>
<table border="1" width=100% style="border:2px brown solid  ">
<TR>
<THEAD>
<TR><TH width=20px>
<small>N</small></TH>
<TH>
<table border=0 width=100% >
<tr><td align=center title="Ip - the address of the author of the question; Character - a picture reflecting the nature of the question;
Date - the date the question was entered;
Name - the name of the author of the question "> 
<b>Asked:&nbsp;&nbsp;Ip&nbsp;,&nbsp;Character&nbsp;,&nbsp; Date&nbsp;</b>
</td>
</tr>
<tr><td  style="background:white" > 
<b>Question</b>
</td></tr>
<tr><td align=center > 
<b>Answered</b>
</td></tr>
<tr><td  style="background:white" > 
<b>Answer</b>
</td></tr>
</table>
</TH>
<TH width=22px title="show/hide">v</TH>
<TH  width=22px title="Delete">x</TH>
<TH  width=10px >&nbsp;</TH>
</TR></THEAD></table>
<DIV id=k  onclick=vib(event) style="OVERFLOW: scroll; HEIGHT: 55%" align=left>
<table  border="1" width=100% style="" ><tbody>
<TBODY>
<?php
$soob=""; 						 // 
//***************************************************************************************************************
if (isset ($_REQUEST['de']))    // 
//**************************************************************************************************************
{$w=fopen(wu(getcwd ( ).'/pages/'.$fol.'/tq/tq.txt',$utf8), 'w') or exit; //
$wh=fopen(wu(getcwd ( ).'/pages/'.$fol.'/tq/tq.htm',$utf8), 'w') or exit; //
fclose($w);   // 
fclose($wh);  // 
$soob="<b style=color:brown>All deleted!</b>";

}
//************************************************************************************************************
if (isset ($_REQUEST['red']))                     //
//************************************************************************************************************
{ $ab=trim(stripslashes ($_REQUEST['ab']));            //
 $ot=trim(stripslashes ($_REQUEST['ot']));             //
 $ab=htmlspecialchars($ab, ENT_QUOTES,'cp1251');       //
 $ot=htmlspecialchars($ot, ENT_QUOTES,'cp1251');       //
 $ab=str_replace("\r\n","<br>",$ab);  // 
 $ot=str_replace("\r\n","<br>&nbsp;&nbsp;&nbsp;",$ot);
  $nus=$_REQUEST['npp']; 					           //
 if ($ab=="") {$ab="Page host";}	               //
 if ($ot=="") {$ot="Thinks how to answer the question";}   //
 $ff=wu(getcwd().'/pages/'.$fol.'/tq/tq.txt',$utf8);
 $l = file(wu($ff,$utf8)); 					           //
 $w = fopen(wu($ff,$utf8), 'w') or exit;  	           //
 foreach ($l as $li => $lin)                           //
  {if ($li==$nus-1)  					               //
   {    list($ip,$ka,$im,$d,$t,$ab1,$ot1,$p)=explode("//",$lin);
    $lin=$ip.'//'.$ka.'//'.$im.'//'.$d.'//'.$t.'//'.$ab.'//'.$ot.'//+'."\r\n";
   } // 
   fwrite($w,$lin);}                                  // 
   fclose($w);
$soob="<b style=color:brown>The answer is accepted! Click 'Execute' to post your answer to the page</b>";
}
//********************************************************************************************************
if (isset ($_REQUEST['hid']))                        // 
//********************************************************************************************************
{// 
//
$l = file(getcwd().'/pages/'.$fol.'/tq/tq.txt');     //
foreach ($l as $li => $lin)  
{
if (substr(trim($lin),0,1)!="*")                            //
{list($ip,$ka,$im,$d,$t,$ab,$ot,$p)=explode("//",$l[$li]);  //
$l[$li]=$ip.'//'.$ka.'//'.$im.'//'.$d.'//'.$t.'//'.$ab.'//'.$ot.'//-'."\r\n";
}}
foreach ($_REQUEST as $i => $z)                             //
  {if (substr($i,0,2)=="uu")                                //
  {$k=trim(substr($i,2));
   $l[$k]="uu";                                             //
  }
else
 {if (substr($i,0,2)=="pp")                                // 
 {$k=trim(substr($i,2));
 list($ip,$ka,$im,$d,$t,$ab,$ot,$p)=explode("//",$l[$k]);
 if ($p!="+")                                              // 
  {$l[$k]=$ip.'//'.$ka.'//'.$im.'//'.$d.'//'.$t.'//'.$ab.'//'.$ot.'//+'."\r\n";
  }                                                       //  
 }}}
// 
$w=fopen(wu(getcwd ( ).'/pages/'.$fol.'/tq/tq.txt',$utf8), 'w') or exit;  // 
$wh=fopen(wu(getcwd ( ).'/pages/'.$fol.'/tq/tq.htm',$utf8), 'w') or exit; // 
fwrite($wh,'<h2 style="background:#b0c4de;text-align:center" align=center>Questions-Answers</h2><table border=0 width=100%><tbody>');
$ii=1;
  foreach ($l as $li => $lin)  
  {if (trim($lin)=="uu")                                   // 
  {}
  else
  {fwrite($w,$lin);
if (substr($lin,0,1)!="*")                                // 
{list($ip,$ka,$im,$d,$t,$ab,$ot,$p)=explode("//",$l[$li]);
if (trim($p)=="+")                                        // 
{$ww='<tr style="background:#e0ffff">
<td width=10px><b>'.$ii++.'</b></td>
<td width=20px><img src="../d~e~f/'.trim($ka).'"></td>'.
'<td width=70px><nobr><b>'.trim($d).'</nobr></b></td>'.
'<td width=80% colspan=2><b>'.trim($im).'</b><b>,&nbsp;QUESTION:</b></td></tr>'.
'<tr><td></td><td colspan=4>'.trim($t).'</td></tr>'.
'<tr ><td></td><td></td><td style="background:#e0ffff" colspan=3><b>'.$ab.'</b><b>,&nbsp;ANSWERS:</b></td></tr>'.
'<tr><td></td><td></td><td colspan=3>'.$ot.'<hr></td></tr>';
if  (strpos($site,'/contents/')>0)                         //
{$ww=str_replace('../','../../../../',$ww);	
}
fwrite($wh,$ww);
}}
} //
}
fclose($w);                                                //
fwrite($wh,"</tbody></table>");
fclose($wh);                                               //
$soob='<b style="color:brown">The answers to the questions are published on the page!</b>';
}

//***************************************************************************************************************
$mf=wu(getcwd().'/pages/'.$fol.'/tq/tq.txt',$utf8); //
//****************************************************************************************************************
$net=true;
if (file_exists($mf))                                      //
{$net=false;
$l = file($mf);
// 
$ii=1;
foreach ($l as $li => $lin)
{echo "<TR>";
 if (substr($lin,0,1)=="*")                                 // 
{}
 else
 {//
 list($ip,$ka,$im,$d,$t,$ab,$ot,$p)=explode("//",$lin);
echo '<td  width=18px>'.$ii.'</td>';
echo '<td aign=center style="background:white">
<center style="background:#e0ffff;width:100%;FONT-WEIGHT: bold">';
echo "<font>".trim($im).':</font>';
echo "<font>".trim($ip).'</font>,&nbsp;';
echo '<img src="d~e~f/'.trim($ka).'">,&nbsp;';
echo "<font>".trim($d).'</font>&nbsp;&nbsp;&nbsp;';
echo '</center>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
echo "<font>".trim($t)."</font>";
echo '<center style="background:#e0ffff;width:100%;FONT-WEIGHT: bold"><font id=a'.$ii.' >'.$ab.'</font></center>';
echo '<font id=o'.$ii++. ' style="width:100%">&nbsp;&nbsp;&nbsp;'.$ot .'</font>';
echo "</td>";

echo '<td align=center width=18px>';
 if (substr($p,0,1)=="+") 
 {echo '<input type="checkbox"   name="pp'.$li.'" checked>';}
else
 {echo '<input type="checkbox"   name="pp'.$li.'">';}
 echo '<td align=center width=18px>';
 echo '<input type="checkbox"   name="uu'.$li.'">';
 echo '</td>';
 }}}
?>
</tr></tbody></table>
</div>
<table border="0" width=100% height=30% >
<tbody><tr><td width=40px>
<b>Answer author:</b>
</td>
<td>
<input type="text" name="ab" id=ab style="width:100%" >
</td></tr>
<tr><td width=40px>
<b>Enter your answer:</b>
</td>
<td>
<textarea name="ot" id=ot rows=6 style="width:100%"></textarea>
</td></tr></tbody></table>
</td>
<td valign=center width=300px>
<b>
<center><font size=3><b>PAGE QUESTIONS MODERATION</b></font>
<u href=#
<?php
if  (strpos($site,'/contents/')>0)      //
{echo "pages/".$a1."/".$a2."/".$a3."/".str_replace(".htm",".php",$a5);
}
else
{echo "pages/".$fol.'.php';}
?>
><b title="To view the published page, go back to the designer and click 'LOOK'!">
<?php  echo rtr($nam); ?> </u></center>
<li><a  href="help/10.htm#103" target=_blank>&nbsp;Help&nbsp;</a>
<li>
Filter&nbsp;&nbsp;<input type="text" id=goto size="30" title="One or more filtering contexts through
delimiter character '/'">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button onclick=got(0) form=""  
title="Show only those lines that contain context in any part of the question, answer ">
Select</button>&nbsp;&nbsp;&nbsp;
<button form="" onclick=got(2) title="Cancel selection">&nbsp;X&nbsp;</button>
&nbsp;&nbsp;&nbsp;To print&nbsp;&nbsp;&nbsp;<button form="" style=width:30 onclick=ptab()>P</button>

<li> All received questions are shown in the table!
<li> Select to show columns "v"
<li> Select to delete column "x"
<li> Tags as text, Enter as indented text on a new line.
<li> To delete, save, publish, click the button<center>
<button form="" onclick=dm()
title="Click me to process the marks.">Execute</button>
</center>
<li>To delete all records, click the button
<center>
<button form="" onclick=da() 
>Delete all</button>
</center>

<li>To enter an answer, click the line, enter or change the data and click
<center>
<input type="submit" value="To accept" name="red" id=red
title="After entering the answer click me"
<?php if ($utf8=="" or $net) {echo "disabled";} ?>>
<br>Selected N&nbsp;&nbsp;<input  type="text" value=0 name="npp" id=npp style="width:40">
</center>
<hr>
<center >
<b id=soob style='color:brown'>
<?php
echo $soob;
?>
</b></center>
</td>
</tr></tbody></table>
<input type="submit" value="Execute" name="hid" id=hid style=display:none>
<input type="submit" value="Delete all" name="de" id=de style=display:none>


</form>
<a id=per target=_blank style="visibility:hidden" href=#>+++</a>
</body>

<script type="text/javascript">
//******************************************************
window.onload=function () //
//******************************************************
{obj9= document.getElementById("k")
obj9.style.height=document.getElementById("ppp").offsetHeight-320
obj9.scrollLeft=0
obj9.scrollTop=0
}

//************************************************************
function dm() //
//***********************************************************
{document.getElementById("soob").innerHTML=""
mch=document.getElementById("k").getElementsByTagName("INPUT")
if (mch.length==0)
{alert("Empty!")
return
}
if (!confirm("Marked in X will be deleted, in V shown, changes are published filter canceled? \r\n Click Cancel to cancel"))
{return}
else
{document.getElementById("hid").click()
}}

//************************************************************
function da()  //
//***********************************************************
{document.getElementById("soob").innerHTML=""
mch=document.getElementById("k").getElementsByTagName("INPUT")
if (mch.length==0)
{alert("Empty!")
return
}
if (!confirm("Will all lines be deleted? \r\n Click Cancel to cancel"))
{return}
else
{
document.getElementById("de").click()
}}

obj=""                                      //
//***************************************************************************************************
function vib(event)  // 
//***************************************************************************************************
{event = event || window.event
var t = event.target || event.srcElement
if (t.tagName=="CENTER")
{t=t.parentNode
}
if (t.tagName=="FONT")
{t=t.parentNode
}
if (t.tagName!="TD" )
{return}
if (obj!="")
{obj.style.background=""}
t.parentNode.style.background="yellow"
obj=t.parentNode
mobj=obj.getElementsByTagName("TD");
document.getElementById("npp").value=mobj[0].innerHTML
mobj=obj.getElementsByTagName("FONT");
document.getElementById("ab").value=mobj[4].innerHTML
w=mobj[5].innerHTML
w=w.replace(/&nbsp;/g," ")
w=w.replace(/<br>/g,"\r\n")
document.getElementById("ot").value="    "+ w
}


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++)
{mtr2[j].style.display=""
}
fi2=false     // 
document.getElementById("soob").innerHTML="Filter canceled"
}
//**************************************************************************************************
if (p==0)                                                  // 
{if (document.getElementById("goto").value=="")
{alert("Enter the filter context!")	
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
}}


for(var j = 0; j <= mtr2.length-1; j++)           //
{mmtr2=mtr2[j].getElementsByTagName("FONT")
ye=false
for(var jj = 0; jj <= mmtr2.length-1; jj++)        //
{for(var jjj = 0; jjj <= mkont.length-1; jjj++)    //
{if (mmtr2[jj].innerHTML.indexOf(mkont[jjj])>=0)
{ye=true;break}}
if (ye)
{break}
}
if (!ye)
{mtr2[j].style.display="none";
}
else
{mtr2[j].style.display="";
}
}
fi2=true
document.getElementById("soob").innerHTML="Filtering!"
}}
//********************************************************************
function ptab() //
//********************************************************************
{
newstr2="<b>WEBSITE: </b>"+document.getElementById("sname2").innerHTML
newstr2=newstr2+"<h2 style='text-align:center'>Answers to questions, page «<?php  echo rtr($nam); ?>»</h2>"
if (fi2)
{newstr2=newstr2+ "Filter by '"+
document.getElementById("goto").value+"' in 2"
}
else
{newstr2=newstr2
}
newstr2=newstr2+"<table width=100% border=1>"+
"<tr>"+
"<td align=center width=30>N</td>"+
"<td align=center ><U>Asked: Ip, Character, Date</u><br>QUESTION "+
"<br> <U> Answered </U>: <br> ANSWER"+    
"</td></tr>"+
"<tr>"+
"<td align=center width=30>1</td>"+
"<td align=center >2"+    
"</td></tr>"
mtr2=document.getElementById("k").getElementsByTagName("TR")  //
for(var j = 0; j <= mtr2.length-1; j++)
{
if (mtr2[j].style.display=="")
{
mmtr2=mtr2[j].getElementsByTagName("FONT")
mmtr20=mtr2[j].getElementsByTagName("TD")
newstr2=newstr2+"<tr><td>"+mmtr20[0].innerHTML+"</td><td><center><u>"+mmtr2[0].innerHTML+mmtr2[1].innerHTML+","+
"</u></center>"+ mmtr2[3].innerHTML+"<center><u>"+mmtr2[4].innerHTML+"</u></center>"+mmtr2[5].innerHTML+"</td></tr> "
}
}
newstr2=newstr2+"</table>"
dop=window.open("","","");
tnap="<HTML><HEAD><META http-equiv=Content-Type content='text/html; charset=windows-1251'></head><body>"
tnap=tnap+newstr2+"</body></html>"
dop.document.write(tnap)
}
</script>
</html>