コード例 #1
0
ファイル: liveid.php プロジェクト: DarneoStudio/bitrix
 public function GetFormHtml($arParams)
 {
     $wll = new WindowsLiveLogin();
     $wll->setAppId(self::GetOption('liveid_appid'));
     $wll->setSecret(self::GetOption('liveid_secret'));
     $_SESSION['BX_LIVEID_LAST_PAGE'] = $GLOBALS["APPLICATION"]->GetCurPageParam('', array('logout'));
     return '<noindex><a href="' . $wll->getLoginUrl() . '" rel="nofollow" class="bx-ss-button liveid-button"></a><span class="bx-spacer"></span><span>' . GetMessage("socserv_liveid_note") . '</span></noindex>';
 }
コード例 #2
0
ファイル: connect.php プロジェクト: laiello/we-promote-this
$WEBAUTHCOOKIE = 'webauthtoken';
$COOKIETTL = time() + 10 * 365 * 24 * 60 * 60;
// The location of the Web Authentication control. You should not have
// to change this value.
$CONTROLURL = 'http://login.live.com/controls/WebAuth.htm';
// The CSS style string to pass in to the Web Authentication control.
$CONTROLSTYLE = urlencode('font-size: 10pt; font-family: verdana; background: white;');
$liveid_appid = get_option('social_connect_liveid_appid_key');
$liveid_secret = get_option('social_connect_liveid_secret_key');
$liveid_secalgo = 'wsignin1.0';
$liveid_return = SOCIAL_CONNECT_PLUGIN_URL . '/liveid/callback.php';
$liveid_policy = get_option('social_connect_liveid_policy_url');
$liveid_settings = array("appid" => $liveid_appid, "secret" => $liveid_secret, "securityalgorithm" => $liveid_secalgo, "returnurl" => $liveid_return, "policyurl" => $liveid_policy);
if ($liveid_appid && $liveid_secret && $liveid_secalgo) {
    // Initialize the WindowsLiveLogin module.
    $wll = WindowsLiveLogin::initFromXml(false, $liveid_settings);
    $wll->setDebug($DEBUG);
    $APPID = $wll->getAppId();
    $login_html = "<p>This application does not know who you are!  Click the <b>Sign in</b> link above.</p>";
    $consent_html = null;
    // If the user token obtained from sign-in through Web Authentication
    // has been cached in a site cookie, attempt to process it and extract
    // the user ID.
    $token = @$_COOKIE[$WEBAUTHCOOKIE];
    $userid = null;
    if ($token) {
        $user = $wll->processToken($token);
        if ($user) {
            $userid = $user->getId();
        }
    }
コード例 #3
0
ファイル: auth.php プロジェクト: Advanture/Online-RolePlay
 /**
  * Constructor
  *
  * @access	public
  * @param	object		ipsRegistry reference
  * @param	array 		Configuration info for this method
  * @param	array 		Custom configuration info for this method
  * @return	@e void
  */
 public function __construct(ipsRegistry $registry, $method, $conf = array())
 {
     /**
      * Turn off strict error reporting for Windows Live
      */
     error_reporting(E_ALL ^ E_NOTICE ^ E_STRICT);
     $this->method_config = $method;
     $this->live_config = $conf;
     parent::__construct($registry);
     //-----------------------------------------
     // Check for necessary extensions
     //-----------------------------------------
     if (!function_exists('mhash')) {
         $this->missingModules[] = 'mhash';
     }
     if (!function_exists('mcrypt_decrypt')) {
         $this->missingModules[] = 'mcrypt_decrypt';
     }
     /* Got missing modules? */
     if (count($this->missingModules)) {
         $this->missingExtensions = true;
         $this->return_code = 'MISSING_EXTENSIONS';
         return false;
     }
     /* Got our key file? */
     if (!is_file($this->live_config['key_file_location'])) {
         $this->missingModules[] = $this->live_config['key_file_location'];
         $this->missingExtensions = true;
         $this->return_code = 'MISSING_EXTENSIONS';
         return false;
     }
     //-----------------------------------------
     // And grab libs
     //-----------------------------------------
     require_once IPS_ROOT_PATH . 'sources/loginauth/live/lib/windowslivelogin.php';
     /*noLibHook*/
     $this->live = WindowsLiveLogin::initFromXml($this->live_config['key_file_location']);
     $this->live->setDebug(FALSE);
 }
コード例 #4
0
ファイル: windowslivelogin.php プロジェクト: mover5/imobackup
 /**
  * Initialize the WindowsLiveLogin module from a settings file. 
  *
  *  'settingsFile' specifies the location of the XML settings file
  *  that contains the application ID, secret key, and security
  *  algorithm. The file is of the following format:
  *
  *  <windowslivelogin>
  *    <appid>APPID</appid>
  *    <secret>SECRET</secret>
  *    <securityalgorithm>wsignin1.0</securityalgorithm>
  *  </windowslivelogin>
  *
  *  In a Delegated Authentication scenario, you may also specify
  *  'returnurl' and 'policyurl' in the settings file, as shown in the
  *  Delegated Authentication samples.
  *
  *  We recommend that you store the WindowsLiveLogin settings file
  *  in an area on your server that cannot be accessed through the 
  *  Internet. This file contains important confidential information.
  */
 public static function initFromXml($settingsFile)
 {
     $o = new WindowsLiveLogin();
     $settings = $o->parseSettings($settingsFile);
     if (@$settings['debug'] == 'true') {
         $o->setDebug(true);
     } else {
         $o->setDebug(false);
     }
     if (@$settings['force_delauth_nonprovisioned'] == 'true') {
         $o->setForceDelAuthNonProvisioned(true);
     } else {
         $o->setForceDelAuthNonProvisioned(false);
     }
     $o->setAppId(@$settings['appid']);
     $o->setSecret(@$settings['secret']);
     $o->setOldSecret(@$settings['oldsecret']);
     $o->setOldSecretExpiry(@$settings['oldsecretexpiry']);
     $o->setSecurityAlgorithm(@$settings['securityalgorithm']);
     $o->setPolicyUrl(@$settings['policyurl']);
     $o->setReturnUrl(@$settings['returnurl']);
     $o->setBaseUrl(@$settings['baseurl']);
     $o->setSecureUrl(@$settings['secureurl']);
     $o->setConsentBaseUrl(@$settings['consenturl']);
     return $o;
 }
コード例 #5
0
ファイル: delauth-handler.php プロジェクト: hoalangoc/ftf
<?php

/**
 * This page handles the 'delauth' Delegated Authentication action.
 * When you create a Windows Live application, you must specify the URL
 * of this handler page.
 */

// Load common settings.  For more information, see settings.php.
include 'settings.php';

include 'windowslivelogin.php';

// Initialize the WindowsLiveLogin module.
$wll = WindowsLiveLogin::initFromXml($KEYFILE);

$wll -> setDebug($DEBUG);

// Extract the 'action' parameter, if any, from the request.
$action = @$_REQUEST['action'];

// user denied application request
if (isset($_REQUEST['ResponseCode']) && $_REQUEST['ResponseCode'] == 'RequestRejected')
{
	processDeniedAndExit();
}

if ($action == 'delauth')
{
	$consent = $wll -> processConsent($_REQUEST);
コード例 #6
0
ファイル: contacts_fn.php プロジェクト: hoalangoc/ftf
function get_people_array()
{
    include 'settings.php';
    include 'windowslivelogin.php';

    //initialize Windows Live Libraries
    $wll = WindowsLiveLogin::initFromXml($KEYFILE);
    $consenturl = $wll -> getConsentUrl($OFFERS);

    // If the raw consent token has been cached in a site cookie, attempt to
    // process it and extract the consent token.
    $token = null;
    $cookie = @$_COOKIE[$COOKIE];
    if ($cookie)
    {
        $token = $wll -> processConsentToken($cookie);
    }

    //Check if there's consent and, if not, redirect to the login page
    if ($token && !$token -> isValid())
    {
        $token = null;
    }
    if ($token == null)
    {
        header('Location:' . $consenturl);
    }
    if ($token)
    {
        // Convert Unix epoch time stamp to user-friendly format.
        $expiry = $token -> getExpiry();
        $expiry = date(DATE_RFC2822, $expiry);
		

        //*******************CONVERT HEX TO DOUBLE LONG INT
        // ***************************************
        $hexIn = $token -> getLocationID();
        include "hex.php";
        $longint = $output;
        //here's the magic long integer to be sent to the Windows Live service

        //*******************CURL THE REQUEST
        // ***************************************
        $uri = "https://livecontacts.services.live.com/users/@C@" . $output . "/LiveContacts";
        $session = curl_init($uri);

        curl_setopt($session, CURLOPT_HEADER, 0);
        curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($session, CURLOPT_USERAGENT, "Windows Live Data Interactive SDK");
        curl_setopt($session, CURLOPT_HTTPHEADER, array("Authorization: DelegatedToken dt=\"" . $token -> getDelegationToken() . "\""));
        curl_setopt($session, CURLOPT_VERBOSE, 1);
        curl_setopt($session, CURLOPT_HTTPPROXYTUNNEL, TRUE);
        curl_setopt($session, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
        curl_setopt($session, CURLOPT_PROXY, $PROXY_SVR);
        curl_setopt($session, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($session, CURLOPT_TIMEOUT, 120);
        $response = curl_exec($session);
		
		
        curl_close($session);

        if (!$response)
        {
            echo $uri;
            die ;
        }

        $data = json_decode(json_encode(simplexml_load_string($response)), 1);
		
		$contacts = array();

        if (isset($data['Contacts']['Contact']))
        {
			$arrContacts = $data['Contacts']['Contact'];
			
			if(isset($arrContacts['ID'])){
				$arrContacts = array($arrContacts);
			}

            foreach ($arrContacts as $contact)
            {
				
                $name = $email = null;
                $name =  @$contact['Profiles']['Personal']['DisplayName'];
                $email = @$contact['Emails']['Email']['Address'];
				
                if($email  == '')
                {
                    continue;    
                }
                
                if(null == $name or $name ==  ' ' or $name  ==  '  '){
                    $name =  $email;
                }

                $contacts[] = array(
                    'name' => $name,
                    'email' => $email
                );
            }
        }
    }

	setcookie($COOKIE, null,time()-86400);
    return $contacts;
}
コード例 #7
0
ファイル: descriptions.php プロジェクト: nProfessor/Mytb
	public function GetDescription()
	{
		$liveid_disabled = !WindowsLiveLogin::IsAvailable();
		$tw_disabled = !function_exists("hash_hmac");

		return array(
			array(
				"ID" => "Facebook",
				"CLASS" => "TrCSocServFacebook",
				"NAME" => "Facebook",
				"ICON" => "facebook",
			),
			array(
				"ID" => "LiveID",
				"CLASS" => "TrCSocServLiveID",
				"NAME" => "LiveID",
				"ICON" => "liveid",
				"DISABLED" => $liveid_disabled,
			),
			array(
				"ID" => "MyMailRu",
				"CLASS" => "TrCSocServMyMailRu",
				"NAME" => GetMessage("socserv_mailru_name"),
				"ICON" => "mymailru",
			),
			array(
				"ID" => "OpenID",
				"CLASS" => "TrCSocServOpenID",
				"NAME" => "OpenID",
				"ICON" => "openid",
			),
			array(
				"ID" => "YandexOpenID",
				"CLASS" => "TrCSocServYandex",
				"NAME" => GetMessage("socserv_openid_yandex"),
				"ICON" => "yandex",
			),
			array(
				"ID" => "MailRuOpenID",
				"CLASS" => "TrCSocServMailRu",
				"NAME" => "Mail.Ru",
				"ICON" => "openid-mail-ru",
			),
			array(
				"ID" => "Livejournal",
				"CLASS" => "TrCSocServLivejournal",
				"NAME" => "Livejournal",
				"ICON" => "livejournal",
			),
			array(
				"ID" => "Liveinternet",
				"CLASS" => "TrCSocServLiveinternet",
				"NAME" => "Liveinternet",
				"ICON" => "liveinternet",
			),
			array(
				"ID" => "Blogger",
				"CLASS" => "TrCSocServBlogger",
				"NAME" => "Blogger",
				"ICON" => "blogger",
			),
			array(
				"ID" => "Rambler",
				"CLASS" => "TrCSocServRambler",
				"NAME" => "Rambler",
				"ICON" => "rambler",
			),
			array(
				"ID" => "Twitter",
				"CLASS" => "TrCSocServTwitter",
				"NAME" => "Twitter",
				"ICON" => "twitter",
				"DISABLED" => $tw_disabled,
			),
			array(
				"ID" => "VKontakte",
				"CLASS" => "TrCSocServVKontakte",
				"NAME" => GetMessage("socserv_vk_name"),
				"ICON" => "vkontakte",
			),
			array(
				"ID" => "GoogleOAuth",
				"CLASS" => "TrCSocServGoogleOAuth",
				"NAME" => "Google",
				"ICON" => "google",
			),
		);
	}
コード例 #8
0
 /**
  * Constructor
  *
  * @access	public
  * @param	object		ipsRegistry reference
  * @param	array 		Configuration info for this method
  * @param	array 		Custom configuration info for this method
  * @return	void
  */
 public function __construct(ipsRegistry $registry, $method, $conf = array())
 {
     $this->method_config = $method;
     $this->live_config = $conf;
     parent::__construct($registry);
     //-----------------------------------------
     // Check for necessary extensions
     //-----------------------------------------
     if (!function_exists('mhash') or !function_exists('mcrypt_decrypt')) {
         $this->missingExtensions = true;
         return false;
     }
     //-----------------------------------------
     // And grab libs
     //-----------------------------------------
     require_once IPS_ROOT_PATH . "sources/loginauth/live/lib/windowslivelogin.php";
     $this->live = WindowsLiveLogin::initFromXml($this->live_config['key_file_location']);
     $this->live->setDebug(FALSE);
 }
コード例 #9
0
ファイル: liveid.php プロジェクト: DarneoStudio/bitrix
 function parse($input)
 {
     if (!$input) {
         WindowsLiveLogin::debug("Error: parse: Null input.");
         return;
     }
     $input = explode('&', $input);
     $pairs = array();
     foreach ($input as $pair) {
         $kv = explode('=', $pair);
         if (count($kv) != 2) {
             WindowsLiveLogin::debug("Error: parse: Bad input to parse: " . $pair);
             return;
         }
         $pairs[$kv[0]] = $kv[1];
     }
     return $pairs;
 }
コード例 #10
0
function liveid($credentials, $options)
{
    $session =& JFactory::getSession();
    $mainframe =& JFactory::getApplication();
    $db = JFactory::getDBO();
    $db->setQuery('select p.apikey, p.secretkey, p.discovery_url as control_url, p.parameters from #__providers p where p.name=' . $db->Quote($credentials['provider']));
    $consumer = $db->loadObject();
    $appid = $consumer->apikey;
    $secret = $consumer->secret;
    $policyurl = JUri::base() . '/policy.html';
    $returnurl = JUri::base() . '/index.php';
    $wll = new WindowsLiveLogin($appid, $secret, 'wsignin1.0', null, $policyurl, $returnurl);
    $info = array();
    $token = @$_COOKIE['webauthtoken'];
    $info[EXTERNAL_ID] = null;
    $info[STATUS] = Auth_FAILURE;
    if ($token) {
        $user = $wll->processToken($token);
        if ($user) {
            $info[EXTERNAL_ID] = $user->getId();
            $info[STATUS] = Auth_SUCCESS;
        }
    } else {
        $hasbegun = $session->get('liveidhasbegun');
        if (isset($hasbegun) || $hasbegun == 'false') {
            $session->set('liveidhasbegun', 'true');
            $url = $consumer->control_url . '?appid=' . $appid . '&' . $consumer->parameters;
            $mainframe->redirect($url);
        }
        $session->set('liveidhasbegun', 'false');
        $action = $credentials['action'];
        if ($action == '' || $action == 'login') {
            $user = $wll->processLogin($credentials);
            if ($user) {
                if ($user->usePersistentCookie()) {
                    $cookieTtl = time() + 10 * 365 * 24 * 60 * 60;
                    setcookie('webauthtoken', $user->getToken(), $cookieTtl);
                } else {
                    setcookie('webauthtoken', $user->getToken());
                }
                $info[EXTERNAL_ID] = $user->getId();
                $info[STATUS] = Auth_SUCCESS;
            }
            $info[STATUS] = Auth_FAILURE;
        }
    }
    // todo: solicitar email
    $info[EMAIL] = '';
    $info[LABEL] = $info[EMAIL];
    return $info;
}