comment.inc.php

来自「学校网站源码http://您的网址/admin/admin_login.asp 」· PHP 代码 · 共 339 行

PHP
339 行
字号
<?php


function sendcomment( )
{
	global $msql;
	global $tbl_comment;
	global $MenuInfo;
	global $strCommentNTC1;
	global $strCommentNTC2;
	global $strCommentNTC3;
	global $strCommentNTC4;
	global $strCommentNTC0;
	global $strCommentNTC5;
	global $strCommentNTC7;
	global $strCommentNTC6;
	global $strHdNTC4;
	global $strHdNTC5;
	global $strHdNTC6;
	global $strHdNTC7;
	global $tbl_play;
	global $tbl_player;
	$REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];
	$ImgCode = $_POST['ImgCode'];
	$title = $_POST['title'];
	$body = $_POST['body'];
	$star = $_POST['star'];
	$nowmenuid = $_POST['nowmenuid'];
	$nowcoltype = $_POST['nowcoltype'];
	$id = $_POST['id'];
	$face = $_POST['face'];
	$pid = $_POST['pid'];
	$formtype = $_POST['formtype'];
	$bm = $_POST['bm'];
	$coltype = $MenuInfo['coltype'];
	$pic = $_FILES['jpg'];
	$uptime = time( );
	$now = time( );
	$exptime = $uptime - 15;
	if ( $pid == "" )
	{
		$pid = 0;
	}
	if ( $id == "" )
	{
		$id = 0;
	}
	$Ic = $_COOKIE['CODEIMG'];
	$Ic = strrev( $Ic ) + 5 * 2 - 9;
	$Ic = substr( $Ic, 0, 4 );
	if ( $ImgCode == "" || $Ic != $ImgCode )
	{
		$PageMain = err( $strCommentNTC0, "", "" );
		return $PageMain;
	}
	if ( !isset( $_COOKIE['MUSER'] ) || !isset( $_COOKIE['ZC'] ) || $_COOKIE['MUSER'] == "" || $_COOKIE['ZC'] == "" || $_COOKIE['MEMBERTYPEID'] == "" )
	{
		echo "<script>window.location='login.php'</script>";
		exit( );
	}
	else
	{
		$md5 = md5( $_COOKIE['MUSER']."76|01|14".$_COOKIE['MEMBERID'].$_COOKIE['MEMBERTYPE'].$_COOKIE['SE'].$_COOKIE['SM'] );
		if ( $_COOKIE['ZC'] != $md5 )
		{
			echo "<script>window.location='login.php'</script>";
			exit( );
		}
	}
	$name = $_COOKIE['MUSER'];
	$mymid = $_COOKIE['MEMBERID'];
	if ( $pid != "0" && $pid != "" )
	{
		if ( securefunc( "7" ) == false )
		{
			$PageMain = err( $strCommentNTC6, "", "" );
			return $PageMain;
		}
	}
	else if ( securefunc( "6" ) == false )
	{
		$PageMain = err( $strCommentNTC5, "", "" );
		return $PageMain;
	}
	if ( securefunc( "30" ) == true )
	{
		$iffb = 1;
		$strCommentSendOk = $strCommentNTC4;
	}
	else
	{
		$iffb = 0;
		$strCommentSendOk = $strCommentNTC7;
	}
	if ( $title == "" || $body == "" )
	{
		$PageMain = err( $strCommentNTC1, "", "" );
		return $PageMain;
	}
	if ( $nowmenuid == "" || $nowcoltype == "" )
	{
		$PageMain = err( $strCommentNTC2, "", "" );
		return $PageMain;
	}
	$msql->query( "select id from {$tbl_comment} where ip='{$REMOTE_ADDR}' and uptime>{$exptime}" );
	if ( $msql->next_record( ) )
	{
		$PageMain = err( $strCommentNTC3, "", "" );
		return $PageMain;
	}
	if ( $formtype == "hd" && $bm == "1" )
	{
		$msql->query( "select * from {$tbl_play} where id='{$id}'" );
		if ( $msql->next_record( ) )
		{
			$hdstat = $msql->f( "stat" );
			$hdexptime = $msql->f( "exptime" );
			$hdpnums = $msql->f( "pnums" );
			$hdaddnums = $msql->f( "addnums" );
		}
		if ( $hdstat == "1" )
		{
			$PageMain = err( $strHdNTC6, "", "" );
			return $PageMain;
		}
		if ( $hdexptime <= $now )
		{
			$PageMain = err( $strHdNTC5, "", "" );
			return $PageMain;
		}
		if ( $hdpnums <= $hdaddnums )
		{
			$PageMain = err( $strHdNTC4, "", "" );
			return $PageMain;
		}
		$msql->query( "select * from {$tbl_player} where memberid='{$mymid}' and rid='{$id}'" );
		if ( $msql->next_record( ) )
		{
			$PageMain = err( $strHdNTC7, "", "" );
			return $PageMain;
		}
	}
	$updir = ROOTPATH."bbspic";
	if ( 0 < $pic['size'] )
	{
		$arr = uploadimage( $pic['tmp_name'], $pic['type'], $pic['size'], $updir );
		if ( $arr[0] != "err" )
		{
			$pictype = $arr[2];
			$picsrc = $arr[3];
		}
		else
		{
			$PageMain = err( $arr[1], "", "" );
			return $PageMain;
		}
	}
	else
	{
		$pictype = "";
		$picsrc = "";
	}
	if ( $formtype == "hd" && $bm == "1" )
	{
		$msql->query( "insert into {$tbl_player} set \r\n\t\t\r\n\t\trid='{$id}',\r\n\t\tmemberid='{$mymid}',\r\n\t\tname='{$name}',\r\n\t\tdtime='{$now}',\r\n\t\tip='{$REMOTE_ADDR}'\r\n\t\t\r\n\t\t" );
		$msql->query( "update {$tbl_play} set addnums=addnums+1 where id='{$id}'" );
	}
	$title = htmlspecialchars( $title );
	$body = htmlspecialchars( $body );
	$msql->query( "insert into {$tbl_comment} values(\r\n\t   0,\r\n\t   '{$pid}',\r\n\t   '{$nowmenuid}',\r\n\t   '{$nowcoltype}',\r\n\t   '{$id}',\r\n\t   '{$name}',\r\n\t   '{$title}',\r\n\t   '{$body}',\r\n\t   '{$star}',\r\n\t   '{$uptime}',\r\n\t   '{$REMOTE_ADDR}',\r\n\t   '{$iffb}',\r\n\t   '0',\r\n\t   '{$face}',\r\n\t   '0',\r\n\t   '{$name}',\r\n\t   '{$picsrc}'\r\n\t\r\n\t)" );
	$nowbbsid = $msql->instid( );
	if ( $pid != "0" && $pid != "" )
	{
		$msql->query( "update {$tbl_comment} set uptime='{$uptime}',lastname='{$name}' where id='{$pid}'" );
		$PageMain = sayok( $strCommentSendOk, "comment_detail.php?commentid=".$pid, "" );
	}
	else
	{
		$PageMain = sayok( $strCommentSendOk, "comment_detail.php?commentid=".$nowbbsid, "" );
	}
	return $PageMain;
}

