Changeset 541069
- Timestamp:
- 05/07/2012 08:10:46 PM (13 years ago)
- Location:
- login-with-ajax/trunk
- Files:
-
- 3 edited
-
login-with-ajax-admin.php (modified) (1 diff)
-
login-with-ajax.php (modified) (30 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
login-with-ajax/trunk/login-with-ajax-admin.php
r361572 r541069 119 119 <h3 class="hndle">Plugin Information</h3> 120 120 <div class="inside"> 121 <p>This plugin was developed by <a href="http:// twitter.com/marcussykes">Marcus Sykes</a> @ <a href="http://netweblogic.com">NetWebLogic</a></p>122 <p>Please visit <a href="http:// netweblogic.com/forums/">ourforum</a> for plugin support.</p>121 <p>This plugin was developed by <a href="http://msyk.es">Marcus Sykes</a> @ <a href="http://netweblogic.com">NetWebLogic</a></p> 122 <p>Please visit <a href="http://wordpress.org/tags/login-with-ajax?forum_id=10">the WordPress forum</a> for plugin support.</p> 123 123 <p>If you'd like to translate this plugin, the language files are in the langs folder. Please email any translations to wp.plugins@netweblogic.com and we'll incorporate it into the plugin.</p> 124 124 </div> -
login-with-ajax/trunk/login-with-ajax.php
r404884 r541069 3 3 Plugin Name: Login With Ajax 4 4 Plugin URI: http://netweblogic.com/wordpress/plugins/login-with-ajax/ 5 Description: Ajax driven login widget. Customisable from within your template folder, and advanced settings from the admin area. 5 Description: Ajax driven login widget. Customisable from within your template folder, and advanced settings from the admin area. 6 6 Author: NetWebLogic 7 Version: 3.0. 47 Version: 3.0.5 8 8 Author URI: http://netweblogic.com/ 9 9 Tags: Login, Ajax, Redirect, BuddyPress, MU, WPMU, sidebar, admin, widget … … 25 25 */ 26 26 class LoginWithAjax { 27 27 28 28 /** 29 29 * If logged in upon instantiation, it is a user object. … … 50 50 * @var string 51 51 */ 52 var $footer_loc; 52 var $footer_loc; 53 53 /** 54 54 * URL for the AJAX Login procedure in templates (including callback and template parameters) … … 66 66 */ 67 67 var $url_register; 68 69 70 68 69 70 71 71 // Class initialization 72 72 function LoginWithAjax() { … … 74 74 add_action( 'widgets_init', array(&$this,'init') ); 75 75 } 76 76 77 77 // Actions to take upon initial action hook 78 78 function init(){ … … 81 81 //Remember the current user, in case there is a logout 82 82 $this->current_user = wp_get_current_user(); 83 83 84 84 //Get Templates from theme and default by checking for folders - we assume a template works if a folder exists! 85 85 //Note that duplicate template names are overwritten in this order of precedence (highest to lowest) - Child Theme > Parent Theme > Plugin Defaults … … 88 88 //Now, the parent theme (if exists) 89 89 if( get_stylesheet_directory() != get_template_directory() ){ 90 $this->find_templates( get_template_directory().'/plugins/login-with-ajax/' ); 91 } 90 $this->find_templates( get_template_directory().'/plugins/login-with-ajax/' ); 91 } 92 92 //Finally, the child theme 93 93 $this->find_templates( get_stylesheet_directory().'/plugins/login-with-ajax/' ); 94 94 95 95 //Generate URLs for login, remember, and register 96 96 $this->url_login = $this->template_link(site_url('wp-login.php', 'login_post')); 97 97 $this->url_register = $this->template_link(site_url('wp-login.php?action=register', 'login_post')); 98 98 $this->url_remember = $this->template_link(site_url('wp-login.php?action=lostpassword', 'login_post')); 99 99 100 100 //Make decision on what to display 101 101 if ( isset($_REQUEST["login-with-ajax"]) ) { //AJAX Request … … 118 118 wp_enqueue_script( "login-with-ajax", $plugin_url."/widget/login-with-ajax.js", array( 'jquery' ) ); 119 119 } 120 121 //Enqueue stylesheets - Only one style enqueued here.... theme CSS takes priority, then default CSS 120 121 //Enqueue stylesheets - Only one style enqueued here.... theme CSS takes priority, then default CSS 122 122 //The concept here is one stylesheet is loaded which will work for multiple templates. 123 123 if( file_exists(get_stylesheet_directory().'/plugins/login-with-ajax/widget.css') ){ //Child Theme (or just theme) … … 129 129 } 130 130 } 131 131 132 132 //Register widget 133 133 register_widget("LoginWithAjaxWidget"); 134 134 135 135 //Add logout/in redirection 136 136 add_action('login_form_register', array(&$this, 'register')); 137 137 add_action('wp_logout', array(&$this, 'logoutRedirect')); 138 138 add_action('logout_url', array(&$this, 'logoutUrl')); 139 add_action('login_redirect', array(&$this, 'loginRedirect'), 1, 3); 139 add_action('login_redirect', array(&$this, 'loginRedirect'), 1, 3); 140 140 add_shortcode('login-with-ajax', array(&$this, 'shortcode')); 141 141 add_shortcode('lwa', array(&$this, 'shortcode')); 142 143 } 144 } 145 142 143 } 144 } 145 146 146 /* 147 147 * LOGIN OPERATIONS 148 148 */ 149 149 150 150 // Decides what action to take from the ajax request 151 151 function ajax(){ … … 164 164 exit(); 165 165 } 166 166 167 167 // Reads ajax login creds via POSt, calls the login script and interprets the result 168 168 function login(){ … … 187 187 $query_vars = ($_GET['template'] != '') ? "&template={$_GET['template']}" : ''; 188 188 $query_vars .= ($_REQUEST['lwa_profile_link'] == '1') ? "&lwa_profile_link=1" : ''; 189 $return['widget'] = get_bloginfo('wpurl')."?login-with-ajax-widget=1$query_vars"; 190 $return['message'] = __("Login successful, updating...",'login-with-ajax'); 189 $return['widget'] = get_bloginfo('wpurl')."?login-with-ajax-widget=1$query_vars"; 190 $return['message'] = __("Login successful, updating...",'login-with-ajax'); 191 191 } 192 192 } elseif ( strtolower(get_class($loginResult)) == 'wp_error' ) { … … 207 207 return $return; 208 208 } 209 209 210 210 /** 211 211 * Checks post data and registers user … … 232 232 } 233 233 } 234 234 235 235 // Reads ajax login creds via POSt, calls the login script and interprets the result 236 236 function remember(){ 237 237 $return = array(); //What we send back 238 238 $result = retrieve_password(); 239 239 240 240 if ( $result === true ) { 241 241 //Password correctly remembered … … 255 255 return $return; 256 256 } 257 258 //Added fix for 257 258 //Added fix for 259 259 function logoutUrl( $logout_url ){ 260 260 //Add ICL if necessary … … 265 265 return $logout_url; 266 266 } 267 267 268 268 /* 269 269 * Redirect Functions 270 270 */ 271 271 272 272 function logoutRedirect(){ 273 273 $redirect = $this->getLogoutRedirect(); … … 277 277 } 278 278 } 279 279 280 280 function getLogoutRedirect(){ 281 281 $data = $this->data; … … 289 289 if( isset($data["logout_redirect_".$code]) ){ 290 290 $redirect = $data["logout_redirect_".$code]; 291 } 291 } 292 292 } 293 293 //Role based redirect … … 298 298 if( !empty($data["role_logout"]) && is_array($data["role_logout"]) && isset($data["role_logout"][$user_role]) ){ 299 299 $redirect = $data["role_logout"][$user_role]; 300 } 300 } 301 301 //Check for language redirects based on roles 302 302 if( !empty($_REQUEST['icl_language_code']) ){ 303 303 if( isset($data["role_logout"][$user_role."_".$code]) ){ 304 304 $redirect = $data["role_logout"][$user_role."_".$code]; 305 } 306 } 305 } 306 } 307 307 } 308 308 $redirect = str_replace("%LASTURL%", $_SERVER['HTTP_REFERER'], $redirect); 309 309 if( !empty($_REQUEST['icl_language_code']) ){ 310 $redirect = str_replace("%LANG%", $code.'/', $redirect); 310 $redirect = str_replace("%LANG%", $code.'/', $redirect); 311 311 } 312 312 return $redirect; 313 313 } 314 314 315 315 function loginRedirect( $redirect, $redirect_notsurewhatthisis, $user ){ 316 316 $data = $this->data; 317 317 if(is_user_logged_in()){ 318 $lwa_redirect = $this->getLoginRedirect($user); 318 $lwa_redirect = $this->getLoginRedirect($user); 319 319 if( $lwa_redirect != '' ){ 320 320 wp_redirect($lwa_redirect); … … 324 324 return $redirect; 325 325 } 326 326 327 327 function getLoginRedirect($user){ 328 $data = $this->data; 328 $data = $this->data; 329 329 //Global redirect 330 330 if($data['login_redirect'] != ''){ … … 336 336 if( isset($data["login_redirect_".$code]) ){ 337 337 $redirect = $data["login_redirect_".$code]; 338 } 338 } 339 339 } 340 340 //Role based redirects … … 343 343 if( isset($data["role_login"][$user_role]) ){ 344 344 $redirect = $data["role_login"][$user_role]; 345 } 345 } 346 346 //Check for language redirects based on roles 347 347 if( !empty($_REQUEST['icl_language_code']) ){ 348 348 if( isset($data["role_login"][$user_role."_".$code]) ){ 349 349 $redirect = $data["role_login"][$user_role."_".$code]; 350 } 351 } 352 } 353 //Do string replacements 350 } 351 } 352 } 353 //Do string replacements 354 354 $redirect = str_replace('%USERNAME%', $user->user_login, $redirect); 355 355 $redirect = str_replace("%LASTURL%", $_SERVER['HTTP_REFERER'], $redirect); 356 356 if( !empty($_REQUEST['icl_language_code']) ){ 357 $redirect = str_replace("%LANG%", $code.'/', $redirect); 357 $redirect = str_replace("%LANG%", $code.'/', $redirect); 358 358 } 359 359 return $redirect; 360 360 } 361 361 362 362 /* 363 363 * WIDGET OPERATIONS 364 364 */ 365 365 366 366 function widget($args, $instance = array() ){ 367 367 //Extract widget arguments … … 390 390 } 391 391 } 392 392 393 393 function shortcode($atts){ 394 394 $defaults = array( 'is_widget' => false, 'profile_link' => false, 'registration' => 1 ); … … 398 398 return ob_get_clean(); 399 399 } 400 400 401 401 function new_user_notification($user_login, $plaintext_pass, $user_email, $blogname){ 402 402 //Copied out of /wp-includes/pluggable.php … … 406 406 $message = str_replace('%BLOGNAME%', $blogname, $message); 407 407 $message = str_replace('%BLOGURL%', get_bloginfo('wpurl'), $message); 408 408 409 409 $subject = $this->data['notification_subject']; 410 410 $subject = str_replace('%BLOGNAME%', $blogname, $subject); 411 411 $subject = str_replace('%BLOGURL%', get_bloginfo('wpurl'), $subject); 412 412 413 413 wp_mail($user_email, $subject, $message); 414 } 415 414 } 415 416 416 /* 417 417 * Auxillary Functions 418 418 */ 419 419 420 420 //Checks a directory for folders and populates the template file 421 function find_templates($dir){ 421 function find_templates($dir){ 422 422 if (is_dir($dir)) { 423 423 if ($dh = opendir($dir)) { … … 432 432 } 433 433 } 434 434 435 435 //Add template link and JSON callback var to the URL 436 436 function template_link( $content ){ … … 442 442 return $content; 443 443 } 444 444 445 445 //PHP4 Safe JSON encoding 446 446 function json_encode($array){ … … 450 450 $return = $this->array_to_json($array); 451 451 } 452 if( isset($_REQUEST['callback']) ){452 if( isset($_REQUEST['callback']) && preg_match("/^jQuery[_a-zA-Z0-9]+$/", $_REQUEST['callback']) ){ 453 453 $return = $_REQUEST['callback']."($return)"; 454 454 } … … 499 499 // Then we collapse the staging array into the JSON form: 500 500 $result = "[ " . implode( ", ", $construct ) . " ]"; 501 } 501 } 502 502 return $result; 503 503 } … … 505 505 //Add translation 506 506 function lwa_load_plugin_textdomain(){ 507 load_plugin_textdomain('login-with-ajax', false, "login-with-ajax/langs"); 508 } 507 load_plugin_textdomain('login-with-ajax', false, "login-with-ajax/langs"); 508 } 509 509 add_action('plugins_loaded','lwa_load_plugin_textdomain'); 510 510 … … 530 530 531 531 // Start plugin 532 global $LoginWithAjax; 532 global $LoginWithAjax; 533 533 $LoginWithAjax = new LoginWithAjax(); 534 534 -
login-with-ajax/trunk/readme.txt
r506873 r541069 5 5 Requires at least: 2.8 6 6 Tested up to: 3.3.1 7 Stable tag: 3.0.4 7 Stable tag: 3.0.4.1 8 8 9 9 Add smooth ajax login and registration effects to your blog and choose where users get redirected upon login/logout. Supports SSL, MU, and BuddyPress. … … 211 211 * added registration attribute to template tags/shortcode 212 212 213 = 3.0.4.1 = 214 * fixed xss vulnerability for re-enlistment on wordpress repo, more on the way 215 213 216 = 3.0.5 = 214 217 * fixed json_encode issue
Note: See TracChangeset
for help on using the changeset viewer.