-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ad9de0
commit 848725f
Showing
40 changed files
with
816 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,18 @@ | ||
Order Deny,Allow | ||
Deny from 204.12.217.130 95.216.5.232 | ||
|
||
RewriteEngine On | ||
RewriteCond %{SERVER_PORT} 80 | ||
RewriteRule ^(.*)$ https://twitchtokengenerator.com/$1 [R,L] | ||
RewriteRule ^(.*)$ https://twitchtokengenerator.com/$1 [R,L] | ||
<Files 403.shtml> | ||
order allow,deny | ||
allow from all | ||
</Files> | ||
|
||
deny from 81.92.203.76 | ||
deny from 81.92.203.0/24 | ||
deny from 84.66.181.27 | ||
deny from 94.109.185.22 | ||
deny from 90.108.238.38 | ||
deny from 73.245.107.0 | ||
deny from 180.150.32.18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
include("../config.php"); | ||
include("../twitchtv.php"); | ||
?> | ||
|
||
<title>Twitch Token Generator by swiftyspiffy - Redirecting...</title> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css"> | ||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> | ||
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js"></script> | ||
|
||
<br> | ||
<div class="container"> | ||
<div class="panel panel-primary"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title text-center">Twitch Token Generator - Redirecting...</h3> | ||
</div> | ||
<div class="panel-body"> | ||
<center> | ||
<span>Redirecting you to authorize on Twitch for <b> <? echo $title; ?> </b>. <br>If you are not redirected in 5 seconds, <a style="font-weight: bold; font-size: 120%;" href="<? echo $url; ?>">click here</a>. | ||
<br><br> | ||
Thanks for using TwitchTokenGenerator.com! | ||
</span> | ||
</center> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
var url = "<? echo $url; ?>"; | ||
|
||
setInterval(function(){ window.location.href = url; }, 3000); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
<? | ||
|
||
if(isset($_POST['robot_identifier'])) { | ||
$id = $_POST['robot_identifier']; | ||
$data = $dao->getApiRecaptchaStatus($id); | ||
if($data['error'] != "0") { | ||
header('Content-Type: application/json'); | ||
exit(json_encode(array('success' => false, 'message' => 'Unknown API workflow identifier'))); | ||
} | ||
|
||
$captcha = $_POST['g-recaptcha-response']; | ||
$ip = $_SERVER['REMOTE_ADDR']; | ||
|
||
if(!isValid($captcha, $ip)) | ||
exit(json_encode(array('success' => false, 'message' => "reCaptcha was not valid!"))); | ||
|
||
switch($data['recaptcha_status']) { | ||
case "0": | ||
if(strlen($data['token']) == 0) { | ||
// send to twitch to auth | ||
$url = getTwitchAuthUrl($data['scopes'], $id); | ||
exit(header("Location: ".$url)); | ||
} else { | ||
// send to success | ||
$dao->updateApiRecaptchaStatus($id, "2"); | ||
$title = $data['title']; | ||
include("success_after_verify.php"); | ||
exit(); | ||
} | ||
case "1": | ||
// authing now | ||
$dao->updateApiRecaptchaStatus($id, "2"); | ||
$url = getTwitchAuthUrl($data['scopes'], $id); | ||
exit(header("Location: ".$url)); | ||
default: | ||
header('Content-Type: application/json'); | ||
exit(json_encode(array('success' => false, 'message' => 'Unknown API workflow identifier'))); | ||
break; | ||
} | ||
} else { | ||
$data = $dao->getApiRecaptchaStatus($identifier); | ||
if(data['error'] != "0") { | ||
header('Content-Type: application/json'); | ||
exit(json_encode(array('success' => false, 'message' => 'Unknown API workflow identifier'))); | ||
} | ||
if($data['recaptcha_status'] == "0" && strlen($data['token']) == 0) { | ||
// go to twitch | ||
$url = getTwitchAuthUrl($data['scopes'], $identifier); | ||
exit(header("Location: ".$url)); | ||
} | ||
exit("status: ".$data['recaptcha_status'].", token: '".$data['token']."'"); | ||
if($data['recaptcha_status'] == "2") { | ||
// go to success page | ||
$title = $data['title']; | ||
include("success_after_verify.php"); | ||
exit(); | ||
} | ||
if($data['recaptcha_status'] == "1" && strlen($data['token']) > 0) { | ||
header('Content-Type: application/json'); | ||
exit(json_encode(array('success' => false, 'message' => 'Invalid API workflow state'))); | ||
} | ||
} | ||
|
||
?> | ||
|
||
<style> | ||
.g-recaptcha{ | ||
margin: 15px auto !important; | ||
width: auto !important; | ||
height: auto !important; | ||
text-align: -webkit-center; | ||
text-align: -moz-center; | ||
text-align: -o-center; | ||
text-align: -ms-center; | ||
} | ||
</style> | ||
|
||
<script> | ||
function recaptchaSuccess() { | ||
$("#robot_form").submit(); | ||
} | ||
</script> | ||
|
||
<title>Twitch Token Generator by swiftyspiffy - Recaptcha</title> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css"> | ||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> | ||
<script src='https://www.google.com/recaptcha/api.js'></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js"></script> | ||
|
||
<br> | ||
<div class="container"> | ||
<div class="panel panel-primary"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title text-center">Twitch Token Generator - Recaptcha</h3> | ||
</div> | ||
<div class="panel-body"> | ||
<center> | ||
<span>Thank you for using TwitchTokenGenerator! Please complete the reCaptcha below!</span> | ||
</center> | ||
<form id="robot_form" action="verify" method="post"> | ||
<input type="hidden" id="robot_identifier" name="robot_identifier" value="<? echo $identifier; ?>"></input> | ||
<div class="g-recaptcha" data-callback="recaptchaSuccess" style="padding-left: 23%" data-sitekey="6LeaCF0UAAAAAMG7-HRJ1Oq_aneLPdQQNN0r9_no"></div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<? | ||
function getTwitchAuthUrl($scopes, $id) { | ||
$url = "https://api.twitch.tv/kraken/oauth2/authorize?response_type=code&client_id=".API_CLIENT_ID."&redirect_uri=https://twitchtokengenerator.com/api/success&scope=".str_replace(" ", "+", $scopes); | ||
$state = base64_encode(json_encode(array('action' => 'api', 'id' => $id)));; | ||
|
||
return $url."&state=".$state."&force_verify=true"; | ||
} | ||
|
||
function isValid($captcha, $ip) { | ||
try { | ||
|
||
$url = 'https://www.google.com/recaptcha/api/siteverify'; | ||
$data = ['secret' => RECAPTCHA_SECRET, | ||
'response' => $captcha, | ||
'remoteip' => $ip]; | ||
|
||
$options = [ | ||
'http' => [ | ||
'header' => "Content-type: application/x-www-form-urlencoded\r\n", | ||
'method' => 'POST', | ||
'content' => http_build_query($data) | ||
] | ||
]; | ||
|
||
$context = stream_context_create($options); | ||
$result = file_get_contents($url, false, $context); | ||
return json_decode($result)->success; | ||
} | ||
catch (Exception $e) { | ||
$dao->insertError("internal.php", "isValid", "failed to verify captcha with google"); | ||
return null; | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.