[wp-cvs] wordpress/wp-admin options.php, 1.39, 1.40 profile.php, 1.38, 1.39

Ryan Boren rboren at users.sourceforge.net
Thu Jan 20 04:56:26 GMT 2005


Update of /cvsroot/cafelog/wordpress/wp-admin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18201/wp-admin

Modified Files:
	options.php profile.php 
Log Message:
wp_setcookie() and wp_clearcookie().  Set cookies for both siteurl and home if they are not the same.  Update cookies whenever home or siteurl change.

Index: profile.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-admin/profile.php,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** profile.php	24 Dec 2004 20:55:36 -0000	1.38
--- profile.php	20 Jan 2005 04:56:24 -0000	1.39
***************
*** 63,68 ****
  		$newuser_pass = $_POST["pass1"];
  		$updatepassword = "user_pass=MD5('$newuser_pass'), ";
! 		setcookie('wordpresspass_' . COOKIEHASH, " ", time() - 31536000, COOKIEPATH);
! 		setcookie('wordpresspass_' . COOKIEHASH, md5(md5($newuser_pass)), time() + 31536000, COOKIEPATH);
  	}
  
--- 63,68 ----
  		$newuser_pass = $_POST["pass1"];
  		$updatepassword = "user_pass=MD5('$newuser_pass'), ";
! 		wp_clearcookie();
! 		wp_setcookie($user_login, $newuser_pass);
  	}
  

Index: options.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-admin/options.php,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -d -r1.39 -r1.40
*** options.php	7 Jan 2005 01:39:18 -0000	1.39
--- options.php	20 Jan 2005 04:56:24 -0000	1.40
***************
*** 28,32 ****
  
  case 'update':
!     $any_changed = 0;
      
  	if (!$_POST['page_options']) {
--- 28,32 ----
  
  case 'update':
! 	$any_changed = 0;
      
  	if (!$_POST['page_options']) {
***************
*** 41,44 ****
--- 41,48 ----
      $options = $wpdb->get_results("SELECT $wpdb->options.option_id, option_name, option_type, option_value, option_admin_level FROM $wpdb->options WHERE option_name IN ($option_names)");
  
+ 		// Save for later.
+ 		$old_siteurl = get_settings('siteurl');
+ 		$old_home = get_settings('home');
+ 
  // HACK
  // Options that if not there have 0 value but need to be something like "closed"
***************
*** 57,62 ****
                  }
                  if( in_array($option->option_name, $nonbools) && $new_val == '0' ) $new_val = 'closed';
!                 if ($new_val !== $old_val)
                      $result = $wpdb->query("UPDATE $wpdb->options SET option_value = '$new_val' WHERE option_name = '$option->option_name'");
              }
          }
--- 61,68 ----
                  }
                  if( in_array($option->option_name, $nonbools) && $new_val == '0' ) $new_val = 'closed';
!                 if ($new_val !== $old_val) {
                      $result = $wpdb->query("UPDATE $wpdb->options SET option_value = '$new_val' WHERE option_name = '$option->option_name'");
+ 										$any_changed++;
+ 								}
              }
          }
***************
*** 66,77 ****
      
      if ($any_changed) {
!         $message = sprintf(__('%d setting(s) saved... '), $any_changed);
      }
      
- 		//$referred = str_replace('?updated=true' , '', $_SERVER['HTTP_REFERER']);
  		$referred = remove_query_arg('updated' , $_SERVER['HTTP_REFERER']);
- 		//$goback = str_replace('?updated=true', '', $_SERVER['HTTP_REFERER']) . '?updated=true';
  		$goback = add_query_arg('updated', 'true', $_SERVER['HTTP_REFERER']);
! 	$goback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $goback);
      header('Location: ' . $goback);
      break;
--- 72,91 ----
      
      if ($any_changed) {
! 			// If siteurl or home changed, reset cookies.
! 			if ( get_settings('siteurl') != $old_siteurl || get_settings('home') != $old_home ) {
! 				// Get currently logged in user and password.
! 				get_currentuserinfo();
! 				// Clear cookies for old paths.
! 				wp_clearcookie();
! 				// Set cookies for new paths.
! 				wp_setcookie($user_login, $user_pass_md5, true, get_settings('home'), get_settings('siteurl'));
! 			}
! 
! 			//$message = sprintf(__('%d setting(s) saved... '), $any_changed);
      }
      
  		$referred = remove_query_arg('updated' , $_SERVER['HTTP_REFERER']);
  		$goback = add_query_arg('updated', 'true', $_SERVER['HTTP_REFERER']);
! 		$goback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $goback);
      header('Location: ' . $goback);
      break;



More information about the cvs mailing list