function commentdetail( )
{
	global $fsql;
	global $tsql;
	global $tbl_comment;
	global $CommentDetail;
	global $MenuInfo;
	global $tbl_menu;
	global $tbl_company;
	global $tbl_info;
	global $tbl_products;
	global $tbl_play;
	$commentid = $_GET['commentid'];
	$i = 0;
	for ( ;	$i <= 3;	$i++	)
	{
		$zz = rand( 1, 9 );
		$code .= $zz;
	}
	setcookie( "CODEIMG", $code, time( ) + 3600, "/" );
	$fsql->query( "update {$tbl_comment} set cl=cl+1 where id='{$commentid}'" );
	$fsql->query( "select * from {$tbl_comment} where id='{$commentid}' and fabu='1'" );
	if ( $fsql->next_record( ) )
	{
		$title = $fsql->f( "title" );
		$author = $fsql->f( "name" );
		$coltype = $fsql->f( "coltype" );
		$nowmenuid = $fsql->f( "menuid" );
		$rid = $fsql->f( "rid" );
		$ip = $fsql->f( "ip" );
		$dtime = $fsql->f( "uptime" );
		$face = $fsql->f( "face" );
		$cl = $fsql->f( "cl" );
		$picsrc = $fsql->f( "picsrc" );
		$body = $fsql->f( "body" );
		$body = str_replace( "\n", "<br>", $body );
	}
	if ( $picsrc != "" )
	{
		$picsrc = ROOTPATH.$picsrc;
	}
	else
	{
		$picsrc = ROOTPATH."images/dot.gif";
	}
	$fsql->query( "select count(id) from {$tbl_comment} where pid='{$commentid}' and fabu='1'" );
	if ( $fsql->next_record( ) )
	{
		$count = $fsql->f( "count(id)" );
	}
	if ( $rid != 0 )
	{
		switch ( $coltype )
		{
		case "news" :
			$tsql->query( "select fold from {$tbl_menu} where menuid='{$nowmenuid}'" );
			if ( $tsql->next_record( ) )
			{
				$fold = $tsql->f( "fold" );
			}
			$relatelink = ROOTPATH.$fold."/html/".$rid.".html";
			break;
		case "cp" :
			$tsql->query( "select fold from {$tbl_menu} where menuid='{$nowmenuid}'" );
			if ( $tsql->next_record( ) )
			{
				$fold = $tsql->f( "fold" );
			}
			$relatelink = ROOTPATH.$fold."/html/".$rid.".html";
			break;
		case "down" :
			$tsql->query( "select fold from {$tbl_menu} where menuid='{$nowmenuid}'" );
			if ( $tsql->next_record( ) )
			{
				$fold = $tsql->f( "fold" );
			}
			$relatelink = ROOTPATH.$fold."/html/".$rid.".html";
			break;
		}
	}
	else
	{
		$relatelink = "comment.php?coltype=".$coltype;
	}
	$arr = explode( ".", $ip );
	$ip = $arr[0].".".$arr[1].".".$arr[2]."."."*";
	$dtime = date( "Y-n-j H:i:s", $dtime );
	$face = ROOTPATH."face/".$face.".gif";
	$Temp = loadtemp( ROOTPATH."templates/".$MenuInfo['skin']."/tpl_comment_detail.htm" );
	$TempArr = splittbltemp( $Temp );
	$var = array(
		"body" => $body,
		"dtime" => $dtime,
		"title" => $title,
		"ip" => $ip,
		"face" => $face,
		"coltype" => $coltype,
		"picsrc" => $picsrc,
		"count" => $count,
		"relatelink" => $relatelink,
		"author" => $author,
		"rid" => $rid,
		"nowmenuid" => $nowmenuid,
		"cl" => $cl
	);
	$str = showtpltemp( $TempArr['start'], $var );
	$fsql->query( "select * from {$tbl_comment} where pid='{$commentid}' and fabu='1' order by id" );
	while ( $fsql->next_record( ) )
	{
		$stitle = $fsql->f( "title" );
		$sauthor = $fsql->f( "name" );
		$sip = $fsql->f( "ip" );
		$sdtime = $fsql->f( "uptime" );
		$sface = $fsql->f( "face" );
		$scl = $fsql->f( "cl" );
		$sbody = $fsql->f( "body" );
		$spicsrc = $fsql->f( "picsrc" );
		$sbody = str_replace( "\n", "<br>", $sbody );
		$arr = explode( ".", $sip );
		$sip = $arr[0].".".$arr[1].".".$arr[2]."."."*";
		$sdtime = date( "Y-n-j H:i:s", $sdtime );
		$sface = ROOTPATH."face/".$sface.".gif";
		if ( $spicsrc != "" )
		{
			$spicsrc = ROOTPATH.$spicsrc;
		}
		else
		{
			$spicsrc = ROOTPATH."images/dot.gif";
		}
		$var = array(
			"body" => $sbody,
			"dtime" => $sdtime,
			"ip" => $sip,
			"face" => $sface,
			"spicsrc" => $spicsrc,
			"author" => $sauthor
		);
		$str .= showtpltemp( $TempArr['list'], $var );
	}
	$rstr = str_replace( "{#nowmenuid#}", $nowmenuid, $TempArr['end'] );
	$rstr = str_replace( "{#nowcoltype#}", $coltype, $rstr );
	$rstr = str_replace( "{#title#}", $title, $rstr );
	$rstr = str_replace( "{#id#}", $rid, $rstr );
	$rstr = str_replace( "{#pid#}", $commentid, $rstr );
	$rstr = str_replace( "{#RP#}", ROOTPATH, $rstr );
	$str .= $rstr;
	$CommentDetail = array(
		"title" => $title,
		"pagecon" => $str
	);
	return $CommentDetail;
}

?>

⌨️ 快捷键说明

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