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

📄 update_user_points.php

📁 这是php编的论坛的原代码
💻 PHP
字号:
<?php
/***************************************************************************
 *                               update_user_points.php
 *                            -------------------
 *   begin                : Sunday, April 14, 2002
 *   copyright            : (C) 2002 Bulletin Board Mods
 *   email                : ssjslim@yahoo.com
 *
 *   $Id: update_user_points.php,v 1.1.1.1 2003/02/11 22:27:28 wei.gao Exp $
 *
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/
 
define('IN_PHPBB', true);
$phpbb_root_path='./';
include($phpbb_root_path.'extension.inc');
include($phpbb_root_path.'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//

if( !$userdata['session_logged_in'] )
{
	header('Location: ' . append_sid("login.$phpEx?redirect=update_user_points.$phpEx", true));
}

if( $userdata['user_level'] != ADMIN )
{
	message_die(GENERAL_MESSAGE, $lang['Not_Authorised']);
}

$sql = "SELECT user_id 
		FROM " . USERS_TABLE . " 
		WHERE user_id != " . ANONYMOUS;
if(	!$result = $db->sql_query($sql) )
{
	message_die(GENERAL_ERROR, 'Could not!', '', __LINE__, __FILE__, $sql);
}
$users = $db->sql_fetchrowset($result);
$total_users = count($users);

for($i = 0; $i < $total_users; $i++)
{
	$user_id = $users[$i]['user_id'];

	$sql = "SELECT COUNT(*) as all_posts 
			FROM " . POSTS_TABLE . " 
			WHERE poster_id = " . $user_id;
	if(	!$result = $db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Could not!', '', __LINE__, __FILE__, $sql);
	}

	$all_posts = $db->sql_fetchrow($result);

	$sql = "SELECT COUNT(*) as total_topics 
			FROM " . TOPICS_TABLE . " 
			WHERE topic_poster = " . $user_id;
	if(	!$result = $db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Could not!', '', __LINE__, __FILE__, $sql);
	}

	$total_topics = $db->sql_fetchrow($result);

	$total_posts = $all_posts['all_posts'] - $total_topics['total_topics'];
	$total_topics = $total_topics['total_topics'];

	$points = 0;
	$points = $points + ( $total_posts * $board_config['points_reply'] );
	$points = $points + ( $total_topics * $board_config['points_topic'] );

	$sql = "UPDATE " . USERS_TABLE . " 
			SET user_points = $points 
			WHERE user_id = " . $user_id;
	if(	!$db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Could not!', '', __LINE__, __FILE__, $sql);
	}

}

message_die(GENERAL_MESSAGE, 'Done updating user\'s points.');

?>

⌨️ 快捷键说明

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