Ejemplo n.º 1
0
        function options_page()
        {
            global $wp_version, $openid;
            WordPressOpenID_Logic::late_bind();
            if (isset($_REQUEST['action'])) {
                switch ($_REQUEST['action']) {
                    case 'rebuild_tables':
                        check_admin_referer('wp-openid-info_rebuild_tables');
                        $openid->store->destroy_tables();
                        $openid->store->create_tables();
                        echo '<div class="updated"><p><strong>' . __('OpenID tables rebuilt.', 'openid') . '</strong></p></div>';
                        break;
                }
            }
            // if we're posted back an update, let's set the values here
            if (isset($_POST['info_update'])) {
                check_admin_referer('wp-openid-info_update');
                $error = '';
                update_option('oid_enable_commentform', isset($_POST['enable_commentform']) ? true : false);
                update_option('oid_enable_approval', isset($_POST['enable_approval']) ? true : false);
                update_option('oid_enable_email_mapping', isset($_POST['enable_email_mapping']) ? true : false);
                if ($error !== '') {
                    echo '<div class="error"><p><strong>' . __('At least one of OpenID options was NOT updated', 'openid') . '</strong>' . $error . '</p></div>';
                } else {
                    echo '<div class="updated"><p><strong>' . __('Open ID options updated', 'openid') . '</strong></p></div>';
                }
            }
            // Display the options page form
            $siteurl = get_option('home');
            if (substr($siteurl, -1, 1) !== '/') {
                $siteurl .= '/';
            }
            ?>
			<div class="wrap">
				<h2><?php 
            _e('WP-OpenID Registration Options', 'openid');
            ?>
</h2>

				<?php 
            if ($wp_version >= '2.3') {
                WordPressOpenID_Interface::printSystemStatus();
            }
            ?>

				<form method="post">

					<?php 
            if ($wp_version < '2.3') {
                ?>
     				<p class="submit"><input type="submit" name="info_update" value="<?php 
                _e('Update Options');
                ?>
 &raquo;" /></p>
					<?php 
            }
            ?>

     				<table class="form-table optiontable editform" cellspacing="2" cellpadding="5" width="100%">
						<tr valign="top">
							<th style="width: 33%" scope="row"><?php 
            _e('Automatic Approval:', 'openid');
            ?>
</th>
							<td>
								<p><input type="checkbox" name="enable_approval" id="enable_approval" <?php 
            echo get_option('oid_enable_approval') ? 'checked="checked"' : '';
            ?>
 />
									<label for="enable_approval"><?php 
            _e('Enable OpenID comment auto-approval', 'openid');
            ?>
</label>

								<p><?php 
            _e('For now this option will cause comments made with OpenIDs ' . 'to be automatically approved.  Since most spammers haven\'t started ' . 'using OpenID yet, this is probably pretty safe.  More importantly ' . 'however, this could be a foundation on which to build more advanced ' . 'automatic approval such as whitelists or a third-party trust service.', 'openid');
            ?>
								</p>

								<p><?php 
            _e('Note that this option will cause OpenID authenticated comments ' . 'to appear, even if you have enabled the option, "An administrator must ' . 'always approve the comment".', 'openid');
            ?>
</p>
								
							</td>
						</tr>

						<tr valign="top">
							<th style="width: 33%" scope="row"><?php 
            _e('Comment Form:', 'openid');
            ?>
</th>
							<td>
								<p><input type="checkbox" name="enable_commentform" id="enable_commentform" <?php 
            if (get_option('oid_enable_commentform')) {
                echo 'checked="checked"';
            }
            ?>
 />
									<label for="enable_commentform"><?php 
            _e('Add OpenID text to the WordPress post comment form.', 'openid');
            ?>
</label></p>

								<p><?php 
            printf(__('This will work for most themes derived from Kubrick or Sandbox.  ' . 'Template authors can tweak the comment form as described in the %sreadme%s.', 'openid'), '<a href="' . get_option('siteurl') . '/' . PLUGINDIR . '/openid/readme.txt">', '</a>');
            ?>
</p>
								<br />
							</td>
						</tr>

						<?php 
            /*
            <tr valign="top">
            	<th style="width: 33%" scope="row"><?php _e('Email Mapping:', 'openid') ?></th>
            	<td>
            		<p><input type="checkbox" name="enable_email_mapping" id="enable_email_mapping" <?php
            		if( get_option('oid_enable_email_mapping') ) echo 'checked="checked"'
            		?> />
            			<label for="enable_email_mapping"><?php _e('Enable email addresses to be mapped to OpenID URLs.', 'openid') ?></label></p>
            
            		<p><?php printf(__('This feature uses the Email-To-URL mapping specification to allow OpenID authentication'
            		. ' based on an email address.  If enabled, commentors who do not supply a valid OpenID URL will have their'
            		. ' supplied email address mapped to an OpenID.  If their email provider does not currently support email to'
            		. ' url mapping, the default provider %s will be used.', 'openid'), '<a href="http://emailtoid.net/" target="_blank">Emailtoid.net</a>') ?></p>
            		<br />
            	</td>
            </tr>
            */
            ?>

     				</table>

					<p><?php 
            printf(__('Occasionally, the WP-OpenID tables don\'t get setup properly, and it may help ' . 'to %srebuild the tables%s.  Don\'t worry, this won\'t cause you to lose any data... it just ' . 'rebuilds a couple of tables that hold only temporary data.', 'openid'), '<a href="' . wp_nonce_url(sprintf('?page=%s&action=rebuild_tables', $_REQUEST['page']), 'wp-openid-info_rebuild_tables') . '">', '</a>');
            ?>
</p>

					<?php 
            wp_nonce_field('wp-openid-info_update');
            ?>
     				<p class="submit"><input type="submit" name="info_update" value="<?php 
            _e('Update Options');
            ?>
 &raquo;" /></p>
     			</form>

			</div>
    			<?php 
            if ($wp_version < '2.3') {
                echo '<br />';
                WordPressOpenID_Interface::printSystemStatus();
            }
        }
