'.__('The WordPress OpenID plugin is not active.', 'openid').''; printf(_('Check %sOpenID Options%s for a full diagnositic report.', 'openid'), '', ''); echo '

'; } /** * Setup admin menus for OpenID options and ID management. * * @action: admin_menu **/ function openid_admin_panels() { // global options page $hookname = add_options_page(__('OpenID options', 'openid'), __('OpenID', 'openid'), 8, 'global-openid-options', 'openid_options_page' ); add_action("load-$hookname", 'openid_js_setup' ); add_action("admin_head-$hookname", 'openid_style' ); // all users can setup external OpenIDs $hookname = add_users_page(__('Your OpenIDs', 'openid'), __('Your OpenIDs', 'openid'), 'read', 'your_openids', 'openid_profile_panel' ); add_action("admin_head-$hookname", 'openid_style' ); add_action("load-$hookname", create_function('', 'wp_enqueue_script("admin-forms");')); add_action("load-$hookname", 'openid_profile_management' ); // additional options for users authorized to use OpenID provider $user = wp_get_current_user(); if ($user->has_cap('use_openid_provider')) { add_action('show_user_profile', 'openid_extend_profile', 5); add_action('profile_update', 'openid_profile_update'); add_action('admin_head-profile.php', 'openid_style'); if (!get_usermeta($user->ID, 'openid_delegate')) { $hookname = add_submenu_page('profile.php', __('Your Trusted Sites', 'openid'), __('Your Trusted Sites', 'openid'), 'read', 'openid_trusted_sites', 'openid_manage_trusted_sites' ); add_action("admin_head-$hookname", 'openid_style' ); add_action("load-$hookname", create_function('', 'wp_enqueue_script("admin-forms");')); } } } /* * Display and handle updates from the Admin screen options page. * * @options_page */ function openid_options_page() { global $wp_version, $wpdb, $wp_roles; if ( isset($_REQUEST['action']) ) { switch($_REQUEST['action']) { case 'rebuild_tables' : check_admin_referer('openid-rebuild_tables'); $store = openid_getStore(); $store->reset(); echo '

'.__('OpenID cache refreshed.', 'openid').'

'; break; } } // if we're posted back an update, let's set the values here if ( isset($_POST['info_update']) ) { check_admin_referer('openid-info_update'); $error = ''; update_option( 'openid_enable_commentform', isset($_POST['enable_commentform']) ? true : false ); update_option( 'openid_enable_approval', isset($_POST['enable_approval']) ? true : false ); update_option( 'openid_enable_email_mapping', isset($_POST['enable_email_mapping']) ? true : false ); update_option( 'openid_required_for_registration', isset($_POST['openid_required_for_registration']) ? true : false ); update_option( 'openid_blog_owner', $_POST['openid_blog_owner']); // set OpenID Capability foreach ($wp_roles->role_names as $key => $name) { $role = $wp_roles->get_role($key); $option_set = $_POST['openid_cap_' . htmlentities($key)] == 'on' ? true : false; if ($role->has_cap('use_openid_provider')) { if (!$option_set) $role->remove_cap('use_openid_provider'); } else { if ($option_set) $role->add_cap('use_openid_provider'); } } if ($error !== '') { echo '

'.__('At least one of OpenID options was NOT updated', 'openid').''.$error.'

'; } else { echo '

'.__('OpenID options updated', 'openid').'

'; } } // Display the options page form $siteurl = get_option('home'); if( substr( $siteurl, -1, 1 ) !== '/' ) $siteurl .= '/'; ?>

*/ ?>

/>

/>

', '') ?>


/>

/>

Emailtoid.net') ?>


', ''); ?>


ID); ?>

user_id); return $u->has_cap("use_openid_provider");')); if (!empty($users)): ?>

role_names as $key => $name) { $role = $wp_roles->get_role($key); $checked = $role->has_cap('use_openid_provider') ? ' checked="checked"' : ''; $option_name = 'openid_cap_' . htmlentities($key); echo '
' . "\n"; } ?>

%1$s) as an OpenID. ' . 'The Blog Owner will be able to use the blog address (%2$s) as their OpenID. If this is a ' . 'single-user blog, you should set this to your account.', 'openid'), sprintf('%1$s', $current_user_url), sprintf('%1$s', trailingslashit(get_option('home'))) ); ?>

