| Server IP : 138.197.176.125 / Your IP : 216.73.217.122 Web Server : Apache/2.4.41 (Ubuntu) System : Linux SuiteCRM-8 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/vtigerversion80/ |
Upload File : |
<?php
/*+**********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
************************************************************************************/
header("Content-Type:application/json");
include_once 'include/Webservices/Relation.php';
include_once 'vtlib/Vtiger/Module.php';
include_once 'includes/main/WebUI.php';
require_once('include/utils/utils.php');
global $adb,$current_user;
$jsonStr = file_get_contents("php://input"); //read the HTTP body.
$jsonDecodeData = json_decode($jsonStr, true);
$currentUserId = $jsonDecodeData['userId'];
$tokenDetails = json_decode($jsonDecodeData['token'],true);
$accessToken = $tokenDetails['access_token'];
$id_token = $tokenDetails['id_token'];
$tokenDetails['created'] = time();
$tokenData = "'".json_encode($tokenDetails)."'";
$clientId = "819644135058-kcmf6pvbcqtbicufib6t4uan475d39d9.apps.googleusercontent.com";
$clientSecret = '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';
$email = CTGoogleSuite_Record_Model::getGoogleUserProfile($accessToken);
$tableName = 'ctgoogleoffice365suite_googlesuite_token';
$getConfigurationData = $adb->pquery("SELECT * FROM $tableName WHERE `user_id` = $currentUserId",array());
$numOfRows = $adb->num_rows($getConfigurationData);
if($numOfRows > 0){
$result = $adb->pquery("UPDATE $tableName SET `token` = $tokenData WHERE `user_id` = $currentUserId", array());
}
else{
$result = $adb->pquery("INSERT INTO $tableName (`user_id`, `token`, `user_email`) VALUES ($currentUserId, $tokenData, '".$email."')",array());
}
echo json_encode(array('status' => 'success'));
?>