Changeset 100
- Timestamp:
- 08/06/07 23:08:06 (1 year ago)
- Files:
-
- trunk/wp-infocard/wp-infocard.php (modified) (1 diff)
- trunk/wp-infocard/wp/admin.pw.php (modified) (4 diffs)
- trunk/wp-infocard/wp/audit.pw.php (modified) (1 diff)
- trunk/wp-infocard/wp/processing.pw.php (modified) (1 diff)
- trunk/wp-infocard/wp/pw-claimtypes.php (modified) (1 diff)
- trunk/wp-infocard/wp/userdata.pw.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/wp-infocard/wp-infocard.php
r77 r100 1 1 <?php 2 2 /* 3 Plugin Name: Information Card Login4 Plugin URI: http:// pamelaproject.com/wp-infocard3 Plugin Name: PamelaWare Information Card Login 4 Plugin URI: http://code.pamelaproject.com/wiki/PWwordpress 5 5 Description: This plugin adds functionality to register and login with "information cards", part of the Identity Metasystem web services framework. Once it is activated, go to the "Options" menu and click on "Information Card Options" to see what to do next. 6 Version: b 27 Author: K. Cameron, P. Dingle 8 Author URI: http ://www.pamelaproject.com/wp-infocard/contributors6 Version: b3 7 Author: K. Cameron, P. Dingle, and more 8 Author URI: https://pamelaproject.com/svn/pw/pwcommon/legal/CONTRIBUTORS 9 9 */ 10 10 include_once( dirname(__FILE__) . '/pw-config.php' ); trunk/wp-infocard/wp/admin.pw.php
r87 r100 3 3 include_once( dirname(__FILE__) . '/../pw-config.php'); 4 4 include_once( dirname(__FILE__) . '/../pwlib/admin.pwlib.php'); 5 include_once( dirname(__FILE__) . '/processing.pw.php'); 5 6 //require_once( ABSPATH . WPINC . '/registration-functions.php'); 6 7 /* … … 96 97 global $wpdb; 97 98 99 /* -- old format 98 100 $myTableIdentityQuery = 99 101 "CREATE TABLE `$this->table_identity` ( … … 101 103 `ppid` varchar(128) NOT NULL default '', 102 104 `accountid` bigint(20) unsigned 105 ) ENGINE = MYISAM"; 106 */ 107 $myTableIdentityQuery = 108 "CREATE TABLE `$this->table_identity` ( 109 `cardhash` text default '', 110 `accountid` bigint(20) unsigned, 111 `cardhandle` varchar(128) NOT NULL default '', 112 `startdate` varchar(128) NOT NULL default '', 113 `lastused` varchar(128) NOT NULL default '' 103 114 ) ENGINE = MYISAM"; 104 115 … … 256 267 global $current_user; 257 268 258 $ppid = pw_userdata::getUserPPID( $current_user->ID ); 259 260 if ( $ppid ) 269 $cardcount = pw_processing::getUserCardCount( $current_user->ID ); 270 $handle = pw_processing::getCardHandle( $current_user->ID ); 271 272 if ( $cardcount > 0 ) 261 273 { 262 274 ?> 263 275 <p> 264 <img src="<?php echo PW_IMGURL; ?>/ic-logo/ic-logo-blue-icon.png"/> <?php pw_utils::screenPrint('Information Card ID: ' ); ?>276 <img src="<?php echo PW_IMGURL; ?>/ic-logo/ic-logo-blue-icon.png"/> <?php pw_utils::screenPrint('Information Card ID: ' . $handle); ?> 265 277 </p> 266 278 trunk/wp-infocard/wp/audit.pw.php
r69 r100 22 22 23 23 $today = date('Y-m-d H-i-s'); 24 $query = "INSERT INTO ` wp_infocard_audit` "24 $query = "INSERT INTO `" . PW_TABLE_PREFIX . "infocard_audit` " 25 25 . "(`modulusHash`, `ppid`, `accountid`, `email`,`time`,`IP`,`status`) " 26 26 . "VALUES ('$modulus', '$ppid', '$acct', '$email','$today','$ip','$error')"; trunk/wp-infocard/wp/processing.pw.php
r98 r100 47 47 48 48 } // end function showProcessingSummary 49 49 50 50 } // end class pw_processing 51 51 ?> trunk/wp-infocard/wp/pw-claimtypes.php
r98 r100 102 102 'return $' . 'claimslist[\'webpage\']->token_value;'); 103 103 104 $datamap['cardhash'] = new pw_mapping( 105 'Card Hash', 106 'cardhash', 107 PW_TABLE_PREFIX . 'infocard_identities', 108 'return pw_processing::getCardHash();', 109 'Calculates a card hash from the PPID and the issuer modulus'); 110 111 $datamap['cardhandle'] = new pw_mapping( 112 'Card Handle', 113 'cardhandle', 114 PW_TABLE_PREFIX . 'infocard_identities', 115 'return pw_processing::calculateCardHandle();', 116 'Calculates a card handle from the PPID and the issuer modulus'); 117 104 118 // Map any custom claims 105 119 if ( PW_CUSTOM_DATA ) trunk/wp-infocard/wp/userdata.pw.php
r98 r100 14 14 class pw_userdata 15 15 { 16 17 //Function: evaluateIncomingRequest18 //Description: decides what kind of user is connecting.19 //Input: email, modulus, ppid from incoming request20 //Output: An array of user information. With the21 //following indices:22 //array['status'] - contains 1 of these statuses:23 //1. valid-user - supplied email address exists24 //and belongs to same user as supplied modulus/ppid25 //2. new-user - email address & modulus/ppid are new26 //3. new-card - email address exists but modulus is new27 //4. new-email - modulus/ppid exists but email is new28 //5. an error code29 //30 //array['id'] - contains the user id number (or 0 if the status31 //is anything other than valid-user32 //Side-effects: none33 16 /* 17 Function: evaluateIncomingRequest 18 Description: decides what kind of user is connecting. 19 Input: email, modulus, ppid from incoming request 20 Output: An array of user information. With the 21 following indices: 22 array['status'] - contains 1 of these statuses: 23 1. valid-user - supplied email address exists 24 and belongs to same user as supplied modulus/ppid 25 2. new-user - email address & modulus/ppid are new 26 3. new-card - email address exists but modulus is new 27 4. new-email - modulus/ppid exists but email is new 28 5. an error code 29 30 array['id'] - contains the user id number (or 0 if the status 31 is anything other than valid-user 32 Side-effects: none 33 */ 34 34 function evaluateIncomingRequest() 35 35 { … … 39 39 $identity_user_id = 0; 40 40 41 $cardhash = pw_processing::getCardHash(); 41 42 pw_utils::printDebug( '<br/>Evaluating Incoming Request:<br/>'); 42 43 … … 45 46 return $incominguser; 46 47 } 47 48 48 49 $query = "SELECT * FROM `" . PW_TABLE_PREFIX 49 . "infocard_identities` WHERE modulusHash = '" 50 . substr_replace($claimslist['signerkeymodulus']->token_value, '', 128, -1) 51 . "' AND ppid = '" 52 . $claimslist['privatepersonalidentifier']->token_value 53 . "'"; 54 pw_utils::printDebug($query); 50 . "infocard_identities` WHERE cardhash = '" 51 . $cardhash . "'"; 55 52 $identity_info = $wpdb->get_results( $query, OBJECT ); 56 53 … … 60 57 // could be valid-user, or new-email 61 58 $identity_user_id = $identity_info[0]->accountid; 62 $datamap['modulusHash']->add_db_value($identity_info[0]->modulusHash); 63 $datamap['privatepersonalidentifier']->add_db_value($identity_info[0]->ppid); 64 59 $datamap['cardhash']->add_db_value($identity_info[0]->cardhash); 65 60 break; 66 61 … … 294 289 // Output: none 295 290 // Side effect: modifies table data 296 function updateIdentityData( $ acct, $modulus, $ppid)291 function updateIdentityData( $datamap ) 297 292 { 298 293 global $wpdb; 299 300 $query = "SELECT * FROM wp_infocard_identities WHERE (ppid = '$ppid' " 301 . "AND modulusHash = '$modulus') OR (accountid = '$acct')"; 294 $acct = $datamap['ID']->new_value; 295 $cardhash = $datamap['cardhash']->new_value; 296 $cardhandle = $datamap['cardhandle']->new_value; 297 $today = date('Y-m-d H-i-s'); 298 299 //$query = "SELECT * FROM wp_infocard_identities WHERE (ppid = '$ppid' " 300 //. "AND modulusHash = '$modulus') OR (accountid = '$acct')"; 301 302 $query = "SELECT * FROM wp_infocard_identities WHERE cardHash = '$cardhash' " 303 . "OR accountid = '$acct'"; 304 305 pw_utils::printDebug($query); 302 306 303 307 $results = $wpdb->get_results( $query, OBJECT ); … … 307 311 { 308 312 case 0: 313 // first card used for this account 309 314 pw_utils::printDebug( ' New Entry<br/>' ); 310 315 $query = "INSERT INTO `wp_infocard_identities` " 311 . "( modulusHash, ppid, accountid ) VALUES "312 . "( '$ modulus', '$ppid', '$acct' )";316 . "( cardhash, cardhandle, accountid, startdate, lastused ) VALUES " 317 . "( '$cardhash', '$cardhandle', '$acct', '$today', '$today' )"; 313 318 $wpdb->query( $query ); 314 319 break; … … 317 322 if (!pw_utils::dataCompare($results[0]->accountid, $acct, 'Account ID')) 318 323 { 319 pw_utils::printDebug( ' PPID/Modulusused for another account<br/>' );324 pw_utils::printDebug( ' Card used for another account<br/>' ); 320 325 return 'CARDINUSE'; 321 326 322 327 } 323 if ( (!pw_utils::dataCompare( $results[0]->modulusHash, $modulus, 'Modulus')) 324 || ( !pw_utils::dataCompare( $results[0]->ppid, $ppid, 'PPID' )))328 329 if (!pw_utils::dataCompare( $results[0]->cardhash, $cardhash, 'Card Hash')) 325 330 { 326 331 $query = "UPDATE `wp_infocard_identities` SET " 327 . "modulusHash = '$modulus', ppid = '$ppid' " 328 . "WHERE accountid = '$acct'"; 332 . "cardhash = '$cardhash', startdate = '$today', " 333 . "cardhandle = '$cardhandle', " 334 . "lastused = '$today' WHERE accountid = '$acct'"; 329 335 $wpdb->query( $query ); 330 336 pw_utils::printDebug( ' Updated Existing Entry<br/>' ); … … 346 352 } // end function updateIdentityData 347 353 348 function getUserPPID( $acct )349 {350 global $wpdb;351 352 $query = "SELECT ppid FROM " . PW_TABLE_PREFIX . "infocard_identities WHERE accountid = '$acct' ";353 354 return $wpdb->get_var( $query );355 356 } //end function getUserPPID357 358 354 /* 359 355 Function: Perform user login functions