' . __('A Blog Owner cannot be set for this blog. To set a Blog Owner, ' . 'first remove the following line from your wp-config.php:', 'openid') . '
define("OPENID_DISALLOW_OWNER", 1);

'; } else { $blog_owner = get_option('openid_blog_owner'); if (empty($blog_owner) || $blog_owner == $current_user->user_login) { echo ''; } else { echo '

' . sprintf(__('Only the current Blog Owner (%s) can change this setting.', 'openid'), $blog_owner) . '

'; } } ?>

'.__('Success:', 'openid').' '.openid_message().'

'; } elseif( 'warning' == $status ) { echo '

'.__('Warning:', 'openid').' '.openid_message().'

'; } elseif( 'error' == $status ) { echo '

'.__('Error:', 'openid').' '.openid_message().'

'; } if (!empty($error)) { echo '

'.__('Error:', 'openid').' '.$error.'

'; unset($error); } ?>

Learn more...', 'openid')?>


ID); if (empty($urls)) { echo ''; } else { foreach ($urls as $url) { echo ' '; } } ?>
'.__('No Verified Accounts.', 'openid').'
'.openid_display_identity($url).'

ID, 'openid_trusted_sites'); $sites = split("\n", $_REQUEST['sites']); $count = 0; foreach ($sites as $site) { $site = trim($site); if (empty($site)) continue; if (strpos($site, 'http') === false || strpos($sites, 'http') != 0) { $site = 'http://' . $site; } $site = clean_url($site); $site_hash = md5($site); if (array_key_exists($site_hash, $trusted_sites)) continue; $count++; $trusted_sites[$site_hash] = array('url' => $site); } if ($count) { update_usermeta($user->ID, 'openid_trusted_sites', $trusted_sites); echo '

' . __('Added '.$count.' trusted site' . ($count>1 ? 's' : '') . '.').'

'; } break; case 'delete': if (empty($_REQUEST['delete'])) break; check_admin_referer('openid-delete_trusted_sites'); $trusted_sites = get_usermeta($user->ID, 'openid_trusted_sites'); $count = 0; foreach ($_REQUEST['delete'] as $site_hash) { if (array_key_exists($site_hash, $trusted_sites)) { $trusted_sites[$site_hash] = null; $count++; } } update_usermeta($user->ID, 'openid_trusted_sites', array_filter($trusted_sites)); if ($count) { echo '

'.__('Deleted '.$count.' trusted site' . ($count>1 ? 's' : '') . '.').'

'; } break; } ?>


ID, 'openid_trusted_sites'); if(empty($trusted_sites)) { echo ''; } else { foreach( $trusted_sites as $site_hash => $site ) { if ($site['last_login']) { $last_login = date(get_option('date_format') . ' - ' . get_option('time_format'), $site['last_login']); } else { $last_login = '-'; } echo ' '; } } ?>
URL Last Login
'.__('No Trusted Sites.', 'openid').'
'.$site['url'].' '.$last_login.'


Enter a list of URLs to be added to your Trusted Sites.


(One URL per line)

