⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index.lib.php3

📁 使用PHP编程的聊天室
💻 PHP3
📖 第 1 页 / 共 3 页
字号:
//		$icon var allows to set phpMyChat icon as the icon for favorites if it set to 1/true.

function send_headers($title, $icon)
{
	global $ChatPath, $From, $L;
	global $Charset, $FontName, $FontSize;

	if ($title) echo("<TITLE>".APP_NAME."</TITLE>\n");
	?>
	<META NAME="description" CONTENT="phpMyChat">
	<META NAME="keywords" CONTENT="phpMyChat">
	<?php
	if ($icon) echo("<LINK REL=\"SHORTCUT ICON\" HREF=\"${ChatPath}favicon.ico\">\n");

	// For translations with an explicit charset (not the 'x-user-defined' one)
	if (!isset($FontName)) $FontName = "";
	?>
	<LINK REL="stylesheet" HREF="<?php echo($ChatPath); ?>config/start_page.css.php3?<?php echo("Charset=${Charset}&medium=${FontSize}&FontName=${FontName}"); ?>" TYPE="text/css">
	<SCRIPT TYPE="text/javascript" LANGUAGE="javascript">
	<!--
	NS4 = (document.layers) ? 1 : 0;
	IE4 = ((document.all) && (parseInt(navigator.appVersion)>=4)) ? 1 : 0;
	ver4 = (NS4 || IE4) ? "H" : "L";

	// Open the tutorial popup
	function tutorial_popup()
	{
		window.focus();
		tutorial_popupWin = window.open("<?php echo($ChatPath); ?>tutorial_popup.php3?<?php echo("L=$L&Ver="); ?>"+ver4,"tutorial_popup","resizable=yes,scrollbars=yes,toolbar=yes,menubar=yes,status=yes");
		tutorial_popupWin.focus();
	}

	// Open the users popup according to the DHTML capacities of the browser
	function users_popup()
	{
		window.focus();
		users_popupWin = window.open("<?php echo($ChatPath); ?>users_popup"+ver4+".php3?<?php echo("From=$From&L=$L"); ?>","users_popup_<?php echo(md5(uniqid(""))); ?>","width=180,height=300,resizable=yes,scrollbars=yes");
		users_popupWin.focus();
	}

	// Open popups for registration stuff
	function reg_popup(name)
	{
		window.focus();
		url = "<?php echo($ChatPath); ?>" + name + ".php3?L=<?php echo($L); ?>&Link=1";
		pop_width = (name != 'admin'? 350:510);
		pop_height = (name != 'deluser'? 470:190);
		param = "width=" + pop_width + ",height=" + pop_height + ",resizable=yes,scrollbars=yes";
		name += "_popup";
		window.open(url,name,param);
	}

	// The three functions bellow allows to ensure an unique choice among rooms
	function reset_R0()
	{
		<?php
		if (C_VERSION == 2)
		{
			?>
			document.Params.R1.options[0].selected = true;
			document.Params.T.options[0].selected = true;
			document.Params.R2.value = '';
			<?php
		}
		?>
	}

	function reset_R1()
	{
		document.Params.R0.options[0].selected = true;
		document.Params.T.options[0].selected = true;
		document.Params.R2.value = '';
	}

	function reset_R2()
	{
		document.Params.R0.options[0].selected = true;
		document.Params.R1.options[0].selected = true;
	}
	// -->
	</SCRIPT>
	<?php

} // end of send_headers function;



// ----	The layout function draw the initial table/form. It will define three way to go
//		into the chat (the $Ver et $Ver1 var) dependent of the browser capacities:
//		-	those that accept DHTML will use "H" (for highest) named scripts, the others
//			will run "L" (for lowest) named scripts;
//		-	those that support JavaScript1.1 stuff will use a color picker to choose
//			messages colors in the chat/input.php3 script ($Ver is set to "M" for medium
//			if the browser can not support DHTML, else "H"), others a drop down list.

