Exemplo n.º 1
0
function updateRank($group, $userId, $rank, $cookie, $ranks, $roles, $rankLimit = 255, $save = '../Private/gxcsrf.txt')
{
    // OH MY GOD SO MANY ARGUMENTS!
    $xcsrf = file_exists($save) ? file_get_contents($save) : '';
    /* 
    		
    		If you want to increase performance do this:
    			Move the following line (currentRank) into the rankLimit if statement.
    			Change the success return to something simpler (does not return user's previous rank)
    	This doesn't actually slow it down that much at all, but when changing ranks **IN BULK** you will be making a lot of requests.
    */
    $currentRank = getRankInGroup($userId, $group);
    if ($rankLimit && $rankLimit < 255) {
        if ($rank > $rankLimit || $currentRank > $rankLimit) {
            // Check if the rank you are trying to change them to and their rank abide to the rank limit
            return "Settings restrict the system from changing any rank over {$rankLimit}.";
        }
    }
    $url = "http://www.roblox.com/groups/api/change-member-rank?groupId={$group}&newRoleSetId=" . getRoleSet($ranks, $rank) . "&targetUserId={$userId}";
    // Get rank URL
    $curl = curl_init($url);
    curl_setopt_array($curl, array(CURLOPT_HEADER => true, CURLOPT_HTTPHEADER => array("X-CSRF-TOKEN: {$xcsrf}", 'Content-Length: 0'), CURLOPT_POST => true, CURLOPT_COOKIEFILE => $cookie, CURLOPT_COOKIEJAR => $cookie, CURLOPT_RETURNTRANSFER => true));
    $response = curl_exec($curl);
    $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
    $responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    if ($responseCode != 200) {
        // BELOW 302 DOES NOT WORK AND IS DEPRACATED FOR NOW
        /*if ($responseCode == 302) { // 302 Moved temporarily - User is not logged in: Redirect to error page
        			login($cookie,$username,$password);
        			return updateRank($username,$password,$group,$userId,$rank,$cookie,$ranks,$roles,$rankLimit,$save); // Would appreciate if someone showed me a better way to do this (not repassing every argument manually).
        		} else */
        if ($responseCode == 403) {
            // 403 XCSRF Token Validation Failed - CONVENIENCE!
            $header = http_parse_headers(substr($response, 0, $headerSize));
            $xcsrf = $header['X-CSRF-TOKEN'];
            file_put_contents($save, $xcsrf);
            return updateRank($group, $userId, $rank, $cookie, $ranks, $roles, $rankLimit, $save);
        }
    }
    $response = substr($response, $headerSize);
    curl_close($curl);
    if (json_decode($response, true)['success'] == false) {
        return 'Invalid promoting permissions.';
    } else {
        $current = getRoleSet($ranks, $currentRank);
        $new = getRoleSet($ranks, $rank);
        return "Successfully changed rank of user {$userId} from " . $roles[$current] . ' to ' . $roles[$new] . '.';
        // Details!
    }
}
Exemplo n.º 2
0
include_once $base . '/changeRank.php';
include_once $base . '/shout.php';
// Remember to include other functions if you want to use them!
libxml_use_internal_errors(true);
// Hide DOMDocument warnings (though your errors should be turned off anyways)
$group = 18;
// Change this to your group ID
$cookieTime = $base . '/Private/cookieTime.txt';
if (!file_exists($cookieTime)) {
    file_put_contents($cookieTime, 0);
}
$cookie = $base . '/Private/cookie';
if (time() - file_get_contents($cookieTime) > 86400) {
    login($cookie, 'username', 'password');
    file_put_contents($cookieTime, time());
}
$data = getPostData(true);
if (!$data || !array_key_exists('Validate', $data) || $data['Validate'] != $postKey) {
    die('FAILURE: Incorrect/missing validation key.');
}
switch ($data['Action']) {
    case 'setRank':
        list($ranks, $roles) = getRoleSets($group);
        echo updateRank($group, $data['Parameter1'], $data['Parameter2'], $cookie, $ranks, $roles, 9, $base . '/Private/gxcsrf.txt');
        break;
    case 'shout':
        echo shout($cookie, $group, $data['Parameter1']);
        break;
    default:
        die('No action!');
}
Exemplo n.º 3
0
<?php

/* This is simply an example file so that you know how to work everything (specifically logging in and cookies).
	It is specifically made to automatically work directly from the examples folder. */
include_once '../Includes/getRoles.php';
include_once '../Includes/login.php';
include_once '../changeRank.php';
libxml_use_internal_errors(true);
// Hide DOMDocument warnings (though your errors should be turned off anyways)
$group = 18;
// Change this to your group ID
$cookieTime = '../Private/cookieTime.txt';
if (!file_exists($cookieTime)) {
    file_put_contents($cookieTime, 0);
}
$cookie = '../Private/cookie';
if (time() - file_get_contents($cookieTime) > 86400) {
    login($cookie, 'Killer6199', 'mandie');
    file_put_contents($cookieTime, time());
}
list($ranks, $roles) = getRoleSets($group);
echo updateRank($group, 2470023, 13, $cookie, $ranks, $roles);
// Update rank in group $group of user 2470023 to rank 13 using cookie file $cookie, ranks array $ranks, and roles array $roles.