SHOW:
|
|
- or go back to the newest paste.
| 1 | <?php | |
| 2 | //Database connection info | |
| 3 | $db_hostname = "188.93.232.9"; //Hostname | |
| 4 | $db_port = 3306; //Port | |
| 5 | $db_username = "NOME"; //Username | |
| 6 | $db_password = "PASSWORD"; //Password | |
| 7 | $db_database = "dbnome"; //Database | |
| 8 | ||
| 9 | //Steam info | |
| 10 | $steam_username = "nomedaconta"; //Steam username | |
| 11 | $steam_password = "passworddaconta"; //Steam password | |
| 12 | $steam_communityid = "76561198029643876"; | |
| 13 | $steam_cookie = "76561198029643876%7C%7C3ECC77FED53CAB9D23BEDC724AF73175B8FDD640"; | |
| 14 | ||
| 15 | //Plugin info | |
| 16 | $plugin_groupid = "103582791433145563"; //Community ID of the group | |
| 17 | $plugin_invites = "250"; //Number of invites per day | |
| 18 | ||
| 19 | //Getting plugin info | |
| 20 | if(!file_exists("autoinvite.txt"))
| |
| 21 | {
| |
| 22 | touch("autoinvite.txt");
| |
| 23 | $invites_sofar = 0; | |
| 24 | $time_of_last_max = 0; | |
| 25 | } | |
| 26 | else | |
| 27 | {
| |
| 28 | list($invites_sofar, $steam_cookie, $time_of_first) = explode("\n", file_get_contents("autoinvite.txt"));
| |
| 29 | } | |
| 30 | ||
| 31 | //Over the time limit, resetting | |
| 32 | if($time_of_first < (time()-7200)) | |
| 33 | {
| |
| 34 | $invites_sofar = 0; | |
| 35 | ||
| 36 | //Fetching Steam cookie | |
| 37 | $data = array("username" => $steam_username,
| |
| 38 | "password" => $steam_password, | |
| 39 | "emailauth" => "", | |
| 40 | "captchagid" => "-1", | |
| 41 | "captcha_text" => ""); | |
| 42 | $steam_login = curl_init(); | |
| 43 | curl_setopt($steam_login, CURLOPT_URL, "https://steamcommunity.com/"); | |
| 44 | curl_setopt($steam_login, CURLOPT_RETURNTRANSFER, 1); | |
| 45 | curl_setopt($steam_login, CURLOPT_HEADER, 1); | |
| 46 | curl_setopt($steam_login, CURLOPT_POST, 1); | |
| 47 | curl_setopt($steam_login, CURLOPT_POSTFIELDS, $data); | |
| 48 | $output=curl_exec($steam_login); | |
| 49 | if(preg_match("/steamLogin=(.*);/i", $output, $steam_cookie))
| |
| 50 | $steam_cookie = $steam_cookie[1]; | |
| 51 | curl_close($steam_login); | |
| 52 | } | |
| 53 | ||
| 54 | $steam_communityid = strstr($steam_cookie, "%", true); | |
| 55 | ||
| 56 | //Connect to database | |
| 57 | $mysqli_conn = new mysqli($db_hostname, $db_username, $db_password, $db_database, $db_port); | |
| 58 | ||
| 59 | $invites_now = 0; | |
| 60 | ||
| 61 | if($invites_sofar < $plugin_invites) | |
| 62 | {
| |
| 63 | if(isset($_GET["communityid"])) | |
| 64 | {
| |
| 65 | $result = invite_player($steam_communityid, $_GET["communityid"], $plugin_groupid, $steam_cookie); | |
| 66 | if(preg_match("/\<\!\[CDATA\[OK\]\]\>/", $result))
| |
| 67 | {
| |
| 68 | $invites_now++; | |
| 69 | $mysqli_conn->query("INSERT INTO invited_players (communityid) VALUES(\"".$mysqli_conn->real_escape_string($_GET["communityid"])."\")");
| |
| 70 | } | |
| 71 | if($_GET["log"]) | |
| 72 | {
| |
| 73 | echo $result; | |
| 74 | } | |
| 75 | } | |
| 76 | ||
| 77 | if(($invites_sofar + $invites_now) < $plugin_invites) | |
| 78 | {
| |
| 79 | //Fetch queued players and invite them | |
| 80 | ||
| 81 | $successful_invites = array(); | |
| 82 | ||
| 83 | $mysql_query = $mysqli_conn->query("SELECT * FROM queued_players LIMIT 0, ".($plugin_invites-$invites_sofar-$invites_now));
| |
| 84 | ||
| 85 | while($player = $mysql_query->fetch_assoc()) | |
| 86 | {
| |
| 87 | $result = invite_player($steam_communityid, $player["communityid"], $plugin_groupid, $steam_cookie); | |
| 88 | ||
| 89 | if(preg_match("/\<\!\[CDATA\[OK\]\]\>/", $result))
| |
| 90 | {
| |
| 91 | $invites_now++; | |
| 92 | $mysqli_conn->query("INSERT INTO invited_players (communityid) VALUES(\"".$player["communityid"]."\")");
| |
| 93 | } | |
| 94 | $successful_invites[] = $player["communityid"]; | |
| 95 | } | |
| 96 | ||
| 97 | //Delete successfully invited players from database | |
| 98 | ||
| 99 | $mysql_query_string = "DELETE FROM queued_players WHERE"; | |
| 100 | ||
| 101 | for($i=0;$i<count($successful_invites);++$i) | |
| 102 | {
| |
| 103 | $mysql_query_string .= " communityid=\"".$successful_invites[$i]."\""; | |
| 104 | if(($i+1) != count($successful_invites)) | |
| 105 | $mysql_query_string .= " OR"; | |
| 106 | } | |
| 107 | ||
| 108 | $mysqli_conn->query($mysql_query_string); | |
| 109 | } | |
| 110 | } | |
| 111 | else | |
| 112 | {
| |
| 113 | if(isset($_GET["communityid"])) | |
| 114 | {
| |
| 115 | //Can't invite more today, queueing | |
| 116 | $mysqli_conn->query("INSERT INTO queued_players (communityid) VALUES(\"".$mysqli_conn->real_escape_string($_GET["communityid"])."\")");
| |
| 117 | } | |
| 118 | } | |
| 119 | ||
| 120 | //Close database connection | |
| 121 | $mysqli_conn->close(); | |
| 122 | ||
| 123 | //Saving plugin info | |
| 124 | //New session | |
| 125 | if($invites_sofar == 0) | |
| 126 | $time_of_first = time(); | |
| 127 | ||
| 128 | $invites_sofar += $invites_now; | |
| 129 | ||
| 130 | file_put_contents("autoinvite.txt", $invites_sofar."\n".$steam_cookie."\n".$time_of_first);
| |
| 131 | ||
| 132 | function invite_player($inviter, $invitee, $group, $steam_cookie) | |
| 133 | {
| |
| 134 | $query_string = "?type=groupInvite&inviter=".$inviter."&invitee=".$invitee."&group=".$group; | |
| 135 | $steam_invite = curl_init(); | |
| 136 | curl_setopt($steam_invite, CURLOPT_URL, "http://steamcommunity.com/actions/GroupInvite".$query_string); | |
| 137 | curl_setopt($steam_invite, CURLOPT_RETURNTRANSFER, 1); | |
| 138 | curl_setopt($steam_invite, CURLOPT_HEADER, 1); | |
| 139 | curl_setopt($steam_invite, CURLOPT_COOKIE, "steamLogin=".$steam_cookie); | |
| 140 | $result = curl_exec($steam_invite); | |
| 141 | curl_close($steam_invite); | |
| 142 | return $result; | |
| 143 | } | |
| 144 | ?> |