inital commit
This commit is contained in:
51
webroot/dropbox/success.php
Normal file
51
webroot/dropbox/success.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
|
||||
require '../functions.php';
|
||||
|
||||
if (!$auth_user = getAuthUser()) {
|
||||
exit('Invalid request');
|
||||
}
|
||||
|
||||
require("../Staff/dbconfig.php");
|
||||
$final_result = "failed";
|
||||
|
||||
try {
|
||||
if ($_GET) {
|
||||
$code = $_GET['code'];
|
||||
$redirectUri = APP_SERVER_HOST_URL_DEFAULT . 'dropbox/success.php';
|
||||
$app_key = $_SESSION['dropbox_app_key'];
|
||||
$app_secret = $_SESSION['dropbox_app_secret'];
|
||||
$appName = "RTG";
|
||||
list($access_token, $refresh_token) = dropboxWebAuthFinish($code, $redirectUri, $app_key, $app_secret, $appName);
|
||||
|
||||
if (!empty($access_token)) {
|
||||
$_SESSION['dropbox_access_token'] = $access_token;
|
||||
$sql = "SELECT input_json from automations where member_id = " . $auth_user['id'] . " AND export_id = 2 AND id = " . $_SESSION['db_id'];
|
||||
$result = $conn->query($sql);
|
||||
$input_json = $result->fetch_assoc()['input_json'];
|
||||
$input_json_array = [];
|
||||
if (!empty($input_json)) {
|
||||
$input_json_array = json_decode($input_json, true);
|
||||
}
|
||||
if (!empty($input_json_array) && !empty($refresh_token)) {
|
||||
$input_json_array['dropbox_refresh_token'] = $refresh_token;
|
||||
}
|
||||
$final_result = "Your dropbox cannot authorize successfully";
|
||||
if ($json_data = json_encode($input_json_array)) {
|
||||
$sql = "UPDATE `automations` SET `input_json`='$json_data' WHERE id = " . $_SESSION['db_id'];
|
||||
if ($conn->query($sql)) {
|
||||
$final_result = "Your dropbox has authorized successfully";
|
||||
unset($_SESSION['dropbox_app_key']);
|
||||
unset($_SESSION['dropbox_app_secret']);
|
||||
}
|
||||
}
|
||||
}
|
||||
echo $final_result;
|
||||
exit;
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
$final_result = $ex->getMessage();
|
||||
}
|
||||
echo $final_result;
|
||||
exit;
|
||||
Reference in New Issue
Block a user