public function getContactInfoAction() { $request = $_GET; $token = isset($request['TOKEN']) ? trim($request['TOKEN']) : null; if (!$token) { return ['STATUS_CODE' => STATUS_CODE_BAD_REQUEST, 'DATA' => buckys_api_get_error_result('Api token should not be blank')]; } if (!($userID = BuckysUsersToken::checkTokenValidity($token, "api"))) { return ['STATUS_CODE' => STATUS_CODE_UNAUTHORIZED, 'DATA' => buckys_api_get_error_result('Api token is not valid.')]; } $contactInfo = BuckysUser::getUserContactInfo($userID); return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => ['STATUS' => 'SUCCESS', 'RESULT' => $contactInfo]]; }
<?php require dirname(__FILE__) . '/includes/bootstrap.php'; //If the user is not logged in, redirect to the index page if (!($userID = buckys_is_logged_in())) { buckys_redirect('/index.php'); } //Getting UserData from Id $userData = BuckysUser::getUserContactInfo($userID); //Goto Homepage if the userID is not correct if (!buckys_not_null($userData)) { buckys_redirect('/index.php'); } if (isset($_POST['action'])) { //Check the user id is same with the current logged user id if ($_POST['userID'] != $userID) { echo 'Invalid Request!'; exit; } //Save Primary Email if ($_POST['action'] == 'save_email') { //Check the email address is valid or not $pattern = '/^([a-zA-Z0-9_+\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9])+$/'; /*if( !preg_match($pattern, $_POST['email']) ) { echo 'Please input a valid e-mail address'; exit; } //Check if the email is used or not if( BuckysUser::checkEmailDuplication($_POST['email'], $userID) ) {