public static function chatcatAjax() { $auth = modChatCatHelper::getAuth(); if ($auth) { $app = JFactory::getApplication(); $input = $app->input; $action = $input->get('action'); if ($action == 'cc_get_uid') { $auth->respondWithUserID(); return null; //return json_decode($auth->UserIdJSON()); } if ($action == 'cc_get_token') { $auth->respondWithToken(); return null; //return json_decode($auth->tokenJSON()); } } else { CCAuth::logout(); return null; //return json_decode(CCAuth::logoutJSON()); } }
function cc_logout() { CCAuth::logout(); die; }
//getting user details if ($user_id > 0) { $api_key = $_REQUEST['api_key']; $secret = $_REQUEST['secret']; $src = urldecode($_REQUEST['src']); $username = $_REQUEST['username']; $description = $_REQUEST['description']; $yearOfBirth = $_REQUEST['yearOfBirth']; $location = $_REQUEST['location']; $homepage = urldecode($_REQUEST['homepage']); $sex = $_REQUEST['sex']; $sex = $sex == 'Male' ? 'M' : 'F'; // Create a new Auth instance $auth = new CCAuth($user_id, $secret, $api_key, ''); // Authenticate the user $auth->setUserInfo($username, $description, $sex, $yearOfBirth, $location, null, $src, array('homepageLink' => $homepage)); return $auth; } return null; } $auth = get_auth(); if ($auth != null) { if ($_REQUEST['action'] == 'cc_get_uid') { $auth->respondWithUserID(); } if ($_REQUEST['action'] == 'cc_get_token') { $auth->respondWithToken(); } } else { CCAuth::logout(); }