Changes from branches/2.6/wp-app.php at r8399 to trunk/wp-app.php at r8267
- File:
-
- 1 edited
-
trunk/wp-app.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-app.php
r8399 r8267 207 207 // authenticate regardless of the operation and set the current 208 208 // user. each handler will decide if auth is required or not. 209 if(!$this->authenticate()) { 209 $this->authenticate(); 210 $u = wp_get_current_user(); 211 if(!isset($u) || $u->ID == 0) { 210 212 if ($always_authenticate) { 211 213 $this->auth_required('Credentials required.'); … … 393 395 394 396 $publish = (isset($parsed->draft) && trim($parsed->draft) == 'yes') ? false : true; 395 $post_status = ($publish) ? 'publish' : 'draft';396 397 397 398 extract($entry); … … 406 407 $post_modified = $pubtimes[0]; 407 408 $post_modified_gmt = $pubtimes[1]; 409 410 // let's not go backwards and make something draft again. 411 if(!$publish && $post_status == 'draft') { 412 $post_status = ($publish) ? 'publish' : 'draft'; 413 } elseif($publish) { 414 $post_status = 'publish'; 415 } 408 416 409 417 $postdata = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'post_date', 'post_date_gmt', 'post_modified', 'post_modified_gmt'); … … 1063 1071 */ 1064 1072 function authenticate() { 1073 $login_data = array(); 1074 $already_md5 = false; 1075 1065 1076 log_app("authenticate()",print_r($_ENV, true)); 1066 1077 … … 1074 1085 // If Basic Auth is working... 1075 1086 if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) { 1076 log_app("Basic Auth",$_SERVER['PHP_AUTH_USER']); 1077 $user = wp_authenticate($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); 1078 if ( $user && !is_wp_error($user) ) { 1079 wp_set_current_user($user->ID); 1080 log_app("authenticate()", $_SERVER['PHP_AUTH_USER']); 1081 return true; 1087 $login_data = array('login' => $_SERVER['PHP_AUTH_USER'], 'password' => $_SERVER['PHP_AUTH_PW']); 1088 log_app("Basic Auth",$login_data['login']); 1089 } else { 1090 // else, do cookie-based authentication 1091 if (function_exists('wp_get_cookie_login')) { 1092 $login_data = wp_get_cookie_login(); 1093 $already_md5 = true; 1082 1094 } 1083 1095 } 1084 1096 1085 return false; 1097 // call wp_login and set current user 1098 if (!empty($login_data) && wp_login($login_data['login'], $login_data['password'], $already_md5)) { 1099 $current_user = new WP_User(0, $login_data['login']); 1100 wp_set_current_user($current_user->ID); 1101 log_app("authenticate()",$login_data['login']); 1102 } 1086 1103 } 1087 1104
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)