function layout($Err, $U, $R, $T)
{
	global $DbLink;
	global $ChatPath, $From, $Action, $L;
	global $Charset, $DisplayFontMsg, $FontName;
	global $AvailableLanguages;
	global $DefaultChatRooms;
	if ($Err) global $Error;
	?>

<TABLE ALIGN="center" CELLPADDING=5 CLASS="ChatBody"><TR><TD CLASS="ChatBody">

<CENTER>
<FORM ACTION="<?php echo("$Action?L=$L"); ?>" METHOD="POST" AUTOCOMPLETE="OFF" NAME="Params">
<SPAN CLASS="ChatTitle"><?php echo(APP_NAME." ".APP_VERSION); ?></SPAN>
<?php
// Msg for translations with no real iso code
if (isset($FontName) && $FontName != "" && file_exists($ChatPath."localization/${L}/${FontName}.zip"))
{
	if (!isset($Error) && $DisplayFontMsg) echo("<P CLASS='ChatError'>This translation of ".APP_NAME." requires the <A HREF=\"${ChatPath}localization/${L}/${FontName}.zip\" CLASS=\"ChatFonts\">${FontName} font face</A></P>");
}
?>
<P>
<A HREF="<?php echo($ChatPath); ?>tutorial_popup.php3?<?php echo("L=$L&Ver=L"); ?>" onClick="tutorial_popup(); return false" CLASS="ChatLink" TARGET="_blank"><?php echo(L_TUTORIAL); ?></A>
</P>
<P CLASS="ChatP1">
<?php echo(L_WEL_1." ".C_MSG_DEL." ".L_WEL_2." ".C_USR_DEL." ".L_WEL_3); ?>
</P>
<?php
$DefaultRoomFound = 0;
if($DbLink->query("SELECT DISTINCT u.username FROM ".C_USR_TBL." u, ".C_MSG_TBL." m WHERE u.room = m.room AND m.type = 1"))
{
	$Nb = $DbLink->num_rows();
	$link = " <A HREF='${ChatPath}users_popupL.php3?From=$From&L=$L' CLASS='ChatLink' onClick='users_popup(); return false' TARGET='_blank'>";
	echo("<P CLASS='ChatP1'>".L_CUR_1.$link.$Nb." ".($Nb > 1 ? L_USERS : L_USER)."</A> ".L_CUR_2."</P>");
}
if(isset($Error))
{
	echo("<P CLASS='ChatError'>$Error</P>");
}
if (!isset($Ver)) $Ver = "L";
?>

<INPUT TYPE="hidden" NAME="Ver" VALUE="<?php echo($Ver); ?>">
<INPUT TYPE="hidden" NAME="Form_Send" VALUE="1">
<INPUT TYPE="hidden" NAME="L" VALUE="<?php echo($L); ?>">
<INPUT TYPE="hidden" NAME="N" VALUE="<?php echo(C_MSG_NB); ?>">
<INPUT TYPE="hidden" NAME="D" VALUE="<?php echo(C_MSG_REFRESH); ?>">

<TABLE BORDER=0 CELLPADDING=3 CLASS="ChatTable">
<TR CLASS="ChatCell">
	<TD ALIGN=CENTER CLASS="ChatCell">
		<TABLE BORDER=0 CLASS="ChatTable">
		<?php
		// Display flags if necessary
		if (C_MULTI_LANG == 1)
		{
		?>
		<TR CLASS="ChatCell">
			<TD COLSPAN=2 ALIGN=CENTER CLASS="ChatCell">
				<SPAN CLASS="ChatFlags">
				<?php
				asort($AvailableLanguages);
				reset($AvailableLanguages);
				$i = 0;
				while(list($key, $name) = each($AvailableLanguages))
				{
					$i++;
					echo("<A HREF=\"$Action?L=${name}\">");
					echo("<IMG SRC=\"${ChatPath}localization/${name}/flag.gif\" BORDER=0 WIDTH=24 HEIGHT=16 ALT=\"".ucfirst(str_replace("_"," ",$name))."\"></A>&nbsp;");
					if ($i == 15) echo ("<BR>");
				};
				unset($AvailableLanguages);
				?>
				</SPAN>
			</TD>
		</TR>
		<?php
		};

		// Horizontal alignment for cells topic
		$CellAlign = ($Charset == "windows-1256" ? "LEFT" : "RIGHT");
		?>
		<TR CLASS="ChatCell">
			<TH COLSPAN=2 CLASS="ChatTabTitle"><?php echo(L_SET_1); ?></TH>
		</TR>
		<TR CLASS="ChatCell">
			<TD ALIGN=<?php echo($CellAlign); ?> VALIGN=TOP CLASS="ChatCell" NOWRAP><?php echo(L_SET_2); ?> :</TD>
			<TD VALIGN=TOP CLASS="ChatCell">
				<INPUT TYPE=text NAME="U" SIZE=11 MAXLENGTH=10 VALUE="<?php echo(htmlspecialchars(urldecode($U))); ?>" CLASS="ChatBox">
			</TD>
		</TR>
		<TR CLASS="ChatCell">
			<TD ALIGN=<?php echo($CellAlign); ?> VALIGN=TOP CLASS="ChatCell" NOWRAP><?php echo(L_REG_1); ?> :</TD>
			<TD VALIGN=TOP CLASS="ChatCell">
				<INPUT TYPE=password NAME="PASSWORD" SIZE=11 MAXLENGTH=16 CLASS="ChatBox">
			</TD>
		</TR>

		<TR CLASS="ChatCell"><TD CLASS="ChatCell">&nbsp;</TD></TR>

		<TR CLASS="ChatCell">
			<TH COLSPAN=2 CLASS="ChatTabTitle"><?php echo(L_REG_2); ?></TH>
		</TR>
		<TR CLASS="ChatCell">
			<TD ALIGN=center COLSPAN=2 CLASS="ChatCell">
				<BR>
				<A HREF="<?php echo($ChatPath); ?>register.php3?L=<?php echo($L); ?>" CLASS="ChatReg" onClick="reg_popup('register'); return false" TARGET="_blank"><?php echo(L_REG_3); ?></A>
				| <A HREF="<?php echo($ChatPath); ?>edituser.php3?L=<?php echo($L); ?>" CLASS="ChatReg" onClick="reg_popup('edituser'); return false" TARGET="_blank"><?php echo(L_REG_4); ?></A>
				<?php
				if (C_SHOW_DEL_PROF != 0)
				{
					?>
					| <A HREF="<?php echo($ChatPath); ?>deluser.php3?L=<?php echo($L); ?>" CLASS="ChatReg" onClick="reg_popup('deluser'); return false" TARGET="_blank"><?php echo(L_REG_5); ?></A>
					<?php
				}
				if (C_SHOW_ADMIN != 0)
				{
					?>
					|| <A HREF="<?php echo($ChatPath); ?>admin.php3?L=<?php echo($L); ?>&Link=1" CLASS="ChatReg" onClick="reg_popup('admin'); return false" TARGET="_blank"><?php echo(L_REG_35); ?></A>
					<?php
				}
				?>
			</TD>
		</TR>
		<?php
		if (C_VERSION > 0)
		{
			?>
			<TR CLASS="ChatCell">
				<TD COLSPAN=2 CLASS="ChatCell">&nbsp;</TD>
			</TR>
			<TR CLASS="ChatCell">
				<TH COLSPAN=2 CLASS="ChatTabTitle"><?php echo(L_SET_5); ?></TH>
			</TR>
			</TABLE>
			<TABLE BORDER=0 CLASS="ChatTable">
			<TR CLASS="ChatCell">
				<TD ALIGN=<?php echo($CellAlign); ?> VALIGN=TOP CLASS="ChatCell" NOWRAP><?php echo(L_SET_6); ?> :</TD>
				<TD VALIGN=TOP CLASS="ChatCell">
					<SELECT NAME="R0" CLASS="ChatBox" onChange="javascript:reset_R0();">
						<OPTION VALUE=""><?php echo(L_SET_7); ?></OPTION>
						<?php
						// Display default rooms in the drop down list
						$PrevRoom = "";
						if($R != "") $PrevRoom = urldecode($R);

						$DefaultRoomsString = "";
						for($i = 0; $i < count($DefaultChatRooms); $i++)
						{
							$tmpRoom = stripslashes($DefaultChatRooms[$i]);
							$DefaultRoomsString .= ($DefaultRoomsString == "" ? "" : ",").$tmpRoom;
							echo("<OPTION VALUE=\"".htmlspecialchars($tmpRoom)."\"");
							if(strcasecmp($tmpRoom, $PrevRoom) == 0)
							{
								echo(" SELECTED");
								$DefaultRoomFound = 1;
							}
							echo(">".$tmpRoom."</OPTION>");
						}
						?>
					</SELECT>
				</TD>
			</TR>
			<?php
		}
		if (C_VERSION == 2)
		{
			?>
			<TR CLASS="ChatCell">
				<TD ALIGN=<?php echo($CellAlign); ?> VALIGN=TOP CLASS="ChatCell" NOWRAP><?php echo(L_SET_8); ?> :</TD>
				<TD VALIGN=TOP CLASS="ChatCell">
					<SELECT NAME="R1" CLASS="ChatBox" onChange="javascript:reset_R1();">
						<OPTION VALUE=""><?php echo(L_SET_7); ?></OPTION>
						<?php
						// Display other public rooms in the drop down list
						$DbLink->query("SELECT DISTINCT room FROM ".C_MSG_TBL." WHERE type = 1 AND username NOT LIKE 'SYS %' ORDER BY room");
						while(list($Room) = $DbLink->next_record())
						{
							if (!room_in($Room, $DefaultRoomsString))
							{
								echo("<OPTION VALUE=\"".htmlspecialchars($Room)."\"");
								if(strcasecmp($Room, $PrevRoom) == 0 && $DefaultRoomFound == 0)
								{
									echo(" SELECTED");
									$DefaultRoomFound = 1;
								}
								echo(">${Room}</OPTION>");
							}
						}
						$DbLink->clean_results();
						?>
					</SELECT>
				</TD>
			</TR>
			<TR CLASS="ChatCell">
				<TD ALIGN=<?php echo($CellAlign); ?> VALIGN=TOP CLASS="ChatCell" NOWRAP>
					<?php echo(L_SET_9." "); ?>
					<SELECT NAME="T" CLASS="ChatBox">
						<OPTION VALUE="1" <?php if($T == 1 && $DefaultRoomFound == 0) echo("SELECTED"); ?>><?php echo(L_SET_10); ?></OPTION>
						<OPTION VALUE="0" <?php if($T == 0 && $DefaultRoomFound == 0) echo("SELECTED"); ?>><?php echo(L_SET_11); ?></OPTION>
					</SELECT>
					<?php echo(" ".L_SET_12); ?> :
				</TD>
				<TD VALIGN=TOP CLASS="ChatCell">
					<INPUT TYPE="text" NAME="R2" SIZE=11 MAXLENGTH=10 <?php if($DefaultRoomFound == 0 && $R != "") echo("VALUE=\"".htmlspecialchars(urldecode($R))."\""); ?> CLASS="ChatBox" onChange="javascript:reset_R2();">
				</TD>
			</TR>
			<?php
		}
		?>
		</TABLE>
		<P CLASS="ChatP2">
		<?php echo(L_SET_13." "); ?>
		<!-- The onClick handler bellow define version of chat to use depending on js1.1 and DHTML availabilities -->
		<INPUT TYPE="submit" VALUE="<?php echo(L_SET_14); ?>" CLASS="ChatBox" onClick="if (document.images && ver4 == 'L') ver4 = 'M'; document.Params.Ver.value = ver4"> ...
		</P>
	</TD>
</TR>
</TABLE>
<SPAN CLASS="ChatCopy">
&copy; 2000 <A HREF="http://www.phpheaven.net/" CLASS="ChatLink">The phpHeaven Team</A>
</SPAN>
</FORM>
</CENTER>

</TD></TR></TABLE>

<?php
} // end of the layout function
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -