summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2007-05-21 18:37:58 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2007-05-21 18:37:58 +0000
commit89fe0ff804e7c6497ebacc8b341ac89974f6f255 (patch)
tree3fce310b29c685008fdbb75c5ab531bc3a6ae12a
parenta139071806ba941346a109fbefb2d5f22bae1cc4 (diff)
downloadwordpress-mu-89fe0ff804e7c6497ebacc8b341ac89974f6f255.tar.gz
wordpress-mu-89fe0ff804e7c6497ebacc8b341ac89974f6f255.tar.xz
wordpress-mu-89fe0ff804e7c6497ebacc8b341ac89974f6f255.zip
WP Merge to rev 5499, this is a big one! Test it before you put it live!
Test only, not for production use yet git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@972 7be80a69-a1ef-0310-a953-fb0f7c49ff36
-rw-r--r--wp-admin/admin-ajax.php25
-rw-r--r--wp-admin/admin-db.php20
-rw-r--r--wp-admin/admin-footer.php2
-rw-r--r--wp-admin/admin-functions.php93
-rw-r--r--wp-admin/admin-header.php4
-rw-r--r--wp-admin/cat.js2
-rw-r--r--wp-admin/categories.js2
-rw-r--r--wp-admin/categories.php1
-rw-r--r--wp-admin/comment.php2
-rw-r--r--wp-admin/custom-header.php17
-rw-r--r--wp-admin/dbx-admin-key.js2
-rw-r--r--wp-admin/edit-comments.js42
-rw-r--r--wp-admin/edit-comments.php161
-rw-r--r--wp-admin/edit-form-advanced.php11
-rw-r--r--wp-admin/edit-form-comment.php2
-rw-r--r--wp-admin/edit-link-form.php6
-rw-r--r--wp-admin/edit-page-form.php11
-rw-r--r--wp-admin/edit-pages.php6
-rw-r--r--wp-admin/edit.php4
-rw-r--r--wp-admin/export.php39
-rw-r--r--wp-admin/images/heading-bg.gifbin0 -> 37 bytes
-rw-r--r--wp-admin/import.php7
-rw-r--r--wp-admin/import/blogger.php4
-rw-r--r--wp-admin/import/dotclear.php32
-rw-r--r--wp-admin/import/greymatter.php8
-rw-r--r--wp-admin/import/livejournal.php3
-rw-r--r--wp-admin/import/mt.php3
-rw-r--r--wp-admin/import/rss.php1
-rw-r--r--wp-admin/import/textpattern.php36
-rw-r--r--wp-admin/import/utw.php270
-rw-r--r--wp-admin/import/wordpress.php242
-rw-r--r--wp-admin/import/wp-cat2tag.php226
-rw-r--r--wp-admin/index-extra.php14
-rw-r--r--wp-admin/index.php12
-rw-r--r--wp-admin/link-import.php8
-rw-r--r--wp-admin/link-manager.php2
-rw-r--r--wp-admin/menu.php1
-rw-r--r--wp-admin/moderation.php8
-rw-r--r--wp-admin/options-permalink.php5
-rw-r--r--wp-admin/page.php6
-rw-r--r--wp-admin/plugins.php20
-rw-r--r--wp-admin/post-new.php4
-rw-r--r--wp-admin/post.php6
-rw-r--r--wp-admin/profile.php24
-rw-r--r--wp-admin/rtl.css9
-rw-r--r--wp-admin/themes.php2
-rw-r--r--wp-admin/upgrade-functions.php38
-rw-r--r--wp-admin/upload-functions.php1
-rw-r--r--wp-admin/upload.css1
-rw-r--r--wp-admin/upload.php4
-rw-r--r--wp-admin/user-edit.php6
-rw-r--r--wp-admin/widgets-rtl.css39
-rw-r--r--wp-admin/widgets.css214
-rw-r--r--wp-admin/widgets.php390
-rw-r--r--wp-admin/wp-admin.css30
-rw-r--r--wp-app.php (renamed from app.php)34
-rw-r--r--wp-comments-post.php6
-rw-r--r--wp-config-sample.php60
-rw-r--r--wp-content/index.php4
-rw-r--r--wp-content/themes/classic/functions.php10
-rw-r--r--wp-content/themes/classic/index.php6
-rw-r--r--wp-content/themes/classic/sidebar.php15
-rw-r--r--wp-content/themes/classic/style.css20
-rw-r--r--wp-content/themes/default/archive.php17
-rw-r--r--wp-content/themes/default/comments.php4
-rw-r--r--wp-content/themes/default/footer.php2
-rw-r--r--wp-content/themes/default/functions.php103
-rw-r--r--wp-content/themes/default/sidebar.php14
-rw-r--r--wp-cron.php2
-rw-r--r--wp-includes/author-template.php30
-rw-r--r--wp-includes/bookmark-template.php87
-rw-r--r--wp-includes/bookmark.php24
-rw-r--r--wp-includes/cache.php5
-rw-r--r--wp-includes/category-template.php68
-rw-r--r--wp-includes/category.php80
-rw-r--r--wp-includes/class-phpmailer.php2996
-rw-r--r--wp-includes/class-smtp.php2090
-rw-r--r--wp-includes/class-snoopy.php2
-rw-r--r--wp-includes/classes.php20
-rw-r--r--wp-includes/comment-template.php8
-rw-r--r--wp-includes/comment.php42
-rw-r--r--wp-includes/compat.php7
-rw-r--r--wp-includes/cron.php2
-rw-r--r--wp-includes/default-filters.php7
-rw-r--r--wp-includes/deprecated.php5
-rw-r--r--wp-includes/feed-atom-comments.php6
-rw-r--r--wp-includes/feed-atom.php2
-rw-r--r--wp-includes/feed-rdf.php2
-rw-r--r--wp-includes/feed-rss.php2
-rw-r--r--wp-includes/feed-rss2.php2
-rw-r--r--wp-includes/feed.php8
-rw-r--r--wp-includes/formatting.php19
-rw-r--r--wp-includes/functions.php138
-rw-r--r--wp-includes/general-template.php40
-rw-r--r--wp-includes/gettext.php714
-rw-r--r--wp-includes/images/rss.pngbin0 -> 3341 bytes
-rw-r--r--wp-includes/js/prototype.js1440
-rw-r--r--wp-includes/js/quicktags.js14
-rw-r--r--wp-includes/js/scriptaculous/builder.js17
-rw-r--r--wp-includes/js/scriptaculous/controls.js78
-rw-r--r--wp-includes/js/scriptaculous/dragdrop.js43
-rw-r--r--wp-includes/js/scriptaculous/effects.js126
-rw-r--r--wp-includes/js/scriptaculous/scriptaculous.js21
-rw-r--r--wp-includes/js/scriptaculous/slider.js7
-rw-r--r--wp-includes/js/scriptaculous/sound.js60
-rw-r--r--wp-includes/js/scriptaculous/unittest.js8
-rw-r--r--wp-includes/js/tinymce/plugins/autosave/editor_plugin.js4
-rw-r--r--wp-includes/js/tinymce/plugins/directionality/editor_plugin.js4
-rw-r--r--wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js242
-rw-r--r--wp-includes/js/tinymce/plugins/paste/editor_plugin.js14
-rwxr-xr-xwp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php30
-rw-r--r--wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js2
-rw-r--r--wp-includes/js/tinymce/plugins/wordpress/langs/en.js4
-rw-r--r--wp-includes/js/tinymce/themes/advanced/color_picker.htm67
-rw-r--r--wp-includes/js/tinymce/themes/advanced/css/colorpicker.css53
-rw-r--r--wp-includes/js/tinymce/themes/advanced/css/editor_ui.css10
-rw-r--r--wp-includes/js/tinymce/themes/advanced/editor_template.js76
-rw-r--r--wp-includes/js/tinymce/themes/advanced/images/colors.jpgbin0 -> 3189 bytes
-rw-r--r--wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js221
-rw-r--r--wp-includes/js/tinymce/themes/advanced/jscripts/link.js5
-rw-r--r--wp-includes/js/tinymce/themes/advanced/langs/en.js11
-rw-r--r--wp-includes/js/tinymce/tiny_mce.js146
-rw-r--r--wp-includes/js/tinymce/tiny_mce_config.php7
-rw-r--r--wp-includes/js/tinymce/tiny_mce_gzip.php2
-rw-r--r--wp-includes/js/wp-ajax.js4
-rw-r--r--wp-includes/kses.php440
-rw-r--r--wp-includes/l10n.php36
-rw-r--r--wp-includes/link-template.php177
-rw-r--r--wp-includes/locale.php12
-rw-r--r--wp-includes/pluggable.php2
-rw-r--r--wp-includes/plugin.php180
-rw-r--r--wp-includes/post-template.php73
-rw-r--r--wp-includes/post.php141
-rw-r--r--wp-includes/query.php6
-rw-r--r--wp-includes/rewrite.php31
-rw-r--r--wp-includes/rss.php5
-rw-r--r--wp-includes/script-loader.php61
-rw-r--r--wp-includes/theme.php46
-rw-r--r--wp-includes/user.php2
-rw-r--r--wp-includes/vars.php46
-rw-r--r--wp-includes/version.php2
-rw-r--r--wp-links-opml.php2
-rw-r--r--wp-mail.php19
-rw-r--r--wp-settings.php10
-rw-r--r--xmlrpc.php93
145 files changed, 8142 insertions, 4789 deletions
diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php
index 2ad2469..ad5064f 100644
--- a/wp-admin/admin-ajax.php
+++ b/wp-admin/admin-ajax.php
@@ -151,6 +151,31 @@ case 'add-cat' : // From Manage->Categories
) );
$x->send();
break;
+case 'add-comment' :
+ if ( !current_user_can( 'edit_post', $id ) )
+ die('-1');
+ $search = isset($_POST['s']) ? $_POST['s'] : false;
+ $start = isset($_POST['page']) ? intval($_POST['page']) * 25 : 25;
+
+ list($comments, $total) = _wp_get_comment_list( $search, $start, 1 );
+
+ if ( !$comments )
+ die('1');
+ $x = new WP_Ajax_Response();
+ foreach ( (array) $comments as $comment ) {
+ get_comment( $comment );
+ ob_start();
+ _wp_comment_list_item( $comment->comment_ID );
+ $comment_list_item = ob_get_contents();
+ ob_end_clean();
+ $x->add( array(
+ 'what' => 'comment',
+ 'id' => $comment->comment_ID,
+ 'data' => $comment_list_item
+ ) );
+ }
+ $x->send();
+ break;
case 'add-meta' :
if ( !current_user_can( 'edit_post', $id ) )
die('-1');
diff --git a/wp-admin/admin-db.php b/wp-admin/admin-db.php
index de90ad7..24e2388 100644
--- a/wp-admin/admin-db.php
+++ b/wp-admin/admin-db.php
@@ -125,6 +125,11 @@ function wp_insert_category($catarr) {
else
$links_private = 0;
+
+ // Let's check if we have this category already, if so just do an update
+ if ( !$update && $cat_ID = category_object_exists( $category_nicename ) )
+ $update = true;
+
if (!$update) {
$maxcat = $wpdb->get_var( "SELECT max(cat_ID) FROM {$wpdb->categories}" );
$cat_ID = mt_rand( $maxcat+100, $maxcat+4000 );
@@ -153,6 +158,11 @@ function wp_insert_category($catarr) {
clean_category_cache($cat_ID);
+ if ($update)
+ do_action('edited_category', $cat_ID);
+ else
+ do_action('created_category', $cat_ID);
+
return $cat_ID;
}
@@ -245,6 +255,14 @@ function wp_create_categories($categories, $post_id = '') {
return $cat_ids;
}
+function category_object_exists($cat_name) {
+ global $wpdb;
+ if (!$category_nicename = sanitize_title($cat_name))
+ return 0;
+
+ return (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'");
+}
+
function category_exists($cat_name) {
global $wpdb;
if (!$category_nicename = sanitize_title($cat_name))
@@ -419,6 +437,8 @@ function wp_delete_link($link_id) {
$wpdb->query("DELETE FROM $wpdb->link2cat WHERE link_id = '$link_id'");
return $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$link_id'");
+
+ do_action('deleted_link', $link_id);
}
function wp_get_link_cats($link_ID = 0) {
diff --git a/wp-admin/admin-footer.php b/wp-admin/admin-footer.php
index 8e30631..40a3e8c 100644
--- a/wp-admin/admin-footer.php
+++ b/wp-admin/admin-footer.php
@@ -2,7 +2,7 @@
<div id="footer">
<p class="logo"><a href="http://wordpress.org/" id="wordpress-logo"><img src="images/wordpress-logo.png" alt="WordPress" /></a></p>
<p class="docs"><?php _e('<a href="http://codex.wordpress.org/">Documentation</a>'); ?> &#8212; <?php _e('<a href="http://wordpress.org/support/">Support Forums</a>'); ?><br />
-<?php bloginfo('version'); ?> &#8212; <?php printf(__('%s seconds'), timer_stop(0, 2)); ?></p>
+<?php printf( __('Version %s'), get_bloginfo('version') ); ?></p>
</div>
<?php do_action('admin_footer', ''); ?>
<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php
index 7b9507c..10f8eeb 100644
--- a/wp-admin/admin-functions.php
+++ b/wp-admin/admin-functions.php
@@ -490,7 +490,7 @@ function edit_user( $user_id = 0 ) {
if ( isset( $_POST['email'] ))
$user->user_email = wp_specialchars( trim( $_POST['email'] ));
if ( isset( $_POST['url'] ) ) {
- $user->user_url = wp_specialchars( trim( $_POST['url'] ));
+ $user->user_url = clean_url( trim( $_POST['url'] ));
$user->user_url = preg_match('/^(https?|ftps?|mailto|news|irc|gopher|nntp|feed|telnet):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url;
}
if ( isset( $_POST['first_name'] ))
@@ -702,6 +702,7 @@ function get_nested_categories( $default = 0, $parent = 0 ) {
}
}
+ $result = apply_filters('get_nested_categories', $result);
usort( $result, 'sort_cats' );
return $result;
@@ -774,6 +775,8 @@ function cat_rows( $parent = 0, $level = 0, $categories = 0 ) {
if (!$categories )
$categories = get_categories( 'hide_empty=0' );
+ $children = _get_category_hierarchy();
+
if ( $categories ) {
ob_start();
foreach ( $categories as $category ) {
@@ -783,7 +786,8 @@ function cat_rows( $parent = 0, $level = 0, $categories = 0 ) {
}
if ( $category->category_parent == $parent) {
echo "\t" . _cat_row( $category, $level );
- cat_rows( $category->cat_ID, $level +1, $categories );
+ if ( isset($children[$category->cat_ID]) )
+ cat_rows( $category->cat_ID, $level +1, $categories );
}
}
$output = ob_get_contents();
@@ -815,8 +819,8 @@ function _cat_row( $category, $level, $name_override = false ) {
$class = ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'";
- $category->category_count = number_format( $category->category_count );
- $category->link_count = number_format( $category->link_count );
+ $category->category_count = number_format_i18n( $category->category_count );
+ $category->link_count = number_format_i18n( $category->link_count );
$posts_count = ( $category->category_count > 0 ) ? "<a href='edit.php?cat=$category->cat_ID'>$category->category_count</a>" : $category->category_count;
return "<tr id='cat-$category->cat_ID'$class>
<th scope='row' style='text-align: center'>$category->cat_ID</th>
@@ -898,6 +902,68 @@ function user_row( $user_object, $style = '' ) {
return $r;
}
+function _wp_get_comment_list( $s = false, $start, $num ) {
+ global $wpdb;
+
+ $start = (int) $start;
+ $num = (int) $num;
+
+ if ( $s ) {
+ $s = $wpdb->escape($s);
+ $comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE
+ (comment_author LIKE '%$s%' OR
+ comment_author_email LIKE '%$s%' OR
+ comment_author_url LIKE ('%$s%') OR
+ comment_author_IP LIKE ('%$s%') OR
+ comment_content LIKE ('%$s%') ) AND
+ comment_approved != 'spam'
+ ORDER BY comment_date DESC LIMIT $start, $num");
+ } else {
+ $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $start, $num" );
+ }
+
+ $total = $wpdb->get_var( "SELECT FOUND_ROWS()" );
+
+ return array($comments, $total);
+}
+
+function _wp_comment_list_item( $id, $alt = 0 ) {
+ global $authordata, $comment, $wpdb;
+ $id = (int) $id;
+ $comment =& get_comment( $id );
+ $class = '';
+ $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
+ $comment_status = wp_get_comment_status($comment->comment_ID);
+ if ( 'unapproved' == $comment_status )
+ $class .= ' unapproved';
+ if ( $alt % 2 )
+ $class .= ' alternate';
+ echo "<li id='comment-$comment->comment_ID' class='$class'>";
+?>
+<p><strong><?php comment_author(); ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
+
+<?php comment_text() ?>
+
+<p><?php comment_date(__('M j, g:i A')); ?> &#8212; [
+<?php
+if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
+ echo " <a href='comment.php?action=editcomment&amp;c=".$comment->comment_ID."'>" . __('Edit') . '</a>';
+ echo ' | <a href="' . wp_nonce_url('ocomment.php?action=deletecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> ';
+ if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) {
+ echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>';
+ echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>';
+ }
+ echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&amp;dt=spam&amp;p=" . $comment->comment_post_ID . "&amp;c=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to mark as spam this comment by '%s'.\n'Cancel' to stop, 'OK' to mark as spam."), $comment->comment_author)) . "', theCommentList );\">" . __('Spam') . "</a> ";
+}
+$post = get_post($comment->comment_post_ID);
+$post_title = wp_specialchars( $post->post_title, 'double' );
+$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
+?>
+ ] &#8212; <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php echo $post_title; ?></a></p>
+ </li>
+<?php
+}
+
function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
global $wpdb;
if (!$categories )
@@ -1279,6 +1345,7 @@ function get_page_templates() {
function page_template_dropdown( $default = '' ) {
$templates = get_page_templates();
+ ksort( $templates );
foreach (array_keys( $templates ) as $template )
: if ( $default == $templates[$template] )
$selected = " selected='selected'";
@@ -1684,7 +1751,7 @@ function get_plugin_data( $plugin_file ) {
$author = '<a href="' . trim( $author_uri[1] ) . '" title="'.__( 'Visit author homepage' ).'">' . trim( $author_name[1] ) . '</a>';
}
- return array ('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1] );
+ return array('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version);
}
function get_plugins() {
@@ -1701,20 +1768,20 @@ function get_plugins() {
$plugins_dir = @ dir( $plugin_root);
if ( $plugins_dir ) {
while (($file = $plugins_dir->read() ) !== false ) {
- if ( preg_match( '|^\.+$|', $file ))
+ if ( substr($file, 0, 1) == '.' )
continue;
if ( is_dir( $plugin_root.'/'.$file ) ) {
$plugins_subdir = @ dir( $plugin_root.'/'.$file );
if ( $plugins_subdir ) {
while (($subfile = $plugins_subdir->read() ) !== false ) {
- if ( preg_match( '|^\.+$|', $subfile ))
+ if ( substr($subfile, 0, 1) == '.' )
continue;
- if ( preg_match( '|\.php$|', $subfile ))
+ if ( substr($subfile, -4) == '.php' )
$plugin_files[] = "$file/$subfile";
}
}
} else {
- if ( preg_match( '|\.php$|', $file ))
+ if ( substr($file, -4) == '.php' )
$plugin_files[] = $file;
}
}
@@ -1795,7 +1862,7 @@ function register_importer( $id, $name, $description, $callback ) {
function get_importers() {
global $wp_importers;
-
+ uasort($wp_importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);'));
return $wp_importers;
}
@@ -1878,8 +1945,11 @@ function wp_handle_upload( &$file, $overrides = false ) {
extract( $wp_filetype );
- if ( !$type || !$ext )
+ if ( ( !$type || !$ext ) && !current_user_can( 'unfiltered_upload' ) )
return $upload_error_handler( $file, __( 'File type does not meet security guidelines. Try another.' ));
+
+ if ( !$ext )
+ $ext = strrchr($file['name'], '.');
}
// A writable uploads dir will pass this test. Again, there's no point overriding this one.
@@ -1950,6 +2020,7 @@ function wp_import_upload_form( $action ) {
?>
<form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo attribute_escape($action) ?>">
<p>
+<?php wp_nonce_field('import-upload'); ?>
<label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?> )
<input type="file" id="upload" name="import" size="25" />
<input type="hidden" name="action" value="save" />
diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php
index 9f6402b..d6ff2ef 100644
--- a/wp-admin/admin-header.php
+++ b/wp-admin/admin-header.php
@@ -13,7 +13,7 @@ get_admin_page_title();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
+<html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
<title><?php bloginfo('name') ?> &rsaquo; <?php echo wp_specialchars( strip_tags( $title ) ); ?> &#8212; WordPress</title>
@@ -44,7 +44,7 @@ do_action('admin_head');
</head>
<body>
<div id="wphead">
-<h1><?php echo wptexturize(get_bloginfo(('name'))); ?> <span>(<a href="<?php echo get_option('home') . '/'; ?>"><?php _e('View site &raquo;') ?></a>)</span></h1>
+<h1><?php bloginfo('name'); ?> <span>(<a href="<?php echo get_option('home') . '/'; ?>"><?php _e('View site &raquo;') ?></a>)</span></h1>
</div>
<div id="user_info"><p><?php printf(__('Howdy, <strong>%s</strong>.'), $user_identity) ?> [<a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="<?php _e('Log out of this account') ?>"><?php _e('Sign Out'); ?></a>, <a href="profile.php"><?php _e('My Profile'); ?></a>] </p></div>
diff --git a/wp-admin/cat.js b/wp-admin/cat.js
index ab94d4c..e93adfc 100644
--- a/wp-admin/cat.js
+++ b/wp-admin/cat.js
@@ -4,7 +4,7 @@ function newCatAddIn() {
var jaxcat = $('jaxcat');
if ( !jaxcat )
return false;
- Element.update(jaxcat,'<span id="ajaxcat"><input type="text" name="newcat" id="newcat" size="16" autocomplete="off"/><input type="button" name="Button" id="catadd" value="' + catL10n.add + '"/><span id="howto">' + catL10n.how + '</span></span>');
+ Element.update(jaxcat,'<span id="ajaxcat"><input type="text" name="newcat" id="newcat" size="16" autocomplete="off"/><input type="button" name="Button" id="catadd" value="' + catL10n.add + '"/><input type="hidden"/><span id="howto">' + catL10n.how + '</span></span>');
$('newcat').onkeypress = function(e) { return killSubmit("catList.ajaxAdder('category','jaxcat');", e); };
$('catadd').onclick = function() { catList.ajaxAdder('category', 'jaxcat'); };
}
diff --git a/wp-admin/categories.js b/wp-admin/categories.js
index 8951df0..515d530 100644
--- a/wp-admin/categories.js
+++ b/wp-admin/categories.js
@@ -2,7 +2,7 @@ addLoadEvent(function() {
if (!theList.theList) return false;
document.forms.addcat.submit.onclick = function(e) {return killSubmit('theList.ajaxAdder("cat", "addcat");', e); };
theList.addComplete = function(what, where, update, transport) {
- var name = getNodeValue(transport.responseXML, 'name');
+ var name = getNodeValue(transport.responseXML, 'name').unescapeHTML();
var id = transport.responseXML.getElementsByTagName(what)[0].getAttribute('id');
var options = document.forms['addcat'].category_parent.options;
options[options.length] = new Option(name, id);
diff --git a/wp-admin/categories.php b/wp-admin/categories.php
index 5e77e0f..40bdbf9 100644
--- a/wp-admin/categories.php
+++ b/wp-admin/categories.php
@@ -118,6 +118,7 @@ cat_rows();
</div>
<?php include('edit-category-form.php'); ?>
+
<?php endif; ?>
<?php
diff --git a/wp-admin/comment.php b/wp-admin/comment.php
index 063b825..6c0872d 100644
--- a/wp-admin/comment.php
+++ b/wp-admin/comment.php
@@ -91,7 +91,7 @@ case 'mac':
<?php if ( $comment->comment_author_url ) { ?>
<tr>
<th scope="row"><?php _e('URL:'); ?></th>
-<td><?php echo $comment->comment_author_url; ?></td>
+<td><?php echo "<a href='$comment->comment_author_url'>$comment->comment_author_url</a>"; ?></td>
</tr>
<?php } ?>
<tr>
diff --git a/wp-admin/custom-header.php b/wp-admin/custom-header.php
index 5daad1e..d18ed87 100644
--- a/wp-admin/custom-header.php
+++ b/wp-admin/custom-header.php
@@ -23,6 +23,7 @@ class Custom_Image_Header {
function js() {
if ( isset( $_POST['textcolor'] ) ) {
+ check_admin_referer('custom-header');
if ( 'blank' == $_POST['textcolor'] ) {
set_theme_mod('header_textcolor', 'blank');
} else {
@@ -31,8 +32,10 @@ class Custom_Image_Header {
set_theme_mod('header_textcolor', $color);
}
}
- if ( isset($_POST['resetheader']) )
+ if ( isset($_POST['resetheader']) ) {
+ check_admin_referer('custom-header');
remove_theme_mods();
+ }
?>
<script type="text/javascript">
@@ -157,7 +160,7 @@ Event.observe( window, 'load', hide_text );
<h2><?php _e('Your Header Image'); ?></h2>
<p><?php _e('This is your header image. You can change the text color or upload and crop a new image.'); ?></p>
-<div id="headimg" style="background: url(<?php header_image() ?>) no-repeat;">
+<div id="headimg" style="background: url(<?php clean_url(header_image()) ?>) no-repeat;">
<h1><a onclick="return false;" href="<?php bloginfo('url'); ?>" title="<?php bloginfo('name'); ?>" id="name"><?php bloginfo('name'); ?></a></h1>
<div id="desc"><?php bloginfo('description');?></div>
</div>
@@ -165,7 +168,8 @@ Event.observe( window, 'load', hide_text );
<form method="post" action="<?php echo get_option('siteurl') ?>/wp-admin/themes.php?page=custom-header&amp;updated=true">
<input type="button" value="<?php _e('Hide Text'); ?>" onclick="hide_text()" id="hidetext" />
<input type="button" value="<?php _e('Select a Text Color'); ?>" onclick="colorSelect($('textcolor'), 'pickcolor')" id="pickcolor" /><input type="button" value="<?php _e('Use Original Color'); ?>" onclick="colorDefault()" id="defaultcolor" />
-<input type="hidden" name="textcolor" id="textcolor" value="#<?php header_textcolor() ?>" /><input name="submit" type="submit" value="<?php _e('Save Changes'); ?> &raquo;" /></form>
+<?php wp_nonce_field('custom-header') ?>
+<input type="hidden" name="textcolor" id="textcolor" value="#<?php attribute_escape(header_textcolor()) ?>" /><input name="submit" type="submit" value="<?php _e('Save Changes'); ?> &raquo;" /></form>
<?php } ?>
<div id="colorPickerDiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;visibility:hidden;"> </div>
@@ -177,6 +181,7 @@ Event.observe( window, 'load', hide_text );
<form enctype="multipart/form-data" id="uploadForm" method="POST" action="<?php echo attribute_escape(add_query_arg('step', 2)) ?>" style="margin: auto; width: 50%;">
<label for="upload"><?php _e('Choose an image from your computer:'); ?></label><br /><input type="file" id="upload" name="import" />
<input type="hidden" name="action" value="save" />
+<?php wp_nonce_field('custom-header') ?>
<p class="submit">
<input type="submit" value="<?php _e('Upload'); ?> &raquo;" />
</p>
@@ -189,6 +194,7 @@ Event.observe( window, 'load', hide_text );
<h2><?php _e('Reset Header Image and Color'); ?></h2>
<p><?php _e('This will restore the original header image and color. You will not be able to retrieve any customizations.') ?></p>
<form method="post" action="<?php echo attribute_escape(add_query_arg('step', 1)) ?>">
+<?php wp_nonce_field('custom-header'); ?>
<input type="submit" name="resetheader" value="<?php _e('Restore Original Header'); ?>" />
</form>
</div>
@@ -197,6 +203,7 @@ Event.observe( window, 'load', hide_text );
}
function step_2() {
+ check_admin_referer('custom-header');
$overrides = array('test_form' => false);
$file = wp_handle_upload($_FILES['import'], $overrides);
@@ -222,7 +229,7 @@ Event.observe( window, 'load', hide_text );
list($width, $height, $type, $attr) = getimagesize( $file );
if ( $width == HEADER_IMAGE_WIDTH && $height == HEADER_IMAGE_HEIGHT ) {
- set_theme_mod('header_image', $url);
+ set_theme_mod('header_image', clean_url($url));
$header = apply_filters('wp_create_file_in_uploads', $file, $id); // For replication
return $this->finished();
} elseif ( $width > HEADER_IMAGE_WIDTH ) {
@@ -256,6 +263,7 @@ Event.observe( window, 'load', hide_text );
<input type="hidden" name="height" id="height" />
<input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo $id; ?>" />
<input type="hidden" name="oitar" id="oitar" value="<?php echo $oitar; ?>" />
+<?php wp_nonce_field('custom-header') ?>
<input type="submit" value="<?php _e('Crop Header &raquo;'); ?>" />
</p>
@@ -265,6 +273,7 @@ Event.observe( window, 'load', hide_text );
}
function step_3() {
+ check_admin_referer('custom-header');
if ( $_POST['oitar'] > 1 ) {
$_POST['x1'] = $_POST['x1'] * $_POST['oitar'];
$_POST['y1'] = $_POST['y1'] * $_POST['oitar'];
diff --git a/wp-admin/dbx-admin-key.js b/wp-admin/dbx-admin-key.js
index 9ea666c..3b3f7af 100644
--- a/wp-admin/dbx-admin-key.js
+++ b/wp-admin/dbx-admin-key.js
@@ -1,4 +1,4 @@
-addLoadEvent( function() {var manager = new dbxManager( dbxL10n.mananger );} );
+addLoadEvent( function() {var manager = new dbxManager( dbxL10n.manager );} );
addLoadEvent( function()
{
diff --git a/wp-admin/edit-comments.js b/wp-admin/edit-comments.js
index 4dfe755..e1fc68f 100644
--- a/wp-admin/edit-comments.js
+++ b/wp-admin/edit-comments.js
@@ -2,15 +2,51 @@ addLoadEvent(function() {
theCommentList = new listMan('the-comment-list');
if ( !theCommentList )
return false;
+
+ theExtraCommentList = new listMan('the-extra-comment-list');
+ if ( theExtraCommentList ) {
+ theExtraCommentList.showLink = 0;
+ theExtraCommentList.altOffset = 1;
+ if ( theExtraCommentList.theList && theExtraCommentList.theList.childNodes )
+ var commentNum = $A(theExtraCommentList.theList.childNodes).findAll( function(i) { return Element.visible(i) } ).length;
+ else
+ var commentNum = 0;
+ var urlQ = document.location.href.split('?');
+ var params = urlQ[1] ? urlQ[1].toQueryParams() : [];
+ var search = params['s'] ? params['s'] : '';
+ var page = params['apage'] ? params['apage'] : 1;
+ }
+
theCommentList.dimComplete = function(what,id,dimClass) {
var m = document.getElementById('awaitmod');
- if ( document.getElementById(what + '-' + id).className.match(dimClass) ) m.innerHTML = parseInt(m.innerHTML,10) + 1;
- else m.innerHTML = parseInt(m.innerHTML,10) - 1;
+ if ( document.getElementById(what + '-' + id).className.match(dimClass) )
+ m.innerHTML = parseInt(m.innerHTML,10) + 1;
+ else
+ m.innerHTML = parseInt(m.innerHTML,10) - 1;
}
+
theCommentList.delComplete = function(what,id) {
var m = document.getElementById('awaitmod');
- if ( document.getElementById(what + '-' + id).className.match('unapproved') ) m.innerHTML = parseInt(m.innerHTML,10) - 1;
+ what = what.split('-')[0];
+ if ( document.getElementById(what + '-' + id).className.match('unapproved') )
+ m.innerHTML = parseInt(m.innerHTML,10) - 1;
+ if ( theExtraCommentList && commentNum ) {
+ var theMover = theExtraCommentList.theList.childNodes[0];
+ Element.removeClassName(theMover,'alternate');
+ theCommentList.theList.appendChild(theMover);
+ theExtraCommentList.inputData += '&page=' + page;
+ if ( search )
+ theExtraCommentList.inputData += '&s=' + search; // trust the URL not the search box
+ theExtraCommentList.addComplete = function() {
+ if ( theExtraCommentList.theList.childNodes )
+ var commentNum = $A(theExtraCommentList.theList.childNodes).findAll( function(i) { return Element.visible(i) } ).length;
+ else
+ var commentNum = 0;
+ }
+ theExtraCommentList.ajaxAdder( 'comment', 'ajax-response' ); // Dummy Request
+ }
}
+
if ( theList ) // the post list: edit.php
theList.delComplete = function() {
var comments = document.getElementById('comments');
diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php
index 0557270..bbd5e22 100644
--- a/wp-admin/edit-comments.php
+++ b/wp-admin/edit-comments.php
@@ -75,104 +75,53 @@ if ( !empty( $_POST['delete_comments'] ) ) :
echo '</p></div>';
endif;
-if (isset($_GET['s'])) {
- $s = $wpdb->escape($_GET['s']);
- $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE
- (comment_author LIKE '%$s%' OR
- comment_author_email LIKE '%$s%' OR
- comment_author_url LIKE ('%$s%') OR
- comment_author_IP LIKE ('%$s%') OR
- comment_content LIKE ('%$s%') ) AND
- comment_approved != 'spam'
- ORDER BY comment_date DESC");
-} else {
- if ( isset( $_GET['apage'] ) )
- $page = (int) $_GET['apage'];
- else
- $page = 1;
- $start = $offset = ( $page - 1 ) * 20;
+if ( isset( $_GET['apage'] ) )
+ $page = (int) $_GET['apage'];
+else
+ $page = 1;
- $comments = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $start, 20" );
- $total = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1'" );
-}
-?>
-<?php if ( $total > 20 ) {
-$total_pages = ceil( $total / 20 );
-$r = '';
-if ( 1 < $page ) {
- $args['apage'] = ( 1 == $page - 1 ) ? FALSE : $page - 1;
- $r .= '<a class="prev" href="' . clean_url(add_query_arg( $args )) . '">&laquo; '. __('Previous Page') .'</a>' . "\n";
-}
-if ( ( $total_pages = ceil( $total / 20 ) ) > 1 ) {
- for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) :
- if ( $page == $page_num ) :
- $r .= "<span>$page_num</span>\n";
- else :
- $p = false;
- if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) :
- $args['apage'] = ( 1 == $page_num ) ? FALSE : $page_num;
- $r .= '<a class="page-numbers" href="' . clean_url(add_query_arg($args)) . '">' . ( $page_num ) . "</a>\n";
- $in = true;
- elseif ( $in == true ) :
- $r .= "...\n";
- $in = false;
- endif;
- endif;
- endfor;
-}
-if ( ( $page ) * 20 < $total || -1 == $total ) {
- $args['apage'] = $page + 1;
- $r .= '<a class="next" href="' . clean_url(add_query_arg($args)) . '">'. __('Next Page') .' &raquo;</a>' . "\n";
-}
-echo "<p class='pagenav'>$r</p>";
-?>
+$start = $offset = ( $page - 1 ) * 20;
-<?php } ?>
+list($_comments, $total) = _wp_get_comment_list( isset($_GET['s']) ? $_GET['s'] : false, $start, 25 ); // Grab a few extra
+
+$comments = array_slice($_comments, 0, 20);
+$extra_comments = array_slice($_comments, 20);
+
+$page_links = paginate_links( array(
+ 'base' => add_query_arg( 'apage', '%_%' ),
+ 'format' => '',
+ 'total' => ceil($total / 20),
+ 'current' => $page
+));
+
+if ( $page_links )
+ echo "<p class='pagenav'>$page_links</p>";
-<?php
if ('view' == $mode) {
if ($comments) {
-?>
-<?php
-$offset = $offset + 1;
-$start = " start='$offset'";
+ $offset = $offset + 1;
+ $start = " start='$offset'";
- echo "<ol id='the-comment-list' class='commentlist' $start>";
+ echo "<ol id='the-comment-list' class='commentlist' $start>\n";
$i = 0;
- foreach ($comments as $comment) {
- ++$i; $class = '';
- $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
- $comment_status = wp_get_comment_status($comment->comment_ID);
- if ('unapproved' == $comment_status)
- $class .= ' unapproved';
- if ($i % 2)
- $class .= ' alternate';
- echo "<li id='comment-$comment->comment_ID' class='$class'>";
-?>
-<p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
-
-<?php comment_text() ?>
+ foreach ( $comments as $comment ) {
+ get_comment( $comment ); // Cache it
+ _wp_comment_list_item( $comment->comment_ID, ++$i );
+ }
+ echo "</ol>\n\n";
-<p><?php comment_date(__('M j, g:i A')); ?> &#8212; [
+if ( $extra_comments ) : ?>
+<div id="extra-comments" style="display:none">
+<ul id="the-extra-comment-list" class="commentlist">
<?php
-if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
- echo " <a href='comment.php?action=editcomment&amp;c=".$comment->comment_ID."'>" . __('Edit') . '</a>';
- echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> ';
- if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) {
- echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>';
- echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>';
+ foreach ( $extra_comments as $comment ) {
+ get_comment( $comment ); // Cache it
+ _wp_comment_list_item( $comment->comment_ID, ++$i );
}
- echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&amp;dt=spam&amp;p=" . $comment->comment_post_ID . "&amp;c=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to mark as spam this comment by '%s'.\n'Cancel' to stop, 'OK' to mark as spam."), $comment->comment_author)) . "', theCommentList );\">" . __('Spam') . "</a> ";
-}
-$post = get_post($comment->comment_post_ID);
-$post_title = wp_specialchars( $post->post_title, 'double' );
-$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
?>
- ] &#8212; <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php echo $post_title; ?></a></p>
- </li>
-
-<?php } // end foreach($comment) ?>
-</ol>
+</ul>
+</div>
+<?php endif; // $extra_comments ?>
<div id="ajax-response"></div>
@@ -208,7 +157,7 @@ $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
$class .= ('unapproved' == $comment_status) ? ' unapproved' : '';
?>
<tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $class; ?>'>
- <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { ?><input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /><?php } ?></td>
+ <td style="text-align: center"><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { ?><input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /><?php } ?></td>
<td><?php comment_author_link() ?></td>
<td><?php comment_author_email_link() ?></td>
<td><a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></td>
@@ -242,39 +191,11 @@ $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
<?php
} // end if ($comments)
}
- ?>
-<?php if ( $total > 20 ) {
-$total_pages = ceil( $total / 20 );
-$r = '';
-if ( 1 < $page ) {
- $args['apage'] = ( 1 == $page - 1 ) ? FALSE : $page - 1;
- $r .= '<a class="prev" href="' . clean_url(add_query_arg( $args )) . '">&laquo; '. __('Previous Page') .'</a>' . "\n";
-}
-if ( ( $total_pages = ceil( $total / 20 ) ) > 1 ) {
- for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) :
- if ( $page == $page_num ) :
- $r .= "<span>$page_num</span>\n";
- else :
- $p = false;
- if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) :
- $args['apage'] = ( 1 == $page_num ) ? FALSE : $page_num;
- $r .= '<a class="page-numbers" href="' . clean_url(add_query_arg($args)) . '">' . ( $page_num ) . "</a>\n";
- $in = true;
- elseif ( $in == true ) :
- $r .= "...\n";
- $in = false;
- endif;
- endif;
- endfor;
-}
-if ( ( $page ) * 20 < $total || -1 == $total ) {
- $args['apage'] = $page + 1;
- $r .= '<a class="next" href="' . clean_url(add_query_arg($args)) . '">'. __('Next Page') .' &raquo;</a>' . "\n";
-}
-echo "<p class='pagenav'>$r</p>";
-?>
-<?php } ?>
+if ( $page_links )
+ echo "<p class='pagenav'>$page_links</p>";
+
+?>
</div>
diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php
index cdf467a..b934ed8 100644
--- a/wp-admin/edit-form-advanced.php
+++ b/wp-admin/edit-form-advanced.php
@@ -144,7 +144,14 @@ endforeach;
</fieldset>
<fieldset id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>">
-<legend><?php _e('Post') ?></legend>
+<legend><?php _e('Post') ?>
+
+<?php if ( 'publish' == $post->post_status ) { ?>
+<a href="<?php echo clean_url(get_permalink($post->ID)); ?>" class="view-link" target="_blank"><?php _e('View &raquo;'); ?></a>
+<?php } elseif ( 'edit' == $action ) { ?>
+<a href="<?php echo clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" class="view-link" target="_blank"><?php _e('Preview &raquo;'); ?></a>
+<?php } ?>
+</legend>
<?php the_editor($post->post_content); ?>
</fieldset>
@@ -183,7 +190,7 @@ if (current_user_can('upload_files')) {
$uploading_iframe_src = wp_nonce_url("upload.php?style=inline&amp;tab=upload&amp;post_id=$uploading_iframe_ID", 'inlineuploading');
$uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
if ( false != $uploading_iframe_src )
- echo '<iframe id="uploading" frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
+ echo '<iframe id="uploading" name="uploading" frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
}
?>
diff --git a/wp-admin/edit-form-comment.php b/wp-admin/edit-form-comment.php
index 92897b2..3e278bc 100644
--- a/wp-admin/edit-form-comment.php
+++ b/wp-admin/edit-form-comment.php
@@ -32,7 +32,7 @@ addLoadEvent(focusit);
<fieldset id="uridiv">
<legend><label for="newcomment_author_url"><?php _e('URL:') ?></label></legend>
<div>
- <input type="text" id="newcomment_author_url" name="newcomment_author_url" size="35" value="<?php echo $comment->comment_author_url ?>" tabindex="3" id="URL" />
+ <input type="text" id="newcomment_author_url" name="newcomment_author_url" size="35" value="<?php echo $comment->comment_author_url ?>" tabindex="3" />
</div>
</fieldset>
diff --git a/wp-admin/edit-link-form.php b/wp-admin/edit-link-form.php
index 41381d9..4e0eece 100644
--- a/wp-admin/edit-link-form.php
+++ b/wp-admin/edit-link-form.php
@@ -80,15 +80,15 @@ function xfn_check($class, $value = '', $type = 'check') {
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
<tr>
<th scope="row" valign="top"><label for="link_name"><?php _e('Name:') ?></label></th>
-<td><input type="text" name="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></td>
+<td><input type="text" name="link_name" id="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></td>
</tr>
<tr>
<th width="20%" scope="row" valign="top"><label for="link_url"><?php _e('Address:') ?></label></th>
-<td width="80%"><input type="text" name="link_url" value="<?php echo $link->link_url; if ( empty( $link->link_url ) ) echo 'http://'; ?>" style="width: 95%" /></td>
+<td width="80%"><input type="text" name="link_url" id="link_url" value="<?php echo $link->link_url; if ( empty( $link->link_url ) ) echo 'http://'; ?>" style="width: 95%" /></td>
</tr>
<tr>
<th scope="row" valign="top"><label for="link_description"><?php _e('Description:') ?></label></th>
-<td><input type="text" name="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></td>
+<td><input type="text" name="link_description" id="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></td>
</tr>
</table>
diff --git a/wp-admin/edit-page-form.php b/wp-admin/edit-page-form.php
index f55f733..f7083fd 100644
--- a/wp-admin/edit-page-form.php
+++ b/wp-admin/edit-page-form.php
@@ -131,7 +131,14 @@ endforeach;
<fieldset id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>">
- <legend><?php _e('Page Content') ?></legend>
+<legend><?php _e('Page Content') ?>
+
+<?php if ( 'publish' == $post->post_status ) { ?>
+<a href="<?php echo clean_url(get_permalink($post->ID)); ?>" style="position: absolute; right: 2em; margin-right: 19em; text-decoration: underline;" target="_blank"><?php _e('View &raquo;'); ?></a>
+<?php } elseif ( 'edit' == $action ) { ?>
+<a href="<?php echo clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" style="position: absolute; right: 2em; margin-right: 19em; text-decoration: underline;" target="_blank"><?php _e('Preview &raquo;'); ?></a>
+<?php } ?>
+</legend>
<?php the_editor($post->post_content); ?>
</fieldset>
@@ -156,7 +163,7 @@ if (current_user_can('upload_files')) {
$uploading_iframe_src = wp_nonce_url("upload.php?style=inline&amp;tab=upload&amp;post_id=$uploading_iframe_ID", 'inlineuploading');
$uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
if ( false != $uploading_iframe_src )
- echo '<iframe id="uploading" frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
+ echo '<iframe id="uploading" name="uploading" frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
}
?>
diff --git a/wp-admin/edit-pages.php b/wp-admin/edit-pages.php
index 627a031..3218a1f 100644
--- a/wp-admin/edit-pages.php
+++ b/wp-admin/edit-pages.php
@@ -10,14 +10,16 @@ require_once('admin-header.php');
<h2><?php _e('Page Management'); ?></h2>
<p><?php _e('Pages are like posts except they live outside of the normal blog chronology and can be hierarchical. You can use pages to organize and manage any amount of content.'); ?> <a href="page-new.php"><?php _e('Create a new page &raquo;'); ?></a></p>
-<form name="searchform" action="" method="get">
+<form name="searchform" id="searchform" action="" method="get">
<fieldset>
<legend><?php _e('Search Pages&hellip;') ?></legend>
- <input type="text" name="s" value="<?php if (isset($_GET['s'])) echo attribute_escape($_GET['s']); ?>" size="17" />
+ <input type="text" name="s" id="s" value="<?php if (isset($_GET['s'])) echo attribute_escape($_GET['s']); ?>" size="17" />
<input type="submit" name="submit" value="<?php _e('Search') ?>" />
</fieldset>
</form>
+<br style="clear:both;" />
+
<?php
wp('post_type=page&orderby=menu_order&what_to_show=posts&posts_per_page=-1&posts_per_archive_page=-1&order=asc');
diff --git a/wp-admin/edit.php b/wp-admin/edit.php
index 47f5ad8..fcb01a1 100644
--- a/wp-admin/edit.php
+++ b/wp-admin/edit.php
@@ -76,7 +76,7 @@ if ( is_month() ) {
<form name="searchform" id="searchform" action="" method="get">
<fieldset>
<legend><?php _e('Search Posts&hellip;') ?></legend>
- <input type="text" name="s" value="<?php if (isset($s)) echo attribute_escape($s); ?>" size="17" />
+ <input type="text" name="s" id="s" value="<?php if (isset($s)) echo attribute_escape($s); ?>" size="17" />
<input type="submit" name="submit" value="<?php _e('Search') ?>" class="button" />
</fieldset>
</form>
@@ -196,7 +196,7 @@ foreach($posts_columns as $column_name=>$column_display_name) {
case 'comments':
?>
<td style="text-align: center">
- <?php comments_number(__('0'), "<a href='edit.php?p=$id&amp;c=1'>" . __('1') . '</a>', "<a href='edit.php?p=$id&amp;c=1'>" . __('%') . '</a>') ?>
+ <?php comments_number("<a href='edit.php?p=$id&amp;c=1'>" . __('0') . '</a>', "<a href='edit.php?p=$id&amp;c=1'>" . __('1') . '</a>', "<a href='edit.php?p=$id&amp;c=1'>" . __('%') . '</a>') ?>
</td>
<?php
break;
diff --git a/wp-admin/export.php b/wp-admin/export.php
index b763412..51e007a 100644
--- a/wp-admin/export.php
+++ b/wp-admin/export.php
@@ -123,22 +123,30 @@ function wxr_category_description($c) {
echo '<wp:category_description>' . wxr_cdata($c->category_description) . '</wp:category_description>';
}
+
+print '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?' . ">\n";
+
?>
-<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your blog. -->
-<!-- It contains information about your blog's posts, comments, and categories. -->
-<!-- You may use this file to transfer that content from one site to another. -->
-<!-- This file is not intended to serve as a complete backup of your blog. -->
-
-<!-- To import this information into a WordPress blog follow these steps. -->
-<!-- 1. Log into that blog as an administrator. -->
-<!-- 2. Go to Manage: Import in the blog's admin panels. -->
-<!-- 3. Choose "WordPress" from the list. -->
-<!-- 4. Upload this file using the form provided on that page. -->
-<!-- 5. You will first be asked to map the authors in this export file to users -->
-<!-- on the blog. For each author, you may choose to map to an -->
-<!-- existing user on the blog or to create a new user -->
-<!-- 6. WordPress will then import each of the posts, comments, and categories -->
-<!-- contained in this file into your blog -->
+
+<!--
+ This is a WordPress eXtended RSS file generated by WordPress as an export of
+ your blog. It contains information about your blog's posts, comments, and
+ categories. You may use this file to transfer that content from one site to
+ another. This file is not intended to serve as a complete backup of your
+ blog.
+
+ To import this information into a WordPress blog follow these steps:
+
+ 1. Log into that blog as an administrator.
+ 2. Go to Manage > Import in the blog's admin.
+ 3. Choose "WordPress" from the list of importers.
+ 4. Upload this file using the form provided on that page.
+ 5. You will first be asked to map the authors in this export file to users
+ on the blog. For each author, you may choose to map an existing user on
+ the blog or to create a new user.
+ 6. WordPress will then import each of the posts, comments, and categories
+ contained in this file onto your blog.
+-->
<!-- generator="wordpress/<?php bloginfo_rss('version') ?>" created="<?php echo date('Y-m-d H:m'); ?>"-->
<rss version="2.0"
@@ -178,6 +186,7 @@ function wxr_category_description($c) {
<wp:post_name><?php echo $post->post_name; ?></wp:post_name>
<wp:status><?php echo $post->post_status; ?></wp:status>
<wp:post_parent><?php echo $post->post_parent; ?></wp:post_parent>
+<wp:menu_order><?php echo $post->menu_order; ?></wp:menu_order>
<wp:post_type><?php echo $post->post_type; ?></wp:post_type>
<?php
$postmeta = $wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE post_id = $post->ID");
diff --git a/wp-admin/images/heading-bg.gif b/wp-admin/images/heading-bg.gif
new file mode 100644
index 0000000..bea18ca
--- /dev/null
+++ b/wp-admin/images/heading-bg.gif
Binary files differ
diff --git a/wp-admin/import.php b/wp-admin/import.php
index e808c92..8c46046 100644
--- a/wp-admin/import.php
+++ b/wp-admin/import.php
@@ -17,10 +17,11 @@ $import_root = ABSPATH.$import_loc;
$imports_dir = @ dir($import_root);
if ($imports_dir) {
while (($file = $imports_dir->read()) !== false) {
- if (preg_match('|^\.+$|', $file))
+ if ($file{0} == '.') {
continue;
- if (preg_match('|\.php$|', $file))
- require_once("$import_root/$file");
+ } elseif (substr($file, -4) == '.php') {
+ require_once($import_root . '/' . $file);
+ }
}
}
diff --git a/wp-admin/import/blogger.php b/wp-admin/import/blogger.php
index fdc6004..4ad7a97 100644
--- a/wp-admin/import/blogger.php
+++ b/wp-admin/import/blogger.php
@@ -743,10 +743,11 @@ class Blogger_Import {
// Step 9: Congratulate the user
function congrats() {
+ $blog = (int) $_GET['blog'];
echo '<h1>'.__('Congratulations!').'</h1><p>'.__('Now that you have imported your Blogger blog into WordPress, what are you going to do? Here are some suggestions:').'</p><ul><li>'.__('That was hard work! Take a break.').'</li>';
if ( count($this->import['blogs']) > 1 )
echo '<li>'.__('In case you haven\'t done it already, you can import the posts from your other blogs:'). $this->show_blogs() . '</li>';
- if ( $n = count($this->import['blogs'][$_GET['blog']]['newusers']) )
+ if ( $n = count($this->import['blogs'][$blog]['newusers']) )
echo '<li>'.sprintf(__('Go to <a href="%s" target="%s">Authors &amp; Users</a>, where you can modify the new user(s) or delete them. If you want to make all of the imported posts yours, you will be given that option when you delete the new authors.'), 'users.php', '_parent').'</li>';
echo '<li>'.__('For security, click the link below to reset this importer.').'</li>';
echo '</ul>';
@@ -765,6 +766,7 @@ class Blogger_Import {
if ( isset( $_REQUEST['blog'] ) ) {
$blog = is_array($_REQUEST['blog']) ? array_shift( array_keys( $_REQUEST['blog'] ) ) : $_REQUEST['blog'];
+ $blog = (int) $blog;
$this->import_blog( $blog );
} elseif ( isset($_GET['token']) )
$this->auth();
diff --git a/wp-admin/import/dotclear.php b/wp-admin/import/dotclear.php
index 9a32e3a..661e1a0 100644
--- a/wp-admin/import/dotclear.php
+++ b/wp-admin/import/dotclear.php
@@ -147,8 +147,9 @@ class Dotclear_Import {
echo '<div class="narrow"><p>'.__('Howdy! This importer allows you to extract posts from a DotClear database into your blog. Mileage may vary.').'</p>';
echo '<p>'.__('Your DotClear Configuration settings are as follows:').'</p>';
echo '<form action="admin.php?import=dotclear&amp;step=1" method="post">';
+ wp_nonce_field('import-dotclear');
$this->db_form();
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Categories').' &raquo;" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" value="'.attribute_escape(__('Import Categories &raquo;')).'" /></p>';
echo '</form></div>';
}
@@ -558,7 +559,8 @@ class Dotclear_Import {
echo '<form action="admin.php?import=dotclear&amp;step=2" method="post">';
- printf('<input type="submit" name="submit" value="%s" />', __('Import Users'));
+ wp_nonce_field('import-dotclear');
+ printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Users')));
echo '</form>';
}
@@ -570,7 +572,8 @@ class Dotclear_Import {
$this->users2wp($users);
echo '<form action="admin.php?import=dotclear&amp;step=3" method="post">';
- printf('<input type="submit" name="submit" value="%s" />', __('Import Posts'));
+ wp_nonce_field('import-dotclear');
+ printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Posts')));
echo '</form>';
}
@@ -581,7 +584,8 @@ class Dotclear_Import {
$this->posts2wp($posts);
echo '<form action="admin.php?import=dotclear&amp;step=4" method="post">';
- printf('<input type="submit" name="submit" value="%s" />', __('Import Comments'));
+ wp_nonce_field('import-dotclear');
+ printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Comments')));
echo '</form>';
}
@@ -592,7 +596,8 @@ class Dotclear_Import {
$this->comments2wp($comments);
echo '<form action="admin.php?import=dotclear&amp;step=5" method="post">';
- printf('<input type="submit" name="submit" value="%s" />', __('Import Links'));
+ wp_nonce_field('import-dotclear');
+ printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Links')));
echo '</form>';
}
@@ -604,7 +609,8 @@ class Dotclear_Import {
add_option('dc_links', $links);
echo '<form action="admin.php?import=dotclear&amp;step=6" method="post">';
- printf('<input type="submit" name="submit" value="%s" />', __('Finish'));
+ wp_nonce_field('import-dotclear');
+ printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Finish')));
echo '</form>';
}
@@ -667,42 +673,44 @@ class Dotclear_Import {
if ( $step > 0 )
{
+ check_admin_referer('import-dotclear');
+
if($_POST['dbuser'])
{
if(get_option('dcuser'))
delete_option('dcuser');
- add_option('dcuser',$_POST['dbuser']);
+ add_option('dcuser', sanitize_user($_POST['dbuser'], true));
}
if($_POST['dbpass'])
{
if(get_option('dcpass'))
delete_option('dcpass');
- add_option('dcpass',$_POST['dbpass']);
+ add_option('dcpass', sanitize_user($_POST['dbpass'], true));
}
if($_POST['dbname'])
{
if(get_option('dcname'))
delete_option('dcname');
- add_option('dcname',$_POST['dbname']);
+ add_option('dcname', sanitize_user($_POST['dbname'], true));
}
if($_POST['dbhost'])
{
if(get_option('dchost'))
delete_option('dchost');
- add_option('dchost',$_POST['dbhost']);
+ add_option('dchost', sanitize_user($_POST['dbhost'], true));
}
if($_POST['dccharset'])
{
if(get_option('dccharset'))
delete_option('dccharset');
- add_option('dccharset',$_POST['dccharset']);
+ add_option('dccharset', sanitize_user($_POST['dccharset'], true));
}
if($_POST['dbprefix'])
{
if(get_option('dcdbprefix'))
delete_option('dcdbprefix');
- add_option('dcdbprefix',$_POST['dbprefix']);
+ add_option('dcdbprefix', sanitize_user($_POST['dbprefix'], true));
}
diff --git a/wp-admin/import/greymatter.php b/wp-admin/import/greymatter.php
index 9203ff7..4305cd1 100644
--- a/wp-admin/import/greymatter.php
+++ b/wp-admin/import/greymatter.php
@@ -34,6 +34,7 @@ class GM_Import {
<form name="stepOne" method="get">
<input type="hidden" name="import" value="greymatter" />
<input type="hidden" name="step" value="1" />
+<?php wp_nonce_field('import-greymatter'); ?>
<h3><?php _e('Second step: GreyMatter details:') ?></h3>
<p><table cellpadding="0">
<tr>
@@ -87,10 +88,12 @@ class GM_Import {
}
if (!chdir($archivespath))
- wp_die(sprintf(__("Wrong path, %s\ndoesn't exist\non the server"), $archivespath));
+ wp_die(__("Wrong path, the path to the GM entries does not exist on the server"));
if (!chdir($gmpath))
- wp_die(sprintf(__("Wrong path, %s\ndoesn't exist\non the server"), $gmpath));
+ wp_die(__("Wrong path, the path to the GM files does not exist on the server"));
+
+ $lastentry = (int) $lastentry;
$this->header();
?>
@@ -297,6 +300,7 @@ class GM_Import {
$this->greet();
break;
case 1:
+ check_admin_referer('import-greymatter');
$this->import();
break;
}
diff --git a/wp-admin/import/livejournal.php b/wp-admin/import/livejournal.php
index 690005b..c3b821a 100644
--- a/wp-admin/import/livejournal.php
+++ b/wp-admin/import/livejournal.php
@@ -49,7 +49,7 @@ class LJ_Import {
preg_match('|<eventtime>(.*?)</eventtime>|is', $post, $post_date);
$post_date = strtotime($post_date[1]);
- $post_date = gmdate('Y-m-d H:i:s', $post_date);
+ $post_date = date('Y-m-d H:i:s', $post_date);
preg_match('|<event>(.*?)</event>|is', $post, $post_content);
$post_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($post_content[1]));
@@ -153,6 +153,7 @@ class LJ_Import {
$this->greet();
break;
case 1 :
+ check_admin_referer('import-upload');
$this->import();
break;
}
diff --git a/wp-admin/import/mt.php b/wp-admin/import/mt.php
index 1effb5c..cd60654 100644
--- a/wp-admin/import/mt.php
+++ b/wp-admin/import/mt.php
@@ -130,6 +130,7 @@ class MT_Import {
$authors = $this->get_mt_authors();
echo '<ol id="authors">';
echo '<form action="?import=mt&amp;step=2&amp;id=' . $this->id . '" method="post">';
+ wp_nonce_field('import-mt');
$j = -1;
foreach ($authors as $author) {
++ $j;
@@ -400,9 +401,11 @@ class MT_Import {
$this->greet();
break;
case 1 :
+ check_admin_referer('import-upload');
$this->select_authors();
break;
case 2:
+ check_admin_referer('import-mt');
$this->import();
break;
}
diff --git a/wp-admin/import/rss.php b/wp-admin/import/rss.php
index 944b297..f46caa1 100644
--- a/wp-admin/import/rss.php
+++ b/wp-admin/import/rss.php
@@ -156,6 +156,7 @@ class RSS_Import {
$this->greet();
break;
case 1 :
+ check_admin_referer('import-upload');
$this->import();
break;
}
diff --git a/wp-admin/import/textpattern.php b/wp-admin/import/textpattern.php
index db60e15..286d74a 100644
--- a/wp-admin/import/textpattern.php
+++ b/wp-admin/import/textpattern.php
@@ -56,8 +56,9 @@ class Textpattern_Import {
echo '<p>'.__('This has not been tested on previous versions of Textpattern. Mileage may vary.').'</p>';
echo '<p>'.__('Your Textpattern Configuration settings are as follows:').'</p>';
echo '<form action="admin.php?import=textpattern&amp;step=1" method="post">';
+ wp_nonce_field('import-textpattern');
$this->db_form();
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Categories').' &raquo;" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" value="'.attribute_escape(__('Import Categories &raquo;')).'" /></p>';
echo '</form>';
echo '</div>';
}
@@ -483,7 +484,8 @@ class Textpattern_Import {
echo '<form action="admin.php?import=textpattern&amp;step=2" method="post">';
- printf('<input type="submit" name="submit" value="%s" />', __('Import Users'));
+ wp_nonce_field('import-textpattern');
+ printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Users')));
echo '</form>';
}
@@ -495,7 +497,8 @@ class Textpattern_Import {
$this->users2wp($users);
echo '<form action="admin.php?import=textpattern&amp;step=3" method="post">';
- printf('<input type="submit" name="submit" value="%s" />', __('Import Posts'));
+ wp_nonce_field('import-textpattern');
+ printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Posts')));
echo '</form>';
}
@@ -506,7 +509,8 @@ class Textpattern_Import {
$this->posts2wp($posts);
echo '<form action="admin.php?import=textpattern&amp;step=4" method="post">';
- printf('<input type="submit" name="submit" value="%s" />', __('Import Comments'));
+ wp_nonce_field('import-textpattern');
+ printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Comments')));
echo '</form>';
}
@@ -517,7 +521,8 @@ class Textpattern_Import {
$this->comments2wp($comments);
echo '<form action="admin.php?import=textpattern&amp;step=5" method="post">';
- printf('<input type="submit" name="submit" value="%s" />', __('Import Links'));
+ wp_nonce_field('import-textpattern');
+ printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Links')));
echo '</form>';
}
@@ -529,7 +534,8 @@ class Textpattern_Import {
add_option('txp_links', $links);
echo '<form action="admin.php?import=textpattern&amp;step=6" method="post">';
- printf('<input type="submit" name="submit" value="%s" />', __('Finish'));
+ wp_nonce_field('import-textpattern');
+ printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Finish')));
echo '</form>';
}
@@ -553,11 +559,11 @@ class Textpattern_Import {
{
echo '<p>'.__('Welcome to WordPress. We hope (and expect!) that you will find this platform incredibly rewarding! As a new WordPress user coming from Textpattern, there are some things that we would like to point out. Hopefully, they will help your transition go as smoothly as possible.').'</p>';
echo '<h3>'.__('Users').'</h3>';
- echo '<p>'.sprintf(__('You have already setup WordPress and have been assigned an administrative login and password. Forget it. You didn\'t have that login in Textpattern, why should you have it here? Instead we have taken care to import all of your users into our system. Unfortunately there is one downside. Because both WordPress and Textpattern uses a strong encryption hash with passwords, it is impossible to decrypt it and we are forced to assign temporary passwords to all your users. <strong>Every user has the same username, but their passwords are reset to password123.</strong> So <a href="%1$s">Login</a> and change it.'), '/wp-login.php').'</p>';
+ echo '<p>'.sprintf(__('You have already setup WordPress and have been assigned an administrative login and password. Forget it. You didn&#8217;t have that login in Textpattern, why should you have it here? Instead we have taken care to import all of your users into our system. Unfortunately there is one downside. Because both WordPress and Textpattern uses a strong encryption hash with passwords, it is impossible to decrypt it and we are forced to assign temporary passwords to all your users. <strong>Every user has the same username, but their passwords are reset to password123.</strong> So <a href="%1$s">Login</a> and change it.'), get_bloginfo( 'wpurl' ) . '/wp-login.php').'</p>';
echo '<h3>'.__('Preserving Authors').'</h3>';
echo '<p>'.__('Secondly, we have attempted to preserve post authors. If you are the only author or contributor to your blog, then you are safe. In most cases, we are successful in this preservation endeavor. However, if we cannot ascertain the name of the writer due to discrepancies between database tables, we assign it to you, the administrative user.').'</p>';
echo '<h3>'.__('Textile').'</h3>';
- echo '<p>'.__('Also, since you\'re coming from Textpattern, you probably have been using Textile to format your comments and posts. If this is the case, we recommend downloading and installing <a href="http://www.huddledmasses.org/category/development/wordpress/textile/">Textile for WordPress</a>. Trust me... You\'ll want it.').'</p>';
+ echo '<p>'.__('Also, since you&#8217;re coming from Textpattern, you probably have been using Textile to format your comments and posts. If this is the case, we recommend downloading and installing <a href="http://www.huddledmasses.org/category/development/wordpress/textile/">Textile for WordPress</a>. Trust me... You&#8217;ll want it.').'</p>';
echo '<h3>'.__('WordPress Resources').'</h3>';
echo '<p>'.__('Finally, there are numerous WordPress resources around the internet. Some of them are:').'</p>';
echo '<ul>';
@@ -565,7 +571,7 @@ class Textpattern_Import {
echo '<li>'.__('<a href="http://wordpress.org/support/">The WordPress support forums</a>').'</li>';
echo '<li>'.__('<a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a>').'</li>';
echo '</ul>';
- echo '<p>'.sprintf(__('That\'s it! What are you waiting for? Go <a href="%1$s">login</a>!'), '/wp-login.php').'</p>';
+ echo '<p>'.sprintf(__('That&#8217;s it! What are you waiting for? Go <a href="%1$s">login</a>!'), get_bloginfo( 'wpurl' ) . '/wp-login.php').'</p>';
}
function db_form()
@@ -590,36 +596,38 @@ class Textpattern_Import {
if ( $step > 0 )
{
+ check_admin_referer('import-textpattern');
+
if($_POST['dbuser'])
{
if(get_option('txpuser'))
delete_option('txpuser');
- add_option('txpuser',$_POST['dbuser']);
+ add_option('txpuser', sanitize_user($_POST['dbuser'], true));
}
if($_POST['dbpass'])
{
if(get_option('txppass'))
delete_option('txppass');
- add_option('txppass',$_POST['dbpass']);
+ add_option('txppass', sanitize_user($_POST['dbpass'], true));
}
if($_POST['dbname'])
{
if(get_option('txpname'))
delete_option('txpname');
- add_option('txpname',$_POST['dbname']);
+ add_option('txpname', sanitize_user($_POST['dbname'], true));
}
if($_POST['dbhost'])
{
if(get_option('txphost'))
delete_option('txphost');
- add_option('txphost',$_POST['dbhost']);
+ add_option('txphost', sanitize_user($_POST['dbhost'], true));
}
if($_POST['dbprefix'])
{
if(get_option('tpre'))
delete_option('tpre');
- add_option('tpre',$_POST['dbprefix']);
+ add_option('tpre', sanitize_user($_POST['dbprefix']));
}
diff --git a/wp-admin/import/utw.php b/wp-admin/import/utw.php
new file mode 100644
index 0000000..824ba50
--- /dev/null
+++ b/wp-admin/import/utw.php
@@ -0,0 +1,270 @@
+<?php
+
+class UTW_Import {
+
+ function header() {
+ echo '<div class="wrap">';
+ echo '<h2>'.__('Import Ultimate Tag Warrior').'</h2>';
+ echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'<br /><br /></p>';
+ }
+
+ function footer() {
+ echo '</div>';
+ }
+
+ function greet() {
+ echo '<div class="narrow">';
+ echo '<p>'.__('Howdy! This imports tags from an existing Ultimate Tag Warrior 3 installation into this blog using the new WordPress native tagging structure.').'</p>';
+ echo '<p>'.__('This has not been tested on any other versions of Ultimate Tag Warrior. Mileage may vary.').'</p>';
+ echo '<p>'.__('To accommodate larger databases for those tag-crazy authors out there, we have made this into an easy 5-step program to help you kick that nasty UTW habit. Just keep clicking along and we will let you know when you are in the clear!').'</p>';
+ echo '<p><strong>'.__('Don&#8217;t be stupid - backup your database before proceeding!').'</strong></p>';
+ echo '<form action="admin.php?import=utw&amp;step=1" method="post">';
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 1 &raquo;').'" /></p>';
+ echo '</form>';
+ echo '</div>';
+ }
+
+
+ function dispatch () {
+ if ( empty( $_GET['step'] ) ) {
+ $step = 0;
+ } else {
+ $step = (int) $_GET['step'];
+ }
+
+ // load the header
+ $this->header();
+
+ switch ( $step ) {
+ case 0 :
+ $this->greet();
+ break;
+ case 1 :
+ $this->import_tags();
+ break;
+ case 2 :
+ $this->import_posts();
+ break;
+ case 3:
+ $this->import_t2p();
+ break;
+ case 4:
+ $this->cleanup_import();
+ break;
+ }
+
+ // load the footer
+ $this->footer();
+ }
+
+
+ function import_tags ( ) {
+ echo '<div class="narrow">';
+ echo '<p><h3>'.__('Reading UTW Tags&#8230;').'</h3></p>';
+
+ $tags = $this->get_utw_tags();
+
+ // if we didn't get any tags back, that's all there is folks!
+ if ( !is_array($tags) ) {
+ echo '<p>' . __('No Tags Found!') . '</p>';
+ return false;
+ }
+ else {
+
+ // if there's an existing entry, delete it
+ if ( get_option('utwimp_tags') ) {
+ delete_option('utwimp_tags');
+ }
+
+ add_option('utwimp_tags', $tags);
+
+
+ $count = count($tags);
+
+ echo '<p>' . sprintf( __('Done! <strong>%s</strong> tags were read.'), $count ) . '<br /></p>';
+ echo '<p>' . __('The following tags were found:') . '</p>';
+
+ echo '<ul>';
+
+ foreach ( $tags as $tag_id => $tag_name ) {
+
+ echo '<li>' . $tag_name . '</li>';
+
+ }
+
+ echo '</ul>';
+
+ echo '<br />';
+
+ echo '<p>' . __('If you don&#8217;t want to import any of these tags, you should delete them from the UTW tag management page and then re-run this import.') . '</p>';
+
+
+ }
+
+ echo '<form action="admin.php?import=utw&amp;step=2" method="post">';
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 2 &raquo;').'" /></p>';
+ echo '</form>';
+ echo '</div>';
+ }
+
+
+ function import_posts ( ) {
+ echo '<div class="narrow">';
+ echo '<p><h3>'.__('Reading UTW Post Tags&#8230;').'</h3></p>';
+
+ // read in all the UTW tag -> post settings
+ $posts = $this->get_utw_posts();
+
+ // if we didn't get any tags back, that's all there is folks!
+ if ( !is_array($posts) ) {
+ echo '<p>' . __('No posts were found to have tags!') . '</p>';
+ return false;
+ }
+ else {
+
+ // if there's an existing entry, delete it
+ if ( get_option('utwimp_posts') ) {
+ delete_option('utwimp_posts');
+ }
+
+ add_option('utwimp_posts', $posts);
+
+
+ $count = count($posts);
+
+ echo '<p>' . sprintf( __('Done! <strong>%s</strong> tag to post relationships were read.'), $count ) . '<br /></p>';
+
+ }
+
+ echo '<form action="admin.php?import=utw&amp;step=3" method="post">';
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 3 &raquo;').'" /></p>';
+ echo '</form>';
+ echo '</div>';
+
+ }
+
+
+ function import_t2p ( ) {
+
+ echo '<div class="narrow">';
+ echo '<p><h3>'.__('Adding Tags to Posts&#8230;').'</h3></p>';
+
+ // run that funky magic!
+ $tags_added = $this->tag2post();
+
+ echo '<p>' . sprintf( __('Done! <strong>%s</strong> tags where added!'), $tags_added ) . '<br /></p>';
+
+ echo '<form action="admin.php?import=utw&amp;step=4" method="post">';
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 4 &raquo;').'" /></p>';
+ echo '</form>';
+ echo '</div>';
+
+ }
+
+
+ function get_utw_tags ( ) {
+
+ global $wpdb;
+
+ // read in all the tags from the UTW tags table: should be wp_tags
+ $tags_query = "SELECT tag_id, tag FROM " . $wpdb->prefix . "tags";
+
+ $tags = $wpdb->get_results($tags_query);
+
+ // rearrange these tags into something we can actually use
+ foreach ( $tags as $tag ) {
+
+ $new_tags[$tag->tag_id] = $tag->tag;
+
+ }
+
+ return $new_tags;
+
+ }
+
+ function get_utw_posts ( ) {
+
+ global $wpdb;
+
+ // read in all the posts from the UTW post->tag table: should be wp_post2tag
+ $posts_query = "SELECT tag_id, post_id FROM " . $wpdb->prefix . "post2tag";
+
+ $posts = $wpdb->get_results($posts_query);
+
+ return $posts;
+
+ }
+
+
+ function tag2post ( ) {
+
+ // get the tags and posts we imported in the last 2 steps
+ $tags = get_option('utwimp_tags');
+ $posts = get_option('utwimp_posts');
+
+ // null out our results
+ $tags_added = 0;
+
+ // loop through each post and add its tags to the db
+ foreach ( $posts as $this_post ) {
+
+ $the_post = (int) $this_post->post_id;
+ $the_tag = (int) $this_post->tag_id;
+
+ // what's the tag name for that id?
+ $the_tag = $tags[$the_tag];
+
+ // screw it, just try to add the tag
+ wp_add_post_tags($the_post, $the_tag);
+
+ $tags_added++;
+
+ }
+
+ // that's it, all posts should be linked to their tags properly, pending any errors we just spit out!
+ return $tags_added;
+
+
+ }
+
+
+ function cleanup_import ( ) {
+
+ delete_option('utwimp_tags');
+ delete_option('utwimp_posts');
+
+ $this->done();
+
+ }
+
+
+ function done ( ) {
+
+ echo '<div class="narrow">';
+ echo '<p><h3>'.__('Import Complete!').'</h3></p>';
+
+ echo '<p>' . __('OK, so we lied about this being a 5-step program! You&#8217;re done!') . '</p>';
+
+ echo '<p>' . __('Now wasn&#8217;t that easy?') . '</p>';
+
+ echo '</div>';
+
+ }
+
+
+ function UTW_Import ( ) {
+
+ // Nothing.
+
+ }
+
+}
+
+
+// create the import object
+$utw_import = new UTW_Import();
+
+// add it to the import page!
+register_importer('utw', 'Ultimate Tag Warrior', __('Import Ultimate Tag Warrior tags into the new native tagging structure.'), array($utw_import, 'dispatch'));
+
+?> \ No newline at end of file
diff --git a/wp-admin/import/wordpress.php b/wp-admin/import/wordpress.php
index 90b616b..fa0d194 100644
--- a/wp-admin/import/wordpress.php
+++ b/wp-admin/import/wordpress.php
@@ -3,6 +3,8 @@
class WP_Import {
var $posts = array ();
+ var $posts_processed = array ();
+ // Array of arrays. [[0] => XML fragment, [1] => New post ID]
var $file;
var $id;
var $mtnames = array ();
@@ -33,8 +35,9 @@ class WP_Import {
}
function get_tag( $string, $tag ) {
+ global $wpdb;
preg_match("|<$tag.*?>(.*?)</$tag>|is", $string, $return);
- $return = addslashes( trim( $return[1] ) );
+ $return = $wpdb->escape( trim( $return[1] ) );
return $return;
}
@@ -65,13 +68,40 @@ class WP_Import {
function get_entries() {
set_magic_quotes_runtime(0);
- $importdata = file($this->file); // Read the file into an array
- $importdata = implode('', $importdata); // squish it
- $importdata = preg_replace("/(\r\n|\n|\r)/", "\n", $importdata);
- preg_match_all('|<item>(.*?)</item>|is', $importdata, $this->posts);
- $this->posts = $this->posts[1];
- preg_match_all('|<wp:category>(.*?)</wp:category>|is', $importdata, $this->categories);
- $this->categories = $this->categories[1];
+ $importdata = array_map('rtrim', file($this->file)); // Read the file into an array
+
+ $this->posts = array();
+ $this->categories = array();
+ $num = 0;
+ $doing_entry = false;
+ foreach ($importdata as $importline) {
+ if ( false !== strpos($importline, '<wp:category>') ) {
+ preg_match('|<wp:category>(.*?)</wp:category>|is', $importline, $category);
+ $this->categories[] = $category[1];
+ continue;
+ }
+ if ( false !== strpos($importline, '<item>') ) {
+ $this->posts[$num] = '';
+ $doing_entry = true;
+ continue;
+ }
+ if ( false !== strpos($importline, '</item>') ) {
+ $num++;
+ $doing_entry = false;
+ continue;
+ }
+ if ( $doing_entry ) {
+ $this->posts[$num] .= $importline . "\n";
+ }
+ }
+
+ foreach ($this->posts as $post) {
+ $post_ID = (int) $this->get_tag( $post, 'wp:post_id' );
+ if ($post_ID) {
+ $this->posts_processed[$post_ID][0] = &$post;
+ $this->posts_processed[$post_ID][1] = 0;
+ }
+ }
}
function get_wp_authors() {
@@ -133,6 +163,7 @@ class WP_Import {
$authors = $this->get_wp_authors();
echo '<ol id="authors">';
echo '<form action="?import=wordpress&amp;step=2&amp;id=' . $this->id . '" method="post">';
+ wp_nonce_field('import-wordpress');
$j = -1;
foreach ($authors as $author) {
++ $j;
@@ -150,10 +181,8 @@ class WP_Import {
function select_authors() {
$file = wp_import_handle_upload();
if ( isset($file['error']) ) {
- $this->header();
echo '<p>'.__('Sorry, there has been an error.').'</p>';
echo '<p><strong>' . $file['error'] . '</strong></p>';
- $this->footer();
return;
}
$this->file = $file['file'];
@@ -193,97 +222,128 @@ class WP_Import {
}
function process_posts() {
- global $wpdb;
$i = -1;
echo '<ol>';
- foreach ($this->posts as $post) {
- // There are only ever one of these
- $post_title = $this->get_tag( $post, 'title' );
- $post_date = $this->get_tag( $post, 'wp:post_date' );
- $post_date_gmt = $this->get_tag( $post, 'wp:post_date_gmt' );
- $comment_status = $this->get_tag( $post, 'wp:comment_status' );
- $ping_status = $this->get_tag( $post, 'wp:ping_status' );
- $post_status = $this->get_tag( $post, 'wp:status' );
- $post_parent = $this->get_tag( $post, 'wp:post_parent' );
- $post_type = $this->get_tag( $post, 'wp:post_type' );
- $guid = $this->get_tag( $post, 'guid' );
- $post_author = $this->get_tag( $post, 'dc:creator' );
-
- $post_content = $this->get_tag( $post, 'content:encoded' );
- $post_content = str_replace(array ('<![CDATA[', ']]>'), '', $post_content);
- $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content);
- $post_content = str_replace('<br>', '<br />', $post_content);
- $post_content = str_replace('<hr>', '<hr />', $post_content);
-
- preg_match_all('|<category>(.*?)</category>|is', $post, $categories);
- $categories = $categories[1];
-
- $cat_index = 0;
- foreach ($categories as $category) {
- $categories[$cat_index] = $wpdb->escape($this->unhtmlentities(str_replace(array ('<![CDATA[', ']]>'), '', $category)));
- $cat_index++;
- }
+ foreach ($this->posts as $post)
+ $this->process_post($post);
- if ($post_id = post_exists($post_title, '', $post_date)) {
- echo '<li>';
- printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title));
- } else {
- echo '<li>';
- printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
+ echo '</ol>';
- $post_author = $this->checkauthor($post_author); //just so that if a post already exists, new users are not created by checkauthor
+ wp_import_cleanup($this->id);
- $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt', 'guid', 'post_parent', 'post_type');
- $comment_post_ID = $post_id = wp_insert_post($postdata);
- // Add categories.
- if (0 != count($categories)) {
- wp_create_categories($categories, $post_id);
- }
- }
+ echo '<h3>'.sprintf(__('All done.').' <a href="%s">'.__('Have fun!').'</a>', get_option('home')).'</h3>';
+ }
+
+ function process_post($post) {
+ global $wpdb;
- // Now for comments
- preg_match_all('|<wp:comment>(.*?)</wp:comment>|is', $post, $comments);
- $comments = $comments[1];
- $num_comments = 0;
- if ( $comments) { foreach ($comments as $comment) {
- $comment_author = $this->get_tag( $comment, 'wp:comment_author');
- $comment_author_email = $this->get_tag( $comment, 'wp:comment_author_email');
- $comment_author_IP = $this->get_tag( $comment, 'wp:comment_author_IP');
- $comment_author_url = $this->get_tag( $comment, 'wp:comment_author_url');
- $comment_date = $this->get_tag( $comment, 'wp:comment_date');
- $comment_date_gmt = $this->get_tag( $comment, 'wp:comment_date_gmt');
- $comment_content = $this->get_tag( $comment, 'wp:comment_content');
- $comment_approved = $this->get_tag( $comment, 'wp:comment_approved');
- $comment_type = $this->get_tag( $comment, 'wp:comment_type');
- $comment_parent = $this->get_tag( $comment, 'wp:comment_parent');
-
- if ( !comment_exists($comment_author, $comment_date) ) {
- $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_approved', 'comment_type', 'comment_parent');
- wp_insert_comment($commentdata);
- $num_comments++;
- }
- } }
- if ( $num_comments )
- printf(' '.__('(%s comments)'), $num_comments);
-
- // Now for post meta
- preg_match_all('|<wp:postmeta>(.*?)</wp:postmeta>|is', $post, $postmeta);
- $postmeta = $postmeta[1];
- if ( $postmeta) { foreach ($postmeta as $p) {
- $key = $this->get_tag( $p, 'wp:meta_key' );
- $value = $this->get_tag( $p, 'wp:meta_value' );
- add_post_meta( $post_id, $key, $value );
- } }
-
- $index++;
+ $post_ID = (int) $this->get_tag( $post, 'wp:post_id' );
+ if ( $post_ID && !empty($this->posts_processed[$post_ID][1]) ) // Processed already
+ return 0;
+
+ // There are only ever one of these
+ $post_title = $this->get_tag( $post, 'title' );
+ $post_date = $this->get_tag( $post, 'wp:post_date' );
+ $post_date_gmt = $this->get_tag( $post, 'wp:post_date_gmt' );
+ $comment_status = $this->get_tag( $post, 'wp:comment_status' );
+ $ping_status = $this->get_tag( $post, 'wp:ping_status' );
+ $post_status = $this->get_tag( $post, 'wp:status' );
+ $post_name = $this->get_tag( $post, 'wp:post_name' );
+ $post_parent = $this->get_tag( $post, 'wp:post_parent' );
+ $menu_order = $this->get_tag( $post, 'wp:menu_order' );
+ $post_type = $this->get_tag( $post, 'wp:post_type' );
+ $guid = $this->get_tag( $post, 'guid' );
+ $post_author = $this->get_tag( $post, 'dc:creator' );
+
+ $post_content = $this->get_tag( $post, 'content:encoded' );
+ $post_content = str_replace(array ('<![CDATA[', ']]>'), '', $post_content);
+ $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content);
+ $post_content = str_replace('<br>', '<br />', $post_content);
+ $post_content = str_replace('<hr>', '<hr />', $post_content);
+
+ preg_match_all('|<category>(.*?)</category>|is', $post, $categories);
+ $categories = $categories[1];
+
+ $cat_index = 0;
+ foreach ($categories as $category) {
+ $categories[$cat_index] = $wpdb->escape($this->unhtmlentities(str_replace(array ('<![CDATA[', ']]>'), '', $category)));
+ $cat_index++;
}
- echo '</ol>';
+ if ($post_id = post_exists($post_title, '', $post_date)) {
+ echo '<li>';
+ printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title));
+ } else {
- wp_import_cleanup($this->id);
+ // If it has parent, process parent first.
+ $post_parent = (int) $post_parent;
+ if ($parent = $this->posts_processed[$post_parent]) {
+ if (!$parent[1]) $this->process_post($parent[0]); // If not yet, process the parent first.
+ $post_parent = $parent[1]; // New ID of the parent;
+ }
- echo '<h3>'.sprintf(__('All done.').' <a href="%s">'.__('Have fun!').'</a>', get_option('home')).'</h3>';
+ echo '<li>';
+ printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
+
+ $post_author = $this->checkauthor($post_author); //just so that if a post already exists, new users are not created by checkauthor
+
+ $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'post_name', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt', 'guid', 'post_parent', 'menu_order', 'post_type');
+ $comment_post_ID = $post_id = wp_insert_post($postdata);
+
+ // Memorize old and new ID.
+ if ( $post_id && $post_ID && $this->posts_processed[$post_ID] )
+ $this->posts_processed[$post_ID][1] = $post_id; // New ID.
+
+ // Add categories.
+ if (count($categories) > 0) {
+ $post_cats = array();
+ foreach ($categories as $category) {
+ $cat_ID = (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name = '$category'");
+ if ($cat_ID == 0) {
+ $cat_ID = wp_insert_category(array('cat_name' => $category));
+ }
+ $post_cats[] = $cat_ID;
+ }
+ wp_set_post_categories($post_id, $post_cats);
+ }
+ }
+
+ // Now for comments
+ preg_match_all('|<wp:comment>(.*?)</wp:comment>|is', $post, $comments);
+ $comments = $comments[1];
+ $num_comments = 0;
+ if ( $comments) { foreach ($comments as $comment) {
+ $comment_author = $this->get_tag( $comment, 'wp:comment_author');
+ $comment_author_email = $this->get_tag( $comment, 'wp:comment_author_email');
+ $comment_author_IP = $this->get_tag( $comment, 'wp:comment_author_IP');
+ $comment_author_url = $this->get_tag( $comment, 'wp:comment_author_url');
+ $comment_date = $this->get_tag( $comment, 'wp:comment_date');
+ $comment_date_gmt = $this->get_tag( $comment, 'wp:comment_date_gmt');
+ $comment_content = $this->get_tag( $comment, 'wp:comment_content');
+ $comment_approved = $this->get_tag( $comment, 'wp:comment_approved');
+ $comment_type = $this->get_tag( $comment, 'wp:comment_type');
+ $comment_parent = $this->get_tag( $comment, 'wp:comment_parent');
+
+ if ( !comment_exists($comment_author, $comment_date) ) {
+ $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_approved', 'comment_type', 'comment_parent');
+ wp_insert_comment($commentdata);
+ $num_comments++;
+ }
+ } }
+
+ if ( $num_comments )
+ printf(' '.__('(%s comments)'), $num_comments);
+
+ // Now for post meta
+ preg_match_all('|<wp:postmeta>(.*?)</wp:postmeta>|is', $post, $postmeta);
+ $postmeta = $postmeta[1];
+ if ( $postmeta) { foreach ($postmeta as $p) {
+ $key = $this->get_tag( $p, 'wp:meta_key' );
+ $value = $this->get_tag( $p, 'wp:meta_value' );
+ $value = stripslashes($value); // add_post_meta() will escape.
+ add_post_meta( $post_id, $key, $value );
+ } }
}
function import() {
@@ -308,9 +368,11 @@ class WP_Import {
$this->greet();
break;
case 1 :
+ check_admin_referer('import-upload');
$this->select_authors();
break;
case 2:
+ check_admin_referer('import-wordpress');
$this->import();
break;
}
diff --git a/wp-admin/import/wp-cat2tag.php b/wp-admin/import/wp-cat2tag.php
new file mode 100644
index 0000000..6df9f1c
--- /dev/null
+++ b/wp-admin/import/wp-cat2tag.php
@@ -0,0 +1,226 @@
+<?php
+
+class WP_Categories_to_Tags {
+ var $categories_to_convert = array();
+ var $all_categories = array();
+
+ function header() {
+ print '<div class="wrap">';
+ print '<h2>' . __('Convert Categories to Tags') . '</h2>';
+ }
+
+ function footer() {
+ print '</div>';
+ }
+
+ function populate_all_categories() {
+ global $wpdb;
+
+ $this->all_categories = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE (type & ~ " . TAXONOMY_TAG . ") != 0 AND category_count > 0 ORDER BY cat_name ASC");
+ }
+
+ function welcome() {
+ $this->populate_all_categories();
+
+ print '<div class="narrow">';
+
+ if (count($this->all_categories) > 0) {
+ print '<p>' . __('Howdy! This converter allows you to selectively convert existing categories to tags. To get started, check the checkboxes of the categories you wish to be converted, then click the Convert button.') . '</p>';
+ print '<p>' . __('Keep in mind that if you convert a category with child categories, those child categories get their parent setting removed, so they\'re in the root.') . '</p>';
+
+ $this->categories_form();
+ } else {
+ print '<p>'.__('You have no categories to convert!').'</p>';
+ }
+
+ print '</div>';
+ }
+
+ function categories_form() {
+ print '<form action="admin.php?import=wp-cat2tag&amp;step=2" method="post">';
+ print '<ul style="list-style:none">';
+
+ $hier = _get_category_hierarchy();
+
+ foreach ($this->all_categories as $category) {
+ if ((int) $category->category_parent == 0) {
+ print '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($category->cat_ID) . '" /> ' . $category->cat_name . ' (' . $category->category_count . ')</label>';
+
+ if (isset($hier[$category->cat_ID])) {
+ $this->_category_children($category, $hier);
+ }
+
+ print '</li>';
+ }
+ }
+
+ print '</ul>';
+
+ print '<p class="submit"><input type="submit" name="maybe_convert_all_cats" value="' . __('Convert All Categories') . '" /> <input type="submit" name="submit" value="' . __('Convert &raquo;') . '" /></p>';
+ print '</form>';
+ }
+
+ function _category_children($parent, $hier) {
+ print '<ul style="list-style:none">';
+
+ foreach ($hier[$parent->cat_ID] as $child_id) {
+ $child =& get_category($child_id);
+
+ print '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($child->cat_ID) . '" /> ' . $child->cat_name . ' (' . $child->category_count . ')</label>';
+
+ if (isset($hier[$child->cat_ID])) {
+ $this->_category_children($child, $hier);
+ }
+
+ print '</li>';
+ }
+
+ print '</ul>';
+ }
+
+ function _category_exists($cat_id) {
+ global $wpdb;
+
+ $cat_id = (int) $cat_id;
+
+ $maybe_exists = $wpdb->get_results("SELECT cat_ID from $wpdb->categories WHERE cat_ID = '$cat_id'");
+
+ if (count($maybe_exists) > 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function convert_them() {
+ global $wpdb;
+
+ if (!isset($_POST['cats_to_convert']) || !is_array($_POST['cats_to_convert'])) {
+ print '<div class="narrow">';
+ print '<p>' . sprintf(__('Uh, oh. Something didn\'t work. Please <a href="%s">try again</a>.'), 'admin.php?import=wp-cat2tag') . '</p>';
+ print '</div>';
+ }
+
+ $this->categories_to_convert = $_POST['cats_to_convert'];
+ $hier = _get_category_hierarchy();
+
+ print '<ul>';
+
+ foreach ($this->categories_to_convert as $cat_id) {
+ $cat_id = (int) $cat_id;
+
+ print '<li>' . __('Converting category') . ' #' . $cat_id . '... ';
+
+ if (!$this->_category_exists($cat_id)) {
+ _e('Category doesn\'t exist!');
+ } else {
+ $category =& get_category($cat_id);
+
+ if ($category->link_count > 0) {
+ $type = $category->type | TAXONOMY_TAG;
+ } else {
+ $type = TAXONOMY_TAG;
+ }
+
+ // Set the category itself to $type from above
+ $wpdb->query("UPDATE $wpdb->categories SET type = '$type' WHERE cat_ID = '{$category->cat_ID}'");
+
+ // Set relationships in post2cat to 'tag', category_count becomes tag_count
+ $wpdb->query("UPDATE $wpdb->post2cat SET rel_type = 'tag' WHERE category_ID = '{$category->cat_ID}'");
+ $wpdb->query("UPDATE $wpdb->categories SET tag_count = '{$category->category_count}', category_count = '0' WHERE cat_ID = '{$category->cat_ID}'");
+
+ // Set all parents to 0 (root-level) if their parent was the converted tag
+ $wpdb->query("UPDATE $wpdb->categories SET category_parent = 0 WHERE category_parent = '{$category->cat_ID}'");
+
+ // Clean the cache
+ clean_category_cache($category->cat_ID);
+
+ _e('Converted successfully.');
+ }
+
+ print '</li>';
+ }
+
+ print '</ul>';
+ }
+
+ function convert_all_confirm() {
+ print '<div class="narrow">';
+
+ print '<h3>' . __('Confirm') . '</h3>';
+
+ print '<p>' . __('You are about to convert all categories to tags. Are you sure you want to continue?') . '</p>';
+
+ print '<form action="admin.php?import=wp-cat2tag" method="post">';
+ print '<p style="text-align:center" class="submit"><input type="submit" value="' . __('Yes') . '" name="yes_convert_all_cats" />&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="' . __('No') . '" name="no_dont_do_it" /></p>';
+ print '</form>';
+
+ print '</div>';
+ }
+
+ function convert_all() {
+ global $wpdb;
+
+ $cats = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE (type & ~ " . TAXONOMY_TAG . ") != 0 AND category_count > 0");
+
+ $_POST['cats_to_convert'] = array();
+
+ foreach ($cats as $cat) {
+ $_POST['cats_to_convert'][] = $cat->cat_ID;
+ }
+
+ $this->convert_them();
+ }
+
+ function init() {
+ echo '<!--'; print_r($_POST); print_r($_GET); echo '-->';
+
+ if (isset($_POST['maybe_convert_all_cats'])) {
+ $step = 3;
+ } elseif (isset($_POST['yes_convert_all_cats'])) {
+ $step = 4;
+ } elseif (isset($_POST['no_dont_do_it'])) {
+ die('no_dont_do_it');
+ } else {
+ $step = (isset($_GET['step'])) ? (int) $_GET['step'] : 1;
+ }
+
+ $this->header();
+
+ if (!current_user_can('manage_categories')) {
+ print '<div class="narrow">';
+ print '<p>' . __('Cheatin&#8217; uh?') . '</p>';
+ print '</div>';
+ } else {
+ switch ($step) {
+ case 1 :
+ $this->welcome();
+ break;
+
+ case 2 :
+ $this->convert_them();
+ break;
+
+ case 3 :
+ $this->convert_all_confirm();
+ break;
+
+ case 4 :
+ $this->convert_all();
+ break;
+ }
+ }
+
+ $this->footer();
+ }
+
+ function WP_Categories_to_Tags() {
+ // Do nothing.
+ }
+}
+
+$wp_cat2tag_importer = new WP_Categories_to_Tags();
+
+register_importer('wp-cat2tag', __('Categories to Tags Converter'), __('Convert existing categories to tags, selectively.'), array(&$wp_cat2tag_importer, 'init'));
+
+?>
diff --git a/wp-admin/index-extra.php b/wp-admin/index-extra.php
index d5262ca..b3d38e9 100644
--- a/wp-admin/index-extra.php
+++ b/wp-admin/index-extra.php
@@ -7,10 +7,10 @@ require_once (ABSPATH . WPINC . '/rss.php');
switch ( $_GET['jax'] ) {
case 'incominglinks' :
-$rss = @fetch_rss('http://feeds.technorati.com/cosmos/rss/?url='. trailingslashit(get_option('home')) .'&partner=wordpress');
+$rss = @fetch_rss(apply_filters( 'dashboard_incoming_links_feed', 'http://feeds.technorati.com/cosmos/rss/?url='. trailingslashit(get_option('home')) .'&partner=wordpress' ));
if ( isset($rss->items) && 1 < count($rss->items) ) { // Technorati returns a 1-item feed when it has no results
?>
-<h3><?php _e('Incoming Links'); ?> <cite><a href="http://www.technorati.com/search/<?php echo trailingslashit(get_option('home')); ?>?partner=wordpress"><?php _e('More &raquo;'); ?></a></cite></h3>
+<h3><?php _e('Incoming Links'); ?> <cite><a href="<?php echo apply_filters( 'dashboard_incoming_links_link', 'http://www.technorati.com/search/'. trailingslashit(get_option('home')) .'?partner=wordpress' ); ?>"><?php _e('More &raquo;'); ?></a></cite></h3>
<ul>
<?php
$rss->items = array_slice($rss->items, 0, 10);
@@ -24,10 +24,10 @@ foreach ($rss->items as $item ) {
break;
case 'devnews' :
-$rss = @fetch_rss('http://wordpress.org/development/feed/');
+$rss = @fetch_rss(apply_filters( 'dashboard_primary_feed', 'http://wordpress.org/development/feed/' ));
if ( isset($rss->items) && 0 != count($rss->items) ) {
?>
-<h3><?php _e('WordPress Development Blog'); ?></h3>
+<h3><?php echo apply_filters( 'dashboard_primary_title', __('WordPress Development Blog') ); ?></h3>
<?php
$rss->items = array_slice($rss->items, 0, 3);
foreach ($rss->items as $item ) {
@@ -43,10 +43,10 @@ foreach ($rss->items as $item ) {
break;
case 'planetnews' :
-$rss = @fetch_rss('http://planet.wordpress.org/feed/');
+$rss = @fetch_rss(apply_filters( 'dashboard_secondary_feed', 'http://planet.wordpress.org/feed/' ));
if ( isset($rss->items) && 0 != count($rss->items) ) {
?>
-<h3><?php _e('Other WordPress News'); ?></h3>
+<h3><?php echo apply_filters( 'dashboard_secondary_title', __('Other WordPress News') ); ?></h3>
<ul>
<?php
$rss->items = array_slice($rss->items, 0, 20);
@@ -60,7 +60,7 @@ $post = preg_replace( '|.+?:(.+)|s', '$1', $item['title'] );
}
?>
</ul>
-<p class="readmore"><a href="http://planet.wordpress.org/"><?php _e('Read more'); ?> &raquo;</a></p>
+<p class="readmore"><a href="<?php echo apply_filters( 'dashboard_secondary_link', 'http://planet.wordpress.org/' ); ?>"><?php _e('Read more'); ?> &raquo;</a></p>
<?php
}
break;
diff --git a/wp-admin/index.php b/wp-admin/index.php
index 2a24a82..a3d3151 100644
--- a/wp-admin/index.php
+++ b/wp-admin/index.php
@@ -43,7 +43,7 @@ if ( $comments || $numcomments ) :
<h3><?php _e('Comments'); ?> <a href="edit-comments.php" title="<?php _e('More comments...'); ?>">&raquo;</a></h3>
<?php if ( $numcomments ) : ?>
-<p><strong><a href="moderation.php"><?php echo sprintf(__('Comments in moderation (%s)'), number_format($numcomments) ); ?> &raquo;</a></strong></p>
+<p><strong><a href="moderation.php"><?php echo sprintf(__('Comments in moderation (%s)'), number_format_i18n($numcomments) ); ?> &raquo;</a></strong></p>
<?php endif; ?>
<ul>
@@ -61,7 +61,7 @@ foreach ($comments as $comment) {
<?php endif; ?>
<?php
-if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 5") ) :
+if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql('post') . " AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 5") ) :
?>
<div>
<h3><?php _e('Posts'); ?> <a href="edit.php" title="<?php _e('More posts...'); ?>">&raquo;</a></h3>
@@ -103,9 +103,9 @@ $numposts = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_t
$numcomms = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
$numcats = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->categories");
-$post_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Posts">post</a>', '%1$s <a href="%2$s" title="Posts">posts</a>', $numposts), number_format($numposts), 'edit.php');
-$comm_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Comments">comment</a>', '%1$s <a href="%2$s" title="Comments">comments</a>', $numcomms), number_format($numcomms), 'edit-comments.php');
-$cat_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Categories">category</a>', '%1$s <a href="%2$s" title="Categories">categories</a>', $numcats), number_format($numcats), 'categories.php');
+$post_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Posts">post</a>', '%1$s <a href="%2$s" title="Posts">posts</a>', $numposts), number_format_i18n($numposts), 'edit.php');
+$comm_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Comments">comment</a>', '%1$s <a href="%2$s" title="Comments">comments</a>', $numcomms), number_format_i18n($numcomms), 'edit-comments.php');
+$cat_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Categories">category</a>', '%1$s <a href="%2$s" title="Categories">categories</a>', $numcats), number_format_i18n($numcats), 'categories.php');
?>
<p><?php printf(__('There are currently %1$s and %2$s, contained within %3$s.'), $post_str, $comm_str, $cat_str); ?></p>
@@ -122,7 +122,7 @@ $cat_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Categories">category<
<?php endif; ?>
<li><a href="profile.php"><?php _e('Update your profile or change your password'); ?></a></li>
<?php if ( current_user_can('manage_links') ) : ?>
- <li><a href="link-add.php"><?php _e('Add a bookmark to your blogroll'); ?></a></li>
+ <li><a href="link-add.php"><?php _e('Add a link to your blogroll'); ?></a></li>
<?php endif; ?>
<?php if ( current_user_can('switch_themes') ) : ?>
<li><a href="themes.php"><?php _e('Change your site&#8217;s look or theme'); ?></a></li>
diff --git a/wp-admin/link-import.php b/wp-admin/link-import.php
index 2c8accf..8502ed8 100644
--- a/wp-admin/link-import.php
+++ b/wp-admin/link-import.php
@@ -93,7 +93,12 @@ foreach ($categories as $category) {
}
if ( isset($opml_url) && $opml_url != '' ) {
- $opml = wp_remote_fopen($opml_url);
+ if ( $blogrolling === true ) {
+ $opml = wp_remote_fopen($opml_url);
+ } else {
+ $opml = file_get_contents($opml_url);
+ }
+
include_once('link-parse-opml.php');
$link_count = count($names);
@@ -118,6 +123,7 @@ else
} // end else
if ( ! $blogrolling )
+ apply_filters( 'wp_delete_file', $opml_url);
@unlink($opml_url);
?>
</div>
diff --git a/wp-admin/link-manager.php b/wp-admin/link-manager.php
index 54ae4f9..77196bb 100644
--- a/wp-admin/link-manager.php
+++ b/wp-admin/link-manager.php
@@ -180,7 +180,7 @@ if ( $links ) {
break;
default:
?>
- <td><?php do_action('manage_link_custom_column', $column_name, $id); ?></td>
+ <td><?php do_action('manage_link_custom_column', $column_name, $link->link_id); ?></td>
<?php
break;
diff --git a/wp-admin/menu.php b/wp-admin/menu.php
index 37e9714..affd314 100644
--- a/wp-admin/menu.php
+++ b/wp-admin/menu.php
@@ -83,6 +83,7 @@ if( is_site_admin() ) {
$submenu[ 'wpmu-admin.php' ][25] = array( __('Options'), '10', 'wpmu-options.php' );
$submenu[ 'wpmu-admin.php' ][30] = array( __('Upgrade'), '10', 'wpmu-upgrade-site.php' );
}
+do_action('_admin_menu');
// Create list of page plugin hook names.
foreach ($menu as $menu_page) {
diff --git a/wp-admin/moderation.php b/wp-admin/moderation.php
index e24a9a1..caa37ec 100644
--- a/wp-admin/moderation.php
+++ b/wp-admin/moderation.php
@@ -123,14 +123,14 @@ $i = 0;
<?php comment_text() ?>
<p><?php comment_date(__('M j, g:i A')); ?> &#8212; [ <?php
echo '<a href="comment.php?action=editcomment&amp;c='.$comment->comment_ID.'">' . __('Edit') . '</a> | ';
-echo " <a href=\"post.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author )) . "', theCommentList );\">" . __('Delete') . "</a> | "; ?>
+echo " <a href=\"post.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author )) . "', theCommentList );\">" . __('Delete') . "</a> "; ?> ] &#8212;
<?php
$post = get_post($comment->comment_post_ID);
$post_title = wp_specialchars( $post->post_title, 'double' );
$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
?>
-<a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ] &#8212;
- <?php _e('Bulk action:') ?>
+<a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php echo $post_title; ?></a></p>
+<p><?php _e('Bulk action:') ?>
<input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-approve" value="approve" /> <label for="comment-<?php echo $comment->comment_ID; ?>-approve"><?php _e('Approve') ?></label> &nbsp;
<input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-spam" value="spam" /> <label for="comment-<?php echo $comment->comment_ID; ?>-spam"><?php _e('Spam') ?></label> &nbsp;
<input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-delete" value="delete" /> <label for="comment-<?php echo $comment->comment_ID; ?>-delete"><?php _e('Delete') ?></label> &nbsp;
@@ -182,7 +182,7 @@ document.write('<ul><li><a href="javascript:markAllForApprove()"><?php _e('Mark
<noscript>
<p>
- <input name="feelinglucky" type="checkbox" id="feelinglucky" value="true" /> <label for="feelinglucky"><?php _e('Delete every comment marked "defer." <strong>Warning: This can&#8217;t be undone.</strong>'); ?></label>
+ <input name="feelinglucky" type="checkbox" id="feelinglucky" value="true" /> <label for="feelinglucky"><?php _e('Delete every comment marked &#8220;defer.&#8221; <strong>Warning: This can&#8217;t be undone.</strong>'); ?></label>
</p>
</noscript>
</form>
diff --git a/wp-admin/options-permalink.php b/wp-admin/options-permalink.php
index 200cabe..75792db 100644
--- a/wp-admin/options-permalink.php
+++ b/wp-admin/options-permalink.php
@@ -168,10 +168,7 @@ checked="checked"
<p><?php _e('If your <code>.htaccess</code> file were <a href="http://codex.wordpress.org/Make_a_Directory_Writable">writable</a>, we could do this automatically, but it isn&#8217;t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.') ?></p>
<form action="options-permalink.php" method="post">
<?php wp_nonce_field('update-permalink') ?>
- <p>
-<textarea rows="5" style="width: 98%;" name="rules"><?php echo wp_specialchars($wp_rewrite->mod_rewrite_rules()); ?>
-</textarea>
- </p>
+ <p><textarea rows="5" style="width: 98%;" name="rules" id="rules"><?php echo wp_specialchars($wp_rewrite->mod_rewrite_rules()); ?></textarea></p>
</form>
<?php endif; ?>
diff --git a/wp-admin/page.php b/wp-admin/page.php
index 4ef74e9..2825184 100644
--- a/wp-admin/page.php
+++ b/wp-admin/page.php
@@ -62,12 +62,6 @@ case 'edit':
die ( __('You are not allowed to edit this page.') );
include('edit-page-form.php');
- ?>
- <div id='preview' class='wrap'>
- <h2 id="preview-post"><?php _e('Page Preview (updated when page is saved)'); ?></h2>
- <iframe src="<?php echo clean_url(apply_filters('preview_page_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" width="100%" height="600" ></iframe>
- </div>
- <?php
break;
case 'editattachment':
diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php
index 68e1caf..a4edf30 100644
--- a/wp-admin/plugins.php
+++ b/wp-admin/plugins.php
@@ -19,11 +19,13 @@ if ( isset($_GET['action']) ) {
wp_die(__('Plugin file does not exist.'));
if (!in_array($plugin, $current)) {
wp_redirect('plugins.php?error=true'); // we'll override this later if the plugin can be included without fatal error
+ ob_start();
@include(ABSPATH . PLUGINDIR . '/' . $plugin);
$current[] = $plugin;
sort($current);
update_option('active_plugins', $current);
do_action('activate_' . $plugin);
+ ob_end_clean();
}
wp_redirect('plugins.php?activate=true'); // overrides the ?error=true one above
} else if ('deactivate' == $_GET['action']) {
@@ -33,6 +35,17 @@ if ( isset($_GET['action']) ) {
update_option('active_plugins', $current);
do_action('deactivate_' . trim( $_GET['plugin'] ));
wp_redirect('plugins.php?deactivate=true');
+ } elseif ($_GET['action'] == 'deactivate-all') {
+ check_admin_referer('deactivate-all');
+ $current = get_option('active_plugins');
+
+ foreach ($current as $plugin) {
+ array_splice($current, array_search($plugin, $current), 1);
+ do_action('deactivate_' . $plugin);
+ }
+
+ update_option('active_plugins', array());
+ wp_redirect('plugins.php?deactivate-all=true');
}
exit;
}
@@ -72,6 +85,8 @@ foreach ($check_plugins as $check_plugin) {
<div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div>
<?php elseif ( isset($_GET['deactivate']) ) : ?>
<div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p></div>
+<?php elseif (isset($_GET['deactivate-all'])) : ?>
+ <div id="message" class="updated fade"><p><?php _e('All plugins <strong>deactivated</strong>.'); ?></p></div>
<?php endif; ?>
<div class="wrap">
@@ -139,6 +154,11 @@ if (empty($plugins)) {
}
?>
+<tr>
+ <td colspan="3">&nbsp;</td>
+ <td colspan="2" style="width:12em;"><a href="<?php echo wp_nonce_url('plugins.php?action=deactivate-all', 'deactivate-all'); ?>" class="delete"><?php _e('Deactivate All Plugins'); ?></a></td>
+</tr>
+
</table>
<?php
}
diff --git a/wp-admin/post-new.php b/wp-admin/post-new.php
index fd8a046..e2c978b 100644
--- a/wp-admin/post-new.php
+++ b/wp-admin/post-new.php
@@ -10,7 +10,7 @@ require_once ('./admin-header.php');
if ( ! current_user_can('edit_posts') ) { ?>
<div class="wrap">
-<p><?php printf(__('Since you&#8217;re a newcomer, you&#8217;ll have to wait for an admin to raise your level to 1, in order to be authorized to post.<br />
+<p><?php printf(__('Since you&#8217;re a newcomer, you&#8217;ll have to wait for an admin to add the <code>edit_posts</code> capability to your user, in order to be authorized to post.<br />
You can also <a href="mailto:%s?subject=Promotion?">e-mail the admin</a> to ask for a promotion.<br />
When you&#8217;re promoted, just reload this page and you&#8217;ll be able to blog. :)'), get_option('admin_email')); ?>
</p>
@@ -57,7 +57,7 @@ include('edit-form-advanced.php');
<?php if ( $is_NS4 || $is_gecko || $is_winIE ) { ?>
<div id="wp-bookmarklet" class="wrap">
<h3><?php _e('WordPress Bookmarklet'); ?></h3>
-<p><?php _e('Right click on the following link and choose "Add to favorites" to create a posting shortcut.'); ?></p>
+<p><?php _e('Right click on the following link and choose &#0147;Bookmark This Link...&#0148; or &#0147;Add to Favorites...&#0148; to create a posting shortcut.'); ?></p>
<p>
<?php
diff --git a/wp-admin/post.php b/wp-admin/post.php
index b67f6bc..3006773 100644
--- a/wp-admin/post.php
+++ b/wp-admin/post.php
@@ -66,12 +66,6 @@ case 'edit':
include('edit-form-advanced.php');
- ?>
- <div id='preview' class='wrap'>
- <h2 id="preview-post"><?php _e('Post Preview (updated when post is saved)'); ?></h2>
- <iframe src="<?php echo clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" width="100%" height="600" ></iframe>
- </div>
- <?php
break;
case 'editattachment':
diff --git a/wp-admin/profile.php b/wp-admin/profile.php
index 3cf24e5..7654868 100644
--- a/wp-admin/profile.php
+++ b/wp-admin/profile.php
@@ -46,16 +46,16 @@ $bookmarklet_height= 440;
</label></p>
<p><label><?php _e('First name:') ?><br />
-<input type="text" name="first_name" value="<?php echo $profileuser->first_name ?>" /></label></p>
+<input type="text" name="first_name" id="first_name" value="<?php echo $profileuser->first_name ?>" /></label></p>
<p><label><?php _e('Last name:') ?><br />
-<input type="text" name="last_name" value="<?php echo $profileuser->last_name ?>" /></label></p>
+<input type="text" name="last_name" id="last_name" value="<?php echo $profileuser->last_name ?>" /></label></p>
<p><label><?php _e('Nickname:') ?><br />
-<input type="text" name="nickname" value="<?php echo $profileuser->nickname ?>" /></label></p>
+<input type="text" name="nickname" id="nickname" value="<?php echo $profileuser->nickname ?>" /></label></p>
<p><label><?php _e('Display name publicly as:') ?> <br />
-<select name="display_name">
+<select name="display_name" id="display_name">
<option value="<?php echo $profileuser->display_name; ?>"><?php echo $profileuser->display_name; ?></option>
<option value="<?php echo $profileuser->nickname ?>"><?php echo $profileuser->nickname ?></option>
<option value="<?php echo $profileuser->user_login ?>"><?php echo $profileuser->user_login ?></option>
@@ -76,29 +76,29 @@ $bookmarklet_height= 440;
<legend><?php _e('Contact Info'); ?></legend>
<p><label><?php _e('E-mail: (required)') ?><br />
-<input type="text" name="email" value="<?php echo $profileuser->user_email ?>" /></label></p>
+<input type="text" name="email" id="email" value="<?php echo $profileuser->user_email ?>" /></label></p>
<p><label><?php _e('Website:') ?><br />
-<input type="text" name="url" value="<?php echo $profileuser->user_url ?>" />
+<input type="text" name="url" id="url" value="<?php echo $profileuser->user_url ?>" />
</label></p>
<p><label><?php _e('AIM:') ?><br />
-<input type="text" name="aim" value="<?php echo $profileuser->aim ?>" />
+<input type="text" name="aim" id="aim" value="<?php echo $profileuser->aim ?>" />
</label></p>
<p><label><?php _e('Yahoo IM:') ?><br />
-<input type="text" name="yim" value="<?php echo $profileuser->yim ?>" />
+<input type="text" name="yim" id="yim" value="<?php echo $profileuser->yim ?>" />
</label></p>
<p><label><?php _e('Jabber / Google Talk:') ?><br />
-<input type="text" name="jabber" value="<?php echo $profileuser->jabber ?>" /></label>
+<input type="text" name="jabber" id="jabber" value="<?php echo $profileuser->jabber ?>" /></label>
</p>
</fieldset>
<br clear="all" />
<fieldset>
<legend><?php _e('About Yourself'); ?></legend>
<p class="desc"><?php _e('Share a little biographical information. '); ?></p>
-<p><textarea name="description" rows="5" cols="30"><?php echo $profileuser->description ?></textarea></p>
+<p><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description ?></textarea></p>
</fieldset>
<?php
@@ -109,10 +109,10 @@ if ( $show_password_fields ) :
<legend><?php _e('Update Your Password'); ?></legend>
<p class="desc"><?php _e('If you would like to change your password type a new one twice below. Otherwise leave this blank.'); ?></p>
<p><label><?php _e('New Password:'); ?><br />
-<input type="password" name="pass1" size="16" value="" />
+<input type="password" name="pass1" id="pass1" size="16" value="" />
</label></p>
<p><label><?php _e('Type it one more time:'); ?><br />
-<input type="password" name="pass2" size="16" value="" />
+<input type="password" name="pass2" id="pass2" size="16" value="" />
</label></p>
</fieldset>
<?php endif; ?>
diff --git a/wp-admin/rtl.css b/wp-admin/rtl.css
index 3fdf6b5..2a83e48 100644
--- a/wp-admin/rtl.css
+++ b/wp-admin/rtl.css
@@ -14,7 +14,7 @@
#wphead h1 { font-size: 2.4em; }
-#postdiv , #titlediv, #guiddiv { margin: 0 0 0 8px; }
+#postdiv, #titlediv, #guiddiv, #tagdiv { margin: 0 0 0 8px; }
#ed_toolbar input { margin: 3px 0 2px 2px; }
@@ -196,3 +196,10 @@ a.dbx-toggle, a.dbx-toggle:visited {
margin-right: auto;
margin-left: 3px;
}
+
+a.view-link {
+ right:auto;
+ left:5%;
+ margin-right:0;
+ margin-left:220px;
+}
diff --git a/wp-admin/themes.php b/wp-admin/themes.php
index 9f2c21f..0b7d64f 100644
--- a/wp-admin/themes.php
+++ b/wp-admin/themes.php
@@ -101,7 +101,7 @@ foreach ($theme_names as $theme_name) {
$activate_link = wp_nonce_url("themes.php?action=activate&amp;template=$template&amp;stylesheet=$stylesheet", 'switch-theme_' . $template);
?>
<div class="available-theme">
-<h3><a href="<?php echo $activate_link; ?>"><?php echo "$title $version"; ?></a></h3>
+<h3><a href="<?php echo $activate_link; ?>"><?php echo $title; ?></a></h3>
<a href="<?php echo $activate_link; ?>" class="screenshot">
<?php if ( $screenshot ) : ?>
diff --git a/wp-admin/upgrade-functions.php b/wp-admin/upgrade-functions.php
index 35095d0..e3357ec 100644
--- a/wp-admin/upgrade-functions.php
+++ b/wp-admin/upgrade-functions.php
@@ -184,6 +184,12 @@ function upgrade_all() {
if ( $wp_current_db_version < 4351 )
upgrade_old_slugs();
+
+ if ( $wp_current_db_version < 5200 ) {
+ upgrade_230();
+ }
+
+ maybe_disable_automattic_widgets();
$wp_rewrite->flush_rules();
@@ -574,6 +580,14 @@ function upgrade_210() {
}
}
+function upgrade_230() {
+ global $wp_current_db_version;
+
+ if ( $wp_current_db_version < 5200 ) {
+ populate_roles_230();
+ }
+}
+
function upgrade_old_slugs() {
// upgrade people who were using the Redirect Old Slugs plugin
global $wpdb;
@@ -666,7 +680,15 @@ function get_alloptions_110() {
// Version of get_option that is private to install/upgrade.
function __get_option($setting) {
global $wpdb;
-
+
+ if ( $setting == 'home' && defined( 'WP_HOME' ) ) {
+ return preg_replace( '|/+$|', '', constant( 'WP_HOME' ) );
+ }
+
+ if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) ) {
+ return preg_replace( '|/+$|', '', constant( 'WP_SITEURL' ) );
+ }
+
$option = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting'");
if ( 'home' == $setting && '' == $option )
@@ -1109,4 +1131,16 @@ function wp_check_mysql_version() {
die(sprintf(__('<strong>ERROR</strong>: WordPress %s requires MySQL 4.0.0 or higher'), $wp_version));
}
-?>
+function maybe_disable_automattic_widgets() {
+ $plugins = __get_option( 'active_plugins' );
+
+ foreach ( (array) $plugins as $plugin ) {
+ if ( basename( $plugin ) == 'widgets.php' ) {
+ array_splice( $plugins, array_search( $plugin, $plugins ), 1 );
+ update_option( 'active_plugins', $plugins );
+ break;
+ }
+ }
+}
+
+?> \ No newline at end of file
diff --git a/wp-admin/upload-functions.php b/wp-admin/upload-functions.php
index 79060e2..31965bc 100644
--- a/wp-admin/upload-functions.php
+++ b/wp-admin/upload-functions.php
@@ -355,4 +355,5 @@ function wp_upload_admin_head() {
echo "</style>";
}
}
+
?>
diff --git a/wp-admin/upload.css b/wp-admin/upload.css
index fbb41cd..009986c 100644
--- a/wp-admin/upload.css
+++ b/wp-admin/upload.css
@@ -44,6 +44,7 @@ body > #upload-menu { border-bottom: 7px solid #fff; }
}
#upload-menu li #current-tab-nav {
+ background: #f9fcfe;
float: left;
padding: 5px 5px 0 0;
margin-left: -5px;
diff --git a/wp-admin/upload.php b/wp-admin/upload.php
index 562272c..2aa3f66 100644
--- a/wp-admin/upload.php
+++ b/wp-admin/upload.php
@@ -59,7 +59,7 @@ foreach ( $wp_upload_tabs as $t => $tab_array ) {
if ( 'inline' == $style ) : ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
+<html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
<title><?php bloginfo('name') ?> &rsaquo; <?php _e('Uploads'); ?> &#8212; WordPress</title>
@@ -89,7 +89,7 @@ echo "<ul id='upload-menu'>\n";
foreach ( $wp_upload_tabs as $t => $tab_array ) { // We've already done the current_user_can check
$href = add_query_arg( array('tab' => $t, 'ID' => '', 'action' => '', 'paged' => '') );
if ( isset($tab_array[4]) && is_array($tab_array[4]) )
- add_query_arg( $tab_array[4], $href );
+ $href = add_query_arg( $tab_array[4], $href );
$_href = clean_url( $href);
$page_links = '';
$class = 'upload-tab alignleft';
diff --git a/wp-admin/user-edit.php b/wp-admin/user-edit.php
index 9760864..c025f62 100644
--- a/wp-admin/user-edit.php
+++ b/wp-admin/user-edit.php
@@ -61,7 +61,7 @@ include ('admin-header.php');
<div id="message" class="updated fade">
<p><strong><?php _e('User updated.') ?></strong></p>
<?php if ( $wp_http_referer ) : ?>
- <p><a href="<?php echo clean_url($wp_http_referer); ?>"><?php _e('&laquo; Back to Authors and Users'); ?></a></p>
+ <p><a href="users.php"><?php _e('&laquo; Back to Authors and Users'); ?></a></p>
<?php endif; ?>
</div>
<?php endif; ?>
@@ -89,6 +89,10 @@ include ('admin-header.php');
<input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" />
</p>
+<p><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="true" <?php checked('true', $profileuser->rich_editing); ?> /> <?php _e('Use the visual editor when writing'); ?></label></p>
+
+<p class="submit"><input type="submit" value="<?php _e('Update User &raquo;'); ?>" name="submit" /></p>
+
<fieldset>
<legend><?php _e('Name'); ?></legend>
<p><label><?php _e('Username: (no editing)'); ?><br />
diff --git a/wp-admin/widgets-rtl.css b/wp-admin/widgets-rtl.css
new file mode 100644
index 0000000..805f39d
--- /dev/null
+++ b/wp-admin/widgets-rtl.css
@@ -0,0 +1,39 @@
+#sbreset, #lastmodule, #palettediv .module, .dropzone, .dropzone ul { float: right; }
+
+* .module, #lastmodule { text-align: right; }
+
+* html #palettediv ul { padding: 0 10px 0 0; }
+
+#palettediv ul { padding: 0 10px 0 0; }
+
+* .handle, #lastmodule span {
+ border-right: 1px solid #f2f2f2;
+ border-left: 1px solid #e8e8e8;
+}
+
+#sbadmin p.submit {
+ padding-right: 0;
+ padding-left: 10px;
+ clear: right;
+}
+
+#palettediv .module, #lastmodule, .dropzone {
+ margin-right: auto;
+ margin-left: 10px;
+}
+
+* .popper {
+ right: auto;
+ left: 3px;
+ background-position: 5px 0;
+}
+
+.controlcloser {
+ right: auto;
+ left: 8px;
+}
+
+#shadow {
+ left: auto;
+ right: 0px;
+} \ No newline at end of file
diff --git a/wp-admin/widgets.css b/wp-admin/widgets.css
new file mode 100644
index 0000000..f78dbe5
--- /dev/null
+++ b/wp-admin/widgets.css
@@ -0,0 +1,214 @@
+body {
+ height: 100%;
+}
+
+#sbadmin #zones {
+ -moz-user-select: none;
+ -khtml-user-select: none;
+ user-select: none;
+}
+
+#sbreset {
+ float: left;
+ margin: 1px 0;
+}
+
+.dropzone {
+ float: left;
+ margin-right: 10px;
+ padding: 5px;
+ border: 1px solid #bbb;
+ background-color: #f0f8ff;
+}
+
+.dropzone h3 {
+ text-align: center;
+ color: #333;
+}
+
+.dropzone ul {
+ list-style-type: none;
+ width: 240px;
+ float: left;
+ margin: 0;
+ padding: 0;
+}
+
+* .module, #lastmodule {
+ width: 238px;
+ padding: 0;
+ margin: 5px 0;
+ cursor: move;
+ display: block;
+ border: 1px solid #ccc;
+ background-color: #fbfbfb;
+ text-align: left;
+ line-height: 25px;
+}
+
+* .handle, #lastmodule span {
+ display: block;
+ width: 216px;
+ padding: 0 10px;
+ border-top: 1px solid #f2f2f2;
+ border-right: 1px solid #e8e8e8;
+ border-bottom: 1px solid #e8e8e8;
+ border-left: 1px solid #f2f2f2;
+}
+
+* .popper {
+ margin: 0;
+ display: inline;
+ position: absolute;
+ top: 3px;
+ right: 3px;
+ overflow: hidden;
+ text-align: center;
+ height: 16px;
+ font-size: 18px;
+ line-height: 14px;
+ cursor: pointer;
+ padding: 0 3px 1px;
+ border-top: 4px solid #6da6d1;
+ background: url( images/fade-butt.png ) -5px 0px;
+}
+
+* html .popper {
+ padding: 1px 6px 0;
+ font-size: 16px;
+}
+
+#sbadmin p.submit {
+ padding-right: 10px;
+ clear: left;
+}
+
+.placematt {
+ cursor: default;
+ margin: 10px 0 0;
+ padding: 0;
+ width: 238px;
+ float:left;
+ background-color: #ffe;
+}
+
+* html .placematt {
+ margin-top: 5px;
+}
+
+.placematt h4 {
+ text-align: center;
+ margin-bottom: 5px;
+}
+
+.placematt span {
+ padding: 0 10px 10px;
+ text-align: justify;
+}
+
+
+#palettediv {
+ border: 1px solid #bbb;
+ background-color: #f0f8ff;
+ height:auto;
+ margin-top: 10px;
+}
+
+#palettediv h3 {
+ text-align: center;
+ color: #333;
+}
+
+#palettediv ul {
+ padding: 0 0 0 10px;
+}
+
+#palettediv .module, #lastmodule {
+ margin-right: 10px;
+ float: left;
+ width: 120px;
+}
+
+#palettediv .handle, #lastmodule span {
+ height: 40px;
+ font-size: 90%;
+ width: 110px;
+ padding: 0 5px;
+}
+
+#palettediv .popper {
+ visibility: hidden;
+}
+
+#lastmodule {
+ visibility: hidden;
+}
+
+* html #palettediv ul {
+ margin: 0;
+ padding: 0 0 0 10px;
+}
+
+* html #palettediv .module {
+ float: none;
+ display: inline;
+}
+
+#controls {
+ height: 0px;
+}
+
+.control {
+ position: absolute;
+ display: block;
+ background: #f9fcfe;
+ padding: 0;
+}
+
+.controlhandle {
+ cursor: move;
+ background-color: #6da6d1;
+ border-bottom: 2px solid #448abd;
+ color: #333;
+ display: block;
+ margin: 0 0 5px;
+ padding: 4px;
+ font-size: 120%;
+}
+
+.controlcloser {
+ cursor: pointer;
+ font-size: 120%;
+ display: block;
+ position: absolute;
+ top: 2px;
+ right: 8px;
+ padding: 0 3px;
+ font-weight: bold;
+}
+
+.controlform {
+ margin: 20px 30px;
+}
+
+.controlform p {
+ text-align: center;
+}
+
+.control .checkbox {
+ border: none;
+ background: transparent;
+}
+
+.hidden {
+ display: none;
+}
+
+#shadow {
+ background: black;
+ display: none;
+ position: absolute;
+ top: 0px;
+ left: 0px;
+ width: 100%;
+} \ No newline at end of file
diff --git a/wp-admin/widgets.php b/wp-admin/widgets.php
new file mode 100644
index 0000000..a8d469e
--- /dev/null
+++ b/wp-admin/widgets.php
@@ -0,0 +1,390 @@
+<?php
+
+require_once 'admin.php';
+
+if ( ! current_user_can('switch_themes') )
+ wp_die( __( 'Cheatin&#8217; uh?' ));
+
+wp_enqueue_script( 'scriptaculous-effects' );
+wp_enqueue_script( 'scriptaculous-dragdrop' );
+
+function wp_widgets_admin_head() {
+ global $wp_registered_sidebars, $wp_registered_widgets, $wp_registered_widget_controls;
+
+ define( 'WP_WIDGETS_WIDTH', 1 + 262 * ( count( $wp_registered_sidebars ) ) );
+ define( 'WP_WIDGETS_HEIGHT', 35 * ( count( $wp_registered_widgets ) ) );
+?>
+ <link rel="stylesheet" href="widgets.css?version=<?php bloginfo('version'); ?>" type="text/css" />
+ <!--[if IE 7]>
+ <style type="text/css">
+ #palette {float:left;}
+ </style>
+ <![endif]-->
+ <style type="text/css">
+ .dropzone ul { height: <?php echo constant( 'WP_WIDGETS_HEIGHT' ); ?>px; }
+ #sbadmin #zones { width: <?php echo constant( 'WP_WIDGETS_WIDTH' ); ?>px; }
+ </style>
+<?php
+ if ( get_bloginfo( 'text_direction' ) == 'rtl' ) {
+?>
+ <link rel="stylesheet" href="widgets-rtl.css?version=<?php bloginfo('version'); ?>" type="text/css" />
+<?php
+ }
+
+ $cols = array();
+ foreach ( $wp_registered_sidebars as $index => $sidebar ) {
+ $cols[] = '\'' . $index . '\'';
+ }
+ $cols = implode( ', ', $cols );
+
+ $widgets = array();
+ foreach ( $wp_registered_widgets as $name => $widget ) {
+ $widgets[] = '\'' . $widget['id'] . '\'';
+ }
+ $widgets = implode( ', ', $widgets );
+?>
+<script type="text/javascript">
+// <![CDATA[
+ var cols = [<?php echo $cols; ?>];
+ var widgets = [<?php echo $widgets; ?>];
+ var controldims = new Array;
+ <?php foreach ( $wp_registered_widget_controls as $name => $widget ) : ?>
+ controldims['<?php echo $widget['id']; ?>control'] = new Array;
+ controldims['<?php echo $widget['id']; ?>control']['width'] = <?php echo (int) $widget['width']; ?>;
+ controldims['<?php echo $widget['id']; ?>control']['height'] = <?php echo (int) $widget['height']; ?>;
+ <?php endforeach; ?>
+ function initWidgets() {
+ <?php foreach ( $wp_registered_widget_controls as $name => $widget ) : ?>
+ $('<?php echo $widget['id']; ?>popper').onclick = function() {popControl('<?php echo $widget['id']; ?>control');};
+ $('<?php echo $widget['id']; ?>closer').onclick = function() {unpopControl('<?php echo $widget['id']; ?>control');};
+ new Draggable('<?php echo $widget['id']; ?>control', {revert:false,handle:'controlhandle',starteffect:function(){},endeffect:function(){},change:function(o){dragChange(o);}});
+ if ( true && window.opera )
+ $('<?php echo $widget['id']; ?>control').style.border = '1px solid #bbb';
+ <?php endforeach; ?>
+ if ( true && window.opera )
+ $('shadow').style.background = 'transparent';
+ new Effect.Opacity('shadow', {to:0.0});
+ widgets.map(function(o) {o='widgetprefix-'+o; Position.absolutize(o); Position.relativize(o);} );
+ $A(Draggables.drags).map(function(o) {o.startDrag(null); o.finishDrag(null);});
+ //for ( var n in Draggables.drags ) {
+ for ( n=0; n<=Draggables.drags.length; n++ ) {
+ if ( Draggables.drags[n].element.id == 'lastmodule' ) {
+ Draggables.drags[n].destroy();
+ break;
+ }
+ }
+ resetPaletteHeight();
+ }
+ function resetDroppableHeights() {
+ var max = 6;
+ cols.map(function(o) {var c = $(o).childNodes.length; if ( c > max ) max = c;} );
+ var height = 35 * ( max + 1);
+ cols.map(function(o) {h = (($(o).childNodes.length + 1) * 35); $(o).style.height = (h > 280 ? h : 280) + 'px';} );
+ }
+ function resetPaletteHeight() {
+ var p = $('palette'), pd = $('palettediv'), last = $('lastmodule');
+ p.appendChild(last);
+ if ( Draggables.activeDraggable && last.id == Draggables.activeDraggable.element.id )
+ last = last.previousSibling;
+ var y1 = Position.cumulativeOffset(last)[1] + last.offsetHeight;
+ var y2 = Position.cumulativeOffset(pd)[1] + pd.offsetHeight;
+ var dy = y1 - y2;
+ pd.style.height = (pd.offsetHeight + dy + 9) + "px";
+ }
+ function maxHeight(elm) {
+ htmlheight = document.body.parentNode.clientHeight;
+ bodyheight = document.body.clientHeight;
+ var height = htmlheight > bodyheight ? htmlheight : bodyheight;
+ $(elm).style.height = height + 'px';
+ }
+ function dragChange(o) {
+ el = o.element ? o.element : $(o);
+ var p = Position.page(el);
+ var right = p[0];
+ var top = p[1];
+ var left = $('shadow').offsetWidth - (el.offsetWidth + right);
+ var bottom = $('shadow').offsetHeight - (el.offsetHeight + top);
+ if ( right < 1 ) el.style.left = 0;
+ if ( top < 1 ) el.style.top = 0;
+ if ( left < 1 ) el.style.left = (left + right) + 'px';
+ if ( bottom < 1 ) el.style.top = (top + bottom) + 'px';
+ }
+ function popControl(elm) {
+ el = $(elm);
+ el.style.width = controldims[elm]['width'] + 'px';
+ el.style.height = controldims[elm]['height'] + 'px';
+ var x = ( document.body.clientWidth - controldims[elm]['width'] ) / 2;
+ var y = ( document.body.parentNode.clientHeight - controldims[elm]['height'] ) / 2;
+ el.style.position = 'absolute';
+ el.style.right = '' + x + 'px';
+ el.style.top = '' + y + 'px';
+ el.style.zIndex = 1000;
+ el.className='control';
+ $('shadow').onclick = function() {unpopControl(elm);};
+ window.onresize = function(){maxHeight('shadow');dragChange(elm);};
+ popShadow();
+ }
+ function popShadow() {
+ maxHeight('shadow');
+ var shadow = $('shadow');
+ shadow.style.zIndex = 999;
+ shadow.style.display = 'block';
+ new Effect.Opacity('shadow', {duration:0.5, from:0.0, to:0.2});
+ }
+ function unpopShadow() {
+ new Effect.Opacity('shadow', {to:0.0});
+ $('shadow').style.display = 'none';
+ }
+ function unpopControl(el) {
+ $(el).className='hidden';
+ unpopShadow();
+ }
+ function serializeAll() {
+ <?php foreach ( $wp_registered_sidebars as $index => $sidebar ) : ?>
+ $('<?php echo $index; ?>order').value = Sortable.serialize('<?php echo $index; ?>');
+ <?php endforeach; ?>
+ }
+ function updateAll() {
+ resetDroppableHeights();
+ resetPaletteHeight();
+ cols.map(function(o){
+ var pm = $(o+'placematt');
+ if ( $(o).childNodes.length == 0 ) {
+ pm.style.display = 'block';
+ //Position.absolutize(o+'placematt');
+ } else {
+ pm.style.display = 'none';
+ }
+ });
+ }
+ function noSelection(event) {
+ if ( document.selection ) {
+ var range = document.selection.createRange();
+ range.collapse(false);
+ range.select();
+ return false;
+ }
+ }
+ addLoadEvent(updateAll);
+ addLoadEvent(initWidgets);
+ Event.observe(window, 'resize', resetPaletteHeight);
+// ]]>
+</script>
+<?php
+}
+add_action( 'admin_head', 'wp_widgets_admin_head' );
+do_action( 'sidebar_admin_setup' );
+
+function wp_widget_draggable( $name ) {
+ global $wp_registered_widgets, $wp_registered_widget_controls;
+
+ if ( !isset( $wp_registered_widgets[$name] ) ) {
+ return;
+ }
+
+ $sanitized_name = sanitize_title( $wp_registered_widgets[$name]['id'] );
+ $link_title = __( 'Configure' );
+ $popper = ( isset( $wp_registered_widget_controls[$name] ) )
+ ? ' <div class="popper" id="' . $sanitized_name . 'popper" title="' . $link_title . '">&#8801;</div>'
+ : '';
+
+ $output = '<li class="module" id="widgetprefix-%1$s"><span class="handle">%2$s</span></li>';
+
+ printf( $output, $sanitized_name, $wp_registered_widgets[$name]['name'] . $popper );
+}
+
+$title = __( 'Widgets' );
+$parent_file = 'themes.php';
+
+require_once 'admin-header.php';
+
+if ( count( $wp_registered_sidebars ) < 1 ) {
+?>
+ <div class="wrap">
+ <h2><?php _e( 'No Sidebars Defined' ); ?></h2>
+
+ <p><?php _e( 'You are seeing this message because the theme you are currently using isn&#8217;t widget-aware, meaning that it has no sidebars that you are able to change. For information on making your theme widget-aware, please <a href="http://automattic.com/code/widgets/themes/">follow these instructions</a>.' ); /* TODO: article on codex */; ?></p>
+ </div>
+<?php
+
+ require_once 'admin-footer.php';
+ exit;
+}
+
+$sidebars_widgets = wp_get_sidebars_widgets();
+
+if ( empty( $sidebars_widgets ) ) {
+ $sidebars_widgets = wp_get_widget_defaults();
+}
+
+if ( isset( $_POST['action'] ) ) {
+ check_admin_referer( 'widgets-save-widget-order' );
+
+ switch ( $_POST['action'] ) {
+ case 'default' :
+ $sidebars_widgets = wp_get_widget_defaults();
+ wp_set_sidebars_widgets( $sidebars_widgets );
+ break;
+
+ case 'save_widget_order' :
+ $sidebars_widgets = array();
+
+ foreach ( $wp_registered_sidebars as $index => $sidebar ) {
+ $postindex = $index . 'order';
+
+ parse_str( $_POST[$postindex], $order );
+
+ $new_order = $order[$index];
+
+ if ( is_array( $new_order ) ) {
+ foreach ( $new_order as $sanitized_name ) {
+ foreach ( $wp_registered_widgets as $name => $widget ) {
+ if ( $sanitized_name == $widget['id'] ) {
+ $sidebars_widgets[$index][] = $name;
+ }
+ }
+ }
+ }
+ }
+
+ wp_set_sidebars_widgets( $sidebars_widgets );
+ break;
+ }
+}
+
+ksort( $wp_registered_widgets );
+
+$inactive_widgets = array();
+
+foreach ( $wp_registered_widgets as $name => $widget ) {
+ $is_active = false;
+
+ foreach ( $wp_registered_sidebars as $index => $sidebar ) {
+ if ( is_array( $sidebars_widgets[$index] ) && in_array( $name, $sidebars_widgets[$index] ) ) {
+ $is_active = true;
+ break;
+ }
+ }
+
+ if ( !$is_active ) {
+ $inactive_widgets[] = $name;
+ }
+}
+
+$containers = array( 'palette' );
+
+foreach ( $wp_registered_sidebars as $index => $sidebar ) {
+ $containers[] = $index;
+}
+
+$c_string = '';
+
+foreach ( $containers as $container ) {
+ $c_string .= '"' . $container . '",';
+}
+
+$c_string = substr( $c_string, 0, -1 );
+
+if ( isset( $_POST['action'] ) ) {
+?>
+ <div class="fade updated" id="message">
+ <p><?php printf( __( 'Sidebar updated. <a href="%s">View site &raquo;</a>' ), get_bloginfo( 'url' ) . '/' ); ?></p>
+ </div>
+<?php
+}
+?>
+ <div class="wrap">
+ <h2><?php _e( 'Sidebar Arrangement' ); ?></h2>
+
+ <p><?php _e( 'You can drag and drop widgets onto your sidebar below.' ); ?></p>
+
+ <form id="sbadmin" method="post" onsubmit="serializeAll();">
+ <p class="submit">
+ <input type="submit" value="<?php _e( 'Save Changes &raquo;' ); ?>" />
+ </p>
+ <div id="zones">
+ <?php
+ foreach ( $wp_registered_sidebars as $index => $sidebar ) {
+ ?>
+ <input type="hidden" id="<?php echo $index; ?>order" name="<?php echo $index; ?>order" value="" />
+
+ <div class="dropzone">
+ <h3><?php echo $sidebar['name']; ?></h3>
+
+ <div id="<?php echo $index; ?>placematt" class="module placemat">
+ <span class="handle">
+ <h4><?php _e( 'Default Sidebar' ); ?></h4>
+ <?php _e( 'Your theme will display its usual sidebar when this box is empty. Dragging widgets into this box will replace the usual sidebar with your customized sidebar.' ); ?>
+ </span>
+ </div>
+
+ <ul id="<?php echo $index; ?>">
+ <?php
+ if ( is_array( $sidebars_widgets[$index] ) ) {
+ foreach ( $sidebars_widgets[$index] as $name ) {
+ wp_widget_draggable( $name );
+ }
+ }
+ ?>
+ </ul>
+ </div>
+ <?php
+ }
+ ?>
+
+ <br class="clear" />
+
+ </div>
+
+ <div id="palettediv">
+ <h3><?php _e( 'Available Widgets' ); ?></h3>
+
+ <ul id="palette">
+ <?php
+ foreach ( $inactive_widgets as $name ) {
+ wp_widget_draggable( $name );
+ }
+ ?>
+ <li id="lastmodule"><span></span></li>
+ </ul>
+ </div>
+
+ <script type="text/javascript">
+ // <![CDATA[
+ <?php foreach ( $containers as $container ) { ?>
+ Sortable.create("<?php echo $container; ?>", {
+ dropOnEmpty: true, containment: [<?php echo $c_string; ?>],
+ handle: 'handle', constraint: false, onUpdate: updateAll,
+ format: /^widgetprefix-(.*)$/
+ });
+ <?php } ?>
+ // ]]>
+ </script>
+
+ <p class="submit">
+ <?php wp_nonce_field( 'widgets-save-widget-order' ); ?>
+ <input type="hidden" name="action" id="action" value="save_widget_order" />
+ <input type="submit" value="<?php _e( 'Save Changes &raquo;' ); ?>" />
+ </p>
+
+ <div id="controls">
+ <?php foreach ( $wp_registered_widget_controls as $name => $widget ) { ?>
+ <div class="hidden" id="<?php echo $widget['id']; ?>control">
+ <span class="controlhandle"><?php echo $widget['name']; ?></span>
+ <span id="<?php echo $widget['id']; ?>closer" class="controlcloser">&#215;</span>
+ <div class="controlform">
+ <?php call_user_func_array( $widget['callback'], $widget['params'] ); ?>
+ </div>
+ </div>
+ <?php } ?>
+ </div>
+ </form>
+
+ <br class="clear" />
+ </div>
+
+ <div id="shadow"> </div>
+
+ <?php do_action( 'sidebar_admin_page' ); ?>
+
+<?php require_once 'admin-footer.php'; ?>
diff --git a/wp-admin/wp-admin.css b/wp-admin/wp-admin.css
index 6de69f4..14c93a2 100644
--- a/wp-admin/wp-admin.css
+++ b/wp-admin/wp-admin.css
@@ -120,7 +120,6 @@ a:visited {
}
a:hover {
-/* border-bottom: 1px solid #3a75ae;*/
color: #069;
}
@@ -132,7 +131,7 @@ body {
}
body, td {
- font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana;
+ font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
}
fieldset {
@@ -170,10 +169,10 @@ form, label input {
}
h2 {
- border-bottom: .5em solid #e5f3ff;
color: #333;
- font: normal 32px/5px serif;
+ font: normal 32px serif;
margin: 5px 10px;
+ background: url( images/heading-bg.gif ) repeat-x bottom;
}
img, #footer a {
@@ -437,7 +436,7 @@ form#upload #post_content {
}
.wrap h2 {
- margin: .4em 0 .5em;
+ margin: 0 0 .5em;
clear: both;
}
@@ -538,7 +537,7 @@ input.disabled, textarea.disabled {
border: none;
}
-#postdiv, #titlediv, #guiddiv {
+#postdiv, #titlediv, #guiddiv, #tagdiv {
margin: 0 8px 0 0;
padding: 0;
}
@@ -554,11 +553,11 @@ input.disabled, textarea.disabled {
}
#postdivrich #content {
- padding: .7em;
+ padding: 5px;
line-height: 140%;
}
-#titlediv input, #guiddiv input {
+#titlediv input, #guiddiv input, #tagdiv input {
margin: 0;
width: 100%;
}
@@ -629,7 +628,7 @@ input.delete:hover {
#title {
font-size: 1.7em;
- padding: 4px;
+ padding: 4px 3px;
}
#postexcerpt div, #attachmentlinks div {
@@ -912,17 +911,13 @@ input.delete:hover {
}
#zeitgeist h2, fieldset legend a {
- border-bottom: none;
+ background: none;
}
* html #zeitgeist h2 {
padding-top: 10px;
}
-#zeitgeist h2 {
- margin-top: .4em;
-}
-
#zeitgeist h3 {
border-bottom: 1px solid #ccc;
font-size: 16px;
@@ -1332,3 +1327,10 @@ a.page-numbers:hover {
font-weight: bold;
margin: 0 6px;
}
+
+a.view-link {
+ position: absolute;
+ right: 5%;
+ margin-right: 220px;
+ text-decoration:underline;
+}
diff --git a/app.php b/wp-app.php
index d64ccc2..078667d 100644
--- a/app.php
+++ b/wp-app.php
@@ -1,6 +1,6 @@
<?php
/*
- * app.php - Atom Publishing Protocol support for WordPress
+ * wp-app.php - Atom Publishing Protocol support for WordPress
* Original code by: Elias Torres, http://torrez.us/archives/2006/08/31/491/
* Modified by: Dougal Campbell, http://dougal.gunters.org/
*
@@ -28,7 +28,7 @@ if ($use_querystring) {
$_SERVER['PATH_INFO'] .= "/$eid";
}
} else {
- $_SERVER['PATH_INFO'] = str_replace( '/app.php', '', $_SERVER['REQUEST_URI'] );
+ $_SERVER['PATH_INFO'] = str_replace( '/wp-app.php', '', $_SERVER['REQUEST_URI'] );
}
$app_logging = 0;
@@ -114,7 +114,7 @@ class AtomParser {
if(!xml_parse($parser, $line)) {
log_app("xml_parse_error", "line: $line");
- $this->error = sprintf("XML error: %s at line %d\n",
+ $this->error = sprintf(__('XML error: %s at line %d')."\n",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser));
log_app("xml_parse_error", $this->error);
@@ -270,7 +270,7 @@ class AtomServer {
var $MEDIA_SINGLE_PATH = "attachment";
var $params = array();
- var $script_name = "app.php";
+ var $script_name = "wp-app.php";
var $media_content_types = array('image/*','audio/*','video/*');
var $atom_content_types = array('application/atom+xml');
@@ -400,7 +400,7 @@ EOD;
* Create Post (No arguments)
*/
function create_post() {
- global $current_blog;
+ global $blog_id;
$this->get_accepted_content_type($this->atom_content_types);
$parser = new AtomParser();
@@ -417,7 +417,7 @@ EOD;
if(!current_user_can($cap))
$this->auth_required('Sorry, you do not have the right to edit/publish new posts.');
- $blog_ID = (int )$current_blog->blog_id;
+ $blog_ID = (int ) $blog_id;
$post_status = ($publish) ? 'publish' : 'draft';
$post_author = (int) $user->ID;
$post_title = $entry->title;
@@ -585,7 +585,7 @@ EOD;
$postID = wp_insert_attachment($attachment, $file, $post);
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.'));
}
$output = $this->get_entry($postID, 'attachment');
@@ -613,7 +613,7 @@ EOD;
$this->escape($entry);
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;
@@ -627,7 +627,7 @@ EOD;
$result = wp_update_post($postdata);
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)");
@@ -642,7 +642,7 @@ EOD;
$this->set_current_entry($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);
@@ -654,7 +654,7 @@ EOD;
$result = wp_delete_post($postID);
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.");
@@ -669,13 +669,13 @@ EOD;
// then whether user can edit the specific post
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);
if(!isset($location))
- $this->internal_error('Error ocurred while accessing post metadata for file location.');
+ $this->internal_error(__('Error ocurred while accessing post metadata for file location.'));
header('Content-Type: ' . $entry['post_mime_type']);
@@ -695,7 +695,7 @@ EOD;
// first check if user can upload
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
global $entry;
@@ -703,13 +703,13 @@ EOD;
// then whether user can edit the specific post
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);
if(!isset($location))
- $this->internal_error('Error ocurred while accessing post metadata for file location.');
+ $this->internal_error(__('Error ocurred while accessing post metadata for file location.'));
$fp = fopen("php://input", "rb");
$localfp = fopen($location, "w+");
@@ -1004,7 +1004,7 @@ $post = $GLOBALS['post'];
break;
endwhile;
else:
- $this->auth_required("Access Denied.");
+ $this->auth_required(__("Access Denied."));
endif;
ob_end_clean();
diff --git a/wp-comments-post.php b/wp-comments-post.php
index 5988fd5..9f5d3b8 100644
--- a/wp-comments-post.php
+++ b/wp-comments-post.php
@@ -1,4 +1,10 @@
<?php
+if ($_SERVER["REQUEST_METHOD"] != "POST") {
+ header('Allow: POST');
+ header("HTTP/1.1 405 Method Not Allowed");
+ header("Content-type: text/plain");
+ exit;
+}
require( dirname(__FILE__) . '/wp-config.php' );
nocache_headers();
diff --git a/wp-config-sample.php b/wp-config-sample.php
index b968f59..4ce2736 100644
--- a/wp-config-sample.php
+++ b/wp-config-sample.php
@@ -1,30 +1,30 @@
-<?php
-// ** MySQL settings ** //
-define('DB_NAME', 'wordpress'); // The name of the database
-define('DB_USER', 'username'); // Your MySQL username
-define('DB_PASSWORD', 'password'); // ...and password
-define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
-define('DB_CHARSET', 'utf8');
-define('DB_COLLATE', '');
-define('VHOST', 'VHOSTSETTING');
-$base = 'BASE';
-
-// double check $base
-if( $base == 'BASE' )
- die( 'Problem in wp-config.php - $base is set to BASE when it should be the path like "/" or "/blogs/"! Please fix it!' );
-// You can have multiple installations in one database if you give each a unique prefix
-$table_prefix = 'wp_'; // Only numbers, letters, and underscores please!
-
-// Change this to localize WordPress. A corresponding MO file for the
-// chosen language must be installed to wp-includes/languages.
-// For example, install de.mo to wp-includes/languages and set WPLANG to 'de'
-// to enable German language support.
-define ('WPLANG', '');
-
-define( "WP_USE_MULTIPLE_DB", false );
-
-/* That's all, stop editing! Happy blogging. */
-
-define('ABSPATH', dirname(__FILE__).'/');
-require_once(ABSPATH.'wp-settings.php');
-?>
+<?php
+// ** MySQL settings ** //
+define('DB_NAME', 'wordpress'); // The name of the database
+define('DB_USER', 'username'); // Your MySQL username
+define('DB_PASSWORD', 'password'); // ...and password
+define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
+define('DB_CHARSET', 'utf8');
+define('DB_COLLATE', '');
+define('VHOST', 'VHOSTSETTING');
+$base = 'BASE';
+
+// double check $base
+if( $base == 'BASE' )
+ die( 'Problem in wp-config.php - $base is set to BASE when it should be the path like "/" or "/blogs/"! Please fix it!' );
+// You can have multiple installations in one database if you give each a unique prefix
+$table_prefix = 'wp_'; // Only numbers, letters, and underscores please!
+
+// Change this to localize WordPress. A corresponding MO file for the
+// chosen language must be installed to wp-content/languages.
+// For example, install de.mo to wp-content/languages and set WPLANG to 'de'
+// to enable German language support.
+define ('WPLANG', '');
+
+define( "WP_USE_MULTIPLE_DB", false );
+
+/* That's all, stop editing! Happy blogging. */
+
+define('ABSPATH', dirname(__FILE__).'/');
+require_once(ABSPATH.'wp-settings.php');
+?>
diff --git a/wp-content/index.php b/wp-content/index.php
index 3d5acf0..4e6c07c 100644
--- a/wp-content/index.php
+++ b/wp-content/index.php
@@ -1,3 +1,3 @@
-<?php
-// Silence is golden.
+<?php
+// Silence is golden.
?> \ No newline at end of file
diff --git a/wp-content/themes/classic/functions.php b/wp-content/themes/classic/functions.php
new file mode 100644
index 0000000..a63850c
--- /dev/null
+++ b/wp-content/themes/classic/functions.php
@@ -0,0 +1,10 @@
+<?php
+if ( function_exists('register_sidebar') )
+ register_sidebar(array(
+ 'before_widget' => '<li id="%1$s" class="widget %2$s">',
+ 'after_widget' => '</li>',
+ 'before_title' => '',
+ 'after_title' => '',
+ ));
+
+?>
diff --git a/wp-content/themes/classic/index.php b/wp-content/themes/classic/index.php
index 2760bff..ce02040 100644
--- a/wp-content/themes/classic/index.php
+++ b/wp-content/themes/classic/index.php
@@ -1,4 +1,4 @@
-<?php
+<?php
get_header();
?>
@@ -15,8 +15,8 @@ get_header();
</div>
<div class="feedback">
- <?php wp_link_pages(); ?>
- <?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?>
+ <?php wp_link_pages(); ?>
+ <?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?>
</div>
</div>
diff --git a/wp-content/themes/classic/sidebar.php b/wp-content/themes/classic/sidebar.php
index ce72662..e4a680a 100644
--- a/wp-content/themes/classic/sidebar.php
+++ b/wp-content/themes/classic/sidebar.php
@@ -3,22 +3,14 @@
<div id="menu">
<ul>
-<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar() ) : ?>
-
-</ul>
-
-</div>
-
-<?php return; ?>
-
-<?php endif; ?>
-
+<?php /* Widgetized sidebar, if you have the plugin installed. */
+ if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
<?php wp_list_pages('title_li=' . __('Pages:')); ?>
<?php wp_list_bookmarks('title_after=&title_before='); ?>
<?php wp_list_categories('title_li=' . __('Categories:')); ?>
<li id="search">
<label for="s"><?php _e('Search:'); ?></label>
- <form id="searchform" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
+ <form id="searchform" method="get" action="<?php bloginfo('home'); ?>">
<div>
<input type="text" name="s" id="s" size="15" /><br />
<input type="submit" value="<?php _e('Search'); ?>" />
@@ -42,6 +34,7 @@
<?php wp_meta(); ?>
</ul>
</li>
+<?php endif; ?>
</ul>
diff --git a/wp-content/themes/classic/style.css b/wp-content/themes/classic/style.css
index e09122d..f5436b2 100644
--- a/wp-content/themes/classic/style.css
+++ b/wp-content/themes/classic/style.css
@@ -48,9 +48,9 @@ blockquote {
body {
background: #fff;
- border: solid 2px #565;
- border-bottom: solid 1px #565;
- border-top: solid 3px #565;
+ border: 2px solid #565;
+ border-bottom: 1px solid #565;
+ border-top: 3px solid #565;
color: #000;
font-family: 'Lucida Grande', 'Lucida Sans Unicode', Verdana, sans-serif;
margin: 0;
@@ -71,7 +71,7 @@ h2 {
}
h3 {
- border-bottom: dotted 1px #eee;
+ border-bottom: 1px dotted #eee;
font-family: "Times New Roman", Times, serif;
margin-top: 0;
}
@@ -96,7 +96,7 @@ ul.post-meta span.post-meta-key {
.credit {
background: #90a090;
- border-top: double 3px #aba;
+ border-top: 3px double #aba;
color: #fff;
font-size: 11px;
margin: 10px 0 0 0;
@@ -166,10 +166,10 @@ ul.post-meta span.post-meta-key {
#header {
background: #90a090;
- border-bottom: double 3px #aba;
- border-left: solid 1px #9a9;
- border-right: solid 1px #565;
- border-top: solid 1px #9a9;
+ border-bottom: 3px double #aba;
+ border-left: 1px solid #9a9;
+ border-right: 1px solid #565;
+ border-top: 1px solid #9a9;
font: italic normal 230% 'Times New Roman', Times, serif;
letter-spacing: 0.2em;
margin: 0;
@@ -188,7 +188,7 @@ ul.post-meta span.post-meta-key {
#menu {
background: #fff;
border-left: 1px dotted #ccc;
- border-top: solid 3px #e0e6e0;
+ border-top: 3px solid #e0e6e0;
padding: 20px 0 10px 30px;
position: absolute;
right: 2px;
diff --git a/wp-content/themes/default/archive.php b/wp-content/themes/default/archive.php
index 1d2b1de..db6db4c 100644
--- a/wp-content/themes/default/archive.php
+++ b/wp-content/themes/default/archive.php
@@ -4,26 +4,21 @@
<?php if (have_posts()) : ?>
- <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
-<?php /* If this is a category archive */ if (is_category()) { ?>
+ <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
+ <?php /* If this is a category archive */ if (is_category()) { ?>
<h2 class="pagetitle">Archive for the &#8216;<?php single_cat_title(); ?>&#8217; Category</h2>
<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
<h2 class="pagetitle">Archive for <?php the_time('F jS, Y'); ?></h2>
-
- <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
+ <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
<h2 class="pagetitle">Archive for <?php the_time('F, Y'); ?></h2>
-
- <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
+ <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
<h2 class="pagetitle">Archive for <?php the_time('Y'); ?></h2>
-
<?php /* If this is an author archive */ } elseif (is_author()) { ?>
<h2 class="pagetitle">Author Archive</h2>
-
- <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
+ <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
<h2 class="pagetitle">Blog Archives</h2>
-
- <?php } ?>
+ <?php } ?>
<div class="navigation">
diff --git a/wp-content/themes/default/comments.php b/wp-content/themes/default/comments.php
index 0ff43b4..a9f1f39 100644
--- a/wp-content/themes/default/comments.php
+++ b/wp-content/themes/default/comments.php
@@ -6,7 +6,7 @@
if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
?>
- <p class="nocomments">This post is password protected. Enter the password to view comments.<p>
+ <p class="nocomments">This post is password protected. Enter the password to view comments.</p>
<?php
return;
@@ -33,7 +33,7 @@
<?php endif; ?>
<br />
- <small class="commentmetadata"><a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?> at <?php comment_time() ?></a> <?php edit_comment_link('e','',''); ?></small>
+ <small class="commentmetadata"><a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?> at <?php comment_time() ?></a> <?php edit_comment_link('edit','&nbsp;&nbsp;',''); ?></small>
<?php comment_text() ?>
diff --git a/wp-content/themes/default/footer.php b/wp-content/themes/default/footer.php
index c2317f2..68e9e5f 100644
--- a/wp-content/themes/default/footer.php
+++ b/wp-content/themes/default/footer.php
@@ -2,7 +2,7 @@
<?php $current_site = get_current_site(); ?>
<hr />
<div id="footer">
-<!-- If you'd like to support WordPress, having the "powered by" link someone on your blog is the best way, it's our only promotion or advertising. -->
+<!-- If you'd like to support WordPress, having the "powered by" link somewhere on your blog is the best way, it's our only promotion or advertising. -->
<p>
<?php bloginfo('name'); ?> is proudly powered by
<a href="http://mu.wordpress.org/">WordPress MU</a> running on <a href="http://<?php echo $current_site->domain . $current_site->path ?>"><?php echo $current_site->site_name ?></a>. <a href="http://<?php echo $current_site->domain . $current_site->path ?>wp-signup.php" title="Create a new blog">Create a new blog</a> and join in the fun!
diff --git a/wp-content/themes/default/functions.php b/wp-content/themes/default/functions.php
index 5079fce..faf85ad 100644
--- a/wp-content/themes/default/functions.php
+++ b/wp-content/themes/default/functions.php
@@ -1,4 +1,11 @@
<?php
+if ( function_exists('register_sidebar') )
+ register_sidebar(array(
+ 'before_widget' => '<li id="%1$s" class="widget %2$s">',
+ 'after_widget' => '</li>',
+ 'before_title' => '<h2 class="widgettitle">',
+ 'after_title' => '</h2>',
+ ));
function kubrick_head() {
$head = "<style type='text/css'>\n<!--";
@@ -75,6 +82,7 @@ add_action('admin_menu', 'kubrick_add_theme_page');
function kubrick_add_theme_page() {
if ( $_GET['page'] == basename(__FILE__) ) {
if ( 'save' == $_REQUEST['action'] ) {
+ check_admin_referer('kubrick-header');
if ( isset($_REQUEST['njform']) ) {
if ( isset($_REQUEST['defaults']) ) {
delete_option('kubrick_header_image');
@@ -83,13 +91,14 @@ function kubrick_add_theme_page() {
} else {
if ( '' == $_REQUEST['njfontcolor'] )
delete_option('kubrick_header_color');
- else
- update_option('kubrick_header_color', $_REQUEST['njfontcolor']);
-
+ else {
+ $fontcolor = preg_replace('/^.*(#[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['njfontcolor']);
+ update_option('kubrick_header_color', $fontcolor);
+ }
if ( preg_match('/[0-9A-F]{6}|[0-9A-F]{3}/i', $_REQUEST['njuppercolor'], $uc) && preg_match('/[0-9A-F]{6}|[0-9A-F]{3}/i', $_REQUEST['njlowercolor'], $lc) ) {
$uc = ( strlen($uc[0]) == 3 ) ? $uc[0]{0}.$uc[0]{0}.$uc[0]{1}.$uc[0]{1}.$uc[0]{2}.$uc[0]{2} : $uc[0];
$lc = ( strlen($lc[0]) == 3 ) ? $lc[0]{0}.$lc[0]{0}.$lc[0]{1}.$lc[0]{1}.$lc[0]{2}.$lc[0]{2} : $lc[0];
- update_option('kubrick_header_image', "header-img.php?upper=$uc&amp;lower=$lc");
+ update_option('kubrick_header_image', "header-img.php?upper=$uc&lower=$lc");
}
if ( isset($_REQUEST['toggledisplay']) ) {
@@ -102,20 +111,27 @@ function kubrick_add_theme_page() {
} else {
if ( isset($_REQUEST['headerimage']) ) {
+ check_admin_referer('kubrick-header');
if ( '' == $_REQUEST['headerimage'] )
delete_option('kubrick_header_image');
- else
- update_option('kubrick_header_image', $_REQUEST['headerimage']);
+ else {
+ $headerimage = preg_replace('/^.*?(header-img.php\?upper=[0-9a-fA-F]{6}&lower=[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['headerimage']);
+ update_option('kubrick_header_image', $headerimage);
+ }
}
if ( isset($_REQUEST['fontcolor']) ) {
+ check_admin_referer('kubrick-header');
if ( '' == $_REQUEST['fontcolor'] )
delete_option('kubrick_header_color');
- else
- update_option('kubrick_header_color', $_REQUEST['fontcolor']);
+ else {
+ $fontcolor = preg_replace('/^.*?(#[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['fontcolor']);
+ update_option('kubrick_header_color', $fontcolor);
+ }
}
if ( isset($_REQUEST['fontdisplay']) ) {
+ check_admin_referer('kubrick-header');
if ( '' == $_REQUEST['fontdisplay'] || 'inline' == $_REQUEST['fontdisplay'] )
delete_option('kubrick_header_display');
else
@@ -128,7 +144,7 @@ function kubrick_add_theme_page() {
}
add_action('admin_head', 'kubrick_theme_page_head');
}
- add_theme_page('Customize Header', 'Header Image and Color', 'edit_themes', basename(__FILE__), 'kubrick_theme_page');
+ add_theme_page(__('Customize Header'), __('Header Image and Color'), 'edit_themes', basename(__FILE__), 'kubrick_theme_page');
}
function kubrick_theme_page_head() {
@@ -141,7 +157,7 @@ function kubrick_theme_page_head() {
kUpdate(ColorPicker_targetInput.id);
}
function PopupWindow_populate(contents) {
- contents += '<br /><p style="text-align:center;margin-top:0px;"><input type="button" value="Close Color Picker" onclick="cp.hidePopup(\'prettyplease\')"></input></p>';
+ contents += '<br /><p style="text-align:center;margin-top:0px;"><input type="button" value="<?php echo attribute_escape(__('Close Color Picker')); ?>" onclick="cp.hidePopup(\'prettyplease\')"></input></p>';
this.contents = contents;
this.populated = false;
}
@@ -226,13 +242,13 @@ function kubrick_theme_page_head() {
document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value;
}
function kRevert() {
- document.getElementById('headerimage').value = '<?php echo kubrick_header_image(); ?>';
- document.getElementById('advuppercolor').value = document.getElementById('uppercolor').value = '#<?php echo kubrick_upper_color(); ?>';
- document.getElementById('advlowercolor').value = document.getElementById('lowercolor').value = '#<?php echo kubrick_lower_color(); ?>';
- document.getElementById('header').style.background = 'url("<?php echo kubrick_header_image_url(); ?>") center no-repeat';
+ document.getElementById('headerimage').value = '<?php echo js_escape(kubrick_header_image()); ?>';
+ document.getElementById('advuppercolor').value = document.getElementById('uppercolor').value = '#<?php echo js_escape(kubrick_upper_color()); ?>';
+ document.getElementById('advlowercolor').value = document.getElementById('lowercolor').value = '#<?php echo js_escape(kubrick_lower_color()); ?>';
+ document.getElementById('header').style.background = 'url("<?php echo js_escape(kubrick_header_image_url()); ?>") center no-repeat';
document.getElementById('header').style.color = '';
- document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value = '<?php echo kubrick_header_color_string(); ?>';
- document.getElementById('fontdisplay').value = '<?php echo kubrick_header_display_string(); ?>';
+ document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value = '<?php echo js_escape(kubrick_header_color_string()); ?>';
+ document.getElementById('fontdisplay').value = '<?php echo js_escape(kubrick_header_display_string()); ?>';
document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value;
}
function kInit() {
@@ -338,11 +354,11 @@ function kubrick_theme_page_head() {
}
function kubrick_theme_page() {
- if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>Options saved.</strong></p></div>';
+ if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.__('Options saved.').'</strong></p></div>';
?>
<div class='wrap'>
<div id="kubrick-header">
- <h2>Header Image and Color</h2>
+ <h2><?php _e('Header Image and Color'); ?></h2>
<div id="headwrap">
<div id="header">
<div id="headerimg">
@@ -354,41 +370,44 @@ function kubrick_theme_page() {
<br />
<div id="nonJsForm">
<form method="post" action="">
- <div class="zerosize"><input type="submit" name="defaultsubmit" value="Save" /></div>
- <label for="njfontcolor">Font Color:</label><input type="text" name="njfontcolor" id="njfontcolor" value="<?php echo kubrick_header_color(); ?>" /> Any CSS color (<code>red</code> or <code>#FF0000</code> or <code>rgb(255, 0, 0)</code>)<br />
- <label for="njuppercolor">Upper Color:</label><input type="text" name="njuppercolor" id="njuppercolor" value="#<?php echo kubrick_upper_color(); ?>" /> HEX only (<code>#FF0000</code> or <code>#F00</code>)<br />
- <label for="njlowercolor">Lower Color:</label><input type="text" name="njlowercolor" id="njlowercolor" value="#<?php echo kubrick_lower_color(); ?>" /> HEX only (<code>#FF0000</code> or <code>#F00</code>)<br />
- <input type="hidden" name="hi" id="hi" value="<?php echo kubrick_header_image(); ?>" />
- <input type="submit" name="toggledisplay" id="toggledisplay" value="Toggle Text" />
- <input type="submit" name="defaults" value="Use Defaults" />
- <input type="submit" class="defbutton" name="submitform" value="&nbsp;&nbsp;Save&nbsp;&nbsp;" />
+ <?php wp_nonce_field('kubrick-header'); ?>
+ <div class="zerosize"><input type="submit" name="defaultsubmit" value="<?php echo attribute_escape(__('Save')); ?>" /></div>
+ <label for="njfontcolor"><?php _e('Font Color:'); ?></label><input type="text" name="njfontcolor" id="njfontcolor" value="<?php echo attribute_escape(kubrick_header_color()); ?>" /> <?php printf(__('Any CSS color (%s or %s or %s)'), '<code>red</code>', '<code>#FF0000</code>', '<code>rgb(255, 0, 0)</code>'); ?><br />
+ <label for="njuppercolor"><?php _e('Upper Color:'); ?></label><input type="text" name="njuppercolor" id="njuppercolor" value="#<?php echo attribute_escape(kubrick_upper_color()); ?>" /> <?php printf(__('HEX only (%s or %s)'), '<code>#FF0000</code>', '<code>#F00</code>'); ?><br />
+ <label for="njlowercolor"><?php _e('Lower Color:'); ?></label><input type="text" name="njlowercolor" id="njlowercolor" value="#<?php echo attribute_escape(kubrick_lower_color()); ?>" /> <?php printf(__('HEX only (%s or %s)'), '<code>#FF0000</code>', '<code>#F00</code>'); ?><br />
+ <input type="hidden" name="hi" id="hi" value="<?php echo attribute_escape(kubrick_header_image()); ?>" />
+ <input type="submit" name="toggledisplay" id="toggledisplay" value="<?php echo attribute_escape(__('Toggle Text')); ?>" />
+ <input type="submit" name="defaults" value="<?php echo attribute_escape(__('Use Defaults')); ?>" />
+ <input type="submit" class="defbutton" name="submitform" value="&nbsp;&nbsp;<?php _e('Save'); ?>&nbsp;&nbsp;" />
<input type="hidden" name="action" value="save" />
<input type="hidden" name="njform" value="true" />
</form>
</div>
<div id="jsForm">
<form style="display:inline;" method="post" name="hicolor" id="hicolor" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
- <input type="button" onclick="tgt=document.getElementById('fontcolor');colorSelect(tgt,'pick1');return false;" name="pick1" id="pick1" value="Font Color"></input>
- <input type="button" onclick="tgt=document.getElementById('uppercolor');colorSelect(tgt,'pick2');return false;" name="pick2" id="pick2" value="Upper Color"></input>
- <input type="button" onclick="tgt=document.getElementById('lowercolor');colorSelect(tgt,'pick3');return false;" name="pick3" id="pick3" value="Lower Color"></input>
- <input type="button" name="revert" value="Revert" onclick="kRevert()" />
- <input type="button" value="Advanced" onclick="toggleAdvanced()" />
+ <?php wp_nonce_field('kubrick-header'); ?>
+ <input type="button" onclick="tgt=document.getElementById('fontcolor');colorSelect(tgt,'pick1');return false;" name="pick1" id="pick1" value="<?php echo attribute_escape(__('Font Color')); ?>"></input>
+ <input type="button" onclick="tgt=document.getElementById('uppercolor');colorSelect(tgt,'pick2');return false;" name="pick2" id="pick2" value="<?php echo attribute_escape(__('Upper Color')); ?>"></input>
+ <input type="button" onclick="tgt=document.getElementById('lowercolor');colorSelect(tgt,'pick3');return false;" name="pick3" id="pick3" value="<?php echo attribute_escape(__('Lower Color')); ?>"></input>
+ <input type="button" name="revert" value="<?php echo attribute_escape(__('Revert')); ?>" onclick="kRevert()" />
+ <input type="button" value="<?php echo attribute_escape(__('Advanced')); ?>" onclick="toggleAdvanced()" />
<input type="hidden" name="action" value="save" />
- <input type="hidden" name="fontdisplay" id="fontdisplay" value="<?php echo kubrick_header_display(); ?>" />
- <input type="hidden" name="fontcolor" id="fontcolor" value="<?php echo kubrick_header_color(); ?>" />
- <input type="hidden" name="uppercolor" id="uppercolor" value="<?php echo kubrick_upper_color(); ?>" />
- <input type="hidden" name="lowercolor" id="lowercolor" value="<?php echo kubrick_lower_color(); ?>" />
- <input type="hidden" name="headerimage" id="headerimage" value="<?php echo kubrick_header_image(); ?>" />
- <p class="submit"><input type="submit" name="submitform" class="defbutton" value="<?php _e('Update Header &raquo;'); ?>" onclick="cp.hidePopup('prettyplease')" /></p>
+ <input type="hidden" name="fontdisplay" id="fontdisplay" value="<?php echo attribute_escape(kubrick_header_display()); ?>" />
+ <input type="hidden" name="fontcolor" id="fontcolor" value="<?php echo attribute_escape(kubrick_header_color()); ?>" />
+ <input type="hidden" name="uppercolor" id="uppercolor" value="<?php echo attribute_escape(kubrick_upper_color()); ?>" />
+ <input type="hidden" name="lowercolor" id="lowercolor" value="<?php echo attribute_escape(kubrick_lower_color()); ?>" />
+ <input type="hidden" name="headerimage" id="headerimage" value="<?php echo attribute_escape(kubrick_header_image()); ?>" />
+ <p class="submit"><input type="submit" name="submitform" class="defbutton" value="<?php echo attribute_escape(__('Update Header &raquo;')); ?>" onclick="cp.hidePopup('prettyplease')" /></p>
</form>
<div id="colorPickerDiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;visibility:hidden;"> </div>
<div id="advanced">
<form id="jsAdvanced" style="display:none;" action="">
- <label for="advfontcolor">Font Color (CSS): </label><input type="text" id="advfontcolor" onchange="advUpdate(this.value, 'fontcolor')" value="<?php echo kubrick_header_color(); ?>" /><br />
- <label for="advuppercolor">Upper Color (HEX): </label><input type="text" id="advuppercolor" onchange="advUpdate(this.value, 'uppercolor')" value="#<?php echo kubrick_upper_color(); ?>" /><br />
- <label for="advlowercolor">Lower Color (HEX): </label><input type="text" id="advlowercolor" onchange="advUpdate(this.value, 'lowercolor')" value="#<?php echo kubrick_lower_color(); ?>" /><br />
- <input type="button" name="default" value="Select Default Colors" onclick="kDefaults()" /><br />
- <input type="button" onclick="toggleDisplay();return false;" name="pick" id="pick" value="Toggle Text Display"></input><br />
+ <?php wp_nonce_field('kubrick-header'); ?>
+ <label for="advfontcolor"><?php _e('Font Color (CSS):'); ?> </label><input type="text" id="advfontcolor" onchange="advUpdate(this.value, 'fontcolor')" value="<?php echo attribute_escape(kubrick_header_color()); ?>" /><br />
+ <label for="advuppercolor"><?php _e('Upper Color (HEX):');?> </label><input type="text" id="advuppercolor" onchange="advUpdate(this.value, 'uppercolor')" value="#<?php echo attribute_escape(kubrick_upper_color()); ?>" /><br />
+ <label for="advlowercolor"><?php _e('Lower Color (HEX):'); ?> </label><input type="text" id="advlowercolor" onchange="advUpdate(this.value, 'lowercolor')" value="#<?php echo attribute_escape(kubrick_lower_color()); ?>" /><br />
+ <input type="button" name="default" value="<?php echo attribute_escape(__('Select Default Colors')); ?>" onclick="kDefaults()" /><br />
+ <input type="button" onclick="toggleDisplay();return false;" name="pick" id="pick" value="<?php echo attribute_escape(__('Toggle Text Display')); ?>"></input><br />
</form>
</div>
</div>
diff --git a/wp-content/themes/default/sidebar.php b/wp-content/themes/default/sidebar.php
index 6834dbc..0fdccda 100644
--- a/wp-content/themes/default/sidebar.php
+++ b/wp-content/themes/default/sidebar.php
@@ -1,6 +1,7 @@
<div id="sidebar">
<ul>
-
+ <?php /* Widgetized sidebar, if you have the plugin installed. */
+ if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar() ) : ?>
</ul>
@@ -19,7 +20,10 @@
</li>
-->
- <li>
+ <?php if ( is_404() || is_category() || is_day() || is_month() ||
+ is_year() || is_search() || is_paged() ) {
+ ?> <li>
+
<?php /* If this is a 404 page */ if (is_404()) { ?>
<?php /* If this is a category archive */ } elseif (is_category()) { ?>
<p>You are currently browsing the archives for the <?php single_cat_title(''); ?> category.</p>
@@ -44,7 +48,8 @@
<p>You are currently browsing the <a href="<?php echo bloginfo('url'); ?>/"><?php echo bloginfo('name'); ?></a> weblog archives.</p>
<?php } ?>
- </li>
+
+ </li> <?php }?>
<?php wp_list_pages('title_li=<h2>Pages</h2>' ); ?>
@@ -73,7 +78,8 @@
</ul>
</li>
<?php } ?>
-
+
+ <?php endif; ?>
</ul>
</div>
diff --git a/wp-cron.php b/wp-cron.php
index 36d7662..eb303f8 100644
--- a/wp-cron.php
+++ b/wp-cron.php
@@ -3,7 +3,7 @@ ignore_user_abort(true);
define('DOING_CRON', TRUE);
require_once('wp-config.php');
-if ( $_GET['check'] != md5(DB_PASS . '187425') )
+if ( $_GET['check'] != wp_hash('187425') )
exit;
if ( get_option('doing_cron') > time() )
diff --git a/wp-includes/author-template.php b/wp-includes/author-template.php
index aa4013d..6006cf3 100644
--- a/wp-includes/author-template.php
+++ b/wp-includes/author-template.php
@@ -173,24 +173,28 @@ function get_author_name( $auth_id ) {
}
function wp_list_authors($args = '') {
- if ( is_array($args) )
- $r = &$args;
- else
- parse_str($args, $r);
-
- $defaults = array('optioncount' => false, 'exclude_admin' => true, 'show_fullname' => false, 'hide_empty' => true,
- 'feed' => '', 'feed_image' => '');
- $r = array_merge($defaults, $r);
- extract($r);
-
global $wpdb;
+
+ $defaults = array(
+ 'optioncount' => false, 'exclude_admin' => true,
+ 'show_fullname' => false, 'hide_empty' => true,
+ 'feed' => '', 'feed_image' => ''
+ );
+
+ $r = wp_parse_args( $args, $defaults );
+ extract($r);
+
// TODO: Move select to get_authors().
- $query = "SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name";
- $authors = $wpdb->get_results($query);
+ $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name");
+
+ $author_count = array();
+ foreach ((array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_status = 'publish' GROUP BY post_author") as $row) {
+ $author_count[$row->post_author] = $row->count;
+ }
foreach ( (array) $authors as $author ) {
$author = get_userdata( $author->ID );
- $posts = get_usernumposts($author->ID);
+ $posts = (isset($author_count[$author->ID])) ? $author_count[$author->ID] : 0;
$name = $author->nickname;
if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') )
diff --git a/wp-includes/bookmark-template.php b/wp-includes/bookmark-template.php
index e7a8480..2a06cf2 100644
--- a/wp-includes/bookmark-template.php
+++ b/wp-includes/bookmark-template.php
@@ -9,28 +9,23 @@
**/
function wp_get_links($args = '') {
global $wpdb;
-
- if ( empty($args) )
- return;
-
- if ( false === strpos($args, '=') ) {
+
+ if ( strpos( $args, '=' ) === false ) {
$cat_id = $args;
- $args = add_query_arg('category', $cat_id, $args);
+ $args = add_query_arg( 'category', $cat_id, $args );
}
-
- parse_str($args);
-
- if ( !isset($category) ) $category = -1;
- if ( !isset($before) ) $before = '';
- if ( !isset($after) ) $after = '<br />';
- if ( !isset($between) ) $between = ' ';
- if ( !isset($show_images) ) $show_images = true;
- if ( !isset($orderby) ) $orderby = 'name';
- if ( !isset($show_description) ) $show_description = true;
- if ( !isset($show_rating) ) $show_rating = false;
- if ( !isset($limit) ) $limit = -1;
- if ( !isset($show_updated) ) $show_updated = 1;
- if ( !isset($echo) ) $echo = true;
+
+ $defaults = array(
+ 'category' => -1, 'before' => '',
+ 'after' => '<br />', 'between' => ' ',
+ 'show_images' => true, 'orderby' => 'name',
+ 'show_description' => true, 'show_rating' => false,
+ 'limit' => -1, 'show_updated' => true,
+ 'echo' => true
+ );
+
+ $r = wp_parse_args( $args, $defaults );
+ extract( $r );
return get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo);
} // end wp_get_links
@@ -136,6 +131,10 @@ function get_links($category = -1,
if ( $show_description && '' != $desc )
$output .= $between . $desc;
+
+ if ($show_rating) {
+ $output .= $between . get_linkrating($row);
+ }
$output .= "$after\n";
} // end while
@@ -241,15 +240,14 @@ function get_links_list($order = 'name', $hide_if_empty = 'obsolete') {
}
function _walk_bookmarks($bookmarks, $args = '' ) {
- if ( is_array($args) )
- $r = &$args;
- else
- parse_str($args, $r);
-
- $defaults = array('show_updated' => 0, 'show_description' => 0, 'show_images' => 1, 'before' => '<li>',
- 'after' => '</li>', 'between' => "\n");
- $r = array_merge($defaults, $r);
- extract($r);
+ $defaults = array(
+ 'show_updated' => 0, 'show_description' => 0,
+ 'show_images' => 1, 'before' => '<li>',
+ 'after' => '</li>', 'between' => "\n"
+ );
+
+ $r = wp_parse_args( $args, $defaults );
+ extract( $r );
foreach ( (array) $bookmarks as $bookmark ) {
if ( !isset($bookmark->recently_updated) )
@@ -304,6 +302,11 @@ function _walk_bookmarks($bookmarks, $args = '' ) {
if ( $show_description && '' != $desc )
$output .= $between . $desc;
+
+ if ($show_rating) {
+ $output .= $between . get_linkrating($bookmark);
+ }
+
$output .= "$after\n";
} // end while
@@ -311,18 +314,20 @@ function _walk_bookmarks($bookmarks, $args = '' ) {
}
function wp_list_bookmarks($args = '') {
- if ( is_array($args) )
- $r = &$args;
- else
- parse_str($args, $r);
-
- $defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => -1, 'category' => '',
- 'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'echo' => 1,
- 'categorize' => 1, 'title_li' => __('Bookmarks'), 'title_before' => '<h2>', 'title_after' => '</h2>',
- 'category_orderby' => 'name', 'category_order' => 'ASC', 'class' => 'linkcat',
- 'category_before' => '<li id="%id" class="%class">', 'category_after' => '</li>');
- $r = array_merge($defaults, $r);
- extract($r);
+ $defaults = array(
+ 'orderby' => 'name', 'order' => 'ASC',
+ 'limit' => -1, 'category' => '',
+ 'category_name' => '', 'hide_invisible' => 1,
+ 'show_updated' => 0, 'echo' => 1,
+ 'categorize' => 1, 'title_li' => __('Bookmarks'),
+ 'title_before' => '<h2>', 'title_after' => '</h2>',
+ 'category_orderby' => 'name', 'category_order' => 'ASC',
+ 'class' => 'linkcat', 'category_before' => '<li id="%id" class="%class">',
+ 'category_after' => '</li>'
+ );
+
+ $r = wp_parse_args( $args, $defaults );
+ extract( $r );
$output = '';
diff --git a/wp-includes/bookmark.php b/wp-includes/bookmark.php
index 5aea9a8..ad2e696 100644
--- a/wp-includes/bookmark.php
+++ b/wp-includes/bookmark.php
@@ -3,6 +3,7 @@
function get_bookmark($bookmark_id, $output = OBJECT) {
global $wpdb;
+ $bookmark_id = (int) $bookmark_id;
$link = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = '$bookmark_id'");
$link->link_category = wp_get_link_cats($bookmark_id);
@@ -24,16 +25,17 @@ function get_link($bookmark_id, $output = OBJECT) {
function get_bookmarks($args = '') {
global $wpdb;
-
- if ( is_array($args) )
- $r = &$args;
- else
- parse_str($args, $r);
-
- $defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => -1, 'category' => '',
- 'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'include' => '', 'exclude' => '');
- $r = array_merge($defaults, $r);
- extract($r);
+
+ $defaults = array(
+ 'orderby' => 'name', 'order' => 'ASC',
+ 'limit' => -1, 'category' => '',
+ 'category_name' => '', 'hide_invisible' => 1,
+ 'show_updated' => 0, 'include' => '',
+ 'exclude' => ''
+ );
+
+ $r = wp_parse_args( $args, $defaults );
+ extract( $r );
$key = md5( serialize( $r ) );
if ( $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ) )
@@ -135,7 +137,7 @@ function get_bookmarks($args = '') {
$results = $wpdb->get_results($query);
$cache[ $key ] = $results;
- wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );
+ wp_cache_add( 'get_bookmarks', $cache, 'bookmark' );
return apply_filters('get_bookmarks', $results, $r);
}
diff --git a/wp-includes/cache.php b/wp-includes/cache.php
index e89e5f6..6901a6b 100644
--- a/wp-includes/cache.php
+++ b/wp-includes/cache.php
@@ -364,10 +364,9 @@ class WP_Object_Cache {
fputs($fd, $serial);
fclose($fd);
if (!@ rename($temp_file, $cache_file)) {
- if (@ copy($temp_file, $cache_file))
- @ unlink($temp_file);
- else
+ if (!@ copy($temp_file, $cache_file))
$errors++;
+ @ unlink($temp_file);
}
@ chmod($cache_file, $file_perms);
}
diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php
index db45dc0..d4c521e 100644
--- a/wp-includes/category-template.php
+++ b/wp-includes/category-template.php
@@ -172,20 +172,21 @@ function category_description($category = 0) {
}
function wp_dropdown_categories($args = '') {
- if ( is_array($args) )
- $r = &$args;
- else
- parse_str($args, $r);
-
- $defaults = array('show_option_all' => '', 'show_option_none' => '', 'orderby' => 'ID',
- 'order' => 'ASC', 'show_last_update' => 0, 'show_count' => 0,
- 'hide_empty' => 1, 'child_of' => 0, 'exclude' => '', 'echo' => 1,
- 'selected' => 0, 'hierarchical' => 0, 'name' => 'cat',
- 'class' => 'postform');
+ $defaults = array(
+ 'show_option_all' => '', 'show_option_none' => '',
+ 'orderby' => 'ID', 'order' => 'ASC',
+ 'show_last_update' => 0, 'show_count' => 0,
+ 'hide_empty' => 1, 'child_of' => 0,
+ 'exclude' => '', 'echo' => 1,
+ 'selected' => 0, 'hierarchical' => 0,
+ 'name' => 'cat', 'class' => 'postform'
+ );
+
$defaults['selected'] = ( is_category() ) ? get_query_var('cat') : 0;
- $r = array_merge($defaults, $r);
+
+ $r = wp_parse_args( $args, $defaults );
$r['include_last_update_time'] = $r['show_last_update'];
- extract($r);
+ extract( $r );
$categories = get_categories($r);
@@ -221,23 +222,28 @@ function wp_dropdown_categories($args = '') {
}
function wp_list_categories($args = '') {
- if ( is_array($args) )
- $r = &$args;
- else
- parse_str($args, $r);
-
- $defaults = array('show_option_all' => '', 'orderby' => 'name',
- 'order' => 'ASC', 'show_last_update' => 0, 'style' => 'list',
- 'show_count' => 0, 'hide_empty' => 1, 'use_desc_for_title' => 1,
- 'child_of' => 0, 'feed' => '', 'feed_image' => '', 'exclude' => '',
- 'hierarchical' => true, 'title_li' => __('Categories'));
- $r = array_merge($defaults, $r);
- if ( !isset($r['pad_counts']) && $r['show_count'] && $r['hierarchical'] )
+ $defaults = array(
+ 'show_option_all' => '', 'orderby' => 'name',
+ 'order' => 'ASC', 'show_last_update' => 0,
+ 'style' => 'list', 'show_count' => 0,
+ 'hide_empty' => 1, 'use_desc_for_title' => 1,
+ 'child_of' => 0, 'feed' => '',
+ 'feed_image' => '', 'exclude' => '',
+ 'hierarchical' => true, 'title_li' => __('Categories')
+ );
+
+ $r = wp_parse_args( $args, $defaults );
+
+ if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) {
$r['pad_counts'] = true;
- if ( isset($r['show_date']) )
+ }
+
+ if ( isset( $r['show_date'] ) ) {
$r['include_last_update_time'] = $r['show_date'];
- extract($r);
-
+ }
+
+ extract( $r );
+
$categories = get_categories($r);
$output = '';
@@ -251,7 +257,13 @@ function wp_list_categories($args = '') {
$output .= __("No categories");
} else {
global $wp_query;
-
+
+ if( !empty($show_option_all) )
+ if ('list' == $style )
+ $output .= '<li><a href="' . get_bloginfo('url') . '">' . $show_option_all . '</a></li>';
+ else
+ $output .= '<a href="' . get_bloginfo('url') . '">' . $show_option_all . '</a>';
+
if ( is_category() )
$r['current_category'] = $wp_query->get_queried_object_id();
diff --git a/wp-includes/category.php b/wp-includes/category.php
index 2ba3d30..b14685d 100644
--- a/wp-includes/category.php
+++ b/wp-includes/category.php
@@ -13,22 +13,25 @@ function get_all_category_ids() {
function &get_categories($args = '') {
global $wpdb, $category_links;
-
- if ( is_array($args) )
- $r = &$args;
- else
- parse_str($args, $r);
-
- $defaults = array('type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC',
- 'hide_empty' => true, 'include_last_update_time' => false, 'hierarchical' => 1, 'exclude' => '', 'include' => '',
- 'number' => '', 'pad_counts' => false);
- $r = array_merge($defaults, $r);
- if ( 'count' == $r['orderby'] )
+
+ $defaults = array(
+ 'type' => 'post', 'child_of' => 0,
+ 'orderby' => 'name', 'order' => 'ASC',
+ 'hide_empty' => true, 'include_last_update_time' => false,
+ 'hierarchical' => 1, 'exclude' => '',
+ 'include' => '', 'number' => '',
+ 'pad_counts' => false
+ );
+
+ $r = wp_parse_args( $args, $defaults );
+
+ if ( $r['orderby'] == 'count' ) {
$r['orderby'] = 'category_count';
- else
- $r['orderby'] = "cat_" . $r['orderby']; // restricts order by to cat_ID and cat_name fields
- $r['number'] = (int) $r['number'];
- extract($r);
+ } else {
+ $r['orderby'] = 'cat_' . $r['orderby'];
+ }
+
+ extract( $r );
$key = md5( serialize( $r ) );
if ( $cache = wp_cache_get( 'get_categories', 'category' ) )
@@ -79,6 +82,8 @@ function &get_categories($args = '') {
$where .= ' AND category_count > 0';
}
+
+
if ( !empty($number) )
$number = 'LIMIT ' . $number;
else
@@ -105,8 +110,11 @@ function &get_categories($args = '') {
unset($cat_stamps);
}
- if ( $child_of || $hierarchical )
- $categories = & _get_cat_children($child_of, $categories);
+ if ( $child_of || $hierarchical ) {
+ $children = _get_category_hierarchy();
+ if ( ! empty($children) )
+ $categories = & _get_cat_children($child_of, $categories);
+ }
// Update category counts to include children.
if ( $pad_counts )
@@ -131,7 +139,8 @@ function &get_categories($args = '') {
$cache[ $key ] = $categories;
wp_cache_set( 'get_categories', $cache, 'category' );
- return apply_filters('get_categories', $categories, $r);
+ $categories = apply_filters('get_categories', $categories, $r);
+ return $categories;
}
// Retrieves category data given a category ID or category object.
@@ -146,6 +155,7 @@ function &get_category(&$category, $output = OBJECT) {
wp_cache_add($category->cat_ID, $category, 'category');
$_category = $category;
} else {
+ $category = (int) $category;
if ( ! $_category = wp_cache_get($category, 'category') ) {
$_category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = '$category' LIMIT 1");
wp_cache_set($category, $_category, 'category');
@@ -201,6 +211,15 @@ function get_category_by_path($category_path, $full_match = true, $output = OBJE
return NULL;
}
+function get_category_by_slug( $slug ) {
+ global $wpdb;
+ $slug = sanitize_title( $slug );
+ if ( empty( $slug ) )
+ return false;
+ $category = $wpdb->get_var( "SELECT * FROM $wpdb->categories WHERE category_nicename = '$slug' " );
+ return get_category( $category );
+}
+
// Get the ID of a category from its name
function get_cat_ID($cat_name='General') {
global $wpdb;
@@ -246,12 +265,21 @@ function &_get_cat_children($category_id, $categories) {
return array();
$category_list = array();
+ $has_children = _get_category_hierarchy();
+
+ if ( ( 0 != $category_id ) && ! isset($has_children[$category_id]) )
+ return array();
+
foreach ( $categories as $category ) {
if ( $category->cat_ID == $category_id )
continue;
if ( $category->category_parent == $category_id ) {
$category_list[] = $category;
+
+ if ( !isset($has_children[$category->cat_ID]) )
+ continue;
+
if ( $children = _get_cat_children($category->cat_ID, $categories) )
$category_list = array_merge($category_list, $children);
}
@@ -299,4 +327,20 @@ function _pad_category_counts($type, &$categories) {
$cats[$id]->{'link' == $type ? 'link_count' : 'category_count'} = count($items);
}
+function _get_category_hierarchy() {
+ $children = get_option('category_children');
+ if ( is_array($children) )
+ return $children;
+
+ $children = array();
+ $categories = get_categories('hide_empty=0&hierarchical=0');
+ foreach ( $categories as $cat ) {
+ if ( $cat->category_parent > 0 )
+ $children[$cat->category_parent][] = $cat->cat_ID;
+ }
+ update_option('category_children', $children);
+
+ return $children;
+}
+
?>
diff --git a/wp-includes/class-phpmailer.php b/wp-includes/class-phpmailer.php
index de6b277..ad439fe 100644
--- a/wp-includes/class-phpmailer.php
+++ b/wp-includes/class-phpmailer.php
@@ -1,1498 +1,1498 @@
-<?php
-////////////////////////////////////////////////////
-// PHPMailer - PHP email class
-//
-// Class for sending email using either
-// sendmail, PHP mail(), or SMTP. Methods are
-// based upon the standard AspEmail(tm) classes.
-//
-// Copyright (C) 2001 - 2003 Brent R. Matzelle
-//
-// License: LGPL, see LICENSE
-////////////////////////////////////////////////////
-
-/**
- * PHPMailer - PHP email transport class
- * @package PHPMailer
- * @author Brent R. Matzelle
- * @copyright 2001 - 2003 Brent R. Matzelle
- */
-class PHPMailer
-{
- /////////////////////////////////////////////////
- // PUBLIC VARIABLES
- /////////////////////////////////////////////////
-
- /**
- * Email priority (1 = High, 3 = Normal, 5 = low).
- * @var int
- */
- var $Priority = 3;
-
- /**
- * Sets the CharSet of the message.
- * @var string
- */
- var $CharSet = "UTF-8";
-
- /**
- * Sets the Content-type of the message.
- * @var string
- */
- var $ContentType = "text/plain";
-
- /**
- * Sets the Encoding of the message. Options for this are "8bit",
- * "7bit", "binary", "base64", and "quoted-printable".
- * @var string
- */
- var $Encoding = "8bit";
-
- /**
- * Holds the most recent mailer error message.
- * @var string
- */
- var $ErrorInfo = "";
-
- /**
- * Sets the From email address for the message.
- * @var string
- */
- var $From = "support@wordpress.com";
-
- /**
- * Sets the From name of the message.
- * @var string
- */
- var $FromName = "Support";
-
- /**
- * Sets the Sender email (Return-Path) of the message. If not empty,
- * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
- * @var string
- */
- var $Sender = "";
-
- /**
- * Sets the Subject of the message.
- * @var string
- */
- var $Subject = "";
-
- /**
- * Sets the Body of the message. This can be either an HTML or text body.
- * If HTML then run IsHTML(true).
- * @var string
- */
- var $Body = "";
-
- /**
- * Sets the text-only body of the message. This automatically sets the
- * email to multipart/alternative. This body can be read by mail
- * clients that do not have HTML email capability such as mutt. Clients
- * that can read HTML will view the normal Body.
- * @var string
- */
- var $AltBody = "";
-
- /**
- * Sets word wrapping on the body of the message to a given number of
- * characters.
- * @var int
- */
- var $WordWrap = 0;
-
- /**
- * Method to send mail: ("mail", "sendmail", or "smtp").
- * @var string
- */
- var $Mailer = "mail";
-
- /**
- * Sets the path of the sendmail program.
- * @var string
- */
- var $Sendmail = "/usr/sbin/sendmail";
-
- /**
- * Path to PHPMailer plugins. This is now only useful if the SMTP class
- * is in a different directory than the PHP include path.
- * @var string
- */
- var $PluginDir = "";
-
- /**
- * Holds PHPMailer version.
- * @var string
- */
- var $Version = "1.73";
-
- /**
- * Sets the email address that a reading confirmation will be sent.
- * @var string
- */
- var $ConfirmReadingTo = "";
-
- /**
- * Sets the hostname to use in Message-Id and Received headers
- * and as default HELO string. If empty, the value returned
- * by SERVER_NAME is used or 'localhost.localdomain'.
- * @var string
- */
- var $Hostname = "";
-
- /////////////////////////////////////////////////
- // SMTP VARIABLES
- /////////////////////////////////////////////////
-
- /**
- * Sets the SMTP hosts. All hosts must be separated by a
- * semicolon. You can also specify a different port
- * for each host by using this format: [hostname:port]
- * (e.g. "smtp1.example.com:25;smtp2.example.com").
- * Hosts will be tried in order.
- * @var string
- */
- var $Host = "localhost";
-
- /**
- * Sets the default SMTP server port.
- * @var int
- */
- var $Port = 25;
-
- /**
- * Sets the SMTP HELO of the message (Default is $Hostname).
- * @var string
- */
- var $Helo = "";
-
- /**
- * Sets SMTP authentication. Utilizes the Username and Password variables.
- * @var bool
- */
- var $SMTPAuth = false;
-
- /**
- * Sets SMTP username.
- * @var string
- */
- var $Username = "";
-
- /**
- * Sets SMTP password.
- * @var string
- */
- var $Password = "";
-
- /**
- * Sets the SMTP server timeout in seconds. This function will not
- * work with the win32 version.
- * @var int
- */
- var $Timeout = 10;
-
- /**
- * Sets SMTP class debugging on or off.
- * @var bool
- */
- var $SMTPDebug = false;
-
- /**
- * Prevents the SMTP connection from being closed after each mail
- * sending. If this is set to true then to close the connection
- * requires an explicit call to SmtpClose().
- * @var bool
- */
- var $SMTPKeepAlive = false;
-
- /**#@+
- * @access private
- */
- var $smtp = NULL;
- var $to = array();
- var $cc = array();
- var $bcc = array();
- var $ReplyTo = array();
- var $attachment = array();
- var $CustomHeader = array();
- var $message_type = "";
- var $boundary = array();
- var $language = array();
- var $error_count = 0;
- var $LE = "\n";
- /**#@-*/
-
- /////////////////////////////////////////////////
- // VARIABLE METHODS
- /////////////////////////////////////////////////
-
- /**
- * Sets message type to HTML.
- * @param bool $bool
- * @return void
- */
- function IsHTML($bool) {
- if($bool == true)
- $this->ContentType = "text/html";
- else
- $this->ContentType = "text/plain";
- }
-
- /**
- * Sets Mailer to send message using SMTP.
- * @return void
- */
- function IsSMTP() {
- $this->Mailer = "smtp";
- }
-
- /**
- * Sets Mailer to send message using PHP mail() function.
- * @return void
- */
- function IsMail() {
- $this->Mailer = "mail";
- }
-
- /**
- * Sets Mailer to send message using the $Sendmail program.
- * @return void
- */
- function IsSendmail() {
- $this->Mailer = "sendmail";
- }
-
- /**
- * Sets Mailer to send message using the qmail MTA.
- * @return void
- */
- function IsQmail() {
- $this->Sendmail = "/var/qmail/bin/sendmail";
- $this->Mailer = "sendmail";
- }
-
-
- /////////////////////////////////////////////////
- // RECIPIENT METHODS
- /////////////////////////////////////////////////
-
- /**
- * Adds a "To" address.
- * @param string $address
- * @param string $name
- * @return void
- */
- function AddAddress($address, $name = "") {
- $cur = count($this->to);
- $this->to[$cur][0] = trim($address);
- $this->to[$cur][1] = $name;
- }
-
- /**
- * Adds a "Cc" address. Note: this function works
- * with the SMTP mailer on win32, not with the "mail"
- * mailer.
- * @param string $address
- * @param string $name
- * @return void
- */
- function AddCC($address, $name = "") {
- $cur = count($this->cc);
- $this->cc[$cur][0] = trim($address);
- $this->cc[$cur][1] = $name;
- }
-
- /**
- * Adds a "Bcc" address. Note: this function works
- * with the SMTP mailer on win32, not with the "mail"
- * mailer.
- * @param string $address
- * @param string $name
- * @return void
- */
- function AddBCC($address, $name = "") {
- $cur = count($this->bcc);
- $this->bcc[$cur][0] = trim($address);
- $this->bcc[$cur][1] = $name;
- }
-
- /**
- * Adds a "Reply-to" address.
- * @param string $address
- * @param string $name
- * @return void
- */
- function AddReplyTo($address, $name = "") {
- $cur = count($this->ReplyTo);
- $this->ReplyTo[$cur][0] = trim($address);
- $this->ReplyTo[$cur][1] = $name;
- }
-
-
- /////////////////////////////////////////////////
- // MAIL SENDING METHODS
- /////////////////////////////////////////////////
-
- /**
- * Creates message and assigns Mailer. If the message is
- * not sent successfully then it returns false. Use the ErrorInfo
- * variable to view description of the error.
- * @return bool
- */
- function Send() {
- $header = "";
- $body = "";
- $result = true;
-
- if((count($this->to) + count($this->cc) + count($this->bcc)) < 1)
- {
- $this->SetError($this->Lang("provide_address"));
- return false;
- }
-
- // Set whether the message is multipart/alternative
- if(!empty($this->AltBody))
- $this->ContentType = "multipart/alternative";
-
- $this->error_count = 0; // reset errors
- $this->SetMessageType();
- $header .= $this->CreateHeader();
- $body = $this->CreateBody();
-
- if($body == "") { return false; }
-
- // Choose the mailer
- switch($this->Mailer)
- {
- case "sendmail":
- $result = $this->SendmailSend($header, $body);
- break;
- case "mail":
- $result = $this->MailSend($header, $body);
- break;
- case "smtp":
- $result = $this->SmtpSend($header, $body);
- break;
- default:
- $this->SetError($this->Mailer . $this->Lang("mailer_not_supported"));
- $result = false;
- break;
- }
-
- return $result;
- }
-
- /**
- * Sends mail using the $Sendmail program.
- * @access private
- * @return bool
- */
- function SendmailSend($header, $body) {
- if ($this->Sender != "")
- $sendmail = sprintf("%s -oi -f %s -t", $this->Sendmail, $this->Sender);
- else
- $sendmail = sprintf("%s -oi -t", $this->Sendmail);
-
- if(!@$mail = popen($sendmail, "w"))
- {
- $this->SetError($this->Lang("execute") . $this->Sendmail);
- return false;
- }
-
- fputs($mail, $header);
- fputs($mail, $body);
-
- $result = pclose($mail) >> 8 & 0xFF;
- if($result != 0)
- {
- $this->SetError($this->Lang("execute") . $this->Sendmail);
- return false;
- }
-
- return true;
- }
-
- /**
- * Sends mail using the PHP mail() function.
- * @access private
- * @return bool
- */
- function MailSend($header, $body) {
- $to = "";
- for($i = 0; $i < count($this->to); $i++)
- {
- if($i != 0) { $to .= ", "; }
- $to .= $this->to[$i][0];
- }
-
- if ($this->Sender != "" && strlen(ini_get("safe_mode"))< 1)
- {
- $old_from = ini_get("sendmail_from");
- ini_set("sendmail_from", $this->Sender);
- $params = sprintf("-oi -f %s", $this->Sender);
- $rt = @mail($to, $this->EncodeHeader($this->Subject), $body,
- $header, $params);
- }
- else
- $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header);
-
- if (isset($old_from))
- ini_set("sendmail_from", $old_from);
-
- if(!$rt)
- {
- $this->SetError($this->Lang("instantiate"));
- return false;
- }
-
- return true;
- }
-
- /**
- * Sends mail via SMTP using PhpSMTP (Author:
- * Chris Ryan). Returns bool. Returns false if there is a
- * bad MAIL FROM, RCPT, or DATA input.
- * @access private
- * @return bool
- */
- function SmtpSend($header, $body) {
- include_once($this->PluginDir . "class.smtp.php");
- $error = "";
- $bad_rcpt = array();
-
- if(!$this->SmtpConnect())
- return false;
-
- $smtp_from = ($this->Sender == "") ? $this->From : $this->Sender;
- if(!$this->smtp->Mail($smtp_from))
- {
- $error = $this->Lang("from_failed") . $smtp_from;
- $this->SetError($error);
- $this->smtp->Reset();
- return false;
- }
-
- // Attempt to send attach all recipients
- for($i = 0; $i < count($this->to); $i++)
- {
- if(!$this->smtp->Recipient($this->to[$i][0]))
- $bad_rcpt[] = $this->to[$i][0];
- }
- for($i = 0; $i < count($this->cc); $i++)
- {
- if(!$this->smtp->Recipient($this->cc[$i][0]))
- $bad_rcpt[] = $this->cc[$i][0];
- }
- for($i = 0; $i < count($this->bcc); $i++)
- {
- if(!$this->smtp->Recipient($this->bcc[$i][0]))
- $bad_rcpt[] = $this->bcc[$i][0];
- }
-
- if(count($bad_rcpt) > 0) // Create error message
- {
- for($i = 0; $i < count($bad_rcpt); $i++)
- {
- if($i != 0) { $error .= ", "; }
- $error .= $bad_rcpt[$i];
- }
- $error = $this->Lang("recipients_failed") . $error;
- $this->SetError($error);
- $this->smtp->Reset();
- return false;
- }
-
- if(!$this->smtp->Data($header . $body))
- {
- $this->SetError($this->Lang("data_not_accepted"));
- $this->smtp->Reset();
- return false;
- }
- if($this->SMTPKeepAlive == true)
- $this->smtp->Reset();
- else
- $this->SmtpClose();
-
- return true;
- }
-
- /**
- * Initiates a connection to an SMTP server. Returns false if the
- * operation failed.
- * @access private
- * @return bool
- */
- function SmtpConnect() {
- if($this->smtp == NULL) { $this->smtp = new SMTP(); }
-
- $this->smtp->do_debug = $this->SMTPDebug;
- $hosts = explode(";", $this->Host);
- $index = 0;
- $connection = ($this->smtp->Connected());
-
- // Retry while there is no connection
- while($index < count($hosts) && $connection == false)
- {
- if(strstr($hosts[$index], ":"))
- list($host, $port) = explode(":", $hosts[$index]);
- else
- {
- $host = $hosts[$index];
- $port = $this->Port;
- }
-
- if($this->smtp->Connect($host, $port, $this->Timeout))
- {
- if ($this->Helo != '')
- $this->smtp->Hello($this->Helo);
- else
- $this->smtp->Hello($this->ServerHostname());
-
- if($this->SMTPAuth)
- {
- if(!$this->smtp->Authenticate($this->Username,
- $this->Password))
- {
- $this->SetError($this->Lang("authenticate"));
- $this->smtp->Reset();
- $connection = false;
- }
- }
- $connection = true;
- }
- $index++;
- }
- if(!$connection)
- $this->SetError($this->Lang("connect_host"));
-
- return $connection;
- }
-
- /**
- * Closes the active SMTP session if one exists.
- * @return void
- */
- function SmtpClose() {
- if($this->smtp != NULL)
- {
- if($this->smtp->Connected())
- {
- $this->smtp->Quit();
- $this->smtp->Close();
- }
- }
- }
-
- /**
- * Sets the language for all class error messages. Returns false
- * if it cannot load the language file. The default language type
- * is English.
- * @param string $lang_type Type of language (e.g. Portuguese: "br")
- * @param string $lang_path Path to the language file directory
- * @access public
- * @return bool
- */
- function SetLanguage($lang_type, $lang_path = "language/") {
- if(file_exists($lang_path.'phpmailer.lang-'.$lang_type.'.php'))
- include($lang_path.'phpmailer.lang-'.$lang_type.'.php');
- else if(file_exists($lang_path.'phpmailer.lang-en.php'))
- include($lang_path.'phpmailer.lang-en.php');
- else
- {
- $this->SetError("Could not load language file");
- return false;
- }
- $this->language = $PHPMAILER_LANG;
-
- return true;
- }
-
- /////////////////////////////////////////////////
- // MESSAGE CREATION METHODS
- /////////////////////////////////////////////////
-
- /**
- * Creates recipient headers.
- * @access private
- * @return string
- */
- function AddrAppend($type, $addr) {
- $addr_str = $type . ": ";
- $addr_str .= $this->AddrFormat($addr[0]);
- if(count($addr) > 1)
- {
- for($i = 1; $i < count($addr); $i++)
- $addr_str .= ", " . $this->AddrFormat($addr[$i]);
- }
- $addr_str .= $this->LE;
-
- return $addr_str;
- }
-
- /**
- * Formats an address correctly.
- * @access private
- * @return string
- */
- function AddrFormat($addr) {
- if(empty($addr[1]))
- $formatted = $addr[0];
- else
- {
- $formatted = $this->EncodeHeader($addr[1], 'phrase') . " <" .
- $addr[0] . ">";
- }
-
- return $formatted;
- }
-
- /**
- * Wraps message for use with mailers that do not
- * automatically perform wrapping and for quoted-printable.
- * Original written by philippe.
- * @access private
- * @return string
- */
- function WrapText($message, $length, $qp_mode = false) {
- $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
-
- $message = $this->FixEOL($message);
- if (substr($message, -1) == $this->LE)
- $message = substr($message, 0, -1);
-
- $line = explode($this->LE, $message);
- $message = "";
- for ($i=0 ;$i < count($line); $i++)
- {
- $line_part = explode(" ", $line[$i]);
- $buf = "";
- for ($e = 0; $e<count($line_part); $e++)
- {
- $word = $line_part[$e];
- if ($qp_mode and (strlen($word) > $length))
- {
- $space_left = $length - strlen($buf) - 1;
- if ($e != 0)
- {
- if ($space_left > 20)
- {
- $len = $space_left;
- if (substr($word, $len - 1, 1) == "=")
- $len--;
- elseif (substr($word, $len - 2, 1) == "=")
- $len -= 2;
- $part = substr($word, 0, $len);
- $word = substr($word, $len);
- $buf .= " " . $part;
- $message .= $buf . sprintf("=%s", $this->LE);
- }
- else
- {
- $message .= $buf . $soft_break;
- }
- $buf = "";
- }
- while (strlen($word) > 0)
- {
- $len = $length;
- if (substr($word, $len - 1, 1) == "=")
- $len--;
- elseif (substr($word, $len - 2, 1) == "=")
- $len -= 2;
- $part = substr($word, 0, $len);
- $word = substr($word, $len);
-
- if (strlen($word) > 0)
- $message .= $part . sprintf("=%s", $this->LE);
- else
- $buf = $part;
- }
- }
- else
- {
- $buf_o = $buf;
- $buf .= ($e == 0) ? $word : (" " . $word);
-
- if (strlen($buf) > $length and $buf_o != "")
- {
- $message .= $buf_o . $soft_break;
- $buf = $word;
- }
- }
- }
- $message .= $buf . $this->LE;
- }
-
- return $message;
- }
-
- /**
- * Set the body wrapping.
- * @access private
- * @return void
- */
- function SetWordWrap() {
- if($this->WordWrap < 1)
- return;
-
- switch($this->message_type)
- {
- case "alt":
- // fall through
- case "alt_attachments":
- $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
- break;
- default:
- $this->Body = $this->WrapText($this->Body, $this->WordWrap);
- break;
- }
- }
-
- /**
- * Assembles message header.
- * @access private
- * @return string
- */
- function CreateHeader() {
- $result = "";
-
- // Set the boundaries
- $uniq_id = md5(uniqid(time()));
- $this->boundary[1] = "b1_" . $uniq_id;
- $this->boundary[2] = "b2_" . $uniq_id;
-
- $result .= $this->HeaderLine("Date", $this->RFCDate());
- if($this->Sender == "")
- $result .= $this->HeaderLine("Return-Path", trim($this->From));
- else
- $result .= $this->HeaderLine("Return-Path", trim($this->Sender));
-
- // To be created automatically by mail()
- if($this->Mailer != "mail")
- {
- if(count($this->to) > 0)
- $result .= $this->AddrAppend("To", $this->to);
- else if (count($this->cc) == 0)
- $result .= $this->HeaderLine("To", "undisclosed-recipients:;");
- if(count($this->cc) > 0)
- $result .= $this->AddrAppend("Cc", $this->cc);
- }
-
- $from = array();
- $from[0][0] = trim($this->From);
- $from[0][1] = $this->FromName;
- $result .= $this->AddrAppend("From", $from);
-
- // sendmail and mail() extract Bcc from the header before sending
- if((($this->Mailer == "sendmail") || ($this->Mailer == "mail")) && (count($this->bcc) > 0))
- $result .= $this->AddrAppend("Bcc", $this->bcc);
-
- if(count($this->ReplyTo) > 0)
- $result .= $this->AddrAppend("Reply-to", $this->ReplyTo);
-
- // mail() sets the subject itself
- if($this->Mailer != "mail")
- $result .= $this->HeaderLine("Subject", $this->EncodeHeader(trim($this->Subject)));
-
- $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
- $result .= $this->HeaderLine("X-Priority", $this->Priority);
-
- if($this->ConfirmReadingTo != "")
- {
- $result .= $this->HeaderLine("Disposition-Notification-To",
- "<" . trim($this->ConfirmReadingTo) . ">");
- }
-
- // Add custom headers
- for($index = 0; $index < count($this->CustomHeader); $index++)
- {
- $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]),
- $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
- }
- $result .= $this->HeaderLine("MIME-Version", "1.0");
-
- switch($this->message_type)
- {
- case "plain":
- $result .= $this->HeaderLine("Content-Transfer-Encoding", $this->Encoding);
- $result .= sprintf("Content-Type: %s; charset=\"%s\"",
- $this->ContentType, $this->CharSet);
- break;
- case "attachments":
- // fall through
- case "alt_attachments":
- if($this->InlineImageExists())
- {
- $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s",
- "multipart/related", $this->LE, $this->LE,
- $this->boundary[1], $this->LE);
- }
- else
- {
- $result .= $this->HeaderLine("Content-Type", "multipart/mixed;");
- $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
- }
- break;
- case "alt":
- $result .= $this->HeaderLine("Content-Type", "multipart/alternative;");
- $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
- break;
- }
-
- if($this->Mailer != "mail")
- $result .= $this->LE.$this->LE;
-
- return $result;
- }
-
- /**
- * Assembles the message body. Returns an empty string on failure.
- * @access private
- * @return string
- */
- function CreateBody() {
- $result = "";
-
- $this->SetWordWrap();
-
- switch($this->message_type)
- {
- case "alt":
- $result .= $this->GetBoundary($this->boundary[1], "",
- "text/plain", "");
- $result .= $this->EncodeString($this->AltBody, $this->Encoding);
- $result .= $this->LE.$this->LE;
- $result .= $this->GetBoundary($this->boundary[1], "",
- "text/html", "");
-
- $result .= $this->EncodeString($this->Body, $this->Encoding);
- $result .= $this->LE.$this->LE;
-
- $result .= $this->EndBoundary($this->boundary[1]);
- break;
- case "plain":
- $result .= $this->EncodeString($this->Body, $this->Encoding);
- break;
- case "attachments":
- $result .= $this->GetBoundary($this->boundary[1], "", "", "");
- $result .= $this->EncodeString($this->Body, $this->Encoding);
- $result .= $this->LE;
-
- $result .= $this->AttachAll();
- break;
- case "alt_attachments":
- $result .= sprintf("--%s%s", $this->boundary[1], $this->LE);
- $result .= sprintf("Content-Type: %s;%s" .
- "\tboundary=\"%s\"%s",
- "multipart/alternative", $this->LE,
- $this->boundary[2], $this->LE.$this->LE);
-
- // Create text body
- $result .= $this->GetBoundary($this->boundary[2], "",
- "text/plain", "") . $this->LE;
-
- $result .= $this->EncodeString($this->AltBody, $this->Encoding);
- $result .= $this->LE.$this->LE;
-
- // Create the HTML body
- $result .= $this->GetBoundary($this->boundary[2], "",
- "text/html", "") . $this->LE;
-
- $result .= $this->EncodeString($this->Body, $this->Encoding);
- $result .= $this->LE.$this->LE;
-
- $result .= $this->EndBoundary($this->boundary[2]);
-
- $result .= $this->AttachAll();
- break;
- }
- if($this->IsError())
- $result = "";
-
- return $result;
- }
-
- /**
- * Returns the start of a message boundary.
- * @access private
- */
- function GetBoundary($boundary, $charSet, $contentType, $encoding) {
- $result = "";
- if($charSet == "") { $charSet = $this->CharSet; }
- if($contentType == "") { $contentType = $this->ContentType; }
- if($encoding == "") { $encoding = $this->Encoding; }
-
- $result .= $this->TextLine("--" . $boundary);
- $result .= sprintf("Content-Type: %s; charset = \"%s\"",
- $contentType, $charSet);
- $result .= $this->LE;
- $result .= $this->HeaderLine("Content-Transfer-Encoding", $encoding);
- $result .= $this->LE;
-
- return $result;
- }
-
- /**
- * Returns the end of a message boundary.
- * @access private
- */
- function EndBoundary($boundary) {
- return $this->LE . "--" . $boundary . "--" . $this->LE;
- }
-
- /**
- * Sets the message type.
- * @access private
- * @return void
- */
- function SetMessageType() {
- if(count($this->attachment) < 1 && strlen($this->AltBody) < 1)
- $this->message_type = "plain";
- else
- {
- if(count($this->attachment) > 0)
- $this->message_type = "attachments";
- if(strlen($this->AltBody) > 0 && count($this->attachment) < 1)
- $this->message_type = "alt";
- if(strlen($this->AltBody) > 0 && count($this->attachment) > 0)
- $this->message_type = "alt_attachments";
- }
- }
-
- /**
- * Returns a formatted header line.
- * @access private
- * @return string
- */
- function HeaderLine($name, $value) {
- return $name . ": " . $value . $this->LE;
- }
-
- /**
- * Returns a formatted mail line.
- * @access private
- * @return string
- */
- function TextLine($value) {
- return $value . $this->LE;
- }
-
- /////////////////////////////////////////////////
- // ATTACHMENT METHODS
- /////////////////////////////////////////////////
-
- /**
- * Adds an attachment from a path on the filesystem.
- * Returns false if the file could not be found
- * or accessed.
- * @param string $path Path to the attachment.
- * @param string $name Overrides the attachment name.
- * @param string $encoding File encoding (see $Encoding).
- * @param string $type File extension (MIME) type.
- * @return bool
- */
- function AddAttachment($path, $name = "", $encoding = "base64",
- $type = "application/octet-stream") {
- if(!@is_file($path))
- {
- $this->SetError($this->Lang("file_access") . $path);
- return false;
- }
-
- $filename = basename($path);
- if($name == "")
- $name = $filename;
-
- $cur = count($this->attachment);
- $this->attachment[$cur][0] = $path;
- $this->attachment[$cur][1] = $filename;
- $this->attachment[$cur][2] = $name;
- $this->attachment[$cur][3] = $encoding;
- $this->attachment[$cur][4] = $type;
- $this->attachment[$cur][5] = false; // isStringAttachment
- $this->attachment[$cur][6] = "attachment";
- $this->attachment[$cur][7] = 0;
-
- return true;
- }
-
- /**
- * Attaches all fs, string, and binary attachments to the message.
- * Returns an empty string on failure.
- * @access private
- * @return string
- */
- function AttachAll() {
- // Return text of body
- $mime = array();
-
- // Add all attachments
- for($i = 0; $i < count($this->attachment); $i++)
- {
- // Check for string attachment
- $bString = $this->attachment[$i][5];
- if ($bString)
- $string = $this->attachment[$i][0];
- else
- $path = $this->attachment[$i][0];
-
- $filename = $this->attachment[$i][1];
- $name = $this->attachment[$i][2];
- $encoding = $this->attachment[$i][3];
- $type = $this->attachment[$i][4];
- $disposition = $this->attachment[$i][6];
- $cid = $this->attachment[$i][7];
-
- $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
- $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $name, $this->LE);
- $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
-
- if($disposition == "inline")
- $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
-
- $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s",
- $disposition, $name, $this->LE.$this->LE);
-
- // Encode as string attachment
- if($bString)
- {
- $mime[] = $this->EncodeString($string, $encoding);
- if($this->IsError()) { return ""; }
- $mime[] = $this->LE.$this->LE;
- }
- else
- {
- $mime[] = $this->EncodeFile($path, $encoding);
- if($this->IsError()) { return ""; }
- $mime[] = $this->LE.$this->LE;
- }
- }
-
- $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);
-
- return join("", $mime);
- }
-
- /**
- * Encodes attachment in requested format. Returns an
- * empty string on failure.
- * @access private
- * @return string
- */
- function EncodeFile ($path, $encoding = "base64") {
- if(!@$fd = fopen($path, "rb"))
- {
- $this->SetError($this->Lang("file_open") . $path);
- return "";
- }
- $magic_quotes = get_magic_quotes_runtime();
- set_magic_quotes_runtime(0);
- $file_buffer = fread($fd, filesize($path));
- $file_buffer = $this->EncodeString($file_buffer, $encoding);
- fclose($fd);
- set_magic_quotes_runtime($magic_quotes);
-
- return $file_buffer;
- }
-
- /**
- * Encodes string to requested format. Returns an
- * empty string on failure.
- * @access private
- * @return string
- */
- function EncodeString ($str, $encoding = "base64") {
- $encoded = "";
- switch(strtolower($encoding)) {
- case "base64":
- // chunk_split is found in PHP >= 3.0.6
- $encoded = chunk_split(base64_encode($str), 76, $this->LE);
- break;
- case "7bit":
- case "8bit":
- $encoded = $this->FixEOL($str);
- if (substr($encoded, -(strlen($this->LE))) != $this->LE)
- $encoded .= $this->LE;
- break;
- case "binary":
- $encoded = $str;
- break;
- case "quoted-printable":
- $encoded = $this->EncodeQP($str);
- break;
- default:
- $this->SetError($this->Lang("encoding") . $encoding);
- break;
- }
- return $encoded;
- }
-
- /**
- * Encode a header string to best of Q, B, quoted or none.
- * @access private
- * @return string
- */
- function EncodeHeader ($str, $position = 'text') {
- $x = 0;
-
- switch (strtolower($position)) {
- case 'phrase':
- if (!preg_match('/[\200-\377]/', $str)) {
- // Can't use addslashes as we don't know what value has magic_quotes_sybase.
- $encoded = addcslashes($str, "\0..\37\177\\\"");
-
- if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str))
- return ($encoded);
- else
- return ("\"$encoded\"");
- }
- $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
- break;
- case 'comment':
- $x = preg_match_all('/[()"]/', $str, $matches);
- // Fall-through
- case 'text':
- default:
- $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
- break;
- }
-
- if ($x == 0)
- return ($str);
-
- $maxlen = 75 - 7 - strlen($this->CharSet);
- // Try to select the encoding which should produce the shortest output
- if (strlen($str)/3 < $x) {
- $encoding = 'B';
- $encoded = base64_encode($str);
- $maxlen -= $maxlen % 4;
- $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
- } else {
- $encoding = 'Q';
- $encoded = $this->EncodeQ($str, $position);
- $encoded = $this->WrapText($encoded, $maxlen, true);
- $encoded = str_replace("=".$this->LE, "\n", trim($encoded));
- }
-
- $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
- $encoded = trim(str_replace("\n", $this->LE, $encoded));
-
- return $encoded;
- }
-
- /**
- * Encode string to quoted-printable.
- * @access private
- * @return string
- */
- function EncodeQP ($str) {
- $encoded = $this->FixEOL($str);
- if (substr($encoded, -(strlen($this->LE))) != $this->LE)
- $encoded .= $this->LE;
-
- // Replace every high ascii, control and = characters
- $encoded = preg_replace('/([\000-\010\013\014\016-\037\075\177-\377])/e',
- "'='.sprintf('%02X', ord('\\1'))", $encoded);
- // Replace every spaces and tabs when it's the last character on a line
- $encoded = preg_replace("/([\011\040])".$this->LE."/e",
- "'='.sprintf('%02X', ord('\\1')).'".$this->LE."'", $encoded);
-
- // Maximum line length of 76 characters before CRLF (74 + space + '=')
- $encoded = $this->WrapText($encoded, 74, true);
-
- return $encoded;
- }
-
- /**
- * Encode string to q encoding.
- * @access private
- * @return string
- */
- function EncodeQ ($str, $position = "text") {
- // There should not be any EOL in the string
- $encoded = preg_replace("[\r\n]", "", $str);
-
- switch (strtolower($position)) {
- case "phrase":
- $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
- break;
- case "comment":
- $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
- case "text":
- default:
- // Replace every high ascii, control =, ? and _ characters
- $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
- "'='.sprintf('%02X', ord('\\1'))", $encoded);
- break;
- }
-
- // Replace every spaces to _ (more readable than =20)
- $encoded = str_replace(" ", "_", $encoded);
-
- return $encoded;
- }
-
- /**
- * Adds a string or binary attachment (non-filesystem) to the list.
- * This method can be used to attach ascii or binary data,
- * such as a BLOB record from a database.
- * @param string $string String attachment data.
- * @param string $filename Name of the attachment.
- * @param string $encoding File encoding (see $Encoding).
- * @param string $type File extension (MIME) type.
- * @return void
- */
- function AddStringAttachment($string, $filename, $encoding = "base64",
- $type = "application/octet-stream") {
- // Append to $attachment array
- $cur = count($this->attachment);
- $this->attachment[$cur][0] = $string;
- $this->attachment[$cur][1] = $filename;
- $this->attachment[$cur][2] = $filename;
- $this->attachment[$cur][3] = $encoding;
- $this->attachment[$cur][4] = $type;
- $this->attachment[$cur][5] = true; // isString
- $this->attachment[$cur][6] = "attachment";
- $this->attachment[$cur][7] = 0;
- }
-
- /**
- * Adds an embedded attachment. This can include images, sounds, and
- * just about any other document. Make sure to set the $type to an
- * image type. For JPEG images use "image/jpeg" and for GIF images
- * use "image/gif".
- * @param string $path Path to the attachment.
- * @param string $cid Content ID of the attachment. Use this to identify
- * the Id for accessing the image in an HTML form.
- * @param string $name Overrides the attachment name.
- * @param string $encoding File encoding (see $Encoding).
- * @param string $type File extension (MIME) type.
- * @return bool
- */
- function AddEmbeddedImage($path, $cid, $name = "", $encoding = "base64",
- $type = "application/octet-stream") {
-
- if(!@is_file($path))
- {
- $this->SetError($this->Lang("file_access") . $path);
- return false;
- }
-
- $filename = basename($path);
- if($name == "")
- $name = $filename;
-
- // Append to $attachment array
- $cur = count($this->attachment);
- $this->attachment[$cur][0] = $path;
- $this->attachment[$cur][1] = $filename;
- $this->attachment[$cur][2] = $name;
- $this->attachment[$cur][3] = $encoding;
- $this->attachment[$cur][4] = $type;
- $this->attachment[$cur][5] = false; // isStringAttachment
- $this->attachment[$cur][6] = "inline";
- $this->attachment[$cur][7] = $cid;
-
- return true;
- }
-
- /**
- * Returns true if an inline attachment is present.
- * @access private
- * @return bool
- */
- function InlineImageExists() {
- $result = false;
- for($i = 0; $i < count($this->attachment); $i++)
- {
- if($this->attachment[$i][6] == "inline")
- {
- $result = true;
- break;
- }
- }
-
- return $result;
- }
-
- /////////////////////////////////////////////////
- // MESSAGE RESET METHODS
- /////////////////////////////////////////////////
-
- /**
- * Clears all recipients assigned in the TO array. Returns void.
- * @return void
- */
- function ClearAddresses() {
- $this->to = array();
- }
-
- /**
- * Clears all recipients assigned in the CC array. Returns void.
- * @return void
- */
- function ClearCCs() {
- $this->cc = array();
- }
-
- /**
- * Clears all recipients assigned in the BCC array. Returns void.
- * @return void
- */
- function ClearBCCs() {
- $this->bcc = array();
- }
-
- /**
- * Clears all recipients assigned in the ReplyTo array. Returns void.
- * @return void
- */
- function ClearReplyTos() {
- $this->ReplyTo = array();
- }
-
- /**
- * Clears all recipients assigned in the TO, CC and BCC
- * array. Returns void.
- * @return void
- */
- function ClearAllRecipients() {
- $this->to = array();
- $this->cc = array();
- $this->bcc = array();
- }
-
- /**
- * Clears all previously set filesystem, string, and binary
- * attachments. Returns void.
- * @return void
- */
- function ClearAttachments() {
- $this->attachment = array();
- }
-
- /**
- * Clears all custom headers. Returns void.
- * @return void
- */
- function ClearCustomHeaders() {
- $this->CustomHeader = array();
- }
-
-
- /////////////////////////////////////////////////
- // MISCELLANEOUS METHODS
- /////////////////////////////////////////////////
-
- /**
- * Adds the error message to the error container.
- * Returns void.
- * @access private
- * @return void
- */
- function SetError($msg) {
- $this->error_count++;
- $this->ErrorInfo = $msg;
- }
-
- /**
- * Returns the proper RFC 822 formatted date.
- * @access private
- * @return string
- */
- function RFCDate() {
- $tz = date("Z");
- $tzs = ($tz < 0) ? "-" : "+";
- $tz = abs($tz);
- $tz = ($tz/3600)*100 + ($tz%3600)/60;
- $result = sprintf("%s %s%04d", date("D, j M Y H:i:s"), $tzs, $tz);
-
- return $result;
- }
-
- /**
- * Returns the appropriate server variable. Should work with both
- * PHP 4.1.0+ as well as older versions. Returns an empty string
- * if nothing is found.
- * @access private
- * @return mixed
- */
- function ServerVar($varName) {
- global $HTTP_SERVER_VARS;
- global $HTTP_ENV_VARS;
-
- if(!isset($_SERVER))
- {
- $_SERVER = $HTTP_SERVER_VARS;
- if(!isset($_SERVER["REMOTE_ADDR"]))
- $_SERVER = $HTTP_ENV_VARS; // must be Apache
- }
-
- if(isset($_SERVER[$varName]))
- return $_SERVER[$varName];
- else
- return "";
- }
-
- /**
- * Returns the server hostname or 'localhost.localdomain' if unknown.
- * @access private
- * @return string
- */
- function ServerHostname() {
- if ($this->Hostname != "")
- $result = $this->Hostname;
- elseif ($this->ServerVar('SERVER_NAME') != "")
- $result = $this->ServerVar('SERVER_NAME');
- else
- $result = "localhost.localdomain";
-
- return $result;
- }
-
- /**
- * Returns a message in the appropriate language.
- * @access private
- * @return string
- */
- function Lang($key) {
- if(count($this->language) < 1)
- $this->SetLanguage("en"); // set the default language
-
- if(isset($this->language[$key]))
- return $this->language[$key];
- else
- return "Language string failed to load: " . $key;
- }
-
- /**
- * Returns true if an error occurred.
- * @return bool
- */
- function IsError() {
- return ($this->error_count > 0);
- }
-
- /**
- * Changes every end of line from CR or LF to CRLF.
- * @access private
- * @return string
- */
- function FixEOL($str) {
- $str = str_replace("\r\n", "\n", $str);
- $str = str_replace("\r", "\n", $str);
- $str = str_replace("\n", $this->LE, $str);
- return $str;
- }
-
- /**
- * Adds a custom header.
- * @return void
- */
- function AddCustomHeader($custom_header) {
- $this->CustomHeader[] = explode(":", $custom_header, 2);
- }
-}
-
-?>
+<?php
+////////////////////////////////////////////////////
+// PHPMailer - PHP email class
+//
+// Class for sending email using either
+// sendmail, PHP mail(), or SMTP. Methods are
+// based upon the standard AspEmail(tm) classes.
+//
+// Copyright (C) 2001 - 2003 Brent R. Matzelle
+//
+// License: LGPL, see LICENSE
+////////////////////////////////////////////////////
+
+/**
+ * PHPMailer - PHP email transport class
+ * @package PHPMailer
+ * @author Brent R. Matzelle
+ * @copyright 2001 - 2003 Brent R. Matzelle
+ */
+class PHPMailer
+{
+ /////////////////////////////////////////////////
+ // PUBLIC VARIABLES
+ /////////////////////////////////////////////////
+
+ /**
+ * Email priority (1 = High, 3 = Normal, 5 = low).
+ * @var int
+ */
+ var $Priority = 3;
+
+ /**
+ * Sets the CharSet of the message.
+ * @var string
+ */
+ var $CharSet = "UTF-8";
+
+ /**
+ * Sets the Content-type of the message.
+ * @var string
+ */
+ var $ContentType = "text/plain";
+
+ /**
+ * Sets the Encoding of the message. Options for this are "8bit",
+ * "7bit", "binary", "base64", and "quoted-printable".
+ * @var string
+ */
+ var $Encoding = "8bit";
+
+ /**
+ * Holds the most recent mailer error message.
+ * @var string
+ */
+ var $ErrorInfo = "";
+
+ /**
+ * Sets the From email address for the message.
+ * @var string
+ */
+ var $From = "support@wordpress.com";
+
+ /**
+ * Sets the From name of the message.
+ * @var string
+ */
+ var $FromName = "Support";
+
+ /**
+ * Sets the Sender email (Return-Path) of the message. If not empty,
+ * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
+ * @var string
+ */
+ var $Sender = "";
+
+ /**
+ * Sets the Subject of the message.
+ * @var string
+ */
+ var $Subject = "";
+
+ /**
+ * Sets the Body of the message. This can be either an HTML or text body.
+ * If HTML then run IsHTML(true).
+ * @var string
+ */
+ var $Body = "";
+
+ /**
+ * Sets the text-only body of the message. This automatically sets the
+ * email to multipart/alternative. This body can be read by mail
+ * clients that do not have HTML email capability such as mutt. Clients
+ * that can read HTML will view the normal Body.
+ * @var string
+ */
+ var $AltBody = "";
+
+ /**
+ * Sets word wrapping on the body of the message to a given number of
+ * characters.
+ * @var int
+ */
+ var $WordWrap = 0;
+
+ /**
+ * Method to send mail: ("mail", "sendmail", or "smtp").
+ * @var string
+ */
+ var $Mailer = "mail";
+
+ /**
+ * Sets the path of the sendmail program.
+ * @var string
+ */
+ var $Sendmail = "/usr/sbin/sendmail";
+
+ /**
+ * Path to PHPMailer plugins. This is now only useful if the SMTP class
+ * is in a different directory than the PHP include path.
+ * @var string
+ */
+ var $PluginDir = "";
+
+ /**
+ * Holds PHPMailer version.
+ * @var string
+ */
+ var $Version = "1.73";
+
+ /**
+ * Sets the email address that a reading confirmation will be sent.
+ * @var string
+ */
+ var $ConfirmReadingTo = "";
+
+ /**
+ * Sets the hostname to use in Message-Id and Received headers
+ * and as default HELO string. If empty, the value returned
+ * by SERVER_NAME is used or 'localhost.localdomain'.
+ * @var string
+ */
+ var $Hostname = "";
+
+ /////////////////////////////////////////////////
+ // SMTP VARIABLES
+ /////////////////////////////////////////////////
+
+ /**
+ * Sets the SMTP hosts. All hosts must be separated by a
+ * semicolon. You can also specify a different port
+ * for each host by using this format: [hostname:port]
+ * (e.g. "smtp1.example.com:25;smtp2.example.com").
+ * Hosts will be tried in order.
+ * @var string
+ */
+ var $Host = "localhost";
+
+ /**
+ * Sets the default SMTP server port.
+ * @var int
+ */
+ var $Port = 25;
+
+ /**
+ * Sets the SMTP HELO of the message (Default is $Hostname).
+ * @var string
+ */
+ var $Helo = "";
+
+ /**
+ * Sets SMTP authentication. Utilizes the Username and Password variables.
+ * @var bool
+ */
+ var $SMTPAuth = false;
+
+ /**
+ * Sets SMTP username.
+ * @var string
+ */
+ var $Username = "";
+
+ /**
+ * Sets SMTP password.
+ * @var string
+ */
+ var $Password = "";
+
+ /**
+ * Sets the SMTP server timeout in seconds. This function will not
+ * work with the win32 version.
+ * @var int
+ */
+ var $Timeout = 10;
+
+ /**
+ * Sets SMTP class debugging on or off.
+ * @var bool
+ */
+ var $SMTPDebug = false;
+
+ /**
+ * Prevents the SMTP connection from being closed after each mail
+ * sending. If this is set to true then to close the connection
+ * requires an explicit call to SmtpClose().
+ * @var bool
+ */
+ var $SMTPKeepAlive = false;
+
+ /**#@+
+ * @access private
+ */
+ var $smtp = NULL;
+ var $to = array();
+ var $cc = array();
+ var $bcc = array();
+ var $ReplyTo = array();
+ var $attachment = array();
+ var $CustomHeader = array();
+ var $message_type = "";
+ var $boundary = array();
+ var $language = array();
+ var $error_count = 0;
+ var $LE = "\n";
+ /**#@-*/
+
+ /////////////////////////////////////////////////
+ // VARIABLE METHODS
+ /////////////////////////////////////////////////
+
+ /**
+ * Sets message type to HTML.
+ * @param bool $bool
+ * @return void
+ */
+ function IsHTML($bool) {
+ if($bool == true)
+ $this->ContentType = "text/html";
+ else
+ $this->ContentType = "text/plain";
+ }
+
+ /**
+ * Sets Mailer to send message using SMTP.
+ * @return void
+ */
+ function IsSMTP() {
+ $this->Mailer = "smtp";
+ }
+
+ /**
+ * Sets Mailer to send message using PHP mail() function.
+ * @return void
+ */
+ function IsMail() {
+ $this->Mailer = "mail";
+ }
+
+ /**
+ * Sets Mailer to send message using the $Sendmail program.
+ * @return void
+ */
+ function IsSendmail() {
+ $this->Mailer = "sendmail";
+ }
+
+ /**
+ * Sets Mailer to send message using the qmail MTA.
+ * @return void
+ */
+ function IsQmail() {
+ $this->Sendmail = "/var/qmail/bin/sendmail";
+ $this->Mailer = "sendmail";
+ }
+
+
+ /////////////////////////////////////////////////
+ // RECIPIENT METHODS
+ /////////////////////////////////////////////////
+
+ /**
+ * Adds a "To" address.
+ * @param string $address
+ * @param string $name
+ * @return void
+ */
+ function AddAddress($address, $name = "") {
+ $cur = count($this->to);
+ $this->to[$cur][0] = trim($address);
+ $this->to[$cur][1] = $name;
+ }
+
+ /**
+ * Adds a "Cc" address. Note: this function works
+ * with the SMTP mailer on win32, not with the "mail"
+ * mailer.
+ * @param string $address
+ * @param string $name
+ * @return void
+ */
+ function AddCC($address, $name = "") {
+ $cur = count($this->cc);
+ $this->cc[$cur][0] = trim($address);
+ $this->cc[$cur][1] = $name;
+ }
+
+ /**
+ * Adds a "Bcc" address. Note: this function works
+ * with the SMTP mailer on win32, not with the "mail"
+ * mailer.
+ * @param string $address
+ * @param string $name
+ * @return void
+ */
+ function AddBCC($address, $name = "") {
+ $cur = count($this->bcc);
+ $this->bcc[$cur][0] = trim($address);
+ $this->bcc[$cur][1] = $name;
+ }
+
+ /**
+ * Adds a "Reply-to" address.
+ * @param string $address
+ * @param string $name
+ * @return void
+ */
+ function AddReplyTo($address, $name = "") {
+ $cur = count($this->ReplyTo);
+ $this->ReplyTo[$cur][0] = trim($address);
+ $this->ReplyTo[$cur][1] = $name;
+ }
+
+
+ /////////////////////////////////////////////////
+ // MAIL SENDING METHODS
+ /////////////////////////////////////////////////
+
+ /**
+ * Creates message and assigns Mailer. If the message is
+ * not sent successfully then it returns false. Use the ErrorInfo
+ * variable to view description of the error.
+ * @return bool
+ */
+ function Send() {
+ $header = "";
+ $body = "";
+ $result = true;
+
+ if((count($this->to) + count($this->cc) + count($this->bcc)) < 1)
+ {
+ $this->SetError($this->Lang("provide_address"));
+ return false;
+ }
+
+ // Set whether the message is multipart/alternative
+ if(!empty($this->AltBody))
+ $this->ContentType = "multipart/alternative";
+
+ $this->error_count = 0; // reset errors
+ $this->SetMessageType();
+ $header .= $this->CreateHeader();
+ $body = $this->CreateBody();
+
+ if($body == "") { return false; }
+
+ // Choose the mailer
+ switch($this->Mailer)
+ {
+ case "sendmail":
+ $result = $this->SendmailSend($header, $body);
+ break;
+ case "mail":
+ $result = $this->MailSend($header, $body);
+ break;
+ case "smtp":
+ $result = $this->SmtpSend($header, $body);
+ break;
+ default:
+ $this->SetError($this->Mailer . $this->Lang("mailer_not_supported"));
+ $result = false;
+ break;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sends mail using the $Sendmail program.
+ * @access private
+ * @return bool
+ */
+ function SendmailSend($header, $body) {
+ if ($this->Sender != "")
+ $sendmail = sprintf("%s -oi -f %s -t", $this->Sendmail, $this->Sender);
+ else
+ $sendmail = sprintf("%s -oi -t", $this->Sendmail);
+
+ if(!@$mail = popen($sendmail, "w"))
+ {
+ $this->SetError($this->Lang("execute") . $this->Sendmail);
+ return false;
+ }
+
+ fputs($mail, $header);
+ fputs($mail, $body);
+
+ $result = pclose($mail) >> 8 & 0xFF;
+ if($result != 0)
+ {
+ $this->SetError($this->Lang("execute") . $this->Sendmail);
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Sends mail using the PHP mail() function.
+ * @access private
+ * @return bool
+ */
+ function MailSend($header, $body) {
+ $to = "";
+ for($i = 0; $i < count($this->to); $i++)
+ {
+ if($i != 0) { $to .= ", "; }
+ $to .= $this->to[$i][0];
+ }
+
+ if ($this->Sender != "" && strlen(ini_get("safe_mode"))< 1)
+ {
+ $old_from = ini_get("sendmail_from");
+ ini_set("sendmail_from", $this->Sender);
+ $params = sprintf("-oi -f %s", $this->Sender);
+ $rt = @mail($to, $this->EncodeHeader($this->Subject), $body,
+ $header, $params);
+ }
+ else
+ $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header);
+
+ if (isset($old_from))
+ ini_set("sendmail_from", $old_from);
+
+ if(!$rt)
+ {
+ $this->SetError($this->Lang("instantiate"));
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Sends mail via SMTP using PhpSMTP (Author:
+ * Chris Ryan). Returns bool. Returns false if there is a
+ * bad MAIL FROM, RCPT, or DATA input.
+ * @access private
+ * @return bool
+ */
+ function SmtpSend($header, $body) {
+ include_once($this->PluginDir . "class.smtp.php");
+ $error = "";
+ $bad_rcpt = array();
+
+ if(!$this->SmtpConnect())
+ return false;
+
+ $smtp_from = ($this->Sender == "") ? $this->From : $this->Sender;
+ if(!$this->smtp->Mail($smtp_from))
+ {
+ $error = $this->Lang("from_failed") . $smtp_from;
+ $this->SetError($error);
+ $this->smtp->Reset();
+ return false;
+ }
+
+ // Attempt to send attach all recipients
+ for($i = 0; $i < count($this->to); $i++)
+ {
+ if(!$this->smtp->Recipient($this->to[$i][0]))
+ $bad_rcpt[] = $this->to[$i][0];
+ }
+ for($i = 0; $i < count($this->cc); $i++)
+ {
+ if(!$this->smtp->Recipient($this->cc[$i][0]))
+ $bad_rcpt[] = $this->cc[$i][0];
+ }
+ for($i = 0; $i < count($this->bcc); $i++)
+ {
+ if(!$this->smtp->Recipient($this->bcc[$i][0]))
+ $bad_rcpt[] = $this->bcc[$i][0];
+ }
+
+ if(count($bad_rcpt) > 0) // Create error message
+ {
+ for($i = 0; $i < count($bad_rcpt); $i++)
+ {
+ if($i != 0) { $error .= ", "; }
+ $error .= $bad_rcpt[$i];
+ }
+ $error = $this->Lang("recipients_failed") . $error;
+ $this->SetError($error);
+ $this->smtp->Reset();
+ return false;
+ }
+
+ if(!$this->smtp->Data($header . $body))
+ {
+ $this->SetError($this->Lang("data_not_accepted"));
+ $this->smtp->Reset();
+ return false;
+ }
+ if($this->SMTPKeepAlive == true)
+ $this->smtp->Reset();
+ else
+ $this->SmtpClose();
+
+ return true;
+ }
+
+ /**
+ * Initiates a connection to an SMTP server. Returns false if the
+ * operation failed.
+ * @access private
+ * @return bool
+ */
+ function SmtpConnect() {
+ if($this->smtp == NULL) { $this->smtp = new SMTP(); }
+
+ $this->smtp->do_debug = $this->SMTPDebug;
+ $hosts = explode(";", $this->Host);
+ $index = 0;
+ $connection = ($this->smtp->Connected());
+
+ // Retry while there is no connection
+ while($index < count($hosts) && $connection == false)
+ {
+ if(strstr($hosts[$index], ":"))
+ list($host, $port) = explode(":", $hosts[$index]);
+ else
+ {
+ $host = $hosts[$index];
+ $port = $this->Port;
+ }
+
+ if($this->smtp->Connect($host, $port, $this->Timeout))
+ {
+ if ($this->Helo != '')
+ $this->smtp->Hello($this->Helo);
+ else
+ $this->smtp->Hello($this->ServerHostname());
+
+ if($this->SMTPAuth)
+ {
+ if(!$this->smtp->Authenticate($this->Username,
+ $this->Password))
+ {
+ $this->SetError($this->Lang("authenticate"));
+ $this->smtp->Reset();
+ $connection = false;
+ }
+ }
+ $connection = true;
+ }
+ $index++;
+ }
+ if(!$connection)
+ $this->SetError($this->Lang("connect_host"));
+
+ return $connection;
+ }
+
+ /**
+ * Closes the active SMTP session if one exists.
+ * @return void
+ */
+ function SmtpClose() {
+ if($this->smtp != NULL)
+ {
+ if($this->smtp->Connected())
+ {
+ $this->smtp->Quit();
+ $this->smtp->Close();
+ }
+ }
+ }
+
+ /**
+ * Sets the language for all class error messages. Returns false
+ * if it cannot load the language file. The default language type
+ * is English.
+ * @param string $lang_type Type of language (e.g. Portuguese: "br")
+ * @param string $lang_path Path to the language file directory
+ * @access public
+ * @return bool
+ */
+ function SetLanguage($lang_type, $lang_path = "language/") {
+ if(file_exists($lang_path.'phpmailer.lang-'.$lang_type.'.php'))
+ include($lang_path.'phpmailer.lang-'.$lang_type.'.php');
+ else if(file_exists($lang_path.'phpmailer.lang-en.php'))
+ include($lang_path.'phpmailer.lang-en.php');
+ else
+ {
+ $this->SetError("Could not load language file");
+ return false;
+ }
+ $this->language = $PHPMAILER_LANG;
+
+ return true;
+ }
+
+ /////////////////////////////////////////////////
+ // MESSAGE CREATION METHODS
+ /////////////////////////////////////////////////
+
+ /**
+ * Creates recipient headers.
+ * @access private
+ * @return string
+ */
+ function AddrAppend($type, $addr) {
+ $addr_str = $type . ": ";
+ $addr_str .= $this->AddrFormat($addr[0]);
+ if(count($addr) > 1)
+ {
+ for($i = 1; $i < count($addr); $i++)
+ $addr_str .= ", " . $this->AddrFormat($addr[$i]);
+ }
+ $addr_str .= $this->LE;
+
+ return $addr_str;
+ }
+
+ /**
+ * Formats an address correctly.
+ * @access private
+ * @return string
+ */
+ function AddrFormat($addr) {
+ if(empty($addr[1]))
+ $formatted = $addr[0];
+ else
+ {
+ $formatted = $this->EncodeHeader($addr[1], 'phrase') . " <" .
+ $addr[0] . ">";
+ }
+
+ return $formatted;
+ }
+
+ /**
+ * Wraps message for use with mailers that do not
+ * automatically perform wrapping and for quoted-printable.
+ * Original written by philippe.
+ * @access private
+ * @return string
+ */
+ function WrapText($message, $length, $qp_mode = false) {
+ $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
+
+ $message = $this->FixEOL($message);
+ if (substr($message, -1) == $this->LE)
+ $message = substr($message, 0, -1);
+
+ $line = explode($this->LE, $message);
+ $message = "";
+ for ($i=0 ;$i < count($line); $i++)
+ {
+ $line_part = explode(" ", $line[$i]);
+ $buf = "";
+ for ($e = 0; $e<count($line_part); $e++)
+ {
+ $word = $line_part[$e];
+ if ($qp_mode and (strlen($word) > $length))
+ {
+ $space_left = $length - strlen($buf) - 1;
+ if ($e != 0)
+ {
+ if ($space_left > 20)
+ {
+ $len = $space_left;
+ if (substr($word, $len - 1, 1) == "=")
+ $len--;
+ elseif (substr($word, $len - 2, 1) == "=")
+ $len -= 2;
+ $part = substr($word, 0, $len);
+ $word = substr($word, $len);
+ $buf .= " " . $part;
+ $message .= $buf . sprintf("=%s", $this->LE);
+ }
+ else
+ {
+ $message .= $buf . $soft_break;
+ }
+ $buf = "";
+ }
+ while (strlen($word) > 0)
+ {
+ $len = $length;
+ if (substr($word, $len - 1, 1) == "=")
+ $len--;
+ elseif (substr($word, $len - 2, 1) == "=")
+ $len -= 2;
+ $part = substr($word, 0, $len);
+ $word = substr($word, $len);
+
+ if (strlen($word) > 0)
+ $message .= $part . sprintf("=%s", $this->LE);
+ else
+ $buf = $part;
+ }
+ }
+ else
+ {
+ $buf_o = $buf;
+ $buf .= ($e == 0) ? $word : (" " . $word);
+
+ if (strlen($buf) > $length and $buf_o != "")
+ {
+ $message .= $buf_o . $soft_break;
+ $buf = $word;
+ }
+ }
+ }
+ $message .= $buf . $this->LE;
+ }
+
+ return $message;
+ }
+
+ /**
+ * Set the body wrapping.
+ * @access private
+ * @return void
+ */
+ function SetWordWrap() {
+ if($this->WordWrap < 1)
+ return;
+
+ switch($this->message_type)
+ {
+ case "alt":
+ // fall through
+ case "alt_attachments":
+ $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
+ break;
+ default:
+ $this->Body = $this->WrapText($this->Body, $this->WordWrap);
+ break;
+ }
+ }
+
+ /**
+ * Assembles message header.
+ * @access private
+ * @return string
+ */
+ function CreateHeader() {
+ $result = "";
+
+ // Set the boundaries
+ $uniq_id = md5(uniqid(time()));
+ $this->boundary[1] = "b1_" . $uniq_id;
+ $this->boundary[2] = "b2_" . $uniq_id;
+
+ $result .= $this->HeaderLine("Date", $this->RFCDate());
+ if($this->Sender == "")
+ $result .= $this->HeaderLine("Return-Path", trim($this->From));
+ else
+ $result .= $this->HeaderLine("Return-Path", trim($this->Sender));
+
+ // To be created automatically by mail()
+ if($this->Mailer != "mail")
+ {
+ if(count($this->to) > 0)
+ $result .= $this->AddrAppend("To", $this->to);
+ else if (count($this->cc) == 0)
+ $result .= $this->HeaderLine("To", "undisclosed-recipients:;");
+ if(count($this->cc) > 0)
+ $result .= $this->AddrAppend("Cc", $this->cc);
+ }
+
+ $from = array();
+ $from[0][0] = trim($this->From);
+ $from[0][1] = $this->FromName;
+ $result .= $this->AddrAppend("From", $from);
+
+ // sendmail and mail() extract Bcc from the header before sending
+ if((($this->Mailer == "sendmail") || ($this->Mailer == "mail")) && (count($this->bcc) > 0))
+ $result .= $this->AddrAppend("Bcc", $this->bcc);
+
+ if(count($this->ReplyTo) > 0)
+ $result .= $this->AddrAppend("Reply-to", $this->ReplyTo);
+
+ // mail() sets the subject itself
+ if($this->Mailer != "mail")
+ $result .= $this->HeaderLine("Subject", $this->EncodeHeader(trim($this->Subject)));
+
+ $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
+ $result .= $this->HeaderLine("X-Priority", $this->Priority);
+
+ if($this->ConfirmReadingTo != "")
+ {
+ $result .= $this->HeaderLine("Disposition-Notification-To",
+ "<" . trim($this->ConfirmReadingTo) . ">");
+ }
+
+ // Add custom headers
+ for($index = 0; $index < count($this->CustomHeader); $index++)
+ {
+ $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]),
+ $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
+ }
+ $result .= $this->HeaderLine("MIME-Version", "1.0");
+
+ switch($this->message_type)
+ {
+ case "plain":
+ $result .= $this->HeaderLine("Content-Transfer-Encoding", $this->Encoding);
+ $result .= sprintf("Content-Type: %s; charset=\"%s\"",
+ $this->ContentType, $this->CharSet);
+ break;
+ case "attachments":
+ // fall through
+ case "alt_attachments":
+ if($this->InlineImageExists())
+ {
+ $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s",
+ "multipart/related", $this->LE, $this->LE,
+ $this->boundary[1], $this->LE);
+ }
+ else
+ {
+ $result .= $this->HeaderLine("Content-Type", "multipart/mixed;");
+ $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
+ }
+ break;
+ case "alt":
+ $result .= $this->HeaderLine("Content-Type", "multipart/alternative;");
+ $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
+ break;
+ }
+
+ if($this->Mailer != "mail")
+ $result .= $this->LE.$this->LE;
+
+ return $result;
+ }
+
+ /**
+ * Assembles the message body. Returns an empty string on failure.
+ * @access private
+ * @return string
+ */
+ function CreateBody() {
+ $result = "";
+
+ $this->SetWordWrap();
+
+ switch($this->message_type)
+ {
+ case "alt":
+ $result .= $this->GetBoundary($this->boundary[1], "",
+ "text/plain", "");
+ $result .= $this->EncodeString($this->AltBody, $this->Encoding);
+ $result .= $this->LE.$this->LE;
+ $result .= $this->GetBoundary($this->boundary[1], "",
+ "text/html", "");
+
+ $result .= $this->EncodeString($this->Body, $this->Encoding);
+ $result .= $this->LE.$this->LE;
+
+ $result .= $this->EndBoundary($this->boundary[1]);
+ break;
+ case "plain":
+ $result .= $this->EncodeString($this->Body, $this->Encoding);
+ break;
+ case "attachments":
+ $result .= $this->GetBoundary($this->boundary[1], "", "", "");
+ $result .= $this->EncodeString($this->Body, $this->Encoding);
+ $result .= $this->LE;
+
+ $result .= $this->AttachAll();
+ break;
+ case "alt_attachments":
+ $result .= sprintf("--%s%s", $this->boundary[1], $this->LE);
+ $result .= sprintf("Content-Type: %s;%s" .
+ "\tboundary=\"%s\"%s",
+ "multipart/alternative", $this->LE,
+ $this->boundary[2], $this->LE.$this->LE);
+
+ // Create text body
+ $result .= $this->GetBoundary($this->boundary[2], "",
+ "text/plain", "") . $this->LE;
+
+ $result .= $this->EncodeString($this->AltBody, $this->Encoding);
+ $result .= $this->LE.$this->LE;
+
+ // Create the HTML body
+ $result .= $this->GetBoundary($this->boundary[2], "",
+ "text/html", "") . $this->LE;
+
+ $result .= $this->EncodeString($this->Body, $this->Encoding);
+ $result .= $this->LE.$this->LE;
+
+ $result .= $this->EndBoundary($this->boundary[2]);
+
+ $result .= $this->AttachAll();
+ break;
+ }
+ if($this->IsError())
+ $result = "";
+
+ return $result;
+ }
+
+ /**
+ * Returns the start of a message boundary.
+ * @access private
+ */
+ function GetBoundary($boundary, $charSet, $contentType, $encoding) {
+ $result = "";
+ if($charSet == "") { $charSet = $this->CharSet; }
+ if($contentType == "") { $contentType = $this->ContentType; }
+ if($encoding == "") { $encoding = $this->Encoding; }
+
+ $result .= $this->TextLine("--" . $boundary);
+ $result .= sprintf("Content-Type: %s; charset = \"%s\"",
+ $contentType, $charSet);
+ $result .= $this->LE;
+ $result .= $this->HeaderLine("Content-Transfer-Encoding", $encoding);
+ $result .= $this->LE;
+
+ return $result;
+ }
+
+ /**
+ * Returns the end of a message boundary.
+ * @access private
+ */
+ function EndBoundary($boundary) {
+ return $this->LE . "--" . $boundary . "--" . $this->LE;
+ }
+
+ /**
+ * Sets the message type.
+ * @access private
+ * @return void
+ */
+ function SetMessageType() {
+ if(count($this->attachment) < 1 && strlen($this->AltBody) < 1)
+ $this->message_type = "plain";
+ else
+ {
+ if(count($this->attachment) > 0)
+ $this->message_type = "attachments";
+ if(strlen($this->AltBody) > 0 && count($this->attachment) < 1)
+ $this->message_type = "alt";
+ if(strlen($this->AltBody) > 0 && count($this->attachment) > 0)
+ $this->message_type = "alt_attachments";
+ }
+ }
+
+ /**
+ * Returns a formatted header line.
+ * @access private
+ * @return string
+ */
+ function HeaderLine($name, $value) {
+ return $name . ": " . $value . $this->LE;
+ }
+
+ /**
+ * Returns a formatted mail line.
+ * @access private
+ * @return string
+ */
+ function TextLine($value) {
+ return $value . $this->LE;
+ }
+
+ /////////////////////////////////////////////////
+ // ATTACHMENT METHODS
+ /////////////////////////////////////////////////
+
+ /**
+ * Adds an attachment from a path on the filesystem.
+ * Returns false if the file could not be found
+ * or accessed.
+ * @param string $path Path to the attachment.
+ * @param string $name Overrides the attachment name.
+ * @param string $encoding File encoding (see $Encoding).
+ * @param string $type File extension (MIME) type.
+ * @return bool
+ */
+ function AddAttachment($path, $name = "", $encoding = "base64",
+ $type = "application/octet-stream") {
+ if(!@is_file($path))
+ {
+ $this->SetError($this->Lang("file_access") . $path);
+ return false;
+ }
+
+ $filename = basename($path);
+ if($name == "")
+ $name = $filename;
+
+ $cur = count($this->attachment);
+ $this->attachment[$cur][0] = $path;
+ $this->attachment[$cur][1] = $filename;
+ $this->attachment[$cur][2] = $name;
+ $this->attachment[$cur][3] = $encoding;
+ $this->attachment[$cur][4] = $type;
+ $this->attachment[$cur][5] = false; // isStringAttachment
+ $this->attachment[$cur][6] = "attachment";
+ $this->attachment[$cur][7] = 0;
+
+ return true;
+ }
+
+ /**
+ * Attaches all fs, string, and binary attachments to the message.
+ * Returns an empty string on failure.
+ * @access private
+ * @return string
+ */
+ function AttachAll() {
+ // Return text of body
+ $mime = array();
+
+ // Add all attachments
+ for($i = 0; $i < count($this->attachment); $i++)
+ {
+ // Check for string attachment
+ $bString = $this->attachment[$i][5];
+ if ($bString)
+ $string = $this->attachment[$i][0];
+ else
+ $path = $this->attachment[$i][0];
+
+ $filename = $this->attachment[$i][1];
+ $name = $this->attachment[$i][2];
+ $encoding = $this->attachment[$i][3];
+ $type = $this->attachment[$i][4];
+ $disposition = $this->attachment[$i][6];
+ $cid = $this->attachment[$i][7];
+
+ $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
+ $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $name, $this->LE);
+ $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
+
+ if($disposition == "inline")
+ $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
+
+ $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s",
+ $disposition, $name, $this->LE.$this->LE);
+
+ // Encode as string attachment
+ if($bString)
+ {
+ $mime[] = $this->EncodeString($string, $encoding);
+ if($this->IsError()) { return ""; }
+ $mime[] = $this->LE.$this->LE;
+ }
+ else
+ {
+ $mime[] = $this->EncodeFile($path, $encoding);
+ if($this->IsError()) { return ""; }
+ $mime[] = $this->LE.$this->LE;
+ }
+ }
+
+ $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);
+
+ return join("", $mime);
+ }
+
+ /**
+ * Encodes attachment in requested format. Returns an
+ * empty string on failure.
+ * @access private
+ * @return string
+ */
+ function EncodeFile ($path, $encoding = "base64") {
+ if(!@$fd = fopen($path, "rb"))
+ {
+ $this->SetError($this->Lang("file_open") . $path);
+ return "";
+ }
+ $magic_quotes = get_magic_quotes_runtime();
+ set_magic_quotes_runtime(0);
+ $file_buffer = fread($fd, filesize($path));
+ $file_buffer = $this->EncodeString($file_buffer, $encoding);
+ fclose($fd);
+ set_magic_quotes_runtime($magic_quotes);
+
+ return $file_buffer;
+ }
+
+ /**
+ * Encodes string to requested format. Returns an
+ * empty string on failure.
+ * @access private
+ * @return string
+ */
+ function EncodeString ($str, $encoding = "base64") {
+ $encoded = "";
+ switch(strtolower($encoding)) {
+ case "base64":
+ // chunk_split is found in PHP >= 3.0.6
+ $encoded = chunk_split(base64_encode($str), 76, $this->LE);
+ break;
+ case "7bit":
+ case "8bit":
+ $encoded = $this->FixEOL($str);
+ if (substr($encoded, -(strlen($this->LE))) != $this->LE)
+ $encoded .= $this->LE;
+ break;
+ case "binary":
+ $encoded = $str;
+ break;
+ case "quoted-printable":
+ $encoded = $this->EncodeQP($str);
+ break;
+ default:
+ $this->SetError($this->Lang("encoding") . $encoding);
+ break;
+ }
+ return $encoded;
+ }
+
+ /**
+ * Encode a header string to best of Q, B, quoted or none.
+ * @access private
+ * @return string
+ */
+ function EncodeHeader ($str, $position = 'text') {
+ $x = 0;
+
+ switch (strtolower($position)) {
+ case 'phrase':
+ if (!preg_match('/[\200-\377]/', $str)) {
+ // Can't use addslashes as we don't know what value has magic_quotes_sybase.
+ $encoded = addcslashes($str, "\0..\37\177\\\"");
+
+ if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str))
+ return ($encoded);
+ else
+ return ("\"$encoded\"");
+ }
+ $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
+ break;
+ case 'comment':
+ $x = preg_match_all('/[()"]/', $str, $matches);
+ // Fall-through
+ case 'text':
+ default:
+ $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
+ break;
+ }
+
+ if ($x == 0)
+ return ($str);
+
+ $maxlen = 75 - 7 - strlen($this->CharSet);
+ // Try to select the encoding which should produce the shortest output
+ if (strlen($str)/3 < $x) {
+ $encoding = 'B';
+ $encoded = base64_encode($str);
+ $maxlen -= $maxlen % 4;
+ $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
+ } else {
+ $encoding = 'Q';
+ $encoded = $this->EncodeQ($str, $position);
+ $encoded = $this->WrapText($encoded, $maxlen, true);
+ $encoded = str_replace("=".$this->LE, "\n", trim($encoded));
+ }
+
+ $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
+ $encoded = trim(str_replace("\n", $this->LE, $encoded));
+
+ return $encoded;
+ }
+
+ /**
+ * Encode string to quoted-printable.
+ * @access private
+ * @return string
+ */
+ function EncodeQP ($str) {
+ $encoded = $this->FixEOL($str);
+ if (substr($encoded, -(strlen($this->LE))) != $this->LE)
+ $encoded .= $this->LE;
+
+ // Replace every high ascii, control and = characters
+ $encoded = preg_replace('/([\000-\010\013\014\016-\037\075\177-\377])/e',
+ "'='.sprintf('%02X', ord('\\1'))", $encoded);
+ // Replace every spaces and tabs when it's the last character on a line
+ $encoded = preg_replace("/([\011\040])".$this->LE."/e",
+ "'='.sprintf('%02X', ord('\\1')).'".$this->LE."'", $encoded);
+
+ // Maximum line length of 76 characters before CRLF (74 + space + '=')
+ $encoded = $this->WrapText($encoded, 74, true);
+
+ return $encoded;
+ }
+
+ /**
+ * Encode string to q encoding.
+ * @access private
+ * @return string
+ */
+ function EncodeQ ($str, $position = "text") {
+ // There should not be any EOL in the string
+ $encoded = preg_replace("[\r\n]", "", $str);
+
+ switch (strtolower($position)) {
+ case "phrase":
+ $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
+ break;
+ case "comment":
+ $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
+ case "text":
+ default:
+ // Replace every high ascii, control =, ? and _ characters
+ $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
+ "'='.sprintf('%02X', ord('\\1'))", $encoded);
+ break;
+ }
+
+ // Replace every spaces to _ (more readable than =20)
+ $encoded = str_replace(" ", "_", $encoded);
+
+ return $encoded;
+ }
+
+ /**
+ * Adds a string or binary attachment (non-filesystem) to the list.
+ * This method can be used to attach ascii or binary data,
+ * such as a BLOB record from a database.
+ * @param string $string String attachment data.
+ * @param string $filename Name of the attachment.
+ * @param string $encoding File encoding (see $Encoding).
+ * @param string $type File extension (MIME) type.
+ * @return void
+ */
+ function AddStringAttachment($string, $filename, $encoding = "base64",
+ $type = "application/octet-stream") {
+ // Append to $attachment array
+ $cur = count($this->attachment);
+ $this->attachment[$cur][0] = $string;
+ $this->attachment[$cur][1] = $filename;
+ $this->attachment[$cur][2] = $filename;
+ $this->attachment[$cur][3] = $encoding;
+ $this->attachment[$cur][4] = $type;
+ $this->attachment[$cur][5] = true; // isString
+ $this->attachment[$cur][6] = "attachment";
+ $this->attachment[$cur][7] = 0;
+ }
+
+ /**
+ * Adds an embedded attachment. This can include images, sounds, and
+ * just about any other document. Make sure to set the $type to an
+ * image type. For JPEG images use "image/jpeg" and for GIF images
+ * use "image/gif".
+ * @param string $path Path to the attachment.
+ * @param string $cid Content ID of the attachment. Use this to identify
+ * the Id for accessing the image in an HTML form.
+ * @param string $name Overrides the attachment name.
+ * @param string $encoding File encoding (see $Encoding).
+ * @param string $type File extension (MIME) type.
+ * @return bool
+ */
+ function AddEmbeddedImage($path, $cid, $name = "", $encoding = "base64",
+ $type = "application/octet-stream") {
+
+ if(!@is_file($path))
+ {
+ $this->SetError($this->Lang("file_access") . $path);
+ return false;
+ }
+
+ $filename = basename($path);
+ if($name == "")
+ $name = $filename;
+
+ // Append to $attachment array
+ $cur = count($this->attachment);
+ $this->attachment[$cur][0] = $path;
+ $this->attachment[$cur][1] = $filename;
+ $this->attachment[$cur][2] = $name;
+ $this->attachment[$cur][3] = $encoding;
+ $this->attachment[$cur][4] = $type;
+ $this->attachment[$cur][5] = false; // isStringAttachment
+ $this->attachment[$cur][6] = "inline";
+ $this->attachment[$cur][7] = $cid;
+
+ return true;
+ }
+
+ /**
+ * Returns true if an inline attachment is present.
+ * @access private
+ * @return bool
+ */
+ function InlineImageExists() {
+ $result = false;
+ for($i = 0; $i < count($this->attachment); $i++)
+ {
+ if($this->attachment[$i][6] == "inline")
+ {
+ $result = true;
+ break;
+ }
+ }
+
+ return $result;
+ }
+
+ /////////////////////////////////////////////////
+ // MESSAGE RESET METHODS
+ /////////////////////////////////////////////////
+
+ /**
+ * Clears all recipients assigned in the TO array. Returns void.
+ * @return void
+ */
+ function ClearAddresses() {
+ $this->to = array();
+ }
+
+ /**
+ * Clears all recipients assigned in the CC array. Returns void.
+ * @return void
+ */
+ function ClearCCs() {
+ $this->cc = array();
+ }
+
+ /**
+ * Clears all recipients assigned in the BCC array. Returns void.
+ * @return void
+ */
+ function ClearBCCs() {
+ $this->bcc = array();
+ }
+
+ /**
+ * Clears all recipients assigned in the ReplyTo array. Returns void.
+ * @return void
+ */
+ function ClearReplyTos() {
+ $this->ReplyTo = array();
+ }
+
+ /**
+ * Clears all recipients assigned in the TO, CC and BCC
+ * array. Returns void.
+ * @return void
+ */
+ function ClearAllRecipients() {
+ $this->to = array();
+ $this->cc = array();
+ $this->bcc = array();
+ }
+
+ /**
+ * Clears all previously set filesystem, string, and binary
+ * attachments. Returns void.
+ * @return void
+ */
+ function ClearAttachments() {
+ $this->attachment = array();
+ }
+
+ /**
+ * Clears all custom headers. Returns void.
+ * @return void
+ */
+ function ClearCustomHeaders() {
+ $this->CustomHeader = array();
+ }
+
+
+ /////////////////////////////////////////////////
+ // MISCELLANEOUS METHODS
+ /////////////////////////////////////////////////
+
+ /**
+ * Adds the error message to the error container.
+ * Returns void.
+ * @access private
+ * @return void
+ */
+ function SetError($msg) {
+ $this->error_count++;
+ $this->ErrorInfo = $msg;
+ }
+
+ /**
+ * Returns the proper RFC 822 formatted date.
+ * @access private
+ * @return string
+ */
+ function RFCDate() {
+ $tz = date("Z");
+ $tzs = ($tz < 0) ? "-" : "+";
+ $tz = abs($tz);
+ $tz = ($tz/3600)*100 + ($tz%3600)/60;
+ $result = sprintf("%s %s%04d", date("D, j M Y H:i:s"), $tzs, $tz);
+
+ return $result;
+ }
+
+ /**
+ * Returns the appropriate server variable. Should work with both
+ * PHP 4.1.0+ as well as older versions. Returns an empty string
+ * if nothing is found.
+ * @access private
+ * @return mixed
+ */
+ function ServerVar($varName) {
+ global $HTTP_SERVER_VARS;
+ global $HTTP_ENV_VARS;
+
+ if(!isset($_SERVER))
+ {
+ $_SERVER = $HTTP_SERVER_VARS;
+ if(!isset($_SERVER["REMOTE_ADDR"]))
+ $_SERVER = $HTTP_ENV_VARS; // must be Apache
+ }
+
+ if(isset($_SERVER[$varName]))
+ return $_SERVER[$varName];
+ else
+ return "";
+ }
+
+ /**
+ * Returns the server hostname or 'localhost.localdomain' if unknown.
+ * @access private
+ * @return string
+ */
+ function ServerHostname() {
+ if ($this->Hostname != "")
+ $result = $this->Hostname;
+ elseif ($this->ServerVar('SERVER_NAME') != "")
+ $result = $this->ServerVar('SERVER_NAME');
+ else
+ $result = "localhost.localdomain";
+
+ return $result;
+ }
+
+ /**
+ * Returns a message in the appropriate language.
+ * @access private
+ * @return string
+ */
+ function Lang($key) {
+ if(count($this->language) < 1)
+ $this->SetLanguage("en"); // set the default language
+
+ if(isset($this->language[$key]))
+ return $this->language[$key];
+ else
+ return "Language string failed to load: " . $key;
+ }
+
+ /**
+ * Returns true if an error occurred.
+ * @return bool
+ */
+ function IsError() {
+ return ($this->error_count > 0);
+ }
+
+ /**
+ * Changes every end of line from CR or LF to CRLF.
+ * @access private
+ * @return string
+ */
+ function FixEOL($str) {
+ $str = str_replace("\r\n", "\n", $str);
+ $str = str_replace("\r", "\n", $str);
+ $str = str_replace("\n", $this->LE, $str);
+ return $str;
+ }
+
+ /**
+ * Adds a custom header.
+ * @return void
+ */
+ function AddCustomHeader($custom_header) {
+ $this->CustomHeader[] = explode(":", $custom_header, 2);
+ }
+}
+
+?>
diff --git a/wp-includes/class-smtp.php b/wp-includes/class-smtp.php
index df3cfb5..9c18e83 100644
--- a/wp-includes/class-smtp.php
+++ b/wp-includes/class-smtp.php
@@ -1,1045 +1,1045 @@
-<?php
-////////////////////////////////////////////////////
-// SMTP - PHP SMTP class
-//
-// Version 1.02
-//
-// Define an SMTP class that can be used to connect
-// and communicate with any SMTP server. It implements
-// all the SMTP functions defined in RFC821 except TURN.
-//
-// Author: Chris Ryan
-//
-// License: LGPL, see LICENSE
-////////////////////////////////////////////////////
-
-/**
- * SMTP is rfc 821 compliant and implements all the rfc 821 SMTP
- * commands except TURN which will always return a not implemented
- * error. SMTP also provides some utility methods for sending mail
- * to an SMTP server.
- * @package PHPMailer
- * @author Chris Ryan
- */
-class SMTP
-{
- /**
- * SMTP server port
- * @var int
- */
- var $SMTP_PORT = 25;
-
- /**
- * SMTP reply line ending
- * @var string
- */
- var $CRLF = "\r\n";
-
- /**
- * Sets whether debugging is turned on
- * @var bool
- */
- var $do_debug; # the level of debug to perform
-
- /**#@+
- * @access private
- */
- var $smtp_conn; # the socket to the server
- var $error; # error if any on the last call
- var $helo_rply; # the reply the server sent to us for HELO
- /**#@-*/
-
- /**
- * Initialize the class so that the data is in a known state.
- * @access public
- * @return void
- */
- function SMTP() {
- $this->smtp_conn = 0;
- $this->error = null;
- $this->helo_rply = null;
-
- $this->do_debug = 0;
- }
-
- /*************************************************************
- * CONNECTION FUNCTIONS *
- ***********************************************************/
-
- /**
- * Connect to the server specified on the port specified.
- * If the port is not specified use the default SMTP_PORT.
- * If tval is specified then a connection will try and be
- * established with the server for that number of seconds.
- * If tval is not specified the default is 30 seconds to
- * try on the connection.
- *
- * SMTP CODE SUCCESS: 220
- * SMTP CODE FAILURE: 421
- * @access public
- * @return bool
- */
- function Connect($host,$port=0,$tval=30) {
- # set the error val to null so there is no confusion
- $this->error = null;
-
- # make sure we are __not__ connected
- if($this->connected()) {
- # ok we are connected! what should we do?
- # for now we will just give an error saying we
- # are already connected
- $this->error =
- array("error" => "Already connected to a server");
- return false;
- }
-
- if(empty($port)) {
- $port = $this->SMTP_PORT;
- }
-
- #connect to the smtp server
- $this->smtp_conn = fsockopen($host, # the host of the server
- $port, # the port to use
- $errno, # error number if any
- $errstr, # error message if any
- $tval); # give up after ? secs
- # verify we connected properly
- if(empty($this->smtp_conn)) {
- $this->error = array("error" => "Failed to connect to server",
- "errno" => $errno,
- "errstr" => $errstr);
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": $errstr ($errno)" . $this->CRLF;
- }
- return false;
- }
-
- # sometimes the SMTP server takes a little longer to respond
- # so we will give it a longer timeout for the first read
- // Windows still does not have support for this timeout function
- if(substr(PHP_OS, 0, 3) != "WIN")
- socket_set_timeout($this->smtp_conn, $tval, 0);
-
- # get any announcement stuff
- $announce = $this->get_lines();
-
- # set the timeout of any socket functions at 1/10 of a second
- //if(function_exists("socket_set_timeout"))
- // socket_set_timeout($this->smtp_conn, 0, 100000);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce;
- }
-
- return true;
- }
-
- /**
- * Performs SMTP authentication. Must be run after running the
- * Hello() method. Returns true if successfully authenticated.
- * @access public
- * @return bool
- */
- function Authenticate($username, $password) {
- // Start authentication
- fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($code != 334) {
- $this->error =
- array("error" => "AUTH not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- // Send encoded username
- fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($code != 334) {
- $this->error =
- array("error" => "Username not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- // Send encoded password
- fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($code != 235) {
- $this->error =
- array("error" => "Password not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- return true;
- }
-
- /**
- * Returns true if connected to a server otherwise false
- * @access private
- * @return bool
- */
- function Connected() {
- if(!empty($this->smtp_conn)) {
- $sock_status = socket_get_status($this->smtp_conn);
- if($sock_status["eof"]) {
- # hmm this is an odd situation... the socket is
- # valid but we aren't connected anymore
- if($this->do_debug >= 1) {
- echo "SMTP -> NOTICE:" . $this->CRLF .
- "EOF caught while checking if connected";
- }
- $this->Close();
- return false;
- }
- return true; # everything looks good
- }
- return false;
- }
-
- /**
- * Closes the socket and cleans up the state of the class.
- * It is not considered good to use this function without
- * first trying to use QUIT.
- * @access public
- * @return void
- */
- function Close() {
- $this->error = null; # so there is no confusion
- $this->helo_rply = null;
- if(!empty($this->smtp_conn)) {
- # close the connection and cleanup
- fclose($this->smtp_conn);
- $this->smtp_conn = 0;
- }
- }
-
-
- /***************************************************************
- * SMTP COMMANDS *
- *************************************************************/
-
- /**
- * Issues a data command and sends the msg_data to the server
- * finializing the mail transaction. $msg_data is the message
- * that is to be send with the headers. Each header needs to be
- * on a single line followed by a <CRLF> with the message headers
- * and the message body being seperated by and additional <CRLF>.
- *
- * Implements rfc 821: DATA <CRLF>
- *
- * SMTP CODE INTERMEDIATE: 354
- * [data]
- * <CRLF>.<CRLF>
- * SMTP CODE SUCCESS: 250
- * SMTP CODE FAILURE: 552,554,451,452
- * SMTP CODE FAILURE: 451,554
- * SMTP CODE ERROR : 500,501,503,421
- * @access public
- * @return bool
- */
- function Data($msg_data) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Data() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"DATA" . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 354) {
- $this->error =
- array("error" => "DATA command not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- # the server is ready to accept data!
- # according to rfc 821 we should not send more than 1000
- # including the CRLF
- # characters on a single line so we will break the data up
- # into lines by \r and/or \n then if needed we will break
- # each of those into smaller lines to fit within the limit.
- # in addition we will be looking for lines that start with
- # a period '.' and append and additional period '.' to that
- # line. NOTE: this does not count towards are limit.
-
- # normalize the line breaks so we know the explode works
- $msg_data = str_replace("\r\n","\n",$msg_data);
- $msg_data = str_replace("\r","\n",$msg_data);
- $lines = explode("\n",$msg_data);
-
- # we need to find a good way to determine is headers are
- # in the msg_data or if it is a straight msg body
- # currently I'm assuming rfc 822 definitions of msg headers
- # and if the first field of the first line (':' sperated)
- # does not contain a space then it _should_ be a header
- # and we can process all lines before a blank "" line as
- # headers.
- $field = substr($lines[0],0,strpos($lines[0],":"));
- $in_headers = false;
- if(!empty($field) && !strstr($field," ")) {
- $in_headers = true;
- }
-
- $max_line_length = 998; # used below; set here for ease in change
-
- while(list(,$line) = @each($lines)) {
- $lines_out = null;
- if($line == "" && $in_headers) {
- $in_headers = false;
- }
- # ok we need to break this line up into several
- # smaller lines
- while(strlen($line) > $max_line_length) {
- $pos = strrpos(substr($line,0,$max_line_length)," ");
-
- # Patch to fix DOS attack
- if(!$pos) {
- $pos = $max_line_length - 1;
- }
-
- $lines_out[] = substr($line,0,$pos);
- $line = substr($line,$pos + 1);
- # if we are processing headers we need to
- # add a LWSP-char to the front of the new line
- # rfc 822 on long msg headers
- if($in_headers) {
- $line = "\t" . $line;
- }
- }
- $lines_out[] = $line;
-
- # now send the lines to the server
- while(list(,$line_out) = @each($lines_out)) {
- if(strlen($line_out) > 0)
- {
- if(substr($line_out, 0, 1) == ".") {
- $line_out = "." . $line_out;
- }
- }
- fputs($this->smtp_conn,$line_out . $this->CRLF);
- }
- }
-
- # ok all the message data has been sent so lets get this
- # over with aleady
- fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "DATA not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
- }
-
- /**
- * Expand takes the name and asks the server to list all the
- * people who are members of the _list_. Expand will return
- * back and array of the result or false if an error occurs.
- * Each value in the array returned has the format of:
- * [ <full-name> <sp> ] <path>
- * The definition of <path> is defined in rfc 821
- *
- * Implements rfc 821: EXPN <SP> <string> <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE FAILURE: 550
- * SMTP CODE ERROR : 500,501,502,504,421
- * @access public
- * @return string array
- */
- function Expand($name) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Expand() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "EXPN not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- # parse the reply and place in our array to return to user
- $entries = explode($this->CRLF,$rply);
- while(list(,$l) = @each($entries)) {
- $list[] = substr($l,4);
- }
-
- return $list;
- }
-
- /**
- * Sends the HELO command to the smtp server.
- * This makes sure that we and the server are in
- * the same known state.
- *
- * Implements from rfc 821: HELO <SP> <domain> <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE ERROR : 500, 501, 504, 421
- * @access public
- * @return bool
- */
- function Hello($host="") {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Hello() without being connected");
- return false;
- }
-
- # if a hostname for the HELO wasn't specified determine
- # a suitable one to send
- if(empty($host)) {
- # we need to determine some sort of appopiate default
- # to send to the server
- $host = "localhost";
- }
-
- // Send extended hello first (RFC 2821)
- if(!$this->SendHello("EHLO", $host))
- {
- if(!$this->SendHello("HELO", $host))
- return false;
- }
-
- return true;
- }
-
- /**
- * Sends a HELO/EHLO command.
- * @access private
- * @return bool
- */
- function SendHello($hello, $host) {
- fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => $hello . " not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- $this->helo_rply = $rply;
-
- return true;
- }
-
- /**
- * Gets help information on the keyword specified. If the keyword
- * is not specified then returns generic help, ussually contianing
- * A list of keywords that help is available on. This function
- * returns the results back to the user. It is up to the user to
- * handle the returned data. If an error occurs then false is
- * returned with $this->error set appropiately.
- *
- * Implements rfc 821: HELP [ <SP> <string> ] <CRLF>
- *
- * SMTP CODE SUCCESS: 211,214
- * SMTP CODE ERROR : 500,501,502,504,421
- * @access public
- * @return string
- */
- function Help($keyword="") {
- $this->error = null; # to avoid confusion
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Help() without being connected");
- return false;
- }
-
- $extra = "";
- if(!empty($keyword)) {
- $extra = " " . $keyword;
- }
-
- fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 211 && $code != 214) {
- $this->error =
- array("error" => "HELP not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- return $rply;
- }
-
- /**
- * Starts a mail transaction from the email address specified in
- * $from. Returns true if successful or false otherwise. If True
- * the mail transaction is started and then one or more Recipient
- * commands may be called followed by a Data command.
- *
- * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE SUCCESS: 552,451,452
- * SMTP CODE SUCCESS: 500,501,421
- * @access public
- * @return bool
- */
- function Mail($from) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Mail() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "MAIL not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
- }
-
- /**
- * Sends the command NOOP to the SMTP server.
- *
- * Implements from rfc 821: NOOP <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE ERROR : 500, 421
- * @access public
- * @return bool
- */
- function Noop() {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Noop() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"NOOP" . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "NOOP not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
- }
-
- /**
- * Sends the quit command to the server and then closes the socket
- * if there is no error or the $close_on_error argument is true.
- *
- * Implements from rfc 821: QUIT <CRLF>
- *
- * SMTP CODE SUCCESS: 221
- * SMTP CODE ERROR : 500
- * @access public
- * @return bool
- */
- function Quit($close_on_error=true) {
- $this->error = null; # so there is no confusion
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Quit() without being connected");
- return false;
- }
-
- # send the quit command to the server
- fputs($this->smtp_conn,"quit" . $this->CRLF);
-
- # get any good-bye messages
- $byemsg = $this->get_lines();
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg;
- }
-
- $rval = true;
- $e = null;
-
- $code = substr($byemsg,0,3);
- if($code != 221) {
- # use e as a tmp var cause Close will overwrite $this->error
- $e = array("error" => "SMTP server rejected quit command",
- "smtp_code" => $code,
- "smtp_rply" => substr($byemsg,4));
- $rval = false;
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $e["error"] . ": " .
- $byemsg . $this->CRLF;
- }
- }
-
- if(empty($e) || $close_on_error) {
- $this->Close();
- }
-
- return $rval;
- }
-
- /**
- * Sends the command RCPT to the SMTP server with the TO: argument of $to.
- * Returns true if the recipient was accepted false if it was rejected.
- *
- * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>
- *
- * SMTP CODE SUCCESS: 250,251
- * SMTP CODE FAILURE: 550,551,552,553,450,451,452
- * SMTP CODE ERROR : 500,501,503,421
- * @access public
- * @return bool
- */
- function Recipient($to) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Recipient() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250 && $code != 251) {
- $this->error =
- array("error" => "RCPT not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
- }
-
- /**
- * Sends the RSET command to abort and transaction that is
- * currently in progress. Returns true if successful false
- * otherwise.
- *
- * Implements rfc 821: RSET <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE ERROR : 500,501,504,421
- * @access public
- * @return bool
- */
- function Reset() {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Reset() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"RSET" . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "RSET failed",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- return true;
- }
-
- /**
- * Starts a mail transaction from the email address specified in
- * $from. Returns true if successful or false otherwise. If True
- * the mail transaction is started and then one or more Recipient
- * commands may be called followed by a Data command. This command
- * will send the message to the users terminal if they are logged
- * in.
- *
- * Implements rfc 821: SEND <SP> FROM:<reverse-path> <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE SUCCESS: 552,451,452
- * SMTP CODE SUCCESS: 500,501,502,421
- * @access public
- * @return bool
- */
- function Send($from) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Send() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "SEND not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
- }
-
- /**
- * Starts a mail transaction from the email address specified in
- * $from. Returns true if successful or false otherwise. If True
- * the mail transaction is started and then one or more Recipient
- * commands may be called followed by a Data command. This command
- * will send the message to the users terminal if they are logged
- * in and send them an email.
- *
- * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE SUCCESS: 552,451,452
- * SMTP CODE SUCCESS: 500,501,502,421
- * @access public
- * @return bool
- */
- function SendAndMail($from) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called SendAndMail() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "SAML not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
- }
-
- /**
- * Starts a mail transaction from the email address specified in
- * $from. Returns true if successful or false otherwise. If True
- * the mail transaction is started and then one or more Recipient
- * commands may be called followed by a Data command. This command
- * will send the message to the users terminal if they are logged
- * in or mail it to them if they are not.
- *
- * Implements rfc 821: SOML <SP> FROM:<reverse-path> <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE SUCCESS: 552,451,452
- * SMTP CODE SUCCESS: 500,501,502,421
- * @access public
- * @return bool
- */
- function SendOrMail($from) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called SendOrMail() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "SOML not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
- }
-
- /**
- * This is an optional command for SMTP that this class does not
- * support. This method is here to make the RFC821 Definition
- * complete for this class and __may__ be implimented in the future
- *
- * Implements from rfc 821: TURN <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE FAILURE: 502
- * SMTP CODE ERROR : 500, 503
- * @access public
- * @return bool
- */
- function Turn() {
- $this->error = array("error" => "This method, TURN, of the SMTP ".
- "is not implemented");
- if($this->do_debug >= 1) {
- echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF;
- }
- return false;
- }
-
- /**
- * Verifies that the name is recognized by the server.
- * Returns false if the name could not be verified otherwise
- * the response from the server is returned.
- *
- * Implements rfc 821: VRFY <SP> <string> <CRLF>
- *
- * SMTP CODE SUCCESS: 250,251
- * SMTP CODE FAILURE: 550,551,553
- * SMTP CODE ERROR : 500,501,502,421
- * @access public
- * @return int
- */
- function Verify($name) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Verify() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250 && $code != 251) {
- $this->error =
- array("error" => "VRFY failed on name '$name'",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return $rply;
- }
-
- /*******************************************************************
- * INTERNAL FUNCTIONS *
- ******************************************************************/
-
- /**
- * Read in as many lines as possible
- * either before eof or socket timeout occurs on the operation.
- * With SMTP we can tell if we have more lines to read if the
- * 4th character is '-' symbol. If it is a space then we don't
- * need to read anything else.
- * @access private
- * @return string
- */
- function get_lines() {
- $data = "";
- while($str = fgets($this->smtp_conn,515)) {
- if($this->do_debug >= 4) {
- echo "SMTP -> get_lines(): \$data was \"$data\"" .
- $this->CRLF;
- echo "SMTP -> get_lines(): \$str is \"$str\"" .
- $this->CRLF;
- }
- $data .= $str;
- if($this->do_debug >= 4) {
- echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF;
- }
- # if the 4th character is a space then we are done reading
- # so just break the loop
- if(substr($str,3,1) == " ") { break; }
- }
- return $data;
- }
-
-}
-
-
- ?>
+<?php
+////////////////////////////////////////////////////
+// SMTP - PHP SMTP class
+//
+// Version 1.02
+//
+// Define an SMTP class that can be used to connect
+// and communicate with any SMTP server. It implements
+// all the SMTP functions defined in RFC821 except TURN.
+//
+// Author: Chris Ryan
+//
+// License: LGPL, see LICENSE
+////////////////////////////////////////////////////
+
+/**
+ * SMTP is rfc 821 compliant and implements all the rfc 821 SMTP
+ * commands except TURN which will always return a not implemented
+ * error. SMTP also provides some utility methods for sending mail
+ * to an SMTP server.
+ * @package PHPMailer
+ * @author Chris Ryan
+ */
+class SMTP
+{
+ /**
+ * SMTP server port
+ * @var int
+ */
+ var $SMTP_PORT = 25;
+
+ /**
+ * SMTP reply line ending
+ * @var string
+ */
+ var $CRLF = "\r\n";
+
+ /**
+ * Sets whether debugging is turned on
+ * @var bool
+ */
+ var $do_debug; # the level of debug to perform
+
+ /**#@+
+ * @access private
+ */
+ var $smtp_conn; # the socket to the server
+ var $error; # error if any on the last call
+ var $helo_rply; # the reply the server sent to us for HELO
+ /**#@-*/
+
+ /**
+ * Initialize the class so that the data is in a known state.
+ * @access public
+ * @return void
+ */
+ function SMTP() {
+ $this->smtp_conn = 0;
+ $this->error = null;
+ $this->helo_rply = null;
+
+ $this->do_debug = 0;
+ }
+
+ /*************************************************************
+ * CONNECTION FUNCTIONS *
+ ***********************************************************/
+
+ /**
+ * Connect to the server specified on the port specified.
+ * If the port is not specified use the default SMTP_PORT.
+ * If tval is specified then a connection will try and be
+ * established with the server for that number of seconds.
+ * If tval is not specified the default is 30 seconds to
+ * try on the connection.
+ *
+ * SMTP CODE SUCCESS: 220
+ * SMTP CODE FAILURE: 421
+ * @access public
+ * @return bool
+ */
+ function Connect($host,$port=0,$tval=30) {
+ # set the error val to null so there is no confusion
+ $this->error = null;
+
+ # make sure we are __not__ connected
+ if($this->connected()) {
+ # ok we are connected! what should we do?
+ # for now we will just give an error saying we
+ # are already connected
+ $this->error =
+ array("error" => "Already connected to a server");
+ return false;
+ }
+
+ if(empty($port)) {
+ $port = $this->SMTP_PORT;
+ }
+
+ #connect to the smtp server
+ $this->smtp_conn = fsockopen($host, # the host of the server
+ $port, # the port to use
+ $errno, # error number if any
+ $errstr, # error message if any
+ $tval); # give up after ? secs
+ # verify we connected properly
+ if(empty($this->smtp_conn)) {
+ $this->error = array("error" => "Failed to connect to server",
+ "errno" => $errno,
+ "errstr" => $errstr);
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": $errstr ($errno)" . $this->CRLF;
+ }
+ return false;
+ }
+
+ # sometimes the SMTP server takes a little longer to respond
+ # so we will give it a longer timeout for the first read
+ // Windows still does not have support for this timeout function
+ if(substr(PHP_OS, 0, 3) != "WIN")
+ socket_set_timeout($this->smtp_conn, $tval, 0);
+
+ # get any announcement stuff
+ $announce = $this->get_lines();
+
+ # set the timeout of any socket functions at 1/10 of a second
+ //if(function_exists("socket_set_timeout"))
+ // socket_set_timeout($this->smtp_conn, 0, 100000);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce;
+ }
+
+ return true;
+ }
+
+ /**
+ * Performs SMTP authentication. Must be run after running the
+ * Hello() method. Returns true if successfully authenticated.
+ * @access public
+ * @return bool
+ */
+ function Authenticate($username, $password) {
+ // Start authentication
+ fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($code != 334) {
+ $this->error =
+ array("error" => "AUTH not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ // Send encoded username
+ fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($code != 334) {
+ $this->error =
+ array("error" => "Username not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ // Send encoded password
+ fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($code != 235) {
+ $this->error =
+ array("error" => "Password not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Returns true if connected to a server otherwise false
+ * @access private
+ * @return bool
+ */
+ function Connected() {
+ if(!empty($this->smtp_conn)) {
+ $sock_status = socket_get_status($this->smtp_conn);
+ if($sock_status["eof"]) {
+ # hmm this is an odd situation... the socket is
+ # valid but we aren't connected anymore
+ if($this->do_debug >= 1) {
+ echo "SMTP -> NOTICE:" . $this->CRLF .
+ "EOF caught while checking if connected";
+ }
+ $this->Close();
+ return false;
+ }
+ return true; # everything looks good
+ }
+ return false;
+ }
+
+ /**
+ * Closes the socket and cleans up the state of the class.
+ * It is not considered good to use this function without
+ * first trying to use QUIT.
+ * @access public
+ * @return void
+ */
+ function Close() {
+ $this->error = null; # so there is no confusion
+ $this->helo_rply = null;
+ if(!empty($this->smtp_conn)) {
+ # close the connection and cleanup
+ fclose($this->smtp_conn);
+ $this->smtp_conn = 0;
+ }
+ }
+
+
+ /***************************************************************
+ * SMTP COMMANDS *
+ *************************************************************/
+
+ /**
+ * Issues a data command and sends the msg_data to the server
+ * finializing the mail transaction. $msg_data is the message
+ * that is to be send with the headers. Each header needs to be
+ * on a single line followed by a <CRLF> with the message headers
+ * and the message body being seperated by and additional <CRLF>.
+ *
+ * Implements rfc 821: DATA <CRLF>
+ *
+ * SMTP CODE INTERMEDIATE: 354
+ * [data]
+ * <CRLF>.<CRLF>
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE FAILURE: 552,554,451,452
+ * SMTP CODE FAILURE: 451,554
+ * SMTP CODE ERROR : 500,501,503,421
+ * @access public
+ * @return bool
+ */
+ function Data($msg_data) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Data() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"DATA" . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 354) {
+ $this->error =
+ array("error" => "DATA command not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ # the server is ready to accept data!
+ # according to rfc 821 we should not send more than 1000
+ # including the CRLF
+ # characters on a single line so we will break the data up
+ # into lines by \r and/or \n then if needed we will break
+ # each of those into smaller lines to fit within the limit.
+ # in addition we will be looking for lines that start with
+ # a period '.' and append and additional period '.' to that
+ # line. NOTE: this does not count towards are limit.
+
+ # normalize the line breaks so we know the explode works
+ $msg_data = str_replace("\r\n","\n",$msg_data);
+ $msg_data = str_replace("\r","\n",$msg_data);
+ $lines = explode("\n",$msg_data);
+
+ # we need to find a good way to determine is headers are
+ # in the msg_data or if it is a straight msg body
+ # currently I'm assuming rfc 822 definitions of msg headers
+ # and if the first field of the first line (':' sperated)
+ # does not contain a space then it _should_ be a header
+ # and we can process all lines before a blank "" line as
+ # headers.
+ $field = substr($lines[0],0,strpos($lines[0],":"));
+ $in_headers = false;
+ if(!empty($field) && !strstr($field," ")) {
+ $in_headers = true;
+ }
+
+ $max_line_length = 998; # used below; set here for ease in change
+
+ while(list(,$line) = @each($lines)) {
+ $lines_out = null;
+ if($line == "" && $in_headers) {
+ $in_headers = false;
+ }
+ # ok we need to break this line up into several
+ # smaller lines
+ while(strlen($line) > $max_line_length) {
+ $pos = strrpos(substr($line,0,$max_line_length)," ");
+
+ # Patch to fix DOS attack
+ if(!$pos) {
+ $pos = $max_line_length - 1;
+ }
+
+ $lines_out[] = substr($line,0,$pos);
+ $line = substr($line,$pos + 1);
+ # if we are processing headers we need to
+ # add a LWSP-char to the front of the new line
+ # rfc 822 on long msg headers
+ if($in_headers) {
+ $line = "\t" . $line;
+ }
+ }
+ $lines_out[] = $line;
+
+ # now send the lines to the server
+ while(list(,$line_out) = @each($lines_out)) {
+ if(strlen($line_out) > 0)
+ {
+ if(substr($line_out, 0, 1) == ".") {
+ $line_out = "." . $line_out;
+ }
+ }
+ fputs($this->smtp_conn,$line_out . $this->CRLF);
+ }
+ }
+
+ # ok all the message data has been sent so lets get this
+ # over with aleady
+ fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "DATA not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Expand takes the name and asks the server to list all the
+ * people who are members of the _list_. Expand will return
+ * back and array of the result or false if an error occurs.
+ * Each value in the array returned has the format of:
+ * [ <full-name> <sp> ] <path>
+ * The definition of <path> is defined in rfc 821
+ *
+ * Implements rfc 821: EXPN <SP> <string> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE FAILURE: 550
+ * SMTP CODE ERROR : 500,501,502,504,421
+ * @access public
+ * @return string array
+ */
+ function Expand($name) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Expand() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "EXPN not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ # parse the reply and place in our array to return to user
+ $entries = explode($this->CRLF,$rply);
+ while(list(,$l) = @each($entries)) {
+ $list[] = substr($l,4);
+ }
+
+ return $list;
+ }
+
+ /**
+ * Sends the HELO command to the smtp server.
+ * This makes sure that we and the server are in
+ * the same known state.
+ *
+ * Implements from rfc 821: HELO <SP> <domain> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE ERROR : 500, 501, 504, 421
+ * @access public
+ * @return bool
+ */
+ function Hello($host="") {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Hello() without being connected");
+ return false;
+ }
+
+ # if a hostname for the HELO wasn't specified determine
+ # a suitable one to send
+ if(empty($host)) {
+ # we need to determine some sort of appopiate default
+ # to send to the server
+ $host = "localhost";
+ }
+
+ // Send extended hello first (RFC 2821)
+ if(!$this->SendHello("EHLO", $host))
+ {
+ if(!$this->SendHello("HELO", $host))
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Sends a HELO/EHLO command.
+ * @access private
+ * @return bool
+ */
+ function SendHello($hello, $host) {
+ fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => $hello . " not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ $this->helo_rply = $rply;
+
+ return true;
+ }
+
+ /**
+ * Gets help information on the keyword specified. If the keyword
+ * is not specified then returns generic help, ussually contianing
+ * A list of keywords that help is available on. This function
+ * returns the results back to the user. It is up to the user to
+ * handle the returned data. If an error occurs then false is
+ * returned with $this->error set appropiately.
+ *
+ * Implements rfc 821: HELP [ <SP> <string> ] <CRLF>
+ *
+ * SMTP CODE SUCCESS: 211,214
+ * SMTP CODE ERROR : 500,501,502,504,421
+ * @access public
+ * @return string
+ */
+ function Help($keyword="") {
+ $this->error = null; # to avoid confusion
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Help() without being connected");
+ return false;
+ }
+
+ $extra = "";
+ if(!empty($keyword)) {
+ $extra = " " . $keyword;
+ }
+
+ fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 211 && $code != 214) {
+ $this->error =
+ array("error" => "HELP not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ return $rply;
+ }
+
+ /**
+ * Starts a mail transaction from the email address specified in
+ * $from. Returns true if successful or false otherwise. If True
+ * the mail transaction is started and then one or more Recipient
+ * commands may be called followed by a Data command.
+ *
+ * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE SUCCESS: 552,451,452
+ * SMTP CODE SUCCESS: 500,501,421
+ * @access public
+ * @return bool
+ */
+ function Mail($from) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Mail() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "MAIL not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Sends the command NOOP to the SMTP server.
+ *
+ * Implements from rfc 821: NOOP <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE ERROR : 500, 421
+ * @access public
+ * @return bool
+ */
+ function Noop() {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Noop() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"NOOP" . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "NOOP not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Sends the quit command to the server and then closes the socket
+ * if there is no error or the $close_on_error argument is true.
+ *
+ * Implements from rfc 821: QUIT <CRLF>
+ *
+ * SMTP CODE SUCCESS: 221
+ * SMTP CODE ERROR : 500
+ * @access public
+ * @return bool
+ */
+ function Quit($close_on_error=true) {
+ $this->error = null; # so there is no confusion
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Quit() without being connected");
+ return false;
+ }
+
+ # send the quit command to the server
+ fputs($this->smtp_conn,"quit" . $this->CRLF);
+
+ # get any good-bye messages
+ $byemsg = $this->get_lines();
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg;
+ }
+
+ $rval = true;
+ $e = null;
+
+ $code = substr($byemsg,0,3);
+ if($code != 221) {
+ # use e as a tmp var cause Close will overwrite $this->error
+ $e = array("error" => "SMTP server rejected quit command",
+ "smtp_code" => $code,
+ "smtp_rply" => substr($byemsg,4));
+ $rval = false;
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $e["error"] . ": " .
+ $byemsg . $this->CRLF;
+ }
+ }
+
+ if(empty($e) || $close_on_error) {
+ $this->Close();
+ }
+
+ return $rval;
+ }
+
+ /**
+ * Sends the command RCPT to the SMTP server with the TO: argument of $to.
+ * Returns true if the recipient was accepted false if it was rejected.
+ *
+ * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250,251
+ * SMTP CODE FAILURE: 550,551,552,553,450,451,452
+ * SMTP CODE ERROR : 500,501,503,421
+ * @access public
+ * @return bool
+ */
+ function Recipient($to) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Recipient() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250 && $code != 251) {
+ $this->error =
+ array("error" => "RCPT not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Sends the RSET command to abort and transaction that is
+ * currently in progress. Returns true if successful false
+ * otherwise.
+ *
+ * Implements rfc 821: RSET <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE ERROR : 500,501,504,421
+ * @access public
+ * @return bool
+ */
+ function Reset() {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Reset() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"RSET" . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "RSET failed",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Starts a mail transaction from the email address specified in
+ * $from. Returns true if successful or false otherwise. If True
+ * the mail transaction is started and then one or more Recipient
+ * commands may be called followed by a Data command. This command
+ * will send the message to the users terminal if they are logged
+ * in.
+ *
+ * Implements rfc 821: SEND <SP> FROM:<reverse-path> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE SUCCESS: 552,451,452
+ * SMTP CODE SUCCESS: 500,501,502,421
+ * @access public
+ * @return bool
+ */
+ function Send($from) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Send() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "SEND not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Starts a mail transaction from the email address specified in
+ * $from. Returns true if successful or false otherwise. If True
+ * the mail transaction is started and then one or more Recipient
+ * commands may be called followed by a Data command. This command
+ * will send the message to the users terminal if they are logged
+ * in and send them an email.
+ *
+ * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE SUCCESS: 552,451,452
+ * SMTP CODE SUCCESS: 500,501,502,421
+ * @access public
+ * @return bool
+ */
+ function SendAndMail($from) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called SendAndMail() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "SAML not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Starts a mail transaction from the email address specified in
+ * $from. Returns true if successful or false otherwise. If True
+ * the mail transaction is started and then one or more Recipient
+ * commands may be called followed by a Data command. This command
+ * will send the message to the users terminal if they are logged
+ * in or mail it to them if they are not.
+ *
+ * Implements rfc 821: SOML <SP> FROM:<reverse-path> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE SUCCESS: 552,451,452
+ * SMTP CODE SUCCESS: 500,501,502,421
+ * @access public
+ * @return bool
+ */
+ function SendOrMail($from) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called SendOrMail() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "SOML not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * This is an optional command for SMTP that this class does not
+ * support. This method is here to make the RFC821 Definition
+ * complete for this class and __may__ be implimented in the future
+ *
+ * Implements from rfc 821: TURN <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE FAILURE: 502
+ * SMTP CODE ERROR : 500, 503
+ * @access public
+ * @return bool
+ */
+ function Turn() {
+ $this->error = array("error" => "This method, TURN, of the SMTP ".
+ "is not implemented");
+ if($this->do_debug >= 1) {
+ echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF;
+ }
+ return false;
+ }
+
+ /**
+ * Verifies that the name is recognized by the server.
+ * Returns false if the name could not be verified otherwise
+ * the response from the server is returned.
+ *
+ * Implements rfc 821: VRFY <SP> <string> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250,251
+ * SMTP CODE FAILURE: 550,551,553
+ * SMTP CODE ERROR : 500,501,502,421
+ * @access public
+ * @return int
+ */
+ function Verify($name) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Verify() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250 && $code != 251) {
+ $this->error =
+ array("error" => "VRFY failed on name '$name'",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return $rply;
+ }
+
+ /*******************************************************************
+ * INTERNAL FUNCTIONS *
+ ******************************************************************/
+
+ /**
+ * Read in as many lines as possible
+ * either before eof or socket timeout occurs on the operation.
+ * With SMTP we can tell if we have more lines to read if the
+ * 4th character is '-' symbol. If it is a space then we don't
+ * need to read anything else.
+ * @access private
+ * @return string
+ */
+ function get_lines() {
+ $data = "";
+ while($str = fgets($this->smtp_conn,515)) {
+ if($this->do_debug >= 4) {
+ echo "SMTP -> get_lines(): \$data was \"$data\"" .
+ $this->CRLF;
+ echo "SMTP -> get_lines(): \$str is \"$str\"" .
+ $this->CRLF;
+ }
+ $data .= $str;
+ if($this->do_debug >= 4) {
+ echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF;
+ }
+ # if the 4th character is a space then we are done reading
+ # so just break the loop
+ if(substr($str,3,1) == " ") { break; }
+ }
+ return $data;
+ }
+
+}
+
+
+ ?>
diff --git a/wp-includes/class-snoopy.php b/wp-includes/class-snoopy.php
index 9bf56b3..5e88787 100644
--- a/wp-includes/class-snoopy.php
+++ b/wp-includes/class-snoopy.php
@@ -796,7 +796,7 @@ class Snoopy
$headers .= "User-Agent: ".$this->agent."\r\n";
if(!empty($this->host) && !isset($this->rawheaders['Host'])) {
$headers .= "Host: ".$this->host;
- if(!empty($this->port))
+ if(!empty($this->port) && $this->port != 80)
$headers .= ":".$this->port;
$headers .= "\r\n";
}
diff --git a/wp-includes/classes.php b/wp-includes/classes.php
index 6bdfb2e..3ca1926 100644
--- a/wp-includes/classes.php
+++ b/wp-includes/classes.php
@@ -514,7 +514,7 @@ class Walker_Page extends Walker {
elseif ( $_current_page && $page->ID == $_current_page->post_parent )
$css_class .= ' current_page_parent';
- $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" title="' . attribute_escape($page->post_title) . '">' . $page->post_title . '</a>';
+ $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" title="' . attribute_escape(apply_filters('the_title', $page->post_title)) . '">' . apply_filters('the_title', $page->post_title) . '</a>';
if ( !empty($show_date) ) {
if ( 'modified' == $show_date )
@@ -687,16 +687,14 @@ class WP_Ajax_Response {
// a WP_Error object can be passed in 'id' or 'data'
function add( $args = '' ) {
- if ( is_array($args) )
- $r = &$args;
- else
- parse_str($args, $r);
-
- $defaults = array('what' => 'object', 'action' => false, 'id' => '0', 'old_id' => false,
- 'data' => '', 'supplemental' => array());
-
- $r = array_merge($defaults, $r);
- extract($r);
+ $defaults = array(
+ 'what' => 'object', 'action' => false,
+ 'id' => '0', 'old_id' => false,
+ 'data' => '', 'supplemental' => array()
+ );
+
+ $r = wp_parse_args( $args, $defaults );
+ extract( $r );
if ( is_wp_error($id) ) {
$data = $id;
diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php
index 0c16240..ed41bb6 100644
--- a/wp-includes/comment-template.php
+++ b/wp-includes/comment-template.php
@@ -228,7 +228,7 @@ function get_trackback_url() {
if ( '' != get_option('permalink_structure') )
$tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback');
- return $tb_url;
+ return apply_filters('trackback_url', $tb_url);
}
function trackback_url( $display = true ) {
if ( $display)
@@ -288,7 +288,9 @@ function comments_template( $file = '/comments.php' ) {
extract($commenter);
// TODO: Use API instead of SELECTs.
- if ( empty($comment_author) ) {
+ if ( $user_ID) {
+ $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND (comment_approved = '1' OR ( user_id = '$user_ID' AND comment_approved = '0' ) ) ORDER BY comment_date");
+ } else if ( empty($comment_author) ) {
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' ORDER BY comment_date");
} else {
$author_db = $wpdb->escape($comment_author);
@@ -331,7 +333,7 @@ function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Com
$number = get_comments_number($id);
if ( 0 == $number && 'closed' == $post->comment_status && 'closed' == $post->ping_status ) {
- echo $none;
+ echo '<span' . ((!empty($CSSclass)) ? ' class="' . $CSSclass . '"' : '') . '>' . $none . '</span>';
return;
}
diff --git a/wp-includes/comment.php b/wp-includes/comment.php
index 6da2264..b1aee83 100644
--- a/wp-includes/comment.php
+++ b/wp-includes/comment.php
@@ -73,15 +73,20 @@ function get_approved_comments($post_id) {
function &get_comment(&$comment, $output = OBJECT) {
global $comment_cache, $wpdb;
- if ( empty($comment) )
- return null;
-
- if ( is_object($comment) ) {
+ if ( empty($comment) ) {
+ if ( isset($GLOBALS['comment']) )
+ $_comment = & $GLOBALS['comment'];
+ else
+ $_comment = null;
+ } elseif ( is_object($comment) ) {
if ( !isset($comment_cache[$comment->comment_ID]) )
$comment_cache[$comment->comment_ID] = &$comment;
$_comment = & $comment_cache[$comment->comment_ID];
} else {
- if ( !isset($comment_cache[$comment]) ) {
+ $comment = (int) $comment;
+ if ( isset($GLOBALS['comment']) && ($GLOBALS['comment']->comment_ID == $comment) ) {
+ $_comment = & $GLOBALS['comment'];
+ } elseif ( !isset($comment_cache[$comment]) ) {
$_comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment' LIMIT 1");
$comment_cache[$comment->comment_ID] = & $_comment;
} else {
@@ -671,9 +676,7 @@ function pingback($content, $post_ID) {
include_once(ABSPATH . WPINC . '/class-IXR.php');
// original code by Mort (http://mort.mine.nu:8080)
- $log = debug_fopen(ABSPATH . '/pingback.log', 'a');
$post_links = array();
- debug_fwrite($log, 'BEGIN ' . date('YmdHis', time()) . "\n");
$pung = get_pung($post_ID);
@@ -689,10 +692,6 @@ function pingback($content, $post_ID) {
// http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php
preg_match_all("{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp);
- // Debug
- debug_fwrite($log, 'Post contents:');
- debug_fwrite($log, $content."\n");
-
// Step 2.
// Walking thru the links array
// first we get rid of links pointing to sites, not to specific files
@@ -716,16 +715,12 @@ function pingback($content, $post_ID) {
do_action_ref_array('pre_ping', array(&$post_links, &$pung));
foreach ( (array) $post_links as $pagelinkedto ) {
- debug_fwrite($log, "Processing -- $pagelinkedto\n");
$pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048);
if ( $pingback_server_url ) {
@ set_time_limit( 60 );
// Now, the RPC call
- debug_fwrite($log, "Page Linked To: $pagelinkedto \n");
- debug_fwrite($log, 'Page Linked From: ');
$pagelinkedfrom = get_permalink($post_ID);
- debug_fwrite($log, $pagelinkedfrom."\n");
// using a timeout of 3 seconds should be enough to cover slow servers
$client = new IXR_Client($pingback_server_url);
@@ -737,13 +732,8 @@ function pingback($content, $post_ID) {
if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto ) )
add_ping( $post_ID, $pagelinkedto );
- else
- debug_fwrite($log, "Error.\n Fault code: ".$client->getErrorCode()." : ".$client->getErrorMessage()."\n");
}
}
-
- debug_fwrite($log, "\nEND: ".time()."\n****************************\n");
- debug_fclose($log);
}
@@ -780,16 +770,6 @@ function trackback($trackback_url, $title, $excerpt, $ID) {
$trackback_url['port'] = 80;
$fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4);
@fputs($fs, $http_request);
-/*
- $debug_file = 'trackback.log';
- $fp = fopen($debug_file, 'a');
- fwrite($fp, "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n");
- while(!@feof($fs)) {
- fwrite($fp, @fgets($fs, 4096));
- }
- fwrite($fp, "\n\n");
- fclose($fp);
-*/
@fclose($fs);
$tb_url = addslashes( $tb_url );
@@ -814,4 +794,4 @@ function weblog_ping($server = '', $path = '') {
$client->query('weblogUpdates.ping', get_option('blogname'), $home);
}
-?>
+?> \ No newline at end of file
diff --git a/wp-includes/compat.php b/wp-includes/compat.php
index 997307f..e68ec2a 100644
--- a/wp-includes/compat.php
+++ b/wp-includes/compat.php
@@ -118,4 +118,11 @@ if ( !function_exists('_') ) {
}
}
+// Added in PHP 5.0
+if (!function_exists('stripos')) {
+ function stripos($haystack, $needle, $offset = 0) {
+ return strpos(strtolower($haystack), strtolower($needle), $offset);
+ }
+}
+
?>
diff --git a/wp-includes/cron.php b/wp-includes/cron.php
index e9a6462..f81c6ad 100644
--- a/wp-includes/cron.php
+++ b/wp-includes/cron.php
@@ -97,7 +97,7 @@ function spawn_cron() {
if ( $argyle )
fputs( $argyle,
- "GET {$parts['path']}?check=" . md5(DB_PASS . '187425') . " HTTP/1.0\r\n"
+ "GET {$parts['path']}?check=" . wp_hash('187425') . " HTTP/1.0\r\n"
. "Host: {$_SERVER['HTTP_HOST']}\r\n\r\n"
);
}
diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php
index cda3cc9..0861361 100644
--- a/wp-includes/default-filters.php
+++ b/wp-includes/default-filters.php
@@ -45,7 +45,7 @@ add_filter('comment_flood_filter', 'wp_throttle_comment_flood', 10, 3);
add_filter('comment_url', 'clean_url');
add_filter('comment_text', 'convert_chars');
-add_filter('comment_text', 'make_clickable');
+add_filter('comment_text', 'make_clickable', 9);
add_filter('comment_text', 'force_balance_tags', 25);
add_filter('comment_text', 'wpautop', 30);
add_filter('comment_text', 'convert_smilies', 20);
@@ -173,4 +173,7 @@ add_action('sanitize_comment_cookies', 'sanitize_comment_cookies');
add_action('admin_print_scripts', 'wp_print_scripts', 20);
add_action('mce_options', '_mce_set_direction');
add_action('init', 'smilies_init', 5);
-?>
+add_action( 'plugins_loaded', 'wp_maybe_load_widgets', 0 );
+add_action( 'shutdown', 'wp_ob_end_flush_all', 1);
+
+?> \ No newline at end of file
diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php
index b72c07f..0caba44 100644
--- a/wp-includes/deprecated.php
+++ b/wp-includes/deprecated.php
@@ -427,10 +427,7 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde
}
function wp_list_cats($args = '') {
- if ( is_array($args) )
- $r = &$args;
- else
- parse_str($args, $r);
+ $r = wp_parse_args( $args );
// Map to new names.
if ( isset($r['optionall']) && isset($r['all']))
diff --git a/wp-includes/feed-atom-comments.php b/wp-includes/feed-atom-comments.php
index 7efb3f9..f7aaba8 100644
--- a/wp-includes/feed-atom-comments.php
+++ b/wp-includes/feed-atom-comments.php
@@ -20,7 +20,7 @@ echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '" ?' . '>'
<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastcommentmodified('GMT')); ?></updated>
<generator uri="http://wordpress.org/" version="<?php bloginfo('version'); ?>">WordPress</generator>
- <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" content="<?php bloginfo_rss('home'); ?>" />
+ <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php bloginfo_rss('home'); ?>" />
<link rel="self" type="application/atom+xml" href="<?php bloginfo_rss('comments_atom_url'); ?>" />
<id><?php bloginfo_rss('comments_atom_url'); ?></id>
@@ -49,8 +49,8 @@ if ( have_comments() ) : while ( have_comments() ) : the_comment();
</author>
<id><?php comment_link(); ?></id>
- <updated><?php echo mysql2date('D, d M Y H:i:s +0000', get_comment_time('Y-m-d H:i:s', true), false); ?></updated>
- <published><?php echo mysql2date('D, d M Y H:i:s +0000', get_comment_time('Y-m-d H:i:s', true), false); ?></published>
+ <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_comment_time('Y-m-d H:i:s', true), false); ?></updated>
+ <published><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_comment_time('Y-m-d H:i:s', true), false); ?></published>
<?php if (!empty($comment_post->post_password) && $_COOKIE['wp-postpass'] != $comment_post->post_password) : ?>
<content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php echo get_the_password_form(); ?>]]></content>
<?php else : // post pass ?>
diff --git a/wp-includes/feed-atom.php b/wp-includes/feed-atom.php
index 8a52d1c..2eb7c2f 100644
--- a/wp-includes/feed-atom.php
+++ b/wp-includes/feed-atom.php
@@ -11,7 +11,7 @@ $more = 1;
xml:base="<?php bloginfo_rss('home') ?>/wp-atom.php"
<?php do_action('atom_ns'); ?>
>
- <title type="text"><?php bloginfo_rss('name') ?></title>
+ <title type="text"><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
<subtitle type="text"><?php bloginfo_rss("description") ?></subtitle>
<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT')); ?></updated>
diff --git a/wp-includes/feed-rdf.php b/wp-includes/feed-rdf.php
index 80b1d6d..d1ac458 100644
--- a/wp-includes/feed-rdf.php
+++ b/wp-includes/feed-rdf.php
@@ -15,7 +15,7 @@ $more = 1;
<?php do_action('rdf_ns'); ?>
>
<channel rdf:about="<?php bloginfo_rss("url") ?>">
- <title><?php bloginfo_rss('name') ?></title>
+ <title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
<link><?php bloginfo_rss('url') ?></link>
<description><?php bloginfo_rss('description') ?></description>
<dc:date><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></dc:date>
diff --git a/wp-includes/feed-rss.php b/wp-includes/feed-rss.php
index 97e0610..447dd59 100644
--- a/wp-includes/feed-rss.php
+++ b/wp-includes/feed-rss.php
@@ -7,7 +7,7 @@ $more = 1;
<!-- generator="wordpress/<?php echo $wp_version ?>" -->
<rss version="0.92">
<channel>
- <title><?php bloginfo_rss('name') ?></title>
+ <title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
<link><?php bloginfo_rss('url') ?></link>
<description><?php bloginfo_rss('description') ?></description>
<lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
diff --git a/wp-includes/feed-rss2.php b/wp-includes/feed-rss2.php
index 03711df..588a063 100644
--- a/wp-includes/feed-rss2.php
+++ b/wp-includes/feed-rss2.php
@@ -14,7 +14,7 @@ $more = 1;
>
<channel>
- <title><?php bloginfo_rss('name'); ?></title>
+ <title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
<link><?php bloginfo_rss('url') ?></link>
<description><?php bloginfo_rss("description") ?></description>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></pubDate>
diff --git a/wp-includes/feed.php b/wp-includes/feed.php
index 26eb4da..4a0c5ac 100644
--- a/wp-includes/feed.php
+++ b/wp-includes/feed.php
@@ -2,12 +2,12 @@
function get_bloginfo_rss($show = '') {
$info = strip_tags(get_bloginfo($show));
- return apply_filters('bloginfo_rss', convert_chars($info));
+ return apply_filters('get_bloginfo_rss', convert_chars($info));
}
function bloginfo_rss($show = '') {
- echo get_bloginfo_rss($show);
+ echo apply_filters('bloginfo_rss', get_bloginfo_rss($show));
}
function get_wp_title_rss($sep = '&#187;') {
@@ -16,6 +16,10 @@ function get_wp_title_rss($sep = '&#187;') {
return $title;
}
+function wp_title_rss($sep = '&#187;') {
+ echo apply_filters('wp_title_rss', get_wp_title_rss($sep));
+}
+
function get_the_title_rss() {
$title = get_the_title();
$title = apply_filters('the_title', $title);
diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php
index d497819..14eb5b8 100644
--- a/wp-includes/formatting.php
+++ b/wp-includes/formatting.php
@@ -55,7 +55,7 @@ function wpautop($pee, $br = 1) {
$pee = $pee . "\n"; // just to make things a little easier, pad the end
$pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);
// Space things out a little
- $allblocks = '(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|map|area|blockquote|address|math|style|script|object|input|param|p|h[1-6])';
+ $allblocks = '(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|map|area|blockquote|address|math|style|input|p|h[1-6]|hr)';
$pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee);
$pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee);
$pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines
@@ -581,11 +581,18 @@ function addslashes_gpc($gpc) {
}
-function stripslashes_deep($value)
-{
+function stripslashes_deep($value) {
$value = is_array($value) ?
- array_map('stripslashes_deep', $value) :
- stripslashes($value);
+ array_map('stripslashes_deep', $value) :
+ stripslashes($value);
+
+ return $value;
+}
+
+function urlencode_deep($value) {
+ $value = is_array($value) ?
+ array_map('urlencode_deep', $value) :
+ urlencode($value);
return $value;
}
@@ -1074,7 +1081,7 @@ function clean_url( $url, $protocols = null ) {
$url = str_replace(';//', '://', $url);
// Append http unless a relative link starting with / or a php file.
if ( strpos($url, '://') === false &&
- substr( $url, 0, 1 ) != '/' && !preg_match('/^[a-z0-9]+?\.php/i', $url) )
+ substr( $url, 0, 1 ) != '/' && !preg_match('/^[a-z0-9-]+?\.php/i', $url) )
$url = 'http://' . $url;
$url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&#038;$1', $url);
diff --git a/wp-includes/functions.php b/wp-includes/functions.php
index df7ad74..97b9915 100644
--- a/wp-includes/functions.php
+++ b/wp-includes/functions.php
@@ -8,7 +8,10 @@ function mysql2date($dateformatstring, $mysqlstring, $translate = true) {
if ( empty($m) ) {
return false;
}
- $i = mktime(substr($m,11,2),substr($m,14,2),substr($m,17,2),substr($m,5,2),substr($m,8,2),substr($m,0,4));
+ $i = mktime(
+ (int) substr( $m, 11, 2 ), (int) substr( $m, 14, 2 ), (int) substr( $m, 17, 2 ),
+ (int) substr( $m, 5, 2 ), (int) substr( $m, 8, 2 ), (int) substr( $m, 0, 4 )
+ );
if( 'U' == $dateformatstring )
return $i;
@@ -80,6 +83,14 @@ function date_i18n($dateformatstring, $unixtimestamp) {
return $j;
}
+function number_format_i18n($number, $decimals = null) {
+ global $wp_locale;
+ // let the user override the precision only
+ $decimals = is_null($decimals)? $wp_locale->number_format['decimals'] : intval($decimals);
+
+ return number_format($number, $decimals, $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep']);
+}
+
function get_weekstartend($mysqlstring, $start_of_week) {
$my = substr($mysqlstring,0,4);
$mm = substr($mysqlstring,8,2);
@@ -328,7 +339,7 @@ function update_option($option_name, $newvalue) {
}
$notoptions = wp_cache_get('notoptions', 'options');
- if ( isset($notoptions[$option_name]) ) {
+ if ( is_array($notoptions) && isset($notoptions[$option_name]) ) {
unset($notoptions[$option_name]);
wp_cache_set('notoptions', $notoptions, 'options');
}
@@ -362,7 +373,7 @@ function add_option($name, $value = '', $description = '', $autoload = 'yes') {
// Make sure the option doesn't already exist we can check the cache before we ask for a db query
$notoptions = wp_cache_get('notoptions', 'options');
- if ( isset($notoptions[$name]) ) {
+ if ( is_array($notoptions) && isset($notoptions[$name]) ) {
unset($notoptions[$name]);
wp_cache_set('notoptions', $notoptions, 'options');
} elseif ( false !== get_option($name) ) {
@@ -759,6 +770,7 @@ function clean_category_cache($id) {
wp_cache_delete($id, 'category');
wp_cache_delete('all_category_ids', 'category');
wp_cache_delete('get_categories', 'category');
+ delete_option('category_children');
}
/*
@@ -815,6 +827,9 @@ function add_query_arg() {
}
parse_str($query, $qs);
+ if ( get_magic_quotes_gpc() )
+ $qs = stripslashes_deep($qs); // parse_str() adds slashes if magicquotes is on. See: http://php.net/parse_str
+ $qs = urlencode_deep($qs);
if ( is_array(func_get_arg(0)) ) {
$kayvees = func_get_arg(0);
$qs = array_merge($qs, $kayvees);
@@ -832,10 +847,10 @@ function add_query_arg() {
$ret .= "$k=$v";
}
}
+ $ret = trim($ret, '?');
$ret = $protocol . $base . $ret . $frag;
- if ( get_magic_quotes_gpc() )
- $ret = stripslashes($ret); // parse_str() adds slashes if magicquotes is on. See: http://php.net/parse_str
- return trim($ret, '?');
+ $ret = trim($ret, '?');
+ return $ret;
}
/*
@@ -911,24 +926,35 @@ function wp($query_vars = '') {
$wp->main($query_vars);
}
+function get_status_header_desc( $code ) {
+ global $wp_header_to_desc;
+
+ $code = (int) $code;
+
+ if ( isset( $wp_header_to_desc[$code] ) ) {
+ return $wp_header_to_desc[$code];
+ } else {
+ return '';
+ }
+}
+
function status_header( $header ) {
- if ( 200 == $header )
- $text = 'OK';
- elseif ( 301 == $header )
- $text = 'Moved Permanently';
- elseif ( 302 == $header )
- $text = 'Moved Temporarily';
- elseif ( 304 == $header )
- $text = 'Not Modified';
- elseif ( 404 == $header )
- $text = 'Not Found';
- elseif ( 410 == $header )
- $text = 'Gone';
-
- if ( version_compare(phpversion(), '4.3.0', '>=') )
- @header("HTTP/1.1 $header $text", true, $header);
- else
- @header("HTTP/1.1 $header $text");
+ $text = get_status_header_desc( $header );
+
+ if ( empty( $text ) )
+ return false;
+
+ $protocol = $_SERVER["SERVER_PROTOCOL"];
+ if ( ('HTTP/1.1' != $protocol) && ('HTTP/1.0' != $protocol) )
+ $protocol = 'HTTP/1.0';
+ $status_header = "$protocol $header $text";
+ $status_header = apply_filters('status_header', $status_header, $header, $text, $protocol);
+
+ if ( version_compare( phpversion(), '4.3.0', '>=' ) ) {
+ return @header( $status_header, true, $header );
+ } else {
+ return @header( $status_header );
+ }
}
function nocache_headers() {
@@ -996,6 +1022,8 @@ function do_feed_atom($for_comments) {
function do_robots() {
global $current_blog;
+ header('Content-type: text/plain; charset=utf-8');
+
do_action('do_robotstxt');
if ( '0' == $current_blog->public ) {
@@ -1196,6 +1224,7 @@ function wp_check_filetype($filename, $mimes = null) {
'js' => 'application/javascript',
'pdf' => 'application/pdf',
'doc' => 'application/msword',
+ 'odt' => 'application/vnd.oasis.opendocument.text',
'pot|pps|ppt' => 'application/vnd.ms-powerpoint',
'wri' => 'application/vnd.ms-write',
'xla|xls|xlt|xlw' => 'application/vnd.ms-excel',
@@ -1243,10 +1272,10 @@ function wp_explain_nonce($action) {
$trans['bulk']['comments'] = array(__('Are you sure you want to bulk modify comments?'), false);
$trans['moderate']['comments'] = array(__('Are you sure you want to moderate comments?'), false);
- $trans['add']['bookmark'] = array(__('Are you sure you want to add this bookmark?'), false);
- $trans['delete']['bookmark'] = array(__('Are you sure you want to delete this bookmark: &quot;%s&quot;?'), 'use_id');
- $trans['update']['bookmark'] = array(__('Are you sure you want to edit this bookmark: &quot;%s&quot;?'), 'use_id');
- $trans['bulk']['bookmarks'] = array(__('Are you sure you want to bulk modify bookmarks?'), false);
+ $trans['add']['bookmark'] = array(__('Are you sure you want to add this link?'), false);
+ $trans['delete']['bookmark'] = array(__('Are you sure you want to delete this link: &quot;%s&quot;?'), 'use_id');
+ $trans['update']['bookmark'] = array(__('Are you sure you want to edit this link: &quot;%s&quot;?'), 'use_id');
+ $trans['bulk']['bookmarks'] = array(__('Are you sure you want to bulk modify links?'), false);
$trans['add']['page'] = array(__('Are you sure you want to add this page?'), false);
$trans['delete']['page'] = array(__('Are you sure you want to delete this page: &quot;%s&quot;?'), 'get_the_title');
@@ -1341,15 +1370,18 @@ function wp_die( $message, $title = '' ) {
$message = "<p>$message</p>";
}
+ if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false)
+ $admin_dir = '';
+ else
+ $admin_dir = 'wp-admin/';
+
+ if ( !did_action('admin_head') ) :
header('Content-Type: text/html; charset=utf-8');
if ( empty($title) )
$title = __('WordPress &rsaquo; Error');
- if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false)
- $admin_dir = '';
- else
- $admin_dir = 'wp-admin/';
+
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -1358,11 +1390,13 @@ function wp_die( $message, $title = '' ) {
<title><?php echo $title ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="<?php echo $admin_dir; ?>install.css" type="text/css" />
-<?php if ( ('rtl' == $wp_locale->text_direction) ) : ?>
+<?php
+if ( ( $wp_locale ) && ('rtl' == $wp_locale->text_direction) ) : ?>
<link rel="stylesheet" href="<?php echo $admin_dir; ?>install-rtl.css" type="text/css" />
<?php endif; ?>
</head>
<body>
+<?php endif; ?>
<h1 id="logo"><img alt="WordPress" src="<?php echo $admin_dir; ?>images/wordpress-logo.png" /></h1>
<?php echo $message; ?>
@@ -1469,11 +1503,49 @@ function smilies_init() {
);
}
+ $siteurl = get_option('siteurl');
foreach ( (array) $wpsmiliestrans as $smiley => $img ) {
$wp_smiliessearch[] = '/(\s|^)'.preg_quote($smiley, '/').'(\s|$)/';
$smiley_masked = htmlspecialchars(trim($smiley), ENT_QUOTES);
- $wp_smiliesreplace[] = " <img src='" . get_option('siteurl') . "/wp-includes/images/smilies/$img' alt='$smiley_masked' class='wp-smiley' /> ";
+ $wp_smiliesreplace[] = " <img src='$siteurl/wp-includes/images/smilies/$img' alt='$smiley_masked' class='wp-smiley' /> ";
}
}
+function wp_parse_args( $args, $defaults = '' ) {
+ if ( is_array( $args ) ) {
+ $r =& $args;
+ } else {
+ parse_str( $args, $r );
+ if ( get_magic_quotes_gpc() ) {
+ $r = stripslashes_deep( $r );
+ }
+ }
+
+ if ( is_array( $defaults ) ) {
+ return array_merge( $defaults, $r );
+ } else {
+ return $r;
+ }
+}
+
+function wp_maybe_load_widgets() {
+ if ( !function_exists( 'dynamic_sidebar' ) ) {
+ require_once ABSPATH . WPINC . '/widgets.php';
+ add_action( '_admin_menu', 'wp_widgets_add_menu' );
+ }
+}
+
+function wp_widgets_add_menu() {
+ global $submenu;
+ $submenu['themes.php'][7] = array( __( 'Widgets' ), 'switch_themes', 'widgets.php' );
+ ksort($submenu['themes.php'], SORT_NUMERIC);
+}
+
+// For PHP 5.2, make sure all output buffers are flushed
+// before our singletons our destroyed.
+function wp_ob_end_flush_all()
+{
+ while ( @ob_end_flush() );
+}
+
?>
diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php
index 7b21003..7980319 100644
--- a/wp-includes/general-template.php
+++ b/wp-includes/general-template.php
@@ -21,6 +21,7 @@ function get_footer() {
function get_sidebar() {
+ do_action( 'get_sidebar' );
if ( file_exists( TEMPLATEPATH . '/sidebar.php') )
load_template( TEMPLATEPATH . '/sidebar.php');
else
@@ -200,7 +201,7 @@ function wp_title($sep = '&raquo;', $display = true) {
// If there's a month
if ( !empty($m) ) {
$my_year = substr($m, 0, 4);
- $my_month = $wp_locale->get_month($m);
+ $my_month = $wp_locale->get_month(substr($m, 4, 2));
$my_day = intval(substr($m, 6, 2));
$title = "$my_year" . ($my_month ? "$sep $my_month" : "") . ($my_day ? "$sep $my_day" : "");
}
@@ -312,16 +313,16 @@ function get_archives_link($url, $text, $format = 'html', $before = '', $after =
function wp_get_archives($args = '') {
- global $wp_locale, $wpdb;
-
- if ( is_array($args) )
- $r = &$args;
- else
- parse_str($args, $r);
-
- $defaults = array('type' => 'monthly', 'limit' => '', 'format' => 'html', 'before' => '', 'after' => '', 'show_post_count' => false);
- $r = array_merge($defaults, $r);
- extract($r);
+ global $wpdb, $wp_locale;
+
+ $defaults = array(
+ 'type' => 'monthly', 'limit' => '',
+ 'format' => 'html', 'before' => '',
+ 'after' => '', 'show_post_count' => false
+ );
+
+ $r = wp_parse_args( $args, $defaults );
+ extract( $r );
if ( '' == $type )
$type = 'monthly';
@@ -424,7 +425,7 @@ function wp_get_archives($args = '') {
$url = get_permalink($arcresult);
$arc_title = $arcresult->post_title;
if ( $arc_title )
- $text = strip_tags($arc_title);
+ $text = strip_tags(apply_filters('the_title', $arc_title));
else
$text = $arcresult->ID;
echo get_archives_link($url, $text, $format, $before, $after);
@@ -634,7 +635,7 @@ function get_calendar($initial = true) {
ob_end_clean();
echo $output;
$cache[ $key ] = $output;
- wp_cache_set( 'get_calendar', $cache, 'calendar' );
+ wp_cache_add( 'get_calendar', $cache, 'calendar' );
}
function delete_get_calendar_cache() {
@@ -809,9 +810,16 @@ function rich_edit_exists() {
function user_can_richedit() {
global $wp_rich_edit, $pagenow;
-
- if ( !isset($wp_rich_edit) )
- $wp_rich_edit = ( 'true' == get_user_option('rich_editing') && !preg_match('!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT']) && 'comment.php' != $pagenow && rich_edit_exists() ) ? true : false;
+
+ if ( !isset( $wp_rich_edit) ) {
+ if ( get_user_option( 'rich_editing' ) == 'true' &&
+ ( ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval($match[1]) >= 420 ) ||
+ !preg_match( '!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT'] ) ) ) {
+ $wp_rich_edit = true;
+ } else {
+ $wp_rich_edit = false;
+ }
+ }
return apply_filters('user_can_richedit', $wp_rich_edit);
}
diff --git a/wp-includes/gettext.php b/wp-includes/gettext.php
index aabd9cf..72558cc 100644
--- a/wp-includes/gettext.php
+++ b/wp-includes/gettext.php
@@ -1,32 +1,32 @@
<?php
/*
- Copyright (c) 2003 Danilo Segan <danilo@kvota.net>.
- Copyright (c) 2005 Nico Kaiser <nico@siriux.net>
-
- This file is part of PHP-gettext.
+ Copyright (c) 2003 Danilo Segan <danilo@kvota.net>.
+ Copyright (c) 2005 Nico Kaiser <nico@siriux.net>
- PHP-gettext is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ This file is part of PHP-gettext.
- PHP-gettext is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ PHP-gettext is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
- You should have received a copy of the GNU General Public License
- along with PHP-gettext; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ PHP-gettext is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with PHP-gettext; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
+
/**
* Provides a simple gettext replacement that works independently from
* the system's gettext abilities.
* It can read MO files and use them for translating strings.
* The files are passed to gettext_reader as a Stream (see streams.php)
- *
+ *
* This version has the ability to cache all strings and translations to
* speed up the string lookup.
* While the cache is enabled by default, it can be switched off with the
@@ -34,332 +34,360 @@
* that you don't want to keep in memory)
*/
class gettext_reader {
- //public:
- var $error = 0; // public variable that holds error code (0 if no error)
-
- //private:
- var $BYTEORDER = 0; // 0: low endian, 1: big endian
- var $STREAM = NULL;
- var $short_circuit = false;
- var $enable_cache = false;
- var $originals = NULL; // offset of original table
- var $translations = NULL; // offset of translation table
- var $pluralheader = NULL; // cache header field for plural forms
- var $total = 0; // total string count
- var $table_originals = NULL; // table for original strings (offsets)
- var $table_translations = NULL; // table for translated strings (offsets)
- var $cache_translations = NULL; // original -> translation mapping
-
-
- /* Methods */
-
-
- /**
- * Reads a 32bit Integer from the Stream
- *
- * @access private
- * @return Integer from the Stream
- */
- function readint() {
- if ($this->BYTEORDER == 0) {
- // low endian
- $low_end = unpack('V', $this->STREAM->read(4));
- return array_shift($low_end);
- } else {
- // big endian
- $big_end = unpack('N', $this->STREAM->read(4));
- return array_shift($big_end);
- }
- }
-
- /**
- * Reads an array of Integers from the Stream
- *
- * @param int count How many elements should be read
- * @return Array of Integers
- */
- function readintarray($count) {
- if ($this->BYTEORDER == 0) {
- // low endian
- return unpack('V'.$count, $this->STREAM->read(4 * $count));
- } else {
- // big endian
- return unpack('N'.$count, $this->STREAM->read(4 * $count));
- }
- }
-
- /**
- * Constructor
- *
- * @param object Reader the StreamReader object
- * @param boolean enable_cache Enable or disable caching of strings (default on)
- */
- function gettext_reader($Reader, $enable_cache = true) {
- // If there isn't a StreamReader, turn on short circuit mode.
- if (! $Reader || isset($Reader->error) ) {
- $this->short_circuit = true;
- return;
- }
-
- // Caching can be turned off
- $this->enable_cache = $enable_cache;
-
- // $MAGIC1 = (int)0x950412de; //bug in PHP 5.0.2, see https://savannah.nongnu.org/bugs/?func=detailitem&item_id=10565
- $MAGIC1 = (int) - 1794895138;
- // $MAGIC2 = (int)0xde120495; //bug
- $MAGIC2 = (int) - 569244523;
- // 64-bit fix
- $MAGIC3 = (int) 2500072158;
-
- $this->STREAM = $Reader;
- $magic = $this->readint();
- if ($magic == ($MAGIC1 & 0xFFFFFFFF) || $magic == ($MAGIC3 & 0xFFFFFFFF)) { // to make sure it works for 64-bit platforms
- $this->BYTEORDER = 0;
- } elseif ($magic == ($MAGIC2 & 0xFFFFFFFF)) {
- $this->BYTEORDER = 1;
- } else {
- $this->error = 1; // not MO file
- return false;
- }
-
- // FIXME: Do we care about revision? We should.
- $revision = $this->readint();
-
- $this->total = $this->readint();
- $this->originals = $this->readint();
- $this->translations = $this->readint();
- }
-
- /**
- * Loads the translation tables from the MO file into the cache
- * If caching is enabled, also loads all strings into a cache
- * to speed up translation lookups
- *
- * @access private
- */
- function load_tables() {
- if (is_array($this->cache_translations) &&
- is_array($this->table_originals) &&
- is_array($this->table_translations))
- return;
-
- /* get original and translations tables */
- $this->STREAM->seekto($this->originals);
- $this->table_originals = $this->readintarray($this->total * 2);
- $this->STREAM->seekto($this->translations);
- $this->table_translations = $this->readintarray($this->total * 2);
-
- if ($this->enable_cache) {
- $this->cache_translations = array ();
- /* read all strings in the cache */
- for ($i = 0; $i < $this->total; $i++) {
- $this->STREAM->seekto($this->table_originals[$i * 2 + 2]);
- $original = $this->STREAM->read($this->table_originals[$i * 2 + 1]);
- $this->STREAM->seekto($this->table_translations[$i * 2 + 2]);
- $translation = $this->STREAM->read($this->table_translations[$i * 2 + 1]);
- $this->cache_translations[$original] = $translation;
- }
- }
- }
-
- /**
- * Returns a string from the "originals" table
- *
- * @access private
- * @param int num Offset number of original string
- * @return string Requested string if found, otherwise ''
- */
- function get_original_string($num) {
- $length = $this->table_originals[$num * 2 + 1];
- $offset = $this->table_originals[$num * 2 + 2];
- if (! $length)
- return '';
- $this->STREAM->seekto($offset);
- $data = $this->STREAM->read($length);
- return (string)$data;
- }
-
- /**
- * Returns a string from the "translations" table
- *
- * @access private
- * @param int num Offset number of original string
- * @return string Requested string if found, otherwise ''
- */
- function get_translation_string($num) {
- $length = $this->table_translations[$num * 2 + 1];
- $offset = $this->table_translations[$num * 2 + 2];
- if (! $length)
- return '';
- $this->STREAM->seekto($offset);
- $data = $this->STREAM->read($length);
- return (string)$data;
- }
-
- /**
- * Binary search for string
- *
- * @access private
- * @param string string
- * @param int start (internally used in recursive function)
- * @param int end (internally used in recursive function)
- * @return int string number (offset in originals table)
- */
- function find_string($string, $start = -1, $end = -1) {
- if (($start == -1) or ($end == -1)) {
- // find_string is called with only one parameter, set start end end
- $start = 0;
- $end = $this->total;
- }
- if (abs($start - $end) <= 1) {
- // We're done, now we either found the string, or it doesn't exist
- $txt = $this->get_original_string($start);
- if ($string == $txt)
- return $start;
- else
- return -1;
- } else if ($start > $end) {
- // start > end -> turn around and start over
- return $this->find_string($string, $end, $start);
- } else {
- // Divide table in two parts
- $half = (int)(($start + $end) / 2);
- $cmp = strcmp($string, $this->get_original_string($half));
- if ($cmp == 0)
- // string is exactly in the middle => return it
- return $half;
- else if ($cmp < 0)
- // The string is in the upper half
- return $this->find_string($string, $start, $half);
- else
- // The string is in the lower half
- return $this->find_string($string, $half, $end);
- }
- }
-
- /**
- * Translates a string
- *
- * @access public
- * @param string string to be translated
- * @return string translated string (or original, if not found)
- */
- function translate($string) {
- if ($this->short_circuit)
- return $string;
- $this->load_tables();
-
- if ($this->enable_cache) {
- // Caching enabled, get translated string from cache
- if (array_key_exists($string, $this->cache_translations))
- return $this->cache_translations[$string];
- else
- return $string;
- } else {
- // Caching not enabled, try to find string
- $num = $this->find_string($string);
- if ($num == -1)
- return $string;
- else
- return $this->get_translation_string($num);
- }
- }
-
- /**
- * Get possible plural forms from MO header
- *
- * @access private
- * @return string plural form header
- */
- function get_plural_forms() {
- // lets assume message number 0 is header
- // this is true, right?
- $this->load_tables();
-
- // cache header field for plural forms
- if (! is_string($this->pluralheader)) {
- if ($this->enable_cache) {
- $header = $this->cache_translations[""];
- } else {
- $header = $this->get_translation_string(0);
- }
- if (eregi("plural-forms: ([^\n]*)\n", $header, $regs))
- $expr = $regs[1];
- else
- $expr = "nplurals=2; plural=n == 1 ? 0 : 1;";
- $this->pluralheader = $expr;
- }
- return $this->pluralheader;
- }
-
- /**
- * Detects which plural form to take
- *
- * @access private
- * @param n count
- * @return int array index of the right plural form
- */
- function select_string($n) {
- $string = $this->get_plural_forms();
- $string = str_replace('nplurals',"\$total",$string);
- $string = str_replace("n",$n,$string);
- $string = str_replace('plural',"\$plural",$string);
-
- # poEdit doesn't put any semicolons, which
- # results in parse error in eval
- $string .= ';';
-
- $total = 0;
- $plural = 0;
-
- eval("$string");
- if ($plural >= $total) $plural = $total - 1;
- return $plural;
- }
-
- /**
- * Plural version of gettext
- *
- * @access public
- * @param string single
- * @param string plural
- * @param string number
- * @return translated plural form
- */
- function ngettext($single, $plural, $number) {
- if ($this->short_circuit) {
- if ($number != 1)
- return $plural;
- else
- return $single;
- }
-
- // find out the appropriate form
- $select = $this->select_string($number);
-
- // this should contains all strings separated by NULLs
- $key = $single.chr(0).$plural;
-
-
- if ($this->enable_cache) {
- if (! array_key_exists($key, $this->cache_translations)) {
- return ($number != 1) ? $plural : $single;
- } else {
- $result = $this->cache_translations[$key];
- $list = explode(chr(0), $result);
- return $list[$select];
- }
- } else {
- $num = $this->find_string($key);
- if ($num == -1) {
- return ($number != 1) ? $plural : $single;
- } else {
- $result = $this->get_translation_string($num);
- $list = explode(chr(0), $result);
- return $list[$select];
- }
- }
- }
+ //public:
+ var $error = 0; // public variable that holds error code (0 if no error)
+
+ //private:
+ var $BYTEORDER = 0; // 0: low endian, 1: big endian
+ var $STREAM = NULL;
+ var $short_circuit = false;
+ var $enable_cache = false;
+ var $originals = NULL; // offset of original table
+ var $translations = NULL; // offset of translation table
+ var $pluralheader = NULL; // cache header field for plural forms
+ var $select_string_function = NULL; // cache function, which chooses plural forms
+ var $total = 0; // total string count
+ var $table_originals = NULL; // table for original strings (offsets)
+ var $table_translations = NULL; // table for translated strings (offsets)
+ var $cache_translations = NULL; // original -> translation mapping
+
+
+ /* Methods */
+
+
+ /**
+ * Reads a 32bit Integer from the Stream
+ *
+ * @access private
+ * @return Integer from the Stream
+ */
+ function readint() {
+ if ($this->BYTEORDER == 0) {
+ // low endian
+ $low_end = unpack('V', $this->STREAM->read(4));
+ return array_shift($low_end);
+ } else {
+ // big endian
+ $big_end = unpack('N', $this->STREAM->read(4));
+ return array_shift($big_end);
+ }
+ }
+
+ /**
+ * Reads an array of Integers from the Stream
+ *
+ * @param int count How many elements should be read
+ * @return Array of Integers
+ */
+ function readintarray($count) {
+ if ($this->BYTEORDER == 0) {
+ // low endian
+ return unpack('V'.$count, $this->STREAM->read(4 * $count));
+ } else {
+ // big endian
+ return unpack('N'.$count, $this->STREAM->read(4 * $count));
+ }
+ }
+
+ /**
+ * Constructor
+ *
+ * @param object Reader the StreamReader object
+ * @param boolean enable_cache Enable or disable caching of strings (default on)
+ */
+ function gettext_reader($Reader, $enable_cache = true) {
+ // If there isn't a StreamReader, turn on short circuit mode.
+ if (! $Reader || isset($Reader->error) ) {
+ $this->short_circuit = true;
+ return;
+ }
+
+ // Caching can be turned off
+ $this->enable_cache = $enable_cache;
+
+ // $MAGIC1 = (int)0x950412de; //bug in PHP 5.0.2, see https://savannah.nongnu.org/bugs/?func=detailitem&item_id=10565
+ $MAGIC1 = (int) - 1794895138;
+ // $MAGIC2 = (int)0xde120495; //bug
+ $MAGIC2 = (int) - 569244523;
+ // 64-bit fix
+ $MAGIC3 = (int) 2500072158;
+
+ $this->STREAM = $Reader;
+ $magic = $this->readint();
+ if ($magic == ($MAGIC1 & 0xFFFFFFFF) || $magic == ($MAGIC3 & 0xFFFFFFFF)) { // to make sure it works for 64-bit platforms
+ $this->BYTEORDER = 0;
+ } elseif ($magic == ($MAGIC2 & 0xFFFFFFFF)) {
+ $this->BYTEORDER = 1;
+ } else {
+ $this->error = 1; // not MO file
+ return false;
+ }
+
+ // FIXME: Do we care about revision? We should.
+ $revision = $this->readint();
+
+ $this->total = $this->readint();
+ $this->originals = $this->readint();
+ $this->translations = $this->readint();
+ }
+
+ /**
+ * Loads the translation tables from the MO file into the cache
+ * If caching is enabled, also loads all strings into a cache
+ * to speed up translation lookups
+ *
+ * @access private
+ */
+ function load_tables() {
+ if (is_array($this->cache_translations) &&
+ is_array($this->table_originals) &&
+ is_array($this->table_translations))
+ return;
+
+ /* get original and translations tables */
+ $this->STREAM->seekto($this->originals);
+ $this->table_originals = $this->readintarray($this->total * 2);
+ $this->STREAM->seekto($this->translations);
+ $this->table_translations = $this->readintarray($this->total * 2);
+
+ if ($this->enable_cache) {
+ $this->cache_translations = array ();
+ /* read all strings in the cache */
+ for ($i = 0; $i < $this->total; $i++) {
+ $this->STREAM->seekto($this->table_originals[$i * 2 + 2]);
+ $original = $this->STREAM->read($this->table_originals[$i * 2 + 1]);
+ $this->STREAM->seekto($this->table_translations[$i * 2 + 2]);
+ $translation = $this->STREAM->read($this->table_translations[$i * 2 + 1]);
+ $this->cache_translations[$original] = $translation;
+ }
+ }
+ }
+
+ /**
+ * Returns a string from the "originals" table
+ *
+ * @access private
+ * @param int num Offset number of original string
+ * @return string Requested string if found, otherwise ''
+ */
+ function get_original_string($num) {
+ $length = $this->table_originals[$num * 2 + 1];
+ $offset = $this->table_originals[$num * 2 + 2];
+ if (! $length)
+ return '';
+ $this->STREAM->seekto($offset);
+ $data = $this->STREAM->read($length);
+ return (string)$data;
+ }
+
+ /**
+ * Returns a string from the "translations" table
+ *
+ * @access private
+ * @param int num Offset number of original string
+ * @return string Requested string if found, otherwise ''
+ */
+ function get_translation_string($num) {
+ $length = $this->table_translations[$num * 2 + 1];
+ $offset = $this->table_translations[$num * 2 + 2];
+ if (! $length)
+ return '';
+ $this->STREAM->seekto($offset);
+ $data = $this->STREAM->read($length);
+ return (string)$data;
+ }
+
+ /**
+ * Binary search for string
+ *
+ * @access private
+ * @param string string
+ * @param int start (internally used in recursive function)
+ * @param int end (internally used in recursive function)
+ * @return int string number (offset in originals table)
+ */
+ function find_string($string, $start = -1, $end = -1) {
+ if (($start == -1) or ($end == -1)) {
+ // find_string is called with only one parameter, set start end end
+ $start = 0;
+ $end = $this->total;
+ }
+ if (abs($start - $end) <= 1) {
+ // We're done, now we either found the string, or it doesn't exist
+ $txt = $this->get_original_string($start);
+ if ($string == $txt)
+ return $start;
+ else
+ return -1;
+ } else if ($start > $end) {
+ // start > end -> turn around and start over
+ return $this->find_string($string, $end, $start);
+ } else {
+ // Divide table in two parts
+ $half = (int)(($start + $end) / 2);
+ $cmp = strcmp($string, $this->get_original_string($half));
+ if ($cmp == 0)
+ // string is exactly in the middle => return it
+ return $half;
+ else if ($cmp < 0)
+ // The string is in the upper half
+ return $this->find_string($string, $start, $half);
+ else
+ // The string is in the lower half
+ return $this->find_string($string, $half, $end);
+ }
+ }
+
+ /**
+ * Translates a string
+ *
+ * @access public
+ * @param string string to be translated
+ * @return string translated string (or original, if not found)
+ */
+ function translate($string) {
+ if ($this->short_circuit)
+ return $string;
+ $this->load_tables();
+
+ if ($this->enable_cache) {
+ // Caching enabled, get translated string from cache
+ if (array_key_exists($string, $this->cache_translations))
+ return $this->cache_translations[$string];
+ else
+ return $string;
+ } else {
+ // Caching not enabled, try to find string
+ $num = $this->find_string($string);
+ if ($num == -1)
+ return $string;
+ else
+ return $this->get_translation_string($num);
+ }
+ }
+
+ /**
+ * Get possible plural forms from MO header
+ *
+ * @access private
+ * @return string plural form header
+ */
+ function get_plural_forms() {
+ // lets assume message number 0 is header
+ // this is true, right?
+ $this->load_tables();
+
+ // cache header field for plural forms
+ if (! is_string($this->pluralheader)) {
+ if ($this->enable_cache) {
+ $header = $this->cache_translations[""];
+ } else {
+ $header = $this->get_translation_string(0);
+ }
+ $header .= "\n"; //make sure our regex matches
+ if (eregi("plural-forms: ([^\n]*)\n", $header, $regs))
+ $expr = $regs[1];
+ else
+ $expr = "nplurals=2; plural=n == 1 ? 0 : 1;";
+
+ // add parentheses
+ // important since PHP's ternary evaluates from left to right
+ $expr.= ';';
+ $res= '';
+ $p= 0;
+ for ($i= 0; $i < strlen($expr); $i++) {
+ $ch= $expr[$i];
+ switch ($ch) {
+ case '?':
+ $res.= ' ? (';
+ $p++;
+ break;
+ case ':':
+ $res.= ') : (';
+ break;
+ case ';':
+ $res.= str_repeat( ')', $p) . ';';
+ $p= 0;
+ break;
+ default:
+ $res.= $ch;
+ }
+ }
+ $this->pluralheader = $res;
+ }
+
+ return $this->pluralheader;
+ }
+
+ /**
+ * Detects which plural form to take
+ *
+ * @access private
+ * @param n count
+ * @return int array index of the right plural form
+ */
+ function select_string($n) {
+ if (is_null($this->select_string_function)) {
+ $string = $this->get_plural_forms();
+ if (preg_match("/nplurals\s*=\s*(\d+)\s*\;\s*plural\s*=\s*(.*?)\;+/", $string, $matches)) {
+ $nplurals = $matches[1];
+ $expression = $matches[2];
+ $expression = str_replace("n", '$n', $expression);
+ } else {
+ $nplurals = 2;
+ $expression = ' $n == 1 ? 0 : 1 ';
+ }
+ $func_body = "
+ \$plural = ($expression);
+ return (\$plural <= $nplurals)? \$plural : \$plural - 1;";
+ $this->select_string_function = create_function('$n', $func_body);
+ }
+ return call_user_func($this->select_string_function, $n);
+ }
+
+ /**
+ * Plural version of gettext
+ *
+ * @access public
+ * @param string single
+ * @param string plural
+ * @param string number
+ * @return translated plural form
+ */
+ function ngettext($single, $plural, $number) {
+ if ($this->short_circuit) {
+ if ($number != 1)
+ return $plural;
+ else
+ return $single;
+ }
+
+ // find out the appropriate form
+ $select = $this->select_string($number);
+
+ // this should contains all strings separated by NULLs
+ $key = $single.chr(0).$plural;
+
+
+ if ($this->enable_cache) {
+ if (! array_key_exists($key, $this->cache_translations)) {
+ return ($number != 1) ? $plural : $single;
+ } else {
+ $result = $this->cache_translations[$key];
+ $list = explode(chr(0), $result);
+ return $list[$select];
+ }
+ } else {
+ $num = $this->find_string($key);
+ if ($num == -1) {
+ return ($number != 1) ? $plural : $single;
+ } else {
+ $result = $this->get_translation_string($num);
+ $list = explode(chr(0), $result);
+ return $list[$select];
+ }
+ }
+ }
}
diff --git a/wp-includes/images/rss.png b/wp-includes/images/rss.png
new file mode 100644
index 0000000..6e7b676
--- /dev/null
+++ b/wp-includes/images/rss.png
Binary files differ
diff --git a/wp-includes/js/prototype.js b/wp-includes/js/prototype.js
index 6253917..842385a 100644
--- a/wp-includes/js/prototype.js
+++ b/wp-includes/js/prototype.js
@@ -1,19 +1,33 @@
-/* Prototype JavaScript framework, version 1.5.0
+/* Prototype JavaScript framework, version 1.5.1
* (c) 2005-2007 Sam Stephenson
*
* Prototype is freely distributable under the terms of an MIT-style license.
- * For details, see the Prototype web site: http://prototype.conio.net/
+ * For details, see the Prototype web site: http://www.prototypejs.org/
*
/*--------------------------------------------------------------------------*/
var Prototype = {
- Version: '1.5.0',
+ Version: '1.5.1',
+
+ Browser: {
+ IE: !!(window.attachEvent && !window.opera),
+ Opera: !!window.opera,
+ WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
+ Gecko: navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1
+ },
+
BrowserFeatures: {
- XPath: !!document.evaluate
+ XPath: !!document.evaluate,
+ ElementExtensions: !!window.HTMLElement,
+ SpecificElementExtensions:
+ (document.createElement('div').__proto__ !==
+ document.createElement('form').__proto__)
},
- ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)',
- emptyFunction: function() {},
+ ScriptFragment: '<script[^>]*>([\u0001-\uFFFF]*?)</script>',
+ JSONFilter: /^\/\*-secure-\s*(.*)\s*\*\/\s*$/,
+
+ emptyFunction: function() { },
K: function(x) { return x }
}
@@ -46,6 +60,26 @@ Object.extend(Object, {
}
},
+ toJSON: function(object) {
+ var type = typeof object;
+ switch(type) {
+ case 'undefined':
+ case 'function':
+ case 'unknown': return;
+ case 'boolean': return object.toString();
+ }
+ if (object === null) return 'null';
+ if (object.toJSON) return object.toJSON();
+ if (object.ownerDocument === document) return;
+ var results = [];
+ for (var property in object) {
+ var value = Object.toJSON(object[property]);
+ if (value !== undefined)
+ results.push(property.toJSON() + ': ' + value);
+ }
+ return '{' + results.join(', ') + '}';
+ },
+
keys: function(object) {
var keys = [];
for (var property in object)
@@ -75,15 +109,13 @@ Function.prototype.bind = function() {
Function.prototype.bindAsEventListener = function(object) {
var __method = this, args = $A(arguments), object = args.shift();
return function(event) {
- return __method.apply(object, [( event || window.event)].concat(args).concat($A(arguments)));
+ return __method.apply(object, [event || window.event].concat(args));
}
}
Object.extend(Number.prototype, {
toColorPart: function() {
- var digits = this.toString(16);
- if (this < 16) return '0' + digits;
- return digits;
+ return this.toPaddedString(2, 16);
},
succ: function() {
@@ -93,9 +125,27 @@ Object.extend(Number.prototype, {
times: function(iterator) {
$R(0, this, true).each(iterator);
return this;
+ },
+
+ toPaddedString: function(length, radix) {
+ var string = this.toString(radix || 10);
+ return '0'.times(length - string.length) + string;
+ },
+
+ toJSON: function() {
+ return isFinite(this) ? this.toString() : 'null';
}
});
+Date.prototype.toJSON = function() {
+ return '"' + this.getFullYear() + '-' +
+ (this.getMonth() + 1).toPaddedString(2) + '-' +
+ this.getDate().toPaddedString(2) + 'T' +
+ this.getHours().toPaddedString(2) + ':' +
+ this.getMinutes().toPaddedString(2) + ':' +
+ this.getSeconds().toPaddedString(2) + '"';
+};
+
var Try = {
these: function() {
var returnValue;
@@ -145,9 +195,19 @@ PeriodicalExecuter.prototype = {
}
}
}
-String.interpret = function(value){
- return value == null ? '' : String(value);
-}
+Object.extend(String, {
+ interpret: function(value) {
+ return value == null ? '' : String(value);
+ },
+ specialChar: {
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '\\': '\\\\'
+ }
+});
Object.extend(String.prototype, {
gsub: function(pattern, replacement) {
@@ -213,17 +273,16 @@ Object.extend(String.prototype, {
},
escapeHTML: function() {
- var div = document.createElement('div');
- var text = document.createTextNode(this);
- div.appendChild(text);
- return div.innerHTML;
+ var self = arguments.callee;
+ self.text.data = this;
+ return self.div.innerHTML;
},
unescapeHTML: function() {
var div = document.createElement('div');
div.innerHTML = this.stripTags();
return div.childNodes[0] ? (div.childNodes.length > 1 ?
- $A(div.childNodes).inject('',function(memo,node){ return memo+node.nodeValue }) :
+ $A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) :
div.childNodes[0].nodeValue) : '';
},
@@ -233,15 +292,15 @@ Object.extend(String.prototype, {
return match[1].split(separator || '&').inject({}, function(hash, pair) {
if ((pair = pair.split('='))[0]) {
- var name = decodeURIComponent(pair[0]);
- var value = pair[1] ? decodeURIComponent(pair[1]) : undefined;
+ var key = decodeURIComponent(pair.shift());
+ var value = pair.length > 1 ? pair.join('=') : pair[0];
+ if (value != undefined) value = decodeURIComponent(value);
- if (hash[name] !== undefined) {
- if (hash[name].constructor != Array)
- hash[name] = [hash[name]];
- if (value) hash[name].push(value);
+ if (key in hash) {
+ if (hash[key].constructor != Array) hash[key] = [hash[key]];
+ hash[key].push(value);
}
- else hash[name] = value;
+ else hash[key] = value;
}
return hash;
});
@@ -256,6 +315,12 @@ Object.extend(String.prototype, {
String.fromCharCode(this.charCodeAt(this.length - 1) + 1);
},
+ times: function(count) {
+ var result = '';
+ for (var i = 0; i < count; i++) result += this;
+ return result;
+ },
+
camelize: function() {
var parts = this.split('-'), len = parts.length;
if (len == 1) return parts[0];
@@ -270,7 +335,7 @@ Object.extend(String.prototype, {
return camelized;
},
- capitalize: function(){
+ capitalize: function() {
return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
},
@@ -283,11 +348,59 @@ Object.extend(String.prototype, {
},
inspect: function(useDoubleQuotes) {
- var escapedString = this.replace(/\\/g, '\\\\');
- if (useDoubleQuotes)
- return '"' + escapedString.replace(/"/g, '\\"') + '"';
- else
- return "'" + escapedString.replace(/'/g, '\\\'') + "'";
+ var escapedString = this.gsub(/[\x00-\x1f\\]/, function(match) {
+ var character = String.specialChar[match[0]];
+ return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16);
+ });
+ if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"';
+ return "'" + escapedString.replace(/'/g, '\\\'') + "'";
+ },
+
+ toJSON: function() {
+ return this.inspect(true);
+ },
+
+ unfilterJSON: function(filter) {
+ return this.sub(filter || Prototype.JSONFilter, '#{1}');
+ },
+
+ evalJSON: function(sanitize) {
+ var json = this.unfilterJSON();
+ try {
+ if (!sanitize || (/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(json)))
+ return eval('(' + json + ')');
+ } catch (e) { }
+ throw new SyntaxError('Badly formed JSON string: ' + this.inspect());
+ },
+
+ include: function(pattern) {
+ return this.indexOf(pattern) > -1;
+ },
+
+ startsWith: function(pattern) {
+ return this.indexOf(pattern) === 0;
+ },
+
+ endsWith: function(pattern) {
+ var d = this.length - pattern.length;
+ return d >= 0 && this.lastIndexOf(pattern) === d;
+ },
+
+ empty: function() {
+ return this == '';
+ },
+
+ blank: function() {
+ return /^\s*$/.test(this);
+ }
+});
+
+if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, {
+ escapeHTML: function() {
+ return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
+ },
+ unescapeHTML: function() {
+ return this.replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>');
}
});
@@ -299,6 +412,13 @@ String.prototype.gsub.prepareReplacement = function(replacement) {
String.prototype.parseQuery = String.prototype.toQueryParams;
+Object.extend(String.prototype.escapeHTML, {
+ div: document.createElement('div'),
+ text: document.createTextNode('')
+});
+
+with (String.prototype.escapeHTML) div.appendChild(text);
+
var Template = Class.create();
Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
Template.prototype = {
@@ -316,19 +436,14 @@ Template.prototype = {
}
}
-var $break = new Object();
-var $continue = new Object();
+var $break = {}, $continue = new Error('"throw $continue" is deprecated, use "return" instead');
var Enumerable = {
each: function(iterator) {
var index = 0;
try {
this._each(function(value) {
- try {
- iterator(value, index++);
- } catch (e) {
- if (e != $continue) throw e;
- }
+ iterator(value, index++);
});
} catch (e) {
if (e != $break) throw e;
@@ -530,6 +645,21 @@ var $A = Array.from = function(iterable) {
}
}
+if (Prototype.Browser.WebKit) {
+ $A = Array.from = function(iterable) {
+ if (!iterable) return [];
+ if (!(typeof iterable == 'function' && iterable == '[object NodeList]') &&
+ iterable.toArray) {
+ return iterable.toArray();
+ } else {
+ var results = [];
+ for (var i = 0, length = iterable.length; i < length; i++)
+ results.push(iterable[i]);
+ return results;
+ }
+ }
+}
+
Object.extend(Array.prototype, Enumerable);
if (!Array.prototype._reverse)
@@ -588,9 +718,11 @@ Object.extend(Array.prototype, {
return this.length > 1 ? this : this[0];
},
- uniq: function() {
- return this.inject([], function(array, value) {
- return array.include(value) ? array : array.concat([value]);
+ uniq: function(sorted) {
+ return this.inject([], function(array, value, index) {
+ if (0 == index || (sorted ? array.last() != value : !array.include(value)))
+ array.push(value);
+ return array;
});
},
@@ -604,23 +736,32 @@ Object.extend(Array.prototype, {
inspect: function() {
return '[' + this.map(Object.inspect).join(', ') + ']';
+ },
+
+ toJSON: function() {
+ var results = [];
+ this.each(function(object) {
+ var value = Object.toJSON(object);
+ if (value !== undefined) results.push(value);
+ });
+ return '[' + results.join(', ') + ']';
}
});
Array.prototype.toArray = Array.prototype.clone;
-function $w(string){
+function $w(string) {
string = string.strip();
return string ? string.split(/\s+/) : [];
}
-if(window.opera){
- Array.prototype.concat = function(){
+if (Prototype.Browser.Opera){
+ Array.prototype.concat = function() {
var array = [];
- for(var i = 0, length = this.length; i < length; i++) array.push(this[i]);
- for(var i = 0, length = arguments.length; i < length; i++) {
- if(arguments[i].constructor == Array) {
- for(var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++)
+ for (var i = 0, length = this.length; i < length; i++) array.push(this[i]);
+ for (var i = 0, length = arguments.length; i < length; i++) {
+ if (arguments[i].constructor == Array) {
+ for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++)
array.push(arguments[i][j]);
} else {
array.push(arguments[i]);
@@ -629,37 +770,48 @@ if(window.opera){
return array;
}
}
-var Hash = function(obj) {
- Object.extend(this, obj || {});
+var Hash = function(object) {
+ if (object instanceof Hash) this.merge(object);
+ else Object.extend(this, object || {});
};
Object.extend(Hash, {
toQueryString: function(obj) {
var parts = [];
+ parts.add = arguments.callee.addPair;
- this.prototype._each.call(obj, function(pair) {
+ this.prototype._each.call(obj, function(pair) {
if (!pair.key) return;
+ var value = pair.value;
- if (pair.value && pair.value.constructor == Array) {
- var values = pair.value.compact();
- if (values.length < 2) pair.value = values.reduce();
- else {
- key = encodeURIComponent(pair.key);
- values.each(function(value) {
- value = value != undefined ? encodeURIComponent(value) : '';
- parts.push(key + '=' + encodeURIComponent(value));
- });
- return;
- }
+ if (value && typeof value == 'object') {
+ if (value.constructor == Array) value.each(function(value) {
+ parts.add(pair.key, value);
+ });
+ return;
}
- if (pair.value == undefined) pair[1] = '';
- parts.push(pair.map(encodeURIComponent).join('='));
- });
+ parts.add(pair.key, value);
+ });
return parts.join('&');
+ },
+
+ toJSON: function(object) {
+ var results = [];
+ this.prototype._each.call(object, function(pair) {
+ var value = Object.toJSON(pair.value);
+ if (value !== undefined) results.push(pair.key.toJSON() + ': ' + value);
+ });
+ return '{' + results.join(', ') + '}';
}
});
+Hash.toQueryString.addPair = function(key, value, prefix) {
+ key = encodeURIComponent(key);
+ if (value === undefined) this.push(key);
+ else this.push(key + '=' + (value == null ? '' : encodeURIComponent(value)));
+}
+
Object.extend(Hash.prototype, Enumerable);
Object.extend(Hash.prototype, {
_each: function(iterator) {
@@ -713,13 +865,36 @@ Object.extend(Hash.prototype, {
return '#<Hash:{' + this.map(function(pair) {
return pair.map(Object.inspect).join(': ');
}).join(', ') + '}>';
+ },
+
+ toJSON: function() {
+ return Hash.toJSON(this);
}
});
function $H(object) {
- if (object && object.constructor == Hash) return object;
+ if (object instanceof Hash) return object;
return new Hash(object);
};
+
+// Safari iterates over shadowed properties
+if (function() {
+ var i = 0, Test = function(value) { this.key = value };
+ Test.prototype.key = 'foo';
+ for (var property in new Test('bar')) i++;
+ return i > 1;
+}()) Hash.prototype._each = function(iterator) {
+ var cache = [];
+ for (var key in this) {
+ var value = this[key];
+ if ((value && value == Hash.prototype[key]) || cache.include(key)) continue;
+ cache.push(key);
+ var pair = [key, value];
+ pair.key = key;
+ pair.value = value;
+ iterator(pair);
+ }
+};
ObjectRange = Class.create();
Object.extend(ObjectRange.prototype, Enumerable);
Object.extend(ObjectRange.prototype, {
@@ -834,7 +1009,7 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
request: function(url) {
this.url = url;
this.method = this.options.method;
- var params = this.options.parameters;
+ var params = Object.clone(this.options.parameters);
if (!['get', 'post'].include(this.method)) {
// simulate other verbs over post
@@ -842,14 +1017,18 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
this.method = 'post';
}
- params = Hash.toQueryString(params);
- if (params && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) params += '&_='
+ this.parameters = params;
- // when GET, append parameters to URL
- if (this.method == 'get' && params)
- this.url += (this.url.indexOf('?') > -1 ? '&' : '?') + params;
+ if (params = Hash.toQueryString(params)) {
+ // when GET, append parameters to URL
+ if (this.method == 'get')
+ this.url += (this.url.include('?') ? '&' : '?') + params;
+ else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent))
+ params += '&_=';
+ }
try {
+ if (this.options.onCreate) this.options.onCreate(this.transport);
Ajax.Responders.dispatch('onCreate', this, this.transport);
this.transport.open(this.method.toUpperCase(), this.url,
@@ -861,9 +1040,8 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
this.transport.onreadystatechange = this.onStateChange.bind(this);
this.setRequestHeaders();
- var body = this.method == 'post' ? (this.options.postBody || params) : null;
-
- this.transport.send(body);
+ this.body = this.method == 'post' ? (this.options.postBody || params) : null;
+ this.transport.send(this.body);
/* Force Firefox to handle ready state 4 for synchronous requests */
if (!this.options.asynchronous && this.transport.overrideMimeType)
@@ -935,7 +1113,8 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
this.dispatchException(e);
}
- if ((this.getHeader('Content-type') || 'text/javascript').strip().
+ var contentType = this.getHeader('Content-type');
+ if (contentType && contentType.strip().
match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i))
this.evalResponse();
}
@@ -962,13 +1141,13 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
evalJSON: function() {
try {
var json = this.getHeader('X-JSON');
- return json ? eval('(' + json + ')') : null;
+ return json ? json.evalJSON() : null;
} catch (e) { return null }
},
evalResponse: function() {
try {
- return eval(this.transport.responseText);
+ return eval((this.transport.responseText || '').unfilterJSON());
} catch (e) {
this.dispatchException(e);
}
@@ -1083,50 +1262,52 @@ if (Prototype.BrowserFeatures.XPath) {
results.push(query.snapshotItem(i));
return results;
};
-}
-document.getElementsByClassName = function(className, parentElement) {
- if (Prototype.BrowserFeatures.XPath) {
+ document.getElementsByClassName = function(className, parentElement) {
var q = ".//*[contains(concat(' ', @class, ' '), ' " + className + " ')]";
return document._getElementsByXPath(q, parentElement);
- } else {
- var children = ($(parentElement) || document.body).getElementsByTagName('*');
- var elements = [], child;
- for (var i = 0, length = children.length; i < length; i++) {
- child = children[i];
- if (Element.hasClassName(child, className))
- elements.push(Element.extend(child));
- }
- return elements;
}
+
+} else document.getElementsByClassName = function(className, parentElement) {
+ var children = ($(parentElement) || document.body).getElementsByTagName('*');
+ var elements = [], child;
+ for (var i = 0, length = children.length; i < length; i++) {
+ child = children[i];
+ if (Element.hasClassName(child, className))
+ elements.push(Element.extend(child));
+ }
+ return elements;
};
/*--------------------------------------------------------------------------*/
-if (!window.Element)
- var Element = new Object();
+if (!window.Element) var Element = {};
Element.extend = function(element) {
- if (!element || _nativeExtensions || element.nodeType == 3) return element;
-
- if (!element._extended && element.tagName && element != window) {
- var methods = Object.clone(Element.Methods), cache = Element.extend.cache;
+ var F = Prototype.BrowserFeatures;
+ if (!element || !element.tagName || element.nodeType == 3 ||
+ element._extended || F.SpecificElementExtensions || element == window)
+ return element;
- if (element.tagName == 'FORM')
- Object.extend(methods, Form.Methods);
- if (['INPUT', 'TEXTAREA', 'SELECT'].include(element.tagName))
- Object.extend(methods, Form.Element.Methods);
+ var methods = {}, tagName = element.tagName, cache = Element.extend.cache,
+ T = Element.Methods.ByTag;
+ // extend methods for all tags (Safari doesn't need this)
+ if (!F.ElementExtensions) {
+ Object.extend(methods, Element.Methods),
Object.extend(methods, Element.Methods.Simulated);
+ }
- for (var property in methods) {
- var value = methods[property];
- if (typeof value == 'function' && !(property in element))
- element[property] = cache.findOrStore(value);
- }
+ // extend methods for specific tags
+ if (T[tagName]) Object.extend(methods, T[tagName]);
+
+ for (var property in methods) {
+ var value = methods[property];
+ if (typeof value == 'function' && !(property in element))
+ element[property] = cache.findOrStore(value);
}
- element._extended = true;
+ element._extended = Prototype.emptyFunction;
return element;
};
@@ -1212,7 +1393,13 @@ Element.Methods = {
},
descendants: function(element) {
- return $A($(element).getElementsByTagName('*'));
+ return $A($(element).getElementsByTagName('*')).each(Element.extend);
+ },
+
+ firstDescendant: function(element) {
+ element = $(element).firstChild;
+ while (element && element.nodeType != 1) element = element.nextSibling;
+ return $(element);
},
immediateDescendants: function(element) {
@@ -1242,19 +1429,35 @@ Element.Methods = {
},
up: function(element, expression, index) {
- return Selector.findElement($(element).ancestors(), expression, index);
+ element = $(element);
+ if (arguments.length == 1) return $(element.parentNode);
+ var ancestors = element.ancestors();
+ return expression ? Selector.findElement(ancestors, expression, index) :
+ ancestors[index || 0];
},
down: function(element, expression, index) {
- return Selector.findElement($(element).descendants(), expression, index);
+ element = $(element);
+ if (arguments.length == 1) return element.firstDescendant();
+ var descendants = element.descendants();
+ return expression ? Selector.findElement(descendants, expression, index) :
+ descendants[index || 0];
},
previous: function(element, expression, index) {
- return Selector.findElement($(element).previousSiblings(), expression, index);
+ element = $(element);
+ if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element));
+ var previousSiblings = element.previousSiblings();
+ return expression ? Selector.findElement(previousSiblings, expression, index) :
+ previousSiblings[index || 0];
},
next: function(element, expression, index) {
- return Selector.findElement($(element).nextSiblings(), expression, index);
+ element = $(element);
+ if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element));
+ var nextSiblings = element.nextSiblings();
+ return expression ? Selector.findElement(nextSiblings, expression, index) :
+ nextSiblings[index || 0];
},
getElementsBySelector: function() {
@@ -1268,12 +1471,13 @@ Element.Methods = {
readAttribute: function(element, name) {
element = $(element);
- if (document.all && !window.opera) {
+ if (Prototype.Browser.IE) {
+ if (!element.attributes) return null;
var t = Element._attributeTranslations;
if (t.values[name]) return t.values[name](element, name);
if (t.names[name]) name = t.names[name];
var attribute = element.attributes[name];
- if(attribute) return attribute.nodeValue;
+ return attribute ? attribute.nodeValue : null;
}
return element.getAttribute(name);
},
@@ -1342,7 +1546,7 @@ Element.Methods = {
},
empty: function(element) {
- return $(element).innerHTML.match(/^\s*$/);
+ return $(element).innerHTML.blank();
},
descendantOf: function(element, ancestor) {
@@ -1361,55 +1565,38 @@ Element.Methods = {
getStyle: function(element, style) {
element = $(element);
- if (['float','cssFloat'].include(style))
- style = (typeof element.style.styleFloat != 'undefined' ? 'styleFloat' : 'cssFloat');
- style = style.camelize();
+ style = style == 'float' ? 'cssFloat' : style.camelize();
var value = element.style[style];
if (!value) {
- if (document.defaultView && document.defaultView.getComputedStyle) {
- var css = document.defaultView.getComputedStyle(element, null);
- value = css ? css[style] : null;
- } else if (element.currentStyle) {
- value = element.currentStyle[style];
- }
+ var css = document.defaultView.getComputedStyle(element, null);
+ value = css ? css[style] : null;
}
+ if (style == 'opacity') return value ? parseFloat(value) : 1.0;
+ return value == 'auto' ? null : value;
+ },
- if((value == 'auto') && ['width','height'].include(style) && (element.getStyle('display') != 'none'))
- value = element['offset'+style.capitalize()] + 'px';
+ getOpacity: function(element) {
+ return $(element).getStyle('opacity');
+ },
- if (window.opera && ['left', 'top', 'right', 'bottom'].include(style))
- if (Element.getStyle(element, 'position') == 'static') value = 'auto';
- if(style == 'opacity') {
- if(value) return parseFloat(value);
- if(value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))
- if(value[1]) return parseFloat(value[1]) / 100;
- return 1.0;
- }
- return value == 'auto' ? null : value;
+ setStyle: function(element, styles, camelized) {
+ element = $(element);
+ var elementStyle = element.style;
+
+ for (var property in styles)
+ if (property == 'opacity') element.setOpacity(styles[property])
+ else
+ elementStyle[(property == 'float' || property == 'cssFloat') ?
+ (elementStyle.styleFloat === undefined ? 'cssFloat' : 'styleFloat') :
+ (camelized ? property : property.camelize())] = styles[property];
+
+ return element;
},
- setStyle: function(element, style) {
+ setOpacity: function(element, value) {
element = $(element);
- for (var name in style) {
- var value = style[name];
- if(name == 'opacity') {
- if (value == 1) {
- value = (/Gecko/.test(navigator.userAgent) &&
- !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? 0.999999 : 1.0;
- if(/MSIE/.test(navigator.userAgent) && !window.opera)
- element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'');
- } else if(value == '') {
- if(/MSIE/.test(navigator.userAgent) && !window.opera)
- element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'');
- } else {
- if(value < 0.00001) value = 0;
- if(/MSIE/.test(navigator.userAgent) && !window.opera)
- element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'') +
- 'alpha(opacity='+value*100+')';
- }
- } else if(['float','cssFloat'].include(name)) name = (typeof element.style.styleFloat != 'undefined') ? 'styleFloat' : 'cssFloat';
- element.style[name.camelize()] = value;
- }
+ element.style.opacity = (value == 1 || value === '') ? '' :
+ (value < 0.00001) ? 0 : value;
return element;
},
@@ -1483,61 +1670,58 @@ Element.Methods = {
}
};
-Object.extend(Element.Methods, {childOf: Element.Methods.descendantOf});
-
-Element._attributeTranslations = {};
-
-Element._attributeTranslations.names = {
- colspan: "colSpan",
- rowspan: "rowSpan",
- valign: "vAlign",
- datetime: "dateTime",
- accesskey: "accessKey",
- tabindex: "tabIndex",
- enctype: "encType",
- maxlength: "maxLength",
- readonly: "readOnly",
- longdesc: "longDesc"
-};
-
-Element._attributeTranslations.values = {
- _getAttr: function(element, attribute) {
- return element.getAttribute(attribute, 2);
- },
-
- _flag: function(element, attribute) {
- return $(element).hasAttribute(attribute) ? attribute : null;
- },
+Object.extend(Element.Methods, {
+ childOf: Element.Methods.descendantOf,
+ childElements: Element.Methods.immediateDescendants
+});
- style: function(element) {
- return element.style.cssText.toLowerCase();
- },
+if (Prototype.Browser.Opera) {
+ Element.Methods._getStyle = Element.Methods.getStyle;
+ Element.Methods.getStyle = function(element, style) {
+ switch(style) {
+ case 'left':
+ case 'top':
+ case 'right':
+ case 'bottom':
+ if (Element._getStyle(element, 'position') == 'static') return null;
+ default: return Element._getStyle(element, style);
+ }
+ };
+}
+else if (Prototype.Browser.IE) {
+ Element.Methods.getStyle = function(element, style) {
+ element = $(element);
+ style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize();
+ var value = element.style[style];
+ if (!value && element.currentStyle) value = element.currentStyle[style];
- title: function(element) {
- var node = element.getAttributeNode('title');
- return node.specified ? node.nodeValue : null;
- }
-};
+ if (style == 'opacity') {
+ if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))
+ if (value[1]) return parseFloat(value[1]) / 100;
+ return 1.0;
+ }
-Object.extend(Element._attributeTranslations.values, {
- href: Element._attributeTranslations.values._getAttr,
- src: Element._attributeTranslations.values._getAttr,
- disabled: Element._attributeTranslations.values._flag,
- checked: Element._attributeTranslations.values._flag,
- readonly: Element._attributeTranslations.values._flag,
- multiple: Element._attributeTranslations.values._flag
-});
+ if (value == 'auto') {
+ if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none'))
+ return element['offset'+style.capitalize()] + 'px';
+ return null;
+ }
+ return value;
+ };
-Element.Methods.Simulated = {
- hasAttribute: function(element, attribute) {
- var t = Element._attributeTranslations;
- attribute = t.names[attribute] || attribute;
- return $(element).getAttributeNode(attribute).specified;
- }
-};
+ Element.Methods.setOpacity = function(element, value) {
+ element = $(element);
+ var filter = element.getStyle('filter'), style = element.style;
+ if (value == 1 || value === '') {
+ style.filter = filter.replace(/alpha\([^\)]*\)/gi,'');
+ return element;
+ } else if (value < 0.00001) value = 0;
+ style.filter = filter.replace(/alpha\([^\)]*\)/gi, '') +
+ 'alpha(opacity=' + (value * 100) + ')';
+ return element;
+ };
-// IE is missing .innerHTML support for TABLE-related elements
-if (document.all && !window.opera){
+ // IE is missing .innerHTML support for TABLE-related elements
Element.Methods.update = function(element, html) {
element = $(element);
html = typeof html == 'undefined' ? '' : html.toString();
@@ -1558,35 +1742,123 @@ if (document.all && !window.opera){
div.innerHTML = '<table><tbody><tr><td>' + html.stripScripts() + '</td></tr></tbody></table>';
depth = 4;
}
- $A(element.childNodes).each(function(node){
- element.removeChild(node)
- });
- depth.times(function(){ div = div.firstChild });
-
- $A(div.childNodes).each(
- function(node){ element.appendChild(node) });
+ $A(element.childNodes).each(function(node) { element.removeChild(node) });
+ depth.times(function() { div = div.firstChild });
+ $A(div.childNodes).each(function(node) { element.appendChild(node) });
} else {
element.innerHTML = html.stripScripts();
}
- setTimeout(function() {html.evalScripts()}, 10);
+ setTimeout(function() { html.evalScripts() }, 10);
+ return element;
+ }
+}
+else if (Prototype.Browser.Gecko) {
+ Element.Methods.setOpacity = function(element, value) {
+ element = $(element);
+ element.style.opacity = (value == 1) ? 0.999999 :
+ (value === '') ? '' : (value < 0.00001) ? 0 : value;
return element;
+ };
+}
+
+Element._attributeTranslations = {
+ names: {
+ colspan: "colSpan",
+ rowspan: "rowSpan",
+ valign: "vAlign",
+ datetime: "dateTime",
+ accesskey: "accessKey",
+ tabindex: "tabIndex",
+ enctype: "encType",
+ maxlength: "maxLength",
+ readonly: "readOnly",
+ longdesc: "longDesc"
+ },
+ values: {
+ _getAttr: function(element, attribute) {
+ return element.getAttribute(attribute, 2);
+ },
+ _flag: function(element, attribute) {
+ return $(element).hasAttribute(attribute) ? attribute : null;
+ },
+ style: function(element) {
+ return element.style.cssText.toLowerCase();
+ },
+ title: function(element) {
+ var node = element.getAttributeNode('title');
+ return node.specified ? node.nodeValue : null;
+ }
}
};
+(function() {
+ Object.extend(this, {
+ href: this._getAttr,
+ src: this._getAttr,
+ type: this._getAttr,
+ disabled: this._flag,
+ checked: this._flag,
+ readonly: this._flag,
+ multiple: this._flag
+ });
+}).call(Element._attributeTranslations.values);
+
+Element.Methods.Simulated = {
+ hasAttribute: function(element, attribute) {
+ var t = Element._attributeTranslations, node;
+ attribute = t.names[attribute] || attribute;
+ node = $(element).getAttributeNode(attribute);
+ return node && node.specified;
+ }
+};
+
+Element.Methods.ByTag = {};
+
Object.extend(Element, Element.Methods);
-var _nativeExtensions = false;
+if (!Prototype.BrowserFeatures.ElementExtensions &&
+ document.createElement('div').__proto__) {
+ window.HTMLElement = {};
+ window.HTMLElement.prototype = document.createElement('div').__proto__;
+ Prototype.BrowserFeatures.ElementExtensions = true;
+}
-if(/Konqueror|Safari|KHTML/.test(navigator.userAgent))
- ['', 'Form', 'Input', 'TextArea', 'Select'].each(function(tag) {
- var className = 'HTML' + tag + 'Element';
- if(window[className]) return;
- var klass = window[className] = {};
- klass.prototype = document.createElement(tag ? tag.toLowerCase() : 'div').__proto__;
- });
+Element.hasAttribute = function(element, attribute) {
+ if (element.hasAttribute) return element.hasAttribute(attribute);
+ return Element.Methods.Simulated.hasAttribute(element, attribute);
+};
Element.addMethods = function(methods) {
- Object.extend(Element.Methods, methods || {});
+ var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag;
+
+ if (!methods) {
+ Object.extend(Form, Form.Methods);
+ Object.extend(Form.Element, Form.Element.Methods);
+ Object.extend(Element.Methods.ByTag, {
+ "FORM": Object.clone(Form.Methods),
+ "INPUT": Object.clone(Form.Element.Methods),
+ "SELECT": Object.clone(Form.Element.Methods),
+ "TEXTAREA": Object.clone(Form.Element.Methods)
+ });
+ }
+
+ if (arguments.length == 2) {
+ var tagName = methods;
+ methods = arguments[1];
+ }
+
+ if (!tagName) Object.extend(Element.Methods, methods || {});
+ else {
+ if (tagName.constructor == Array) tagName.each(extend);
+ else extend(tagName);
+ }
+
+ function extend(tagName) {
+ tagName = tagName.toUpperCase();
+ if (!Element.Methods.ByTag[tagName])
+ Element.Methods.ByTag[tagName] = {};
+ Object.extend(Element.Methods.ByTag[tagName], methods);
+ }
function copy(methods, destination, onlyIfAbsent) {
onlyIfAbsent = onlyIfAbsent || false;
@@ -1598,19 +1870,49 @@ Element.addMethods = function(methods) {
}
}
- if (typeof HTMLElement != 'undefined') {
+ function findDOMClass(tagName) {
+ var klass;
+ var trans = {
+ "OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph",
+ "FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList",
+ "DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading",
+ "H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote",
+ "INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION":
+ "TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD":
+ "TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR":
+ "TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET":
+ "FrameSet", "IFRAME": "IFrame"
+ };
+ if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element';
+ if (window[klass]) return window[klass];
+ klass = 'HTML' + tagName + 'Element';
+ if (window[klass]) return window[klass];
+ klass = 'HTML' + tagName.capitalize() + 'Element';
+ if (window[klass]) return window[klass];
+
+ window[klass] = {};
+ window[klass].prototype = document.createElement(tagName).__proto__;
+ return window[klass];
+ }
+
+ if (F.ElementExtensions) {
copy(Element.Methods, HTMLElement.prototype);
copy(Element.Methods.Simulated, HTMLElement.prototype, true);
- copy(Form.Methods, HTMLFormElement.prototype);
- [HTMLInputElement, HTMLTextAreaElement, HTMLSelectElement].each(function(klass) {
- copy(Form.Element.Methods, klass.prototype);
- });
- _nativeExtensions = true;
}
-}
-var Toggle = new Object();
-Toggle.display = Element.toggle;
+ if (F.SpecificElementExtensions) {
+ for (var tag in Element.Methods.ByTag) {
+ var klass = findDOMClass(tag);
+ if (typeof klass == "undefined") continue;
+ copy(T[tag], klass.prototype);
+ }
+ }
+
+ Object.extend(Element, Element.Methods);
+ delete Element.ByTag;
+};
+
+var Toggle = { display: Element.toggle };
/*--------------------------------------------------------------------------*/
@@ -1741,129 +2043,572 @@ Element.ClassNames.prototype = {
};
Object.extend(Element.ClassNames.prototype, Enumerable);
+/* Portions of the Selector class are derived from Jack Slocum’s DomQuery,
+ * part of YUI-Ext version 0.40, distributed under the terms of an MIT-style
+ * license. Please see http://www.yui-ext.com/ for more information. */
+
var Selector = Class.create();
+
Selector.prototype = {
initialize: function(expression) {
- this.params = {classNames: []};
- this.expression = expression.toString().strip();
- this.parseExpression();
+ this.expression = expression.strip();
this.compileMatcher();
},
- parseExpression: function() {
- function abort(message) { throw 'Parse error in selector: ' + message; }
+ compileMatcher: function() {
+ // Selectors with namespaced attributes can't use the XPath version
+ if (Prototype.BrowserFeatures.XPath && !(/\[[\w-]*?:/).test(this.expression))
+ return this.compileXPathMatcher();
- if (this.expression == '') abort('empty expression');
+ var e = this.expression, ps = Selector.patterns, h = Selector.handlers,
+ c = Selector.criteria, le, p, m;
- var params = this.params, expr = this.expression, match, modifier, clause, rest;
- while (match = expr.match(/^(.*)\[([a-z0-9_:-]+?)(?:([~\|!]?=)(?:"([^"]*)"|([^\]\s]*)))?\]$/i)) {
- params.attributes = params.attributes || [];
- params.attributes.push({name: match[2], operator: match[3], value: match[4] || match[5] || ''});
- expr = match[1];
+ if (Selector._cache[e]) {
+ this.matcher = Selector._cache[e]; return;
}
-
- if (expr == '*') return this.params.wildcard = true;
-
- while (match = expr.match(/^([^a-z0-9_-])?([a-z0-9_-]+)(.*)/i)) {
- modifier = match[1], clause = match[2], rest = match[3];
- switch (modifier) {
- case '#': params.id = clause; break;
- case '.': params.classNames.push(clause); break;
- case '':
- case undefined: params.tagName = clause.toUpperCase(); break;
- default: abort(expr.inspect());
+ this.matcher = ["this.matcher = function(root) {",
+ "var r = root, h = Selector.handlers, c = false, n;"];
+
+ while (e && le != e && (/\S/).test(e)) {
+ le = e;
+ for (var i in ps) {
+ p = ps[i];
+ if (m = e.match(p)) {
+ this.matcher.push(typeof c[i] == 'function' ? c[i](m) :
+ new Template(c[i]).evaluate(m));
+ e = e.replace(m[0], '');
+ break;
+ }
}
- expr = rest;
}
- if (expr.length > 0) abort(expr.inspect());
+ this.matcher.push("return h.unique(n);\n}");
+ eval(this.matcher.join('\n'));
+ Selector._cache[this.expression] = this.matcher;
},
- buildMatchExpression: function() {
- var params = this.params, conditions = [], clause;
+ compileXPathMatcher: function() {
+ var e = this.expression, ps = Selector.patterns,
+ x = Selector.xpath, le, m;
- if (params.wildcard)
- conditions.push('true');
- if (clause = params.id)
- conditions.push('element.readAttribute("id") == ' + clause.inspect());
- if (clause = params.tagName)
- conditions.push('element.tagName.toUpperCase() == ' + clause.inspect());
- if ((clause = params.classNames).length > 0)
- for (var i = 0, length = clause.length; i < length; i++)
- conditions.push('element.hasClassName(' + clause[i].inspect() + ')');
- if (clause = params.attributes) {
- clause.each(function(attribute) {
- var value = 'element.readAttribute(' + attribute.name.inspect() + ')';
- var splitValueBy = function(delimiter) {
- return value + ' && ' + value + '.split(' + delimiter.inspect() + ')';
- }
+ if (Selector._cache[e]) {
+ this.xpath = Selector._cache[e]; return;
+ }
- switch (attribute.operator) {
- case '=': conditions.push(value + ' == ' + attribute.value.inspect()); break;
- case '~=': conditions.push(splitValueBy(' ') + '.include(' + attribute.value.inspect() + ')'); break;
- case '|=': conditions.push(
- splitValueBy('-') + '.first().toUpperCase() == ' + attribute.value.toUpperCase().inspect()
- ); break;
- case '!=': conditions.push(value + ' != ' + attribute.value.inspect()); break;
- case '':
- case undefined: conditions.push('element.hasAttribute(' + attribute.name.inspect() + ')'); break;
- default: throw 'Unknown operator ' + attribute.operator + ' in selector';
+ this.matcher = ['.//*'];
+ while (e && le != e && (/\S/).test(e)) {
+ le = e;
+ for (var i in ps) {
+ if (m = e.match(ps[i])) {
+ this.matcher.push(typeof x[i] == 'function' ? x[i](m) :
+ new Template(x[i]).evaluate(m));
+ e = e.replace(m[0], '');
+ break;
}
- });
+ }
}
- return conditions.join(' && ');
+ this.xpath = this.matcher.join('');
+ Selector._cache[this.expression] = this.xpath;
},
- compileMatcher: function() {
- this.match = new Function('element', 'if (!element.tagName) return false; \
- element = $(element); \
- return ' + this.buildMatchExpression());
+ findElements: function(root) {
+ root = root || document;
+ if (this.xpath) return document._getElementsByXPath(this.xpath, root);
+ return this.matcher(root);
},
- findElements: function(scope) {
- var element;
-
- if (element = $(this.params.id))
- if (this.match(element))
- if (!scope || Element.childOf(element, scope))
- return [element];
-
- scope = (scope || document).getElementsByTagName(this.params.tagName || '*');
-
- var results = [];
- for (var i = 0, length = scope.length; i < length; i++)
- if (this.match(element = scope[i]))
- results.push(Element.extend(element));
-
- return results;
+ match: function(element) {
+ return this.findElements(document).include(element);
},
toString: function() {
return this.expression;
+ },
+
+ inspect: function() {
+ return "#<Selector:" + this.expression.inspect() + ">";
}
-}
+};
Object.extend(Selector, {
+ _cache: {},
+
+ xpath: {
+ descendant: "//*",
+ child: "/*",
+ adjacent: "/following-sibling::*[1]",
+ laterSibling: '/following-sibling::*',
+ tagName: function(m) {
+ if (m[1] == '*') return '';
+ return "[local-name()='" + m[1].toLowerCase() +
+ "' or local-name()='" + m[1].toUpperCase() + "']";
+ },
+ className: "[contains(concat(' ', @class, ' '), ' #{1} ')]",
+ id: "[@id='#{1}']",
+ attrPresence: "[@#{1}]",
+ attr: function(m) {
+ m[3] = m[5] || m[6];
+ return new Template(Selector.xpath.operators[m[2]]).evaluate(m);
+ },
+ pseudo: function(m) {
+ var h = Selector.xpath.pseudos[m[1]];
+ if (!h) return '';
+ if (typeof h === 'function') return h(m);
+ return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m);
+ },
+ operators: {
+ '=': "[@#{1}='#{3}']",
+ '!=': "[@#{1}!='#{3}']",
+ '^=': "[starts-with(@#{1}, '#{3}')]",
+ '$=': "[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']",
+ '*=': "[contains(@#{1}, '#{3}')]",
+ '~=': "[contains(concat(' ', @#{1}, ' '), ' #{3} ')]",
+ '|=': "[contains(concat('-', @#{1}, '-'), '-#{3}-')]"
+ },
+ pseudos: {
+ 'first-child': '[not(preceding-sibling::*)]',
+ 'last-child': '[not(following-sibling::*)]',
+ 'only-child': '[not(preceding-sibling::* or following-sibling::*)]',
+ 'empty': "[count(*) = 0 and (count(text()) = 0 or translate(text(), ' \t\r\n', '') = '')]",
+ 'checked': "[@checked]",
+ 'disabled': "[@disabled]",
+ 'enabled': "[not(@disabled)]",
+ 'not': function(m) {
+ var e = m[6], p = Selector.patterns,
+ x = Selector.xpath, le, m, v;
+
+ var exclusion = [];
+ while (e && le != e && (/\S/).test(e)) {
+ le = e;
+ for (var i in p) {
+ if (m = e.match(p[i])) {
+ v = typeof x[i] == 'function' ? x[i](m) : new Template(x[i]).evaluate(m);
+ exclusion.push("(" + v.substring(1, v.length - 1) + ")");
+ e = e.replace(m[0], '');
+ break;
+ }
+ }
+ }
+ return "[not(" + exclusion.join(" and ") + ")]";
+ },
+ 'nth-child': function(m) {
+ return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ", m);
+ },
+ 'nth-last-child': function(m) {
+ return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ", m);
+ },
+ 'nth-of-type': function(m) {
+ return Selector.xpath.pseudos.nth("position() ", m);
+ },
+ 'nth-last-of-type': function(m) {
+ return Selector.xpath.pseudos.nth("(last() + 1 - position()) ", m);
+ },
+ 'first-of-type': function(m) {
+ m[6] = "1"; return Selector.xpath.pseudos['nth-of-type'](m);
+ },
+ 'last-of-type': function(m) {
+ m[6] = "1"; return Selector.xpath.pseudos['nth-last-of-type'](m);
+ },
+ 'only-of-type': function(m) {
+ var p = Selector.xpath.pseudos; return p['first-of-type'](m) + p['last-of-type'](m);
+ },
+ nth: function(fragment, m) {
+ var mm, formula = m[6], predicate;
+ if (formula == 'even') formula = '2n+0';
+ if (formula == 'odd') formula = '2n+1';
+ if (mm = formula.match(/^(\d+)$/)) // digit only
+ return '[' + fragment + "= " + mm[1] + ']';
+ if (mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
+ if (mm[1] == "-") mm[1] = -1;
+ var a = mm[1] ? Number(mm[1]) : 1;
+ var b = mm[2] ? Number(mm[2]) : 0;
+ predicate = "[((#{fragment} - #{b}) mod #{a} = 0) and " +
+ "((#{fragment} - #{b}) div #{a} >= 0)]";
+ return new Template(predicate).evaluate({
+ fragment: fragment, a: a, b: b });
+ }
+ }
+ }
+ },
+
+ criteria: {
+ tagName: 'n = h.tagName(n, r, "#{1}", c); c = false;',
+ className: 'n = h.className(n, r, "#{1}", c); c = false;',
+ id: 'n = h.id(n, r, "#{1}", c); c = false;',
+ attrPresence: 'n = h.attrPresence(n, r, "#{1}"); c = false;',
+ attr: function(m) {
+ m[3] = (m[5] || m[6]);
+ return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}"); c = false;').evaluate(m);
+ },
+ pseudo: function(m) {
+ if (m[6]) m[6] = m[6].replace(/"/g, '\\"');
+ return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m);
+ },
+ descendant: 'c = "descendant";',
+ child: 'c = "child";',
+ adjacent: 'c = "adjacent";',
+ laterSibling: 'c = "laterSibling";'
+ },
+
+ patterns: {
+ // combinators must be listed first
+ // (and descendant needs to be last combinator)
+ laterSibling: /^\s*~\s*/,
+ child: /^\s*>\s*/,
+ adjacent: /^\s*\+\s*/,
+ descendant: /^\s/,
+
+ // selectors follow
+ tagName: /^\s*(\*|[\w\-]+)(\b|$)?/,
+ id: /^#([\w\-\*]+)(\b|$)/,
+ className: /^\.([\w\-\*]+)(\b|$)/,
+ pseudo: /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|\s|(?=:))/,
+ attrPresence: /^\[([\w]+)\]/,
+ attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\]]*?)\4|([^'"][^\]]*?)))?\]/
+ },
+
+ handlers: {
+ // UTILITY FUNCTIONS
+ // joins two collections
+ concat: function(a, b) {
+ for (var i = 0, node; node = b[i]; i++)
+ a.push(node);
+ return a;
+ },
+
+ // marks an array of nodes for counting
+ mark: function(nodes) {
+ for (var i = 0, node; node = nodes[i]; i++)
+ node._counted = true;
+ return nodes;
+ },
+
+ unmark: function(nodes) {
+ for (var i = 0, node; node = nodes[i]; i++)
+ node._counted = undefined;
+ return nodes;
+ },
+
+ // mark each child node with its position (for nth calls)
+ // "ofType" flag indicates whether we're indexing for nth-of-type
+ // rather than nth-child
+ index: function(parentNode, reverse, ofType) {
+ parentNode._counted = true;
+ if (reverse) {
+ for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) {
+ node = nodes[i];
+ if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++;
+ }
+ } else {
+ for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++)
+ if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++;
+ }
+ },
+
+ // filters out duplicates and extends all nodes
+ unique: function(nodes) {
+ if (nodes.length == 0) return nodes;
+ var results = [], n;
+ for (var i = 0, l = nodes.length; i < l; i++)
+ if (!(n = nodes[i])._counted) {
+ n._counted = true;
+ results.push(Element.extend(n));
+ }
+ return Selector.handlers.unmark(results);
+ },
+
+ // COMBINATOR FUNCTIONS
+ descendant: function(nodes) {
+ var h = Selector.handlers;
+ for (var i = 0, results = [], node; node = nodes[i]; i++)
+ h.concat(results, node.getElementsByTagName('*'));
+ return results;
+ },
+
+ child: function(nodes) {
+ var h = Selector.handlers;
+ for (var i = 0, results = [], node; node = nodes[i]; i++) {
+ for (var j = 0, children = [], child; child = node.childNodes[j]; j++)
+ if (child.nodeType == 1 && child.tagName != '!') results.push(child);
+ }
+ return results;
+ },
+
+ adjacent: function(nodes) {
+ for (var i = 0, results = [], node; node = nodes[i]; i++) {
+ var next = this.nextElementSibling(node);
+ if (next) results.push(next);
+ }
+ return results;
+ },
+
+ laterSibling: function(nodes) {
+ var h = Selector.handlers;
+ for (var i = 0, results = [], node; node = nodes[i]; i++)
+ h.concat(results, Element.nextSiblings(node));
+ return results;
+ },
+
+ nextElementSibling: function(node) {
+ while (node = node.nextSibling)
+ if (node.nodeType == 1) return node;
+ return null;
+ },
+
+ previousElementSibling: function(node) {
+ while (node = node.previousSibling)
+ if (node.nodeType == 1) return node;
+ return null;
+ },
+
+ // TOKEN FUNCTIONS
+ tagName: function(nodes, root, tagName, combinator) {
+ tagName = tagName.toUpperCase();
+ var results = [], h = Selector.handlers;
+ if (nodes) {
+ if (combinator) {
+ // fastlane for ordinary descendant combinators
+ if (combinator == "descendant") {
+ for (var i = 0, node; node = nodes[i]; i++)
+ h.concat(results, node.getElementsByTagName(tagName));
+ return results;
+ } else nodes = this[combinator](nodes);
+ if (tagName == "*") return nodes;
+ }
+ for (var i = 0, node; node = nodes[i]; i++)
+ if (node.tagName.toUpperCase() == tagName) results.push(node);
+ return results;
+ } else return root.getElementsByTagName(tagName);
+ },
+
+ id: function(nodes, root, id, combinator) {
+ var targetNode = $(id), h = Selector.handlers;
+ if (!nodes && root == document) return targetNode ? [targetNode] : [];
+ if (nodes) {
+ if (combinator) {
+ if (combinator == 'child') {
+ for (var i = 0, node; node = nodes[i]; i++)
+ if (targetNode.parentNode == node) return [targetNode];
+ } else if (combinator == 'descendant') {
+ for (var i = 0, node; node = nodes[i]; i++)
+ if (Element.descendantOf(targetNode, node)) return [targetNode];
+ } else if (combinator == 'adjacent') {
+ for (var i = 0, node; node = nodes[i]; i++)
+ if (Selector.handlers.previousElementSibling(targetNode) == node)
+ return [targetNode];
+ } else nodes = h[combinator](nodes);
+ }
+ for (var i = 0, node; node = nodes[i]; i++)
+ if (node == targetNode) return [targetNode];
+ return [];
+ }
+ return (targetNode && Element.descendantOf(targetNode, root)) ? [targetNode] : [];
+ },
+
+ className: function(nodes, root, className, combinator) {
+ if (nodes && combinator) nodes = this[combinator](nodes);
+ return Selector.handlers.byClassName(nodes, root, className);
+ },
+
+ byClassName: function(nodes, root, className) {
+ if (!nodes) nodes = Selector.handlers.descendant([root]);
+ var needle = ' ' + className + ' ';
+ for (var i = 0, results = [], node, nodeClassName; node = nodes[i]; i++) {
+ nodeClassName = node.className;
+ if (nodeClassName.length == 0) continue;
+ if (nodeClassName == className || (' ' + nodeClassName + ' ').include(needle))
+ results.push(node);
+ }
+ return results;
+ },
+
+ attrPresence: function(nodes, root, attr) {
+ var results = [];
+ for (var i = 0, node; node = nodes[i]; i++)
+ if (Element.hasAttribute(node, attr)) results.push(node);
+ return results;
+ },
+
+ attr: function(nodes, root, attr, value, operator) {
+ if (!nodes) nodes = root.getElementsByTagName("*");
+ var handler = Selector.operators[operator], results = [];
+ for (var i = 0, node; node = nodes[i]; i++) {
+ var nodeValue = Element.readAttribute(node, attr);
+ if (nodeValue === null) continue;
+ if (handler(nodeValue, value)) results.push(node);
+ }
+ return results;
+ },
+
+ pseudo: function(nodes, name, value, root, combinator) {
+ if (nodes && combinator) nodes = this[combinator](nodes);
+ if (!nodes) nodes = root.getElementsByTagName("*");
+ return Selector.pseudos[name](nodes, value, root);
+ }
+ },
+
+ pseudos: {
+ 'first-child': function(nodes, value, root) {
+ for (var i = 0, results = [], node; node = nodes[i]; i++) {
+ if (Selector.handlers.previousElementSibling(node)) continue;
+ results.push(node);
+ }
+ return results;
+ },
+ 'last-child': function(nodes, value, root) {
+ for (var i = 0, results = [], node; node = nodes[i]; i++) {
+ if (Selector.handlers.nextElementSibling(node)) continue;
+ results.push(node);
+ }
+ return results;
+ },
+ 'only-child': function(nodes, value, root) {
+ var h = Selector.handlers;
+ for (var i = 0, results = [], node; node = nodes[i]; i++)
+ if (!h.previousElementSibling(node) && !h.nextElementSibling(node))
+ results.push(node);
+ return results;
+ },
+ 'nth-child': function(nodes, formula, root) {
+ return Selector.pseudos.nth(nodes, formula, root);
+ },
+ 'nth-last-child': function(nodes, formula, root) {
+ return Selector.pseudos.nth(nodes, formula, root, true);
+ },
+ 'nth-of-type': function(nodes, formula, root) {
+ return Selector.pseudos.nth(nodes, formula, root, false, true);
+ },
+ 'nth-last-of-type': function(nodes, formula, root) {
+ return Selector.pseudos.nth(nodes, formula, root, true, true);
+ },
+ 'first-of-type': function(nodes, formula, root) {
+ return Selector.pseudos.nth(nodes, "1", root, false, true);
+ },
+ 'last-of-type': function(nodes, formula, root) {
+ return Selector.pseudos.nth(nodes, "1", root, true, true);
+ },
+ 'only-of-type': function(nodes, formula, root) {
+ var p = Selector.pseudos;
+ return p['last-of-type'](p['first-of-type'](nodes, formula, root), formula, root);
+ },
+
+ // handles the an+b logic
+ getIndices: function(a, b, total) {
+ if (a == 0) return b > 0 ? [b] : [];
+ return $R(1, total).inject([], function(memo, i) {
+ if (0 == (i - b) % a && (i - b) / a >= 0) memo.push(i);
+ return memo;
+ });
+ },
+
+ // handles nth(-last)-child, nth(-last)-of-type, and (first|last)-of-type
+ nth: function(nodes, formula, root, reverse, ofType) {
+ if (nodes.length == 0) return [];
+ if (formula == 'even') formula = '2n+0';
+ if (formula == 'odd') formula = '2n+1';
+ var h = Selector.handlers, results = [], indexed = [], m;
+ h.mark(nodes);
+ for (var i = 0, node; node = nodes[i]; i++) {
+ if (!node.parentNode._counted) {
+ h.index(node.parentNode, reverse, ofType);
+ indexed.push(node.parentNode);
+ }
+ }
+ if (formula.match(/^\d+$/)) { // just a number
+ formula = Number(formula);
+ for (var i = 0, node; node = nodes[i]; i++)
+ if (node.nodeIndex == formula) results.push(node);
+ } else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
+ if (m[1] == "-") m[1] = -1;
+ var a = m[1] ? Number(m[1]) : 1;
+ var b = m[2] ? Number(m[2]) : 0;
+ var indices = Selector.pseudos.getIndices(a, b, nodes.length);
+ for (var i = 0, node, l = indices.length; node = nodes[i]; i++) {
+ for (var j = 0; j < l; j++)
+ if (node.nodeIndex == indices[j]) results.push(node);
+ }
+ }
+ h.unmark(nodes);
+ h.unmark(indexed);
+ return results;
+ },
+
+ 'empty': function(nodes, value, root) {
+ for (var i = 0, results = [], node; node = nodes[i]; i++) {
+ // IE treats comments as element nodes
+ if (node.tagName == '!' || (node.firstChild && !node.innerHTML.match(/^\s*$/))) continue;
+ results.push(node);
+ }
+ return results;
+ },
+
+ 'not': function(nodes, selector, root) {
+ var h = Selector.handlers, selectorType, m;
+ var exclusions = new Selector(selector).findElements(root);
+ h.mark(exclusions);
+ for (var i = 0, results = [], node; node = nodes[i]; i++)
+ if (!node._counted) results.push(node);
+ h.unmark(exclusions);
+ return results;
+ },
+
+ 'enabled': function(nodes, value, root) {
+ for (var i = 0, results = [], node; node = nodes[i]; i++)
+ if (!node.disabled) results.push(node);
+ return results;
+ },
+
+ 'disabled': function(nodes, value, root) {
+ for (var i = 0, results = [], node; node = nodes[i]; i++)
+ if (node.disabled) results.push(node);
+ return results;
+ },
+
+ 'checked': function(nodes, value, root) {
+ for (var i = 0, results = [], node; node = nodes[i]; i++)
+ if (node.checked) results.push(node);
+ return results;
+ }
+ },
+
+ operators: {
+ '=': function(nv, v) { return nv == v; },
+ '!=': function(nv, v) { return nv != v; },
+ '^=': function(nv, v) { return nv.startsWith(v); },
+ '$=': function(nv, v) { return nv.endsWith(v); },
+ '*=': function(nv, v) { return nv.include(v); },
+ '~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); },
+ '|=': function(nv, v) { return ('-' + nv.toUpperCase() + '-').include('-' + v.toUpperCase() + '-'); }
+ },
+
matchElements: function(elements, expression) {
- var selector = new Selector(expression);
- return elements.select(selector.match.bind(selector)).map(Element.extend);
+ var matches = new Selector(expression).findElements(), h = Selector.handlers;
+ h.mark(matches);
+ for (var i = 0, results = [], element; element = elements[i]; i++)
+ if (element._counted) results.push(element);
+ h.unmark(matches);
+ return results;
},
findElement: function(elements, expression, index) {
- if (typeof expression == 'number') index = expression, expression = false;
+ if (typeof expression == 'number') {
+ index = expression; expression = false;
+ }
return Selector.matchElements(elements, expression || '*')[index || 0];
},
findChildElements: function(element, expressions) {
- return expressions.map(function(expression) {
- return expression.match(/[^\s"]+(?:"[^"]*"[^\s"]+)*/g).inject([null], function(results, expr) {
- var selector = new Selector(expr);
- return results.inject([], function(elements, result) {
- return elements.concat(selector.findElements(result || element));
- });
- });
- }).flatten();
+ var exprs = expressions.join(','), expressions = [];
+ exprs.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) {
+ expressions.push(m[1].strip());
+ });
+ var results = [], h = Selector.handlers;
+ for (var i = 0, l = expressions.length, selector; i < l; i++) {
+ selector = new Selector(expressions[i].strip());
+ h.concat(results, selector.findElements(element));
+ }
+ return (l > 1) ? h.unique(results) : results;
}
});
@@ -1880,8 +2625,8 @@ var Form = {
var data = elements.inject({}, function(result, element) {
if (!element.disabled && element.name) {
var key = element.name, value = $(element).getValue();
- if (value != undefined) {
- if (result[key]) {
+ if (value != null) {
+ if (key in result) {
if (result[key].constructor != Array) result[key] = [result[key]];
result[key].push(value);
}
@@ -1928,18 +2673,13 @@ Form.Methods = {
disable: function(form) {
form = $(form);
- form.getElements().each(function(element) {
- element.blur();
- element.disabled = 'true';
- });
+ Form.getElements(form).invoke('disable');
return form;
},
enable: function(form) {
form = $(form);
- form.getElements().each(function(element) {
- element.disabled = '';
- });
+ Form.getElements(form).invoke('enable');
return form;
},
@@ -1954,11 +2694,26 @@ Form.Methods = {
form = $(form);
form.findFirstElement().activate();
return form;
+ },
+
+ request: function(form, options) {
+ form = $(form), options = Object.clone(options || {});
+
+ var params = options.parameters;
+ options.parameters = form.serialize(true);
+
+ if (params) {
+ if (typeof params == 'string') params = params.toQueryParams();
+ Object.extend(options.parameters, params);
+ }
+
+ if (form.hasAttribute('method') && !options.method)
+ options.method = form.method;
+
+ return new Ajax.Request(form.readAttribute('action'), options);
}
}
-Object.extend(Form, Form.Methods);
-
/*--------------------------------------------------------------------------*/
Form.Element = {
@@ -2004,30 +2759,33 @@ Form.Element.Methods = {
activate: function(element) {
element = $(element);
- element.focus();
- if (element.select && ( element.tagName.toLowerCase() != 'input' ||
- !['button', 'reset', 'submit'].include(element.type) ) )
- element.select();
+ try {
+ element.focus();
+ if (element.select && (element.tagName.toLowerCase() != 'input' ||
+ !['button', 'reset', 'submit'].include(element.type)))
+ element.select();
+ } catch (e) {}
return element;
},
disable: function(element) {
element = $(element);
+ element.blur();
element.disabled = true;
return element;
},
enable: function(element) {
element = $(element);
- element.blur();
element.disabled = false;
return element;
}
}
-Object.extend(Form.Element, Form.Element.Methods);
+/*--------------------------------------------------------------------------*/
+
var Field = Form.Element;
-var $F = Form.Element.getValue;
+var $F = Form.Element.Methods.getValue;
/*--------------------------------------------------------------------------*/
@@ -2194,7 +2952,7 @@ Object.extend(Event, {
KEY_PAGEDOWN: 34,
element: function(event) {
- return event.target || event.srcElement;
+ return $(event.target || event.srcElement);
},
isLeftClick: function(event) {
@@ -2259,8 +3017,7 @@ Object.extend(Event, {
useCapture = useCapture || false;
if (name == 'keypress' &&
- (navigator.appVersion.match(/Konqueror|Safari|KHTML/)
- || element.attachEvent))
+ (Prototype.Browser.WebKit || element.attachEvent))
name = 'keydown';
Event._observeAndCache(element, name, observer, useCapture);
@@ -2271,8 +3028,7 @@ Object.extend(Event, {
useCapture = useCapture || false;
if (name == 'keypress' &&
- (navigator.appVersion.match(/Konqueror|Safari|KHTML/)
- || element.detachEvent))
+ (Prototype.Browser.WebKit || element.attachEvent))
name = 'keydown';
if (element.removeEventListener) {
@@ -2286,7 +3042,7 @@ Object.extend(Event, {
});
/* prevent memory leaks in IE */
-if (navigator.appVersion.match(/\bMSIE\b/))
+if (Prototype.Browser.IE)
Event.observe(window, 'unload', Event.unloadCache, false);
var Position = {
// set to true if needed, warning: firefox performance problems
@@ -2400,7 +3156,7 @@ var Position = {
valueL += element.offsetLeft || 0;
// Safari fix
- if (element.offsetParent==document.body)
+ if (element.offsetParent == document.body)
if (Element.getStyle(element,'position')=='absolute') break;
} while (element = element.offsetParent);
@@ -2496,7 +3252,7 @@ var Position = {
// Safari returns margins on body which is incorrect if the child is absolutely
// positioned. For performance reasons, redefine Position.cumulativeOffset for
// KHTML/WebKit only.
-if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) {
+if (Prototype.Browser.WebKit) {
Position.cumulativeOffset = function(element) {
var valueT = 0, valueL = 0;
do {
diff --git a/wp-includes/js/quicktags.js b/wp-includes/js/quicktags.js
index 12a95c7..0837d84 100644
--- a/wp-includes/js/quicktags.js
+++ b/wp-includes/js/quicktags.js
@@ -168,7 +168,7 @@ function edShowButton(button, i) {
}
function edShowLinks() {
- var tempStr = '<select onchange="edQuickLink(this.options[this.selectedIndex].value, this);"><option value="-1" selected>(Quick Links)</option>';
+ var tempStr = '<select onchange="edQuickLink(this.options[this.selectedIndex].value, this);"><option value="-1" selected>' + quicktagsL10n.quickLinks + '</option>';
for (i = 0; i < edLinks.length; i++) {
tempStr += '<option value="' + i + '">' + edLinks[i].display + '</option>';
}
@@ -248,7 +248,7 @@ function edSpell(myField) {
}
}
if (word == '') {
- word = prompt('Enter a word to look up:', '');
+ word = prompt(quicktagsL10n.wordLookup, '');
}
if (word !== null && /^\w[\w ]*$/.test(word)) {
window.open('http://www.answers.com/' + escape(word));
@@ -260,8 +260,8 @@ function edToolbar() {
for (i = 0; i < edButtons.length; i++) {
edShowButton(edButtons[i], i);
}
- document.write('<input type="button" id="ed_spell" class="ed_button" onclick="edSpell(edCanvas);" title="Dictionary lookup" value="lookup" />');
- document.write('<input type="button" id="ed_close" class="ed_button" onclick="edCloseAllTags();" title="Close all open tags" value="Close Tags" />');
+ document.write('<input type="button" id="ed_spell" class="ed_button" onclick="edSpell(edCanvas);" title="' + quicktagsL10n.dictionaryLookup + '" value="' + quicktagsL10n.lookup + '" />');
+ document.write('<input type="button" id="ed_close" class="ed_button" onclick="edCloseAllTags();" title="' + quicktagsL10n.closeAllOpenTags + '" value="' + quicktagsL10n.closeTags + '" />');
// edShowLinks(); // disabled by default
document.write('</div>');
}
@@ -366,7 +366,7 @@ function edInsertLink(myField, i, defaultValue) {
defaultValue = 'http://';
}
if (!edCheckOpenTags(i)) {
- var URL = prompt('Enter the URL' ,defaultValue);
+ var URL = prompt(quicktagsL10n.enterURL, defaultValue);
if (URL) {
edButtons[i].tagStart = '<a href="' + URL + '">';
edInsertTag(myField, i);
@@ -378,11 +378,11 @@ function edInsertLink(myField, i, defaultValue) {
}
function edInsertImage(myField) {
- var myValue = prompt('Enter the URL of the image', 'http://');
+ var myValue = prompt(quicktagsL10n.enterImageURL, 'http://');
if (myValue) {
myValue = '<img src="'
+ myValue
- + '" alt="' + prompt('Enter a description of the image', '')
+ + '" alt="' + prompt(quicktagsL10n.enterImageDescription, '')
+ '" />';
edInsertContent(myField, myValue);
}
diff --git a/wp-includes/js/scriptaculous/builder.js b/wp-includes/js/scriptaculous/builder.js
index 199afc1..69a1506 100644
--- a/wp-includes/js/scriptaculous/builder.js
+++ b/wp-includes/js/scriptaculous/builder.js
@@ -1,6 +1,6 @@
-// script.aculo.us builder.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
+// script.aculo.us builder.js v1.7.1_beta2, Sat Apr 28 15:20:12 CEST 2007
-// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/
@@ -48,7 +48,8 @@ var Builder = {
// attributes (or text)
if(arguments[1])
if(this._isStringOrNumber(arguments[1]) ||
- (arguments[1] instanceof Array)) {
+ (arguments[1] instanceof Array) ||
+ arguments[1].tagName) {
this._children(element, arguments[1]);
} else {
var attrs = this._attributes(arguments[1]);
@@ -66,7 +67,7 @@ var Builder = {
}
if(element.tagName.toUpperCase() != elementName)
element = parentElement.getElementsByTagName(elementName)[0];
- }
+ }
}
// text, or array of children
@@ -92,6 +93,10 @@ var Builder = {
return attrs.join(" ");
},
_children: function(element, children) {
+ if(children.tagName) {
+ element.appendChild(children);
+ return;
+ }
if(typeof children=='object') { // array can hold nodes and text
children.flatten().each( function(e) {
if(typeof e=='object')
@@ -101,8 +106,8 @@ var Builder = {
element.appendChild(Builder._text(e));
});
} else
- if(Builder._isStringOrNumber(children))
- element.appendChild(Builder._text(children));
+ if(Builder._isStringOrNumber(children))
+ element.appendChild(Builder._text(children));
},
_isStringOrNumber: function(param) {
return(typeof param=='string' || typeof param=='number');
diff --git a/wp-includes/js/scriptaculous/controls.js b/wp-includes/js/scriptaculous/controls.js
index 46f2cc1..feea27e 100644
--- a/wp-includes/js/scriptaculous/controls.js
+++ b/wp-includes/js/scriptaculous/controls.js
@@ -1,8 +1,8 @@
-// script.aculo.us controls.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
+// script.aculo.us controls.js v1.7.1_beta2, Sat Apr 28 15:20:12 CEST 2007
-// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
-// (c) 2005, 2006 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
-// (c) 2005, 2006 Jon Tirsen (http://www.tirsen.com)
+// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// (c) 2005-2007 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
+// (c) 2005-2007 Jon Tirsen (http://www.tirsen.com)
// Contributors:
// Richard Livsey
// Rahul Bhargava
@@ -43,7 +43,8 @@ var Autocompleter = {}
Autocompleter.Base = function() {};
Autocompleter.Base.prototype = {
baseInitialize: function(element, update, options) {
- this.element = $(element);
+ element = $(element)
+ this.element = element;
this.update = $(update);
this.hasFocus = false;
this.changed = false;
@@ -83,15 +84,20 @@ Autocompleter.Base.prototype = {
Element.hide(this.update);
- Event.observe(this.element, "blur", this.onBlur.bindAsEventListener(this));
- Event.observe(this.element, "keypress", this.onKeyPress.bindAsEventListener(this));
+ Event.observe(this.element, 'blur', this.onBlur.bindAsEventListener(this));
+ Event.observe(this.element, 'keypress', this.onKeyPress.bindAsEventListener(this));
+
+ // Turn autocomplete back on when the user leaves the page, so that the
+ // field's value will be remembered on Mozilla-based browsers.
+ Event.observe(window, 'beforeunload', function(){
+ element.setAttribute('autocomplete', 'on');
+ });
},
show: function() {
if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update);
if(!this.iefix &&
- (navigator.appVersion.indexOf('MSIE')>0) &&
- (navigator.userAgent.indexOf('Opera')<0) &&
+ (Prototype.Browser.IE) &&
(Element.getStyle(this.update, 'position')=='absolute')) {
new Insertion.After(this.update,
'<iframe id="' + this.update.id + '_iefix" '+
@@ -141,17 +147,17 @@ Autocompleter.Base.prototype = {
case Event.KEY_UP:
this.markPrevious();
this.render();
- if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event);
+ if(Prototype.Browser.WebKit) Event.stop(event);
return;
case Event.KEY_DOWN:
this.markNext();
this.render();
- if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event);
+ if(Prototype.Browser.WebKit) Event.stop(event);
return;
}
else
if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
- (navigator.appVersion.indexOf('AppleWebKit') > 0 && event.keyCode == 0)) return;
+ (Prototype.Browser.WebKit > 0 && event.keyCode == 0)) return;
this.changed = true;
this.hasFocus = true;
@@ -197,7 +203,6 @@ Autocompleter.Base.prototype = {
this.index==i ?
Element.addClassName(this.getEntry(i),"selected") :
Element.removeClassName(this.getEntry(i),"selected");
-
if(this.hasFocus) {
this.show();
this.active = true;
@@ -299,7 +304,6 @@ Autocompleter.Base.prototype = {
onObserverEvent: function() {
this.changed = false;
if(this.getToken().length>=this.options.minChars) {
- this.startIndicator();
this.getUpdatedChoices();
} else {
this.active = false;
@@ -340,7 +344,9 @@ Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.pro
},
getUpdatedChoices: function() {
- entry = encodeURIComponent(this.options.paramName) + '=' +
+ this.startIndicator();
+
+ var entry = encodeURIComponent(this.options.paramName) + '=' +
encodeURIComponent(this.getToken());
this.options.parameters = this.options.callback ?
@@ -348,7 +354,7 @@ Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.pro
if(this.options.defaultParams)
this.options.parameters += '&' + this.options.defaultParams;
-
+
new Ajax.Request(this.url, this.options);
},
@@ -477,9 +483,14 @@ Ajax.InPlaceEditor.prototype = {
this.options = Object.extend({
paramName: "value",
okButton: true,
+ okLink: false,
okText: "ok",
+ cancelButton: false,
cancelLink: true,
cancelText: "cancel",
+ textBeforeControls: '',
+ textBetweenControls: '',
+ textAfterControls: '',
savingText: "Saving...",
clickToEditText: "Click to edit",
okText: "ok",
@@ -567,23 +578,52 @@ Ajax.InPlaceEditor.prototype = {
var br = document.createElement("br");
this.form.appendChild(br);
}
+
+ if (this.options.textBeforeControls)
+ this.form.appendChild(document.createTextNode(this.options.textBeforeControls));
if (this.options.okButton) {
- okButton = document.createElement("input");
+ var okButton = document.createElement("input");
okButton.type = "submit";
okButton.value = this.options.okText;
okButton.className = 'editor_ok_button';
this.form.appendChild(okButton);
}
+
+ if (this.options.okLink) {
+ var okLink = document.createElement("a");
+ okLink.href = "#";
+ okLink.appendChild(document.createTextNode(this.options.okText));
+ okLink.onclick = this.onSubmit.bind(this);
+ okLink.className = 'editor_ok_link';
+ this.form.appendChild(okLink);
+ }
+
+ if (this.options.textBetweenControls &&
+ (this.options.okLink || this.options.okButton) &&
+ (this.options.cancelLink || this.options.cancelButton))
+ this.form.appendChild(document.createTextNode(this.options.textBetweenControls));
+
+ if (this.options.cancelButton) {
+ var cancelButton = document.createElement("input");
+ cancelButton.type = "submit";
+ cancelButton.value = this.options.cancelText;
+ cancelButton.onclick = this.onclickCancel.bind(this);
+ cancelButton.className = 'editor_cancel_button';
+ this.form.appendChild(cancelButton);
+ }
if (this.options.cancelLink) {
- cancelLink = document.createElement("a");
+ var cancelLink = document.createElement("a");
cancelLink.href = "#";
cancelLink.appendChild(document.createTextNode(this.options.cancelText));
cancelLink.onclick = this.onclickCancel.bind(this);
- cancelLink.className = 'editor_cancel';
+ cancelLink.className = 'editor_cancel editor_cancel_link';
this.form.appendChild(cancelLink);
}
+
+ if (this.options.textAfterControls)
+ this.form.appendChild(document.createTextNode(this.options.textAfterControls));
},
hasHTMLLineBreaks: function(string) {
if (!this.options.handleLineBreaks) return false;
diff --git a/wp-includes/js/scriptaculous/dragdrop.js b/wp-includes/js/scriptaculous/dragdrop.js
index 32c91bc..58fe342 100644
--- a/wp-includes/js/scriptaculous/dragdrop.js
+++ b/wp-includes/js/scriptaculous/dragdrop.js
@@ -1,7 +1,7 @@
-// script.aculo.us dragdrop.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
+// script.aculo.us dragdrop.js v1.7.1_beta2, Sat Apr 28 15:20:12 CEST 2007
-// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
-// (c) 2005, 2006 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
+// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// (c) 2005-2007 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/
@@ -112,8 +112,10 @@ var Droppables = {
Position.prepare();
if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active))
- if (this.last_active.onDrop)
- this.last_active.onDrop(element, this.last_active.element, event);
+ if (this.last_active.onDrop) {
+ this.last_active.onDrop(element, this.last_active.element, event);
+ return true;
+ }
},
reset: function() {
@@ -245,6 +247,7 @@ Draggable.prototype = {
},
zindex: 1000,
revert: false,
+ quiet: false,
scroll: false,
scrollSensitivity: 20,
scrollSpeed: 15,
@@ -353,8 +356,12 @@ Draggable.prototype = {
updateDrag: function(event, pointer) {
if(!this.dragging) this.startDrag(event);
- Position.prepare();
- Droppables.show(pointer, this.element);
+
+ if(!this.options.quiet){
+ Position.prepare();
+ Droppables.show(pointer, this.element);
+ }
+
Draggables.notify('onDrag', this, event);
this.draw(pointer);
@@ -382,13 +389,19 @@ Draggable.prototype = {
}
// fix AppleWebKit rendering
- if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
+ if(Prototype.Browser.WebKit) window.scrollBy(0,0);
Event.stop(event);
},
finishDrag: function(event, success) {
this.dragging = false;
+
+ if(this.options.quiet){
+ Position.prepare();
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ Droppables.show(pointer, this.element);
+ }
if(this.options.ghosting) {
Position.relativize(this.element);
@@ -396,7 +409,12 @@ Draggable.prototype = {
this._clone = null;
}
- if(success) Droppables.fire(event, this.element);
+ var dropped = false;
+ if(success) {
+ dropped = Droppables.fire(event, this.element);
+ if (!dropped) dropped = false;
+ }
+ if(dropped && this.options.onDropped) this.options.onDropped(this.element);
Draggables.notify('onEnd', this, event);
var revert = this.options.revert;
@@ -404,8 +422,9 @@ Draggable.prototype = {
var d = this.currentDelta();
if(revert && this.options.reverteffect) {
- this.options.reverteffect(this.element,
- d[1]-this.delta[1], d[0]-this.delta[0]);
+ if (dropped == 0 || revert != 'failure')
+ this.options.reverteffect(this.element,
+ d[1]-this.delta[1], d[0]-this.delta[0]);
} else {
this.delta = d;
}
@@ -614,6 +633,7 @@ var Sortable = {
delay: 0,
hoverclass: null,
ghosting: false,
+ quiet: false,
scroll: false,
scrollSensitivity: 20,
scrollSpeed: 15,
@@ -628,6 +648,7 @@ var Sortable = {
// build options for the draggables
var options_for_draggable = {
revert: true,
+ quiet: options.quiet,
scroll: options.scroll,
scrollSpeed: options.scrollSpeed,
scrollSensitivity: options.scrollSensitivity,
diff --git a/wp-includes/js/scriptaculous/effects.js b/wp-includes/js/scriptaculous/effects.js
index 6b7e5c3..596b62e 100644
--- a/wp-includes/js/scriptaculous/effects.js
+++ b/wp-includes/js/scriptaculous/effects.js
@@ -1,6 +1,6 @@
-// script.aculo.us effects.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
+// script.aculo.us effects.js v1.7.1_beta2, Sat Apr 28 15:20:12 CEST 2007
-// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// Contributors:
// Justin Palmer (http://encytemedia.com/)
// Mark Pilgrim (http://diveintomark.org/)
@@ -45,18 +45,10 @@ Element.collectTextNodesIgnoreClass = function(element, className) {
Element.setContentZoom = function(element, percent) {
element = $(element);
element.setStyle({fontSize: (percent/100) + 'em'});
- if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
+ if(Prototype.Browser.WebKit) window.scrollBy(0,0);
return element;
}
-Element.getOpacity = function(element){
- return $(element).getStyle('opacity');
-}
-
-Element.setOpacity = function(element, value){
- return $(element).setStyle({opacity:value});
-}
-
Element.getInlineOpacity = function(element){
return $(element).style.opacity || '';
}
@@ -89,7 +81,7 @@ var Effect = {
throw("Effect.tagifyText requires including script.aculo.us' builder.js library");
var tagifyStyle = 'position:relative';
- if(/MSIE/.test(navigator.userAgent) && !window.opera) tagifyStyle += ';zoom:1';
+ if(Prototype.Browser.IE) tagifyStyle += ';zoom:1';
element = $(element);
$A(element.childNodes).each( function(child) {
@@ -152,7 +144,8 @@ Effect.Transitions = {
return 1-pos;
},
flicker: function(pos) {
- return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4;
+ var pos = ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4;
+ return (pos > 1 ? 1 : pos);
},
wobble: function(pos) {
return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5;
@@ -179,7 +172,7 @@ Effect.ScopedQueue = Class.create();
Object.extend(Object.extend(Effect.ScopedQueue.prototype, Enumerable), {
initialize: function() {
this.effects = [];
- this.interval = null;
+ this.interval = null;
},
_each: function(iterator) {
this.effects._each(iterator);
@@ -213,7 +206,7 @@ Object.extend(Object.extend(Effect.ScopedQueue.prototype, Enumerable), {
if(!effect.options.queue.limit || (this.effects.length < effect.options.queue.limit))
this.effects.push(effect);
- if(!this.interval)
+ if(!this.interval)
this.interval = setInterval(this.loop.bind(this), 15);
},
remove: function(effect) {
@@ -226,7 +219,7 @@ Object.extend(Object.extend(Effect.ScopedQueue.prototype, Enumerable), {
loop: function() {
var timePos = new Date().getTime();
for(var i=0, len=this.effects.length;i<len;i++)
- if(this.effects[i]) this.effects[i].loop(timePos);
+ this.effects[i] && this.effects[i].loop(timePos);
}
});
@@ -246,7 +239,7 @@ Effect.Queue = Effect.Queues.get('global');
Effect.DefaultOptions = {
transition: Effect.Transitions.sinoidal,
duration: 1.0, // seconds
- fps: 60.0, // max. 60fps due to Effect.Queue implementation
+ fps: 100, // 100= assume 66fps max.
sync: false, // true for combining
from: 0.0,
to: 1.0,
@@ -258,11 +251,35 @@ Effect.Base = function() {};
Effect.Base.prototype = {
position: null,
start: function(options) {
+ function codeForEvent(options,eventName){
+ return (
+ (options[eventName+'Internal'] ? 'this.options.'+eventName+'Internal(this);' : '') +
+ (options[eventName] ? 'this.options.'+eventName+'(this);' : '')
+ );
+ }
+ if(options.transition === false) options.transition = Effect.Transitions.linear;
this.options = Object.extend(Object.extend({},Effect.DefaultOptions), options || {});
this.currentFrame = 0;
this.state = 'idle';
this.startOn = this.options.delay*1000;
- this.finishOn = this.startOn + (this.options.duration*1000);
+ this.finishOn = this.startOn+(this.options.duration*1000);
+ this.fromToDelta = this.options.to-this.options.from;
+ this.totalTime = this.finishOn-this.startOn;
+ this.totalFrames = this.options.fps*this.options.duration;
+
+ eval('this.render = function(pos){ '+
+ 'if(this.state=="idle"){this.state="running";'+
+ codeForEvent(options,'beforeSetup')+
+ (this.setup ? 'this.setup();':'')+
+ codeForEvent(options,'afterSetup')+
+ '};if(this.state=="running"){'+
+ 'pos=this.options.transition(pos)*'+this.fromToDelta+'+'+this.options.from+';'+
+ 'this.position=pos;'+
+ codeForEvent(options,'beforeUpdate')+
+ (this.update ? 'this.update(pos);':'')+
+ codeForEvent(options,'afterUpdate')+
+ '}}');
+
this.event('beforeStart');
if(!this.options.sync)
Effect.Queues.get(typeof this.options.queue == 'string' ?
@@ -278,31 +295,14 @@ Effect.Base.prototype = {
this.event('afterFinish');
return;
}
- var pos = (timePos - this.startOn) / (this.finishOn - this.startOn);
- var frame = Math.round(pos * this.options.fps * this.options.duration);
+ var pos = (timePos - this.startOn) / this.totalTime,
+ frame = Math.round(pos * this.totalFrames);
if(frame > this.currentFrame) {
this.render(pos);
this.currentFrame = frame;
}
}
},
- render: function(pos) {
- if(this.state == 'idle') {
- this.state = 'running';
- this.event('beforeSetup');
- if(this.setup) this.setup();
- this.event('afterSetup');
- }
- if(this.state == 'running') {
- if(this.options.transition) pos = this.options.transition(pos);
- pos *= (this.options.to-this.options.from);
- pos += this.options.from;
- this.position = pos;
- this.event('beforeUpdate');
- if(this.update) this.update(pos);
- this.event('afterUpdate');
- }
- },
cancel: function() {
if(!this.options.sync)
Effect.Queues.get(typeof this.options.queue == 'string' ?
@@ -358,7 +358,7 @@ Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {
this.element = $(element);
if(!this.element) throw(Effect._elementDoesNotExistError);
// make this work on IE on elements without 'layout'
- if(/MSIE/.test(navigator.userAgent) && !window.opera && (!this.element.currentStyle.hasLayout))
+ if(Prototype.Browser.IE && (!this.element.currentStyle.hasLayout))
this.element.setStyle({zoom: 1});
var options = Object.extend({
from: this.element.getOpacity() || 0.0,
@@ -953,7 +953,7 @@ Object.extend(Object.extend(Effect.Morph.prototype, Effect.Base.prototype), {
effect.element.addClassName(effect.options.style);
effect.transforms.each(function(transform) {
if(transform.style != 'opacity')
- effect.element.style[transform.style.camelize()] = '';
+ effect.element.style[transform.style] = '';
});
}
} else this.style = options.style.parseStyle();
@@ -969,26 +969,28 @@ Object.extend(Object.extend(Effect.Morph.prototype, Effect.Base.prototype), {
});
}
this.transforms = this.style.map(function(pair){
- var property = pair[0].underscore().dasherize(), value = pair[1], unit = null;
+ var property = pair[0], value = pair[1], unit = null;
if(value.parseColor('#zzzzzz') != '#zzzzzz') {
value = value.parseColor();
unit = 'color';
} else if(property == 'opacity') {
value = parseFloat(value);
- if(/MSIE/.test(navigator.userAgent) && !window.opera && (!this.element.currentStyle.hasLayout))
+ if(Prototype.Browser.IE && (!this.element.currentStyle.hasLayout))
this.element.setStyle({zoom: 1});
- } else if(Element.CSS_LENGTH.test(value))
- var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/),
- value = parseFloat(components[1]), unit = (components.length == 3) ? components[2] : null;
+ } else if(Element.CSS_LENGTH.test(value)) {
+ var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/);
+ value = parseFloat(components[1]);
+ unit = (components.length == 3) ? components[2] : null;
+ }
var originalValue = this.element.getStyle(property);
- return $H({
- style: property,
+ return {
+ style: property.camelize(),
originalValue: unit=='color' ? parseColor(originalValue) : parseFloat(originalValue || 0),
targetValue: unit=='color' ? parseColor(value) : value,
unit: unit
- });
+ };
}.bind(this)).reject(function(transform){
return (
(transform.originalValue == transform.targetValue) ||
@@ -1000,17 +1002,19 @@ Object.extend(Object.extend(Effect.Morph.prototype, Effect.Base.prototype), {
});
},
update: function(position) {
- var style = $H(), value = null;
- this.transforms.each(function(transform){
- value = transform.unit=='color' ?
- $R(0,2).inject('#',function(m,v,i){
- return m+(Math.round(transform.originalValue[i]+
- (transform.targetValue[i] - transform.originalValue[i])*position)).toColorPart() }) :
+ var style = {}, transform, i = this.transforms.length;
+ while(i--)
+ style[(transform = this.transforms[i]).style] =
+ transform.unit=='color' ? '#'+
+ (Math.round(transform.originalValue[0]+
+ (transform.targetValue[0]-transform.originalValue[0])*position)).toColorPart() +
+ (Math.round(transform.originalValue[1]+
+ (transform.targetValue[1]-transform.originalValue[1])*position)).toColorPart() +
+ (Math.round(transform.originalValue[2]+
+ (transform.targetValue[2]-transform.originalValue[2])*position)).toColorPart() :
transform.originalValue + Math.round(
((transform.targetValue - transform.originalValue) * position) * 1000)/1000 + transform.unit;
- style[transform.style] = value;
- });
- this.element.setStyle(style);
+ this.element.setStyle(style, true);
}
});
@@ -1057,14 +1061,14 @@ Element.CSS_PROPERTIES = $w(
Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;
String.prototype.parseStyle = function(){
- var element = Element.extend(document.createElement('div'));
+ var element = document.createElement('div');
element.innerHTML = '<div style="' + this + '"></div>';
- var style = element.down().style, styleRules = $H();
+ var style = element.childNodes[0].style, styleRules = $H();
Element.CSS_PROPERTIES.each(function(property){
if(style[property]) styleRules[property] = style[property];
});
- if(/MSIE/.test(navigator.userAgent) && !window.opera && this.indexOf('opacity') > -1) {
+ if(Prototype.Browser.IE && this.indexOf('opacity') > -1) {
styleRules.opacity = this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1];
}
return styleRules;
@@ -1075,13 +1079,13 @@ Element.morph = function(element, style) {
return element;
};
-['setOpacity','getOpacity','getInlineOpacity','forceRerendering','setContentZoom',
+['getInlineOpacity','forceRerendering','setContentZoom',
'collectTextNodes','collectTextNodesIgnoreClass','morph'].each(
function(f) { Element.Methods[f] = Element[f]; }
);
Element.Methods.visualEffect = function(element, effect, options) {
- s = effect.gsub(/_/, '-').camelize();
+ s = effect.dasherize().camelize();
effect_class = s.charAt(0).toUpperCase() + s.substring(1);
new Effect[effect_class](element, options);
return $(element);
diff --git a/wp-includes/js/scriptaculous/scriptaculous.js b/wp-includes/js/scriptaculous/scriptaculous.js
index 0844cef..5f403a3 100644
--- a/wp-includes/js/scriptaculous/scriptaculous.js
+++ b/wp-includes/js/scriptaculous/scriptaculous.js
@@ -1,6 +1,6 @@
-// script.aculo.us scriptaculous.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
+// script.aculo.us scriptaculous.js v1.7.1_beta2, Sat Apr 28 15:20:12 CEST 2007
-// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -24,25 +24,32 @@
// For details, see the script.aculo.us web site: http://script.aculo.us/
var Scriptaculous = {
- Version: '1.7.0',
+ Version: '1.7.1_beta2',
require: function(libraryName) {
// inserting via DOM fails in Safari 2.0, so brute force approach
document.write('<script type="text/javascript" src="'+libraryName+'"></script>');
},
+ REQUIRED_PROTOTYPE: '1.5.1',
load: function() {
+ function convertVersionString(versionString){
+ var r = versionString.split('.');
+ return parseInt(r[0])*100000 + parseInt(r[1])*1000 + parseInt(r[2]);
+ }
+
if((typeof Prototype=='undefined') ||
(typeof Element == 'undefined') ||
(typeof Element.Methods=='undefined') ||
- parseFloat(Prototype.Version.split(".")[0] + "." +
- Prototype.Version.split(".")[1]) < 1.5)
- throw("script.aculo.us requires the Prototype JavaScript framework >= 1.5.0");
+ (convertVersionString(Prototype.Version) <
+ convertVersionString(Scriptaculous.REQUIRED_PROTOTYPE)))
+ throw("script.aculo.us requires the Prototype JavaScript framework >= " +
+ Scriptaculous.REQUIRED_PROTOTYPE);
$A(document.getElementsByTagName("script")).findAll( function(s) {
return (s.src && s.src.match(/scriptaculous\.js(\?.*)?$/))
}).each( function(s) {
var path = s.src.replace(/scriptaculous\.js(\?.*)?$/,'');
var includes = s.src.match(/\?.*load=([a-z,]*)/);
- (includes ? includes[1] : 'builder,effects,dragdrop,controls,slider').split(',').each(
+ (includes ? includes[1] : 'builder,effects,dragdrop,controls,slider,sound').split(',').each(
function(include) { Scriptaculous.require(path+include+'.js') });
});
}
diff --git a/wp-includes/js/scriptaculous/slider.js b/wp-includes/js/scriptaculous/slider.js
index 4899587..4db286b 100644
--- a/wp-includes/js/scriptaculous/slider.js
+++ b/wp-includes/js/scriptaculous/slider.js
@@ -1,6 +1,6 @@
-// script.aculo.us slider.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
+// script.aculo.us slider.js v1.7.1_beta2, Sat Apr 28 15:20:12 CEST 2007
-// Copyright (c) 2005, 2006 Marty Haught, Thomas Fuchs
+// Copyright (c) 2005-2007 Marty Haught, Thomas Fuchs
//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/
@@ -242,8 +242,7 @@ Control.Slider.prototype = {
if(this.active) {
if(!this.dragging) this.dragging = true;
this.draw(event);
- // fix AppleWebKit rendering
- if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
+ if(Prototype.Browser.WebKit) window.scrollBy(0,0);
Event.stop(event);
}
},
diff --git a/wp-includes/js/scriptaculous/sound.js b/wp-includes/js/scriptaculous/sound.js
new file mode 100644
index 0000000..fab10e8
--- /dev/null
+++ b/wp-includes/js/scriptaculous/sound.js
@@ -0,0 +1,60 @@
+// script.aculo.us sound.js v1.7.1_beta2, Sat Apr 28 15:20:12 CEST 2007
+
+// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+//
+// Based on code created by Jules Gravinese (http://www.webveteran.com/)
+//
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site: http://script.aculo.us/
+
+Sound = {
+ tracks: {},
+ _enabled: true,
+ template:
+ new Template('<embed style="height:0" id="sound_#{track}_#{id}" src="#{url}" loop="false" autostart="true" hidden="true"/>'),
+ enable: function(){
+ Sound._enabled = true;
+ },
+ disable: function(){
+ Sound._enabled = false;
+ },
+ play: function(url){
+ if(!Sound._enabled) return;
+ var options = Object.extend({
+ track: 'global', url: url, replace: false
+ }, arguments[1] || {});
+
+ if(options.replace && this.tracks[options.track]) {
+ $R(0, this.tracks[options.track].id).each(function(id){
+ var sound = $('sound_'+options.track+'_'+id);
+ sound.Stop && sound.Stop();
+ sound.remove();
+ })
+ this.tracks[options.track] = null;
+ }
+
+ if(!this.tracks[options.track])
+ this.tracks[options.track] = { id: 0 }
+ else
+ this.tracks[options.track].id++;
+
+ options.id = this.tracks[options.track].id;
+ if (Prototype.Browser.IE) {
+ var sound = document.createElement('bgsound');
+ sound.setAttribute('id','sound_'+options.track+'_'+options.id);
+ sound.setAttribute('src',options.url);
+ sound.setAttribute('loop','1');
+ sound.setAttribute('autostart','true');
+ $$('body')[0].appendChild(sound);
+ }
+ else
+ new Insertion.Bottom($$('body')[0], Sound.template.evaluate(options));
+ }
+};
+
+if(Prototype.Browser.Gecko && navigator.userAgent.indexOf("Win") > 0){
+ if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('QuickTime') != -1 }))
+ Sound.template = new Template('<object id="sound_#{track}_#{id}" width="0" height="0" type="audio/mpeg" data="#{url}"/>')
+ else
+ Sound.play = function(){}
+}
diff --git a/wp-includes/js/scriptaculous/unittest.js b/wp-includes/js/scriptaculous/unittest.js
index f272ab2..f46cca4 100644
--- a/wp-includes/js/scriptaculous/unittest.js
+++ b/wp-includes/js/scriptaculous/unittest.js
@@ -1,8 +1,8 @@
-// script.aculo.us unittest.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
+// script.aculo.us unittest.js v1.7.1_beta2, Sat Apr 28 15:20:12 CEST 2007
-// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
-// (c) 2005, 2006 Jon Tirsen (http://www.tirsen.com)
-// (c) 2005, 2006 Michael Schuerig (http://www.schuerig.de/michael/)
+// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// (c) 2005-2007 Jon Tirsen (http://www.tirsen.com)
+// (c) 2005-2007 Michael Schuerig (http://www.schuerig.de/michael/)
//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/
diff --git a/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js b/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js
index 1ab5d1e..f76aeeb 100644
--- a/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js
+++ b/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js
@@ -1,5 +1,5 @@
/**
- * $Id: editor_plugin_src.js 162 2007-01-03 16:16:52Z spocke $
+ * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
*
* @author Moxiecode
* @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
@@ -14,7 +14,7 @@ var TinyMCE_AutoSavePlugin = {
longname : 'Auto save',
author : 'Moxiecode Systems AB',
authorurl : 'http://tinymce.moxiecode.com',
- infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_autosave.html',
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autosave',
version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
};
},
diff --git a/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js b/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js
index eb758f5..eb106f1 100644
--- a/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js
+++ b/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js
@@ -1,5 +1,5 @@
/**
- * $Id: editor_plugin_src.js 162 2007-01-03 16:16:52Z spocke $
+ * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
*
* @author Moxiecode
* @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
@@ -14,7 +14,7 @@ var TinyMCE_DirectionalityPlugin = {
longname : 'Directionality',
author : 'Moxiecode Systems AB',
authorurl : 'http://tinymce.moxiecode.com',
- infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_directionality.html',
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/directionality',
version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
};
},
diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js b/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js
index 9f75e29..8f844a7 100644
--- a/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js
+++ b/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js
@@ -1,5 +1,5 @@
/**
- * $Id: editor_plugin_src.js 172 2007-01-09 11:37:11Z spocke $
+ * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
*
* Moxiecode DHTML Windows script.
*
@@ -15,7 +15,7 @@ var TinyMCE_InlinePopupsPlugin = {
longname : 'Inline Popups',
author : 'Moxiecode Systems AB',
authorurl : 'http://tinymce.moxiecode.com',
- infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_inlinepopups.html',
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/inlinepopups',
version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
};
}
@@ -26,6 +26,7 @@ tinyMCE.addPlugin("inlinepopups", TinyMCE_InlinePopupsPlugin);
// Patch openWindow, closeWindow TinyMCE functions
TinyMCE_Engine.prototype.orgOpenWindow = TinyMCE_Engine.prototype.openWindow;
+TinyMCE_Engine.prototype.orgCloseWindow = TinyMCE_Engine.prototype.closeWindow;
TinyMCE_Engine.prototype.openWindow = function(template, args) {
// Does the caller support inline
@@ -52,6 +53,12 @@ TinyMCE_Engine.prototype.openWindow = function(template, args) {
if (!(height = parseInt(template['height'])))
height = 200;
+ if (!(minWidth = parseInt(template['minWidth'])))
+ minWidth = 100;
+
+ if (!(minHeight = parseInt(template['minHeight'])))
+ minHeight = 100;
+
resizable = (args && args['resizable']) ? args['resizable'] : "no";
scrollbars = (args && args['scrollbars']) ? args['scrollbars'] : "no";
@@ -78,16 +85,23 @@ TinyMCE_Engine.prototype.openWindow = function(template, args) {
url += tinyMCE.settings['imp_version'] ? (url.indexOf('?')==-1?'?':'&') + 'ver=' + tinyMCE.settings['imp_version'] : ''; // WordPress cache buster
- mcWindows.open(url, mcWindows.idCounter++, "modal=yes,width=" + width+ ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",statusbar=" + resizable + ",left=" + pos.absLeft + ",top=" + pos.absTop);
+ mcWindows.open(url, mcWindows.idCounter++, "modal=yes,width=" + width+ ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",statusbar=" + resizable + ",left=" + pos.absLeft + ",top=" + pos.absTop + ",minWidth=" + minWidth + ",minHeight=" + minHeight );
};
-TinyMCE_Engine.prototype.orgCloseWindow = TinyMCE_Engine.prototype.closeWindow;
-
TinyMCE_Engine.prototype.closeWindow = function(win) {
- if (mcWindows.selectedWindow != null)
- mcWindows.selectedWindow.close();
- else
+ var gotit = false, n, w;
+ for (n in mcWindows.windows) {
+ w = mcWindows.windows[n];
+ if (typeof(w) == 'function') continue;
+ if (win.name == w.id + '_iframe') {
+ w.close();
+ gotit = true;
+ }
+ }
+ if (!gotit)
this.orgCloseWindow(win);
+
+ tinyMCE.selectedInstance.getWin().focus();
};
TinyMCE_Engine.prototype.setWindowTitle = function(win_ref, title) {
@@ -135,9 +149,46 @@ TinyMCE_Windows.prototype.init = function(settings) {
this.addEvent(document, "mouseup", mcWindows.eventDispatcher);
+ this.addEvent(window, "resize", mcWindows.eventDispatcher);
+ this.addEvent(document, "scroll", mcWindows.eventDispatcher);
+
this.doc = document;
};
+TinyMCE_Windows.prototype.getBounds = function() {
+ if (!this.bounds) {
+ var vp = tinyMCE.getViewPort(window);
+ var top, left, bottom, right, docEl = this.doc.documentElement;
+
+ top = vp.top;
+ left = vp.left;
+ bottom = vp.height + top - 2;
+ right = vp.width + left - 22; // TODO this number is platform dependant
+ // x1, y1, x2, y2
+ this.bounds = [left, top, right, bottom];
+ }
+ return this.bounds;
+};
+
+TinyMCE_Windows.prototype.clampBoxPosition = function(x, y, w, h, minW, minH) {
+ var bounds = this.getBounds();
+
+ x = Math.max(bounds[0], Math.min(bounds[2], x + w) - w);
+ y = Math.max(bounds[1], Math.min(bounds[3], y + h) - h);
+
+ return this.clampBoxSize(x, y, w, h, minW, minH);
+};
+
+TinyMCE_Windows.prototype.clampBoxSize = function(x, y, w, h, minW, minH) {
+ var bounds = this.getBounds();
+
+ return [
+ x, y,
+ Math.max(minW, Math.min(bounds[2], x + w) - x),
+ Math.max(minH, Math.min(bounds[3], y + h) - y)
+ ];
+};
+
TinyMCE_Windows.prototype.getParam = function(name, default_value) {
var value = null;
@@ -186,6 +237,43 @@ TinyMCE_Windows.prototype.eventDispatcher = function(e) {
case "focus":
mcWindows.selectedWindow.onFocus(e);
break;
+ case "scroll":
+ case "resize":
+ if (mcWindows.clampUpdateTimeout)
+ clearTimeout(mcWindows.clampUpdateTimeout);
+ mcWindows.clampEventType = e.type;
+ mcWindows.clampUpdateTimeout =
+ setTimeout(function () {mcWindows.updateClamping()}, 100);
+ break;
+ }
+};
+
+TinyMCE_Windows.prototype.updateClamping = function () {
+ var clamp, oversize, etype = mcWindows.clampEventType;
+
+ this.bounds = null; // Recalc window bounds on resize/scroll
+ this.clampUpdateTimeout = null;
+
+ for (var n in this.windows) {
+ win = this.windows[n];
+ if (typeof(win) == 'function' || ! win.winElement) continue;
+
+ clamp = mcWindows.clampBoxPosition(
+ win.left, win.top,
+ win.winElement.scrollWidth,
+ win.winElement.scrollHeight,
+ win.features.minWidth,
+ win.features.minHeight
+ );
+ oversize = (
+ clamp[2] != win.winElement.scrollWidth ||
+ clamp[3] != win.winElement.scrollHeight
+ ) ? true : false;
+
+ if (!oversize || win.features.resizable == "yes" || etype != "scroll")
+ win.moveTo(clamp[0], clamp[1]);
+ if (oversize && win.features.resizable == "yes")
+ win.resizeTo(clamp[2], clamp[3]);
}
};
@@ -193,7 +281,7 @@ TinyMCE_Windows.prototype.addEvent = function(obj, name, handler) {
if (this.isMSIE)
obj.attachEvent("on" + name, handler);
else
- obj.addEventListener(name, handler, true);
+ obj.addEventListener(name, handler, false);
};
TinyMCE_Windows.prototype.cancelEvent = function(e) {
@@ -217,6 +305,8 @@ TinyMCE_Windows.prototype.parseFeatures = function(opts) {
options['top'] = "10";
options['width'] = "300";
options['height'] = "300";
+ options['minwidth'] = "100";
+ options['minheight'] = "100";
options['resizable'] = "yes";
options['minimizable'] = "yes";
options['maximizable'] = "yes";
@@ -240,6 +330,8 @@ TinyMCE_Windows.prototype.parseFeatures = function(opts) {
options['top'] = parseInt(options['top']);
options['width'] = parseInt(options['width']);
options['height'] = parseInt(options['height']);
+ options['minWidth'] = parseInt(options['minwidth']);
+ options['minHeight'] = parseInt(options['minheight']);
return options;
};
@@ -253,6 +345,21 @@ TinyMCE_Windows.prototype.open = function(url, name, features) {
features = this.parseFeatures(features);
+ // Clamp specified dimensions
+ var clamp = mcWindows.clampBoxPosition(
+ features['left'], features['top'],
+ features['width'], features['height'],
+ features['minWidth'], features['minHeight']
+ );
+
+ features['left'] = clamp[0];
+ features['top'] = clamp[1];
+
+ if (features['resizable'] == "yes") {
+ features['width'] = clamp[2];
+ features['height'] = clamp[3];
+ }
+
// Create div
id = "mcWindow_" + name;
win.deltaHeight = 18;
@@ -285,9 +392,9 @@ TinyMCE_Windows.prototype.open = function(url, name, features) {
html += '<html>';
html += '<head>';
html += '<title>Wrapper iframe</title>';
+ if (this.isMac) html += '<style type="text/css">.mceWindowTitle{float:none;margin:0;width:100%;text-align:center;}.mceWindowClose{float:none;position:absolute;left:0px;top:0px;}</style>';
html += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
html += '<link href="' + this.getParam("css_file") + '" rel="stylesheet" type="text/css" />';
- if ( this.isMac ) html += '<style type="text/css">.mceWindowTitle{float:none;margin:0;text-align:center;}.mceWindowClose{float:none;position:absolute;left:0px;top:0px;}</style>';
html += '</head>';
html += '<body onload="parent.mcWindows.onLoad(\'' + name + '\');">';
@@ -297,8 +404,9 @@ TinyMCE_Windows.prototype.open = function(url, name, features) {
html += ' onselectstart="return false;" unselectable="on" style="-moz-user-select: none !important;"></div>';
html += ' <div class="mceWindowHeadTools">';
html += ' <a href="javascript:parent.mcWindows.windows[\'' + name + '\'].close();" target="_self" onmousedown="return false;" class="mceWindowClose"><img border="0" src="' + imgPath + '/window_close.gif" /></a>';
-// html += ' <a href="javascript:mcWindows.windows[\'' + name + '\'].maximize();" target="_self" onmousedown="return false;" class="mceWindowMaximize"></a>';
-// html += ' <a href="javascript:mcWindows.windows[\'' + name + '\'].minimize();" target="_self" onmousedown="return false;" class="mceWindowMinimize"></a>';
+ if (features['resizable'] == "yes" && features['maximizable'] == "yes")
+ html += ' <a href="javascript:parent.mcWindows.windows[\'' + name + '\'].maximize();" target="_self" onmousedown="return false;" class="mceWindowMaximize"><img border="0" src="' + imgPath + '/window_maximize.gif" /></a>';
+ // html += ' <a href="javascript:mcWindows.windows[\'' + name + '\'].minimize();" target="_self" onmousedown="return false;" class="mceWindowMinimize"></a>';
html += ' </div>';
html += '</div><div id="' + id + '_body" class="mceWindowBody" style="width: ' + width + 'px; height: ' + height + 'px;">';
html += '<iframe id="' + id + '_iframe" name="' + id + '_iframe" frameborder="0" width="' + iframeWidth + '" height="' + iframeHeight + '" src="' + url + '" class="mceWindowBodyIframe" scrolling="' + features['scrollbars'] + '"></iframe></div>';
@@ -447,6 +555,7 @@ TinyMCE_Windows.prototype.createFloatingIFrame = function(id_prefix, left, top,
div.setAttribute("width", width);
div.setAttribute("height", (height));
div.style.position = "absolute";
+
div.style.left = left + "px";
div.style.top = top + "px";
div.style.width = width + "px";
@@ -473,7 +582,7 @@ TinyMCE_Windows.prototype.createFloatingIFrame = function(id_prefix, left, top,
iframe.setAttribute("topMargin", "0");
iframe.setAttribute("width", iframeWidth);
iframe.setAttribute("height", iframeHeight);
-// iframe.setAttribute("src", "../jscripts/tiny_mce/blank.htm");
+ // iframe.setAttribute("src", "../jscripts/tiny_mce/blank.htm");
// iframe.setAttribute("allowtransparency", "false");
iframe.setAttribute("scrolling", "no");
iframe.style.width = iframeWidth + "px";
@@ -522,7 +631,24 @@ TinyMCE_Window.prototype.minimize = function() {
};
TinyMCE_Window.prototype.maximize = function() {
-
+ if (this.restoreSize) {
+ this.moveTo(this.restoreSize[0], this.restoreSize[1]);
+ this.resizeTo(this.restoreSize[2], this.restoreSize[3]);
+ this.updateClamping();
+ this.restoreSize = null;
+ } else {
+ var bounds = mcWindows.getBounds();
+ this.restoreSize = [
+ this.left, this.top,
+ this.winElement.scrollWidth,
+ this.winElement.scrollHeight
+ ];
+ this.moveTo(bounds[0], bounds[1]);
+ this.resizeTo(
+ bounds[2] - bounds[0],
+ bounds[3] - bounds[1]
+ );
+ }
};
TinyMCE_Window.prototype.startResize = function() {
@@ -552,7 +678,7 @@ TinyMCE_Window.prototype.close = function() {
mcWindows.windows = mcWindowsNew;
-// alert(mcWindows.doc.getElementById(this.id + "_iframe"));
+ // alert(mcWindows.doc.getElementById(this.id + "_iframe"));
var e = mcWindows.doc.getElementById(this.id + "_iframe");
e.parentNode.removeChild(e);
@@ -561,42 +687,24 @@ TinyMCE_Window.prototype.close = function() {
e.parentNode.removeChild(e);
mcWindows.setDocumentLock(false);
-
- tinyMCE.selectedInstance.getWin().focus(); // WordPress: focus on the editor after closing a popup
};
TinyMCE_Window.prototype.onMouseMove = function(e) {
- var scrollX = 0;//this.doc.body.scrollLeft;
- var scrollY = 0;//this.doc.body.scrollTop;
-
+ var clamp;
// Calculate real X, Y
var dx = e.screenX - mcWindows.mouseDownScreenX;
var dy = e.screenY - mcWindows.mouseDownScreenY;
switch (mcWindows.action) {
case "resize":
- width = mcWindows.mouseDownWidth + (e.screenX - mcWindows.mouseDownScreenX);
- height = mcWindows.mouseDownHeight + (e.screenY - mcWindows.mouseDownScreenY);
+ clamp = mcWindows.clampBoxSize(
+ this.left, this.top,
+ mcWindows.mouseDownWidth + (e.screenX - mcWindows.mouseDownScreenX),
+ mcWindows.mouseDownHeight + (e.screenY - mcWindows.mouseDownScreenY),
+ this.features.minWidth, this.features.minHeight
+ );
- width = width < 100 ? 100 : width;
- height = height < 100 ? 100 : height;
-
- this.wrapperIFrameElement.style.width = (width+2) + 'px';
- this.wrapperIFrameElement.style.height = (height+2) + 'px';
- this.wrapperIFrameElement.width = width+2;
- this.wrapperIFrameElement.height = height+2;
- this.winElement.style.width = width + 'px';
- this.winElement.style.height = height + 'px';
-
- height = height - this.deltaHeight;
-
- this.containerElement.style.width = width + 'px';
- this.iframeElement.style.width = width + 'px';
- this.iframeElement.style.height = height + 'px';
- this.bodyElement.style.width = width + 'px';
- this.bodyElement.style.height = height + 'px';
- this.headElement.style.width = width + 'px';
- //this.statusElement.style.width = width + 'px';
+ this.resizeTo(clamp[2], clamp[3]);
mcWindows.cancelEvent(e);
break;
@@ -604,14 +712,59 @@ TinyMCE_Window.prototype.onMouseMove = function(e) {
case "move":
this.left = mcWindows.mouseDownLayerX + (e.screenX - mcWindows.mouseDownScreenX);
this.top = mcWindows.mouseDownLayerY + (e.screenY - mcWindows.mouseDownScreenY);
- this.winElement.style.left = this.left + "px";
- this.winElement.style.top = this.top + "px";
+ this.updateClamping();
mcWindows.cancelEvent(e);
break;
}
};
+TinyMCE_Window.prototype.moveTo = function (x, y) {
+ this.left = x;
+ this.top = y;
+
+ this.winElement.style.left = this.left + "px";
+ this.winElement.style.top = this.top + "px";
+};
+
+TinyMCE_Window.prototype.resizeTo = function (width, height) {
+ this.wrapperIFrameElement.style.width = (width+2) + 'px';
+ this.wrapperIFrameElement.style.height = (height+2) + 'px';
+ this.wrapperIFrameElement.width = width+2;
+ this.wrapperIFrameElement.height = height+2;
+ this.winElement.style.width = width + 'px';
+ this.winElement.style.height = height + 'px';
+
+ height = height - this.deltaHeight;
+
+ this.containerElement.style.width = width + 'px';
+ this.iframeElement.style.width = width + 'px';
+ this.iframeElement.style.height = height + 'px';
+ this.bodyElement.style.width = width + 'px';
+ this.bodyElement.style.height = height + 'px';
+ this.headElement.style.width = width + 'px';
+ //this.statusElement.style.width = width + 'px';
+};
+
+TinyMCE_Window.prototype.updateClamping = function () {
+ var clamp, oversize;
+
+ clamp = mcWindows.clampBoxPosition(
+ this.left, this.top,
+ this.winElement.scrollWidth,
+ this.winElement.scrollHeight,
+ this.features.minWidth, this.features.minHeight
+ );
+ oversize = (
+ clamp[2] != this.winElement.scrollWidth ||
+ clamp[3] != this.winElement.scrollHeight
+ ) ? true : false;
+
+ this.moveTo(clamp[0], clamp[1]);
+ if (this.features.resizable == "yes" && oversize)
+ this.resizeTo(clamp[2], clamp[3]);
+};
+
function debug(msg) {
document.getElementById('debug').value += msg + "\n";
}
@@ -639,9 +792,6 @@ TinyMCE_Window.prototype.onFocus = function(e) {
TinyMCE_Window.prototype.onMouseDown = function(e) {
var elm = mcWindows.isMSIE ? this.wrapperFrame.event.srcElement : e.target;
- var scrollX = 0;//this.doc.body.scrollLeft;
- var scrollY = 0;//this.doc.body.scrollTop;
-
mcWindows.mouseDownScreenX = e.screenX;
mcWindows.mouseDownScreenY = e.screenY;
mcWindows.mouseDownLayerX = this.left;
diff --git a/wp-includes/js/tinymce/plugins/paste/editor_plugin.js b/wp-includes/js/tinymce/plugins/paste/editor_plugin.js
index 3ef1d7a..5e884cf 100644
--- a/wp-includes/js/tinymce/plugins/paste/editor_plugin.js
+++ b/wp-includes/js/tinymce/plugins/paste/editor_plugin.js
@@ -1,5 +1,5 @@
/**
- * $Id: editor_plugin_src.js 162 2007-01-03 16:16:52Z spocke $
+ * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
*
* @author Moxiecode
* @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
@@ -14,7 +14,7 @@ var TinyMCE_PastePlugin = {
longname : 'Paste text/word',
author : 'Moxiecode Systems AB',
authorurl : 'http://tinymce.moxiecode.com',
- infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_paste.html',
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste',
version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
};
},
@@ -24,6 +24,16 @@ var TinyMCE_PastePlugin = {
tinyMCE.addEvent(inst.getBody(), "paste", TinyMCE_PastePlugin._handlePasteEvent);
},
+ handleEvent : function(e) {
+ // Force paste dialog if non IE browser
+ if (!tinyMCE.isRealIE && tinyMCE.getParam("paste_auto_cleanup_on_paste", false) && e.ctrlKey && e.keyCode == 86 && e.type == "keydown") {
+ window.setTimeout('tinyMCE.selectedInstance.execCommand("mcePasteText",true)', 1);
+ return tinyMCE.cancelEvent(e);
+ }
+
+ return true;
+ },
+
getControlHTML : function(cn) {
switch (cn) {
case "pastetext":
diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php
index cf3d800..0127ff1 100755
--- a/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php
+++ b/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php
@@ -78,19 +78,8 @@ class TinyGoogleSpell {
$header .= $xml;
//$this->_debugData($xml);
- // Use raw sockets
- $fp = fsockopen("ssl://" . $server, $port, $errno, $errstr, 30);
- if ($fp) {
- // Send request
- fwrite($fp, $header);
-
- // Read response
- $xml = "";
- while (!feof($fp))
- $xml .= fgets($fp, 128);
-
- fclose($fp);
- } else {
+ // Use curl if it exists
+ if (function_exists('curl_init')) {
// Use curl
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
@@ -99,6 +88,21 @@ class TinyGoogleSpell {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$xml = curl_exec($ch);
curl_close($ch);
+ } else {
+ // Use raw sockets
+ $fp = fsockopen("ssl://" . $server, $port, $errno, $errstr, 30);
+ if ($fp) {
+ // Send request
+ fwrite($fp, $header);
+
+ // Read response
+ $xml = "";
+ while (!feof($fp))
+ $xml .= fgets($fp, 128);
+
+ fclose($fp);
+ } else
+ echo "Could not open SSL connection to google.";
}
//$this->_debugData($xml);
diff --git a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
index ede6576..f834e97 100644
--- a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
+++ b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
@@ -515,7 +515,7 @@ function switchEditors(id) {
ta.style.height = (ta.clientHeight + y1 - y2) + 'px';
// Tweak the widths
- ta.parentNode.style.paddingRight = '2px';
+ ta.parentNode.style.paddingRight = '12px';
if ( tinyMCE.isMSIE && !tinyMCE.isOpera ) {
} else {
diff --git a/wp-includes/js/tinymce/plugins/wordpress/langs/en.js b/wp-includes/js/tinymce/plugins/wordpress/langs/en.js
index 2d4e1e3..68ca7ba 100644
--- a/wp-includes/js/tinymce/plugins/wordpress/langs/en.js
+++ b/wp-includes/js/tinymce/plugins/wordpress/langs/en.js
@@ -4,6 +4,10 @@ if (navigator.userAgent.indexOf('Mac OS') != -1) {
// Mac OS browsers use Ctrl to hit accesskeys
var metaKey = 'Ctrl';
}
+else if (navigator.userAgent.indexOf('Firefox/2') != -1) {
+// Firefox 2.x uses Alt+Shift to hit accesskeys
+ var metaKey = 'Alt+Shift';
+}
else {
var metaKey = 'Alt';
}
diff --git a/wp-includes/js/tinymce/themes/advanced/color_picker.htm b/wp-includes/js/tinymce/themes/advanced/color_picker.htm
index e5fdc9f..5e24920 100644
--- a/wp-includes/js/tinymce/themes/advanced/color_picker.htm
+++ b/wp-includes/js/tinymce/themes/advanced/color_picker.htm
@@ -2,12 +2,73 @@
<head>
<title>{$lang_theme_colorpicker_title}</title>
<script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script>
+ <script language="javascript" type="text/javascript" src="../../utils/mctabs.js"></script>
<script language="javascript" type="text/javascript" src="jscripts/color_picker.js"></script>
+ <link href="css/colorpicker.css" rel="stylesheet" type="text/css" />
<base target="_self" />
</head>
-<body onload="tinyMCEPopup.executeOnLoad('init();');" style="margin: 3px; display: none">
- <div align="center">
- <script language="javascript" type="text/javascript">renderColorMap();</script>
+<body onload="tinyMCEPopup.executeOnLoad('init();');" style="display: none">
+ <div class="tabs">
+ <ul>
+ <li id="picker_tab" class="current"><span><a href="javascript:mcTabs.displayTab('picker_tab','picker_panel');" onmousedown="return false;">{$lang_color_picker_tab}</a></span></li>
+ <li id="rgb_tab"><span><a href="#" onclick="generateWebColors();mcTabs.displayTab('rgb_tab','rgb_panel');" onmousedown="return false;">{$lang_web_colors_tab}</a></span></li>
+ <li id="named_tab"><span><a href="#" onclick="generateNamedColors();javascript:mcTabs.displayTab('named_tab','named_panel');" onmousedown="return false;">{$lang_named_colors_tab}</a></span></li>
+ </ul>
+ </div>
+
+ <div class="panel_wrapper">
+ <div id="picker_panel" class="panel current">
+ <fieldset>
+ <legend>{$lang_color_picker}</legend>
+ <div id="picker">
+ <img id="colorpicker" src="images/colors.jpg" onclick="computeColor(event)" onmousedown="isMouseDown = true;return false;" onmouseup="isMouseDown = false;" onmousemove="if (isMouseDown && isMouseOver) computeColor(event); return false;" onmouseover="isMouseOver=true;" onmouseout="isMouseOver=false;" />
+
+ <div id="light">
+ <!-- Will be filled with divs -->
+ </div>
+
+ <br style="clear: both" />
+ </div>
+ </fieldset>
+ </div>
+
+ <div id="rgb_panel" class="panel">
+ <fieldset>
+ <legend>{$lang_web_colors}</legend>
+ <div id="webcolors">
+ <!-- Gets filled with web safe colors-->
+ </div>
+
+ <br style="clear: both" />
+ </fieldset>
+ </div>
+
+ <div id="named_panel" class="panel">
+ <fieldset>
+ <legend>{$lang_named_colors}</legend>
+ <div id="namedcolors">
+ <!-- Gets filled with named colors-->
+ </div>
+
+ <br style="clear: both" />
+
+ <div id="colornamecontainer">
+ {$lang_color_name} <span id="colorname"></span>
+ </div>
+ </fieldset>
+ </div>
+ </div>
+
+ <div class="mceActionPanel">
+ <div style="float: left">
+ <input type="button" id="insert" name="insert" value="{$lang_theme_colorpicker_apply}" onclick="insertAction();" />
+ </div>
+
+ <div id="preview"></div>
+
+ <div id="previewblock">
+ <label for="color">{$lang_color}</label> <input id="color" type="text" size="8" maxlength="8" class="text" />
+ </div>
</div>
</body>
</html>
diff --git a/wp-includes/js/tinymce/themes/advanced/css/colorpicker.css b/wp-includes/js/tinymce/themes/advanced/css/colorpicker.css
new file mode 100644
index 0000000..4b0360b
--- /dev/null
+++ b/wp-includes/js/tinymce/themes/advanced/css/colorpicker.css
@@ -0,0 +1,53 @@
+/* Colorpicker dialog specific CSS */
+
+#preview {
+ float: right;
+ width: 50px;
+ height: 14px;
+ line-height: 1px;
+ border: 1px solid black;
+ margin-left: 5px;
+}
+
+#colorpicker {
+ float: left;
+ cursor: crosshair;
+}
+
+#light {
+ border: 1px solid gray;
+ margin-left: 5px;
+ float: left;
+ width: 15px;
+ cursor: crosshair;
+}
+
+#light div {
+ overflow: hidden;
+}
+
+#previewblock {
+ float: right;
+ padding-left: 10px;
+ height: 20px;
+}
+
+.panel_wrapper div.current {
+ height: 175px;
+}
+
+#namedcolors {
+ width: 150px;
+}
+
+#namedcolors a {
+ display: block;
+ float: left;
+ width: 10px; height: 10px;
+ margin: 1px 1px 0 0;
+ overflow: hidden;
+}
+
+#colornamecontainer {
+ margin-top: 5px;
+} \ No newline at end of file
diff --git a/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css b/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css
index 58e6b8e..851837d 100644
--- a/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css
+++ b/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css
@@ -11,7 +11,7 @@
.mceToolbarTop, .mceToolbarBottom {background: #F0F0EE; line-height: 1px; font-size: 1px;}
.mceToolbarTop {border-bottom: 1px solid #cccccc; padding-bottom: 1px;}
.mceToolbarBottom {border-top: 1px solid #cccccc;}
-.mceToolbarContainer {position: relative; left: 0; top: 0; display: block;}
+.mceToolbarContainer {display: block; position: relative; left: 0; top: 0; width: 100%;}
.mceStatusbarTop, .mceStatusbarBottom, .mceStatusbar {height: 20px;}
.mceStatusbarTop .mceStatusbarPathText, .mceStatusbarBottom .mceStatusbarPathText, .mceStatusbar .mceStatusbarPathText {font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 9pt; padding: 2px; line-height: 16px; overflow: visible;}
.mceStatusbarTop {border-bottom: 1px solid #cccccc;}
@@ -49,7 +49,7 @@ span.mceMenuButtonSelected.mceMenuHover img.mceMenuButton {border: 1px solid #0A
/* Menu */
-.mceMenu {position: absolute; left: 0; top: 0; display: none; z-index: 100; background-color: white; border: 1px solid gray; font-weight: normal;}
+.mceMenu {position: absolute; left: 0; top: 0; display: none; z-index: 1000; background-color: white; border: 1px solid gray; font-weight: normal;}
.mceMenu a, .mceMenuTitle, .mceMenuDisabled {display: block; width: 100%; text-decoration: none; background-color: white; font-family: Tahoma, Verdana, Arial, Helvetica; font-size: 11px; line-height: 20px; color: black;}
.mceMenu a:hover {background-color: #B6BDD2; color: black; text-decoration: none !important;}
.mceMenu span {padding-left: 10px; padding-right: 10px; display: block; line-height: 20px;}
@@ -61,7 +61,7 @@ span.mceMenuSelectedItem {background-image: url('../images/menu_check.gif'); bac
span.mceMenuCheckItem {padding-left: 20px;}
span.mceMenuLine {display: block; position: absolute; left: 0; top: -1px; background-color: #F5F4F2; width: 30px; height: 1px; overflow: hidden; padding-left: 0; padding-right: 0;}
.mceColors table, .mceColors td {margin: 0; padding: 2px;}
-a.mceMoreColors {width: 130px; margin: 0; padding: 0; margin-left: 3px; margin-bottom: 3px; text-align: center; border: 1px solid white;}
+a.mceMoreColors {width: auto; padding: 0; margin: 0 3px 3px 3px; text-align: center; border: 1px solid white; text-decoration: none !important;}
.mceColorPreview {position: absolute; overflow:hidden; left: 0; top: 0; margin-left: 3px; margin-top: 15px; width: 16px; height: 4px; background-color: red;}
a.mceMoreColors:hover {border: 1px solid #0A246A;}
.mceColors td a {width: 9px; height: 9px; overflow: hidden; border: 1px solid #808080;}
@@ -77,7 +77,7 @@ a.mceMoreColors:hover {border: 1px solid #0A246A;}
* html .mceSelectList {margin-top: 2px;}
* html span.mceMenuButton, * html span.mceMenuButtonFocus {position: relative; left: 0; top: 0;}
* html span.mceMenuButton img, * html span.mceMenuButtonSelected img, * html span.mceMenuButtonFocus img {position: relative; top: 1px;}
-* html a.mceMoreColors {width: 132px;}
+* html a.mceMoreColors {width: auto;}
* html .mceColors td a {width: 10px; height: 10px;}
* html .mceColorPreview {margin-left: 2px; margin-top: 14px;}
@@ -92,6 +92,6 @@ a.mceMoreColors:hover {border: 1px solid #0A246A;}
*:first-child+html .mceSelectList {margin-top: 2px;}
*:first-child+html span.mceMenuButton, *:first-child+html span.mceMenuButtonFocus {position: relative; left: 0; top: 0;}
*:first-child+html span.mceMenuButton img, *:first-child+html span.mceMenuButtonSelected img, *:first-child+html span.mceMenuButtonFocus img {position: relative; top: 1px;}
-*:first-child+html a.mceMoreColors {width: 132px;}
+*:first-child+html a.mceMoreColors {width: 137px;}
*:first-child+html .mceColors td a {width: 10px; height: 10px;}
*:first-child+html .mceColorPreview {margin: 0; padding-left: 4px; margin-top: 14px; width: 14px;}
diff --git a/wp-includes/js/tinymce/themes/advanced/editor_template.js b/wp-includes/js/tinymce/themes/advanced/editor_template.js
index 3d91891..b8e3685 100644
--- a/wp-includes/js/tinymce/themes/advanced/editor_template.js
+++ b/wp-includes/js/tinymce/themes/advanced/editor_template.js
@@ -1,5 +1,5 @@
/**
- * $Id: editor_template_src.js 166 2007-01-05 10:31:50Z spocke $
+ * $Id: editor_template_src.js 218 2007-02-13 11:08:01Z spocke $
*
* @author Moxiecode
* @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
@@ -43,7 +43,9 @@ var TinyMCE_AdvancedTheme = {
['sub', 'sub.gif', 'lang_theme_sub_desc', 'subscript'],
['sup', 'sup.gif', 'lang_theme_sup_desc', 'superscript'],
['forecolor', 'forecolor.gif', 'lang_theme_forecolor_desc', 'forecolor', true],
+ ['forecolorpicker', 'forecolor.gif', 'lang_theme_forecolor_desc', 'forecolorpicker', true],
['backcolor', 'backcolor.gif', 'lang_theme_backcolor_desc', 'HiliteColor', true],
+ ['backcolorpicker', 'backcolor.gif', 'lang_theme_backcolor_desc', 'backcolorpicker', true],
['charmap', 'charmap.gif', 'lang_theme_charmap_desc', 'mceCharMap'],
['visualaid', 'visualaid.gif', 'lang_theme_visualaid_desc', 'mceToggleVisualAid'],
['anchor', 'anchor.gif', 'lang_theme_anchor_desc', 'mceInsertAnchor'],
@@ -356,6 +358,10 @@ var TinyMCE_AdvancedTheme = {
return false;
+ case "forecolorpicker":
+ this._pickColor(editor_id, 'forecolor');
+ return true;
+
case "forecolorMenu":
TinyMCE_AdvancedTheme._hideMenus(editor_id);
@@ -420,15 +426,21 @@ var TinyMCE_AdvancedTheme = {
ml.show();
return true;
+
+ case "backcolorpicker":
+ this._pickColor(editor_id, 'HiliteColor');
+ return true;
case "mceColorPicker":
if (user_interface) {
- var template = new Array();
- var inputColor = value['document'].getElementById(value['element_id']).value;
+ var template = [];
+
+ if (!value['callback'] && !value['color'])
+ value['color'] = value['document'].getElementById(value['element_id']).value;
template['file'] = 'color_picker.htm';
- template['width'] = 220;
- template['height'] = 190;
+ template['width'] = 380;
+ template['height'] = 250;
template['close_previous'] = "no";
template['width'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_width', 0);
@@ -438,10 +450,16 @@ var TinyMCE_AdvancedTheme = {
value['store_selection'] = true;
tinyMCE.lastColorPickerValue = value;
- tinyMCE.openWindow(template, {editor_id : editor_id, mce_store_selection : value['store_selection'], inline : "yes", command : "mceColorPicker", input_color : inputColor});
+ tinyMCE.openWindow(template, {editor_id : editor_id, mce_store_selection : value['store_selection'], inline : "yes", command : "mceColorPicker", input_color : value['color']});
} else {
- var savedVal = tinyMCE.lastColorPickerValue;
- var elm = savedVal['document'].getElementById(savedVal['element_id']);
+ var savedVal = tinyMCE.lastColorPickerValue, elm;
+
+ if (savedVal['callback']) {
+ savedVal['callback'](value);
+ return true;
+ }
+
+ elm = savedVal['document'].getElementById(savedVal['element_id']);
elm.value = value;
if (elm.onchange != null && elm.onchange != '')
@@ -599,9 +617,8 @@ var TinyMCE_AdvancedTheme = {
// Setup template html
template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width_style};height:{$height_style}"><tbody>';
- if (toolbarLocation == "top") {
- template['html'] += '<tr><td class="mceToolbarTop" align="' + toolbarAlign + '" height="1" nowrap="nowrap"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>';
- }
+ if (toolbarLocation == "top")
+ template['html'] += '<tr><td dir="ltr" class="mceToolbarTop" align="' + toolbarAlign + '" height="1" nowrap="nowrap"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>';
if (statusbarLocation == "top") {
template['html'] += '<tr><td class="mceStatusbarTop" height="1">' + statusbarHTML + '</td></tr>';
@@ -610,9 +627,8 @@ var TinyMCE_AdvancedTheme = {
template['html'] += '<tr><td align="center"><span id="{$editor_id}"></span></td></tr>';
- if (toolbarLocation == "bottom") {
- template['html'] += '<tr><td class="mceToolbarBottom" align="' + toolbarAlign + '" height="1"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>';
- }
+ if (toolbarLocation == "bottom")
+ template['html'] += '<tr><td dir="ltr" class="mceToolbarBottom" align="' + toolbarAlign + '" height="1"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>';
// External toolbar changes
if (toolbarLocation == "external") {
@@ -738,9 +754,12 @@ var TinyMCE_AdvancedTheme = {
},
removeInstance : function(inst) {
- var fcm = new TinyMCE_Layer(inst.editorId + '_fcMenu');
+ new TinyMCE_Layer(inst.editorId + '_fcMenu').remove();
+ new TinyMCE_Layer(inst.editorId + '_bcMenu').remove();
+ },
- fcm.remove();
+ hideInstance : function(inst) {
+ TinyMCE_AdvancedTheme._hideMenus(inst.editorId);
},
_handleMenuEvent : function(e) {
@@ -1224,6 +1243,7 @@ var TinyMCE_AdvancedTheme = {
if (set_w)
tableElm.style.width = w + "px";
+ if ( !tinyMCE.isMSIE || tinyMCE.isMSIE7 || tinyMCE.isOpera ) // WordPress: do this later to avoid creeping toolbar bug in MSIE6
tableElm.style.height = h + "px";
iw = iframe.clientWidth + dx;
@@ -1232,10 +1252,12 @@ var TinyMCE_AdvancedTheme = {
iw = iw < 1 ? 30 : iw;
ih = ih < 1 ? 30 : ih;
+/* WordPress found that this led to a shrinking editor with every resize. (Gray background creeps in 1px at a time.)
if (tinyMCE.isGecko) {
iw -= 2;
ih -= 2;
}
+*/
if (set_w)
iframe.style.width = iw + "px";
@@ -1253,6 +1275,8 @@ var TinyMCE_AdvancedTheme = {
}
}
+ tableElm.style.height = h + "px"; // WordPress: see above
+
// Remove pesky table controls
inst.useCSS = false;
},
@@ -1378,13 +1402,27 @@ var TinyMCE_AdvancedTheme = {
}
h += '</tr></table>';
- /*
- h += '<a href="" class="mceMoreColors">More colors</a>';
- */
+
+ if (tinyMCE.getParam("theme_advanced_more_colors", true))
+ h += '<a href="#" onclick="TinyMCE_AdvancedTheme._pickColor(\'' + id + '\',\'' + cm + '\');" class="mceMoreColors">' + tinyMCE.getLang('lang_more_colors') + '</a>';
return h;
},
+ _pickColor : function(id, cm) {
+ var inputColor, inst = tinyMCE.selectedInstance;
+
+ if (cm == 'forecolor' && inst)
+ inputColor = inst.foreColor;
+
+ if ((cm == 'backcolor' || cm == 'HiliteColor') && inst)
+ inputColor = inst.backColor;
+
+ tinyMCE.execCommand('mceColorPicker', true, {color : inputColor, callback : function(c) {
+ tinyMCE.execInstanceCommand(id, cm, false, c);
+ }});
+ },
+
_insertImage : function(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout) {
tinyMCE.execCommand('mceBeginUndoLevel');
diff --git a/wp-includes/js/tinymce/themes/advanced/images/colors.jpg b/wp-includes/js/tinymce/themes/advanced/images/colors.jpg
new file mode 100644
index 0000000..b4c542d
--- /dev/null
+++ b/wp-includes/js/tinymce/themes/advanced/images/colors.jpg
Binary files differ
diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js b/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js
index aa80714..78425e4 100644
--- a/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js
+++ b/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js
@@ -1,19 +1,4 @@
-function init() {
- if (tinyMCE.isMSIE)
- tinyMCEPopup.resizeToInnerSize();
-}
-
-function selectColor() {
- var color = document.getElementById("selectedColorBox").value;
-
- tinyMCEPopup.execCommand(tinyMCE.getWindowArg('command'), false, color);
- tinyMCEPopup.close();
-}
-
-function showColor(color) {
- document.getElementById("selectedColor").style.backgroundColor = color;
- document.getElementById("selectedColorBox").value = color;
-}
+var detail = 50, strhex = "0123456789abcdef", i, isMouseDown = false, isMouseOver = false;
var colors = new Array(
"#000000","#000033","#000066","#000099","#0000cc","#0000ff","#330000","#330033",
@@ -45,9 +30,71 @@ var colors = new Array(
"#ccffcc","#ccffff","#ffff00","#ffff33","#ffff66","#ffff99","#ffffcc","#ffffff"
);
+var named = {
+ '#F0F8FF':'AliceBlue','#FAEBD7':'AntiqueWhite','#00FFFF':'Aqua','#7FFFD4':'Aquamarine','#F0FFFF':'Azure','#F5F5DC':'Beige',
+ '#FFE4C4':'Bisque','#000000':'Black','#FFEBCD':'BlanchedAlmond','#0000FF':'Blue','#8A2BE2':'BlueViolet','#A52A2A':'Brown',
+ '#DEB887':'BurlyWood','#5F9EA0':'CadetBlue','#7FFF00':'Chartreuse','#D2691E':'Chocolate','#FF7F50':'Coral','#6495ED':'CornflowerBlue',
+ '#FFF8DC':'Cornsilk','#DC143C':'Crimson','#00FFFF':'Cyan','#00008B':'DarkBlue','#008B8B':'DarkCyan','#B8860B':'DarkGoldenRod',
+ '#A9A9A9':'DarkGray','#A9A9A9':'DarkGrey','#006400':'DarkGreen','#BDB76B':'DarkKhaki','#8B008B':'DarkMagenta','#556B2F':'DarkOliveGreen',
+ '#FF8C00':'Darkorange','#9932CC':'DarkOrchid','#8B0000':'DarkRed','#E9967A':'DarkSalmon','#8FBC8F':'DarkSeaGreen','#483D8B':'DarkSlateBlue',
+ '#2F4F4F':'DarkSlateGray','#2F4F4F':'DarkSlateGrey','#00CED1':'DarkTurquoise','#9400D3':'DarkViolet','#FF1493':'DeepPink','#00BFFF':'DeepSkyBlue',
+ '#696969':'DimGray','#696969':'DimGrey','#1E90FF':'DodgerBlue','#B22222':'FireBrick','#FFFAF0':'FloralWhite','#228B22':'ForestGreen',
+ '#FF00FF':'Fuchsia','#DCDCDC':'Gainsboro','#F8F8FF':'GhostWhite','#FFD700':'Gold','#DAA520':'GoldenRod','#808080':'Gray','#808080':'Grey',
+ '#008000':'Green','#ADFF2F':'GreenYellow','#F0FFF0':'HoneyDew','#FF69B4':'HotPink','#CD5C5C':'IndianRed','#4B0082':'Indigo','#FFFFF0':'Ivory',
+ '#F0E68C':'Khaki','#E6E6FA':'Lavender','#FFF0F5':'LavenderBlush','#7CFC00':'LawnGreen','#FFFACD':'LemonChiffon','#ADD8E6':'LightBlue',
+ '#F08080':'LightCoral','#E0FFFF':'LightCyan','#FAFAD2':'LightGoldenRodYellow','#D3D3D3':'LightGray','#D3D3D3':'LightGrey','#90EE90':'LightGreen',
+ '#FFB6C1':'LightPink','#FFA07A':'LightSalmon','#20B2AA':'LightSeaGreen','#87CEFA':'LightSkyBlue','#778899':'LightSlateGray','#778899':'LightSlateGrey',
+ '#B0C4DE':'LightSteelBlue','#FFFFE0':'LightYellow','#00FF00':'Lime','#32CD32':'LimeGreen','#FAF0E6':'Linen','#FF00FF':'Magenta','#800000':'Maroon',
+ '#66CDAA':'MediumAquaMarine','#0000CD':'MediumBlue','#BA55D3':'MediumOrchid','#9370D8':'MediumPurple','#3CB371':'MediumSeaGreen','#7B68EE':'MediumSlateBlue',
+ '#00FA9A':'MediumSpringGreen','#48D1CC':'MediumTurquoise','#C71585':'MediumVioletRed','#191970':'MidnightBlue','#F5FFFA':'MintCream','#FFE4E1':'MistyRose','#FFE4B5':'Moccasin',
+ '#FFDEAD':'NavajoWhite','#000080':'Navy','#FDF5E6':'OldLace','#808000':'Olive','#6B8E23':'OliveDrab','#FFA500':'Orange','#FF4500':'OrangeRed','#DA70D6':'Orchid',
+ '#EEE8AA':'PaleGoldenRod','#98FB98':'PaleGreen','#AFEEEE':'PaleTurquoise','#D87093':'PaleVioletRed','#FFEFD5':'PapayaWhip','#FFDAB9':'PeachPuff',
+ '#CD853F':'Peru','#FFC0CB':'Pink','#DDA0DD':'Plum','#B0E0E6':'PowderBlue','#800080':'Purple','#FF0000':'Red','#BC8F8F':'RosyBrown','#4169E1':'RoyalBlue',
+ '#8B4513':'SaddleBrown','#FA8072':'Salmon','#F4A460':'SandyBrown','#2E8B57':'SeaGreen','#FFF5EE':'SeaShell','#A0522D':'Sienna','#C0C0C0':'Silver',
+ '#87CEEB':'SkyBlue','#6A5ACD':'SlateBlue','#708090':'SlateGray','#708090':'SlateGrey','#FFFAFA':'Snow','#00FF7F':'SpringGreen',
+ '#4682B4':'SteelBlue','#D2B48C':'Tan','#008080':'Teal','#D8BFD8':'Thistle','#FF6347':'Tomato','#40E0D0':'Turquoise','#EE82EE':'Violet',
+ '#F5DEB3':'Wheat','#FFFFFF':'White','#F5F5F5':'WhiteSmoke','#FFFF00':'Yellow','#9ACD32':'YellowGreen'
+};
+
+function init() {
+ var inputColor = convertRGBToHex(tinyMCE.getWindowArg('input_color'));
+
+ if (tinyMCE.isMSIE)
+ tinyMCEPopup.resizeToInnerSize();
+
+ generatePicker();
+
+ if (inputColor) {
+ changeFinalColor(inputColor);
+
+ col = convertHexToRGB(inputColor);
+
+ if (col)
+ updateLight(col.r, col.g, col.b);
+ }
+}
+
+function insertAction() {
+ var color = document.getElementById("color").value;
+
+ tinyMCEPopup.execCommand(tinyMCE.getWindowArg('command'), false, color);
+ tinyMCEPopup.close();
+}
+
+function showColor(color, name) {
+ if (name)
+ document.getElementById("colorname").innerHTML = name;
+
+ document.getElementById("preview").style.backgroundColor = color;
+ document.getElementById("color").value = color;
+}
+
function convertRGBToHex(col) {
var re = new RegExp("rgb\\s*\\(\\s*([0-9]+).*,\\s*([0-9]+).*,\\s*([0-9]+).*\\)", "gi");
+ if (!col)
+ return col;
+
var rgb = col.replace(re, "$1,$2,$3").split(',');
if (rgb.length == 3) {
r = parseInt(rgb[0]).toString(16);
@@ -72,37 +119,131 @@ function convertHexToRGB(col) {
g = parseInt(col.substring(2, 4), 16);
b = parseInt(col.substring(4, 6), 16);
- return "rgb(" + r + "," + g + "," + b + ")";
+ return {r : r, g : g, b : b};
}
- return col;
+ return null;
}
-function renderColorMap() {
- var html = "";
- var inputColor = convertRGBToHex(tinyMCE.getWindowArg('input_color'));
+function generatePicker() {
+ var el = document.getElementById('light'), h = '', i;
+
+ for (i = 0; i < detail; i++){
+ h += '<div id="gs'+i+'" style="background-color:#000000; width:15px; height:3px; border-style:none; border-width:0px;"'
+ + ' onclick="changeFinalColor(this.style.backgroundColor)"'
+ + ' onmousedown="isMouseDown = true; return false;"'
+ + ' onmouseup="isMouseDown = false;"'
+ + ' onmousemove="if (isMouseDown && isMouseOver) changeFinalColor(this.style.backgroundColor); return false;"'
+ + ' onmouseover="isMouseOver = true;"'
+ + ' onmouseout="isMouseOver = false;"'
+ + '></div>';
+ }
+
+ el.innerHTML = h;
+}
+
+function generateWebColors() {
+ var el = document.getElementById('webcolors'), h = '', i;
+
+ if (el.className == 'generated')
+ return;
- html += '<table border="0" cellspacing="1" cellpadding="0">'
+ h += '<table border="0" cellspacing="1" cellpadding="0">'
+ '<tr>';
- for (var i=0; i<colors.length; i++) {
- html += '<td bgcolor="' + colors[i] + '">'
+
+ for (i=0; i<colors.length; i++) {
+ h += '<td bgcolor="' + colors[i] + '">'
+ '<a href="javascript:selectColor();" onfocus="showColor(\'' + colors[i] + '\');" onmouseover="showColor(\'' + colors[i] + '\');">'
+ '<img border="0" src="images/spacer.gif" width="10" height="10" title="' + colors[i] + '" alt="' + colors[i] + '" /></a></td>';
if ((i+1) % 18 == 0)
- html += '</tr><tr>';
+ h += '</tr><tr>';
+ }
+
+ h += '</table>';
+
+ el.innerHTML = h;
+ el.className = 'generated';
+}
+
+function generateNamedColors() {
+ var el = document.getElementById('namedcolors'), h = '', n, v, i = 0;
+
+ if (el.className == 'generated')
+ return;
+
+ for (n in named) {
+ v = named[n];
+ h += '<a href="javascript:selectColor();" onmouseover="showColor(\'' + n + '\',\'' + v + '\');" style="background-color: ' + n + '"><!-- IE --></a>'
+ }
+
+ el.innerHTML = h;
+ el.className = 'generated';
+}
+
+function selectColor() {
+ var color = document.getElementById("color").value;
+
+ if(window.opener)
+ window.opener.tinyMCE.execInstanceCommand(tinyMCE.getWindowArg('editor_id'),tinyMCE.getWindowArg('command'),false,color);
+
+ window.close();
+}
+
+function dechex(n) {
+ return strhex.charAt(Math.floor(n / 16)) + strhex.charAt(n % 16);
+}
+
+function computeColor(e) {
+ var x, y, partWidth, partDetail, imHeight, r, g, b, coef, i, finalCoef, finalR, finalG, finalB;
+
+ x = e.offsetX ? e.offsetX : (e.target ? e.clientX - e.target.x : 0);
+ y = e.offsetY ? e.offsetY : (e.target ? e.clientY - e.target.y : 0);
+
+ partWidth = document.getElementById('colorpicker').width / 6;
+ partDetail = detail / 2;
+ imHeight = document.getElementById('colorpicker').height;
+
+ r = (x >= 0)*(x < partWidth)*255 + (x >= partWidth)*(x < 2*partWidth)*(2*255 - x * 255 / partWidth) + (x >= 4*partWidth)*(x < 5*partWidth)*(-4*255 + x * 255 / partWidth) + (x >= 5*partWidth)*(x < 6*partWidth)*255;
+ g = (x >= 0)*(x < partWidth)*(x * 255 / partWidth) + (x >= partWidth)*(x < 3*partWidth)*255 + (x >= 3*partWidth)*(x < 4*partWidth)*(4*255 - x * 255 / partWidth);
+ b = (x >= 2*partWidth)*(x < 3*partWidth)*(-2*255 + x * 255 / partWidth) + (x >= 3*partWidth)*(x < 5*partWidth)*255 + (x >= 5*partWidth)*(x < 6*partWidth)*(6*255 - x * 255 / partWidth);
+
+ coef = (imHeight - y) / imHeight;
+ r = 128 + (r - 128) * coef;
+ g = 128 + (g - 128) * coef;
+ b = 128 + (b - 128) * coef;
+
+ changeFinalColor('#' + dechex(r) + dechex(g) + dechex(b));
+ updateLight(r, g, b);
+}
+
+function updateLight(r, g, b) {
+ var i, partDetail = detail / 2, finalCoef, finalR, finalG, finalB, color;
+
+ for (i=0; i<detail; i++) {
+ if ((i>=0) && (i<partDetail)) {
+ finalCoef = i / partDetail;
+ finalR = dechex(255 - (255 - r) * finalCoef);
+ finalG = dechex(255 - (255 - g) * finalCoef);
+ finalB = dechex(255 - (255 - b) * finalCoef);
+ } else {
+ finalCoef = 2 - i / partDetail;
+ finalR = dechex(r * finalCoef);
+ finalG = dechex(g * finalCoef);
+ finalB = dechex(b * finalCoef);
+ }
+
+ color = finalR + finalG + finalB;
+
+ document.getElementById('gs' + i).style.backgroundColor = '#'+color;
}
- html += '<tr><td colspan="18">'
- + '<table width="100%" border="0" cellspacing="0" cellpadding="0">'
- + '<tr><td>'
- + '<img id="selectedColor" style="background-color:' + tinyMCE.getWindowArg('input_color') + '" border="0" src="images/spacer.gif" width="80" height="16" />'
- + '</td><td align="right">'
- + '<input id="selectedColorBox" name="selectedColorBox" type="text" size="7" maxlength="7" style="width:65px" value="' + inputColor + '" />'
- + '</td></tr>'
- + '</table>'
- + '<div style="float: left"><input type="button" id="insert" name="insert" value="{$lang_theme_colorpicker_apply}" style="margin-top:3px" onclick="selectColor();"></div>'
- + '<div style="float: right"><input type="button" name="cancel" value="{$lang_cancel}" style="margin-top:3px" onclick="tinyMCEPopup.close();" id="cancel" /></div>'
- + '</td></tr>'
- + '</table>';
-
- document.write(html);
-} \ No newline at end of file
+}
+
+function changeFinalColor(color) {
+ if (color.indexOf('#') == -1)
+ color = convertRGBToHex(color);
+
+ document.getElementById('preview').style.backgroundColor = color;
+ document.getElementById('color').value = color;
+}
+
+window.focus(); \ No newline at end of file
diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/link.js b/wp-includes/js/tinymce/themes/advanced/jscripts/link.js
index 990b7a4..9adac22 100644
--- a/wp-includes/js/tinymce/themes/advanced/jscripts/link.js
+++ b/wp-includes/js/tinymce/themes/advanced/jscripts/link.js
@@ -27,6 +27,7 @@ function init() {
document.forms[0].href.value = tinyMCE.getWindowArg('href') || 'http://';
document.forms[0].href.select();
+ document.forms[0].href.focus();
document.forms[0].linktitle.value = tinyMCE.getWindowArg('title');
document.forms[0].insert.value = tinyMCE.getLang('lang_' + tinyMCE.getWindowArg('action'), 'Insert', true);
@@ -57,8 +58,8 @@ function insertLink() {
var title = document.forms[0].linktitle.value;
var style_class = document.forms[0].styleSelect ? document.forms[0].styleSelect.value : "";
var dummy;
-
- // Make anchors absolute
+
+ // WordPress: Make anchors absolute;
if (href.charAt(0) == '#')
href = tinyMCE.settings['document_base_url'] + href;
diff --git a/wp-includes/js/tinymce/themes/advanced/langs/en.js b/wp-includes/js/tinymce/themes/advanced/langs/en.js
index fd915ea..c658d6d 100644
--- a/wp-includes/js/tinymce/themes/advanced/langs/en.js
+++ b/wp-includes/js/tinymce/themes/advanced/langs/en.js
@@ -78,5 +78,14 @@ help : 'Help',
not_set : '-- Not set --',
close : 'Close',
toolbar_focus : 'Jump to tool buttons - Alt+Q, Jump to editor - Alt-Z, Jump to element path - Alt-X',
-invalid_data : 'Error: Invalid values entered, these are marked in red.'
+invalid_data : 'Error: Invalid values entered, these are marked in red.',
+more_colors : 'More colors',
+color_picker_tab : 'Picker',
+color_picker : 'Color picker',
+web_colors_tab : 'Web safe',
+web_colors : 'Web safe colors',
+named_colors_tab : 'Named',
+named_colors : 'Named colors',
+color : 'Color:',
+color_name : 'Name:'
});
diff --git a/wp-includes/js/tinymce/tiny_mce.js b/wp-includes/js/tinymce/tiny_mce.js
index c3f2159..e425a1e 100644
--- a/wp-includes/js/tinymce/tiny_mce.js
+++ b/wp-includes/js/tinymce/tiny_mce.js
@@ -5,8 +5,8 @@ function TinyMCE_Engine() {
var ua;
this.majorVersion = "2";
- this.minorVersion = "0.9";
- this.releaseDate = "2007-01-09";
+ this.minorVersion = "1.0";
+ this.releaseDate = "2007-02-13";
this.instances = new Array();
this.switchClassCache = new Array();
@@ -186,7 +186,7 @@ TinyMCE_Engine.prototype = {
this._def("custom_shortcuts", true);
this._def("convert_on_click", false);
this._def("content_css", '');
- this._def("fix_list_elements", false);
+ this._def("fix_list_elements", true);
this._def("fix_table_elements", false);
this._def("strict_loading_mode", document.contentType == 'application/xhtml+xml');
this._def("hidden_tab_class", '');
@@ -241,7 +241,7 @@ TinyMCE_Engine.prototype = {
this.blockElms = 'H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|FORM|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP';
this.blockRegExp = new RegExp("^(" + this.blockElms + ")$", "i");
this.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40);
- this.uniqueURL = 'javascript:TINYMCE_UNIQUEURL();'; // Make unique URL non real URL
+ this.uniqueURL = 'javascript:void(091039730);'; // Make unique URL non real URL
this.uniqueTag = '<div id="mceTMPElement" style="display: none">TMP</div>';
this.callbacks = new Array('onInit', 'getInfo', 'getEditorTemplate', 'setupContent', 'onChange', 'onPageLoad', 'handleNodeChange', 'initInstance', 'execCommand', 'getControlHTML', 'handleEvent', 'cleanup', 'removeInstance');
@@ -740,6 +740,35 @@ TinyMCE_Engine.prototype = {
tinyMCE.removeMCEControl(value);
return;
+ case "mceToggleEditor":
+ var inst = tinyMCE.getInstanceById(value), pe, te;
+
+ if (inst) {
+ pe = document.getElementById(inst.editorId + '_parent');
+ te = inst.oldTargetElement;
+
+ if (typeof(inst.enabled) == 'undefined')
+ inst.enabled = true;
+
+ inst.enabled = !inst.enabled;
+
+ if (!inst.enabled) {
+ pe.style.display = 'none';
+ te.value = inst.getHTML();
+ te.style.display = inst.oldTargetDisplay;
+ tinyMCE.dispatchCallback(inst, 'hide_instance_callback', 'hideInstance', inst);
+ } else {
+ pe.style.display = 'block';
+ te.style.display = 'none';
+ inst.setHTML(te.value);
+ inst.useCSS = false;
+ tinyMCE.dispatchCallback(inst, 'show_instance_callback', 'showInstance', inst);
+ }
+ } else
+ tinyMCE.addMCEControl(tinyMCE._getElementById(value), value);
+
+ return;
+
case "mceResetDesignMode":
// Resets the designmode state of the editors in Gecko
if (!tinyMCE.isIE) {
@@ -961,10 +990,6 @@ TinyMCE_Engine.prototype = {
// Fix for bug #957681
//inst.getDoc().designMode = inst.getDoc().designMode;
- // Setup element references
- var parentElm = inst.targetDoc.getElementById(inst.editorId + '_parent');
- inst.formElement = tinyMCE.isGecko ? parentElm.previousSibling : parentElm.nextSibling;
-
tinyMCE.handleVisualAid(inst.getBody(), true, tinyMCE.settings['visual'], inst);
tinyMCE.dispatchCallback(inst, 'setupcontent_callback', 'setupContent', editor_id, inst.getBody(), inst.getDoc());
@@ -1445,9 +1470,9 @@ TinyMCE_Engine.prototype = {
h += '</a></span>';
} else {
if (tinyMCE.isRealIE)
- h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton" onmouseover="tinyMCE._menuButtonEvent(\'over\',this);tinyMCE.lastHover = this;" onmouseout="tinyMCE._menuButtonEvent(\'out\',this);">';
+ h += '<span id="{$editor_id}_' + id + '" dir="ltr" class="mceMenuButton" onmouseover="tinyMCE._menuButtonEvent(\'over\',this);tinyMCE.lastHover = this;" onmouseout="tinyMCE._menuButtonEvent(\'out\',this);">';
else
- h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton">';
+ h += '<span id="{$editor_id}_' + id + '" dir="ltr" class="mceMenuButton">';
h += '<a href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceMenuButtonNormal" target="_self">';
h += '<img src="' + img + '" title="{$' + lang + '}" /></a>';
@@ -1693,7 +1718,7 @@ TinyMCE_Engine.prototype = {
},
triggerNodeChange : function(focus, setup_content) {
- var elm, inst, editorId, undoIndex = -1, undoLevels = -1, doc, anySelection = false;
+ var elm, inst, editorId, undoIndex = -1, undoLevels = -1, doc, anySelection = false, st;
if (tinyMCE.selectedInstance) {
inst = tinyMCE.selectedInstance;
@@ -1705,7 +1730,7 @@ TinyMCE_Engine.prototype = {
inst.lastTriggerEl = elm;*/
editorId = inst.editorId;
- selectedText = inst.selection.getSelectedText();
+ st = inst.selection.getSelectedText();
if (tinyMCE.settings.auto_resize)
inst.resizeToContent();
@@ -1716,7 +1741,7 @@ TinyMCE_Engine.prototype = {
inst.switchSettings();
if (tinyMCE.selectedElement)
- anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (selectedText && selectedText.length > 0);
+ anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (st && st.length > 0);
if (tinyMCE.settings['custom_undo_redo']) {
undoIndex = inst.undoRedo.undoIndex;
@@ -2180,11 +2205,11 @@ TinyMCE_Engine.prototype = {
},
getCSSClasses : function(editor_id, doc) {
- var output = new Array();
+ var inst = tinyMCE.getInstanceById(editor_id);
// Is cached, use that
- if (typeof(tinyMCE.cssClasses) != "undefined")
- return tinyMCE.cssClasses;
+ if (inst && inst.cssClasses.length > 0)
+ return inst.cssClasses;
if (typeof(editor_id) == "undefined" && typeof(doc) == "undefined") {
var instance;
@@ -2242,13 +2267,13 @@ TinyMCE_Engine.prototype = {
var cssClass = rule.substring(rule.indexOf('.') + 1);
var addClass = true;
- for (var p=0; p<output.length && addClass; p++) {
- if (output[p] == cssClass)
+ for (var p=0; p<inst.cssClasses.length && addClass; p++) {
+ if (inst.cssClasses[p] == cssClass)
addClass = false;
}
if (addClass)
- output[output.length] = cssClass;
+ inst.cssClasses[inst.cssClasses.length] = cssClass;
}
}
}
@@ -2257,11 +2282,7 @@ TinyMCE_Engine.prototype = {
}
}
- // Cache em
- if (output.length > 0)
- tinyMCE.cssClasses = output;
-
- return output;
+ return inst.cssClasses;
},
regexpReplace : function(in_str, reg_exp, replace_str, opts) {
@@ -2289,19 +2310,27 @@ TinyMCE_Engine.prototype = {
},
getControlHTML : function(c) {
- var i, l, n, o, v;
+ var i, l, n, o, v, rtl = tinyMCE.getLang('lang_dir') == 'rtl';
l = tinyMCE.plugins;
for (n in l) {
o = l[n];
- if (o.getControlHTML && (v = o.getControlHTML(c)) != '')
+ if (o.getControlHTML && (v = o.getControlHTML(c)) != '') {
+ if (rtl)
+ return '<span dir="rtl">' + tinyMCE.replaceVar(v, "pluginurl", o.baseURL) + '</span>';
+
return tinyMCE.replaceVar(v, "pluginurl", o.baseURL);
+ }
}
o = tinyMCE.themes[tinyMCE.settings['theme']];
- if (o.getControlHTML && (v = o.getControlHTML(c)) != '')
+ if (o.getControlHTML && (v = o.getControlHTML(c)) != '') {
+ if (rtl)
+ return '<span dir="rtl">' + v + '</span>';
+
return v;
+ }
return '';
},
@@ -2433,6 +2462,7 @@ function TinyMCE_Control(settings) {
this.hasMouseMoved = false;
this.foreColor = this.backColor = "#999999";
this.data = {};
+ this.cssClasses = [];
this.cleanup.init({
valid_elements : s.valid_elements,
@@ -2865,7 +2895,7 @@ TinyMCE_Control.prototype = {
if (tinyMCE.isGecko && this.getSel().isCollapsed) {
focusElm = tinyMCE.getParentElement(focusElm, 'A');
- if (focusElm && this.getRng(0).endOffset > 0 && this.getRng(0).endOffset != focusElm.innerHTML.length) // WordPress mod to prevent unlinking if caret at start/end of link
+ if (focusElm)
this.selection.selectNode(focusElm, false);
}
@@ -3690,6 +3720,7 @@ TinyMCE_Control.prototype = {
hc = '<textarea wrap="off" id="' + form_element_name + '" name="' + form_element_name + '" cols="100" rows="15"></textarea>';
} else {
hc = '<input type="hidden" id="' + form_element_name + '" name="' + form_element_name + '" />';
+ this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline');
this.oldTargetElement.style.display = "none";
}
@@ -3715,8 +3746,10 @@ TinyMCE_Control.prototype = {
// Just hide the textarea element
this.oldTargetElement = replace_element;
- if (!tinyMCE.settings['debug'])
+ if (!tinyMCE.settings['debug']) {
+ this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline');
this.oldTargetElement.style.display = "none";
+ }
// Output HTML and set editable
if (tinyMCE.isGecko) {
@@ -3790,6 +3823,10 @@ TinyMCE_Control.prototype = {
if (tinyMCE.isIE)
window.setTimeout("tinyMCE.addEventHandlers(tinyMCE.instances[\"" + this.editorId + "\"]);", 1);
+ // Setup element references
+ var parentElm = this.targetDoc.getElementById(this.editorId + '_parent');
+ this.formElement = tinyMCE.isGecko ? parentElm.previousSibling : parentElm.nextSibling;
+
tinyMCE.setupContent(this.editorId, true);
return true;
@@ -4865,7 +4902,7 @@ TinyMCE_Cleanup.prototype = {
if (r.forceAttribs && (t = r.forceAttribs[an]))
av = t;
- if (os && av.length != 0 && this.settings.url_converter.length != 0 && /^(src|href|longdesc)$/.test(an))
+ if (os && av.length != 0 && /^(src|href|longdesc)$/.test(an))
av = this._urlConverter(this, n, av);
if (av.length != 0 && r.validAttribValues && r.validAttribValues[an] && !r.validAttribValues[an].test(av))
@@ -5186,9 +5223,10 @@ TinyMCE_Engine.prototype.setInnerHTML = function(e, h) {
// Convert all strong/em to b/i in Gecko
if (tinyMCE.isGecko) {
- h = h.replace(/<strong/gi, '<b');
- h = h.replace(/<em(\/?)/gi, '<i');
- h = h.replace(/<em /gi, '<i');
+ h = h.replace(/<embed([^>]*)>/gi, '<tmpembed$1>');
+ h = h.replace(/<em([^>]*)>/gi, '<i$1>');
+ h = h.replace(/<tmpembed([^>]*)>/gi, '<embed$1>');
+ h = h.replace(/<strong([^>]*)>/gi, '<b$1>');
h = h.replace(/<\/strong>/gi, '</b>');
h = h.replace(/<\/em>/gi, '</i>');
}
@@ -5503,6 +5541,32 @@ TinyMCE_Engine.prototype.getViewPort = function(w) {
};
};
+TinyMCE_Engine.prototype.getStyle = function(n, na, d) {
+ if (!n)
+ return false;
+
+ // Gecko
+ if (tinyMCE.isGecko && n.ownerDocument.defaultView) {
+ try {
+ return n.ownerDocument.defaultView.getComputedStyle(n, null).getPropertyValue(na);
+ } catch (n) {
+ // Old safari might fail
+ return null;
+ }
+ }
+
+ // Camelcase it, if needed
+ na = na.replace(/-(\D)/g, function(a, b){
+ return b.toUpperCase();
+ });
+
+ // IE & Opera
+ if (n.currentStyle)
+ return n.currentStyle[na];
+
+ return false;
+};
+
/* file:jscripts/tiny_mce/classes/TinyMCE_URL.class.js */
TinyMCE_Engine.prototype.parseURL = function(url_str) {
@@ -7132,13 +7196,21 @@ TinyMCE_Layer.prototype = {
},
show : function() {
- this.getElement().style.display = 'block';
- this.updateBlocker();
+ var el = this.getElement();
+
+ if (el) {
+ el.style.display = 'block';
+ this.updateBlocker();
+ }
},
hide : function() {
- this.getElement().style.display = 'none';
- this.updateBlocker();
+ var el = this.getElement();
+
+ if (el) {
+ el.style.display = 'none';
+ this.updateBlocker();
+ }
},
isVisible : function() {
diff --git a/wp-includes/js/tinymce/tiny_mce_config.php b/wp-includes/js/tinymce/tiny_mce_config.php
index 9e06575..de01c67 100644
--- a/wp-includes/js/tinymce/tiny_mce_config.php
+++ b/wp-includes/js/tinymce/tiny_mce_config.php
@@ -29,7 +29,7 @@
$plugins = apply_filters('mce_plugins', $plugins);
$plugins = implode($plugins, ',');
- $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'separator', 'bullist', 'numlist', 'outdent', 'indent', 'separator', 'justifyleft', 'justifycenter', 'justifyright', 'separator', 'link', 'unlink', 'image', 'wp_more', 'separator', 'spellchecker', 'separator', 'wp_help', 'wp_adv_start', 'wp_adv', 'separator', 'formatselect', 'underline', 'justifyfull', 'forecolor', 'separator', 'pastetext', 'pasteword', 'separator', 'removeformat', 'cleanup', 'separator', 'charmap', 'separator', 'undo', 'redo', 'wp_adv_end'));
+ $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'separator', 'bullist', 'numlist', 'outdent', 'indent', 'separator', 'justifyleft', 'justifycenter', 'justifyright', 'separator', 'link', 'unlink', 'image', 'wp_more', 'separator', 'spellchecker', 'separator', 'wp_help', 'wp_adv', 'wp_adv_start', 'formatselect', 'underline', 'justifyfull', 'forecolor', 'separator', 'pastetext', 'pasteword', 'separator', 'removeformat', 'cleanup', 'separator', 'charmap', 'separator', 'undo', 'redo', 'wp_adv_end'));
$mce_buttons = implode($mce_buttons, ',');
$mce_buttons_2 = apply_filters('mce_buttons_2', array());
@@ -48,6 +48,8 @@
$mce_css = str_replace('http://', 'https://', $mce_css);
$mce_popups_css = str_replace('http://', 'https://', $mce_popups_css);
}
+
+ $mce_locale = ( '' == get_locale() ) ? 'en' : strtolower(get_locale());
?>
initArray = {
@@ -58,7 +60,7 @@ initArray = {
theme_advanced_buttons1 : "<?php echo $mce_buttons; ?>",
theme_advanced_buttons2 : "<?php echo $mce_buttons_2; ?>",
theme_advanced_buttons3 : "<?php echo $mce_buttons_3; ?>",
- language : "<?php echo strtolower(get_locale()); ?>",
+ language : "<?php echo $mce_locale; ?>",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_path_location : "bottom",
@@ -76,6 +78,7 @@ initArray = {
fix_list_elements : true,
gecko_spellcheck : true,
entities : "38,amp,60,lt,62,gt",
+ button_tile_map : true,
content_css : "<?php echo $mce_css; ?>",
valid_elements : "<?php echo $valid_elements; ?>",
save_callback : 'TinyMCE_wordpressPlugin.saveCallback',
diff --git a/wp-includes/js/tinymce/tiny_mce_gzip.php b/wp-includes/js/tinymce/tiny_mce_gzip.php
index 59af4b6..14ffba3 100644
--- a/wp-includes/js/tinymce/tiny_mce_gzip.php
+++ b/wp-includes/js/tinymce/tiny_mce_gzip.php
@@ -84,7 +84,7 @@
if (isset($_SERVER['HTTP_ACCEPT_ENCODING']))
$encodings = explode(',', strtolower(preg_replace("/\s+/", "", $_SERVER['HTTP_ACCEPT_ENCODING'])));
- if ((in_array('gzip', $encodings) || in_array('x-gzip', $encodings) || isset($_SERVER['---------------'])) && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression')) {
+ if ((in_array('gzip', $encodings) || in_array('x-gzip', $encodings) || isset($_SERVER['---------------'])) && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression') && ini_get('output_handler') != 'ob_gzhandler') {
$enc = in_array('x-gzip', $encodings) ? "x-gzip" : "gzip";
$supportsGzip = true;
}
diff --git a/wp-includes/js/wp-ajax.js b/wp-includes/js/wp-ajax.js
index cc3bb5a..e3f63f7 100644
--- a/wp-includes/js/wp-ajax.js
+++ b/wp-includes/js/wp-ajax.js
@@ -27,9 +27,9 @@ Object.extend(WPAjax.prototype, {
this.getResponseElement(responseEl);
},
addArg: function(key, value) {
- var a = [];
+ var a = $H();
a[encodeURIComponent(key)] = encodeURIComponent(value);
- this.options.parameters = $H(this.options.parameters).merge($H(a));
+ this.options.parameters = $H(this.options.parameters).merge(a);
},
getResponseElement: function(r) {
var p = $(r + '-p');
diff --git a/wp-includes/kses.php b/wp-includes/kses.php
index aa9e465..4b5a284 100644
--- a/wp-includes/kses.php
+++ b/wp-includes/kses.php
@@ -18,253 +18,207 @@ if (!defined('CUSTOM_TAGS'))
// You can override this in your my-hacks.php file
if (!CUSTOM_TAGS) {
- $allowedposttags = array (
- 'address' => array (),
- 'a' => array (
- 'class' => array (),
- 'href' => array (),
- 'id' => array (),
- 'title' => array (),
- 'rel' => array (),
- 'rev' => array (),
- 'name' => array (),
- 'target' => array()),
- 'abbr' => array (
- 'title' => array ()),
- 'acronym' => array (
- 'title' => array ()),
- 'b' => array (),
- 'big' => array (),
- 'blockquote' => array (
- 'id' => array (),
- 'cite' => array ()),
- 'br' => array (
- 'class' => array ()),
- 'button' => array (
- 'disabled' => array (),
- 'name' => array (),
- 'type' => array (),
- 'value' => array ()),
- 'caption' => array (
- 'align' => array (),
- 'class' => array ()),
- 'cite' => array (
- 'class' => array(),
- 'dir' => array(),
- 'lang' => array(),
- 'title' => array ()),
- 'code' => array (),
- 'col' => array (
- 'align' => array (),
- 'char' => array (),
- 'charoff' => array (),
- 'span' => array (),
- 'dir' => array(),
- 'valign' => array (),
- 'width' => array ()),
- 'del' => array (
- 'datetime' => array ()),
- 'dd' => array (),
- 'div' => array (
- 'align' => array (),
- 'class' => array (),
- 'dir' => array ()),
- 'dl' => array (),
- 'dt' => array (),
- 'em' => array (),
- 'fieldset' => array (),
- 'font' => array (
- 'color' => array (),
- 'face' => array (),
- 'size' => array ()),
- 'form' => array (
- 'action' => array (),
- 'accept' => array (),
- 'accept-charset' => array (),
- 'enctype' => array (),
- 'method' => array (),
- 'name' => array (),
- 'target' => array ()),
- 'h1' => array (
- 'align' => array (),
- 'class' => array ()),
- 'h2' => array (
- 'align' => array (),
- 'class' => array ()),
- 'h3' => array (
- 'align' => array (),
- 'class' => array ()),
- 'h4' => array (
- 'align' => array (),
- 'class' => array ()),
- 'h5' => array (
- 'align' => array (),
- 'class' => array ()),
- 'h6' => array (
- 'align' => array (),
- 'class' => array ()),
- 'hr' => array (
- 'align' => array (),
- 'class' => array (),
- 'noshade' => array (),
- 'size' => array (),
- 'width' => array ()),
- 'i' => array (),
- 'img' => array (
- 'alt' => array (),
- 'align' => array (),
- 'border' => array (),
- 'class' => array (),
- 'height' => array (),
- 'hspace' => array (),
- 'longdesc' => array (),
- 'vspace' => array (),
- 'src' => array (),
- 'width' => array ()),
- 'ins' => array (
- 'datetime' => array (),
- 'cite' => array ()),
- 'kbd' => array (),
- 'label' => array (
- 'for' => array ()),
- 'legend' => array (
- 'align' => array ()),
- 'li' => array (
- 'align' => array (),
- 'class' => array ()),
- 'p' => array (
- 'class' => array (),
- 'align' => array (),
- 'dir' => array()),
- 'pre' => array (
- 'width' => array ()),
- 'q' => array (
- 'cite' => array ()),
- 's' => array (),
- 'span' => array (
- 'class' => array (),
- 'dir' => array (),
- 'align' => array ()),
- 'strike' => array (),
- 'strong' => array (),
- 'sub' => array (),
- 'sup' => array (),
- 'table' => array (
- 'align' => array (),
- 'bgcolor' => array (),
- 'border' => array (),
- 'cellpadding' => array (),
- 'cellspacing' => array (),
- 'class' => array (),
- 'dir' => array(),
- 'rules' => array (),
- 'summary' => array (),
- 'width' => array ()),
- 'tbody' => array (
- 'align' => array (),
- 'char' => array (),
- 'charoff' => array (),
- 'valign' => array ()),
- 'td' => array (
- 'abbr' => array (),
- 'align' => array (),
- 'axis' => array (),
- 'bgcolor' => array (),
- 'char' => array (),
- 'charoff' => array (),
- 'class' => array (),
- 'colspan' => array (),
- 'dir' => array(),
- 'headers' => array (),
- 'height' => array (),
- 'nowrap' => array (),
- 'rowspan' => array (),
- 'scope' => array (),
- 'valign' => array (),
- 'width' => array ()),
- 'textarea' => array (
- 'cols' => array (),
- 'rows' => array (),
- 'disabled' => array (),
- 'name' => array (),
- 'readonly' => array ()),
- 'tfoot' => array (
- 'align' => array (),
- 'char' => array (),
- 'class' => array (),
- 'charoff' => array (),
- 'valign' => array ()),
- 'th' => array (
- 'abbr' => array (),
- 'align' => array (),
- 'axis' => array (),
- 'bgcolor' => array (),
- 'char' => array (),
- 'charoff' => array (),
- 'class' => array (),
- 'colspan' => array (),
- 'headers' => array (),
- 'height' => array (),
- 'nowrap' => array (),
- 'rowspan' => array (),
- 'scope' => array (),
- 'valign' => array (),
- 'width' => array ()),
- 'thead' => array (
- 'align' => array (),
- 'char' => array (),
- 'charoff' => array (),
- 'class' => array (),
- 'valign' => array ()),
- 'title' => array (),
- 'tr' => array (
- 'align' => array (),
- 'bgcolor' => array (),
- 'char' => array (),
- 'charoff' => array (),
- 'class' => array (),
- 'valign' => array ()),
- 'tt' => array (),
- 'u' => array (),
- 'ul' => array (
- 'class' => array ()),
- 'ol' => array (
- 'class' => array ()),
- 'var' => array ());
- $allowedtags = array (
- 'a' => array (
- 'href' => array (),
- 'title' => array ()),
- 'abbr' => array (
- 'title' => array ()),
- 'acronym' => array (
- 'title' => array ()),
- 'b' => array (),
- 'blockquote' => array (
- 'cite' => array ()),
- // 'br' => array(),
- 'cite' => array (),
- 'code' => array (),
+ $allowedposttags = array(
+ 'address' => array(),
+ 'a' => array(
+ 'href' => array(), 'title' => array(),
+ 'rel' => array(), 'rev' => array(),
+ 'name' => array()
+ ),
+ 'abbr' => array(
+ 'title' => array(), 'class' => array()
+ ),
+ 'acronym' => array(
+ 'title' => array()
+ ),
+ 'b' => array(),
+ 'big' => array(),
+ 'blockquote' => array(
+ 'cite' => array(), 'xml:lang' => array(),
+ 'lang' => array()
+ ),
+ 'br' => array(),
+ 'button' => array(
+ 'disabled' => array(), 'name' => array(),
+ 'type' => array(), 'value' => array()
+ ),
+ 'caption' => array(
+ 'align' => array()
+ ),
+ 'code' => array(),
+ 'col' => array(
+ 'align' => array(), 'char' => array(),
+ 'charoff' => array(), 'span' => array(),
+ 'valign' => array(), 'width' => array()
+ ),
'del' => array(
- 'datetime' => array ()),
- // 'dd' => array(),
- // 'dl' => array(),
- // 'dt' => array(),
- 'em' => array (), 'i' => array (),
- // 'ins' => array('datetime' => array(), 'cite' => array()),
- // 'li' => array(),
- // 'ol' => array(),
- // 'p' => array(),
+ 'datetime' => array()
+ ),
+ 'dd' => array(),
+ 'div' => array(
+ 'align' => array(), 'xml:lang' => array(),
+ 'lang' => array()
+ ),
+ 'dl' => array(),
+ 'dt' => array(),
+ 'em' => array(),
+ 'fieldset' => array(),
+ 'font' => array(
+ 'color' => array(), 'face' => array(),
+ 'size' => array()
+ ),
+ 'form' => array(
+ 'action' => array(), 'accept' => array(),
+ 'accept-charset' => array(), 'enctype' => array(),
+ 'method' => array(), 'name' => array(),
+ 'target' => array()
+ ),
+ 'h1' => array(
+ 'align' => array()
+ ),
+ 'h2' => array(
+ 'align' => array()
+ ),
+ 'h3' => array(
+ 'align' => array()
+ ),
+ 'h4' => array(
+ 'align' => array()
+ ),
+ 'h5' => array(
+ 'align' => array()
+ ),
+ 'h6' => array(
+ 'align' => array()
+ ),
+ 'hr' => array(
+ 'align' => array(), 'noshade' => array(),
+ 'size' => array(), 'width' => array()
+ ),
+ 'i' => array(),
+ 'img' => array(
+ 'alt' => array(), 'align' => array(),
+ 'border' => array(), 'height' => array(),
+ 'hspace' => array(), 'longdesc' => array(),
+ 'vspace' => array(), 'src' => array(),
+ 'width' => array()
+ ),
+ 'ins' => array(
+ 'datetime' => array(), 'cite' => array()
+ ),
+ 'kbd' => array(),
+ 'label' => array(
+ 'for' => array()
+ ),
+ 'legend' => array(
+ 'align' => array()
+ ),
+ 'li' => array(),
+ 'p' => array(
+ 'align' => array(), 'xml:lang' => array(),
+ 'lang' => array()
+ ),
+ 'pre' => array(
+ 'width' => array()
+ ),
'q' => array(
- 'cite' => array ()),
- 'strike' => array (),
- 'strong' => array (),
- // 'sub' => array(),
- // 'sup' => array(),
- // 'u' => array(),
- // 'ul' => array(),
+ 'cite' => array()
+ ),
+ 's' => array(),
+ 'strike' => array(),
+ 'strong' => array(),
+ 'sub' => array(),
+ 'sup' => array(),
+ 'table' => array(
+ 'align' => array(), 'bgcolor' => array(),
+ 'border' => array(), 'cellpadding' => array(),
+ 'cellspacing' => array(), 'rules' => array(),
+ 'summary' => array(), 'width' => array()
+ ),
+ 'tbody' => array(
+ 'align' => array(), 'char' => array(),
+ 'charoff' => array(), 'valign' => array()
+ ),
+ 'td' => array(
+ 'abbr' => array(), 'align' => array(),
+ 'axis' => array(), 'bgcolor' => array(),
+ 'char' => array(), 'charoff' => array(),
+ 'colspan' => array(), 'headers' => array(),
+ 'height' => array(), 'nowrap' => array(),
+ 'rowspan' => array(), 'scope' => array(),
+ 'valign' => array(), 'width' => array()
+ ),
+ 'textarea' => array(
+ 'cols' => array(), 'rows' => array(),
+ 'disabled' => array(), 'name' => array(),
+ 'readonly' => array()
+ ),
+ 'tfoot' => array(
+ 'align' => array(), 'char' => array(),
+ 'charoff' => array(), 'valign' => array()
+ ),
+ 'th' => array(
+ 'abbr' => array(), 'align' => array(),
+ 'axis' => array(), 'bgcolor' => array(),
+ 'char' => array(), 'charoff' => array(),
+ 'colspan' => array(), 'headers' => array(),
+ 'height' => array(), 'nowrap' => array(),
+ 'rowspan' => array(), 'scope' => array(),
+ 'valign' => array(), 'width' => array()
+ ),
+ 'thead' => array(
+ 'align' => array(), 'char' => array(),
+ 'charoff' => array(), 'valign' => array()
+ ),
+ 'title' => array(),
+ 'tr' => array(
+ 'align' => array(), 'bgcolor' => array(),
+ 'char' => array(), 'charoff' => array(),
+ 'valign' => array()
+ ),
+ 'tt' => array(),
+ 'u' => array(),
+ 'ul' => array(),
+ 'ol' => array(),
+ 'var' => array()
+ );
+
+ $allowedtags = array(
+ 'a' => array(
+ 'href' => array(), 'title' => array()
+ ),
+ 'abbr' => array(
+ 'title' => array()
+ ),
+ 'acronym' => array(
+ 'title' => array()
+ ),
+ 'b' => array(),
+ 'blockquote' => array(
+ 'cite' => array()
+ ),
+ // 'br' => array(),
+ 'code' => array(),
+ // 'del' => array('datetime' => array()),
+ // 'dd' => array(),
+ // 'dl' => array(),
+ // 'dt' => array(),
+ 'em' => array(),
+ 'i' => array(),
+ // 'ins' => array('datetime' => array(), 'cite' => array()),
+ // 'li' => array(),
+ // 'ol' => array(),
+ // 'p' => array(),
+ // 'q' => array(),
+ 'strike' => array(),
+ 'strong' => array(),
+ // 'sub' => array(),
+ // 'sup' => array(),
+ // 'u' => array(),
+ // 'ul' => array(),
);
}
+
function wp_kses($string, $allowed_html, $allowed_protocols = array ('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet'))
###############################################################################
# This function makes sure that only the allowed HTML element names, attribute
diff --git a/wp-includes/l10n.php b/wp-includes/l10n.php
index 0847ea3..4dba679 100644
--- a/wp-includes/l10n.php
+++ b/wp-includes/l10n.php
@@ -17,8 +17,7 @@ function get_locale() {
return $locale;
}
-// Return a translated string.
-function __($text, $domain = 'default') {
+function translate($text, $domain) {
global $l10n;
if (isset($l10n[$domain]))
@@ -27,29 +26,24 @@ function __($text, $domain = 'default') {
return $text;
}
+// Return a translated string.
+function __($text, $domain = 'default') {
+ return translate($text, $domain);
+}
+
// Echo a translated string.
function _e($text, $domain = 'default') {
- global $l10n;
-
- if (isset($l10n[$domain]))
- echo apply_filters('gettext', $l10n[$domain]->translate($text), $text);
- else
- echo $text;
+ echo translate($text, $domain);
}
function _c($text, $domain = 'default') {
- global $l10n;
-
- if ( isset($l10n[$domain]) )
- $whole = apply_filters('gettext', $l10n[$domain]->translate($text), $text);
- else
- $whole = $text;
-
- $trans = explode('|', $whole, 2);
- if ( isset( $trans[1] ) )
- return $trans[1];
- else
- return $trans[0];
+ $whole = translate($text, $domain);
+ $last_bar = strrpos($whole, '|');
+ if ( false == $last_bar ) {
+ return $whole;
+ } else {
+ return substr($whole, 0, $last_bar);
+ }
}
// Return the plural form.
@@ -57,7 +51,7 @@ function __ngettext($single, $plural, $number, $domain = 'default') {
global $l10n;
if (isset($l10n[$domain])) {
- return $l10n[$domain]->ngettext($single, $plural, $number);
+ return apply_filters('ngettext', $l10n[$domain]->ngettext($single, $plural, $number), $single, $plural, $number);
} else {
if ($number != 1)
return $plural;
diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php
index a7f9601..99b8ae0 100644
--- a/wp-includes/link-template.php
+++ b/wp-includes/link-template.php
@@ -109,7 +109,7 @@ function get_permalink($id = 0) {
}
// get permalink from post ID
-function post_permalink($post_id = 0, $mode = '') { // $mode legacy
+function post_permalink($post_id = 0, $deprecated = '') {
return get_permalink($post_id);
}
@@ -273,39 +273,80 @@ function get_post_comments_feed_link($post_id = '', $feed = 'rss2') {
return apply_filters('post_comments_feed_link', $url);
}
-function edit_post_link($link = 'Edit This', $before = '', $after = '') {
+function get_edit_post_link( $id = 0 ) {
+ $post = &get_post( $id );
+
+ if ( $post->post_type == 'attachment' ) {
+ return;
+ } elseif ( $post->post_type == 'page' ) {
+ if ( !current_user_can( 'edit_page', $post->ID ) )
+ return;
+
+ $file = 'page';
+ } else {
+ if ( !current_user_can( 'edit_post', $post->ID ) )
+ return;
+
+ $file = 'post';
+ }
+
+ return apply_filters( 'get_edit_post_link', get_bloginfo( 'wpurl' ) . '/wp-admin/' . $file . '.php?action=edit&amp;post=' . $post->ID, $post->ID );
+}
+
+function edit_post_link( $link = 'Edit This', $before = '', $after = '' ) {
global $post;
- if ( is_attachment() )
+ if ( $post->post_type == 'attachment' ) {
return;
-
- if( $post->post_type == 'page' ) {
- if ( ! current_user_can('edit_page', $post->ID) )
+ } elseif ( $post->post_type == 'page' ) {
+ if ( !current_user_can( 'edit_page', $post->ID ) )
return;
+
$file = 'page';
} else {
- if ( ! current_user_can('edit_post', $post->ID) )
+ if ( !current_user_can( 'edit_post', $post->ID ) )
return;
+
$file = 'post';
}
- $location = get_option('siteurl') . "/wp-admin/{$file}.php?action=edit&amp;post=$post->ID";
- echo $before . "<a href=\"$location\">$link</a>" . $after;
+ $link = '<a href="' . get_edit_post_link( $post->ID ) . '" title="' . __( 'Edit post' ) . '">' . $link . '</a>';
+ echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after;
}
-function edit_comment_link($link = 'Edit This', $before = '', $after = '') {
- global $post, $comment;
+function get_edit_comment_link( $comment_id = 0 ) {
+ $comment = &get_comment( $comment_id );
+ $post = &get_post( $comment->comment_post_ID );
+
+ if ( $post->post_type == 'attachment' ) {
+ return;
+ } elseif ( $post->post_type == 'page' ) {
+ if ( !current_user_can( 'edit_page', $post->ID ) )
+ return;
+ } else {
+ if ( !current_user_can( 'edit_post', $post->ID ) )
+ return;
+ }
- if( $post->post_type == 'page' ){
- if ( ! current_user_can('edit_page', $post->ID) )
+ $location = get_bloginfo( 'wpurl' ) . '/wp-admin/comment.php?action=editcomment&amp;c=' . $comment->comment_ID;
+ return apply_filters( 'get_edit_comment_link', $location );
+}
+
+function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) {
+ global $comment, $post;
+
+ if ( $post->post_type == 'attachment' ) {
+ return;
+ } elseif ( $post->post_type == 'page' ) {
+ if ( !current_user_can( 'edit_page', $post->ID ) )
return;
} else {
- if ( ! current_user_can('edit_post', $post->ID) )
+ if ( !current_user_can( 'edit_post', $post->ID ) )
return;
}
- $location = get_option('siteurl') . "/wp-admin/comment.php?action=editcomment&amp;c=$comment->comment_ID";
- echo $before . "<a href='$location'>$link</a>" . $after;
+ $link = '<a href="' . get_edit_comment_link( $comment->comment_ID ) . '" title="' . __( 'Edit comment' ) . '">' . $link . '</a>';
+ echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
}
// Navigation links
@@ -422,73 +463,55 @@ function next_post_link($format='%link &raquo;', $link='%title', $in_same_cat =
function get_pagenum_link($pagenum = 1) {
global $wp_rewrite;
-
- $qstr = $_SERVER['REQUEST_URI'];
-
- $page_querystring = "paged";
- $page_modstring = "page/";
- $page_modregex = "page/?";
- $permalink = 0;
-
+
+ $pagenum = (int) $pagenum;
+
+ $request = remove_query_arg( 'paged' );
+
$home_root = parse_url(get_option('home'));
$home_root = $home_root['path'];
- $home_root = trailingslashit($home_root);
- $qstr = preg_replace('|^'. $home_root . '|', '', $qstr);
- $qstr = preg_replace('|^/+|', '', $qstr);
-
- $index = $_SERVER['PHP_SELF'];
- $index = preg_replace('|^'. $home_root . '|', '', $index);
- $index = preg_replace('|^/+|', '', $index);
-
- // if we already have a QUERY style page string
- if ( stristr( $qstr, $page_querystring ) ) {
- $replacement = "$page_querystring=$pagenum";
- $qstr = preg_replace("/".$page_querystring."[^\d]+\d+/", $replacement, $qstr);
- // if we already have a mod_rewrite style page string
- } elseif ( preg_match( '|'.$page_modregex.'\d+|', $qstr ) ) {
- $permalink = 1;
- $qstr = preg_replace('|'.$page_modregex.'\d+|',"$page_modstring$pagenum",$qstr);
-
- // if we don't have a page string at all ...
- // lets see what sort of URL we have...
+ $home_root = preg_quote( trailingslashit( $home_root ), '|' );
+
+ $request = preg_replace('|^'. $home_root . '|', '', $request);
+ $request = preg_replace('|^/+|', '', $request);
+
+ if ( !$wp_rewrite->using_permalinks() ) {
+ $base = trailingslashit( get_bloginfo( 'home' ) );
+
+ if ( $pagenum > 1 ) {
+ $result = add_query_arg( 'paged', $pagenum, $base . $request );
+ } else {
+ $result = $base . $request;
+ }
} else {
- // we need to know the way queries are being written
- // if there's a querystring_start (a "?" usually), it's definitely not mod_rewritten
- if ( stristr( $qstr, '?' ) ) {
- // so append the query string (using &, since we already have ?)
- $qstr .= '&amp;' . $page_querystring . '=' . $pagenum;
- // otherwise, it could be rewritten, OR just the default index ...
- } elseif( '' != get_option('permalink_structure') && ! is_admin() ) {
- $permalink = 1;
- $index = $wp_rewrite->index;
- // If it's not a path info permalink structure, trim the index.
- if ( !$wp_rewrite->using_index_permalinks() ) {
- $qstr = preg_replace("#/*" . $index . "/*#", '/', $qstr);
- } else {
- // If using path info style permalinks, make sure the index is in
- // the URL.
- if ( strpos($qstr, $index) === false )
- $qstr = '/' . $index . $qstr;
- }
-
- $qstr = trailingslashit($qstr) . $page_modstring . $pagenum;
+ $request = preg_replace( '|/?page/(.+)/?$|', '', $request);
+
+ $qs_regex = '|\?.*?$|';
+ preg_match( $qs_regex, $request, $qs_match );
+
+ if ( $qs_match[0] ) {
+ $query_string = $qs_match[0];
+ $request = preg_replace( $qs_regex, '', $request );
} else {
- $qstr = $index . '?' . $page_querystring . '=' . $pagenum;
+ $query_string = '';
}
+
+ $base = trailingslashit( get_bloginfo( 'url' ) );
+
+ if ( $wp_rewrite->using_index_permalinks() && $pagenum > 1 ) {
+ $base .= 'index.php/';
+ }
+
+ if ( $pagenum > 1 ) {
+ $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( 'page/' . $pagenum, 'paged' );
+ } else {
+ $request = user_trailingslashit( $request );
+ }
+
+ $result = $base . $request . $query_string;
}
-
- $qstr = preg_replace('|^/+|', '', $qstr);
- if ( $permalink )
- $qstr = user_trailingslashit($qstr, 'paged');
- $qstr = preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', trailingslashit( get_option('home') ) . $qstr );
-
- // showing /page/1/ or ?paged=1 is redundant
- if ( 1 === $pagenum ) {
- $qstr = str_replace(user_trailingslashit('index.php/page/1', 'paged'), '', $qstr); // for PATHINFO style
- $qstr = str_replace(user_trailingslashit('page/1', 'paged'), '', $qstr); // for mod_rewrite style
- $qstr = remove_query_arg('paged', $qstr); // for query style
- }
- return $qstr;
+
+ return $result;
}
function get_next_posts_page_link($max_page = 0) {
diff --git a/wp-includes/locale.php b/wp-includes/locale.php
index 0c8ec8b..af3fc13 100644
--- a/wp-includes/locale.php
+++ b/wp-includes/locale.php
@@ -87,6 +87,18 @@ class WP_Locale {
$this->meridiem['AM'] = __('AM');
$this->meridiem['PM'] = __('PM');
+ // Numbers formatting
+ // See http://php.net/number_format
+
+ $trans = __('number_format_decimals');
+ $this->number_format['decimals'] = ('number_format_decimals' == $trans) ? 0 : $trans;
+
+ $trans = __('number_format_decimal_point');
+ $this->number_format['decimal_point'] = ('number_format_decimal_point' == $trans) ? '.' : $trans;
+
+ $trans = __('number_format_thousands_sep');
+ $this->number_format['thousands_sep'] = ('number_format_thousands_sep' == $trans) ? ',' : $trans;
+
// Import global locale vars set during inclusion of $locale.php.
foreach ( $this->locale_vars as $var ) {
if ( isset($GLOBALS[$var]) )
diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php
index 5f00e1d..949e603 100644
--- a/wp-includes/pluggable.php
+++ b/wp-includes/pluggable.php
@@ -121,6 +121,8 @@ function get_userdatabylogin($user_login) {
if ( $userdata )
return $userdata;
+ $user_login = $wpdb->escape($user_login);
+
if ( !$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$user_login'") )
return false;
diff --git a/wp-includes/plugin.php b/wp-includes/plugin.php
index 61580e7..b8bf524 100644
--- a/wp-includes/plugin.php
+++ b/wp-includes/plugin.php
@@ -1,25 +1,53 @@
<?php
-//
-// Filter functions, the core of the WP plugin architecture.
-//
-
+/**
+ * Hooks a function to a specific filter action.
+ *
+ * Filters are the hooks that WordPress launches to modify text of various types
+ * before adding it to the database or sending it to the browser screen. Plugins
+ * can specify that one or more of its PHP functions is executed to
+ * modify specific types of text at these times, using the Filter API.
+ * See the [Plugin API] for a list of filter hooks.
+ *
+ * @param string $tag The name of the filter to hook the <tt>$function_to_add</tt> to.
+ * @param callback $function_to_add The name of the function to be called when the filter is applied.
+ * @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
+ * @param int $accepted_args optional. The number of arguments the function accept (default 1). In WordPress 1.5.1+, hooked functions can take extra arguments that are set when the matching do_action() or apply_filters() call is run.
+ * @return boolean true if the <tt>$function_to_add</tt> is added succesfully to filter <tt>$tag</tt>. How many arguments your function takes. In WordPress 1.5.1+, hooked functions can take extra arguments that are set when the matching <tt>do_action()</tt> or <tt>apply_filters()</tt> call is run. For example, the action <tt>comment_id_not_found</tt> will pass any functions that hook onto it the ID of the requested comment.
+ */
function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
- global $wp_filter;
+ global $wp_filter, $merged_filters;
// So the format is wp_filter['tag']['array of priorities']['array of functions serialized']['array of ['array (functions, accepted_args)]']
$wp_filter[$tag][$priority][serialize($function_to_add)] = array('function' => $function_to_add, 'accepted_args' => $accepted_args);
+ unset( $merged_filters[ $tag ] );
return true;
}
+/**
+ * Call the functions added to a filter hook.
+ *
+ * The callback functions attached to filter hook <tt>$tag</tt> are invoked by
+ * calling this function. This function can be used to create a new filter hook
+ * by simply calling this function with the name of the new hook specified using
+ * the <tt>$tag</a> parameter.
+ * @uses merge_filters Merges the filter hooks using this function.
+ * @param string $tag The name of the filter hook.
+ * @param string $string The text on which the filters hooked to <tt>$tag</tt> are applied on.
+ * @param mixed $var,... Additional variables passed to the functions hooked to <tt>$tag</tt>.
+ * @return string The text in <tt>$string</tt> after all hooked functions are applied to it.
+ */
function apply_filters($tag, $string) {
- global $wp_filter;
+ global $wp_filter, $merged_filters;
- merge_filters($tag);
+ if ( !isset( $merged_filters[ $tag ] ) )
+ merge_filters($tag);
if ( !isset($wp_filter[$tag]) )
return $string;
+ reset( $wp_filter[ $tag ] );
+
$args = func_get_args();
do{
@@ -34,37 +62,87 @@ function apply_filters($tag, $string) {
return $string;
}
+/**
+ * Merge the filter functions of a specific filter hook with generic filter functions.
+ *
+ * It is possible to defined generic filter functions using the filter hook
+ * <em>all</e>. These functions are called for every filter tag. This function
+ * merges the functions attached to the <em>all</em> hook with the functions
+ * of a specific hoook defined by <tt>$tag</tt>.
+ * @param string $tag The filter hook of which the functions should be merged.
+ */
function merge_filters($tag) {
- global $wp_filter;
+ global $wp_filter, $merged_filters;
- if ( isset($wp_filter['all']) )
+ if ( isset($wp_filter['all']) && is_array($wp_filter['all']) )
$wp_filter[$tag] = array_merge($wp_filter['all'], (array) $wp_filter[$tag]);
if ( isset($wp_filter[$tag]) ){
reset($wp_filter[$tag]);
uksort($wp_filter[$tag], "strnatcasecmp");
}
+ $merged_filters[ $tag ] = true;
}
+/**
+ * Removes a function from a specified filter hook.
+ *
+ * This function removes a function attached to a specified filter hook. This
+ * method can be used to remove default functions attached to a specific filter
+ * hook and possibly replace them with a substitute.
+ * @param string $tag The filter hook to which the function to be removed is hooked.
+ * @param callback $function_to_remove The name of the function which should be removed.
+ * @param int $priority optional. The priority of the function (default: 10).
+ * @param int $accepted_args optional. The number of arguments the function accpets (default: 1).
+ * @return boolean Whether the function is removed.
+ */
function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
- global $wp_filter;
+ $function_to_remove = serialize($function_to_remove);
- unset($GLOBALS['wp_filter'][$tag][$priority][serialize($function_to_remove)]);
+ $r = isset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]);
- return true;
-}
+ unset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]);
+ unset($GLOBALS['merged_filters'][$tag]);
-//
-// Action functions
-//
+ return $r;
+}
+/**
+ * Hooks a function on to a specific action.
+ *
+ * Actions are the hooks that the WordPress core launches at specific points
+ * during execution, or when specific events occur. Plugins can specify that
+ * one or more of its PHP functions are executed at these points, using the
+ * Action API.
+ *
+ * @param string $tag The name of the action to which the <tt>$function_to-add</tt> is hooked.
+ * @param callback $function_to_add The name of the function you wish to be called. Note: any of the syntaxes explained in the PHP documentation for the 'callback' type (http://us2.php.net/manual/en/language.pseudo-types.php#language.types.callback) are valid.
+ * @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
+ * @param int $accepted_args optional. The number of arguments the function accept (default 1). In WordPress 1.5.1+, hooked functions can take extra arguments that are set when the matching do_action() or apply_filters() call is run.
+ * @return boolean Always true.
+ */
function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
add_filter($tag, $function_to_add, $priority, $accepted_args);
}
+/**
+ * Execute functions hooked on a specific action hook.
+ *
+ * This function invokes all functions attached to action hook <tt>$tag</tt>.
+ * It is possible to create new action hooks by simply calling this function,
+ * specifying the name of the new hook using the <tt>$tag</tt> parameter.
+ * @uses merge_filters
+ * @param string $tag The name of the action to be executed.
+ * @param mixed $arg,... Optional additional arguments which are passed on to the functions hooked to the action.
+ */
function do_action($tag, $arg = '') {
global $wp_filter, $wp_actions;
+ if ( is_array($wp_actions) )
+ $wp_actions[] = $tag;
+ else
+ $wp_actions = array($tag);
+
$args = array();
if ( is_array($arg) && 1 == count($arg) && is_object($arg[0]) ) // array(&$this)
$args[] =& $arg[0];
@@ -85,19 +163,30 @@ function do_action($tag, $arg = '') {
} while ( next($wp_filter[$tag]) );
- if ( is_array($wp_actions) )
- $wp_actions[] = $tag;
- else
- $wp_actions = array($tag);
}
-// Returns the number of times an action has been done
+/**
+ * Return the number times an action is fired.
+ * @param string $tag The name of the action hook.
+ * @return int The number of times action hook <tt>$tag</tt> is fired
+ */
function did_action($tag) {
global $wp_actions;
+ if ( empty($wp_actions) )
+ return 0;
+
return count(array_keys($wp_actions, $tag));
}
+/**
+ * Execute functions hooked on a specific action hook, specifying arguments in a array.
+ *
+ * This function is identical to {@link do_action}, but the argumetns passe to
+ * the functions hooked to <tt>$tag</tt> are supplied using an array.
+ * @param string $tag The name of the action to be executed.
+ * @param array $args The arguments supplied to the functions hooked to <tt>$tag</tt>
+ */
function do_action_ref_array($tag, $args) {
global $wp_filter, $wp_actions;
@@ -120,25 +209,72 @@ function do_action_ref_array($tag, $args) {
}
+/**
+ * Removes a function from a specified action hook.
+ *
+ * This function removes a function attached to a specified action hook. This
+ * method can be used to remove default functions attached to a specific filter
+ * hook and possibly replace them with a substitute.
+ * @param string $tag The action hook to which the function to be removed is hooked.
+ * @param callback $function_to_remove The name of the function which should be removed.
+ * @param int $priority optional The priority of the function (default: 10).
+ * @param int $accepted_args optional. The number of arguments the function accpets (default: 1).
+ * @return boolean Whether the function is removed.
+ */
function remove_action($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
- remove_filter($tag, $function_to_remove, $priority, $accepted_args);
+ return remove_filter($tag, $function_to_remove, $priority, $accepted_args);
}
//
// Functions for handling plugins.
//
+/**
+ * Gets the basename of a plugin.
+ *
+ * This method extract the name of a plugin from its filename.
+ * @param string $file The filename of plugin.
+ * @return string The name of a plugin.
+ */
function plugin_basename($file) {
$file = preg_replace('|\\\\+|', '\\\\', $file);
$file = preg_replace('/^.*wp-content[\\\\\/]plugins[\\\\\/]/', '', $file);
return $file;
}
+/**
+ * Hook a function on a plugin activation action hook.
+ *
+ * When a plugin is activated, the action 'activate_PLUGINNAME' hook is
+ * activated. In the name of this hook, PLUGINNAME is replaced with the name of
+ * the plugin, including the optional subdirectory. For example, when the plugin
+ * is located in <tt>wp-content/plugin/sampleplugin/sample.php</tt>, then the
+ * name of this hook will become 'activate_sampleplugin/sample.php'.
+ * When the plugin consists of only one file and is (as by default) located at
+ * <tt>wp-content/plugin/sample.php</tt> the name of this hook will be
+ * 'activate_sample.php'.
+ * @param string $file The filename of the plugin including the path.
+ * @param string $function the function hooked to the 'activate_PLUGIN' action.
+ */
function register_activation_hook($file, $function) {
$file = plugin_basename($file);
add_action('activate_' . $file, $function);
}
+/**
+ * Hook a function on a plugin deactivation action hook.
+ *
+ * When a plugin is deactivated, the action 'deactivate_PLUGINNAME' hook is
+ * deactivated. In the name of this hook, PLUGINNAME is replaced with the name of
+ * the plugin, including the optional subdirectory. For example, when the plugin
+ * is located in <tt>wp-content/plugin/sampleplugin/sample.php</tt>, then the
+ * name of this hook will become 'activate_sampleplugin/sample.php'.
+ * When the plugin consists of only one file and is (as by default) located at
+ * <tt>wp-content/plugin/sample.php</tt> the name of this hook will be
+ * 'activate_sample.php'.
+ * @param string $file The filename of the plugin including the path.
+ * @param string $function the function hooked to the 'activate_PLUGIN' action.
+ */
function register_deactivation_hook($file, $function) {
$file = plugin_basename($file);
add_action('deactivate_' . $file, $function);
diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php
index 94d2876..cee198b 100644
--- a/wp-includes/post-template.php
+++ b/wp-includes/post-template.php
@@ -80,7 +80,7 @@ function get_the_content($more_link_text = '(more...)', $stripteaser = 0, $more_
$page = count($pages); // give them the highest numbered page that DOES exist
$content = $pages[$page-1];
- if ( preg_match('/<!--more(.+?)?-->/', $content, $matches) ) {
+ if ( preg_match('/<!--more(.*?)?-->/', $content, $matches) ) {
$content = explode($matches[0], $content, 2);
if ( !empty($matches[1]) && !empty($more_link_text) )
$more_link_text = strip_tags(wp_kses_no_null(trim($matches[1])));
@@ -129,19 +129,23 @@ function get_the_excerpt($fakeit = true) {
return apply_filters('get_the_excerpt', $output);
}
+function has_excerpt( $id = 0 ) {
+ $post = &get_post( $id );
+ return ( !empty( $post->post_excerpt ) );
+}
function wp_link_pages($args = '') {
- if ( is_array($args) )
- $r = &$args;
- else
- parse_str($args, $r);
-
- $defaults = array('before' => '<p>' . __('Pages:'), 'after' => '</p>', 'next_or_number' => 'number', 'nextpagelink' => __('Next page'),
- 'previouspagelink' => __('Previous page'), 'pagelink' => '%', 'more_file' => '', 'echo' => 1);
- $r = array_merge($defaults, $r);
- extract($r);
-
- global $id, $page, $numpages, $multipage, $more, $pagenow;
+ $defaults = array(
+ 'before' => '<p>' . __('Pages:'), 'after' => '</p>',
+ 'next_or_number' => 'number', 'nextpagelink' => __('Next page'),
+ 'previouspagelink' => __('Previous page'), 'pagelink' => '%',
+ 'more_file' => '', 'echo' => 1
+ );
+
+ $r = wp_parse_args( $args, $defaults );
+ extract( $r );
+
+ global $post, $id, $page, $numpages, $multipage, $more, $pagenow;
if ( $more_file != '' )
$file = $more_file;
else
@@ -158,7 +162,7 @@ function wp_link_pages($args = '') {
if ( 1 == $i ) {
$output .= '<a href="' . get_permalink() . '">';
} else {
- if ( '' == get_option('permalink_structure') )
+ if ( '' == get_option('permalink_structure') || 'draft' == $post->post_status )
$output .= '<a href="' . get_permalink() . '&amp;page=' . $i . '">';
else
$output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">';
@@ -177,7 +181,7 @@ function wp_link_pages($args = '') {
if ( 1 == $i ) {
$output .= '<a href="' . get_permalink() . '">' . $previouspagelink . '</a>';
} else {
- if ( '' == get_option('permalink_structure') )
+ if ( '' == get_option('permalink_structure') || 'draft' == $post->post_status )
$output .= '<a href="' . get_permalink() . '&amp;page=' . $i . '">' . $previouspagelink . '</a>';
else
$output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">' . $previouspagelink . '</a>';
@@ -188,7 +192,7 @@ function wp_link_pages($args = '') {
if ( 1 == $i ) {
$output .= '<a href="' . get_permalink() . '">' . $nextpagelink . '</a>';
} else {
- if ( '' == get_option('permalink_structure') )
+ if ( '' == get_option('permalink_structure') || 'draft' == $post->post_status )
$output .= '<a href="' . get_permalink() . '&amp;page=' . $i . '">' . $nextpagelink . '</a>';
else
$output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">' . $nextpagelink . '</a>';
@@ -233,7 +237,7 @@ function the_meta() {
continue;
$values = array_map('trim', get_post_custom_values($key));
$value = implode($values,', ');
- echo "<li><span class='post-meta-key'>$key:</span> $value</li>\n";
+ echo apply_filters('the_meta_key', "<li><span class='post-meta-key'>$key:</span> $value</li>\n", $key, $value);
}
echo "</ul>\n";
}
@@ -245,15 +249,14 @@ function the_meta() {
//
function wp_dropdown_pages($args = '') {
- if ( is_array($args) )
- $r = &$args;
- else
- parse_str($args, $r);
-
- $defaults = array('depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1,
- 'name' => 'page_id', 'show_option_none' => '');
- $r = array_merge($defaults, $r);
- extract($r);
+ $defaults = array(
+ 'depth' => 0, 'child_of' => 0,
+ 'selected' => 0, 'echo' => 1,
+ 'name' => 'page_id', 'show_option_none' => ''
+ );
+
+ $r = wp_parse_args( $args, $defaults );
+ extract( $r );
$pages = get_pages($r);
$output = '';
@@ -275,14 +278,16 @@ function wp_dropdown_pages($args = '') {
}
function wp_list_pages($args = '') {
- if ( is_array($args) )
- $r = &$args;
- else
- parse_str($args, $r);
-
- $defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'),
- 'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title');
- $r = array_merge($defaults, $r);
+ $defaults = array(
+ 'depth' => 0, 'show_date' => '',
+ 'date_format' => get_option('date_format'),
+ 'child_of' => 0, 'exclude' => '',
+ 'title_li' => __('Pages'), 'echo' => 1,
+ 'authors' => '', 'sort_column' => 'menu_order, post_title'
+ );
+
+ $r = wp_parse_args( $args, $defaults );
+ extract( $r );
$output = '';
$current_page = 0;
@@ -345,7 +350,7 @@ function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false)
$id = (int) $id;
$_post = & get_post($id);
- if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url() )
+ if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) )
return __('Missing Attachment');
$post_title = attribute_escape($_post->post_title);
diff --git a/wp-includes/post.php b/wp-includes/post.php
index 0c0dfb6..9c6929a 100644
--- a/wp-includes/post.php
+++ b/wp-includes/post.php
@@ -27,23 +27,25 @@ function update_attached_file( $attachment_id, $file ) {
function &get_children($args = '', $output = OBJECT) {
global $post_cache, $wpdb, $blog_id;
-
- if ( empty($args) ) {
- if ( isset($GLOBALS['post']) )
- $r = array('post_parent' => & $GLOBALS['post']->post_parent);
- else
+
+ if ( empty( $args ) ) {
+ if ( isset( $GLOBALS['post'] ) ) {
+ $args = 'post_parent=' . (int) $GLOBALS['post']->post_parent;
+ } else {
return false;
- } elseif ( is_object($args) )
- $r = array('post_parent' => $post->post_parent);
- elseif ( is_numeric($args) )
- $r = array('post_parent' => $args);
- elseif ( is_array($args) )
- $r = &$args;
- else
- parse_str($args, $r);
-
- $defaults = array('numberposts' => -1, 'post_type' => '', 'post_status' => '', 'post_parent' => 0);
- $r = array_merge($defaults, $r);
+ }
+ } elseif ( is_object( $args ) ) {
+ $args = 'post_parent=' . (int) $args->post_parent;
+ } elseif ( is_numeric( $args ) ) {
+ $args = 'post_parent=' . (int) $args;
+ }
+
+ $defaults = array(
+ 'numberposts' => -1, 'post_type' => '',
+ 'post_status' => '', 'post_parent' => 0
+ );
+
+ $r = wp_parse_args( $args, $defaults );
$children = get_posts( $r );
@@ -74,7 +76,7 @@ function &get_children($args = '', $output = OBJECT) {
// get extended entry info (<!--more-->)
function get_extended($post) {
//Match the new style more links
- if ( preg_match('/<!--more(.*?)-->/', $post, $matches) ) {
+ if ( preg_match('/<!--more(.*?)?-->/', $post, $matches) ) {
list($main, $extended) = explode($matches[0], $post, 2);
} else {
$main = $post;
@@ -172,17 +174,19 @@ function get_post_type($post = false) {
function get_posts($args) {
global $wpdb;
-
- if ( is_array($args) )
- $r = &$args;
- else
- parse_str($args, $r);
-
- $defaults = array('numberposts' => 5, 'offset' => 0, 'category' => 0,
- 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '',
- 'meta_key' => '', 'meta_value' =>'', 'post_type' => 'post', 'post_status' => 'publish', 'post_parent' => 0);
- $r = array_merge($defaults, $r);
- extract($r);
+
+ $defaults = array(
+ 'numberposts' => 5, 'offset' => 0,
+ 'category' => 0, 'orderby' => 'post_date',
+ 'order' => 'DESC', 'include' => '',
+ 'exclude' => '', 'meta_key' => '',
+ 'meta_value' =>'', 'post_type' => 'post',
+ 'post_status' => 'publish', 'post_parent' => 0
+ );
+
+ $r = wp_parse_args( $args, $defaults );
+ extract( $r );
+
$numberposts = (int) $numberposts;
$offset = (int) $offset;
$category = (int) $category;
@@ -225,14 +229,6 @@ function get_posts($args) {
if (!empty($exclusions))
$exclusions .= ')';
- $query ="SELECT DISTINCT * FROM $wpdb->posts " ;
- $query .= ( empty( $category ) ? "" : ", $wpdb->post2cat " );
- $query .= ( empty( $meta_key ) ? "" : ", $wpdb->postmeta " );
- $query .= " WHERE (post_type = 'post' AND post_status = 'publish') $exclusions $inclusions ";
- $query .= ( empty( $category ) ? "" : "AND ($wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $category. ") " );
- $query .= ( empty( $meta_key ) | empty($meta_value) ? "" : " AND ($wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '$meta_key' AND $wpdb->postmeta.meta_value = '$meta_value' )" );
- $query .= " GROUP BY $wpdb->posts.ID ORDER BY " . $orderby . " " . $order . " LIMIT " . $offset . ',' . $numberposts;
-
$query = "SELECT DISTINCT * FROM $wpdb->posts ";
$query .= empty( $category ) ? '' : ", $wpdb->post2cat ";
$query .= empty( $meta_key ) ? '' : ", $wpdb->postmeta ";
@@ -443,8 +439,8 @@ function wp_delete_post($postid = 0) {
$wp_rewrite->flush_rules();
}
- do_action('post_deleted', $postid);
-
+ do_action('deleted_post', $postid);
+
return $post;
}
@@ -653,7 +649,7 @@ function wp_insert_post($postarr = array()) {
$wpdb->query( "UPDATE $wpdb->posts SET post_name = '$post_name' WHERE ID = '$post_ID'" );
}
- wp_set_post_categories($post_ID, $post_category);
+ wp_set_post_categories( $post_ID, $post_category );
if ( 'page' == $post_type ) {
clean_page_cache($post_ID);
@@ -1066,16 +1062,17 @@ function get_page_uri($page_id) {
function &get_pages($args = '') {
global $wpdb;
-
- if ( is_array($args) )
- $r = &$args;
- else
- parse_str($args, $r);
-
- $defaults = array('child_of' => 0, 'sort_order' => 'ASC', 'sort_column' => 'post_title',
- 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'meta_key' => '', 'meta_value' => '', 'authors' => '');
- $r = array_merge($defaults, $r);
- extract($r);
+
+ $defaults = array(
+ 'child_of' => 0, 'sort_order' => 'ASC',
+ 'sort_column' => 'post_title', 'hierarchical' => 1,
+ 'exclude' => '', 'include' => '',
+ 'meta_key' => '', 'meta_value' => '',
+ 'authors' => ''
+ );
+
+ $r = wp_parse_args( $args, $defaults );
+ extract( $r );
$key = md5( serialize( $r ) );
if ( $cache = wp_cache_get( 'get_pages', 'page' ) )
@@ -1568,4 +1565,50 @@ function wp_check_for_changed_slugs($post_id) {
return $post_id;
}
+/**
+ * This function provides a standardized way to appropriately select on
+ * the post_status of posts/pages. The function will return a piece of
+ * SQL code that can be added to a WHERE clause; this SQL is constructed
+ * to allow all published posts, and all private posts to which the user
+ * has access.
+ *
+ * @param string $post_type currently only supports 'post' or 'page'.
+ * @return string SQL code that can be added to a where clause.
+ */
+function get_private_posts_cap_sql($post_type) {
+ global $user_ID;
+ $cap = '';
+
+ // Private posts
+ if ($post_type == 'post') {
+ $cap = 'read_private_posts';
+ // Private pages
+ } elseif ($post_type == 'page') {
+ $cap = 'read_private_pages';
+ // Dunno what it is, maybe plugins have their own post type?
+ } else {
+ $cap = apply_filters('pub_priv_sql_capability', $cap);
+
+ if (empty($cap)) {
+ // We don't know what it is, filters don't change anything,
+ // so set the SQL up to return nothing.
+ return '1 = 0';
+ }
+ }
+
+ $sql = '(post_status = \'publish\'';
+
+ if (current_user_can($cap)) {
+ // Does the user have the capability to view private posts? Guess so.
+ $sql .= ' OR post_status = \'private\'';
+ } elseif (is_user_logged_in()) {
+ // Users can view their own private posts.
+ $sql .= ' OR post_status = \'private\' AND post_author = \'' . $user_ID . '\'';
+ }
+
+ $sql .= ')';
+
+ return $sql;
+}
+
?>
diff --git a/wp-includes/query.php b/wp-includes/query.php
index 26e1afc..05dc692 100644
--- a/wp-includes/query.php
+++ b/wp-includes/query.php
@@ -888,6 +888,8 @@ class WP_Query {
$groupby = "{$wpdb->posts}.ID";
}
+
+
// Author/user stuff
if ( empty($q['author']) || ($q['author'] == '0') ) {
@@ -1023,7 +1025,7 @@ class WP_Query {
$cwhere = apply_filters('comment_feed_where', $cwhere);
$cgroupby = apply_filters('comment_feed_groupby', $cgroupby);
- $this->comments = (array) $wpdb->get_results("SELECT $distinct $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby ORDER BY comment_date_gmt DESC LIMIT " . get_settings('posts_per_rss'));
+ $this->comments = (array) $wpdb->get_results("SELECT $distinct $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss'));
$this->comment_count = count($this->comments);
$post_ids = array();
@@ -1062,7 +1064,7 @@ class WP_Query {
if ( $this->is_comment_feed && $this->is_singular ) {
$cjoin = apply_filters('comment_feed_join', '');
$cwhere = apply_filters('comment_feed_where', "WHERE comment_post_ID = {$this->posts[0]->ID} AND comment_approved = '1'");
- $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere ORDER BY comment_date_gmt DESC LIMIT " . get_settings('posts_per_rss');
+ $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss');
$this->comments = $wpdb->get_results($comments_request);
$this->comment_count = count($this->comments);
}
diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php
index d22d3fc..eb10bf7 100644
--- a/wp-includes/rewrite.php
+++ b/wp-includes/rewrite.php
@@ -46,11 +46,11 @@ define('EP_ROOT', 64 );
define('EP_COMMENTS', 128 );
define('EP_SEARCH', 256 );
define('EP_CATEGORIES', 512 );
-define('EP_AUTHORS', 1024);
-define('EP_PAGES', 2048);
+define('EP_AUTHORS', 2048);
+define('EP_PAGES', 4096);
//pseudo-places
define('EP_NONE', 0 );
-define('EP_ALL', 255);
+define('EP_ALL', 8191);
//and an endpoint, like /trackback/
function add_rewrite_endpoint($name, $places) {
@@ -62,6 +62,8 @@ function add_rewrite_endpoint($name, $places) {
// determine the post ID it represents.
function url_to_postid($url) {
global $wp_rewrite;
+
+ $url = apply_filters('url_to_postid', $url);
// First, check to see if there is a 'p=N' or 'page_id=N' to match against
preg_match('#[?&](p|page_id)=(\d+)#', $url, $values);
@@ -197,6 +199,7 @@ class WP_Rewrite {
'([^/]+)',
'([0-9]+)',
'(.+?)',
+ '(.+?)',
'([^/]+)',
'([^/]+)',
'(.+)'
@@ -582,6 +585,16 @@ class WP_Rewrite {
if ($paged) //...and /page/xx ones
$rewrite = array_merge($rewrite, array($pagematch => $pagequery));
+ //do endpoints
+ if ($endpoints) {
+ foreach ($ep_query_append as $regex => $ep) {
+ //add the endpoints on if the mask fits
+ if ($ep[0] & $ep_mask || $ep[0] & $ep_mask_specific) {
+ $rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2);
+ }
+ }
+ }
+
//if we've got some tags in this dir
if ($num_toks) {
$post = false;
@@ -599,16 +612,6 @@ class WP_Rewrite {
$page = true;
}
- //do endpoints
- if ($endpoints) {
- foreach ($ep_query_append as $regex => $ep) {
- //add the endpoints on if the mask fits
- if ($ep[0] & $ep_mask || $ep[0] & $ep_mask_specific) {
- $rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2);
- }
- }
- }
-
//if we're creating rules for a permalink, do all the endpoints like attachments etc
if ($post) {
$post = true;
@@ -869,7 +872,7 @@ class WP_Rewrite {
if ($this->using_index_permalinks()) {
$this->root = $this->index . '/';
}
- $this->category_base = get_option('category_base');
+ $this->category_base = get_option( 'category_base' );
unset($this->category_structure);
unset($this->author_structure);
unset($this->date_structure);
diff --git a/wp-includes/rss.php b/wp-includes/rss.php
index 44005a7..da7bc1b 100644
--- a/wp-includes/rss.php
+++ b/wp-includes/rss.php
@@ -815,7 +815,8 @@ function parse_w3cdtf ( $date_str ) {
else {
return -1;
}
- }
+}
+
function wp_rss ($url, $num_items) {
//ini_set("display_errors", false); uncomment to suppress php errors thrown if the feed is not returned.
$rss = fetch_rss($url);
@@ -832,7 +833,7 @@ function wp_rss ($url, $num_items) {
echo "</ul>";
}
else {
- echo "an error has occured the feed is probably down, try again later.";
+ echo 'An error has occurred the feed is probably down, try again later.';
}
}
diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php
index c4a318a..bc180cf 100644
--- a/wp-includes/script-loader.php
+++ b/wp-includes/script-loader.php
@@ -11,14 +11,32 @@ class WP_Scripts {
function default_scripts() {
$this->add( 'dbx', '/wp-includes/js/dbx.js', false, '2.05' );
+
$this->add( 'fat', '/wp-includes/js/fat.js', false, '1.0-RC1_3660' );
+
$this->add( 'sack', '/wp-includes/js/tw-sack.js', false, '1.6.1' );
- $this->add( 'quicktags', '/wp-includes/js/quicktags.js', false, '3517' );
+
+ $this->add( 'quicktags', '/wp-includes/js/quicktags.js', false, '3958' );
+ $this->localize( 'quicktags', 'quicktagsL10n', array(
+ 'quickLinks' => __('(Quick Links)'),
+ 'wordLookup' => __('Enter a word to look up:'),
+ 'dictionaryLookup' => attribute_escape(__('Dictionary lookup')),
+ 'lookup' => attribute_escape(__('lookup')),
+ 'closeAllOpenTags' => attribute_escape(__('Close all open tags')),
+ 'closeTags' => attribute_escape(__('close tags')),
+ 'enterURL' => __('Enter the URL'),
+ 'enterImageURL' => __('Enter the URL of the image'),
+ 'enterImageDescription' => __('Enter a description of the image')
+ ) );
+
$this->add( 'colorpicker', '/wp-includes/js/colorpicker.js', false, '3517' );
+
$this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '20070326' );
$mce_config = apply_filters('tiny_mce_config_url', '/wp-includes/js/tinymce/tiny_mce_config.php');
$this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20070225' );
- $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.5.0-0');
+
+ $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.5.1');
+
$this->add( 'autosave', '/wp-includes/js/autosave.js', array('prototype', 'sack'), '20070306');
$this->localize( 'autosave', 'autosaveL10n', array(
'autosaveInterval' => apply_filters('autosave_interval', '120'),
@@ -27,6 +45,7 @@ class WP_Scripts {
'requestFile' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php',
'savingText' => __('Saving Draft...')
) );
+
$this->add( 'wp-ajax', '/wp-includes/js/wp-ajax.js', array('prototype'), '20070306');
$this->localize( 'wp-ajax', 'WPAjaxL10n', array(
'defaultUrl' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php',
@@ -34,21 +53,27 @@ class WP_Scripts {
'strangeText' => __("Something strange happened. Try refreshing the page."),
'whoaText' => __("Slow down, I'm still sending your data!")
) );
- $this->add( 'listman', '/wp-includes/js/list-manipulation.js', array('wp-ajax', 'fat'), '20070306');
+
+ $this->add( 'listman', '/wp-includes/js/list-manipulation.js', array('wp-ajax', 'fat'), '20070306' );
$this->localize( 'listman', 'listManL10n', array(
'jumpText' => __('Jump to new item'),
'delText' => __('Are you sure you want to delete this %thing%?')
) );
- $this->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/wp-scriptaculous.js', array('prototype'), '1.7.0');
- $this->add( 'scriptaculous-builder', '/wp-includes/js/scriptaculous/builder.js', array('scriptaculous-root'), '1.7.0');
- $this->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.7.0');
- $this->add( 'scriptaculous-effects', '/wp-includes/js/scriptaculous/effects.js', array('scriptaculous-root'), '1.7.0');
- $this->add( 'scriptaculous-slider', '/wp-includes/js/scriptaculous/slider.js', array('scriptaculous-effects'), '1.7.0');
- $this->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/controls.js', array('scriptaculous-root'), '1.7.0');
- $this->add( 'scriptaculous', '', array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls'), '1.7.0');
+
+ $this->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/wp-scriptaculous.js', array('prototype'), '1.7.1-b2');
+ $this->add( 'scriptaculous-builder', '/wp-includes/js/scriptaculous/builder.js', array('scriptaculous-root'), '1.7.1-b2');
+ $this->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.7.1-b2');
+ $this->add( 'scriptaculous-effects', '/wp-includes/js/scriptaculous/effects.js', array('scriptaculous-root'), '1.7.1-b2');
+ $this->add( 'scriptaculous-slider', '/wp-includes/js/scriptaculous/slider.js', array('scriptaculous-effects'), '1.7.1-b2');
+ $this->add( 'scriptaculous-sound', '/wp-includes/js/scriptaculous/sound.js', array( 'scriptaculous-root' ), '1.7.1-b2' );
+ $this->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/controls.js', array('scriptaculous-root'), '1.7.1-b2');
+ $this->add( 'scriptaculous', '', array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls'), '1.7.1-b2');
+
$this->add( 'cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop'), '20070118');
- $this->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.1.1');
- $this->add( 'interface', '/wp-includes/js/jquery/interface.js', array('jquery'), '1.1.1');
+
+ $this->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.1.2');
+ $this->add( 'interface', '/wp-includes/js/jquery/interface.js', array('jquery'), '1.2');
+
if ( is_admin() ) {
global $pagenow;
$man = false;
@@ -67,7 +92,7 @@ class WP_Scripts {
break;
endswitch;
if ( $man ) {
- $this->add( 'dbx-admin-key', '/wp-admin/dbx-admin-key.js', array('dbx'), '20070306' );
+ $this->add( 'dbx-admin-key', '/wp-admin/dbx-admin-key.js', array('dbx'), '20070417' );
$this->localize( 'dbx-admin-key', 'dbxL10n', array(
'manager' => $man,
'open' => __('open'),
@@ -78,14 +103,14 @@ class WP_Scripts {
'toggleKey' => __(', or press the enter key to %toggle% it'),
) );
}
- $this->add( 'ajaxcat', '/wp-admin/cat.js', array('listman'), '20070306' );
+ $this->add( 'ajaxcat', '/wp-admin/cat.js', array('listman'), '20070417' );
$this->localize( 'ajaxcat', 'catL10n', array(
'add' => attribute_escape(__('Add')),
'how' => __('Separate multiple categories with commas.')
) );
$this->add( 'admin-categories', '/wp-admin/categories.js', array('listman'), '3684' );
$this->add( 'admin-custom-fields', '/wp-admin/custom-fields.js', array('listman'), '3733' );
- $this->add( 'admin-comments', '/wp-admin/edit-comments.js', array('listman'), '3847' );
+ $this->add( 'admin-comments', '/wp-admin/edit-comments.js', array('listman'), '20070327' );
$this->add( 'admin-users', '/wp-admin/users.js', array('listman'), '4583' );
$this->add( 'xfn', '/wp-admin/xfn.js', false, '3517' );
$this->add( 'upload', '/wp-admin/upload.js', array('prototype'), '20070306' );
@@ -150,6 +175,12 @@ class WP_Scripts {
if ( isset($this->args[$handle]) )
$ver .= '&amp;' . $this->args[$handle];
$src = 0 === strpos($this->scripts[$handle]->src, 'http://') ? $this->scripts[$handle]->src : get_option( 'siteurl' ) . $this->scripts[$handle]->src;
+ $src = $this->scripts[$handle]->src;
+
+ if (!preg_match('|^https?://|', $src)) {
+ $src = get_option('siteurl') . $src;
+ }
+
$src = add_query_arg('ver', $ver, $src);
$src = clean_url(apply_filters( 'script_loader_src', $src ));
echo "<script type='text/javascript' src='$src'></script>\n";
diff --git a/wp-includes/theme.php b/wp-includes/theme.php
index 2a7ac8c..c251935 100644
--- a/wp-includes/theme.php
+++ b/wp-includes/theme.php
@@ -56,6 +56,21 @@ function get_template_directory_uri() {
}
function get_theme_data( $theme_file ) {
+ $themes_allowed_tags = array(
+ 'a' => array(
+ 'href' => array(),'title' => array()
+ ),
+ 'abbr' => array(
+ 'title' => array()
+ ),
+ 'acronym' => array(
+ 'title' => array()
+ ),
+ 'code' => array(),
+ 'em' => array(),
+ 'strong' => array()
+ );
+
$theme_data = implode( '', file( $theme_file ) );
$theme_data = str_replace ( '\r', '\n', $theme_data );
preg_match( '|Theme Name:(.*)|i', $theme_data, $theme_name );
@@ -64,26 +79,28 @@ function get_theme_data( $theme_file ) {
preg_match( '|Author:(.*)|i', $theme_data, $author_name );
preg_match( '|Author URI:(.*)|i', $theme_data, $author_uri );
preg_match( '|Template:(.*)|i', $theme_data, $template );
+
if ( preg_match( '|Version:(.*)|i', $theme_data, $version ) )
- $version = trim( $version[1] );
+ $version = wp_kses( trim( $version[1] ), $themes_allowed_tags );
else
- $version ='';
+ $version = '';
+
if ( preg_match('|Status:(.*)|i', $theme_data, $status) )
- $status = trim($status[1]);
+ $status = wp_kses( trim( $status[1] ), $themes_allowed_tags );
else
$status = 'publish';
-
- $description = wptexturize( trim( $description[1] ) );
-
- $name = $theme_name[1];
- $name = trim( $name );
- $theme = $name;
- $theme_uri = trim( $theme_uri[1] );
-
- if ( '' == $author_uri[1] ) {
- $author = trim( $author_name[1] );
+
+ $name = $theme = wp_kses( trim( $theme_name[1] ), $themes_allowed_tags );
+ $theme_uri = clean_url( trim( $theme_uri[1] ) );
+ $description = wptexturize( wp_kses( trim( $description[1] ), $themes_allowed_tags ) );
+ $template = wp_kses( trim( $template[1] ), $themes_allowed_tags );
+
+ $author_uri = clean_url( trim( $author_uri[1] ) );
+
+ if ( empty( $author_uri[1] ) ) {
+ $author = wp_kses( trim( $author_name[1] ), $themes_allowed_tags );
} else {
- $author = '<a href="' . trim( $author_uri[1] ) . '" title="' . __('Visit author homepage') . '">' . trim( $author_name[1] ) . '</a>';
+ $author = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', $author_uri, __( 'Visit author homepage' ), wp_kses( trim( $author_name[1] ), $themes_allowed_tags ) );
}
return array( 'Name' => $name, 'Title' => $theme, 'URI' => $theme_uri, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1], 'Status' => $status );
@@ -163,6 +180,7 @@ function get_themes() {
$template = $theme_data['Template'];
$stylesheet = dirname($theme_file);
+ $screenshot = false;
foreach ( array('png', 'gif', 'jpg', 'jpeg') as $ext ) {
if (file_exists("$theme_root/$stylesheet/screenshot.$ext")) {
$screenshot = "screenshot.$ext";
diff --git a/wp-includes/user.php b/wp-includes/user.php
index 14de35a..ca4006b 100644
--- a/wp-includes/user.php
+++ b/wp-includes/user.php
@@ -10,7 +10,7 @@ function get_profile($field, $user = false) {
function get_usernumposts($userid) {
global $wpdb;
$userid = (int) $userid;
- return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$userid' AND post_type = 'post' AND post_status = 'publish'");
+ return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$userid' AND post_type = 'post' AND " . get_private_posts_cap_sql('post'));
}
// TODO: xmlrpc only. Maybe move to xmlrpc.php.
diff --git a/wp-includes/vars.php b/wp-includes/vars.php
index 0f749be..010d174 100644
--- a/wp-includes/vars.php
+++ b/wp-includes/vars.php
@@ -35,4 +35,50 @@ $is_IE = ( $is_macIE || $is_winIE );
$is_apache = ((strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false) || (strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false)) ? true : false;
$is_IIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false) ? true : false;
+$wp_header_to_desc = apply_filters( 'wp_header_to_desc_array', array(
+ 100 => 'Continue',
+ 101 => 'Switching Protocols',
+
+ 200 => 'OK',
+ 201 => 'Created',
+ 202 => 'Accepted',
+ 203 => 'Non-Authoritative Information',
+ 204 => 'No Content',
+ 205 => 'Reset Content',
+ 206 => 'Partial Content',
+
+ 300 => 'Multiple Choices',
+ 301 => 'Moved Permanently',
+ 302 => 'Found',
+ 303 => 'See Other',
+ 304 => 'Not Modified',
+ 305 => 'Use Proxy',
+ 307 => 'Temporary Redirect',
+
+ 400 => 'Bad Request',
+ 401 => 'Unauthorized',
+ 403 => 'Forbidden',
+ 404 => 'Not Found',
+ 405 => 'Method Not Allowed',
+ 406 => 'Not Acceptable',
+ 407 => 'Proxy Authentication Required',
+ 408 => 'Request Timeout',
+ 409 => 'Conflict',
+ 410 => 'Gone',
+ 411 => 'Length Required',
+ 412 => 'Precondition Failed',
+ 413 => 'Request Entity Too Large',
+ 414 => 'Request-URI Too Long',
+ 415 => 'Unsupported Media Type',
+ 416 => 'Requested Range Not Satisfiable',
+ 417 => 'Expectation Failed',
+
+ 500 => 'Internal Server Error',
+ 501 => 'Not Implemented',
+ 502 => 'Bad Gateway',
+ 503 => 'Service Unavailable',
+ 504 => 'Gateway Timeout',
+ 505 => 'HTTP Version Not Supported'
+) );
+
?>
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 5355c5c..ca88592 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -3,6 +3,6 @@
// This holds the version number in a separate file so we can bump it without cluttering the SVN
$wp_version = 'wordpress-mu-1.2.1'; // Let's just avoid confusion
-$wp_db_version = 4860;
+$wp_db_version = 5200;
?>
diff --git a/wp-links-opml.php b/wp-links-opml.php
index 4b72322..111ac8d 100644
--- a/wp-links-opml.php
+++ b/wp-links-opml.php
@@ -17,7 +17,7 @@ if ((empty ($link_cat)) || ($link_cat == 'all') || ($link_cat == '0')) {
<!-- generator="wordpress/<?php bloginfo_rss('version') ?>" -->
<opml version="1.0">
<head>
- <title>Links for <?php echo get_bloginfo('name').$cat_name ?></title>
+ <title>Links for <?php echo attribute_escape(get_bloginfo('name').$cat_name); ?></title>
<dateCreated><?php echo gmdate("D, d M Y H:i:s"); ?> GMT</dateCreated>
</head>
<body>
diff --git a/wp-mail.php b/wp-mail.php
index ded37bd..8795c74 100644
--- a/wp-mail.php
+++ b/wp-mail.php
@@ -24,10 +24,10 @@ for ($i=1; $i <= $count; $i++) :
$content = '';
$content_type = '';
+ $content_transfer_encoding = '';
$boundary = '';
$bodysignal = 0;
- $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
+ $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
foreach ($message as $line) :
if (strlen($line) < 3) $bodysignal = 1;
@@ -40,6 +40,12 @@ for ($i=1; $i <= $count; $i++) :
$content_type = explode(';', $content_type);
$content_type = $content_type[0];
}
+ if (preg_match('/Content-Transfer-Encoding: /i', $line)) {
+ $content_transfer_encoding = trim($line);
+ $content_transfer_encoding = substr($content_transfer_encoding, 27, strlen($content_transfer_encoding)-14);
+ $content_transfer_encoding = explode(';', $content_transfer_encoding);
+ $content_transfer_encoding = $content_transfer_encoding[0];
+ }
if (($content_type == 'multipart/alternative') && (preg_match('/boundary="/', $line)) && ($boundary == '')) {
$boundary = trim($line);
$boundary = explode('"', $boundary);
@@ -56,7 +62,7 @@ for ($i=1; $i <= $count; $i++) :
// Set the author using the email address (To or Reply-To, the last used)
// otherwise use the site admin
- if (preg_match('/From: /', $line) | preg_match('Reply-To: /', $line)) {
+ if (preg_match('/From: /', $line) | preg_match('/Reply-To: /', $line)) {
$author=trim($line);
if ( ereg("([a-zA-Z0-9\_\-\.]+@[\a-zA-z0-9\_\-\.]+)", $author , $regs) ) {
$author = $regs[1];
@@ -111,11 +117,16 @@ for ($i=1; $i <= $count; $i++) :
$content = strip_tags($content[1], '<img><p><br><i><b><u><em><strong><strike><font><span><div>');
}
$content = trim($content);
+
+ if (stripos($content_transfer_encoding, "quoted-printable") !== false) {
+ $content = quoted_printable_decode($content);
+ }
+
// Captures any text in the body after $phone_delim as the body
$content = explode($phone_delim, $content);
$content[1] ? $content = $content[1] : $content = $content[0];
- echo "<p><b>Content-type:</b> $content_type, <b>boundary:</b> $boundary</p>\n";
+ echo "<p><b>Content-type:</b> $content_type, <b>Content-Transfer-Encoding:</b> $content_transfer_encoding, <b>boundary:</b> $boundary</p>\n";
echo "<p><b>Raw content:</b><br /><pre>".$content.'</pre></p>';
$content = trim($content);
diff --git a/wp-settings.php b/wp-settings.php
index 25833c6..9fa1350 100644
--- a/wp-settings.php
+++ b/wp-settings.php
@@ -77,7 +77,7 @@ function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(
$mtime = $mtime[1] + $mtime[0];
$timeend = $mtime;
$timetotal = $timeend-$timestart;
- $r = number_format($timetotal, $precision);
+ $r = number_format_i18n($timetotal, $precision);
if ( $display )
echo $r;
return $r;
@@ -89,7 +89,7 @@ error_reporting(E_ALL ^ E_NOTICE);
// For an advanced caching plugin to use, static because you would only want one
if ( defined('WP_CACHE') )
- require (ABSPATH . 'wp-content/advanced-cache.php');
+ @include ABSPATH . 'wp-content/advanced-cache.php';
define('WPINC', 'wp-includes');
@@ -148,9 +148,9 @@ if ( defined('CUSTOM_USER_META_TABLE') )
$tableposts = $tableusers = $tablecategories = $tablepost2cat = $tablecomments = $tablelink2cat = $tablelinks = $tablelinkcategories = $tableoptions = $tablepostmeta = '';
if ( file_exists(ABSPATH . 'wp-content/object-cache.php') )
- require (ABSPATH . 'wp-content/object-cache.php');
+ require_once (ABSPATH . 'wp-content/object-cache.php');
else
- require (ABSPATH . WPINC . '/cache.php');
+ require_once (ABSPATH . WPINC . '/cache.php');
// To disable persistant caching, add the below line to your wp-config.php file, uncommented of course.
// define('DISABLE_CACHE', true);
@@ -333,4 +333,4 @@ register_shutdown_function('shutdown_action_hook');
// Everything is loaded and initialized.
do_action('init');
-?>
+?> \ No newline at end of file
diff --git a/xmlrpc.php b/xmlrpc.php
index 41d5def..1283c7c 100644
--- a/xmlrpc.php
+++ b/xmlrpc.php
@@ -5,6 +5,12 @@ define('XMLRPC_REQUEST', true);
// Some browser-embedded clients send cookies. We don't want them.
$_COOKIE = array();
+// A bug in PHP < 5.2.2 makes $HTTP_RAW_POST_DATA not set by default,
+// but we can do it ourself.
+if ( !isset( $HTTP_RAW_POST_DATA ) ) {
+ $HTTP_RAW_POST_DATA = file_get_contents( 'php://input' );
+}
+
# fix for mozBlog and other cases where '<?xml' isn't on the very first line
if ( isset($HTTP_RAW_POST_DATA) )
$HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA);
@@ -202,7 +208,7 @@ class wp_xmlrpc_server extends IXR_Server {
$allow_pings = ("open" == $page->ping_status) ? 1 : 0;
// Format page date.
- $page_date = mysql2date("Ymd\TH:i:s", $page->post_date);
+ $page_date = mysql2date("Ymd\TH:i:s", $page->post_date_gmt);
// Pull the categories info together.
$categories = array();
@@ -423,7 +429,7 @@ class wp_xmlrpc_server extends IXR_Server {
SELECT ID page_id,
post_title page_title,
post_parent page_parent_id,
- post_date
+ post_date_gmt
FROM {$wpdb->posts}
WHERE post_type = 'page'
ORDER BY ID
@@ -432,10 +438,10 @@ class wp_xmlrpc_server extends IXR_Server {
// The date needs to be formated properly.
$num_pages = count($page_list);
for($i = 0; $i < $num_pages; $i++) {
- $post_date = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date);
+ $post_date = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date_gmt);
$page_list[$i]->dateCreated = new IXR_Date($post_date);
- unset($page_list[$i]->post_date);
+ unset($page_list[$i]->post_date_gmt);
}
return($page_list);
@@ -569,8 +575,9 @@ class wp_xmlrpc_server extends IXR_Server {
$user_login = $args[1];
$user_pass = $args[2];
- if (!$this->login_pass_ok($user_login, $user_pass))
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
return $this->error;
+ }
$user = set_current_user(0, $user_login);
@@ -949,12 +956,12 @@ class wp_xmlrpc_server extends IXR_Server {
// Let WordPress generate the post_name (slug) unless
// one has been provided.
$post_name = "";
- if(!empty($content_struct["wp_slug"])) {
+ if(isset($content_struct["wp_slug"])) {
$post_name = $content_struct["wp_slug"];
}
// Only use a password if one was given.
- if(!empty($content_struct["wp_password"])) {
+ if(isset($content_struct["wp_password"])) {
$post_password = $content_struct["wp_password"];
}
@@ -964,14 +971,17 @@ class wp_xmlrpc_server extends IXR_Server {
}
// Only set the menu_order if it was provided.
- if(!empty($content_struct["wp_page_order"])) {
+ if(isset($content_struct["wp_page_order"])) {
$menu_order = $content_struct["wp_page_order"];
}
$post_author = $user->ID;
// If an author id was provided then use it instead.
- if(!empty($content_struct["wp_author_id"])) {
+ if(
+ isset($content_struct["wp_author_id"])
+ && ($user->ID != $content_struct["wp_author_id"])
+ ) {
switch($post_type) {
case "post":
if(!current_user_can("edit_others_posts")) {
@@ -999,13 +1009,33 @@ class wp_xmlrpc_server extends IXR_Server {
$post_excerpt = $content_struct['mt_excerpt'];
$post_more = $content_struct['mt_text_more'];
- $comment_status = (!isset($content_struct['mt_allow_comments'])) ?
- get_option('default_comment_status')
- : $content_struct['mt_allow_comments'];
+ if(isset($content_struct["mt_allow_comments"])) {
+ switch((int) $content_struct["mt_allow_comments"]) {
+ case 0:
+ $comment_status = "closed";
+ break;
+ case 1:
+ $comment_status = "open";
+ break;
+ default:
+ $comment_status = get_option("default_comment_status");
+ break;
+ }
+ }
- $ping_status = (!isset($content_struct['mt_allow_pings'])) ?
- get_option('default_ping_status')
- : $content_struct['mt_allow_pings'];
+ if(isset($content_struct["mt_allow_pings"])) {
+ switch((int) $content_struct["mt_allow_pings"]) {
+ case 0:
+ $ping_status = "closed";
+ break;
+ case 1:
+ $ping_status = "open";
+ break;
+ default:
+ $ping_status = get_option("default_ping_status");
+ break;
+ }
+ }
if ($post_more) {
$post_content = $post_content . "\n<!--more-->\n" . $post_more;
@@ -1020,7 +1050,7 @@ class wp_xmlrpc_server extends IXR_Server {
if (!empty($dateCreatedd)) {
$dateCreated = $dateCreatedd->getIso();
$post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
- $post_date_gmt = iso8601_to_datetime($dateCreated, GMT);
+ $post_date_gmt = iso8601_to_datetime($dateCreated. "Z", GMT);
} else {
$post_date = current_time('mysql');
$post_date_gmt = current_time('mysql', 1);
@@ -1083,7 +1113,7 @@ class wp_xmlrpc_server extends IXR_Server {
return $this->error;
}
- set_current_user(0, $user_login);
+ $user = set_current_user(0, $user_login);
// The post_type defaults to post, but could also be page.
$post_type = "post";
@@ -1112,12 +1142,12 @@ class wp_xmlrpc_server extends IXR_Server {
// Let WordPress manage slug if none was provided.
$post_name = "";
- if(!empty($content_struct["wp_slug"])) {
+ if(isset($content_struct["wp_slug"])) {
$post_name = $content_struct["wp_slug"];
}
// Only use a password if one was given.
- if(!empty($content_struct["wp_password"])) {
+ if(isset($content_struct["wp_password"])) {
$post_password = $content_struct["wp_password"];
}
@@ -1127,12 +1157,17 @@ class wp_xmlrpc_server extends IXR_Server {
}
// Only set the menu_order if it was given.
- if(!empty($content_struct["wp_page_order"])) {
+ if(isset($content_struct["wp_page_order"])) {
$menu_order = $content_struct["wp_page_order"];
}
+ $post_author = $user->ID;
+
// Only set the post_author if one is set.
- if(!empty($content_struct["wp_author_id"])) {
+ if(
+ isset($content_struct["wp_author_id"])
+ && ($user->ID != $content_struct["wp_author_id"])
+ ) {
switch($post_type) {
case "post":
if(!current_user_can("edit_others_posts")) {
@@ -1155,11 +1190,11 @@ class wp_xmlrpc_server extends IXR_Server {
// Only set ping_status if it was provided.
if(isset($content_struct["mt_allow_pings"])) {
- switch($content_struct["mt_allow_pings"]) {
- case "0":
+ switch((int) $content_struct["mt_allow_pings"]) {
+ case 0:
$ping_status = "closed";
break;
- case "1":
+ case 1:
$ping_status = "open";
break;
}
@@ -1197,7 +1232,7 @@ class wp_xmlrpc_server extends IXR_Server {
$to_ping = implode(' ', $to_ping);
if(isset($content_struct["mt_allow_comments"])) {
- $comment_status = $content_struct["mt_allow_comments"];
+ $comment_status = (int) $content_struct["mt_allow_comments"];
}
// Do some timestamp voodoo
@@ -1205,7 +1240,7 @@ class wp_xmlrpc_server extends IXR_Server {
if (!empty($dateCreatedd)) {
$dateCreated = $dateCreatedd->getIso();
$post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
- $post_date_gmt = iso8601_to_datetime($dateCreated, GMT);
+ $post_date_gmt = iso8601_to_datetime($dateCreated . "Z", GMT);
} else {
$post_date = $postdata['post_date'];
$post_date_gmt = $postdata['post_date_gmt'];
@@ -1245,7 +1280,7 @@ class wp_xmlrpc_server extends IXR_Server {
if ($postdata['post_date'] != '') {
- $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date']);
+ $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt']);
$categories = array();
$catids = wp_get_post_categories($post_ID);
@@ -1313,7 +1348,7 @@ class wp_xmlrpc_server extends IXR_Server {
foreach ($posts_list as $entry) {
- $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
+ $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt']);
$categories = array();
$catids = wp_get_post_categories($entry['ID']);
foreach($catids as $catid) {
@@ -1498,7 +1533,7 @@ class wp_xmlrpc_server extends IXR_Server {
foreach ($posts_list as $entry) {
- $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
+ $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt']);
$struct[] = array(
'dateCreated' => new IXR_Date($post_date),