Beispiel #1
0
$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();
        }
    }
Beispiel #2
0
 /**
  * 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);
 }
Beispiel #3
0
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;
}
Beispiel #4
0
<?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);
 /**
  * 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);
 }