Esempio n. 1
0
        echo $captcha['hidden'];
    }
    ?>
			</p>
			<?php 
}
?>
		<p><?php 
echo gettext('<strong>*</strong>Required');
?>
</p>
		<input type="submit" class="button buttons" value="<?php 
echo gettext('Submit');
?>
" />
		<?php 
if (class_exists('federated_logon')) {
    ?>
			<p id="Federated_buttons_fieldlist">
				<?php 
    echo gettext('You may also register using federated credentials');
    ?>
				<?php 
    federated_logon::buttons(WEBPATH . '/index.php');
    ?>
			</p>
			<?php 
}
?>
	</form>
</div>
Esempio n. 2
0
    /**
     * Creates a list of logon buttons for federated logon handlers.
     * Note that it will use an image if one exists. The name of the image
     * should be cononical to the name of the logon handler, but without the "_logon'.
     * The image must be a PNG file.
     *
     * The styling of the buttons is done by the "federated_logon_buttons.css". If you do not like the
     * one provided place an alternate version in your theme folder or the plugins/federated_logon
     * folder.
     */
    static function buttons($redirect = NULL)
    {
        $alt_handlers = federated_logon::alt_login_handler('');
        ?>
		<ul class="logon_buttons">
			<?php 
        foreach ($alt_handlers as $handler => $details) {
            $script = $details['script'];
            $authority = str_replace('_logon', '', stripSuffix(basename($script)));
            if (is_null($redirect)) {
                $details['params'][] = 'redirect=/' . ZENFOLDER . '/admin.php';
            } else {
                if (!empty($redirect)) {
                    $details['params'][] = 'redirect=' . $redirect;
                }
            }
            if (count($details['params'])) {
                $params = "'" . implode("','", $details['params']) . "'";
            } else {
                $params = '';
            }
            ?>
				<li>
					<span class="fed_buttons">
						<a href="javascript:launchScript('<?php 
            echo $script;
            ?>
',[<?php 
            echo $params;
            ?>
]);" title="<?php 
            echo $authority;
            ?>
" >
							<?php 
            $logo = ltrim(str_replace(WEBPATH, '', dirname($script)) . '/' . $authority . '.png', '/');
            if (file_exists(SERVERPATH . '/' . $logo)) {
                ?>
								<img src="<?php 
                echo WEBPATH . '/' . $logo;
                ?>
" alt="<?php 
                echo $authority;
                ?>
" title="<?php 
                printf(gettext('Login using %s'), $authority);
                ?>
" />
								<?php 
            } else {
                echo $authority;
            }
            ?>
						</a>
					</span>
				</li>
				<?php 
        }
        ?>
		</ul>
		<?php 
    }
Esempio n. 3
0
function run()
{
    $consumer = getConsumer();
    // Complete the authentication process using the server's
    // response.
    $return_to = getReturnTo();
    $response = $consumer->complete($return_to);
    // Check the response status.
    if ($response->status == Auth_OpenID_CANCEL) {
        // This means the authentication was cancelled.
        $msg = gettext('Verification cancelled.');
    } else {
        if ($response->status == Auth_OpenID_FAILURE) {
            // Authentication failed; display the error message.
            $msg = sprintf(gettext("OpenID authentication failed: %s"), $response->message);
        } else {
            if ($response->status == Auth_OpenID_SUCCESS) {
                // This means the authentication succeeded; extract the
                // identity URL and Simple Registration data (if it was
                // returned).
                $openid = $response->getDisplayIdentifier();
                $esc_identity = escape($openid);
                $success = sprintf(gettext('You have successfully verified <a href="%s">%s</a> as your identity.'), $esc_identity, $esc_identity);
                if ($response->endpoint->canonicalID) {
                    $escaped_canonicalID = escape($response->endpoint->canonicalID);
                    $success .= '  (XRI CanonicalID: ' . $escaped_canonicalID . ') ';
                }
                $email = $name = NULL;
                $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
                $sreg = $sreg_resp->contents();
                if ($sreg) {
                    if (@$sreg['email']) {
                        $email = trim($sreg['email']);
                    }
                    if (@$sreg['nickname']) {
                        $name = $sreg['nickname'];
                    }
                    if (@$sreg['fullname']) {
                        $name = $sreg['fullname'];
                    }
                }
                $ax_resp = Auth_OpenID_AX_FetchResponse::fromSuccessResponse($response);
                if ($ax_resp) {
                    $arr_ax_resp = get_object_vars($ax_resp);
                    $arr_ax_data = $arr_ax_resp['data'];
                    if (empty($email) && isset($arr_ax_data["http://axschema.org/contact/email"]) && count($arr_ax_data["http://axschema.org/contact/email"]) > 0) {
                        $email = $arr_ax_data["http://axschema.org/contact/email"][0];
                    }
                    if (empty($name) && isset($arr_ax_data["http://axschema.org/namePerson"]) && count($arr_ax_data["http://axschema.org/namePerson"]) > 0) {
                        $name = $arr_ax_data["http://axschema.org/namePerson"][0];
                    }
                    if (empty($name)) {
                        $name_first = '';
                        $name_middle = '';
                        $name_last = '';
                        if (isset($arr_ax_data["http://axschema.org/namePerson/first"]) && count($arr_ax_data["http://axschema.org/namePerson/first"]) > 0) {
                            $name_first = $arr_ax_data["http://axschema.org/namePerson/first"][0];
                        }
                        if (isset($arr_ax_data["http://axschema.org/namePerson/middle"]) && count($arr_ax_data["http://axschema.org/namePerson/middle"]) > 0) {
                            $name_middle = $arr_ax_data["http://axschema.org/namePerson/middle"][0];
                        }
                        if (isset($arr_ax_data["http://axschema.org/namePerson/last"]) && count($arr_ax_data["http://axschema.org/namePerson/last"]) > 0) {
                            $name_last = $arr_ax_data["http://axschema.org/namePerson/last"][0];
                        }
                        $fullname = trim(trim(trim($name_first) . ' ' . $name_middle) . ' ' . $name_last);
                        if (!empty($fullname)) {
                            $name = $fullname;
                        }
                    }
                    if (empty($name) && isset($arr_ax_data["http://axschema.org/namePerson/friendly"]) && count($arr_ax_data["http://axschema.org/namePerson/friendly"]) > 0) {
                        $name = $arr_ax_data["http://axschema.org/namePerson/friendly"][0];
                    }
                }
                $userid = trim(str_replace(array('http://', 'https://'), '', $openid), '/');
                //	always remove the protocol
                $pattern = @$_SESSION['OpenID_cleaner_pattern'];
                if ($pattern) {
                    if (preg_match($pattern, $userid, $matches)) {
                        $userid = $matches[1];
                    }
                }
                $provider = @$_SESSION['provider'];
                if (strlen($userid) + strlen($provider) > 63) {
                    $userid = sha1($userid);
                }
                if ($provider) {
                    $userid = $provider . ':' . $userid;
                }
                $redirect = @$_SESSION['OpenID_redirect'];
                $success .= federated_logon::credentials($userid, $email, $name, $redirect);
            }
        }
    }
    return $success;
}