Ejemplo n.º 1
0
/**
 * Display the Rublon page
 * 
 */
function rublon2factor_render_settings_page()
{
    ?>
<div class="wrap">
	<div id="rublon2factor_page">
		<h2 class="rublon-header">
			<?php 
    _e('Rublon', 'rublon');
    ?>
		</h2>			
		
		<?php 
    $isProjectOwner = RublonHelper::isProjectOwner();
    $isAdministrator = current_user_can('manage_options');
    $title = $isProjectOwner ? __('Only your account is protected! Need Rublon for more accounts?', 'rublon') : __('Your account is not protected! Need Rublon for more accounts?', 'rublon');
    $text = $isProjectOwner ? __('You are currently using the Rublon Personal API, which limits protection to 1 account per website.', 'rublon') : __('Your website is currently using the Rublon Personal API, which limits protection to 1 account per website (the administrator who has installed and activated the plugin).', 'rublon');
    $text2 = $isProjectOwner ? __('If you\'d like to protect more accounts, you need to upgrade to the Rublon Business API.', 'rublon') : __('If you\'d like to protect your or more accounts, you need to upgrade to the Rublon Business API.', 'rublon');
    ?>
		<?php 
    if (!RublonFeature::isBusinessEdition()) {
        ?>
		
    		<?php 
        if ($isAdministrator) {
            ?>
                    
            <div class="updated rublon-be-infobox-container<?php 
            echo !$isProjectOwner ? ' rublon-warning' : '';
            ?>
">
    				
    			<div id="message" class="rublon-be-infobox-content">
    			    <div class="rublon-buy-now-subcontainer">
    			        <div class="rublon-buy-now-left">  				
            				
                    		<h3><?php 
            echo $title;
            ?>
</h3>
                    		
            				<p>
                    		  <?php 
            echo $text;
            ?>
                		                  		
                    		  <?php 
            echo $text2;
            ?>
                		  
                    		  <?php 
            echo __('You can easily order online.', 'rublon');
            ?>
                		  
                    		</p>
                    		<?php 
            if ($isAdministrator) {
                ?>
                		        		
                    		<p>
            					<a href="<?php 
                echo RublonHelper::getBuyBusinessEditionURL();
                ?>
" class="rublon-button-buy-now" target="_blank"><?php 
                echo __('Upgrade now', 'rublon');
                ?>
</a>
            				</p>        				
            				<p class="rublon-buy-now-tip">
                    		  <?php 
                echo __('After purchasing the upgrade, please click on the "Purge cache" button located in the bottom right corner of this page to activate your license.', 'rublon');
                ?>
                    		</p> 
                    		<?php 
            }
            ?>
 
                		</div>            			
    				</div>
    			</div>
    		</div>
            				
    		<?php 
        } else {
            ?>
    		
    		<div class="updated rublon-be-infobox rublon-warning">
    			<div id="message" class="rublon-be-infobox-content">
    			    <div class="rublon-buy-now-subcontainer">
    			        <div class="rublon-buy-now-left">                            
                    		<h3><?php 
            echo __('Your account is not protected!', 'rublon');
            ?>
</h3>                            
            				<p>
                    		  <?php 
            echo __('You have logged in successfully, but due the Personal Edition limitation your account isn\'t protected by Rublon and thus vulnerable to password theft and brute force attacks. Upgrade to the Business Edition needed (sales@rublon.com). Please contact your administrator.', 'rublon');
            ?>
                    		</p>                                		                        				
                		</div>                                  		
    				</div>
    			</div>
    		</div>
    		        
    	    <?php 
        }
        // isAdministrator
        ?>
    	    
	    <?php 
    }
    // isBusinessEdition
    ?>
		
		<?php 
    // necessary, otherwise "updated" messages won't be visible
    settings_errors();
    // Header text
    echo '<p>' . __('Rublon instantly protects all accounts with effortless, email-based two-factor authentication.', 'rublon') . ' ' . __('Get the optional mobile app for more security!', 'rublon') . ' ' . sprintf(__('Learn more at <a href="%s" target="_blank">wordpress.rublon.com</a>.', 'rublon'), RublonHelper::wordpressRublonComURL()) . '</p>';
    if (RublonHelper::isSiteRegistered()) {
        RublonHelper::printSocialSection();
        $current_user = wp_get_current_user();
        // No protection warning
        if (!RublonHelper::isUserProtected($current_user) && is_user_member_of_blog()) {
            printf('<span style="color: red; font-weight: bold;">' . __('Warning!', 'rublon') . '</span>' . ' ' . __('Your account is not protected. Go to <a href="%s">your profile page</a> to enable account protection.', 'rublon'), admin_url(RublonHelper::WP_PROFILE_PAGE . RublonHelper::WP_PROFILE_EMAIL2FA_SECTION));
        }
        // Rublon settings
        if (current_user_can('manage_options')) {
            // START_BLOCK: Is user authorized to manage plugins?
            ?>

				<form method="post" action="options.php"
			id="rublon-plugin-additional-settings">
				<?php 
            settings_fields('rublon2factor_additional_settings_group');
            do_settings_sections('rublon');
            // Cache purge button
            printf('<p style="float:right;"><a href="%s" class="button">%s</a></p>', esc_attr(admin_url(sprintf('admin.php?page=rublon&action=%s&nonce=%s', esc_attr(urlencode(RublonHelper::CACHE_PURGE_ACTION)), wp_create_nonce(RublonHelper::CACHE_PURGE_NONCE)))), __('Purge cache', 'rublon'));
            submit_button();
            echo '<script>//<![CDATA[
						document.addEventListener(\'DOMContentLoaded\', function() {
 							if (RublonWP) {
								RublonWP.setUpFormSubmitListener("rublon-plugin-additional-settings", "rublon-confirmation-form");
 							}
 							if (RublonSDK) {
 								RublonSDK.initConfirmationForms();
 							}
						}, false);
					//]]></script>';
            ?>
				</form>							
			<?php 
        }
        // END_BLOCK: Is user authorized to manage plugins?
    }
    ?>
	</div>
</div>
<?php 
}