Ejemplo n.º 2
0
 /**
  * Action method for completing the 'comment' action.  This action is used when leaving a comment.
  *
  * @param string $identity_url verified OpenID URL
  */
 function _finish_openid_comment($identity_url)
 {
     global $openid;
     if (empty($identity_url)) {
         // FIXME unable to authenticate OpenID - give option to post anonymously
         WordPressOpenID_Interface::display_error('unable to authenticate OpenID');
     }
     WordPressOpenID_Logic::set_current_user($identity_url);
     if (is_user_logged_in()) {
         // simulate an authenticated comment submission
         $_SESSION['oid_comment_post']['author'] = null;
         $_SESSION['oid_comment_post']['email'] = null;
         $_SESSION['oid_comment_post']['url'] = null;
     } else {
         // try to get user data from the verified OpenID
         $user_data =& WordPressOpenID_Logic::get_user_data($identity_url);
         if (!empty($user_data['display_name'])) {
             $_SESSION['oid_comment_post']['author'] = $user_data['display_name'];
         }
         if ($oid_user_data['user_email']) {
             $_SESSION['oid_comment_post']['email'] = $user_data['user_email'];
         }
     }
     // record that we're about to post an OpenID authenticated comment.
     // We can't actually record it in the database until after the repost below.
     $_SESSION['oid_posted_comment'] = true;
     $wpp = parse_url(get_option('siteurl'));
     WordPressOpenID_Interface::repost($wpp['path'] . '/wp-comments-post.php', array_filter($_SESSION['oid_comment_post']));
 }
Ejemplo n.º 3
0
 /**
  * Intercept comment submission and check if it includes a valid OpenID.  If it does, save the entire POST
  * array and begin the OpenID authentication process.
  *
  * regarding comment_type: http://trac.wordpress.org/ticket/2659
  *
  * @param object $comment comment object
  * @return object comment object
  */
 function comment_tagging($comment)
 {
     global $openid;
     if ($_REQUEST['oid_skip']) {
         return $comment;
     }
     $openid_url = array_key_exists('openid_url', $_POST) ? $_POST['openid_url'] : $_POST['url'];
     if (!empty($openid_url)) {
         // Comment form's OpenID url is filled in.
         $_SESSION['oid_comment_post'] = $_POST;
         $_SESSION['oid_comment_post']['comment_author_openid'] = $openid_url;
         $_SESSION['oid_comment_post']['oid_skip'] = 1;
         WordPressOpenID_Logic::start_login($openid_url, 'comment');
         // Failure to redirect at all, the URL is malformed or unreachable.
         // Display an error message only if an explicit OpenID field was used.  Otherwise,
         // just ignore the error... it just means the user entered a normal URL.
         if (array_key_exists('openid_url', $_POST)) {
             WordPressOpenID_Interface::repost_comment_anonymously($_SESSION['oid_comment_post']);
         }
     }
     /*
     if (get_option('oid_enable_email_mapping') && !empty($_POST['email'])) {
     	$_SESSION['oid_comment_post'] = $_POST;
     	$_SESSION['oid_comment_post']['comment_author_openid'] = $openid_url;
     	$_SESSION['oid_comment_post']['oid_skip'] = 1;
     
     	set_include_path( dirname(__FILE__) . PATH_SEPARATOR . get_include_path() );
     	require_once 'Auth/Yadis/Email.php';
     	$id = Auth_Yadis_Email_getID($_POST['email'], trailingslashit(get_option('home')));
     	WordPressOpenID_Logic::start_login( $id, 'comment');
     }
     */
     return $comment;
 }