| 1 |
<?php |
| 2 |
if(!function_exists('wppb_curpageurl')){ |
| 3 |
function wppb_curpageurl() { |
| 4 |
$pageURL = 'http'; |
| 5 |
if ((isset($_SERVER["HTTPS"])) && ($_SERVER["HTTPS"] == "on")) { |
| 6 |
$pageURL .= "s"; |
| 7 |
} |
| 8 |
$pageURL .= "://"; |
| 9 |
if ($_SERVER["SERVER_PORT"] != "80") { |
| 10 |
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; |
| 11 |
} else { |
| 12 |
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; |
| 13 |
} |
| 14 |
return $pageURL; |
| 15 |
} |
| 16 |
} |
| 17 |
|
| 18 |
/* wp_signon can only be executed before anything is outputed in the page because of that we're adding it to the init hook */ |
| 19 |
global $wppb_login; |
| 20 |
$wppb_login = false; |
| 21 |
|
| 22 |
function wppb_signon(){ |
| 23 |
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'log-in' && wp_verify_nonce($_POST['login_nonce_field'],'verify_true_login')) : |
| 24 |
global $error; |
| 25 |
global $wppb_login; |
| 26 |
|
| 27 |
if (isset($_POST['remember-me'])) |
| 28 |
$remember = $_POST['remember-me']; |
| 29 |
else $remember = false; |
| 30 |
$wppb_login = wp_signon( array( 'user_login' => $_POST['user-name'], 'user_password' => $_POST['password'], 'remember' => $_POST['remember-me'] ), false ); |
| 31 |
endif; |
| 32 |
} |
| 33 |
add_action('init', 'wppb_signon'); |
| 34 |
|
| 35 |
function wppb_front_end_login(){ |
| 36 |
$loginFilterArray = array(); |
| 37 |
ob_start(); |
| 38 |
global $wppb_login; |
| 39 |
|
| 40 |
echo '<div class="wppb_holder" id="wppb_login">'; |
| 41 |
|
| 42 |
if ( is_user_logged_in() ) : // Already logged in |
| 43 |
global $user_ID; |
| 44 |
$wppb_user = get_userdata( $user_ID ); |
| 45 |
if($wppb_user->display_name == ''){ |
| 46 |
$wppb_user->display_name = $wppb_user->user_login; |
| 47 |
} |
| 48 |
|
| 49 |
?> |
| 50 |
<?php |
| 51 |
$loginFilterArray['loginMessage1'] = ' |
| 52 |
<p class="alert">'. |
| 53 |
__('You are currently logged in as', 'profilebuilder').' <a href="'.$authorPostsUrl = get_author_posts_url( $wppb_user->ID ).'" title="'.$wppb_user->display_name.'">'.$wppb_user->display_name.'</a>. |
| 54 |
<a href="'.wp_logout_url( get_permalink() ).'" title="'. __('Log out of this account', 'profilebuilder').'">'. __('Log out', 'profilebuilder').' »</a> |
| 55 |
</p><!-- .alert-->'; |
| 56 |
|
| 57 |
$loginFilterArray['loginMessage1'] = apply_filters('wppb_login_login_message1', $loginFilterArray['loginMessage1']); |
| 58 |
echo $loginFilterArray['loginMessage1']; |
| 59 |
?> |
| 60 |
|
| 61 |
<?php elseif ( $wppb_login->ID ) : // Successful login ?> |
| 62 |
<?php |
| 63 |
//$wppb_login = get_userdata( $wppb_login->ID ); |
| 64 |
if($wppb_login->display_name == ''){ |
| 65 |
$wppb_login->display_name = $wppb_login->user_login; |
| 66 |
} |
| 67 |
|
| 68 |
?> |
| 69 |
|
| 70 |
<?php |
| 71 |
$loginFilterArray['loginMessage2'] = ' |
| 72 |
<p class="success">'. |
| 73 |
__('You have successfully logged in as', 'profilebuilder').' <a href="'.$authorPostsUrl = get_author_posts_url( $wppb_login->ID ).'" title="'.$wppb_login->display_name.'">'.$wppb_login->display_name.'</a>. |
| 74 |
</p><!-- .success-->'; |
| 75 |
|
| 76 |
$loginFilterArray['loginMessage2'] = apply_filters('wppb_login_login_message2', $loginFilterArray['loginMessage2']); |
| 77 |
echo $loginFilterArray['loginMessage2']; |
| 78 |
?> |
| 79 |
|
| 80 |
|
| 81 |
<?php |
| 82 |
$permaLnk2 = get_permalink(); |
| 83 |
$wppb_addons = wppb_plugin_dir . '/premium/addon/'; |
| 84 |
if (file_exists ( $wppb_addons.'addon.php' )){ |
| 85 |
//check to see if the redirecting addon is present and activated |
| 86 |
$wppb_premium_addon_settings = get_option('wppb_premium_addon_settings'); //fetch the descriptions array |
| 87 |
if ($wppb_premium_addon_settings['customRedirect'] == 'show'){ |
| 88 |
//check to see if the redirect location is not an empty string and is activated |
| 89 |
$customRedirectSettings = get_option('customRedirectSettings'); |
| 90 |
if ((trim($customRedirectSettings['afterLoginTarget']) != '') && ($customRedirectSettings['afterLogin'] == 'yes')){ |
| 91 |
$permaLnk2 = trim($customRedirectSettings['afterLoginTarget']); |
| 92 |
$findHttp = strpos($permaLnk2, 'http'); |
| 93 |
if ($findHttp === false) |
| 94 |
$permaLnk2 = 'http://'. $permaLnk2; |
| 95 |
} |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
$loginFilterArray['redirectMessage'] = ' |
| 100 |
<font color="black">'. __('You will soon be redirected automatically. If you see this page for more than 1 second, please click', 'profilebuilder').' <a href="'.$permaLnk2.'">'. __('here', 'profilebuilder').'</a>.<meta http-equiv="Refresh" content="1;url='.$permaLnk2.'" /></font><br/><br/>'; |
| 101 |
$loginFilterArray['redirectMessage'] = apply_filters('wppb_login_redirect_message', $loginFilterArray['redirectMessage']); |
| 102 |
echo $loginFilterArray['redirectMessage']; |
| 103 |
?> |
| 104 |
<?php else : // Not logged in ?> |
| 105 |
|
| 106 |
<?php if (!empty( $_POST['action'] )): ?> |
| 107 |
<p class="error"> |
| 108 |
<?php if ( trim($_POST['user-name']) == '') echo '<strong>'. __('ERROR:','profilebuilder').'</strong> '. __('The username field is empty', 'profilebuilder').'. '; ?> |
| 109 |
<?php if ( is_wp_error($wppb_login) ) echo $wppb_login->get_error_message();?> |
| 110 |
</p><!-- .error --> |
| 111 |
<?php endif; ?> |
| 112 |
|
| 113 |
<?php /* use this action hook to add extra content before the login form. */ ?> |
| 114 |
<?php do_action( 'wppb_before_login' ); ?> |
| 115 |
|
| 116 |
<form action="<?php wppb_curpageurl(); ?>" method="post" class="sign-in"> |
| 117 |
<p class="login-form-username"> |
| 118 |
<label for="user-name"><?php _e('Username', 'profilebuilder'); ?></label> |
| 119 |
<?php |
| 120 |
if (isset($_POST['user-name'])) |
| 121 |
$userName = esc_html( $_POST['user-name'] ); |
| 122 |
else $userName = ''; |
| 123 |
?> |
| 124 |
<?php echo '<input type="text" name="user-name" id="user-name" class="text-input" value="'.$userName.'" />'; ?> |
| 125 |
</p><!-- .form-username --> |
| 126 |
|
| 127 |
<p class="login-form-password"> |
| 128 |
<label for="password"><?php _e('Password', 'profilebuilder'); ?></label> |
| 129 |
<input type="password" name="password" id="password" class="text-input" /> |
| 130 |
</p><!-- .form-password --> |
| 131 |
<p class="login-form-submit"> |
| 132 |
<input type="submit" name="submit" class="submit button" value="<?php _e('Log in', 'profilebuilder'); ?>" /> |
| 133 |
<?php |
| 134 |
$loginFilterArray['rememberMe'] = ' |
| 135 |
<input class="remember-me checkbox" name="remember-me" id="remember-me" type="checkbox" checked="checked" value="forever" /> |
| 136 |
<label for="remember-me">'. __('Remember me', 'profilebuilder').'</label>'; |
| 137 |
$loginFilterArray['rememberMe'] = apply_filters('wppb_login_remember_me', $loginFilterArray['rememberMe']); |
| 138 |
echo $loginFilterArray['rememberMe']; |
| 139 |
?> |
| 140 |
|
| 141 |
<input type="hidden" name="action" value="log-in" /> |
| 142 |
</p><!-- .form-submit --> |
| 143 |
<?php |
| 144 |
$loginFilterArray['loginURL'] = ' |
| 145 |
<p> |
| 146 |
<a href="'.$siteURL=get_option('siteurl').'/wp-login.php?action=lostpassword">'. __('Lost password?', 'profilebuilder').'</a> |
| 147 |
</p>'; |
| 148 |
$loginFilterArray['loginURL'] = apply_filters('wppb_login_url', $loginFilterArray['loginURL']); |
| 149 |
echo $loginFilterArray['loginURL']; |
| 150 |
?> |
| 151 |
<?php wp_nonce_field('verify_true_login','login_nonce_field'); ?> |
| 152 |
</form><!-- .sign-in --> |
| 153 |
|
| 154 |
<?php endif;?> |
| 155 |
|
| 156 |
<?php /* use this action hook to add extra content after the login form. */ ?> |
| 157 |
<?php do_action( 'wppb_after_login' ); ?> |
| 158 |
|
| 159 |
</div> |
| 160 |
<?php |
| 161 |
$output = ob_get_contents(); |
| 162 |
ob_end_clean(); |
| 163 |
|
| 164 |
$loginFilterArray = apply_filters('wppb_login', $loginFilterArray); |
| 165 |
|
| 166 |
return $output; |
| 167 |
} |