Coding style cleanups
git-svn-id: https://develop.svn.wordpress.org/trunk@12734 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
8ef8b7bad5
commit
3dfc463062
@ -7,7 +7,7 @@ require( dirname(__FILE__) . '/wp-load.php' );
|
|||||||
require( 'wp-blog-header.php' );
|
require( 'wp-blog-header.php' );
|
||||||
require_once( ABSPATH . WPINC . '/registration.php');
|
require_once( ABSPATH . WPINC . '/registration.php');
|
||||||
|
|
||||||
if( is_object( $wp_object_cache ) )
|
if ( is_object( $wp_object_cache ) )
|
||||||
$wp_object_cache->cache_enabled = false;
|
$wp_object_cache->cache_enabled = false;
|
||||||
|
|
||||||
do_action("activate_header");
|
do_action("activate_header");
|
||||||
@ -52,7 +52,7 @@ get_header();
|
|||||||
?>
|
?>
|
||||||
<h2><?php _e('Your account is now active!'); ?></h2>
|
<h2><?php _e('Your account is now active!'); ?></h2>
|
||||||
<?php
|
<?php
|
||||||
if( $signup->domain . $signup->path == '' ) {
|
if ( $signup->domain . $signup->path == '' ) {
|
||||||
printf(__('<p class="lead-in">Your account has been activated. You may now <a href="%1$s">login</a> to the site using your chosen username of "%2$s". Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.</p>'), 'http://' . $current_site->domain . $current_site->path . 'wp-login.php', $signup->user_login, $signup->user_email, 'http://' . $current_site->domain . $current_site->path . 'wp-login.php?action=lostpassword');
|
printf(__('<p class="lead-in">Your account has been activated. You may now <a href="%1$s">login</a> to the site using your chosen username of "%2$s". Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.</p>'), 'http://' . $current_site->domain . $current_site->path . 'wp-login.php', $signup->user_login, $signup->user_email, 'http://' . $current_site->domain . $current_site->path . 'wp-login.php?action=lostpassword');
|
||||||
} else {
|
} else {
|
||||||
printf(__('<p class="lead-in">Your blog at <a href="%1$s">%2$s</a> is active. You may now login to your blog using your chosen username of "%3$s". Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%5$s">reset your password</a>.</p>'), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, 'http://' . $current_site->domain . $current_site->path . 'wp-login.php?action=lostpassword');
|
printf(__('<p class="lead-in">Your blog at <a href="%1$s">%2$s</a> is active. You may now login to your blog using your chosen username of "%3$s". Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%5$s">reset your password</a>.</p>'), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, 'http://' . $current_site->domain . $current_site->path . 'wp-login.php?action=lostpassword');
|
||||||
@ -75,7 +75,7 @@ get_header();
|
|||||||
<p><span class="h3"><?php _e('Password:'); ?></span> <?php echo $password; ?></p>
|
<p><span class="h3"><?php _e('Password:'); ?></span> <?php echo $password; ?></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if( $url != 'http://' . $current_site->domain . $current_site->path ) : ?>
|
<?php if ( $url != 'http://' . $current_site->domain . $current_site->path ) : ?>
|
||||||
<p class="view"><?php printf(__('Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Login</a>'), $url, $url . 'wp-login.php' ); ?></p>
|
<p class="view"><?php printf(__('Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Login</a>'), $url, $url . 'wp-login.php' ); ?></p>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<p class="view"><?php printf( __( 'Your account is now activated. <a href="%1$s">Login</a> or go back to the <a href="%2$s">homepage</a>.' ), 'http://' . $current_site->domain . $current_site->path . 'wp-login.php', 'http://' . $current_site->domain . $current_site->path ); ?></p>
|
<p class="view"><?php printf( __( 'Your account is now activated. <a href="%1$s">Login</a> or go back to the <a href="%2$s">homepage</a>.' ), 'http://' . $current_site->domain . $current_site->path . 'wp-login.php', 'http://' . $current_site->domain . $current_site->path ); ?></p>
|
||||||
|
133
wp-app.php
133
wp-app.php
@ -265,7 +265,7 @@ class AtomServer {
|
|||||||
function handle_request() {
|
function handle_request() {
|
||||||
global $always_authenticate;
|
global $always_authenticate;
|
||||||
|
|
||||||
if( !empty( $_SERVER['ORIG_PATH_INFO'] ) )
|
if ( !empty( $_SERVER['ORIG_PATH_INFO'] ) )
|
||||||
$path = $_SERVER['ORIG_PATH_INFO'];
|
$path = $_SERVER['ORIG_PATH_INFO'];
|
||||||
else
|
else
|
||||||
$path = $_SERVER['PATH_INFO'];
|
$path = $_SERVER['PATH_INFO'];
|
||||||
@ -278,40 +278,38 @@ class AtomServer {
|
|||||||
//$this->process_conditionals();
|
//$this->process_conditionals();
|
||||||
|
|
||||||
// exception case for HEAD (treat exactly as GET, but don't output)
|
// exception case for HEAD (treat exactly as GET, but don't output)
|
||||||
if($method == 'HEAD') {
|
if ($method == 'HEAD') {
|
||||||
$this->do_output = false;
|
$this->do_output = false;
|
||||||
$method = 'GET';
|
$method = 'GET';
|
||||||
}
|
}
|
||||||
|
|
||||||
// redirect to /service in case no path is found.
|
// redirect to /service in case no path is found.
|
||||||
if(strlen($path) == 0 || $path == '/') {
|
if(strlen($path) == 0 || $path == '/')
|
||||||
$this->redirect($this->get_service_url());
|
$this->redirect($this->get_service_url());
|
||||||
}
|
|
||||||
|
|
||||||
// check to see if AtomPub is enabled
|
// check to see if AtomPub is enabled
|
||||||
if( !get_option( 'enable_app' ) )
|
if ( !get_option( 'enable_app' ) )
|
||||||
$this->forbidden( sprintf( __( 'AtomPub services are disabled on this blog. An admin user can enable them at %s' ), admin_url('options-writing.php') ) );
|
$this->forbidden( sprintf( __( 'AtomPub services are disabled on this blog. An admin user can enable them at %s' ), admin_url('options-writing.php') ) );
|
||||||
|
|
||||||
// dispatch
|
// dispatch
|
||||||
foreach($this->selectors as $regex => $funcs) {
|
foreach ( $this->selectors as $regex => $funcs ) {
|
||||||
if(preg_match($regex, $path, $matches)) {
|
if ( preg_match($regex, $path, $matches) ) {
|
||||||
if(isset($funcs[$method])) {
|
if ( isset($funcs[$method]) ) {
|
||||||
|
|
||||||
// authenticate regardless of the operation and set the current
|
// authenticate regardless of the operation and set the current
|
||||||
// user. each handler will decide if auth is required or not.
|
// user. each handler will decide if auth is required or not.
|
||||||
if(!$this->authenticate()) {
|
if ( !$this->authenticate() ) {
|
||||||
if ($always_authenticate) {
|
if ( $always_authenticate )
|
||||||
$this->auth_required('Credentials required.');
|
$this->auth_required('Credentials required.');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
array_shift($matches);
|
array_shift($matches);
|
||||||
call_user_func_array(array(&$this,$funcs[$method]), $matches);
|
call_user_func_array(array(&$this,$funcs[$method]), $matches);
|
||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
// only allow what we have handlers for...
|
// only allow what we have handlers for...
|
||||||
$this->not_allowed(array_keys($funcs));
|
$this->not_allowed(array_keys($funcs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,7 +325,7 @@ class AtomServer {
|
|||||||
function get_service() {
|
function get_service() {
|
||||||
log_app('function','get_service()');
|
log_app('function','get_service()');
|
||||||
|
|
||||||
if( !current_user_can( 'edit_posts' ) )
|
if ( !current_user_can( 'edit_posts' ) )
|
||||||
$this->auth_required( __( 'Sorry, you do not have the right to access this blog.' ) );
|
$this->auth_required( __( 'Sorry, you do not have the right to access this blog.' ) );
|
||||||
|
|
||||||
$entries_url = esc_attr($this->get_entries_url());
|
$entries_url = esc_attr($this->get_entries_url());
|
||||||
@ -338,7 +336,7 @@ class AtomServer {
|
|||||||
$accepted_media_types = $accepted_media_types . "<accept>" . $med . "</accept>";
|
$accepted_media_types = $accepted_media_types . "<accept>" . $med . "</accept>";
|
||||||
}
|
}
|
||||||
$atom_prefix="atom";
|
$atom_prefix="atom";
|
||||||
$atom_blogname=get_bloginfo('name');
|
$atom_blogname = get_bloginfo('name');
|
||||||
$service_doc = <<<EOD
|
$service_doc = <<<EOD
|
||||||
<service xmlns="$this->ATOMPUB_NS" xmlns:$atom_prefix="$this->ATOM_NS">
|
<service xmlns="$this->ATOMPUB_NS" xmlns:$atom_prefix="$this->ATOM_NS">
|
||||||
<workspace>
|
<workspace>
|
||||||
@ -368,16 +366,16 @@ EOD;
|
|||||||
function get_categories_xml() {
|
function get_categories_xml() {
|
||||||
log_app('function','get_categories_xml()');
|
log_app('function','get_categories_xml()');
|
||||||
|
|
||||||
if( !current_user_can( 'edit_posts' ) )
|
if ( !current_user_can( 'edit_posts' ) )
|
||||||
$this->auth_required( __( 'Sorry, you do not have the right to access this blog.' ) );
|
$this->auth_required( __( 'Sorry, you do not have the right to access this blog.' ) );
|
||||||
|
|
||||||
$home = esc_attr(get_bloginfo_rss('url'));
|
$home = esc_attr(get_bloginfo_rss('url'));
|
||||||
|
|
||||||
$categories = "";
|
$categories = "";
|
||||||
$cats = get_categories(array('hierarchical' => 0, 'hide_empty' => 0));
|
$cats = get_categories(array('hierarchical' => 0, 'hide_empty' => 0));
|
||||||
foreach ((array) $cats as $cat) {
|
foreach ( (array) $cats as $cat ) {
|
||||||
$categories .= " <category term=\"" . esc_attr($cat->name) . "\" />\n";
|
$categories .= " <category term=\"" . esc_attr($cat->name) . "\" />\n";
|
||||||
}
|
}
|
||||||
$output = <<<EOD
|
$output = <<<EOD
|
||||||
<app:categories xmlns:app="$this->ATOMPUB_NS"
|
<app:categories xmlns:app="$this->ATOMPUB_NS"
|
||||||
xmlns="$this->ATOM_NS"
|
xmlns="$this->ATOM_NS"
|
||||||
@ -385,8 +383,8 @@ EOD;
|
|||||||
$categories
|
$categories
|
||||||
</app:categories>
|
</app:categories>
|
||||||
EOD;
|
EOD;
|
||||||
$this->output($output, $this->CATEGORIES_CONTENT_TYPE);
|
$this->output($output, $this->CATEGORIES_CONTENT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new post.
|
* Create new post.
|
||||||
@ -398,24 +396,24 @@ EOD;
|
|||||||
$this->get_accepted_content_type($this->atom_content_types);
|
$this->get_accepted_content_type($this->atom_content_types);
|
||||||
|
|
||||||
$parser = new AtomParser();
|
$parser = new AtomParser();
|
||||||
if(!$parser->parse()) {
|
if ( !$parser->parse() )
|
||||||
$this->client_error();
|
$this->client_error();
|
||||||
}
|
|
||||||
|
|
||||||
$entry = array_pop($parser->feed->entries);
|
$entry = array_pop($parser->feed->entries);
|
||||||
|
|
||||||
log_app('Received entry:', print_r($entry,true));
|
log_app('Received entry:', print_r($entry,true));
|
||||||
|
|
||||||
$catnames = array();
|
$catnames = array();
|
||||||
foreach($entry->categories as $cat)
|
foreach ( $entry->categories as $cat ) {
|
||||||
array_push($catnames, $cat["term"]);
|
array_push($catnames, $cat["term"]);
|
||||||
|
}
|
||||||
|
|
||||||
$wp_cats = get_categories(array('hide_empty' => false));
|
$wp_cats = get_categories(array('hide_empty' => false));
|
||||||
|
|
||||||
$post_category = array();
|
$post_category = array();
|
||||||
|
|
||||||
foreach($wp_cats as $cat) {
|
foreach ( $wp_cats as $cat ) {
|
||||||
if(in_array($cat->name, $catnames))
|
if ( in_array($cat->name, $catnames) )
|
||||||
array_push($post_category, $cat->term_id);
|
array_push($post_category, $cat->term_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,7 +421,7 @@ EOD;
|
|||||||
|
|
||||||
$cap = ($publish) ? 'publish_posts' : 'edit_posts';
|
$cap = ($publish) ? 'publish_posts' : 'edit_posts';
|
||||||
|
|
||||||
if(!current_user_can($cap))
|
if ( !current_user_can($cap) )
|
||||||
$this->auth_required(__('Sorry, you do not have the right to edit/publish new posts.'));
|
$this->auth_required(__('Sorry, you do not have the right to edit/publish new posts.'));
|
||||||
|
|
||||||
$blog_ID = (int ) $blog_id;
|
$blog_ID = (int ) $blog_id;
|
||||||
@ -448,7 +446,7 @@ EOD;
|
|||||||
if ( is_wp_error( $postID ) )
|
if ( is_wp_error( $postID ) )
|
||||||
$this->internal_error($postID->get_error_message());
|
$this->internal_error($postID->get_error_message());
|
||||||
|
|
||||||
if (!$postID)
|
if ( !$postID )
|
||||||
$this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.'));
|
$this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.'));
|
||||||
|
|
||||||
// getting warning here about unable to set headers
|
// getting warning here about unable to set headers
|
||||||
@ -475,7 +473,7 @@ EOD;
|
|||||||
function get_post($postID) {
|
function get_post($postID) {
|
||||||
global $entry;
|
global $entry;
|
||||||
|
|
||||||
if( !current_user_can( 'edit_post', $postID ) )
|
if ( !current_user_can( 'edit_post', $postID ) )
|
||||||
$this->auth_required( __( 'Sorry, you do not have the right to access this post.' ) );
|
$this->auth_required( __( 'Sorry, you do not have the right to access this post.' ) );
|
||||||
|
|
||||||
$this->set_current_entry($postID);
|
$this->set_current_entry($postID);
|
||||||
@ -498,9 +496,8 @@ EOD;
|
|||||||
$this->get_accepted_content_type($this->atom_content_types);
|
$this->get_accepted_content_type($this->atom_content_types);
|
||||||
|
|
||||||
$parser = new AtomParser();
|
$parser = new AtomParser();
|
||||||
if(!$parser->parse()) {
|
if ( !$parser->parse() )
|
||||||
$this->bad_request();
|
$this->bad_request();
|
||||||
}
|
|
||||||
|
|
||||||
$parsed = array_pop($parser->feed->entries);
|
$parsed = array_pop($parser->feed->entries);
|
||||||
|
|
||||||
@ -510,7 +507,7 @@ EOD;
|
|||||||
global $entry;
|
global $entry;
|
||||||
$this->set_current_entry($postID);
|
$this->set_current_entry($postID);
|
||||||
|
|
||||||
if(!current_user_can('edit_post', $entry['ID']))
|
if ( !current_user_can('edit_post', $entry['ID']) )
|
||||||
$this->auth_required(__('Sorry, you do not have the right to edit this post.'));
|
$this->auth_required(__('Sorry, you do not have the right to edit this post.'));
|
||||||
|
|
||||||
$publish = (isset($parsed->draft) && trim($parsed->draft) == 'yes') ? false : true;
|
$publish = (isset($parsed->draft) && trim($parsed->draft) == 'yes') ? false : true;
|
||||||
@ -533,9 +530,8 @@ EOD;
|
|||||||
|
|
||||||
$result = wp_update_post($postdata);
|
$result = wp_update_post($postdata);
|
||||||
|
|
||||||
if (!$result) {
|
if ( !$result )
|
||||||
$this->internal_error(__('For some strange yet very annoying reason, this post could not be edited.'));
|
$this->internal_error(__('For some strange yet very annoying reason, this post could not be edited.'));
|
||||||
}
|
|
||||||
|
|
||||||
do_action( 'atompub_put_post', $ID, $parsed );
|
do_action( 'atompub_put_post', $ID, $parsed );
|
||||||
|
|
||||||
@ -556,16 +552,15 @@ EOD;
|
|||||||
global $entry;
|
global $entry;
|
||||||
$this->set_current_entry($postID);
|
$this->set_current_entry($postID);
|
||||||
|
|
||||||
if(!current_user_can('edit_post', $postID)) {
|
if ( !current_user_can('edit_post', $postID) )
|
||||||
$this->auth_required(__('Sorry, you do not have the right to delete this post.'));
|
$this->auth_required(__('Sorry, you do not have the right to delete this post.'));
|
||||||
}
|
|
||||||
|
|
||||||
if ($entry['post_type'] == 'attachment') {
|
if ( $entry['post_type'] == 'attachment' ) {
|
||||||
$this->delete_attachment($postID);
|
$this->delete_attachment($postID);
|
||||||
} else {
|
} else {
|
||||||
$result = wp_delete_post($postID);
|
$result = wp_delete_post($postID);
|
||||||
|
|
||||||
if (!$result) {
|
if ( !$result ) {
|
||||||
$this->internal_error(__('For some strange yet very annoying reason, this post could not be deleted.'));
|
$this->internal_error(__('For some strange yet very annoying reason, this post could not be deleted.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -583,10 +578,10 @@ EOD;
|
|||||||
* @param int $postID Optional. Post ID.
|
* @param int $postID Optional. Post ID.
|
||||||
*/
|
*/
|
||||||
function get_attachment($postID = null) {
|
function get_attachment($postID = null) {
|
||||||
if( !current_user_can( 'upload_files' ) )
|
if ( !current_user_can( 'upload_files' ) )
|
||||||
$this->auth_required( __( 'Sorry, you do not have permission to upload files.' ) );
|
$this->auth_required( __( 'Sorry, you do not have permission to upload files.' ) );
|
||||||
|
|
||||||
if (!isset($postID)) {
|
if ( !isset($postID) ) {
|
||||||
$this->get_attachments();
|
$this->get_attachments();
|
||||||
} else {
|
} else {
|
||||||
$this->set_current_entry($postID);
|
$this->set_current_entry($postID);
|
||||||
@ -605,12 +600,12 @@ EOD;
|
|||||||
|
|
||||||
$type = $this->get_accepted_content_type();
|
$type = $this->get_accepted_content_type();
|
||||||
|
|
||||||
if(!current_user_can('upload_files'))
|
if ( !current_user_can('upload_files') )
|
||||||
$this->auth_required(__('You do not have permission to upload files.'));
|
$this->auth_required(__('You do not have permission to upload files.'));
|
||||||
|
|
||||||
$fp = fopen("php://input", "rb");
|
$fp = fopen("php://input", "rb");
|
||||||
$bits = null;
|
$bits = null;
|
||||||
while(!feof($fp)) {
|
while ( !feof($fp) ) {
|
||||||
$bits .= fread($fp, 4096);
|
$bits .= fread($fp, 4096);
|
||||||
}
|
}
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
@ -678,7 +673,7 @@ EOD;
|
|||||||
global $entry;
|
global $entry;
|
||||||
$this->set_current_entry($postID);
|
$this->set_current_entry($postID);
|
||||||
|
|
||||||
if(!current_user_can('edit_post', $entry['ID']))
|
if ( !current_user_can('edit_post', $entry['ID']) )
|
||||||
$this->auth_required(__('Sorry, you do not have the right to edit this post.'));
|
$this->auth_required(__('Sorry, you do not have the right to edit this post.'));
|
||||||
|
|
||||||
extract($entry);
|
extract($entry);
|
||||||
@ -694,9 +689,8 @@ EOD;
|
|||||||
|
|
||||||
$result = wp_update_post($postdata);
|
$result = wp_update_post($postdata);
|
||||||
|
|
||||||
if (!$result) {
|
if ( !$result )
|
||||||
$this->internal_error(__('For some strange yet very annoying reason, this post could not be edited.'));
|
$this->internal_error(__('For some strange yet very annoying reason, this post could not be edited.'));
|
||||||
}
|
|
||||||
|
|
||||||
log_app('function',"put_attachment($postID)");
|
log_app('function',"put_attachment($postID)");
|
||||||
$this->ok();
|
$this->ok();
|
||||||
@ -716,14 +710,13 @@ EOD;
|
|||||||
global $entry;
|
global $entry;
|
||||||
$this->set_current_entry($postID);
|
$this->set_current_entry($postID);
|
||||||
|
|
||||||
if(!current_user_can('edit_post', $postID)) {
|
if ( !current_user_can('edit_post', $postID) )
|
||||||
$this->auth_required(__('Sorry, you do not have the right to delete this post.'));
|
$this->auth_required(__('Sorry, you do not have the right to delete this post.'));
|
||||||
}
|
|
||||||
|
|
||||||
$location = get_post_meta($entry['ID'], '_wp_attached_file', true);
|
$location = get_post_meta($entry['ID'], '_wp_attached_file', true);
|
||||||
$filetype = wp_check_filetype($location);
|
$filetype = wp_check_filetype($location);
|
||||||
|
|
||||||
if(!isset($location) || 'attachment' != $entry['post_type'] || empty($filetype['ext']))
|
if ( !isset($location) || 'attachment' != $entry['post_type'] || empty($filetype['ext']) )
|
||||||
$this->internal_error(__('Error ocurred while accessing post metadata for file location.'));
|
$this->internal_error(__('Error ocurred while accessing post metadata for file location.'));
|
||||||
|
|
||||||
// delete file
|
// delete file
|
||||||
@ -732,9 +725,8 @@ EOD;
|
|||||||
// delete attachment
|
// delete attachment
|
||||||
$result = wp_delete_post($postID);
|
$result = wp_delete_post($postID);
|
||||||
|
|
||||||
if (!$result) {
|
if ( !$result )
|
||||||
$this->internal_error(__('For some strange yet very annoying reason, this post could not be deleted.'));
|
$this->internal_error(__('For some strange yet very annoying reason, this post could not be deleted.'));
|
||||||
}
|
|
||||||
|
|
||||||
log_app('function',"delete_attachment($postID). File '$location' deleted.");
|
log_app('function',"delete_attachment($postID). File '$location' deleted.");
|
||||||
$this->ok();
|
$this->ok();
|
||||||
@ -754,27 +746,26 @@ EOD;
|
|||||||
$this->set_current_entry($postID);
|
$this->set_current_entry($postID);
|
||||||
|
|
||||||
// then whether user can edit the specific post
|
// then whether user can edit the specific post
|
||||||
if(!current_user_can('edit_post', $postID)) {
|
if ( !current_user_can('edit_post', $postID) )
|
||||||
$this->auth_required(__('Sorry, you do not have the right to edit this post.'));
|
$this->auth_required(__('Sorry, you do not have the right to edit this post.'));
|
||||||
}
|
|
||||||
|
|
||||||
$location = get_post_meta($entry['ID'], '_wp_attached_file', true);
|
$location = get_post_meta($entry['ID'], '_wp_attached_file', true);
|
||||||
$location = get_option ('upload_path') . '/' . $location;
|
$location = get_option ('upload_path') . '/' . $location;
|
||||||
$filetype = wp_check_filetype($location);
|
$filetype = wp_check_filetype($location);
|
||||||
|
|
||||||
if(!isset($location) || 'attachment' != $entry['post_type'] || empty($filetype['ext']))
|
if ( !isset($location) || 'attachment' != $entry['post_type'] || empty($filetype['ext']) )
|
||||||
$this->internal_error(__('Error ocurred while accessing post metadata for file location.'));
|
$this->internal_error(__('Error ocurred while accessing post metadata for file location.'));
|
||||||
|
|
||||||
status_header('200');
|
status_header('200');
|
||||||
header('Content-Type: ' . $entry['post_mime_type']);
|
header('Content-Type: ' . $entry['post_mime_type']);
|
||||||
header('Connection: close');
|
header('Connection: close');
|
||||||
|
|
||||||
if ($fp = fopen($location, "rb")) {
|
if ( $fp = fopen($location, "rb") ) {
|
||||||
status_header('200');
|
status_header('200');
|
||||||
header('Content-Type: ' . $entry['post_mime_type']);
|
header('Content-Type: ' . $entry['post_mime_type']);
|
||||||
header('Connection: close');
|
header('Connection: close');
|
||||||
|
|
||||||
while(!feof($fp)) {
|
while ( !feof($fp) ) {
|
||||||
echo fread($fp, 4096);
|
echo fread($fp, 4096);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -797,7 +788,7 @@ EOD;
|
|||||||
function put_file($postID) {
|
function put_file($postID) {
|
||||||
|
|
||||||
// first check if user can upload
|
// first check if user can upload
|
||||||
if(!current_user_can('upload_files'))
|
if ( !current_user_can('upload_files') )
|
||||||
$this->auth_required(__('You do not have permission to upload files.'));
|
$this->auth_required(__('You do not have permission to upload files.'));
|
||||||
|
|
||||||
// check for not found
|
// check for not found
|
||||||
@ -805,9 +796,8 @@ EOD;
|
|||||||
$this->set_current_entry($postID);
|
$this->set_current_entry($postID);
|
||||||
|
|
||||||
// then whether user can edit the specific post
|
// then whether user can edit the specific post
|
||||||
if(!current_user_can('edit_post', $postID)) {
|
if ( !current_user_can('edit_post', $postID) )
|
||||||
$this->auth_required(__('Sorry, you do not have the right to edit this post.'));
|
$this->auth_required(__('Sorry, you do not have the right to edit this post.'));
|
||||||
}
|
|
||||||
|
|
||||||
$upload_dir = wp_upload_dir( );
|
$upload_dir = wp_upload_dir( );
|
||||||
$location = get_post_meta($entry['ID'], '_wp_attached_file', true);
|
$location = get_post_meta($entry['ID'], '_wp_attached_file', true);
|
||||||
@ -820,7 +810,7 @@ EOD;
|
|||||||
|
|
||||||
$fp = fopen("php://input", "rb");
|
$fp = fopen("php://input", "rb");
|
||||||
$localfp = fopen($location, "w+");
|
$localfp = fopen($location, "w+");
|
||||||
while(!feof($fp)) {
|
while ( !feof($fp) ) {
|
||||||
fwrite($localfp,fread($fp, 4096));
|
fwrite($localfp,fread($fp, 4096));
|
||||||
}
|
}
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
@ -837,9 +827,8 @@ EOD;
|
|||||||
$post_data = compact('ID', 'post_date', 'post_date_gmt', 'post_modified', 'post_modified_gmt');
|
$post_data = compact('ID', 'post_date', 'post_date_gmt', 'post_modified', 'post_modified_gmt');
|
||||||
$result = wp_update_post($post_data);
|
$result = wp_update_post($post_data);
|
||||||
|
|
||||||
if (!$result) {
|
if ( !$result )
|
||||||
$this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.'));
|
$this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.'));
|
||||||
}
|
|
||||||
|
|
||||||
wp_update_attachment_metadata( $postID, wp_generate_attachment_metadata( $postID, $location ) );
|
wp_update_attachment_metadata( $postID, wp_generate_attachment_metadata( $postID, $location ) );
|
||||||
|
|
||||||
@ -856,15 +845,13 @@ EOD;
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function get_entries_url($page = null) {
|
function get_entries_url($page = null) {
|
||||||
if ( isset($GLOBALS['post_type']) && ( $GLOBALS['post_type'] == 'attachment' ) ) {
|
if ( isset($GLOBALS['post_type']) && ( $GLOBALS['post_type'] == 'attachment' ) )
|
||||||
$path = $this->MEDIA_PATH;
|
$path = $this->MEDIA_PATH;
|
||||||
} else {
|
else
|
||||||
$path = $this->ENTRIES_PATH;
|
$path = $this->ENTRIES_PATH;
|
||||||
}
|
|
||||||
$url = $this->app_base . $path;
|
$url = $this->app_base . $path;
|
||||||
if(isset($page) && is_int($page)) {
|
if ( isset($page) && is_int($page) )
|
||||||
$url .= "/$page";
|
$url .= "/$page";
|
||||||
}
|
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,10 +271,9 @@ function wp_start_object_cache() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function wp_not_installed() {
|
function wp_not_installed() {
|
||||||
if( is_multisite() ) {
|
if ( is_multisite() ) {
|
||||||
if ( !is_blog_installed() && !defined('WP_INSTALLING') ) {
|
if ( !is_blog_installed() && !defined('WP_INSTALLING') )
|
||||||
die( __( 'The blog you have requested is not installed properly. Please contact the system administrator.' ) ); // have to die here ~ Mark
|
die( __( 'The blog you have requested is not installed properly. Please contact the system administrator.' ) ); // have to die here ~ Mark
|
||||||
}
|
|
||||||
} elseif ( !is_blog_installed() && (strpos($_SERVER['PHP_SELF'], 'install.php') === false && !defined('WP_INSTALLING')) ) {
|
} elseif ( !is_blog_installed() && (strpos($_SERVER['PHP_SELF'], 'install.php') === false && !defined('WP_INSTALLING')) ) {
|
||||||
if ( defined('WP_SITEURL') )
|
if ( defined('WP_SITEURL') )
|
||||||
$link = WP_SITEURL . '/wp-admin/install.php';
|
$link = WP_SITEURL . '/wp-admin/install.php';
|
||||||
@ -329,7 +328,6 @@ function wp_load_plugins() {
|
|||||||
unset($plugin);
|
unset($plugin);
|
||||||
}
|
}
|
||||||
unset($current_plugins);
|
unset($current_plugins);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function wp_set_internal_encoding() {
|
function wp_set_internal_encoding() {
|
||||||
|
@ -64,7 +64,7 @@ require (ABSPATH . WPINC . '/plugin.php');
|
|||||||
require (ABSPATH . WPINC . '/default-filters.php');
|
require (ABSPATH . WPINC . '/default-filters.php');
|
||||||
include_once(ABSPATH . WPINC . '/pomo/mo.php');
|
include_once(ABSPATH . WPINC . '/pomo/mo.php');
|
||||||
|
|
||||||
if( is_multisite() && SHORTINIT ) // stop most of WP being loaded, we just want the basics
|
if ( SHORTINIT ) // stop most of WP being loaded, we just want the basics
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
require_once (ABSPATH . WPINC . '/l10n.php');
|
require_once (ABSPATH . WPINC . '/l10n.php');
|
||||||
@ -110,8 +110,8 @@ if ( is_multisite() ) {
|
|||||||
|
|
||||||
wp_default_constants('wp_included');
|
wp_default_constants('wp_included');
|
||||||
|
|
||||||
if( is_multisite() )
|
if ( is_multisite() )
|
||||||
ms_network_settings();
|
ms_network_settings();
|
||||||
|
|
||||||
wp_default_constants('ms_network_settings_loaded');
|
wp_default_constants('ms_network_settings_loaded');
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ wp_load_mu_plugins();
|
|||||||
* Used to load network wide plugins
|
* Used to load network wide plugins
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
if( is_multisite() )
|
if ( is_multisite() )
|
||||||
ms_network_plugins();
|
ms_network_plugins();
|
||||||
|
|
||||||
do_action('muplugins_loaded');
|
do_action('muplugins_loaded');
|
||||||
@ -130,7 +130,7 @@ do_action('muplugins_loaded');
|
|||||||
* Used to check site status
|
* Used to check site status
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
if( is_multisite() ) {
|
if ( is_multisite() ) {
|
||||||
ms_site_check();
|
ms_site_check();
|
||||||
ms_network_cookies();
|
ms_network_cookies();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user