Location: PHPKode > projects > PHP Newsgroup Reader > top.php
<link href="javascript/style.css" type=text/css rel=stylesheet>
<?php
	include("init.inc");

?>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script><meta http-equiv="Content-Type" content="text/html; charset=big5">
<body bgcolor="#f3f3f3">
<A href="http://sourceforge.net"> </A> 
<table border="0" align="left" bgcolor="#BECCE7">
  <tr>
    <td><a href="http://sourceforge.net/projects/webmynews/" target="_blank"><font color="#FFFFFF" size="6" face="Courier New, Courier, mono"><em><strong>W 
      e b M y N e w s</strong></em></font></a></td>
  </tr>
</table>
<table border="0" align="right" bgcolor="#BECCE7">
  <tr> 
	<TD><a href="http://sourceforge.net/projects/webmynews/" target="_blank"><font color="#FFFFFF" size="6" face="Courier New, Courier, mono"><em></em></font></a></TD>
<?
	if ( !isset($_GET["server"]) )
	{
	print("<FORM name=form method=GET target=top action=top.php>");
	print("<td nowrap><strong>Please select a Newsgroup server :</strong></td><TD nowrap>\n");
	print("<select id=server name=server onChange='this.form.submit();'>\n");

	/*$server_arr = array("news.3home.net", "news2.3home.net", "news.school.net.hk", "news.balabu.net", "news.linux.org.hk", "news.netgod.org.hk",
						"news.newsgroup.com.hk", "news.hkpcug.org", "news.hkux.net", "news.hkpeople.net",
						"news.popart.com.hk", "www.visualmedia.com.hk", "news.hkteen.org", "202.85.134.146");*/
	$server_arr = array("news2.3home.net", "news.hkpcug.org");
	sort($server_arr);

	if ( !isset($_GET["server"]) )
		print("<option value=# selected>----CLICK IT----</option>\n");
	for ($i=0; $i<count($server_arr); ++$i)
	{
		$st = "";
		if ( isset($_GET["server"])&&($_GET["server"]==$server_arr[$i]) )
			$st = "selected";		
		print("<option value=$server_arr[$i] $st>$server_arr[$i]</option>\n");
	}
	print("</select></FROM></td>");
	}else{
		print("<TD noWrap><strong>Please select a Newsgroup :</strong></TD>");
		print("<FORM name=selection method=GET action=left.php target=left>");
		$server = $_GET["server"];
		print("<input type=hidden name=server value=$server>");
		print("<input type=hidden name=page value=1>");
/*		print("<TD nowrap><select id=server name=server onChange='this.form.submit();'>\n");
		print("<option value=$server selected>$server</option></select></TD>\n");
		print("<TD noWrap>Please select a Group :</TD>");
*/
		$fp = fsockopen($server, 119);
	    $st = fgets($fp, 1024);
        fputs($fp, "list\n");
	    $st = fgets($fp, 1024);
		print("<TD nowrap>\n");
		print("<select id=group name=group onChange='this.form.submit();'>\n");

		$i = 0;
/*		$file_exist = 1;
		if ( !file_exists("file/pop_news.$server.html") )
		{
				$file_exist = 0;
				@mkdir("file",0755);			
				$fp_pop_news = fopen("file/pop_news.$server.html", "wb");
		}
		do{
				$st = fgets($fp, 1024);
				if ( $st[0]!='.' )
				{
						@list($group[++$i], $tmp, $tmp, $tmp) = split(" ", $st, 4);
						if ( !$file_exist )
								$pop_news[$group[$i]] = 0;
				}
		}while ( $st[0]!='.' );
		if ( !$file_exist )
		{
				fputs($fp_pop_news, serialize($pop_news));
				fclose($fp_pop_news);
		}*/

		print("<option value=# selected>----CLICK IT----</option>\n");
		do{
				$st = fgets($fp, 1024);
				if ( $st[0]!='.' )
				{
						@list($group[++$i], $tmp, $tmp, $tmp) = split(" ", $st, 4);
				}
		}while ( $st[0]!='.' );
		fputs($fp, "QUIT\n");
		fclose($fp);

/*		$replace1 = array(chr(13), chr(10));
		$replace2 = array('', '');
		$fp_pop_news = fopen("file/pop_news.$server.html", "rb");
		$pop_news = unserialize(str_replace($replace1, $replace2, fgets($fp_pop_news)));
		fclose($fp_pop_news);
  print("<PRE>");
  print_r($pop_news[$server]);
  print("</PRE>");
		asort($pop_news[$server]);
  print("<PRE>");
  print_r($pop_news[$server]);
  print("</PRE>");
  exit(0);
		$i=count($group)+1;
		while ( $pop_news[$group[--$i]]!=0 );

		for ($j=count($group); $j>$i; --$j)
				print("<option value=".$group[$j].">".$group[$j]."</option>\n");
		print("<option value=# selected>----CLICK IT----</option>\n");*/


		sort($group);
		for ($i=1; $i<count($group); ++$i)
				print("<option value=".$group[$i].">".$group[$i]."</option>\n");
		print("</select></TD></FORM>");
		print("<TD> <form name=form method=post action=top.php><input type=submit name=submit value=Back></form></TD>");
		print("</tr>");
	}
?>
</table>
Return current item: PHP Newsgroup Reader