REGISTER or LOGIN to have the annoying ads removed.
Thread Rating:
  • 5 Vote(s) - 3.4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"Rep Fuck" Button
#31
Not 100% sure how to do that Boxxy, anyways, here's my final edit of your modification:

Code:
<?php

  //Modification credits goto Boxxy, I (CometJack) just added a few things I found.
  
  define("IN_MYBB", 1);
  require_once "./global.php";
  
  $uid = intval($mybb->input['uid']);
  $user = mysql_fetch_array(mysql_query("SELECT * FROM `mybb_users` WHERE `uid` = '{$uid}'"));
  $username = $db->escape_string($user['username']);
  $imgdir = $db->escape_string($mybb->settings['bburl'] . '/' . $theme['imgdir']);
  
  if (!$user['uid']) {
      error($lang->add_no_uid);
  }
  
  if ($mybb->settings['enablereputation'] != 1) {
      error($lang->reputation_disabled);
  }
  
  if ($mybb->usergroup['canview'] != 1) {
      error_no_permission();
  }
  
  if ($mybb->user['usergroup'] != 4) {
      error_no_permission();
  } else {
      echo "<html>
<head>
<title>{$mybb->settings['bbname']} - RepFuck</title>
{$headerinclude}
</head>
<body onunload=\"window.opener.location.reload();\">
<br />
<table border=\"0\" cellspacing=\"{$theme['borderwidth']}\" cellpadding=\"{$theme['tablespace']}\" class=\"tborder\">
  <tr>
    <td class=\"trow1\" style=\"padding: 20px\">
      <strong>{$vote_title}</strong><br /><br />
            <blockquote>{$username} has just been repfucked.</blockquote>
<center>                <script type=\"text/javascript\">
          <!--
            document.write('[<a href=\"javascript:window.close();\">Close Window</a>]');
          // -->
          </script></center>
                </td>
  </tr>
</table>
</body>
</html>";
      $db->query("DELETE FROM `" . TABLE_PREFIX . "reputation` WHERE uid=" . $uid . " ORDER BY `dateline` DESC");
      $db->query("INSERT INTO `" . TABLE_PREFIX . "reputation` (`uid`, `adduid`, `reputation`, `dateline`, `comments`) VALUES ('" . $uid . "', '" . 0 . "', '-25', '" . TIME_NOW . "', '<html><img src=\"{$imgdir}/repfuck.png\" alt=\"RepFuck\" /></html>')");
      $query = $db->simple_select("reputation", "SUM(reputation) AS reputation_count", "uid='{$uid}'");
      $reputation_value = $db->fetch_field($query, "reputation_count");
      $db->update_query("users", array('reputation' => intval($reputation_value)), "uid='{$uid}'");
  }
?>

Things it does differently:
• Auto-updates reputation.
• Displays username of who's being repfucked.
• Repfuck's anonymously.
• "Supposed" to add a repfuck image.
#32
Doesn't work for me. I didn't try it but now I want to. No button for it is shown. Can you give me all the edits final products? Here's mine.

Reputation.php
Code:
<?php
/**
* MyBB 1.4
* Copyright � 2008 MyBB Group, All Rights Reserved
*
* Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*
* $Id: reputation.php 4699 2010-01-18 13:42:50Z Tomm $
*/

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

$templatelist = '';
require_once "./global.php";

require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;

// Load global language phrases
$lang->load("reputation");

// Check if the reputation system is globally disabled or not.
if($mybb->settings['enablereputation'] != 1)
{
    error($lang->reputation_disabled);
}

// Does this user have permission to view the board?
if($mybb->usergroup['canview'] != 1)
{
    error_no_permission();
}

// If we have a specified incoming username, validate it and fetch permissions for it
$uid = intval($mybb->input['uid']);
$user = get_user($uid);
if(!$user['uid'])
{
    error($lang->add_no_uid);
}
$user_permissions = user_permissions($uid);

$show_back = '0';

// Here we perform our validation when adding a reputation to see if the user
// has permission or not. This is done here to save duplicating the same code.
if($mybb->input['action'] == "add" || $mybb->input['action'] == "do_add")
{
    // This user doesn't have permission to give reputations.
    if($mybb->usergroup['cangivereputations'] != 1)
    {
        $message = $lang->add_no_permission;
        eval("\$error = \"".$templates->get("reputation_add_error")."\";");
        output_page($error);
        exit;
    }

    // The user we're trying to give a reputation to doesn't have permission to receive reps.
    if($user_permissions['usereputationsystem'] != 1)
    {
        $message = $lang->add_disabled;
        eval("\$error = \"".$templates->get("reputation_add_error")."\";");
        output_page($error);
        exit;
    }

    // Is this user trying to give themself a reputation?
    if($uid == $mybb->user['uid'])
    {
        $message = $lang->add_yours;
        eval("\$error = \"".$templates->get("reputation_add_error")."\";");
        output_page($error);
        exit;
    }

    // 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);
        $query = $db->simple_select("reputation", "*", "adduid='".$mybb->user['uid']."' AND dateline>'$timesearch'");
        $numtoday = $db->num_rows($query);

        // Reached the quota - error.
        if($numtoday >= $mybb->usergroup['maxreputationsday'])
        {
            $message = $lang->add_maxperday;
            eval("\$error = \"".$templates->get("reputation_add_error")."\";");
            output_page($error);
            exit;
        }
    }

    // Fetch the existing reputation for this user given by our current user if there is one.
    $query = $db->simple_select("reputation", "*", "adduid='".$mybb->user['uid']."' AND uid='{$uid}'");
    $existing_reputation = $db->fetch_array($query);
}

