⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cardspace.module

📁 开源的OpenId的一个java实现
💻 MODULE
字号:
<?phpglobal $cardspace_cons;$cardspace_cons['apache_get'] = '__mod_cspace_login__';$cardspace_cons['ppid'] = 'cardspace_http://schemas_xmlsoap_org/ws/2005/05/identity/claims/privatepersonalidentifier';$cardspace_cons['requiredClaims'][] = 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/privatepersonalidentifier';function cardspace_form_alter($form_id, &$form){    if ($form_id == 'user_login_block' || $form_id == 'user_login') {        $form['cardspace_link'] = array('#value' => '<a href="' .                                         url('cardspace/authenticate') .                                        '"><div>' .                                        '<img src="modules/cardspace/logo.png"><br />' . t('Cardspace Login') .                                        '</div></a>'                                       );    }    return $form;}function cardspace_user($type, &$edit, &$account, $category = NULL){    if ($type == 'view') {        $items['cardspace'] = array('title'=>t('Card Management'),                                     'value' => '<a href="' .                                         url('cardspace/associate') .                                        '"><div>' .                                        t('Associate Card') .                                        '</div></a>' . '<a href="' .                                         url('cardspace/cards') .                                        '"><div>' .                                        t('Card List') .                                        '</div></a>'                                   );                                           return array(t('CardSpace') => $items);    }}function cardspace_object(){    global $cardspace_cons;    if (!$_REQUEST[$cardspace_cons['apache_get']]) {    ?>    <html>    <body onload="cardspace_auth.submit()">        <form id="cardspace_auth" method="POST" action="?<?=$cardspace_cons['apache_get']?>=xx&q=cardspace/authenticate">        <?php            cardspace_object_part();        ?>        </form>    </body>    </html>    <?php    } else {        if($_SERVER['cardspace_auth_state']=='success') {            $ppid = $_SERVER[$cardspace_cons['ppid']];            $sql = "SELECT name FROM cardspace_assoc WHERE ppid='$ppid'";	            $res = db_query($sql);            $res = db_fetch_object($res);                        if (!$res || $res->name !='') {                $name = $res->name;                $sql = "SELECT uid FROM users WHERE name='$name'";	                $res = db_query($sql);                $res = db_fetch_object($res);                global $user;                $user->uid = $res->uid;                user_login_submit('user_login', array());                drupal_goto();                            } else {                drupal_set_message("Invalid Card or not associated with an account");                drupal_goto();            }                    }    }}function cardspace_associate(){    global $cardspace_cons;    if (!$_REQUEST[$cardspace_cons['apache_get']]) {        ?>        <html>        <body onload="cardspace_auth.submit()">            <form id="cardspace_auth" method="POST" action="?<?=$cardspace_cons['apache_get']?>=xx&q=cardspace/associate">            <?php                cardspace_object_part();            ?>            </form>        </body>        </html>        <?php    } else {        global $user;        $name = $user->name;        $ppid = $_SERVER[$cardspace_cons['ppid']];                if ($_SERVER['cardspace_auth_state']=='success' && $ppid == '') {            drupal_set_message("Invalid Card" . print_r($_SERVER, TRUE));            drupal_goto();        }                $sql = "INSERT INTO cardspace_assoc VALUES('$ppid', '$name')";        db_query($sql);        drupal_set_message("Card Associated with this account");        drupal_goto();    }}function cardspace_assoc_list(){    $head = array(t('Cardspace ID'), t('Action'));        global $user;    $name = $user->name;    $sql = "SELECT * FROM cardspace_assoc WHERE name='$name'";    $res = db_query($sql);    while ($assoc = db_fetch_object($res)) {        $body[] = array($assoc->ppid, l(t('Delete'), 'cardspace/remove/'. $assoc->ppid));    }        if(count($body)<1) {        $body[] = array("No Cards yet", l(t('Associate new card'), 'cardspace/associate'));    }        $page = theme('table', $head, $body);    return $page;}function cardspace_remove(){    $ppid = arg(2);    if ($ppid && $ppid!='') {        global $user;        $name = $user->name;        $sql = "DELETE FROM cardspace_assoc WHERE ppid='$ppid' AND name='$name'";        db_query($sql);        drupal_set_message(t('Association successfully removed'));    } else {        drupal_set_message(t("Error : BAD PPID :" . arg(2)));    }        drupal_goto('cardspace/cards');}function cardspace_object_part(){    global $cardspace_cons;    foreach ($cardspace_cons['requiredClaims'] as $claim) {        $claims .= $claim . '';    }    $claims = trim($claims);?>    <OBJECT type="application/x-informationCard" name="xmlToken">    <PARAM  Name="tokenType" Value="urn:oasis:names:tc:SAML:1.0:assertion">    <PARAM  Name="requiredClaims" value="<?=$claims?>">    </OBJECT><?php}function cardspace_menu($may_cache){    $items[] = array('path' => 'cardspace/authenticate',                     'title' => t('CardSpace Authentication'),                     'callback' => 'cardspace_object',                     'access' => TRUE,                     'type' => MENU_CALLBACK                    );        $items[] = array('path' => 'cardspace/associate',                     'title' => t('CardSpace Associate'),                     'callback' => 'cardspace_associate',                     'access' => TRUE,                     'type' => MENU_CALLBACK                    );                        $items[] = array('path' => 'cardspace/cards',                     'title' => t('CardSpace card list'),                     'callback' => 'cardspace_assoc_list',                     'access' => TRUE,                     'type' => MENU_CALLBACK                    );    $items[] = array('path' => 'cardspace/remove',                     'title' => t('CardSpace Remove'),                     'callback' => 'cardspace_remove',                     'callback arguments' => 'infocard_admin',                     'access' => TRUE,                     'type' => MENU_CALLBACK                    );    return $items;}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -