phorum\include\ftopic.ppc :: ppC++ web compiler
   <?
 int topicn = ppc.int(ppc.read_file("dat/top_"+ppc.s+"_topics"));
if(ppc.sop=="new"){?>
	<script language=JavaScript>
	function submtopic(){
		if(document.topicf.author.value=='')
			alert('Enter your name');
		else if(document.topicf.tname.value=='')
			alert('Enter topic name');
		else if(document.topicf.tcont.value=='')
			alert('Enter topic content');
		else document.topicf.submit();			
	}
	</script>
	<form name=topicf method=POST action='<?=ppc.SCRIPT?>?op=ft&sop=addnew&s=<?=ppc.s?>'>
	<h3>Add new topic to "<a href='<?=ppc.SCRIPT?>?op=fsector&s=<?=ppc.s?>'><?=ppc.read_file("dat/sect_"+ppc.s)?></a>"</h3>
	<?oTable2(77)?>
	Your name</td><td><input name=author size=32 
			value='<?=cookie.ppcsimplephorumuname?>'></td></tr>
	<tr><td>Topic name</td><td><input name=tname size=32></td></tr>
	<tr><td>&nbsp;</td><td>
		<textarea cols=64 rows=7 name=tcont></textarea>
	</td></tr>
	<tr><td>&nbsp;</td><td><input type=button value='Publish topic'
										onclick='submtopic()'>
	<?cTable()?>	
	</form>
<?}else if(ppc.sop=="delete"){if(isadmin){
	remove(to_c_str("dat/top_"+ppc.s+"_"+ppc.t));
	remove(to_c_str("dat/top_"+ppc.s+"_"+ppc.t+ppc.string("_auth")));
	remove(to_c_str("dat/top_"+ppc.s+"_"+ppc.t+ppc.string("_cont")));
	remove(to_c_str("dat/top_"+ppc.s+"_"+ppc.t+ppc.string("_date")));
	xredir("Topic removed successfully!", "op=fsector&s="+ppc.s);
	?>
<?}}else if(ppc.sop=="addnew"){
	// adding new topic:
	ppc.save_file("dat/top_"+ppc.s+"_"+ppc.string(topicn), pHTMLt(ppc.tname) );
	ppc.save_file("dat/top_"+ppc.s+"_"+ppc.string(topicn)+"_auth", pHTMLt(ppc.author) );
	ppc.save_file("dat/top_"+ppc.s+"_"+ppc.string(topicn)+"_cont", pHTMLt(ppc.tcont) );
	time_t t;   time(&t);  
	ppc.save_file("dat/top_"+ppc.s+"_"+ppc.string(topicn)+"_date", string(ctime(&t)));
	topicn++;
	ppc.save_file("dat/top_"+ppc.s+"_topics", ppc.string(topicn));
	// saving username in a cookie:
	cookie.set("ppcsimplephorumuname="+ppc.author);
	xredir("Topic is published!", "op=fsector&s="+ppc.s);
}else if(ppc.sop=="show"){
	?><h3><a href='<?=ppc.SCRIPT?>'>Top</a> &gt;
				<a href='<?=ppc.SCRIPT?>?op=fsector&s=<?=ppc.s?>'>
			   <?=ppc.read_file("dat/sect_"+ppc.s)?></a> &gt; 
			   <?=ppc.read_file("dat/top_"+ppc.s+"_"+ppc.t )?></h3>
	<table width='100%' border=0 cellpadding=2 cellspacing=0 bgcolor='#aaaabf'>				
	<tr><td>&nbsp;</td><td align=right><a href='#rreply'>reply to this topic</a></td></tr>
	<tr><td width='20%'><b><?=ppc.read_file("dat/top_"+ppc.s+"_"+ppc.t+"_auth" )?></b>
		<br><br>
		<small><?=ppc.read_file("dat/top_"+ppc.s+"_"+ppc.t+"_date" )?></small>
		</td><td width='80%'><?
	oTable3()?>		
		<pre><?=pHTMLt(ppc.read_file("dat/top_"+ppc.s+"_"+ppc.t+"_cont" ))?></pre>
	<?cTable()?>
	</td></tr>
	</table>
	<?
	// fetching replies here:
	int answ = ppc.int(ppc.read_file("dat/top_"+ppc.s+"_"+ppc.t+"_anum" ));
		bool fee=false;
		for(int i=0;i<answ;++i){
			string ffa=ppc.read_file("dat/top_"+ppc.s+"_"+
											ppc.t+"_"+ppc.string(i)+"_auth");
			if(ffa!=""){oTable4a()?>
				<table border=0 width='100%'><tr><td width='20%'>
					<b><?=pHTMLt(ffa)?></b></td>
				<td width="80%">
				<?if(fee=!fee)oTable1a();else oTable2a();
					cout << "<pre>"<<pHTMLt(ppc.read_file("dat/top_"+ppc.s+"_"+
											ppc.t+"_"+ppc.string(i)+"_cont"))
											<<"</pre>";
				cTable();?></td></tr></table><?
				cTable();
			}
		}	
	?>
	
	
	<hr>	
	<script language=JavaScript>
	function submrepl(){
		if(document.rfo.author.value=='')
			alert('Enter your name');
		else if(document.rfo.cont.value=='')
			alert('Enter topic content');
		else document.rfo.submit();			
	}
	</script>
	<?oTable4(77)?>
	<a name=rreply>REPLY</a>
	<form name=rfo action='<?=ppc.SCRIPT?>?op=reply&s=<?=ppc.s?>&t=<?=ppc.t?>' method=POST>
	<table border=0 width='100%'>
	<tr><td>Your name</td><td><input name=author size=32 
			value='<?=cookie.ppcsimplephorumuname?>'></td>	
	<tr><td>&nbsp;</td><td>
		<textarea cols=64 rows=5 name=cont></textarea>
	</td></tr>
	<tr><td>&nbsp;</td><td><input type=button value='Post reply'
										onclick='submrepl()'>
	</table>
	<?cTable()?>	
<?}?>                       






General Public License
2003 ppC++ team