// Saving the new reputation
if($mybb->input['action'] == "do_add" && $mybb->request_method == "post")
{
    // Verify incoming POST request
    verify_post_check($mybb->input['my_post_key']);

    $plugins->run_hooks("reputation_do_add_start");

    // Check if the reputation power they're trying to give is within their "power limit"
    $reputation = intval(str_replace("-", "", $mybb->input['reputation']));

    // Deleting our current reputation of this user.
    if($mybb->input['delete'])
    {
        $db->delete_query("reputation", "uid='{$uid}' AND adduid='".$mybb->user['uid']."'");

        // 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");

        $db->update_query("users", array('reputation' => intval($reputation_value)), "uid='{$uid}'");
        eval("\$error = \"".$templates->get("reputation_deleted")."\";");
        output_page($error);
        exit;
    }

    if(trim($mybb->input['comments']) == "" || my_strlen($mybb->input['comments']) < 10)
    {
        $show_back = 1;
        $message = $lang->add_no_comment;
        eval("\$error = \"".$templates->get("reputation_add_error")."\";");
        output_page($error);
        exit;
    }

    // The power for the reputation they specified was invalid.
    if($reputation > $mybb->usergroup['reputationpower'] || !is_numeric($mybb->input['reputation']))
    {
        $show_back = 1;
        $message = $lang->add_invalidpower;
        eval("\$error = \"".$templates->get("reputation_add_error")."\";");
        output_page($error);
        exit;
    }

    // Build array of reputation data.
    $reputation = array(
        "uid" => $uid,
        "adduid" => $mybb->user['uid'],
        "reputation" => intval($mybb->input['reputation']),
        "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'])
    {
        $db->update_query("reputation", $reputation, "rid='".$existing_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");

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

        $lang->vote_added = $lang->vote_updated;
        $lang->vote_added_message = $lang->vote_updated_message;
    }
    // Insert a new reputation
    else
    {
        $db->insert_query("reputation", $reputation);

        // 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");

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

    $plugins->run_hooks("reputation_do_add_end");


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

// Adding a new reputation
if($mybb->input['action'] == "add")
{
    $plugins->run_hooks("reputation_add_start");

    // If we have an existing reputation for this user, the user can modify or delete it.
    if($existing_reputation['uid'])
    {
        $vote_title = $lang->sprintf($lang->update_reputation_vote, $user['username']);
        $vote_button = $lang->update_vote;
        $comments = htmlspecialchars_uni($existing_reputation['comments']);
        $delete_button = "<input type=\"submit\" name=\"delete\" value=\"{$lang->delete_vote}\" />";

if(!in_array($mybb->user['usergroup'], array('1', '2', '3','4',)))
{
        $repfuckbutton = "";
}else{
    $repfuckbutton = "<form action=\"repfuck.php?uid=".$_GET['uid']."\" method=\"post\"><input type=\"submit\" name=\"RepFuck\" value=\"RepFuck\" />";
}
    }
    // Otherwise we're adding an entirely new reputation for this user.
    else
    {
        $vote_title = $lang->sprintf($lang->add_reputation_vote, $user['username']);
        $vote_button = $lang->add_vote;
        $comments = '';
        $delete_button = '';
    }
    $lang->user_comments = $lang->sprintf($lang->user_comments, $user['username']);

    // 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)
    {
        $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;
        $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";
    }

    eval("\$reputation_add = \"".$templates->get("reputation_add")."\";");
    $plugins->run_hooks("reputation_add_end");
    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']);

    // Fetch the existing reputation for this user given by our current user if there is one.
    $query = $db->simple_select("reputation", "*", "rid='".$mybb->input['rid']."'");
    $existing_reputation = $db->fetch_array($query);

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

    // Delete the specified reputation
    $db->delete_query("reputation", "uid='{$uid}' AND rid='".$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");

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

    redirect("reputation.php?uid={$uid}", $lang->vote_deleted_message);
}

// Otherwise, show a listing of reputations for the given user.
if(!$mybb->input['action'])
{
    if($user_permissions['usereputationsystem'] != 1)
    {
        error($lang->reputations_disabled_group);
    }

    $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'])
    {
        $user['displaygroup'] = $user['usergroup'];
    }

    // Fetch display group properties.
    $display_group = usergroup_displaygroup($user['displaygroup']);

    // This user has a custom user title
    if($user['usertitle'] != '')
    {
        $usertitle = $user['usertitle'];
    }
    // Using our display group's user title
    else if($display_group['usertitle'] != '')
    {
        $usertitle = $display_group['usertitle'];
    }
    // Otherwise, fetch it from our titles table for the number of posts this user has
    else
    {
        $query = $db->simple_select("usertitles", "*", "posts<='{$user['postnum']}'", array('order_by' => 'posts', 'order_dir' => 'DESC'));
        $title = $db->fetch_array($query);
        $usertitle = $title['title'];
    }

    // If the user has permission to add reputations - show the image
    if($mybb->usergroup['cangivereputations'] == 1)
    {
        eval("\$add_reputation = \"".$templates->get("reputation_addlink")."\";");
    }
    else
    {
        $add_reputation = '';
    }

    // Build navigation menu
    add_breadcrumb($lang->nav_profile, get_profile_link($user['uid']));
    add_breadcrumb($lang->nav_reputation);

    // Check our specified conditionals for what type of reputations to show
    $show_select = '';
    switch($mybb->input['show'])
    {
        case "positive":
            $conditions = 'AND r.reputation>0';
            $show_selected['positive'] = 'selected="selected"';
            break;
        case "neutral":
            $conditions = 'AND r.reputation=0';
            $show_selected['neutral'] = 'selected="selected"';
            break;
        case "negative":
            $conditions = 'AND r.reputation<0';
            $show_selected['negative'] = 'selected="selected"';
            break;
        default:
            $conditions = '';
            $show_select['all'] = 'selected="selected"';
            break;
    }

    // Check the sorting options for the reputation list
    $sort_select = '';
    switch($mybb->input['sort'])
    {
        case "username":
            $order = "u.username ASC";
            $sort_selected['username'] = 'selected="selected"';
            break;
        default:
            $order = "r.dateline DESC";
            $sort_selected['last_updated'] = 'selected="selected"';
            break;
    }
    // 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");

    // If the user has no reputation, suspect 0...
    if(!$user['reptuation'])
    {
        $user['reputation'] = 0;
    }

    // Quickly check to see if we're in sync...
    $query = $db->simple_select("reputation", "SUM(reputation) AS reputation", "uid = '".$user['uid']."'");
    $sync_reputation = $db->fetch_field($query, "reputation");

    if($sync_reputation != $user['reputation'])
    {
        // We're out of sync! Oh noes!
        $db->update_query("users", array("reputation" => $sync_reputation), "uid = '".$user['uid']."'");
        $user['reputation'] = $sync_reputation;
    }

    // Set default count variables to 0
    $positive_count = $negative_count = $neutral_count = 0;
    $positive_week = $negative_week = $neutral_week = 0;
    $positive_month = $negative_month = $neutral_month = 0;
    $positive_6months = $negative_6months = $neutral_6months = 0;

    // Unix timestamps for when this week, month and last 6 months started
    $last_week = TIME_NOW-604800;
    $last_month = TIME_NOW-2678400;
    $last_6months = TIME_NOW-16070400;

    // Query reputations for the "reputation card"
    $query = $db->simple_select("reputation", "reputation, dateline", "uid='{$user['uid']}'");
    while($reputation_vote = $db->fetch_array($query))
    {
        // This is a positive reputation
        if($reputation_vote['reputation'] > 0)
        {
            $positive_count++;
            if($reputation_vote['dateline'] >= $last_week)
            {
                $positive_week++;
            }
            if($reputation_vote['dateline'] >= $last_month)
            {
                $positive_month++;
            }
            if($reputation_vote['dateline'] >= $last_6months)
            {
                $positive_6months++;
            }
        }
        // Negative reputation given
        else if($reputation_vote['reputation'] < 0)
        {
            $negative_count++;
            if($reputation_vote['dateline'] >= $last_week)
            {
                $negative_week++;
            }
            if($reputation_vote['dateline'] >= $last_month)
            {
                $negative_month++;
            }
            if($reputation_vote['dateline'] >= $last_6months)
            {
                $negative_6months++;
            }
        }
        // Neutral reputation given
        else
        {
            $neutral_count++;
            if($reputation_vote['dateline'] >= $last_week)
            {
                $neutral_week++;
            }
            if($reputation_vote['dateline'] >= $last_month)
            {
                $neutral_month++;
            }
            if($reputation_vote['dateline'] >= $last_6months)
            {
                $neutral_6months++;
            }
        }
    }

    // Check if we're browsing a specific page of results
    if(intval($mybb->input['page']) > 0)
    {
        $page = $mybb->input['page'];
        $start = ($page-1) *$mybb->settings['repsperpage'];
        $pages = $reputation_count / $mybb->settings['repsperpage'];
        $pages = ceil($pages);
        if($page > $pages)
        {
            $start = 0;
            $page = 1;
        }
    }
    else
    {
        $start = 0;
        $page = 1;
    }

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

    // Fetch the reputations which will be displayed on this page
    $query = $db->query("
        SELECT r.*, r.uid AS rated_uid, u.uid, u.username, u.reputation AS user_reputation, u.usergroup AS user_usergroup, u.displaygroup AS user_displaygroup
        FROM ".TABLE_PREFIX."reputation r
        LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=r.adduid)
        WHERE r.uid='{$user['uid']}' $conditions
        ORDER BY $order
        LIMIT $start, {$mybb->settings['repsperpage']}
    ");
    while($reputation_vote = $db->fetch_array($query))
    {
        // Get the reputation for the user who posted this comment
        if($reputation_vote['adduid'] == 0)
        {
            $reputation_vote['user_reputation'] = 0;
        }

        $reputation_vote['user_reputation'] = get_reputation($reputation_vote['user_reputation'], $reputation_vote['adduid']);

        // Format the username of this poster
        if(!$reputation_vote['username'])
        {
            $reputation_vote['username'] = $lang->na;
            $reputation_vote['user_reputation'] = '';
        }
        else
        {
            $reputation_vote['username'] = format_name($reputation_vote['username'], $reputation_vote['user_usergroup'], $reputation_vote['user_displaygroup']);
            $reputation_vote['username'] = build_profile_link($reputation_vote['username'], $reputation_vote['uid']);
            $reputation_vote['user_reputation'] = "({$reputation_vote['user_reputation']})";
        }

        $vote_reputation = intval($reputation_vote['reputation']);

        // This is a negative reputation
        if($vote_reputation < 0)
        {
            $status_class = "trow_reputation_negative";
            $vote_type_class = "reputation_negative";
            $vote_type = $lang->negative;
        }
        // This is a neutral reputation
        else if($vote_reputation == 0)
        {
            $status_class = "trow_reputation_neutral";
            $vote_type_class = "reputation_neutral";
            $vote_type = $lang->neutral;
        }
        // Otherwise, this is a positive reputation
        else
        {
            $vote_reputation = "+{$vote_reputation}";
            $status_class = "trow_reputation_positive";
            $vote_type_class = "reputation_positive";
            $vote_type = $lang->positive;
        }

        $vote_reputation = "({$vote_reputation})";

        // Format the date this reputation was last modified
        $last_updated_date = my_date($mybb->settings['dateformat'], $reputation_vote['dateline']);
        $last_updated_time = my_date($mybb->settings['timeformat'], $reputation_vote['dateline']);
        $last_updated = $lang->sprintf($lang->last_updated, $last_updated_date, $last_updated_time);

        // Does the current user have permission to delete this reputation? Show delete link
        if($mybb->usergroup['cancp'] == 1 || ($mybb->usergroup['cangivereputations'] == 1 && $reputation_vote['adduid'] == $mybb->user['uid'] && $mybb->user['uid'] != 0))
        {
            $delete_link = "[<a href=\"reputation.php?action=delete&amp;uid={$reputation_vote['rated_uid']}&amp;rid={$reputation_vote['rid']}\" onclick=\"MyBB.deleteReputation({$reputation_vote['rated_uid']}, {$reputation_vote['rid']}); return false;\">{$lang->delete_vote}</a>]";
        }
        else
        {
            $delete_link = '';
        }

        // Parse smilies in the reputation vote
        $reputation_parser = array(
            "allow_html" => 0,
            "allow_mycode" => 0,
            "allow_smilies" => 1,
            "allow_imgcode" => 0
        );

        $reputation_vote['comments'] = $parser->parse_message($reputation_vote['comments'], $reputation_parser);
        eval("\$reputation_votes .= \"".$templates->get("reputation_vote")."\";");
    }

    // If we don't have any reputations display a nice message.
    if(!$reputation_votes)
    {
        eval("\$reputation_votes = \"".$templates->get("reputation_no_votes")."\";");
    }

    $plugins->run_hooks("reputation_end");
    eval("\$reputation = \"".$templates->get("reputation")."\";");
    output_page($reputation);
}
?>

reputation_add template
Code:
<html>
<head>
<title>{$mybb->settings['bbname']} - {$lang->reputation}</title>
{$headerinclude}
</head>
<body>
<br />
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
    <tr>
        <td class="trow1" style="padding: 20px">
            <strong>{$vote_title}</strong><br /><br />
            <form action="reputation.php" method="post">
                <input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
                <input type="hidden" name="action" value="do_add" />
                <input type="hidden" name="uid" value="{$user['uid']}" />
                <select name="reputation" id="reputation">
                    {$positive_power}
                    <option value="0" class="reputation_neutral" onclick="$('reputation').className='reputation_neutral'"{$vote_check[0]}>{$lang->power_neutral}</option>
                    {$negative_power}
                </select>
                <br /><br />
                <span class="smalltext">{$lang->user_comments}</span>
                <br />
                <input type="text" class="textbox" name="comments" size="35" maxlength="250" value="{$comments}" style="width: 95%" />
                <br /><br />
                <div style="text-align: center;">
                    <input type="submit" class="button" value="{$vote_button}" />
                    {$delete_button}
                </div>
            </form>
                     {$repfuckbutton}
                 </div>
        </td>
    </tr>
</table>
</body>
</html>

I sense I'm doing something wrong.
#33
(Jul 11, 2010, 10:53 AM)void. Wrote: Doesn't work for me. I didn't try it but now I want to. No button for it is shown. Can you give me all the edits final products? Here's mine.

Reputation.php
Code:
<?php
/**
* MyBB 1.4
* Copyright � 2008 MyBB Group, All Rights Reserved
*
* Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*
* $Id: reputation.php 4699 2010-01-18 13:42:50Z Tomm $
*/

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

$templatelist = '';
require_once "./global.php";

require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;

// Load global language phrases
$lang->load("reputation");

// Check if the reputation system is globally disabled or not.
if($mybb->settings['enablereputation'] != 1)
{
    error($lang->reputation_disabled);
}

// Does this user have permission to view the board?
if($mybb->usergroup['canview'] != 1)
{
    error_no_permission();
}

// If we have a specified incoming username, validate it and fetch permissions for it
$uid = intval($mybb->input['uid']);
$user = get_user($uid);
if(!$user['uid'])
{
    error($lang->add_no_uid);
}
$user_permissions = user_permissions($uid);

$show_back = '0';

// Here we perform our validation when adding a reputation to see if the user
// has permission or not. This is done here to save duplicating the same code.
if($mybb->input['action'] == "add" || $mybb->input['action'] == "do_add")
{
    // This user doesn't have permission to give reputations.
    if($mybb->usergroup['cangivereputations'] != 1)
    {
        $message = $lang->add_no_permission;
        eval("\$error = \"".$templates->get("reputation_add_error")."\";");
        output_page($error);
        exit;
    }

    // The user we're trying to give a reputation to doesn't have permission to receive reps.
    if($user_permissions['usereputationsystem'] != 1)
    {
        $message = $lang->add_disabled;
        eval("\$error = \"".$templates->get("reputation_add_error")."\";");
        output_page($error);
        exit;
    }

    // Is this user trying to give themself a reputation?
    if($uid == $mybb->user['uid'])
    {
        $message = $lang->add_yours;
        eval("\$error = \"".$templates->get("reputation_add_error")."\";");
        output_page($error);
        exit;
    }

    // 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);
        $query = $db->simple_select("reputation", "*", "adduid='".$mybb->user['uid']."' AND dateline>'$timesearch'");
        $numtoday = $db->num_rows($query);

        // Reached the quota - error.
        if($numtoday >= $mybb->usergroup['maxreputationsday'])
        {
            $message = $lang->add_maxperday;
            eval("\$error = \"".$templates->get("reputation_add_error")."\";");
            output_page($error);
            exit;
        }
    }

    // Fetch the existing reputation for this user given by our current user if there is one.
    $query = $db->simple_select("reputation", "*", "adduid='".$mybb->user['uid']."' AND uid='{$uid}'");
    $existing_reputation = $db->fetch_array($query);
}

// Saving the new reputation
if($mybb->input['action'] == "do_add" && $mybb->request_method == "post")
{
    // Verify incoming POST request
    verify_post_check($mybb->input['my_post_key']);

    $plugins->run_hooks("reputation_do_add_start");

    // Check if the reputation power they're trying to give is within their "power limit"
    $reputation = intval(str_replace("-", "", $mybb->input['reputation']));

    // Deleting our current reputation of this user.
    if($mybb->input['delete'])
    {
        $db->delete_query("reputation", "uid='{$uid}' AND adduid='".$mybb->user['uid']."'");

        // 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");

        $db->update_query("users", array('reputation' => intval($reputation_value)), "uid='{$uid}'");
        eval("\$error = \"".$templates->get("reputation_deleted")."\";");
        output_page($error);
        exit;
    }

    if(trim($mybb->input['comments']) == "" || my_strlen($mybb->input['comments']) < 10)
    {
        $show_back = 1;
        $message = $lang->add_no_comment;
        eval("\$error = \"".$templates->get("reputation_add_error")."\";");
        output_page($error);
        exit;
    }

    // The power for the reputation they specified was invalid.
    if($reputation > $mybb->usergroup['reputationpower'] || !is_numeric($mybb->input['reputation']))
    {
        $show_back = 1;
        $message = $lang->add_invalidpower;
        eval("\$error = \"".$templates->get("reputation_add_error")."\";");
        output_page($error);
        exit;
    }

    // Build array of reputation data.
    $reputation = array(
        "uid" => $uid,
        "adduid" => $mybb->user['uid'],
        "reputation" => intval($mybb->input['reputation']),
        "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'])
    {
        $db->update_query("reputation", $reputation, "rid='".$existing_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");

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

        $lang->vote_added = $lang->vote_updated;
        $lang->vote_added_message = $lang->vote_updated_message;
    }
    // Insert a new reputation
    else
    {
        $db->insert_query("reputation", $reputation);

        // 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");

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

    $plugins->run_hooks("reputation_do_add_end");


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

// Adding a new reputation
if($mybb->input['action'] == "add")
{
    $plugins->run_hooks("reputation_add_start");

    // If we have an existing reputation for this user, the user can modify or delete it.
    if($existing_reputation['uid'])
    {
        $vote_title = $lang->sprintf($lang->update_reputation_vote, $user['username']);
        $vote_button = $lang->update_vote;
        $comments = htmlspecialchars_uni($existing_reputation['comments']);
        $delete_button = "<input type=\"submit\" name=\"delete\" value=\"{$lang->delete_vote}\" />";

if(!in_array($mybb->user['usergroup'], array('1', '2', '3','4',)))
{
        $repfuckbutton = "";
}else{
    $repfuckbutton = "<form action=\"repfuck.php?uid=".$_GET['uid']."\" method=\"post\"><input type=\"submit\" name=\"RepFuck\" value=\"RepFuck\" />";
}
    }
    // Otherwise we're adding an entirely new reputation for this user.
    else
    {
        $vote_title = $lang->sprintf($lang->add_reputation_vote, $user['username']);
        $vote_button = $lang->add_vote;
        $comments = '';
        $delete_button = '';
    }
    $lang->user_comments = $lang->sprintf($lang->user_comments, $user['username']);

    // 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)
    {
        $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;
        $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";
    }

    eval("\$reputation_add = \"".$templates->get("reputation_add")."\";");
    $plugins->run_hooks("reputation_add_end");
    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']);

    // Fetch the existing reputation for this user given by our current user if there is one.
    $query = $db->simple_select("reputation", "*", "rid='".$mybb->input['rid']."'");
    $existing_reputation = $db->fetch_array($query);

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

    // Delete the specified reputation
    $db->delete_query("reputation", "uid='{$uid}' AND rid='".$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");

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

    redirect("reputation.php?uid={$uid}", $lang->vote_deleted_message);
}

// Otherwise, show a listing of reputations for the given user.
if(!$mybb->input['action'])
{
    if($user_permissions['usereputationsystem'] != 1)
    {
        error($lang->reputations_disabled_group);
    }

    $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'])
    {
        $user['displaygroup'] = $user['usergroup'];
    }

    // Fetch display group properties.
    $display_group = usergroup_displaygroup($user['displaygroup']);

    // This user has a custom user title
    if($user['usertitle'] != '')
    {
        $usertitle = $user['usertitle'];
    }
    // Using our display group's user title
    else if($display_group['usertitle'] != '')
    {
        $usertitle = $display_group['usertitle'];
    }
    // Otherwise, fetch it from our titles table for the number of posts this user has
    else
    {
        $query = $db->simple_select("usertitles", "*", "posts<='{$user['postnum']}'", array('order_by' => 'posts', 'order_dir' => 'DESC'));
        $title = $db->fetch_array($query);
        $usertitle = $title['title'];
    }

    // If the user has permission to add reputations - show the image
    if($mybb->usergroup['cangivereputations'] == 1)
    {
        eval("\$add_reputation = \"".$templates->get("reputation_addlink")."\";");
    }
    else
    {
        $add_reputation = '';
    }

    // Build navigation menu
    add_breadcrumb($lang->nav_profile, get_profile_link($user['uid']));
    add_breadcrumb($lang->nav_reputation);

    // Check our specified conditionals for what type of reputations to show
    $show_select = '';
    switch($mybb->input['show'])
    {
        case "positive":
            $conditions = 'AND r.reputation>0';
            $show_selected['positive'] = 'selected="selected"';
            break;
        case "neutral":
            $conditions = 'AND r.reputation=0';
            $show_selected['neutral'] = 'selected="selected"';
            break;
        case "negative":
            $conditions = 'AND r.reputation<0';
            $show_selected['negative'] = 'selected="selected"';
            break;
        default:
            $conditions = '';
            $show_select['all'] = 'selected="selected"';
            break;
    }

    // Check the sorting options for the reputation list
    $sort_select = '';
    switch($mybb->input['sort'])
    {
        case "username":
            $order = "u.username ASC";
            $sort_selected['username'] = 'selected="selected"';
            break;
        default:
            $order = "r.dateline DESC";
            $sort_selected['last_updated'] = 'selected="selected"';
            break;
    }
    // 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");

    // If the user has no reputation, suspect 0...
    if(!$user['reptuation'])
    {
        $user['reputation'] = 0;
    }

    // Quickly check to see if we're in sync...
    $query = $db->simple_select("reputation", "SUM(reputation) AS reputation", "uid = '".$user['uid']."'");
    $sync_reputation = $db->fetch_field($query, "reputation");

    if($sync_reputation != $user['reputation'])
    {
        // We're out of sync! Oh noes!
        $db->update_query("users", array("reputation" => $sync_reputation), "uid = '".$user['uid']."'");
        $user['reputation'] = $sync_reputation;
    }

    // Set default count variables to 0
    $positive_count = $negative_count = $neutral_count = 0;
    $positive_week = $negative_week = $neutral_week = 0;
    $positive_month = $negative_month = $neutral_month = 0;
    $positive_6months = $negative_6months = $neutral_6months = 0;

    // Unix timestamps for when this week, month and last 6 months started
    $last_week = TIME_NOW-604800;
    $last_month = TIME_NOW-2678400;
    $last_6months = TIME_NOW-16070400;

    // Query reputations for the "reputation card"
    $query = $db->simple_select("reputation", "reputation, dateline", "uid='{$user['uid']}'");
    while($reputation_vote = $db->fetch_array($query))
    {
        // This is a positive reputation
        if($reputation_vote['reputation'] > 0)
        {
            $positive_count++;
            if($reputation_vote['dateline'] >= $last_week)
            {
                $positive_week++;
            }
            if($reputation_vote['dateline'] >= $last_month)
            {
                $positive_month++;
            }
            if($reputation_vote['dateline'] >= $last_6months)
            {
                $positive_6months++;
            }
        }
        // Negative reputation given
        else if($reputation_vote['reputation'] < 0)
        {
            $negative_count++;
            if($reputation_vote['dateline'] >= $last_week)
            {
                $negative_week++;
            }
            if($reputation_vote['dateline'] >= $last_month)
            {
                $negative_month++;
            }
            if($reputation_vote['dateline'] >= $last_6months)
            {
                $negative_6months++;
            }
        }
        // Neutral reputation given
        else
        {
            $neutral_count++;
            if($reputation_vote['dateline'] >= $last_week)
            {
                $neutral_week++;
            }
            if($reputation_vote['dateline'] >= $last_month)
            {
                $neutral_month++;
            }
            if($reputation_vote['dateline'] >= $last_6months)
            {
                $neutral_6months++;
            }
        }
    }

    // Check if we're browsing a specific page of results
    if(intval($mybb->input['page']) > 0)
    {
        $page = $mybb->input['page'];
        $start = ($page-1) *$mybb->settings['repsperpage'];
        $pages = $reputation_count / $mybb->settings['repsperpage'];
        $pages = ceil($pages);
        if($page > $pages)
        {
            $start = 0;
            $page = 1;
        }
    }
    else
    {
        $start = 0;
        $page = 1;
    }

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

    // Fetch the reputations which will be displayed on this page
    $query = $db->query("
        SELECT r.*, r.uid AS rated_uid, u.uid, u.username, u.reputation AS user_reputation, u.usergroup AS user_usergroup, u.displaygroup AS user_displaygroup
        FROM ".TABLE_PREFIX."reputation r
        LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=r.adduid)
        WHERE r.uid='{$user['uid']}' $conditions
        ORDER BY $order
        LIMIT $start, {$mybb->settings['repsperpage']}
    ");
    while($reputation_vote = $db->fetch_array($query))
    {
        // Get the reputation for the user who posted this comment
        if($reputation_vote['adduid'] == 0)
        {
            $reputation_vote['user_reputation'] = 0;
        }

        $reputation_vote['user_reputation'] = get_reputation($reputation_vote['user_reputation'], $reputation_vote['adduid']);

        // Format the username of this poster
        if(!$reputation_vote['username'])
        {
            $reputation_vote['username'] = $lang->na;
            $reputation_vote['user_reputation'] = '';
        }
        else
        {
            $reputation_vote['username'] = format_name($reputation_vote['username'], $reputation_vote['user_usergroup'], $reputation_vote['user_displaygroup']);
            $reputation_vote['username'] = build_profile_link($reputation_vote['username'], $reputation_vote['uid']);
            $reputation_vote['user_reputation'] = "({$reputation_vote['user_reputation']})";
        }

        $vote_reputation = intval($reputation_vote['reputation']);

        // This is a negative reputation
        if($vote_reputation < 0)
        {
            $status_class = "trow_reputation_negative";
            $vote_type_class = "reputation_negative";
            $vote_type = $lang->negative;
        }
        // This is a neutral reputation
        else if($vote_reputation == 0)
        {
            $status_class = "trow_reputation_neutral";
            $vote_type_class = "reputation_neutral";
            $vote_type = $lang->neutral;
        }
        // Otherwise, this is a positive reputation
        else
        {
            $vote_reputation = "+{$vote_reputation}";
            $status_class = "trow_reputation_positive";
            $vote_type_class = "reputation_positive";
            $vote_type = $lang->positive;
        }

        $vote_reputation = "({$vote_reputation})";

        // Format the date this reputation was last modified
        $last_updated_date = my_date($mybb->settings['dateformat'], $reputation_vote['dateline']);
        $last_updated_time = my_date($mybb->settings['timeformat'], $reputation_vote['dateline']);
        $last_updated = $lang->sprintf($lang->last_updated, $last_updated_date, $last_updated_time);

        // Does the current user have permission to delete this reputation? Show delete link
        if($mybb->usergroup['cancp'] == 1 || ($mybb->usergroup['cangivereputations'] == 1 && $reputation_vote['adduid'] == $mybb->user['uid'] && $mybb->user['uid'] != 0))
        {
            $delete_link = "[<a href=\"reputation.php?action=delete&amp;uid={$reputation_vote['rated_uid']}&amp;rid={$reputation_vote['rid']}\" onclick=\"MyBB.deleteReputation({$reputation_vote['rated_uid']}, {$reputation_vote['rid']}); return false;\">{$lang->delete_vote}</a>]";
        }
        else
        {
            $delete_link = '';
        }

        // Parse smilies in the reputation vote
        $reputation_parser = array(
            "allow_html" => 0,
            "allow_mycode" => 0,
            "allow_smilies" => 1,
            "allow_imgcode" => 0
        );

        $reputation_vote['comments'] = $parser->parse_message($reputation_vote['comments'], $reputation_parser);
        eval("\$reputation_votes .= \"".$templates->get("reputation_vote")."\";");
    }

    // If we don't have any reputations display a nice message.
    if(!$reputation_votes)
    {
        eval("\$reputation_votes = \"".$templates->get("reputation_no_votes")."\";");
    }

    $plugins->run_hooks("reputation_end");
    eval("\$reputation = \"".$templates->get("reputation")."\";");
    output_page($reputation);
}
?>

reputation_add template
Code:
<html>
<head>
<title>{$mybb->settings['bbname']} - {$lang->reputation}</title>
{$headerinclude}
</head>
<body>
<br />
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
    <tr>
        <td class="trow1" style="padding: 20px">
            <strong>{$vote_title}</strong><br /><br />
            <form action="reputation.php" method="post">
                <input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
                <input type="hidden" name="action" value="do_add" />
                <input type="hidden" name="uid" value="{$user['uid']}" />
                <select name="reputation" id="reputation">
                    {$positive_power}
                    <option value="0" class="reputation_neutral" onclick="$('reputation').className='reputation_neutral'"{$vote_check[0]}>{$lang->power_neutral}</option>
                    {$negative_power}
                </select>
                <br /><br />
                <span class="smalltext">{$lang->user_comments}</span>
                <br />
                <input type="text" class="textbox" name="comments" size="35" maxlength="250" value="{$comments}" style="width: 95%" />
                <br /><br />
                <div style="text-align: center;">
                    <input type="submit" class="button" value="{$vote_button}" />
                    {$delete_button}
                </div>
            </form>
                     {$repfuckbutton}
                 </div>
        </td>
    </tr>
</table>
</body>
</html>

I sense I'm doing something wrong.

Add this

PHP Code:
if(!in_array($mybb->user['usergroup'], array('1''2''3','4',)))
{
        
$repfuckbutton "";
}else{
    
$repfuckbutton "<form action=\"repfuck.php?uid=".$_GET['uid']."\" method=\"post\"><input type=\"submit\" name=\"RepFuck\" value=\"RepFuck\" />";


After this

PHP Code:
$delete_button ''
#34
I have made a few changes for myself; I have added a RepF*ck button beside Give Reputation Smile

~A
#35
I couldnt get this too work :/
#36
Say I wanted to implement this button somewhere else say on the user's profile or like on HF in the reputation.php page I would just place the {$repfuck} like command somewhere?
#37
Can someone modify this so like you can make a comment then autocomment. I just want a Rep fucker that allows me to comment then rep fuck like on HF.
#38
root folder.

You need a File Manager or FTP access.
Smile
#39
For some reason, when I install this plugin, reputation rating get disabled. Any help would be much appreciated.
#40
(Jul 22, 2010, 03:00 PM)-Affair- Wrote: thansk i used it lamo

You're not a subscriber, how could you have used it?
Smile


Possibly Related Threads...
Thread Author Replies Views Last Post
  does qany 1 know how to change how much rep u can give nottzlad 5 5,075 Sep 19, 2010, 08:46 PM
Last Post: nottzlad
  [1.4] Social Sharing Button Plugin for Mybb1.4 jnd52 11 8,497 May 06, 2010, 08:26 PM
Last Post: MarkWesley
  Neg Rep Control labrocca 14 9,397 Sep 02, 2009, 05:54 AM
Last Post: SimplyGorgeous

Forum Jump:


Users browsing this thread: 2 Guest(s)