Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $forum_path = '/var/www/vhosts/gooncave.com/mwo';
- require_once( $forum_path . 'SSI.php' );
- echo "<html>
- <head>
- <title>mwo - SA Authorization</title>
- <link rel='shortcut icon' type='image/x-icon' href='/favicon.ico'>
- <!-- CHANGE THE CSS FILE HERE -->
- <link rel="stylesheet" type="text/css"href="http://mwo.gooncave.com/Themes/blackrain_202/css/index.css?fin20" />
- </head>
- <body>
- <h3 class='pagetop'>SA Authorization</h3>
- <div class='content navigation'>
- </div>\n<br><br><br>
- <div class='wrapper'><div class='content'>
- <div id='content' class='clearfix'>
- <div class='guestMessage'><center>";
- if ( !empty($user_info['id'] )
- {
- if ( in_array(3, $user_info['groups']) ) // Allow only member_group_id == 0, which is 'Regular Members'
- {
- # Forums Info
- $mwoUsername = $user_info['name'];
- $mwoMemberID = $user_info['id'];
- # Start of SomethingAwful Auth
- if ( !$_POST )
- {
- # Generate a key to verify the user
- $key = sha1(rand(1000000, 9999999));
- $_SESSION['auth_key'] = $key;
- $_SESSION['auth_done'] = "no";
- $_SESSION['auth_action'] = "signup";
- echo "<script language='Javascript'>
- function validate()
- {
- if ( !document.auth.sausername.value )
- {
- alert('You must enter your SA username');
- return false;
- } else
- return true;
- }
- </script>
- <b>Welcome to the Mechwarrior Online Goons forums!</b><br>
- We're open to all SA forum members. Use this page to verify that you're an SA forum member.<br><br>
- To do this, <a href='http://forums.somethingawful.com/member.php?s=&action=editprofile' target='_blank'>edit your SA profile</a>, and add this key to your Interests field:<br>
- <b>" . $key . "</b><br>
- (notice: this key changes each refresh)
- <br/><br/>
- Once you've done that, enter your SA username below, and click Continue.
- <br/><br/>
- <form name='auth' method='post'>
- Your SA Username: <input type='text' name='sausername'>
- <input type='hidden' name='auth_key' value='" . $_SESSION['auth_key'] . "'>
- <input type='submit' onclick='return validate()' name='submit' value='Continue'>
- </center>
- </form>
- </div></div></div></div>";
- }
- else
- {
- if ( !isset( $_SESSION['auth_key'] ) )
- {
- echo "<div class='content warning'>Sorry, looks like your key expired. Press Back and try again.</div>";
- exit();
- } elseif ( $_SESSION['auth_key'] != $_POST['auth_key'] )
- {
- echo "<div class='content warning'>Key mismatch. Press back and try again.</div>";
- exit();
- }
- # The user we want to check, and they key to check
- $user = $_POST['sausername'];
- $key = $_SESSION['auth_key'];
- # Setup values to use in the CURL operation
- $en = 'action=getinfo&username=' . urlencode($user);
- $profile_encode = 'http://forums.somethingawful.com/member.php?' . $en;
- $login = array('action' => 'login', 'username' => 'wargames', 'password' => '');
- # Logfile Access
- //$logfile = '/var/www/vhosts/gooncave.com/mwo/debug.txt';
- //$open = fopen($logfile, 'w');
- # These aren't necessary, but it helps to prevent setting off any alarms
- $useragent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0';
- $referer = 'http://forums.somethingawful.com/usercp.php?s=';
- # Initialize CURL and start collecting the output buffer
- $ch = curl_init();
- # Setup CURL options
- curl_setopt($ch, CURLOPT_URL, "http://forums.somethingawful.com/account.php");
- curl_setopt($ch, CURLOPT_POST, TRUE);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $login);
- curl_setopt($ch, CURLOPT_HEADER, TRUE);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
- //curl_setopt($ch, CURLOPT_STDERR, $open);
- curl_setopt($ch, CURLOPT_COOKIESESSION, true);
- curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt");
- curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
- curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
- curl_setopt($ch, CURLOPT_REFERER, $referer);
- $result = curl_exec ($ch);
- curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
- curl_setopt($ch, CURLOPT_URL, "http://forums.somethingawful.com/index.php");
- $response = curl_exec ($ch);
- curl_setopt($ch, CURLOPT_URL, $profile_encode);
- curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE);
- $response = curl_exec ($ch);
- $headers = curl_getinfo($ch, CURLINFO_HEADER_OUT);
- # SA Scrape Debug
- //echo $headers;
- //echo "<hr />";
- //echo $profile_encode;
- //echo "<hr />";
- //echo $result2;
- //echo "<hr />";
- $x = curl_version();
- if ( $response == "" )
- {
- echo "<div class='content warning'>The signup system is down! Please report this to wargames. (No response from SA forums: " . curl_errno($ch) . " " . curl_error($ch) .")</div>";
- } elseif ( strpos($response, 'This user has not registered and therefore does not have a profile to view.') )
- {
- echo "<div class='content warning'>I could not find your profile, did you type your nickname correctly? Press back and try again.</div>";
- } elseif ( strpos($response, 'You are not logged in') )
- {
- echo "<div class='content warning'>The signup system is down! Please report this to wargames. (Could not log in)</div>";
- } elseif ( strpos($response, 'Special Message from Senor Lowtax') )
- {
- echo "<div class='content warning'>There was a problem checking your nickname against the forums. (Special message from Senor Lowtax - forums down?)</div>";
- } elseif ( strpos($response, $key) )
- {
- # Begin session cleanup
- $_SESSION['auth_done'] = 'yes';
- $_SESSION['auth_username'] = $_POST['sausername'];
- unset( $_SESSION['auth_key'] );
- require_once($sourcedir . '/Subs-MemberGroups.php');
- # Change users forum group to 'Authorized Members' (10) and adds their SA Name to their profilez
- addMembersToGroup($user_info['id'], 10, 'only_additional', true)
- # Congrats!
- echo "<h3>Well done, " . $user_info['name'] . "!</h3>\n<div class='content current'>\nThank you, you have now been verified as a forum member.\n
- <b>First, <a href='http://forums.somethingawful.com/member.php?s=&action=editprofile'>edit your SA profile</a> again, and remove the key.</b><br><br></div>";
- } else
- {
- echo "<div class='content warning'>I couldn't see your key ( <b>" . $_SESSION['auth_key'] . "</b> ) in your profile. Press Back and try again.</div>";
- }
- curl_close($ch);
- }
- } else {
- echo "ERROR: User is not an 'Unauthorized Member'<br><br>\n";
- // Forums Info
- echo "Forums Username: " . $user_info['name'] . "<br>\n";
- echo "Forums memberID: " . $user_info['id'] . "<br>\n";
- echo "Forums Group ID: " . implode(',', $user_info['groups']) . "<br>\n";
- }
- } else {
- echo "User is not logged into the mwo goons forums.<br>\n";
- }
- ?>
- </div></div></div></div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement