Exemplo n.º 1
0
	public function Authorize()
	{
		$GLOBALS["APPLICATION"]->RestartBuffer();
		$bSuccess = false;

			if(isset($_REQUEST["code"]) && $_REQUEST["code"] <> '')
			{
				if(CSocServAuthManager::CheckUniqueKey())
				{
				$redirect_uri = CSocServUtil::GetCurUrl('auth_service_id='.self::ID, array("code"));

				$appID = self::GetOption("facebook_appid");
				$appSecret = self::GetOption("facebook_appsecret");

				$fb = new CFacebookInterface($appID, $appSecret, $_REQUEST["code"]);

				if($fb->GetAccessToken($redirect_uri) !== false)
				{
					$arFBUser = $fb->GetCurrentUser();
					if(isset($arFBUser["id"]))
					{
						$arFields = array(
							'EXTERNAL_AUTH_ID' => self::ID,
							'XML_ID' => $arFBUser["id"],
							'LOGIN' => "FB_".$arFBUser["email"],
							'EMAIL' => $arFBUser["email"],
							'NAME'=> $arFBUser["first_name"],
							'LAST_NAME'=> $arFBUser["last_name"],
						);

						if(isset($arFBUser['picture']['data']['url']) && self::CheckPhotoURI($arFBUser['picture']['data']['url']))
							if ($arPic = CFile::MakeFileArray($arFBUser['picture']['data']['url']))
								$arFields["PERSONAL_PHOTO"] = $arPic;
						if(isset($arFBUser['birthday']))
							if ($date = MakeTimeStamp($arFBUser['birthday'], "MM/DD/YYYY"))
								$arFields["PERSONAL_BIRTHDAY"] = ConvertTimeStamp($date);
						if(isset($arFBUser['gender']) && $arFBUser['gender'] != '')
						{
							if ($arFBUser['gender'] == 'male')
								$arFields["PERSONAL_GENDER"] = 'M';
							elseif ($arFBUser['gender'] == 'female')
								$arFields["PERSONAL_GENDER"] = 'F';
						}
						$arFields["PERSONAL_WWW"] = "http://www.facebook.com/".$arFBUser["id"];
						$bSuccess = $this->AuthorizeUser($arFields);
					}
				}
			}
		}
		$aRemove = array("logout", "auth_service_error", "auth_service_id", "code", "error_reason", "error", "error_description", "check_key");
		$url = $GLOBALS['APPLICATION']->GetCurPageParam(($bSuccess? '':'auth_service_id='.self::ID.'&auth_service_error=1'), $aRemove);
		echo '
<script type="text/javascript">
if(window.opener)
	window.opener.location = \''.CUtil::JSEscape($url).'\';
window.close();
</script>
';
		die();
	}
Exemplo n.º 2
0
	public function Authorize($identity=false, $var=false)
	{
		if($var === false)
			$var = 'OPENID_IDENTITY_OPENID';

		$step = COpenIDClient::GetOpenIDAuthStep($var);
		if($step > 0)
		{
			$obOpenID = new COpenIDClient();
		
			if($step == 2)
			{
				return $obOpenID->Authorize();
			}
			elseif($step == 1)
			{
				if($identity === false)
					$identity = $_REQUEST['OPENID_IDENTITY_OPENID'];
				CSocServAuthManager::SetUniqueKey();
				$return_to = CSocServUtil::GetCurUrl("auth_service_id=".urlencode($_REQUEST["auth_service_id"])."&check_key=".$_SESSION["UNIQUE_KEY"]);

				if($url = $obOpenID->GetRedirectUrl($identity, $return_to))
					LocalRedirect($url, true);
				else
					return false;
			}
		}
		return false;
	}
Exemplo n.º 3
0
 public function getFriendsList($limit, &$next)
 {
     if (IsModuleInstalled('bitrix24') && defined('BX24_HOST_NAME')) {
         $redirect_uri = static::CONTROLLER_URL . "/redirect.php";
     } else {
         $redirect_uri = CSocServUtil::ServerName() . "/bitrix/tools/oauth/google.php";
     }
     $ob = $this->getEntityOAuth();
     if ($ob->GetAccessToken($redirect_uri) !== false) {
         $res = $ob->getCurrentUserFriends($limit, $next);
         foreach ($res["items"] as $key => $contact) {
             $contact["uid"] = $contact["id"];
             if (array_key_exists("name", $contact)) {
                 $contact["first_name"] = $contact["name"]["givenName"];
                 $contact["last_name"] = $contact["name"]["familyName"];
             } else {
                 list($contact["first_name"], $contact["last_name"]) = explode(" ", $contact["displayName"], 2);
             }
             if (array_key_exists("image", $contact)) {
                 $contact["picture"] = preg_replace("/\\?.*\$/", "", $contact["image"]["url"]);
             }
             $res["items"][$key] = $contact;
         }
         return $res["items"];
     }
     return false;
 }
Exemplo n.º 4
0
 public function Authorize($identity = false, $var = false)
 {
     if ($var === false) {
         $var = 'OPENID_IDENTITY_OPENID';
     }
     $step = COpenIDClient::GetOpenIDAuthStep($var);
     if ($step > 0) {
         $obOpenID = new COpenIDClient();
         if ($step == 2) {
             return $obOpenID->Authorize();
         } elseif ($step == 1) {
             if ($identity === false) {
                 $identity = $_REQUEST['OPENID_IDENTITY_OPENID'];
             }
             CSocServAuthManager::SetUniqueKey();
             $return_to = CSocServUtil::GetCurUrl("auth_service_id=" . urlencode($_REQUEST["auth_service_id"]) . "&check_key=" . $_SESSION["UNIQUE_KEY"], array("SEF_APPLICATION_CUR_PAGE_URL", "auth_service_error", "auth_service_id", "login"));
             if ($url = $obOpenID->GetRedirectUrl($identity, $return_to)) {
                 LocalRedirect($url, true);
             } else {
                 LocalRedirect(CSocServUtil::GetCurUrl("auth_service_id=" . urlencode($_REQUEST["auth_service_id"]) . "&auth_service_error=1"));
             }
             return false;
         }
     }
     return false;
 }
Exemplo n.º 5
0
    public function Authorize()
    {
        $GLOBALS["APPLICATION"]->RestartBuffer();
        $bSuccess = 1;
        if (isset($_REQUEST["code"]) && $_REQUEST["code"] != '') {
            if (CSocServAuthManager::CheckUniqueKey()) {
                if (IsModuleInstalled('bitrix24') && defined('BX24_HOST_NAME')) {
                    $redirect_uri = self::CONTROLLER_URL . "/redirect.php?redirect_to=" . urlencode(CSocServUtil::GetCurUrl('auth_service_id=' . self::ID, array("code")));
                } else {
                    $redirect_uri = CSocServUtil::GetCurUrl('auth_service_id=' . self::ID, array("code"));
                }
                $appID = trim(self::GetOption("facebook_appid"));
                $appSecret = trim(self::GetOption("facebook_appsecret"));
                $fb = new CFacebookInterface($appID, $appSecret, $_REQUEST["code"]);
                if ($fb->GetAccessToken($redirect_uri) !== false) {
                    $arFBUser = $fb->GetCurrentUser();
                    if (is_array($arFBUser) && isset($arFBUser["id"])) {
                        $email = $arFBUser["email"] != '' ? $arFBUser["email"] : '';
                        $arFields = array('EXTERNAL_AUTH_ID' => self::ID, 'XML_ID' => $arFBUser["id"], 'LOGIN' => "FB_" . $arFBUser["id"], 'EMAIL' => $email, 'NAME' => $arFBUser["first_name"], 'LAST_NAME' => $arFBUser["last_name"]);
                        if (isset($arFBUser['picture']['data']['url']) && self::CheckPhotoURI($arFBUser['picture']['data']['url'])) {
                            if ($arPic = CFile::MakeFileArray($arFBUser['picture']['data']['url'])) {
                                $arFields["PERSONAL_PHOTO"] = $arPic;
                            }
                        }
                        if (isset($arFBUser['birthday'])) {
                            if ($date = MakeTimeStamp($arFBUser['birthday'], "MM/DD/YYYY")) {
                                $arFields["PERSONAL_BIRTHDAY"] = ConvertTimeStamp($date);
                            }
                        }
                        if (isset($arFBUser['gender']) && $arFBUser['gender'] != '') {
                            if ($arFBUser['gender'] == 'male') {
                                $arFields["PERSONAL_GENDER"] = 'M';
                            } elseif ($arFBUser['gender'] == 'female') {
                                $arFields["PERSONAL_GENDER"] = 'F';
                            }
                        }
                        $arFields["PERSONAL_WWW"] = "http://www.facebook.com/" . $arFBUser["id"];
                        if (strlen(SITE_ID) > 0) {
                            $arFields["SITE_ID"] = SITE_ID;
                        }
                        $bSuccess = $this->AuthorizeUser($arFields);
                    }
                }
            }
        }
        $aRemove = array("logout", "auth_service_error", "auth_service_id", "code", "error_reason", "error", "error_description", "check_key", "current_fieldset");
        $url = $GLOBALS['APPLICATION']->GetCurPageParam($bSuccess === true ? '' : 'auth_service_id=' . self::ID . '&auth_service_error=' . $bSuccess, $aRemove);
        if (CModule::IncludeModule("socialnetwork") && strpos($url, "current_fieldset=") === false) {
            $url = preg_match("/\\?/", $url) ? $url . "&current_fieldset=SOCSERV" : $url . "?current_fieldset=SOCSERV";
        }
        echo '
<script type="text/javascript">
if(window.opener)
	window.opener.location = \'' . CUtil::JSEscape($url) . '\';
window.close();
</script>
';
        die;
    }
Exemplo n.º 6
0
    public function Authorize()
    {
        $GLOBALS["APPLICATION"]->RestartBuffer();
        $bSuccess = 1;
        $appID = trim(self::GetOption("twitter_key"));
        $appSecret = trim(self::GetOption("twitter_secret"));
        if (!isset($_REQUEST["oauth_token"]) || $_REQUEST["oauth_token"] == '') {
            $tw = new CTwitterInterface($appID, $appSecret);
            $callback = CSocServUtil::GetCurUrl('auth_service_id=' . self::ID);
            //$callback = 'http://algerman.sam:6448/script.php?auth_service_id='.self::ID;
            if ($tw->GetRequestToken($callback)) {
                $tw->RedirectAuthUrl();
            }
        } elseif (CSocServAuthManager::CheckUniqueKey()) {
            $tw = new CTwitterInterface($appID, $appSecret, $_REQUEST["oauth_token"], $_REQUEST["oauth_verifier"]);
            if (($arResult = $tw->GetAccessToken()) !== false && $arResult["user_id"] != '') {
                $twUser = $tw->GetUserInfo($arResult["user_id"]);
                $first_name = $last_name = "";
                if ($twUser["name"] != '') {
                    $aName = explode(" ", $twUser["name"]);
                    $first_name = $aName[0];
                    if (isset($aName[1])) {
                        $last_name = $aName[1];
                    }
                }
                $arFields = array('EXTERNAL_AUTH_ID' => self::ID, 'XML_ID' => $arResult["user_id"], 'LOGIN' => $arResult["screen_name"], 'NAME' => $first_name, 'LAST_NAME' => $last_name);
                if (isset($twUser["profile_image_url"]) && self::CheckPhotoURI($twUser["profile_image_url"])) {
                    if ($arPic = CFile::MakeFileArray($twUser["profile_image_url"])) {
                        $arFields["PERSONAL_PHOTO"] = $arPic;
                    }
                }
                $arFields["PERSONAL_WWW"] = "https://twitter.com/" . $arResult["screen_name"];
                if (strlen(SITE_ID) > 0) {
                    $arFields["SITE_ID"] = SITE_ID;
                }
                if (COption::GetOptionString('socialservices', 'last_twit_id', '1') == 1) {
                    if (isset($twUser["status"]["id_str"])) {
                        COption::SetOptionString('socialservices', 'last_twit_id', $twUser["status"]["id_str"]);
                    }
                }
                $bSuccess = $this->AuthorizeUser($arFields);
            }
        }
        $aRemove = array("logout", "auth_service_error", "auth_service_id", "oauth_token", "oauth_verifier", "check_key", "current_fieldset");
        $url = $GLOBALS['APPLICATION']->GetCurPageParam($bSuccess === true ? '' : 'auth_service_id=' . self::ID . '&auth_service_error=' . $bSuccess, $aRemove);
        if (CModule::IncludeModule("socialnetwork")) {
            $url = preg_match("/\\?/", $url) ? $url . "&current_fieldset=SOCSERV" : $url . "?current_fieldset=SOCSERV";
        }
        echo '
<script type="text/javascript">
if(window.opener)
	window.opener.location = \'' . CUtil::JSEscape($url) . '\';
window.close();
</script>
';
        die;
    }
Exemplo n.º 7
0
	public function Authorize()
	{
		$GLOBALS["APPLICATION"]->RestartBuffer();
		$bSuccess = false;

		$appID = self::GetOption("twitter_key");
		$appSecret = self::GetOption("twitter_secret");

		if(!isset($_REQUEST["oauth_token"]) || $_REQUEST["oauth_token"] == '')
		{
			$tw = new CTwitterInterface($appID, $appSecret);
			$callback = CSocServUtil::GetCurUrl('auth_service_id='.self::ID);
			if($tw->GetRequestToken($callback))
				$tw->RedirectAuthUrl();
		}
		elseif(CSocServAuthManager::CheckUniqueKey())
		{
			$tw = new CTwitterInterface($appID, $appSecret, $_REQUEST["oauth_token"], $_REQUEST["oauth_verifier"]);
			if(($arResult = $tw->GetAccessToken()) !== false && $arResult["user_id"] <> '')
			{
				$twUser = $tw->GetUserInfo($arResult["user_id"]);

				$first_name = $last_name = "";
				if($twUser["name"] <> '')
				{
					$aName = explode(" ", $twUser["name"]);
					$first_name = $aName[0];
					if(isset($aName[1]))
						$last_name = $aName[1];
				}

				$arFields = array(
					'EXTERNAL_AUTH_ID' => self::ID,
					'XML_ID' => $arResult["user_id"],
					'LOGIN' => $arResult["screen_name"],
					'NAME'=> $first_name,
					'LAST_NAME'=> $last_name,
				);
				$arFields["PERSONAL_WWW"] = "https://twitter.com/".$twUser["screen_name"];

				$bSuccess = $this->AuthorizeUser($arFields);
			}
		}

		$aRemove = array("logout", "auth_service_error", "auth_service_id", "oauth_token", "oauth_verifier", "check_key");
		$url = $GLOBALS['APPLICATION']->GetCurPageParam(($bSuccess? '':'auth_service_id='.self::ID.'&auth_service_error=1'), $aRemove);
		echo '
<script type="text/javascript">
if(window.opener)
	window.opener.location = \''.CUtil::JSEscape($url).'\';
window.close();
</script>
';
		die();
	}
Exemplo n.º 8
0
	public function getFriendsList($limit = 0, $offset = 0)
	{
		$li = new CLiveIDOAuthInterface();

		if(IsModuleInstalled('bitrix24') && defined('BX24_HOST_NAME'))
		{
			$redirect_uri = self::CONTROLLER_URL."/redirect.php";
		}
		else
		{
			$redirect_uri = CSocServUtil::ServerName()."/bitrix/tools/oauth/liveid.php";
		}

		if($li->GetAccessToken($redirect_uri) !== false)
		{
			$res = $li->GetCurrentUserFriends($limit, $offset);
		}

		if(is_array($res) && is_array($res['data']))
		{
			foreach($res['data'] as $key => $contact)
			{
				$res['data'][$key]['uid'] = $contact['id'];
				$res['data'][$key]['url'] = $this->getProfileUrl($contact['id']);
			}
			return $res['data'];
		}

		return false;
	}
Exemplo n.º 9
0
	public function Authorize()
	{
		$GLOBALS["APPLICATION"]->RestartBuffer();
		$bSuccess = SOCSERV_AUTHORISATION_ERROR;

		if((isset($_REQUEST["code"]) && $_REQUEST["code"] <> '') && CSocServAuthManager::CheckUniqueKey())
		{
			if(IsModuleInstalled('bitrix24') && defined('BX24_HOST_NAME'))
				$redirect_uri = self::CONTROLLER_URL."/redirect.php";
			else
				$redirect_uri = CSocServUtil::ServerName().$GLOBALS['APPLICATION']->GetCurPage(true).'?auth_service_id='.self::ID;
			$appID = trim(self::GetOption("vkontakte_appid"));
			$appSecret = trim(self::GetOption("vkontakte_appsecret"));

			$gAuth = new CVKontakteOAuthInterface($appID, $appSecret, $_REQUEST["code"]);
			if($gAuth->GetAccessToken($redirect_uri) !== false)
			{
				$arVkUser = $gAuth->GetCurrentUser();

				if(is_array($arVkUser) && ($arVkUser['response']['0']['uid'] <> ''))
				{
					$first_name = $last_name = $gender = "";
					if($arVkUser['response']['0']['first_name'] <> '')
					{
						$first_name = $arVkUser['response']['0']['first_name'];
					}
					if($arVkUser['response']['0']['last_name'] <> '')
					{
						$last_name = $arVkUser['response']['0']['last_name'];
					}

					if(isset($arVkUser['response']['0']['sex']) && $arVkUser['response']['0']['sex'] != '')
					{
						if ($arVkUser['response']['0']['sex'] == '2')
							$gender = 'M';
						elseif ($arVkUser['response']['0']['sex'] == '1')
							$gender = 'F';
					}

					$arFields = array(
						'EXTERNAL_AUTH_ID' => self::ID,
						'XML_ID' => $arVkUser['response']['0']['uid'],
						'LOGIN' => "VKuser".$arVkUser['response']['0']['uid'],
						'NAME'=> $first_name,
						'LAST_NAME'=> $last_name,
						'PERSONAL_GENDER' => $gender,
					);

					if(isset($arVkUser['response']['0']['photo_big']) && self::CheckPhotoURI($arVkUser['response']['0']['photo_big']))
						if ($arPic = CFile::MakeFileArray($arVkUser['response']['0']['photo_big']))
							$arFields["PERSONAL_PHOTO"] = $arPic;
					if(isset($arVkUser['response']['0']['bdate']))
						if ($date = MakeTimeStamp($arVkUser['response']['0']['bdate'], "DD.MM.YYYY"))
							$arFields["PERSONAL_BIRTHDAY"] = ConvertTimeStamp($date);
					$arFields["PERSONAL_WWW"] = "http://vk.com/id".$arVkUser['response']['0']['uid'];
					if(strlen(SITE_ID) > 0)
						$arFields["SITE_ID"] = SITE_ID;

					$bSuccess = $this->AuthorizeUser($arFields);
				}
			}
		}

		$url = ($GLOBALS["APPLICATION"]->GetCurDir() == "/login/") ? "" : $GLOBALS["APPLICATION"]->GetCurDir();
		$aRemove = array("logout", "auth_service_error", "auth_service_id", "code", "error_reason", "error", "error_description", "check_key", "current_fieldset");

		if(isset($_REQUEST["state"]))
		{
			$arState = array();
			parse_str($_REQUEST["state"], $arState);

			if(isset($arState['backurl']))
			{
				$parseUrl = parse_url($arState['backurl']);
				$urlPath = $parseUrl["path"];
				$arUrlQuery = explode('&', $parseUrl["query"]);

				foreach($arUrlQuery as $key => $value)
				{
					foreach($aRemove as $param)
					{
						if(strpos($value, $param."=") === 0)
						{
							unset($arUrlQuery[$key]);
							break;
						}
					}
				}
				$url = (!empty($arUrlQuery)) ? $urlPath.'?'.implode("&", $arUrlQuery) : $urlPath;
			}
		}
		if($bSuccess === SOCSERV_REGISTRATION_DENY)
		{
			$url = (preg_match("/\?/", $url)) ? $url.'&' : $url.'?';
			$url .= 'auth_service_id='.self::ID.'&auth_service_error='.$bSuccess;
		}
		elseif($bSuccess !== true)
			$url = (isset($urlPath)) ? $urlPath.'?auth_service_id='.self::ID.'&auth_service_error='.$bSuccess : $GLOBALS['APPLICATION']->GetCurPageParam(('auth_service_id='.self::ID.'&auth_service_error='.$bSuccess), $aRemove);
		if(CModule::IncludeModule("socialnetwork") && strpos($url, "current_fieldset=") === false)
			$url = (preg_match("/\?/", $url)) ? $url."&current_fieldset=SOCSERV" : $url."?current_fieldset=SOCSERV";

		echo '
<script type="text/javascript">
if(window.opener)
	window.opener.location = \''.CUtil::JSEscape($url).'\';
window.close();
</script>
';
		die();
	}
Exemplo n.º 10
0
 public function GetRedirectURI()
 {
     return CSocServUtil::ServerName() . "/bitrix/tools/seo_client.php";
 }
Exemplo n.º 11
0
	public function Authorize()
	{
		global $APPLICATION;

		$APPLICATION->RestartBuffer();
		$bSuccess = SOCSERV_AUTHORISATION_ERROR;
		if(isset($_REQUEST["code"]) && $_REQUEST["code"] != '' && CSocServAuthManager::CheckUniqueKey())
		{
			$redirect_uri= CSocServUtil::GetCurUrl('auth_service_id='.self::ID, array("code", "state", "backurl", "check_key", "current_fieldset"));
			$appID = trim(self::GetOption("liveid_appid"));
			$appSecret = trim(self::GetOption("liveid_appsecret"));

			$gAuth = new CLiveIDOAuthInterface($appID, $appSecret, $_REQUEST["code"]);

			if($gAuth->GetAccessToken($redirect_uri) !== false)
			{
				$arLiveIDUser = $gAuth->GetCurrentUser();

				if(is_array($arLiveIDUser) &&  ($arLiveIDUser['id'] <> ''))
				{
					$email = $first_name = $last_name = "";
					$login = "******".$arLiveIDUser['id'];
					$uId = $arLiveIDUser['id'];
					if($arLiveIDUser['first_name'] <> '')
						$first_name = $arLiveIDUser['first_name'];
					if($arLiveIDUser['last_name'] <> '')
						$last_name = $arLiveIDUser['last_name'];
					if($arLiveIDUser['emails']['preferred'] <> '')
					{
						$email = $arLiveIDUser['emails']['preferred'];
						$login = $arLiveIDUser['emails']['preferred'];
						$uId = $arLiveIDUser['emails']['preferred'];
					}
					$arFields = array(
						'EXTERNAL_AUTH_ID' => self::ID,
						'XML_ID' => $uId,
						'LOGIN' => $login,
						'EMAIL' => $email,
						'NAME'=> $first_name,
						'LAST_NAME'=> $last_name,
					);
					$arFields["PERSONAL_WWW"] = $arLiveIDUser["link"];
					if(isset($arLiveIDUser['access_token']))
						$arFields["OATOKEN"] = $arLiveIDUser['access_token'];

					if(isset($arLiveIDUser['refresh_token']))
						$arFields["REFRESH_TOKEN"] = $arLiveIDUser['refresh_token'];

					if(isset($arLiveIDUser['expires_in']))
						$arFields["OATOKEN_EXPIRES"] = time() + $arLiveIDUser['expires_in'];
					if(strlen(SITE_ID) > 0)
						$arFields["SITE_ID"] = SITE_ID;
					$bSuccess = $this->AuthorizeUser($arFields);

				}
			}
		}
		$url = ($APPLICATION->GetCurDir() == "/login/") ? "" : $APPLICATION->GetCurDir();
		$aRemove = array("logout", "auth_service_error", "auth_service_id", "code", "error_reason", "error", "error_description", "check_key", "current_fieldset");

		$mode = 'opener';
		if(isset($_REQUEST["state"]))
		{
			$arState = array();
			parse_str($_REQUEST["state"], $arState);
			if(isset($arState['backurl']))
			{
				$parseUrl = parse_url($arState['backurl']);
				$urlPath = $parseUrl["path"];
				$arUrlQuery = explode('&', $parseUrl["query"]);

				foreach($arUrlQuery as $key => $value)
				{
					foreach($aRemove as $param)
					{
						if(strpos($value, $param."=") === 0)
						{
							unset($arUrlQuery[$key]);
							break;
						}
					}
				}

				$url = (!empty($arUrlQuery)) ? $urlPath.'?'.implode("&", $arUrlQuery) : $urlPath;
			}

			if(isset($arState['mode']))
			{
				$mode = $arState['mode'];
			}
		}
		if($bSuccess === SOCSERV_REGISTRATION_DENY)
		{
			$url = (preg_match("/\?/", $url)) ? $url.'&' : $url.'?';
			$url .= 'auth_service_id='.self::ID.'&auth_service_error='.SOCSERV_REGISTRATION_DENY;
		}
		elseif($bSuccess !== true)
			$url = (isset($urlPath)) ? $urlPath.'?auth_service_id='.self::ID.'&auth_service_error='.$bSuccess : $APPLICATION->GetCurPageParam(('auth_service_id='.self::ID.'&auth_service_error='.$bSuccess), $aRemove);
		if(CModule::IncludeModule("socialnetwork") && strpos($url, "current_fieldset=") === false)
			$url = (preg_match("/\?/", $url)) ? $url."&current_fieldset=SOCSERV" : $url."?current_fieldset=SOCSERV";

		$url = CUtil::JSEscape($url);
		$location = ($mode == "opener") ? 'if(window.opener) window.opener.location = \''.$url.'\'; window.close();' : ' window.location = \''.$url.'\';';

		$JSScript = '
		<script type="text/javascript">
		'.$location.'
		</script>
		';

		echo $JSScript;

		die();
	}
Exemplo n.º 12
0
    public function gadgetAuthorize()
    {
        global $APPLICATION;
        $APPLICATION->RestartBuffer();
        if (isset($_REQUEST["code"]) && $_REQUEST["code"] != '' && CSocServAuthManager::CheckUniqueKey()) {
            CUserOptions::SetOption('socialservices', 'bitrix24_task_planer_gadget_code', $_REQUEST["code"]);
        }
        $url = CSocServUtil::ServerName() . BX_ROOT;
        $mode = 'opener';
        $url = CUtil::JSEscape($url);
        $location = $mode == "opener" ? 'if(window.opener) window.opener.location = \'' . $url . '\'; window.close();' : ' window.location = \'' . $url . '\';';
        $JSScript = '
		<script type="text/javascript">
		' . $location . '
		</script>
		';
        echo $JSScript;
        die;
    }
Exemplo n.º 13
0
 public function getFriendsList($limit, &$next)
 {
     if (IsModuleInstalled('bitrix24') && defined('BX24_HOST_NAME')) {
         $redirect_uri = static::CONTROLLER_URL . "/redirect.php";
     } else {
         $redirect_uri = CSocServUtil::ServerName() . "/bitrix/tools/oauth/google.php";
     }
     $ob = $this->getEntityOAuth();
     if ($ob->GetAccessToken($redirect_uri) !== false) {
         $res = $ob->getCurrentUserFriends($limit, $next);
         foreach ($res as $key => $contact) {
             $contact['uid'] = $contact['email'];
             $arName = $contact['name'];
             $contact['first_name'] = trim($arName['givenName']);
             $contact['last_name'] = trim($arName['familyName']);
             $contact['second_name'] = trim($arName['additionalName']);
             if (!$contact['first_name'] && !$contact['last_name']) {
                 $contact['first_name'] = $contact['uid'];
             }
             $res[$key] = $contact;
         }
     }
     return $res;
 }
Exemplo n.º 14
0
	public function Authorize()
	{
		$GLOBALS["APPLICATION"]->RestartBuffer();
		$bSuccess = 1;
		if((isset($_REQUEST["code"]) && $_REQUEST["code"] <> '') && CSocServAuthManager::CheckUniqueKey())
		{
			$redirect_uri = CSocServUtil::ServerName()."/bitrix/tools/oauth/google.php";
			$appID = trim(self::GetOption("google_appid"));
			$appSecret = trim(self::GetOption("google_appsecret"));

			$gAuth = new CGoogleOAuthInterface($appID, $appSecret, $_REQUEST["code"]);

			if($gAuth->GetAccessToken($redirect_uri) !== false)
			{
				$arGoogleUser = $gAuth->GetCurrentUser();

				if($arGoogleUser['feed']['author']['0']['email']['$t'] <> '')
				{
					$first_name = $last_name = "";
					if($arGoogleUser['feed']['author']['0']['name']['$t'] <> '')
					{
						$aName = explode(" ", $arGoogleUser['feed']['author']['0']['name']['$t']);
						$first_name = $aName[0];
						if(isset($aName[1]))
							$last_name = $aName[1];
					}
					$email = $arGoogleUser['feed']['author']['0']['email']['$t'];

					$arFields = array(
						'EXTERNAL_AUTH_ID' => self::ID,
						'XML_ID' => $email,
						'LOGIN' => "G_".$email,
						'EMAIL' => $email,
						'NAME'=> $first_name,
						'LAST_NAME'=> $last_name,
					);
					$arFields["PERSONAL_WWW"] = "https://accounts.google.com";
					$bSuccess = $this->AuthorizeUser($arFields);
				}
			}
		}
		$url = ($GLOBALS["APPLICATION"]->GetCurDir() == "/login/") ? "/auth/" : $GLOBALS["APPLICATION"]->GetCurDir();
		if(isset($_REQUEST["state"]))
		{
			$arState = array();
			parse_str($_REQUEST["state"], $arState);
		
			if(isset($arState['backurl']))
				$url = parse_url($arState['backurl'], PHP_URL_PATH);
		}
		$aRemove = array("logout", "auth_service_error", "auth_service_id", "code", "error_reason", "error", "error_description", "check_key");
		if(CModule::IncludeModule("socialnetwork"))
			$url = (preg_match("/\?/", $url)) ? $url."&current_fieldset=SOCSERV" : $url."?current_fieldset=SOCSERV";
		if($bSuccess !== true)
			$url = $GLOBALS['APPLICATION']->GetCurPageParam(('auth_service_id='.self::ID.'&auth_service_error='.$bSuccess), $aRemove);
		if($bSuccess === 2)
			$url = '/?auth_service_id='.self::ID.'&auth_service_error='.$bSuccess;
		echo '
<script type="text/javascript">
if(window.opener)
	window.opener.location = \''.CUtil::JSEscape($url).'\';
window.close();
</script>
';
		die();
	}
Exemplo n.º 15
0
	public function Authorize()
	{
		$GLOBALS["APPLICATION"]->RestartBuffer();
		$bSuccess = false;
		if((isset($_REQUEST["code"]) && $_REQUEST["code"] <> '') && CSocServAuthManager::CheckUniqueKey())
		{
			$redirect_uri = CSocServUtil::ServerName()."/bitrix/tools/oauth/google.php";
			$appID = self::GetOption("google_appid");
			$appSecret = self::GetOption("google_appsecret");

			$gAuth = new CGoogleOAuthInterface($appID, $appSecret, $_REQUEST["code"]);

			if($gAuth->GetAccessToken($redirect_uri) !== false)
			{
				$arGoogleUser = $gAuth->GetCurrentUser();

				if($arGoogleUser['feed']['author']['0']['email']['$t'] <> '')
				{
					$first_name = $last_name = "";
					if($arGoogleUser['feed']['author']['0']['name']['$t'] <> '')
					{
						$aName = explode(" ", $arGoogleUser['feed']['author']['0']['name']['$t']);
						$first_name = $aName[0];
						if(isset($aName[1]))
							$last_name = $aName[1];
					}
					$email = $arGoogleUser['feed']['author']['0']['email']['$t'];

					$arFields = array(
						'EXTERNAL_AUTH_ID' => self::ID,
						'XML_ID' => $email,
						'LOGIN' => "G_".$email,
						'EMAIL' => $email,
						'NAME'=> $first_name,
						'LAST_NAME'=> $last_name,
					);
					$bSuccess = $this->AuthorizeUser($arFields);
				}
			}
		}
		$url = '/personal/profile/';
		if(isset($_REQUEST["state"]))
		{
			$arState = array();
			parse_str($_REQUEST["state"], $arState);
		
			if(isset($arState['backurl']))
				$url = parse_url($arState['backurl'], PHP_URL_PATH);
		}
		$aRemove = array("logout", "auth_service_error", "auth_service_id", "code", "error_reason", "error", "error_description", "check_key");
		if(!$bSuccess)
			$url = $GLOBALS['APPLICATION']->GetCurPageParam(('auth_service_id='.self::ID.'&auth_service_error=1'), $aRemove);
		echo '
<script type="text/javascript">
if(window.opener)
	window.opener.location = \''.CUtil::JSEscape($url).'\';
window.close();
</script>
';
		die();
	}
Exemplo n.º 16
0
    public function Authorize()
    {
        $GLOBALS["APPLICATION"]->RestartBuffer();
        $bSuccess = 1;
        if (isset($_REQUEST["code"]) && $_REQUEST["code"] != '' && CSocServAuthManager::CheckUniqueKey()) {
            if (IsModuleInstalled('bitrix24') && defined('BX24_HOST_NAME')) {
                $redirect_uri = self::CONTROLLER_URL . "/redirect.php";
            } else {
                $redirect_uri = CSocServUtil::ServerName() . "/bitrix/tools/oauth/google.php";
            }
            $appID = trim(self::GetOption("google_appid"));
            $appSecret = trim(self::GetOption("google_appsecret"));
            $gAuth = new CGoogleOAuthInterface($appID, $appSecret, $_REQUEST["code"]);
            if ($gAuth->GetAccessToken($redirect_uri) !== false) {
                $arGoogleUser = $gAuth->GetCurrentUser();
                if ($arGoogleUser['email'] != '') {
                    $first_name = $last_name = $gender = "";
                    if ($arGoogleUser['name'] != '') {
                        $aName = explode(" ", $arGoogleUser['name']);
                        if ($arGoogleUser['given_name'] != '') {
                            $first_name = $arGoogleUser['given_name'];
                        } else {
                            $first_name = $aName[0];
                        }
                        if ($arGoogleUser['family_name'] != '') {
                            $last_name = $arGoogleUser['family_name'];
                        } elseif (isset($aName[1])) {
                            $last_name = $aName[1];
                        }
                    }
                    $email = $arGoogleUser['email'];
                    if ($arGoogleUser['gender'] != '') {
                        if ($arGoogleUser['gender'] == 'male') {
                            $gender = 'M';
                        } elseif ($arGoogleUser['gender'] == 'female') {
                            $gender = 'F';
                        }
                    }
                    $arFields = array('EXTERNAL_AUTH_ID' => self::ID, 'XML_ID' => $email, 'LOGIN' => "G_" . $email, 'EMAIL' => $email, 'NAME' => $first_name, 'LAST_NAME' => $last_name);
                    if ($gender != "") {
                        $arFields['PERSONAL_GENDER'] = $gender;
                    }
                    if (isset($arGoogleUser['picture']) && self::CheckPhotoURI($arGoogleUser['picture'])) {
                        if ($arPic = CFile::MakeFileArray($arGoogleUser['picture'])) {
                            $arFields["PERSONAL_PHOTO"] = $arPic;
                        }
                    }
                    $arFields["PERSONAL_WWW"] = $arGoogleUser['link'];
                    if (strlen(SITE_ID) > 0) {
                        $arFields["SITE_ID"] = SITE_ID;
                    }
                    $bSuccess = $this->AuthorizeUser($arFields);
                }
            }
        }
        $url = $GLOBALS["APPLICATION"]->GetCurDir() == "/login/" ? "/auth/" : $GLOBALS["APPLICATION"]->GetCurDir();
        if (isset($_REQUEST["state"])) {
            $arState = array();
            parse_str($_REQUEST["state"], $arState);
            if (isset($arState['backurl'])) {
                $parseUrl = parse_url($arState['backurl'], PHP_URL_PATH);
                $url = $parseUrl;
            }
        }
        $aRemove = array("logout", "auth_service_error", "auth_service_id", "code", "error_reason", "error", "error_description", "check_key", "current_fieldset");
        if ($bSuccess === 2) {
            $url = preg_match("/\\?/", $url) ? $url . '&' : $url . '?';
            $url .= 'auth_service_id=' . self::ID . '&auth_service_error=' . $bSuccess;
        } elseif ($bSuccess !== true) {
            $url = isset($parseUrl) ? $parseUrl . '?auth_service_id=' . self::ID . '&auth_service_error=' . $bSuccess : $GLOBALS['APPLICATION']->GetCurPageParam('auth_service_id=' . self::ID . '&auth_service_error=' . $bSuccess, $aRemove);
        }
        if (CModule::IncludeModule("socialnetwork")) {
            $url = preg_match("/\\?/", $url) ? $url . "&current_fieldset=SOCSERV" : $url . "?current_fieldset=SOCSERV";
        }
        echo '
<script type="text/javascript">
if(window.opener)
	window.opener.location = \'' . CUtil::JSEscape($url) . '\';
window.close();
</script>
';
        die;
    }
Exemplo n.º 17
0
	public function Authorize()
	{
		$GLOBALS["APPLICATION"]->RestartBuffer();
		$bSuccess = 1;

		if((isset($_REQUEST["code"]) && $_REQUEST["code"] <> '') && CSocServAuthManager::CheckUniqueKey())
		{
			$redirect_uri = CSocServUtil::GetCurUrl('auth_service_id='.self::ID, array("code", "state", "backurl", "check_key"));
			$appID = trim(self::GetOption("vkontakte_appid"));
			$appSecret = trim(self::GetOption("vkontakte_appsecret"));

			$gAuth = new CVKontakteOAuthInterface($appID, $appSecret, $_REQUEST["code"]);
			if($gAuth->GetAccessToken($redirect_uri) !== false)
			{
				$arVkUser = $gAuth->GetCurrentUser();

				if($arVkUser['response']['0']['uid'] <> '')
				{
					$first_name = $last_name = $gender = "";
					if($arVkUser['response']['0']['first_name'] <> '')
					{
						$first_name = $arVkUser['response']['0']['first_name'];
					}
					if($arVkUser['response']['0']['last_name'] <> '')
					{
						$last_name = $arVkUser['response']['0']['last_name'];
					}

					if(isset($arVkUser['response']['0']['sex']) && $arVkUser['response']['0']['sex'] != '')
					{
						if ($arVkUser['response']['0']['sex'] == '2')
							$gender = 'M';
						elseif ($arVkUser['response']['0']['sex'] == '1')
							$gender = 'F';
					}

					$arFields = array(
						'EXTERNAL_AUTH_ID' => self::ID,
						'XML_ID' => $arVkUser['response']['0']['uid'],
						'LOGIN' => "VKuser".$arVkUser['response']['0']['uid'],
						'NAME'=> $first_name,
						'LAST_NAME'=> $last_name,
						'PERSONAL_GENDER' => $gender,
					);

					if(isset($arVkUser['response']['0']['photo_big']) && self::CheckPhotoURI($arVkUser['response']['0']['photo_big']))
						if ($arPic = CFile::MakeFileArray($arVkUser['response']['0']['photo_big']))
							$arFields["PERSONAL_PHOTO"] = $arPic;
					if(isset($arVkUser['response']['0']['bdate']))
						if ($date = MakeTimeStamp($arVkUser['response']['0']['bdate'], "DD.MM.YYYY"))
							$arFields["PERSONAL_BIRTHDAY"] = ConvertTimeStamp($date);
					$arFields["PERSONAL_WWW"] = "http://vk.com/id".$arVkUser['response']['0']['uid'];

					$bSuccess = $this->AuthorizeUser($arFields);
				}
			}
		}

		$url = ($GLOBALS["APPLICATION"]->GetCurDir() == "/login/") ? "/auth/" : $GLOBALS["APPLICATION"]->GetCurDir();

		if(isset($_REQUEST["state"]))
		{
			$arState = array();
			parse_str($_REQUEST["state"], $arState);

			if(isset($arState['backurl']))
				$url = parse_url($arState['backurl'], PHP_URL_PATH);
		}
		$aRemove = array("logout", "auth_service_error", "auth_service_id", "code", "error_reason", "error", "error_description", "check_key", "current_fieldset");
		if(isset($_REQUEST["current_fieldset"]))
			$url = $GLOBALS['APPLICATION']->GetCurPageParam(('current_fieldset='.$_REQUEST["current_fieldset"]), $aRemove);
		if($bSuccess !== true)
			$url = $GLOBALS['APPLICATION']->GetCurPageParam(('auth_service_id='.self::ID.'&auth_service_error='.$bSuccess), $aRemove);
		echo '
<script type="text/javascript">
if(window.opener)
	window.opener.location = \''.CUtil::JSEscape($url).'\';
window.close();
</script>
';
		die();
	}
Exemplo n.º 18
0
    public function Authorize()
    {
        $GLOBALS["APPLICATION"]->RestartBuffer();
        $bSuccess = 1;
        if (isset($_REQUEST["code"]) && $_REQUEST["code"] != '' && CSocServAuthManager::CheckUniqueKey()) {
            $redirect_uri = CSocServUtil::GetCurUrl('auth_service_id=' . self::ID, array("code", "state", "backurl", "check_key"));
            $appID = trim(self::GetOption("liveid_appid"));
            $appSecret = trim(self::GetOption("liveid_appsecret"));
            $gAuth = new CLiveIDOAuthInterface($appID, $appSecret, $_REQUEST["code"]);
            if ($gAuth->GetAccessToken($redirect_uri) !== false) {
                $arLiveIDUser = $gAuth->GetCurrentUser();
                if ($arLiveIDUser['id'] != '') {
                    $email = $first_name = $last_name = "";
                    $login = "******" . $arLiveIDUser['id'];
                    $uId = $arLiveIDUser['id'];
                    if ($arLiveIDUser['first_name'] != '') {
                        $first_name = $arLiveIDUser['first_name'];
                    }
                    if ($arLiveIDUser['last_name'] != '') {
                        $last_name = $arLiveIDUser['last_name'];
                    }
                    if ($arLiveIDUser['emails']['preferred'] != '') {
                        $email = $arLiveIDUser['emails']['preferred'];
                        $login = $arLiveIDUser['emails']['preferred'];
                        $uId = $arLiveIDUser['emails']['preferred'];
                    }
                    $arFields = array('EXTERNAL_AUTH_ID' => self::ID, 'XML_ID' => $uId, 'LOGIN' => $login, 'EMAIL' => $email, 'NAME' => $first_name, 'LAST_NAME' => $last_name);
                    $arFields["PERSONAL_WWW"] = $arLiveIDUser["link"];
                    if (strlen(SITE_ID) > 0) {
                        $arFields["SITE_ID"] = SITE_ID;
                    }
                    $bSuccess = $this->AuthorizeUser($arFields);
                }
            }
        }
        $url = $GLOBALS["APPLICATION"]->GetCurDir() == "/login/" ? "/auth/" : $GLOBALS["APPLICATION"]->GetCurDir();
        if (isset($_REQUEST["state"])) {
            $arState = array();
            parse_str($_REQUEST["state"], $arState);
            if (isset($arState['backurl'])) {
                $url = parse_url($arState['backurl'], PHP_URL_PATH);
            }
        }
        $aRemove = array("logout", "auth_service_error", "auth_service_id", "code", "error_reason", "error", "error_description", "check_key", "current_fieldset", "backurl", "state");
        if ($bSuccess === 2) {
            $url = preg_match("/\\?/", $url) ? $url . '&' : $url . '?';
            $url .= 'auth_service_id=' . self::ID . '&auth_service_error=' . $bSuccess;
        } elseif ($bSuccess !== true) {
            $url = isset($parseUrl) ? $parseUrl . '?auth_service_id=' . self::ID . '&auth_service_error=' . $bSuccess : $GLOBALS['APPLICATION']->GetCurPageParam('auth_service_id=' . self::ID . '&auth_service_error=' . $bSuccess, $aRemove);
        }
        if (CModule::IncludeModule("socialnetwork")) {
            $url = preg_match("/\\?/", $url) ? $url . "&current_fieldset=SOCSERV" : $url . "?current_fieldset=SOCSERV";
        }
        echo '
<script type="text/javascript">
if(window.opener)
	window.opener.location = \'' . CUtil::JSEscape($url) . '\';
window.close();
</script>
';
        die;
    }
Exemplo n.º 19
0
 public function getUrl($mode = "page")
 {
     $redirect_uri = CSocServUtil::GetCurUrl('auth_service_id=' . self::ID);
     $state = (defined("ADMIN_SECTION") && ADMIN_SECTION == true ? 'admin=1' : 'site_id=' . SITE_ID) . '&backurl=' . urlencode($GLOBALS["APPLICATION"]->GetCurPageParam('check_key=' . CSocServAuthManager::GetUniqueKey(), array("logout", "auth_service_error", "auth_service_id", "check_key"))) . '&mode=' . $mode;
     return $this->getEntityOAuth()->GetAuthUrl($redirect_uri, $state, $mode);
 }
Exemplo n.º 20
0
}
$arGadgetParams = $_SESSION["GD_PLANNER_PARAMS"][$rnd];
CModule::IncludeModule('socialservices');
CSocServAuthManager::SetUniqueKey();
$clientId = $arGadgetParams["APP_ID"];
$clientSecret = $arGadgetParams["APP_SECRET"];
$domain = $portalURI = $arGadgetParams["PORTAL_URI"];
?>
<div class="bx-gadgets-planner">
	<?php 
if ($clientId == '' || $clientSecret == '' || $portalURI == '') {
    exit;
}
$needAuthorize = false;
$accessToken = '';
$redirectURI = CSocServUtil::ServerName() . '/bitrix/tools/oauth/bitrix24.php';
$savedPortalURI = CUserOptions::GetOption('socialservices', 'bitrix24_task_planer_gadget_portal', '', $userId);
$requestCode = CUserOptions::GetOption('socialservices', 'bitrix24_task_planer_gadget_code', '', $userId);
if ($savedPortalURI !== $portalURI || $savedPortalURI == '') {
    $needAuthorize = true;
    CUserOptions::SetOption('socialservices', 'bitrix24_task_planer_gadget_portal', $portalURI, false, $userId);
}
if (!preg_match('|^http[s]?|', $portalURI)) {
    $portalURI = 'https://' . $portalURI;
}
$objBitrixOAuth = new CSocServBitrixOAuth($clientId, $clientSecret, $portalURI, $redirectURI, $userId);
$objBitrixOAuth->addScope(array('task', 'calendar'));
$arTasks = $arEvents = array();
if ($requestCode != '') {
    $accessToken = $objBitrixOAuth->getAccessToken($requestCode);
    CUserOptions::SetOption('socialservices', 'bitrix24_task_planer_gadget_code', '', false, $userId);
Exemplo n.º 21
0
    public function Authorize()
    {
        global $APPLICATION;
        $APPLICATION->RestartBuffer();
        $bSuccess = SOCSERV_AUTHORISATION_ERROR;
        $bProcessState = false;
        if (isset($_REQUEST["code"]) && $_REQUEST["code"] != '' && CSocServAuthManager::CheckUniqueKey()) {
            $bProcessState = true;
            if (IsModuleInstalled('bitrix24') && defined('BX24_HOST_NAME')) {
                $redirect_uri = self::CONTROLLER_URL . "/redirect.php";
            } else {
                $redirect_uri = CSocServUtil::ServerName() . "/bitrix/tools/oauth/odnoklassniki.php";
            }
            $appID = trim(self::GetOption("odnoklassniki_appid"));
            $appSecret = trim(self::GetOption("odnoklassniki_appsecret"));
            $appKey = trim(self::GetOption("odnoklassniki_appkey"));
            $gAuth = new COdnoklassnikiInterface($appID, $appSecret, $appKey, $_REQUEST["code"]);
            if ($gAuth->GetAccessToken($redirect_uri) !== false) {
                $arOdnoklUser = $gAuth->GetCurrentUser();
                if (is_array($arOdnoklUser) && $arOdnoklUser['uid'] != '') {
                    $uid = $arOdnoklUser['uid'];
                    $first_name = $last_name = $gender = "";
                    if ($arOdnoklUser['first_name'] != '') {
                        $first_name = $arOdnoklUser['first_name'];
                    }
                    if ($arOdnoklUser['last_name'] != '') {
                        $last_name = $arOdnoklUser['last_name'];
                    }
                    if (isset($arOdnoklUser['gender']) && $arOdnoklUser['gender'] != '') {
                        if ($arOdnoklUser['gender'] == 'male') {
                            $gender = 'M';
                        } elseif ($arOdnoklUser['gender'] == 'female') {
                            $gender = 'F';
                        }
                    }
                    $arFields = array('EXTERNAL_AUTH_ID' => self::ID, 'XML_ID' => "OK" . $uid, 'LOGIN' => "OKuser" . $uid, 'NAME' => $first_name, 'LAST_NAME' => $last_name, 'PERSONAL_GENDER' => $gender);
                    if (isset($arOdnoklUser['birthday'])) {
                        if ($date = MakeTimeStamp($arOdnoklUser['birthday'], "YYYY-MM-DD")) {
                            $arFields["PERSONAL_BIRTHDAY"] = ConvertTimeStamp($date);
                        }
                    }
                    if (isset($arOdnoklUser['pic_2']) && self::CheckPhotoURI($arOdnoklUser['pic_2'])) {
                        if ($arPic = CFile::MakeFileArray($arOdnoklUser['pic_2'] . '&name=/' . md5($arOdnoklUser['pic_2']) . '.jpg')) {
                            $arFields["PERSONAL_PHOTO"] = $arPic;
                        }
                    }
                    $arFields["PERSONAL_WWW"] = "http://odnoklassniki.ru/profile/" . $uid;
                    if (strlen(SITE_ID) > 0) {
                        $arFields["SITE_ID"] = SITE_ID;
                    }
                    $bSuccess = $this->AuthorizeUser($arFields);
                }
            }
        }
        if (!$bProcessState) {
            unset($_REQUEST["state"]);
        }
        $url = $APPLICATION->GetCurDir() == "/login/" ? "" : $APPLICATION->GetCurDir();
        $aRemove = array("logout", "auth_service_error", "auth_service_id", "code", "error_reason", "error", "error_description", "check_key", "current_fieldset");
        $mode = 'opener';
        if (isset($_REQUEST["state"])) {
            $arState = array();
            parse_str($_REQUEST["state"], $arState);
            if (isset($arState['backurl']) || isset($arState['redirect_url'])) {
                $parseUrl = parse_url(!empty($arState['redirect_url']) ? $arState['redirect_url'] : $arState['backurl']);
                $urlPath = $parseUrl["path"];
                $arUrlQuery = explode('&', $parseUrl["query"]);
                foreach ($arUrlQuery as $key => $value) {
                    foreach ($aRemove as $param) {
                        if (strpos($value, $param . "=") === 0) {
                            unset($arUrlQuery[$key]);
                            break;
                        }
                    }
                }
                $url = !empty($arUrlQuery) ? $urlPath . '?' . implode("&", $arUrlQuery) : $urlPath;
            }
            if (isset($arState['mode'])) {
                $mode = $arState['mode'];
            }
        }
        if ($bSuccess === SOCSERV_REGISTRATION_DENY) {
            $url = preg_match("/\\?/", $url) ? $url . '&' : $url . '?';
            $url .= 'auth_service_id=' . self::ID . '&auth_service_error=' . SOCSERV_REGISTRATION_DENY;
        } elseif ($bSuccess !== true) {
            $url = isset($parseUrl) ? $urlPath . '?auth_service_id=' . self::ID . '&auth_service_error=' . $bSuccess : $APPLICATION->GetCurPageParam('auth_service_id=' . self::ID . '&auth_service_error=' . $bSuccess, $aRemove);
        }
        if (CModule::IncludeModule("socialnetwork") && strpos($url, "current_fieldset=") === false) {
            $url = preg_match("/\\?/", $url) ? $url . "&current_fieldset=SOCSERV" : $url . "?current_fieldset=SOCSERV";
        }
        $url = CUtil::JSEscape($url);
        $location = $mode == "opener" ? 'if(window.opener) window.opener.location = \'' . $url . '\'; window.close();' : ' window.location = \'' . $url . '\';';
        $JSScript = '
		<script type="text/javascript">
		' . $location . '
		</script>
		';
        echo $JSScript;
        die;
    }
Exemplo n.º 22
0
	public function Authorize()
	{
		global $APPLICATION;
		$APPLICATION->RestartBuffer();
		$bSuccess = SOCSERV_AUTHORISATION_ERROR;
		if((isset($_REQUEST["code"]) && $_REQUEST["code"] <> '') && CSocServAuthManager::CheckUniqueKey())
		{
			if(IsModuleInstalled('freetrix24') && defined('BX24_HOST_NAME'))
				$redirect_uri = self::CONTROLLER_URL."/redirect.php";
			else
				$redirect_uri = CSocServUtil::ServerName()."/freetrix/tools/oauth/google.php";

			$appID = trim(self::GetOption("google_appid"));
			$appSecret = trim(self::GetOption("google_appsecret"));

			$gAuth = new CGoogleOAuthInterface($appID, $appSecret, $_REQUEST["code"]);

			$this->entityOAuth = $gAuth;

			if($gAuth->GetAccessToken($redirect_uri) !== false)
			{
				$arGoogleUser = $gAuth->GetCurrentUser();

				if(is_array($arGoogleUser) && ($arGoogleUser['email'] <> ''))
				{
					$first_name = $last_name = $gender = "";
					if($arGoogleUser['name'] <> '')
					{
						$aName = explode(" ", $arGoogleUser['name']);
						if($arGoogleUser['given_name'] <> '')
							$first_name = $arGoogleUser['given_name'];
						else
							$first_name = $aName[0];
						if($arGoogleUser['family_name'] <> '')
							$last_name = $arGoogleUser['family_name'];
						elseif(isset($aName[1]))
							$last_name = $aName[1];
					}
					$email = $arGoogleUser['email'];
					if($arGoogleUser['gender'] <> '')
						if($arGoogleUser['gender'] == 'male')
							$gender = 'M';
						elseif($arGoogleUser['gender'] == 'female')
							$gender = 'F';

					$arFields = array(
						'EXTERNAL_AUTH_ID' => self::ID,
						'XML_ID' => $email,
						'LOGIN' => "G_".$email,
						'EMAIL' => $email,
						'NAME'=> $first_name,
						'LAST_NAME'=> $last_name
					);

					if($gender != "")
						$arFields['PERSONAL_GENDER'] = $gender;

					if(isset($arGoogleUser['picture']) && self::CheckPhotoURI($arGoogleUser['picture']))
						if($arPic = CFile::MakeFileArray($arGoogleUser['picture']))
							$arFields["PERSONAL_PHOTO"] = $arPic;

					$arFields["PERSONAL_WWW"] = $arGoogleUser['link'];

					if(isset($arGoogleUser['access_token']))
						$arFields["OATOKEN"] = $arGoogleUser['access_token'];

					if(isset($arGoogleUser['refresh_token']))
						$arFields["REFRESH_TOKEN"] = $arGoogleUser['refresh_token'];

					if(isset($arGoogleUser['expires_in']))
						$arFields["OATOKEN_EXPIRES"] = $arGoogleUser['expires_in'];

					if(strlen(SITE_ID) > 0)
						$arFields["SITE_ID"] = SITE_ID;
					$bSuccess = $this->AuthorizeUser($arFields);
				}
			}
		}
		$url = ($APPLICATION->GetCurDir() == "/login/") ? "" : $APPLICATION->GetCurDir();
		$aRemove = array("logout", "auth_service_error", "auth_service_id", "code", "error_reason", "error", "error_description", "check_key", "current_fieldset");

		$mode = 'opener';
		if(isset($_REQUEST["state"]))
		{
			$arState = array();
			parse_str($_REQUEST["state"], $arState);
			if(isset($arState['backurl']))
			{
				$parseUrl = parse_url($arState['backurl']);
				$urlPath = $parseUrl["path"];
				$arUrlQuery = explode('&', $parseUrl["query"]);

				foreach($arUrlQuery as $key => $value)
				{
					foreach($aRemove as $param)
					{
						if(strpos($value, $param."=") === 0)
						{
							unset($arUrlQuery[$key]);
							break;
						}
					}
				}

				$url = (!empty($arUrlQuery)) ? $urlPath.'?'.implode("&", $arUrlQuery) : $urlPath;
			}

			if(isset($arState['mode']))
			{
				$mode = $arState['mode'];
			}
		}
		if($bSuccess === SOCSERV_REGISTRATION_DENY)
		{
			$url = (preg_match("/\?/", $url)) ? $url.'&' : $url.'?';
			$url .= 'auth_service_id='.self::ID.'&auth_service_error='.SOCSERV_REGISTRATION_DENY;
		}
		elseif($bSuccess !== true)
			$url = (isset($urlPath)) ? $urlPath.'?auth_service_id='.self::ID.'&auth_service_error='.$bSuccess : $APPLICATION->GetCurPageParam(('auth_service_id='.self::ID.'&auth_service_error='.$bSuccess), $aRemove);
		if(CModule::IncludeModule("socialnetwork") && strpos($url, "current_fieldset=") === false)
			$url = (preg_match("/\?/", $url)) ? $url."&current_fieldset=SOCSERV" : $url."?current_fieldset=SOCSERV";

		$url = CUtil::JSEscape($url);
		$location = ($mode == "opener") ? 'if(window.opener) window.opener.location = \''.$url.'\'; window.close();' : ' window.location = \''.$url.'\';';

		$JSScript = '
		<script type="text/javascript">
		'.$location.'
		</script>
		';

		echo $JSScript;

		die();
	}
Exemplo n.º 23
0
 public function getMessages($uid)
 {
     $fb = new CFacebookInterface();
     if (IsModuleInstalled('bitrix24') && defined('BX24_HOST_NAME')) {
         $redirect_uri = self::CONTROLLER_URL . "/redirect.php?redirect_to=" . urlencode(CSocServUtil::GetCurUrl('auth_service_id=' . self::ID, array("code")));
     } else {
         $redirect_uri = CSocServUtil::GetCurUrl('auth_service_id=' . self::ID, array("code"));
     }
     if ($fb->GetAccessToken($redirect_uri) !== false) {
         $res = $fb->getMessages($uid);
     }
     return $res;
 }
Exemplo n.º 24
0
 public function GetRedirectURI()
 {
     return CSocServUtil::ServerName() . "/bitrix/tools/oauth/yandex.php";
 }
Exemplo n.º 25
0
 public function GetRedirectURI()
 {
     return CSocServUtil::ServerName(true) . "/bitrix/tools/oauth/dropbox.php";
 }
Exemplo n.º 26
0
    public function Authorize()
    {
        $GLOBALS["APPLICATION"]->RestartBuffer();
        $bSuccess = 1;
        $bProcessState = false;
        if (isset($_REQUEST["code"]) && $_REQUEST["code"] != '' && CSocServAuthManager::CheckUniqueKey()) {
            $bProcessState = true;
            $redirect_uri = CSocServUtil::GetCurUrl('auth_service_id=' . self::ID, array("code", "state", "check_key", "backurl"));
            $appID = trim(self::GetOption("mailru_id"));
            $appSecret = trim(self::GetOption("mailru_secret_key"));
            $gAuth = new CMailRuOAuthInterface($appID, $appSecret, $_REQUEST["code"]);
            if ($gAuth->GetAccessToken($redirect_uri) !== false) {
                $arMRUser = $gAuth->GetCurrentUser();
                if (is_array($arMRUser) && $arMRUser['0']['uid'] != '') {
                    $email = $first_name = $last_name = $gender = "";
                    if ($arMRUser['0']['first_name'] != '') {
                        $first_name = $arMRUser['0']['first_name'];
                    }
                    if ($arMRUser['0']['last_name'] != '') {
                        $last_name = $arMRUser['0']['last_name'];
                    }
                    if ($arMRUser['0']['email'] != '') {
                        $email = $arMRUser['0']['email'];
                    }
                    if (isset($arMRUser['0']['sex']) && $arMRUser['0']['sex'] != '') {
                        if ($arMRUser['0']['sex'] == '0') {
                            $gender = 'M';
                        } elseif ($arMRUser['0']['sex'] == '1') {
                            $gender = 'F';
                        }
                    }
                    $arFields = array('EXTERNAL_AUTH_ID' => self::ID, 'XML_ID' => $arMRUser['0']['uid'], 'LOGIN' => "MM_" . $email, 'NAME' => $first_name, 'EMAIL' => $email, 'LAST_NAME' => $last_name, 'PERSONAL_GENDER' => $gender);
                    if (isset($arMRUser['0']['birthday'])) {
                        if ($date = MakeTimeStamp($arMRUser['0']['birthday'], "DD.MM.YYYY")) {
                            $arFields["PERSONAL_BIRTHDAY"] = ConvertTimeStamp($date);
                        }
                    }
                    if (isset($arMRUser['0']['pic_190']) && self::CheckPhotoURI($arMRUser['0']['pic_190'])) {
                        if ($arPic = CFile::MakeFileArray($arMRUser['0']['pic_190'] . '?name=/' . md5($arMRUser['0']['pic_190']) . '.jpg')) {
                            $arFields["PERSONAL_PHOTO"] = $arPic;
                        }
                    }
                    $arFields["PERSONAL_WWW"] = $arMRUser['0']['link'];
                    if (strlen(SITE_ID) > 0) {
                        $arFields["SITE_ID"] = SITE_ID;
                    }
                    $bSuccess = $this->AuthorizeUser($arFields);
                }
            }
        }
        if (!$bProcessState) {
            unset($_REQUEST["state"]);
        }
        $url = $GLOBALS["APPLICATION"]->GetCurDir() == "/login/" ? "" : $GLOBALS["APPLICATION"]->GetCurDir();
        if (isset($_REQUEST["state"])) {
            $arState = array();
            parse_str($_REQUEST["state"], $arState);
            if (isset($arState['backurl'])) {
                $url = parse_url($arState['backurl'], PHP_URL_PATH);
            }
        }
        $aRemove = array("logout", "auth_service_error", "auth_service_id", "code", "error_reason", "error", "error_description", "check_key");
        if ($bSuccess !== true) {
            $url = $GLOBALS['APPLICATION']->GetCurPageParam('auth_service_id=' . self::ID . '&auth_service_error=' . $bSuccess, $aRemove);
        }
        echo '
<script type="text/javascript">
if(window.opener)
	window.opener.location = \'' . CUtil::JSEscape($url) . '\';
window.close();
</script>
';
        die;
    }
Exemplo n.º 27
0
 public static function sendMessage($uid, $message)
 {
     $vk = new CVKontakteOAuthInterface();
     if (IsModuleInstalled('bitrix24') && defined('BX24_HOST_NAME')) {
         $redirect_uri = self::CONTROLLER_URL . "/redirect.php";
     } else {
         $redirect_uri = CSocServUtil::ServerName() . $GLOBALS['APPLICATION']->GetCurPage() . '?auth_service_id=' . self::ID;
     }
     if ($vk->GetAccessToken($redirect_uri) !== false) {
         $res = $vk->sendMessage($uid, $message);
     }
     return $res;
 }
Exemplo n.º 28
0
	public function Authorize()
	{
		$GLOBALS["APPLICATION"]->RestartBuffer();
		$bSuccess = false;
			if((isset($_REQUEST["code"]) && $_REQUEST["code"] <> '') && CSocServAuthManager::CheckUniqueKey())
			{
				$redirect_uri= CSocServUtil::GetCurUrl('auth_service_id='.self::ID, array("code"));
				$appID = trim(self::GetOption("liveid_appid"));
				$appSecret = trim(self::GetOption("liveid_appsecret"));

				$gAuth = new CLiveIDOAuthInterface($appID, $appSecret, $_REQUEST["code"]);

				if($gAuth->GetAccessToken($redirect_uri) !== false)
				{
					$arLiveIDUser = $gAuth->GetCurrentUser();

					if ($arLiveIDUser['id'] <> '')
					{
						$email = $first_name = $last_name = "";
						$login = "******".$arLiveIDUser['id'];
						$uId = $arLiveIDUser['id'];
						if($arLiveIDUser['first_name'] <> '')
							$first_name = $arLiveIDUser['first_name'];
						if($arLiveIDUser['last_name'] <> '')
							$last_name = $arLiveIDUser['last_name'];
						if($arLiveIDUser['emails']['preferred'] <> '')
						{
							$email = $arLiveIDUser['emails']['preferred'];
							$login = $arLiveIDUser['emails']['preferred'];
							$uId = $arLiveIDUser['emails']['preferred'];
						}
						$arFields = array(
							'EXTERNAL_AUTH_ID' => self::ID,
							'XML_ID' => $uId,
							'LOGIN' => $login,
							'EMAIL' => $email,
							'NAME'=> $first_name,
							'LAST_NAME'=> $last_name,
						);
						$arFields["PERSONAL_WWW"] = $arLiveIDUser["link"];

						$bSuccess = $this->AuthorizeUser($arFields);

					}
				}
			}

		$url = ($GLOBALS["APPLICATION"]->GetCurDir() == "/login/") ? "/auth/" : $GLOBALS["APPLICATION"]->GetCurDir();
		if(isset($_REQUEST["state"]))
		{
			$arState = array();
			parse_str($_REQUEST["state"], $arState);

			if(isset($arState['backurl']))
				$url = parse_url($arState['backurl'], PHP_URL_PATH);
		}
		if($bSuccess !== true)
			$url .= (strpos($url, '?') === false? '?':'&').'auth_service_id='.self::ID.'&auth_service_error='.$bSuccess;
	
		echo '
<script type="text/javascript">
if(window.opener)
	window.opener.location = \''.CUtil::JSEscape($url).'\';
window.close();
</script>
';
		die();
	}
Exemplo n.º 29
0
	public function Authorize()
	{
		$GLOBALS["APPLICATION"]->RestartBuffer();
		$bSuccess = false;
		if((isset($_REQUEST["code"]) && $_REQUEST["code"] <> '') && CSocServAuthManager::CheckUniqueKey())
		{
			$redirect_uri = CSocServUtil::GetCurUrl('auth_service_id='.self::ID, array("code"));
			$appID = self::GetOption("odnoklassniki_appid");
			$appSecret = self::GetOption("odnoklassniki_appsecret");
			$appKey = self::GetOption("odnoklassniki_appkey");
			$gAuth = new COdnoklassnikiInterface($appID, $appSecret, $appKey, $_REQUEST["code"]);

			if($gAuth->GetAccessToken($redirect_uri) !== false)
			{
				$arOdnoklUser = $gAuth->GetCurrentUser();

				if ($arOdnoklUser['uid'] <> '')
				{
					$uid = $arOdnoklUser['uid'];
					$first_name = $last_name = $gender = "";
					if($arOdnoklUser['first_name'] <> '')
						$first_name = $arOdnoklUser['first_name'];
					if($arOdnoklUser['last_name'] <> '')
						$last_name = $arOdnoklUser['last_name'];
					if(isset($arOdnoklUser['gender']) && $arOdnoklUser['gender'] != '')
					{
						if ($arOdnoklUser['gender'] == 'male')
							$gender = 'M';
						elseif ($arOdnoklUser['gender'] == 'female')
							$gender = 'F';
					}

					$arFields = array(
						'EXTERNAL_AUTH_ID' => self::ID,
						'XML_ID' => "OK".$uid,
						'LOGIN' => "OKuser".$uid,
						'EMAIL'=> $uid."@".self::ID.".bitrix",
						'NAME'=> $first_name,
						'LAST_NAME'=> $last_name,
						'PERSONAL_GENDER' => $gender,
					);
					if(isset($arOdnoklUser['birthday']))
						if ($date = MakeTimeStamp($arOdnoklUser['birthday'], "YYYY-MM-DD"))
							$arFields["PERSONAL_BIRTHDAY"] = ConvertTimeStamp($date);
					if(isset($arOdnoklUser['pic_2']) && self::CheckPhotoURI($arOdnoklUser['pic_2']))
						if ($arPic = CFile::MakeFileArray($arOdnoklUser['pic_2'].'&name=/'.md5($arOdnoklUser['pic_2']).'.jpg'))
							$arFields["PERSONAL_PHOTO"] = $arPic;
					$arFields["PERSONAL_WWW"] = "http://odnoklassniki.ru/profile/".$uid;

					$bSuccess = $this->AuthorizeUser($arFields);
				}
			}
		}
		$url = '/personal/profile/';
		if(isset($_REQUEST["state"]))
		{
			$arState = array();
			parse_str($_REQUEST["state"], $arState);

			if(isset($arState['backurl']))
				$url = parse_url($arState['backurl'], PHP_URL_PATH);
		}
		$aRemove = array("logout", "auth_service_error", "auth_service_id", "code", "error_reason", "error", "error_description", "check_key");
		if(!$bSuccess)
			$url = $GLOBALS['APPLICATION']->GetCurPageParam(('auth_service_id='.self::ID.'&auth_service_error=1'), $aRemove);

		echo '
<script type="text/javascript">
if(window.opener)
	window.opener.location = \''.CUtil::JSEscape($url).'\';
window.close();
</script>
';
		die();
	}
Exemplo n.º 30
-1
    public function Authorize()
    {
        global $APPLICATION;
        $APPLICATION->RestartBuffer();
        $authError = SOCSERV_AUTHORISATION_ERROR;
        if (isset($_REQUEST["code"]) && $_REQUEST["code"] != '' && CSocServAuthManager::CheckUniqueKey()) {
            $redirect_uri = CSocServUtil::ServerName() . '/bitrix/tools/oauth/bitrix24net.php';
            if ($this->getEntityOAuth($_REQUEST["code"])->GetAccessToken($redirect_uri) !== false) {
                $arB24NetUser = $this->entityOAuth->GetCurrentUser();
                if ($arB24NetUser) {
                    if (isset($_REQUEST['checkword']) && $arB24NetUser['PROFILE_ID'] > 0) {
                        $profileId = $arB24NetUser['PROFILE_ID'];
                        $checkword = trim($_REQUEST['checkword']);
                        $dbRes = CUser::getById($profileId);
                        $arUser = $dbRes->fetch();
                        if ($arUser && !$arUser['LAST_LOGIN']) {
                            if ($arUser['CONFIRM_CODE'] == $checkword) {
                                $arUserFields = array('XML_ID' => $arB24NetUser['ID'], 'EXTERNAL_AUTH_ID' => 'socservices');
                                if ($arUser['NAME'] == '' && $arUser['LAST_NAME'] == '') {
                                    $arUserFields['NAME'] = $arB24NetUser['NAME'];
                                    $arUserFields['LAST_NAME'] = $arB24NetUser['LAST_NAME'];
                                    if (strlen($arB24NetUser['PERSONAL_PHOTO']) > 0 && self::CheckPhotoURI($arB24NetUser['PERSONAL_PHOTO'])) {
                                        $arUserFields['PERSONAL_PHOTO'] = CFile::MakeFileArray($arB24NetUser['PERSONAL_PHOTO']);
                                    }
                                }
                                $obUser = new CUser();
                                if ($obUser->update($profileId, $arUserFields)) {
                                    foreach (GetModuleEvents("main", "OnUserInitialize", true) as $arEvent) {
                                        ExecuteModuleEventEx($arEvent, array($profileId, $arUserFields));
                                    }
                                }
                            }
                        }
                    }
                    $arFields = array('EXTERNAL_AUTH_ID' => self::ID, 'XML_ID' => $arB24NetUser["ID"], 'LOGIN' => "B24_" . $arB24NetUser["ID"], 'NAME' => $arB24NetUser["NAME"], 'LAST_NAME' => $arB24NetUser["LAST_NAME"], 'EMAIL' => $arB24NetUser["EMAIL"], 'PERSONAL_WWW' => $arB24NetUser["PROFILE"], 'OATOKEN' => $this->entityOAuth->getToken(), 'REFRESH_TOKEN' => $this->entityOAuth->getRefreshToken(), 'OATOKEN_EXPIRES' => $this->entityOAuth->getAccessTokenExpires());
                    if (IsModuleInstalled('bitrix24')) {
                        $arFields['LOGIN'] = $arFields['EMAIL'];
                    }
                    if (strlen(SITE_ID) > 0) {
                        $arFields["SITE_ID"] = SITE_ID;
                    }
                    $authError = $this->AuthorizeUser($arFields);
                }
            }
        }
        $bSuccess = $authError === true;
        $aRemove = array("logout", "auth_service_error", "auth_service_id", "code", "error_reason", "error", "error_description", "check_key", "current_fieldset", "checkword");
        $url = $APPLICATION->GetCurDir() == "/login/" ? "" : $APPLICATION->GetCurDir();
        $mode = 'page';
        if (isset($_REQUEST["state"])) {
            $arState = array();
            parse_str($_REQUEST["state"], $arState);
            if (isset($arState['backurl']) || isset($arState['redirect_url'])) {
                $parseUrl = parse_url(isset($arState['redirect_url']) ? $arState['redirect_url'] : $arState['backurl']);
                $urlPath = $parseUrl["path"];
                $arUrlQuery = explode('&', $parseUrl["query"]);
                foreach ($arUrlQuery as $key => $value) {
                    foreach ($aRemove as $param) {
                        if (strpos($value, $param . "=") === 0) {
                            unset($arUrlQuery[$key]);
                            break;
                        }
                    }
                }
                $url = !empty($arUrlQuery) ? $urlPath . '?' . implode("&", $arUrlQuery) : $urlPath;
            }
            if (isset($arState['mode'])) {
                $mode = $arState['mode'];
            }
        }
        if (strlen($url) <= 0 || preg_match("'^(http://|https://|ftp://|//)'i", $url)) {
            $url = CSocServUtil::ServerName() . '/';
        }
        $url = CUtil::JSEscape($url);
        if ($bSuccess) {
            unset($_SESSION['B24_NETWORK_REDIRECT_TRY']);
        } else {
            if (IsModuleInstalled('bitrix24')) {
                if (isset($_SESSION['B24_NETWORK_REDIRECT_TRY'])) {
                    unset($_SESSION['B24_NETWORK_REDIRECT_TRY']);
                    $url = self::getUrl();
                    $url .= (strpos($url, '?') >= 0 ? '&' : '?') . 'skip_redirect=1';
                } else {
                    $_SESSION['B24_NETWORK_REDIRECT_TRY'] = true;
                    $url = '/';
                }
            } else {
                if ($authError === SOCSERV_REGISTRATION_DENY) {
                    $url = preg_match("/\\?/", $url) ? $url . '&' : $url . '?';
                    $url .= 'auth_service_id=' . self::ID . '&auth_service_error=' . $authError;
                } elseif ($bSuccess !== true) {
                    $url = isset($urlPath) ? $urlPath . '?auth_service_id=' . self::ID . '&auth_service_error=' . $authError : $GLOBALS['APPLICATION']->GetCurPageParam('auth_service_id=' . self::ID . '&auth_service_error=' . $authError, $aRemove);
                }
            }
        }
        if (CModule::IncludeModule("socialnetwork") && strpos($url, "current_fieldset=") === false) {
            $url .= (strpos($url, "?") === false ? '?' : '&') . "current_fieldset=SOCSERV";
        }
        $location = $mode == "popup" ? 'if(window.opener) window.opener.location = \'' . $url . '\'; window.close();' : 'window.location = \'' . $url . '\';';
        ?>
<script type="text/javascript">
<?php 
        echo $location;
        ?>
</script>
<?php 
        die;
    }