Vergleich reputation.php - 1.6.3 - 1.6.7

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * $Id: reputation.php 5380 2011-02-21 12:04:43Z Tomm $

 * $Id: reputation.php 5750 2012-03-09 12:21:10Z Tomm $

 */

define("IN_MYBB", 1);
define('THIS_SCRIPT', 'reputation.php');


 */

define("IN_MYBB", 1);
define('THIS_SCRIPT', 'reputation.php');


$templatelist = 'reputation_addlink,reputation_no_votes,reputation,reputation_add_error,reputation_deleted,reputation_added,reputation_add,reputation_vote';

$templatelist = 'reputation_addlink,reputation_no_votes,reputation,reputation_add_error,reputation_deleted,reputation_added,reputation_add,reputation_vote,multipage_page_current,multipage_page,multipage_nextpage,multipage';

require_once "./global.php";

require_once MYBB_ROOT."inc/class_parser.php";

require_once "./global.php";

require_once MYBB_ROOT."inc/class_parser.php";

Zeile 76Zeile 76
		output_page($error);
exit;
}

		output_page($error);
exit;
}









	
// If a post has been given but post ratings have been disabled, set the post to 0. This will mean all subsequent code will think no post was given.
if($mybb->input['pid'] != 0 && $mybb->settings['postrep'] != 1)
{
$mybb->input['pid'] = 0;
}


	// Check if this user has reached their "maximum reputations per day" quota
if($mybb->usergroup['maxreputationsday'] != 0 && ($mybb->input['action'] != "do_add" || ($mybb->input['action'] == "do_add" && !$mybb->input['delete'])))

	// Check if this user has reached their "maximum reputations per day" quota
if($mybb->usergroup['maxreputationsday'] != 0 && ($mybb->input['action'] != "do_add" || ($mybb->input['action'] == "do_add" && !$mybb->input['delete'])))

	{
$timesearch = TIME_NOW - (60 * 60 * 24);

	{
$timesearch = TIME_NOW - (60 * 60 * 24);

		$query = $db->simple_select("reputation", "*", "adduid='".$mybb->user['uid']."' AND dateline>'$timesearch'");
$numtoday = $db->num_rows($query);


		$query = $db->simple_select("reputation", "*", "adduid='".$mybb->user['uid']."' AND dateline>'$timesearch'");
$numtoday = $db->num_rows($query);


Zeile 88Zeile 94
		if($numtoday >= $mybb->usergroup['maxreputationsday'])
{
$message = $lang->add_maxperday;

		if($numtoday >= $mybb->usergroup['maxreputationsday'])
{
$message = $lang->add_maxperday;

			eval("\$error = \"".$templates->get("reputation_add_error")."\";");
output_page($error);
exit;

			eval("\$error = \"".$templates->get("reputation_add_error")."\";");
output_page($error);
exit;

		}
}


		}
}


Zeile 100Zeile 106
		$timesearch = TIME_NOW - (60 * 60 * 24);
$query = $db->simple_select("reputation", "*", "uid='".$uid."' AND dateline>'$timesearch'");
$numtoday = $db->num_rows($query);

		$timesearch = TIME_NOW - (60 * 60 * 24);
