diff --git a/wp-app.php b/wp-app.php
index 74789443bb..911d5aa3fe 100644
--- a/wp-app.php
+++ b/wp-app.php
@@ -13,24 +13,7 @@ require_once('./wp-config.php');
require_once(ABSPATH . WPINC . '/post-template.php');
require_once(ABSPATH . WPINC . '/atomlib.php');
-// Attempt to automatically detect whether to use querystring
-// or PATH_INFO, based on our environment:
-$use_querystring = $wp_version == 'MU' ? 1 : 0;
-
-// If using querystring, we need to put the path together manually:
-if ($use_querystring) {
- $GLOBALS['use_querystring'] = $use_querystring;
- $action = $_GET['action'];
- $eid = (int) $_GET['eid'];
-
- $_SERVER['PATH_INFO'] = $action;
-
- if ($eid) {
- $_SERVER['PATH_INFO'] .= "/$eid";
- }
-} else {
- $_SERVER['PATH_INFO'] = str_replace( '.*/wp-app.php', '', $_SERVER['REQUEST_URI'] );
-}
+$_SERVER['PATH_INFO'] = preg_replace( '/.*\/wp-app\.php/', '', $_SERVER['REQUEST_URI'] );
$app_logging = 0;
@@ -142,7 +125,7 @@ class AtomServer {
// redirect to /service in case no path is found.
if(strlen($path) == 0 || $path == '/') {
- $this->redirect($this->get_service_url());
+ $this->redirect($this->get_service_url());
}
// dispatch
@@ -150,22 +133,22 @@ class AtomServer {
if(preg_match($regex, $path, $matches)) {
if(isset($funcs[$method])) {
- // authenticate regardless of the operation and set the current
- // user. each handler will decide if auth is required or not.
- $this->authenticate();
- $u = wp_get_current_user();
- if(!isset($u) || $u->ID == 0) {
- if ($always_authenticate) {
- $this->auth_required('Credentials required.');
- }
- }
+ // authenticate regardless of the operation and set the current
+ // user. each handler will decide if auth is required or not.
+ $this->authenticate();
+ $u = wp_get_current_user();
+ if(!isset($u) || $u->ID == 0) {
+ if ($always_authenticate) {
+ $this->auth_required('Credentials required.');
+ }
+ }
- array_shift($matches);
- call_user_func_array(array(&$this,$funcs[$method]), $matches);
- exit();
+ array_shift($matches);
+ call_user_func_array(array(&$this,$funcs[$method]), $matches);
+ exit();
} else {
- // only allow what we have handlers for...
- $this->not_allowed(array_keys($funcs));
+ // only allow what we have handlers for...
+ $this->not_allowed(array_keys($funcs));
}
}
}
@@ -245,7 +228,6 @@ EOD;
array_push($catnames, $cat["term"]);
$wp_cats = get_categories(array('hide_empty' => false));
- log_app('CATEGORIES :', print_r($wp_cats,true));
$post_category = array();
@@ -352,8 +334,6 @@ EOD;
$postdata = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'post_date', 'post_date_gmt');
$this->escape($postdata);
- log_app('UPDATING ENTRY WITH:', print_r($postdata,true));
-
$result = wp_update_post($postdata);
if (!$result) {
@@ -606,23 +586,14 @@ EOD;
}
function get_entries_url($page = NULL) {
- global $use_querystring;
if($GLOBALS['post_type'] == 'attachment') {
$path = $this->MEDIA_PATH;
} else {
$path = $this->ENTRIES_PATH;
}
- $url = get_bloginfo('url') . '/' . $this->script_name;
- if ($use_querystring) {
- $url .= '?action=/' . $path;
- if(isset($page) && is_int($page)) {
- $url .= "&eid=$page";
- }
- } else {
- $url .= '/' . $path;
- if(isset($page) && is_int($page)) {
- $url .= "/$page";
- }
+ $url = get_bloginfo('url') . '/' . $this->script_name . '/' . $path;
+ if(isset($page) && is_int($page)) {
+ $url .= "/$page";
}
return $url;
}
@@ -633,14 +604,7 @@ EOD;
}
function get_categories_url($page = NULL) {
- global $use_querystring;
- $url = get_bloginfo('url') . '/' . $this->script_name;
- if ($use_querystring) {
- $url .= '?action=/' . $this->CATEGORIES_PATH;
- } else {
- $url .= '/' . $this->CATEGORIES_PATH;
- }
- return $url;
+ return get_bloginfo('url') . '/' . $this->script_name . '/' . $this->CATEGORIES_PATH;
}
function the_categories_url() {
@@ -649,18 +613,9 @@ EOD;
}
function get_attachments_url($page = NULL) {
- global $use_querystring;
- $url = get_bloginfo('url') . '/' . $this->script_name;
- if ($use_querystring) {
- $url .= '?action=/' . $this->MEDIA_PATH;
- if(isset($page) && is_int($page)) {
- $url .= "&eid=$page";
- }
- } else {
- $url .= '/' . $this->MEDIA_PATH;
- if(isset($page) && is_int($page)) {
- $url .= "/$page";
- }
+ $url = get_bloginfo('url') . '/' . $this->script_name . '/' . $this->MEDIA_PATH;
+ if(isset($page) && is_int($page)) {
+ $url .= "/$page";
}
return $url;
}
@@ -671,28 +626,16 @@ EOD;
}
function get_service_url() {
- global $use_querystring;
- $url = get_bloginfo('url') . '/' . $this->script_name;
- if ($use_querystring) {
- $url .= '?action=/' . $this->SERVICE_PATH;
- } else {
- $url .= '/' . $this->SERVICE_PATH;
- }
- return $url;
+ return get_bloginfo('url') . '/' . $this->script_name . '/' . $this->SERVICE_PATH;
}
function get_entry_url($postID = NULL) {
- global $use_querystring;
if(!isset($postID)) {
global $post;
$postID = (int) $GLOBALS['post']->ID;
}
- if ($use_querystring) {
- $url = get_bloginfo('url') . '/' . $this->script_name . '?action=/' . $this->ENTRY_PATH . "&eid=$postID";
- } else {
- $url = get_bloginfo('url') . '/' . $this->script_name . '/' . $this->ENTRY_PATH . "/$postID";
- }
+ $url = get_bloginfo('url') . '/' . $this->script_name . '/' . $this->ENTRY_PATH . "/$postID";
log_app('function',"get_entry_url() = $url");
return $url;
@@ -704,17 +647,12 @@ EOD;
}
function get_media_url($postID = NULL) {
- global $use_querystring;
if(!isset($postID)) {
global $post;
$postID = (int) $GLOBALS['post']->ID;
}
- if ($use_querystring) {
- $url = get_bloginfo('url') . '/' . $this->script_name . '?action=/' . $this->MEDIA_SINGLE_PATH ."/file&eid=$postID";
- } else {
- $url = get_bloginfo('url') . '/' . $this->script_name . '/' . $this->MEDIA_SINGLE_PATH ."/file/$postID";
- }
+ $url = get_bloginfo('url') . '/' . $this->script_name . '/' . $this->MEDIA_SINGLE_PATH ."/file/$postID";
log_app('function',"get_media_url() = $url");
return $url;
@@ -767,7 +705,7 @@ EOD;
$count = get_option('posts_per_rss');
- wp('what_to_show=posts&posts_per_page=' . $count . '&offset=' . ($page-1));
+ wp('what_to_show=posts&posts_per_page=' . $count . '&offset=' . ($count * ($page-1) ));
$post = $GLOBALS['post'];
$posts = $GLOBALS['posts'];
@@ -783,6 +721,7 @@ EOD;
$next_page = (($page + 1) > $last_page) ? NULL : $page + 1;
$prev_page = ($page - 1) < 1 ? NULL : $page - 1;
$last_page = ((int)$last_page == 1 || (int)$last_page == 0) ? NULL : (int) $last_page;
+ $self_page = $page > 1 ? $page : NULL;
?>