Ejemplo 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!
    }
}
Ejemplo n.º 2
0
function getPlayers($ranks, $raw, $group, $rank, $limit, $online)
{
    $players = array();
    $role = getRoleSet($ranks, $rank);
    $start = time();
    $url = "http://www.roblox.com/Groups/group.aspx?gid={$group}";
    $curl = curl_init($url);
    // Start off by just getting the page
    // We need the correct validation before sending other requests
    curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => true, CURLOPT_USERAGENT => 'Mozilla'));
    $response = curl_exec($curl);
    // Include __VIEWSTATE, __EVENTVALIDATION, and __VIEWSTATEGENERATOR in the next post array
    // Set the rank we want to search from while we're at it
    $nextPost = getPostArray($response, array('ctl00$cphRoblox$rbxGroupRoleSetMembersPane$dlRolesetList' => $role, 'ctl00$cphRoblox$rbxGroupRoleSetMembersPane$currentRoleSetID' => $role, '__ASYNCPOST' => 'true'));
    curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $nextPost));
    $response = curl_exec($curl);
    $doc = new DOMDocument();
    $doc->loadHTML($response);
    $find = new DomXPath($doc);
    // Do a dance to get the number of pages
    foreach ($find->query("(//div[contains(@id,'ctl00_cphRoblox_rbxGroupRoleSetMembersPane_dlUsers_Footer_ctl01_Div1')]//div[contains(@class,'paging_pagenums_container')])[1]") as $node) {
        $pages = $node->textContent;
    }
    if (!isset($pages)) {
        $pages = 1;
    }
    curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $nextPost));
    $response = curl_exec($curl);
    for ($i = 1; $i <= $pages; $i++) {
        if ($limit != -1 && count($players) >= $limit) {
            break;
        }
        $players = getPlayersOnPage($response, $players, $limit, $online);
        // __VIEWSTATE and __EVENTVALIDATION are not updated as inputs, rather some weird format I don't recognize
        preg_match('#\\|__VIEWSTATE\\|(.*?)\\|.*\\|__EVENTVALIDATION\\|(.*?)\\|#', $response, $inputs);
        $nextPost = array('__VIEWSTATE' => $inputs[1], '__EVENTVALIDATION' => $inputs[2], '__ASYNCPOST' => 'true', 'ctl00$cphRoblox$rbxGroupRoleSetMembersPane$currentRoleSetID' => $role, 'ctl00$cphRoblox$rbxGroupRoleSetMembersPane$dlUsers_Footer$ctl01$HiddenInputButton' => '', 'ctl00$cphRoblox$rbxGroupRoleSetMembersPane$dlUsers_Footer$ctl01$PageTextBox' => $i + 1);
        curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $nextPost));
        $response = curl_exec($curl);
    }
    if (!$raw) {
        echo 'Get time: ' . (time() - $start) . ' seconds<br>Players: ' . count($players) . '<br><br>';
    }
    return $players;
}
Ejemplo n.º 3
0
function getPlayers($ranks, $raw, $group, $rank, $limit, $online, $multiLimit)
{
    $players = array();
    $role = getRoleSet($ranks, $rank);
    $start = time();
    $url = "http://www.roblox.com/Groups/group.aspx?gid={$group}";
    $curl = curl_init($url);
    // Start off by just getting the page
    // We need the correct validation before sending other requests
    curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => true, CURLOPT_USERAGENT => 'Mozilla'));
    $response = curl_exec($curl);
    // Include __VIEWSTATE, __EVENTVALIDATION, and __VIEWSTATEGENERATOR in the next post array
    // Set the rank we want to search from while we're at it
    $nextPost = getPostArray($response, array('ctl00$cphRoblox$rbxGroupRoleSetMembersPane$dlRolesetList' => $role, 'ctl00$cphRoblox$rbxGroupRoleSetMembersPane$currentRoleSetID' => $role, '__ASYNCPOST' => 'true'));
    $vs = $nextPost['__VIEWSTATE'];
    $ev = $nextPost['__EVENTVALIDATION'];
    curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $nextPost));
    $response = curl_exec($curl);
    $doc = new DOMDocument();
    $doc->loadHTML($response);
    $find = new DomXPath($doc);
    // Do a dance to get the number of pages
    foreach ($find->query("(//div[contains(@id,'ctl00_cphRoblox_rbxGroupRoleSetMembersPane_dlUsers_Footer_ctl01_Div1')]//div[contains(@class,'paging_pagenums_container')])[1]") as $node) {
        $pages = $node->textContent;
    }
    if (!isset($pages)) {
        $pages = 1;
    }
    curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $nextPost));
    $response = curl_exec($curl);
    curl_close($curl);
    $players = getPlayersOnPage($response, $players, $limit, $online);
    if ($pages > $multiLimit) {
        $maxml = ceil($pages / $multiLimit);
    } else {
        $maxml = 1;
    }
    for ($ml = 0; $ml < $maxml; $ml++) {
        if ($limit != -1 && count($players) >= $limit) {
            break;
        }
        $requests = array();
        $multi = curl_multi_init();
        $max = ($ml + 1) * $multiLimit;
        if ($max > $pages) {
            $max = $pages - 1;
        }
        for ($i = 1 + $ml * $multiLimit; $i <= $max; $i++) {
            if ($limit != -1 && count($players) >= $limit) {
                break;
            }
            $nextPost = array('__VIEWSTATE' => $vs, '__EVENTVALIDATION' => $ev, '__ASYNCPOST' => 'true', 'ctl00$cphRoblox$rbxGroupRoleSetMembersPane$currentRoleSetID' => $role, 'ctl00$cphRoblox$rbxGroupRoleSetMembersPane$dlUsers_Footer$ctl01$HiddenInputButton' => '', 'ctl00$cphRoblox$rbxGroupRoleSetMembersPane$dlUsers_Footer$ctl01$PageTextBox' => $i + 1);
            $curl = curl_init($url);
            curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $nextPost, CURLOPT_USERAGENT => 'Mozilla'));
            array_push($requests, $curl);
            curl_multi_add_handle($multi, $curl);
        }
        do {
            curl_multi_exec($multi, $running);
            curl_multi_select($multi);
        } while ($running > 0);
        foreach ($requests as $index => $request) {
            $data = curl_multi_getcontent($request);
            $players = getPlayersOnPage($data, $players, $limit, $online);
            curl_close($request);
            curl_multi_remove_handle($multi, $request);
        }
        curl_multi_close($multi);
    }
    if (!$raw) {
        echo 'Get time: ' . (time() - $start) . ' seconds<br>Players: ' . count($players) . '<br><br>';
    }
    return $players;
}