$query = $db->simple_select("reputation", "*", "uid='".$uid."' AND dateline>'$timesearch'");
$numtoday = $db->num_rows($query);





		if($numtoday >= $mybb->usergroup['maxreputationsperuser'])
{
$message = $lang->add_maxperuser;

		if($numtoday >= $mybb->usergroup['maxreputationsperuser'])
{
$message = $lang->add_maxperuser;

Zeile 110Zeile 116
		}
}


		}
}


	// Has the user given too much reputation to another in the same thread?

 
	if($mybb->input['pid'])
{

	if($mybb->input['pid'])
{

 
		// Make sure that this post exists, and that the author of the post we're giving this reputation for corresponds with the user the rep is being given to.
$post = get_post($mybb->input['pid']);
if($uid != $post['uid'])
{
$mybb->input['pid'] = 0;
}
else
// We have the correct post, but has the user given too much reputation to another in the same thread?

		if($mybb->usergroup['maxreputationsperthread'] != 0 && ($mybb->input['action'] != "do_add" || ($mybb->input['action'] == "do_add" && !$mybb->input['delete'])))
{
$timesearch = TIME_NOW - (60 * 60 * 24);

		if($mybb->usergroup['maxreputationsperthread'] != 0 && ($mybb->input['action'] != "do_add" || ($mybb->input['action'] == "do_add" && !$mybb->input['delete'])))
{
$timesearch = TIME_NOW - (60 * 60 * 24);

			$query = $db->query("
SELECT p.pid
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."reputation r ON (p.pid=r.pid)
WHERE r.uid = '{$uid}'
AND r.dateline > '{$timesearch}'

			$query = $db->query("				
SELECT COUNT(p.pid) AS posts
FROM ".TABLE_PREFIX."reputation r
LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid = r.pid)
WHERE r.uid = '{$uid}' AND r.adduid = '{$mybb->user['uid']}' AND p.tid = '{$post['tid']}' AND r.dateline > '{$timesearch}'


			");

			");

			$numtoday = $db->num_rows($query);



$numtoday = $db->fetch_field($query, 'posts');


if($numtoday >= $mybb->usergroup['maxreputationsperthread'])
{


if($numtoday >= $mybb->usergroup['maxreputationsperthread'])
{

Zeile 165Zeile 178
	// Deleting our current reputation of this user.
if($mybb->input['delete'])
{

	// Deleting our current reputation of this user.
if($mybb->input['delete'])
{

 
		// Only administrators, super moderators, as well as users who gave a specifc vote can delete one.
if($mybb->usergroup['cancp'] != 1 && $mybb->usergroup['issupermod'] != 1 && $existing_reputation['adduid'] != $mybb->user['uid'])
{
error_no_permission();
}


		if($mybb->input['pid'] != 0)
{
$db->delete_query("reputation", "uid='{$uid}' AND adduid='".$mybb->user['uid']."' AND pid = '".intval($mybb->input['pid'])."'");

		if($mybb->input['pid'] != 0)
{
$db->delete_query("reputation", "uid='{$uid}' AND adduid='".$mybb->user['uid']."' AND pid = '".intval($mybb->input['pid'])."'");

Zeile 183Zeile 202
		output_page($error);
exit;
}

		output_page($error);
exit;
}



	

	if($mybb->input['pid'] == 0)
{
$mybb->input['comments'] = trim($mybb->input['comments']); // Trim whitespace to check for length

	if($mybb->input['pid'] == 0)
{
$mybb->input['comments'] = trim($mybb->input['comments']); // Trim whitespace to check for length

Zeile 202Zeile 221
	{
$show_back = 1;
$message = $lang->add_invalidpower;

	{
$show_back = 1;
$message = $lang->add_invalidpower;

		eval("\$error = \"".$templates->get("reputation_add_error")."\";");
output_page($error);































		eval("\$error = \"".$templates->get("reputation_add_error")."\";");
output_page($error);
exit;
}

// The user is trying to give a negative reputation, but negative reps have been disabled.
if($mybb->input['reputation'] < 0 && $mybb->settings['negrep'] != 1)
{
$show_back = 1;
$message = $lang->add_negative_disabled;
eval("\$error = \"".$templates->get("reputation_add_error")."\";");
output_page($error);
exit;
}

// This user is trying to give a neutral reputation, but neutral reps have been disabled.
if($mybb->input['reputation'] == 0 && $mybb->settings['neurep'] != 1)
{
$show_back = 1;
$message = $lang->add_neutral_disabled;
eval("\$error = \"".$templates->get("reputation_add_error")."\";");
output_page($error);
exit;
}

// This user is trying to give a positive reputation, but positive reps have been disabled.
if($mybb->input['reputation'] > 0 && $mybb->settings['posrep'] != 1)
{
$show_back = 1;
$message = $lang->add_positive_disabled;
eval("\$error = \"".$templates->get("reputation_add_error")."\";");
output_page($error);

		exit;
}

		exit;
}

	



	// The length of the comment is too long
if(my_strlen($mybb->input['comments']) > $mybb->settings['maxreplength'])
{

	// The length of the comment is too long
if(my_strlen($mybb->input['comments']) > $mybb->settings['maxreplength'])
{

Zeile 226Zeile 275
		"dateline" => TIME_NOW,
"comments" => $db->escape_string($mybb->input['comments'])
);

		"dateline" => TIME_NOW,
"comments" => $db->escape_string($mybb->input['comments'])
);





	$plugins->run_hooks("reputation_do_add_process");

// Updating an existing reputation
if($existing_reputation['uid'] || $existing_post_reputation['uid'])
{
if($existing_reputation['uid'])

	$plugins->run_hooks("reputation_do_add_process");

// Updating an existing reputation
if($existing_reputation['uid'] || $existing_post_reputation['uid'])
{
if($existing_reputation['uid'])

		{

		{

			$db->update_query("reputation", $reputation, "rid='".$existing_reputation['rid']."'");

			$db->update_query("reputation", $reputation, "rid='".$existing_reputation['rid']."'");

		}

		}

		elseif($existing_post_reputation['uid'])
{
$db->update_query("reputation", $reputation, "rid='".$existing_post_reputation['rid']."'");
}

		elseif($existing_post_reputation['uid'])
{
$db->update_query("reputation", $reputation, "rid='".$existing_post_reputation['rid']."'");
}





		// Recount the reputation of this user - keep it in sync.
$query = $db->simple_select("reputation", "SUM(reputation) AS reputation_count", "uid='{$uid}'");
$reputation_value = $db->fetch_field($query, "reputation_count");

		// Recount the reputation of this user - keep it in sync.
$query = $db->simple_select("reputation", "SUM(reputation) AS reputation_count", "uid='{$uid}'");
$reputation_value = $db->fetch_field($query, "reputation_count");

Zeile 260Zeile 309
		$reputation_value = $db->fetch_field($query, "reputation_count");

$db->update_query("users", array('reputation' => intval($reputation_value)), "uid='{$uid}'");

		$reputation_value = $db->fetch_field($query, "reputation_count");

$db->update_query("users", array('reputation' => intval($reputation_value)), "uid='{$uid}'");

	}

$plugins->run_hooks("reputation_do_add_end");

	}

$plugins->run_hooks("reputation_do_add_end");


eval("\$reputation = \"".$templates->get("reputation_added")."\";");
output_page($reputation);


eval("\$reputation = \"".$templates->get("reputation_added")."\";");
output_page($reputation);

Zeile 285Zeile 334
		elseif($existing_post_reputation['uid'])
{
$comments = htmlspecialchars_uni($existing_post_reputation['comments']);

		elseif($existing_post_reputation['uid'])
{
$comments = htmlspecialchars_uni($existing_post_reputation['comments']);

		}

		}

		$delete_button = "<input type=\"submit\" name=\"delete\" value=\"{$lang->delete_vote}\" />";
}
// Otherwise we're adding an entirely new reputation for this user.

		$delete_button = "<input type=\"submit\" name=\"delete\" value=\"{$lang->delete_vote}\" />";
}
// Otherwise we're adding an entirely new reputation for this user.

Zeile 306Zeile 355
	else
{
$post_rep_info = '';

	else
{
$post_rep_info = '';

	}


	}


	// Draw the "power" options

	// Draw the "power" options

	$positive_power = '';
$negative_power = '';
$vote_check = '';
if($existing_reputation['uid'])
{
$vote_check[$existing_reputation['reputation']] = " selected=\"selected\"";
}
$reputationpower = $mybb->usergroup['reputationpower'];
for($i = 1; $i <= $reputationpower; ++$i)

	if($mybb->settings['negrep'] || $mybb->settings['neurep'] || $mybb->settings['posrep'])









	{

	{

		$positive_title = $lang->sprintf($lang->power_positive, "+".$i);
$positive_power = "\t\t\t\t\t<option value=\"{$i}\" class=\"reputation_positive\" onclick=\"$('reputation').className='reputation_positive'\"{$vote_check[$i]}>{$positive_title}</option>\n".$positive_power;
if($mybb->settings['negrep'])















		$vote_check = '';
$positive_power = '';
$negative_power = '';
$reputationpower = $mybb->usergroup['reputationpower'];

if($existing_reputation['uid'])
{
$vote_check[$existing_reputation['reputation']] = " selected=\"selected\"";
}

if($mybb->settings['neurep'])
{
$neutral_title = $lang->power_neutral;
$neutral_power = "\t\t\t\t\t<option value=\"0\" class=\"reputation_neutral\" onclick=\"$('reputation').className='reputation_neutral'\"{$vote_check[0]}>{$lang->power_neutral}</option>\n";
}

for($i = 1; $i <= $reputationpower; ++$i)

		{

		{

			$negative_title = $lang->sprintf($lang->power_negative, "-".$i);
$negative_power .= "\t\t\t\t\t<option value=\"-{$i}\" class=\"reputation_negative\" onclick=\"$('reputation').className='reputation_negative'\"{$vote_check[-$i]}>{$negative_title}</option>\n";










			if($mybb->settings['posrep'])
{
$positive_title = $lang->sprintf($lang->power_positive, "+".$i);
$positive_power = "\t\t\t\t\t<option value=\"{$i}\" class=\"reputation_positive\" onclick=\"$('reputation').className='reputation_positive'\"{$vote_check[$i]}>{$positive_title}</option>\n".$positive_power;
}

if($mybb->settings['negrep'])
{
$negative_title = $lang->sprintf($lang->power_negative, "-".$i);
$negative_power .= "\t\t\t\t\t<option value=\"-{$i}\" class=\"reputation_negative\" onclick=\"$('reputation').className='reputation_negative'\"{$vote_check[-$i]}>{$negative_title}</option>\n";
}

		}

		}

 

$plugins->run_hooks("reputation_add_end");
eval("\$reputation_add = \"".$templates->get("reputation_add")."\";");
}
else
{
$message = $lang->add_all_rep_disabled;

$plugins->run_hooks("reputation_add_end_error");
eval("\$reputation_add = \"".$templates->get("reputation_add_error")."\";");

	}

	}

	
$plugins->run_hooks("reputation_add_end");

 




	eval("\$reputation_add = \"".$templates->get("reputation_add")."\";");

 
	output_page($reputation_add);
}

// Delete a specific reputation from a user.
if($mybb->input['action'] == "delete")

	output_page($reputation_add);
}

// Delete a specific reputation from a user.
if($mybb->input['action'] == "delete")

{

{

	// Verify incoming POST request
verify_post_check($mybb->input['my_post_key']);


	// Verify incoming POST request
verify_post_check($mybb->input['my_post_key']);


Zeile 351Zeile 422

// Only administrators, super moderators, as well as users who gave a specifc vote can delete one.
if($mybb->usergroup['cancp'] != 1 && $mybb->usergroup['issupermod'] != 1 && $existing_reputation['adduid'] != $mybb->user['uid'])


// Only administrators, super moderators, as well as users who gave a specifc vote can delete one.
if($mybb->usergroup['cancp'] != 1 && $mybb->usergroup['issupermod'] != 1 && $existing_reputation['adduid'] != $mybb->user['uid'])

	{

	{

		error_no_permission();
}

// Delete the specified reputation

		error_no_permission();
}

// Delete the specified reputation

	$db->delete_query("reputation", "uid='{$uid}' AND rid='".$mybb->input['rid']."'");

	$db->delete_query("reputation", "uid='{$uid}' AND rid='".intval($mybb->input['rid'])."'");


// Recount the reputation of this user - keep it in sync.
$query = $db->simple_select("reputation", "SUM(reputation) AS reputation_count", "uid='{$uid}'");
$reputation_value = $db->fetch_field($query, "reputation_count");

// Create moderator log


// Recount the reputation of this user - keep it in sync.
$query = $db->simple_select("reputation", "SUM(reputation) AS reputation_count", "uid='{$uid}'");
$reputation_value = $db->fetch_field($query, "reputation_count");

// Create moderator log

	$rep_remove = build_profile_link($existing_reputation['username'], $existing_reputation['adduid']);
log_moderator_action(array("uid" => $user['uid'], "username" => $user['username']), $lang->sprintf($lang->delete_reputation_log, $rep_remove));

	log_moderator_action(array("uid" => $user['uid'], "username" => $user['username']), $lang->sprintf($lang->delete_reputation_log, $existing_reputation['username'], $existing_reputation['adduid']));



$db->update_query("users", array('reputation' => intval($reputation_value)), "uid='{$uid}'");



$db->update_query("users", array('reputation' => intval($reputation_value)), "uid='{$uid}'");


Zeile 377Zeile 447
	if($user_permissions['usereputationsystem'] != 1)
{
error($lang->reputations_disabled_group);

	if($user_permissions['usereputationsystem'] != 1)
{
error($lang->reputations_disabled_group);

	}








	}

if($mybb->usergroup['canviewprofiles'] == 0)
{
// Reputation page is a part of a profile
error_no_permission();
}


	$lang->nav_profile = $lang->sprintf($lang->nav_profile, $user['username']);
$lang->reputation_report = $lang->sprintf($lang->reputation_report, $user['username']);

// Format the user name using the group username style
$username = format_name($user['username'], $user['usergroup'], $user['displaygroup']);

	$lang->nav_profile = $lang->sprintf($lang->nav_profile, $user['username']);
$lang->reputation_report = $lang->sprintf($lang->reputation_report, $user['username']);

// Format the user name using the group username style
$username = format_name($user['username'], $user['usergroup'], $user['displaygroup']);





	// Set display group to their user group if they don't have a display group.
if(!$user['displaygroup'])
{

	// Set display group to their user group if they don't have a display group.
if(!$user['displaygroup'])
{

Zeile 395Zeile 471
	$display_group = usergroup_displaygroup($user['displaygroup']);

// This user has a custom user title

	$display_group = usergroup_displaygroup($user['displaygroup']);

// This user has a custom user title

	if($user['usertitle'] != '')

	if(trim($user['usertitle']) != '')

	{
$usertitle = $user['usertitle'];
}
// Using our display group's user title

	{
$usertitle = $user['usertitle'];
}
// Using our display group's user title

	else if($display_group['usertitle'] != '')
{

	elseif(trim($display_group['usertitle']) != '')
{

		$usertitle = $display_group['usertitle'];
}
// Otherwise, fetch it from our titles table for the number of posts this user has

		$usertitle = $display_group['usertitle'];
}
// Otherwise, fetch it from our titles table for the number of posts this user has

Zeile 413Zeile 489
	}

// If the user has permission to add reputations - show the image

	}

// If the user has permission to add reputations - show the image

	if($mybb->usergroup['cangivereputations'] == 1)

	if($mybb->usergroup['cangivereputations'] == 1 && ($mybb->settings['posrep'] || $mybb->settings['neurep'] || $mybb->settings['negrep']))

	{
eval("\$add_reputation = \"".$templates->get("reputation_addlink")."\";");
}

	{
eval("\$add_reputation = \"".$templates->get("reputation_addlink")."\";");
}

Zeile 431Zeile 507
	switch($mybb->input['show'])
{
case "positive":

	switch($mybb->input['show'])
{
case "positive":

 
			$s_url = "&show=positive";

			$conditions = 'AND r.reputation>0';
$show_selected['positive'] = 'selected="selected"';
break;
case "neutral":

			$conditions = 'AND r.reputation>0';
$show_selected['positive'] = 'selected="selected"';
break;
case "neutral":

 
			$s_url = "&show=neutral";

			$conditions = 'AND r.reputation=0';
$show_selected['neutral'] = 'selected="selected"';
break;
case "negative":

			$conditions = 'AND r.reputation=0';
$show_selected['neutral'] = 'selected="selected"';
break;
case "negative":

 
			$s_url = "&show=negative";

			$conditions = 'AND r.reputation<0';
$show_selected['negative'] = 'selected="selected"';
break;
default:

			$conditions = 'AND r.reputation<0';
$show_selected['negative'] = 'selected="selected"';
break;
default:

 
			$s_url = '&show=all';

			$conditions = '';
$show_select['all'] = 'selected="selected"';

			$conditions = '';
$show_select['all'] = 'selected="selected"';

			break;
}

			break;
}


// Check the sorting options for the reputation list
$sort_select = '';
switch($mybb->input['sort'])
{
case "username":


// Check the sorting options for the reputation list
$sort_select = '';
switch($mybb->input['sort'])
{
case "username":

 
			$s_url .= "&sort=username";

			$order = "u.username ASC";
$sort_selected['username'] = 'selected="selected"';
break;
default:

			$order = "u.username ASC";
$sort_selected['username'] = 'selected="selected"';
break;
default:

 
			$s_url .= '&sort=dateline';

			$order = "r.dateline DESC";
$sort_selected['last_updated'] = 'selected="selected"';
break;
}

			$order = "r.dateline DESC";
$sort_selected['last_updated'] = 'selected="selected"';
break;
}

 

if(!$mybb->input['show'] && !$mybb->input['sort'])
{
$s_url = '';
}


	// Fetch the total number of reputations for this user
$query = $db->simple_select("reputation r", "COUNT(r.rid) AS reputation_count", "r.uid='{$user['uid']}' $conditions");
$reputation_count = $db->fetch_field($query, "reputation_count");

	// Fetch the total number of reputations for this user
$query = $db->simple_select("reputation r", "COUNT(r.rid) AS reputation_count", "r.uid='{$user['uid']}' $conditions");
$reputation_count = $db->fetch_field($query, "reputation_count");

Zeile 521Zeile 609
		else if($reputation_vote['reputation'] < 0)
{
$negative_count++;

		else if($reputation_vote['reputation'] < 0)
{
$negative_count++;

			if($reputation_vote['dateline'] >= $last_week)
{

			if($reputation_vote['dateline'] >= $last_week)
{

				$negative_week++;

				$negative_week++;

			}

			}

			if($reputation_vote['dateline'] >= $last_month)
{
$negative_month++;

			if($reputation_vote['dateline'] >= $last_month)
{
$negative_month++;

			}
if($reputation_vote['dateline'] >= $last_6months)

			}
if($reputation_vote['dateline'] >= $last_6months)

			{
$negative_6months++;
}

			{
$negative_6months++;
}

Zeile 551Zeile 639
				$neutral_6months++;
}
}

				$neutral_6months++;
}
}

	}

	}


// Format the user's 'total' reputation
if($user['reputation'] < 0)


// Format the user's 'total' reputation
if($user['reputation'] < 0)

Zeile 565Zeile 653
	else
{
$total_class = "_neutral";

	else
{
$total_class = "_neutral";

	}


	}


	// Figure out how many reps have come from posts / 'general'
// Posts
$query = $db->simple_select("reputation", "COUNT(rid) AS rep_posts", "uid = '".$user['uid']."' AND pid > 0");

	// Figure out how many reps have come from posts / 'general'
// Posts
$query = $db->simple_select("reputation", "COUNT(rid) AS rep_posts", "uid = '".$user['uid']."' AND pid > 0");

Zeile 580Zeile 668
	// Is negative reputation disabled? If so, tell the user
if($mybb->settings['negrep'] == 0)
{

	// Is negative reputation disabled? If so, tell the user
if($mybb->settings['negrep'] == 0)
{

		$negative_count = $negative_count."*";

 
		$neg_rep_info = $lang->neg_rep_disabled;

		$neg_rep_info = $lang->neg_rep_disabled;

 
	}

if($mybb->settings['posrep'] == 0)
{
$pos_rep_info = $lang->pos_rep_disabled;
}

if($mybb->settings['neurep'] == 0)
{
$neu_rep_info = $lang->neu_rep_disabled;

	}

// Check if we're browsing a specific page of results

	}

// Check if we're browsing a specific page of results

Zeile 606Zeile 703
	// Build out multipage navigation
if($reputation_count > 0)
{

	// Build out multipage navigation
if($reputation_count > 0)
{

		$multipage = multipage($reputation_count, $mybb->settings['repsperpage'], $page, "reputation.php?uid={$user['uid']}");

		$multipage = multipage($reputation_count, $mybb->settings['repsperpage'], $page, "reputation.php?uid={$user['uid']}".$s_url);

	}

// Fetch the reputations which will be displayed on this page

	}

// Fetch the reputations which will be displayed on this page