Files
Testing/verified.php

163 lines
6.5 KiB
PHP
Raw Permalink Normal View History

2026-11-17 16:15:01 -05:00
<?php
include("header.php");
if($user->user_info["verified"]==1&&$user->user_info["user_id"]!=7653){header("Location: /home.php");exit;}
/*
Test:
API ID: af98db4e-0197-4c05-903e-b862d76eff48
API KEY: key-d-c517285c-e4c9-467a-8e70-bdf4be3a2605
API Secret: secret-d-4aa58055-4bcd-4902-968d-ddb0bb21c7c5
*/
//https://oauth.verifymycontent.com/oauth/authorize?country=gb&client_id=key-d-2c8bf910-8565-468c-8170-3478168c9966&redirect_uri=https://bateworld.com/verified.php&scope=identity-check
$authorize_url = "https://oauth.verifymycontent.com/oauth/authorize";
$token_url = "https://oauth.verifymycontent.com/oauth/token";
// callback URL specified when the application was defined--has to match what the application says
$callback_uri = "https://bateworld.com/verified.php";
$test_api_url = "https://oauth.verifymycontent.com/users/me?access_token=";
$client_id = "key-d-2c8bf910-8565-468c-8170-3478168c9966";
$client_secret = "secret-d-b805e08c-22dd-4a56-a644-92fdf96d63c2";
if ($_POST["authorization_code"]) {
// what to do if there's an authorization code
$access_token = getAccessToken($_POST["authorization_code"]);
$resource = getResource($access_token);
} elseif ($_GET["code"]) {
$access_token = getAccessToken($_GET["code"]);
$resource = getResource($access_token);
if($resource["id"]!="")
{
if($user->user_info["user_level_id"]==2)
{
$database->database_query("UPDATE se_users SET verified=1, verified_id='".$database->database_real_escape_string($resource["id"])."', threshold='".$database->database_real_escape_string($resource["threshold"])."', verifieddate='".time()."' WHERE user_id='".$user->user_info["user_id"]."'");
$subs=$database->database_query("SELECT * FROM se_semods_userplans WHERE userplan_user_id='".$database->database_real_escape_string($user->user_info["user_id"])."'");
$sub=$database->database_fetch_array($subs);
if($sub["userplan_plan_id"]!="1"&&$sub["userplan_plan_id"]!="9"&&$sub["userplan_plan_id"]!="10") //if not recurring
{
$database->database_query("UPDATE se_users SET verifiedmembershippending=1 WHERE user_id='".$user->user_info["user_id"]."'");
}
elseif(strtolower($sub["biller"])=="segpay"){
$c=unserialize($sub["userplan_metadata"]);
if(trim($c["cc_id"])==""){$database->database_query("UPDATE se_users SET verifiedmembershippending=1 WHERE user_id='".$sub["user_id"]."'");}else{
$results=file("https://srs.segpay.com/ADM.asmx/ExtendMembership?Userid=S34Nob7E&UserAccessKey=\$SrSAccess0285&PurchaseID=".$c["cc_id"]."&Days=30");
if(trim($results[1])!="Successful"){
$database->database_query("UPDATE se_users SET verifiedmembershippending=1 WHERE user_id='".$user->user_info["user_id"]."'");
}}
}
elseif(strtolower($sub["biller"])=="ccbill"){
$c=unserialize($sub["userplan_metadata"]);
$x=0;
$y=0;
while($x<30){
if(trim($c["cc_id"])==""){$database->database_query("UPDATE se_users SET verifiedmembershippending=1 WHERE user_id='".$sub["user_id"]."'");}else{
$results=file("https://datalink.ccbill.com/utils/subscriptionManagement.cgi?clientAccnum=940183&username=peterr24&password=MickeY12!!&action=extendSubscription&extendLength=5&subscriptionId=".$c["cc_id"]."");
if(trim($results[1])=='"1"'){
$x=$x+5;
$database->database_query("UPDATE se_users SET verifiedcount='".($x)."' WHERE user_id='".$sub["userplan_user_id"]."'");
}
$y++;
if($y>=100){$database->database_query("UPDATE se_users SET verifiedcount='".($x)."' WHERE user_id='".$sub["userplan_user_id"]."'");break;}
}
}
}
else
{
mail("wayne@bateworld.com", "Verification Premium Issue", $user->user_info["user_username"]." has a premium membership, but we can't extend it for some reason.");
}
}
else{
$database->database_query("UPDATE se_users SET verified=1, verified_id='".$database->database_real_escape_string($resource["id"])."', threshold='".$database->database_real_escape_string($resource["threshold"])."', verifieddate='".time()."' WHERE user_id='".$user->user_info["user_id"]."'");
$plan = new semods_plan(7, $user->user_info["user_id"]);
$plan->plan_subscribe($user->user_info["user_id"], 0, array('cc_id' => "Verified member promotion"), FALSE, '');
}
header("Location: /home.php"); exit;
}
header("Location: /verified.php"); exit;
} else {
// what to do if there's no authorization code
getAuthorizationCode();
}
// step A - simulate a request from a browser on the authorize_url
// will return an authorization code after the user is prompted for credentials
function getAuthorizationCode() {
global $authorize_url, $client_id, $callback_uri;
$authorization_redirect_url = $authorize_url . "?country=gb&client_id=" . $client_id . "&redirect_uri=" . $callback_uri . "&scope=identity-check";
//echo $authorization_redirect_url; exit;
header("Location: " . $authorization_redirect_url);
// if you don't want to redirect
// echo "Go <a href='$authorization_redirect_url'>here</a>, copy the code, and paste it into the box below.<br /><form action=" . $_SERVER["PHP_SELF"] . " method = 'post'><input type='text' name='authorization_code' /><br /><input type='submit'></form>";
}
// step I, J - turn the authorization code into an access token, etc.
function getAccessToken($authorization_code) {
global $token_url, $client_id, $client_secret, $callback_uri;
$authorization = base64_encode($client_id.":".$client_secret);
$header = array("Content-Type: application/json");
$content = json_encode(array("code"=>$authorization_code, "client_secret"=>$client_secret, "client_id"=>$client_id));
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $token_url,
CURLOPT_HTTPHEADER => $header,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $content
));
$response = curl_exec($curl);
curl_close($curl);
if ($response === false) {
echo "Failed";
echo curl_error($curl);
echo "Failed";
} elseif (json_decode($response)->error) {
echo "Error:<br />";
echo $authorization_code;
echo $response;
}
return json_decode($response)->access_token;
}
// we can now use the access_token as much as we want to access protected resources
function getResource($access_token) {
global $test_api_url;
$header = array("Authorization: Bearer {$access_token}");
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $test_api_url,
CURLOPT_HTTPHEADER => $header,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_RETURNTRANSFER => true
));
$response = curl_exec($curl);
curl_close($curl);
if(json_decode($response, true)){
return json_decode($response, true);
}else{return $response;
}
}
?>