base_prefix) ? $wpdb->base_prefix : $wpdb->prefix ); if ( extension_loaded('suhosin') ) { $status[] = array( 'Curl', false, 'Hardened php (suhosin) extension active -- curl version checking skipped.' ); } else { $curl_message = ''; if( function_exists('curl_version') ) { $curl_version = curl_version(); if(isset($curl_version['version'])) $curl_message .= 'Version ' . $curl_version['version'] . '. '; if(isset($curl_version['ssl_version'])) $curl_message .= 'SSL: ' . $curl_version['ssl_version'] . '. '; if(isset($curl_message['libz_version'])) $curl_message .= 'zlib: ' . $curl_version['libz_version'] . '. '; if(isset($curl_version['protocols'])) { if (is_array($curl_version['protocols'])) { $curl_message .= 'Supports: ' . implode(', ',$curl_version['protocols']) . '. '; } else { $curl_message .= 'Supports: ' . $curl_version['protocols'] . '. '; } } } else { $curl_message = 'This PHP installation does not have support for libcurl. Some functionality, such as ' . 'fetching https:// URLs, will be missing and performance will slightly impared. See ' . 'php.net/manual/en/ref.curl.php about ' . 'enabling libcurl support for PHP.'; } $status[] = array( 'Curl Support', isset($curl_version), $curl_message ); } if (extension_loaded('gmp') and @gmp_init(1)) { $status[] = array( 'Big Integer support', true, 'GMP is installed.' ); } elseif (extension_loaded('bcmath') and @bcadd(1,1)==2) { $status[] = array( 'Big Integer support', true, 'BCMath is installed (though GMP is preferred).' ); } elseif (defined('Auth_OpenID_NO_MATH_SUPPORT')) { $status[] = array( 'Big Integer support', false, 'The OpenID Library is operating in Dumb Mode. Recommend installing GMP support.' ); } $status[] = array( 'Plugin Revision', 'info', OPENID_PLUGIN_REVISION); $status[] = array( 'Plugin Database Revision', 'info', get_option('openid_db_revision')); if (function_exists('xrds_meta')) { $status[] = array( 'XRDS-Simple', 'info', 'XRDS-Simple plugin is installed.'); } else { $status[] = array( 'XRDS-Simple', false, 'XRDS-Simple plugin is not installed. Some features may not work properly (including providing OpenIDs).'); } $openid_enabled = openid_enabled(); $status[] = array( 'Overall Plugin Status', ($openid_enabled), ($openid_enabled ? '' : 'There are problems above that must be dealt with before the plugin can be used.') ); if( $openid_enabled ) { // Display status information echo'

' . __('Status information:', 'openid') . ' ' . __('All Systems Nominal', 'openid') . ' (' . __('Toggle More/Less', 'openid') . ')

'; } else { echo '

' . __('Plugin is currently disabled. Fix the problem, then Deactivate/Reactivate the plugin.', 'openid') . '

'; } echo '
'; foreach( $status as $s ) { list ($name, $state, $message) = $s; echo '
'; if( $state === false ) { echo "[".__('FAIL', 'openid')."] $name"; } elseif( $state === true ) { echo "[".__('OK', 'openid')."] $name"; } else { echo "[".__('INFO', 'openid')."] $name"; } echo ($message ? ': ' : '') . ''; echo (is_array($message) ? '
  • ' . implode('
  • ', $message) . '
' : $message); echo '
'; } echo '
'; } /** * Handle OpenID profile management. */ function openid_profile_management() { global $wp_version; if( !isset( $_REQUEST['action'] )) return; switch( $_REQUEST['action'] ) { case 'verify': finish_openid($_REQUEST['action']); break; case 'add': check_admin_referer('openid-add_openid'); $user = wp_get_current_user(); $auth_request = openid_begin_consumer($_POST['openid_identifier']); $userid = get_user_by_openid($auth_request->endpoint->claimed_id); if ($userid) { global $error; if ($user->ID == $userid) { $error = __('You already have this OpenID!', 'openid'); } else { $error = __('This OpenID is already associated with another user.', 'openid'); } return; } $return_to = admin_url(current_user_can('edit_users') ? 'users.php' : 'profile.php'); openid_start_login($_POST['openid_identifier'], 'verify', array('page' => $_REQUEST['page']), $return_to); break; case 'delete': openid_profile_delete_openids($_REQUEST['delete']); break; } } /** * Remove identity URL from current user account. * * @param int $id id of identity URL to remove */ function openid_profile_delete_openids($delete) { if (empty($delete) || $_REQUEST['cancel']) return; check_admin_referer('openid-delete_openids'); $user = wp_get_current_user(); $urls = get_user_openids($user->ID); if (sizeof($urls) == sizeof($delete) && !$_REQUEST['confirm']) { $html = '

'.__('OpenID Warning', 'openid').'

'.__('Are you sure you want to delete all of your OpenID associations? Doing so may prevent you from logging in.', 'openid').'

'; foreach ($delete as $d) { $html .= ''; } $html .= wp_nonce_field('openid-delete_openids', '_wpnonce', true, false) . '
'; openid_page($html, __('OpenID Warning', 'openid')); return; } $count = 0; foreach ($urls as $url) { if (in_array(md5($url), $_REQUEST['delete'])) { if (openid_drop_identity($user->ID, $url)) { $count++; } } } if ($count) { openid_message(sprintf(__('Deleted %1$s OpenID association%2$s.', 'openid'), $count, ($count>1 ? 's' : ''))); openid_status('success'); // ensure that profile URL is still a verified OpenID set_include_path( dirname(__FILE__) . PATH_SEPARATOR . get_include_path() ); require_once 'Auth/OpenID.php'; @include_once(ABSPATH . WPINC . '/registration.php'); // WP < 2.3 @include_once(ABSPATH . 'wp-admin/includes/admin.php'); // WP >= 2.3 if (!openid_ensure_url_match($user)) { $identities = get_user_openids($user->ID); wp_update_user( array('ID' => $user->ID, 'user_url' => $identities[0]) ); openid_message(openid_message() . '
'.__('Note: For security reasons, your profile URL has been updated to match your OpenID.', 'openid')); } return; } openid_message(__('OpenID association delete failed: Unknown reason.', 'openid')); openid_status('error'); } /** * Action method for completing the 'verify' action. This action is used adding an identity URL to a * WordPress user through the admin interface. * * @param string $identity_url verified OpenID URL */ function openid_finish_verify($identity_url) { if ($_REQUEST['action'] != 'verify') return; $user = wp_get_current_user(); if (empty($identity_url)) { $message = openid_message(); if (empty($message)) openid_message('Unable to authenticate OpenID.'); } else { if( !openid_add_identity($user->ID, $identity_url) ) { openid_message(__('OpenID assertion successful, but this URL is already associated with ' . 'another user on this blog. This is probably a bug.', 'openid')); } else { openid_message(sprintf(__('Added association with OpenID: %s', 'openid'), openid_display_identity($identity_url) )); openid_status('success'); // ensure that profile URL is a verified OpenID set_include_path( dirname(__FILE__) . PATH_SEPARATOR . get_include_path() ); require_once 'Auth/OpenID.php'; if ($GLOBALS['wp_version'] >= '2.3') { require_once(ABSPATH . 'wp-admin/includes/admin.php'); } else { require_once(ABSPATH . WPINC . '/registration.php'); } if (!openid_ensure_url_match($user)) { wp_update_user( array('ID' => $user->ID, 'user_url' => $identity_url) ); openid_message(openid_message() . '
'.__('Note: For security reasons, your profile URL has been updated to match your OpenID.', 'openid')); } } } return; } /** * Prior to WordPress 2.5, the 'personal_options_update' hook was called * AFTER updating the user's profile. We need to ensure the profile URL * matches before then. */ function openid_compat_pre_user_url($url) { if ($_POST['from'] == 'profile') { openid_personal_options_update(); } return $url; } /** * hook in and call when user is updating their profile URL... make sure it is an OpenID they control. */ function openid_personal_options_update() { $user = wp_get_current_user(); if (!openid_ensure_url_match($user, $_POST['url'])) { wp_die(sprintf(__('For security reasons, your profile URL must be one of your claimed OpenIDs: %s'), '')); } } /** * Ensure that the user's profile URL matches one of their OpenIDs */ function openid_ensure_url_match($user, $url = null) { $identities = get_user_openids($user->ID); if (empty($identities)) return true; set_include_path( dirname(__FILE__) . PATH_SEPARATOR . get_include_path() ); require_once 'Auth/OpenID.php'; if ($url == null) $url = $user->user_url; $url = Auth_OpenID::normalizeUrl($url); foreach ($identities as $id) { if ($id == $url) return true; } return false; } function openid_admin_return_url($urls) { $urls[] = admin_url('users.php'); $urls[] = admin_url('profile.php'); return $urls; } function openid_extend_profile() { $user = wp_get_current_user(); echo '

'.__('OpenID Delegation allows you to use an external OpenID provider of your choice.', 'openid').'

To delegate, enter a valid OpenID. Otherwise leave this blank.

'; } function openid_profile_update($user_id) { if (empty($_POST['openid_delegate'])) { delete_usermeta($user_id, 'openid_delegate'); } else { $old_delegate = get_usermeta($user_id, 'openid_delegate'); $delegate = Auth_OpenID::normalizeUrl($_POST['openid_delegate']); if(openid_server_update_delegation_info($user_id, $delegate)) { openid_message(sprintf(__('Gathered OpenID information for delegate URL %s', 'openid'), ''.$delegate.'')); openid_status('success'); } else { openid_message(sprintf(__('Unable to find any OpenID information for delegate URL %s', 'openid'), ''.$delegate.'')); openid_status('error'); } } } ?>