oid = new WordpressOpenIDRegistration();
if( null === $this->oid ) {
error_log('WPOpenID plugin core is disabled -- Could not create WordpressOpenIDRegistration object. Ensure files are uploaded correctly.');
add_action('admin_notices', array( $wordpressOpenIDRegistrationUI, 'admin_notices_plugin_problem_warning' ));
return;
}
$this->oid->uptodate(); // Quick check for plugin OK state.
if( !$this->oid->enabled ) { // Something broke, can't start UI
error_log('WPOpenID plugin core is disabled -- Check Options -> OpenID tab for a full diagnositic report.');
add_action('admin_notices', array( $wordpressOpenIDRegistrationUI, 'admin_notices_plugin_problem_warning' ));
return;
}
// Kickstart
register_activation_hook( 'wpopenid/openid-registration.php', array( $wordpressOpenIDRegistrationUI->oid, 'late_bind' ) );
// Add hooks to handle actions in Wordpress
add_action( 'wp_authenticate', array( $wordpressOpenIDRegistrationUI->oid, 'wp_authenticate' ) ); // openid loop start
add_action( 'init', array( $wordpressOpenIDRegistrationUI->oid, 'finish_login' ) ); // openid loop done
// Start and finish the redirect loop, for the admin pages profile.php & users.php
add_action( 'init', array( $wordpressOpenIDRegistrationUI->oid, 'admin_page_handler' ) );
// Comment filtering
add_action( 'preprocess_comment', array( $wordpressOpenIDRegistrationUI->oid, 'openid_wp_comment_tagging' ), -99999 );
add_filter( 'option_require_name_email', array( $wordpressOpenIDRegistrationUI->oid, 'openid_bypass_option_require_name_email') );
add_filter( 'comment_notification_subject', array( $wordpressOpenIDRegistrationUI->oid, 'openid_comment_notification_subject'), 10, 2 );
add_filter( 'comment_notification_text', array( $wordpressOpenIDRegistrationUI->oid, 'openid_comment_notification_text'), 10, 2 );
add_action( 'delete_user', array( $wordpressOpenIDRegistrationUI->oid, 'drop_all_identities_for_user' ) ); // If user is dropped from database, remove their identities too.
if( get_option('oid_enable_commentform') ) {
add_filter( 'comments_template', array( $wordpressOpenIDRegistrationUI, 'setup_openid_wp_login_ob'));
add_filter( 'get_comment_author_link', array( $wordpressOpenIDRegistrationUI, 'openid_comment_author_link_prefx'));
}
if( get_option('oid_enable_loginform') ) {
add_action( 'login_form', array( $wordpressOpenIDRegistrationUI, 'login_form_v2_insert_fields'));
add_action( 'register_form', array( $wordpressOpenIDRegistrationUI, 'openid_wp_register_v2'));
add_filter( 'login_errors', array( $wordpressOpenIDRegistrationUI, 'login_form_v2_hide_username_password_errors'));
add_filter( 'register', array( $wordpressOpenIDRegistrationUI, 'openid_wp_sidebar_register' ));
}
add_filter( 'loginout', array( $wordpressOpenIDRegistrationUI, 'openid_wp_sidebar_loginout' ));
}
function login_form_v2_hide_username_password_errors($r) {
if( $_POST['openid_url']
or $_GET['action'] == 'loginopenid'
or $_GET['action'] == 'commentopenid' ) return $this->oid->error;
return $r;
}
function login_form_v2_insert_fields() {
global $wordpressOpenIDRegistrationUI;
$wordpressOpenIDRegistrationUI->__flag_use_Viper007Bond_login_form = true;
$style = get_option('oid_enable_selfstyle') ? ('style="background: #f4f4f4 url('.OPENIDIMAGE.') no-repeat;
background-position: 0 50%; padding-left: 18px;" ') : '';
?>
__flag_use_Viper007Bond_login_form ) return $form;
global $redirect_to;
$style = get_option('oid_enable_selfstyle') ? ('style="background: #f4f4f4 url('.OPENIDIMAGE.') no-repeat;
background-position: 0 50%; padding-left: 18px;" ') : '';
$newform = 'WordPress User
';
$form = preg_replace( '#';
$form = preg_replace( '##', $newform, $form, 1 );
return $form;
}
/* Hook. Add information about registration to wp-login.php?action=register */
function openid_wp_register_v2() {
?>For faster registration, just login with
OpenID!
has_cap('edit_posts') ) {
$link = preg_replace( '#Site Admin#', '' . __('Profile') . '', $link );
}
if( $current_user->ID ) {
$chunk ='Logged in as '
. ( is_user_openid()
? ('
') : '' )
. ( !empty($current_user->user_url)
? ('' . htmlentities( $current_user->display_name ) . '')
: htmlentities( $current_user->display_name ) ) . '';
} else {
$style = get_option('oid_enable_selfstyle') ? ('style="border: 1px solid #ccc; background: url('.OPENIDIMAGE.') no-repeat;
background-position: 0 50%; padding-left: 18px; " ') : '';
$chunk ='';
}
return $chunk . $link;
}
function openid_wp_sidebar_loginout( $link ) {
if( '' == $link ) return '';
if( strpos('redirect_to', $link )) return $link;
return str_replace( 'action=logout', 'action=logout' . ini_get('arg_separator.output') . 'redirect_to=' . urlencode($_SERVER["REQUEST_URI"]), $link );
}
// Add OpenID logo beside username for theme.
function openid_comment_author_link_prefx( $html ) {
global $comment_is_openid;
get_comment_type();
if( $comment_is_openid === true )
return '
' . $html;
return $html;
}
/*
* Hook. Add OpenID login-n-comment box above the comment form.
* Uses Output Buffering to rewrite the comment form html.
*/
function setup_openid_wp_login_ob($string) {
global $wordpressOpenIDRegistrationUI;
ob_start( array( $wordpressOpenIDRegistrationUI, "openid_wp_comment_form_ob" ) );
return $string;
}
function openid_wp_comment_form_ob( $html ) {
$block = array('address','blockquote','dsiv','dl','span',
'fieldset','h1','h2','h3','h4','h5','h6',
'p','ul','li', 'dd','dt');
global $user_ID, $user_identity;
if( $user_ID ) {
// Logged in already. Add the OpenID logo to the username?
if( is_user_openid() ) {
return preg_replace( '|(Logged in as (]*>)?)|', '\\1
' , $html );
}
return $html;
} elseif ( get_option('comment_registration') ) {
// Not logged in already, login is required to leave comments. Add the form.
$openid = '';
$html = preg_replace( '%<(' . implode('|', $block) . ')( [^>]*)?>'.
'You must be logged in to post a comment.\\1>%',
'\\0' . $openid, $html );
return $html;
}
if (get_option('oid_enable_unobtrusive') && get_option('oid_enable_selfstyle')) {
$newhtml = preg_replace( '|(.*.*)|', '\\1 (OpenID Enabled)\\3', $html );
return $newhtml;
} else {
// 1. Set aside everything outside the (.*)|ism', $html, $matches );
$form_pre = $matches[1];
$form_post = $matches[4];
$form_inner = $matches[2];
// 2. Working on the segment in
$work = $matches[3];
$matches = array();
$foundform = preg_match( '||', $html, $matches );
// 3. Find the segments, with block level containers.
$rinput = '(]*?name="([^"]+)"[^>]*?>)';
$rblock = '<(' . implode('|', $block) . ')( [^>]*)?>';
$rs = '(.*?)';
$rblockend = '\\1>(\s)+';
$r = '%' . $rblock . $rs . $rinput . $rs . $rblockend . '%ism';
$matches = array();
$num = preg_match_all( $r, $work, $matches, PREG_OFFSET_CAPTURE );
// 4. Set aside the standard anonymous fields
$fields = array( 'author','url','email' );
$chunks = array();
foreach( $matches[5] as $k=>$v ) {
if( in_array( strtolower($v[0]), $fields ) ) {
$chunks[] = array( 'line' => $matches[0][$k][0],
'startpos' => $matches[0][$k][1],
'starttag' => strtolower( $matches[1][$k][0] ),
'length' => strlen( $matches[0][$k][0] ) );
}
}
// 5. Grab starting position for re-insertion
$insert_point = $chunks[0]['startpos'];
$insert_tag = $chunks[0]['starttag'];
// 6. Create OpenID version of the Author line
$author = $chunks[0]['line'];
$author_name = trim(strip_tags($author));
$style = get_option('oid_enable_selfstyle') ? ('style="background: url('.OPENIDIMAGE.') no-repeat;
background-position: 0 50%; padding-left: 18px; " ') : '';
$openid = str_replace( array('name="author"', "$author_name"),
array( $style.'name="openid_url" class="commentform_openid"',
'Sign in with your OpenID ?'), $author );
if( preg_match( '/id="[^"]+"/', $openid )) {
$openid = preg_replace( '/id="[^"]+"/', 'id="commentform_openid"', $openid );
$openid = preg_replace( '/for="[^"]+"/', 'for="commentform_openid"', $openid );
} else {
$openid = preg_replace( '/name="/', 'id="commentform_openid" name="', $openid );
}
// 6. Remove the Anonymous chunks from the html source
$blocklength = 0;
$anonymous = '';
$chunks = array_reverse($chunks);
foreach( $chunks as $k=>$v ) {
$work = substr_replace( $work, '', $v['startpos'], $v['length'] );
$blocklength += $v['length'];
$anonymous = $v['line'] . $anonymous;
}
if( count( $chunks )) {
// 7. Custom template
switch ($insert_tag) {
case 'li':
$n = "OpenID
$openid\nAnonymous
$anonymous\n";
break;
default:
$n = "\n";
}
$work = substr_replace( $work, $n, $insert_point, 0 );
// 8. Reassemble
$final = "$form_pre$form_post";
return $final;
} else {
return $html;
}
}
}
/* Spam up the admin interface with warnings */
function admin_notices_plugin_problem_warning() {
?>The Wordpress OpenID plugin is not active.
Check OpenID Options for
a full diagnositic report.
oid->late_bind();
if( WORDPRESSOPENIDREGISTRATION_DEBUG ) error_log("WPOpenID Plugin: " . ($this->oid->enabled? 'Enabled':'Disabled' ) . ' (start of wordpress options page)' );
// if we're posted back an update, let's set the values here
if ( isset($_POST['info_update']) ) {
$trust = $_POST['oid_trust_root'];
if( $trust == null ) $trust = get_settings('siteurl');
$error = '';
if( $this->oid->openid_is_url($trust) ) {
update_option('oid_trust_root', $trust);
} else {
$error .= "".$trust." is not a url!";
}
update_option( 'oid_enable_selfstyle', isset($_POST['enable_selfstyle']) ? true : false );
update_option( 'oid_enable_loginform', isset($_POST['enable_loginform']) ? true : false );
update_option( 'oid_enable_commentform', isset($_POST['enable_commentform']) ? true : false );
update_option( 'oid_enable_unobtrusive', isset($_POST['enable_unobtrusive']) ? true : false );
if ($error !== '') {
echo 'At least one of Open ID options was NOT updated'.$error.'
';
} else {
echo '';
}
}
$relativeto = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
$paths = explode(PATH_SEPARATOR, get_include_path());
foreach( $paths as $path ) {
$fullpath = $path . DIRECTORY_SEPARATOR;
if( $path == '.' ) $fullpath = '';
if( substr( $path, 0, 1 ) !== '/' ) $fullpath = $relativeto . $fullpath;
$list_of_paths[] = $fullpath;
}
wordpressOpenIDRegistration_Status_Set( 'Include Path', 'info', implode('
', $list_of_paths ) );
global $wp_version;
wordpressOpenIDRegistration_Status_Set( 'WordPress version', 'info', $wp_version );
wordpressOpenIDRegistration_Status_Set( 'MySQL version', 'info', function_exists('mysql_get_client_info') ? mysql_get_client_info() : 'Mysql client information not available. Very strange, as Wordpress requires MySQL.' );
wordpressOpenIDRegistration_Status_Set( 'PHP version', 'info', phpversion() );
$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'] . '. ';
}
wordpressOpenIDRegistration_Status_Set( 'Curl version', function_exists('curl_version'), function_exists('curl_version') ? $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.');
/* Check for Long Integer math library */
wordpressOpenIDRegistration_Status_Set( 'library: GMP compiled into in PHP', ( extension_loaded('gmp') and @gmp_init(1) ), 'GMP does not appear to be built into PHP. This is highly recommended for performance reasons.' );
wordpressOpenIDRegistration_Status_Set( 'library: BCMath compiled into in PHP', ( extension_loaded('bcmath') and @bcadd(1,1)==2 ), 'BCMath does not appear to be built into PHP. GMP is preferred.' );
$loaded_long_integer_library = false;
if( function_exists('Auth_OpenID_detectMathLibrary') ) {
global $_Auth_OpenID_math_extensions;
$loaded_long_integer_library = Auth_OpenID_detectMathLibrary( $_Auth_OpenID_math_extensions );
wordpressOpenIDRegistration_Status_Set( 'Loaded long integer library', $loaded_long_integer_library==null?false:'info', $loaded_long_integer_library?$loaded_long_integer_library['extension']:'No long integer library is loaded! Key calculation will be very slow!' );
} else {
wordpressOpenIDRegistration_Status_Set( 'Loaded long integer library', false, 'The underlying OpenID library function Auth_OpenID_detectMathLibrary is not available. Install library first.' );
}
if( defined( 'Auth_OpenID_NO_MATH_SUPPORT' ) ) {
wordpressOpenIDRegistration_Status_Set( 'Loaded long integer library', false, 'The OpenID Library is operating Dumb Mode, since it doesn\'t have a big integer library. Recommend installing GMP support.' );
}
if( defined( 'Auth_OpenID_RAND_SOURCE' ) ) {
wordpressOpenIDRegistration_Status_Set( 'Cryptographic Randomness Source', (Auth_OpenID_RAND_SOURCE===null) ? false: 'info' ,
(Auth_OpenID_RAND_SOURCE===null)
? '/dev/urandom unavailable, using an insecure random number generator. open_basedir is "' . ini_get('open_basedir') . '"'
: Auth_OpenID_RAND_SOURCE );
}
/* Check for updates via SF RSS feed */
@include_once (ABSPATH . WPINC . '/rss.php');
@include_once (ABSPATH . WPINC . '/rss-functions.php');
$plugins = get_plugins();
$matches = array();
if( function_exists( 'fetch_simplepie' )) {
$rss = @fetch_simplepie('http://sourceforge.net/export/rss2_projfiles.php?group_id=167532');
if ( $rss and $rss->get_item_quantity() > 0 ) {
$items = $rss->get_items(0,0);
preg_match( '/wpopenid ([^ ]+) released/', $items[0]->get_title(), $matches );
}
} elseif ( function_exists( 'fetch_rss' )) {
$rss = @fetch_rss('http://sourceforge.net/export/rss2_projfiles.php?group_id=167532');
if( isset( $rss->items ) and 0 != count( $rss->items )) {
preg_match( '/wpopenid ([^ ]+) released/', $rss->items[0]['title'], $matches );
}
}
$vercmp_message = 'Running version ' . (int)WPOPENID_PLUGIN_VERSION . '. ';
if( $matches[1] ) {
$vercmp_message .= "Latest stable release is $matches[1]. ";
switch( version_compare( (int)WPOPENID_PLUGIN_VERSION, (int)$matches[1] ) ) {
case 1: $vercmp_message .= 'This revision is newer than the latest stable.'; break;
case 0: $vercmp_message .= 'Up to date.'; break;
case -1: $vercmp_message .= 'A new version of this plugin is available.'; break;
}
} else {
$vercmp_message .= 'Could not contact sourceforge for latest version information.';
}
wordpressOpenIDRegistration_Status_Set( 'Plugin version', 'info', $vercmp_message);
wordpressOpenIDRegistration_Status_Set( 'Plugin Database Version', 'info', 'Plugin database is currently at revision ' . get_option('oid_plugin_version') . '.' );
wordpressOpenIDRegistration_Status_Set( 'Overall Plugin Status', ($this->oid->enabled), 'There are problems above that must be dealt with before the plugin can be used.' );
?>
oid->enabled ) { // Display status information
?>Status information: All Systems Nominal
Plugin is currently disabled. Fix the problem, then Deactivate/Reactivate the plugin.
$v ) {
if( $v['state'] === false ) { echo "- [FAIL] $k
"; }
elseif( $v['state'] === true ) { echo "- [OK] $k
"; }
else { echo "- [INFO] $k
"; }
if( $v['state']!==true and $v['message'] ) echo '- ' . $v['message'] . '
';
}
?>
oid->enabled ) add_submenu_page('profile.php', 'Your OpenID Identities', 'Your OpenID Identities', 'read', 'your-openid-identities', array($this, 'profile_panel') );
}
function profile_panel() {
if( current_user_can('read') ) {
$this->oid->late_bind();
?>
oid->action ) { ?>
oid->error ) { ?>
OpenID Identities
The following OpenID Identity Urls? are tied to
this user account. You can login with equivalent permissions using any of the following identity urls.
oid->get_my_identities();
if( count($urls) ) {
?>
There are OpenID identities associated with this Wordpress user.
You can login with any of these urls, or your Wordpress username and password.
| ID | Identity Url | Action |
$v ) {
?>
|
| |
Delete |
There are no OpenID identity urls associated with this Wordpress user.
You can login with your Wordpress username and password.
tag with the OpenID logo
*/
if( !function_exists( 'get_comment_openid' ) ) {
function get_comment_openid() {
global $comment_is_openid;
get_comment_type();
if( $comment_is_openid === true ) echo '

';
}
}
/* is_comment_openid()
* If the current comment was submitted with OpenID, return true
* useful for
*/
if( !function_exists( 'is_comment_openid' ) ) {
function is_comment_openid() {
global $comment_is_openid;
get_comment_type();
return ( $comment_is_openid === true );
}
}
if( !function_exists( 'mask_comment_type' ) ) {
function mask_comment_type( $comment_type ) {
global $comment_is_openid;
if( $comment_type === 'openid' ) {
$comment_is_openid = true;
return 'comment';
}
$comment_is_openid = false;
return $comment_type;
}
add_filter('get_comment_type', 'mask_comment_type' );
}
if( !function_exists('is_user_openid') ) {
function is_user_openid() {
global $current_user;
return ( null !== $current_user && get_usermeta($current_user->ID, 'registered_with_openid') );
}
}
?>