Exemplo n.º 1
0
    if (isset($_GET['vote']) && $canVote) {
        $vote = (int) $_GET['vote'];
        if ($vote > 1) {
            $vote = 1;
        }
        if ($vote < -1) {
            $vote = -1;
        }
        $k = FetchResult("select count(*) from uservotes where uid=" . $id . " and voter=" . $loguserid);
        if ($k == 0) {
            $qKarma = "insert into uservotes (uid, voter, up) values (" . $id . ", " . $loguserid . ", " . $vote . ")";
        } else {
            $qKarma = "update uservotes set up=" . $vote . " where uid=" . $id . " and voter=" . $loguserid;
        }
        $rKarma = Query($qKarma);
        $user['karma'] = RecalculateKarma($id);
    }
    $qKarma = "select up from uservotes where uid=" . $id . " and voter=" . $loguserid;
    $k = FetchResult($qKarma);
    if ($k == -1) {
        $karmaLinks = " <small>[<a href=\"profile.php?id=" . $id . "&amp;vote=1\">&#x2191;</a>/<a href=\"profile.php?id=" . $id . "&amp;vote=0\">&#x2193;</a>]</small>";
    } else {
        if ($k == 0) {
            $karmaLinks = " <small>[<a href=\"profile.php?id=" . $id . "&amp;vote=1\">&#x2191;</a>]</small>";
        } else {
            if ($k == 1) {
                $karmaLinks = " <small>[<a href=\"profile.php?id=" . $id . "&amp;vote=0\">&#x2193;</a>]</small>";
            }
        }
    }
}
Exemplo n.º 2
0
print "<tr class=\"header1\"><th>" . __("Name") . "</th><th>" . __("Actual") . "</th><th>" . __("Reported") . "</th><th>&nbsp;</th></tr>";
print "<tr class=\"header0\"><th colspan=\"4\">" . __("Counting user's posts&hellip;") . "</th></tr>";
$qUsers = "select * from users";
$rUsers = Query($qUsers);
while ($user = Fetch($rUsers)) {
    $cellClass = ($cellClass + 1) % 2;
    print "<tr class=\"cell" . $cellClass . "\">";
    print "<td>" . htmlspecialchars($user['name']) . "</td>";
    $qPosts = "select count(*) from posts where user="******"<td>" . $posts . "</td><td>" . $user['posts'] . "</td>";
    print "<td style=\"background: " . ($posts == $user['posts'] ? "green" : "red") . ";\"></td>";
    print "</tr>";
    $qUser = "******" . $posts . " where id=" . $user['id'] . " limit 1";
    $rUser = Query($qUser);
    RecalculateKarma($user['id']);
}
print "<tr class=\"header0\"><th colspan=\"4\">" . __("Counting thread replies&hellip;") . "</th></tr>";
$qThreads = "select * from threads";
$rThreads = Query($qThreads);
while ($thread = Fetch($rThreads)) {
    $thread['title'] = htmlspecialchars($thread['title']);
    $cellClass = ($cellClass + 1) % 2;
    print "<tr class=\"cell" . $cellClass . "\">";
    print "<td>" . $thread['title'] . "</td>";
    $qPosts = "select count(*) from posts where thread=" . $thread['id'];
    $posts = FetchResult($qPosts);
    print "<td>" . ($posts - 1) . "</td><td>" . $thread['replies'] . "</td>";
    print "<td style=\"background: " . ($posts - 1 == $thread['replies'] ? "green" : "red") . ";\"></td>";
    print "</tr>";
    $qThread = "update threads set replies=" . ($posts - 1) . " where id=" . $thread['id'] . " limit 1";
Exemplo n.º 3
0
function Karma()
{
    global $userid;
    $votes = Query("select uid from {uservotes} where voter={0}", $userid);
    if (NumRows($votes)) {
        while ($karmaChameleon = Fetch($votes)) {
            RecalculateKarma($karmaChameleon['uid']);
        }
    }
}
Exemplo n.º 4
0
			LEFT JOIN {users} u2 on u2.id = v.voter
			WHERE v.uid = u.id AND u2.powerlevel = 0 ) + 
			10 * (SELECT COUNT(*) FROM {uservotes} v 
			LEFT JOIN {users} u2 on u2.id = v.voter
			WHERE v.uid = u.id AND u2.powerlevel = 1 OR u2.powerlevel = 2 ) + 
			15 * (SELECT COUNT(*) FROM {uservotes} v 
			LEFT JOIN {users} u2 on u2.id = v.voter
			WHERE v.uid = u.id AND u2.powerlevel >= 3 ) 
		");
reportFix(__("Counting user's karma&hellip;"));
*/
startFix();
$aff = 0;
$users = query("select id from {users}");
while ($user = fetch($users)) {
    RecalculateKarma($user["id"]);
    $aff += affectedRows();
}
reportFix(__("Counting user's karma&hellip;"), $aff);
startFix();
query("UPDATE {threads} t SET replies =\n\t\t\t(SELECT COUNT(*) FROM {posts} p WHERE p.thread = t.id) - 1\n\t\t");
reportFix(__("Counting thread replies&hellip;"));
startFix();
query("UPDATE {forums} f SET numthreads =\n\t\t\t(SELECT COUNT(*) FROM {threads} t WHERE t.forum = f.id)\n\t\t");
reportFix(__("Counting forum threads&hellip;"));
startFix();
query("UPDATE {forums} f SET numposts =\n\t\t\t(SELECT SUM(replies+1) FROM {threads} t WHERE t.forum = f.id)\n\t\t");
reportFix(__("Counting forum posts&hellip;"));
startFix();
//For some reason, this beautiful query will set MySQL to use 100% CPU and never finishes.
/*query("UPDATE {threads} t SET