Changeset 144
- Timestamp:
- 12/27/07 00:53:51 (1 year ago)
- Files:
-
- trunk/dist (copied) (copied from branches/RB-0.9/dist)
- trunk/dist/wp-infocard.v09.tar.gz (copied) (copied from branches/RB-0.9/dist/wp-infocard.v09.tar.gz)
- trunk/wp-infocard (modified) (1 prop)
- trunk/wp-infocard/pw-config.php (modified) (1 diff)
- trunk/wp-infocard/site-messages/en-us/new-email.html (modified) (1 diff)
- trunk/wp-infocard/site-messages/en-us/to-be-verified-new-user.html (copied) (copied from branches/RB-0.9/wp-infocard/site-messages/en-us/to-be-verified-new-user.html)
- trunk/wp-infocard/site-messages/en-us/trusted-new-email.html (copied) (copied from branches/RB-0.9/wp-infocard/site-messages/en-us/trusted-new-email.html)
- trunk/wp-infocard/site-messages/en-us/verified-new-email.html (copied) (copied from branches/RB-0.9/wp-infocard/site-messages/en-us/verified-new-email.html)
- trunk/wp-infocard/site-messages/infocard-usermessage.php (modified) (1 diff)
- trunk/wp-infocard/wp-infocard.php (modified) (2 diffs)
- trunk/wp-infocard/wp/admin.pw.php (modified) (12 diffs)
- trunk/wp-infocard/wp/clickback.pw.php (modified) (3 diffs)
- trunk/wp-infocard/wp/db_upgrade.pw.php (copied) (copied from branches/RB-0.9/wp-infocard/wp/db_upgrade.pw.php)
- trunk/wp-infocard/wp/login/infocard-clickback.php (modified) (2 diffs)
- trunk/wp-infocard/wp/login/infocard-login.php (modified) (1 diff)
- trunk/wp-infocard/wp/login/infocard-newcard.php (copied) (copied from branches/RB-0.9/wp-infocard/wp/login/infocard-newcard.php)
- trunk/wp-infocard/wp/processing.pw.php (modified) (3 diffs)
- trunk/wp-infocard/wp/pw-config.php.wp (deleted)
- trunk/wp-infocard/wp/userdata.pw.php (modified) (20 diffs)
- trunk/wp-infocard/wp/utils.pw.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/wp-infocard
- Property svn:externals changed from
pwlib https://pamelaproject.com/svn/pw/pwcommon/trunk/pwlib
legal https://pamelaproject.com/svn/pw/pwcommon/trunk/legal
to
pwlib https://pamelaproject.com/svn/pw/pwcommon/branches/RB-1.0/pwlib
legal https://pamelaproject.com/svn/pw/pwcommon/branches/RB-1.0/legal
- Property svn:externals changed from
trunk/wp-infocard/pw-config.php
r109 r144 7 7 define ('PW_SHOW_BINARY', FALSE); 8 8 define ('PW_PLUGINPATH', '/wp-content/plugins/wp-infocard'); 9 define ('PW_VERSION', 'b3'); 10 define ('PW_VERSION_DATE', '29Sep07'); 9 define ('PW_VERSION', 'v0.9'); 10 define ('PW_VERSION_DATE', '12/26/07'); 11 define ('PW_DB_VERSION', 'DB v3'); 11 12 define ('PW_USECAPTCHAS', false ); 12 13 define ('PW_DEBUG_ON', get_settings('pw_debug_on')); 14 define ('PW_DEBUG_LEVEL', '0'); 13 15 define ('PW_SELECTOR_TRIGGER', get_settings('pw_selector_trigger')); 14 16 define ('PW_CUSTOM_DATA', get_settings('pw_custom_data')); trunk/wp-infocard/site-messages/en-us/new-email.html
r110 r144 1 <h2>Email Address Change</h2> 2 <p>Your email address has changed - please note that your login ID is based on your original email address, and will remain the same. This will be important if you ever need to recover your regular password.</p> 1 <h2>Email Validation Required</h2> 2 3 <p>You have changed the email address in your registered Information Card. You must validate the new email address before you can continue.</p> 4 5 <p>This blog is currently sending you an email. It contains a link back to this site. Please click on that link, which will validate you by proving that your claim to control the stated email address is legitimate.</p> trunk/wp-infocard/site-messages/infocard-usermessage.php
r112 r144 2 2 <?php 3 3 $messageType = $_REQUEST['mesg']; 4 4 5 5 6 include_once( dirname(__FILE__) . '/../' . '/pw-config.php'); trunk/wp-infocard/wp-infocard.php
r100 r144 3 3 Plugin Name: PamelaWare Information Card Login 4 4 Plugin URI: http://code.pamelaproject.com/wiki/PWwordpress 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: b35 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 Cards" to see what to do next. 6 Version: v0.9 7 7 Author: K. Cameron, P. Dingle, and more 8 8 Author URI: https://pamelaproject.com/svn/pw/pwcommon/legal/CONTRIBUTORS … … 47 47 // function to add information card link to wp-login.php 48 48 add_action( 'login_form', array( $wpInfocard, 'pw_loginform_link')); 49 add_action( 'register_form', array( $wpInfocard, 'pw_registerform_link')); 49 50 50 51 //if ( PW_USECAPTCHAS ) trunk/wp-infocard/wp/admin.pw.php
r110 r144 11 11 include_once( dirname(__FILE__) . '/../pwlib/admin.pwlib.php'); 12 12 include_once( dirname(__FILE__) . '/processing.pw.php'); 13 include_once( dirname(__FILE__) . '/utils.pw.php'); 13 14 //require_once( ABSPATH . WPINC . '/registration-functions.php'); 14 15 /* … … 62 63 63 64 $myTableAuditQuery = 64 "CREATE TABLE `$this->table_audit` (65 "CREATE TABLE IF NOT EXISTS `$this->table_audit` ( 65 66 `cardhash` text default '', 66 67 `accountid` bigint(20) unsigned, … … 168 169 foreach ( $wpdb->get_col("SHOW TABLES", 0) as $table ) 169 170 { 170 if ( $table == $this->table_ identity)171 if ( $table == $this->table_options ) 171 172 { 172 173 return true; … … 185 186 { 186 187 global $wpdb; 188 pw_admin::createInfocardAuditTable(); 189 pw_admin::createInfocardIdentityTable(); 187 190 188 191 $isAuditTableCreated = $this->_createAuditTable(); … … 198 201 $this->createOption('pw_securesiteurl', $https_url); 199 202 203 $this->createOption('pw_db_version', PW_DB_VERSION); 200 204 $this->createOption('pw_debug_on', 0); 201 205 $this->createOption('pw_enable_pass', 0); … … 236 240 { 237 241 global $current_user; 238 if (strpos($_SERVER[SCRIPT_URI], "https")) 239 { 240 $css = PW_PLUGINURL . "/custom/infocard-frontpage.css"; 241 } 242 else 243 { 244 $css = PW_SECUREPLUGINURL . "/custom/infocard-frontpage.css"; 245 } 242 $css = get_option('siteurl') . "/custom/infocard-frontpage.css"; 246 243 247 244 $chunk = ""; 248 245 if( !$current_user->ID ) 249 246 { 250 $chunk = '<link rel="stylesheet" href="'.$css.'" type="text/css" />'; 247 //$chunk = '<link rel="stylesheet" href="'.$css.'" type="text/css" />'; 248 $chunk = ''; 251 249 // note I set the CSS styles inline because otherwise 252 250 // the user has to link infocard.css - not worth it 253 251 // for this one icon 254 $chunk .='< /li><li><a id="pw_frontpage_link" href="'252 $chunk .='<li><a id="pw_frontpage_link" href="' 255 253 . PW_SECUREPLUGINURL .'/' . PW_PLUGIN 256 254 . '/login/infocard-login.php" alt="' 257 255 . __('Information Card Login') 258 . '" ><img id="pw_frontpage_icon" src="'256 . '" style="border-bottom:none;"><img id="pw_frontpage_icon" src="' 259 257 . PW_IMGURL . '/' .PW_FP_ICON 260 . '" /></a></li>';258 . '" style="border:none; border-bottom: none; background: none;"/></a></div></li>'; 261 259 } 262 return $link . $chunk;260 return $link . $chunk; 263 261 } //end function pw_frontpage_link 264 262 … … 280 278 } //end function pw_loginform_link 281 279 280 281 function pw_registerform_link() 282 { 283 // if ( PW_USECAPTCHAS ) 284 // display_cryptographp(); 285 ?> 286 <hr /> 287 <a href="<?php echo PW_SECUREPLUGINURL . '/' . PW_PLUGIN; ?>/login/infocard-login.php" alt="<?php pw_utils::screenPrint('Infocard Login'); ?>" style="border-bottom: none; color: #FFF"> 288 <?php pw_utils::screenPrint('Register using an Information Card'); ?> 289 <br/> 290 <img src="<?php echo PW_IMGURL; ?>/infocard_60x42.png" style="padding:10px" /> 291 </a> 292 <a alt="<?php echo __('What is this?'); ?>" style="border-bottom: none; color: #fff" href="http://pamelaproject.com/"> 293 <?php echo __('(what is this?)'); ?> 294 </a> 295 <?php 296 } //end function pw_registerform_link 297 282 298 function pw_printUserCardStatus() 283 299 { … … 292 308 ?> 293 309 <p> 294 <img src="<?php echo PW_IMGURL; ?>/ic-logo/ic-logo-blue-icon.png"/> <?php pw_utils::screenPrint('Information Card ID: ' . $handle); ?> 310 <img src="<?php echo PW_IMGURL; ?>/infocard_60x42.png"/> 311 <?php 312 pw_utils::screenPrint('An Information Card is associated with this account'); 313 //pw_utils::screenPrint('Information Card ID: ' . $handle); 314 ?> 295 315 </p> 296 316 … … 302 322 . "<label for='Information Card Info' style='display: inline'><img src=\"" 303 323 . PW_IMGURL 304 . '/i c-logo/ic-logo-disabled.png"'324 . '/infocard_60x42_disabled.png"' 305 325 . " style='vertical-align: middle'/> "; 306 pw_utils::screenPrint('No Information Card in use.');326 pw_utils::screenPrint('No Information Card associated with this account.'); 307 327 echo "</label></p>"; 308 328 } … … 319 339 function getOption($attr_name) 320 340 { 321 return get_ settings($attr_name);341 return get_option($attr_name); 322 342 } //end function getOption 323 343 324 /*325 Function: createNewAccount326 Description: creates a new db record327 Input: account details328 Output: returns the user Id on success, FALSE on failure329 Side effect: none330 */331 function createNewAccount( $datamap )332 {333 require_once( ABSPATH . WPINC . '/registration-functions.php');334 335 $user_login = $datamap['user_login']->new_value;336 $user_firstname = $datamap['first_name']->new_value;337 $user_lastname = $datamap['last_name']->new_value;338 $user_email = $datamap['user_email']->new_value;339 $display_name = $datamap['display_name']->new_value;340 $user_nicename = $display_name;341 $user_pass = MD5($datamap['cardhash']->new_value);342 $user_url = $datamap['user_url']->new_value;343 344 InfocardUtils::printDebug("<br/>Action: createNewAccount<br>");345 InfocardUtils::printDebug("<br/>Nice Name: $user_nicename<br>");346 $userdata = compact('user_login', 'user_pass', 'user_email', 'user_nicename', 'user_url', 'display_name', 'user_firstname', 'user_lastname');347 $user_ID = wp_insert_user($userdata);348 349 if ($user_ID)350 {351 InfocardUtils::printDebug(" Inserted record # $user_ID<br>");352 return $user_ID;353 }354 else355 {356 InfocardUtils::printDebug(" Error - new user not created<br/>");357 return FALSE;358 }359 } // end function createNewAccount360 361 344 function createOption( $option_name, $option_value ) 362 { 363 // this function needs to be inside the pw_infocard class for WP to call it. This is just a 364 // placeholder 365 } 345 { 346 // this is duplicated in the case of the wordpress plugin. 347 $options = get_option($option_name); 348 if ( !$options ) 349 $options = $option_value; 350 351 update_option($option_name, $options); 352 } 353 354 function removeOption( $option_name ) 355 { 356 delete_option( $option_name ); 357 358 } 359 366 360 function pwAdminScreen() 367 361 { … … 369 363 $opts = pw_admin::updateAdminOptions(); 370 364 // write submitted changes if this page reload shows a submit 365 if (pw_utils::databaseUpToDate()) 366 { 367 echo "<p>Plugin Version: ". PW_VERSION . " " . PW_VERSION_DATE 368 . " (" . $opts['pw_db_version'] . ")</p>"; 369 } 370 else 371 { 372 ?> 373 <form action="" method="post"> 374 <?php 375 echo "<div id='message' class='updated'>" . pw_admin::fixDatabase() . "</div>"; 376 ?> 377 <input type="submit" name="infocard_admin_upgrade" id="infocard_admin_upgrade" value="Continue" /> 378 </form> 379 <?php 380 return; 381 } 371 382 372 383 pw_admin::printSystemCheck($opts['pw_securesiteurl']); … … 491 502 return $option_val; 492 503 } 493 function checkDatabaseStructure() 494 { 495 // eventually this is where I will put my database upgrade code. 504 505 function createInfocardAuditTable() 506 { 507 global $wpdb; 508 $audittable = PW_TABLE_PREFIX . "infocard_audit"; 509 510 $myTableAuditQuery = 511 "CREATE TABLE IF NOT EXISTS `" . $audittable . "` ( 512 `cardhash` text default '', 513 `accountid` bigint(20) unsigned, 514 `email` varchar(128) NOT NULL default '', 515 `time` datetime NOT NULL default '0000-00-00 00:00:00', 516 `IP` varchar(16) NOT NULL default '', 517 `status` varchar(128) NOT NULL default '' 518 ) ENGINE = MYISAM"; 519 520 // Check if table is already there 521 foreach ($wpdb->get_col("SHOW TABLES", 0) as $table ) 522 { 523 if ($table == $audittable) 524 { 525 return false; 526 } 527 } 528 529 // Ok, let's proceed 530 if ( $wpdb->query( $myTableAuditQuery ) === false ) 531 { 532 return false; 533 } 534 535 // Just to be sure, we check that tables were actually created 536 foreach ( $wpdb->get_col("SHOW TABLES", 0) as $table ) 537 { 538 if ( $table == $audittable ) 539 { 540 return true; 541 } 542 } 543 return false; 544 } //end function createInfocardAuditTable 545 546 function createInfocardIdentityTable() 547 { 548 global $wpdb; 549 $identitytable = PW_TABLE_PREFIX . "infocard_identities"; 550 551 $myTableIdentityQuery = 552 "CREATE TABLE `" . $identitytable . "` ( 553 `cardhash` text default '', 554 `accountid` bigint(20) unsigned, 555 `cardhandle` varchar(128) NOT NULL default '', 556 `startdate` varchar(128) NOT NULL default '', 557 `lastused` varchar(128) NOT NULL default '' 558 ) ENGINE = MYISAM"; 559 560 // Check if table is already there 561 foreach ($wpdb->get_col("SHOW TABLES", 0) as $table ) 562 { 563 if ($table == $identitytable) 564 { 565 return false; 566 } 567 } 568 569 // Ok, let's proceed 570 if ( $wpdb->query( $myTableIdentityQuery ) === false ) 571 { 572 return false; 573 } 574 575 // Just to be sure, we check that tables were actually created 576 foreach ( $wpdb->get_col("SHOW TABLES", 0) as $table ) 577 { 578 if ( $table == $identitytable ) 579 { 580 return true; 581 } 582 } 583 return false; 584 } // end function createInfocardIdentityTable 585 586 /* 587 Function: fixDatabase 588 Description: updates/alters database depending on detection 589 of database version 590 Input: none 591 Output: status string 592 Side-Effect: may alter database structure 593 */ 594 function fixDatabase() 595 { 596 include_once('db_upgrade.pw.php'); 597 $output = "<h4>Upgrading PamelaWare to " . PW_VERSION . "</h4>"; 598 if (pw_admin::getOption('pw_db_version')) 599 return $output . "oops sorry, up to date</p>"; 600 601 if (pw_admin::getOption('pw_infocard_key')) 602 { 603 global $wpdb; 604 // we are at least DBv2, maybe DBv3 605 $query = "describe wp_infocard_identities"; 606 $identity_info = $wpdb->get_results( $query, OBJECT ); 607 608 $cardhash_present = FALSE; 609 foreach (array_values($identity_info) as $x) 610 if ($x->Field == 'cardhash') 611 $cardhash_present = TRUE; 612 613 if ($cardhash_present) 614 { 615 // DB is already v3, just fix options 616 $output .= "<p>Version DBv3 detected</p>"; 617 pw_admin::setOption('pw_db_version', 'DB v3'); 618 } 619 else 620 { 621 // DB is v2, must upgrade 622 $output .= "<p>Version DBv2 detected</p>"; 623 $output .= pw_db_upgrade::upgradeDBv2ToDBv3(); 624 } 625 626 return $output . "</p>"; 627 } 628 629 if (pw_admin::getOption('infocard_key')) 630 { 631 $output .= "<p>Version DBv1 detected</p>"; 632 $output .= pw_db_upgrade::upgradeDBv1ToDBv3(); 633 return $output . "</p>"; 634 } 635 return $output . "ERROR: non-standard database state!"; 496 636 } 497 637 } // end class pw_admin trunk/wp-infocard/wp/clickback.pw.php
r106 r144 42 42 } 43 43 44 pw_utils::printDebug("Clickback: Challenge Created. <br/>" 45 . "Clickback: salted data is " . (($data)?$data:"empty") . "<br/>" 46 . "Clickback: length is " . PW_CLICKBACK_LENGTH 47 . "<br/>Clickback: salt is $clickback_salt <br/>"); 44 pw_utils::printDebug("Clickback: Challenge Created (" . PW_CLICKBACK_LENGTH . " characters)<br/>"); 45 pw_utils::printDebug("<ul><li>salted data is " . (($data)?$data:"empty") . "</li>" 46 . "<li>Clickback: salt is $clickback_salt </li>", 2); 48 47 49 48 $data = MD5($clickback_salt . $data); … … 51 50 $chopped = substr($data, 0, PW_CLICKBACK_LENGTH); 52 51 53 pw_utils::printDebug(" Clickback: Hash of the salted challenge data: $data<br/>"54 . " Clickback: Chopped challenge data: $chopped <br/>");52 pw_utils::printDebug("<li>Hash of the salted challenge data: $data</li>" 53 . "<li>Chopped challenge data: $chopped</li></ul>", 2); 55 54 56 55 return ($chopped); … … 108 107 // Output: none 109 108 // Side Effects: sends an email 110 function sendAccountValidation( $clickbackID, $user_email )109 function sendAccountValidation( $clickbackID, $user_email, $function='registration' ) 111 110 { 112 global $mosConfig_live_site; 111 switch ($function) 112 { 113 case "registration": 114 $message = sprintf('Please complete your registration at %s by opening the link below.', pw_utils::getTitle()) . "\r\n\r\n"; 115 $email_title = 'New Information Card Registration'; 116 break; 117 118 case "emailvalidation": 119 $email_title = 'Information Card Email Validation'; 120 $message = sprintf('Someone has recently attempted to change their email address at %s (%s) to be this email address. If you are the person who has triggered this change, please click on the link below to confirm. If you have received this email in error, please disregard.', pw_utils::getTitle(), pw_utils::getSuccessUrl()) . "\r\n\r\n"; 121 break; 122 case "cardvalidation": 123 $email_title = 'New Information Card Validation'; 124 $message = sprintf('Someone has recently attempted to change the information card associated with the account at this email address at %s (%s). If you are the person who has triggered this change, please click on the link below to confirm. If you have received this email in error, please disregard.', pw_utils::getTitle(), pw_utils::getSuccessUrl()) . "\r\n\r\n"; 125 break; 126 127 128 default: 129 pw_utils::printDebug('Error: invalid function passed to sendAccountValidation!<br/>'); 130 131 } 113 132 $clickbackUrl = PW_SECUREPLUGINURL . "/" . PW_PLUGIN . "/login/infocard-clickback.php?clickbackID=" . $clickbackID; 114 133 115 $message = sprintf('Please complete your registration at %s by opening the link below.', pw_utils::getTitle()) . "\r\n\r\n"; 116 $message .= $clickbackUrl."\r\n\r\nThanks\r\n"; 134 $message .= $clickbackUrl."\r\n\r\nThank You.\r\n"; 117 135 // sendEmail: to-address, subject, body 118 pw_utils::sendEmail($user_email, 'New InfoCard Registration', $message);136 pw_utils::sendEmail($user_email, $email_title, $message); 119 137 120 138 pw_utils::printDebug( "<br/><br/>Account Validation is required.<br/>" trunk/wp-infocard/wp/login/infocard-clickback.php
r98 r144 21 21 </title> 22 22 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 23 <link rel="stylesheet" href="<?php pw_utils::printCSSlink( ); ?>" type="text/css" />23 <link rel="stylesheet" href="<?php pw_utils::printCSSlink('ssl'); ?>" type="text/css" /> 24 24 <script type="text/javascript" src="<?php echo pw_utils::printJqueryLocation(); ?>"></script> 25 25 <script> … … 101 101 </div> 102 102 <div id="pw_login_footer"> 103 <a id="pw_pamelaproject_logo" href="http ://pamelaproject.com" alt="Powered by PamelaWare"><img src='<?php pw_utils::displayPamelaProjectLogo(); ?>' /></a>103 <a id="pw_pamelaproject_logo" href="https://pamelaproject.com" alt="Powered by PamelaWare"><img src='<?php pw_utils::displayPamelaProjectLogo('ssl'); ?>' /></a> 104 104 </div> 105 105 </div> trunk/wp-infocard/wp/login/infocard-login.php
r109 r144 32 32 </head> 33 33 <body> 34 <?php 35 if ( !($_SERVER['HTTPS']) || !(strtolower($_SERVER['HTTPS']) == 'on')) 36 { 37 pw_utils::errorPageRedirect('NOHTTPS'); 38 } 39 40 ?> 34 41 <div id="pw_login_main"> 35 42 <div id="pw_login_header"> trunk/wp-infocard/wp/processing.pw.php
r108 r144 26 26 pw_utils::printDebug(" Login ID: ".$datamap['user_login']->new_value."<br />"); 27 27 pw_utils::printDebug(" Account ID: ".$datamap['ID']->new_value."<br />"); 28 pw_utils::printDebug(" Status: ".$status." <br/>");28 pw_utils::printDebug(" User Status: ".$status." <br/>"); 29 29 30 30 pw_utils::printDebug(" Errors: "); … … 34 34 pw_utils::printDebug(" none<br />"); 35 35 36 pw_utils::printDebug(" Trusted Source:"); 37 if ($blessed) 38 pw_utils::printDebug("Yes<br/>"); 39 else 40 pw_utils::printDebug("No<br/>"); 36 pw_utils::printDebug(" Issuer Trust: ".$blessed."<br />"); 41 37 42 38 pw_utils::printDebug(" Account Validation: "); 43 if ($validated )44 pw_utils::printDebug(" Sent<br/>");39 if ($validated === 'validate') 40 pw_utils::printDebug("Required<br/>"); 45 41 else 46 42 pw_utils::printDebug("Not needed<br/>"); … … 51 47 } // end function showProcessingSummary 52 48 49 /* 50 Function: getDBv1CardHash 51 Description: Before we started storing card hash, we stored 52 the PPID and an MD5 hash of the base64-decoded 53 modulus. 54 This means that when we upgraded the database 55 from v1 to v3, we had to make a hash out of 56 the ppid and the md5 hash, not the ppid and the 57 modulus. 58 Input: none 59 Output: SHA256 card hash with ppid 60 & md5(base64_decode(modulus)) 61 */ 62 function getDBv1CardHash() 63 { 64 global $claimslist; 65 66 $mod = md5(base64_decode($claimslist['signerkeymodulus']->token_value)); 67 pw_utils::printDebug('<br/>Checking DBv1 card hash<br/>', 1); 68 pw_utils::printDebug('--Modulus: ' . $mod . '<br/>', 1); 69 70 $cardhash = pw_processing::calculateCardHash( 71 $claimslist['privatepersonalidentifier']->token_value, 72 $mod 73 ); 74 pw_utils::printDebug('--CardHash: ' . $cardhash . '<br/>', 1); 75 return $cardhash; 76 } //end function getDBv1CardHash 77 53 78 } // end class pw_processing 54 79 ?> trunk/wp-infocard/wp/userdata.pw.php
r110 r144 22 22 class pw_userdata extends pwlib_userdata 23 23 { 24 // Function: evaluateIncomingRequest25 // Description: decides what kind of user is connecting.26 // Input: email, modulus, ppid from incoming request27 // Output: An array of user information. With the28 // following indices:29 // array['status'] - contains 1 of these statuses:30 // 1. valid-user - supplied email address exists31 // and belongs to same user as supplied modulus/ppid32 // 2. new-user - email address & modulus/ppid are new33 // 3. new-card - email address exists but modulus is new34 // 4. new-email - modulus/ppid exists but email is new35 // 5. an error code36 //37 // array['id'] - contains the user id number (or 0 if the status38 // is anything other than valid-user)39 // Side-effects: none40 function evaluateIncomingRequest()41 {42 global $wpdb, $claimslist, $datamap;43 $incominguser['id'] = 0;44 $incominguser['status'] = 'UNKNOWNERROR';45 $identity_user_id = 0;46 47 $cardhash = pw_processing::getCardHash();48 pw_utils::printDebug( '<br/>Evaluating Incoming Request:<br/>');49 50 if (!is_email($claimslist['emailaddress']->token_value))51 {52 $incominguser['status'] = "INVALIDEMAIL";53 return $incominguser;54 }55 56 $query = "SELECT * FROM `" . PW_TABLE_PREFIX57 . "infocard_identities` WHERE cardhash = '"58 . $cardhash . "'";59 $identity_info = $wpdb->get_results( $query, OBJECT );60 61 switch (count($identity_info))62 {63 case 1:64 // could be valid-user, or new-email65 $identity_user_id = $identity_info[0]->accountid;66 $datamap['cardhash']->add_db_value($identity_info[0]->cardhash);67 break;68 69 case 0:70 // could be new-card or new-user71 $identity_user_id = 0;72 break;73 74 default:75 $incominguser['status'] = "CARDNOTUNIQUE";76 return $incominguser;77 }78 79 pw_utils::printDebug(' Card belongs to account #: ' . $identity_user_id . "<br/>" );80 81 $query = "SELECT * from " . PW_TABLE_PREFIX . "users "82 . "WHERE user_email LIKE '"83 . $claimslist['emailaddress']->token_value . "'";84 85 $user_info = $wpdb->get_results( $query, ARRAY_A );86 87 switch (count($user_info))88 {89 case 1:90 $mail_user_id = $user_info[0][ID];91 pw_utils::printDebug(' User belongs to account #: ' . $mail_user_id . "<br/>" );92 if ($identity_user_id == 0)93 {94 $incominguser['id'] = $mail_user_id;95 $incominguser['status'] = 'new-card';96 }97 elseif ($identity_user_id != $mail_user_id)98 {99 $incominguser['status'] = "CLAIMSMISMATCHED";100 return $incominguser;101 }102 if ($identity_user_id == $mail_user_id)103 {104 $incominguser['id'] = $mail_user_id;105 $incominguser['status'] = 'valid-user';106 107 }108 foreach (array_keys($datamap) as $key)109 {110 if (array_key_exists($datamap[$key]->mappingattribute, $user_info[0]))111 {112 pw_utils::printDebug('Existing Value: found '.$datamap[$key]->mappingattribute.' in user_info[0]<br/>');113 $datamap[$key]->add_db_value($user_info[0][$datamap[$key]->mappingattribute]);114 }115 }116 117 // special case for first, last name118 $first = get_usermeta($mail_user_id, 'first_name');119 if ($first)120 {121 pw_utils::printDebug('Existing Value: found '.$datamap['first_name']->mappingattribute.' in usermeta ( '.$first.' )<br/>');122 $datamap['first_name']->add_db_value( $first );123 }124 125 $last = get_usermeta($mail_user_id, 'last_name');126 if ($last)127 {128 pw_utils::printDebug('Existing Value: found '.$datamap['last_name']->mappingattribute.' in usermeta ( '.$last.' )<br/>');129 $datamap['last_name']->add_db_value( $last );130 }131 132 if ( PW_CUSTOM_DATA )133 pw_customdata::evaluateIncomingCustomData( $mail_user_id );134 break;135 136 case 0:137 $mail_user_id = 0;138 if ($identity_user_id == 0)139 {140 // no user entry or identity entry141 $incominguser['status'] = 'new-user';142 }143 else144 {145 //identity entry but no mail entry146 $incominguser['id'] = $identity_user_id;147 $incominguser['status'] = 'new-email';148 }149 break;150 151 default:152 // More than one record returned for an email address153 $incominguser['status'] = "EMAILNOTUNIQUE";154 return $incominguser;155 }156 157 pw_utils::printDebug( " Email address belongs toaccount #: $mail_user_id <br/>" );158 pw_utils::printDebug( " Status: " . $incominguser['status'] . "<br/><br/>" );159 160 return $incominguser;161 } // end function evaluateIncomingRequest162 24 163 25 function mapTokenData() 164 26 { 165 27 global $claimslist, $datamap; 166 pw_utils::printDebug('<br/>Mapped Token Data:<br/>' );28 pw_utils::printDebug('<br/>Mapped Token Data:<br/>', 1); 167 29 foreach(array_keys($datamap) as $key) 168 30 { 169 31 $datamap[$key]->new_value = eval($datamap[$key]->mappingfunction); 170 //pw_utils::printDebug(' Mapping Function: '.$datamap[$key]->mappingfunction.'<br/>');171 pw_utils::printDebug(' ' . $datamap[$key]->handle.' Value: '.$datamap[$key]->new_value.'<br/>' );172 } 173 pw_utils::printDebug('<br />' );32 pw_utils::printDebug(' Mapping Function: '.$datamap[$key]->mappingfunction.'<br/>',2); 33 pw_utils::printDebug(' ' . $datamap[$key]->handle.' Value: '.$datamap[$key]->new_value.'<br/>', 1); 34 } 35 pw_utils::printDebug('<br />', 1); 174 36 } // end
