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

📄 comment.php

📁 自己写的一个网络日志(BLOG)系统
💻 PHP
字号:
<?php
!function_exists('usermsg') && exit('Forbidden');

$basename .= '&type='.$type;
!N_InArray($type,array('blog','bookmark','file','goods','music','photo')) && usermsg('undefined_action');

if ($job != 'update') {
	InitGP(array('page','author','keyword','ifcheck','sc'));
	$cmtdb = $catedb = $sltsc = $sltcheck = array();
	$sql = $addpage = $pages = '';
	$sltsc[$sc] = $sltcheck[$ifcheck] = ' SELECTED';
	include_once(D_P."data/cache/forum_cache_$type.php");
	$catedb = ${strtoupper('_'.$type)};
	if (strlen($author) > 0) {
		$sql .= ($sql ? ' AND' : '')." author LIKE '%".str_replace('*','%',$author)."%'";
		$addpage .= "author=$author&";
	}
	if (strlen($keyword) > 0) {
		$sql .= ($sql ? ' AND' : '')." content LIKE '%".str_replace('*','%',$keyword)."%'";
		$addpage .= "keyword=$keyword&";
	}
	if (strlen($ifcheck) > 0 && (int)$ifcheck > -1) {
		$sql .= ($sql ? ' AND' : '')." ifcheck='$ifcheck'";
		$addpage .= "ifcheck=$ifcheck&";
	}
	$sql && $sql = ' AND '.$sql;
	$sc != 'asc' && $sc = 'desc';
	!$db_perpage && $db_perpage = 30;
	$addpage .= "sc=$sc&";
	$orderby = " ORDER BY postdate $sc";
	(int)$page<1 && $page = 1;
	$limit = 'LIMIT '.($page-1)*$db_perpage.",$db_perpage";
	$query = $db->query("SELECT id,cid,author,authorid,postdate,ifcheck,content FROM pw_comment WHERE uid='$admin_uid'$sql $orderby $limit");
	while ($rt = $db->fetch_array($query)) {
		$rt['author'] = substrs($rt['author'],16);
		$rt['cate'] = $rt['cid'] ? $catedb[$rt['cid']]['name'] : $ulang['none'];
		$rt['ifcheck'] = $ulang['ifcheck_'.$rt['ifcheck']];
		$rt['postdate'] = get_date($rt['postdate'],'Y-m-d');
		$rt['content'] = str_replace(array("\r","\n"),'',$rt['content']);
		$rt['content'] = substrs($rt['content'],35);
		$cmtdb[] = $rt;
	}
	$db->free_result($query);
	$count = $db->get_value("SELECT COUNT(*) FROM pw_comment WHERE uid='$admin_uid'$sql");
	if ($count > $db_perpage) {
		require_once(R_P.'mod/page_mod.php');
		$pages = page($count,$page,$db_perpage,"$basename&$addpage");
	}
	include PrintEot('comment');footer();
} else {
	InitGP(array('selid','ntype'),'P');
	$cids = '';
	!is_array($selid) && $selid = array();
	foreach ($selid as $value) {
		if ((int)$value > 0) {
			$cids .= ($cids ? ',' : '')."'$value'";
		}
	}
	!$cids && usermsg('operate_error');
	$userdb = $itemdb = array();
	$sqlwhere = strpos($cids,',')===false ? "=$cids" : " IN ($cids)";
	$query = $db->query("SELECT uid,itemid,ifcheck FROM pw_comment WHERE id{$sqlwhere}");
	if ($ntype == 'delete') {
		while ($rt = $db->fetch_array($query)) {
			if ($rt['ifcheck']) {
				$userdb[$rt['uid']]['comments']++;
				$itemdb[$rt['itemid']]['replies']++;
			}
		}
		$db->free_result($query);
		foreach ($userdb as $key => $value) {
			$db->update("UPDATE pw_user SET comments=comments-'".(int)$value[comments]."' WHERE uid='$key'");
		}
		foreach ($itemdb as $key => $value) {
			$db->update("UPDATE pw_items SET replies=replies-'".(int)$value[replies]."' WHERE itemid='$key'");
		}
		$db->update("DELETE FROM pw_comment WHERE id{$sqlwhere}");
	} elseif ($ntype == 'allowcheck') {
		while ($rt = $db->fetch_array($query)) {
			if (!$rt['ifcheck']) {
				$userdb[$rt['uid']]['comments']++;
				$itemdb[$rt['itemid']]['replies']++;
			}
		}
		$db->free_result($query);
		foreach ($userdb as $key => $value) {
			$db->update("UPDATE pw_user SET comments=comments+'".(int)$value[comments]."' WHERE uid='$key'");
		}
		foreach ($itemdb as $key => $value) {
			$db->update("UPDATE pw_items SET replies=replies+'".(int)$value[replies]."' WHERE itemid='$key'");
		}
		$db->update("UPDATE pw_comment SET ifcheck='1' WHERE id{$sqlwhere}");
	}
	usermsg('operate_success');
}
?>

⌨️ 快捷键说明

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