summaryrefslogtreecommitdiffstats
path: root/wp-admin
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-06-22 18:31:50 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-06-22 18:31:50 +0000
commitd48e85e0ac5e675ca33fac173f30c75403d1033f (patch)
tree1164430fa3b83a4d9283961b09c1576f2885e6b2 /wp-admin
parent086dcde66603301531efc6d8087bd06d0546f148 (diff)
downloadwordpress-mu-d48e85e0ac5e675ca33fac173f30c75403d1033f.tar.gz
wordpress-mu-d48e85e0ac5e675ca33fac173f30c75403d1033f.tar.xz
wordpress-mu-d48e85e0ac5e675ca33fac173f30c75403d1033f.zip
Moved everything in wp-inst down a directory.
Uses's Ryan Boren's htaccess rules and mods If you're upgrading, try this on a test server first! git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@591 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin')
-rw-r--r--wp-admin/admin-ajax.php234
-rw-r--r--wp-admin/admin-db.php554
-rw-r--r--wp-admin/admin-footer.php13
-rw-r--r--wp-admin/admin-functions.php2009
-rw-r--r--wp-admin/admin-header.php41
-rw-r--r--wp-admin/admin.php120
-rw-r--r--wp-admin/bookmarklet.php104
-rw-r--r--wp-admin/cat-js.php35
-rw-r--r--wp-admin/categories.js5
-rw-r--r--wp-admin/categories.php135
-rw-r--r--wp-admin/comment.php209
-rw-r--r--wp-admin/custom-fields.js26
-rw-r--r--wp-admin/dbx-admin-key-js.php68
-rw-r--r--wp-admin/edit-category-form.php46
-rw-r--r--wp-admin/edit-comments.js23
-rw-r--r--wp-admin/edit-comments.php211
-rw-r--r--wp-admin/edit-form-advanced.php237
-rw-r--r--wp-admin/edit-form-ajax-cat.php37
-rw-r--r--wp-admin/edit-form-comment.php80
-rw-r--r--wp-admin/edit-form.php75
-rw-r--r--wp-admin/edit-link-form.php257
-rw-r--r--wp-admin/edit-page-form.php194
-rw-r--r--wp-admin/edit-pages.php62
-rw-r--r--wp-admin/edit.php296
-rw-r--r--wp-admin/export.php106
-rw-r--r--wp-admin/images/box-bg.gifbin0 -> 111 bytes
-rw-r--r--wp-admin/images/box-butt.gifbin0 -> 347 bytes
-rw-r--r--wp-admin/images/box-head.gifbin0 -> 879 bytes
-rw-r--r--wp-admin/images/browse-happy.gifbin0 -> 4398 bytes
-rw-r--r--wp-admin/images/fade-butt.pngbin0 -> 785 bytes
-rw-r--r--wp-admin/images/notice.gifbin0 -> 156 bytes
-rw-r--r--wp-admin/images/toggle.gifbin0 -> 216 bytes
-rw-r--r--wp-admin/images/wordpress-logo.pngbin0 -> 2098 bytes
-rw-r--r--wp-admin/import.php62
-rw-r--r--wp-admin/import/b2.php0
-rw-r--r--wp-admin/import/blogger.php675
-rw-r--r--wp-admin/import/blogware.php192
-rw-r--r--wp-admin/import/dotclear.php747
-rw-r--r--wp-admin/import/greymatter.php312
-rw-r--r--wp-admin/import/livejournal.php168
-rw-r--r--wp-admin/import/mt.php407
-rw-r--r--wp-admin/import/rss.php171
-rw-r--r--wp-admin/import/textpattern.php663
-rw-r--r--wp-admin/import/wordpress.php288
-rw-r--r--wp-admin/index.php181
-rw-r--r--wp-admin/inline-uploading.php728
-rw-r--r--wp-admin/install-helper.php152
-rw-r--r--wp-admin/invites.php196
-rw-r--r--wp-admin/link-add.php49
-rw-r--r--wp-admin/link-import.php133
-rw-r--r--wp-admin/link-manager.php209
-rw-r--r--wp-admin/link-parse-opml.php65
-rw-r--r--wp-admin/link.php128
-rw-r--r--wp-admin/list-manipulation-js.php163
-rw-r--r--wp-admin/menu-header.php61
-rw-r--r--wp-admin/menu.php141
-rw-r--r--wp-admin/moderation.php232
-rw-r--r--wp-admin/options-discussion.php101
-rw-r--r--wp-admin/options-general.php123
-rw-r--r--wp-admin/options-head.php24
-rw-r--r--wp-admin/options-misc.php52
-rw-r--r--wp-admin/options-permalink.php180
-rw-r--r--wp-admin/options-reading.php95
-rw-r--r--wp-admin/options-writing.php66
-rw-r--r--wp-admin/options.php163
-rw-r--r--wp-admin/page-new.php23
-rw-r--r--wp-admin/page.php159
-rw-r--r--wp-admin/plugin-editor.php127
-rw-r--r--wp-admin/plugins.php142
-rw-r--r--wp-admin/post-new.php94
-rw-r--r--wp-admin/post.php161
-rw-r--r--wp-admin/profile-update.php34
-rw-r--r--wp-admin/profile.php148
-rw-r--r--wp-admin/setup-config.php189
-rw-r--r--wp-admin/sidebar.php80
-rw-r--r--wp-admin/templates.php171
-rw-r--r--wp-admin/theme-editor.php162
-rw-r--r--wp-admin/themes.php142
-rw-r--r--wp-admin/update-links.php44
-rw-r--r--wp-admin/upgrade-functions.php1076
-rw-r--r--wp-admin/upgrade-schema.php467
-rw-r--r--wp-admin/upgrade.php106
-rw-r--r--wp-admin/user-edit.php280
-rw-r--r--wp-admin/users.js20
-rw-r--r--wp-admin/users.php597
-rw-r--r--wp-admin/wp-admin.css1009
-rw-r--r--wp-admin/wpmu-admin.php52
-rw-r--r--wp-admin/wpmu-blogs.php527
-rw-r--r--wp-admin/wpmu-edit.php263
-rw-r--r--wp-admin/wpmu-feedback.php10
-rw-r--r--wp-admin/wpmu-feeds.php43
-rw-r--r--wp-admin/wpmu-options.php131
-rw-r--r--wp-admin/wpmu-themes.php57
-rw-r--r--wp-admin/wpmu-upgrade-site.php73
-rw-r--r--wp-admin/wpmu-users.php339
-rw-r--r--wp-admin/xfn.js46
96 files changed, 18876 insertions, 0 deletions
diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php
new file mode 100644
index 0000000..088ce31
--- /dev/null
+++ b/wp-admin/admin-ajax.php
@@ -0,0 +1,234 @@
+<?php
+require_once('../wp-config.php');
+require_once('admin-functions.php');
+require_once('admin-db.php');
+
+define('DOING_AJAX', true);
+
+
+check_ajax_referer();
+if ( !is_user_logged_in() )
+ die('-1');
+
+function get_out_now() { exit; }
+add_action( 'shutdown', 'get_out_now', -1 );
+
+function wp_clean_ajax_input( $i ) {
+ global $wpdb;
+ $i = is_array($i) ? array_map('wp_clean_ajax_input', $i) : $wpdb->escape( rawurldecode(stripslashes($i)) );
+ return $i;
+}
+
+function wp_ajax_echo_meta( $pid, $mid, $key, $value ) {
+ $value = wp_specialchars($value, true);
+ $key_js = addslashes(wp_specialchars($key, 'double'));
+ $key = wp_specialchars($key, true);
+ $r = "<meta><id>$mid</id><postid>$pid</postid><newitem><![CDATA[<table><tbody>";
+ $r .= "<tr id='meta-$mid'><td valign='top'>";
+ $r .= "<input name='meta[$mid][key]' tabindex='6' onkeypress='return killSubmit(\"theList.ajaxUpdater(&#039;meta&#039;,&#039;meta-$mid&#039;);\",event);' type='text' size='20' value='$key' />";
+ $r .= "</td><td><textarea name='meta[$mid][value]' tabindex='6' rows='2' cols='30'>$value</textarea></td><td align='center'>";
+ $r .= "<input name='updatemeta' type='button' class='updatemeta' tabindex='6' value='Update' onclick='return theList.ajaxUpdater(&#039;meta&#039;,&#039;meta-$mid&#039;);' /><br />";
+ $r .= "<input name='deletemeta[$mid]' type='submit' onclick=\"return deleteSomething( 'meta', $mid, '";
+ $r .= sprintf(__("You are about to delete the &quot;%s&quot; custom field on this post.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), $key_js);
+ $r .= "' );\" class='deletemeta' tabindex='6' value='Delete' />";
+ $r .= "</td></tr></tbody></table>]]></newitem></meta>";
+ return $r;
+}
+
+$_POST = wp_clean_ajax_input( $_POST );
+$id = (int) $_POST['id'];
+switch ( $_POST['action'] ) :
+case 'delete-comment' :
+ if ( !$comment = get_comment( $id ) )
+ die('0');
+ if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
+ die('-1');
+
+ if ( wp_delete_comment( $comment->comment_ID ) )
+ die('1');
+ else die('0');
+ break;
+case 'delete-comment-as-spam' :
+ if ( !$comment = get_comment( $id ) )
+ die('0');
+ if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
+ die('-1');
+
+ if ( wp_set_comment_status( $comment->comment_ID, 'spam' ) )
+ die('1');
+ else die('0');
+ break;
+case 'delete-cat' :
+ if ( !current_user_can( 'manage_categories' ) )
+ die('-1');
+
+ if ( wp_delete_category( $id ) )
+ die('1');
+ else die('0');
+ break;
+case 'delete-link' :
+ if ( !current_user_can( 'manage_links' ) )
+ die('-1');
+
+ if ( wp_delete_link( $id ) )
+ die('1');
+ else die('0');
+ break;
+case 'delete-meta' :
+ if ( !$meta = get_post_meta_by_id( $id ) )
+ die('0');
+ if ( !current_user_can( 'edit_post', $meta->post_id ) )
+ die('-1');
+ if ( delete_meta( $meta->meta_id ) )
+ die('1');
+ die('0');
+ break;
+case 'delete-post' :
+ if ( !current_user_can( 'delete_post', $id ) )
+ die('-1');
+
+ if ( wp_delete_post( $id ) )
+ die('1');
+ else die('0');
+ break;
+case 'delete-page' :
+ if ( !current_user_can( 'delete_page', $id ) )
+ die('-1');
+
+ if ( wp_delete_post( $id ) )
+ die('1');
+ else die('0');
+ break;
+case 'dim-comment' :
+ if ( !$comment = get_comment( $id ) )
+ die('0');
+ if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
+ die('-1');
+ if ( !current_user_can( 'moderate_comments' ) )
+ die('-1');
+
+ if ( 'unapproved' == wp_get_comment_status($comment->comment_ID) ) {
+ if ( wp_set_comment_status( $comment->comment_ID, 'approve' ) )
+ die('1');
+ } else {
+ if ( wp_set_comment_status( $comment->comment_ID, 'hold' ) )
+ die('1');
+ }
+ die('0');
+ break;
+case 'add-category' : // On the Fly
+ if ( !current_user_can( 'manage_categories' ) )
+ die('-1');
+ $names = explode(',', $_POST['newcat']);
+ $r = "<?xml version='1.0' standalone='yes'?><ajaxresponse>";
+ foreach ( $names as $cat_name ) {
+ $cat_name = trim($cat_name);
+ if ( !$category_nicename = sanitize_title($cat_name) )
+ die('0');
+ if ( !$cat_id = category_exists( $cat_name ) )
+ $cat_id = wp_create_category( $cat_name );
+ $cat_name = wp_specialchars(stripslashes($cat_name));
+ $r .= "<category><id>$cat_id</id><newitem><![CDATA[";
+ $r .= "<li id='category-$cat_id'><label for='in-category-$cat_id' class='selectit'>";
+ $r .= "<input value='$cat_id' type='checkbox' checked='checked' name='post_category[]' id='in-category-$cat_id'/> $cat_name</label></li>";
+ $r .= "]]></newitem></category>";
+ }
+ $r .= '</ajaxresponse>';
+ header('Content-type: text/xml');
+ die($r);
+ break;
+case 'add-cat' : // From Manage->Categories
+ if ( !current_user_can( 'manage_categories' ) )
+ die('-1');
+ if ( !$cat = wp_insert_category( $_POST ) )
+ die('0');
+ if ( !$cat = get_category( $cat ) )
+ die('0');
+ $pad = 0;
+ $_cat = $cat;
+ while ( $_cat->category_parent ) {
+ $_cat = get_category( $_cat->category_parent );
+ $pad++;
+ }
+ $pad = str_repeat('&#8212; ', $pad);
+
+ $r = "<?xml version='1.0' standalone='yes'?><ajaxresponse>";
+ $r .= "<cat><id>$cat->cat_ID</id><newitem><![CDATA[<table><tbody>";
+ $r .= "<tr id='cat-$cat->cat_ID'><th scope='row'>$cat->cat_ID</th><td>$pad $cat->cat_name</td>";
+ $r .= "<td>$cat->category_description</td><td>$cat->category_count</td><td>$cat->link_count</td>";
+ $r .= "<td><a href='categories.php?action=edit&amp;cat_ID=$cat->cat_ID' class='edit'>" . __('Edit') . "</a></td>";
+ $r .= "<td><a href='categories.php?action=delete&amp;cat_ID=$cat->cat_ID' onclick='return deleteSomething( \"cat\", $cat->cat_ID, \"";
+ $r .= sprintf(__('You are about to delete the category \"%s\". All of its posts and bookmarks will go to the default categories.\\n\"OK\" to delete, \"Cancel\" to stop.'), addslashes($cat->cat_name));
+ $r .= "\" );' class='delete'>".__('Delete')."</a></td></tr>";
+ $r .= "</tbody></table>]]></newitem></cat></ajaxresponse>";
+ header('Content-type: text/xml');
+ die($r);
+
+ break;
+case 'add-meta' :
+ if ( !current_user_can( 'edit_post', $id ) )
+ die('-1');
+ if ( $id < 0 ) {
+ if ( $pid = write_post() )
+ $meta = has_meta( $pid );
+ else
+ die('0');
+ $key = $meta[0]['meta_key'];
+ $value = $meta[0]['meta_value'];
+ $mid = (int) $meta[0]['meta_id'];
+ } else {
+ if ( $mid = add_meta( $id ) )
+ $meta = get_post_meta_by_id( $mid );
+ else
+ die('0');
+ $key = $meta->meta_key;
+ $value = $meta->meta_value;
+ $pid = (int) $meta->post_id;
+ }
+ $r = "<?xml version='1.0' standalone='yes'?><ajaxresponse>";
+ $r .= wp_ajax_echo_meta( $pid, $mid, $key, $value );
+ $r .= '</ajaxresponse>';
+ header('Content-type: text/xml');
+ die($r);
+ break;
+case 'update-meta' :
+ $mid = (int) array_pop(array_keys($_POST['meta']));
+ $key = $_POST['meta'][$mid]['key'];
+ $value = $_POST['meta'][$mid]['value'];
+ if ( !$meta = get_post_meta_by_id( $mid ) )
+ die('0');
+ if ( !current_user_can( 'edit_post', $meta->post_id ) )
+ die('-1');
+ $r = "<?xml version='1.0' standalone='yes'?><ajaxresponse>";
+ if ( $u = update_meta( $mid, $key, $value ) ) {
+ $key = stripslashes($key);
+ $value = stripslashes($value);
+ $r .= wp_ajax_echo_meta( $meta->post_id, $mid, $key, $value );
+ }
+ $r .= '</ajaxresponse>';
+ header('Content-type: text/xml');
+ die($r);
+ break;
+case 'add-user' :
+ if ( !current_user_can('edit_users') )
+ die('-1');
+ require_once(ABSPATH . WPINC . '/registration.php');
+ $user_id = add_user();
+ if ( is_wp_error( $user_id ) ) {
+ foreach( $user_id->get_error_messages() as $message )
+ echo "$message<br />";
+ exit;
+ } elseif ( !$user_id ) {
+ die('0');
+ }
+ $r = "<?xml version='1.0' standalone='yes'?><ajaxresponse><user><id>$user_id</id><newitem><![CDATA[<table><tbody>";
+ $r .= user_row( $user_id );
+ $r .= "</tbody></table>]]></newitem></user></ajaxresponse>";
+ header('Content-type: text/xml');
+ die($r);
+ break;
+default :
+ die('0');
+ break;
+endswitch;
+?>
diff --git a/wp-admin/admin-db.php b/wp-admin/admin-db.php
new file mode 100644
index 0000000..0b8c264
--- /dev/null
+++ b/wp-admin/admin-db.php
@@ -0,0 +1,554 @@
+<?php
+
+function get_users_drafts( $user_id ) {
+ global $wpdb;
+ $user_id = (int) $user_id;
+ $query = "SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author = $user_id ORDER BY ID DESC";
+ $query = apply_filters('get_users_drafts', $query);
+ return $wpdb->get_results( $query );
+}
+
+function get_others_drafts( $user_id ) {
+ global $wpdb;
+ $user = get_userdata( $user_id );
+ $level_key = $wpdb->prefix . 'user_level';
+
+ $editable = get_editable_user_ids( $user_id );
+
+ if( !$editable ) {
+ $other_drafts = '';
+ } else {
+ $editable = join(',', $editable);
+ $other_drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author IN ($editable) AND post_author != '$user_id' ");
+ }
+
+ return apply_filters('get_others_drafts', $other_drafts);
+}
+
+function get_editable_authors( $user_id ) {
+ global $wpdb;
+
+ $editable = get_editable_user_ids( $user_id );
+
+ if( !$editable ) {
+ return false;
+ } else {
+ $editable = join(',', $editable);
+ $authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable)" );
+ }
+
+ return apply_filters('get_editable_authors', $authors);
+}
+
+function get_editable_user_ids( $user_id, $exclude_zeros = true ) {
+ global $wpdb;
+
+ $user = new WP_User( $user_id );
+
+ if ( ! $user->has_cap('edit_others_posts') ) {
+ if ( $user->has_cap('edit_posts') || $exclude_zeros == false )
+ return array($user->id);
+ else
+ return false;
+ }
+
+ $level_key = $wpdb->prefix . 'user_level';
+
+ $query = "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key'";
+ if ( $exclude_zeros )
+ $query .= " AND meta_value != '0'";
+
+ return $wpdb->get_col( $query );
+}
+
+function get_author_user_ids() {
+ global $wpdb;
+ $level_key = $wpdb->prefix . 'user_level';
+
+ $query = "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key' AND meta_value != '0'";
+
+ return $wpdb->get_col( $query );
+}
+
+function get_nonauthor_user_ids() {
+ global $wpdb;
+ $level_key = $wpdb->prefix . 'user_level';
+
+ $query = "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key' AND meta_value = '0'";
+
+ return $wpdb->get_col( $query );
+}
+
+function wp_insert_category($catarr) {
+ global $wpdb;
+
+ extract($catarr);
+
+ $cat_ID = (int) $cat_ID;
+
+ // Are we updating or creating?
+ if (!empty ($cat_ID))
+ $update = true;
+ else
+ $update = false;
+
+ $cat_name = apply_filters('pre_category_name', $cat_name);
+
+ if ( !$update && category_exists($cat_name) )
+ return 0;
+
+ if (empty ($category_nicename))
+ $category_nicename = sanitize_title($cat_name);
+ else
+ $category_nicename = sanitize_title($category_nicename);
+ $category_nicename = apply_filters('pre_category_nicename', $category_nicename);
+
+ if (empty ($category_description))
+ $category_description = '';
+ $category_description = apply_filters('pre_category_description', $category_description);
+
+ $category_parent = (int) $category_parent;
+ if (empty ($category_parent))
+ $category_parent = 0;
+
+ if ( isset($posts_private) )
+ $posts_private = (int) $posts_private;
+ else
+ $posts_private = 0;
+
+ if ( isset($links_private) )
+ $links_private = (int) $links_private;
+ else
+ $links_private = 0;
+
+ if (!$update) {
+ $maxcat = $wpdb->get_var( "SELECT max(cat_ID) FROM {$wpdb->categories}" );
+ $cat_ID = mt_rand( $maxcat+100, $maxcat+4000 );
+ $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent, links_private, posts_private) VALUES ('$cat_ID', '$cat_name', '$category_nicename', '$category_description', '$category_parent', '$links_private', '$posts_private')");
+ } else {
+ $wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent', links_private = '$links_private', posts_private = '$posts_private' WHERE cat_ID = '$cat_ID'");
+ }
+
+ if ( $category_nicename == '' ) {
+ $category_nicename = sanitize_title($cat_name, $cat_ID );
+ $wpdb->query( "UPDATE $wpdb->categories SET category_nicename = '$category_nicename' WHERE cat_ID = '$cat_ID'" );
+ }
+
+ wp_cache_delete($cat_ID, 'category');
+
+ if ($update) {
+ do_action('edit_category', $cat_ID);
+ } else {
+ wp_cache_delete('all_category_ids', 'category');
+ do_action('create_category', $cat_ID);
+ do_action('add_category', $cat_ID);
+ }
+ $cat_ID = apply_filters( "cat_id_filter", $cat_ID );
+
+ return $cat_ID;
+}
+
+function wp_update_category($catarr) {
+ global $wpdb;
+
+ $cat_ID = (int) $catarr['cat_ID'];
+
+ // First, get all of the original fields
+ $category = get_category($cat_ID, ARRAY_A);
+
+ // Escape data pulled from DB.
+ $category = add_magic_quotes($category);
+
+ // Merge old and new fields with new fields overwriting old ones.
+ $catarr = array_merge($category, $catarr);
+
+ return wp_insert_category($catarr);
+}
+
+function wp_delete_category($cat_ID) {
+ global $wpdb;
+
+ $cat_ID = (int) $cat_ID;
+
+ // Don't delete the default cat.
+ if ( $cat_ID == get_option('default_category') )
+ return 0;
+
+ if ( $cat_ID == get_option('default_link_category') )
+ return 0;
+
+ $category = get_category($cat_ID);
+
+ $parent = $category->category_parent;
+
+ // Delete the category.
+ if ( !$wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'") )
+ return 0;
+
+ // Update children to point to new parent.
+ $wpdb->query("UPDATE $wpdb->categories SET category_parent = '$parent' WHERE category_parent = '$cat_ID'");
+
+ // Only set posts and links to the default category if they're not in another category already.
+ $default_cat = get_option('default_category');
+ $posts = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id='$cat_ID'");
+ if ( is_array($posts) ) foreach ($posts as $post_id) {
+ $cats = wp_get_post_categories($post_id);
+ if ( 1 == count($cats) )
+ $cats = array($default_cat);
+ else
+ $cats = array_diff($cats, array($cat_ID));
+ wp_set_post_categories($post_id, $cats);
+ }
+
+ $default_link_cat = get_option('default_link_category');
+ $links = $wpdb->get_col("SELECT link_id FROM $wpdb->link2cat WHERE category_id='$cat_ID'");
+ if ( is_array($links) ) foreach ($links as $link_id) {
+ $cats = wp_get_link_cats($link_id);
+ if ( 1 == count($cats) )
+ $cats = array($default_link_cat);
+ else
+ $cats = array_diff($cats, array($cat_ID));
+ wp_set_link_cats($link_id, $cats);
+ }
+
+ wp_cache_delete($cat_ID, 'category');
+ wp_cache_delete('all_category_ids', 'category');
+
+ do_action('delete_category', $cat_ID);
+
+ return 1;
+}
+
+function wp_create_category($cat_name) {
+ $cat_array = compact('cat_name');
+ return wp_insert_category($cat_array);
+}
+
+function wp_create_categories($categories, $post_id = '') {
+ $cat_ids = array ();
+ foreach ($categories as $category) {
+ if ($id = category_exists($category))
+ $cat_ids[] = $id;
+ else
+ if ($id = wp_create_category($category))
+ $cat_ids[] = $id;
+ }
+
+ if ($post_id)
+ wp_set_post_categories($post_id, $cat_ids);
+
+ return $cat_ids;
+}
+
+function category_exists($cat_name) {
+ global $wpdb;
+ if (!$category_nicename = sanitize_title($cat_name))
+ return 0;
+
+ return $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'");
+}
+
+function wp_delete_user($id, $reassign = 'novalue') {
+ global $wpdb;
+
+ $id = (int) $id;
+ $user = get_userdata($id);
+
+ if ($reassign == 'novalue') {
+ $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id");
+
+ if ($post_ids) {
+ foreach ($post_ids as $post_id)
+ wp_delete_post($post_id);
+ }
+
+ // Clean links
+ $wpdb->query("DELETE FROM $wpdb->links WHERE link_owner = $id");
+ } else {
+ $reassign = (int) $reassign;
+ $wpdb->query("UPDATE $wpdb->posts SET post_author = {$reassign} WHERE post_author = {$id}");
+ $wpdb->query("UPDATE $wpdb->links SET link_owner = {$reassign} WHERE link_owner = {$id}");
+ }
+
+ // FINALLY, delete user
+ $wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = $id AND meta_key = '{$wpdb->prefix}capabilities'");
+
+ wp_cache_delete($id, 'users');
+ wp_cache_delete($user->user_login, 'userlogins');
+
+ do_action('delete_user', $id);
+
+ return true;
+}
+
+function wp_revoke_user($id) {
+ $id = (int) $id;
+
+ $user = new WP_User($id);
+ $user->remove_all_caps();
+}
+
+function wp_insert_link($linkdata) {
+ global $wpdb, $current_user;
+
+ extract($linkdata);
+
+ $update = false;
+ if ( !empty($link_id) )
+ $update = true;
+
+ if ( empty($link_rating) )
+ $link_rating = 0;
+
+ if ( empty($link_target) )
+ $link_target = '';
+
+ if ( empty($link_visible) )
+ $link_visible = 'Y';
+
+ if ( empty($link_owner) )
+ $link_owner = $current_user->id;
+
+ if ( empty($link_notes) )
+ $link_notes = '';
+
+ // Make sure we set a valid category
+ if (0 == count($link_category) || !is_array($link_category)) {
+ $link_category = array(get_option('default_link_category'));
+ }
+
+ if ( $update ) {
+ $wpdb->query("UPDATE $wpdb->links SET link_url='$link_url',
+ link_name='$link_name', link_image='$link_image',
+ link_target='$link_target',
+ link_visible='$link_visible', link_description='$link_description',
+ link_rating='$link_rating', link_rel='$link_rel',
+ link_notes='$link_notes', link_rss = '$link_rss'
+ WHERE link_id='$link_id'");
+ } else {
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES('$link_url','$link_name', '$link_image', '$link_target', '$link_description', '$link_visible', '$link_owner', '$link_rating', '$link_rel', '$link_notes', '$link_rss')");
+ $link_id = $wpdb->insert_id;
+ }
+
+ wp_set_link_cats($link_id, $link_category);
+
+ if ( $update )
+ do_action('edit_link', $link_id);
+ else
+ do_action('add_link', $link_id);
+
+ return $link_id;
+}
+
+function wp_update_link($linkdata) {
+ global $wpdb;
+
+ $link_id = (int) $linkdata['link_id'];
+
+ $link = get_link($link_id, ARRAY_A);
+
+ // Escape data pulled from DB.
+ $link = add_magic_quotes($link);
+
+ // Passed link category list overwrites existing category list if not empty.
+ if ( isset($linkdata['link_category']) && is_array($linkdata['link_category'])
+ && 0 != count($linkdata['link_category']) )
+ $link_cats = $linkdata['link_category'];
+ else
+ $link_cats = $link['link_category'];
+
+ // Merge old and new fields with new fields overwriting old ones.
+ $linkdata = array_merge($link, $linkdata);
+ $linkdata['link_category'] = $link_cats;
+
+ return wp_insert_link($linkdata);
+}
+
+function wp_delete_link($link_id) {
+ global $wpdb;
+
+ do_action('delete_link', $link_id);
+
+ $categories = wp_get_link_cats($link_id);
+ if( is_array( $categories ) ) {
+ foreach ( $categories as $category ) {
+ $wpdb->query("UPDATE $wpdb->categories SET link_count = link_count - 1 WHERE cat_ID = '$category'");
+ wp_cache_delete($category, 'category');
+ }
+ }
+
+ $wpdb->query("DELETE FROM $wpdb->link2cat WHERE link_id = '$link_id'");
+ return $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$link_id'");
+}
+
+function wp_get_link_cats($link_ID = 0) {
+ global $wpdb;
+
+ $sql = "SELECT category_id
+ FROM $wpdb->link2cat
+ WHERE link_id = $link_ID
+ ORDER BY category_id";
+
+ $result = $wpdb->get_col($sql);
+
+ if ( !$result )
+ $result = array();
+
+ return array_unique($result);
+}
+
+function wp_set_link_cats($link_ID = 0, $link_categories = array()) {
+ global $wpdb;
+ // If $link_categories isn't already an array, make it one:
+ if (!is_array($link_categories) || 0 == count($link_categories))
+ $link_categories = array(get_option('default_link_category'));
+
+ $link_categories = array_unique($link_categories);
+
+ // First the old categories
+ $old_categories = $wpdb->get_col("
+ SELECT category_id
+ FROM $wpdb->link2cat
+ WHERE link_id = $link_ID");
+
+ if (!$old_categories) {
+ $old_categories = array();
+ } else {
+ $old_categories = array_unique($old_categories);
+ }
+
+ // Delete any?
+ $delete_cats = array_diff($old_categories,$link_categories);
+
+ if ($delete_cats) {
+ foreach ($delete_cats as $del) {
+ $wpdb->query("
+ DELETE FROM $wpdb->link2cat
+ WHERE category_id = $del
+ AND link_id = $link_ID
+ ");
+ }
+ }
+
+ // Add any?
+ $add_cats = array_diff($link_categories, $old_categories);
+
+ if ($add_cats) {
+ foreach ($add_cats as $new_cat) {
+ $wpdb->query("
+ INSERT INTO $wpdb->link2cat (link_id, category_id)
+ VALUES ($link_ID, $new_cat)");
+ }
+ }
+
+ // Update category counts.
+ $all_affected_cats = array_unique(array_merge($link_categories, $old_categories));
+ foreach ( $all_affected_cats as $cat_id ) {
+ $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->link2cat, $wpdb->links WHERE $wpdb->links.link_id = $wpdb->link2cat.link_id AND category_id = '$cat_id'");
+ $wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'");
+ wp_cache_delete($cat_id, 'category');
+ }
+} // wp_set_link_cats()
+
+function post_exists($title, $content = '', $post_date = '') {
+ global $wpdb;
+
+ if (!empty ($post_date))
+ $post_date = "AND post_date = '$post_date'";
+
+ if (!empty ($title))
+ return $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$title' $post_date");
+ else
+ if (!empty ($content))
+ return $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_content = '$content' $post_date");
+
+ return 0;
+}
+
+function comment_exists($comment_author, $comment_date) {
+ global $wpdb;
+
+ return $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments
+ WHERE comment_author = '$comment_author' AND comment_date = '$comment_date'");
+}
+
+function wpmu_delete_blog($blog_id, $drop = false) {
+ global $wpdb, $wpmuBaseTablePrefix;
+
+ if ( $blog_id != $wpdb->blogid ) {
+ $switch = true;
+ switch_to_blog($blog_id);
+ }
+
+ do_action('delete_blog', $blog_id, $drop);
+
+ $users = get_users_of_blog($blog_id);
+
+ // Remove users from this blog.
+ if ( !empty($users) ) foreach ($users as $user) {
+ remove_user_from_blog($user->user_id, $blog_id);
+ }
+
+ update_blog_status( $wpdb->blogid, 'deleted', 1 );
+
+ if ( $drop ) {
+ $drop_tables = array( $wpmuBaseTablePrefix . $blog_id . "_categories",
+ $wpmuBaseTablePrefix . $blog_id . "_comments",
+ $wpmuBaseTablePrefix . $blog_id . "_linkcategories",
+ $wpmuBaseTablePrefix . $blog_id . "_links",
+ $wpmuBaseTablePrefix . $blog_id . "_link2cat",
+ $wpmuBaseTablePrefix . $blog_id . "_options",
+ $wpmuBaseTablePrefix . $blog_id . "_post2cat",
+ $wpmuBaseTablePrefix . $blog_id . "_postmeta",
+ $wpmuBaseTablePrefix . $blog_id . "_posts",
+ $wpmuBaseTablePrefix . $blog_id . "_referer_visitLog",
+ $wpmuBaseTablePrefix . $blog_id . "_referer_blacklist" );
+ reset( $drop_tables );
+
+ while( list( $key, $val ) = each( $drop_tables ) )
+ $wpdb->query( "DROP TABLE IF EXISTS $val" );
+
+ $wpdb->query( "DELETE FROM $wpdb->blogs WHERE blog_id = '$blog_id'" );
+ }
+
+ if ( $switch )
+ restore_current_blog();
+}
+
+function wpmu_delete_user($id) {
+ global $wpdb;
+
+ $id = (int) $id;
+ $user = get_userdata($id);
+
+ do_action('wpmu_delete_user', $id);
+
+ $blogs = get_blogs_of_user($id);
+
+ if ( ! empty($blogs) ) foreach ($blogs as $blog) {
+ switch_to_blog($blog->userblog_id);
+ remove_user_from_blog($id, $blog->userblog_id);
+
+ $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id");
+
+ if ($post_ids) {
+ foreach ($post_ids as $post_id)
+ wp_delete_post($post_id);
+ }
+
+ // Clean links
+ $wpdb->query("DELETE FROM $wpdb->links WHERE link_owner = $id");
+
+ restore_current_blog();
+ }
+
+ $wpdb->query("DELETE FROM $wpdb->users WHERE ID = $id");
+ $wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = '$id'");
+
+ wp_cache_delete($id, 'users');
+ wp_cache_delete($user->user_login, 'userlogins');
+
+ return true;
+}
+
+?>
diff --git a/wp-admin/admin-footer.php b/wp-admin/admin-footer.php
new file mode 100644
index 0000000..783be91
--- /dev/null
+++ b/wp-admin/admin-footer.php
@@ -0,0 +1,13 @@
+
+<div id="footer"><p><a href="http://wordpress.org/" id="wordpress-logo"><img src="images/wordpress-logo.png" alt="WordPress" /></a></p>
+<p>
+<a href="http://codex.wordpress.org/"><?php _e('Documentation'); ?></a> &#8212; <a href="http://wordpress.org/support/"><?php _e('Support Forums'); ?></a> <br />
+<?php bloginfo('version'); ?> &#8212; <?php printf(__('%s seconds'), number_format(timer_stop(), 2)); ?>
+</p>
+
+</div>
+<?php do_action('admin_footer', ''); ?>
+<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
+
+</body>
+</html>
diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php
new file mode 100644
index 0000000..d229073
--- /dev/null
+++ b/wp-admin/admin-functions.php
@@ -0,0 +1,2009 @@
+<?php
+
+// Creates a new post from the "Write Post" form using $_POST information.
+function write_post() {
+ global $user_ID;
+
+ if ( 'page' == $_POST['post_type'] ) {
+ if ( !current_user_can('edit_pages') )
+ die(__('You are not allowed to create pages on this blog.'));
+ } else {
+ if ( !current_user_can('edit_posts') )
+ die(__('You are not allowed to create posts or drafts on this blog.'));
+ }
+
+ // Rename.
+ $_POST['post_content'] = $_POST['content'];
+ $_POST['post_excerpt'] = $_POST['excerpt'];
+ $_POST['post_parent'] = $_POST['parent_id'];
+ $_POST['to_ping'] = $_POST['trackback_url'];
+
+ if (!empty ($_POST['post_author_override'])) {
+ $_POST['post_author'] = (int) $_POST['post_author_override'];
+ } else {
+ if (!empty ($_POST['post_author'])) {
+ $_POST['post_author'] = (int) $_POST['post_author'];
+ } else {
+ $_POST['post_author'] = (int) $_POST['user_ID'];
+ }
+
+ }
+
+ if ($_POST['post_author'] != $_POST['user_ID']) {
+ if ( 'page' == $_POST['post_type'] ) {
+ if ( !current_user_can('edit_others_pages') )
+ die(__('You cannot create pages as this user.'));
+ } else {
+ if ( !current_user_can('edit_others_posts') )
+ die(__('You cannot post as this user.'));
+
+ }
+ }
+
+ // What to do based on which button they pressed
+ if ('' != $_POST['saveasdraft'])
+ $_POST['post_status'] = 'draft';
+ if ('' != $_POST['saveasprivate'])
+ $_POST['post_status'] = 'private';
+ if ('' != $_POST['publish'])
+ $_POST['post_status'] = 'publish';
+ if ('' != $_POST['advanced'])
+ $_POST['post_status'] = 'draft';
+
+ if ( 'page' == $_POST['post_type'] ) {
+ if ('publish' == $_POST['post_status'] && !current_user_can('publish_pages'))
+ $_POST['post_status'] = 'draft';
+ } else {
+ if ('publish' == $_POST['post_status'] && !current_user_can('publish_posts'))
+ $_POST['post_status'] = 'draft';
+ }
+
+ if (!isset ($_POST['comment_status']))
+ $_POST['comment_status'] = 'closed';
+
+ if (!isset ($_POST['ping_status']))
+ $_POST['ping_status'] = 'closed';
+
+ if (!empty ($_POST['edit_date'])) {
+ $aa = $_POST['aa'];
+ $mm = $_POST['mm'];
+ $jj = $_POST['jj'];
+ $hh = $_POST['hh'];
+ $mn = $_POST['mn'];
+ $ss = $_POST['ss'];
+ $jj = ($jj > 31) ? 31 : $jj;
+ $hh = ($hh > 23) ? $hh -24 : $hh;
+ $mn = ($mn > 59) ? $mn -60 : $mn;
+ $ss = ($ss > 59) ? $ss -60 : $ss;
+ $_POST['post_date'] = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss);
+ $_POST['post_date_gmt'] = get_gmt_from_date($_POST['post_date']);
+ }
+
+ // Create the post.
+ $post_ID = wp_insert_post($_POST);
+ add_meta($post_ID);
+
+ // Reunite any orphaned attachments with their parent
+ if ( $_POST['temp_ID'] )
+ relocate_children($_POST['temp_ID'], $post_ID);
+
+ // Now that we have an ID we can fix any attachment anchor hrefs
+ fix_attachment_links($post_ID);
+
+ return $post_ID;
+}
+
+// Move child posts to a new parent
+function relocate_children($old_ID, $new_ID) {
+ global $wpdb;
+ $old_ID = (int) $old_ID;
+ $new_ID = (int) $new_ID;
+ return $wpdb->query("UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID");
+}
+
+// Replace hrefs of attachment anchors with up-to-date permalinks.
+function fix_attachment_links($post_ID) {
+ global $wp_rewrite;
+
+ $post = & get_post($post_ID, ARRAY_A);
+
+ $search = "#<a[^>]+rel=('|\")[^'\"]*attachment[^>]*>#ie";
+
+ // See if we have any rel="attachment" links
+ if ( 0 == preg_match_all($search, $post['post_content'], $anchor_matches, PREG_PATTERN_ORDER) )
+ return;
+
+ $i = 0;
+ $search = "# id=(\"|')p(\d+)\\1#i";
+ foreach ( $anchor_matches[0] as $anchor ) {
+ if ( 0 == preg_match($search, $anchor, $id_matches) )
+ continue;
+
+ $id = $id_matches[2];
+
+ // While we have the attachment ID, let's adopt any orphans.
+ $attachment = & get_post($id, ARRAY_A);
+ if ( ! empty($attachment) && ! is_object(get_post($attachment['post_parent'])) ) {
+ $attachment['post_parent'] = $post_ID;
+ // Escape data pulled from DB.
+ $attachment = add_magic_quotes($attachment);
+ wp_update_post($attachment);
+ }
+
+ $post_search[$i] = $anchor;
+ $post_replace[$i] = preg_replace("#href=(\"|')[^'\"]*\\1#e", "stripslashes('href=\\1').get_attachment_link($id).stripslashes('\\1')", $anchor);
+ ++$i;
+ }
+
+ $post['post_content'] = str_replace($post_search, $post_replace, $post['post_content']);
+
+ // Escape data pulled from DB.
+ $post = add_magic_quotes($post);
+
+ return wp_update_post($post);
+}
+
+// Update an existing post with values provided in $_POST.
+function edit_post() {
+ global $user_ID;
+
+ $post_ID = (int) $_POST['post_ID'];
+
+ if ( 'page' == $_POST['post_type'] ) {
+ if ( !current_user_can('edit_page', $post_ID) )
+ die(__('You are not allowed to edit this page.'));
+ } else {
+ if ( !current_user_can('edit_post', $post_ID) )
+ die(__('You are not allowed to edit this post.'));
+ }
+
+ // Rename.
+ $_POST['ID'] = (int) $_POST['post_ID'];
+ $_POST['post_content'] = $_POST['content'];
+ $_POST['post_excerpt'] = $_POST['excerpt'];
+ $_POST['post_parent'] = $_POST['parent_id'];
+ $_POST['to_ping'] = $_POST['trackback_url'];
+
+ if (!empty ($_POST['post_author_override'])) {
+ $_POST['post_author'] = (int) $_POST['post_author_override'];
+ } else
+ if (!empty ($_POST['post_author'])) {
+ $_POST['post_author'] = (int) $_POST['post_author'];
+ } else {
+ $_POST['post_author'] = (int) $_POST['user_ID'];
+ }
+
+ if ($_POST['post_author'] != $_POST['user_ID']) {
+ if ( 'page' == $_POST['post_type'] ) {
+ if ( !current_user_can('edit_others_pages') )
+ die(__('You cannot edit pages as this user.'));
+ } else {
+ if ( !current_user_can('edit_others_posts') )
+ die(__('You cannot edit posts as this user.'));
+
+ }
+ }
+
+ // What to do based on which button they pressed
+ if ('' != $_POST['saveasdraft'])
+ $_POST['post_status'] = 'draft';
+ if ('' != $_POST['saveasprivate'])
+ $_POST['post_status'] = 'private';
+ if ('' != $_POST['publish'])
+ $_POST['post_status'] = 'publish';
+ if ('' != $_POST['advanced'])
+ $_POST['post_status'] = 'draft';
+
+ if ( 'page' == $_POST['post_type'] ) {
+ if ('publish' == $_POST['post_status'] && !current_user_can('edit_published_pages'))
+ $_POST['post_status'] = 'draft';
+ } else {
+ if ('publish' == $_POST['post_status'] && !current_user_can('edit_published_posts'))
+ $_POST['post_status'] = 'draft';
+ }
+
+ if (!isset ($_POST['comment_status']))
+ $_POST['comment_status'] = 'closed';
+
+ if (!isset ($_POST['ping_status']))
+ $_POST['ping_status'] = 'closed';
+
+ if (!empty ($_POST['edit_date'])) {
+ $aa = $_POST['aa'];
+ $mm = $_POST['mm'];
+ $jj = $_POST['jj'];
+ $hh = $_POST['hh'];
+ $mn = $_POST['mn'];
+ $ss = $_POST['ss'];
+ $jj = ($jj > 31) ? 31 : $jj;
+ $hh = ($hh > 23) ? $hh -24 : $hh;
+ $mn = ($mn > 59) ? $mn -60 : $mn;
+ $ss = ($ss > 59) ? $ss -60 : $ss;
+ $_POST['post_date'] = "$aa-$mm-$jj $hh:$mn:$ss";
+ $_POST['post_date_gmt'] = get_gmt_from_date("$aa-$mm-$jj $hh:$mn:$ss");
+ }
+
+ // Meta Stuff
+ if ($_POST['meta']) {
+ foreach ($_POST['meta'] as $key => $value)
+ update_meta($key, $value['key'], $value['value']);
+ }
+
+ if ($_POST['deletemeta']) {
+ foreach ($_POST['deletemeta'] as $key => $value)
+ delete_meta($key);
+ }
+
+ add_meta($post_ID);
+
+ wp_update_post($_POST);
+
+ // Now that we have an ID we can fix any attachment anchor hrefs
+ fix_attachment_links($post_ID);
+
+ return $post_ID;
+}
+
+function edit_comment() {
+ global $user_ID;
+
+ $comment_ID = (int) $_POST['comment_ID'];
+ $comment_post_ID = (int) $_POST['comment_post_ID'];
+
+ if (!current_user_can('edit_post', $comment_post_ID))
+ die(__('You are not allowed to edit comments on this post, so you cannot edit this comment.'));
+
+ $_POST['comment_author'] = $_POST['newcomment_author'];
+ $_POST['comment_author_email'] = $_POST['newcomment_author_email'];
+ $_POST['comment_author_url'] = $_POST['newcomment_author_url'];
+ $_POST['comment_approved'] = $_POST['comment_status'];
+ $_POST['comment_content'] = $_POST['content'];
+ $_POST['comment_ID'] = (int) $_POST['comment_ID'];
+
+ if (!empty ($_POST['edit_date'])) {
+ $aa = $_POST['aa'];
+ $mm = $_POST['mm'];
+ $jj = $_POST['jj'];
+ $hh = $_POST['hh'];
+ $mn = $_POST['mn'];
+ $ss = $_POST['ss'];
+ $jj = ($jj > 31) ? 31 : $jj;
+ $hh = ($hh > 23) ? $hh -24 : $hh;
+ $mn = ($mn > 59) ? $mn -60 : $mn;
+ $ss = ($ss > 59) ? $ss -60 : $ss;
+ $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss";
+ }
+
+ wp_update_comment($_POST);
+}
+
+// Get an existing post and format it for editing.
+function get_post_to_edit($id) {
+ global $richedit;
+ $richedit = ( 'true' == get_user_option('rich_editing') ) ? true : false;
+
+ $post = get_post($id);
+
+ $post->post_content = format_to_edit($post->post_content, $richedit);
+ $post->post_content = apply_filters('content_edit_pre', $post->post_content);
+
+ $post->post_excerpt = format_to_edit($post->post_excerpt);
+ $post->post_excerpt = apply_filters('excerpt_edit_pre', $post->post_excerpt);
+
+ $post->post_title = format_to_edit($post->post_title);
+ $post->post_title = apply_filters('title_edit_pre', $post->post_title);
+
+ if ($post->post_type == 'page')
+ $post->page_template = get_post_meta($id, '_wp_page_template', true);
+
+ return $post;
+}
+
+// Default post information to use when populating the "Write Post" form.
+function get_default_post_to_edit() {
+ if ( !empty($_REQUEST['post_title']) )
+ $post_title = wp_specialchars(stripslashes($_REQUEST['post_title']));
+ else if ( !empty($_REQUEST['popuptitle']) ) {
+ $post_title = wp_specialchars(stripslashes($_REQUEST['popuptitle']));
+ $post_title = funky_javascript_fix($post_title);
+ } else {
+ $post_title = '';
+ }
+
+ if ( !empty($_REQUEST['content']) )
+ $post_content = wp_specialchars(stripslashes($_REQUEST['content']));
+ else if ( !empty($post_title) ) {
+ $text = wp_specialchars(stripslashes(urldecode($_REQUEST['text'])));
+ $text = funky_javascript_fix($text);
+ $popupurl = wp_specialchars($_REQUEST['popupurl']);
+ $post_content = '<a href="'.$popupurl.'">'.$post_title.'</a>'."\n$text";
+ }
+
+ if ( !empty($_REQUEST['excerpt']) )
+ $post_excerpt = wp_specialchars(stripslashes($_REQUEST['excerpt']));
+ else
+ $post_excerpt = '';
+
+ $post->post_status = 'draft';
+ $post->comment_status = get_settings('default_comment_status');
+ $post->ping_status = get_settings('default_ping_status');
+ $post->post_pingback = get_settings('default_pingback_flag');
+ $post->post_category = get_settings('default_category');
+ $post->post_content = apply_filters('default_content', $post_content);
+ $post->post_title = apply_filters('default_title', $post_title);
+ $post->post_excerpt = apply_filters('default_excerpt', $post_excerpt);
+ $post->page_template = 'default';
+ $post->post_parent = 0;
+ $post->menu_order = 0;
+
+ return $post;
+}
+
+function get_comment_to_edit($id) {
+ global $richedit;
+ $richedit = ( 'true' == get_user_option('rich_editing') ) ? true : false;
+
+ $comment = get_comment($id);
+
+ $comment->comment_content = format_to_edit($comment->comment_content, $richedit);
+ $comment->comment_content = apply_filters('comment_edit_pre', $comment->comment_content);
+
+ $comment->comment_author = format_to_edit($comment->comment_author);
+ $comment->comment_author_email = format_to_edit($comment->comment_author_email);
+ $comment->comment_author_url = format_to_edit($comment->comment_author_url);
+
+ return $comment;
+}
+
+function get_category_to_edit($id) {
+ $category = get_category($id);
+
+ return $category;
+}
+
+function wp_dropdown_roles( $default = false ) {
+ global $wp_roles;
+ $r = '';
+ foreach($wp_roles->role_names as $role => $name)
+ if ( $default == $role ) // Make default first in list
+ $p = "\n\t<option selected='selected' value='$role'>$name</option>";
+ else
+ $r .= "\n\t<option value='$role'>$name</option>";
+ echo $p . $r;
+}
+
+
+// Creates a new user from the "Users" form using $_POST information.
+
+function add_user() {
+ if ( func_num_args() ) { // The hackiest hack that ever did hack
+ global $current_user, $wp_roles;
+ $user_id = func_get_arg(0);
+ if (isset ($_POST['role'])) {
+ if($user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap('edit_users')) {
+ $user = new WP_User($user_id);
+ $user->set_role($_POST['role']);
+ }
+ }
+ } else {
+ add_action('user_register', 'add_user'); // See above
+ return edit_user();
+ }
+}
+
+function edit_user($user_id = 0) {
+ global $current_user, $wp_roles, $wpdb;
+ if ($user_id != 0) {
+ $update = true;
+ $user->ID = $user_id;
+ $userdata = get_userdata($user_id);
+ $user->user_login = $wpdb->escape($userdata->user_login);
+ } else {
+ $update = false;
+ $user = '';
+ }
+
+ if (isset ($_POST['user_login']))
+ $user->user_login = wp_specialchars(trim($_POST['user_login']));
+
+ $pass1 = $pass2 = '';
+ if (isset ($_POST['pass1']))
+ $pass1 = $_POST['pass1'];
+ if (isset ($_POST['pass2']))
+ $pass2 = $_POST['pass2'];
+
+ if (isset ($_POST['role'])) {
+ if($user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap('edit_users'))
+ $user->role = $_POST['role'];
+ }
+
+ 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 = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url;
+ }
+ if (isset ($_POST['first_name']))
+ $user->first_name = wp_specialchars(trim($_POST['first_name']));
+ if (isset ($_POST['last_name']))
+ $user->last_name = wp_specialchars(trim($_POST['last_name']));
+ if (isset ($_POST['nickname']))
+ $user->nickname = wp_specialchars(trim($_POST['nickname']));
+ if (isset ($_POST['display_name']))
+ $user->display_name = wp_specialchars(trim($_POST['display_name']));
+ if (isset ($_POST['description']))
+ $user->description = wp_specialchars(trim($_POST['description']));
+ if (isset ($_POST['jabber']))
+ $user->jabber = wp_specialchars(trim($_POST['jabber']));
+ if (isset ($_POST['aim']))
+ $user->aim = wp_specialchars(trim($_POST['aim']));
+ if (isset ($_POST['yim']))
+ $user->yim = wp_specialchars(trim($_POST['yim']));
+
+ $errors = new WP_Error();
+
+ /* checking that username has been typed */
+ if ($user->user_login == '')
+ $errors->add('user_login', __('<strong>ERROR</strong>: Please enter a username.'));
+
+ /* checking the password has been typed twice */
+ do_action('check_passwords', array ($user->user_login, & $pass1, & $pass2));
+
+ if (!$update) {
+ if ($pass1 == '' || $pass2 == '')
+ $errors->add('pass', __('<strong>ERROR</strong>: Please enter your password twice.'));
+ } else {
+ if ((empty ($pass1) && !empty ($pass2)) || (empty ($pass2) && !empty ($pass1)))
+ $errors->add('pass', __("<strong>ERROR</strong>: you typed your new password only once."));
+ }
+
+ /* Check for "\" in password */
+ if( strpos( " ".$pass1, "\\" ) )
+ $errors->add('pass', __('<strong>ERROR</strong>: Passwords may not contain the character "\\".'));
+
+ /* checking the password has been typed twice the same */
+ if ($pass1 != $pass2)
+ $errors->add('pass', __('<strong>ERROR</strong>: Please type the same password in the two password fields.'));
+
+ if (!empty ($pass1))
+ $user->user_pass = $pass1;
+
+ if ( !validate_username($user->user_login) )
+ $errors->add('user_login', __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.'));
+
+ if (!$update && username_exists($user->user_login))
+ $errors->add('user_login', __('<strong>ERROR</strong>: This username is already registered, please choose another one.'));
+
+ /* checking e-mail address */
+ if (empty ($user->user_email)) {
+ $errors->add('user_email', __("<strong>ERROR</strong>: please type an e-mail address"));
+ } else
+ if (!is_email($user->user_email)) {
+ $errors->add('user_email', __("<strong>ERROR</strong>: the email address isn't correct"));
+ }
+
+ if ( $errors->get_error_codes() )
+ return $errors;
+
+ if ($update) {
+ $user_id = wp_update_user(get_object_vars($user));
+ } else {
+ $user_id = wp_insert_user(get_object_vars($user));
+ wp_new_user_notification($user_id);
+ }
+ return $user_id;
+}
+
+
+function get_link_to_edit($link_id) {
+ $link = get_link($link_id);
+
+ $link->link_url = wp_specialchars($link->link_url, 1);
+ $link->link_name = wp_specialchars($link->link_name, 1);
+ $link->link_description = wp_specialchars($link->link_description);
+ $link->link_notes = wp_specialchars($link->link_notes);
+ $link->link_rss = wp_specialchars($link->link_rss);
+ $link->post_category = $link->link_category;
+
+ return $link;
+}
+
+function get_default_link_to_edit() {
+ if ( isset($_GET['linkurl']) )
+ $link->link_url = wp_specialchars($_GET['linkurl'], 1);
+ else
+ $link->link_url = '';
+
+ if ( isset($_GET['name']) )
+ $link->link_name = wp_specialchars($_GET['name'], 1);
+ else
+ $link->link_name = '';
+
+ $link->link_visible = 'Y';
+
+ return $link;
+}
+
+function add_link() {
+ return edit_link();
+}
+
+function edit_link($link_id = '') {
+ if (!current_user_can('manage_links'))
+ die(__("Cheatin' uh ?"));
+
+ $_POST['link_url'] = wp_specialchars($_POST['link_url']);
+ $_POST['link_url'] = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $_POST['link_url']) ? $_POST['link_url'] : 'http://' . $_POST['link_url'];
+ $_POST['link_name'] = wp_specialchars($_POST['link_name']);
+ $_POST['link_image'] = wp_specialchars($_POST['link_image']);
+ $_POST['link_rss'] = wp_specialchars($_POST['link_rss']);
+ $_POST['link_category'] = $_POST['post_category'];
+
+ if ( !empty($link_id) ) {
+ $_POST['link_id'] = $link_id;
+ return wp_update_link($_POST);
+ } else {
+ return wp_insert_link($_POST);
+ }
+}
+
+function url_shorten($url) {
+ $short_url = str_replace('http://', '', stripslashes($url));
+ $short_url = str_replace('www.', '', $short_url);
+ if ('/' == substr($short_url, -1))
+ $short_url = substr($short_url, 0, -1);
+ if (strlen($short_url) > 35)
+ $short_url = substr($short_url, 0, 32).'...';
+ return $short_url;
+}
+
+function selected($selected, $current) {
+ if ($selected == $current)
+ echo ' selected="selected"';
+}
+
+function checked($checked, $current) {
+ if ($checked == $current)
+ echo ' checked="checked"';
+}
+
+function return_categories_list($parent = 0) {
+ global $wpdb;
+ return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY category_count DESC");
+}
+
+function sort_cats($cat1, $cat2) {
+ return strcasecmp($cat1['cat_name'], $cat2['cat_name']);
+}
+
+function get_nested_categories($default = 0, $parent = 0) {
+ global $post_ID, $link_id, $mode, $wpdb;
+
+ if ($post_ID) {
+ $checked_categories = $wpdb->get_col("
+ SELECT category_id
+ FROM $wpdb->categories, $wpdb->post2cat
+ WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$post_ID'
+ ");
+
+ if (count($checked_categories) == 0) {
+ // No selected categories, strange
+ $checked_categories[] = $default;
+ }
+ } else if ($link_id) {
+ $checked_categories = $wpdb->get_col("
+ SELECT category_id
+ FROM $wpdb->categories, $wpdb->link2cat
+ WHERE $wpdb->link2cat.category_id = cat_ID AND $wpdb->link2cat.link_id = '$link_id'
+ ");
+
+ if (count($checked_categories) == 0) {
+ // No selected categories, strange
+ $checked_categories[] = $default;
+ }
+ } else {
+ $checked_categories[] = $default;
+ }
+
+ $cats = return_categories_list($parent);
+ $result = array ();
+
+ if (is_array($cats)) {
+ foreach ($cats as $cat) {
+ if ( $cat == 0 ) { // HACK, added 2006-05-13
+ $wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = 0");
+ continue;
+ }
+ $result[$cat]['children'] = get_nested_categories($default, $cat);
+ $result[$cat]['cat_ID'] = $cat;
+ $result[$cat]['checked'] = in_array($cat, $checked_categories);
+ $result[$cat]['cat_name'] = get_the_category_by_ID($cat);
+ }
+ }
+
+ usort($result, 'sort_cats');
+
+ return $result;
+}
+
+function write_nested_categories($categories) {
+ foreach ($categories as $category) {
+ echo '<li id="category-', $category['cat_ID'], '"><label for="in-category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="in-category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : ""), '/> ', wp_specialchars($category['cat_name']), "</label></li>\n";
+
+ if ( $category['children'] ) {
+ echo "<ul>\n";
+ write_nested_categories($category['children']);
+ echo "</ul>\n";
+ }
+ }
+}
+
+function dropdown_categories($default = 0) {
+ write_nested_categories(get_nested_categories($default));
+}
+
+// Dandy new recursive multiple category stuff.
+function cat_rows($parent = 0, $level = 0, $categories = 0) {
+ global $wpdb, $class;
+
+ if (!$categories)
+ $categories = get_categories('hide_empty=0');
+
+ if ($categories) {
+ foreach ($categories as $category) {
+ if ( $category->cat_ID == 0 ) { // HACK, added 2006-05-13
+ $wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = 0");
+ continue;
+ }
+ if ($category->category_parent == $parent) {
+ $category->cat_name = wp_specialchars($category->cat_name,'double');
+ $pad = str_repeat('&#8212; ', $level);
+ if ( current_user_can('manage_categories') ) {
+ $edit = "<a href='categories.php?action=edit&amp;cat_ID=$category->cat_ID' class='edit'>".__('Edit')."</a></td>";
+ $default_cat_id = get_option('default_category');
+ $default_link_cat_id = get_option('default_link_category');
+
+ if ( ($category->cat_ID != $default_cat_id) && ($category->cat_ID != $default_link_cat_id) )
+ $edit .= "<td><a href='" . wp_nonce_url("categories.php?action=delete&amp;cat_ID=$category->cat_ID", 'delete-category_' . $category->cat_ID ) . "' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '" . sprintf(__("You are about to delete the category &quot;%s&quot;.\\nAll of its posts will go into the default category of &quot;%s&quot;\\nAll of its bookmarks will go into the default category of &quot;%s&quot;.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), addslashes($category->cat_name), js_escape(get_catname($default_cat_id)), js_escape(get_catname($default_link_cat_id))) . "' );\" class='delete'>".__('Delete')."</a>";
+ else
+ $edit .= "<td style='text-align:center'>".__("Default");
+ }
+ else
+ $edit = '';
+
+ $class = ('alternate' == $class) ? '' : 'alternate';
+
+ $category->category_count = number_format( $category->category_count );
+ $category->link_count = number_format( $category->link_count );
+ echo "<tr id='cat-$category->cat_ID' class='$class'><th scope='row'>$category->cat_ID</th><td>$pad $category->cat_name</td>
+ <td>$category->category_description</td>
+ <td align='center'>$category->category_count</td>
+ <td align='center'>$category->link_count</td>
+ <td>$edit</td>
+ </tr>";
+ cat_rows($category->cat_ID, $level +1, $categories);
+ }
+ }
+ } else {
+ return false;
+ }
+}
+
+function page_rows($parent = 0, $level = 0, $pages = 0, $hierarchy = true) {
+ global $wpdb, $class, $post;
+
+ if (!$pages)
+ $pages = get_pages('sort_column=menu_order');
+
+ if (! $pages)
+ return false;
+
+ foreach ($pages as $post) {
+ setup_postdata($post);
+ if ( $hierarchy && ($post->post_parent != $parent) )
+ continue;
+
+ $post->post_title = wp_specialchars($post->post_title);
+ $pad = str_repeat('&#8212; ', $level);
+ $id = $post->ID;
+ $class = ('alternate' == $class) ? '' : 'alternate';
+?>
+ <tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'>
+ <th scope="row"><?php echo $post->ID; ?></th>
+ <td>
+ <?php echo $pad; ?><?php the_title() ?>
+ <?php if ('private' == $post->post_status) _e(' - <strong>Private</strong>'); ?></td>
+ </td>
+ <td><?php the_author() ?></td>
+ <td><?php echo mysql2date('Y-m-d g:i a', $post->post_modified); ?></td>
+ <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
+ <td><?php if ( current_user_can('edit_page', $id) ) { echo "<a href='page.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
+ <td><?php if ( current_user_can('edit_page', $id) ) { echo "<a href='" . wp_nonce_url("page.php?action=delete&amp;post=$id", 'delete-page_' . $id) . "' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the &quot;%s&quot; page.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), addslashes(wp_specialchars(get_the_title(),'double')) ) . "' );\">" . __('Delete') . "</a>"; } ?></td>
+ </tr>
+
+<?php
+ if ( $hierarchy) page_rows($id, $level + 1, $pages);
+ }
+}
+
+function user_row( $user_object, $style = '' ) {
+ global $current_user;
+
+ if ( !(is_object($user_object) && is_a($user_object, 'WP_User')) )
+ $user_object = new WP_User( (int) $user_object );
+ $email = $user_object->user_email;
+ if( $current_user->ID != $user_object->ID && is_site_admin() == false )
+ $email = "N/A";
+ $url = $user_object->user_url;
+ $short_url = str_replace('http://', '', $url);
+ $short_url = str_replace('www.', '', $short_url);
+ if ('/' == substr($short_url, -1))
+ $short_url = substr($short_url, 0, -1);
+ if (strlen($short_url) > 35)
+ $short_url = substr($short_url, 0, 32).'...';
+ $numposts = get_usernumposts($user_object->ID);
+ $r = "<tr id='user-$user_object->ID'$style>
+ <td><input type='checkbox' name='users[]' id='user_{$user_object->ID}' value='{$user_object->ID}' /> <label for='user_{$user_object->ID}'>{$user_object->ID}</label></td>
+ <td><label for='user_{$user_object->ID}'><strong>$user_object->user_login</strong></label></td>
+ <td><label for='user_{$user_object->ID}'>$user_object->first_name $user_object->last_name</label></td>
+ <td><a href='mailto:$email' title='" . sprintf(__('e-mail: %s'), $email) . "'>$email</a></td>
+ <td><a href='$url' title='website: $url'>$short_url</a></td>";
+ $r .= "\n\t\t<td align='center'>";
+ if ($numposts > 0) {
+ $r .= "<a href='edit.php?author=$user_object->ID' title='" . __('View posts by this author') . "' class='edit'>";
+ $r .= sprintf(__('View %1$s %2$s'), $numposts, __ngettext('post', 'posts', $numposts));
+ }
+ $r .= "</td>\n\t\t<td>";
+ $edit_link = add_query_arg('wp_http_referer', wp_specialchars(urlencode(stripslashes($_SERVER['REQUEST_URI']))), "user-edit.php?user_id=$user_object->ID");
+ if ( ( is_site_admin() || $current_user->ID == $user_object->ID ) && current_user_can('edit_user', $user_object->ID) )
+ $r .= "<a href='$edit_link' class='edit'>".__('Edit')."</a>";
+ $r .= "</td>\n\t</tr>";
+ return $r;
+}
+
+function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0) {
+ global $wpdb;
+ if (!$categories)
+ $categories = get_categories('hide_empty=0');
+
+ if ($categories) {
+ foreach ($categories as $category) {
+ if ($currentcat != $category->cat_ID && $parent == $category->category_parent) {
+ $pad = str_repeat('&#8211; ', $level);
+ $category->cat_name = wp_specialchars($category->cat_name);
+ echo "\n\t<option value='$category->cat_ID'";
+ if ($currentparent == $category->cat_ID)
+ echo " selected='selected'";
+ echo ">$pad$category->cat_name</option>";
+ wp_dropdown_cats($currentcat, $currentparent, $category->cat_ID, $level +1, $categories);
+ }
+ }
+ } else {
+ return false;
+ }
+}
+
+function return_link_categories_list($parent = 0) {
+ global $wpdb;
+ return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY link_count DESC");
+}
+
+function wp_create_thumbnail($file, $max_side, $effect = '') {
+
+ // 1 = GIF, 2 = JPEG, 3 = PNG
+
+ if (file_exists($file)) {
+ $type = getimagesize($file);
+
+ // if the associated function doesn't exist - then it's not
+ // handle. duh. i hope.
+
+ if (!function_exists('imagegif') && $type[2] == 1) {
+ $error = __('Filetype not supported. Thumbnail not created.');
+ }
+ elseif (!function_exists('imagejpeg') && $type[2] == 2) {
+ $error = __('Filetype not supported. Thumbnail not created.');
+ }
+ elseif (!function_exists('imagepng') && $type[2] == 3) {
+ $error = __('Filetype not supported. Thumbnail not created.');
+ } else {
+
+ // create the initial copy from the original file
+ if ($type[2] == 1) {
+ $image = imagecreatefromgif($file);
+ }
+ elseif ($type[2] == 2) {
+ $image = imagecreatefromjpeg($file);
+ }
+ elseif ($type[2] == 3) {
+ $image = imagecreatefrompng($file);
+ }
+
+ if (function_exists('imageantialias'))
+ imageantialias($image, TRUE);
+
+ $image_attr = getimagesize($file);
+
+ // figure out the longest side
+
+ if ($image_attr[0] > $image_attr[1]) {
+ $image_width = $image_attr[0];
+ $image_height = $image_attr[1];
+ $image_new_width = $max_side;
+
+ $image_ratio = $image_width / $image_new_width;
+ $image_new_height = $image_height / $image_ratio;
+ //width is > height
+ } else {
+ $image_width = $image_attr[0];
+ $image_height = $image_attr[1];
+ $image_new_height = $max_side;
+
+ $image_ratio = $image_height / $image_new_height;
+ $image_new_width = $image_width / $image_ratio;
+ //height > width
+ }
+
+ $thumbnail = imagecreatetruecolor($image_new_width, $image_new_height);
+ @ imagecopyresampled($thumbnail, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $image_attr[0], $image_attr[1]);
+
+ // If no filters change the filename, we'll do a default transformation.
+ if ( basename($file) == $thumb = apply_filters('thumbnail_filename', basename($file)) )
+ $thumb = preg_replace('!(\.[^.]+)?$!', __('.thumbnail').'$1', basename($file), 1);
+
+ $thumbpath = str_replace(basename($file), $thumb, $file);
+
+ // move the thumbnail to it's final destination
+ if ($type[2] == 1) {
+ if (!imagegif($thumbnail, $thumbpath)) {
+ $error = __("Thumbnail path invalid");
+ }
+ }
+ elseif ($type[2] == 2) {
+ if (!imagejpeg($thumbnail, $thumbpath)) {
+ $error = __("Thumbnail path invalid");
+ }
+ }
+ elseif ($type[2] == 3) {
+ if (!imagepng($thumbnail, $thumbpath)) {
+ $error = __("Thumbnail path invalid");
+ }
+ }
+
+ }
+ } else {
+ $error = __('File not found');
+ }
+
+ if (!empty ($error)) {
+ return $error;
+ } else {
+ return $thumbpath;
+ }
+}
+
+// Some postmeta stuff
+function has_meta($postid) {
+ global $wpdb;
+
+ return $wpdb->get_results("
+ SELECT meta_key, meta_value, meta_id, post_id
+ FROM $wpdb->postmeta
+ WHERE post_id = '$postid'
+ ORDER BY meta_key,meta_id", ARRAY_A);
+
+}
+
+function list_meta($meta) {
+ global $post_ID;
+ // Exit if no meta
+ if (!$meta) {
+ echo '<tbody id="the-list"></tbody>'; //TBODY needed for list-manipulation JS
+ return;
+ }
+ $count = 0;
+?>
+ <thead>
+ <tr>
+ <th><?php _e('Key') ?></th>
+ <th><?php _e('Value') ?></th>
+ <th colspan='2'><?php _e('Action') ?></th>
+ </tr>
+ </thead>
+<?php
+ $r ="\n\t<tbody id='the-list'>";
+ foreach ($meta as $entry) {
+ ++ $count;
+ if ($count % 2)
+ $style = 'alternate';
+ else
+ $style = '';
+ if ('_' == $entry['meta_key'] { 0 })
+ $style .= ' hidden';
+ $key_js = addslashes(wp_specialchars( $entry['meta_key'], 'double' ));
+ $entry['meta_key'] = wp_specialchars( $entry['meta_key'], true );
+ $entry['meta_value'] = wp_specialchars( $entry['meta_value'], true );
+ $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";
+ $r .= "\n\t\t<td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td>";
+ $r .= "\n\t\t<td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>";
+ $r .= "\n\t\t<td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".__('Update')."' /><br />";
+ $r .= "\n\t\t<input name='deletemeta[{$entry['meta_id']}]' type='submit' onclick=\"return deleteSomething( 'meta', {$entry['meta_id']}, '";
+ $r .= sprintf(__("You are about to delete the &quot;%s&quot; custom field on this post.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), $key_js);
+ $r .= "' );\" class='deletemeta' tabindex='6' value='".__('Delete')."' /></td>";
+ $r .= "\n\t</tr>";
+ }
+ echo $r;
+ echo "\n\t</tbody>";
+}
+
+// Get a list of previously defined keys
+function get_meta_keys() {
+ global $wpdb;
+
+ $keys = $wpdb->get_col("
+ SELECT meta_key
+ FROM $wpdb->postmeta
+ GROUP BY meta_key
+ ORDER BY meta_key");
+
+ return $keys;
+}
+
+function meta_form() {
+ global $wpdb;
+ $keys = $wpdb->get_col("
+ SELECT meta_key
+ FROM $wpdb->postmeta
+ GROUP BY meta_key
+ ORDER BY meta_id DESC
+ LIMIT 10");
+?>
+<h3><?php _e('Add a new custom field:') ?></h3>
+<table id="newmeta" cellspacing="3" cellpadding="3">
+ <tr>
+<th colspan="2"><?php _e('Key') ?></th>
+<th><?php _e('Value') ?></th>
+</tr>
+ <tr valign="top">
+ <td align="right" width="18%">
+<?php if ($keys) : ?>
+<select id="metakeyselect" name="metakeyselect" tabindex="7">
+<option value="#NONE#"><?php _e('- Select -'); ?></option>
+<?php
+
+ foreach ($keys as $key) {
+ echo "\n\t<option value='$key'>$key</option>";
+ }
+?>
+</select> <?php _e('or'); ?>
+<?php endif; ?>
+</td>
+<td><input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" /></td>
+ <td><textarea id="metavalue" name="metavalue" rows="3" cols="25" tabindex="8"></textarea></td>
+ </tr>
+
+</table>
+<p class="submit"><input type="submit" id="updatemetasub" name="updatemeta" tabindex="9" value="<?php _e('Add Custom Field &raquo;') ?>" /></p>
+<?php
+
+}
+
+function add_meta($post_ID) {
+ global $wpdb;
+ $post_ID = (int) $post_ID;
+
+ $metakeyselect = $wpdb->escape(stripslashes(trim($_POST['metakeyselect'])));
+ $metakeyinput = $wpdb->escape(stripslashes(trim($_POST['metakeyinput'])));
+ $metavalue = $wpdb->escape(stripslashes(trim($_POST['metavalue'])));
+
+ if ( ('0' === $metavalue || !empty ($metavalue)) && ((('#NONE#' != $metakeyselect) && !empty ($metakeyselect)) || !empty ($metakeyinput)) ) {
+ // We have a key/value pair. If both the select and the
+ // input for the key have data, the input takes precedence:
+
+ if ('#NONE#' != $metakeyselect)
+ $metakey = $metakeyselect;
+
+ if ($metakeyinput)
+ $metakey = $metakeyinput; // default
+
+ $result = $wpdb->query("
+ INSERT INTO $wpdb->postmeta
+ (post_id,meta_key,meta_value)
+ VALUES ('$post_ID','$metakey','$metavalue')
+ ");
+ return $wpdb->insert_id;
+ }
+ return false;
+} // add_meta
+
+function delete_meta($mid) {
+ global $wpdb;
+ $mid = (int) $mid;
+
+ return $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'");
+}
+
+function update_meta($mid, $mkey, $mvalue) {
+ global $wpdb;
+ $mid = (int) $mid;
+
+ return $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'");
+}
+
+function get_post_meta_by_id($mid) {
+ global $wpdb;
+ $mid = (int) $mid;
+
+ return $wpdb->get_row("SELECT * FROM $wpdb->postmeta WHERE meta_id = '$mid'");
+}
+
+function touch_time($edit = 1, $for_post = 1) {
+ global $wp_locale, $post, $comment;
+
+ if ( $for_post )
+ $edit = ( ('draft' == $post->post_status) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date) ) ? false : true;
+
+ echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" /> <label for="timestamp">'.__('Edit timestamp').'</label></legend>';
+
+ $time_adj = time() + (get_settings('gmt_offset') * 3600);
+ $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
+ $jj = ($edit) ? mysql2date('d', $post_date) : gmdate('d', $time_adj);
+ $mm = ($edit) ? mysql2date('m', $post_date) : gmdate('m', $time_adj);
+ $aa = ($edit) ? mysql2date('Y', $post_date) : gmdate('Y', $time_adj);
+ $hh = ($edit) ? mysql2date('H', $post_date) : gmdate('H', $time_adj);
+ $mn = ($edit) ? mysql2date('i', $post_date) : gmdate('i', $time_adj);
+ $ss = ($edit) ? mysql2date('s', $post_date) : gmdate('s', $time_adj);
+
+ echo "<select name=\"mm\" onchange=\"edit_date.checked=true\">\n";
+ for ($i = 1; $i < 13; $i = $i +1) {
+ echo "\t\t\t<option value=\"$i\"";
+ if ($i == $mm)
+ echo ' selected="selected"';
+ echo '>' . $wp_locale->get_month($i) . "</option>\n";
+ }
+?>
+</select>
+<input type="text" id="jj" name="jj" value="<?php echo $jj; ?>" size="2" maxlength="2" onchange="edit_date.checked=true"/>
+<input type="text" id="aa" name="aa" value="<?php echo $aa ?>" size="4" maxlength="5" onchange="edit_date.checked=true" /> @
+<input type="text" id="hh" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" onchange="edit_date.checked=true" /> :
+<input type="text" id="mn" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" onchange="edit_date.checked=true" />
+<input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" onchange="edit_date.checked=true" />
+<?php
+ if ( $edit ) {
+ _e('Existing timestamp');
+ //echo ': ' . $wp_locale->get_month($mm) . "$jj, $aa @ $hh:$mn";
+ echo sprintf(__(': %1$s %2$s, %3$s @ %4$s:%5$s'), $wp_locale->get_month($mm), $jj, $aa, $hh, $mn);
+ }
+?>
+</fieldset>
+ <?php
+
+}
+
+// insert_with_markers: Owen Winkler, fixed by Eric Anderson
+// Inserts an array of strings into a file (.htaccess), placing it between
+// BEGIN and END markers. Replaces existing marked info. Retains surrounding
+// data. Creates file if none exists.
+// Returns true on write success, false on failure.
+function insert_with_markers($filename, $marker, $insertion) {
+ return true;
+ if (!file_exists($filename) || is_writeable($filename)) {
+ if (!file_exists($filename)) {
+ $markerdata = '';
+ } else {
+ $markerdata = explode("\n", implode('', file($filename)));
+ }
+
+ $f = fopen($filename, 'w');
+ $foundit = false;
+ if ($markerdata) {
+ $state = true;
+ foreach ($markerdata as $n => $markerline) {
+ if (strstr($markerline, "# BEGIN {$marker}"))
+ $state = false;
+ if ($state) {
+ if ( $n + 1 < count($markerdata) )
+ fwrite($f, "{$markerline}\n");
+ else
+ fwrite($f, "{$markerline}");
+ }
+ if (strstr($markerline, "# END {$marker}")) {
+ fwrite($f, "# BEGIN {$marker}\n");
+ if (is_array($insertion))
+ foreach ($insertion as $insertline)
+ fwrite($f, "{$insertline}\n");
+ fwrite($f, "# END {$marker}\n");
+ $state = true;
+ $foundit = true;
+ }
+ }
+ }
+ if (!$foundit) {
+ fwrite($f, "# BEGIN {$marker}\n");
+ foreach ($insertion as $insertline)
+ fwrite($f, "{$insertline}\n");
+ fwrite($f, "# END {$marker}\n");
+ }
+ fclose($f);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+// extract_from_markers: Owen Winkler
+// Returns an array of strings from a file (.htaccess) from between BEGIN
+// and END markers.
+function extract_from_markers($filename, $marker) {
+ $result = array ();
+
+ if (!file_exists($filename)) {
+ return $result;
+ }
+
+ if ($markerdata = explode("\n", implode('', file($filename))));
+ {
+ $state = false;
+ foreach ($markerdata as $markerline) {
+ if (strstr($markerline, "# END {$marker}"))
+ $state = false;
+ if ($state)
+ $result[] = $markerline;
+ if (strstr($markerline, "# BEGIN {$marker}"))
+ $state = true;
+ }
+ }
+
+ return $result;
+}
+
+function got_mod_rewrite() {
+ global $is_apache;
+
+ // take 3 educated guesses as to whether or not mod_rewrite is available
+ if ( !$is_apache )
+ return false;
+
+ if ( function_exists('apache_get_modules') ) {
+ if ( !in_array('mod_rewrite', apache_get_modules()) )
+ return false;
+ }
+
+ return true;
+}
+
+function save_mod_rewrite_rules() {
+ global $is_apache, $wp_rewrite;
+ $home_path = get_home_path();
+
+ if (!$wp_rewrite->using_mod_rewrite_permalinks())
+ return;
+
+ if (!((!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess')))
+ return;
+
+ if (! got_mod_rewrite())
+ return;
+
+ $rules = explode("\n", $wp_rewrite->mod_rewrite_rules());
+ insert_with_markers($home_path.'.htaccess', 'WordPress', $rules);
+}
+
+function the_quicktags() {
+ // Browser detection sucks, but until Safari supports the JS needed for this to work people just assume it's a bug in WP
+ if (!strstr($_SERVER['HTTP_USER_AGENT'], 'Safari')) {
+ echo '
+ <div id="quicktags">
+ ';
+ wp_print_scripts( 'quicktags' );
+ echo ' <script type="text/javascript">if ( typeof tinyMCE == "undefined" || tinyMCE.configs.length < 1 ) edToolbar();</script>
+ </div>
+';
+ } else echo '
+<script type="text/javascript">
+function edInsertContent(myField, myValue) {
+ //IE support
+ if (document.selection) {
+ myField.focus();
+ sel = document.selection.createRange();
+ sel.text = myValue;
+ myField.focus();
+ }
+ //MOZILLA/NETSCAPE support
+ else if (myField.selectionStart || myField.selectionStart == "0") {
+ var startPos = myField.selectionStart;
+ var endPos = myField.selectionEnd;
+ myField.value = myField.value.substring(0, startPos)
+ + myValue
+ + myField.value.substring(endPos, myField.value.length);
+ myField.focus();
+ myField.selectionStart = startPos + myValue.length;
+ myField.selectionEnd = startPos + myValue.length;
+ } else {
+ myField.value += myValue;
+ myField.focus();
+ }
+}
+</script>
+';
+}
+
+function validate_current_theme() {
+ $theme_loc = 'wp-content/themes';
+ $theme_root = ABSPATH.$theme_loc;
+
+ $template = get_settings('template');
+ $stylesheet = get_settings('stylesheet');
+
+ if (($template != 'default') && (!file_exists("$theme_root/$template/index.php"))) {
+ update_option('template', 'default');
+ update_option('stylesheet', 'default');
+ do_action('switch_theme', 'Default');
+ return false;
+ }
+
+ if (($stylesheet != 'default') && (!file_exists("$theme_root/$stylesheet/style.css"))) {
+ update_option('template', 'default');
+ update_option('stylesheet', 'default');
+ do_action('switch_theme', 'Default');
+ return false;
+ }
+
+ return true;
+}
+
+function get_broken_themes() {
+ global $wp_broken_themes;
+
+ get_themes();
+ return $wp_broken_themes;
+}
+
+function get_page_templates() {
+ $themes = get_themes();
+ $theme = get_current_theme();
+ $templates = $themes[$theme]['Template Files'];
+ $page_templates = array ();
+
+ if (is_array($templates)) {
+ foreach ($templates as $template) {
+ $template_data = implode('', file(ABSPATH.$template));
+ preg_match("|Template Name:(.*)|i", $template_data, $name);
+ preg_match("|Description:(.*)|i", $template_data, $description);
+
+ $name = $name[1];
+ $description = $description[1];
+
+ if (!empty ($name)) {
+ $page_templates[trim($name)] = basename($template);
+ }
+ }
+ }
+
+ return $page_templates;
+}
+
+function page_template_dropdown($default = '') {
+ $templates = get_page_templates();
+ foreach (array_keys($templates) as $template)
+ : if ($default == $templates[$template])
+ $selected = " selected='selected'";
+ else
+ $selected = '';
+ echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>";
+ endforeach;
+}
+
+function parent_dropdown($default = 0, $parent = 0, $level = 0) {
+ global $wpdb, $post_ID;
+ $items = $wpdb->get_results("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_type = 'page' ORDER BY menu_order");
+
+ if ($items) {
+ foreach ($items as $item) {
+ // A page cannot be it's own parent.
+ if (!empty ($post_ID)) {
+ if ($item->ID == $post_ID) {
+ continue;
+ }
+ }
+ $pad = str_repeat('&nbsp;', $level * 3);
+ if ($item->ID == $default)
+ $current = ' selected="selected"';
+ else
+ $current = '';
+
+ echo "\n\t<option value='$item->ID'$current>$pad $item->post_title</option>";
+ parent_dropdown($default, $item->ID, $level +1);
+ }
+ } else {
+ return false;
+ }
+}
+
+function user_can_access_admin_page() {
+ global $pagenow;
+ global $menu;
+ global $submenu;
+ global $menu_nopriv;
+
+ $parent = get_admin_page_parent();
+
+ if ( isset($menu_nopriv[$pagenow]) )
+ return false;
+
+ if ( empty($parent) )
+ return true;
+
+ if (isset ($submenu[$parent])) {
+ foreach ($submenu[$parent] as $submenu_array) {
+ if ($submenu_array[2] == $pagenow) {
+ if (current_user_can($submenu_array[1]))
+ return true;
+ else
+ return false;
+ }
+ }
+ }
+
+ foreach ($menu as $menu_array) {
+ //echo "parent array: " . $menu_array[2];
+ if ($menu_array[2] == $parent) {
+ if (current_user_can($menu_array[1]))
+ return true;
+ else
+ return false;
+ }
+ }
+
+ return true;
+}
+
+function get_admin_page_title() {
+ global $title;
+ global $menu;
+ global $submenu;
+ global $pagenow;
+ global $plugin_page;
+
+ if (isset ($title) && !empty ($title)) {
+ return $title;
+ }
+
+ $hook = get_plugin_page_hook($plugin_page, $pagenow);
+
+ $parent = $parent1 = get_admin_page_parent();
+ if (empty ($parent)) {
+ foreach ($menu as $menu_array) {
+ if (isset ($menu_array[3])) {
+ if ($menu_array[2] == $pagenow) {
+ $title = $menu_array[3];
+ return $menu_array[3];
+ } else
+ if (isset ($plugin_page) && ($plugin_page == $menu_array[2]) && ($hook == $menu_array[3])) {
+ $title = $menu_array[3];
+ return $menu_array[3];
+ }
+ }
+ }
+ } else {
+ foreach (array_keys($submenu) as $parent) {
+ foreach ($submenu[$parent] as $submenu_array) {
+ if (isset ($submenu_array[3])) {
+ if ($submenu_array[2] == $pagenow) {
+ $title = $submenu_array[3];
+ return $submenu_array[3];
+ } else
+ if (isset ($plugin_page) && ($plugin_page == $submenu_array[2]) && (($parent == $pagenow) || ($parent == $plugin_page) || ($plugin_page == $hook) || (($pagenow == 'admin.php') && ($parent1 != $submenu_array[2])))) {
+ $title = $submenu_array[3];
+ return $submenu_array[3];
+ }
+ }
+ }
+ }
+ }
+
+ return '';
+}
+
+function get_admin_page_parent() {
+ global $parent_file;
+ global $menu;
+ global $submenu;
+ global $pagenow;
+ global $plugin_page;
+ global $real_parent_file;
+
+ if ( !empty ($parent_file) ) {
+ if ( isset($real_parent_file[$parent_file]) )
+ $parent_file = $real_parent_file[$parent_file];
+
+ return $parent_file;
+ }
+
+ if ($pagenow == 'admin.php' && isset ($plugin_page)) {
+ foreach ($menu as $parent_menu) {
+ if ($parent_menu[2] == $plugin_page) {
+ $parent_file = $plugin_page;
+ if ( isset($real_parent_file[$parent_file]) )
+ $parent_file = $real_parent_file[$parent_file];
+
+ return $parent_file;
+ }
+ }
+ }
+
+ foreach (array_keys($submenu) as $parent) {
+ foreach ($submenu[$parent] as $submenu_array) {
+ if ( isset($real_parent_file[$parent]) )
+ $parent = $real_parent_file[$parent];
+ if ($submenu_array[2] == $pagenow) {
+ $parent_file = $parent;
+ return $parent;
+ } else
+ if (isset ($plugin_page) && ($plugin_page == $submenu_array[2])) {
+ $parent_file = $parent;
+ return $parent;
+ }
+ }
+ }
+
+ $parent_file = '';
+ return '';
+}
+
+function add_menu_page($page_title, $menu_title, $access_level, $file, $function = '') {
+ global $menu, $admin_page_hooks;
+
+ $file = plugin_basename($file);
+
+ $menu[] = array ($menu_title, $access_level, $file, $page_title);
+
+ $admin_page_hooks[$file] = sanitize_title($menu_title);
+
+ $hookname = get_plugin_page_hookname($file, '');
+ if (!empty ($function) && !empty ($hookname))
+ add_action($hookname, $function);
+
+ return $hookname;
+}
+
+function add_submenu_page($parent, $page_title, $menu_title, $access_level, $file, $function = '') {
+ global $submenu;
+ global $menu;
+ global $real_parent_file;
+
+ $parent = plugin_basename($parent);
+ if ( isset($real_parent_file[$parent]) )
+ $parent = $real_parent_file[$parent];
+
+ $file = plugin_basename($file);
+
+ // If the parent doesn't already have a submenu, add a link to the parent
+ // as the first item in the submenu. If the submenu file is the same as the
+ // parent file someone is trying to link back to the parent manually. In
+ // this case, don't automatically add a link back to avoid duplication.
+ if (!isset ($submenu[$parent]) && $file != $parent) {
+ foreach ($menu as $parent_menu) {
+ if ($parent_menu[2] == $parent) {
+ $submenu[$parent][] = $parent_menu;
+ }
+ }
+ }
+
+ $submenu[$parent][] = array ($menu_title, $access_level, $file, $page_title);
+
+ $hookname = get_plugin_page_hookname($file, $parent);
+ if (!empty ($function) && !empty ($hookname))
+ add_action($hookname, $function);
+
+ return $hookname;
+}
+
+function add_options_page($page_title, $menu_title, $access_level, $file, $function = '') {
+ return add_submenu_page('options-general.php', $page_title, $menu_title, $access_level, $file, $function);
+}
+
+function add_management_page($page_title, $menu_title, $access_level, $file, $function = '') {
+ return add_submenu_page('edit.php', $page_title, $menu_title, $access_level, $file, $function);
+}
+
+function add_theme_page($page_title, $menu_title, $access_level, $file, $function = '') {
+ return add_submenu_page('themes.php', $page_title, $menu_title, $access_level, $file, $function);
+}
+
+function validate_file($file, $allowed_files = '') {
+ if (false !== strpos($file, './'))
+ return 1;
+
+ if (':' == substr($file, 1, 1))
+ return 2;
+
+ if (!empty ($allowed_files) && (!in_array($file, $allowed_files)))
+ return 3;
+
+ return 0;
+}
+
+function validate_file_to_edit($file, $allowed_files = '') {
+ $file = stripslashes($file);
+
+ $code = validate_file($file, $allowed_files);
+
+ if (!$code)
+ return $file;
+
+ switch ($code) {
+ case 1 :
+ die(__('Sorry, can&#8217;t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.'));
+
+ case 2 :
+ die(__('Sorry, can&#8217;t call files with their real path.'));
+
+ case 3 :
+ die(__('Sorry, that file cannot be edited.'));
+ }
+}
+
+function get_home_path() {
+ $home = get_settings('home');
+ if ($home != '' && $home != get_settings('siteurl')) {
+ $home_path = parse_url($home);
+ $home_path = $home_path['path'];
+ $root = str_replace($_SERVER["PHP_SELF"], '', $_SERVER["SCRIPT_FILENAME"]);
+ $home_path = trailingslashit($root.$home_path);
+ } else {
+ $home_path = ABSPATH;
+ }
+
+ return $home_path;
+}
+
+function get_real_file_to_edit($file) {
+ if ('index.php' == $file || '.htaccess' == $file) {
+ $real_file = get_home_path().$file;
+ } else {
+ $real_file = ABSPATH.$file;
+ }
+
+ return $real_file;
+}
+
+$wp_file_descriptions = array ('index.php' => __('Main Index Template'), 'style.css' => __('Stylesheet'), 'comments.php' => __('Comments'), 'comments-popup.php' => __('Popup Comments'), 'footer.php' => __('Footer'), 'header.php' => __('Header'), 'sidebar.php' => __('Sidebar'), 'archive.php' => __('Archives'), 'category.php' => __('Category Template'), 'page.php' => __('Page Template'), 'search.php' => __('Search Results'), 'single.php' => __('Single Post'), '404.php' => __('404 Template'), 'my-hacks.php' => __('my-hacks.php (legacy hacks support)'), '.htaccess' => __('.htaccess (for rewrite rules)'),
+ // Deprecated files
+ 'wp-layout.css' => __('Stylesheet'), 'wp-comments.php' => __('Comments Template'), 'wp-comments-popup.php' => __('Popup Comments Template'));
+
+function get_file_description($file) {
+ global $wp_file_descriptions;
+
+ if (isset ($wp_file_descriptions[basename($file)])) {
+ return $wp_file_descriptions[basename($file)];
+ }
+ elseif ( file_exists( ABSPATH . $file ) && is_file( ABSPATH . $file ) ) {
+ $template_data = implode('', file( ABSPATH . $file ));
+ if (preg_match("|Template Name:(.*)|i", $template_data, $name))
+ return $name[1];
+ }
+
+ return basename($file);
+}
+
+function update_recently_edited($file) {
+ $oldfiles = (array) get_option('recently_edited');
+ if ($oldfiles) {
+ $oldfiles = array_reverse($oldfiles);
+ $oldfiles[] = $file;
+ $oldfiles = array_reverse($oldfiles);
+ $oldfiles = array_unique($oldfiles);
+ if (5 < count($oldfiles))
+ array_pop($oldfiles);
+ } else {
+ $oldfiles[] = $file;
+ }
+ update_option('recently_edited', $oldfiles);
+}
+
+function get_plugin_data($plugin_file) {
+ $plugin_data = implode('', file($plugin_file));
+ preg_match("|Plugin Name:(.*)|i", $plugin_data, $plugin_name);
+ preg_match("|Plugin URI:(.*)|i", $plugin_data, $plugin_uri);
+ preg_match("|Description:(.*)|i", $plugin_data, $description);
+ preg_match("|Author:(.*)|i", $plugin_data, $author_name);
+ preg_match("|Author URI:(.*)|i", $plugin_data, $author_uri);
+ if (preg_match("|Version:(.*)|i", $plugin_data, $version))
+ $version = $version[1];
+ else
+ $version = '';
+
+ $description = wptexturize($description[1]);
+
+ $name = $plugin_name[1];
+ $name = trim($name);
+ $plugin = $name;
+ if ('' != $plugin_uri[1] && '' != $name) {
+ $plugin = '<a href="'.$plugin_uri[1].'" title="'.__('Visit plugin homepage').'">'.$plugin.'</a>';
+ }
+
+ if ('' == $author_uri[1]) {
+ $author = $author_name[1];
+ } else {
+ $author = '<a href="'.$author_uri[1].'" title="'.__('Visit author homepage').'">'.$author_name[1].'</a>';
+ }
+
+ return array ('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1]);
+}
+
+function get_plugins() {
+ global $wp_plugins;
+
+ if (isset ($wp_plugins)) {
+ return $wp_plugins;
+ }
+
+ $wp_plugins = array ();
+ $plugin_loc = 'wp-content/plugins';
+ $plugin_root = ABSPATH.$plugin_loc;
+
+ // Files in wp-content/plugins directory
+ $plugins_dir = @ dir($plugin_root);
+ if ($plugins_dir) {
+ while (($file = $plugins_dir->read()) !== false) {
+ if (preg_match('|^\.+$|', $file))
+ 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))
+ continue;
+ if (preg_match('|\.php$|', $subfile))
+ $plugin_files[] = "$file/$subfile";
+ }
+ }
+ } else {
+ if (preg_match('|\.php$|', $file))
+ $plugin_files[] = $file;
+ }
+ }
+ }
+
+ if (!$plugins_dir || !$plugin_files) {
+ return $wp_plugins;
+ }
+
+ sort($plugin_files);
+
+ foreach ($plugin_files as $plugin_file) {
+ if ( !is_readable("$plugin_root/$plugin_file"))
+ continue;
+
+ $plugin_data = get_plugin_data("$plugin_root/$plugin_file");
+
+ if (empty ($plugin_data['Name'])) {
+ continue;
+ }
+
+ $wp_plugins[plugin_basename($plugin_file)] = $plugin_data;
+ }
+
+ return $wp_plugins;
+}
+
+function get_plugin_page_hookname($plugin_page, $parent_page) {
+ global $admin_page_hooks;
+
+ $parent = get_admin_page_parent();
+
+ if (empty ($parent_page) || 'admin.php' == $parent_page) {
+ if (isset ($admin_page_hooks[$plugin_page]))
+ $page_type = 'toplevel';
+ else
+ if (isset ($admin_page_hooks[$parent]))
+ $page_type = $admin_page_hooks[$parent];
+ } else
+ if (isset ($admin_page_hooks[$parent_page])) {
+ $page_type = $admin_page_hooks[$parent_page];
+ } else {
+ $page_type = 'admin';
+ }
+
+ $plugin_name = preg_replace('!\.php!', '', $plugin_page);
+
+ return $page_type.'_page_'.$plugin_name;
+}
+
+function get_plugin_page_hook($plugin_page, $parent_page) {
+ global $wp_filter;
+
+ $hook = get_plugin_page_hookname($plugin_page, $parent_page);
+ if (isset ($wp_filter[$hook]))
+ return $hook;
+ else
+ return '';
+}
+
+function browse_happy() {
+ $getit = __('WordPress recommends a better browser');
+ echo '
+ <p id="bh" style="text-align: center;"><a href="http://browsehappy.com/" title="'.$getit.'"><img src="images/browse-happy.gif" alt="Browse Happy" /></a></p>
+ ';
+}
+if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE'))
+ add_action('admin_footer', 'browse_happy');
+
+function documentation_link($for) {
+ return;
+}
+
+function register_importer($id, $name, $description, $callback) {
+ global $wp_importers;
+
+ $wp_importers[$id] = array ($name, $description, $callback);
+}
+
+function get_importers() {
+ global $wp_importers;
+
+ return $wp_importers;
+}
+
+function current_theme_info() {
+ $themes = get_themes();
+ $current_theme = get_current_theme();
+ $ct->name = $current_theme;
+ $ct->title = $themes[$current_theme]['Title'];
+ $ct->version = $themes[$current_theme]['Version'];
+ $ct->parent_theme = $themes[$current_theme]['Parent Theme'];
+ $ct->template_dir = $themes[$current_theme]['Template Dir'];
+ $ct->stylesheet_dir = $themes[$current_theme]['Stylesheet Dir'];
+ $ct->template = $themes[$current_theme]['Template'];
+ $ct->stylesheet = $themes[$current_theme]['Stylesheet'];
+ $ct->screenshot = $themes[$current_theme]['Screenshot'];
+ $ct->description = $themes[$current_theme]['Description'];
+ $ct->author = $themes[$current_theme]['Author'];
+ return $ct;
+}
+
+
+// array wp_handle_upload ( array &file [, array overrides] )
+// file: reference to a single element of $_FILES. Call the function once for each uploaded file.
+// overrides: an associative array of names=>values to override default variables with extract($overrides, EXTR_OVERWRITE).
+// On success, returns an associative array of file attributes.
+// On failure, returns $overrides['upload_error_handler'](&$file, $message) or array('error'=>$message).
+function wp_handle_upload(&$file, $overrides = false) {
+ // The default error handler.
+ if (! function_exists('wp_handle_upload_error') ) {
+ function wp_handle_upload_error(&$file, $message) {
+ return array('error'=>$message);
+ }
+ }
+
+ // You may define your own function and pass the name in $overrides['upload_error_handler']
+ $upload_error_handler = 'wp_handle_upload_error';
+
+ // $_POST['action'] must be set and its value must equal $overrides['action'] or this:
+ $action = 'wp_handle_upload';
+
+ // Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error'].
+ $upload_error_strings = array(false,
+ __("The uploaded file exceeds the <code>upload_max_filesize</code> directive in <code>php.ini</code>."),
+ __("The uploaded file exceeds the <em>MAX_FILE_SIZE</em> directive that was specified in the HTML form."),
+ __("The uploaded file was only partially uploaded."),
+ __("No file was uploaded."),
+ __("Missing a temporary folder."),
+ __("Failed to write file to disk."));
+
+ // All tests are on by default. Most can be turned off by $override[{test_name}] = false;
+ $test_form = true;
+ $test_size = true;
+
+ // If you override this, you must provide $ext and $type!!!!
+ $test_type = true;
+
+ // Install user overrides. Did we mention that this voids your warranty?
+ if ( is_array($overrides) )
+ extract($overrides, EXTR_OVERWRITE);
+
+ // A correct form post will pass this test.
+ if ( $test_form && (!isset($_POST['action']) || ($_POST['action'] != $action)) )
+ return $upload_error_handler($file, __('Invalid form submission.'));
+
+ // A successful upload will pass this test. It makes no sense to override this one.
+ if ( $file['error'] > 0 )
+ return $upload_error_handler($file, $upload_error_strings[$file['error']]);
+
+ // A non-empty file will pass this test.
+ if ( $test_size && !($file['size'] > 0) )
+ return $upload_error_handler($file, __('File is empty. Please upload something more substantial.'));
+
+ // A properly uploaded file will pass this test. There should be no reason to override this one.
+ if (! @ is_uploaded_file($file['tmp_name']) )
+ return $upload_error_handler($file, __('Specified file failed upload test.'));
+
+ // A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter.
+ if ( $test_type ) {
+ $wp_filetype = wp_check_filetype($file['name'], $mimes);
+
+ extract($wp_filetype);
+
+ if ( !$type || !$ext )
+ return $upload_error_handler($file, __('File type does not meet security guidelines. Try another.'));
+ }
+
+ // A writable uploads dir will pass this test. Again, there's no point overriding this one.
+ if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )
+ return $upload_error_handler($file, $uploads['error']);
+
+ // Increment the file number until we have a unique file to save in $dir. Use $override['unique_filename_callback'] if supplied.
+ if ( isset($unique_filename_callback) && function_exists($unique_filename_callback) ) {
+ $filename = $unique_filename_callback($uploads['path'], $file['name']);
+ } else {
+ $number = '';
+ $filename = str_replace('#', '_', $file['name']);
+ $filename = str_replace(array('\\', "'"), '', $filename);
+ if ( empty($ext) )
+ $ext = '';
+ else
+ $ext = ".$ext";
+ while ( file_exists($uploads['path'] . "/$filename") ) {
+ if ( '' == "$number$ext" )
+ $filename = $filename . ++$number . $ext;
+ else
+ $filename = str_replace("$number$ext", ++$number . $ext, $filename);
+ }
+ $filename = str_replace($ext, '', $filename);
+ $filename = sanitize_title_with_dashes($filename) . $ext;
+ }
+
+ // Move the file to the uploads dir
+ $new_file = $uploads['path'] . "/$filename";
+ if ( false === @ move_uploaded_file($file['tmp_name'], $new_file) )
+ die(printf(__('The uploaded file could not be moved to %s.'), $file['path']));
+
+ // Set correct file permissions
+ $stat = stat(dirname($new_file));
+ $perms = $stat['mode'] & 0000666;
+ @ chmod($new_file, $perms);
+
+ // Compute the URL
+ $url = $uploads['url'] . "/$filename";
+
+ $return = apply_filters( 'wp_handle_upload', array('file' => $new_file, 'url' => $url, 'type' => $type) );
+
+ return $return;
+}
+
+function wp_shrink_dimensions($width, $height, $wmax = 128, $hmax = 96) {
+ if ( $height <= $hmax && $width <= $wmax )
+ return array($width, $height);
+ elseif ( $width / $height > $wmax / $hmax )
+ return array($wmax, (int) ($height / $width * $wmax));
+ else
+ return array((int) ($width / $height * $hmax), $hmax);
+}
+
+function wp_import_cleanup($id) {
+ wp_delete_attachment($id);
+}
+
+function wp_import_upload_form($action) {
+?>
+<form enctype="multipart/form-data" id="import-upload-form" method="POST" action="<?php echo $action ?>">
+<p>
+<label for="upload"><?php _e('Choose a file from your computer:'); ?></label> <input type="file" id="upload" name="import" size="25" />
+<input type="hidden" name="action" value="save" />
+</p>
+<p class="submit">
+<input type="submit" value="<?php _e('Upload file and import'); ?> &raquo;" />
+</p>
+</form>
+<?php
+}
+
+function wp_import_handle_upload() {
+ $overrides = array('test_form' => false, 'test_type' => false);
+ $file = wp_handle_upload($_FILES['import'], $overrides);
+
+ if ( isset($file['error']) )
+ return $file;
+
+ $url = $file['url'];
+ $file = addslashes( $file['file'] );
+ $filename = basename($file);
+
+ // Construct the object array
+ $object = array(
+ 'post_title' => $filename,
+ 'post_content' => $url,
+ 'post_mime_type' => 'import',
+ 'guid' => $url
+ );
+
+ // Save the data
+ $id = wp_insert_attachment($object, $file);
+
+ return array('file' => $file, 'id' => $id);
+}
+
+function user_can_richedit() {
+ if ( 'true' != get_user_option('rich_editing') )
+ return false;
+
+ if ( preg_match('!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT']) )
+ return false;
+
+ return true; // Best guess
+}
+
+function the_attachment_links($id = false) {
+ $id = (int) $id;
+ $post = & get_post($id);
+
+ if ( $post->post_type != 'attachment' )
+ return false;
+
+ $icon = get_attachment_icon($post->ID);
+
+?>
+<p><?php _e('Text linked to file') ?><br />
+<textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid ?>" class="attachmentlink"><?php echo basename($post->guid) ?></a></textarea></p>
+<p><?php _e('Text linked to subpost') ?><br />
+<textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment" id="<?php echo $post->ID ?>"><?php echo $post->post_title ?></a></textarea></p>
+<?php if ( $icon ) : ?>
+<p><?php _e('Thumbnail linked to file') ?><br />
+<textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid ?>" class="attachmentlink"><?php echo $icon ?></a></textarea></p>
+<p><?php _e('Thumbnail linked to subpost') ?><br />
+<textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment" id="<?php echo $post->ID ?>"><?php echo $icon ?></a></textarea></p>
+<?php endif; ?>
+<?php
+}
+
+function get_udims($width, $height) {
+ if ( $height <= 96 && $width <= 128 )
+ return array($width, $height);
+ elseif ( $width / $height > 4 / 3 )
+ return array(128, (int) ($height / $width * 128));
+ else
+ return array((int) ($width / $height * 96), 96);
+}
+
+function autocomplete_css() {
+ ?>
+<style type='text/css'>
+ div.autocomplete {
+ position:absolute;
+ width:200px;
+ background-color:white;
+ border:1px solid #888;
+ margin:0px;
+ padding:0px;
+ }
+ div.autocomplete ul {
+ list-style-type:none;
+ margin:0px;
+ padding:0px;
+ }
+ div.autocomplete ul li.selected { background-color: #ffb;}
+ div.autocomplete ul li {
+ list-style-type:none;
+ display:block;
+ margin:0;
+ padding:2px;
+ height:32px;
+ cursor:pointer;
+ }
+</style>
+<?php
+}
+function autocomplete_textbox( $url, $search_field, $results_field ) {
+ ?>
+<script src="<?php echo get_option( "siteurl" ) ?>/wp-includes/js/scriptaculous/scriptaculous.js" type="text/javascript"></script>
+<script type="text/javascript">
+function load_autocompleter() {
+ new Ajax.Autocompleter("<?php echo $search_field ?>", "<?php echo $results_field ?>", "<?php echo $url ?>", {paramName: "search", minChars: 3});
+}
+addLoadEvent( load_autocompleter );
+</script>
+<?php
+}
+
+?>
diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php
new file mode 100644
index 0000000..ee0c286
--- /dev/null
+++ b/wp-admin/admin-header.php
@@ -0,0 +1,41 @@
+<?php
+@header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
+if (!isset($_GET["page"])) require_once('admin.php');
+if ( $editing ) {
+ wp_enqueue_script( array("dbx-admin-key?pagenow=$pagenow",'admin-custom-fields') );
+ if ( current_user_can('manage_categories') )
+ wp_enqueue_script( 'ajaxcat' );
+ if ( user_can_richedit() )
+ wp_enqueue_script( 'wp_tiny_mce' );
+}
+
+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">
+<head>
+<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
+<title><?php bloginfo('name') ?> &rsaquo; <?php echo $title; ?> &#8212; WordPress</title>
+<link rel="stylesheet" href="<?php echo get_settings('siteurl') ?>/wp-admin/wp-admin.css?version=<?php bloginfo('version'); ?>" type="text/css" />
+<script type="text/javascript">
+//<![CDATA[
+function addLoadEvent(func) {if ( typeof wpOnload!='function'){wpOnload=func;}else{ var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}
+//]]>
+</script>
+<?php if ( ($parent_file != 'link-manager.php') && ($parent_file != 'options-general.php') ) : ?>
+<style type="text/css">* html { overflow-x: hidden; }</style>
+<?php endif; wp_print_scripts(); do_action('admin_head'); ?>
+</head>
+<body>
+<div id="wphead">
+<h1><?php echo wptexturize(get_settings(('blogname'))); ?> <span>(<a href="<?php echo get_settings('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_settings('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 Account'); ?></a>] </p></div>
+
+<?php
+require(ABSPATH . '/wp-admin/menu-header.php');
+
+if ( $parent_file == 'options-general.php' ) {
+ require(ABSPATH . '/wp-admin/options-head.php');
+}
+?>
diff --git a/wp-admin/admin.php b/wp-admin/admin.php
new file mode 100644
index 0000000..ffec08f
--- /dev/null
+++ b/wp-admin/admin.php
@@ -0,0 +1,120 @@
+<?php
+if ( defined('ABSPATH') )
+ require_once( ABSPATH . 'wp-config.php');
+else
+ require_once('../wp-config.php');
+
+if ( get_option('db_version') != $wp_db_version ) {
+ $http_fopen = ini_get("allow_url_fopen");
+ if($http_fopen) {
+ $out = @file( get_option( "siteurl" ) . "/wp-admin/upgrade.php?step=1" ); // upgrade the db!
+ } else {
+ require_once('../wp-includes/class-snoopy.php');
+ $client = new Snoopy();
+ @$client->fetch( get_option( "siteurl" ) . "wp-admin/upgrade.php?step=1");
+ }
+}
+
+
+require_once(ABSPATH . 'wp-admin/admin-functions.php');
+require_once(ABSPATH . 'wp-admin/admin-db.php');
+require_once(ABSPATH . WPINC . '/registration.php');
+
+auth_redirect();
+
+nocache_headers();
+
+update_category_cache();
+
+wp_get_current_user();
+
+$posts_per_page = get_settings('posts_per_page');
+$what_to_show = get_settings('what_to_show');
+$date_format = get_settings('date_format');
+$time_format = get_settings('time_format');
+
+$wpvarstoreset = array('profile','redirect','redirect_url','a','popuptitle','popupurl','text', 'trackback', 'pingback');
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+wp_enqueue_script( 'fat' );
+
+$editing = false;
+
+require(ABSPATH . '/wp-admin/menu.php');
+
+// Handle plugin admin pages.
+if (isset($_GET['page'])) {
+ $plugin_page = stripslashes($_GET['page']);
+ $plugin_page = plugin_basename($plugin_page);
+ $page_hook = get_plugin_page_hook($plugin_page, $pagenow);
+
+ if ( $page_hook ) {
+ if (! isset($_GET['noheader']))
+ require_once(ABSPATH . '/wp-admin/admin-header.php');
+
+ do_action($page_hook);
+ } else {
+ if ( validate_file($plugin_page) ) {
+ die(__('Invalid plugin page'));
+ }
+
+ if (! file_exists(ABSPATH . "wp-content/plugins/$plugin_page") && ! file_exists(ABSPATH . "wp-content/mu-plugins/$plugin_page"))
+ die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page)));
+
+ if (! isset($_GET['noheader']))
+ require_once(ABSPATH . '/wp-admin/admin-header.php');
+
+ if ( file_exists(ABSPATH . "wp-content/mu-plugins/$plugin_page") )
+ include(ABSPATH . "wp-content/mu-plugins/$plugin_page");
+ else
+ include(ABSPATH . "wp-content/plugins/$plugin_page");
+ }
+
+ include(ABSPATH . 'wp-admin/admin-footer.php');
+
+ exit();
+} else if (isset($_GET['import'])) {
+
+ $importer = $_GET['import'];
+
+ if ( validate_file($importer) ) {
+ die(__('Invalid importer.'));
+ }
+
+ if (! file_exists(ABSPATH . "wp-admin/import/$importer.php"))
+ die(__('Cannot load importer.'));
+
+ include(ABSPATH . "wp-admin/import/$importer.php");
+
+ $parent_file = 'import.php';
+ $title = __('Import');
+
+ if (! isset($_GET['noheader']))
+ require_once(ABSPATH . 'wp-admin/admin-header.php');
+
+ require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
+
+ define('WP_IMPORTING', true);
+ kses_init_filters(); // Always filter imported data with kses.
+
+ call_user_func($wp_importers[$importer][2]);
+
+ include(ABSPATH . 'wp-admin/admin-footer.php');
+
+ exit();
+}
+
+?>
diff --git a/wp-admin/bookmarklet.php b/wp-admin/bookmarklet.php
new file mode 100644
index 0000000..4345340
--- /dev/null
+++ b/wp-admin/bookmarklet.php
@@ -0,0 +1,104 @@
+<?php
+$mode = 'bookmarklet';
+require_once('admin.php');
+
+if ( ! current_user_can('edit_posts') )
+ die ("Cheatin' uh?");
+
+if ('b' == $a):
+?><!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">
+<head>
+<script type="text/javascript">
+<!--
+window.close()
+-->
+</script>
+</head>
+<body></body>
+</html>
+<?php
+exit;
+endif;
+
+$post = get_default_post_to_edit();
+
+$popuptitle = wp_specialchars(stripslashes($popuptitle));
+$text = wp_specialchars(stripslashes(urldecode($text)));
+
+$popuptitle = funky_javascript_fix($popuptitle);
+$text = funky_javascript_fix($text);
+
+$post_title = wp_specialchars($_REQUEST['post_title']);
+if (!empty($post_title))
+ $post->post_title = stripslashes($post_title);
+else
+ $post->post_title = $popuptitle;
+
+
+$content = wp_specialchars($_REQUEST['content']);
+$popupurl = wp_specialchars($_REQUEST['popupurl']);
+ if ( !empty($content) ) {
+ $post->post_content = wp_specialchars( stripslashes($_REQUEST['content']) );
+ } else {
+ $post->post_content = '<a href="'.$popupurl.'">'.$popuptitle.'</a>'."\n$text";
+ }
+
+ /* /big funky fixes */
+
+?><!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">
+<head>
+<title><?php bloginfo('name') ?> &rsaquo; Bookmarklet &#8212; WordPress</title>
+<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
+<link rel="stylesheet" href="wp-admin.css" type="text/css" />
+
+<style type="text/css">
+<!--
+
+#wpbookmarklet textarea,input,select {
+ border-width: 1px;
+ border-color: #cccccc;
+ border-style: solid;
+ padding: 2px;
+ margin: 1px;
+}
+
+#wpbookmarklet .checkbox {
+ background-color: #ffffff;
+ border-width: 0px;
+ padding: 0px;
+ margin: 0px;
+}
+
+#wpbookmarklet textarea {
+ font-family: Verdana, Geneva, Arial, Helvetica;
+ font-size: 0.9em;
+}
+
+#wpbookmarklet .wrap {
+ border: 0px;
+}
+
+#wpbookmarklet #postdiv {
+ margin-bottom: 0.5em;
+}
+
+#wpbookmarklet #titlediv {
+ margin-bottom: 1em;
+}
+
+-->
+</style>
+</head>
+<body id="wpbookmarklet">
+<div id="wphead">
+<h1><?php bloginfo('name') ?></h1>
+</div>
+
+<?php require('edit-form.php'); ?>
+
+<?php do_action('admin_footer', ''); ?>
+
+</body>
+</html>
diff --git a/wp-admin/cat-js.php b/wp-admin/cat-js.php
new file mode 100644
index 0000000..08393b7
--- /dev/null
+++ b/wp-admin/cat-js.php
@@ -0,0 +1,35 @@
+<?php
+require_once('../wp-config.php');
+header('Content-type: text/javascript; charset=' . get_settings('blog_charset'), true);
+?>
+addLoadEvent(function(){catList=new listMan('categorychecklist');catList.ajaxRespEl='jaxcat';catList.topAdder=1;catList.alt=0;catList.showLink=0;});
+addLoadEvent(newCatAddIn);
+function newCatAddIn() {
+ if ( !document.getElementById('jaxcat') ) return false;
+ var ajaxcat = document.createElement('span');
+ ajaxcat.id = 'ajaxcat';
+
+ newcat = document.createElement('input');
+ newcat.type = 'text';
+ newcat.name = 'newcat';
+ newcat.id = 'newcat';
+ newcat.size = '16';
+ newcat.setAttribute('autocomplete', 'off');
+ newcat.onkeypress = function(e) { return killSubmit("catList.ajaxAdder('category','categorydiv');", e); };
+
+ var newcatSub = document.createElement('input');
+ newcatSub.type = 'button';
+ newcatSub.name = 'Button';
+ newcatSub.id = 'catadd';
+ newcatSub.value = 'Add';
+ newcatSub.onclick = function() { catList.ajaxAdder('category', 'categorydiv'); };
+
+ ajaxcat.appendChild(newcat);
+ ajaxcat.appendChild(newcatSub);
+ document.getElementById('jaxcat').appendChild(ajaxcat);
+
+ howto = document.createElement('span');
+ howto.innerHTML = "<?php _e('Separate multiple categories with commas.'); ?>";
+ howto.id = 'howto';
+ ajaxcat.appendChild(howto);
+}
diff --git a/wp-admin/categories.js b/wp-admin/categories.js
new file mode 100644
index 0000000..46ae62f
--- /dev/null
+++ b/wp-admin/categories.js
@@ -0,0 +1,5 @@
+addLoadEvent(newCategoryAddIn);
+function newCategoryAddIn() {
+ if (!theList.theList) return false;
+ document.forms.addcat.submit.onclick = function(e) {return killSubmit('theList.ajaxAdder("cat", "addcat");', e); };
+}
diff --git a/wp-admin/categories.php b/wp-admin/categories.php
new file mode 100644
index 0000000..3e33f0c
--- /dev/null
+++ b/wp-admin/categories.php
@@ -0,0 +1,135 @@
+<?php
+require_once('admin.php');
+
+$title = __('Categories');
+$parent_file = 'edit.php';
+
+$wpvarstoreset = array('action','cat');
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+switch($action) {
+
+case 'addcat':
+
+ check_admin_referer('add-category');
+
+ if ( !current_user_can('manage_categories') )
+ die (__('Cheatin&#8217; uh?'));
+
+ wp_insert_category($_POST);
+
+ header('Location: categories.php?message=1#addcat');
+break;
+
+case 'delete':
+ $cat_ID = (int) $_GET['cat_ID'];
+ check_admin_referer('delete-category_' . $cat_ID);
+
+ if ( !current_user_can('manage_categories') )
+ die (__('Cheatin&#8217; uh?'));
+
+ $cat_name = get_catname($cat_ID);
+
+ // Don't delete the default cats.
+ if ( $cat_ID == get_option('default_category') )
+ die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one"), $cat_name));
+
+ if ( $cat_ID == get_option('default_link_category') )
+ die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one for bookmarks"), $cat_name));
+
+ wp_delete_category($cat_ID);
+
+ header('Location: categories.php?message=2');
+
+break;
+
+case 'edit':
+
+ require_once ('admin-header.php');
+ $cat_ID = (int) $_GET['cat_ID'];
+ $category = get_category_to_edit($cat_ID);
+ include('edit-category-form.php');
+
+break;
+
+case 'editedcat':
+ $cat_ID = (int) $_POST['cat_ID'];
+ check_admin_referer('update-category_' . $cat_ID);
+
+ if ( !current_user_can('manage_categories') )
+ die (__('Cheatin&#8217; uh?'));
+
+ wp_update_category($_POST);
+
+ header('Location: categories.php?message=3');
+break;
+
+default:
+
+wp_enqueue_script( 'admin-categories' );
+require_once ('admin-header.php');
+
+$messages[1] = __('Category added.');
+$messages[2] = __('Category deleted.');
+$messages[3] = __('Category updated.');
+?>
+
+<?php if (isset($_GET['message'])) : ?>
+<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
+<?php endif; ?>
+
+<div class="wrap">
+<?php if ( current_user_can('manage_categories') ) : ?>
+ <h2><?php printf(__('Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2>
+<?php else : ?>
+ <h2><?php _e('Categories') ?> </h2>
+<?php endif; ?>
+<table class="widefat">
+ <thead>
+ <tr>
+ <th scope="col"><?php _e('ID') ?></th>
+ <th scope="col" style="text-align: left"><?php _e('Name') ?></th>
+ <th scope="col" style="text-align: left"><?php _e('Description') ?></th>
+ <th scope="col" width="90"><?php _e('Posts') ?></th>
+ <th scope="col" width="90"><?php _e('Bookmarks') ?></th>
+ <th colspan="2"><?php _e('Action') ?></th>
+ </tr>
+ </thead>
+ <tbody id="the-list">
+<?php
+cat_rows();
+?>
+ </tbody>
+</table>
+
+</div>
+
+<?php if ( current_user_can('manage_categories') ) : ?>
+<div class="wrap">
+<p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts and bookmarks in that category. Instead, posts in the deleted category are set to the category <strong>%s</strong> and bookmarks are set to <strong>%s</strong>.'), get_catname(get_option('default_category')), get_catname(get_option('default_link_category'))) ?></p>
+<p><?php _e('<strong>Also Note:</strong><br />Categories will appear on your blog once you have posted something in them. Empty categories remain invisible.'); ?></p>
+</div>
+
+<?php include('edit-category-form.php'); ?>
+<?php endif; ?>
+
+<?php
+break;
+}
+
+include('admin-footer.php');
+
+?>
diff --git a/wp-admin/comment.php b/wp-admin/comment.php
new file mode 100644
index 0000000..a8be39e
--- /dev/null
+++ b/wp-admin/comment.php
@@ -0,0 +1,209 @@
+<?php
+require_once('admin.php');
+
+$parent_file = 'edit.php';
+$submenu_file = 'edit-comments.php';
+$wpvarstoreset = array('action');
+
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+if ( isset( $_POST['deletecomment'] ) )
+ $action = 'deletecomment';
+
+switch($action) {
+case 'editcomment':
+ $title = __('Edit Comment');
+ if ( user_can_richedit() )
+ wp_enqueue_script( 'wp_tiny_mce' );
+ require_once ('admin-header.php');
+
+ $comment = (int) $_GET['comment'];
+
+ if ( ! $comment = get_comment($comment) )
+ die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'javascript:history.go(-1)'));
+
+ if ( !current_user_can('edit_post', $comment->comment_post_ID) )
+ die( __('You are not allowed to edit comments on this post.') );
+
+ $comment = get_comment_to_edit($comment);
+
+ include('edit-form-comment.php');
+
+ break;
+
+case 'confirmdeletecomment':
+case 'mailapprovecomment':
+
+ require_once('./admin-header.php');
+
+ $comment = (int) $_GET['comment'];
+ $p = (int) $_GET['p'];
+ $formaction = 'confirmdeletecomment' == $action ? 'deletecomment' : 'approvecomment';
+ $nonce_action = 'confirmdeletecomment' == $action ? 'delete-comment_' : 'approve-comment_';
+ $nonce_action .= $comment;
+
+ if ( ! $comment = get_comment($comment) )
+ die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
+
+ if ( !current_user_can('edit_post', $comment->comment_post_ID) )
+ die( 'confirmdeletecomment' == $action ? __('You are not allowed to delete comments on this post.') : __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
+
+ echo "<div class='wrap'>\n";
+ if ( 'spam' == $_GET['delete_type'] )
+ echo "<p>" . __('<strong>Caution:</strong> You are about to mark the following comment as spam:') . "</p>\n";
+ elseif ( 'confirmdeletecomment' == $action )
+ echo "<p>" . __('<strong>Caution:</strong> You are about to delete the following comment:') . "</p>\n";
+ else
+ echo "<p>" . __('<strong>Caution:</strong> You are about to approve the following comment:') . "</p>\n";
+ echo "<table border='0'>\n";
+ echo "<tr><td>" . __('Author:') . "</td><td>$comment->comment_author</td></tr>\n";
+ echo "<tr><td>" . __('E-mail:') . "</td><td>$comment->comment_author_email</td></tr>\n";
+ echo "<tr><td>". __('URL:') . "</td><td>$comment->comment_author_url</td></tr>\n";
+ echo "<tr><td>". __('Comment:') . "</td><td>$comment->comment_content</td></tr>\n";
+ echo "</table>\n";
+ echo "<p>" . __('Are you sure you want to do that?') . "</p>\n";
+
+ echo "<form action='".get_settings('siteurl')."/wp-admin/comment.php' method='get'>\n";
+ wp_nonce_field($nonce_action);
+ echo "<input type='hidden' name='action' value='$formaction' />\n";
+ if ( 'spam' == $_GET['delete_type'] )
+ echo "<input type='hidden' name='delete_type' value='spam' />\n";
+ echo "<input type='hidden' name='p' value='$p' />\n";
+ echo "<input type='hidden' name='comment' value='{$comment->comment_ID}' />\n";
+ echo "<input type='hidden' name='noredir' value='1' />\n";
+ echo "<input type='submit' value='" . __('Yes') . "' />";
+ echo "&nbsp;&nbsp;";
+ echo "<input type='button' value='" . __('No') . "' onclick=\"self.location='". get_settings('siteurl') ."/wp-admin/edit-comments.php';\" />\n";
+ echo "</form>\n";
+ echo "</div>\n";
+
+ break;
+
+case 'deletecomment':
+ $comment = (int) $_REQUEST['comment'];
+ check_admin_referer('delete-comment_' . $comment);
+
+ $p = (int) $_REQUEST['p'];
+ if ( isset($_REQUEST['noredir']) ) {
+ $noredir = true;
+ } else {
+ $noredir = false;
+ }
+
+ $postdata = get_post($p) or
+ die(sprintf(__('Oops, no post with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
+
+ if ( ! $comment = get_comment($comment) )
+ die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit-comments.php'));
+
+ if ( !current_user_can('edit_post', $comment->comment_post_ID) )
+ die( __('You are not allowed to edit comments on this post.') );
+
+ if ( 'spam' == $_REQUEST['delete_type'] )
+ wp_set_comment_status($comment->comment_ID, 'spam');
+ else
+ wp_delete_comment($comment->comment_ID);
+
+ if (($_SERVER['HTTP_REFERER'] != '') && (false == $noredir)) {
+ header('Location: ' . $_SERVER['HTTP_REFERER']);
+ } else {
+ header('Location: '. get_settings('siteurl') .'/wp-admin/edit-comments.php');
+ }
+ exit();
+ break;
+
+case 'unapprovecomment':
+ $comment = (int) $_GET['comment'];
+ check_admin_referer('unapprove-comment_' . $comment);
+
+ $p = (int) $_GET['p'];
+ if (isset($_GET['noredir'])) {
+ $noredir = true;
+ } else {
+ $noredir = false;
+ }
+
+ if ( ! $comment = get_comment($comment) )
+ die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
+
+ if ( !current_user_can('edit_post', $comment->comment_post_ID) )
+ die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );
+
+ wp_set_comment_status($comment->comment_ID, "hold");
+
+ if (($_SERVER['HTTP_REFERER'] != "") && (false == $noredir)) {
+ header('Location: ' . $_SERVER['HTTP_REFERER']);
+ } else {
+ header('Location: '. get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
+ }
+ exit();
+ break;
+
+case 'approvecomment':
+ $comment = (int) $_GET['comment'];
+ check_admin_referer('approve-comment_' . $comment);
+
+ $p = (int) $_GET['p'];
+ if (isset($_GET['noredir'])) {
+ $noredir = true;
+ } else {
+ $noredir = false;
+ }
+
+ if ( ! $comment = get_comment($comment) )
+ die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
+
+ if ( !current_user_can('edit_post', $comment->comment_post_ID) )
+ die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
+
+ wp_set_comment_status($comment->comment_ID, "approve");
+ if (get_settings("comments_notify") == true) {
+ wp_notify_postauthor($comment->comment_ID);
+ }
+
+
+ if (($_SERVER['HTTP_REFERER'] != "") && (false == $noredir)) {
+ header('Location: ' . $_SERVER['HTTP_REFERER']);
+ } else {
+ header('Location: '. get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
+ }
+ exit();
+ break;
+
+case 'editedcomment':
+
+ $comment_ID = (int) $_POST['comment_ID'];
+ $comment_post_ID = (int) $_POST['comment_post_id'];
+
+ check_admin_referer('update-comment_' . $comment_ID);
+
+ edit_comment();
+
+ $referredby = $_POST['referredby'];
+ if (!empty($referredby)) {
+ header('Location: ' . $referredby);
+ } else {
+ header ("Location: edit.php?p=$comment_post_ID&c=1#comments");
+ }
+
+ break;
+default:
+ break;
+} // end switch
+
+include('admin-footer.php');
+
+?>
diff --git a/wp-admin/custom-fields.js b/wp-admin/custom-fields.js
new file mode 100644
index 0000000..e86c87e
--- /dev/null
+++ b/wp-admin/custom-fields.js
@@ -0,0 +1,26 @@
+function customFieldsOnComplete() {
+ var pidEl = document.getElementById('post_ID');
+ pidEl.name = 'post_ID';
+ pidEl.value = getNodeValue(theList.ajaxAdd.responseXML, 'postid');
+ var aEl = document.getElementById('hiddenaction')
+ if ( aEl.value == 'post' ) aEl.value = 'postajaxpost';
+}
+addLoadEvent(customFieldsAddIn);
+function customFieldsAddIn() {
+ theList.showLink=0;
+ theList.addComplete = customFieldsOnComplete;
+ if (!theList.theList) return false;
+ inputs = theList.theList.getElementsByTagName('input');
+ for ( var i=0; i < inputs.length; i++ ) {
+ if ('text' == inputs[i].type) {
+ inputs[i].setAttribute('autocomplete', 'off');
+ inputs[i].onkeypress = function(e) {return killSubmit('theList.ajaxUpdater("meta", "meta-' + parseInt(this.name.slice(5),10) + '");', e); };
+ }
+ if ('updatemeta' == inputs[i].className) {
+ inputs[i].onclick = function(e) {return killSubmit('theList.ajaxUpdater("meta", "meta-' + parseInt(this.parentNode.parentNode.id.slice(5),10) + '");', e); };
+ }
+ }
+
+ document.getElementById('metakeyinput').onkeypress = function(e) {return killSubmit('theList.inputData+="&id="+document.getElementById("post_ID").value;theList.ajaxAdder("meta", "newmeta");', e); };
+ document.getElementById('updatemetasub').onclick = function(e) {return killSubmit('theList.inputData+="&id="+document.getElementById("post_ID").value;theList.ajaxAdder("meta", "newmeta");', e); };
+}
diff --git a/wp-admin/dbx-admin-key-js.php b/wp-admin/dbx-admin-key-js.php
new file mode 100644
index 0000000..bca04ce
--- /dev/null
+++ b/wp-admin/dbx-admin-key-js.php
@@ -0,0 +1,68 @@
+<?php
+require_once('admin.php');
+header('Content-type: text/javascript; charset=' . get_settings('blog_charset'), true);
+
+switch ( $_GET['pagenow'] ) :
+ case 'post.php' :
+ case 'post-new.php' :
+ $man = 'postmeta';
+ break;
+ case 'page.php' :
+ case 'page-new.php' :
+ $man = 'pagemeta';
+ break;
+ case 'link.php' :
+ $man = 'linkmeta';
+ break;
+ default:
+ exit;
+ break;
+endswitch;
+?>
+addLoadEvent( function() {var manager = new dbxManager('<?php echo $man; ?>');} );
+
+addLoadEvent( function()
+{
+ //create new docking boxes group
+ var meta = new dbxGroup(
+ 'grabit', // container ID [/-_a-zA-Z0-9/]
+ 'vertical', // orientation ['vertical'|'horizontal']
+ '10', // drag threshold ['n' pixels]
+ 'no', // restrict drag movement to container axis ['yes'|'no']
+ '10', // animate re-ordering [frames per transition, or '0' for no effect]
+ 'yes', // include open/close toggle buttons ['yes'|'no']
+ 'closed', // default state ['open'|'closed']
+ 'open', // word for "open", as in "open this box"
+ 'close', // word for "close", as in "close this box"
+ 'click-down and drag to move this box', // sentence for "move this box" by mouse
+ 'click to %toggle% this box', // pattern-match sentence for "(open|close) this box" by mouse
+ 'use the arrow keys to move this box', // sentence for "move this box" by keyboard
+ ', or press the enter key to %toggle% it', // pattern-match sentence-fragment for "(open|close) this box" by keyboard
+ '%mytitle% [%dbxtitle%]' // pattern-match syntax for title-attribute conflicts
+ );
+
+ // Boxes are closed by default. Open the Category box if the cookie isn't already set.
+ var catdiv = document.getElementById('categorydiv');
+ if ( catdiv ) {
+ var button = catdiv.getElementsByTagName('A')[0];
+ if ( dbx.cookiestate == null && /dbx\-toggle\-closed/.test(button.className) )
+ meta.toggleBoxState(button, true);
+ }
+
+ var advanced = new dbxGroup(
+ 'advancedstuff', // container ID [/-_a-zA-Z0-9/]
+ 'vertical', // orientation ['vertical'|'horizontal']
+ '10', // drag threshold ['n' pixels]
+ 'yes', // restrict drag movement to container axis ['yes'|'no']
+ '10', // animate re-ordering [frames per transition, or '0' for no effect]
+ 'yes', // include open/close toggle buttons ['yes'|'no']
+ 'closed', // default state ['open'|'closed']
+ 'open', // word for "open", as in "open this box"
+ 'close', // word for "close", as in "close this box"
+ 'click-down and drag to move this box', // sentence for "move this box" by mouse
+ 'click to %toggle% this box', // pattern-match sentence for "(open|close) this box" by mouse
+ 'use the arrow keys to move this box', // sentence for "move this box" by keyboard
+ ', or press the enter key to %toggle% it', // pattern-match sentence-fragment for "(open|close) this box" by keyboard
+ '%mytitle% [%dbxtitle%]' // pattern-match syntax for title-attribute conflicts
+ );
+});
diff --git a/wp-admin/edit-category-form.php b/wp-admin/edit-category-form.php
new file mode 100644
index 0000000..9b700af
--- /dev/null
+++ b/wp-admin/edit-category-form.php
@@ -0,0 +1,46 @@
+<?php
+if ( ! empty($cat_ID) ) {
+ $heading = __('Edit Category');
+ $submit_text = __('Edit Category &raquo;');
+ $form = '<form name="editcat" id="editcat" method="post" action="categories.php">';
+ $action = 'editedcat';
+ $nonce_action = 'update-category_' . $cat_ID;
+} else {
+ $heading = __('Add Category');
+ $submit_text = __('Add Category &raquo;');
+ $form = '<form name="addcat" id="addcat" method="post" action="categories.php">';
+ $action = 'addcat';
+ $nonce_action = 'add-category';
+}
+?>
+
+<div class="wrap">
+<h2><?php echo $heading ?></h2>
+<?php echo $form ?>
+<input type="hidden" name="action" value="<?php echo $action ?>" />
+<input type="hidden" name="cat_ID" value="<?php echo $category->cat_ID ?>" />
+<?php wp_nonce_field($nonce_action); ?>
+<?php autocomplete_css(); ?>
+ <table class="editform" width="100%" cellspacing="2" cellpadding="5">
+ <tr>
+ <th width="33%" scope="row" valign="top"><label for="cat_name"><?php _e('Category name:') ?></label></th>
+ <td width="67%"><input type="text" id="cat_name" name="cat_name" value="<?php echo wp_specialchars($category->cat_name); ?>" size="40" /><div id="searchresults" class="autocomplete"></div></td>
+ </tr>
+ <tr>
+ <th scope="row" valign="top"><label for="category_parent"><?php _e('Category parent:') ?></label></th>
+ <td>
+ <select name='category_parent' id='category_parent'>
+ <option value='0' <?php if (!$category->category_parent) echo " selected='selected'"; ?>><?php _e('None') ?></option>
+ <?php wp_dropdown_cats($category->cat_ID, $category->category_parent); ?>
+ </select></td>
+ </tr>
+ <tr>
+ <th scope="row" valign="top"><label for="category_description"><?php _e('Description: (optional)') ?></label></th>
+ <td><textarea name="category_description" id="category_description" rows="5" cols="50" style="width: 97%;"><?php echo wp_specialchars($category->category_description, 1); ?></textarea></td>
+ </tr>
+ </table>
+<?php autocomplete_textbox( "wpmu-edit.php?action=searchcategories&search=", "cat_name", "searchresults" ); ?>
+<p class="submit"><input type="submit" name="submit" value="<?php echo $submit_text ?>" /></p>
+<div id="ajax-response"></div>
+</form>
+</div>
diff --git a/wp-admin/edit-comments.js b/wp-admin/edit-comments.js
new file mode 100644
index 0000000..4dfe755
--- /dev/null
+++ b/wp-admin/edit-comments.js
@@ -0,0 +1,23 @@
+addLoadEvent(function() {
+ theCommentList = new listMan('the-comment-list');
+ if ( !theCommentList )
+ return false;
+ 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;
+ }
+ 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;
+ }
+ if ( theList ) // the post list: edit.php
+ theList.delComplete = function() {
+ var comments = document.getElementById('comments');
+ var commdel = encloseFunc(function(a){a.parentNode.removeChild(a);},comments);
+ var listdel = encloseFunc(function(a){a.parentNode.removeChild(a);},theCommentList.theList);
+ setTimeout(commdel,705);
+ setTimeout(listdel,705);
+ }
+});
+
diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php
new file mode 100644
index 0000000..db8ad12
--- /dev/null
+++ b/wp-admin/edit-comments.php
@@ -0,0 +1,211 @@
+<?php
+require_once('admin.php');
+
+$title = __('Edit Comments');
+$parent_file = 'edit.php';
+wp_enqueue_script( 'admin-comments' );
+
+require_once('admin-header.php');
+if (empty($_GET['mode'])) $mode = 'view';
+else $mode = wp_specialchars($_GET['mode'], 1);
+?>
+
+<script type="text/javascript">
+<!--
+function checkAll(form)
+{
+ for (i = 0, n = form.elements.length; i < n; i++) {
+ if(form.elements[i].type == "checkbox") {
+ if(form.elements[i].checked == true)
+ form.elements[i].checked = false;
+ else
+ form.elements[i].checked = true;
+ }
+ }
+}
+
+function getNumChecked(form)
+{
+ var num = 0;
+ for (i = 0, n = form.elements.length; i < n; i++) {
+ if(form.elements[i].type == "checkbox") {
+ if(form.elements[i].checked == true)
+ num++;
+ }
+ }
+ return num;
+}
+//-->
+</script>
+<div class="wrap">
+<h2><?php _e('Comments'); ?></h2>
+<form name="searchform" action="" method="get" id="editcomments">
+ <fieldset>
+ <legend><?php _e('Show Comments That Contain...') ?></legend>
+ <input type="text" name="s" value="<?php if (isset($_GET['s'])) echo wp_specialchars($_GET['s'], 1); ?>" size="17" />
+ <input type="submit" name="submit" value="<?php _e('Search') ?>" />
+ <input type="hidden" name="mode" value="<?php echo $mode; ?>" />
+ <?php _e('(Searches within comment text, e-mail, URI, and IP address.)') ?>
+ </fieldset>
+</form>
+<p><a href="?mode=view"><?php _e('View Mode') ?></a> | <a href="?mode=edit"><?php _e('Mass Edit Mode') ?></a></p>
+<?php
+if ( !empty( $_POST['delete_comments'] ) ) :
+ check_admin_referer('bulk-comments');
+
+ $i = 0;
+ foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each
+ $comment = (int) $comment;
+ $post_id = $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
+ // $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") );
+ if ( current_user_can('edit_post', $post_id) ) {
+ if ( !empty( $_POST['spam_button'] ) )
+ wp_set_comment_status($comment, 'spam');
+ else
+ wp_set_comment_status($comment, 'delete');
+ ++$i;
+ }
+ endforeach;
+ echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>';
+ if ( !empty( $_POST['spam_button'] ) )
+ printf(__('%s comments marked as spam.'), $i);
+ else
+ printf(__('%s comments deleted.'), $i);
+ 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['offset']) )
+ $offset = (int) $_GET['offset'] * 20;
+ else
+ $offset = 0;
+
+ $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $offset,20");
+}
+if ('view' == $mode) {
+ if ($comments) {
+ if ($offset)
+ $start = " start='$offset'";
+ else
+ $start = '';
+
+ echo "<ol id='the-comment-list' class='commentlist' $start>";
+ $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() ?>
+
+<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;comment=".$comment->comment_ID."\'>" . __('Edit') . '</a>';
+ echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), js_escape($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=' . $post->ID . '&amp;comment=' . $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=' . $post->ID . '&amp;comment=' . $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;delete_type=spam&amp;p=" . $comment->comment_post_ID . "&amp;comment=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . sprintf(__("You are about to mark as spam this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to mark as spam."), js_escape( $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;
+?>
+ | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ]</p>
+ </li>
+
+<?php } // end foreach($comment) ?>
+</ol>
+
+<div id="ajax-response"></div>
+
+<?php
+ } else { //no comments to show
+
+ ?>
+ <p>
+ <strong><?php _e('No comments found.') ?></strong></p>
+
+ <?php
+ } // end if ($comments)
+} elseif ('edit' == $mode) {
+
+ if ($comments) {
+ echo '<form name="deletecomments" id="deletecomments" action="" method="post"> ';
+ wp_nonce_field('bulk-comments');
+ echo '<table class="widefat">
+<thead>
+ <tr>
+ <th scope="col"><input type="checkbox" onclick="checkAll(document.getElementById(\'deletecomments\'));" /></th>
+ <th scope="col" style="text-align: left">' . __('Name') . '</th>
+ <th scope="col" style="text-align: left">' . __('E-mail') . '</th>
+ <th scope="col" style="text-align: left">' . __('IP') . '</th>
+ <th scope="col" style="text-align: left">' . __('Comment Excerpt') . '</th>
+ <th scope="col" colspan="3">' . __('Actions') . '</th>
+ </tr>
+</thead>';
+ foreach ($comments as $comment) {
+ $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);
+ $class = ('alternate' == $class) ? '' : 'alternate';
+ $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><?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>
+ <td><?php comment_excerpt(); ?></td>
+ <td>
+ <?php if ('unapproved' == $comment_status) { ?>
+ (Unapproved)
+ <?php } else { ?>
+ <a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit"><?php _e('View') ?></a>
+ <?php } ?>
+ </td>
+ <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
+ echo "<a href='comment.php?action=editcomment&amp;comment=$comment->comment_ID' class='edit'>" . __('Edit') . "</a>"; } ?></td>
+ <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
+ echo "<a href=\"comment.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), js_escape( $comment->comment_author )) . "', theCommentList );\" class='delete'>" . __('Delete') . "</a> ";
+ } ?></td>
+ </tr>
+ <?php
+ } // end foreach
+ ?></table>
+<p class="submit"><input type="submit" name="delete_button" value="<?php _e('Delete Checked Comments &raquo;') ?>" onclick="var numchecked = getNumChecked(document.getElementById('deletecomments')); if(numchecked < 1) { alert('<?php _e("Please select some comments to delete"); ?>'); return false } return confirm('<?php printf(__("You are about to delete %s comments permanently \\n \'Cancel\' to stop, \'OK\' to delete."), "' + numchecked + '"); ?>')" />
+ <input type="submit" name="spam_button" value="<?php _e('Mark Checked Comments as Spam &raquo;') ?>" onclick="return confirm('<?php _e("You are about to mark these comments as spam \\n \'Cancel\' to stop, \'OK\' to mark as spam.") ?>')" /></p>
+ </form>
+<div id="ajax-response"></div>
+<?php
+ } else {
+?>
+<p>
+<strong><?php _e('No results found.') ?></strong>
+</p>
+<?php
+ } // end if ($comments)
+}
+ ?>
+
+</div>
+
+<?php include('admin-footer.php'); ?>
diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php
new file mode 100644
index 0000000..894e239
--- /dev/null
+++ b/wp-admin/edit-form-advanced.php
@@ -0,0 +1,237 @@
+<?php
+$messages[1] = __('Post updated');
+$messages[2] = __('Custom field updated');
+$messages[3] = __('Custom field deleted.');
+?>
+<?php if (isset($_GET['message'])) : ?>
+<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
+<?php endif; ?>
+
+<form name="post" action="post.php" method="post" id="post">
+<?php if ( (isset($mode) && 'bookmarklet' == $mode) ||
+ isset($_GET['popupurl']) ): ?>
+<input type="hidden" name="mode" value="bookmarklet" />
+<?php endif; ?>
+
+<div class="wrap">
+<h2 id="write-post"><?php _e('Write Post'); ?><?php if ( 0 != $post_ID ) : ?>
+ <small class="quickjump"><a href="#preview-post"><?php _e('preview &darr;'); ?></a></small><?php endif; ?></h2>
+<?php
+
+if (0 == $post_ID) {
+ $form_action = 'post';
+ $temp_ID = -1 * time();
+ $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />";
+ wp_nonce_field('add-post');
+} else {
+ $form_action = 'editpost';
+ $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";
+ wp_nonce_field('update-post_' . $post_ID);
+}
+
+$form_pingback = '<input type="hidden" name="post_pingback" value="' . get_option('default_pingback_flag') . '" id="post_pingback" />';
+
+$form_prevstatus = '<input type="hidden" name="prev_status" value="' . $post->post_status . '" />';
+
+$form_trackback = '<input type="text" name="trackback_url" style="width: 415px" id="trackback" tabindex="7" value="'. str_replace("\n", ' ', $post->to_ping) .'" />';
+
+if ('' != $post->pinged) {
+ $pings = '<p>'. __('Already pinged:') . '</p><ul>';
+ $already_pinged = explode("\n", trim($post->pinged));
+ foreach ($already_pinged as $pinged_url) {
+ $pings .= "\n\t<li>$pinged_url</li>";
+ }
+ $pings .= '</ul>';
+}
+
+$saveasdraft = '<input name="save" type="submit" id="save" tabindex="3" value="' . __('Save and Continue Editing') . '" />';
+
+if (empty($post->post_status)) $post->post_status = 'draft';
+
+?>
+
+<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
+<input type="hidden" id="hiddenaction" name="action" value="<?php echo $form_action ?>" />
+<input type="hidden" name="post_author" value="<?php echo $post->post_author ?>" />
+<input type="hidden" name="post_type" value="post" />
+
+<?php echo $form_extra ?>
+<?php if (isset($_GET['message']) && 2 > $_GET['message']) : ?>
+<script type="text/javascript">
+function focusit() {
+ // focus on first input field
+ document.post.title.focus();
+}
+addLoadEvent(focusit);
+</script>
+<?php endif; ?>
+<?php autocomplete_css(); ?>
+<div id="poststuff">
+
+<div id="moremeta">
+<div id="grabit" class="dbx-group">
+
+<fieldset id="categorydiv" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Categories') ?></h3>
+<div class="dbx-content">
+<p id="jaxcat"></p>
+<?php if ( current_user_can('manage_categories') ) : ?>
+<div id="searchresults" class="autocomplete"></div>
+<?php autocomplete_textbox( "wpmu-edit.php?action=searchcategories&search=", "newcat", "searchresults" ); ?>
+<?php endif; ?>
+<ul id="categorychecklist"><?php dropdown_categories(get_settings('default_category')); ?></ul>
+</div>
+</fieldset>
+
+<fieldset id="commentstatusdiv" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Discussion') ?></h3>
+<div class="dbx-content">
+<input name="advanced_view" type="hidden" value="1" />
+<label for="comment_status" class="selectit">
+<input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> />
+<?php _e('Allow Comments') ?></label>
+<label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php _e('Allow Pings') ?></label>
+</div>
+</fieldset>
+
+<fieldset id="passworddiv" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Password-Protect Post') ?></h3>
+<div class="dbx-content"><input name="post_password" type="text" size="13" id="post_password" value="<?php echo $post->post_password ?>" /></div>
+</fieldset>
+
+<fieldset id="slugdiv" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Post slug') ?></h3>
+<div class="dbx-content"><input name="post_name" type="text" size="13" id="post_name" value="<?php echo $post->post_name ?>" /></div>
+</fieldset>
+
+<fieldset class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Post Status') ?></h3>
+<div class="dbx-content"><?php if ( current_user_can('publish_posts') ) : ?>
+<label for="post_status_publish" class="selectit"><input id="post_status_publish" name="post_status" type="radio" value="publish" <?php checked($post->post_status, 'publish'); checked($post->post_status, 'future'); ?> /> <?php _e('Published') ?></label>
+<?php endif; ?>
+ <label for="post_status_draft" class="selectit"><input id="post_status_draft" name="post_status" type="radio" value="draft" <?php checked($post->post_status, 'draft'); ?> /> <?php _e('Draft') ?></label>
+ <label for="post_status_private" class="selectit"><input id="post_status_private" name="post_status" type="radio" value="private" <?php checked($post->post_status, 'private'); ?> /> <?php _e('Private') ?></label></div>
+</fieldset>
+
+<?php if ( current_user_can('edit_posts') ) : ?>
+<fieldset class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Post Timestamp'); ?>:</h3>
+<div class="dbx-content"><?php touch_time(($action == 'edit')); ?></div>
+</fieldset>
+<?php endif; ?>
+
+<?php if ( $authors = get_editable_authors( $current_user->id ) ) : // TODO: ROLE SYSTEM ?>
+<fieldset id="authordiv" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Post author'); ?>:</h3>
+<div class="dbx-content">
+<select name="post_author_override" id="post_author_override">
+<?php
+foreach ($authors as $o) :
+$o = get_userdata( $o->ID );
+if ( $post->post_author == $o->ID || ( empty($post_ID) && $user_ID == $o->ID ) ) $selected = 'selected="selected"';
+else $selected = '';
+echo "<option value='$o->ID' $selected>$o->display_name</option>";
+endforeach;
+?>
+</select>
+</div>
+</fieldset>
+<?php endif; ?>
+
+<?php do_action('dbx_post_sidebar'); ?>
+
+</div>
+</div>
+
+<fieldset id="titlediv">
+ <legend><?php _e('Title') ?></legend>
+ <div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo $post->post_title; ?>" id="title" /></div>
+</fieldset>
+
+<fieldset id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>">
+<legend><?php _e('Post') ?></legend>
+
+ <?php the_editor($post->post_content); ?>
+
+<?php echo $form_pingback ?>
+<?php echo $form_prevstatus ?>
+
+
+<p class="submit"><?php echo $saveasdraft; ?> <input type="submit" name="submit" value="<?php _e('Save') ?>" style="font-weight: bold;" tabindex="4" />
+<?php
+if ('publish' != $post->post_status || 0 == $post_ID) {
+?>
+<?php if ( current_user_can('publish_posts') ) : ?>
+ <input name="publish" type="submit" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" />
+<?php endif; ?>
+<?php
+}
+?>
+<input name="referredby" type="hidden" id="referredby" value="<?php
+if ( !empty($_REQUEST['popupurl']) )
+ echo wp_specialchars($_REQUEST['popupurl']);
+else if ( url_to_postid($_SERVER['HTTP_REFERER']) == $post_ID )
+ echo 'redo';
+else
+ echo wp_specialchars($_SERVER['HTTP_REFERER']);
+?>" /></p>
+
+<?php do_action('edit_form_advanced'); ?>
+
+<?php
+if (current_user_can('upload_files')) {
+ $uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID);
+ $uploading_iframe_src = wp_nonce_url("inline-uploading.php?action=view&amp;post=$uploading_iframe_ID", 'inlineuploading');
+ $uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
+ if ( false != $uploading_iframe_src )
+ echo '<iframe id="uploading" border="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
+}
+?>
+
+<div id="advancedstuff" class="dbx-group" >
+
+<fieldset id="postexcerpt" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Optional Excerpt') ?></h3>
+<div class="dbx-content"><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt ?></textarea></div>
+</fieldset>
+
+<fieldset class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Trackbacks') ?></h3>
+<div class="dbx-content"><?php _e('Send trackbacks to'); ?>: <?php echo $form_trackback; ?> (<?php _e('Separate multiple URIs with spaces'); ?>)
+<?php
+if ( ! empty($pings) )
+ echo $pings;
+?>
+</div>
+</fieldset>
+
+<fieldset id="postcustom" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Custom Fields') ?></h3>
+<div id="postcustomstuff" class="dbx-content">
+<table cellpadding="3">
+<?php
+$metadata = has_meta($post_ID);
+list_meta($metadata);
+?>
+
+</table>
+<?php
+ meta_form();
+?>
+<div id="ajax-response"></div>
+</div>
+</fieldset>
+
+<?php do_action('dbx_post_advanced'); ?>
+
+</div>
+
+<?php if ('edit' == $action) : $delete_nonce = wp_create_nonce( 'delete-post_' . $post_ID ); ?>
+<input name="deletepost" class="button" type="submit" id="deletepost" tabindex="10" value="<?php _e('Delete this post') ?>" <?php echo "onclick=\"if ( confirm('" . sprintf(__("You are about to delete this post \'%s\'\\n \'Cancel\' to stop, \'OK\' to delete."), addslashes($post->post_title) ) . "') ) { document.forms.post._wpnonce.value = '$delete_nonce'; return true;}return false;\""; ?> />
+<?php endif; ?>
+
+</div>
+
+</div>
+
+</form>
diff --git a/wp-admin/edit-form-ajax-cat.php b/wp-admin/edit-form-ajax-cat.php
new file mode 100644
index 0000000..4a4665c
--- /dev/null
+++ b/wp-admin/edit-form-ajax-cat.php
@@ -0,0 +1,37 @@
+<?php
+require_once('../wp-config.php');
+require_once('admin-functions.php');
+require_once('admin-db.php');
+
+get_currentuserinfo();
+
+if ( !current_user_can('manage_categories') )
+ die('-1');
+
+function get_out_now() { exit; }
+
+add_action('shutdown', 'get_out_now', -1);
+
+$names = explode(',', rawurldecode($_GET['ajaxnewcat']) );
+$ids = array();
+
+foreach ($names as $cat_name) {
+ $cat_name = trim( $cat_name );
+
+ if ( !$category_nicename = sanitize_title($cat_name) )
+ continue;
+ if ( $already = category_exists($cat_name) ) {
+ $ids[] = (string) $already;
+ continue;
+ }
+
+ $new_cat_id = wp_create_category($cat_name);
+
+ $ids[] = (string) $new_cat_id;
+}
+
+$return = join(',', $ids);
+
+die( (string) $return );
+
+?>
diff --git a/wp-admin/edit-form-comment.php b/wp-admin/edit-form-comment.php
new file mode 100644
index 0000000..1f23cef
--- /dev/null
+++ b/wp-admin/edit-form-comment.php
@@ -0,0 +1,80 @@
+<?php
+$submitbutton_text = __('Edit Comment &raquo;');
+$toprow_title = sprintf(__('Editing Comment # %s'), $comment->comment_ID);
+$form_action = 'editedcomment';
+$form_extra = "' />\n<input type='hidden' name='comment_ID' value='" . $comment->comment_ID . "' />\n<input type='hidden' name='comment_post_ID' value='".$comment->comment_post_ID;
+?>
+
+<form name="post" action="comment.php" method="post" id="post">
+<?php wp_nonce_field('update-comment_' . $comment->comment_ID) ?>
+<div class="wrap">
+<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
+<input type="hidden" name="action" value='<?php echo $form_action . $form_extra ?>' />
+
+<script type="text/javascript">
+function focusit() { // focus on first input field
+ document.post.name.focus();
+}
+addLoadEvent(focusit);
+</script>
+<fieldset id="namediv">
+ <legend><label for="name"><?php _e('Name:') ?></label></legend>
+ <div>
+ <input type="text" name="newcomment_author" size="25" value="<?php echo $comment->comment_author ?>" tabindex="1" id="name" />
+ </div>
+</fieldset>
+<fieldset id="emaildiv">
+ <legend><label for="email"><?php _e('E-mail:') ?></label></legend>
+ <div>
+ <input type="text" name="newcomment_author_email" size="20" value="<?php echo $comment->comment_author_email ?>" tabindex="2" id="email" />
+ </div>
+</fieldset>
+<fieldset id="uridiv">
+ <legend><label for="URL"><?php _e('URI:') ?></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" />
+ </div>
+</fieldset>
+
+<fieldset style="clear: both;">
+ <legend><?php _e('Comment') ?></legend>
+ <?php the_editor($comment->comment_content, 'content', 'newcomment_author_url'); ?>
+</fieldset>
+
+<p class="submit"><input type="submit" name="editcomment" id="editcomment" value="<?php echo $submitbutton_text ?>" style="font-weight: bold;" tabindex="6" />
+ <input name="referredby" type="hidden" id="referredby" value="<?php echo $_SERVER['HTTP_REFERER']; ?>" />
+</p>
+
+</div>
+
+<div class="wrap">
+<h2><?php _e('Advanced'); ?></h2>
+
+<table width="100%" cellspacing="2" cellpadding="5" class="editform">
+ <tr>
+ <th scope="row" valign="top"><?php _e('Comment Status') ?>:</th>
+ <td><label for="comment_status_approved" class="selectit"><input id="comment_status_approved" name="comment_status" type="radio" value="1" <?php checked($comment->comment_approved, '1'); ?> /> <?php _e('Approved') ?></label><br />
+ <label for="comment_status_moderated" class="selectit"><input id="comment_status_moderated" name="comment_status" type="radio" value="0" <?php checked($comment->comment_approved, '0'); ?> /> <?php _e('Moderated') ?></label><br />
+ <label for="comment_status_spam" class="selectit"><input id="comment_status_spam" name="comment_status" type="radio" value="spam" <?php checked($comment->comment_approved, 'spam'); ?> /> <?php _e('Spam') ?></label></td>
+ </tr>
+
+<?php if ( current_user_can('edit_posts') ) : ?>
+ <tr>
+ <th scope="row" valign="top"><?php _e('Edit time'); ?>:</th>
+ <td><?php touch_time(('editcomment' == $action), 0); ?> </td>
+ </tr>
+<?php endif; ?>
+
+ <tr>
+ <th scope="row" valign="top"><?php _e('Delete'); ?>:</th>
+ <td><input name="deletecomment" class="button" type="submit" id="deletecomment" tabindex="10" value="<?php _e('Delete this comment') ?>" <?php echo "onclick=\"return confirm('" . __("You are about to delete this comment \\n \'Cancel\' to stop, \'OK\' to delete.") . "')\""; ?> />
+ <input type="hidden" name="comment" value="<?php echo $comment->comment_ID ?>" />
+ <input type="hidden" name="p" value="<?php echo $comment->comment_post_ID ?>" />
+ <input type="hidden" name="noredir" value="1" />
+ </td>
+ </tr>
+</table>
+
+</div>
+
+</form>
diff --git a/wp-admin/edit-form.php b/wp-admin/edit-form.php
new file mode 100644
index 0000000..dd4bc75
--- /dev/null
+++ b/wp-admin/edit-form.php
@@ -0,0 +1,75 @@
+
+<div class="wrap">
+<h2><?php _e('Write Post'); ?></h2>
+<form name="post" action="post.php" method="post" id="simple">
+
+<?php if (isset($mode) && 'bookmarklet' == $mode) : ?>
+<input type="hidden" name="mode" value="bookmarklet" />
+<?php endif; ?>
+<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
+<input type="hidden" name="action" value='post' />
+
+<script type="text/javascript">
+<!--
+function focusit() { // focus on first input field
+ document.getElementById('title').focus();
+}
+addLoadEvent(focusit);
+//-->
+</script>
+
+<div id="poststuff">
+ <fieldset id="titlediv">
+ <legend><a href="http://wordpress.org/docs/reference/post/#title" title="<?php _e('Help on titles') ?>"><?php _e('Title') ?></a></legend>
+ <div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo $post->post_title; ?>" id="title" /></div>
+ </fieldset>
+
+ <fieldset id="categorydiv">
+ <legend><a href="http://wordpress.org/docs/reference/post/#category" title="<?php _e('Help on categories') ?>"><?php _e('Categories') ?></a></legend>
+ <div><?php dropdown_categories($post->post_category); ?></div>
+ </fieldset>
+
+<br />
+<fieldset id="postdiv">
+ <legend><a href="http://wordpress.org/docs/reference/post/#post" title="<?php _e('Help with post field') ?>"><?php _e('Post') ?></a></legend>
+<?php the_quicktags(); ?>
+<?php
+ $rows = get_settings('default_post_edit_rows');
+ if (($rows < 3) || ($rows > 100)) {
+ $rows = 10;
+ }
+?>
+<div><textarea rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="4" id="content"><?php echo $post->post_content ?></textarea></div>
+</fieldset>
+
+
+<script type="text/javascript">
+<!--
+edCanvas = document.getElementById('content');
+//-->
+</script>
+
+<input type="hidden" name="post_pingback" value="<?php echo get_option('default_pingback_flag') ?>" id="post_pingback" />
+
+<p><label for="trackback"> <?php printf(__('<a href="%s" title="Help on trackbacks"><strong>TrackBack</strong> a <abbr title="Universal Resource Identifier">URI</abbr></a>:</label> (Separate multiple <abbr title="Universal Resource Identifier">URI</abbr>s with spaces.)<br />'), 'http://wordpress.org/docs/reference/post/#trackback') ?>
+ <input type="text" name="trackback_url" style="width: 360px" id="trackback" tabindex="7" /></p>
+
+<p class="submit"><input name="saveasdraft" type="submit" id="saveasdraft" tabindex="9" value="<?php _e('Save as Draft') ?>" />
+ <input name="saveasprivate" type="submit" id="saveasprivate" tabindex="10" value="<?php _e('Save as Private') ?>" />
+
+ <?php if ( current_user_can('edit_posts') ) : ?>
+ <input name="publish" type="submit" id="publish" tabindex="6" style="font-weight: bold;" value="<?php _e('Publish') ?>" />
+<?php endif; ?>
+
+<?php if ('bookmarklet' != $mode) {
+ echo '<input name="advanced" type="submit" id="advancededit" tabindex="7" value="' . __('Advanced Editing &raquo;') . '" />';
+ } ?>
+ <input name="referredby" type="hidden" id="referredby" value="<?php if (isset($_SERVER['HTTP_REFERER'])) echo urlencode($_SERVER['HTTP_REFERER']); ?>" />
+</p>
+
+<?php do_action('simple_edit_form', ''); ?>
+
+</div>
+</form>
+
+</div>
diff --git a/wp-admin/edit-link-form.php b/wp-admin/edit-link-form.php
new file mode 100644
index 0000000..faa4956
--- /dev/null
+++ b/wp-admin/edit-link-form.php
@@ -0,0 +1,257 @@
+<?php
+if ( ! empty($link_id) ) {
+ $heading = __('Edit Bookmark');
+ $submit_text = __('Save Changes &raquo;');
+ $form = '<form name="editlink" id="editlink" method="post" action="link.php">';
+ $nonce_action = 'update-bookmark_' . $link_id;
+} else {
+ $heading = __('Create Bookmark');
+ $submit_text = __('Add Bookmark &raquo;');
+ $form = '<form name="addlink" id="addlink" method="post" action="link.php">';
+ $nonce_action = 'add-bookmark';
+}
+
+function xfn_check($class, $value = '', $type = 'check') {
+ global $link;
+
+ $link_rel = $link->link_rel;
+ $rels = preg_split('/\s+/', $link_rel);
+
+ if ('' != $value && in_array($value, $rels) ) {
+ echo ' checked="checked"';
+ }
+
+ if ('' == $value) {
+ if ('family' == $class && !strstr($link_rel, 'child') && !strstr($link_rel, 'parent') && !strstr($link_rel, 'sibling') && !strstr($link_rel, 'spouse') && !strstr($link_rel, 'kin')) echo ' checked="checked"';
+ if ('friendship' == $class && !strstr($link_rel, 'friend') && !strstr($link_rel, 'acquaintance') && !strstr($link_rel, 'contact') ) echo ' checked="checked"';
+ if ('geographical' == $class && !strstr($link_rel, 'co-resident') && !strstr($link_rel, 'neighbor') ) echo ' checked="checked"';
+ if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"';
+ }
+}
+?>
+
+<div class="wrap">
+<h2><?php echo $heading ?></h2>
+<?php echo $form ?>
+<?php wp_nonce_field($nonce_action); ?>
+
+<div id="poststuff">
+<div id="moremeta">
+<div id="grabit" class="dbx-group">
+
+<fieldset id="categorydiv" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Categories') ?></h3>
+<div class="dbx-content">
+<p id="jaxcat"></p>
+<ul id="categorychecklist"><?php dropdown_categories(get_settings('default_link_category')); ?></ul>
+</div>
+</fieldset>
+
+<fieldset class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Target') ?></h3>
+<div class="dbx-content">
+<label for="link_target_blank" class="selectit">
+<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo(($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
+<code>_blank</code></label>
+<label for="link_target_top" class="selectit">
+<input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo(($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
+<code>_top</code></label>
+<label for="link_target_none" class="selectit">
+<input id="link_target_none" type="radio" name="link_target" value="" <?php echo(($link->link_target == '') ? 'checked="checked"' : ''); ?> />
+<?php _e('none') ?></label>
+</div>
+</fieldset>
+
+<fieldset class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Visible') ?></h3>
+<div class="dbx-content">
+<label for="link_visible_yes" class="selectit">
+<input id="link_visible_yes" type="radio" name="link_visible" <?php if ($link->link_visible == 'Y') echo "checked='checked'"; ?> value="Y" />
+<?php _e('Yes') ?></label>
+<label for="link_visible_no" class="selectit">
+<input id="link_visible_no" type="radio" name="link_visible" <?php if ($link->link_visible == 'N') echo "checked='checked'"; ?> value="N" />
+<?php _e('No') ?></label>
+</div>
+</fieldset>
+
+</div>
+</div>
+
+<table class="editform" width="100%" cellspacing="2" cellpadding="5">
+<tr>
+<th width="20%" scope="row" valign="top"><label for="link_url"><?php _e('URI:') ?></label></th>
+<td width="80%"><input type="text" name="link_url" value="<?php echo $link->link_url; ?>" style="width: 95%" /></td>
+</tr>
+<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>
+</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>
+</tr>
+</table>
+
+<p class="submit">
+<input type="submit" name="submit" value="<?php echo $submit_text ?>" />
+</p>
+
+<div id="advancedstuff" class="dbx-group" >
+
+<fieldset id="xfn" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Link Relationship (XFN)') ?></h3>
+<div class="dbx-content">
+<table class="editform" width="100%" cellspacing="2" cellpadding="5">
+ <tr>
+ <th width="20%" scope="row"><?php _e('rel:') ?></th>
+ <td width="80%"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo $link->link_rel; ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('<a href="http://gmpg.org/xfn/">XFN</a> Creator:') ?></th>
+ <td>
+ <table cellpadding="3" cellspacing="5">
+ <tr>
+ <th scope="row"> <?php _e('identity') ?> </th>
+ <td>
+ <label for="me">
+ <input type="checkbox" name="identity" value="me" id="me" <?php xfn_check('identity', 'me'); ?> />
+ <?php _e('another web address of mine') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('friendship') ?> </th>
+ <td>
+ <label for="contact">
+ <input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact', 'radio'); ?> /> <?php _e('contact') ?></label>
+ <label for="acquaintance">
+ <input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance', 'radio'); ?> /> <?php _e('acquaintance') ?></label>
+ <label id="friend">
+ <input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend', 'radio'); ?> /> <?php _e('friend') ?></label>
+ <label for="friendship">
+ <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship', '', 'radio'); ?> /> <?php _e('none') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('physical') ?> </th>
+ <td>
+ <label for="met">
+ <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> />
+ <?php _e('met') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('professional') ?> </th>
+ <td>
+ <label for="co-worker">
+ <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> />
+ <?php _e('co-worker') ?></label>
+ <label for="colleague">
+ <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> />
+ <?php _e('colleague') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('geographical') ?> </th>
+ <td>
+ <label for="co-resident">
+ <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident', 'radio'); ?> />
+ <?php _e('co-resident') ?></label>
+ <label for="neighbor">
+ <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor', 'radio'); ?> />
+ <?php _e('neighbor') ?></label>
+ <label for="geographical">
+ <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical', '', 'radio'); ?> />
+ <?php _e('none') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('family') ?> </th>
+ <td>
+ <label for="child">
+ <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child', 'radio'); ?> />
+ <?php _e('child') ?></label>
+ <label for="kin">
+ <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin', 'radio'); ?> />
+ <?php _e('kin') ?></label>
+ <label for="parent">
+ <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent', 'radio'); ?> />
+ <?php _e('parent') ?></label>
+ <label for="sibling">
+ <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling', 'radio'); ?> />
+ <?php _e('sibling') ?></label>
+ <label for="spouse">
+ <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse', 'radio'); ?> />
+ <?php _e('spouse') ?></label>
+ <label for="family">
+ <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family', '', 'radio'); ?> />
+ <?php _e('none') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('romantic') ?> </th>
+ <td>
+ <label for="muse">
+ <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> />
+ <?php _e('muse') ?></label>
+ <label for="crush">
+ <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> />
+ <?php _e('crush') ?></label>
+ <label for="date">
+ <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> />
+ <?php _e('date') ?></label>
+ <label for="romantic">
+ <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> />
+ <?php _e('sweetheart') ?></label>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+</div>
+</fieldset>
+
+<fieldset id="advanced" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Advanced') ?></h3>
+<div class="dbx-content">
+<table class="editform" width="100%" cellspacing="2" cellpadding="5">
+ <tr>
+ <th width="20%" scope="row"><?php _e('Image URI:') ?></th>
+ <td width="80%"><input type="text" name="link_image" size="50" value="<?php echo $link->link_image; ?>" style="width: 95%" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('RSS URI:') ?> </th>
+ <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo $link->link_rss; ?>" size="50" style="width: 95%" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Notes:') ?></th>
+ <td><textarea name="link_notes" cols="50" rows="10" style="width: 95%"><?php echo $link->link_notes; ?></textarea></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Rating:') ?></th>
+ <td><select name="link_rating" size="1">
+ <?php
+ for ($r = 0; $r < 10; $r++) {
+ echo(' <option value="'.$r.'" ');
+ if ($link->link_rating == $r)
+ echo 'selected="selected"';
+ echo('>'.$r.'</option>');
+ }
+ ?></select>&nbsp;<?php _e('(Leave at 0 for no rating.)') ?>
+ </td>
+ </tr>
+</table>
+</fieldset>
+</div>
+
+<?php if ( $link_id ) : ?>
+<input type="hidden" name="action" value="save" />
+<input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" />
+<input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" />
+<input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
+<?php else: ?>
+<input type="hidden" name="action" value="add" />
+<?php endif; ?>
+</div>
+</form>
+</div>
diff --git a/wp-admin/edit-page-form.php b/wp-admin/edit-page-form.php
new file mode 100644
index 0000000..530f979
--- /dev/null
+++ b/wp-admin/edit-page-form.php
@@ -0,0 +1,194 @@
+
+<div class="wrap">
+<h2 id="write-post"><?php _e('Write Page'); ?><?php if ( 0 != $post_ID ) : ?>
+<small class="quickjump"><a href="#preview-post"><?php _e('preview &darr;'); ?></a></small><?php endif; ?></h2>
+<?php
+if (0 == $post_ID) {
+ $form_action = 'post';
+ $nonce_action = 'add-page';
+ $temp_ID = -1 * time();
+ $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />";
+} else {
+ $form_action = 'editpost';
+ $nonce_action = 'update-page_' . $post_ID;
+ $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";
+}
+
+$sendto = $_SERVER['HTTP_REFERER'];
+
+if ( 0 != $post_ID && $sendto == get_permalink($post_ID) )
+ $sendto = 'redo';
+$sendto = wp_specialchars( $sendto );
+
+?>
+
+<form name="post" action="page.php" method="post" id="post">
+
+<?php
+wp_nonce_field($nonce_action);
+
+if (isset($mode) && 'bookmarklet' == $mode) {
+ echo '<input type="hidden" name="mode" value="bookmarklet" />';
+}
+?>
+<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
+<input type="hidden" name="action" value='<?php echo $form_action ?>' />
+<?php echo $form_extra ?>
+<input type="hidden" name="post_type" value="page" />
+
+<script type="text/javascript">
+<!--
+function focusit() { // focus on first input field
+ document.post.title.focus();
+}
+addLoadEvent(focusit);
+//-->
+</script>
+<div id="poststuff">
+
+<div id="moremeta">
+<div id="grabit" class="dbx-group">
+<fieldset id="commentstatusdiv" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Discussion') ?></h3>
+<div class="dbx-content">
+<input name="advanced_view" type="hidden" value="1" />
+<label for="comment_status" class="selectit">
+<input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> />
+<?php _e('Allow Comments') ?></label>
+<label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php _e('Allow Pings') ?></label>
+</div>
+</fieldset>
+
+<fieldset class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Page Status') ?></h3>
+<div class="dbx-content"><?php if ( current_user_can('publish_pages') ) : ?>
+<label for="post_status_publish" class="selectit"><input id="post_status_publish" name="post_status" type="radio" value="publish" <?php checked($post->post_status, 'publish'); checked($post->post_status, 'future'); ?> /> <?php _e('Published') ?></label>
+<?php endif; ?>
+ <label for="post_status_draft" class="selectit"><input id="post_status_draft" name="post_status" type="radio" value="draft" <?php checked($post->post_status, 'draft'); ?> /> <?php _e('Draft') ?></label>
+ <label for="post_status_private" class="selectit"><input id="post_status_private" name="post_status" type="radio" value="private" <?php checked($post->post_status, 'private'); ?> /> <?php _e('Private') ?></label></div>
+</fieldset>
+
+<fieldset id="passworddiv" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Password-Protect Page') ?></h3>
+<div class="dbx-content"><input name="post_password" type="text" size="13" id="post_password" value="<?php echo $post->post_password ?>" /></div>
+</fieldset>
+
+<fieldset id="pageparent" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Page Parent') ?></h3>
+<div class="dbx-content"><p><select name="parent_id">
+<option value='0'><?php _e('Main Page (no parent)'); ?></option>
+<?php parent_dropdown($post->post_parent); ?>
+</select></p>
+</div>
+</fieldset>
+
+<?php if ( 0 != count( get_page_templates() ) ) { ?>
+<fieldset id="pageparent" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Page Template:') ?></h3>
+<div class="dbx-content"><p><select name="page_template">
+ <option value='default'><?php _e('Default Template'); ?></option>
+ <?php page_template_dropdown($post->page_template); ?>
+ </select></p>
+</div>
+</fieldset>
+<?php } ?>
+
+<fieldset id="slugdiv" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Page slug') ?></h3>
+<div class="dbx-content"><input name="post_name" type="text" size="13" id="post_name" value="<?php echo $post->post_name ?>" /></div>
+</fieldset>
+
+<?php if ( $authors = get_editable_authors( $current_user->id ) ) : // TODO: ROLE SYSTEM ?>
+<fieldset id="authordiv" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Page author'); ?>:</h3>
+<div class="dbx-content">
+<select name="post_author_override" id="post_author_override">
+<?php
+foreach ($authors as $o) :
+$o = get_userdata( $o->ID );
+if ( $post->post_author == $o->ID || ( empty($post_ID) && $user_ID == $o->ID ) ) $selected = 'selected="selected"';
+else $selected = '';
+echo "<option value='$o->ID' $selected>$o->display_name</option>";
+endforeach;
+?>
+</select>
+</div>
+</fieldset>
+<?php endif; ?>
+
+<fieldset id="pageorder" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Page Order') ?></h3>
+<div class="dbx-content"><p><input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo $post->menu_order ?>" /></p></div>
+</fieldset>
+
+<?php do_action('dbx_page_sidebar'); ?>
+
+</div>
+</div>
+
+<fieldset id="titlediv">
+ <legend><?php _e('Page Title') ?></legend>
+ <div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo $post->post_title; ?>" id="title" /></div>
+</fieldset>
+
+
+<fieldset id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>">
+ <legend><?php _e('Page Content') ?></legend>
+ <?php the_editor($post->post_content); ?>
+</fieldset>
+
+<p class="submit">
+<input name="save" type="submit" id="save" tabindex="3" value="<?php _e('Save and Continue Editing'); ?>" />
+<input type="submit" name="submit" value="<?php _e('Save') ?>" style="font-weight: bold;" tabindex="4" />
+<?php
+if ('publish' != $post->post_status || 0 == $post_ID):
+?>
+<?php if ( current_user_can('publish_pages') ) : ?>
+ <input name="publish" type="submit" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" />
+<?php endif; endif;?>
+<input name="referredby" type="hidden" id="referredby" value="<?php echo $sendto; ?>" />
+</p>
+
+<?php do_action('edit_page_form'); ?>
+
+<?php
+if (current_user_can('upload_files')) {
+ $uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID);
+ $uploading_iframe_src = wp_nonce_url("inline-uploading.php?action=view&amp;post=$uploading_iframe_ID", 'inlineuploading');
+ $uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
+ if ( false != $uploading_iframe_src )
+ echo '<iframe id="uploading" border="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
+}
+?>
+
+<div id="advancedstuff" class="dbx-group">
+
+<fieldset id="postcustom" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Custom Fields') ?></h3>
+<div id="postcustomstuff" class="dbx-content">
+<table cellpadding="3">
+<?php
+$metadata = has_meta($post_ID);
+list_meta($metadata);
+?>
+
+</table>
+<?php
+ meta_form();
+?>
+</div>
+</fieldset>
+
+<?php do_action('dbx_page_advanced'); ?>
+
+</div>
+
+<?php if ('edit' == $action) :
+ if ( current_user_can('delete_page', $post->ID) ) ?>
+ <input name="deletepost" class="delete" type="submit" id="deletepost" tabindex="10" value="<?php _e('Delete this page') ?>" <?php echo "onclick=\"return confirm('" . sprintf(__("You are about to delete this page \'%s\'\\n \'Cancel\' to stop, \'OK\' to delete."), $wpdb->escape($post->post_title) ) . "')\""; ?> />
+<?php endif; ?>
+</form>
+
+</div>
+
+</div>
diff --git a/wp-admin/edit-pages.php b/wp-admin/edit-pages.php
new file mode 100644
index 0000000..ce169b8
--- /dev/null
+++ b/wp-admin/edit-pages.php
@@ -0,0 +1,62 @@
+<?php
+require_once('admin.php');
+$title = __('Pages');
+$parent_file = 'edit.php';
+wp_enqueue_script( 'listman' );
+require_once('admin-header.php');
+?>
+
+<div class="wrap">
+<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">
+ <fieldset>
+ <legend><?php _e('Search Pages&hellip;') ?></legend>
+ <input type="text" name="s" value="<?php if (isset($_GET['s'])) echo wp_specialchars($_GET['s'], 1); ?>" size="17" />
+ <input type="submit" name="submit" value="<?php _e('Search') ?>" />
+ </fieldset>
+</form>
+
+<?php
+wp('post_type=page&orderby=menu_order&what_to_show=posts&posts_per_page=-1&posts_per_archive_page=-1');
+
+if ( $_GET['s'] )
+ $all = false;
+else
+ $all = true;
+
+if ($posts) {
+?>
+<table class="widefat">
+ <thead>
+ <tr>
+ <th scope="col"><?php _e('ID') ?></th>
+ <th scope="col" style="text-align: left"><?php _e('Title') ?></th>
+ <th scope="col" style="text-align: left"><?php _e('Owner') ?></th>
+ <th scope="col" style="text-align: left"><?php _e('Updated') ?></th>
+ <th scope="col" colspan="3"><?php _e('Action'); ?></th>
+ </tr>
+ </thead>
+ <tbody id="the-list">
+<?php
+page_rows(0, 0, $posts, $all);
+?>
+ </tbody>
+</table>
+
+<div id="ajax-response"></div>
+
+<?php
+} else {
+?>
+<p><?php _e('No pages yet.') ?></p>
+<?php
+} // end if ($posts)
+?>
+
+<h3><a href="page-new.php"><?php _e('Create New Page &raquo;'); ?></a></h3>
+
+</div>
+
+<?php include('admin-footer.php'); ?>
diff --git a/wp-admin/edit.php b/wp-admin/edit.php
new file mode 100644
index 0000000..a39338d
--- /dev/null
+++ b/wp-admin/edit.php
@@ -0,0 +1,296 @@
+<?php
+require_once('admin.php');
+
+$title = __('Posts');
+$parent_file = 'edit.php';
+wp_enqueue_script( 1 == $_GET['c'] ? 'admin-comments' : 'listman' );
+require_once('admin-header.php');
+
+$_GET['m'] = (int) $_GET['m'];
+
+$drafts = get_users_drafts( $user_ID );
+$other_drafts = get_others_drafts( $user_ID);
+
+if ($drafts || $other_drafts) {
+?>
+<div class="wrap">
+<?php if ($drafts) { ?>
+ <p><strong><?php _e('Your Drafts:') ?></strong>
+ <?php
+ $i = 0;
+ foreach ($drafts as $draft) {
+ if (0 != $i)
+ echo ', ';
+ $draft->post_title = stripslashes($draft->post_title);
+ if ($draft->post_title == '')
+ $draft->post_title = sprintf(__('Post #%s'), $draft->ID);
+ echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
+ ++$i;
+ }
+ ?>
+ .</p>
+<?php } ?>
+
+<?php if ($other_drafts) { ?>
+ <p><strong><?php _e('Other&#8217;s Drafts:') ?></strong>
+ <?php
+ $i = 0;
+ foreach ($other_drafts as $draft) {
+ if (0 != $i)
+ echo ', ';
+ $draft->post_title = stripslashes($draft->post_title);
+ if ($draft->post_title == '')
+ $draft->post_title = sprintf(__('Post #%s'), $draft->ID);
+ echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
+ ++$i;
+ }
+ ?>
+ .</p>
+
+<?php } ?>
+
+</div>
+<?php } ?>
+
+<div class="wrap">
+<h2>
+<?php
+
+wp('what_to_show=posts&posts_per_page=15&posts_per_archive_page=-1');
+
+if ( is_month() ) {
+ single_month_title(' ');
+} elseif ( is_search() ) {
+ printf(__('Search for &#8220;%s&#8221;'), wp_specialchars($_GET['s']) );
+} else {
+ if ( is_single() )
+ printf(__('Comments on %s'), $post->post_title);
+ elseif ( ! is_paged() || get_query_var('paged') == 1 )
+ _e('Last 15 Posts');
+ else
+ _e('Previous Posts');
+}
+?>
+</h2>
+
+<form name="searchform" action="" method="get" style="float: left; width: 16em; margin-right: 3em;">
+ <fieldset>
+ <legend><?php _e('Search Posts&hellip;') ?></legend>
+ <input type="text" name="s" value="<?php if (isset($s)) echo wp_specialchars($s, 1); ?>" size="17" />
+ <input type="submit" name="submit" value="<?php _e('Search') ?>" />
+ </fieldset>
+</form>
+
+<?php $arc_result = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC");
+
+if ( count($arc_result) ) { ?>
+
+<form name="viewarc" action="" method="get" style="float: left; width: 20em; margin-bottom: 1em;">
+ <fieldset>
+ <legend><?php _e('Browse Month&hellip;') ?></legend>
+ <select name='m'>
+ <?php
+ foreach ($arc_result as $arc_row) {
+ if ( $arc_row->yyear == 0 )
+ continue;
+ $arc_row->mmonth = zeroise($arc_row->mmonth, 2);
+
+ if( isset($_GET['m']) && $arc_row->yyear . $arc_row->mmonth == (int) $_GET['m'] )
+ $default = 'selected="selected"';
+ else
+ $default = null;
+
+ echo "<option $default value='$arc_row->yyear$arc_row->mmonth'>";
+ echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear";
+ echo "</option>\n";
+ }
+ ?>
+ </select>
+ <input type="submit" name="submit" value="<?php _e('Show Month') ?>" />
+ </fieldset>
+</form>
+
+<?php } ?>
+
+<br style="clear:both;" />
+
+<?php
+// define the columns to display, the syntax is 'internal name' => 'display name'
+$posts_columns = array(
+ 'id' => __('ID'),
+ 'date' => __('When'),
+ 'title' => __('Title'),
+ 'categories' => __('Categories'),
+ 'comments' => __('Comments'),
+ 'author' => __('Author')
+);
+$posts_columns = apply_filters('manage_posts_columns', $posts_columns);
+
+// you can not edit these at the moment
+$posts_columns['control_view'] = '';
+$posts_columns['control_edit'] = '';
+$posts_columns['control_delete'] = '';
+
+?>
+
+<table class="widefat">
+ <thead>
+ <tr>
+
+<?php foreach($posts_columns as $column_display_name) { ?>
+ <th scope="col"><?php echo $column_display_name; ?></th>
+<?php } ?>
+
+ </tr>
+ </thead>
+ <tbody id="the-list">
+<?php
+if ($posts) {
+$bgcolor = '';
+foreach ($posts as $post) { start_wp();
+add_filter('the_title','wp_specialchars');
+$class = ('alternate' == $class) ? '' : 'alternate';
+?>
+ <tr id='post-<?php echo $id; ?>' class='<?php echo $class; ?>'>
+
+<?php
+
+foreach($posts_columns as $column_name=>$column_display_name) {
+
+ switch($column_name) {
+
+ case 'id':
+ ?>
+ <th scope="row"><?php echo $id ?></th>
+ <?php
+ break;
+
+ case 'date':
+ ?>
+ <td><?php the_time('Y-m-d \<\b\r \/\> g:i:s a'); ?></td>
+ <?php
+ break;
+ case 'title':
+ ?>
+ <td><?php the_title() ?>
+ <?php if ('private' == $post->post_status) _e(' - <strong>Private</strong>'); ?></td>
+ <?php
+ break;
+
+ case 'categories':
+ ?>
+ <td><?php the_category(','); ?></td>
+ <?php
+ break;
+
+ case 'comments':
+ ?>
+ <td style="text-align: center"><a href="edit.php?p=<?php echo $id ?>&amp;c=1">
+ <?php comments_number(__('0'), __('1'), __('%')) ?>
+ </a></td>
+ <?php
+ break;
+
+ case 'author':
+ ?>
+ <td><?php the_author() ?></td>
+ <?php
+ break;
+
+ case 'control_view':
+ ?>
+ <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
+ <?php
+ break;
+
+ case 'control_edit':
+ ?>
+ <td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
+ <?php
+ break;
+
+ case 'control_delete':
+ ?>
+ <td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post_' . $post->ID) . "' class='delete' onclick=\"return deleteSomething( 'post', " . $id . ", '" . sprintf(__("You are about to delete this post &quot;%s&quot;.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), js_escape(get_the_title()) ) . "' );\">" . __('Delete') . "</a>"; } ?></td>
+ <?php
+ break;
+
+ default:
+ ?>
+ <td><?php do_action('manage_posts_custom_column', $column_name, $id); ?></td>
+ <?php
+ break;
+ }
+}
+?>
+ </tr>
+<?php
+}
+} else {
+?>
+ <tr style='background-color: <?php echo $bgcolor; ?>'>
+ <td colspan="8"><?php _e('No posts found.') ?></td>
+ </tr>
+<?php
+} // end if ($posts)
+?>
+ </tbody>
+</table>
+
+<div id="ajax-response"></div>
+
+<div class="navigation">
+<div class="alignleft"><?php next_posts_link(__('&laquo; Previous Entries')) ?></div>
+<div class="alignright"><?php previous_posts_link(__('Next Entries &raquo;')) ?></div>
+</div>
+
+<?php
+if ( 1 == count($posts) ) {
+
+ $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved != 'spam' ORDER BY comment_date");
+ if ($comments) {
+ ?>
+<h3 id="comments"><?php _e('Comments') ?></h3>
+<ol id="the-comment-list" class="commentlist">
+<?php
+$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() ?>
+
+<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;comment=".$comment->comment_ID."\'>" . __('Edit') . '</a>';
+ echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), js_escape($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=' . $post->ID . '&amp;comment=' . $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=' . $post->ID . '&amp;comment=' . $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;delete_type=spam&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . sprintf(__("You are about to mark as spam this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to mark as spam."), js_escape( $comment->comment_author)) . "', theCommentList );\">" . __('Spam') . "</a> ]";
+} // end if any comments to show
+?>
+</p>
+ </li>
+
+<?php //end of the loop, don't delete
+ } // end foreach
+ echo '</ol>';
+ }//end if comments
+ ?>
+<?php } ?>
+</div>
+<?php
+ include('admin-footer.php');
+?>
diff --git a/wp-admin/export.php b/wp-admin/export.php
new file mode 100644
index 0000000..8894f29
--- /dev/null
+++ b/wp-admin/export.php
@@ -0,0 +1,106 @@
+<?php
+require_once ('admin.php');
+$title = __('Export');
+$parent_file = 'edit.php';
+
+if ( isset( $_GET['download'] ) )
+ export_wp();
+
+require_once ('admin-header.php');
+?>
+
+<div class="wrap">
+<h2><?php _e('Export'); ?></h2>
+<p><?php _e('This will allow you to download an export of your WordPress posts and comments in a XML format.'); ?></p>
+<p>We need some more text here. Maybe talking about the export file or how to save it.</p>
+<form action="" method="get">
+<p class="submit"><input type="submit" name="submit" value="<?php _e('Download Export File'); ?> &raquo;" />
+<input type="hidden" name="download" value="true" />
+</p>
+</form>
+</div>
+
+<?php
+
+function export_wp() {
+ global $wpdb, $posts, $post;
+ $filename = 'wordpress.' . date('Y-m-d') . '.xml';
+header('Content-Description: File Transfer');
+header('Content-Type: application/octet-stream');
+header("Content-Disposition: attachment; filename=$filename");
+header('Content-type: text/xml; charset=' . get_settings('blog_charset'), true);
+//$posts = query_posts('');
+$posts = $wpdb->get_results("SELECT * FROM $wpdb->posts ORDER BY post_date_gmt ASC");
+?>
+<!-- generator="wordpress/<?php bloginfo_rss('version') ?>" created="<?php echo date('Y-m-d H:m'); ?>"-->
+<rss version="2.0"
+ xmlns:content="http://purl.org/rss/1.0/modules/content/"
+ xmlns:wfw="http://wellformedweb.org/CommentAPI/"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:wp="http://wordpress.org/export/1.0/"
+>
+
+<channel>
+ <title><?php bloginfo_rss('name'); ?></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>
+ <generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>
+ <language><?php echo get_option('rss_language'); ?></language>
+ <?php do_action('rss2_head'); ?>
+ <?php if ($posts) { foreach ($posts as $post) { start_wp(); ?>
+<item>
+<title><?php the_title_rss() ?></title>
+<link><?php permalink_single_rss() ?></link>
+<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
+<dc:creator><?php the_author() ?></dc:creator>
+<?php the_category_rss() ?>
+
+<guid isPermaLink="false"><?php the_guid(); ?></guid>
+<description></description>
+<content:encoded><![CDATA[<?php echo $post->post_content ?>]]></content:encoded>
+<wp:post_date><?php echo $post->post_date; ?></wp:post_date>
+<wp:post_date_gmt><?php echo $post->post_date_gmt; ?></wp:post_date_gmt>
+<wp:comment_status><?php echo $post->comment_status; ?></wp:comment_status>
+<wp:ping_status><?php echo $post->ping_status; ?></wp:ping_status>
+<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:post_type><?php echo $post->post_type; ?></wp:post_type>
+<?php
+$postmeta = $wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE post_id = $post->ID");
+if ( $postmeta ) {
+?>
+<?php foreach( $postmeta as $meta ) { ?>
+<wp:postmeta>
+<wp:meta_key><?php echo $meta->meta_key; ?></wp:meta_key>
+<wp:meta_value><?Php echo $meta->meta_value; ?></wp:meta_value>
+</wp:postmeta>
+<?php } ?>
+<?php } ?>
+<?php
+$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post->ID");
+if ( $comments ) { foreach ( $comments as $c ) { ?>
+<wp:comment>
+<wp:comment_author><?php echo $c->comment_author; ?></wp:comment_author>
+<wp:comment_author_email><?php echo $c->comment_author_email; ?></wp:comment_author_email>
+<wp:comment_author_url><?php echo $c->comment_author_url; ?></wp:comment_author_url>
+<wp:comment_author_IP><?php echo $c->comment_author_IP; ?></wp:comment_author_IP>
+<wp:comment_date><?php echo $c->comment_date; ?></wp:comment_date>
+<wp:comment_date_gmt><?php echo $c->comment_date_gmt; ?></wp:comment_date_gmt>
+<wp:comment_content><?php echo $c->comment_content; ?></wp:comment_content>
+<wp:comment_approved><?php echo $c->comment_approved; ?></wp:comment_approved>
+<wp:comment_type><?php echo $c->comment_type; ?></wp:comment_type>
+<wp:comment_parent><?php echo $c->comment_parent; ?></wp:comment_parent>
+</wp:comment>
+<?php } } ?>
+ </item>
+<?php } } ?>
+</channel>
+</rss>
+<?php
+ die();
+}
+
+include ('admin-footer.php');
+?> \ No newline at end of file
diff --git a/wp-admin/images/box-bg.gif b/wp-admin/images/box-bg.gif
new file mode 100644
index 0000000..2eb7f58
--- /dev/null
+++ b/wp-admin/images/box-bg.gif
Binary files differ
diff --git a/wp-admin/images/box-butt.gif b/wp-admin/images/box-butt.gif
new file mode 100644
index 0000000..514a165
--- /dev/null
+++ b/wp-admin/images/box-butt.gif
Binary files differ
diff --git a/wp-admin/images/box-head.gif b/wp-admin/images/box-head.gif
new file mode 100644
index 0000000..5c09a9a
--- /dev/null
+++ b/wp-admin/images/box-head.gif
Binary files differ
diff --git a/wp-admin/images/browse-happy.gif b/wp-admin/images/browse-happy.gif
new file mode 100644
index 0000000..09f13bc
--- /dev/null
+++ b/wp-admin/images/browse-happy.gif
Binary files differ
diff --git a/wp-admin/images/fade-butt.png b/wp-admin/images/fade-butt.png
new file mode 100644
index 0000000..42f08b7
--- /dev/null
+++ b/wp-admin/images/fade-butt.png
Binary files differ
diff --git a/wp-admin/images/notice.gif b/wp-admin/images/notice.gif
new file mode 100644
index 0000000..ba6eab0
--- /dev/null
+++ b/wp-admin/images/notice.gif
Binary files differ
diff --git a/wp-admin/images/toggle.gif b/wp-admin/images/toggle.gif
new file mode 100644
index 0000000..72e8b44
--- /dev/null
+++ b/wp-admin/images/toggle.gif
Binary files differ
diff --git a/wp-admin/images/wordpress-logo.png b/wp-admin/images/wordpress-logo.png
new file mode 100644
index 0000000..7d8e672
--- /dev/null
+++ b/wp-admin/images/wordpress-logo.png
Binary files differ
diff --git a/wp-admin/import.php b/wp-admin/import.php
new file mode 100644
index 0000000..cd1951a
--- /dev/null
+++ b/wp-admin/import.php
@@ -0,0 +1,62 @@
+<?php
+require_once ('admin.php');
+$title = __('Import');
+$parent_file = 'edit.php';
+require_once ('admin-header.php');
+?>
+
+<div class="wrap">
+<h2><?php _e('Import'); ?></h2>
+<p><?php _e('If you have posts or comments in another system WordPress can import them into your current blog. To get started, choose a system to import from below:'); ?></p>
+
+<?php
+
+// Load all importers so that they can register.
+$import_loc = 'wp-admin/import';
+$import_root = ABSPATH.$import_loc;
+$imports_dir = @ dir($import_root);
+if ($imports_dir) {
+ while (($file = $imports_dir->read()) !== false) {
+ if (preg_match('|^\.+$|', $file))
+ continue;
+ if (preg_match('|\.php$|', $file))
+ require_once("$import_root/$file");
+ }
+}
+
+$importers = get_importers();
+
+if (empty ($importers)) {
+ echo '<p>'.__('No importers are available.').'</p>'; // TODO: make more helpful
+} else {
+?>
+<table class="widefat">
+
+<?php
+ $style = '';
+ foreach ($importers as $id => $data) {
+ $style = ('class="alternate"' == $style || 'class="alternate active"' == $style) ? '' : 'alternate';
+ $action = "<a href='admin.php?import=$id' title='{$data[1]}'>{$data[0]}</a>";
+
+ if ($style != '')
+ $style = 'class="'.$style.'"';
+ echo "
+ <tr $style>
+ <td class='import-system'>$action</td>
+ <td class='desc'>{$data[1]}</td>
+ </tr>";
+ }
+?>
+
+</table>
+<?php
+}
+?>
+
+</div>
+
+<?php
+
+include ('admin-footer.php');
+?>
+
diff --git a/wp-admin/import/b2.php b/wp-admin/import/b2.php
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/wp-admin/import/b2.php
diff --git a/wp-admin/import/blogger.php b/wp-admin/import/blogger.php
new file mode 100644
index 0000000..8de766c
--- /dev/null
+++ b/wp-admin/import/blogger.php
@@ -0,0 +1,675 @@
+<?php
+
+class Blogger_Import {
+
+ var $lump_authors = true;
+ var $import = array();
+
+ // Shows the welcome screen and the magic iframe.
+ function greet() {
+ $title = __('Import Blogger');
+ $welcome = __('Howdy! This importer allows you to import posts and comments from your Blogger account into your WordPress blog.');
+ $noiframes = __('This feature requires iframe support.');
+ $warning = __('This will delete everything saved by the Blogger importer except your posts and comments. Are you sure you want to do this?');
+ $reset = __('Reset this importer');
+ $incompat = __('Your web server is not properly configured to use this importer. Please enable the CURL extension for PHP and then reload this page.');
+
+ echo "<div class='wrap'><h2>$title</h2><p>$welcome</p>";
+ if ( function_exists('curl_init') )
+ echo "<iframe src='admin.php?import=blogger&amp;noheader=true' height='350px' width = '99%'>$noiframes</iframe><p><a href='admin.php?import=blogger&amp;restart=true&amp;noheader=true' onclick='return confirm(\"$warning\")'>$reset</a></p>";
+ else
+ echo "<p>$incompat</p>";
+ echo "</div>\n";
+ }
+
+ function reencode($text) {
+ return $text;
+ return mb_convert_encoding($text, get_setting('blog_charset'), $this->import['blogs'][$_GET['blog']]['options']['blog-formatting']['backup']['encoding']);
+ }
+
+ // Deletes saved data and redirect.
+ function restart() {
+ delete_option('import-blogger');
+ header("Location: admin.php?import=blogger");
+ die();
+ }
+
+ // Generates a string that will make the page reload in a specified interval.
+ function refresher($msec) {
+ if ( $msec )
+ return "<html><head><script type='text/javascript'>window.onload=setTimeout('window.location.reload()', $msec);</script>\n</head>\n<body>\n";
+ else
+ return "<html><head><script type='text/javascript'>window.onload=window.location.reload();</script>\n</head>\n<body>\n";
+ }
+
+ // Returns associative array of code, header, cookies, body. Based on code from php.net.
+ function parse_response($this_response) {
+ // Split response into header and body sections
+ list($response_headers, $response_body) = explode("\r\n\r\n", $this_response, 2);
+ $response_header_lines = explode("\r\n", $response_headers);
+
+ // First line of headers is the HTTP response code
+ $http_response_line = array_shift($response_header_lines);
+ if(preg_match('@^HTTP/[0-9]\.[0-9] ([0-9]{3})@',$http_response_line, $matches)) { $response_code = $matches[1]; }
+
+ // put the rest of the headers in an array
+ $response_header_array = array();
+ foreach($response_header_lines as $header_line) {
+ list($header,$value) = explode(': ', $header_line, 2);
+ $response_header_array[$header] .= $value."\n";
+ }
+
+ $cookie_array = array();
+ $cookies = explode("\n", $response_header_array["Set-Cookie"]);
+ foreach($cookies as $this_cookie) { array_push($cookie_array, "Cookie: ".$this_cookie); }
+
+ return array("code" => $response_code, "header" => $response_header_array, "cookies" => $cookie_array, "body" => $response_body);
+ }
+
+ // Prints a form for the user to enter Blogger creds.
+ function login_form($text='') {
+ echo '<h1>' . __('Log in to Blogger') . "</h1>\n$text\n";
+ echo '<form method="post" action="admin.php?import=blogger&amp;noheader=true&amp;step=0"><table><tr><td>' . __('Username') . ':</td><td><input type="text" name="user" /></td></tr><tr><td>' . __('Password') . ':</td><td><input type="password" name="pass" /></td><td><input type="submit" value="' . __('Start') . '" /></td></tr></table></form>';
+ die;
+ }
+
+ // Sends creds to Blogger, returns the session cookies an array of headers.
+ function login_blogger($user, $pass) {
+ $_url = 'http://www.blogger.com/login.do';
+ $params = "username=$user&password=$pass";
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_POST,1);
+ curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
+ curl_setopt($ch, CURLOPT_URL,$_url);
+ curl_setopt($ch, CURLOPT_USERAGENT, 'Blogger Exporter');
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
+ curl_setopt($ch, CURLOPT_HEADER,1);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
+ $response = curl_exec ($ch);
+
+ $response = $this->parse_response($response);
+
+ sleep(1);
+
+ return $response['cookies'];
+ }
+
+ // Requests page from Blogger, returns the response array.
+ function get_blogger($url, $header = '', $user=false, $pass=false) {
+ $ch = curl_init();
+ if ($user && $pass) curl_setopt($ch, CURLOPT_USERPWD,"{$user}:{$pass}");
+ curl_setopt($ch, CURLOPT_URL,$url);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 20);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
+ curl_setopt($ch, CURLOPT_USERAGENT, 'Blogger Exporter');
+ curl_setopt($ch, CURLOPT_HEADER,1);
+ if (is_array($header)) curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
+ $response = curl_exec ($ch);
+
+ $response = $this->parse_response($response);
+ $response['url'] = $url;
+
+ if (curl_errno($ch)) {
+ print curl_error($ch);
+ } else {
+ curl_close($ch);
+ }
+
+ return $response;
+ }
+
+ // Posts data to Blogger, returns response array.
+ function post_blogger($url, $header = false, $paramary = false, $parse=true) {
+ $params = '';
+ if ( is_array($paramary) ) {
+ foreach($paramary as $key=>$value)
+ if($key && $value != '')
+ $params.=$key."=".urlencode(stripslashes($value))."&";
+ }
+ if ($user && $pass) $params .= "username=$user&password=$pass";
+ $params = trim($params,'&');
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_POST,1);
+ curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
+ if ($user && $pass) curl_setopt($ch, CURLOPT_USERPWD,"{$user}:{$pass}");
+ curl_setopt($ch, CURLOPT_URL,$url);
+ curl_setopt($ch, CURLOPT_USERAGENT, 'Blogger Exporter');
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
+ curl_setopt($ch, CURLOPT_HEADER,$parse);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
+ if ($header) curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
+ $response = curl_exec ($ch);
+
+ if ($parse) {
+ $response = $this->parse_response($response);
+ $response['url'] = $url;
+ return $response;
+ }
+
+ return $response;
+ }
+
+ // Prints the list of blogs for import.
+ function show_blogs() {
+ global $import;
+ echo '<h1>' . __('Selecting a Blog') . "</h1>\n<ul>";
+ foreach ( $this->import['blogs'] as $blog ) {
+ if (9 == $blog['nextstep']) $status = "100%";
+ elseif (8 == $blog['nextstep']) $status = "90%";
+ elseif (7 == $blog['nextstep']) $status = "82.5%";
+ elseif (6 == $blog['nextstep']) $status = "75%";
+ elseif (5 == $blog['nextstep']) $status = "57%";
+ elseif (4 == $blog['nextstep']) $status = "28%";
+ elseif (3 == $blog['nextstep']) $status = "14%";
+ else $status = "0%";
+ echo "\t<li><a href='admin.php?import=blogger&amp;noheader=true&amp;blog={$blog['id']}'>{$blog['title']}</a> $status</li>\n";
+ }
+ die("</ul>\n");
+ }
+
+ // Publishes.
+ function publish_blogger($i, $text) {
+ $head = $this->refresher(2000) . "<h1>$text</h1>\n";
+ if ( ! strstr($this->import['blogs'][$_GET['blog']]['publish'][$i], 'http') ) {
+ // First call. Start the publish process with a fresh set of cookies.
+ $this->import['cookies'] = $this->login_blogger($this->import['user'], $this->import['pass']);
+ update_option('import-blogger', $this->import);
+ $paramary = array('blogID' => $_GET['blog'], 'all' => '1', 'republishAll' => 'Republish Entire Blog', 'publish' => '1', 'redirectUrl' => "/publish.do?blogID={$_GET['blog']}&inprogress=true");
+
+ $response = $this->post_blogger("http://www.blogger.com/publish.do?blogID={$_GET['blog']}", $this->import['cookies'], $paramary);
+ if ( $response['code'] == '302' ) {
+ $url = str_replace('publish.g', 'publish-body.g', $response['header']['Location']);
+ $this->import['blogs'][$_GET['blog']]['publish'][$i] = $url;
+ update_option('import-blogger', $this->import);
+ $response = $this->get_blogger($url, $this->import['cookies']);
+ preg_match('#<p class="progressIndicator">.*</p>#U', $response['body'], $matches);
+ $progress = $matches[0];
+ die($head . $progress);
+ } else {
+ $this->import['blogs'][$_GET['blog']]['publish'][$i] = false;
+ update_option('import-blogger', $this->import);
+ die($head);
+ }
+ } else {
+ // Subsequent call. Keep checking status until Blogger reports publish complete.
+ $url = $this->import['blogs'][$_GET['blog']]['publish'][$i];
+ $response = $this->get_blogger($url, $this->import['cookies']);
+ if ( preg_match('#<p class="progressIndicator">.*</p>#U', $response['body'], $matches) ) {
+ $progress = $matches[0];
+ if ( strstr($progress, '100%') ) {
+ $this->set_next_step($i);
+ $progress .= '<p>'.__('Moving on...').'</p>';
+ }
+ die($head . $progress);
+ } else {
+ $this->import['blogs'][$_GET['blog']]['publish'][$i] = false;
+ update_option('import-blogger', $this->import);
+ die("$head<p>" . __('Trying again...') . '</p>');
+ }
+ }
+ }
+
+ // Sets next step, saves options
+ function set_next_step($step) {
+ $this->import['blogs'][$_GET['blog']]['nextstep'] = $step;
+ update_option('import-blogger', $this->import);
+ }
+
+ // Redirects to next step
+ function do_next_step() {
+ header("Location: admin.php?import=blogger&noheader=true&blog={$_GET['blog']}");
+ die();
+ }
+
+ // Step 0: Do Blogger login, get blogid/title pairs.
+ function do_login() {
+ if ( ( ! $this->import['user'] && ! is_array($this->import['cookies']) ) ) {
+ // The user must provide a Blogger username and password.
+ if ( ! ( $_POST['user'] && $_POST['pass'] ) ) {
+ $this->login_form(__('The script will log into your Blogger account, change some settings so it can read your blog, and restore the original settings when it\'s done. Here\'s what you do:').'</p><ol><li>'.__('Back up your Blogger template.').'</li><li>'.__('Back up any other Blogger settings you might need later.').'</li><li>'.__('Log out of Blogger').'</li><li>'.__('Log in <em>here</em> with your Blogger username and password.').'</li><li>'.__('On the next screen, click one of your Blogger blogs.').'</li><li>'.__('Do not close this window or navigate away until the process is complete.').'</li></ol>');
+ }
+
+ // Try logging in. If we get an array of cookies back, we at least connected.
+ $this->import['cookies'] = $this->login_blogger($_POST['user'], $_POST['pass']);
+ if ( !is_array( $this->import['cookies'] ) ) {
+ $this->login_form(__('Login failed. Please enter your credentials again.'));
+ }
+
+ // Save the password so we can log the browser in when it's time to publish.
+ $this->import['pass'] = $_POST['pass'];
+ $this->import['user'] = $_POST['user'];
+
+ // Get the Blogger welcome page and scrape the blog numbers and names from it
+ $response = $this->get_blogger('http://www.blogger.com/home', $this->import['cookies']);
+ if (! stristr($response['body'], 'signed in as') ) $this->login_form(__('Login failed. Please re-enter your username and password.'));
+ $blogsary = array();
+ preg_match_all('#posts\.g\?blogID=(\d+)">([^<]+)</a>#U', $response['body'], $blogsary);
+ if ( ! count( $blogsary[1] < 1 ) )
+ die(__('No blogs found for this user.'));
+ $this->import['blogs'] = array();
+ $template = '<!--<MainPage><BloggerArchives><a class="wparchive" href="<$BlogArchiveURL$>"><$BlogArchiveName$></a><br /></BloggerArchives></MainPage><ArchivePage><Blogger><wordpresspost><$BlogItemDateTime$>|W|P|<$BlogItemAuthorNickname$>|W|P|<$BlogItemBody$>|W|P|<$BlogItemNumber$>|W|P|<$BlogItemTitle$>|W|P|<$BlogItemAuthorEmail$><BlogItemCommentsEnabled><BlogItemComments><wordpresscomment><$BlogCommentDateTime$>|W|P|<$BlogCommentAuthor$>|W|P|<$BlogCommentBody$></BlogItemComments></BlogItemCommentsEnabled></Blogger></ArchivePage>-->';
+ foreach ( $blogsary[1] as $key => $id ) {
+ // Define the required Blogger options.
+ $blog_opts = array(
+ 'blog-options-basic' => false,
+ 'blog-options-archiving' => array('archiveFrequency' => 'm'),
+ 'blog-publishing' => array('publishMode'=>'0', 'blogID' => "$id", 'subdomain' => mt_rand().mt_rand(), 'pingWeblogs' => 'false'),
+ 'blog-formatting' => array('timeStampFormat' => '0', 'convertLineBreaks'=>'false', 'floatAlignment'=>'false'),
+ 'blog-comments' => array('commentsTimeStampFormat' => '0'),
+ 'template-edit' => array( 'templateText' => str_replace('%title%', trim($blogsary[2][$key]), $template) )
+ );
+
+ // Build the blog options array template
+ foreach ($blog_opts as $blog_opt => $modify)
+ $new_opts["$blog_opt"] = array('backup'=>false, 'modify' => $modify, 'error'=>false);
+
+ $this->import['blogs']["$id"] = array(
+ 'id' => $id,
+ 'title' => trim($blogsary[2][$key]),
+ 'options' => $new_opts,
+ 'url' => false,
+ 'publish_cookies' => false,
+ 'published' => false,
+ 'archives' => false,
+ 'lump_authors' => false,
+ 'newusers' => array(),
+ 'nextstep' => 2
+ );
+ }
+ update_option('import-blogger', $this->import);
+ header("Location: admin.php?import=blogger&noheader=true&step=1");
+ }
+ die();
+ }
+
+ // Step 1: Select one of the blogs belonging to the user logged in.
+ function select_blog() {
+ if ( is_array($this->import['blogs']) ) {
+ $this->show_blogs();
+ die();
+ } else {
+ $this->restart();
+ }
+ }
+
+ // Step 2: Backup the Blogger options pages, updating some of them.
+ function backup_settings() {
+ $output.= '<h1>'.__('Backing up Blogger options')."</h1>\n";
+ $form = false;
+ foreach ($this->import['blogs'][$_GET['blog']]['options'] as $blog_opt => $optary) {
+ if ( $blog_opt == $_GET['form'] ) {
+ // Save the posted form data
+ $this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['backup'] = $_POST;
+ update_option('import-blogger',$this->import);
+
+ // Post the modified form data to Blogger
+ if ( $optary['modify'] ) {
+ $posturl = "http://www.blogger.com/{$blog_opt}.do";
+ $headers = array_merge($this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['cookies'], $this->import['cookies']);
+ if ( 'blog-publishing' == $blog_opt ) {
+ if ( $_POST['publishMode'] > 0 ) {
+ $response = $this->get_blogger("http://www.blogger.com/blog-publishing.g?blogID={$_GET['blog']}&publishMode=0", $headers);
+ if ( $response['code'] >= 400 )
+ die('<h2>'.__('Failed attempt to change publish mode from FTP to BlogSpot.').'</h2><pre>' . addslashes(print_r($headers, 1)) . addslashes(print_r($response, 1)) . '</pre>');
+ $this->import['blogs'][$_GET['blog']]['url'] = 'http://' . $optary['modify']['subdomain'] . '.blogspot.com/';
+ sleep(2);
+ } else {
+ $this->import['blogs'][$_GET['blog']]['url'] = 'http://' . $_POST['subdomain'] . '.blogspot.com/';
+ update_option('import-blogger', $this->import);
+ $output .= "<del><p>$blog_opt</p></del>\n";
+ continue;
+ }
+ $paramary = $optary['modify'];
+ } elseif ( 'template-edit' == $blog_opt ) {
+ $optary['modify']['templateText'] = $_POST['templateText'] . $optary['modify']['templateText'];
+ $paramary = array_merge($_POST, $optary['modify']);
+ } else {
+ $paramary = array_merge($_POST, $optary['modify']);
+ }
+ $response = $this->post_blogger($posturl, $headers, $paramary);
+ if ( $response['code'] >= 400 || strstr($response['body'], 'There are errors on this form') )
+ die('<p>'.__('Error on form submission. Retry or reset the importer.').'</p>' . addslashes(print_r($response, 1)));
+ }
+ $output .= "<del><p>$blog_opt</p></del>\n";
+ } elseif ( is_array($this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['backup']) ) {
+ // This option set has already been backed up.
+ $output .= "<del><p>$blog_opt</p></del>\n";
+ } elseif ( ! $form ) {
+ // This option page needs to be downloaded and given to the browser for submission back to this script.
+ $response = $this->get_blogger("http://www.blogger.com/{$blog_opt}.g?blogID={$_GET['blog']}", $this->import['cookies']);
+ $this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['cookies'] = $response['cookies'];
+ update_option('import-blogger',$this->import);
+ $body = $response['body'];
+ $body = preg_replace("|\<!DOCTYPE.*\<body[^>]*>|ms","",$body);
+ $body = preg_replace("|/?{$blog_opt}.do|","admin.php?import=blogger&amp;noheader=true&amp;step=2&amp;blog={$_GET['blog']}&amp;form={$blog_opt}",$body);
+ $body = str_replace("name='submit'","name='supermit'",$body);
+ $body = str_replace('name="submit"','name="supermit"',$body);
+ $body = str_replace('</body>','',str_replace('</html>','',$body));
+ $form = "<div style='height:0px;width:0px;overflow:hidden;'>";
+ $form.= $body;
+ $form.= "</div><script type='text/javascript'>forms=document.getElementsByTagName('form');for(i=0;i<forms.length;i++){if(forms[i].action.search('{$blog_opt}')){forms[i].submit();break;}}</script>";
+ $output.= '<p>'.sprintf('<strong>%s</strong> in progress, please wait...', $blog_opt)."</p>\n";
+ } else {
+ $output.= "<p>$blog_opt</p>\n";
+ }
+ }
+ if ( $form )
+ die($output . $form);
+
+ $this->set_next_step(4);
+ $this->do_next_step();
+ }
+
+ // Step 3: Cancelled :-)
+
+ // Step 4: Publish with the new template and settings.
+ function publish_blog() {
+ $this->publish_blogger(5, __('Publishing with new template and options'));
+ }
+
+ // Step 5: Get the archive URLs from the new blog.
+ function get_archive_urls() {
+ $bloghtml = $this->get_blogger($this->import['blogs'][$_GET['blog']]['url']);
+ if (! strstr($bloghtml['body'], '<a class="wparchive"') )
+ die(__('Your Blogger blog did not take the new template or did not respond.'));
+ preg_match_all('#<a class="wparchive" href="([^"]*)"#', $bloghtml['body'], $archives);
+ foreach ($archives[1] as $archive) {
+ $this->import['blogs'][$_GET['blog']]['archives'][$archive] = false;
+ }
+ $this->set_next_step(6);
+ $this->do_next_step();
+ }
+
+ // Step 6: Get each monthly archive, import it, mark it done.
+ function get_archive() {
+ global $wpdb;
+ $output = '<h2>'.__('Importing Blogger archives into WordPress').'</h2>';
+ $did_one = false;
+ $post_array = $posts = array();
+ foreach ( $this->import['blogs'][$_GET['blog']]['archives'] as $url => $status ) {
+ $archivename = substr(basename($url),0,7);
+ if ( $status || $did_one ) {
+ $foo = 'bar';
+ // Do nothing.
+ } else {
+ // Import the selected month
+ $postcount = 0;
+ $skippedpostcount = 0;
+ $commentcount = 0;
+ $skippedcommentcount = 0;
+ $status = __('in progress...');
+ $this->import['blogs'][$_GET['blog']]['archives']["$url"] = $status;
+ update_option('import-blogger', $import);
+ $archive = $this->get_blogger($url);
+ if ( $archive['code'] > 200 )
+ continue;
+ $posts = explode('<wordpresspost>', $archive['body']);
+ for ($i = 1; $i < count($posts); $i = $i + 1) {
+ $postparts = explode('<wordpresscomment>', $posts[$i]);
+ $postinfo = explode('|W|P|', $postparts[0]);
+ $post_date = $postinfo[0];
+ $post_content = $postinfo[2];
+ // Don't try to re-use the original numbers
+ // because the new, longer numbers are too
+ // big to handle as ints.
+ //$post_number = $postinfo[3];
+ $post_title = ( $postinfo[4] != '' ) ? $postinfo[4] : $postinfo[3];
+ $post_author_name = $wpdb->escape(trim($postinfo[1]));
+ $post_author_email = $postinfo[5] ? $postinfo[5] : 'user@wordpress.org';
+
+ if ( $this->lump_authors ) {
+ // Ignore Blogger authors. Use the current user_ID for all posts imported.
+ $post_author = $GLOBALS['user_ID'];
+ } else {
+ // Add a user for each new author encountered.
+ if (! username_exists($post_author_name) ) {
+ $user_login = $wpdb->escape($post_author_name);
+ $user_email = $wpdb->escape($post_author_email);
+ $user_password = substr(md5(uniqid(microtime())), 0, 6);
+ $result = wp_create_user( $user_login, $user_password, $user_email );
+ $status.= sprintf('Registered user <strong>%s</strong>.', $user_login);
+ $this->import['blogs'][$_GET['blog']]['newusers'][] = $user_login;
+ }
+ $userdata = get_userdatabylogin( $post_author_name );
+ $post_author = $userdata->ID;
+ }
+ $post_date = explode(' ', $post_date);
+ $post_date_Ymd = explode('/', $post_date[0]);
+ $postyear = $post_date_Ymd[2];
+ $postmonth = zeroise($post_date_Ymd[0], 2);
+ $postday = zeroise($post_date_Ymd[1], 2);
+ $post_date_His = explode(':', $post_date[1]);
+ $posthour = zeroise($post_date_His[0], 2);
+ $postminute = zeroise($post_date_His[1], 2);
+ $postsecond = zeroise($post_date_His[2], 2);
+
+ if (($post_date[2] == 'PM') && ($posthour != '12'))
+ $posthour = $posthour + 12;
+ else if (($post_date[2] == 'AM') && ($posthour == '12'))
+ $posthour = '00';
+
+ $post_date = "$postyear-$postmonth-$postday $posthour:$postminute:$postsecond";
+
+ $post_content = addslashes($this->reencode($post_content));
+ $post_content = str_replace(array('<br>','<BR>','<br/>','<BR/>','<br />','<BR />'), "\n", $post_content); // the XHTML touch... ;)
+
+ $post_title = addslashes($this->reencode($post_title));
+
+ $post_status = 'publish';
+
+ if ( $ID = post_exists($post_title, '', $post_date) ) {
+ $post_array[$i]['ID'] = $ID;
+ $skippedpostcount++;
+ } else {
+ $post_array[$i]['post'] = compact('post_author', 'post_content', 'post_title', 'post_category', 'post_author', 'post_date', 'post_status');
+ $post_array[$i]['comments'] = false;
+ }
+
+ // Import any comments attached to this post.
+ if ($postparts[1]) :
+ for ($j = 1; $j < count($postparts); $j = $j + 1) {
+ $commentinfo = explode('|W|P|', $postparts[$j]);
+ $comment_date = explode(' ', $commentinfo[0]);
+ $comment_date_Ymd = explode('/', $comment_date[0]);
+ $commentyear = $comment_date_Ymd[2];
+ $commentmonth = zeroise($comment_date_Ymd[0], 2);
+ $commentday = zeroise($comment_date_Ymd[1], 2);
+ $comment_date_His = explode(':', $comment_date[1]);
+ $commenthour = zeroise($comment_date_His[0], 2);
+ $commentminute = zeroise($comment_date_His[1], 2);
+ $commentsecond = '00';
+ if (($comment_date[2] == 'PM') && ($commenthour != '12'))
+ $commenthour = $commenthour + 12;
+ else if (($comment_date[2] == 'AM') && ($commenthour == '12'))
+ $commenthour = '00';
+ $comment_date = "$commentyear-$commentmonth-$commentday $commenthour:$commentminute:$commentsecond";
+ $comment_author = addslashes($this->reencode(strip_tags($commentinfo[1])));
+ if ( strpos($commentinfo[1], 'a href') ) {
+ $comment_author_parts = explode('&quot;', htmlentities($commentinfo[1]));
+ $comment_author_url = $comment_author_parts[1];
+ } else $comment_author_url = '';
+ $comment_content = $this->reencode($commentinfo[2]);
+ $comment_content = str_replace(array('<br>','<BR>','<br/>','<BR/>','<br />','<BR />'), "\n", $comment_content);
+ $comment_approved = 1;
+ if ( comment_exists($comment_author, $comment_date) ) {
+ $skippedcommentcount++;
+ } else {
+ $comment = compact('comment_author', 'comment_author_url', 'comment_date', 'comment_content', 'comment_approved');
+ $post_array[$i]['comments'][$j] = wp_filter_comment($comment);
+ }
+ $commentcount++;
+ }
+ endif;
+ $postcount++;
+ }
+ if ( count($post_array) ) {
+ krsort($post_array);
+ foreach($post_array as $post) {
+ if ( ! $comment_post_ID = $post['ID'] )
+ $comment_post_ID = wp_insert_post($post['post']);
+ if ( $post['comments'] ) {
+ foreach ( $post['comments'] as $comment ) {
+ $comment['comment_post_ID'] = $comment_post_ID;
+ wp_insert_comment($comment);
+ }
+ }
+ }
+ }
+ $status = sprintf(__('%s post(s) parsed, %s skipped...'), $postcount, $skippedpostcount).' '.
+ sprintf(__('%s comment(s) parsed, %s skipped...'), $commentcount, $skippedcommentcount).' '.
+ ' <strong>'.__('Done').'</strong>';
+ $import = $this->import;
+ $import['blogs'][$_GET['blog']]['archives']["$url"] = $status;
+ update_option('import-blogger', $import);
+ $did_one = true;
+ }
+ $output.= "<p>$archivename $status</p>\n";
+ }
+ if ( ! $did_one )
+ $this->set_next_step(7);
+ die( $this->refresher(1000) . $output );
+ }
+
+ // Step 7: Restore the backed-up settings to Blogger
+ function restore_settings() {
+ $output = '<h1>'.__('Restoring your Blogger options')."</h1>\n";
+ $did_one = false;
+ // Restore options in reverse order.
+ if ( ! $this->import['reversed'] ) {
+ $this->import['blogs'][$_GET['blog']]['options'] = array_reverse($this->import['blogs'][$_GET['blog']]['options'], true);
+ $this->import['reversed'] = true;
+ update_option('import-blogger', $this->import);
+ }
+ foreach ( $this->import['blogs'][$_GET['blog']]['options'] as $blog_opt => $optary ) {
+ if ( $did_one ) {
+ $output .= "<p>$blog_opt</p>\n";
+ } elseif ( $optary['restored'] || ! $optary['modify'] ) {
+ $output .= "<p><del>$blog_opt</del></p>\n";
+ } else {
+ $posturl = "http://www.blogger.com/{$blog_opt}.do";
+ $headers = array_merge($this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['cookies'], $this->import['cookies']);
+ if ( 'blog-publishing' == $blog_opt) {
+ if ( $optary['backup']['publishMode'] > 0 ) {
+ $response = $this->get_blogger("http://www.blogger.com/blog-publishing.g?blogID={$_GET['blog']}&publishMode={$optary['backup']['publishMode']}", $headers);
+ sleep(2);
+ if ( $response['code'] >= 400 )
+ die('<h1>Error restoring publishMode.</h1><p>Please tell the devs.</p>' . addslashes(print_r($response, 1)) );
+ }
+ }
+ if ( $optary['backup'] != $optary['modify'] ) {
+ $response = $this->post_blogger($posturl, $headers, $optary['backup']);
+ if ( $response['code'] >= 400 || strstr($response['body'], 'There are errors on this form') ) {
+ $this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['error'] = true;
+ update_option('import-blogger', $this->import);
+ $output .= sprintf(__('%s failed. Trying again.'), "<p><strong>$blog_opt</strong> ").'</p>';
+ } else {
+ $this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['restored'] = true;
+ update_option('import-blogger', $this->import);
+ $output .= sprintf(__('%s restored.'), "<p><strong>$blog_opt</strong> ").'</p>';
+ }
+ }
+ $did_one = true;
+ }
+ }
+
+ if ( $did_one ) {
+ die( $this->refresher(1000) . $output );
+ } elseif ( $this->import['blogs'][$_GET['blog']]['options']['blog-publishing']['backup']['publishMode'] > 0 ) {
+ $this->set_next_step(9);
+ } else {
+ $this->set_next_step(8);
+ }
+
+ $this->do_next_step();
+ }
+
+ // Step 8: Republish, all back to normal
+ function republish_blog() {
+ $this->publish_blogger(9, __('Publishing with original template and options'));
+ }
+
+ // Step 9: Congratulate the user
+ function congrats() {
+ 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']) )
+ 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. That will clear your Blogger credentials and options from the database.').'</li>';
+ echo '</ul>';
+ }
+
+ // Figures out what to do, then does it.
+ function start() {
+ if ( $_GET['restart'] == 'true' ) {
+ $this->restart();
+ }
+
+ if ( isset($_GET['noheader']) ) {
+ header('Content-Type: text/html; charset=utf-8');
+
+ $this->import = get_settings('import-blogger');
+
+ if ( false === $this->import ) {
+ $step = 0;
+ } elseif ( isset($_GET['step']) ) {
+ $step = (int) $_GET['step'];
+ } elseif ( isset($_GET['blog']) && isset($this->import['blogs'][$_GET['blog']]['nextstep']) ) {
+ $step = $this->import['blogs'][$_GET['blog']]['nextstep'];
+ } elseif ( is_array($this->import['blogs']) ) {
+ $step = 1;
+ } else {
+ $step = 0;
+ }
+//echo "Step $step.";
+//die('<pre>'.print_r($this->import,1).'</pre');
+ switch ($step) {
+ case 0 :
+ $this->do_login();
+ break;
+ case 1 :
+ $this->select_blog();
+ break;
+ case 2 :
+ $this->backup_settings();
+ break;
+ case 3 :
+ $this->wait_for_blogger();
+ break;
+ case 4 :
+ $this->publish_blog();
+ break;
+ case 5 :
+ $this->get_archive_urls();
+ break;
+ case 6 :
+ $this->get_archive();
+ break;
+ case 7 :
+ $this->restore_settings();
+ break;
+ case 8 :
+ $this->republish_blog();
+ break;
+ case 9 :
+ $this->congrats();
+ break;
+ }
+ die;
+
+ } else {
+ $this->greet();
+ }
+ }
+
+ function Blogger_Import() {
+ // This space intentionally left blank.
+ }
+}
+
+$blogger_import = new Blogger_Import();
+
+register_importer('blogger', 'Blogger and Blogspot', __('Import <strong>posts and comments</strong> from your Blogger account'), array ($blogger_import, 'start'));
+
+?>
diff --git a/wp-admin/import/blogware.php b/wp-admin/import/blogware.php
new file mode 100644
index 0000000..35ab610
--- /dev/null
+++ b/wp-admin/import/blogware.php
@@ -0,0 +1,192 @@
+<?php
+
+/* By Shayne Sweeney - http://www.theshayne.com/ */
+
+class BW_Import {
+
+ var $file;
+
+ function header() {
+ echo '<div class="wrap">';
+ echo '<h2>'.__('Import Blogware').'</h2>';
+ }
+
+ function footer() {
+ echo '</div>';
+ }
+
+ function unhtmlentities($string) { // From php.net for < 4.3 compat
+ $trans_tbl = get_html_translation_table(HTML_ENTITIES);
+ $trans_tbl = array_flip($trans_tbl);
+ return strtr($string, $trans_tbl);
+ }
+
+ function greet() {
+ echo '<p>'.__('Howdy! This importer allows you to extract posts from Blogware XML export file into your blog. Pick a Blogware file to upload and click Import.').'</p>';
+ wp_import_upload_form("admin.php?import=blogware&amp;step=1");
+ }
+
+ function import_posts() {
+ global $wpdb, $current_user;
+
+ set_magic_quotes_runtime(0);
+ $importdata = file($this->file); // Read the file into an array
+ $importdata = implode('', $importdata); // squish it
+ $importdata = str_replace(array ("\r\n", "\r"), "\n", $importdata);
+
+ preg_match_all('|(<item[^>]+>(.*?)</item>)|is', $importdata, $posts);
+ $posts = $posts[1];
+ unset($importdata);
+ echo '<ol>';
+ foreach ($posts as $post) {
+ flush();
+ preg_match('|<item type=\"(.*?)\">|is', $post, $post_type);
+ $post_type = $post_type[1];
+ if($post_type == "photo") {
+ preg_match('|<photoFilename>(.*?)</photoFilename>|is', $post, $post_title);
+ } else {
+ preg_match('|<title>(.*?)</title>|is', $post, $post_title);
+ }
+ $post_title = $wpdb->escape(trim($post_title[1]));
+
+ preg_match('|<pubDate>(.*?)</pubDate>|is', $post, $post_date);
+ $post_date = strtotime($post_date[1]);
+ $post_date = gmdate('Y-m-d H:i:s', $post_date);
+
+ 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($category));
+ $cat_index++;
+ }
+
+ if(strcasecmp($post_type, "photo") === 0) {
+ preg_match('|<sizedPhotoUrl>(.*?)</sizedPhotoUrl>|is', $post, $post_content);
+ $post_content = '<img src="'.trim($post_content[1]).'" />';
+ $post_content = $this->unhtmlentities($post_content);
+ } else {
+ preg_match('|<body>(.*?)</body>|is', $post, $post_content);
+ $post_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($post_content[1]));
+ $post_content = $this->unhtmlentities($post_content);
+ }
+
+ // Clean up 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);
+ $post_content = $wpdb->escape($post_content);
+
+ $post_author = $current_user->ID;
+ preg_match('|<postStatus>(.*?)</postStatus>|is', $post, $post_status);
+ $post_status = trim($post_status[1]);
+
+ echo '<li>';
+ if ($post_id = post_exists($post_title, $post_content, $post_date)) {
+ printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title));
+ } else {
+ printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
+ $postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status');
+ $post_id = wp_insert_post($postdata);
+ if (!$post_id) {
+ _e("Couldn't get post ID");
+ echo '</li>';
+ break;
+ }
+ if(0 != count($categories))
+ wp_create_categories($categories, $post_id);
+ }
+
+ preg_match_all('|<comment>(.*?)</comment>|is', $post, $comments);
+ $comments = $comments[1];
+
+ if ( $comments ) {
+ $comment_post_ID = $post_id;
+ $num_comments = 0;
+ foreach ($comments as $comment) {
+ preg_match('|<body>(.*?)</body>|is', $comment, $comment_content);
+ $comment_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($comment_content[1]));
+ $comment_content = $this->unhtmlentities($comment_content);
+
+ // Clean up content
+ $comment_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $comment_content);
+ $comment_content = str_replace('<br>', '<br />', $comment_content);
+ $comment_content = str_replace('<hr>', '<hr />', $comment_content);
+ $comment_content = $wpdb->escape($comment_content);
+
+ preg_match('|<pubDate>(.*?)</pubDate>|is', $comment, $comment_date);
+ $comment_date = trim($comment_date[1]);
+ $comment_date = date('Y-m-d H:i:s', strtotime($comment_date));
+
+ preg_match('|<author>(.*?)</author>|is', $comment, $comment_author);
+ $comment_author = $wpdb->escape(trim($comment_author[1]));
+
+ $comment_author_email = NULL;
+
+ $comment_approved = 1;
+ // Check if it's already there
+ if (!comment_exists($comment_author, $comment_date)) {
+ $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_date', 'comment_content', 'comment_approved');
+ $commentdata = wp_filter_comment($commentdata);
+ wp_insert_comment($commentdata);
+ $num_comments++;
+ }
+ }
+ }
+ if ( $num_comments ) {
+ echo ' ';
+ printf(__('(%s comments)'), $num_comments);
+ }
+ echo '</li>';
+ flush();
+ ob_flush();
+ }
+ echo '</ol>';
+ }
+
+ function import() {
+ $file = wp_import_handle_upload();
+ if ( isset($file['error']) ) {
+ echo $file['error'];
+ return;
+ }
+
+ $this->file = $file['file'];
+ $this->import_posts();
+ wp_import_cleanup($file['id']);
+
+ echo '<h3>';
+ printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home'));
+ echo '</h3>';
+ }
+
+ function dispatch() {
+ if (empty ($_GET['step']))
+ $step = 0;
+ else
+ $step = (int) $_GET['step'];
+
+ $this->header();
+
+ switch ($step) {
+ case 0 :
+ $this->greet();
+ break;
+ case 1 :
+ $this->import();
+ break;
+ }
+
+ $this->footer();
+ }
+
+ function BW_Import() {
+ // Nothing.
+ }
+}
+
+$blogware_import = new BW_Import();
+
+register_importer('blogware', 'Blogware', __('Import posts from Blogware'), array ($blogware_import, 'dispatch'));
+?>
diff --git a/wp-admin/import/dotclear.php b/wp-admin/import/dotclear.php
new file mode 100644
index 0000000..9dc8a6e
--- /dev/null
+++ b/wp-admin/import/dotclear.php
@@ -0,0 +1,747 @@
+<?php
+/*
+ * Dotclear import plugin
+ * by Thomas Quinot - http://thomas.quinot.org/
+ */
+
+/**
+ Add These Functions to make our lives easier
+**/
+if(!function_exists('get_catbynicename'))
+{
+ function get_catbynicename($category_nicename)
+ {
+ global $wpdb;
+
+ $cat_id -= 0; // force numeric
+ $name = $wpdb->get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"');
+
+ return $name;
+ }
+}
+
+if(!function_exists('get_comment_count'))
+{
+ function get_comment_count($post_ID)
+ {
+ global $wpdb;
+ return $wpdb->get_var('SELECT count(*) FROM '.$wpdb->comments.' WHERE comment_post_ID = '.$post_ID);
+ }
+}
+
+if(!function_exists('link_cat_exists'))
+{
+ function link_cat_exists($catname)
+ {
+ global $wpdb;
+ return $wpdb->get_var('SELECT cat_id FROM '.$wpdb->linkcategories.' WHERE cat_name = "'.$wpdb->escape($catname).'"');
+ }
+}
+
+if(!function_exists('link_exists'))
+{
+ function link_exists($linkname)
+ {
+ global $wpdb;
+ return $wpdb->get_var('SELECT link_id FROM '.$wpdb->links.' WHERE link_name = "'.$linkname.'"');
+ }
+}
+
+/*
+ Identify UTF-8 text
+ Taken from http://www.php.net/manual/fr/function.mb-detect-encoding.php#50087
+*/
+//
+// utf8 encoding validation developed based on Wikipedia entry at:
+// http://en.wikipedia.org/wiki/UTF-8
+//
+// Implemented as a recursive descent parser based on a simple state machine
+// copyright 2005 Maarten Meijer
+//
+// This cries out for a C-implementation to be included in PHP core
+//
+ function valid_1byte($char) {
+ if(!is_int($char)) return false;
+ return ($char & 0x80) == 0x00;
+ }
+
+ function valid_2byte($char) {
+ if(!is_int($char)) return false;
+ return ($char & 0xE0) == 0xC0;
+ }
+
+ function valid_3byte($char) {
+ if(!is_int($char)) return false;
+ return ($char & 0xF0) == 0xE0;
+ }
+
+ function valid_4byte($char) {
+ if(!is_int($char)) return false;
+ return ($char & 0xF8) == 0xF0;
+ }
+
+ function valid_nextbyte($char) {
+ if(!is_int($char)) return false;
+ return ($char & 0xC0) == 0x80;
+ }
+
+ function valid_utf8($string) {
+ $len = strlen($string);
+ $i = 0;
+ while( $i < $len ) {
+ $char = ord(substr($string, $i++, 1));
+ if(valid_1byte($char)) { // continue
+ continue;
+ } else if(valid_2byte($char)) { // check 1 byte
+ if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+ return false;
+ } else if(valid_3byte($char)) { // check 2 bytes
+ if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+ return false;
+ if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+ return false;
+ } else if(valid_4byte($char)) { // check 3 bytes
+ if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+ return false;
+ if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+ return false;
+ if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+ return false;
+ } // goto next char
+ }
+ return true; // done
+ }
+
+function csc ($s) {
+ if (valid_utf8 ($s)) {
+ return $s;
+ } else {
+ return iconv(get_option ("dccharset"),"UTF-8",$s);
+ }
+}
+
+function textconv ($s) {
+ return csc (preg_replace ('|(?<!<br />)\s*\n|', ' ', $s));
+}
+
+/**
+ The Main Importer Class
+**/
+class Dotclear_Import {
+
+ function header()
+ {
+ echo '<div class="wrap">';
+ echo '<h2>'.__('Import Dotclear').'</h2>';
+ echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'</p>';
+ }
+
+ function footer()
+ {
+ echo '</div>';
+ }
+
+ function greet()
+ {
+ echo '<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">';
+ $this->db_form();
+ echo '<input type="submit" name="submit" value="'.__('Import Categories').'" />';
+ echo '</form>';
+ }
+
+ function get_dc_cats()
+ {
+ global $wpdb;
+ // General Housekeeping
+ $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
+ set_magic_quotes_runtime(0);
+ $dbprefix = get_option('dcdbprefix');
+
+ // Get Categories
+ return $dcdb->get_results('SELECT * FROM '.$dbprefix.'categorie', ARRAY_A);
+ }
+
+ function get_dc_users()
+ {
+ global $wpdb;
+ // General Housekeeping
+ $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
+ set_magic_quotes_runtime(0);
+ $dbprefix = get_option('dcdbprefix');
+
+ // Get Users
+
+ return $dcdb->get_results('SELECT * FROM '.$dbprefix.'user', ARRAY_A);
+ }
+
+ function get_dc_posts()
+ {
+ // General Housekeeping
+ $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
+ set_magic_quotes_runtime(0);
+ $dbprefix = get_option('dcdbprefix');
+
+ // Get Posts
+ return $dcdb->get_results('SELECT '.$dbprefix.'post.*, '.$dbprefix.'categorie.cat_libelle_url AS post_cat_name
+ FROM '.$dbprefix.'post INNER JOIN '.$dbprefix.'categorie
+ ON '.$dbprefix.'post.cat_id = '.$dbprefix.'categorie.cat_id', ARRAY_A);
+ }
+
+ function get_dc_comments()
+ {
+ global $wpdb;
+ // General Housekeeping
+ $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
+ set_magic_quotes_runtime(0);
+ $dbprefix = get_option('dcdbprefix');
+
+ // Get Comments
+ return $dcdb->get_results('SELECT * FROM '.$dbprefix.'comment', ARRAY_A);
+ }
+
+ function get_dc_links()
+ {
+ //General Housekeeping
+ $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
+ set_magic_quotes_runtime(0);
+ $dbprefix = get_option('dcdbprefix');
+
+ return $dcdb->get_results('SELECT * FROM '.$dbprefix.'link ORDER BY position', ARRAY_A);
+ }
+
+ function cat2wp($categories='')
+ {
+ // General Housekeeping
+ global $wpdb;
+ $count = 0;
+ $dccat2wpcat = array();
+ // Do the Magic
+ if(is_array($categories))
+ {
+ echo '<p>'.__('Importing Categories...').'<br /><br /></p>';
+ foreach ($categories as $category)
+ {
+ $count++;
+ extract($category);
+
+ // Make Nice Variables
+ $name = $wpdb->escape($cat_libelle_url);
+ $title = $wpdb->escape(csc ($cat_libelle));
+ $desc = $wpdb->escape(csc ($cat_desc));
+
+ if($cinfo = category_exists($name))
+ {
+ $ret_id = wp_insert_category(array('cat_ID' => $cinfo, 'category_nicename' => $name, 'cat_name' => $title, 'category_description' => $desc));
+ }
+ else
+ {
+ $ret_id = wp_insert_category(array('category_nicename' => $name, 'cat_name' => $title, 'category_description' => $desc));
+ }
+ $dccat2wpcat[$id] = $ret_id;
+ }
+
+ // Store category translation for future use
+ add_option('dccat2wpcat',$dccat2wpcat);
+ echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> categories imported.'), $count).'<br /><br /></p>';
+ return true;
+ }
+ echo __('No Categories to Import!');
+ return false;
+ }
+
+ function users2wp($users='')
+ {
+ // General Housekeeping
+ global $wpdb;
+ $count = 0;
+ $dcid2wpid = array();
+
+ // Midnight Mojo
+ if(is_array($users))
+ {
+ echo '<p>'.__('Importing Users...').'<br /><br /></p>';
+ foreach($users as $user)
+ {
+ $count++;
+ extract($user);
+
+ // Make Nice Variables
+ $name = $wpdb->escape(csc ($name));
+ $RealName = $wpdb->escape(csc ($user_pseudo));
+
+ if($uinfo = get_userdatabylogin($name))
+ {
+
+ $ret_id = wp_insert_user(array(
+ 'ID' => $uinfo->ID,
+ 'user_login' => $user_id,
+ 'user_nicename' => $Realname,
+ 'user_email' => $user_email,
+ 'user_url' => 'http://',
+ 'display_name' => $Realname)
+ );
+ }
+ else
+ {
+ $ret_id = wp_insert_user(array(
+ 'user_login' => $user_id,
+ 'user_nicename' => csc ($user_pseudo),
+ 'user_email' => $user_email,
+ 'user_url' => 'http://',
+ 'display_name' => $Realname)
+ );
+ }
+ $dcid2wpid[$user_id] = $ret_id;
+
+ // Set Dotclear-to-WordPress permissions translation
+
+ // Update Usermeta Data
+ $user = new WP_User($ret_id);
+ $wp_perms = $user_level + 1;
+ if(10 == $wp_perms) { $user->set_role('administrator'); }
+ else if(9 == $wp_perms) { $user->set_role('editor'); }
+ else if(5 <= $wp_perms) { $user->set_role('editor'); }
+ else if(4 <= $wp_perms) { $user->set_role('author'); }
+ else if(3 <= $wp_perms) { $user->set_role('contributor'); }
+ else if(2 <= $wp_perms) { $user->set_role('contributor'); }
+ else { $user->set_role('subscriber'); }
+
+ update_usermeta( $ret_id, 'wp_user_level', $wp_perms);
+ update_usermeta( $ret_id, 'rich_editing', 'false');
+ update_usermeta( $ret_id, 'first_name', csc ($user_prenom));
+ update_usermeta( $ret_id, 'last_name', csc ($user_nom));
+ }// End foreach($users as $user)
+
+ // Store id translation array for future use
+ add_option('dcid2wpid',$dcid2wpid);
+
+
+ echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> users imported.'), $count).'<br /><br /></p>';
+ return true;
+ }// End if(is_array($users)
+
+ echo __('No Users to Import!');
+ return false;
+
+ }// End function user2wp()
+
+ function posts2wp($posts='')
+ {
+ // General Housekeeping
+ global $wpdb;
+ $count = 0;
+ $dcposts2wpposts = array();
+ $cats = array();
+
+ // Do the Magic
+ if(is_array($posts))
+ {
+ echo '<p>'.__('Importing Posts...').'<br /><br /></p>';
+ foreach($posts as $post)
+ {
+ $count++;
+ extract($post);
+
+ // Set Dotclear-to-WordPress status translation
+ $stattrans = array(0 => 'draft', 1 => 'publish');
+ $comment_status_map = array (0 => 'closed', 1 => 'open');
+
+ //Can we do this more efficiently?
+ $uinfo = ( get_userdatabylogin( $user_id ) ) ? get_userdatabylogin( $user_id ) : 1;
+ $authorid = ( is_object( $uinfo ) ) ? $uinfo->ID : $uinfo ;
+
+ $Title = $wpdb->escape(csc ($post_titre));
+ $post_content = textconv ($post_content);
+ $post_excerpt = "";
+ if ($post_chapo != "") {
+ $post_excerpt = textconv ($post_chapo);
+ $post_content = $post_excerpt ."\n<!--more-->\n".$post_content;
+ }
+ $post_excerpt = $wpdb->escape ($post_excerpt);
+ $post_content = $wpdb->escape ($post_content);
+ $post_status = $stattrans[$post_pub];
+
+ // Import Post data into WordPress
+
+ if($pinfo = post_exists($Title,$post_content))
+ {
+ $ret_id = wp_insert_post(array(
+ 'ID' => $pinfo,
+ 'post_author' => $authorid,
+ 'post_date' => $post_dt,
+ 'post_date_gmt' => $post_dt,
+ 'post_modified' => $post_upddt,
+ 'post_modified_gmt' => $post_upddt,
+ 'post_title' => $Title,
+ 'post_content' => $post_content,
+ 'post_excerpt' => $post_excerpt,
+ 'post_status' => $post_status,
+ 'post_name' => $post_titre_url,
+ 'comment_status' => $comment_status_map[$post_open_comment],
+ 'ping_status' => $comment_status_map[$post_open_tb],
+ 'comment_count' => $post_nb_comment + $post_nb_trackback)
+ );
+ }
+ else
+ {
+ $ret_id = wp_insert_post(array(
+ 'post_author' => $authorid,
+ 'post_date' => $post_dt,
+ 'post_date_gmt' => $post_dt,
+ 'post_modified' => $post_modified_gmt,
+ 'post_modified_gmt' => $post_modified_gmt,
+ 'post_title' => $Title,
+ 'post_content' => $post_content,
+ 'post_excerpt' => $post_excerpt,
+ 'post_status' => $post_status,
+ 'post_name' => $post_titre_url,
+ 'comment_status' => $comment_status_map[$post_open_comment],
+ 'ping_status' => $comment_status_map[$post_open_tb],
+ 'comment_count' => $post_nb_comment + $post_nb_trackback)
+ );
+ }
+ $dcposts2wpposts[$post_id] = $ret_id;
+
+ // Make Post-to-Category associations
+ $cats = array();
+ if($cat1 = get_catbynicename($post_cat_name)) { $cats[1] = $cat1; }
+
+ if(!empty($cats)) { wp_set_post_cats('', $ret_id, $cats); }
+ }
+ }
+ // Store ID translation for later use
+ add_option('dcposts2wpposts',$dcposts2wpposts);
+
+ echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> posts imported.'), $count).'<br /><br /></p>';
+ return true;
+ }
+
+ function comments2wp($comments='')
+ {
+ // General Housekeeping
+ global $wpdb;
+ $count = 0;
+ $dccm2wpcm = array();
+ $postarr = get_option('dcposts2wpposts');
+
+ // Magic Mojo
+ if(is_array($comments))
+ {
+ echo '<p>'.__('Importing Comments...').'<br /><br /></p>';
+ foreach($comments as $comment)
+ {
+ $count++;
+ extract($comment);
+
+ // WordPressify Data
+ $comment_ID = ltrim($comment_id, '0');
+ $comment_post_ID = $postarr[$post_id];
+ $comment_approved = "$comment_pub";
+ $name = $wpdb->escape(csc ($comment_auteur));
+ $email = $wpdb->escape($comment_email);
+ $web = "http://".$wpdb->escape($comment_site);
+ $message = $wpdb->escape(textconv ($comment_content));
+
+ if($cinfo = comment_exists($name, $comment_dt))
+ {
+ // Update comments
+ $ret_id = wp_update_comment(array(
+ 'comment_ID' => $cinfo,
+ 'comment_post_ID' => $comment_post_ID,
+ 'comment_author' => $name,
+ 'comment_author_email' => $email,
+ 'comment_author_url' => $web,
+ 'comment_author_IP' => $comment_ip,
+ 'comment_date' => $comment_dt,
+ 'comment_date_gmt' => $comment_dt,
+ 'comment_content' => $message,
+ 'comment_approved' => $comment_approved)
+ );
+ }
+ else
+ {
+ // Insert comments
+ $ret_id = wp_insert_comment(array(
+ 'comment_post_ID' => $comment_post_ID,
+ 'comment_author' => $name,
+ 'comment_author_email' => $email,
+ 'comment_author_url' => $web,
+ 'comment_author_IP' => $comment_ip,
+ 'comment_date' => $comment_dt,
+ 'comment_date_gmt' => $comment_dt,
+ 'comment_content' => $message,
+ 'comment_approved' => $comment_approved)
+ );
+ }
+ $dccm2wpcm[$comment_ID] = $ret_id;
+ }
+ // Store Comment ID translation for future use
+ add_option('dccm2wpcm', $dccm2wpcm);
+
+ // Associate newly formed categories with posts
+ get_comment_count($ret_id);
+
+
+ echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> comments imported.'), $count).'<br /><br /></p>';
+ return true;
+ }
+ echo __('No Comments to Import!');
+ return false;
+ }
+
+ function links2wp($links='')
+ {
+ // General Housekeeping
+ global $wpdb;
+ $count = 0;
+
+ // Deal with the links
+ if(is_array($links))
+ {
+ echo '<p>'.__('Importing Links...').'<br /><br /></p>';
+ foreach($links as $link)
+ {
+ $count++;
+ extract($link);
+
+ if ($title != "") {
+ if ($cinfo = link_cat_exists (csc ($title))) {
+ $category = $cinfo;
+ } else {
+ $wpdb->query ("INSERT INTO $wpdb->linkcategories (cat_name) VALUES ('".
+ $wpdb->escape (csc ($title))."')");
+ $category = $wpdb->insert_id;
+ }
+ } else {
+ $linkname = $wpdb->escape(csc ($label));
+ $description = $wpdb->escape(csc ($title));
+
+ if($linfo = link_exists($linkname)) {
+ $ret_id = wp_insert_link(array(
+ 'link_id' => $linfo,
+ 'link_url' => $href,
+ 'link_name' => $linkname,
+ 'link_category' => $category,
+ 'link_description' => $description)
+ );
+ } else {
+ $ret_id = wp_insert_link(array(
+ 'link_url' => $url,
+ 'link_name' => $linkname,
+ 'link_category' => $category,
+ 'link_description' => $description)
+ );
+ }
+ $dclinks2wplinks[$link_id] = $ret_id;
+ }
+ }
+ add_option('dclinks2wplinks',$dclinks2wplinks);
+ echo '<p>';
+ printf(__('Done! <strong>%s</strong> links or link categories imported'), $count);
+ echo '<br /><br /></p>';
+ return true;
+ }
+ echo __('No Links to Import!');
+ return false;
+ }
+
+ function import_categories()
+ {
+ // Category Import
+ $cats = $this->get_dc_cats();
+ $this->cat2wp($cats);
+ add_option('dc_cats', $cats);
+
+
+
+ echo '<form action="admin.php?import=dotclear&amp;step=2" method="post">';
+ printf('<input type="submit" name="submit" value="%s" />', __('Import Users'));
+ echo '</form>';
+
+ }
+
+ function import_users()
+ {
+ // User Import
+ $users = $this->get_dc_users();
+ $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'));
+ echo '</form>';
+ }
+
+ function import_posts()
+ {
+ // Post Import
+ $posts = $this->get_dc_posts();
+ $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'));
+ echo '</form>';
+ }
+
+ function import_comments()
+ {
+ // Comment Import
+ $comments = $this->get_dc_comments();
+ $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'));
+ echo '</form>';
+ }
+
+ function import_links()
+ {
+ //Link Import
+ $links = $this->get_dc_links();
+ $this->links2wp($links);
+ 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'));
+ echo '</form>';
+ }
+
+ function cleanup_dcimport()
+ {
+ delete_option('dcdbprefix');
+ delete_option('dc_cats');
+ delete_option('dcid2wpid');
+ delete_option('dccat2wpcat');
+ delete_option('dcposts2wpposts');
+ delete_option('dccm2wpcm');
+ delete_option('dclinks2wplinks');
+ delete_option('dcuser');
+ delete_option('dcpass');
+ delete_option('dcname');
+ delete_option('dchost');
+ delete_option('dccharset');
+ $this->tips();
+ }
+
+ function tips()
+ {
+ echo '<p>'.__('Welcome to WordPress. We hope (and expect!) that you will find this platform incredibly rewarding! As a new WordPress user coming from Dotclear, 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 Dotclear, 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 Dotclear 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 '<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 Dotclear, 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/2004/04/19/wordpress-plugin-textile-20/">Textile for WordPress</a>. Trust me... You\'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>';
+ echo '<li>'.__('<a href="http://www.wordpress.org">The official WordPress site</a>').'</li>';
+ echo '<li>'.__('<a href="http://wordpress.org/support/">The WordPress support forums').'</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>';
+ }
+
+ function db_form()
+ {
+ echo '<ul>';
+ printf('<li><label for="dbuser">%s</label> <input type="text" name="dbuser" /></li>', __('Dotclear Database User:'));
+ printf('<li><label for="dbpass">%s</label> <input type="password" name="dbpass" /></li>', __('Dotclear Database Password:'));
+ printf('<li><label for="dbname">%s</label> <input type="text" name="dbname" /></li>', __('Dotclear Database Name:'));
+ printf('<li><label for="dbhost">%s</label> <input type="text" name="dbhost" value="localhost" /></li>', __('Dotclear Database Host:'));
+ printf('<li><label for="dbprefix">%s</label> <input type="text" name="dbprefix" value="dc_"/></li>', __('Dotclear Table prefix:'));
+ printf('<li><label for="dccharset">%s</label> <input type="text" name="dccharset" value="ISO-8859-15"/></li>', __('Originating character set:'));
+ echo '</ul>';
+ }
+
+ function dispatch()
+ {
+
+ if (empty ($_GET['step']))
+ $step = 0;
+ else
+ $step = (int) $_GET['step'];
+ $this->header();
+
+ if ( $step > 0 )
+ {
+ if($_POST['dbuser'])
+ {
+ if(get_option('dcuser'))
+ delete_option('dcuser');
+ add_option('dcuser',$_POST['dbuser']);
+ }
+ if($_POST['dbpass'])
+ {
+ if(get_option('dcpass'))
+ delete_option('dcpass');
+ add_option('dcpass',$_POST['dbpass']);
+ }
+
+ if($_POST['dbname'])
+ {
+ if(get_option('dcname'))
+ delete_option('dcname');
+ add_option('dcname',$_POST['dbname']);
+ }
+ if($_POST['dbhost'])
+ {
+ if(get_option('dchost'))
+ delete_option('dchost');
+ add_option('dchost',$_POST['dbhost']);
+ }
+ if($_POST['dccharset'])
+ {
+ if(get_option('dccharset'))
+ delete_option('dccharset');
+ add_option('dccharset',$_POST['dccharset']);
+ }
+ if($_POST['dbprefix'])
+ {
+ if(get_option('dcdbprefix'))
+ delete_option('dcdbprefix');
+ add_option('dcdbprefix',$_POST['dbprefix']);
+ }
+
+
+ }
+
+ switch ($step)
+ {
+ default:
+ case 0 :
+ $this->greet();
+ break;
+ case 1 :
+ $this->import_categories();
+ break;
+ case 2 :
+ $this->import_users();
+ break;
+ case 3 :
+ $this->import_posts();
+ break;
+ case 4 :
+ $this->import_comments();
+ break;
+ case 5 :
+ $this->import_links();
+ break;
+ case 6 :
+ $this->cleanup_dcimport();
+ break;
+ }
+
+ $this->footer();
+ }
+
+ function Dotclear_Import()
+ {
+ // Nothing.
+ }
+}
+
+$dc_import = new Dotclear_Import();
+register_importer('dotclear', 'Dotclear', __('Import posts from a Dotclear Blog'), array ($dc_import, 'dispatch'));
+?>
diff --git a/wp-admin/import/greymatter.php b/wp-admin/import/greymatter.php
new file mode 100644
index 0000000..f2b4e2d
--- /dev/null
+++ b/wp-admin/import/greymatter.php
@@ -0,0 +1,312 @@
+<?php
+
+class GM_Import {
+
+ var $gmnames = array ();
+
+ function header() {
+ echo '<div class="wrap">';
+ echo '<h2>'.__('Import Greymatter').'</h2>';
+ }
+
+ function footer() {
+ echo '</div>';
+ }
+
+ function greet() {
+ $this->header();
+?>
+<p>This is a basic GreyMatter to WordPress import script.</p>
+<p>What it does:</p>
+<ul>
+<li>Parses gm-authors.cgi to import (new) authors. Everyone is imported at level 1.</li>
+<li>Parses the entries cgi files to import posts, comments, and karma on posts (although karma is not used on WordPress yet).<br />If authors are found not to be in gm-authors.cgi, imports them at level 0.</li>
+<li>Detects duplicate entries or comments. If you don't import everything the first time, or this import should fail in the middle, duplicate entries will not be made when you try again.</li>
+</ul>
+<p>What it does not:</p>
+<ul>
+<li>Parse gm-counter.cgi, gm-banlist.cgi, gm-cplog.cgi (you can make a CP log hack if you really feel like it, but I question the need of a CP log).</li>
+<li>Import gm-templates.</li>
+<li>Doesn't keep entries on top.</li>
+</ul>
+<p>&nbsp;</p>
+
+<form name="stepOne" method="get">
+<input type="hidden" name="import" value="greymatter" />
+<input type="hidden" name="step" value="1" />
+<h3>Second step: GreyMatter details:</h3>
+<p><table cellpadding="0">
+<tr>
+<td>Path to GM files:</td>
+<td><input type="text" style="width:300px" name="gmpath" value="/home/my/site/cgi-bin/greymatter/" /></td>
+</tr>
+<tr>
+<td>Path to GM entries:</td>
+<td><input type="text" style="width:300px" name="archivespath" value="/home/my/site/cgi-bin/greymatter/archives/" /></td>
+</tr>
+<tr>
+<td colspan="2"><br />This importer will search for files 00000001.cgi to 000-whatever.cgi,<br />so you need to enter the number of the last GM post here.<br />(if you don't know that number, just log into your FTP and look it out<br />in the entries' folder)</td>
+</tr>
+<tr>
+<td>Last entry's number:</td>
+<td><input type="text" name="lastentry" value="00000001" /></td>
+</tr>
+</table>
+</p>
+<p>When you're ready, click OK to start importing: <input type="submit" name="submit" value="OK" class="search" /></p>
+</form>
+<p>&nbsp</p>
+<?php
+ $this->footer();
+ }
+
+
+
+ function gm2autobr($string) { // transforms GM's |*| into b2's <br />\n
+ $string = str_replace("|*|","<br />\n",$string);
+ return($string);
+ }
+
+ function import() {
+ global $wpdb;
+
+ $wpvarstoreset = array('gmpath', 'archivespath', 'lastentry');
+ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+ }
+
+ if (!chdir($archivespath))
+ die("Wrong path, $archivespath\ndoesn't exist\non the server");
+
+ if (!chdir($gmpath))
+ die("Wrong path, $gmpath\ndoesn't exist\non the server");
+
+ $this->header();
+?>
+<p>The importer is running...</p>
+<ul>
+<li>importing users... <ul><?php
+
+ chdir($gmpath);
+ $userbase = file("gm-authors.cgi");
+
+ foreach($userbase as $user) {
+ $userdata=explode("|", $user);
+
+ $user_ip="127.0.0.1";
+ $user_domain="localhost";
+ $user_browser="server";
+
+ $s=$userdata[4];
+ $user_joindate=substr($s,6,4)."-".substr($s,0,2)."-".substr($s,3,2)." 00:00:00";
+
+ $user_login=$wpdb->escape($userdata[0]);
+ $pass1=$wpdb->escape($userdata[1]);
+ $user_nickname=$wpdb->escape($userdata[0]);
+ $user_email=$wpdb->escape($userdata[2]);
+ $user_url=$wpdb->escape($userdata[3]);
+ $user_joindate=$wpdb->escape($user_joindate);
+
+ $user_id = username_exists($user_login);
+ if ($user_id) {
+ echo "<li>user <i>$user_login</i>... <b>Already exists</b></li>";
+ $this->gmnames[$userdata[0]] = $user_id;
+ continue;
+ }
+
+ $user_info = array("user_login"=>"$user_login", "user_pass"=>"$pass1", "user_nickname"=>"$user_nickname", "user_email"=>"$user_email", "user_url"=>"$user_url", "user_ip"=>"$user_ip", "user_domain"=>"$user_domain", "user_browser"=>"$user_browser", "dateYMDhour"=>"$user_joindate", "user_level"=>"1", "user_idmode"=>"nickname");
+ $user_id = wp_insert_user($user_info);
+ $this->gmnames[$userdata[0]] = $user_id;
+
+ echo "<li>user <i>$user_login</i>... <b>Done</b></li>";
+
+ }
+
+?></ul><b>Done</b></li>
+<li>importing posts, comments, and karma...<br /><ul><?php
+
+ chdir($archivespath);
+
+ for($i = 0; $i <= $lastentry; $i = $i + 1) {
+
+ $entryfile = "";
+
+ if ($i<10000000) {
+ $entryfile .= "0";
+ if ($i<1000000) {
+ $entryfile .= "0";
+ if ($i<100000) {
+ $entryfile .= "0";
+ if ($i<10000) {
+ $entryfile .= "0";
+ if ($i<1000) {
+ $entryfile .= "0";
+ if ($i<100) {
+ $entryfile .= "0";
+ if ($i<10) {
+ $entryfile .= "0";
+ }}}}}}}
+
+ $entryfile .= "$i";
+
+ if (is_file($entryfile.".cgi")) {
+
+ $entry=file($entryfile.".cgi");
+ echo "<li>entry # $entryfile ";
+ $postinfo=explode("|",$entry[0]);
+ $postmaincontent=$this->gm2autobr($entry[2]);
+ $postmorecontent=$this->gm2autobr($entry[3]);
+
+ $post_author=trim($wpdb->escape($postinfo[1]));
+
+ $post_title=$this->gm2autobr($postinfo[2]);
+ echo " : $post_title : by $postinfo[1]";
+ $post_title=$wpdb->escape($post_title);
+
+ $postyear=$postinfo[6];
+ $postmonth=zeroise($postinfo[4],2);
+ $postday=zeroise($postinfo[5],2);
+ $posthour=zeroise($postinfo[7],2);
+ $postminute=zeroise($postinfo[8],2);
+ $postsecond=zeroise($postinfo[9],2);
+
+ if (($postinfo[10]=="PM") && ($posthour!="12"))
+ $posthour=$posthour+12;
+
+ $post_date="$postyear-$postmonth-$postday $posthour:$postminute:$postsecond";
+
+ $post_content=$postmaincontent;
+ if (strlen($postmorecontent)>3)
+ $post_content .= "<!--more--><br /><br />".$postmorecontent;
+ $post_content=$wpdb->escape($post_content);
+
+ $post_karma=$postinfo[12];
+
+ $post_status = 'publish'; //in greymatter, there are no drafts
+ $comment_status = 'open';
+ $ping_status = 'closed';
+
+ if ($post_ID = post_exists($post_title, '', $post_date)) {
+ echo ' (already exists)';
+ } else {
+ //just so that if a post already exists, new users are not created by checkauthor
+ // we'll check the author is registered, or if it's a deleted author
+ $user_id = username_exists($post_author);
+ if (!$user_id) { // if deleted from GM, we register the author as a level 0 user
+ $user_ip="127.0.0.1";
+ $user_domain="localhost";
+ $user_browser="server";
+ $user_joindate="1979-06-06 00:41:00";
+ $user_login=$wpdb->escape($post_author);
+ $pass1=$wpdb->escape("password");
+ $user_nickname=$wpdb->escape($post_author);
+ $user_email=$wpdb->escape("user@deleted.com");
+ $user_url=$wpdb->escape("");
+ $user_joindate=$wpdb->escape($user_joindate);
+
+ $user_info = array("user_login"=>$user_login, "user_pass"=>$pass1, "user_nickname"=>$user_nickname, "user_email"=>$user_email, "user_url"=>$user_url, "user_ip"=>$user_ip, "user_domain"=>$user_domain, "user_browser"=>$user_browser, "dateYMDhour"=>$user_joindate, "user_level"=>0, "user_idmode"=>"nickname");
+ $user_id = wp_insert_user($user_info);
+ $this->gmnames[$postinfo[1]] = $user_id;
+
+ echo ": registered deleted user <i>$user_login</i> at level 0 ";
+ }
+
+ if (array_key_exists($postinfo[1], $this->gmnames)) {
+ $post_author = $this->gmnames[$postinfo[1]];
+ } else {
+ $post_author = $user_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');
+ $post_ID = wp_insert_post($postdata);
+ }
+
+ $c=count($entry);
+ if ($c>4) {
+ $numAddedComments = 0;
+ $numComments = 0;
+ for ($j=4;$j<$c;$j++) {
+ $entry[$j]=$this->gm2autobr($entry[$j]);
+ $commentinfo=explode("|",$entry[$j]);
+ $comment_post_ID=$post_ID;
+ $comment_author=$wpdb->escape($commentinfo[0]);
+ $comment_author_email=$wpdb->escape($commentinfo[2]);
+ $comment_author_url=$wpdb->escape($commentinfo[3]);
+ $comment_author_IP=$wpdb->escape($commentinfo[1]);
+
+ $commentyear=$commentinfo[7];
+ $commentmonth=zeroise($commentinfo[5],2);
+ $commentday=zeroise($commentinfo[6],2);
+ $commenthour=zeroise($commentinfo[8],2);
+ $commentminute=zeroise($commentinfo[9],2);
+ $commentsecond=zeroise($commentinfo[10],2);
+ if (($commentinfo[11]=="PM") && ($commenthour!="12"))
+ $commenthour=$commenthour+12;
+ $comment_date="$commentyear-$commentmonth-$commentday $commenthour:$commentminute:$commentsecond";
+
+ $comment_content=$wpdb->escape($commentinfo[12]);
+
+ 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_content', 'comment_approved');
+ $commentdata = wp_filter_comment($commentdata);
+ wp_insert_comment($commentdata);
+ $numAddedComments++;
+ }
+ $numComments++;
+ }
+ if ($numAddedComments > 0) {
+ echo ": imported $numAddedComments comment";
+ if ($numAddedComments != 1)
+ echo "s";
+ }
+ $preExisting = $numComments - numAddedComments;
+ if ($preExisting > 0)
+ echo " (ignored $preExisting pre-existing comments)";
+ }
+ echo "... <b>Done</b></li>";
+ }
+ }
+ ?>
+</ul><b>Done</b></li></ul>
+<p>&nbsp;</p>
+<p>Completed Greymatter import !</p>
+<?php
+ $this->footer();
+ }
+
+ function dispatch() {
+ if (empty ($_GET['step']))
+ $step = 0;
+ else
+ $step = (int) $_GET['step'];
+
+ switch ($step) {
+ case 0 :
+ $this->greet();
+ break;
+ case 1:
+ $this->import();
+ break;
+ }
+ }
+
+ function GM_Import() {
+ // Nothing.
+ }
+}
+
+$gm_import = new GM_Import();
+
+register_importer('greymatter', 'Greymatter', __('Import posts and comments from your Greymatter blog'), array ($gm_import, 'dispatch'));
+?>
diff --git a/wp-admin/import/livejournal.php b/wp-admin/import/livejournal.php
new file mode 100644
index 0000000..44b92a5
--- /dev/null
+++ b/wp-admin/import/livejournal.php
@@ -0,0 +1,168 @@
+<?php
+
+class LJ_Import {
+
+ var $file;
+
+ function header() {
+ echo '<div class="wrap">';
+ echo '<h2>'.__('Import LiveJournal').'</h2>';
+ }
+
+ function footer() {
+ echo '</div>';
+ }
+
+ function unhtmlentities($string) { // From php.net for < 4.3 compat
+ $trans_tbl = get_html_translation_table(HTML_ENTITIES);
+ $trans_tbl = array_flip($trans_tbl);
+ return strtr($string, $trans_tbl);
+ }
+
+ function greet() {
+ echo '<p>'.__('Howdy! This importer allows you to extract posts from LiveJournal XML export file into your blog. Pick a LiveJournal file to upload and click Import.').'</p>';
+ wp_import_upload_form("admin.php?import=livejournal&amp;step=1");
+ }
+
+ function import_posts() {
+ global $wpdb, $current_user;
+
+ set_magic_quotes_runtime(0);
+ $importdata = file($this->file); // Read the file into an array
+ $importdata = implode('', $importdata); // squish it
+ $importdata = str_replace(array ("\r\n", "\r"), "\n", $importdata);
+
+ preg_match_all('|<entry>(.*?)</entry>|is', $importdata, $posts);
+ $posts = $posts[1];
+ unset($importdata);
+ echo '<ol>';
+ foreach ($posts as $post) {
+ preg_match('|<subject>(.*?)</subject>|is', $post, $post_title);
+ $post_title = $wpdb->escape(trim($post_title[1]));
+ if ( empty($post_title) ) {
+ preg_match('|<itemid>(.*?)</itemid>|is', $post, $post_title);
+ $post_title = $wpdb->escape(trim($post_title[1]));
+ }
+
+ 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);
+
+ preg_match('|<event>(.*?)</event>|is', $post, $post_content);
+ $post_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($post_content[1]));
+ $post_content = $this->unhtmlentities($post_content);
+
+ // Clean up 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);
+ $post_content = $wpdb->escape($post_content);
+
+ $post_author = $current_user->ID;
+ $post_status = 'publish';
+
+ echo '<li>';
+ if ($post_id = post_exists($post_title, $post_content, $post_date)) {
+ printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title));
+ } else {
+ printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
+ $postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status');
+ $post_id = wp_insert_post($postdata);
+ if (!$post_id) {
+ _e("Couldn't get post ID");
+ echo '</li>';
+ break;
+ }
+ }
+
+ preg_match_all('|<comment>(.*?)</comment>|is', $post, $comments);
+ $comments = $comments[1];
+
+ if ( $comments ) {
+ $comment_post_ID = $post_id;
+ $num_comments = 0;
+ foreach ($comments as $comment) {
+ preg_match('|<event>(.*?)</event>|is', $comment, $comment_content);
+ $comment_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($comment_content[1]));
+ $comment_content = $this->unhtmlentities($comment_content);
+
+ // Clean up content
+ $comment_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $comment_content);
+ $comment_content = str_replace('<br>', '<br />', $comment_content);
+ $comment_content = str_replace('<hr>', '<hr />', $comment_content);
+ $comment_content = $wpdb->escape($comment_content);
+
+ preg_match('|<eventtime>(.*?)</eventtime>|is', $comment, $comment_date);
+ $comment_date = trim($comment_date[1]);
+ $comment_date = date('Y-m-d H:i:s', strtotime($comment_date));
+
+ preg_match('|<name>(.*?)</name>|is', $comment, $comment_author);
+ $comment_author = $wpdb->escape(trim($comment_author[1]));
+
+ preg_match('|<email>(.*?)</email>|is', $comment, $comment_author_email);
+ $comment_author_email = $wpdb->escape(trim($comment_author_email[1]));
+
+ $comment_approved = 1;
+ // Check if it's already there
+ if (!comment_exists($comment_author, $comment_date)) {
+ $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_date', 'comment_content', 'comment_approved');
+ $commentdata = wp_filter_comment($commentdata);
+ wp_insert_comment($commentdata);
+ $num_comments++;
+ }
+ }
+ }
+ if ( $num_comments ) {
+ echo ' ';
+ printf(__('(%s comments)'), $num_comments);
+ }
+ echo '</li>';
+ }
+ echo '</ol>';
+ }
+
+ function import() {
+ $file = wp_import_handle_upload();
+ if ( isset($file['error']) ) {
+ echo $file['error'];
+ return;
+ }
+
+ $this->file = $file['file'];
+ $this->import_posts();
+ wp_import_cleanup($file['id']);
+
+ echo '<h3>';
+ printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home'));
+ echo '</h3>';
+ }
+
+ function dispatch() {
+ if (empty ($_GET['step']))
+ $step = 0;
+ else
+ $step = (int) $_GET['step'];
+
+ $this->header();
+
+ switch ($step) {
+ case 0 :
+ $this->greet();
+ break;
+ case 1 :
+ $this->import();
+ break;
+ }
+
+ $this->footer();
+ }
+
+ function LJ_Import() {
+ // Nothing.
+ }
+}
+
+$livejournal_import = new LJ_Import();
+
+register_importer('livejournal', 'LiveJournal', __('Import posts from LiveJournal'), array ($livejournal_import, 'dispatch'));
+?>
diff --git a/wp-admin/import/mt.php b/wp-admin/import/mt.php
new file mode 100644
index 0000000..59259ea
--- /dev/null
+++ b/wp-admin/import/mt.php
@@ -0,0 +1,407 @@
+<?php
+
+class MT_Import {
+
+ var $posts = array ();
+ var $file;
+ var $id;
+ var $mtnames = array ();
+ var $newauthornames = array ();
+ var $j = -1;
+
+ function header() {
+ echo '<div class="wrap">';
+ echo '<h2>'.__('Import Movable Type and Typepad').'</h2>';
+ }
+
+ function footer() {
+ echo '</div>';
+ }
+
+ function greet() {
+ $this->header();
+?>
+<p><?php _e('Howdy! We&#8217;re about to begin the process to import all of your Movable Type entries into WordPress. To begin, select a file to upload and click Import.'); ?></p>
+<?php wp_import_upload_form( add_query_arg('step', 1) ); ?>
+ <p><?php _e('The importer is smart enough not to import duplicates, so you can run this multiple times without worry if&#8212;for whatever reason&#8212;it doesn\'t finish. If you get an <strong>out of memory</strong> error try splitting up the import file into pieces.'); ?> </p>
+<?php
+ $this->footer();
+ }
+
+ function users_form($n) {
+ global $wpdb, $testing;
+ $users = get_users_of_blog($wpdb->blogid);
+?><select name="userselect[<?php echo $n; ?>]">
+ <option value="#NONE#">- Select -</option>
+ <?php
+
+
+ foreach ($users as $user) {
+ echo '<option value="'.$user->user_login.'">'.$user->user_login.'</option>';
+ }
+?>
+ </select>
+ <?php
+
+
+ }
+
+ //function to check the authorname and do the mapping
+ function checkauthor($author) {
+ global $wpdb;
+ //mtnames is an array with the names in the mt import file
+ $key = array_search($author, $this->mtnames); //find the array key for $author in the $mtnames array
+ $user_id = username_exists($this->newauthornames[$key]); //use that key to get the value of the author's name from $newauthornames
+
+ return $user_id;
+ }
+
+ 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);
+ $importdata = preg_replace("/\n--------\n/", "--MT-ENTRY--\n", $importdata);
+ $this->posts = explode("--MT-ENTRY--", $importdata);
+ }
+
+ function get_mt_authors() {
+ $temp = array ();
+ $i = -1;
+ foreach ($this->posts as $post) {
+ if ('' != trim($post)) {
+ ++ $i;
+ preg_match("|AUTHOR:(.*)|", $post, $thematch);
+ $thematch = trim($thematch[1]);
+ array_push($temp, "$thematch"); //store the extracted author names in a temporary array
+ }
+ }
+
+ //we need to find unique values of author names, while preserving the order, so this function emulates the unique_value(); php function, without the sorting.
+ $authors[0] = array_shift($temp);
+ $y = count($temp) + 1;
+ for ($x = 1; $x < $y; $x ++) {
+ $next = array_shift($temp);
+ if (!(in_array($next, $authors)))
+ array_push($authors, "$next");
+ }
+
+ return $authors;
+ }
+
+ function get_authors_from_post() {
+ $formnames = array ();
+ $selectnames = array ();
+
+ foreach ($_POST['userselect'] as $user => $key) {
+ $selected = trim(stripslashes($key));
+ array_push($selectnames, "$selected");
+ }
+
+ $count = count($formnames);
+ for ($i = 0; $i < $count; $i ++) {
+ if ($selectnames[$i] != '#NONE#') { //if no name was selected from the select menu, use the name entered in the form
+ array_push($this->newauthornames, "$selectnames[$i]");
+ } else {
+ array_push($this->newauthornames, "$formnames[$i]");
+ }
+ }
+ }
+
+ function mt_authors_form() {
+?>
+<div class="wrap">
+<h2><?php _e('Assign Authors'); ?></h2>
+<p><?php _e('To make it easier for you to edit and save the imported posts and drafts, you may want to change the name of the author of the posts. For example, you may want to import all the entries as <code>admin</code>s entries.'); ?></p>
+<p><?php _e('Below, you can see the names of the authors of the MovableType posts in <i>italics</i>. For each of these names, you can either pick an author in your WordPress installation from the menu, or enter a name for the author in the textbox.'); ?></p>
+<p><?php _e('If a new user is created by WordPress, the password will be set, by default, to "changeme". Quite suggestive, eh? ;)'); ?></p>
+ <?php
+
+
+ $authors = $this->get_mt_authors();
+ echo '<ol id="authors">';
+ echo '<form action="?import=mt&amp;step=2&amp;id=' . $this->id . '" method="post">';
+ $j = -1;
+ foreach ($authors as $author) {
+ ++ $j;
+ echo '<li><i>'.$author.'</i><br />'.'<input type="text" value="'.$author.'" name="'.'user[]'.'" maxlength="30">';
+ $this->users_form($j);
+ echo '</li>';
+ }
+
+ echo '<input type="submit" value="Submit">'.'<br/>';
+ echo '</form>';
+ echo '</ol></div>';
+
+ }
+
+ function select_authors() {
+ $file = wp_import_handle_upload();
+ if ( isset($file['error']) ) {
+ echo $file['error'];
+ return;
+ }
+ $this->file = $file['file'];
+ $this->id = $file['id'];
+
+ $this->get_entries();
+ $this->mt_authors_form();
+ }
+
+ function process_posts() {
+ global $wpdb;
+ $i = -1;
+ echo "<div class='wrap'><ol>";
+ foreach ($this->posts as $post) {
+ if ('' != trim($post)) {
+ ++ $i;
+ unset ($post_categories);
+
+ // Take the pings out first
+ preg_match("|(-----\n\nPING:.*)|s", $post, $pings);
+ $post = preg_replace("|(-----\n\nPING:.*)|s", '', $post);
+
+ // Then take the comments out
+ preg_match("|(-----\nCOMMENT:.*)|s", $post, $comments);
+ $post = preg_replace("|(-----\nCOMMENT:.*)|s", '', $post);
+
+ // We ignore the keywords
+ $post = preg_replace("|(-----\nKEYWORDS:.*)|s", '', $post);
+
+ // We want the excerpt
+ preg_match("|-----\nEXCERPT:(.*)|s", $post, $excerpt);
+ $excerpt = $wpdb->escape(trim($excerpt[1]));
+ $post = preg_replace("|(-----\nEXCERPT:.*)|s", '', $post);
+
+ // We're going to put extended body into main body with a more tag
+ preg_match("|-----\nEXTENDED BODY:(.*)|s", $post, $extended);
+ $extended = trim($extended[1]);
+ if ('' != $extended)
+ $extended = "\n<!--more-->\n$extended";
+ $post = preg_replace("|(-----\nEXTENDED BODY:.*)|s", '', $post);
+
+ // Now for the main body
+ preg_match("|-----\nBODY:(.*)|s", $post, $body);
+ $body = trim($body[1]);
+ $post_content = $wpdb->escape($body.$extended);
+ $post = preg_replace("|(-----\nBODY:.*)|s", '', $post);
+
+ // Grab the metadata from what's left
+ $metadata = explode("\n", $post);
+ foreach ($metadata as $line) {
+ preg_match("/^(.*?):(.*)/", $line, $token);
+ $key = trim($token[1]);
+ $value = trim($token[2]);
+ // Now we decide what it is and what to do with it
+ switch ($key) {
+ case '' :
+ break;
+ case 'AUTHOR' :
+ $post_author = $value;
+ break;
+ case 'TITLE' :
+ $post_title = $wpdb->escape($value);
+ break;
+ case 'STATUS' :
+ // "publish" and "draft" enumeration items match up; no change required
+ $post_status = $value;
+ if (empty ($post_status))
+ $post_status = 'publish';
+ break;
+ case 'ALLOW COMMENTS' :
+ $post_allow_comments = $value;
+ if ($post_allow_comments == 1) {
+ $comment_status = 'open';
+ } else {
+ $comment_status = 'closed';
+ }
+ break;
+ case 'CONVERT BREAKS' :
+ $post_convert_breaks = $value;
+ break;
+ case 'ALLOW PINGS' :
+ $ping_status = trim($meta[2][0]);
+ if ($ping_status == 1) {
+ $ping_status = 'open';
+ } else {
+ $ping_status = 'closed';
+ }
+ break;
+ case 'PRIMARY CATEGORY' :
+ if (! empty ($value) )
+ $post_categories[] = $wpdb->escape($value);
+ break;
+ case 'CATEGORY' :
+ if (! empty ($value) )
+ $post_categories[] = $wpdb->escape($value);
+ break;
+ case 'DATE' :
+ $post_modified = strtotime($value);
+ $post_modified = date('Y-m-d H:i:s', $post_modified);
+ $post_modified_gmt = get_gmt_from_date("$post_modified");
+ $post_date = $post_modified;
+ $post_date_gmt = $post_modified_gmt;
+ break;
+ default :
+ // echo "\n$key: $value";
+ break;
+ } // end switch
+ } // End foreach
+
+ // Let's check to see if it's in already
+ 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));
+
+ $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', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt');
+ $post_id = wp_insert_post($postdata);
+ // Add categories.
+ if (0 != count($post_categories)) {
+ wp_create_categories($post_categories, $post_id);
+ }
+ }
+
+ $comment_post_ID = $post_id;
+ $comment_approved = 1;
+
+ // Now for comments
+ $comments = explode("-----\nCOMMENT:", $comments[0]);
+ $num_comments = 0;
+ foreach ($comments as $comment) {
+ if ('' != trim($comment)) {
+ // Author
+ preg_match("|AUTHOR:(.*)|", $comment, $comment_author);
+ $comment_author = $wpdb->escape(trim($comment_author[1]));
+ $comment = preg_replace('|(\n?AUTHOR:.*)|', '', $comment);
+ preg_match("|EMAIL:(.*)|", $comment, $comment_author_email);
+ $comment_author_email = $wpdb->escape(trim($comment_author_email[1]));
+ $comment = preg_replace('|(\n?EMAIL:.*)|', '', $comment);
+
+ preg_match("|IP:(.*)|", $comment, $comment_author_IP);
+ $comment_author_IP = trim($comment_author_IP[1]);
+ $comment = preg_replace('|(\n?IP:.*)|', '', $comment);
+
+ preg_match("|URL:(.*)|", $comment, $comment_author_url);
+ $comment_author_url = $wpdb->escape(trim($comment_author_url[1]));
+ $comment = preg_replace('|(\n?URL:.*)|', '', $comment);
+
+ preg_match("|DATE:(.*)|", $comment, $comment_date);
+ $comment_date = trim($comment_date[1]);
+ $comment_date = date('Y-m-d H:i:s', strtotime($comment_date));
+ $comment = preg_replace('|(\n?DATE:.*)|', '', $comment);
+
+ $comment_content = $wpdb->escape(trim($comment));
+ $comment_content = str_replace('-----', '', $comment_content);
+ // Check if it's already there
+ 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_content', 'comment_approved');
+ $commentdata = wp_filter_comment($commentdata);
+ wp_insert_comment($commentdata);
+ $num_comments++;
+ }
+ }
+ }
+ if ( $num_comments )
+ printf(__(' (%s comments)'), $num_comments);
+
+ // Finally the pings
+ // fix the double newline on the first one
+ $pings[0] = str_replace("-----\n\n", "-----\n", $pings[0]);
+ $pings = explode("-----\nPING:", $pings[0]);
+ $num_pings = 0;
+ foreach ($pings as $ping) {
+ if ('' != trim($ping)) {
+ // 'Author'
+ preg_match("|BLOG NAME:(.*)|", $ping, $comment_author);
+ $comment_author = $wpdb->escape(trim($comment_author[1]));
+ $ping = preg_replace('|(\n?BLOG NAME:.*)|', '', $ping);
+
+ preg_match("|IP:(.*)|", $ping, $comment_author_IP);
+ $comment_author_IP = trim($comment_author_IP[1]);
+ $ping = preg_replace('|(\n?IP:.*)|', '', $ping);
+
+ preg_match("|URL:(.*)|", $ping, $comment_author_url);
+ $comment_author_url = $wpdb->escape(trim($comment_author_url[1]));
+ $ping = preg_replace('|(\n?URL:.*)|', '', $ping);
+
+ preg_match("|DATE:(.*)|", $ping, $comment_date);
+ $comment_date = trim($comment_date[1]);
+ $comment_date = date('Y-m-d H:i:s', strtotime($comment_date));
+ $ping = preg_replace('|(\n?DATE:.*)|', '', $ping);
+
+ preg_match("|TITLE:(.*)|", $ping, $ping_title);
+ $ping_title = $wpdb->escape(trim($ping_title[1]));
+ $ping = preg_replace('|(\n?TITLE:.*)|', '', $ping);
+
+ $comment_content = $wpdb->escape(trim($ping));
+ $comment_content = str_replace('-----', '', $comment_content);
+
+ $comment_content = "<strong>$ping_title</strong>\n\n$comment_content";
+
+ $comment_type = 'trackback';
+
+ // Check if it's already there
+ 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_content', 'comment_type', 'comment_approved');
+ $commentdata = wp_filter_comment($commentdata);
+ wp_insert_comment($commentdata);
+ $num_pings++;
+ }
+ }
+ }
+ if ( $num_pings )
+ printf(__(' (%s pings)'), $num_pings);
+
+ echo "</li>";
+ }
+ }
+
+ echo '</ol>';
+
+ wp_import_cleanup($this->id);
+
+ echo '<h3>'.sprintf(__('All done. <a href="%s">Have fun!</a>'), get_option('home')).'</h3></div>';
+ }
+
+ function import() {
+ $this->id = (int) $_GET['id'];
+
+ $this->file = get_attached_file($this->id);
+ $this->get_authors_from_post();
+ $this->get_entries();
+ $this->process_posts();
+ }
+
+ function dispatch() {
+ if (empty ($_GET['step']))
+ $step = 0;
+ else
+ $step = (int) $_GET['step'];
+
+ switch ($step) {
+ case 0 :
+ $this->greet();
+ break;
+ case 1 :
+ $this->select_authors();
+ break;
+ case 2:
+ $this->import();
+ break;
+ }
+ }
+
+ function MT_Import() {
+ // Nothing.
+ }
+}
+
+$mt_import = new MT_Import();
+
+register_importer('mt', 'Movable Type and Typepad', __('Imports <strong>posts and comments</strong> from your Movable Type or Typepad blog'), array ($mt_import, 'dispatch'));
+?>
diff --git a/wp-admin/import/rss.php b/wp-admin/import/rss.php
new file mode 100644
index 0000000..69972f3
--- /dev/null
+++ b/wp-admin/import/rss.php
@@ -0,0 +1,171 @@
+<?php
+
+class RSS_Import {
+
+ var $posts = array ();
+ var $file;
+
+ function header() {
+ echo '<div class="wrap">';
+ echo '<h2>'.__('Import RSS').'</h2>';
+ }
+
+ function footer() {
+ echo '</div>';
+ }
+
+ function unhtmlentities($string) { // From php.net for < 4.3 compat
+ $trans_tbl = get_html_translation_table(HTML_ENTITIES);
+ $trans_tbl = array_flip($trans_tbl);
+ return strtr($string, $trans_tbl);
+ }
+
+ function greet() {
+ echo '<p>'.__('Howdy! This importer allows you to extract posts from any RSS 2.0 file into your blog. This is useful if you want to import your posts from a system that is not handled by a custom import tool. Pick an RSS file to upload and click Import.').'</p>';
+ wp_import_upload_form("admin.php?import=rss&amp;step=1");
+ }
+
+ function get_posts() {
+ global $wpdb;
+
+ set_magic_quotes_runtime(0);
+ $datalines = file($this->file); // Read the file into an array
+ $importdata = implode('', $datalines); // squish it
+ $importdata = str_replace(array ("\r\n", "\r"), "\n", $importdata);
+
+ preg_match_all('|<item>(.*?)</item>|is', $importdata, $this->posts);
+ $this->posts = $this->posts[1];
+ $index = 0;
+ foreach ($this->posts as $post) {
+ preg_match('|<title>(.*?)</title>|is', $post, $post_title);
+ $post_title = $wpdb->escape(trim($post_title[1]));
+
+ preg_match('|<pubdate>(.*?)</pubdate>|is', $post, $post_date);
+
+ if ($post_date) {
+ $post_date = strtotime($post_date[1]);
+ } else {
+ // if we don't already have something from pubDate
+ preg_match('|<dc:date>(.*?)</dc:date>|is', $post, $post_date);
+ $post_date = preg_replace('|([-+])([0-9]+):([0-9]+)$|', '\1\2\3', $post_date[1]);
+ $post_date = str_replace('T', ' ', $post_date);
+ $post_date = strtotime($post_date);
+ }
+
+ $post_date = gmdate('Y-m-d H:i:s', $post_date);
+
+ preg_match_all('|<category>(.*?)</category>|is', $post, $categories);
+ $categories = $categories[1];
+
+ if (!$categories) {
+ preg_match_all('|<dc:subject>(.*?)</dc:subject>|is', $post, $categories);
+ $categories = $categories[1];
+ }
+
+ $cat_index = 0;
+ foreach ($categories as $category) {
+ $categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category));
+ $cat_index++;
+ }
+
+ preg_match('|<guid.+?>(.*?)</guid>|is', $post, $guid);
+ if ($guid)
+ $guid = $wpdb->escape(trim($guid[1]));
+ else
+ $guid = '';
+
+ preg_match('|<content:encoded>(.*?)</content:encoded>|is', $post, $post_content);
+ $post_content = str_replace(array ('<![CDATA[', ']]>'), '', $wpdb->escape(trim($post_content[1])));
+
+ if (!$post_content) {
+ // This is for feeds that put content in description
+ preg_match('|<description>(.*?)</description>|is', $post, $post_content);
+ $post_content = $wpdb->escape($this->unhtmlentities(trim($post_content[1])));
+ }
+
+ // Clean up 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);
+
+ $post_author = 1;
+ $post_status = 'publish';
+ $this->posts[$index] = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status', 'guid', 'categories');
+ $index++;
+ }
+ }
+
+ function import_posts() {
+ echo '<ol>';
+
+ foreach ($this->posts as $post) {
+ echo "<li>".__('Importing post...');
+
+ extract($post);
+
+ if ($post_id = post_exists($post_title, $post_content, $post_date)) {
+ _e('Post already imported');
+ } else {
+ $post_id = wp_insert_post($post);
+ if (!$post_id) {
+ _e("Couldn't get post ID");
+ return;
+ }
+
+ if (0 != count($categories))
+ wp_create_categories($categories, $post_id);
+ _e('Done !');
+ }
+ echo '</li>';
+ }
+
+ echo '</ol>';
+
+ }
+
+ function import() {
+ $file = wp_import_handle_upload();
+ if ( isset($file['error']) ) {
+ echo $file['error'];
+ return;
+ }
+
+ $this->file = $file['file'];
+ $this->get_posts();
+ $this->import_posts();
+ wp_import_cleanup($file['id']);
+
+ echo '<h3>';
+ printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home'));
+ echo '</h3>';
+ }
+
+ function dispatch() {
+ if (empty ($_GET['step']))
+ $step = 0;
+ else
+ $step = (int) $_GET['step'];
+
+ $this->header();
+
+ switch ($step) {
+ case 0 :
+ $this->greet();
+ break;
+ case 1 :
+ $this->import();
+ break;
+ }
+
+ $this->footer();
+ }
+
+ function RSS_Import() {
+ // Nothing.
+ }
+}
+
+$rss_import = new RSS_Import();
+
+register_importer('rss', 'RSS', __('Import posts from an RSS feed'), array ($rss_import, 'dispatch'));
+?>
diff --git a/wp-admin/import/textpattern.php b/wp-admin/import/textpattern.php
new file mode 100644
index 0000000..17cae87
--- /dev/null
+++ b/wp-admin/import/textpattern.php
@@ -0,0 +1,663 @@
+<?php
+/**
+ Add These Functions to make our lives easier
+**/
+if(!function_exists('get_catbynicename'))
+{
+ function get_catbynicename($category_nicename)
+ {
+ global $wpdb;
+
+ $cat_id -= 0; // force numeric
+ $name = $wpdb->get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"');
+
+ return $name;
+ }
+}
+
+if(!function_exists('get_comment_count'))
+{
+ function get_comment_count($post_ID)
+ {
+ global $wpdb;
+ return $wpdb->get_var('SELECT count(*) FROM '.$wpdb->comments.' WHERE comment_post_ID = '.$post_ID);
+ }
+}
+
+if(!function_exists('link_exists'))
+{
+ function link_exists($linkname)
+ {
+ global $wpdb;
+ return $wpdb->get_var('SELECT link_id FROM '.$wpdb->links.' WHERE link_name = "'.$wpdb->escape($linkname).'"');
+ }
+}
+
+/**
+ The Main Importer Class
+**/
+class Textpattern_Import {
+
+ function header()
+ {
+ echo '<div class="wrap">';
+ echo '<h2>'.__('Import Textpattern').'</h2>';
+ echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'</p>';
+ }
+
+ function footer()
+ {
+ echo '</div>';
+ }
+
+ function greet()
+ {
+ echo '<p>'.__('Howdy! This importer allows you to extract posts from any Textpattern 4.0.2+ into your blog. 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">';
+ $this->db_form();
+ echo '<input type="submit" name="submit" value="'.__('Import Categories').'" />';
+ echo '</form>';
+ }
+
+ function get_txp_cats()
+ {
+ global $wpdb;
+ // General Housekeeping
+ $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost'));
+ set_magic_quotes_runtime(0);
+ $prefix = get_option('tpre');
+
+ // Get Categories
+ return $txpdb->get_results('SELECT
+ id,
+ name,
+ title
+ FROM '.$prefix.'txp_category
+ WHERE type = "article"',
+ ARRAY_A);
+ }
+
+ function get_txp_users()
+ {
+ global $wpdb;
+ // General Housekeeping
+ $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost'));
+ set_magic_quotes_runtime(0);
+ $prefix = get_option('tpre');
+
+ // Get Users
+
+ return $txpdb->get_results('SELECT
+ user_id,
+ name,
+ RealName,
+ email,
+ privs
+ FROM '.$prefix.'txp_users', ARRAY_A);
+ }
+
+ function get_txp_posts()
+ {
+ // General Housekeeping
+ $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost'));
+ set_magic_quotes_runtime(0);
+ $prefix = get_option('tpre');
+
+ // Get Posts
+ return $txpdb->get_results('SELECT
+ ID,
+ Posted,
+ AuthorID,
+ LastMod,
+ Title,
+ Body,
+ Excerpt,
+ Category1,
+ Category2,
+ Status,
+ Keywords,
+ url_title,
+ comments_count
+ FROM '.$prefix.'textpattern
+ ', ARRAY_A);
+ }
+
+ function get_txp_comments()
+ {
+ global $wpdb;
+ // General Housekeeping
+ $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost'));
+ set_magic_quotes_runtime(0);
+ $prefix = get_option('tpre');
+
+ // Get Comments
+ return $txpdb->get_results('SELECT * FROM '.$prefix.'txp_discuss', ARRAY_A);
+ }
+
+ function get_txp_links()
+ {
+ //General Housekeeping
+ $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost'));
+ set_magic_quotes_runtime(0);
+ $prefix = get_option('tpre');
+
+ return $txpdb->get_results('SELECT
+ id,
+ date,
+ category,
+ url,
+ linkname,
+ description
+ FROM '.$prefix.'txp_link',
+ ARRAY_A);
+ }
+
+ function cat2wp($categories='')
+ {
+ // General Housekeeping
+ global $wpdb;
+ $count = 0;
+ $txpcat2wpcat = array();
+ // Do the Magic
+ if(is_array($categories))
+ {
+ echo '<p>'.__('Importing Categories...').'<br /><br /></p>';
+ foreach ($categories as $category)
+ {
+ $count++;
+ extract($category);
+
+
+ // Make Nice Variables
+ $name = $wpdb->escape($name);
+ $title = $wpdb->escape($title);
+
+ if($cinfo = category_exists($name))
+ {
+ $ret_id = wp_insert_category(array('cat_ID' => $cinfo, 'category_nicename' => $name, 'cat_name' => $title));
+ }
+ else
+ {
+ $ret_id = wp_insert_category(array('category_nicename' => $name, 'cat_name' => $title));
+ }
+ $txpcat2wpcat[$id] = $ret_id;
+ }
+
+ // Store category translation for future use
+ add_option('txpcat2wpcat',$txpcat2wpcat);
+ echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> categories imported.'), $count).'<br /><br /></p>';
+ return true;
+ }
+ echo __('No Categories to Import!');
+ return false;
+ }
+
+ function users2wp($users='')
+ {
+ // General Housekeeping
+ global $wpdb;
+ $count = 0;
+ $txpid2wpid = array();
+
+ // Midnight Mojo
+ if(is_array($users))
+ {
+ echo '<p>'.__('Importing Users...').'<br /><br /></p>';
+ foreach($users as $user)
+ {
+ $count++;
+ extract($user);
+
+ // Make Nice Variables
+ $name = $wpdb->escape($name);
+ $RealName = $wpdb->escape($RealName);
+
+ if($uinfo = get_userdatabylogin($name))
+ {
+
+ $ret_id = wp_insert_user(array(
+ 'ID' => $uinfo->ID,
+ 'user_login' => $name,
+ 'user_nicename' => $RealName,
+ 'user_email' => $email,
+ 'user_url' => 'http://',
+ 'display_name' => $name)
+ );
+ }
+ else
+ {
+ $ret_id = wp_insert_user(array(
+ 'user_login' => $name,
+ 'user_nicename' => $RealName,
+ 'user_email' => $email,
+ 'user_url' => 'http://',
+ 'display_name' => $name)
+ );
+ }
+ $txpid2wpid[$user_id] = $ret_id;
+
+ // Set Textpattern-to-WordPress permissions translation
+ $transperms = array(1 => '10', 2 => '9', 3 => '5', 4 => '4', 5 => '3', 6 => '2', 7 => '0');
+
+ // Update Usermeta Data
+ $user = new WP_User($ret_id);
+ if('10' == $transperms[$privs]) { $user->set_role('administrator'); }
+ if('9' == $transperms[$privs]) { $user->set_role('editor'); }
+ if('5' == $transperms[$privs]) { $user->set_role('editor'); }
+ if('4' == $transperms[$privs]) { $user->set_role('author'); }
+ if('3' == $transperms[$privs]) { $user->set_role('contributor'); }
+ if('2' == $transperms[$privs]) { $user->set_role('contributor'); }
+ if('0' == $transperms[$privs]) { $user->set_role('subscriber'); }
+
+ update_usermeta( $ret_id, 'wp_user_level', $transperms[$privs] );
+ update_usermeta( $ret_id, 'rich_editing', 'false');
+ }// End foreach($users as $user)
+
+ // Store id translation array for future use
+ add_option('txpid2wpid',$txpid2wpid);
+
+
+ echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> users imported.'), $count).'<br /><br /></p>';
+ return true;
+ }// End if(is_array($users)
+
+ echo __('No Users to Import!');
+ return false;
+
+ }// End function user2wp()
+
+ function posts2wp($posts='')
+ {
+ // General Housekeeping
+ global $wpdb;
+ $count = 0;
+ $txpposts2wpposts = array();
+ $cats = array();
+
+ // Do the Magic
+ if(is_array($posts))
+ {
+ echo '<p>'.__('Importing Posts...').'<br /><br /></p>';
+ foreach($posts as $post)
+ {
+ $count++;
+ extract($post);
+
+ // Set Textpattern-to-WordPress status translation
+ $stattrans = array(1 => 'draft', 2 => 'private', 3 => 'draft', 4 => 'publish', 5 => 'publish');
+
+ //Can we do this more efficiently?
+ $uinfo = ( get_userdatabylogin( $AuthorID ) ) ? get_userdatabylogin( $AuthorID ) : 1;
+ $authorid = ( is_object( $uinfo ) ) ? $uinfo->ID : $uinfo ;
+
+ $Title = $wpdb->escape($Title);
+ $Body = $wpdb->escape($Body);
+ $Excerpt = $wpdb->escape($Excerpt);
+ $post_status = $stattrans[$Status];
+
+ // Import Post data into WordPress
+
+ if($pinfo = post_exists($Title,$Body))
+ {
+ $ret_id = wp_insert_post(array(
+ 'ID' => $pinfo,
+ 'post_date' => $Posted,
+ 'post_date_gmt' => $post_date_gmt,
+ 'post_author' => $authorid,
+ 'post_modified' => $LastMod,
+ 'post_modified_gmt' => $post_modified_gmt,
+ 'post_title' => $Title,
+ 'post_content' => $Body,
+ 'post_excerpt' => $Excerpt,
+ 'post_status' => $post_status,
+ 'post_name' => $url_title,
+ 'comment_count' => $comments_count)
+ );
+ }
+ else
+ {
+ $ret_id = wp_insert_post(array(
+ 'post_date' => $Posted,
+ 'post_date_gmt' => $post_date_gmt,
+ 'post_author' => $authorid,
+ 'post_modified' => $LastMod,
+ 'post_modified_gmt' => $post_modified_gmt,
+ 'post_title' => $Title,
+ 'post_content' => $Body,
+ 'post_excerpt' => $Excerpt,
+ 'post_status' => $post_status,
+ 'post_name' => $url_title,
+ 'comment_count' => $comments_count)
+ );
+ }
+ $txpposts2wpposts[$ID] = $ret_id;
+
+ // Make Post-to-Category associations
+ $cats = array();
+ if($cat1 = get_catbynicename($Category1)) { $cats[1] = $cat1; }
+ if($cat2 = get_catbynicename($Category2)) { $cats[2] = $cat2; }
+
+ if(!empty($cats)) { wp_set_post_cats('', $ret_id, $cats); }
+ }
+ }
+ // Store ID translation for later use
+ add_option('txpposts2wpposts',$txpposts2wpposts);
+
+ echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> posts imported.'), $count).'<br /><br /></p>';
+ return true;
+ }
+
+ function comments2wp($comments='')
+ {
+ // General Housekeeping
+ global $wpdb;
+ $count = 0;
+ $txpcm2wpcm = array();
+ $postarr = get_option('txpposts2wpposts');
+
+ // Magic Mojo
+ if(is_array($comments))
+ {
+ echo '<p>'.__('Importing Comments...').'<br /><br /></p>';
+ foreach($comments as $comment)
+ {
+ $count++;
+ extract($comment);
+
+ // WordPressify Data
+ $comment_ID = ltrim($discussid, '0');
+ $comment_post_ID = $postarr[$parentid];
+ $comment_approved = (1 == $visible) ? 1 : 0;
+ $name = $wpdb->escape($name);
+ $email = $wpdb->escape($email);
+ $web = $wpdb->escape($web);
+ $message = $wpdb->escape($message);
+
+ if($cinfo = comment_exists($name, $posted))
+ {
+ // Update comments
+ $ret_id = wp_update_comment(array(
+ 'comment_ID' => $cinfo,
+ 'comment_post_ID' => $comment_post_ID,
+ 'comment_author' => $name,
+ 'comment_author_email' => $email,
+ 'comment_author_url' => $web,
+ 'comment_date' => $posted,
+ 'comment_content' => $message,
+ 'comment_approved' => $comment_approved)
+ );
+ }
+ else
+ {
+ // Insert comments
+ $ret_id = wp_insert_comment(array(
+ 'comment_post_ID' => $comment_post_ID,
+ 'comment_author' => $name,
+ 'comment_author_email' => $email,
+ 'comment_author_url' => $web,
+ 'comment_author_IP' => $ip,
+ 'comment_date' => $posted,
+ 'comment_content' => $message,
+ 'comment_approved' => $comment_approved)
+ );
+ }
+ $txpcm2wpcm[$comment_ID] = $ret_id;
+ }
+ // Store Comment ID translation for future use
+ add_option('txpcm2wpcm', $txpcm2wpcm);
+
+ // Associate newly formed categories with posts
+ get_comment_count($ret_id);
+
+
+ echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> comments imported.'), $count).'<br /><br /></p>';
+ return true;
+ }
+ echo __('No Comments to Import!');
+ return false;
+ }
+
+ function links2wp($links='')
+ {
+ // General Housekeeping
+ global $wpdb;
+ $count = 0;
+
+ // Deal with the links
+ if(is_array($links))
+ {
+ echo '<p>'.__('Importing Links...').'<br /><br /></p>';
+ foreach($links as $link)
+ {
+ $count++;
+ extract($link);
+
+ // Make nice vars
+ $category = $wpdb->escape($category);
+ $linkname = $wpdb->escape($linkname);
+ $description = $wpdb->escape($description);
+
+ if($linfo = link_exists($linkname))
+ {
+ $ret_id = wp_insert_link(array(
+ 'link_id' => $linfo,
+ 'link_url' => $url,
+ 'link_name' => $linkname,
+ 'link_category' => $category,
+ 'link_description' => $description,
+ 'link_updated' => $date)
+ );
+ }
+ else
+ {
+ $ret_id = wp_insert_link(array(
+ 'link_url' => $url,
+ 'link_name' => $linkname,
+ 'link_category' => $category,
+ 'link_description' => $description,
+ 'link_updated' => $date)
+ );
+ }
+ $txplinks2wplinks[$link_id] = $ret_id;
+ }
+ add_option('txplinks2wplinks',$txplinks2wplinks);
+ echo '<p>';
+ printf(__('Done! <strong>%s</strong> Links imported'), $count);
+ echo '<br /><br /></p>';
+ return true;
+ }
+ echo __('No Links to Import!');
+ return false;
+ }
+
+ function import_categories()
+ {
+ // Category Import
+ $cats = $this->get_txp_cats();
+ $this->cat2wp($cats);
+ add_option('txp_cats', $cats);
+
+
+
+ echo '<form action="admin.php?import=textpattern&amp;step=2" method="post">';
+ printf('<input type="submit" name="submit" value="%s" />', __('Import Users'));
+ echo '</form>';
+
+ }
+
+ function import_users()
+ {
+ // User Import
+ $users = $this->get_txp_users();
+ $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'));
+ echo '</form>';
+ }
+
+ function import_posts()
+ {
+ // Post Import
+ $posts = $this->get_txp_posts();
+ $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'));
+ echo '</form>';
+ }
+
+ function import_comments()
+ {
+ // Comment Import
+ $comments = $this->get_txp_comments();
+ $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'));
+ echo '</form>';
+ }
+
+ function import_links()
+ {
+ //Link Import
+ $links = $this->get_txp_links();
+ $this->links2wp($links);
+ 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'));
+ echo '</form>';
+ }
+
+ function cleanup_txpimport()
+ {
+ delete_option('tpre');
+ delete_option('txp_cats');
+ delete_option('txpid2wpid');
+ delete_option('txpcat2wpcat');
+ delete_option('txpposts2wpposts');
+ delete_option('txpcm2wpcm');
+ delete_option('txplinks2wplinks');
+ delete_option('txpuser');
+ delete_option('txppass');
+ delete_option('txpname');
+ delete_option('txphost');
+ $this->tips();
+ }
+
+ function tips()
+ {
+ 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 '<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/2004/04/19/wordpress-plugin-textile-20/">Textile for WordPress</a>. Trust me... You\'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>';
+ echo '<li>'.__('<a href="http://www.wordpress.org">The official WordPress site</a>').'</li>';
+ echo '<li>'.__('<a href="http://wordpress.org/support/">The WordPress support forums').'</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>';
+ }
+
+ function db_form()
+ {
+ echo '<ul>';
+ printf('<li><label for="dbuser">%s</label> <input type="text" name="dbuser" /></li>', __('Textpattern Database User:'));
+ printf('<li><label for="dbpass">%s</label> <input type="password" name="dbpass" /></li>', __('Textpattern Database Password:'));
+ printf('<li><label for="dbname">%s</label> <input type="text" name="dbname" /></li>', __('Textpattern Database Name:'));
+ printf('<li><label for="dbhost">%s</label> <input type="text" name="dbhost" value="localhost" /></li>', __('Textpattern Database Host:'));
+ printf('<li><label for="dbprefix">%s</label> <input type="text" name="dbprefix" /></li>', __('Textpattern Table prefix (if any):'));
+ echo '</ul>';
+ }
+
+ function dispatch()
+ {
+
+ if (empty ($_GET['step']))
+ $step = 0;
+ else
+ $step = (int) $_GET['step'];
+ $this->header();
+
+ if ( $step > 0 )
+ {
+ if($_POST['dbuser'])
+ {
+ if(get_option('txpuser'))
+ delete_option('txpuser');
+ add_option('txpuser',$_POST['dbuser']);
+ }
+ if($_POST['dbpass'])
+ {
+ if(get_option('txppass'))
+ delete_option('txppass');
+ add_option('txppass',$_POST['dbpass']);
+ }
+
+ if($_POST['dbname'])
+ {
+ if(get_option('txpname'))
+ delete_option('txpname');
+ add_option('txpname',$_POST['dbname']);
+ }
+ if($_POST['dbhost'])
+ {
+ if(get_option('txphost'))
+ delete_option('txphost');
+ add_option('txphost',$_POST['dbhost']);
+ }
+ if($_POST['dbprefix'])
+ {
+ if(get_option('tpre'))
+ delete_option('tpre');
+ add_option('tpre',$_POST['dbprefix']);
+ }
+
+
+ }
+
+ switch ($step)
+ {
+ default:
+ case 0 :
+ $this->greet();
+ break;
+ case 1 :
+ $this->import_categories();
+ break;
+ case 2 :
+ $this->import_users();
+ break;
+ case 3 :
+ $this->import_posts();
+ break;
+ case 4 :
+ $this->import_comments();
+ break;
+ case 5 :
+ $this->import_links();
+ break;
+ case 6 :
+ $this->cleanup_txpimport();
+ break;
+ }
+
+ $this->footer();
+ }
+
+ function Textpattern_Import()
+ {
+ // Nothing.
+ }
+}
+
+$txp_import = new Textpattern_Import();
+register_importer('textpattern', 'Textpattern', __('Import posts from a Textpattern Blog'), array ($txp_import, 'dispatch'));
+?>
diff --git a/wp-admin/import/wordpress.php b/wp-admin/import/wordpress.php
new file mode 100644
index 0000000..997628b
--- /dev/null
+++ b/wp-admin/import/wordpress.php
@@ -0,0 +1,288 @@
+<?php
+
+class WP_Import {
+
+ var $posts = array ();
+ var $file;
+ var $id;
+ var $mtnames = array ();
+ var $newauthornames = array ();
+ var $j = -1;
+
+ function header() {
+ echo '<div class="wrap">';
+ echo '<h2>'.__('Import WordPress').'</h2>';
+ }
+
+ function footer() {
+ echo '</div>';
+ }
+
+ function unhtmlentities($string) { // From php.net for < 4.3 compat
+ $trans_tbl = get_html_translation_table(HTML_ENTITIES);
+ $trans_tbl = array_flip($trans_tbl);
+ return strtr($string, $trans_tbl);
+ }
+
+ function greet() {
+ echo '<p>'.__('Howdy! Upload your WordPress eXtended RSS (WXR) file and we&#8217;ll import the posts and comments into this blog.').'</p>';
+ wp_import_upload_form("admin.php?import=wordpress&amp;step=1");
+ }
+
+ function get_tag( $string, $tag ) {
+ preg_match("|<$tag.*?>(.*?)</$tag>|is", $string, $return);
+ $return = addslashes( trim( $return[1] ) );
+ return $return;
+ }
+
+ function users_form($n) {
+ global $wpdb, $testing;
+ $users = get_users_of_blog($wpdb->blogid);
+?><select name="userselect[<?php echo $n; ?>]">
+ <option value="#NONE#">- Select -</option>
+ <?php
+ foreach ($users as $user) {
+ echo '<option value="'.$user->user_login.'">'.$user->user_login.'</option>';
+ }
+?>
+ </select>
+ <?php
+ }
+
+ //function to check the authorname and do the mapping
+ function checkauthor($author) {
+ global $wpdb;
+ //mtnames is an array with the names in the mt import file
+ $pass = 'changeme';
+ $key = array_search($author, $this->mtnames); //find the array key for $author in the $mtnames array
+ $user_id = username_exists($this->newauthornames[$key]); //use that key to get the value of the author's name from $newauthornames
+
+ return $user_id;
+ }
+
+ 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];
+ }
+
+ function get_wp_authors() {
+ $temp = array ();
+ $i = -1;
+ foreach ($this->posts as $post) {
+ if ('' != trim($post)) {
+ ++ $i;
+ $author = $this->get_tag( $post, 'dc:creator' );
+ array_push($temp, "$author"); //store the extracted author names in a temporary array
+ }
+ }
+
+ // We need to find unique values of author names, while preserving the order, so this function emulates the unique_value(); php function, without the sorting.
+ $authors[0] = array_shift($temp);
+ $y = count($temp) + 1;
+ for ($x = 1; $x < $y; $x ++) {
+ $next = array_shift($temp);
+ if (!(in_array($next, $authors)))
+ array_push($authors, "$next");
+ }
+
+ return $authors;
+ }
+
+ function get_authors_from_post() {
+ $formnames = array ();
+ $selectnames = array ();
+
+ foreach ($_POST['userselect'] as $user => $key) {
+ $selected = trim(stripslashes($key));
+ array_push($selectnames, "$selected");
+ }
+
+ $count = count($formnames);
+ for ($i = 0; $i < $count; $i ++) {
+ if ($selectnames[$i] != '#NONE#') { //if no name was selected from the select menu, use the name entered in the form
+ array_push($this->newauthornames, "$selectnames[$i]");
+ } else {
+ array_push($this->newauthornames, "$formnames[$i]");
+ }
+ }
+ }
+
+ function wp_authors_form() {
+?>
+<h2><?php _e('Assign Authors'); ?></h2>
+<p><?php _e('To make it easier for you to edit and save the imported posts and drafts, you may want to change the name of the author of the posts. For example, you may want to import all the entries as <code>admin</code>s entries.'); ?></p>
+<p><?php _e('If a new user is created by WordPress, the password will be set, by default, to "changeme". Quite suggestive, eh? ;)'); ?></p>
+ <?php
+
+
+ $authors = $this->get_wp_authors();
+ echo '<ol id="authors">';
+ echo '<form action="?import=wordpress&amp;step=2&amp;id=' . $this->id . '" method="post">';
+ $j = -1;
+ foreach ($authors as $author) {
+ ++ $j;
+ echo '<li>Current author: <strong>'.$author.'</strong><br />'.'Map to existing: ';
+ $this->users_form($j);
+ echo '</li>';
+ }
+
+ echo '<input type="submit" value="Submit">'.'<br/>';
+ echo '</form>';
+ echo '</ol>';
+
+ }
+
+ 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'];
+ $this->id = $file['id'];
+
+ $this->get_entries();
+ $this->wp_authors_form();
+ }
+
+ 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($category));
+ $cat_index++;
+ }
+
+ 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));
+
+ $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', '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);
+ }
+ }
+
+ // 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++;
+ }
+
+ echo '</ol>';
+
+ wp_import_cleanup($this->id);
+
+ echo '<h3>'.sprintf(__('All done. <a href="%s">Have fun!</a>'), get_option('home')).'</h3>';
+ }
+
+ function import() {
+ $this->id = (int) $_GET['id'];
+
+ $this->file = get_attached_file($this->id);
+ $this->get_authors_from_post();
+ $this->get_entries();
+ $this->process_posts();
+ }
+
+ function dispatch() {
+ if (empty ($_GET['step']))
+ $step = 0;
+ else
+ $step = (int) $_GET['step'];
+
+ $this->header();
+ switch ($step) {
+ case 0 :
+ $this->greet();
+ break;
+ case 1 :
+ $this->select_authors();
+ break;
+ case 2:
+ $this->import();
+ break;
+ }
+ $this->footer();
+ }
+
+ function WP_Import() {
+ // Nothing.
+ }
+}
+
+$wp_import = new WP_Import();
+
+register_importer('wordpress', 'WordPress', __('Import posts from a WordPress export file'), array ($wp_import, 'dispatch'));
+
+?>
diff --git a/wp-admin/index.php b/wp-admin/index.php
new file mode 100644
index 0000000..306e0b3
--- /dev/null
+++ b/wp-admin/index.php
@@ -0,0 +1,181 @@
+<?php
+require_once('admin.php');
+$title = __('Dashboard');
+require_once('admin-header.php');
+require_once (ABSPATH . WPINC . '/rss.php');
+
+$today = current_time('mysql', 1);
+?>
+
+<div class="wrap">
+
+<h2><?php _e('Dashboard'); ?></h2>
+
+<div id="zeitgeist">
+<h2><?php _e('Latest Activity'); ?></h2>
+
+<?php
+$rss = @fetch_rss('http://feeds.technorati.com/cosmos/rss/?url='. trailingslashit(get_option('siteurl')) .'&partner=wordpress');
+if ( isset($rss->items) && 0 != count($rss->items) ) {
+?>
+<div id="incominglinks">
+<h3><?php _e('Incoming Links'); ?> <cite><a href="http://www.technorati.com/search/<?php echo trailingslashit(get_option('siteurl')); ?>?partner=wordpress"><?php _e('More'); ?> &raquo;</a></cite></h3>
+<ul>
+<?php
+$rss->items = array_slice($rss->items, 0, 10);
+foreach ($rss->items as $item ) {
+?>
+ <li><a href="<?php echo wp_filter_kses($item['link']); ?>"><?php echo wp_specialchars($item['title']); ?></a></li>
+<?php } ?>
+</ul>
+</div>
+<?php } ?>
+
+<?php
+$comments = $wpdb->get_results("SELECT comment_author, comment_author_url, comment_ID, comment_post_ID FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 5");
+$numcomments = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");
+
+if ( $comments || $numcomments ) :
+?>
+<div>
+<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>
+<?php endif; ?>
+</div>
+
+<ul>
+<?php
+if ( $comments ) {
+foreach ($comments as $comment) {
+ echo '<li>' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . get_the_title($comment->comment_post_ID) . '</a>');
+ edit_comment_link(__("Edit"), ' <small>(', ')</small>');
+ echo '</li>';
+}
+}
+?>
+</ul>
+
+<?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") ) :
+?>
+<div>
+<h3><?php _e('Posts'); ?> <a href="edit.php" title="<?php _e('More posts...'); ?>">&raquo;</a></h3>
+<ul>
+<?php
+foreach ($recentposts as $post) {
+ if ($post->post_title == '')
+ $post->post_title = sprintf(__('Post #%s'), $post->ID);
+ echo "<li><a href='post.php?action=edit&amp;post=$post->ID'>";
+ the_title();
+ echo '</a></li>';
+}
+?>
+</ul>
+</div>
+<?php endif; ?>
+
+<?php
+if ( $scheduled = $wpdb->get_results("SELECT ID, post_title, post_date_gmt FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' AND post_date_gmt > '$today' ORDER BY post_date ASC") ) :
+?>
+<div>
+<h3><?php _e('Scheduled Entries:') ?></h3>
+<ul>
+<?php
+foreach ($scheduled as $post) {
+ if ($post->post_title == '')
+ $post->post_title = sprintf(__('Post #%s'), $post->ID);
+ echo "<li>" . sprintf(__('%1$s in %2$s'), "<a href='post.php?action=edit&amp;post=$post->ID' title='" . __('Edit this post') . "'>$post->post_title</a>", human_time_diff( current_time('timestamp', 1), strtotime($post->post_date_gmt. ' GMT') )) . "</li>";
+}
+?>
+</ul>
+</div>
+<?php endif; ?>
+
+<div>
+<h3><?php _e('Blog Stats'); ?></h3>
+<?php
+$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'");
+if (0 < $numposts) $numposts = number_format($numposts);
+
+$numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
+if (0 < $numcomms) $numcomms = number_format($numcomms);
+
+$numcats = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->categories");
+if (0 < $numcats) $numcats = number_format($numcats);
+?>
+<p><?php printf(__('There are currently %1$s <a href="%2$s" title="Posts">posts</a> and %3$s <a href="%4$s" title="Comments">comments</a>, contained within %5$s <a href="%6$s" title="categories">categories</a>.'), $numposts, 'edit.php', $numcomms, 'edit-comments.php', $numcats, 'categories.php'); ?></p>
+</div>
+
+<?php do_action('activity_box_end'); ?>
+</div>
+<?php
+$rss = @fetch_rss(get_site_option( 'dashboardfeed1' ));
+$title = get_site_option( 'dashboardfeed1name' );
+if( get_site_option( 'customizefeed1' ) == 1 ) {
+ if( get_option( 'dashboardfeed1' ) == 0 ) {
+ $rss = @fetch_rss(get_option( 'dashboardfeed1' ));
+ $title = get_option( 'dashboardfeed1name' );
+ }
+}
+
+if( $rss == false ) {
+ $rss = @fetch_rss('http://wordpress.org/development/feed/');
+ $title = "WordPress Development Blog";
+}
+
+if ( isset($rss->items) && 0 != count($rss->items) ) {
+ print "<h3>$title</h3>";
+ $rss->items = array_slice($rss->items, 0, 3);
+ foreach ($rss->items as $item ) {
+?>
+<h4><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a> &#8212; <?php printf(__('%s ago'), human_time_diff(strtotime($item['pubdate'], time() ) ) ); ?></h4>
+<p><?php echo $item['description']; ?></p>
+<?php
+ }
+}
+?>
+
+
+<?php
+$rss = @fetch_rss(get_site_option( 'dashboardfeed2' ));
+$title = get_site_option( 'dashboardfeed2name' );
+if( get_site_option( 'customizefeed2' ) == 1 ) {
+ if( get_option( 'dashboardfeed2' ) == 0 ) {
+ $rss = @fetch_rss(get_option( 'dashboardfeed2' ));
+ $title = get_option( 'dashboardfeed2name' );
+ }
+}
+if( $rss == false ) {
+ $rss = @fetch_rss('http://wordpress.org/development/feed/');
+}
+
+if ( isset($rss->items) && 0 != count($rss->items) ) {
+?>
+<div id="planetnews">
+<h3><?php _e( $title ); ?> &raquo;</a></h3>
+<ul>
+<?php
+$rss->items = array_slice($rss->items, 0, 20);
+foreach ($rss->items as $item ) {
+?>
+<li><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a></li>
+<?php
+ }
+?>
+</ul>
+</div>
+<?php
+}
+?>
+<div style="clear: both">&nbsp;
+<br clear="all" />
+</div>
+</div>
+
+<?php
+require('./admin-footer.php');
+?>
diff --git a/wp-admin/inline-uploading.php b/wp-admin/inline-uploading.php
new file mode 100644
index 0000000..601f530
--- /dev/null
+++ b/wp-admin/inline-uploading.php
@@ -0,0 +1,728 @@
+<?php
+
+require_once('admin.php');
+
+header('Content-Type: text/html; charset=' . get_option('blog_charset'));
+
+if (!current_user_can('upload_files'))
+ die(__('You do not have permission to upload files.'));
+
+$wpvarstoreset = array('action', 'post', 'all', 'last', 'link', 'sort', 'start', 'imgtitle', 'descr', 'attachment');
+
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+$post = (int) $post;
+$images_width = 1;
+
+switch($action) {
+case 'links':
+// Do not pass GO.
+break;
+
+case 'delete':
+
+check_admin_referer('inlineuploading');
+
+if ( !current_user_can('edit_post', (int) $attachment) )
+ die(__('You are not allowed to delete this attachment.').' <a href="'.basename(__FILE__)."?post=$post&amp;all=$all&amp;action=upload\">".__('Go back').'</a>');
+
+wp_delete_attachment($attachment);
+
+header("Location: " . basename(__FILE__) ."?post=$post&all=$all&action=view&start=$start");
+die;
+
+case 'save':
+
+check_admin_referer('inlineuploading');
+
+$overrides = array('action'=>'save');
+
+$file = wp_handle_upload($_FILES['image'], $overrides);
+
+if( isset( $file[ 'error' ] ) == false )
+ $file[ 'error' ] = apply_filters( "check_uploaded_file", $file[ 'error' ] );
+
+if ( isset($file['error']) )
+ die($file['error'] . '<br /><a href="' . basename(__FILE__) . '?action=upload&post=' . $post . '">'.__('Back to Image Uploading').'</a>');
+
+$url = $file['url'];
+$type = $file['type'];
+$file = $file['file'];
+$filename = basename($file);
+
+// Construct the attachment array
+$attachment = array(
+ 'post_title' => $imgtitle ? $imgtitle : $filename,
+ 'post_content' => $descr,
+ 'post_type' => 'attachment',
+ 'post_parent' => $post,
+ 'post_mime_type' => $type,
+ 'guid' => $url
+ );
+
+// Save the data
+$id = wp_insert_attachment($attachment, $file, $post);
+
+if ( preg_match('!^image/!', $attachment['post_mime_type']) ) {
+ // Generate the attachment's postmeta.
+ $imagesize = getimagesize($file);
+ $imagedata['width'] = $imagesize['0'];
+ $imagedata['height'] = $imagesize['1'];
+ list($uwidth, $uheight) = get_udims($imagedata['width'], $imagedata['height']);
+ $imagedata['hwstring_small'] = "height='$uheight' width='$uwidth'";
+ $imagedata['file'] = $file;
+
+ add_post_meta($id, '_wp_attachment_metadata', $imagedata);
+
+ if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) {
+ if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 )
+ $thumb = wp_create_thumbnail($file, 128);
+ elseif ( $imagedata['height'] > 96 )
+ $thumb = wp_create_thumbnail($file, 96);
+
+ if ( @file_exists($thumb) ) {
+ $newdata = $imagedata;
+ $newdata['thumb'] = basename($thumb);
+ update_post_meta($id, '_wp_attachment_metadata', $newdata, $imagedata);
+ } else {
+ $error = $thumb;
+ }
+ }
+} else {
+ add_post_meta($id, '_wp_attachment_metadata', array());
+}
+
+header("Location: " . basename(__FILE__) . "?post=$post&all=$all&action=view&start=0");
+die();
+
+case 'upload':
+
+$current_1 = ' class="current"';
+$back = $next = false;
+break;
+
+case 'view':
+
+// How many images do we show? How many do we query?
+$num = 5;
+$double = $num * 2;
+
+if ( $post && (empty($all) || $all == 'false') ) {
+ $and_post = "AND post_parent = '$post'";
+ $current_2 = ' class="current"';
+} else {
+ $current_3 = ' class="current"';
+}
+
+if (! current_user_can('edit_others_posts') )
+ $and_user = "AND post_author = " . $user_ID;
+
+if ( $last )
+ $start = $wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_type = 'attachment' $and_user $and_post") - $num;
+else
+ $start = (int) $start;
+
+if ( $start < 0 )
+ $start = 0;
+
+if ( '' == $sort )
+ $sort = "post_date_gmt DESC";
+
+$attachments = $wpdb->get_results("SELECT ID, post_date, post_title, post_mime_type, guid FROM $wpdb->posts WHERE post_type = 'attachment' $and_type $and_post $and_user ORDER BY $sort LIMIT $start, $double", ARRAY_A);
+
+if ( count($attachments) == 0 ) {
+ header("Location: " . basename(__FILE__) ."?post=$post&action=upload" );
+ die;
+} elseif ( count($attachments) > $num ) {
+ $next = $start + count($attachments) - $num;
+} else {
+ $next = false;
+}
+
+if ( $start > 0 ) {
+ $back = $start - $num;
+ if ( $back < 1 )
+ $back = '0';
+} else {
+ $back = false;
+}
+
+$uwidth_sum = 0;
+$html = '';
+$popups = '';
+$style = '';
+$script = '';
+if ( count($attachments) > 0 ) {
+ $attachments = array_slice( $attachments, 0, $num );
+ $__delete = __('Delete');
+ $__not_linked = __('Not Linked');
+ $__linked_to_page = __('Linked to Page');
+ $__linked_to_image = __('Linked to Image');
+ $__linked_to_file = __('Linked to File');
+ $__using_thumbnail = __('Using Thumbnail');
+ $__using_original = __('Using Original');
+ $__using_title = __('Using Title');
+ $__using_filename = __('Using Filename');
+ $__using_icon = __('Using Icon');
+ $__no_thumbnail = '<del>'.__('No Thumbnail').'</del>';
+ $__send_to_editor = __('Send to editor');
+ $__close = __('Close Options');
+ $__confirmdelete = __('Delete this file from the server?');
+ $__nothumb = __('There is no thumbnail associated with this photo.');
+ $script .= "notlinked = '$__not_linked';
+linkedtoimage = '$__linked_to_image';
+linkedtopage = '$__linked_to_page';
+linkedtofile = '$__linked_to_file';
+usingthumbnail = '$__using_thumbnail';
+usingoriginal = '$__using_original';
+usingtitle = '$__using_title';
+usingfilename = '$__using_filename';
+usingicon = '$__using_icon';
+var aa = new Array();
+var ab = new Array();
+var imga = new Array();
+var imgb = new Array();
+var srca = new Array();
+var srcb = new Array();
+var title = new Array();
+var filename = new Array();
+var icon = new Array();
+";
+ foreach ( $attachments as $key => $attachment ) {
+ $ID = $attachment['ID'];
+ $href = get_attachment_link($ID);
+ $meta = get_post_meta($ID, '_wp_attachment_metadata', true);
+ if (!is_array($meta)) {
+ $meta = get_post_meta($ID, 'imagedata', true); // Try 1.6 Alpha meta key
+ if (!is_array($meta)) {
+ $meta = array();
+ }
+ add_post_meta($ID, '_wp_attachment_metadata', $meta);
+ }
+ $attachment = array_merge($attachment, $meta);
+ $noscript = "<noscript>
+ <div class='caption'><a href=\"".basename(__FILE__)."?action=links&amp;attachment={$ID}&amp;post={$post}&amp;all={$all}&amp;start={$start}\">Choose Links</a></div>
+ </noscript>
+";
+ $send_delete_cancel = "<a onclick=\"sendToEditor({$ID});return false;\" href=\"javascript:void()\">$__send_to_editor</a>
+<a onclick=\"return confirm('$__confirmdelete')\" href=\"" . wp_nonce_url( basename(__FILE__) . "?action=delete&amp;attachment={$ID}&amp;all=$all&amp;start=$start&amp;post=$post", inlineuploading) . "\">$__delete</a>
+ <a onclick=\"popup.style.display='none';return false;\" href=\"javascript:void()\">$__close</a>
+";
+ $uwidth_sum += 128;
+ if ( preg_match('!^image/!', $attachment['post_mime_type'] ) ) {
+ $image = & $attachment;
+ if ( ($image['width'] > 128 || $image['height'] > 96) && !empty($image['thumb']) && file_exists(dirname($image['file']).'/'.$image['thumb']) ) {
+ $src = str_replace(basename($image['guid']), $image['thumb'], $image['guid']);
+ $script .= "srca[{$ID}] = '$src';
+srcb[{$ID}] = '{$image['guid']}';
+";
+ $thumb = 'true';
+ $thumbtext = $__using_thumbnail;
+ } else {
+ $src = $image['guid'];
+ $thumb = 'false';
+ $thumbtext = $__no_thumbnail;
+ }
+ list($image['uwidth'], $image['uheight']) = get_udims($image['width'], $image['height']);
+ $height_width = 'height="'.$image['uheight'].'" width="'.$image['uwidth'].'"';
+ $xpadding = (128 - $image['uwidth']) / 2;
+ $ypadding = (96 - $image['uheight']) / 2;
+ $style .= "#target{$ID} img { padding: {$ypadding}px {$xpadding}px; }\n";
+ $title = wp_specialchars($image['post_title'], ENT_QUOTES);
+ $script .= "aa[{$ID}] = '<a id=\"p{$ID}\" rel=\"attachment\" class=\"imagelink\" href=\"$href\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
+ab[{$ID}] = '<a class=\"imagelink\" href=\"{$image['guid']}\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
+imga[{$ID}] = '<img id=\"image{$ID}\" src=\"$src\" alt=\"{$title}\" $height_width />';
+imgb[{$ID}] = '<img id=\"image{$ID}\" src=\"{$image['guid']}\" alt=\"{$title}\" $height_width />';
+";
+ $html .= "<div id='target{$ID}' class='attwrap left'>
+ <div id='div{$ID}' class='imagewrap' onclick=\"doPopup({$ID});\">
+ <img id=\"image{$ID}\" src=\"$src\" alt=\"{$title}\" $height_width />
+ </div>
+ {$noscript}
+</div>
+";
+ $popups .= "<div id='popup{$ID}' class='popup'>
+ <a id=\"I{$ID}\" onclick=\"if($thumb)toggleImage({$ID});else alert('$__nothumb');return false;\" href=\"javascript:void()\">$thumbtext</a>
+ <a id=\"L{$ID}\" onclick=\"toggleLink({$ID});return false;\" href=\"javascript:void()\">$__not_linked</a>
+ {$send_delete_cancel}
+</div>
+";
+ } else {
+ $title = wp_specialchars($attachment['post_title'], ENT_QUOTES);
+ $filename = basename($attachment['guid']);
+ $icon = get_attachment_icon($ID);
+ $toggle_icon = "<a id=\"I{$ID}\" onclick=\"toggleOtherIcon({$ID});return false;\" href=\"javascript:void()\">$__using_title</a>";
+ $script .= "aa[{$ID}] = '<a id=\"p{$ID}\" rel=\"attachment\" href=\"$href\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
+ab[{$ID}] = '<a id=\"p{$ID}\" href=\"{$filename}\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
+title[{$ID}] = '{$title}';
+filename[{$ID}] = '{$filename}';
+icon[{$ID}] = '{$icon}';
+";
+ $html .= "<div id='target{$ID}' class='attwrap left'>
+ <div id='div{$ID}' class='otherwrap usingtext' onmousedown=\"selectLink({$ID})\" onclick=\"doPopup({$ID});return false;\">
+ <a id=\"p{$ID}\" href=\"{$attachment['guid']}\" onmousedown=\"selectLink({$ID});\" onclick=\"return false;\">{$title}</a>
+ </div>
+ {$noscript}
+</div>
+";
+ $popups .= "<div id='popup{$ID}' class='popup'>
+ <div class='filetype'>".__('File Type:').' '.str_replace('/',"/\n",$attachment['post_mime_type'])."</div>
+ <a id=\"L{$ID}\" onclick=\"toggleOtherLink({$ID});return false;\" href=\"javascript:void()\">$__linked_to_file</a>
+ {$toggle_icon}
+ {$send_delete_cancel}
+</div>
+";
+ }
+ }
+}
+
+$images_width = $uwidth_sum + ( count($images) * 6 ) + 35;
+
+break;
+
+default:
+die(__('This script was not meant to be called directly.'));
+}
+
+?>
+<!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">
+<head>
+<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
+<meta http-equiv="imagetoolbar" content="no" />
+<script type="text/javascript">
+/* Define any variables we'll need, such as alternate URLs. */
+<?php echo $script; ?>
+function htmldecode(st) {
+ o = document.getElementById('htmldecode');
+ if (! o) {
+ o = document.createElement("A");
+ o.id = "htmldecode"
+ }
+ o.innerHTML = st;
+ r = o.innerHTML;
+ return r;
+}
+function cancelUpload() {
+ o = document.getElementById('uploadForm');
+ o.method = 'GET';
+ o.action.value = 'view';
+ o.submit();
+}
+function doPopup(i) {
+ if ( popup )
+ popup.style.display = 'none';
+ target = document.getElementById('target'+i);
+ popup = document.getElementById('popup'+i);
+ popup.style.left = (target.offsetLeft) + 'px';
+ popup.style.top = (target.offsetTop) + 'px';
+ popup.style.display = 'block';
+}
+popup = false;
+function selectLink(n) {
+ o=document.getElementById('div'+n);
+ if ( typeof document.body.createTextRange == 'undefined' || typeof win.tinyMCE == 'undefined' || win.tinyMCE.configs.length < 1 )
+ return;
+ r = document.body.createTextRange();
+ if ( typeof r != 'undefined' ) {
+ r.moveToElementText(o);
+ r.select();
+ }
+}
+function toggleLink(n) {
+ ol=document.getElementById('L'+n);
+ if ( ol.innerHTML == htmldecode(notlinked) ) {
+ ol.innerHTML = linkedtoimage;
+ } else if ( ol.innerHTML == htmldecode(linkedtoimage) ) {
+ ol.innerHTML = linkedtopage;
+ } else {
+ ol.innerHTML = notlinked;
+ }
+ updateImage(n);
+}
+function toggleOtherLink(n) {
+ ol=document.getElementById('L'+n);
+ if ( ol.innerHTML == htmldecode(linkedtofile) ) {
+ ol.innerHTML = linkedtopage;
+ } else {
+ ol.innerHTML = linkedtofile;
+ }
+ updateOtherIcon(n);
+}
+function toggleImage(n) {
+ oi = document.getElementById('I'+n);
+ if ( oi.innerHTML == htmldecode(usingthumbnail) ) {
+ oi.innerHTML = usingoriginal;
+ } else {
+ oi.innerHTML = usingthumbnail;
+ }
+ updateImage(n);
+}
+function toggleOtherIcon(n) {
+ od = document.getElementById('div'+n);
+ oi = document.getElementById('I'+n);
+ if ( oi.innerHTML == htmldecode(usingtitle) ) {
+ oi.innerHTML = usingfilename;
+ od.className = 'otherwrap usingtext';
+ } else if ( oi.innerHTML == htmldecode(usingfilename) && icon[n] != '' ) {
+ oi.innerHTML = usingicon;
+ od.className = 'otherwrap usingicon';
+ } else {
+ oi.innerHTML = usingtitle;
+ od.className = 'otherwrap usingtext';
+ }
+ updateOtherIcon(n);
+}
+function updateImage(n) {
+ od=document.getElementById('div'+n);
+ ol=document.getElementById('L'+n);
+ oi=document.getElementById('I'+n);
+ if ( oi.innerHTML == htmldecode(usingthumbnail) ) {
+ img = imga[n];
+ } else {
+ img = imgb[n];
+ }
+ if ( ol.innerHTML == htmldecode(linkedtoimage) ) {
+ od.innerHTML = ab[n]+img+'</a>';
+ } else if ( ol.innerHTML == htmldecode(linkedtopage) ) {
+ od.innerHTML = aa[n]+img+'</a>';
+ } else {
+ od.innerHTML = img;
+ }
+}
+function updateOtherIcon(n) {
+ od=document.getElementById('div'+n);
+ ol=document.getElementById('L'+n);
+ oi=document.getElementById('I'+n);
+ if ( oi.innerHTML == htmldecode(usingfilename) ) {
+ txt = filename[n];
+ } else if ( oi.innerHTML == htmldecode(usingicon) ) {
+ txt = icon[n];
+ } else {
+ txt = title[n];
+ }
+ if ( ol.innerHTML == htmldecode(linkedtofile) ) {
+ od.innerHTML = ab[n]+txt+'</a>';
+ } else if ( ol.innerHTML == htmldecode(linkedtopage) ) {
+ od.innerHTML = aa[n]+txt+'</a>';
+ } else {
+ od.innerHTML = txt;
+ }
+}
+
+var win = window.opener ? window.opener : window.dialogArguments;
+if (!win) win = top;
+tinyMCE = win.tinyMCE;
+richedit = ( typeof tinyMCE == 'object' && tinyMCE.configs.length > 0 );
+function sendToEditor(n) {
+ o = document.getElementById('div'+n);
+ h = o.innerHTML.replace(new RegExp('^\\s*(.*?)\\s*$', ''), '$1'); // Trim
+ h = h.replace(new RegExp(' (class|title|width|height|id|onclick|onmousedown)=([^\'"][^ ]*)( |/|>)', 'g'), ' $1="$2"$3'); // Enclose attribs in quotes
+ h = h.replace(new RegExp(' (width|height)=".*?"', 'g'), ''); // Drop size constraints
+ h = h.replace(new RegExp(' on(click|mousedown)="[^"]*"', 'g'), ''); // Drop menu events
+ h = h.replace(new RegExp('<(/?)A', 'g'), '<$1a'); // Lowercase tagnames
+ h = h.replace(new RegExp('<IMG', 'g'), '<img'); // Lowercase again
+ h = h.replace(new RegExp('(<img .+?")>', 'g'), '$1 />'); // XHTML
+ if ( richedit )
+ win.tinyMCE.execCommand('mceInsertContent', false, h);
+ else
+ win.edInsertContent(win.edCanvas, h);
+}
+</script>
+<style type="text/css">
+<?php if ( $action == 'links' ) : ?>
+* html { overflow-x: hidden; }
+<?php else : ?>
+* html { overflow-y: hidden; }
+<?php endif; ?>
+body {
+ font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana;
+ border: none;
+ margin: 0px;
+ height: 150px;
+ background: #dfe8f1;
+}
+form {
+ margin: 3px 2px 0px 6px;
+}
+#wrap {
+ clear: both;
+ padding: 0px;
+ width: 100%;
+}
+#images {
+ position: absolute;
+ clear: both;
+ margin: 0px;
+ padding: 15px 15px;
+ width: <?php echo $images_width; ?>px;
+}
+#images img {
+ background-color: rgb(209, 226, 239);
+}
+<?php echo $style; ?>
+.attwrap, .attwrap * {
+ margin: 0px;
+ padding: 0px;
+ border: 0px;
+}
+.imagewrap {
+ margin-right: 5px;
+ overflow: hidden;
+ width: 128px;
+}
+.otherwrap {
+ margin-right: 5px;
+ overflow: hidden;
+ background-color: #f9fcfe;
+}
+.otherwrap a {
+ display: block;
+}
+.otherwrap a, .otherwrap a:hover, .otherwrap a:active, .otherwrap a:visited {
+ color: blue;
+}
+.usingicon {
+ padding: 0px;
+ height: 96px;
+ text-align: center;
+ width: 128px;
+}
+.usingtext {
+ padding: 3px;
+ height: 90px;
+ text-align: left;
+ width: 122px;
+}
+.filetype {
+ font-size: 80%;
+ border-bottom: 3px double #89a
+}
+.imagewrap, .imagewrap img, .imagewrap a, .imagewrap a img, .imagewrap a:hover img, .imagewrap a:visited img, .imagewrap a:active img {
+ text-decoration: none;
+}
+#upload-menu {
+ background: #fff;
+ margin: 0px;
+ padding: 0;
+ list-style: none;
+ height: 2em;
+ border-bottom: 1px solid #448abd;
+ width: 100%;
+}
+#upload-menu li {
+ float: left;
+ margin: 0 0 0 .75em;
+}
+#upload-menu a {
+ display: block;
+ padding: 5px;
+ text-decoration: none;
+ color: #000;
+ border-top: 3px solid #fff;
+}
+#upload-menu .current a {
+ background: #dfe8f1;
+ border-right: 2px solid #448abd;
+}
+#upload-menu a:hover {
+ background: #dfe8f1;
+ color: #000;
+}
+.tip {
+ color: rgb(68, 138, 189);
+ padding: 2px 1em;
+}
+.inactive {
+ color: #fff;
+ padding: 1px 3px;
+}
+.left {
+ float: left;
+}
+.right {
+ float: right;
+}
+.center {
+ text-align: center;
+}
+#upload-menu li.spacer {
+ margin-left: 40px;
+}
+#title, #descr {
+ width: 99%;
+ margin-top: 1px;
+}
+th {
+ width: 4.5em;
+}
+#descr {
+ height: 36px;
+}
+#buttons {
+ margin-top: 2px;
+ text-align: right;
+}
+.popup {
+ margin: 4px 4px;
+ padding: 1px;
+ position: absolute;
+ width: 114px;
+ display: none;
+ background-color: rgb(240, 240, 238);
+ border-top: 2px solid #fff;
+ border-right: 2px solid #ddd;
+ border-bottom: 2px solid #ddd;
+ border-left: 2px solid #fff;
+ text-align: center;
+}
+.imagewrap .popup {
+ opacity: .90;
+ filter:alpha(opacity=90);
+}
+.otherwrap .popup {
+ padding-top: 20px;
+}
+.popup a, .popup a:visited, .popup a:active {
+ background-color: transparent;
+ display: block;
+ width: 100%;
+ text-decoration: none;
+ color: #246;
+}
+.popup a:hover {
+ background-color: #fff;
+ color: #000;
+}
+.caption {
+ text-align: center;
+}
+#submit {
+ margin: 1px;
+ width: 99%;
+}
+#submit input, #submit input:focus {
+ background: url( images/fade-butt.png );
+ border: 3px double #999;
+ border-left-color: #ccc;
+ border-top-color: #ccc;
+ color: #333;
+ padding: 0.25em;
+}
+#submit input:active {
+ background: #f4f4f4;
+ border: 3px double #ccc;
+ border-left-color: #999;
+ border-top-color: #999;
+}
+.zerosize {
+ width: 0px;
+ height: 0px;
+ overflow: hidden;
+ position: absolute;
+}
+#links {
+ margin: 3px 8px;
+ line-height: 2em;
+}
+#links textarea {
+ width: 95%;
+ height: 4.5em;
+}
+</style>
+</head>
+<body>
+<ul id="upload-menu">
+<li<?php echo $current_1; ?>><a href="<?php echo basename(__FILE__) . "?action=upload&amp;post=$post&amp;all=$all&amp;start=$start"; ?>"><?php _e('Upload'); ?></a></li>
+<?php if ( $attachments = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post'") ) { ?>
+<li<?php echo $current_2; ?>><a href="<?php echo basename(__FILE__) . "?action=view&amp;post=$post&amp;all=false"; ?>"><?php _e('Browse'); ?></a></li>
+<?php } ?>
+<?php if ($wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_type = 'attachment'")) { ?>
+<li<?php echo $current_3; ?>><a href="<?php echo basename(__FILE__) . "?action=view&amp;post=$post&amp;all=true"; ?>"><?php _e('Browse All'); ?></a></li>
+<?php } ?>
+<li> </li>
+<?php if ( $action == 'view' ) { ?>
+<?php if ( false !== $back ) : ?>
+<li class="spacer"><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;start=0"; ?>" title="<?php _e('First'); ?>">|&laquo;</a></li>
+<li><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;start=$back"; ?>">&laquo; <?php _e('Back'); ?></a></li>
+<?php else : ?>
+<li class="inactive spacer">|&laquo;</li>
+<li class="inactive">&laquo; <?php _e('Back'); ?></li>
+<?php endif; ?>
+<?php if ( false !== $next ) : ?>
+<li><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;start=$next"; ?>"><?php _e('Next &raquo;'); ?></a></li>
+<li><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;last=true"; ?>" title="<?php _e('Last'); ?>">&raquo;|</a></li>
+<?php else : ?>
+<li class="inactive"><?php _e('Next &raquo;'); ?></li>
+<li class="inactive">&raquo;|</li>
+<?php endif; ?>
+<?php } // endif not upload?>
+</ul>
+<?php if ( $action == 'view' ) : ?>
+<div id="wrap">
+<!--<div class="tip"><?php _e('You can drag and drop these items into your post. Click on one for more options.'); ?></div>-->
+<div id="images">
+<?php echo $html; ?>
+<?php echo $popups; ?>
+</div>
+</div>
+<?php elseif ( $action == 'upload' ) : ?>
+ <?php $upload_err = apply_filters( "pre_upload_error", false );
+ if( $upload_err != false ) {
+ ?><div class="center tip"><?php echo $upload_err ?></div><?php
+ } else { ?>
+<div class="tip"></div>
+<form enctype="multipart/form-data" id="uploadForm" method="POST" action="<?php echo basename(__FILE__); ?>">
+<table style="width:99%;">
+<tr>
+<th scope="row" align="right"><label for="upload"><?php _e('File:'); ?></label></th>
+<td><input type="file" id="upload" name="image" /></td>
+</tr>
+<tr>
+<th scope="row" align="right"><label for="title"><?php _e('Title:'); ?></label></th>
+<td><input type="text" id="title" name="imgtitle" /></td>
+</tr>
+<tr>
+<th scope="row" align="right"><label for="descr"><?php _e('Description:'); ?></label></th>
+<td><input type="textarea" name="descr" id="descr" value="" /></td>
+</tr>
+<tr id="buttons">
+<th></th>
+<td>
+<input type="hidden" name="action" value="save" />
+<input type="hidden" name="post" value="<?php echo $post; ?>" />
+<input type="hidden" name="all" value="<?php echo $all; ?>" />
+<input type="hidden" name="start" value="<?php echo $start; ?>" />
+<?php wp_nonce_field( 'inlineuploading' ); ?>
+<div id="submit">
+<input type="submit" value="<?php _e('Upload'); ?>" />
+<?php if ( !empty($all) ) : ?>
+<input type="button" value="<?php _e('Cancel'); ?>" onclick="cancelUpload()" />
+<?php endif; ?>
+</div>
+</td>
+</tr>
+</table>
+</div>
+</form>
+<?php } ?>
+<?php elseif ( $action == 'links' ) : ?>
+<div id="links">
+<?php the_attachment_links($attachment); ?>
+</div>
+<?php endif; ?>
+</body>
+</html>
diff --git a/wp-admin/install-helper.php b/wp-admin/install-helper.php
new file mode 100644
index 0000000..86138db
--- /dev/null
+++ b/wp-admin/install-helper.php
@@ -0,0 +1,152 @@
+<?php
+require_once('../wp-config.php');
+$debug = 0;
+
+/**
+ ** maybe_create_table()
+ ** Create db table if it doesn't exist.
+ ** Returns: true if already exists or on successful completion
+ ** false on error
+ */
+function maybe_create_table($table_name, $create_ddl) {
+ global $wpdb;
+ foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
+ if ($table == $table_name) {
+ return true;
+ }
+ }
+ //didn't find it try to create it.
+ $q = $wpdb->query($create_ddl);
+ // we cannot directly tell that whether this succeeded!
+ foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
+ if ($table == $table_name) {
+ return true;
+ }
+ }
+ return false;
+}
+
+/**
+ ** maybe_add_column()
+ ** Add column to db table if it doesn't exist.
+ ** Returns: true if already exists or on successful completion
+ ** false on error
+ */
+function maybe_add_column($table_name, $column_name, $create_ddl) {
+ global $wpdb, $debug;
+ foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
+ if ($debug) echo("checking $column == $column_name<br />");
+ if ($column == $column_name) {
+ return true;
+ }
+ }
+ //didn't find it try to create it.
+ $q = $wpdb->query($create_ddl);
+ // we cannot directly tell that whether this succeeded!
+ foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
+ if ($column == $column_name) {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+/**
+ ** maybe_drop_column()
+ ** Drop column from db table if it exists.
+ ** Returns: true if it doesn't already exist or on successful drop
+ ** false on error
+ */
+function maybe_drop_column($table_name, $column_name, $drop_ddl) {
+ global $wpdb;
+ foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
+ if ($column == $column_name) {
+ //found it try to drop it.
+ $q = $wpdb->query($drop_ddl);
+ // we cannot directly tell that whether this succeeded!
+ foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
+ if ($column == $column_name) {
+ return false;
+ }
+ }
+ }
+ }
+ // else didn't find it
+ return true;
+}
+
+
+/**
+ ** check_column()
+ ** Check column matches passed in criteria.
+ ** Pass in null to skip checking that criteria
+ ** Returns: true if it matches
+ ** false otherwise
+ ** (case sensitive) Column names returned from DESC table are:
+ ** Field
+ ** Type
+ ** Null
+ ** Key
+ ** Default
+ ** Extra
+ */
+function check_column($table_name, $col_name, $col_type, $is_null = null, $key = null, $default = null, $extra = null) {
+ global $wpdb, $debug;
+ $diffs = 0;
+ $results = $wpdb->get_results("DESC $table_name");
+
+ foreach ($results as $row ) {
+ if ($debug > 1) print_r($row);
+ if ($row->Field == $col_name) {
+ // got our column, check the params
+ if ($debug) echo ("checking $row->Type against $col_type\n");
+ if (($col_type != null) && ($row->Type != $col_type)) {
+ ++$diffs;
+ }
+ if (($is_null != null) && ($row->Null != $is_null)) {
+ ++$diffs;
+ }
+ if (($key != null) && ($row->Key != $key)) {
+ ++$diffs;
+ }
+ if (($default != null) && ($row->Default != $default)) {
+ ++$diffs;
+ }
+ if (($extra != null) && ($row->Extra != $extra)) {
+ ++$diffs;
+ }
+ if ($diffs > 0) {
+ if ($debug) echo ("diffs = $diffs returning false\n");
+ return false;
+ }
+ return true;
+ } // end if found our column
+ }
+ return false;
+}
+
+/*
+echo "<p>testing</p>";
+echo "<pre>";
+
+//check_column('wp_links', 'link_description', 'mediumtext');
+//if (check_column($wpdb->comments, 'comment_author', 'tinytext'))
+// echo "ok\n";
+$error_count = 0;
+$tablename = $wpdb->links;
+// check the column
+if (!check_column($wpdb->links, 'link_description', 'varchar(255)'))
+{
+ $ddl = "ALTER TABLE $wpdb->links MODIFY COLUMN link_description varchar(255) NOT NULL DEFAULT '' ";
+ $q = $wpdb->query($ddl);
+}
+if (check_column($wpdb->links, 'link_description', 'varchar(255)')) {
+ $res .= $tablename . ' - ok <br />';
+} else {
+ $res .= 'There was a problem with ' . $tablename . '<br />';
+ ++$error_count;
+}
+echo "</pre>";
+*/
+?> \ No newline at end of file
diff --git a/wp-admin/invites.php b/wp-admin/invites.php
new file mode 100644
index 0000000..d955387
--- /dev/null
+++ b/wp-admin/invites.php
@@ -0,0 +1,196 @@
+<?php
+require_once('admin.php');
+
+$title = __('Invites');
+$parent_file = 'edit.php';
+
+if( $_POST[ 'action' ] == 'send' ) {
+ $invites_left = get_usermeta( $user_ID, 'invites_left' );
+ if( $_POST[ 'email' ] != '' && is_email( $_POST[ 'email' ] ) ) {
+ $email = strtolower( $_POST[ 'email' ] );
+ if( $invites_left != false || is_site_admin() == true ) {
+ $invites_list = get_usermeta( $current_user->data->ID, "invites_list" );
+ $pos = strpos( $invites_list, substr( $email, 1 ) );
+ if( $pos == true ) {
+ header( "Location: ".get_settings( "siteurl" )."/wp-admin/invites.php?result=alreadysent&to=" . urlencode( $email ) );
+ exit;
+ }
+ $invites_list .= strtolower( $email ) . " ";
+ update_usermeta( $current_user->data->ID, "invites_list", $invites_list );
+
+ $msg = get_site_option( "invites_default_message" );
+ $subject = get_site_option( "invites_default_subject" );
+ $from = $cache_userdata[ $user_ID ]->user_email;
+
+ $visitor_pass = md5( $email );
+ $msg = str_replace( "FIRSTNAME", $_POST[ 'fname' ], $msg );
+ $msg = str_replace( "LASTNAME", $_POST[ 'lname' ], $msg );
+ $msg = str_replace( "PERSONALMESSAGE", $_POST[ 'personalmessage' ], $msg );
+ $msg = str_replace( "VISITORPASS", $visitor_pass, $msg );
+ $msg = str_replace( "\\r\\n", "\n", stripslashes( str_replace( "REGURL", "http://" . $current_site->domain . "/invite/" . $visitor_pass, $msg ) ) );
+
+ $subject = str_replace( "FIRSTNAME", $_POST[ 'fname' ], $subject );
+ if( $cache_userdata[ $user_ID ]->display_name != '' ) {
+ $username = $cache_userdata[ $user_ID ]->display_name;
+ } elseif( $cache_userdata[ $user_ID ]->first_name != '' ) {
+ $username = $cache_userdata[ $user_ID ]->first_name;
+ } elseif( $cache_userdata[ $user_ID ]->nickname != '' ) {
+ $username = $cache_userdata[ $user_ID ]->nickname;
+ } else {
+ $username = __( 'Someone' );
+ }
+ $msg = str_replace( "USERNAME", ucfirst( $username ), $msg );
+ $subject = str_replace( "USERNAME", ucfirst( $username ), $subject );
+
+ $wpdb->query( "INSERT INTO ".$wpdb->usermeta." ( `umeta_id` , `user_id` , `meta_key` , `meta_value` ) VALUES ( NULL, '0', 'invite' , '".md5( strtolower( $email ) )."')" );
+ $wpdb->query( "INSERT INTO ".$wpdb->usermeta." ( `umeta_id` , `user_id` , `meta_key` , `meta_value` ) VALUES ( NULL, '0', '".md5( strtolower( $email ) )."_invited_by' , '$user_ID')" );
+ $wpdb->query( "INSERT INTO ".$wpdb->usermeta." ( `umeta_id` , `user_id` , `meta_key` , `meta_value` ) VALUES ( NULL, '0', '".md5( strtolower( $email ) )."_to_email' , '{$_POST[ 'email' ]}')" );
+ $wpdb->query( "INSERT INTO ".$wpdb->usermeta." ( `umeta_id` , `user_id` , `meta_key` , `meta_value` ) VALUES ( NULL, '0', '".md5( strtolower( $email ) )."_to_name' , '{$_POST[ 'fname' ]}')" );
+ $wpdb->query( "INSERT INTO ".$wpdb->usermeta." ( `umeta_id` , `user_id` , `meta_key` , `meta_value` ) VALUES ( NULL, '0', '".md5( strtolower( $email ) )."_invite_timestamp' , UNIX_TIMESTAMP())" );
+ if( $_POST[ 'add_blog_to_blogroll' ] == '1' ) {
+ $t = array( "blogid" => $wpdb->blogid, "userid" => get_current_user_id() );
+ $wpdb->query( "INSERT INTO ".$wpdb->usermeta." ( `umeta_id` , `user_id` , `meta_key` , `meta_value` ) VALUES ( NULL, '0', '".md5( strtolower( $email ) )."_add_to_blogroll' , '" . serialize( $t ) . "')" );
+ }
+
+ mail( $_POST[ 'email' ], $subject, $msg, "From: $from" );
+ if( is_site_admin() == false ) {
+ $invites_left = $invites_left - 1;
+ update_usermeta( $user_ID, "invites_left", $invites_left );
+ }
+ header( "Location: ".get_settings( "siteurl" )."/wp-admin/invites.php?result=sent&to=" . urlencode( $email ) );
+ exit;
+ } else {
+ header( "Location: ".get_settings( "siteurl" )."/wp-admin/invites.php?result=notsent&to=" . urlencode( $email ) );
+ exit;
+ }
+ } else {
+ header( "Location: ".get_settings( "siteurl" )."/wp-admin/invites.php?result=completeform" );
+ exit;
+ }
+} elseif( $_GET[ 'action' ] == 'deleteinvite' ) {
+ delete_invite( md5( $_GET[ 'inviteemail' ] ) );
+ header( "Location: ".get_settings( "siteurl" )."/wp-admin/invites.php?result=deletedinvite" );
+ exit;
+}
+
+if( $_POST[ 'personalmessage' ] == '' ) {
+ if( $current_site->site_name != '' ) {
+ $site_name = $current_site->site_name;
+ } else {
+ $site_name = get_settings( 'blogname' );
+ }
+ $_POST[ 'personalmessage' ] = sprintf( __( "I've been using %s and thought you might
+like to try it out. Here's an invitation to
+create an account." ), $site_name ) ;
+}
+
+include('admin-header.php');
+if (isset($_GET['result'] ) && $_GET['result'] == 'sent' ) {
+ ?><div id="sent" class="updated fade"><p><strong><?php echo sprintf( __("Invite Sent to %s."),
+$wpdb->escape( $_GET[ 'to' ] ) ) ?></strong></p></div><?php
+} elseif (isset($_GET['result'] ) && $_GET['result'] == 'notsent' ) {
+ ?><div id="sent" class="updated fade"><p><strong><?php echo sprintf( __("Invite Not Sent to %s."),
+$wpdb->escape( $_GET[ 'to' ] ) ) ?></strong></p></div><?php
+} elseif (isset($_GET['result'] ) && $_GET['result'] == 'alreadysent' ) {
+ ?><div id="sent" class="updated fade"><p><strong><?php echo sprintf( __("Invite Already Sent to
+%s."),
+$wpdb->escape( $_GET[ 'to' ] ) ) ?></strong></p></div><?php
+} elseif (isset($_GET['result'] ) && $_GET['result'] == 'completeform' ) {
+ ?><div id="sent" class="updated fade"><p><strong><?php _e("Please complete the form.") ?></strong></p></div><?php
+} elseif (isset($_GET['result'] ) && $_GET['result'] == 'deletedinvite' ) {
+ ?><div id="sent" class="updated fade"><p><strong><?php _e("Invite Deleted.") ?></strong></p></div><?php
+}
+if( $invites_left != false || is_site_admin() == true ) {
+?>
+
+<div class="wrap">
+ <h2><?php _e('Invites') ?></h2>
+ <form name="form1" method="post" action="invites.php">
+ <input type="hidden" name="action" value="send" />
+ <fieldset class="options">
+ <legend><?php _e('Send Invite To') ?></legend>
+ <table width="100%" cellspacing="2" cellpadding="5" class="editform">
+ <tr valign="top">
+ <th width="33%" scope="row"><?php _e('First Name:') ?></th>
+ <td><input name="fname" type="text" id="fname" value="<?php echo stripslashes( $_POST[ 'fname' ] ) ?>" size="40" /></td>
+ </tr>
+ <tr valign="top">
+ <th width="33%" scope="row"><?php _e('Last Name:') ?></th>
+ <td><input name="lname" type="text" id="lname" value="<?php echo stripslashes( $_POST[ 'lname' ] ) ?>" size="40" /></td>
+ </tr>
+ <tr valign="top">
+ <th width="33%" scope="row"><?php _e('Email:') ?></th>
+ <td><input name="email" type="text" id="email" value="<?php echo stripslashes( $_POST[ 'email' ] ) ?>" size="40" /></td>
+ </tr>
+ <tr valign="top">
+ <th width="33%" scope="row"><?php _e('Personal Message:') ?></th>
+ <td><textarea rows="5" cols="60" name="personalmessage" tabindex="5" id="defaultmessage"><?php echo stripslashes( $_POST[ 'personalmessage' ] ) ?></textarea></td>
+ </tr>
+ <tr valign="top">
+ <th width="33%" scope="row"></th>
+ <td><label><input type='checkbox' name='add_blog_to_blogroll' value='1' /> <?php _e('Add to my blogroll after signup') ?></label></td>
+ </tr>
+ </table>
+ </fieldset>
+ <p class="submit">
+ <input type="submit" name="Submit" value="<?php _e('Send Invite') ?> &raquo;" />
+ </p>
+ </form>
+</div>
+<?php
+} else { // check for invites/is_site_admin()
+ ?>
+ <div class="wrap">
+ <p>Sorry, you have used all your invites!</p>
+ </div>
+ <?php
+}
+
+$invites_list = get_usermeta( $current_user->data->ID, "invites_list" );
+if( $invites_list != '' )
+{
+ if( strlen( $invites_list ) > 3 ) {
+ ?><div class="wrap">
+ <h3>Already Invited</h3>
+ <table><?php
+ $invites = explode( " ", $invites_list );
+ reset( $invites );
+ while( list( $key, $val ) = each( $invites ) ) {
+ if( $val != "" ) {
+ $id = $wpdb->get_row( "SELECT ID FROM {$wpdb->users} WHERE user_email = '$val'" );
+ if( $id ) {
+ $invited_user_id = $id->ID;
+ } else {
+ $invited_user_id = $wpdb->get_var( "SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = 'invite_hash' AND meta_value = '" . md5( $val ) . "'" );
+ }
+
+ if( $invited_user_id != 0 ) {
+ $invited_user_blog = $wpdb->get_var( "SELECT meta_value FROM $wpdb->usermeta WHERE user_id = '$invited_user_id' AND meta_key='source_domain'" );
+ } else {
+ $invited_user_blog = '';
+ }
+ $invited_user_login = $wpdb->get_var( "SELECT user_login FROM $wpdb->users WHERE ID = '$invited_user_id'" );
+ if( $invited_user_blog != '' ) {
+ print "<tr><td>$val</td><td>$invited_user_login</td><td><a href='http://{$invited_user_blog}'>http://$invited_user_blog</a></td></tr>";
+ } else {
+ $invited_time = $wpdb->get_var( "SELECT meta_value FROM $wpdb->usermeta WHERE meta_key = '" . md5( $val ) . "_invite_timestamp'" );
+ if( $invited_time ) {
+ $days_left = intval( get_site_option( "invite_time_limit" ) ) - intval( ( time() - $invited_time ) / 86400 );
+ print "<tr><td>$val</td><td>$invited_user_login</td><td><em>Invite Not Used Yet</em> ($days_left days left)";
+ if ( function_exists('delete_invite') )
+ print " (<a href='?action=deleteinvite&inviteemail=" . urlencode( $val ) . "'>Delete</a>)";
+ print "</td></tr>";
+ } else {
+ print "<tr><td>$val</td><td>$invited_user_login</td><td><em>Invite Not Used Yet</em>";
+ if ( function_exists('delete_invite') )
+ print " (<a href='?action=deleteinvite&inviteemail=" . urlencode( $val ) . "'>Delete</a>)";
+ print "</td></tr>";
+ }
+ }
+ }
+ }
+ ?></table></div><?php
+ }
+}
+?>
+<?php include("admin-footer.php") ?>
diff --git a/wp-admin/link-add.php b/wp-admin/link-add.php
new file mode 100644
index 0000000..71ce294
--- /dev/null
+++ b/wp-admin/link-add.php
@@ -0,0 +1,49 @@
+<?php
+require_once('admin.php');
+
+$title = __('Add Bookmark');
+$this_file = 'link-manager.php';
+$parent_file = 'link-manager.php';
+
+
+$wpvarstoreset = array('action', 'cat_id', 'linkurl', 'name', 'image',
+ 'description', 'visible', 'target', 'category', 'link_id',
+ 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel',
+ 'notes', 'linkcheck[]');
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+wp_enqueue_script( array('xfn', 'dbx-admin-key?pagenow=link.php') );
+if ( current_user_can( 'manage_categories' ) )
+ wp_enqueue_script( 'ajaxcat' );
+require('admin-header.php');
+?>
+
+<?php if ($_GET['added']) : ?>
+<div id="message" class="updated fade"><p><?php _e('Bookmark added.'); ?></p></div>
+<?php endif; ?>
+
+<?php
+ $link = get_default_link_to_edit();
+ include('edit-link-form.php');
+?>
+
+<div class="wrap">
+<?php printf(__('<p>You can drag <a href="%s" title="Bookmark add bookmarklet">Link This</a> to your toolbar and when you click it a window will pop up that will allow you to add whatever site you&#8217;re on to your bookmarks! Right now this only works on Mozilla or Netscape, but we&#8217;re working on it.</p>'), "javascript:void(linkmanpopup=window.open('" . get_settings('siteurl') . "/wp-admin/link-add.php?action=popup&amp;linkurl='+escape(location.href)+'&amp;name='+escape(document.title),'LinkManager','scrollbars=yes,width=750,height=550,left=15,top=15,status=yes,resizable=yes'));linkmanpopup.focus();window.focus();linkmanpopup.focus();") ?>
+</div>
+
+<?php
+require('admin-footer.php');
+?>
diff --git a/wp-admin/link-import.php b/wp-admin/link-import.php
new file mode 100644
index 0000000..352b6e7
--- /dev/null
+++ b/wp-admin/link-import.php
@@ -0,0 +1,133 @@
+<?php
+// Links
+// Copyright (C) 2002 Mike Little -- mike@zed1.com
+
+require_once('admin.php');
+$parent_file = 'link-manager.php';
+$title = __('Import Blogroll');
+$this_file = 'link-import.php';
+
+$step = $_POST['step'];
+if (!$step) $step = 0;
+?>
+<?php
+switch ($step) {
+ case 0:
+ {
+ include_once('admin-header.php');
+ if ( !current_user_can('manage_links') )
+ die (__("Cheatin&#8217; uh?"));
+
+ $opmltype = 'blogrolling'; // default.
+?>
+
+<div class="wrap">
+<h2><?php _e('Import your blogroll from another system') ?> </h2>
+<form enctype="multipart/form-data" action="link-import.php" method="post" name="blogroll">
+<?php wp_nonce_field('import-bookmarks') ?>
+
+<p><?php _e('If a program or website you use allows you to export your bookmarks or subscriptions as OPML you may import them here.'); ?>
+<div style="width: 70%; margin: auto; height: 8em;">
+<input type="hidden" name="step" value="1" />
+<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
+<div style="width: 48%; float: left;">
+<h3><?php _e('Specify an OPML URL:'); ?></h3>
+<input type="text" name="opml_url" size="50" style="width: 90%;" value="http://" />
+</div>
+
+<div style="width: 48%; float: left;">
+<h3><?php _e('Or choose from your local disk:'); ?></h3>
+<input id="userfile" name="userfile" type="file" size="30" />
+</div>
+
+
+</div>
+
+<p style="clear: both; margin-top: 1em;"><?php _e('Now select a category you want to put these bookmarks in.') ?><br />
+<?php _e('Category:') ?> <select name="cat_id">
+<?php
+$categories = get_categories('hide_empty=0');
+foreach ($categories as $category) {
+?>
+<option value="<?php echo $category->cat_ID; ?>"><?php echo wp_specialchars($category->cat_name); ?></option>
+<?php
+} // end foreach
+?>
+</select></p>
+
+<p class="submit"><input type="submit" name="submit" value="<?php _e('Import OPML File &raquo;') ?>" /></p>
+</form>
+
+</div>
+<?php
+ break;
+ } // end case 0
+
+ case 1: {
+ check_admin_referer('import-bookmarks');
+
+ include_once('admin-header.php');
+ if ( !current_user_can('manage_links') )
+ die (__("Cheatin' uh ?"));
+?>
+<div class="wrap">
+
+ <h2><?php _e('Importing...') ?></h2>
+<?php
+ $cat_id = $_POST['cat_id'];
+ if (($cat_id == '') || ($cat_id == 0)) {
+ $cat_id = 1;
+ }
+
+ $opml_url = $_POST['opml_url'];
+ if (isset($opml_url) && $opml_url != '' && $opml_url != 'http://') {
+ $blogrolling = true;
+ }
+ else // try to get the upload file.
+ {
+ $overrides = array('test_form' => false, 'test_type' => false);
+ $file = wp_handle_upload($_FILES['userfile'], $overrides);
+
+ if ( isset($file['error']) )
+ die($file['error']);
+
+ $url = $file['url'];
+ $opml_url = $file['file'];
+ $blogrolling = false;
+ }
+
+ if (isset($opml_url) && $opml_url != '') {
+ $opml = wp_remote_fopen($opml_url);
+ include_once('link-parse-opml.php');
+
+ $link_count = count($names);
+ for ($i = 0; $i < $link_count; $i++) {
+ if ('Last' == substr($titles[$i], 0, 4))
+ $titles[$i] = '';
+ if ('http' == substr($titles[$i], 0, 4))
+ $titles[$i] = '';
+ $link = array( 'link_url' => $urls[$i], 'link_name' => $wpdb->escape($names[$i]), 'link_category' => array($cat_id), 'link_description' => $wpdb->escape($descriptions[$i]), 'link_owner' => $user_ID, 'link_rss' => $feeds[$i]);
+ wp_insert_link($link);
+ echo sprintf('<p>'.__('Inserted <strong>%s</strong>').'</p>', $names[$i]);
+ }
+?>
+ <p><?php printf(__('Inserted %1$d bookmarks into category %2$s. All done! Go <a href="%3$s">manage those bookmarks</a>.'), $link_count, $cat_id, 'link-manager.php') ?></p>
+<?php
+ } // end if got url
+ else
+ {
+ echo "<p>" . __("You need to supply your OPML url. Press back on your browser and try again") . "</p>\n";
+ } // end else
+
+ if ( ! $blogrolling )
+ @unlink($opml_url);
+?>
+</div>
+<?php
+ break;
+ } // end case 1
+} // end switch
+
+include('admin-footer.php');
+
+?>
diff --git a/wp-admin/link-manager.php b/wp-admin/link-manager.php
new file mode 100644
index 0000000..7638d5f
--- /dev/null
+++ b/wp-admin/link-manager.php
@@ -0,0 +1,209 @@
+<?php
+
+
+// Links
+// Copyright (C) 2002, 2003 Mike Little -- mike@zed1.com
+
+require_once ('admin.php');
+
+$title = __('Manage Bookmarks');
+$this_file = $parent_file = 'link-manager.php';
+wp_enqueue_script( 'listman' );
+
+$wpvarstoreset = array ('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]');
+
+for ($i = 0; $i < count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset ($$wpvar)) {
+ if (empty ($_POST["$wpvar"])) {
+ if (empty ($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+if (empty ($cat_id))
+ $cat_id = 'all';
+
+if (empty ($order_by))
+ $order_by = 'order_name';
+
+$title = __('Manage Bookmarks');
+include_once ("./admin-header.php");
+
+if (!current_user_can('manage_links'))
+ die(__("You do not have sufficient permissions to edit the bookmarks for this blog."));
+
+switch ($order_by) {
+ case 'order_id' :
+ $sqlorderby = 'id';
+ break;
+ case 'order_url' :
+ $sqlorderby = 'url';
+ break;
+ case 'order_desc' :
+ $sqlorderby = 'description';
+ break;
+ case 'order_owner' :
+ $sqlorderby = 'owner';
+ break;
+ case 'order_rating' :
+ $sqlorderby = 'rating';
+ break;
+ case 'order_name' :
+ default :
+ $sqlorderby = 'name';
+ break;
+}
+?>
+<script type="text/javascript">
+<!--
+function checkAll(form)
+{
+ for (i = 0, n = form.elements.length; i < n; i++) {
+ if(form.elements[i].type == "checkbox") {
+ if(form.elements[i].checked == true)
+ form.elements[i].checked = false;
+ else
+ form.elements[i].checked = true;
+ }
+ }
+}
+//-->
+</script>
+
+<?php
+if ( isset($_GET['deleted']) ) {
+ echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>';
+ $deleted = (int) $_GET['deleted'];
+ printf(__('%s bookmarks deleted.'), $deleted);
+ echo '</p></div>';
+}
+?>
+
+<div class="wrap">
+
+<h2><?php _e('Bookmark Management'); ?></h2>
+<p><?php _e('Here you add links to sites that you visit often and share them on your blog. When you have a list of links in your sidebar to other blogs, it&#8217;s called a &#8220;blogroll.&#8221;'); ?></p>
+<form id="cats" method="get" action="">
+<p>Currently showing
+<?php $categories = get_categories("hide_empty=1&type=link"); ?>
+<select name="cat_id">
+<option value="all" <?php echo ($cat_id == 'all') ? " selected='selected'" : ''; ?>><?php _e('All') ?></option>
+<?php foreach ($categories as $cat): ?>
+<option value="<?php echo $cat->cat_ID; ?>"<?php echo ($cat->cat_ID == $cat_id) ? " selected='selected'" : ''; ?>><?php echo wp_specialchars($cat->cat_name); ?>
+</option>
+<?php endforeach; ?>
+</select>
+bookmarks ordered by
+<select name="order_by">
+<option value="order_id" <?php if ($order_by == 'order_id') echo " selected='selected'";?>><?php _e('Bookmark ID') ?></option>
+<option value="order_name" <?php if ($order_by == 'order_name') echo " selected='selected'";?>><?php _e('Name') ?></option>
+<option value="order_url" <?php if ($order_by == 'order_url') echo " selected='selected'";?>><?php _e('URI') ?></option>
+</select>
+<input type="submit" name="action" value="<?php _e('Update &raquo;') ?>" />
+</form>
+
+<form id="links" method="post" action="link.php">
+<?php wp_nonce_field('bulk-bookmarks') ?>
+<input type="hidden" name="link_id" value="" />
+<input type="hidden" name="action" value="" />
+<input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" />
+<input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
+<table class="widefat">
+ <thead>
+ <tr>
+ <th width="15%" style="text-align: left"><?php _e('Name') ?></th>
+ <th style="text-align: left"><?php _e('URI') ?></th>
+ <th style="text-align: left"><?php _e('Categories') ?></th>
+ <th><?php _e('rel') ?></th>
+ <th><?php _e('Visible') ?></th>
+ <th colspan="2"><?php _e('Action') ?></th>
+ <th><input type="checkbox" onclick="checkAll(document.getElementById('links'));" /></th>
+ </tr>
+ </thead>
+ <tbody id="the-list">
+<?php
+if ( 'all' == $cat_id )
+ $cat_id = '';
+$links = get_bookmarks("category=$cat_id&hide_invisible=0&orderby=$sqlorderby&hide_empty=0");
+if ($links)
+ foreach ($links as $link) {
+ $link->link_name = wp_specialchars($link->link_name);
+ $link->link_description = wp_specialchars($link->link_description);
+ $link->link_url = wp_specialchars($link->link_url);
+ $link->link_category = wp_get_link_cats($link->link_id);
+ $short_url = str_replace('http://', '', $link->link_url);
+ $short_url = str_replace('www.', '', $short_url);
+ if ('/' == substr($short_url, -1))
+ $short_url = substr($short_url, 0, -1);
+ if (strlen($short_url) > 35)
+ $short_url = substr($short_url, 0, 32).'...';
+
+ $visible = ($link->link_visible == 'Y') ? __('Yes') : __('No');
+ ++ $i;
+ $style = ($i % 2) ? '' : ' class="alternate"';
+?>
+ <tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>>
+ <td><strong><?php echo $link->link_name; ?></strong><br />
+ <?php
+
+
+ echo $link->link_description . "</td>";
+ echo "<td><a href=\"$link->link_url\" title=\"".sprintf(__('Visit %s'), $link->link_name)."\">$short_url</a></td>";
+ ?>
+ <td>
+ <?php
+
+ $cat_names = array();
+ foreach ($link->link_category as $category) {
+ $cat_name = get_the_category_by_ID($category);
+ $cat_name = wp_specialchars($cat_name);
+ if ( $cat_id != $category )
+ $cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>";
+ $cat_names[] = $cat_name;
+ }
+ echo implode(', ', $cat_names);
+ ?>
+ </td>
+ <td><?php echo $link->link_rel; ?></td>
+ <td align='center'><?php echo $visible; ?></td>
+<?php
+
+ echo '<td><a href="link.php?link_id='.$link->link_id.'&amp;action=edit" class="edit">'.__('Edit').'</a></td>';
+ echo '<td><a href="' . wp_nonce_url('link.php?link_id='.$link->link_id.'&amp;action=delete', 'delete-bookmark_' . $link->link_id ) . '"'." class='delete' onclick=\"return deleteSomething( 'link', $link->link_id , '".sprintf(__("You are about to delete the &quot;%s&quot; bookmark to %s.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), wp_specialchars($link->link_name, 1), wp_specialchars($link->link_url)).'\' );" class="delete">'.__('Delete').'</a></td>';
+ echo '<td align="center"><input type="checkbox" name="linkcheck[]" value="'.$link->link_id.'" /></td>';
+ echo "\n </tr>\n";
+ }
+?>
+ </tbody>
+</table>
+
+<div id="ajax-response"></div>
+
+<p class="submit"><input type="submit" class="button" name="deletebookmarks" id="deletebookmarks" value="<?php _e('Delete Checked Bookmarks') ?> &raquo;" onclick="return confirm('<?php _e("You are about to delete these bookmarks permanently \\n \'Cancel\' to stop, \'OK\' to delete.") ?>')" /></p>
+</div>
+</form>
+
+<?php
+if( wp_cache_get( "checked_bookmarks_table", "options" ) == false ) {
+ $results = $wpdb->get_results( "SELECT link_id, category_id, count( * ) AS c FROM {$wpdb->link2cat} GROUP BY link_id, category_id" );
+ if( $results != null ) {
+ foreach( $results as $link ) {
+ if( $link->c > 1 ) {
+ $wpdb->query( "DELETE FROM {$wpdb->link2cat} WHERE link_id='{$link->link_id}' AND category_id='{$link->category_id}'" );
+ $wpdb->query( "INSERT INTO {$wpdb->link2cat} VALUES ( 0, '{$link->link_id}', '{$link->category_id}' )" );
+ }
+ }
+ }
+ wp_cache_set( "checked_bookmarks_table", "1", "options" );
+}
+
+?>
+
+<?php include('admin-footer.php'); ?>
diff --git a/wp-admin/link-parse-opml.php b/wp-admin/link-parse-opml.php
new file mode 100644
index 0000000..196f3cb
--- /dev/null
+++ b/wp-admin/link-parse-opml.php
@@ -0,0 +1,65 @@
+<?php
+require_once('../wp-config.php');
+
+// columns we wish to find are: link_url, link_name, link_target, link_description
+// we need to map XML attribute names to our columns
+$opml_map = array('URL' => 'link_url',
+ 'HTMLURL' => 'link_url',
+ 'TEXT' => 'link_name',
+ 'TITLE' => 'link_name',
+ 'TARGET' => 'link_target',
+ 'DESCRIPTION' => 'link_description',
+ 'XMLURL' => 'link_rss'
+);
+
+$map = $opml_map;
+
+/**
+ ** startElement()
+ ** Callback function. Called at the start of a new xml tag.
+ **/
+function startElement($parser, $tagName, $attrs) {
+ global $updated_timestamp, $all_links, $map;
+ global $names, $urls, $targets, $descriptions, $feeds;
+
+ if ($tagName == 'OUTLINE') {
+ foreach (array_keys($map) as $key) {
+ if (isset($attrs[$key])) {
+ $$map[$key] = $attrs[$key];
+ }
+ }
+
+ //echo("got data: link_url = [$link_url], link_name = [$link_name], link_target = [$link_target], link_description = [$link_description]<br />\n");
+
+ // save the data away.
+ $names[] = $link_name;
+ $urls[] = $link_url;
+ $targets[] = $link_target;
+ $feeds[] = $link_rss;
+ $descriptions[] = $link_description;
+ } // end if outline
+}
+
+/**
+ ** endElement()
+ ** Callback function. Called at the end of an xml tag.
+ **/
+function endElement($parser, $tagName) {
+ // nothing to do.
+}
+
+// Create an XML parser
+$xml_parser = xml_parser_create();
+
+// Set the functions to handle opening and closing tags
+xml_set_element_handler($xml_parser, "startElement", "endElement");
+
+if (!xml_parse($xml_parser, $opml, true)) {
+ echo(sprintf(__('XML error: %1$s at line %2$s'),
+ xml_error_string(xml_get_error_code($xml_parser)),
+ xml_get_current_line_number($xml_parser)));
+}
+
+// Free up memory used by the XML parser
+xml_parser_free($xml_parser);
+?>
diff --git a/wp-admin/link.php b/wp-admin/link.php
new file mode 100644
index 0000000..6e3056d
--- /dev/null
+++ b/wp-admin/link.php
@@ -0,0 +1,128 @@
+<?php
+require_once ('admin.php');
+
+$wpvarstoreset = array ('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]');
+
+for ($i = 0; $i < count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset ($$wpvar)) {
+ if (empty ($_POST["$wpvar"])) {
+ if (empty ($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+if ('' != $_POST['deletebookmarks'])
+ $action = 'deletebookmarks';
+if ('' != $_POST['move'])
+ $action = 'move';
+if ('' != $_POST['linkcheck'])
+ $linkcheck = $_POST[linkcheck];
+
+$this_file = 'link-manager.php';
+
+switch ($action) {
+ case 'deletebookmarks' :
+ check_admin_referer('bulk-bookmarks');
+
+ // check the current user's level first.
+ if (!current_user_can('manage_links'))
+ die(__("Cheatin' uh ?"));
+
+ //for each link id (in $linkcheck[]) change category to selected value
+ if (count($linkcheck) == 0) {
+ header('Location: '.$this_file);
+ exit;
+ }
+
+ $deleted = 0;
+ foreach ($linkcheck as $link_id) {
+ $link_id = (int) $link_id;
+
+ if ( wp_delete_link($link_id) )
+ $deleted++;
+ }
+
+ header("Location: $this_file?deleted=$deleted");
+ break;
+
+ case 'move' :
+ check_admin_referer('bulk-bookmarks');
+
+ // check the current user's level first.
+ if (!current_user_can('manage_links'))
+ die(__("Cheatin' uh ?"));
+
+ //for each link id (in $linkcheck[]) change category to selected value
+ if (count($linkcheck) == 0) {
+ header('Location: '.$this_file);
+ exit;
+ }
+ $all_links = join(',', $linkcheck);
+ // should now have an array of links we can change
+ //$q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)");
+
+ header('Location: '.$this_file);
+ break;
+
+ case 'add' :
+ check_admin_referer('add-bookmark');
+
+ add_link();
+
+ header('Location: '.$_SERVER['HTTP_REFERER'].'?added=true');
+ break;
+
+ case 'save' :
+ $link_id = (int) $_POST['link_id'];
+ check_admin_referer('update-bookmark_' . $link_id);
+
+ edit_link($link_id);
+
+ wp_redirect($this_file);
+ exit;
+ break;
+
+ case 'delete' :
+ $link_id = (int) $_GET['link_id'];
+ check_admin_referer('delete-bookmark_' . $link_id);
+
+ if (!current_user_can('manage_links'))
+ die(__("Cheatin' uh ?"));
+
+ wp_delete_link($link_id);
+
+ wp_redirect($this_file);
+ break;
+
+ case 'edit' :
+ wp_enqueue_script( array('xfn', 'dbx-admin-key?pagenow=link.php') );
+ if ( current_user_can( 'manage_categories' ) )
+ wp_enqueue_script( 'ajaxcat' );
+ $parent_file = 'link-manager.php';
+ $submenu_file = 'link-manager.php';
+ $title = __('Edit Bookmark');
+ include_once ('admin-header.php');
+ if (!current_user_can('manage_links'))
+ die(__('You do not have sufficient permissions to edit the bookmarks for this blog.'));
+
+ $link_id = (int) $_GET['link_id'];
+
+ if (!$link = get_link_to_edit($link_id))
+ die(__('Link not found.'));
+
+ include ('edit-link-form.php');
+ break;
+
+ default :
+ break;
+}
+
+include ('admin-footer.php');
+?>
diff --git a/wp-admin/list-manipulation-js.php b/wp-admin/list-manipulation-js.php
new file mode 100644
index 0000000..ef09467
--- /dev/null
+++ b/wp-admin/list-manipulation-js.php
@@ -0,0 +1,163 @@
+<?php
+require_once('admin.php');
+header('Content-type: text/javascript; charset=' . get_settings('blog_charset'), true);
+?>
+addLoadEvent(function(){theList=new listMan();});
+function deleteSomething(what,id,message,obj){if(!obj)obj=theList;if(!message)message="<?php printf(__('Are you sure you want to delete this %s?'),"'+what+'"); ?>";if(confirm(message))return obj.ajaxDelete(what,id);else return false;}
+function dimSomething(what,id,dimClass,obj){if(!obj)obj=theList;return obj.ajaxDimmer(what,id,dimClass);}
+
+function WPAjax(file, responseEl){//class WPAjax extends sack
+ this.getResponseElement=function(r){var p=document.getElementById(r+'-p');if(!p){p=document.createElement('span');p.id=r+'-p';document.getElementById(r).appendChild(p);}this.myResponseElement=p; }
+ this.parseAjaxResponse=function(){
+ if(isNaN(this.response)){this.myResponseElement.innerHTML='<div class="error"><p>'+this.response+'</p></div>';return false;}
+ this.response=parseInt(this.response,10);
+ if(-1==this.response){this.myResponseElement.innerHTML="<div class='error'><p><?php _e("You don't have permission to do that."); ?></p></div>";return false;}
+ else if(0==this.response){this.myResponseElement.innerHTML="<div class='error'><p><?php _e("Something odd happened. Try refreshing the page? Either that or what you tried to change never existed in the first place."); ?></p></div>";return false;}
+ return true;
+ }
+ this.parseAjaxResponseXML=function(){
+ if(this.responseXML&&typeof this.responseXML=='object')return true;
+ if(isNaN(this.response)){this.myResponseElement.innerHTML='<div class="error"><p>'+this.response+'</p></div>';return false;}
+ var r=parseInt(this.response,10);
+ if(-1==r){this.myResponseElement.innerHTML="<div class='error'><p><?php _e("You don't have permission to do that."); ?></p></div>";}
+ else if(0==r){this.myResponseElement.innerHTML="<div class='error'><p><?php _e("Invalid Entry."); ?></p></div>";}
+ return false;
+ }
+ this.init(file,responseEl);
+} WPAjax.prototype=new sack;
+ WPAjax.prototype.init=function(f,r){
+ this.encVar('cookie', document.cookie);
+ this.requestFile=f;this.getResponseElement(r);this.method='POST';
+ this.onLoading=function(){this.myResponseElement.innerHTML="<?php _e('Sending Data...'); ?>";};
+ this.onLoaded=function(){this.myResponseElement.innerHTML="<?php _e('Data Sent...'); ?>";};
+ this.onInteractive=function(){this.myResponseElement.innerHTML="<?php _e('Processing Data...'); ?>";};
+ }
+
+function listMan(theListId){
+ this.theList=null;
+ this.ajaxRespEl=null;
+ this.inputData='';this.clearInputs=new Array();this.showLink=1;
+ this.topAdder=0;this.alt='alternate';this.recolorPos;this.reg_color='#FFFFFF';this.alt_color='#F1F1F1';
+ this.addComplete=null;this.delComplete=null;this.dimComplete=null;
+ var listType;var listItems;
+ self.aTrap=0;
+
+ this.ajaxAdder=function(what,where,update){//for TR, server must wrap TR in TABLE TBODY. this.makeEl cleans it
+ if(self.aTrap)return;self.aTrap=1;setTimeout('aTrap=0',300);
+ this.ajaxAdd=new WPAjax('admin-ajax.php',this.ajaxRespEl?this.ajaxRespEl:'ajax-response');
+ if(this.ajaxAdd.failed)return true;
+ this.grabInputs(where);
+ var tempObj=this;
+ this.ajaxAdd.onCompletion=function(){
+ if(!this.parseAjaxResponseXML())return;
+ var newItems=this.responseXML.getElementsByTagName(what);
+ if(tempObj.topAdder)tempObj.recolorPos=0;
+ if(newItems){for (c=0;c<newItems.length;c++){
+ var id=parseInt(getNodeValue(newItems[c],'id'),10);
+ var exists=document.getElementById(what+'-'+id);
+ if(exists)tempObj.replaceListItem(exists.id,getNodeValue(newItems[c],'newitem'),newItems.length,update);
+ else tempObj.addListItem(getNodeValue(newItems[c],'newitem'),newItems.length);
+ }}
+ tempObj.inputData='';
+ if(tempObj.showLink){this.myResponseElement.innerHTML='<div id="jumplink" class="updated fade"><p><a href="#'+what+'-'+id+'"><?php _e('Jump to new item'); ?></a></p></div>';}
+ else this.myResponseElement.innerHTML='';
+ for(var i=0;i<tempObj.clearInputs.length;i++){try{var theI=document.getElementById(tempObj.clearInputs[i]);if(theI.tagName.match(/select/i))theI.selectedIndex=0;else theI.value='';}catch(e){}}
+ if(tempObj.addComplete&&typeof tempObj.addComplete=='function')tempObj.addComplete(what,where,update);
+ tempObj.recolorList(tempObj.recolorPos,1000);
+ }
+ this.ajaxAdd.runAJAX('action='+(update?'update-':'add-')+what+this.inputData);
+ return false;
+ }
+ this.ajaxUpdater=function(what,where){return this.ajaxAdder(what,where,true);}
+ this.ajaxDelete=function(what,id){
+ if(self.aTrap)return;self.aTrap=1;setTimeout('aTrap=0',300);
+ this.ajaxDel=new WPAjax('admin-ajax.php',this.ajaxRespEl?this.ajaxRespEl:'ajax-response');
+ if(this.ajaxDel.failed)return true;
+ var tempObj=this;
+ this.ajaxDel.onCompletion=function(){if(this.parseAjaxResponse()){tempObj.removeListItem(what.replace('-as-spam','')+'-'+id);this.myResponseElement.innerHTML='';if(tempObj.delComplete&&typeof tempObj.delComplete=='function')tempObj.delComplete(what,id);tempObj.recolorList(tempObj.recolorPos,1000)}};
+ this.ajaxDel.runAJAX('action=delete-'+what+'&id='+id);
+ return false;
+ }
+ this.ajaxDimmer=function(what,id,dimClass){
+ if(self.aTrap)return;self.aTrap=1;setTimeout('aTrap=0',300);
+ this.ajaxDim=new WPAjax('admin-ajax.php',this.ajaxRespEl?this.ajaxRespEl:'ajax-response');
+ if(this.ajaxDim.failed)return true;
+ var tempObj=this;
+ this.ajaxDim.onCompletion=function(){if(this.parseAjaxResponse()){tempObj.dimItem(what+'-'+id,dimClass);this.myResponseElement.innerHTML='';if(tempObj.dimComplete&&typeof tempObj.dimComplete=='function')tempObj.dimComplete(what,id,dimClass);}};
+ this.ajaxDim.runAJAX('action=dim-'+what+'&id='+id);
+ return false;
+ }
+ this.makeEl=function(h){var fakeItem=document.createElement('div');fakeItem.innerHTML=h;var r=fakeItem.firstChild;while(r.tagName.match(/(table|tbody)/i)){r=r.firstChild;}return r;}
+ this.addListItem=function(h,tot){
+ newItem=this.makeEl(h);
+ if(this.topAdder){var firstItem=this.theList.getElementsByTagName('table'==listType?'tr':'li')[0];listItems.unshift(newItem.id);this.recolorPos++}
+ else{listItems.push(newItem.id);this.recolorPos=listItems.length;}
+ if(this.alt&&!((tot-this.recolorPos)%2))newItem.className+=' '+this.alt;
+ if(firstItem)firstItem.parentNode.insertBefore(newItem,firstItem);
+ else this.theList.appendChild(newItem);
+ Fat.fade_element(newItem.id);
+ }
+ this.removeListItem=function(id,noFade){
+ if(!noFade)Fat.fade_element(id,null,700,'#FF3333');
+ var theItem=document.getElementById(id);
+ if(!noFade){var func=encloseFunc(function(a){a.parentNode.removeChild(a);},theItem);setTimeout(func,705);}
+ else{theItem.parentNode.removeChild(theItem);}
+ var pos=this.getListPos(id);
+ listItems.splice(pos,1);
+ }
+ this.replaceListItem=function(id,h,tot,update){
+ if(!update){this.removeListItem(id,true);this.addListItem(h,tot);return;}
+ var newItem=this.makeEl(h);
+ var oldItem=document.getElementById(id);
+ var pos=this.getListPos(oldItem.id,1);if(this.alt&&!(pos%2))newItem.className+=' '+this.alt;
+ oldItem.parentNode.replaceChild(newItem,oldItem);
+ Fat.fade_element(newItem.id);
+ }
+ this.dimItem=function(id,dimClass,noFade){
+ var theItem=document.getElementById(id);
+ if(theItem.className.match(dimClass)){if(!noFade)Fat.fade_element(id,null,700,null);theItem.className=theItem.className.replace(dimClass,'');}
+ else{if(!noFade)Fat.fade_element(id,null,700,'#FF3333');theItem.className=theItem.className+' '+dimClass;}
+ }
+ this.grabInputs=function(elId){//text,password,hidden,textarea,select
+ var theItem=document.getElementById(elId);
+ var inputs=new Array();
+ inputs.push(theItem.getElementsByTagName('input'),theItem.getElementsByTagName('textarea'),theItem.getElementsByTagName('select'));
+ for(var a=0;a<inputs.length;a++){
+ for(var i=0;i<inputs[a].length;i++){
+ if('action'==inputs[a][i].name)continue;
+ if('text'==inputs[a][i].type||'password'==inputs[a][i].type||'hidden'==inputs[a][i].type||inputs[a][i].tagName.match(/textarea/i)){
+ this.inputData+='&'+inputs[a][i].name+'='+encodeURIComponent(inputs[a][i].value);if('hidden'!=inputs[a][i].type)this.clearInputs.push(inputs[a][i].id);
+ }else if(inputs[a][i].tagName.match(/select/i)){
+ this.inputData+='&'+inputs[a][i].name+'='+encodeURIComponent(inputs[a][i].options[inputs[a][i].selectedIndex].value);this.clearInputs.push(inputs[a][i].id);
+ }
+ }
+ }
+ }
+ this.getListPos=function(id,n){for(var i=0;i<listItems.length;i++){if(id==listItems[i]){var pos=i;break;}}if(!n){if(pos<this.recolorPos)this.recolorPos=pos;}return pos;}
+ this.getListItems=function(){
+ if(this.theList)return;
+ listItems=new Array();
+ if(theListId){this.theList=document.getElementById(theListId);if(!this.theList)return false;}
+ else{this.theList=document.getElementById('the-list');if(this.theList)theListId='the-list';}
+ if(this.theList){
+ var items=this.theList.getElementsByTagName('tr');listType='table';
+ if(!items[0]){items=this.theList.getElementsByTagName('li');listType='list';}
+ for(var i=0;i<items.length;i++){listItems.push(items[i].id);}
+ this.recolorPos=listItems.length;
+ }
+ }
+ this.recolorList=function(pos,dur){
+ if(!this.alt)return;if(!pos)pos=0;this.recolorPos=listItems.length;
+ for(var i=pos;i<listItems.length;i++){var e=document.getElementById(listItems[i]);if(i%2)e.className=e.className.replace(this.alt,'fade-'+this.alt_color.slice(1));else e.className+=' '+this.alt+' fade-'+this.reg_color.slice(1);e.style.backgroundColor='';}
+ Fat.fade_all(dur);
+ var func=encloseFunc(function(l){for(var i=0;i<l.length;i++){var e=document.getElementById(l[i]);e.className=e.className.replace(/fade-[a-f0-9]{6}/i,'');}},listItems);
+ setTimeout(func,dur+5);
+ }
+ this.getListItems();
+}
+//No submit unless eval(code) returns true.
+function killSubmit(code,e){if(!e){if(window.event)e=window.event;else return;}var t=e.target?e.target:e.srcElement;if(('text'==t.type&&e.keyCode==13)||('submit'==t.type&&'click'==e.type)){if(!eval(code)){e.returnValue=false;e.cancelBubble=true;return false;}}}
+//Pretty func from ALA http://www.alistapart.com/articles/gettingstartedwithajax
+function getNodeValue(tree,el){return tree.getElementsByTagName(el)[0].firstChild.nodeValue;}
+//Generic but lame JS closure
+function encloseFunc(f){var a=arguments[1];return function(){return f(a);}}
diff --git a/wp-admin/menu-header.php b/wp-admin/menu-header.php
new file mode 100644
index 0000000..416a229
--- /dev/null
+++ b/wp-admin/menu-header.php
@@ -0,0 +1,61 @@
+<ul id="adminmenu">
+<?php
+$self = preg_replace('|^.*/wp-admin/|i', '', $_SERVER['PHP_SELF']);
+$self = preg_replace('|^.*/plugins/|i', '', $self);
+
+get_admin_page_parent();
+
+foreach ($menu as $item) {
+ $class = '';
+
+ // 0 = name, 1 = capability, 2 = file
+ if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"';
+
+ if ( !empty($submenu[$item[2]]) || current_user_can($item[1]) ) {
+ if ( file_exists(ABSPATH . "wp-content/plugins/{$item[2]}") )
+ echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
+ else
+ echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/{$item[2]}'$class>{$item[0]}</a></li>";
+ }
+}
+
+?>
+</ul>
+
+<?php
+// Sub-menu
+if ( isset($submenu["$parent_file"]) ) :
+?>
+<ul id="submenu">
+<?php
+foreach ($submenu["$parent_file"] as $item) :
+ if ( !current_user_can($item[1]) )
+ continue;
+
+if ( isset($submenu_file) ) {
+ if ( $submenu_file == $item[2] ) $class = ' class="current"';
+ else $class = '';
+} else if ( (isset($plugin_page) && $plugin_page == $item[2]) || (!isset($plugin_page) && $self == $item[2]) ) $class = ' class="current"';
+else $class = '';
+
+$menu_hook = get_plugin_page_hook($item[2], $parent_file);
+
+if (file_exists(ABSPATH . "wp-content/plugins/{$item[2]}") || ! empty($menu_hook)) {
+ if ( 'admin.php' == $pagenow )
+ echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
+ else
+ echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/{$parent_file}?page={$item[2]}'$class>{$item[0]}</a></li>";
+ } else {
+ echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/{$item[2]}'$class>{$item[0]}</a></li>";
+ }
+endforeach;
+?>
+
+</ul>
+<?php
+
+endif;
+
+do_action('admin_notices');
+
+?>
diff --git a/wp-admin/menu.php b/wp-admin/menu.php
new file mode 100644
index 0000000..f363a76
--- /dev/null
+++ b/wp-admin/menu.php
@@ -0,0 +1,141 @@
+<?php
+// This array constructs the admin menu bar.
+//
+// Menu item name
+// The minimum level the user needs to access the item: between 0 and 10
+// The URL of the item's file
+
+$menu_perms = get_site_option( "menu_items" );
+if( is_array( $menu_perms ) == false )
+ $menu_perms = array();
+
+$menu[0] = array(__('Dashboard'), 'read', 'index.php');
+$menu[5] = array(__('Write'), 'edit_posts', 'post-new.php');
+$menu[10] = array(__('Manage'), 'edit_posts', 'edit.php');
+$menu[20] = array(__('Bookmarks'), 'manage_links', 'link-manager.php');
+$menu[25] = array(__('Presentation'), 'switch_themes', 'themes.php');
+if( $menu_perms[ 'plugins' ] == 1 )
+ $menu[30] = array(__('Plugins'), 'activate_plugins', 'plugins.php');
+if ( current_user_can('edit_users') )
+ $menu[35] = array(__('Users'), 'edit_users', 'users.php');
+else
+ $menu[35] = array(__('Profile'), 'read', 'profile.php');
+$menu[40] = array(__('Options'), 'manage_options', 'options-general.php');
+
+
+$submenu['post-new.php'][5] = array(__('Write Post'), 'edit_posts', 'post-new.php');
+$submenu['post-new.php'][10] = array(__('Write Page'), 'edit_pages', 'page-new.php');
+
+$submenu['edit.php'][5] = array(__('Posts'), 'edit_posts', 'edit.php');
+$submenu['edit.php'][10] = array(__('Pages'), 'edit_pages', 'edit-pages.php');
+$submenu['edit.php'][15] = array(__('Categories'), 'manage_categories', 'categories.php');
+$submenu['edit.php'][20] = array(__('Comments'), 'edit_posts', 'edit-comments.php');
+$awaiting_mod = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");
+$submenu['edit.php'][25] = array(sprintf(__("Awaiting Moderation (%s)"), "<span id='awaitmod'>$awaiting_mod</span>"), 'edit_posts', 'moderation.php');
+//$submenu['edit.php'][30] = array(__('Files'), 'edit_files', 'templates.php');
+$submenu['edit.php'][35] = array(__('Import'), 'import', 'import.php');
+$submenu['edit.php'][40] = array(__('Export'), 'import', 'export.php');
+//$invites_left = get_usermeta( $user_ID, 'invites_left' );
+//$submenu['edit.php'][45] = array(sprintf(__("Invites (%s)"), $invites_left ), 'edit_posts', 'invites.php'); // TODO: put somewhere else.
+
+$submenu['link-manager.php'][5] = array(__('Manage Bookmarks'), 'manage_links', 'link-manager.php');
+$submenu['link-manager.php'][10] = array(__('Add Bookmark'), 'manage_links', 'link-add.php');
+$submenu['link-manager.php'][20] = array(__('Import Bookmarks'), 'manage_links', 'link-import.php');
+
+if ( current_user_can('edit_users') ) {
+ $submenu['users.php'][5] = array(__('Authors &amp; Users'), 'edit_users', 'users.php');
+ $submenu['users.php'][10] = array(__('Your Profile'), 'read', 'profile.php');
+} else {
+ $submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php');
+}
+
+$submenu['options-general.php'][10] = array(__('General'), 'manage_options', 'options-general.php');
+$submenu['options-general.php'][15] = array(__('Writing'), 'manage_options', 'options-writing.php');
+$submenu['options-general.php'][20] = array(__('Reading'), 'manage_options', 'options-reading.php');
+$submenu['options-general.php'][25] = array(__('Discussion'), 'manage_options', 'options-discussion.php');
+//$submenu['options-general.php'][30] = array(__('Privacy'), 'manage_options', 'options-privacy.php');
+//$submenu['options-general.php'][35] = array(__('Permalinks'), 'manage_options', 'options-permalink.php');
+//$submenu['options-general.php'][40] = array(__('Miscellaneous'), 'manage_options', 'options-misc.php');
+
+//$submenu['plugins.php'][5] = array(__('Plugins'), 'activate_plugins', 'plugins.php');
+//$submenu['plugins.php'][10] = array(__('Plugin Editor'), 'edit_plugins', 'plugin-editor.php');
+
+$submenu['themes.php'][5] = array(__('Themes'), 'switch_themes', 'themes.php');
+//$submenu['themes.php'][10] = array(__('Theme Editor'), 'edit_themes', 'theme-editor.php');
+
+// Create list of page plugin hook names.
+foreach ($menu as $menu_page) {
+ $admin_page_hooks[$menu_page[2]] = sanitize_title($menu_page[0]);
+}
+
+do_action('admin_menu', '');
+
+// Loop over submenus and remove pages for which the user does not have privs.
+foreach ($submenu as $parent => $sub) {
+ foreach ($sub as $index => $data) {
+ if ( ! current_user_can($data[1]) ) {
+ $menu_nopriv[$data[2]] = true;
+ unset($submenu[$parent][$index]);
+ }
+ }
+
+ if ( empty($submenu[$parent]) )
+ unset($submenu[$parent]);
+}
+
+// Loop over the top-level menu.
+// Remove menus that have no accessible submenus and require privs that the user does not have.
+// Menus for which the original parent is not acessible due to lack of privs will have the next
+// submenu in line be assigned as the new menu parent.
+foreach ( $menu as $id => $data ) {
+ // If submenu is empty...
+ if ( empty($submenu[$data[2]]) ) {
+ // And user doesn't have privs, remove menu.
+ if ( ! current_user_can($data[1]) ) {
+ $menu_nopriv[$data[2]] = true;
+ unset($menu[$id]);
+ }
+ } else {
+ $subs = $submenu[$data[2]];
+ $first_sub = array_shift($subs);
+ $old_parent = $data[2];
+ $new_parent = $first_sub[2];
+ // If the first submenu is not the same as the assigned parent,
+ // make the first submenu the new parent.
+ if ( $new_parent != $old_parent ) {
+ $real_parent_file[$old_parent] = $new_parent;
+ $menu[$id][2] = $new_parent;
+
+ foreach ($submenu[$old_parent] as $index => $data) {
+ $submenu[$new_parent][$index] = $submenu[$old_parent][$index];
+ unset($submenu[$old_parent][$index]);
+ }
+ unset($submenu[$old_parent]);
+ }
+ }
+}
+
+get_currentuserinfo();
+if( is_site_admin() ) {
+ $menu[1] = array(__('Site Admin'), '10', 'wpmu-admin.php' );
+ $submenu[ 'wpmu-admin.php' ][5] = array( 'Blogs', '10', 'wpmu-blogs.php' );
+ $submenu[ 'wpmu-admin.php' ][10] = array( 'Users', '10', 'wpmu-users.php' );
+ $submenu[ 'wpmu-admin.php' ][15] = array( 'Feeds', '10', 'wpmu-feeds.php' );
+ $submenu[ 'wpmu-admin.php' ][20] = array( 'Themes', '10', 'wpmu-themes.php' );
+ $submenu[ 'wpmu-admin.php' ][25] = array( 'Options', '10', 'wpmu-options.php' );
+ $submenu[ 'wpmu-admin.php' ][30] = array( 'Upgrade', '10', 'wpmu-upgrade-site.php' );
+}
+ksort($menu); // make it all pretty
+
+if (! user_can_access_admin_page()) {
+ global $wpdb;
+ // find the blog of this user first
+ $primary_blog = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->usermeta} WHERE user_id = '$user_ID' AND meta_key = 'primary_blog'" );
+ if( $primary_blog ) {
+ header( "Location: " . get_blog_option( $primary_blog, "siteurl" ) . "/wp-admin/" );
+ exit;
+ }
+ die( __('You do not have sufficient permissions to access this page.') );
+}
+
+?>
diff --git a/wp-admin/moderation.php b/wp-admin/moderation.php
new file mode 100644
index 0000000..5839e6f
--- /dev/null
+++ b/wp-admin/moderation.php
@@ -0,0 +1,232 @@
+<?php
+require_once('admin.php');
+
+$title = __('Moderate comments');
+$parent_file = 'edit.php';
+wp_enqueue_script( 'admin-comments' );
+
+$wpvarstoreset = array('action', 'item_ignored', 'item_deleted', 'item_approved', 'item_spam', 'feelinglucky');
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+$comment = array();
+if (isset($_POST["comment"])) {
+ foreach ($_POST["comment"] as $k => $v) {
+ $comment[intval($k)] = $v;
+ }
+}
+
+switch($action) {
+
+case 'update':
+
+ check_admin_referer('moderate-comments');
+
+ if ( ! current_user_can('moderate_comments') )
+ die('<p>'.__('Your level is not high enough to moderate comments.').'</p>');
+
+ $item_ignored = 0;
+ $item_deleted = 0;
+ $item_approved = 0;
+ $item_spam = 0;
+
+ foreach($comment as $key => $value) {
+ if ($feelinglucky && 'later' == $value)
+ $value = 'delete';
+ switch($value) {
+ case 'later':
+ // do nothing with that comment
+ // wp_set_comment_status($key, "hold");
+ ++$item_ignored;
+ break;
+ case 'delete':
+ wp_set_comment_status($key, 'delete');
+ ++$item_deleted;
+ break;
+ case 'spam':
+ wp_set_comment_status($key, 'spam');
+ ++$item_spam;
+ break;
+ case 'approve':
+ wp_set_comment_status($key, 'approve');
+ if ( get_settings('comments_notify') == true ) {
+ wp_notify_postauthor($key);
+ }
+ ++$item_approved;
+ break;
+ }
+ }
+
+ $file = basename(__FILE__);
+ header("Location: $file?ignored=$item_ignored&deleted=$item_deleted&approved=$item_approved&spam=$item_spam");
+ exit();
+
+break;
+
+default:
+
+require_once('admin-header.php');
+
+if ( isset($_GET['deleted']) || isset($_GET['approved']) || isset($_GET['ignored']) ) {
+ echo "<div id='moderated' class='updated fade'>\n<p>";
+ $approved = (int) $_GET['approved'];
+ $deleted = (int) $_GET['deleted'];
+ $ignored = (int) $_GET['ignored'];
+ $spam = (int) $_GET['spam'];
+ if ($approved) {
+ if ('1' == $approved) {
+ echo __("1 comment approved") . " <br/>\n";
+ } else {
+ echo sprintf(__("%s comments approved <br />"), $approved) . "\n";
+ }
+ }
+ if ($deleted) {
+ if ('1' == $deleted) {
+ echo __("1 comment deleted") . " <br/>\n";
+ } else {
+ echo sprintf(__("%s comments deleted"), $deleted) . " <br/>\n";
+ }
+ }
+ if ($spam) {
+ if ('1' == $spam) {
+ echo __("1 comment marked as spam") . " <br/>\n";
+ } else {
+ echo sprintf(__("%s comments marked as spam"), $spam) . " <br/>\n";
+ }
+ }
+ if ($ignored) {
+ if ('1' == $ignored) {
+ echo __("1 comment unchanged") . " <br/>\n";
+ } else {
+ echo sprintf(__("%s comments unchanged"), $ignored) . " <br/>\n";
+ }
+ }
+ echo "</p></div>\n";
+}
+
+?>
+
+<div class="wrap">
+
+<?php
+if ( current_user_can('moderate_comments') )
+ $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '0'");
+else
+ $comments = '';
+
+if ($comments) {
+ // list all comments that are waiting for approval
+ $file = basename(__FILE__);
+?>
+ <h2><?php _e('Moderation Queue') ?></h2>
+ <form name="approval" action="moderation.php" method="post">
+ <?php wp_nonce_field('moderate-comments') ?>
+ <input type="hidden" name="action" value="update" />
+ <ol id="the-comment-list" class="commentlist">
+<?php
+$i = 0;
+ foreach($comments as $comment) {
+ ++$i;
+ $comment_date = mysql2date(get_settings("date_format") . " @ " . get_settings("time_format"), $comment->comment_date);
+ $post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID='$comment->comment_post_ID'");
+ if ($i % 2) $class = 'js-unapproved alternate';
+ else $class = 'js-unapproved';
+ echo "\n\t<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
+echo '<a href="comment.php?action=editcomment&amp;comment='.$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, '" . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), js_escape($comment->comment_author)) . "', theCommentList );\">" . __('Delete ') . "</a> | "; ?>
+<?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:') ?>
+ <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;
+ <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment[<?php echo $comment->comment_ID; ?>]-nothing" value="later" checked="checked" /> <label for="comment[<?php echo $comment->comment_ID; ?>]-nothing"><?php _e('Defer until later') ?></label>
+ </p>
+
+ </li>
+<?php
+ }
+?>
+ </ol>
+
+<div id="ajax-response"></div>
+
+ <p class="submit"><input type="submit" name="submit" value="<?php _e('Bulk Moderate Comments &raquo;') ?>" /></p>
+<script type="text/javascript">
+// <![CDATA[
+function markAllForDelete() {
+ for (var i=0; i< document.approval.length; i++) {
+ if (document.approval[i].value == "delete") {
+ document.approval[i].checked = true;
+ }
+ }
+}
+function markAllForApprove() {
+ for (var i=0; i< document.approval.length; i++) {
+ if (document.approval[i].value == "approve") {
+ document.approval[i].checked = true;
+ }
+ }
+}
+function markAllForDefer() {
+ for (var i=0; i< document.approval.length; i++) {
+ if (document.approval[i].value == "later") {
+ document.approval[i].checked = true;
+ }
+ }
+}
+function markAllAsSpam() {
+ for (var i=0; i< document.approval.length; i++) {
+ if (document.approval[i].value == "spam") {
+ document.approval[i].checked = true;
+ }
+ }
+}
+document.write('<ul><li><a href="javascript:markAllForApprove()"><?php _e('Mark all for approval'); ?></a></li><li><a href="javascript:markAllAsSpam()"><?php _e('Mark all as spam'); ?></a></li><li><a href="javascript:markAllForDelete()"><?php _e('Mark all for deletion'); ?></a></li><li><a href="javascript:markAllForDefer()"><?php _e('Mark all for later'); ?></a></li></ul>');
+// ]]>
+</script>
+
+<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>
+ </p>
+</noscript>
+ </form>
+<?php
+} else {
+ // nothing to approve
+ echo '<p>'.__("Currently there are no comments for you to moderate.") . "</p>\n";
+}
+?>
+
+</div>
+
+<?php
+
+break;
+}
+
+
+include('admin-footer.php');
+
+?>
diff --git a/wp-admin/options-discussion.php b/wp-admin/options-discussion.php
new file mode 100644
index 0000000..247c01f
--- /dev/null
+++ b/wp-admin/options-discussion.php
@@ -0,0 +1,101 @@
+<?php
+require_once('admin.php');
+
+$title = __('Discussion Options');
+$parent_file = 'options-general.php';
+
+include('admin-header.php');
+
+if ($action == 'retrospam') {
+ if ( $_GET['move'] == 'true' ) {
+ retrospam_mgr::move_spam( $_GET[ids] );
+ }
+ $retrospaminator = new retrospam_mgr();
+ $result = $retrospaminator->find_spam();
+ echo $retrospaminator->display_edit_form( $result );
+ include('./admin-footer.php');
+ exit;
+}
+?>
+
+<div class="wrap">
+<h2><?php _e('Discussion Options') ?></h2>
+<form method="post" action="options.php">
+<?php wp_nonce_field('update-options') ?>
+<fieldset class="options">
+<legend><?php _e('Usual settings for an article:<br /><small><em>(These settings may be overridden for individual articles.)</em></small>') ?></legend>
+<ul>
+<li>
+<label for="default_pingback_flag">
+<input name="default_pingback_flag" type="checkbox" id="default_pingback_flag" value="1" <?php checked('1', get_settings('default_pingback_flag')); ?> />
+<?php _e('Attempt to notify any Weblogs linked to from the article (slows down posting.)') ?></label>
+</li>
+<li>
+<label for="default_ping_status">
+<input name="default_ping_status" type="checkbox" id="default_ping_status" value="open" <?php checked('open', get_settings('default_ping_status')); ?> />
+<?php _e('Allow link notifications from other Weblogs (pingbacks and trackbacks.)') ?></label>
+</li>
+<li>
+<label for="default_comment_status">
+<input name="default_comment_status" type="checkbox" id="default_comment_status" value="open" <?php checked('open', get_settings('default_comment_status')); ?> />
+<?php _e('Allow people to post comments on the article') ?></label>
+</li>
+</ul>
+</fieldset>
+<fieldset class="options">
+<legend><?php _e('E-mail me whenever:') ?></legend>
+<ul>
+<li>
+<label for="comments_notify">
+<input name="comments_notify" type="checkbox" id="comments_notify" value="1" <?php checked('1', get_settings('comments_notify')); ?> />
+<?php _e('Anyone posts a comment') ?> </label>
+</li>
+<li>
+<label for="moderation_notify">
+<input name="moderation_notify" type="checkbox" id="moderation_notify" value="1" <?php checked('1', get_settings('moderation_notify')); ?> />
+<?php _e('A comment is held for moderation') ?> </label>
+</li>
+</ul>
+</fieldset>
+<fieldset class="options">
+<legend><?php _e('Before a comment appears:') ?></legend>
+<ul>
+<li>
+<label for="comment_moderation">
+<input name="comment_moderation" type="checkbox" id="comment_moderation" value="1" <?php checked('1', get_settings('comment_moderation')); ?> />
+<?php _e('An administrator must approve the comment (regardless of any matches below)') ?> </label>
+</li>
+<li><label for="require_name_email"><input type="checkbox" name="require_name_email" id="require_name_email" value="1" <?php checked('1', get_settings('require_name_email')); ?> /> <?php _e('Comment author must fill out name and e-mail') ?></label></li>
+<li><label for="comment_whitelist"><input type="checkbox" name="comment_whitelist" id="comment_whitelist" value="1" <?php checked('1', get_settings('comment_whitelist')); ?> /> <?php _e('Comment author must have a previously approved comment') ?></label></li>
+</ul>
+</fieldset>
+<fieldset class="options">
+<legend><?php _e('Comment Moderation') ?></legend>
+<p><?php printf(__('Hold a comment in the queue if it contains more than %s links. (A common characteristic of comment spam is a large number of hyperlinks.)'), '<input name="comment_max_links" type="text" id="comment_max_links" size="3" value="' . get_settings('comment_max_links'). '" />' ) ?></p>
+
+<p><?php _e('When a comment contains any of these words in its content, name, URI, e-mail, or IP, hold it in the moderation queue: (Separate multiple words with new lines.) <a href="http://codex.wordpress.org/Spam_Words">Common spam words</a>.') ?></p>
+<p>
+<textarea name="moderation_keys" cols="60" rows="4" id="moderation_keys" style="width: 98%; font-size: 12px;" class="code"><?php form_option('moderation_keys'); ?></textarea>
+</p>
+<p>
+<a id="retrospambutton" href="options-discussion.php?action=retrospam"><?php _e('Check past comments against moderation list'); ?></a>
+</p>
+</fieldset>
+<fieldset class="options">
+<legend><?php _e('Comment Blacklist') ?></legend>
+<p><?php _e('This is a list of words that you want completely blacklisted from your blog. Be very careful what you add here, because if a comment matches something here it will be completely nuked and there will be no notification. Remember that partial words can match, so if there is any chance something here might match it would be better to put it in the moderation box above.') ?></p>
+<p>
+<textarea name="blacklist_keys" cols="60" rows="4" id="blacklist_keys" style="width: 98%; font-size: 12px;" class="code"><?php form_option('blacklist_keys'); ?></textarea>
+</p>
+<p><label for="open_proxy_check">
+<input name="open_proxy_check" type="checkbox" id="open_proxy_check" value="1" <?php checked('1', get_settings('open_proxy_check')); ?> />
+<?php _e('Blacklist comments from open and insecure proxies.') ?></label></p>
+</fieldset>
+<p class="submit">
+<input type="hidden" name="action" value="update" />
+<input type="hidden" name="page_options" value="default_pingback_flag,default_ping_status,default_comment_status,comments_notify,moderation_notify,comment_moderation,require_name_email,comment_whitelist,comment_max_links,moderation_keys,blacklist_keys,open_proxy_check" />
+<input type="submit" name="Submit" value="<?php _e('Update Options') ?>" />
+</p>
+</form>
+</div>
+<?php include('./admin-footer.php'); ?>
diff --git a/wp-admin/options-general.php b/wp-admin/options-general.php
new file mode 100644
index 0000000..91ac1d7
--- /dev/null
+++ b/wp-admin/options-general.php
@@ -0,0 +1,123 @@
+<?php
+require_once('./admin.php');
+
+$title = __('General Options');
+$parent_file = 'options-general.php';
+
+include('./admin-header.php');
+?>
+
+<div class="wrap">
+<h2><?php _e('General Options') ?></h2>
+<form method="post" action="options.php">
+<?php wp_nonce_field('update-options') ?>
+<table class="optiontable">
+<tr valign="top">
+<th scope="row"><?php _e('Weblog title:') ?></th>
+<td><input name="blogname" type="text" id="blogname" value="<?php form_option('blogname'); ?>" size="40" /></td>
+</tr>
+<tr valign="top">
+<th scope="row"><?php _e('Tagline:') ?></th>
+<td><input name="blogdescription" type="text" id="blogdescription" style="width: 95%" value="<?php form_option('blogdescription'); ?>" size="45" />
+<br />
+<?php _e('In a few words, explain what this weblog is about.') ?></td>
+</tr>
+<tr valign="top">
+<th scope="row"><?php _e('Search Engines:') ?> </th>
+<td><label><input type="checkbox" name="blog_public" value="1" <?php checked('1', $current_blog->public); ?> /> <?php _e('I would like my blog to appear in search engines like Google and Technorati, and in public listings around WordPress.com.'); ?></label> (<a href="http://wordpress.com/blog/2006/01/29/a-little-privacy/">more</a>)
+</td>
+</tr>
+
+<tr valign="top">
+<th scope="row"><?php _e('Membership:') ?></th>
+<td> <label for="comment_registration">
+<input name="comment_registration" type="checkbox" id="comment_registration" value="1" <?php checked('1', get_settings('comment_registration')); ?> />
+<?php _e('Users must be registered and logged in to comment') ?>
+</label>
+</td>
+</tr>
+<tr valign="top">
+<th scope="row"><?php _e('E-mail address:') ?> </th>
+<td><input name="new_admin_email" type="text" id="new_admin_email" value="<?php form_option('admin_email'); ?>" size="40" class="code" />
+<br />
+<p><?php _e('This address is used only for admin purposes.') ?> If you change this we will send you an email at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong></p>
+</td>
+</tr>
+
+<?php
+$lang_files = glob( ABSPATH . WPINC . "/languages/*" );
+$lang = get_option( "WPLANG" );
+if( $lang == false ) {
+ $lang = get_site_option( "WPLANG" );
+ add_option( "WPLANG", $lang );
+}
+
+if( is_array( $lang_files ) && count($lang_files) > 1 ) {
+ ?>
+ <tr valign="top">
+ <th width="33%" scope="row"><?php _e('Language:') ?></th>
+ <td><select name="WPLANG" id="WPLANG">
+ <?php
+ echo "<option value=''>Default</option>";
+ while( list( $key, $val ) = each( $lang_files ) ) {
+ $l = basename( $val, ".mo" );
+ echo "<option value='$l'";
+ echo $lang == $l ? " selected" : "";
+ echo "> $l</option>";
+ }
+ ?>
+ </select></td>
+ </tr>
+ <?php
+} // languages
+?>
+</table>
+<fieldset class="options">
+<legend><?php _e('Date and Time') ?></legend>
+<table class="optiontable">
+<tr>
+<th scope="row"><?php _e('<abbr title="Coordinated Universal Time">UTC</abbr> time is:') ?> </th>
+<td><code><?php echo gmdate('Y-m-d g:i:s a'); ?></code></td>
+</tr>
+<tr>
+<th scope="row"><?php _e('Times in the weblog should differ by:') ?> </th>
+<td><input name="gmt_offset" type="text" id="gmt_offset" size="2" value="<?php form_option('gmt_offset'); ?>" />
+<?php _e('hours') ?> </td>
+</tr>
+<tr>
+<th scope="row"><?php _e('Default date format:') ?></th>
+<td><input name="date_format" type="text" id="date_format" size="30" value="<?php form_option('date_format'); ?>" /><br />
+<?php _e('Output:') ?> <strong><?php echo mysql2date(get_settings('date_format'), current_time('mysql')); ?></strong></td>
+</tr>
+<tr>
+<th scope="row"><?php _e('Default time format:') ?></th>
+<td><input name="time_format" type="text" id="time_format" size="30" value="<?php form_option('time_format'); ?>" /><br />
+<?php _e('Output:') ?> <strong><?php echo gmdate(get_settings('time_format'), current_time('timestamp')); ?></strong></td>
+</tr>
+<tr>
+<th scope="row">&nbsp;</th>
+<td><?php _e('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date formatting</a>. Save option to update sample output.') ?> </td>
+</tr>
+<tr>
+<th scope="row"><?php _e('Weeks in the calendar should start on:') ?></th>
+<td><select name="start_of_week" id="start_of_week">
+<?php
+for ($day_index = 0; $day_index <= 6; $day_index++) :
+ $selected = (get_settings('start_of_week') == $day_index) ? 'selected="selected"' : '';
+ echo "\n\t<option value='$day_index' $selected>" . $wp_locale->get_weekday($day_index) . '</option>';
+endfor;
+?>
+</select></td>
+</tr>
+</table>
+</fieldset>
+
+<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
+<input type="hidden" name="action" value="update" />
+<input type="hidden" name="page_options" value="blogname,blogdescription,new_admin_email,users_can_register,gmt_offset,date_format,time_format,start_of_week,comment_registration,WPLANG,language,blog_public" />
+</p>
+</form>
+
+</div>
+
+<?php include('./admin-footer.php') ?>
diff --git a/wp-admin/options-head.php b/wp-admin/options-head.php
new file mode 100644
index 0000000..54f426c
--- /dev/null
+++ b/wp-admin/options-head.php
@@ -0,0 +1,24 @@
+<?php
+
+$wpvarstoreset = array('action','standalone', 'option_group_id');
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+?>
+
+<br clear="all" />
+
+<?php if (isset($_GET['updated'])) : ?>
+<div id="message" class="updated fade"><p><strong><?php _e('Options saved.') ?></strong></p></div>
+<?php endif; ?>
diff --git a/wp-admin/options-misc.php b/wp-admin/options-misc.php
new file mode 100644
index 0000000..3dd1120
--- /dev/null
+++ b/wp-admin/options-misc.php
@@ -0,0 +1,52 @@
+<?php
+die();
+require_once('admin.php');
+
+$title = __('Miscellaneous Options');
+$parent_file = 'options-general.php';
+
+include('admin-header.php');
+
+?>
+
+<div class="wrap">
+<h2><?php _e('Miscellaneous Options') ?></h2>
+<form method="post" action="options.php">
+<?php wp_nonce_field('update-options') ?>
+<fieldset class="options">
+<legend><?php _e('Uploading'); ?></legend>
+<table class="editform optiontable">
+<tr valign="top">
+<th scope="row"><?php _e('Store uploads in this folder'); ?>:</th>
+<td><input name="upload_path" type="text" id="upload_path" class="code" value="<?php echo str_replace(ABSPATH, '', get_settings('upload_path')); ?>" size="40" />
+<br />
+<?php _e('Default is <code>wp-content/uploads</code>'); ?>
+</td>
+</tr>
+<tr>
+<td></td>
+<td>
+<label for="uploads_use_yearmonth_folders">
+<input name="uploads_use_yearmonth_folders" type="checkbox" id="uploads_use_yearmonth_folders" value="1" <?php checked('1', get_settings('uploads_use_yearmonth_folders')); ?> />
+<?php _e('Organize my uploads into month- and year-based folders'); ?>
+</label>
+</td>
+</tr>
+</table>
+</fieldset>
+
+<p><input name="use_linksupdate" type="checkbox" id="use_linksupdate" value="1" <?php checked('1', get_settings('use_linksupdate')); ?> />
+<label for="use_linksupdate"><?php _e('Track Bookmarks&#8217; Update Times') ?></label></p>
+<p>
+<label><input type="checkbox" name="hack_file" value="1" <?php checked('1', get_settings('hack_file')); ?> /> <?php _e('Use legacy <code>my-hacks.php</code> file support') ?></label>
+</p>
+
+<p class="submit">
+<input type="hidden" name="action" value="update" />
+<input type="hidden" name="page_options" value="hack_file,use_linksupdate,uploads_use_yearmonth_folders,upload_path" />
+<input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
+</p>
+</form>
+</div>
+
+<?php include('./admin-footer.php'); ?>
diff --git a/wp-admin/options-permalink.php b/wp-admin/options-permalink.php
new file mode 100644
index 0000000..73a610b
--- /dev/null
+++ b/wp-admin/options-permalink.php
@@ -0,0 +1,180 @@
+<?php
+die();
+require_once('admin.php');
+
+$title = __('Permalink Options');
+$parent_file = 'options-general.php';
+
+function add_js() {
+?>
+<script type="text/javascript">
+//<![CDATA[
+function GetElementsWithClassName(elementName, className) {
+var allElements = document.getElementsByTagName(elementName);
+var elemColl = new Array();
+for (i = 0; i < allElements.length; i++) {
+if (allElements[i].className == className) {
+elemColl[elemColl.length] = allElements[i];
+}
+}
+return elemColl;
+}
+
+function upit() {
+var inputColl = GetElementsWithClassName('input', 'tog');
+var structure = document.getElementById('permalink_structure');
+var inputs = '';
+for (i = 0; i < inputColl.length; i++) {
+if ( inputColl[i].checked && inputColl[i].value != '') {
+inputs += inputColl[i].value + ' ';
+}
+}
+inputs = inputs.substr(0,inputs.length - 1);
+if ( 'custom' != inputs )
+structure.value = inputs;
+}
+
+function blurry() {
+if (!document.getElementById) return;
+
+var structure = document.getElementById('permalink_structure');
+structure.onfocus = function () { document.getElementById('custom_selection').checked = 'checked'; }
+
+var aInputs = document.getElementsByTagName('input');
+
+for (var i = 0; i < aInputs.length; i++) {
+aInputs[i].onclick = aInputs[i].onkeyup = upit;
+}
+}
+
+window.onload = blurry;
+//]]>
+</script>
+<?php
+}
+add_filter('admin_head', 'add_js');
+
+include('admin-header.php');
+
+$home_path = get_home_path();
+
+if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
+ check_admin_referer('update-permalink');
+
+ if ( isset($_POST['permalink_structure']) ) {
+ $permalink_structure = $_POST['permalink_structure'];
+ if (! empty($permalink_structure) )
+ $permalink_structure = preg_replace('#/+#', '/', '/' . $_POST['permalink_structure']);
+ $wp_rewrite->set_permalink_structure($permalink_structure);
+ }
+
+ if ( isset($_POST['category_base']) ) {
+ $category_base = $_POST['category_base'];
+ if (! empty($category_base) )
+ $category_base = preg_replace('#/+#', '/', '/' . $_POST['category_base']);
+ $wp_rewrite->set_category_base($category_base);
+ }
+}
+
+$permalink_structure = get_settings('permalink_structure');
+$category_base = get_settings('category_base');
+
+if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') )
+ $writable = true;
+else
+ $writable = false;
+
+if ($wp_rewrite->using_index_permalinks())
+ $usingpi = true;
+else
+ $usingpi = false;
+
+$wp_rewrite->flush_rules();
+?>
+
+<?php if (isset($_POST['submit'])) : ?>
+<div id="message" class="updated fade"><p><?php
+if ($writable)
+ _e('Permalink structure updated.');
+else
+ _e('You should update your .htaccess now.');
+?></p></div>
+<?php endif; ?>
+
+<div class="wrap">
+ <h2><?php _e('Customize Permalink Structure') ?></h2>
+ <p><?php _e('By default WordPress uses web URIs which have question marks and lots of numbers in them, however WordPress offers you the ability to create a custom URI structure for your permalinks and archives. This can improve the aesthetics, usability, and forward-compatibility of your links. A <a href="http://codex.wordpress.org/Using_Permalinks">number of tags are available</a>, and here are some examples to get you started.'); ?></p>
+
+<?php
+$prefix = '';
+
+if ( ! got_mod_rewrite() )
+ $prefix = '/index.php';
+
+$structures = array(
+ '',
+ $prefix . '/%year%/%monthnum%/%day%/%postname%/',
+ $prefix . '/archives/%post_id%'
+ );
+?>
+<form name="form" action="options-permalink.php" method="post">
+<?php wp_nonce_field('update-permalink') ?>
+<h3><?php _e('Common options:'); ?></h3>
+<p>
+ <label>
+<input name="selection" type="radio" value="" class="tog" <?php checked('', $permalink_structure); ?> />
+<?php _e('Default'); ?><br /> <span> &raquo; <code><?php echo get_settings('home'); ?>/?p=123</code></span>
+ </label>
+</p>
+<p>
+ <label>
+<input name="selection" type="radio" value="<?php echo $structures[1]; ?>" class="tog" <?php checked($structures[1], $permalink_structure); ?> />
+<?php _e('Date and name based'); ?><br /> <span> &raquo; <code><?php echo get_settings('home') . $prefix . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/sample-post/'; ?></code></span>
+ </label>
+</p>
+<p>
+ <label>
+<input name="selection" type="radio" value="<?php echo $structures[2]; ?>" class="tog" <?php checked($structures[2], $permalink_structure); ?> />
+<?php _e('Numeric'); ?><br /> <span> &raquo; <code><?php echo get_settings('home') . $prefix ; ?>/archives/123</code></span>
+ </label>
+</p>
+<p>
+<label>
+<input name="selection" id="custom_selection" type="radio" value="custom" class="tog"
+<?php if ( !in_array($permalink_structure, $structures) ) { ?>
+checked="checked"
+<?php } ?>
+ />
+<?php _e('Custom, specify below'); ?>
+</label>
+<br />
+</p>
+<p id="customstructure"><?php _e('Custom structure'); ?>: <input name="permalink_structure" id="permalink_structure" type="text" class="code" style="width: 60%;" value="<?php echo $permalink_structure; ?>" size="50" /></p>
+
+<h3><?php _e('Optional'); ?></h3>
+<?php if ($is_apache) : ?>
+ <p><?php _e('If you like, you may enter a custom prefix for your category URIs here. For example, <code>/taxonomy/tags</code> would make your category links like <code>http://example.org/taxonomy/tags/uncategorized/</code>. If you leave this blank the default will be used.') ?></p>
+<?php else : ?>
+ <p><?php _e('If you like, you may enter a custom prefix for your category URIs here. For example, <code>/index.php/taxonomy/tags</code> would make your category links like <code>http://example.org/index.php/taxonomy/tags/uncategorized/</code>. If you leave this blank the default will be used.') ?></p>
+<?php endif; ?>
+ <p>
+ <?php _e('Category base'); ?>: <input name="category_base" type="text" class="code" value="<?php echo $category_base; ?>" size="30" />
+ </p>
+ <p class="submit">
+ <input type="submit" name="submit" value="<?php _e('Update Permalink Structure &raquo;') ?>" />
+ </p>
+ </form>
+<?php if ( $permalink_structure && !$usingpi && !$writable ) : ?>
+ <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_rewrite->mod_rewrite_rules(); ?>
+</textarea>
+ </p>
+</form>
+<?php endif; ?>
+
+</div>
+
+<?php require('./admin-footer.php'); ?>
diff --git a/wp-admin/options-reading.php b/wp-admin/options-reading.php
new file mode 100644
index 0000000..aa806c9
--- /dev/null
+++ b/wp-admin/options-reading.php
@@ -0,0 +1,95 @@
+<?php
+require_once('admin.php');
+
+$title = __('Reading Options');
+$parent_file = 'options-general.php';
+
+include('admin-header.php');
+?>
+
+<div class="wrap">
+<h2><?php _e('Reading Options') ?></h2>
+<form name="form1" method="post" action="options.php">
+<?php wp_nonce_field('update-options') ?>
+
+<?php if ( get_pages() ): ?>
+<fieldset class="options">
+<legend><?php _e('Front Page') ?></legend>
+<table width="100%" cellspacing="2" cellpadding="5" class="editform">
+<tr valign="top">
+<th width="33%" scope="row"><?php _e('Front page displays:')?></th>
+<td>
+ <label>
+ <input name="show_on_front" type="radio" value="posts" class="tog" <?php checked('posts', get_option('show_on_front')); ?> />
+ <?php _e('The latest posts'); ?>
+ </label>
+ <br />
+ <label>
+ <input name="show_on_front" type="radio" value="page" class="tog" <?php checked('page', get_option('show_on_front')); ?> />
+ <?php printf(__('A static <a href="%s">page</a> (select below)'), 'edit-pages.php'); ?>
+ </label>
+<ul>
+ <li><?php printf(__('Show this page on the front page: %s'), wp_dropdown_pages("name=page_on_front&echo=0&show_option_none=".__('- Select -')."&selected=" . get_option('page_on_front'))); ?></li>
+ <li><?php printf(__('Show the latest posts on this page: %s'), wp_dropdown_pages("name=page_for_posts&echo=0&show_option_none=".__('- Select -')."&selected=" . get_option('page_for_posts'))); ?></li>
+</ul>
+<?php if ( 'page' == get_option('show_on_front') && get_option('page_for_posts') == get_option('page_on_front') ) : ?>
+<div id="front-page-warning" class="updated fade-ff0000">
+ <p>
+ <?php _e('<strong>Warning:</strong> these pages should not be the same!'); ?>
+ </p>
+</div>
+<?php endif; ?>
+</fieldset>
+</td>
+</tr>
+</table>
+</fieldset>
+<?php endif; ?>
+
+<fieldset class="options">
+<legend><?php _e('Blog Pages') ?></legend>
+<table width="100%" cellspacing="2" cellpadding="5" class="editform">
+<tr valign="top">
+<th width="33%" scope="row"><?php _e('Show at most:') ?></th>
+<td>
+<input name="posts_per_page" type="text" id="posts_per_page" value="<?php form_option('posts_per_page'); ?>" size="3" />
+<select name="what_to_show" id="what_to_show" >
+<option value="days" <?php selected('days', get_settings('what_to_show')); ?>><?php _e('days') ?></option>
+<option value="posts" <?php selected('posts', get_settings('what_to_show')); ?>><?php _e('posts') ?></option>
+</select>
+</td>
+</tr>
+</table>
+</fieldset>
+
+<fieldset class="options">
+<legend><?php _e('Syndication Feeds') ?></legend>
+<table width="100%" cellspacing="2" cellpadding="5" class="editform">
+<tr valign="top">
+<th width="33%" scope="row"><?php _e('Show the most recent:') ?></th>
+<td><input name="posts_per_rss" type="text" id="posts_per_rss" value="<?php form_option('posts_per_rss'); ?>" size="3" /> <?php _e('posts') ?></td>
+</tr>
+<tr valign="top">
+<th scope="row"><?php _e('For each article, show:') ?> </th>
+<td>
+<label><input name="rss_use_excerpt" type="radio" value="0" <?php checked(0, get_settings('rss_use_excerpt')); ?> /> <?php _e('Full text') ?></label><br />
+<label><input name="rss_use_excerpt" type="radio" value="1" <?php checked(1, get_settings('rss_use_excerpt')); ?> /> <?php _e('Summary') ?></label>
+</td>
+</tr>
+</table>
+</fieldset>
+<table width="100%" cellspacing="2" cellpadding="5" class="editform">
+<tr valign="top">
+<th width="33%" scope="row"><?php _e('Encoding for pages and feeds:') ?></th>
+<td><input name="blog_charset" type="text" id="blog_charset" value="<?php form_option('blog_charset'); ?>" size="20" class="code" /><br />
+<?php _e('The character encoding you write your blog in (UTF-8 is <a href="http://developer.apple.com/documentation/macos8/TextIntlSvcs/TextEncodingConversionManager/TEC1.5/TEC.b0.html">recommended</a>)') ?></td>
+</tr>
+</table>
+<p class="submit">
+<input type="hidden" name="action" value="update" />
+<input type="hidden" name="page_options" value="posts_per_page,what_to_show,posts_per_rss,rss_use_excerpt,blog_charset,gzipcompression,show_on_front,page_on_front,page_for_posts" />
+<input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
+</p>
+</form>
+</div>
+<?php include('./admin-footer.php'); ?>
diff --git a/wp-admin/options-writing.php b/wp-admin/options-writing.php
new file mode 100644
index 0000000..4f362d3
--- /dev/null
+++ b/wp-admin/options-writing.php
@@ -0,0 +1,66 @@
+<?php
+require_once('admin.php');
+
+$title = __('Writing Options');
+$parent_file = 'options-general.php';
+
+include('admin-header.php');
+?>
+
+<div class="wrap">
+<h2><?php _e('Writing Options') ?></h2>
+<form method="post" action="options.php">
+<?php wp_nonce_field('update-options') ?>
+<table width="100%" cellspacing="2" cellpadding="5" class="editform">
+<tr valign="top">
+<th width="33%" scope="row"> <?php _e('Size of the post box:') ?></th>
+<td><input name="default_post_edit_rows" type="text" id="default_post_edit_rows" value="<?php form_option('default_post_edit_rows'); ?>" size="2" style="width: 1.5em; " />
+<?php _e('lines') ?></td>
+</tr>
+<tr valign="top">
+<th scope="row"><?php _e('Formatting:') ?></th>
+<td>
+<label for="use_smilies">
+<input name="use_smilies" type="checkbox" id="use_smilies" value="1" <?php checked('1', get_settings('use_smilies')); ?> />
+<?php _e('Convert emoticons like <code>:-)</code> and <code>:-P</code> to graphics on display') ?></label><br />
+<label for="use_balanceTags"><input name="use_balanceTags" type="checkbox" id="use_balanceTags" value="1" <?php checked('1', get_settings('use_balanceTags')); ?> /> <?php _e('WordPress should correct invalidly nested XHTML automatically') ?></label>
+</td>
+</tr>
+<tr valign="top">
+<th scope="row"><?php _e('Default post category:') ?></th>
+<td><select name="default_category" id="default_category">
+<?php
+$categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
+foreach ($categories as $category) :
+if ($category->cat_ID == get_settings('default_category')) $selected = " selected='selected'";
+else $selected = '';
+echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>";
+endforeach;
+?>
+</select></td>
+</tr>
+<tr valign="top">
+<th scope="row"><?php _e('Default bookmark category:') ?></th>
+<td><select name="default_link_category" id="default_link_category">
+<?php
+foreach ($categories as $category) :
+if ($category->cat_ID == get_settings('default_link_category')) $selected = " selected='selected'";
+else $selected = '';
+echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>";
+endforeach;
+?>
+</select></td>
+</tr>
+</table>
+
+
+
+<p class="submit">
+<input type="hidden" name="action" value="update" />
+<input type="hidden" name="page_options" value="default_post_edit_rows,use_smilies,default_category,default_email_category,use_balanceTags,default_link_category" />
+<input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
+</p>
+</form>
+</div>
+
+<?php include('./admin-footer.php') ?>
diff --git a/wp-admin/options.php b/wp-admin/options.php
new file mode 100644
index 0000000..f2752b9
--- /dev/null
+++ b/wp-admin/options.php
@@ -0,0 +1,163 @@
+<?php
+require_once('admin.php');
+
+$title = __('Options');
+$this_file = 'options.php';
+$parent_file = 'options-general.php';
+
+$wpvarstoreset = array('action');
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+if ( !current_user_can('manage_options') )
+ die ( __('Cheatin&#8217; uh?') );
+
+if( $_GET[ 'adminhash' ] ) {
+ $new_admin_details = get_option( 'new_admin_email' );
+ if( is_array( $new_admin_details ) && $new_admin_details[ 'hash' ] == $_GET[ 'adminhash' ] && $new_admin_details[ 'newemail' ] != '' ) {
+ update_option( "admin_email", $new_admin_details[ 'newemail' ] );
+ delete_option( "new_admin_email" );
+ }
+ wp_redirect( get_option( "siteurl" ) . "/wp-admin/options-general.php?updated=true" );
+ exit;
+}
+
+switch($action) {
+
+case 'update':
+ $any_changed = 0;
+
+ check_admin_referer('update-options');
+
+ if (!$_POST['page_options']) {
+ foreach ($_POST as $key => $value) {
+ $options[] = $key;
+ }
+ } else {
+ $options = explode(',', stripslashes($_POST['page_options']));
+ }
+
+ // Save for later.
+ $old_siteurl = get_settings('siteurl');
+ $old_home = get_settings('home');
+
+ // HACK
+ // Options that if not there have 0 value but need to be something like "closed"
+ $nonbools = array('default_ping_status', 'default_comment_status');
+ if ($options) {
+ foreach ($options as $option) {
+ $option = trim($option);
+ $value = trim(stripslashes($_POST[$option]));
+ if( in_array($option, $nonbools) && ( $value == '0' || $value == '') )
+ $value = 'closed';
+
+ if( $option == 'blogdescription' || $option == 'blogname' )
+ $value = wp_filter_post_kses( $value );
+
+ if( $option == 'posts_per_page' && $value == '' )
+ $value = 10;
+
+ if( $option == 'new_admin_email' && $value != get_option( 'admin_email' ) ) {
+ $hash = md5( $value.time().mt_rand() );
+ $newadminemail = array(
+ "hash" => $hash,
+ "newemail" => $value
+ );
+ update_option( "new_admin_email", $newadminemail );
+ wp_mail( $value, "[ " . get_option( 'blogname' ) . " ] New Admin Email Address", "Dear User,
+
+You recently requested to have the administration email address on
+your blog changed.
+If this is correct, please click on the following link to change it:
+" . get_option( "siteurl" ) . "/adminemail/{$hash}/
+
+You can safely ignore and delete this email if you do not want to
+take this action.
+
+" );
+ } elseif (update_option($option, $value) ) {
+ $any_changed++;
+ }
+
+ if ( 'language' == $option ) {
+ $value = (int) $value;
+ update_blog_status( $wpdb->blogid, 'lang_id', $value );
+ $any_changed++;
+ }
+ if ( 'blog_public' == $option ) {
+ $value = (int) $value;
+ update_blog_status( $wpdb->blogid, 'public', $value );
+ $any_changed++;
+ }
+ }
+ }
+
+ if ($any_changed) {
+ // If siteurl or home changed, reset cookies.
+ if ( get_settings('siteurl') != $old_siteurl || get_settings('home') != $old_home ) {
+ // If home changed, write rewrite rules to new location.
+ $wp_rewrite->flush_rules();
+ // Clear cookies for old paths.
+ wp_clearcookie();
+ // Set cookies for new paths.
+ wp_setcookie($user_login, $user_pass_md5, true, get_settings('home'), get_settings('siteurl'));
+ }
+
+ //$message = sprintf(__('%d setting(s) saved... '), $any_changed);
+ }
+
+ $referred = remove_query_arg('updated' , $_SERVER['HTTP_REFERER']);
+ $goback = add_query_arg('updated', 'true', $_SERVER['HTTP_REFERER']);
+ $goback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $goback);
+ wp_redirect($goback);
+ break;
+
+default:
+if (!is_site_admin())
+ die('Not admin');
+
+ include('admin-header.php'); ?>
+
+<div class="wrap">
+ <h2><?php _e('All options'); ?></h2>
+ <form name="form" action="options.php" method="post">
+ <?php wp_nonce_field('update-options') ?>
+ <input type="hidden" name="action" value="update" />
+ <table width="98%">
+<?php
+$options = $wpdb->get_results("SELECT * FROM $wpdb->options ORDER BY option_name");
+
+foreach ($options as $option) :
+ $value = wp_specialchars($option->option_value, 'single');
+ echo "
+<tr>
+ <th scope='row'><label for='$option->option_name'>$option->option_name</label></th>
+ <td><input type='text' name='$option->option_name' id='$option->option_name' size='30' value='" . $value . "' /></td>
+ <td>$option->option_description</td>
+</tr>";
+endforeach;
+?>
+ </table>
+<p class="submit"><input type="submit" name="Update" value="<?php _e('Update Settings &raquo;') ?>" /></p>
+ </form>
+</div>
+
+
+<?php
+break;
+} // end switch
+
+include('admin-footer.php');
+?>
diff --git a/wp-admin/page-new.php b/wp-admin/page-new.php
new file mode 100644
index 0000000..4f7fb8f
--- /dev/null
+++ b/wp-admin/page-new.php
@@ -0,0 +1,23 @@
+<?php
+require_once('admin.php');
+$title = __('New Page');
+$parent_file = 'post-new.php';
+$editing = true;
+require_once('admin-header.php');
+?>
+
+<?php if ( isset($_GET['saved']) || isset($_GET['posted']) ) : ?>
+<div id="message" class="updated fade"><p><strong><?php _e('Page saved.') ?> <a href="edit-pages.php"><?php _e('Manage pages'); ?></a> | <a href="<?php echo get_bloginfo('home') . '/'; ?>"><?php _e('View site') ; ?> &raquo;</a></strong></p></div>
+<?php endif; ?>
+
+<?php
+if ( current_user_can('edit_pages') ) {
+ $action = 'post';
+ $post = get_default_post_to_edit();
+ $post->post_type = 'page';
+
+ include('edit-page-form.php');
+}
+?>
+
+<?php include('admin-footer.php'); ?>
diff --git a/wp-admin/page.php b/wp-admin/page.php
new file mode 100644
index 0000000..cd4d5cc
--- /dev/null
+++ b/wp-admin/page.php
@@ -0,0 +1,159 @@
+<?php
+require_once('admin.php');
+
+$parent_file = 'edit.php';
+$submenu_file = 'edit-pages.php';
+
+$wp_rewrite->flush_rules();
+
+$wpvarstoreset = array('action');
+
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+if (isset($_POST['deletepost'])) {
+$action = "delete";
+}
+
+switch($action) {
+case 'post':
+ check_admin_referer('add-page');
+ $page_ID = write_post();
+
+ // Redirect.
+ if (!empty($_POST['mode'])) {
+ switch($_POST['mode']) {
+ case 'bookmarklet':
+ $location = $_POST['referredby'];
+ break;
+ case 'sidebar':
+ $location = 'sidebar.php?a=b';
+ break;
+ default:
+ $location = 'page-new.php';
+ break;
+ }
+ } else {
+ $location = 'page-new.php?posted=true';
+ }
+
+ if ( isset($_POST['save']) )
+ $location = "page.php?action=edit&post=$page_ID";
+
+ header("Location: $location");
+ exit();
+ break;
+
+case 'edit':
+ $title = __('Edit');
+ $editing = true;
+
+ $page_ID = $post_ID = $p = (int) $_GET['post'];
+ $post = get_post($page_ID);
+ if( $post->post_type == 'post' ) {
+ header( "Location: " . str_replace( "page.php", "post.php", $_SERVER[ 'REQUEST_URI' ] ) );
+ die();
+ }
+ require_once('admin-header.php');
+
+ if ( !current_user_can('edit_page', $page_ID) )
+ die ( __('You are not allowed to edit this page.') );
+
+ $post = get_post_to_edit($page_ID);
+
+ include('edit-page-form.php');
+ ?>
+ <div id='preview' class='wrap'>
+ <h2 id="preview-post"><?php _e('Page Preview (updated when page is saved)'); ?> <small class="quickjump"><a href="#write-post"><?php _e('edit &uarr;'); ?></a></small></h2>
+ <iframe src="<?php echo add_query_arg('preview', 'true', get_permalink($post->ID)); ?>" width="100%" height="600" ></iframe>
+ </div>
+ <?php
+ break;
+
+case 'editattachment':
+ $page_id = $post_ID = (int) $_POST['post_ID'];
+ check_admin_referer('update-attachment_' . $page_id);
+
+ // Don't let these be changed
+ unset($_POST['guid']);
+ $_POST['post_type'] = 'attachment';
+
+ // Update the thumbnail filename
+ $oldmeta = $newmeta = get_post_meta($page_id, '_wp_attachment_metadata', true);
+ $newmeta['thumb'] = $_POST['thumb'];
+
+ if ( '' !== $oldmeta )
+ update_post_meta($page_id, '_wp_attachment_metadata', $newmeta, $oldmeta);
+ else
+ add_post_meta($page_id, '_wp_attachment_metadata', $newmeta);
+
+case 'editpost':
+ $page_ID = (int) $_POST['post_ID'];
+ check_admin_referer('update-page_' . $page_ID);
+
+ $page_ID = edit_post();
+
+ if ($_POST['save']) {
+ $location = $_SERVER['HTTP_REFERER'];
+ } elseif ($_POST['updatemeta']) {
+ $location = $_SERVER['HTTP_REFERER'] . '&message=2#postcustom';
+ } elseif ($_POST['deletemeta']) {
+ $location = $_SERVER['HTTP_REFERER'] . '&message=3#postcustom';
+ } elseif (isset($_POST['referredby']) && $_POST['referredby'] != $_SERVER['HTTP_REFERER']) {
+ $location = $_POST['referredby'];
+ if ( $_POST['referredby'] == 'redo' )
+ $location = get_permalink( $page_ID );
+ } elseif ($action == 'editattachment') {
+ $location = 'attachments.php';
+ } else {
+ $location = 'page-new.php';
+ }
+ header ('Location: ' . $location); // Send user on their way while we keep working
+
+ exit();
+ break;
+
+case 'delete':
+ $page_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']);
+ check_admin_referer('delete-page_' . $page_id);
+
+ $page = & get_post($page_id);
+
+ if ( !current_user_can('delete_page', $page_id) )
+ die( __('You are not allowed to delete this page.') );
+
+ if ( $page->post_type == 'attachment' ) {
+ if ( ! wp_delete_attachment($page_id) )
+ die( __('Error in deleting...') );
+ } else {
+ if ( !wp_delete_post($page_id) )
+ die( __('Error in deleting...') );
+ }
+
+ $sendback = $_SERVER['HTTP_REFERER'];
+ if (strstr($sendback, 'page.php')) $sendback = get_settings('siteurl') .'/wp-admin/page.php';
+ elseif (strstr($sendback, 'attachments.php')) $sendback = get_settings('siteurl') .'/wp-admin/attachments.php';
+ $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
+ header ('Location: ' . $sendback);
+ exit();
+ break;
+
+default:
+ header('Location: edit-pages.php');
+ exit();
+ break;
+} // end switch
+include('admin-footer.php');
+?>
diff --git a/wp-admin/plugin-editor.php b/wp-admin/plugin-editor.php
new file mode 100644
index 0000000..56bab5a
--- /dev/null
+++ b/wp-admin/plugin-editor.php
@@ -0,0 +1,127 @@
+<?php
+die();
+require_once('admin.php');
+
+$title = __("Edit Plugins");
+$parent_file = 'plugins.php';
+
+$wpvarstoreset = array('action','redirect','profile','error','warning','a','file');
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+$plugins = get_plugins();
+$plugin_files = array_keys($plugins);
+
+if (empty($file)) {
+ $file = $plugin_files[0];
+}
+
+$file = validate_file_to_edit($file, $plugin_files);
+$real_file = get_real_file_to_edit("wp-content/plugins/$file");
+
+switch($action) {
+
+case 'update':
+
+ check_admin_referer('edit-plugin_' . $file);
+
+ if ( !current_user_can('edit_plugins') )
+ die('<p>'.__('You have do not have sufficient permissions to edit templates for this blog.').'</p>');
+
+ $newcontent = stripslashes($_POST['newcontent']);
+ if (is_writeable($real_file)) {
+ $f = fopen($real_file, 'w+');
+ fwrite($f, $newcontent);
+ fclose($f);
+ header("Location: plugin-editor.php?file=$file&a=te");
+ } else {
+ header("Location: plugin-editor.php?file=$file");
+ }
+
+ exit();
+
+break;
+
+default:
+
+ require_once('admin-header.php');
+ if ( !current_user_can('edit_plugins') )
+ die('<p>'.__('You have do not have sufficient permissions to edit plugins for this blog.').'</p>');
+
+ update_recently_edited("wp-content/plugins/$file");
+
+ if (!is_file($real_file))
+ $error = 1;
+
+ if (!$error) {
+ $f = fopen($real_file, 'r');
+ $content = fread($f, filesize($real_file));
+ $content = htmlspecialchars($content);
+ }
+
+ ?>
+<?php if (isset($_GET['a'])) : ?>
+ <div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div>
+<?php endif; ?>
+ <div class="wrap">
+ <?php
+ if (is_writeable($real_file)) {
+ echo '<h2>' . sprintf(__('Editing <strong>%s</strong>'), $file) . '</h2>';
+ } else {
+ echo '<h2>' . sprintf(__('Browsing <strong>%s</strong>'), $file) . '</h2>';
+ }
+ ?>
+ <div id="templateside">
+<h3><?php _e('Plugin files') ?></h3>
+
+<?php
+if ($plugin_files) :
+?>
+ <ul>
+<?php foreach($plugin_files as $plugin_file) : ?>
+ <li><a href="plugin-editor.php?file=<?php echo "$plugin_file"; ?>"><?php echo $plugins[$plugin_file]['Name']; ?></a></li>
+<?php endforeach; ?>
+ </ul>
+<?php endif; ?>
+</div>
+ <?php if (!$error) { ?>
+ <form name="template" id="template" action="plugin-editor.php" method="post">
+ <?php wp_nonce_field('edit-plugin_' . $file) ?>
+ <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea>
+ <input type="hidden" name="action" value="update" />
+ <input type="hidden" name="file" value="<?php echo $file ?>" />
+ </div>
+<?php if ( is_writeable($real_file) ) : ?>
+ <p class="submit">
+<?php
+ echo "<input type='submit' name='submit' value=' " . __('Update File &raquo;') . "' tabindex='2' />";
+?>
+</p>
+<?php else : ?>
+<p><em><?php _e('If this file were writable you could edit it.'); ?></em></p>
+<?php endif; ?>
+ </form>
+ <?php
+ } else {
+ echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>';
+ }
+ ?>
+<div class="clear"> &nbsp; </div>
+</div>
+<?php
+break;
+}
+
+include("admin-footer.php") ?>
diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php
new file mode 100644
index 0000000..e289e59
--- /dev/null
+++ b/wp-admin/plugins.php
@@ -0,0 +1,142 @@
+<?php
+require_once('admin.php');
+
+$menu_perms = get_site_option( "menu_items" );
+if( is_array( $menu_perms ) == false )
+ $menu_perms = array();
+
+if( $menu_perms[ 'plugins' ] != 1 )
+ return;
+
+if ( isset($_GET['action']) ) {
+ if ('activate' == $_GET['action']) {
+ check_admin_referer('activate-plugin_' . $_GET['plugin']);
+ $current = get_settings('active_plugins');
+ if (!in_array($_GET['plugin'], $current)) {
+ $current[] = trim( $_GET['plugin'] );
+ sort($current);
+ update_option('active_plugins', $current);
+ include(ABSPATH . 'wp-content/plugins/' . trim( $_GET['plugin'] ));
+ do_action('activate_' . trim( $_GET['plugin'] ));
+ }
+ header('Location: plugins.php?activate=true');
+ } else if ('deactivate' == $_GET['action']) {
+ check_admin_referer('deactivate-plugin_' . $_GET['plugin']);
+ $current = get_settings('active_plugins');
+ array_splice($current, array_search( $_GET['plugin'], $current), 1 ); // Array-fu!
+ update_option('active_plugins', $current);
+ do_action('deactivate_' . trim( $_GET['plugin'] ));
+ header('Location: plugins.php?deactivate=true');
+ }
+ exit;
+}
+
+$title = __('Manage Plugins');
+require_once('admin-header.php');
+
+// Clean up options
+// If any plugins don't exist, axe 'em
+
+$check_plugins = get_settings('active_plugins');
+
+// Sanity check. If the active plugin list is not an array, make it an
+// empty array.
+if ( !is_array($check_plugins) ) {
+ $check_plugins = array();
+ update_option('active_plugins', $check_plugins);
+}
+
+// If a plugin file does not exist, remove it from the list of active
+// plugins.
+foreach ($check_plugins as $check_plugin) {
+ if (!file_exists(ABSPATH . 'wp-content/plugins/' . $check_plugin)) {
+ $current = get_settings('active_plugins');
+ $key = array_search($check_plugin, $current);
+ if ( false !== $key && NULL !== $key ) {
+ unset($current[$key]);
+ update_option('active_plugins', $current);
+ }
+ }
+}
+?>
+
+<?php if (isset($_GET['activate'])) : ?>
+<div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p>
+</div>
+<?php endif; ?>
+<?php if (isset($_GET['deactivate'])) : ?>
+<div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p>
+</div>
+<?php endif; ?>
+
+<div class="wrap">
+<h2><?php _e('Plugin Management'); ?></h2>
+<p><?php _e('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.'); ?></p>
+<?php
+
+if ( get_settings('active_plugins') )
+ $current_plugins = get_settings('active_plugins');
+
+$plugins = get_plugins();
+
+if (empty($plugins)) {
+ echo '<p>';
+ _e("Couldn't open plugins directory or there are no plugins available."); // TODO: make more helpful
+ echo '</p>';
+} else {
+?>
+<table class="widefat">
+ <thead>
+ <tr>
+ <th style="text-align: left"><?php _e('Plugin'); ?></th>
+ <th><?php _e('Version'); ?></th>
+ <th style="text-align: left"><?php _e('Description'); ?></th>
+ <th><?php _e('Action'); ?></th>
+ </tr>
+ </thead>
+<?php
+ $style = '';
+
+ function sort_plugins($plug1, $plug2) {
+ return strnatcasecmp($plug1['Name'], $plug2['Name']);
+ }
+
+ uksort($plugins, 'sort_plugins');
+
+ foreach($plugins as $plugin_file => $plugin_data) {
+ $style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate';
+
+ if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) {
+ $action = "<a href='" . wp_nonce_url("plugins.php?action=deactivate&amp;plugin=$plugin_file", 'deactivate-plugin_' . $plugin_file) . "' title='".__('Deactivate this plugin')."' class='delete'>".__('Deactivate')."</a>";
+ $plugin_data['Title'] = "<strong>{$plugin_data['Title']}</strong>";
+ $style .= $style == 'alternate' ? ' active' : 'active';
+ } else {
+ $action = "<a href='" . wp_nonce_url("plugins.php?action=activate&amp;plugin=$plugin_file", 'activate-plugin_' . $plugin_file) . "' title='".__('Activate this plugin')."' class='edit'>".__('Activate')."</a>";
+ }
+ $plugin_data['Description'] = wp_kses($plugin_data['Description'], array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()) ); ;
+ if ($style != '') $style = 'class="' . $style . '"';
+ echo "
+ <tr $style>
+ <td class='name'>{$plugin_data['Title']}</td>
+ <td class='vers'>{$plugin_data['Version']}</td>
+ <td class='desc'>{$plugin_data['Description']} <cite>".sprintf(__('By %s'), $plugin_data['Author']).".</cite></td>
+ <td class='togl'>$action</td>
+ </tr>";
+ }
+?>
+
+</table>
+<?php
+}
+?>
+
+<p><?php _e('If something goes wrong with a plugin and you can&#8217;t use WordPress, delete or rename that file in the <code>wp-content/plugins</code> directory and it will be automatically deactivated.'); ?></p>
+
+<h2><?php _e('Get More Plugins'); ?></h2>
+<p><?php _e('You can find additional plugins for your site in the <a href="http://wordpress.org/extend/plugins/">WordPress plugin directory</a>. To install a plugin you generally just need to upload the plugin file into your <code>wp-content/plugins</code> directory. Once a plugin is uploaded, you may activate it here.'); ?></p>
+
+</div>
+
+<?php
+include('admin-footer.php');
+?>
diff --git a/wp-admin/post-new.php b/wp-admin/post-new.php
new file mode 100644
index 0000000..d0f9844
--- /dev/null
+++ b/wp-admin/post-new.php
@@ -0,0 +1,94 @@
+<?php
+require_once('admin.php');
+$title = __('Create New Post');
+$parent_file = 'post-new.php';
+$editing = true;
+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 />
+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_settings('admin_email')); ?>
+</p>
+</div>
+<?php
+ include('admin-footer.php');
+ exit();
+}
+
+if ( isset($_GET['posted']) ) : ?>
+<div id="message" class="updated fade"><p><?php printf(__('Post saved. <a href="%s">View site &raquo;</a>'), get_bloginfo('home') . '/'); ?></p></div>
+<?php
+endif;
+
+if ( $drafts = get_users_drafts( $user_ID ) ) { ?>
+<div class="wrap">
+<p><strong><?php _e('Your Drafts:') ?></strong>
+<?php
+// Show drafts.
+ $num_drafts = count($drafts);
+ if ( $num_drafts > 15 ) $num_drafts = 15;
+ for ( $i = 0; $i < $num_drafts; $i++ ) {
+ $draft = $drafts[$i];
+ if ( 0 != $i )
+ echo ', ';
+ if ( empty($draft->post_title) )
+ $draft->post_title = sprintf(__('Post # %s'), $draft->ID);
+ echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
+ }
+
+ if ( 15 < count($drafts) ) { ?>
+ , <a href="edit.php"><?php echo sprintf(__('and %s more'), (count($drafts) - 15) ); ?> &raquo;</a>
+ <?php } ?>
+.</p>
+</div>
+<?php
+}
+
+// Show post form.
+$post = get_default_post_to_edit();
+include('edit-form-advanced.php');
+?>
+
+<?php if ( $is_NS4 || $is_gecko || $is_winIE ) { ?>
+<div 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
+if ($is_NS4 || $is_gecko) {
+?>
+<a href="javascript:if(navigator.userAgent.indexOf('Safari') >= 0){Q=getSelection();}else{Q=document.selection?document.selection.createRange().text:document.getSelection();}location.href='<?php echo get_settings('siteurl') ?>/wp-admin/post-new.php?text='+encodeURIComponent(Q)+'&amp;popupurl='+encodeURIComponent(location.href)+'&amp;popuptitle='+encodeURIComponent(document.title);"><?php printf(__('Press It - %s'), wp_specialchars(get_settings('blogname'))); ?></a>
+<?php
+} else if ($is_winIE) {
+?>
+<a href="javascript:Q='';if(top.frames.length==0)Q=document.selection.createRange().text;location.href='<?php echo get_settings('siteurl') ?>/wp-admin/post-new.php?text='+encodeURIComponent(Q)+'&amp;popupurl='+encodeURIComponent(location.href)+'&amp;popuptitle='+encodeURIComponent(document.title);"><?php printf(__('Press it - %s'), get_settings('blogname')); ?></a>
+<script type="text/javascript">
+<!--
+function oneclickbookmarklet(blah) {
+window.open ("profile.php?action=IErightclick", "oneclickbookmarklet", "width=500, height=450, location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=120, left=120, screenY=120, top=120");
+}
+// -->
+</script>
+<br />
+<br />
+<?php _e('One-click bookmarklet:') ?><br />
+<a href="javascript:oneclickbookmarklet(0);"><?php _e('click here') ?></a>
+<?php
+} else if ($is_opera) {
+?>
+<a href="javascript:location.href='<?php echo get_settings('siteurl'); ?>/wp-admin/post-new.php?popupurl='+escape(location.href)+'&popuptitle='+escape(document.title);"><?php printf(__('Press it - %s'), get_settings('blogname')); ?></a>
+<?php
+} else if ($is_macIE) {
+?>
+<a href="javascript:Q='';location.href='<?php echo get_settings('siteurl'); ?>/wp-admin/bookmarklet.php?text='+escape(document.getSelection())+'&popupurl='+escape(location.href)+'&popuptitle='+escape(document.title);"><?php printf(__('Press it - %s'), get_settings('blogname')); ?></a>
+<?php
+}
+?>
+</p>
+</div>
+<?php } ?>
+
+<?php include('admin-footer.php'); ?>
diff --git a/wp-admin/post.php b/wp-admin/post.php
new file mode 100644
index 0000000..aad14e9
--- /dev/null
+++ b/wp-admin/post.php
@@ -0,0 +1,161 @@
+<?php
+require_once('admin.php');
+
+$parent_file = 'edit.php';
+$submenu_file = 'edit.php';
+$wpvarstoreset = array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder' );
+
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+if ( isset( $_POST['deletepost'] ) )
+ $action = 'delete';
+
+switch($action) {
+case 'postajaxpost':
+case 'post':
+ $parent_file = 'post-new.php';
+ $submenu_file = 'post-new.php';
+ check_admin_referer('add-post');
+
+ $post_ID = 'post' == $action ? write_post() : edit_post();
+
+ // Redirect.
+ if (!empty($_POST['mode'])) {
+ switch($_POST['mode']) {
+ case 'bookmarklet':
+ $location = $_POST['referredby'];
+ break;
+ case 'sidebar':
+ $location = 'sidebar.php?a=b';
+ break;
+ default:
+ $location = 'post-new.php';
+ break;
+ }
+ } else {
+ $location = 'post-new.php?posted=true';
+ }
+
+ if ( isset($_POST['save']) )
+ $location = "post.php?action=edit&post=$post_ID";
+
+ header("Location: $location");
+ exit();
+ break;
+
+case 'edit':
+ $title = __('Edit');
+ $editing = true;
+
+ $post_ID = $p = (int) $_GET['post'];
+
+ $post = get_post($post_ID);
+ if( $post->post_type == 'page' ) {
+ header( "Location: " . str_replace( "post.php", "page.php", $_SERVER[ 'REQUEST_URI' ] ) );
+ die();
+ }
+ require_once('admin-header.php');
+ if ( !current_user_can('edit_post', $post_ID) )
+ die ( __('You are not allowed to edit this post.') );
+
+ $post = get_post_to_edit($post_ID);
+
+ include('edit-form-advanced.php');
+
+ ?>
+ <div id='preview' class='wrap'>
+ <h2 id="preview-post"><?php _e('Post Preview (updated when post is saved)'); ?> <small class="quickjump"><a href="#write-post"><?php _e('edit &uarr;'); ?></a></small></h2>
+ <iframe src="<?php echo add_query_arg('preview', 'true', get_permalink($post->ID)); ?>" width="100%" height="600" ></iframe>
+ </div>
+ <?php
+ break;
+
+case 'editattachment':
+ $post_id = (int) $_POST['post_ID'];
+
+ check_admin_referer('update-attachment_' . $post_id);
+
+ // Don't let these be changed
+ unset($_POST['guid']);
+ $_POST['post_type'] = 'attachment';
+
+ // Update the thumbnail filename
+ $oldmeta = $newmeta = get_post_meta($post_id, '_wp_attachment_metadata', true);
+ $newmeta['thumb'] = $_POST['thumb'];
+
+ if ( '' !== $oldmeta )
+ update_post_meta($post_id, '_wp_attachment_metadata', $newmeta, $oldmeta);
+ else
+ add_post_meta($post_id, '_wp_attachment_metadata', $newmeta);
+
+case 'editpost':
+ $post_ID = (int) $_POST['post_ID'];
+ check_admin_referer('update-post_' . $post_ID);
+
+ $post_ID = edit_post();
+
+ if ($_POST['save']) {
+ $location = $_SERVER['HTTP_REFERER'];
+ } elseif ($_POST['updatemeta']) {
+ $location = $_SERVER['HTTP_REFERER'] . '&message=2#postcustom';
+ } elseif ($_POST['deletemeta']) {
+ $location = $_SERVER['HTTP_REFERER'] . '&message=3#postcustom';
+ } elseif (isset($_POST['referredby']) && $_POST['referredby'] != $_SERVER['HTTP_REFERER']) {
+ $location = $_POST['referredby'];
+ if ( $_POST['referredby'] == 'redo' )
+ $location = get_permalink( $post_ID );
+ } elseif ($action == 'editattachment') {
+ $location = 'attachments.php';
+ } else {
+ $location = 'post-new.php';
+ }
+ header ('Location: ' . $location); // Send user on their way while we keep working
+
+ exit();
+ break;
+
+case 'delete':
+ $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']);
+ check_admin_referer('delete-post_' . $post_id);
+
+ $post = & get_post($post_id);
+
+ if ( !current_user_can('delete_post', $post_id) )
+ die( __('You are not allowed to delete this post.') );
+
+ if ( $post->post_type == 'attachment' ) {
+ if ( ! wp_delete_attachment($post_id) )
+ die( __('Error in deleting...') );
+ } else {
+ if ( !wp_delete_post($post_id) )
+ die( __('Error in deleting...') );
+ }
+
+ $sendback = $_SERVER['HTTP_REFERER'];
+ if (strstr($sendback, 'post.php')) $sendback = get_settings('siteurl') .'/wp-admin/post-new.php';
+ elseif (strstr($sendback, 'attachments.php')) $sendback = get_settings('siteurl') .'/wp-admin/attachments.php';
+ $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
+ header ('Location: ' . $sendback);
+ exit();
+ break;
+
+default:
+ header('Location: edit.php');
+ exit();
+ break;
+} // end switch
+include('admin-footer.php');
+?>
diff --git a/wp-admin/profile-update.php b/wp-admin/profile-update.php
new file mode 100644
index 0000000..4d6595b
--- /dev/null
+++ b/wp-admin/profile-update.php
@@ -0,0 +1,34 @@
+<?php
+
+$parent_file = 'profile.php';
+$submenu_file = 'profile.php';
+require_once('admin.php');
+
+check_admin_referer('update-profile_' . $user_ID);
+
+if ( !$_POST )
+ die( __('No post?') );
+
+$errors = edit_user($user_ID);
+
+if ( is_wp_error( $errors ) ) {
+ foreach( $errors->get_error_messages() as $message )
+ echo "$message<br />";
+ exit;
+}
+
+if ( !isset( $_POST['rich_editing'] ) )
+ $_POST['rich_editing'] = 'false';
+update_user_option( $current_user->id, 'rich_editing', $_POST['rich_editing'], true );
+
+do_action('personal_options_update');
+
+if ( 'profile' == $_POST['from'] )
+ $to = 'profile.php?updated=true';
+else
+ $to = 'profile.php?updated=true';
+
+wp_redirect( $to );
+exit;
+
+?>
diff --git a/wp-admin/profile.php b/wp-admin/profile.php
new file mode 100644
index 0000000..eb66e07
--- /dev/null
+++ b/wp-admin/profile.php
@@ -0,0 +1,148 @@
+<?php
+require_once('admin.php');
+
+$title = __('Profile');
+
+if ( current_user_can('edit_users') )
+ $parent_file = 'users.php';
+else
+ $parent_file = 'profile.php';
+include_once('admin-header.php');
+$profileuser = new WP_User($user_ID);
+
+$bookmarklet_height= 440;
+?>
+
+<?php if ( isset($_GET['updated']) ) { ?>
+<div id="message" class="updated fade">
+<p><strong><?php _e('Profile updated.') ?></strong></p>
+</div>
+<?php } ?>
+
+<div class="wrap">
+<h2><?php _e('Your Profile and Personal Options'); ?></h2>
+<form name="profile" id="your-profile" action="profile-update.php" method="post">
+<?php wp_nonce_field('update-profile_' . $user_ID) ?>
+<p>
+<input type="hidden" name="from" value="profile" />
+<input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" />
+</p>
+
+<fieldset>
+<legend><?php _e('Name'); ?></legend>
+<p><label><?php _e('Username: (no editing)'); ?><br />
+<input type="text" name="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" />
+</label></p>
+
+<p><label><?php _e('First name:') ?><br />
+<input type="text" name="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>
+
+<p><label><?php _e('Nickname:') ?><br />
+<input type="text" name="nickname" value="<?php echo $profileuser->nickname ?>" /></label></p>
+
+<p><label><?php _e('Display name publicly as:') ?> <br />
+<select name="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>
+<?php if ( !empty( $profileuser->first_name ) ) : ?>
+<option value="<?php echo $profileuser->first_name ?>"><?php echo $profileuser->first_name ?></option>
+<?php endif; ?>
+<?php if ( !empty( $profileuser->last_name ) ) : ?>
+<option value="<?php echo $profileuser->last_name ?>"><?php echo $profileuser->last_name ?></option>
+<?php endif; ?>
+<?php if ( !empty( $profileuser->first_name ) && !empty( $profileuser->last_name ) ) : ?>
+<option value="<?php echo $profileuser->first_name." ".$profileuser->last_name ?>"><?php echo $profileuser->first_name." ".$profileuser->last_name ?></option>
+<option value="<?php echo $profileuser->last_name." ".$profileuser->first_name ?>"><?php echo $profileuser->last_name." ".$profileuser->first_name ?></option>
+<?php endif; ?>
+</select></label></p>
+</fieldset>
+
+<fieldset>
+<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>
+
+<p><label><?php _e('Website:') ?><br />
+<input type="text" name="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 ?>" />
+</label></p>
+
+<p><label><?php _e('Yahoo IM:') ?><br />
+<input type="text" name="yim" value="<?php echo $profileuser->yim ?>" />
+</label></p>
+
+<p><label><?php _e('Jabber / Google Talk:') ?>
+<input type="text" name="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 to fill out your profile. This may be shown publicly.'); ?></p>
+<p><textarea name="description" rows="5" cols="30"><?php echo $profileuser->description ?></textarea></p>
+</fieldset>
+
+<?php
+$show_password_fields = apply_filters('show_password_fields', true);
+if ( $show_password_fields ) :
+?>
+<fieldset>
+<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="" />
+</label></p>
+<p><label><?php _e('Type it one more time:'); ?><br />
+<input type="password" name="pass2" size="16" value="" />
+</label></p>
+</fieldset>
+<?php endif; ?>
+
+<?php do_action('show_user_profile'); ?>
+
+<br clear="all" />
+
+<h3><?php _e('Personal Options'); ?></h3>
+
+<p><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="true" <?php checked('true', get_user_option('rich_editing')); ?> />
+<?php _e('Use the visual rich editor when writing') ?></label></p>
+
+<?php do_action('profile_personal_options'); ?>
+
+ <table width="99%" border="0" cellspacing="2" cellpadding="3" class="editform">
+ <?php
+ if(count($profileuser->caps) > count($profileuser->roles)):
+ ?>
+ <tr>
+ <th scope="row"><?php _e('Additional Capabilities:') ?></th>
+ <td><?php
+ $output = '';
+ foreach($profileuser->caps as $cap => $value) {
+ if(!$wp_roles->is_role($cap)) {
+ if($output != '') $output .= ', ';
+ $output .= $value ? $cap : "Denied: {$cap}";
+ }
+ }
+ echo $output;
+ ?></td>
+ </tr>
+ <?php
+ endif;
+ ?>
+ </table>
+<p class="submit">
+<input type="submit" value="<?php _e('Update Profile &raquo;') ?>" name="submit" />
+</p>
+</form>
+
+</div>
+
+<?php include('admin-footer.php'); ?>
diff --git a/wp-admin/setup-config.php b/wp-admin/setup-config.php
new file mode 100644
index 0000000..d25c58b
--- /dev/null
+++ b/wp-admin/setup-config.php
@@ -0,0 +1,189 @@
+<?php
+die();
+define('WP_INSTALLING', true);
+
+if (!file_exists('../wp-config-sample.php'))
+ die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.');
+
+$configFile = file('../wp-config-sample.php');
+
+if (!is_writable('../')) die("Sorry, I can't write to the directory. You'll have to either change the permissions on your WordPress directory or create your wp-config.php manually.");
+
+
+if (isset($_GET['step']))
+ $step = $_GET['step'];
+else
+ $step = 0;
+header( 'Content-Type: text/html; charset=utf-8' );
+?>
+<!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">
+<head>
+<title>WordPress &rsaquo; Setup Configuration File</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<style media="screen" type="text/css">
+ <!--
+ html {
+ background: #eee;
+ }
+ body {
+ background: #fff;
+ color: #000;
+ font-family: Georgia, "Times New Roman", Times, serif;
+ margin-left: 20%;
+ margin-right: 20%;
+ padding: .2em 2em;
+ }
+
+ h1 {
+ color: #006;
+ font-size: 18px;
+ font-weight: lighter;
+ }
+
+ h2 {
+ font-size: 16px;
+ }
+
+ p, li, dt {
+ line-height: 140%;
+ padding-bottom: 2px;
+ }
+
+ ul, ol {
+ padding: 5px 5px 5px 20px;
+ }
+ #logo {
+ margin-bottom: 2em;
+ }
+ .step a, .step input {
+ font-size: 2em;
+ }
+ td input {
+ font-size: 1.5em;
+ }
+ .step, th {
+ text-align: right;
+ }
+ #footer {
+ text-align: center;
+ border-top: 1px solid #ccc;
+ padding-top: 1em;
+ font-style: italic;
+ }
+ -->
+ </style>
+</head>
+<body>
+<h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1>
+<?php
+// Check if wp-config.php has been created
+if (file_exists('../wp-config.php'))
+ die("<p>The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>.</p></body></html>");
+
+switch($step) {
+ case 0:
+?>
+
+<p>Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.</p>
+<ol>
+ <li>Database name</li>
+ <li>Database username</li>
+ <li>Database password</li>
+ <li>Database host</li>
+ <li>Table prefix (if you want to run more than one WordPress in a single database) </li>
+</ol>
+<p><strong>If for any reason this automatic file creation doesn't work, don't worry. All this does is fill in the database information to a configuration file. You may also simply open <code>wp-config-sample.php</code> in a text editor, fill in your information, and save it as <code>wp-config.php</code>. </strong></p>
+<p>In all likelihood, these items were supplied to you by your ISP. If you do not have this information, then you will need to contact them before you can continue. If you&#8217;re all ready, <a href="setup-config.php?step=1">let&#8217;s go</a>! </p>
+<?php
+ break;
+
+ case 1:
+ ?>
+</p>
+<form method="post" action="setup-config.php?step=2">
+ <p>Below you should enter your database connection details. If you're not sure about these, contact your host. </p>
+ <table>
+ <tr>
+ <th scope="row">Database Name</th>
+ <td><input name="dbname" type="text" size="25" value="wordpress" /></td>
+ <td>The name of the database you want to run WP in. </td>
+ </tr>
+ <tr>
+ <th scope="row">User Name</th>
+ <td><input name="uname" type="text" size="25" value="username" /></td>
+ <td>Your MySQL username</td>
+ </tr>
+ <tr>
+ <th scope="row">Password</th>
+ <td><input name="pwd" type="text" size="25" value="password" /></td>
+ <td>...and MySQL password.</td>
+ </tr>
+ <tr>
+ <th scope="row">Database Host</th>
+ <td><input name="dbhost" type="text" size="25" value="localhost" /></td>
+ <td>99% chance you won't need to change this value.</td>
+ </tr>
+ <tr>
+ <th scope="row">Table Prefix</th>
+ <td><input name="prefix" type="text" id="prefix" value="wp_" size="25" /></td>
+ <td>If you want to run multiple WordPress installations in a single database, change this.</td>
+ </tr>
+ </table>
+ <h2 class="step">
+ <input name="submit" type="submit" value="Submit" />
+ </h2>
+</form>
+<?php
+ break;
+
+ case 2:
+ $dbname = trim($_POST['dbname']);
+ $uname = trim($_POST['uname']);
+ $passwrd = trim($_POST['pwd']);
+ $dbhost = trim($_POST['dbhost']);
+ $prefix = trim($_POST['prefix']);
+ if (empty($prefix)) $prefix = 'wp_';
+
+ // Test the db connection.
+ define('DB_NAME', $dbname);
+ define('DB_USER', $uname);
+ define('DB_PASSWORD', $passwrd);
+ define('DB_HOST', $dbhost);
+
+ // We'll fail here if the values are no good.
+ require_once('../wp-includes/wp-db.php');
+ $handle = fopen('../wp-config.php', 'w');
+
+ foreach ($configFile as $line_num => $line) {
+ switch (substr($line,0,16)) {
+ case "define('DB_NAME'":
+ fwrite($handle, str_replace("wordpress", $dbname, $line));
+ break;
+ case "define('DB_USER'":
+ fwrite($handle, str_replace("'username'", "'$uname'", $line));
+ break;
+ case "define('DB_PASSW":
+ fwrite($handle, str_replace("'password'", "'$passwrd'", $line));
+ break;
+ case "define('DB_HOST'":
+ fwrite($handle, str_replace("localhost", $dbhost, $line));
+ break;
+ case '$table_prefix =':
+ fwrite($handle, str_replace('wp_', $prefix, $line));
+ break;
+ default:
+ fwrite($handle, $line);
+ }
+ }
+ fclose($handle);
+ chmod('../wp-config.php', 0666);
+?>
+<p>All right sparky! You've made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to <a href="install.php">run the install!</a></p>
+<?php
+ break;
+}
+?>
+<p id="footer"><a href="http://wordpress.org/">WordPress</a>, personal publishing platform.</p>
+</body>
+</html>
diff --git a/wp-admin/sidebar.php b/wp-admin/sidebar.php
new file mode 100644
index 0000000..140bd36
--- /dev/null
+++ b/wp-admin/sidebar.php
@@ -0,0 +1,80 @@
+<?php
+$mode = 'sidebar';
+
+require_once('admin.php');
+
+if ( ! current_user_can('edit_posts') )
+ die ("Cheatin' uh ?");
+
+if ('b' == $_GET['a']) {
+
+?><!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">
+<head>
+<title>WordPress &#8250; Posted</title>
+<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=UTF-8" />
+<link rel="stylesheet" href="wp-admin.css" type="text/css" />
+</head>
+<body>
+ <p>Posted !</p>
+ <p><a href="sidebar.php">Click here</a> to post again.</p>
+</body>
+</html><?php
+
+} else {
+
+?><!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">
+<head>
+<title>WordPress &#8250; Sidebar</title>
+<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('blog_charset'); ?>" />
+<link rel="stylesheet" href="wp-admin.css" type="text/css" />
+<style type="text/css" media="screen">
+form {
+ padding: 3px;
+}
+.sidebar-categories {
+ display: block;
+ height: 6.6em;
+ overflow: auto;
+ background-color: #f4f4f4;
+}
+.sidebar-categories label {
+ font-size: 10px;
+ display: block;
+ width: 90%;
+}
+</style>
+</head>
+<body id="sidebar">
+<h1 id="wphead"><a href="http://wordpress.org/" rel="external">WordPress</a></h1>
+<form name="post" action="post.php" method="POST">
+<div><input type="hidden" name="action" value="post" />
+<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
+<input type="hidden" name="mode" value="sidebar" />
+<p>Title:
+<input type="text" name="post_title" size="20" tabindex="1" style="width: 100%;" />
+</p>
+<p>Categories:
+<span class="sidebar-categories">
+<?php dropdown_categories(); ?>
+</span>
+</p>
+<p>
+Post:
+<textarea rows="8" cols="12" style="width: 100%" name="content" tabindex="2"></textarea>
+</p>
+<p>
+ <input name="saveasdraft" type="submit" id="saveasdraft" tabindex="9" value="Save as Draft" />
+<?php if ( current_user_can('publish_posts') ) : ?>
+ <input name="publish" type="submit" id="publish" tabindex="6" style="font-weight: bold;" value="Publish" />
+<?php endif; ?>
+</p>
+</div>
+</form>
+
+</body>
+</html>
+<?php
+}
+?>
diff --git a/wp-admin/templates.php b/wp-admin/templates.php
new file mode 100644
index 0000000..c22d56a
--- /dev/null
+++ b/wp-admin/templates.php
@@ -0,0 +1,171 @@
+<?php
+die();
+require_once('admin.php');
+$title = __('Template &amp; File Editing');
+$parent_file = 'edit.php';
+
+$wpvarstoreset = array('action','redirect','profile','error','warning','a','file');
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+$recents = get_option('recently_edited');
+
+if (empty($file)) {
+ if ($recents) {
+ $file = $recents[0];
+ } else {
+ $file = 'index.php';
+ }
+}
+
+$file = validate_file_to_edit($file);
+$real_file = get_real_file_to_edit($file);
+
+switch($action) {
+
+case 'update':
+
+ check_admin_referer('edit-file_' . $file);
+
+ if ( ! current_user_can('edit_files') )
+ die('<p>'.__('You do not have sufficient permissions to edit templates for this blog.').'</p>');
+
+ $newcontent = stripslashes($_POST['newcontent']);
+ if (is_writeable($real_file)) {
+ $f = @ fopen($real_file, 'w+');
+ if ( $f ) {
+ fwrite($f, $newcontent);
+ fclose($f);
+ header("Location: templates.php?file=$file&a=te");
+ } else {
+ header("Location: templates.php?file=$file&a=err");
+ }
+ } else {
+ header("Location: templates.php?file=$file&a=err");
+ }
+
+ exit();
+
+break;
+
+default:
+
+ require_once('./admin-header.php');
+
+ if ( ! current_user_can('edit_files') )
+ die('<p>'.__('You have do not have sufficient permissions to edit templates for this blog.').'</p>');
+
+ if ( strstr( $file, 'wp-config.php' ) )
+ die('<p>'.__('The config file cannot be edited or viewed through the web interface. Sorry!').'</p>');
+
+ update_recently_edited($file);
+
+ if (!is_file($real_file))
+ $error = true;
+
+ if (!$error) {
+ $f = @ fopen($real_file, 'r');
+ if ( $f ) {
+ $content = fread($f, filesize($real_file));
+ $content = htmlspecialchars($content);
+ } else {
+ $error = true;
+ }
+ }
+
+ ?>
+<?php if (isset($_GET['a'])) : ?>
+ <?php if ( 'err' == $_GET['a'] ) : ?>
+ <div id="message" class="error"><p><?php _e('Could not save file.') ?></p></div>
+ <?php else: ?>
+ <div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div>
+ <?php endif; ?>
+<?php endif; ?>
+ <div class="wrap">
+<?php
+if (is_writeable($real_file)) {
+ echo '<h2>' . sprintf(__('Editing <strong>%s</strong>'), wp_specialchars($file) ) . '</h2>';
+} else {
+ echo '<h2>' . sprintf(__('Browsing <strong>%s</strong>'), wp_specialchars($file) ) . '</h2>';
+}
+?>
+<div id="templateside">
+<?php
+if ( $recents ) :
+?>
+<h3><?php _e('Recent'); ?></h3>
+<?php
+echo '<ol>';
+foreach ($recents as $recent) :
+ echo "<li><a href='templates.php?file=$recent'>" . get_file_description(basename($recent)) . "</a></li>";
+endforeach;
+echo '</ol>';
+endif;
+?>
+<h3><?php _e('Common'); ?></h3>
+ <?php $common_files = array('index.php', '.htaccess', 'my-hacks.php');
+ $old_files = array('wp-layout.css', 'wp-comments.php', 'wp-comments-popup.php');
+ foreach ($old_files as $old_file) {
+ if (file_exists(ABSPATH . $old_file))
+ $common_files[] = $old_file;
+ } ?>
+ <ul>
+ <?php foreach ($common_files as $common_file) : ?>
+ <li><a href="templates.php?file=<?php echo $common_file?>"><?php echo get_file_description($common_file); ?></a></li>
+ <?php endforeach; ?>
+ </ul>
+</div>
+<?php if (!$error) { ?>
+ <form name="template" id="template" action="templates.php" method="post">
+ <?php wp_nonce_field('edit-file_' . $file) ?>
+ <div><textarea cols="70" rows="25" name="newcontent" id='newcontent' tabindex="1"><?php echo $content ?></textarea>
+ <input type="hidden" name="action" value="update" />
+ <input type="hidden" name="file" value="<?php echo $file ?>" />
+</div>
+<?php if ( is_writeable($real_file) ) : ?>
+ <p class="submit">
+<?php
+ echo "<input type='submit' name='submit' value=' " . __('Update File &raquo;') . "' tabindex='2' />";
+?>
+</p>
+<?php else : ?>
+<p><em><?php _e('If this file were writable you could edit it.'); ?></em></p>
+<?php endif; ?>
+ </form>
+ <?php
+ } else {
+ echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>';
+ }
+ ?>
+<div class="clear"> &nbsp; </div>
+</div>
+<div class="wrap">
+<h2><?php _e('Other Files') ?></h2>
+
+ <p><?php _e('To edit a file, type its name here. You can edit any file <a href="http://codex.wordpress.org/Changing_File_Permissions" title="Read more about making files writable">writable by the server</a>, e.g. CHMOD 666.') ?></p>
+ <form name="file" action="templates.php" method="get">
+ <input type="text" name="file" />
+ <input type="submit" name="submit" value="<?php _e('Edit file &raquo;') ?>" />
+ </form>
+
+ <p><?php _e('Note: of course, you can also edit the files/templates in your text editor of choice and upload them. This online editor is only meant to be used when you don&#8217;t have access to a text editor or FTP client.') ?></p>
+</div>
+<?php
+
+break;
+}
+
+include("admin-footer.php");
+?>
diff --git a/wp-admin/theme-editor.php b/wp-admin/theme-editor.php
new file mode 100644
index 0000000..10fb8fc
--- /dev/null
+++ b/wp-admin/theme-editor.php
@@ -0,0 +1,162 @@
+<?php
+die();
+require_once('admin.php');
+
+$title = __("Edit Themes");
+$parent_file = 'themes.php';
+
+$wpvarstoreset = array('action','redirect','profile','error','warning','a','file', 'theme');
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+$themes = get_themes();
+
+if (empty($theme)) {
+ $theme = get_current_theme();
+} else {
+ $theme = stripslashes($theme);
+ }
+
+
+if ( ! isset($themes[$theme]) )
+ die(__('The requested theme does not exist.'));
+
+$allowed_files = array_merge($themes[$theme]['Stylesheet Files'], $themes[$theme]['Template Files']);
+
+if (empty($file)) {
+ $file = $allowed_files[0];
+}
+
+$file = validate_file_to_edit($file, $allowed_files);
+$real_file = get_real_file_to_edit($file);
+
+$file_show = basename( $file );
+
+switch($action) {
+
+case 'update':
+
+ check_admin_referer('edit-theme_' . $file . $theme);
+
+ if ( !current_user_can('edit_themes') )
+ die('<p>'.__('You have do not have sufficient permissions to edit templates for this blog.').'</p>');
+
+ $newcontent = stripslashes($_POST['newcontent']);
+ $theme = urlencode($theme);
+ if (is_writeable($real_file)) {
+ $f = fopen($real_file, 'w+');
+ fwrite($f, $newcontent);
+ fclose($f);
+ header("Location: theme-editor.php?file=$file&theme=$theme&a=te");
+ } else {
+ header("Location: theme-editor.php?file=$file&theme=$theme");
+ }
+
+ exit();
+
+break;
+
+default:
+
+ require_once('admin-header.php');
+ if ( !current_user_can('edit_themes') )
+ die('<p>'.__('You have do not have sufficient permissions to edit themes for this blog.').'</p>');
+
+ update_recently_edited($file);
+
+ if (!is_file($real_file))
+ $error = 1;
+
+ if (!$error && filesize($real_file) > 0) {
+ $f = fopen($real_file, 'r');
+ $content = fread($f, filesize($real_file));
+ $content = htmlspecialchars($content);
+ }
+
+ ?>
+<?php if (isset($_GET['a'])) : ?>
+ <div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div>
+<?php endif; ?>
+ <div class="wrap">
+ <form name="theme" action="theme-editor.php" method="post">
+ <?php _e('Select theme to edit:') ?>
+ <select name="theme" id="theme">
+ <?php
+ foreach ($themes as $a_theme) {
+ $theme_name = $a_theme['Name'];
+ if ($theme_name == $theme) $selected = " selected='selected'";
+ else $selected = '';
+ $theme_name = wp_specialchars($theme_name, true);
+ echo "\n\t<option value=\"$theme_name\" $selected>$theme_name</option>";
+ }
+?>
+ </select>
+ <input type="submit" name="Submit" value="<?php _e('Select &raquo;') ?>" />
+ </form>
+ </div>
+
+ <div class="wrap">
+ <?php
+ if ( is_writeable($real_file) ) {
+ echo '<h2>' . sprintf(__('Editing <code>%s</code>'), $file_show) . '</h2>';
+ } else {
+ echo '<h2>' . sprintf(__('Browsing <code>%s</code>'), $file_show) . '</h2>';
+ }
+ ?>
+ <div id="templateside">
+ <h3><?php printf(__("<strong>'%s'</strong> theme files"), $theme) ?></h3>
+
+<?php
+if ($allowed_files) :
+?>
+ <ul>
+<?php foreach($allowed_files as $allowed_file) : ?>
+ <li><a href="theme-editor.php?file=<?php echo "$allowed_file"; ?>&amp;theme=<?php echo urlencode($theme) ?>"><?php echo get_file_description($allowed_file); ?></a></li>
+<?php endforeach; ?>
+ </ul>
+<?php endif; ?>
+</div>
+ <?php
+ if (!$error) {
+ ?>
+ <form name="template" id="template" action="theme-editor.php" method="post">
+ <?php wp_nonce_field('edit-theme_' . $file . $theme) ?>
+ <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea>
+ <input type="hidden" name="action" value="update" />
+ <input type="hidden" name="file" value="<?php echo $file ?>" />
+ <input type="hidden" name="theme" value="<?php echo $theme ?>" />
+ </div>
+<?php if ( is_writeable($real_file) ) : ?>
+ <p class="submit">
+<?php
+ echo "<input type='submit' name='submit' value=' " . __('Update File &raquo;') . "' tabindex='2' />";
+?>
+</p>
+<?php else : ?>
+<p><em><?php _e('If this file were writable you could edit it.'); ?></em></p>
+<?php endif; ?>
+ </form>
+ <?php
+ } else {
+ echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>';
+ }
+ ?>
+<div class="clear"> &nbsp; </div>
+</div>
+<?php
+break;
+}
+
+include("admin-footer.php") ?>
diff --git a/wp-admin/themes.php b/wp-admin/themes.php
new file mode 100644
index 0000000..f57bd1b
--- /dev/null
+++ b/wp-admin/themes.php
@@ -0,0 +1,142 @@
+<?php
+require_once('admin.php');
+
+if ( isset($_GET['action']) ) {
+ check_admin_referer('switch-theme_' . $_GET['template']);
+
+ if ('activate' == $_GET['action']) {
+ if ( isset($_GET['template']) )
+ update_option('template', $_GET['template']);
+
+ if ( isset($_GET['stylesheet']) )
+ update_option('stylesheet', $_GET['stylesheet']);
+
+ do_action('switch_theme', get_current_theme());
+
+ header('Location: themes.php?activated=true');
+ exit;
+ }
+}
+
+$title = __('Manage Themes');
+$parent_file = 'themes.php';
+require_once('admin-header.php');
+?>
+
+<?php if ( ! validate_current_theme() ) : ?>
+<div id="message1" class="updated fade"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div>
+<?php elseif ( isset($_GET['activated']) ) : ?>
+<div id="message2" class="updated fade"><p><?php printf(__('New theme activated. <a href="%s">View site &raquo;</a>'), get_bloginfo('home') . '/'); ?></p></div>
+<?php endif; ?>
+
+<?php
+$themes = get_themes();
+$ct = current_theme_info();
+$allowed_themes = get_site_option( "allowed_themes" );
+if( $allowed_themes == false ) {
+ $allowed_themes = $themes;
+}
+$blog_allowed_themes = get_option( "allowed_themes" );
+
+if( is_array( $blog_allowed_themes ) )
+ $allowed_themes = array_merge( $allowed_themes, $blog_allowed_themes );
+
+if( isset( $allowed_themes[ $ct->title ] ) == false ) {
+ $allowed_themes[ $ct->title ] = true;
+}
+reset( $themes );
+while( list( $key, $val ) = each( $themes ) ) {
+ if( isset( $allowed_themes[ $key ] ) == false ) {
+ unset( $themes[ $key ] );
+ }
+}
+reset( $themes );
+?>
+
+<div class="wrap">
+<h2><?php _e('Current Theme'); ?></h2>
+<div id="currenttheme">
+<?php if ( $ct->screenshot ) : ?>
+<img src="<?php echo get_option('siteurl') . '/' . $ct->stylesheet_dir . '/' . $ct->screenshot; ?>" alt="<?php _e('Current theme preview'); ?>" />
+<?php endif; ?>
+<h3><?php printf(__('%1$s %2$s by %3$s'), $ct->title, $ct->version, $ct->author) ; ?></h3>
+<p><?php echo $ct->description; ?></p>
+</div>
+
+<h2><?php _e('Available Themes'); ?></h2>
+<?php if ( 1 < count($themes) ) { ?>
+
+<?php
+$style = '';
+
+$theme_names = array_keys($themes);
+natcasesort($theme_names);
+
+foreach ($theme_names as $theme_name) {
+ if ( $theme_name == $ct->name )
+ continue;
+ $template = $themes[$theme_name]['Template'];
+ $stylesheet = $themes[$theme_name]['Stylesheet'];
+ $title = $themes[$theme_name]['Title'];
+ $version = $themes[$theme_name]['Version'];
+ $description = $themes[$theme_name]['Description'];
+ $author = $themes[$theme_name]['Author'];
+ $screenshot = $themes[$theme_name]['Screenshot'];
+ $stylesheet_dir = $themes[$theme_name]['Stylesheet Dir'];
+ $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>
+
+<a href="<?php echo $activate_link; ?>" class="screenshot">
+<?php if ( $screenshot ) : ?>
+<img src="<?php echo get_option('siteurl') . '/' . $stylesheet_dir . '/' . $screenshot; ?>" alt="" />
+<?php endif; ?>
+</a>
+
+<p><?php echo $description; ?></p>
+</div>
+<?php } // end foreach theme_names ?>
+
+<?php } ?>
+
+<?php
+// List broken themes, if any.
+$broken_themes = get_broken_themes();
+if ( count($broken_themes) ) {
+?>
+
+<h2><?php _e('Broken Themes'); ?></h2>
+<p><?php _e('The following themes are installed but incomplete. Themes must have a stylesheet and a template.'); ?></p>
+
+<table width="100%" cellpadding="3" cellspacing="3">
+ <tr>
+ <th><?php _e('Name'); ?></th>
+ <th><?php _e('Description'); ?></th>
+ </tr>
+<?php
+ $theme = '';
+
+ $theme_names = array_keys($broken_themes);
+ natcasesort($theme_names);
+
+ foreach ($theme_names as $theme_name) {
+ $title = $broken_themes[$theme_name]['Title'];
+ $description = $broken_themes[$theme_name]['Description'];
+
+ $theme = ('class="alternate"' == $theme) ? '' : 'class="alternate"';
+ echo "
+ <tr $theme>
+ <td>$title</td>
+ <td>$description</td>
+ </tr>";
+ }
+?>
+</table>
+<?php
+}
+?>
+<br clear="all" />
+</div>
+
+<?php require('admin-footer.php'); ?>
diff --git a/wp-admin/update-links.php b/wp-admin/update-links.php
new file mode 100644
index 0000000..46a7f5a
--- /dev/null
+++ b/wp-admin/update-links.php
@@ -0,0 +1,44 @@
+<?php
+require_once( dirname( dirname(__FILE__) ) . '/wp-config.php');
+require_once( ABSPATH . 'wp-includes/class-snoopy.php');
+
+if ( !get_option('use_linksupdate') )
+ die(__('Feature disabled.'));
+
+$link_uris = $wpdb->get_col("SELECT link_url FROM $wpdb->links");
+
+if ( !$link_uris )
+ die('No links');
+
+$link_uris = urlencode( join( $link_uris, "\n" ) );
+
+$query_string = "uris=$link_uris";
+
+$http_request = "POST /updated-batch/ HTTP/1.0\r\n";
+$http_request .= "Host: api.pingomatic.com\r\n";
+$http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.get_settings('blog_charset')."\r\n";
+$http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n";
+$http_request .= 'User-Agent: WordPress/' . $wp_version . "\r\n";
+$http_request .= "\r\n";
+$http_request .= $query_string;
+
+$response = '';
+if( false !== ( $fs = fsockopen('api.pingomatic.com', 80, $errno, $errstr, 5) ) ) {
+ fwrite($fs, $http_request);
+ while ( !feof($fs) )
+ $response .= fgets($fs, 1160); // One TCP-IP packet
+ fclose($fs);
+
+ $response = explode("\r\n\r\n", $response, 2);
+ $body = trim( $response[1] );
+ $body = str_replace(array("\r\n", "\r"), "\n", $body);
+
+ $returns = explode("\n", $body);
+
+ foreach ($returns as $return) :
+ $time = $wpdb->escape( substr($return, 0, 19) );
+ $uri = $wpdb->escape( preg_replace('/(.*?) | (.*?)/', '$2', $return) );
+ $wpdb->query("UPDATE $wpdb->links SET link_updated = '$time' WHERE link_url = '$uri'");
+ endforeach;
+}
+?>
diff --git a/wp-admin/upgrade-functions.php b/wp-admin/upgrade-functions.php
new file mode 100644
index 0000000..03c34c2
--- /dev/null
+++ b/wp-admin/upgrade-functions.php
@@ -0,0 +1,1076 @@
+<?php
+
+if ( file_exists(ABSPATH . 'wp-content/install.php') )
+ require (ABSPATH . 'wp-content/install.php');
+require_once(ABSPATH . '/wp-admin/admin-functions.php');
+require_once(ABSPATH . '/wp-admin/admin-db.php');
+require_once(ABSPATH . '/wp-admin/upgrade-schema.php');
+require_once(ABSPATH . WPINC . '/registration.php');
+
+if ( !function_exists('wp_install') ) :
+function wp_install($blog_title, $user_name, $user_email, $public, $meta='') {
+ global $wp_rewrite;
+
+ wp_cache_flush();
+ make_db_current_silent();
+ populate_options();
+ populate_roles();
+
+ update_option('blogname', $blog_title);
+ update_option('admin_email', $user_email);
+ update_option('blog_public', $public);
+ $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
+ $guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
+ update_option('siteurl', $guessurl);
+
+ // If not a public blog, don't ping.
+ if ( ! $public )
+ update_option('default_pingback_flag', 0);
+
+ // Create default user. If the user already exists, the user tables are
+ // being shared among blogs. Just set the role in that case.
+ $user_id = username_exists($user_name);
+ if ( !$user_id ) {
+ $random_password = substr(md5(uniqid(microtime())), 0, 6);
+ $user_id = wp_create_user($user_name, $random_password, $user_email);
+ } else {
+ $random_password = __('User already exists. Password inherited.');
+ }
+
+ $user = new WP_User($user_id);
+ $user->set_role('administrator');
+
+ wp_install_defaults($user_id);
+
+ $wp_rewrite->flush_rules();
+
+ wp_new_blog_notification($blog_title, $guessurl, $user_id, $random_password);
+
+ wp_cache_flush();
+
+ return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password);
+}
+endif;
+
+if ( !function_exists('wp_install_defaults') ) :
+function wp_install_defaults($user_id) {
+ global $wpdb;
+
+ // Default category
+ $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_count, category_description) VALUES ('0', '".$wpdb->escape(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."', '1', '')");
+
+ // Default link category
+ $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, link_count, category_description) VALUES ('0', '".$wpdb->escape(__('Blogroll'))."', '".sanitize_title(__('Blogroll'))."', '7', '')");
+
+ // Now drop in some default links
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://inphotos.org/', 'Donncha', 0, 'http://inphotos.org/feed/', '');");
+ $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (1, 2)" );
+
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zengun.org/weblog/', 'Michel', 0, 'http://zengun.org/weblog/feed/', '');");
+ $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (2, 2)" );
+
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://boren.nu/', 'Ryan', 0, 'http://boren.nu/feed/', '');");
+ $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (3, 2)" );
+
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://photomatt.net/', 'Matt', 0, 'http://xml.photomatt.net/feed/', '');");
+ $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (4, 2)" );
+
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zed1.com/journalized/', 'Mike', 0, 'http://zed1.com/journalized/feed/', '');");
+ $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (5, 2)" );
+
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://www.alexking.org/', 'Alex', 0, 'http://www.alexking.org/blog/wp-rss2.php', '');");
+ $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (6, 2)" );
+
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://dougal.gunters.org/', 'Dougal', 0, 'http://dougal.gunters.org/feed/', '');");
+ $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (7, 2)" );
+
+ // First post
+ $now = date('Y-m-d H:i:s');
+ $now_gmt = gmdate('Y-m-d H:i:s');
+ $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, comment_count, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'))."', '', '".$wpdb->escape(__('Hello world!'))."', '0', '".$wpdb->escape(__('hello-world'))."', '$now', '$now_gmt', '1', '', '', '')");
+
+ $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" );
+
+ // Default comment
+ $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_date_gmt, comment_content) VALUES ('1', '".$wpdb->escape(__('Mr WordPress'))."', '', 'http://wordpress.org/', '$now', '$now_gmt', '".$wpdb->escape(__('Hi, this is a comment.<br />To delete a comment, just log in, and view the posts\' comments, there you will have the option to edit or delete them.'))."')");
+
+ // First Page
+
+ $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status, post_type, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '', '".$wpdb->escape(__('About'))."', '0', '".$wpdb->escape(__('about'))."', '$now', '$now_gmt', 'publish', 'page', '', '', '')");
+}
+endif;
+
+if ( !function_exists('wp_new_blog_notification') ) :
+function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) {
+ $user = new WP_User($user_id);
+ $email = $user->user_email;
+ $name = $user->user_login;
+ $message_headers = 'From: ' . $blog_title . ' <wordpress@' . $_SERVER['SERVER_NAME'] . '>';
+ $message = sprintf(__("Your new WordPress blog has been successfully set up at:
+
+%1\$s
+
+You can log in to the administrator account with the following information:
+
+Username: %2\$s
+Password: %3\$s
+
+We hope you enjoy your new weblog. Thanks!
+
+--The WordPress Team
+http://wordpress.org/
+"), $blog_url, $name, $password);
+
+ @wp_mail($email, __('New WordPress Blog'), $message, $message_headers);
+}
+endif;
+
+if ( !function_exists('wp_upgrade') ) :
+function wp_upgrade() {
+ global $wp_current_db_version, $wp_db_version;
+
+ $wp_current_db_version = __get_option('db_version');
+
+ // We are up-to-date. Nothing to do.
+ if ( $wp_db_version == $wp_current_db_version )
+ return;
+
+ wp_cache_flush();
+ make_db_current_silent();
+ upgrade_all();
+ wp_cache_flush();
+}
+endif;
+
+// Functions to be called in install and upgrade scripts
+function upgrade_all() {
+ global $wp_current_db_version, $wp_db_version, $wp_rewrite;
+ $wp_current_db_version = __get_option('db_version');
+
+ // We are up-to-date. Nothing to do.
+ if ( $wp_db_version == $wp_current_db_version )
+ return;
+
+ // If the version is not set in the DB, try to guess the version.
+ if ( empty($wp_current_db_version) ) {
+ $wp_current_db_version = 0;
+
+ // If the template option exists, we have 1.5.
+ $template = __get_option('template');
+ if ( !empty($template) )
+ $wp_current_db_version = 2541;
+ }
+
+ populate_options();
+
+ if ( $wp_current_db_version < 2541 ) {
+ upgrade_100();
+ upgrade_101();
+ upgrade_110();
+ upgrade_130();
+ }
+
+ if ( $wp_current_db_version < 3308 )
+ upgrade_160();
+
+ if ( $wp_current_db_version < 3845 )
+ upgrade_210();
+
+ $wp_rewrite->flush_rules();
+
+ update_option('db_version', $wp_db_version);
+}
+
+function upgrade_100() {
+ global $wpdb;
+
+ // Get the title and ID of every post, post_name to check if it already has a value
+ $posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM $wpdb->posts WHERE post_name = ''");
+ if ($posts) {
+ foreach($posts as $post) {
+ if ('' == $post->post_name) {
+ $newtitle = sanitize_title($post->post_title);
+ $wpdb->query("UPDATE $wpdb->posts SET post_name = '$newtitle' WHERE ID = '$post->ID'");
+ }
+ }
+ }
+
+ $categories = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename FROM $wpdb->categories");
+ foreach ($categories as $category) {
+ if ('' == $category->category_nicename) {
+ $newtitle = sanitize_title($category->cat_name);
+ $wpdb->query("UPDATE $wpdb->categories SET category_nicename = '$newtitle' WHERE cat_ID = '$category->cat_ID'");
+ }
+ }
+
+
+ $wpdb->query("UPDATE $wpdb->options SET option_value = REPLACE(option_value, 'wp-links/links-images/', 'wp-images/links/')
+ WHERE option_name LIKE 'links_rating_image%'
+ AND option_value LIKE 'wp-links/links-images/%'");
+
+ $done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $wpdb->post2cat");
+ if ($done_ids) :
+ foreach ($done_ids as $done_id) :
+ $done_posts[] = $done_id->post_id;
+ endforeach;
+ $catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')';
+ else:
+ $catwhere = '';
+ endif;
+
+ $allposts = $wpdb->get_results("SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere");
+ if ($allposts) :
+ foreach ($allposts as $post) {
+ // Check to see if it's already been imported
+ $cat = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post->ID AND category_id = $post->post_category");
+ if (!$cat && 0 != $post->post_category) { // If there's no result
+ $wpdb->query("
+ INSERT INTO $wpdb->post2cat
+ (post_id, category_id)
+ VALUES
+ ('$post->ID', '$post->post_category')
+ ");
+ }
+ }
+ endif;
+}
+
+function upgrade_101() {
+ global $wpdb;
+
+ // Clean up indices, add a few
+ add_clean_index($wpdb->posts, 'post_name');
+ add_clean_index($wpdb->posts, 'post_status');
+ add_clean_index($wpdb->categories, 'category_nicename');
+ add_clean_index($wpdb->comments, 'comment_approved');
+ add_clean_index($wpdb->comments, 'comment_post_ID');
+ add_clean_index($wpdb->links , 'link_category');
+ add_clean_index($wpdb->links , 'link_visible');
+}
+
+
+function upgrade_110() {
+ global $wpdb;
+
+ // Set user_nicename.
+ $users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users");
+ foreach ($users as $user) {
+ if ('' == $user->user_nicename) {
+ $newname = sanitize_title($user->user_nickname);
+ $wpdb->query("UPDATE $wpdb->users SET user_nicename = '$newname' WHERE ID = '$user->ID'");
+ }
+ }
+
+ $users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users");
+ foreach ($users as $row) {
+ if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) {
+ $wpdb->query('UPDATE '.$wpdb->users.' SET user_pass = MD5(\''.$row->user_pass.'\') WHERE ID = \''.$row->ID.'\'');
+ }
+ }
+
+
+ // Get the GMT offset, we'll use that later on
+ $all_options = get_alloptions_110();
+
+ $time_difference = $all_options->time_difference;
+
+ $server_time = time()+date('Z');
+ $weblogger_time = $server_time + $time_difference*3600;
+ $gmt_time = time();
+
+ $diff_gmt_server = ($gmt_time - $server_time) / 3600;
+ $diff_weblogger_server = ($weblogger_time - $server_time) / 3600;
+ $diff_gmt_weblogger = $diff_gmt_server - $diff_weblogger_server;
+ $gmt_offset = -$diff_gmt_weblogger;
+
+ // Add a gmt_offset option, with value $gmt_offset
+ add_option('gmt_offset', $gmt_offset);
+
+ // Check if we already set the GMT fields (if we did, then
+ // MAX(post_date_gmt) can't be '0000-00-00 00:00:00'
+ // <michel_v> I just slapped myself silly for not thinking about it earlier
+ $got_gmt_fields = ($wpdb->get_var("SELECT MAX(post_date_gmt) FROM $wpdb->posts") == '0000-00-00 00:00:00') ? false : true;
+
+ if (!$got_gmt_fields) {
+
+ // Add or substract time to all dates, to get GMT dates
+ $add_hours = intval($diff_gmt_weblogger);
+ $add_minutes = intval(60 * ($diff_gmt_weblogger - $add_hours));
+ $wpdb->query("UPDATE $wpdb->posts SET post_date_gmt = DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
+ $wpdb->query("UPDATE $wpdb->posts SET post_modified = post_date");
+ $wpdb->query("UPDATE $wpdb->posts SET post_modified_gmt = DATE_ADD(post_modified, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE) WHERE post_modified != '0000-00-00 00:00:00'");
+ $wpdb->query("UPDATE $wpdb->comments SET comment_date_gmt = DATE_ADD(comment_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
+ $wpdb->query("UPDATE $wpdb->users SET user_registered = DATE_ADD(user_registered, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
+ }
+
+}
+
+function upgrade_130() {
+ global $wpdb;
+
+ // Remove extraneous backslashes.
+ $posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts");
+ if ($posts) {
+ foreach($posts as $post) {
+ $post_content = addslashes(deslash($post->post_content));
+ $post_title = addslashes(deslash($post->post_title));
+ $post_excerpt = addslashes(deslash($post->post_excerpt));
+ if ( empty($post->guid) )
+ $guid = get_permalink($post->ID);
+ else
+ $guid = $post->guid;
+
+ $wpdb->query("UPDATE $wpdb->posts SET post_title = '$post_title', post_content = '$post_content', post_excerpt = '$post_excerpt', guid = '$guid' WHERE ID = '$post->ID'");
+ }
+ }
+
+ // Remove extraneous backslashes.
+ $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_content FROM $wpdb->comments");
+ if ($comments) {
+ foreach($comments as $comment) {
+ $comment_content = addslashes(deslash($comment->comment_content));
+ $comment_author = addslashes(deslash($comment->comment_author));
+ $wpdb->query("UPDATE $wpdb->comments SET comment_content = '$comment_content', comment_author = '$comment_author' WHERE comment_ID = '$comment->comment_ID'");
+ }
+ }
+
+ // Remove extraneous backslashes.
+ $links = $wpdb->get_results("SELECT link_id, link_name, link_description FROM $wpdb->links");
+ if ($links) {
+ foreach($links as $link) {
+ $link_name = addslashes(deslash($link->link_name));
+ $link_description = addslashes(deslash($link->link_description));
+ $wpdb->query("UPDATE $wpdb->links SET link_name = '$link_name', link_description = '$link_description' WHERE link_id = '$link->link_id'");
+ }
+ }
+
+ // The "paged" option for what_to_show is no more.
+ if ($wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'what_to_show'") == 'paged') {
+ $wpdb->query("UPDATE $wpdb->options SET option_value = 'posts' WHERE option_name = 'what_to_show'");
+ }
+
+ $active_plugins = __get_option('active_plugins');
+
+ // If plugins are not stored in an array, they're stored in the old
+ // newline separated format. Convert to new format.
+ if ( !is_array( $active_plugins ) ) {
+ $active_plugins = explode("\n", trim($active_plugins));
+ update_option('active_plugins', $active_plugins);
+ }
+
+ // Obsolete tables
+ $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optionvalues');
+ $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiontypes');
+ $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroups');
+ $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroup_options');
+
+ // Update comments table to use comment_type
+ $wpdb->query("UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'");
+ $wpdb->query("UPDATE $wpdb->comments SET comment_type='pingback', comment_content = REPLACE(comment_content, '<pingback />', '') WHERE comment_content LIKE '<pingback />%'");
+
+ // Some versions have multiple duplicate option_name rows with the same values
+ $options = $wpdb->get_results("SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name");
+ foreach ( $options as $option ) {
+ if ( 1 != $option->dupes ) { // Could this be done in the query?
+ $limit = $option->dupes - 1;
+ $dupe_ids = $wpdb->get_col("SELECT option_id FROM $wpdb->options WHERE option_name = '$option->option_name' LIMIT $limit");
+ $dupe_ids = join($dupe_ids, ',');
+ $wpdb->query("DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)");
+ }
+ }
+
+ make_site_theme();
+}
+
+function upgrade_160_helper( $users ) {
+ global $wpdb;
+
+ populate_roles_160();
+
+ foreach ( $users as $user_details ) :
+ $user = $wpdb->get_results("SELECT * FROM $wpdb->users WHERE ID = '" . $user_details[ 'user_id' ] . "'");
+ if ( !empty( $user->user_firstname ) )
+ update_usermeta( $user->ID, 'first_name', $wpdb->escape($user->user_firstname) );
+ if ( !empty( $user->user_lastname ) )
+ update_usermeta( $user->ID, 'last_name', $wpdb->escape($user->user_lastname) );
+ if ( !empty( $user->user_nickname ) )
+ update_usermeta( $user->ID, 'nickname', $wpdb->escape($user->user_nickname) );
+ if ( !empty( $user->user_level ) )
+ update_usermeta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level );
+ if ( !empty( $user->user_icq ) )
+ update_usermeta( $user->ID, 'icq', $wpdb->escape($user->user_icq) );
+ if ( !empty( $user->user_aim ) )
+ update_usermeta( $user->ID, 'aim', $wpdb->escape($user->user_aim) );
+ if ( !empty( $user->user_msn ) )
+ update_usermeta( $user->ID, 'msn', $wpdb->escape($user->user_msn) );
+ if ( !empty( $user->user_yim ) )
+ update_usermeta( $user->ID, 'yim', $wpdb->escape($user->user_icq) );
+ if ( !empty( $user->user_description ) )
+ update_usermeta( $user->ID, 'description', $wpdb->escape($user->user_description) );
+
+ if ( isset( $user->user_idmode ) ):
+ $idmode = $user->user_idmode;
+ if ($idmode == 'nickname') $id = $user->user_nickname;
+ if ($idmode == 'login') $id = $user->user_login;
+ if ($idmode == 'firstname') $id = $user->user_firstname;
+ if ($idmode == 'lastname') $id = $user->user_lastname;
+ if ($idmode == 'namefl') $id = $user->user_firstname.' '.$user->user_lastname;
+ if ($idmode == 'namelf') $id = $user->user_lastname.' '.$user->user_firstname;
+ if (!$idmode) $id = $user->user_nickname;
+ $id = $wpdb->escape( $id );
+ $wpdb->query("UPDATE $wpdb->users SET display_name = '$id' WHERE ID = '$user->ID'");
+ endif;
+
+ // FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set.
+ $caps = get_usermeta( $user->ID, $wpdb->prefix . 'capabilities');
+ if ( empty($caps) || defined('RESET_CAPS') ) {
+ $level = get_usermeta($user->ID, $wpdb->prefix . 'user_level');
+ $role = translate_level_to_role($level);
+ update_usermeta( $user->ID, $wpdb->prefix . 'capabilities', array($role => true) );
+ }
+
+ endforeach;
+}
+
+function upgrade_160() {
+ global $wpdb, $table_prefix, $wp_current_db_version;
+ $users = $wpdb->get_results("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '{$table_prefix}capabilities'", ARRAY_A);
+ upgrade_160_helper( $users );
+ $users = $wpdb->get_results("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '{$table_prefix}user_level'", ARRAY_A);
+ upgrade_160_helper( $users );
+ $old_user_fields = array( 'user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level' );
+ $wpdb->hide_errors();
+ foreach ( $old_user_fields as $old )
+ $wpdb->query("ALTER TABLE $wpdb->users DROP $old");
+ $wpdb->show_errors();
+
+ if ( 0 == $wpdb->get_var("SELECT SUM(category_count) FROM $wpdb->categories") ) { // Create counts
+ $categories = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories");
+ foreach ( $categories as $cat_id ) {
+ $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_type='post' AND post_status='publish' AND category_id = '$cat_id'");
+ $wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'");
+ }
+ }
+ add_option( "gmt_offset", 0 );
+
+ // populate comment_count field of posts table
+ $comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" );
+ if( is_array( $comments ) ) {
+ foreach ($comments as $comment) {
+ $wpdb->query( "UPDATE $wpdb->posts SET comment_count = $comment->c WHERE ID = '$comment->comment_post_ID'" );
+ }
+ }
+
+ // Some alpha versions used a post status of object instead of attachment and put
+ // the mime type in post_type instead of post_mime_type.
+ if ( $wp_current_db_version > 2541 && $wp_current_db_version <= 3091 ) {
+ $objects = $wpdb->get_results("SELECT ID, post_type FROM $wpdb->posts WHERE post_status = 'object'");
+ foreach ($objects as $object) {
+ $wpdb->query("UPDATE $wpdb->posts SET post_status = 'attachment',
+ post_mime_type = '$object->post_type',
+ post_type = ''
+ WHERE ID = $object->ID");
+
+ $meta = get_post_meta($object->ID, 'imagedata', true);
+ if ( ! empty($meta['file']) )
+ add_post_meta($object->ID, '_wp_attached_file', $meta['file']);
+ }
+ }
+}
+
+function upgrade_210() {
+ global $wpdb, $wp_current_db_version;
+
+ if ( $wp_current_db_version < 3506 ) {
+ // Update status and type.
+ $posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts");
+
+ if ( ! empty($posts) ) foreach ($posts as $post) {
+ $status = $post->post_status;
+ $type = 'post';
+
+ if ( 'static' == $status ) {
+ $status = 'publish';
+ $type = 'page';
+ } else if ( 'attachment' == $status ) {
+ $status = 'inherit';
+ $type = 'attachment';
+ }
+
+ $wpdb->query("UPDATE $wpdb->posts SET post_status = '$status', post_type = '$type' WHERE ID = '$post->ID'");
+ }
+ }
+
+ if ( $wp_current_db_version < 3845 ) {
+ populate_roles_210();
+ }
+
+ if ( $wp_current_db_version < 3531 ) {
+ // Give future posts a post_status of future.
+ $now = gmdate('Y-m-d H:i:59');
+ $wpdb->query ("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'");
+
+ $posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'");
+ if ( !empty($posts) )
+ foreach ( $posts as $post )
+ wp_schedule_single_event(mysql2date('U', $post->post_date), 'publish_future_post', $post->ID);
+ }
+ if ( $wp_current_db_version < 3570 ) {
+ // Create categories for link categories if a category with the same
+ // name doesn't exist. Create a map of link cat IDs to cat IDs.
+ $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
+ foreach ( $link_cats as $link_cat) {
+ if ( $cat_id = category_exists($link_cat->cat_name) ) {
+ $link_cat_id_map[$link_cat->cat_id] = $cat_id;
+ $default_link_cat = $cat_id;
+ } else {
+ $link_cat_id_map[$link_cat->cat_id] = wp_create_category($link_cat->cat_name);
+ $default_link_cat = $link_cat_id_map[$link_cat->cat_id];
+ }
+ }
+
+ // Associate links to cats.
+ $links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links");
+ if ( !empty($links) ) foreach ( $links as $link ) {
+ $link_cat = $link_cat_id_map[$link->link_category];
+ $cat = $wpdb->get_row("SELECT * FROM $wpdb->link2cat WHERE link_id = '$link->link_id' AND category_id = '$link_cat'");
+ if (!$cat && 0 != $link->link_category) {
+ $wpdb->query("INSERT INTO $wpdb->link2cat (link_id, category_id)
+ VALUES ('$link->link_id', '$link_cat')");
+ }
+ }
+
+ // Set default to the last category we grabbed during the upgrade loop.
+ update_option('default_link_category', $default_link_cat);
+
+ // Count links per category.
+ if ( 0 == $wpdb->get_var("SELECT SUM(link_count) FROM $wpdb->categories") ) {
+ $categories = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories");
+ foreach ( $categories as $cat_id ) {
+ $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->link2cat, $wpdb->links WHERE $wpdb->links.link_id = $wpdb->link2cat.link_id AND category_id = '$cat_id'");
+ $wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'");
+ }
+ }
+ }
+}
+
+// The functions we use to actually do stuff
+
+// General
+function maybe_create_table($table_name, $create_ddl) {
+ global $wpdb;
+ foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
+ if ($table == $table_name) {
+ return true;
+ }
+ }
+ //didn't find it try to create it.
+ $q = $wpdb->query($create_ddl);
+ // we cannot directly tell that whether this succeeded!
+ foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
+ if ($table == $table_name) {
+ return true;
+ }
+ }
+ return false;
+}
+
+function drop_index($table, $index) {
+ global $wpdb;
+ $wpdb->hide_errors();
+ $wpdb->query("ALTER TABLE `$table` DROP INDEX `$index`");
+ // Now we need to take out all the extra ones we may have created
+ for ($i = 0; $i < 25; $i++) {
+ $wpdb->query("ALTER TABLE `$table` DROP INDEX `{$index}_$i`");
+ }
+ $wpdb->show_errors();
+ return true;
+}
+
+function add_clean_index($table, $index) {
+ global $wpdb;
+ drop_index($table, $index);
+ $wpdb->query("ALTER TABLE `$table` ADD INDEX ( `$index` )");
+ return true;
+}
+
+/**
+ ** maybe_add_column()
+ ** Add column to db table if it doesn't exist.
+ ** Returns: true if already exists or on successful completion
+ ** false on error
+ */
+function maybe_add_column($table_name, $column_name, $create_ddl) {
+ global $wpdb, $debug;
+ foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
+ if ($debug) echo("checking $column == $column_name<br />");
+ if ($column == $column_name) {
+ return true;
+ }
+ }
+ //didn't find it try to create it.
+ $q = $wpdb->query($create_ddl);
+ // we cannot directly tell that whether this succeeded!
+ foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
+ if ($column == $column_name) {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+// get_alloptions as it was for 1.2.
+function get_alloptions_110() {
+ global $wpdb;
+ if ($options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options")) {
+ foreach ($options as $option) {
+ // "When trying to design a foolproof system,
+ // never underestimate the ingenuity of the fools :)" -- Dougal
+ if ('siteurl' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
+ if ('home' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
+ if ('category_base' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
+ $all_options->{$option->option_name} = stripslashes($option->option_value);
+ }
+ }
+ return $all_options;
+}
+
+// Version of get_option that is private to install/upgrade.
+function __get_option($setting) {
+ global $wpdb;
+
+ $option = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting'");
+
+ if ( 'home' == $setting && '' == $option )
+ return __get_option('siteurl');
+
+ if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting )
+ $option = preg_replace('|/+$|', '', $option);
+
+ @ $kellogs = unserialize($option);
+ if ($kellogs !== FALSE)
+ return $kellogs;
+ else
+ return $option;
+}
+
+function deslash($content) {
+ // Note: \\\ inside a regex denotes a single backslash.
+
+ // Replace one or more backslashes followed by a single quote with
+ // a single quote.
+ $content = preg_replace("/\\\+'/", "'", $content);
+
+ // Replace one or more backslashes followed by a double quote with
+ // a double quote.
+ $content = preg_replace('/\\\+"/', '"', $content);
+
+ // Replace one or more backslashes with one backslash.
+ $content = preg_replace("/\\\+/", "\\", $content);
+
+ return $content;
+}
+
+function dbDelta($queries, $execute = true) {
+ global $wpdb;
+
+ // Seperate individual queries into an array
+ if( !is_array($queries) ) {
+ $queries = explode( ';', $queries );
+ if('' == $queries[count($queries) - 1]) array_pop($queries);
+ }
+
+ $cqueries = array(); // Creation Queries
+ $iqueries = array(); // Insertion Queries
+ $for_update = array();
+
+ // Create a tablename index for an array ($cqueries) of queries
+ foreach($queries as $qry) {
+ if(preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) {
+ $cqueries[strtolower($matches[1])] = $qry;
+ $for_update[$matches[1]] = 'Created table '.$matches[1];
+ }
+ else if(preg_match("|CREATE DATABASE ([^ ]*)|", $qry, $matches)) {
+ array_unshift($cqueries, $qry);
+ }
+ else if(preg_match("|INSERT INTO ([^ ]*)|", $qry, $matches)) {
+ $iqueries[] = $qry;
+ }
+ else if(preg_match("|UPDATE ([^ ]*)|", $qry, $matches)) {
+ $iqueries[] = $qry;
+ }
+ else {
+ // Unrecognized query type
+ }
+ }
+
+ // Check to see which tables and fields exist
+ if($tables = $wpdb->get_col('SHOW TABLES;')) {
+ // For every table in the database
+ foreach($tables as $table) {
+ // If a table query exists for the database table...
+ if( array_key_exists(strtolower($table), $cqueries) ) {
+ // Clear the field and index arrays
+ unset($cfields);
+ unset($indices);
+ // Get all of the field names in the query from between the parens
+ preg_match("|\((.*)\)|ms", $cqueries[strtolower($table)], $match2);
+ $qryline = trim($match2[1]);
+
+ // Separate field lines into an array
+ $flds = explode("\n", $qryline);
+
+ //echo "<hr/><pre>\n".print_r(strtolower($table), true).":\n".print_r($cqueries, true)."</pre><hr/>";
+
+ // For every field line specified in the query
+ foreach($flds as $fld) {
+ // Extract the field name
+ preg_match("|^([^ ]*)|", trim($fld), $fvals);
+ $fieldname = $fvals[1];
+
+ // Verify the found field name
+ $validfield = true;
+ switch(strtolower($fieldname))
+ {
+ case '':
+ case 'primary':
+ case 'index':
+ case 'fulltext':
+ case 'unique':
+ case 'key':
+ $validfield = false;
+ $indices[] = trim(trim($fld), ", \n");
+ break;
+ }
+ $fld = trim($fld);
+
+ // If it's a valid field, add it to the field array
+ if($validfield) {
+ $cfields[strtolower($fieldname)] = trim($fld, ", \n");
+ }
+ }
+
+ // Fetch the table column structure from the database
+ $tablefields = $wpdb->get_results("DESCRIBE {$table};");
+
+ // For every field in the table
+ foreach($tablefields as $tablefield) {
+ // If the table field exists in the field array...
+ if(array_key_exists(strtolower($tablefield->Field), $cfields)) {
+ // Get the field type from the query
+ preg_match("|".$tablefield->Field." ([^ ]*( unsigned)?)|i", $cfields[strtolower($tablefield->Field)], $matches);
+ $fieldtype = $matches[1];
+
+ // Is actual field type different from the field type in query?
+ if($tablefield->Type != $fieldtype) {
+ // Add a query to change the column type
+ $cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN {$tablefield->Field} " . $cfields[strtolower($tablefield->Field)];
+ $for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}";
+ }
+
+ // Get the default value from the array
+ //echo "{$cfields[strtolower($tablefield->Field)]}<br>";
+ if(preg_match("| DEFAULT '(.*)'|i", $cfields[strtolower($tablefield->Field)], $matches)) {
+ $default_value = $matches[1];
+ if($tablefield->Default != $default_value)
+ {
+ // Add a query to change the column's default value
+ $cqueries[] = "ALTER TABLE {$table} ALTER COLUMN {$tablefield->Field} SET DEFAULT '{$default_value}'";
+ $for_update[$table.'.'.$tablefield->Field] = "Changed default value of {$table}.{$tablefield->Field} from {$tablefield->Default} to {$default_value}";
+ }
+ }
+
+ // Remove the field from the array (so it's not added)
+ unset($cfields[strtolower($tablefield->Field)]);
+ }
+ else {
+ // This field exists in the table, but not in the creation queries?
+ }
+ }
+
+ // For every remaining field specified for the table
+ foreach($cfields as $fieldname => $fielddef) {
+ // Push a query line into $cqueries that adds the field to that table
+ $cqueries[] = "ALTER TABLE {$table} ADD COLUMN $fielddef";
+ $for_update[$table.'.'.$fieldname] = 'Added column '.$table.'.'.$fieldname;
+ }
+
+ // Index stuff goes here
+ // Fetch the table index structure from the database
+ $tableindices = $wpdb->get_results("SHOW INDEX FROM {$table};");
+
+ if($tableindices) {
+ // Clear the index array
+ unset($index_ary);
+
+ // For every index in the table
+ foreach($tableindices as $tableindex) {
+ // Add the index to the index data array
+ $keyname = $tableindex->Key_name;
+ $index_ary[$keyname]['columns'][] = array('fieldname' => $tableindex->Column_name, 'subpart' => $tableindex->Sub_part);
+ $index_ary[$keyname]['unique'] = ($tableindex->Non_unique == 0)?true:false;
+ }
+
+ // For each actual index in the index array
+ foreach($index_ary as $index_name => $index_data) {
+ // Build a create string to compare to the query
+ $index_string = '';
+ if($index_name == 'PRIMARY') {
+ $index_string .= 'PRIMARY ';
+ }
+ else if($index_data['unique']) {
+ $index_string .= 'UNIQUE ';
+ }
+ $index_string .= 'KEY ';
+ if($index_name != 'PRIMARY') {
+ $index_string .= $index_name;
+ }
+ $index_columns = '';
+ // For each column in the index
+ foreach($index_data['columns'] as $column_data) {
+ if($index_columns != '') $index_columns .= ',';
+ // Add the field to the column list string
+ $index_columns .= $column_data['fieldname'];
+ if($column_data['subpart'] != '') {
+ $index_columns .= '('.$column_data['subpart'].')';
+ }
+ }
+ // Add the column list to the index create string
+ $index_string .= ' ('.$index_columns.')';
+
+ if(!(($aindex = array_search($index_string, $indices)) === false)) {
+ unset($indices[$aindex]);
+ //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br/>Found index:".$index_string."</pre>\n";
+ }
+ //else echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br/><b>Did not find index:</b>".$index_string."<br/>".print_r($indices, true)."</pre>\n";
+ }
+ }
+
+ // For every remaining index specified for the table
+ foreach($indices as $index) {
+ // Push a query line into $cqueries that adds the index to that table
+ $cqueries[] = "ALTER TABLE {$table} ADD $index";
+ $for_update[$table.'.'.$fieldname] = 'Added index '.$table.' '.$index;
+ }
+
+ // Remove the original table creation query from processing
+ unset($cqueries[strtolower($table)]);
+ unset($for_update[strtolower($table)]);
+ } else {
+ // This table exists in the database, but not in the creation queries?
+ }
+ }
+ }
+
+ $allqueries = array_merge($cqueries, $iqueries);
+ if($execute) {
+ foreach($allqueries as $query) {
+ //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">".print_r($query, true)."</pre>\n";
+ $wpdb->query($query);
+ }
+ }
+
+ return $for_update;
+}
+
+function make_db_current() {
+ global $wp_queries;
+
+ $alterations = dbDelta($wp_queries);
+ echo "<ol>\n";
+ foreach($alterations as $alteration) echo "<li>$alteration</li>\n";
+ echo "</ol>\n";
+}
+
+function make_db_current_silent() {
+ global $wp_queries;
+
+ $alterations = dbDelta($wp_queries);
+}
+
+function make_site_theme_from_oldschool($theme_name, $template) {
+ $home_path = get_home_path();
+ $site_dir = ABSPATH . "wp-content/themes/$template";
+
+ if (! file_exists("$home_path/index.php"))
+ return false;
+
+ // Copy files from the old locations to the site theme.
+ // TODO: This does not copy arbitarary include dependencies. Only the
+ // standard WP files are copied.
+ $files = array('index.php' => 'index.php', 'wp-layout.css' => 'style.css', 'wp-comments.php' => 'comments.php', 'wp-comments-popup.php' => 'comments-popup.php');
+
+ foreach ($files as $oldfile => $newfile) {
+ if ($oldfile == 'index.php')
+ $oldpath = $home_path;
+ else
+ $oldpath = ABSPATH;
+
+ if ($oldfile == 'index.php') { // Check to make sure it's not a new index
+ $index = implode('', file("$oldpath/$oldfile"));
+ if ( strstr( $index, 'WP_USE_THEMES' ) ) {
+ if (! @copy(ABSPATH . 'wp-content/themes/default/index.php', "$site_dir/$newfile"))
+ return false;
+ continue; // Don't copy anything
+ }
+ }
+
+ if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile"))
+ return false;
+
+ chmod("$site_dir/$newfile", 0777);
+
+ // Update the blog header include in each file.
+ $lines = explode("\n", implode('', file("$site_dir/$newfile")));
+ if ($lines) {
+ $f = fopen("$site_dir/$newfile", 'w');
+
+ foreach ($lines as $line) {
+ if (preg_match('/require.*wp-blog-header/', $line))
+ $line = '//' . $line;
+
+ // Update stylesheet references.
+ $line = str_replace("<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line);
+
+ // Update comments template inclusion.
+ $line = str_replace("<?php include(ABSPATH . 'wp-comments.php'); ?>", "<?php comments_template(); ?>", $line);
+
+ fwrite($f, "{$line}\n");
+ }
+ fclose($f);
+ }
+ }
+
+ // Add a theme header.
+ $header = "/*\nTheme Name: $theme_name\nTheme URI: " . __get_option('siteurl') . "\nDescription: A theme automatically created by the upgrade.\nVersion: 1.0\nAuthor: Moi\n*/\n";
+
+ $stylelines = file_get_contents("$site_dir/style.css");
+ if ($stylelines) {
+ $f = fopen("$site_dir/style.css", 'w');
+
+ fwrite($f, $header);
+ fwrite($f, $stylelines);
+ fclose($f);
+ }
+
+ return true;
+}
+
+function make_site_theme_from_default($theme_name, $template) {
+ $site_dir = ABSPATH . "wp-content/themes/$template";
+ $default_dir = ABSPATH . 'wp-content/themes/default';
+
+ // Copy files from the default theme to the site theme.
+ //$files = array('index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css');
+
+ $theme_dir = @ dir("$default_dir");
+ if ($theme_dir) {
+ while(($theme_file = $theme_dir->read()) !== false) {
+ if (is_dir("$default_dir/$theme_file"))
+ continue;
+ if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file"))
+ return;
+ chmod("$site_dir/$theme_file", 0777);
+ }
+ }
+
+ // Rewrite the theme header.
+ $stylelines = explode("\n", implode('', file("$site_dir/style.css")));
+ if ($stylelines) {
+ $f = fopen("$site_dir/style.css", 'w');
+
+ foreach ($stylelines as $line) {
+ if (strstr($line, "Theme Name:")) $line = "Theme Name: $theme_name";
+ elseif (strstr($line, "Theme URI:")) $line = "Theme URI: " . __get_option('siteurl');
+ elseif (strstr($line, "Description:")) $line = "Description: Your theme";
+ elseif (strstr($line, "Version:")) $line = "Version: 1";
+ elseif (strstr($line, "Author:")) $line = "Author: You";
+ fwrite($f, "{$line}\n");
+ }
+ fclose($f);
+ }
+
+ // Copy the images.
+ umask(0);
+ if (! mkdir("$site_dir/images", 0777)) {
+ return false;
+ }
+
+ $images_dir = @ dir("$default_dir/images");
+ if ($images_dir) {
+ while(($image = $images_dir->read()) !== false) {
+ if (is_dir("$default_dir/images/$image"))
+ continue;
+ if (! @copy("$default_dir/images/$image", "$site_dir/images/$image"))
+ return;
+ chmod("$site_dir/images/$image", 0777);
+ }
+ }
+}
+
+// Create a site theme from the default theme.
+function make_site_theme() {
+ return true;
+ // Name the theme after the blog.
+ $theme_name = __get_option('blogname');
+ $template = sanitize_title($theme_name);
+ $site_dir = ABSPATH . "wp-content/themes/$template";
+
+ // If the theme already exists, nothing to do.
+ if ( is_dir($site_dir)) {
+ return false;
+ }
+
+ // We must be able to write to the themes dir.
+ if (! is_writable(ABSPATH . "wp-content/themes")) {
+ return false;
+ }
+
+ umask(0);
+ if (! mkdir($site_dir, 0777)) {
+ return false;
+ }
+
+ if (file_exists(ABSPATH . 'wp-layout.css')) {
+ if (! make_site_theme_from_oldschool($theme_name, $template)) {
+ // TODO: rm -rf the site theme directory.
+ return false;
+ }
+ } else {
+ if (! make_site_theme_from_default($theme_name, $template))
+ // TODO: rm -rf the site theme directory.
+ return false;
+ }
+
+ // Make the new site theme active.
+ $current_template = __get_option('template');
+ if ($current_template == 'default') {
+ update_option('template', $template);
+ update_option('stylesheet', $template);
+ }
+ return $template;
+}
+
+function translate_level_to_role($level) {
+ switch ($level) {
+ case 10:
+ case 9:
+ case 8:
+ return 'administrator';
+ case 7:
+ case 6:
+ case 5:
+ return 'editor';
+ case 4:
+ case 3:
+ case 2:
+ return 'author';
+ case 1:
+ return 'contributor';
+ case 0:
+ return 'subscriber';
+ }
+}
+
+?>
diff --git a/wp-admin/upgrade-schema.php b/wp-admin/upgrade-schema.php
new file mode 100644
index 0000000..702fe4c
--- /dev/null
+++ b/wp-admin/upgrade-schema.php
@@ -0,0 +1,467 @@
+<?php
+// Here we keep the DB structure and option values
+
+global $wp_queries;
+
+$wp_queries="CREATE TABLE $wpdb->categories (
+ cat_ID bigint(20) NOT NULL auto_increment,
+ cat_name varchar(55) NOT NULL default '',
+ category_nicename varchar(200) NOT NULL default '',
+ category_description longtext NOT NULL,
+ category_parent bigint(20) NOT NULL default '0',
+ category_count bigint(20) NOT NULL default '0',
+ link_count bigint(20) NOT NULL default '0',
+ posts_private tinyint(1) NOT NULL default '0',
+ links_private tinyint(1) NOT NULL default '0',
+ PRIMARY KEY (cat_ID),
+ KEY category_nicename (category_nicename)
+) TYPE=MyISAM;
+CREATE TABLE $wpdb->comments (
+ comment_ID bigint(20) unsigned NOT NULL auto_increment,
+ comment_post_ID int(11) NOT NULL default '0',
+ comment_author tinytext NOT NULL,
+ comment_author_email varchar(100) NOT NULL default '',
+ comment_author_url varchar(200) NOT NULL default '',
+ comment_author_IP varchar(100) NOT NULL default '',
+ comment_date datetime NOT NULL default '0000-00-00 00:00:00',
+ comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
+ comment_content text NOT NULL,
+ comment_karma int(11) NOT NULL default '0',
+ comment_approved enum('0','1','spam') NOT NULL default '1',
+ comment_agent varchar(255) NOT NULL default '',
+ comment_type varchar(20) NOT NULL default '',
+ comment_parent bigint(20) NOT NULL default '0',
+ user_id bigint(20) NOT NULL default '0',
+ PRIMARY KEY (comment_ID),
+ KEY comment_approved (comment_approved),
+ KEY comment_post_ID (comment_post_ID)
+) TYPE=MyISAM;
+CREATE TABLE $wpdb->link2cat (
+ rel_id bigint(20) NOT NULL auto_increment,
+ link_id bigint(20) NOT NULL default '0',
+ category_id bigint(20) NOT NULL default '0',
+ PRIMARY KEY (rel_id),
+ KEY link_id (link_id,category_id)
+) TYPE=MyISAM;
+CREATE TABLE $wpdb->links (
+ link_id bigint(20) NOT NULL auto_increment,
+ link_url varchar(255) NOT NULL default '',
+ link_name varchar(255) NOT NULL default '',
+ link_image varchar(255) NOT NULL default '',
+ link_target varchar(25) NOT NULL default '',
+ link_category bigint(20) NOT NULL default '0',
+ link_description varchar(255) NOT NULL default '',
+ link_visible enum('Y','N') NOT NULL default 'Y',
+ link_owner int(11) NOT NULL default '1',
+ link_rating int(11) NOT NULL default '0',
+ link_updated datetime NOT NULL default '0000-00-00 00:00:00',
+ link_rel varchar(255) NOT NULL default '',
+ link_notes mediumtext NOT NULL,
+ link_rss varchar(255) NOT NULL default '',
+ PRIMARY KEY (link_id),
+ KEY link_category (link_category),
+ KEY link_visible (link_visible)
+) TYPE=MyISAM;
+CREATE TABLE $wpdb->options (
+ option_id bigint(20) NOT NULL auto_increment,
+ blog_id int(11) NOT NULL default '0',
+ option_name varchar(64) NOT NULL default '',
+ option_can_override enum('Y','N') NOT NULL default 'Y',
+ option_type int(11) NOT NULL default '1',
+ option_value longtext NOT NULL,
+ option_width int(11) NOT NULL default '20',
+ option_height int(11) NOT NULL default '8',
+ option_description tinytext NOT NULL,
+ option_admin_level int(11) NOT NULL default '1',
+ autoload enum('yes','no') NOT NULL default 'yes',
+ PRIMARY KEY (option_id,blog_id,option_name),
+ KEY option_name (option_name)
+) TYPE=MyISAM;
+CREATE TABLE $wpdb->post2cat (
+ rel_id bigint(20) NOT NULL auto_increment,
+ post_id bigint(20) NOT NULL default '0',
+ category_id bigint(20) NOT NULL default '0',
+ PRIMARY KEY (rel_id),
+ KEY post_id (post_id,category_id)
+) TYPE=MyISAM;
+CREATE TABLE $wpdb->postmeta (
+ meta_id bigint(20) NOT NULL auto_increment,
+ post_id bigint(20) NOT NULL default '0',
+ meta_key varchar(255) default NULL,
+ meta_value longtext,
+ PRIMARY KEY (meta_id),
+ KEY post_id (post_id),
+ KEY meta_key (meta_key)
+) TYPE=MyISAM;
+CREATE TABLE $wpdb->posts (
+ ID bigint(20) unsigned NOT NULL auto_increment,
+ post_author bigint(20) NOT NULL default '0',
+ post_date datetime NOT NULL default '0000-00-00 00:00:00',
+ post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
+ post_content longtext NOT NULL,
+ post_title text NOT NULL,
+ post_category int(4) NOT NULL default '0',
+ post_excerpt text NOT NULL,
+ post_status enum('publish','draft','private','static','object','attachment','inherit','future') NOT NULL default 'publish',
+ comment_status enum('open','closed','registered_only') NOT NULL default 'open',
+ ping_status enum('open','closed') NOT NULL default 'open',
+ post_password varchar(20) NOT NULL default '',
+ post_name varchar(200) NOT NULL default '',
+ to_ping text NOT NULL,
+ pinged text NOT NULL,
+ post_modified datetime NOT NULL default '0000-00-00 00:00:00',
+ post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00',
+ post_content_filtered text NOT NULL,
+ post_parent bigint(20) NOT NULL default '0',
+ guid varchar(255) NOT NULL default '',
+ menu_order int(11) NOT NULL default '0',
+ post_type varchar(20) NOT NULL default 'post',
+ post_mime_type varchar(100) NOT NULL default '',
+ comment_count bigint(20) NOT NULL default '0',
+ PRIMARY KEY (ID),
+ KEY post_name (post_name),
+ KEY type_status_date (post_type, post_status, post_date, ID)
+) TYPE=MyISAM;
+CREATE TABLE $wpdb->users (
+ ID bigint(20) unsigned NOT NULL auto_increment,
+ user_login varchar(60) NOT NULL default '',
+ user_pass varchar(64) NOT NULL default '',
+ user_nicename varchar(50) NOT NULL default '',
+ user_email varchar(100) NOT NULL default '',
+ user_url varchar(100) NOT NULL default '',
+ user_registered datetime NOT NULL default '0000-00-00 00:00:00',
+ user_activation_key varchar(60) NOT NULL default '',
+ user_status int(11) NOT NULL default '0',
+ display_name varchar(250) NOT NULL default '',
+ spam tinyint(2) NOT NULL default '0',
+ deleted tinyint(2) NOT NULL default '0',
+ PRIMARY KEY (ID),
+ KEY user_login_key (user_login)
+);
+CREATE TABLE $wpdb->usermeta (
+ umeta_id bigint(20) NOT NULL auto_increment,
+ user_id bigint(20) NOT NULL default '0',
+ meta_key varchar(255) default NULL,
+ meta_value longtext,
+ PRIMARY KEY (umeta_id),
+ KEY user_id (user_id),
+ KEY meta_key (meta_key)
+);
+CREATE TABLE $wpdb->blogs (
+ blog_id bigint(20) NOT NULL auto_increment,
+ site_id bigint(20) NOT NULL default '0',
+ domain varchar(200) NOT NULL default '',
+ path varchar(100) NOT NULL default '',
+ registered datetime NOT NULL default '0000-00-00 00:00:00',
+ last_updated datetime NOT NULL default '0000-00-00 00:00:00',
+ public tinyint(2) NOT NULL default '1',
+ archived enum('0','1') NOT NULL default '0',
+ mature tinyint(2) NOT NULL default '0',
+ spam tinyint(2) NOT NULL default '0',
+ deleted tinyint(2) NOT NULL default '0',
+ lang_id int(11) NOT NULL default '0',
+ PRIMARY KEY (blog_id),
+ KEY domain (domain(50),path(5)),
+ KEY lang_id (lang_id)
+);
+CREATE TABLE wp_blog_versions (
+ blog_id bigint(20) NOT NULL default '0',
+ db_version varchar(20) NOT NULL default '',
+ last_updated datetime NOT NULL default '0000-00-00 00:00:00',
+ PRIMARY KEY (blog_id),
+ KEY db_version (db_version)
+);
+CREATE TABLE wp_registration_log (
+ ID bigint(20) NOT NULL auto_increment,
+ email varchar(255) NOT NULL default '',
+ IP varchar(30) NOT NULL default '',
+ blog_id bigint(20) NOT NULL default '0',
+ t timestamp NOT NULL,
+ PRIMARY KEY (ID),
+ KEY IP (IP)
+);
+CREATE TABLE $wpdb->site (
+ id bigint(20) NOT NULL auto_increment,
+ domain varchar(200) NOT NULL default '',
+ path varchar(100) NOT NULL default '',
+ PRIMARY KEY (id),
+ KEY domain (domain,path)
+);
+CREATE TABLE $wpdb->sitemeta (
+ meta_id bigint(20) NOT NULL auto_increment,
+ site_id bigint(20) NOT NULL default '0',
+ meta_key varchar(255) default NULL,
+ meta_value longtext,
+ PRIMARY KEY (meta_id),
+ KEY meta_key (meta_key),
+ KEY site_id (site_id)
+);
+CREATE TABLE $wpdb->sitecategories (
+ cat_ID bigint(20) NOT NULL auto_increment,
+ cat_name varchar(55) NOT NULL default '',
+ category_nicename varchar(200) NOT NULL default '',
+ last_updated timestamp NOT NULL,
+ PRIMARY KEY (cat_ID),
+ KEY category_nicename (category_nicename),
+ KEY last_updated (last_updated)
+);
+CREATE TABLE $wpdb->signups (
+ domain varchar(200) NOT NULL default '',
+ path varchar(100) NOT NULL default '',
+ title longtext NOT NULL,
+ user_login varchar(60) NOT NULL default '',
+ user_email varchar(100) NOT NULL default '',
+ registered datetime NOT NULL default '0000-00-00 00:00:00',
+ activated datetime NOT NULL default '0000-00-00 00:00:00',
+ active tinyint(1) NOT NULL default '0',
+ activation_key varchar(50) NOT NULL default '',
+ meta longtext,
+ KEY activation_key (activation_key),
+ KEY domain (domain)
+);
+";
+
+function populate_options() {
+ global $wpdb, $wp_db_version, $wpblog, $current_site;
+
+ $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
+ $guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
+ add_option('siteurl', $guessurl, __('WordPress web address'));
+ add_option('blogname', __('My Weblog'), __('Blog title'));
+ add_option('blogdescription', __('Just another ' . $current_site->site_name . ' weblog'), __('Short tagline'));
+ add_option('new_users_can_blog', 0);
+ add_option('users_can_register', 0);
+ add_option('admin_email', 'you@example.com');
+ add_option('start_of_week', 1);
+ add_option('use_balanceTags', 0);
+ add_option('use_smilies', 1);
+ add_option('require_name_email', 1);
+ add_option('comments_notify', 1);
+ add_option('posts_per_rss', 10);
+ add_option('rss_excerpt_length', 50);
+ add_option('rss_use_excerpt', 0);
+ add_option('mailserver_url', 'mail.example.com');
+ add_option('mailserver_login', 'login@example.com');
+ add_option('mailserver_pass', 'password');
+ add_option('mailserver_port', 110);
+ add_option('default_category', 1);
+ add_option('default_comment_status', 'open');
+ add_option('default_ping_status', 'open');
+ add_option('default_pingback_flag', 1);
+ add_option('default_post_edit_rows', 10);
+ add_option('posts_per_page', 10);
+ add_option('what_to_show', 'posts');
+ add_option('date_format', __('F j, Y'));
+ add_option('time_format', __('g:i a'));
+ add_option('links_updated_date_format', __('F j, Y g:i a'));
+ add_option('links_recently_updated_prepend', '<em>');
+ add_option('links_recently_updated_append', '</em>');
+ add_option('links_recently_updated_time', 120);
+ add_option('comment_moderation', 0);
+ add_option('moderation_notify', 1);
+ add_option('permalink_structure', '/%year%/%monthnum%/%day%/%postname%/');
+ add_option('gzipcompression', 0);
+ add_option('hack_file', 0);
+ add_option('blog_charset', 'UTF-8');
+ add_option('moderation_keys');
+ add_option('active_plugins');
+ add_option('home', $guessurl);
+ // in case it is set, but blank, update "home"
+ if ( !__get_option('home') ) update_option('home', $guessurl);
+ add_option('category_base');
+ add_option('ping_sites', 'http://rpc.pingomatic.com/');
+ add_option('advanced_edit', 0);
+ add_option('comment_max_links', 2);
+ add_option('gmt_offset', date('Z') / 3600);
+ // 1.5
+ add_option('default_email_category', 1, __('Posts by email go to this category'));
+ add_option('recently_edited');
+ add_option('use_linksupdate', 0);
+ add_option('template', 'default');
+ add_option('stylesheet', 'default');
+ add_option('comment_whitelist', 0);
+ add_option('page_uris');
+ add_option('blacklist_keys');
+ add_option('comment_registration', 0);
+ add_option('open_proxy_check', 1);
+ add_option('rss_language', 'en');
+ add_option('html_type', 'text/html');
+ // 1.5.1
+ add_option('use_trackback', 0);
+ // 2.0
+ add_option('default_role', 'subscriber');
+ add_option('rich_editing', 'true');
+ add_option('db_version', $wp_db_version);
+ // 2.0.1
+ if ( ini_get('safe_mode') ) {
+ // Safe mode screws up mkdir(), so we must use a flat structure.
+ add_option('uploads_use_yearmonth_folders', 0);
+ add_option('upload_path', 'wp-content');
+ } else {
+ add_option('uploads_use_yearmonth_folders', 1);
+ add_option('upload_path', 'wp-content/uploads');
+ }
+
+ // 2.0.3
+ add_option('secret', md5(uniqid(microtime())));
+
+ // 2.1
+ add_option('blog_public', '1');
+ add_option('default_link_category', 2);
+ add_option('show_on_front', 'posts');
+
+ add_site_option( 'customizefeed1', '0' );
+ add_site_option( 'customizefeed2', '0' );
+ add_site_option( 'dashboardfeed1', 'http://wordpress.org/development/feed/' );
+ add_site_option( 'dashboardfeed2', 'http://planet.wordpress.org/feed/' );
+ add_site_option( 'dashboardfeed1name', 'WordPress Development Blog' );
+ add_site_option( 'dashboardfeed2name', 'Other WordPress News' );
+
+ // Delete unused options
+ $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog');
+ foreach ($unusedoptions as $option) :
+ delete_option($option);
+ endforeach;
+
+ // Set up a few options not to load by default
+ $fatoptions = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' );
+ foreach ($fatoptions as $fatoption) :
+ $wpdb->query("UPDATE $wpdb->options SET `autoload` = 'no' WHERE option_name = '$fatoption'");
+ endforeach;
+}
+
+function populate_roles() {
+ populate_roles_160();
+ populate_roles_210();
+}
+
+function populate_roles_160() {
+ global $wp_roles;
+
+ // Add roles
+ add_role('administrator', __('Administrator'));
+ add_role('editor', __('Editor'));
+ add_role('author', __('Author'));
+ add_role('contributor', __('Contributor'));
+ add_role('subscriber', __('Subscriber'));
+
+ // Add caps for Administrator role
+ $role = get_role('administrator');
+ $role->add_cap('switch_themes');
+ $role->add_cap('edit_themes');
+ $role->add_cap('activate_plugins');
+ $role->add_cap('edit_plugins');
+ $role->add_cap('edit_users');
+ $role->add_cap('edit_files');
+ $role->add_cap('manage_options');
+ $role->add_cap('moderate_comments');
+ $role->add_cap('manage_categories');
+ $role->add_cap('manage_links');
+ $role->add_cap('upload_files');
+ $role->add_cap('import');
+ $role->add_cap('edit_posts');
+ $role->add_cap('edit_others_posts');
+ $role->add_cap('edit_published_posts');
+ $role->add_cap('publish_posts');
+ $role->add_cap('edit_pages');
+ $role->add_cap('read');
+ $role->add_cap('level_10');
+ $role->add_cap('level_9');
+ $role->add_cap('level_8');
+ $role->add_cap('level_7');
+ $role->add_cap('level_6');
+ $role->add_cap('level_5');
+ $role->add_cap('level_4');
+ $role->add_cap('level_3');
+ $role->add_cap('level_2');
+ $role->add_cap('level_1');
+ $role->add_cap('level_0');
+
+ // Add caps for Editor role
+ $role = get_role('editor');
+ $role->add_cap('moderate_comments');
+ $role->add_cap('manage_categories');
+ $role->add_cap('manage_links');
+ $role->add_cap('upload_files');
+ $role->add_cap('edit_posts');
+ $role->add_cap('edit_others_posts');
+ $role->add_cap('edit_published_posts');
+ $role->add_cap('publish_posts');
+ $role->add_cap('edit_pages');
+ $role->add_cap('read');
+ $role->add_cap('level_7');
+ $role->add_cap('level_6');
+ $role->add_cap('level_5');
+ $role->add_cap('level_4');
+ $role->add_cap('level_3');
+ $role->add_cap('level_2');
+ $role->add_cap('level_1');
+ $role->add_cap('level_0');
+
+ // Add caps for Author role
+ $role = get_role('author');
+ $role->add_cap('upload_files');
+ $role->add_cap('edit_posts');
+ $role->add_cap('edit_published_posts');
+ $role->add_cap('publish_posts');
+ $role->add_cap('read');
+ $role->add_cap('level_2');
+ $role->add_cap('level_1');
+ $role->add_cap('level_0');
+
+ // Add caps for Contributor role
+ $role = get_role('contributor');
+ $role->add_cap('edit_posts');
+ $role->add_cap('read');
+ $role->add_cap('level_1');
+ $role->add_cap('level_0');
+
+ // Add caps for Subscriber role
+ $role = get_role('subscriber');
+ $role->add_cap('read');
+ $role->add_cap('level_0');
+}
+
+function populate_roles_210() {
+ $roles = array('administrator', 'editor');
+ foreach ($roles as $role) {
+ $role = get_role($role);
+ if ( empty($role) )
+ continue;
+
+ $role->add_cap('edit_others_pages');
+ $role->add_cap('edit_published_pages');
+ $role->add_cap('publish_pages');
+ $role->add_cap('delete_pages');
+ $role->add_cap('delete_others_pages');
+ $role->add_cap('delete_published_pages');
+ $role->add_cap('delete_posts');
+ $role->add_cap('delete_others_posts');
+ $role->add_cap('delete_published_posts');
+ $role->add_cap('delete_private_posts');
+ $role->add_cap('edit_private_posts');
+ $role->add_cap('read_private_posts');
+ $role->add_cap('delete_private_pages');
+ $role->add_cap('edit_private_pages');
+ $role->add_cap('read_private_pages');
+ }
+
+ $role = get_role('administrator');
+ if ( ! empty($role) ) {
+ $role->add_cap('delete_users');
+ $role->add_cap('create_users');
+ }
+
+ $role = get_role('author');
+ if ( ! empty($role) ) {
+ $role->add_cap('delete_posts');
+ $role->add_cap('delete_published_posts');
+ }
+
+ $role = get_role('contributor');
+ if ( ! empty($role) ) {
+ $role->add_cap('delete_posts');
+ }
+}
+
+?>
diff --git a/wp-admin/upgrade.php b/wp-admin/upgrade.php
new file mode 100644
index 0000000..66f3fec
--- /dev/null
+++ b/wp-admin/upgrade.php
@@ -0,0 +1,106 @@
+<?php
+define('WP_INSTALLING', true);
+if (!file_exists('../wp-config.php')) die("There doesn't seem to be a wp-config.php file. Double check that you updated wp-config-sample.php with the proper database connection information and renamed it to wp-config.php.");
+require('../wp-config.php');
+timer_start();
+require_once(ABSPATH . '/wp-admin/upgrade-functions.php');
+
+$step = $_GET['step'];
+if (!$step) $step = 0;
+header( 'Content-Type: text/html; charset=utf-8' );
+?>
+<!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">
+<head>
+ <title>WordPress &rsaquo; Upgrade</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <style media="screen" type="text/css">
+ <!--
+ html {
+ background: #eee;
+ }
+ body {
+ background: #fff;
+ color: #000;
+ font-family: Georgia, "Times New Roman", Times, serif;
+ margin-left: 20%;
+ margin-right: 20%;
+ padding: .2em 2em;
+ }
+
+ h1 {
+ color: #006;
+ font-size: 18px;
+ font-weight: lighter;
+ }
+
+ h2 {
+ font-size: 16px;
+ }
+
+ p, li, dt {
+ line-height: 140%;
+ padding-bottom: 2px;
+ }
+
+ ul, ol {
+ padding: 5px 5px 5px 20px;
+ }
+ #logo {
+ margin-bottom: 2em;
+ }
+.step a, .step input {
+ font-size: 2em;
+}
+.step, th {
+ text-align: right;
+}
+#footer {
+text-align: center; border-top: 1px solid #ccc; padding-top: 1em; font-style: italic;
+}
+ -->
+ </style>
+</head>
+<body>
+<h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1>
+<?php
+switch($step) {
+
+ case 0:
+ $goback = wp_specialchars($_SERVER['HTTP_REFERER'], 1);
+?>
+<p><?php _e('This file upgrades you from any previous version of WordPress to the latest. It may take a while though, so be patient.'); ?></p>
+ <h2 class="step"><a href="upgrade.php?step=1&amp;backto=<?php echo $goback; ?>"><?php _e('Upgrade WordPress &raquo;'); ?></a></h2>
+<?php
+ break;
+
+ case 1:
+ wp_upgrade();
+ if( $wpdb->get_row( "SELECT blog_id FROM wp_blog_versions WHERE blog_id = '{$wpdb->blogid}'" ) ) {
+ $wpdb->query( "UPDATE wp_blog_versions SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" );
+ } else {
+ $wpdb->query( "INSERT INTO wp_blog_versions ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" );
+ }
+
+ if ( empty( $_GET['backto'] ) )
+ $backto = __get_option('home');
+ else
+ $backto = wp_specialchars( $_GET['backto'] , 1 );
+?>
+<h2><?php _e('Step 1'); ?></h2>
+ <p><?php printf(__("There's actually only one step. So if you see this, you're done. <a href='%s'>Have fun</a>!"), $backto); ?></p>
+
+<!--
+<pre>
+<?php printf(__('%s queries'), $wpdb->num_queries); ?>
+
+<?php printf(__('%s seconds'), timer_stop(0)); ?>
+</pre>
+-->
+
+<?php
+ break;
+}
+?>
+</body>
+</html>
diff --git a/wp-admin/user-edit.php b/wp-admin/user-edit.php
new file mode 100644
index 0000000..0aff941
--- /dev/null
+++ b/wp-admin/user-edit.php
@@ -0,0 +1,280 @@
+<?php
+require_once('admin.php');
+
+$title = __('Edit User');
+if ( current_user_can('edit_users') )
+ $parent_file = 'users.php';
+else
+ $parent_file = 'profile.php';
+$submenu_file = 'users.php';
+
+$wpvarstoreset = array('action', 'redirect', 'profile', 'user_id', 'wp_http_referer');
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+$wp_http_referer = remove_query_arg(array('update', 'delete_count'), stripslashes($wp_http_referer));
+$errors = array();
+
+// Only allow site admins to edit every user.
+if( is_site_admin() == false )
+ if( $user_id != $current_user->ID ) $errors = new WP_Error('head', __('You do not have permission to edit this user.'));
+
+switch ($action) {
+case 'switchposts':
+
+check_admin_referer();
+
+/* TODO: Switch all posts from one user to another user */
+
+break;
+
+case 'update':
+
+check_admin_referer('update-user_' . $user_id);
+
+if ( !current_user_can('edit_user', $user_id) )
+ $errors = new WP_Error('head', __('You do not have permission to edit this user.'));
+else
+ if( isset( $errors ) == false ) $errors = edit_user($user_id);
+
+if( !is_wp_error( $errors ) ) {
+ if( is_site_admin() )
+ update_usermeta( $user_id, 'invites_left', intval( $_POST[ 'invites_left' ] ) );
+ $redirect = "user-edit.php?user_id=$user_id&updated=true";
+ $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
+ header("Location: $redirect");
+ exit;
+}
+
+default:
+include ('admin-header.php');
+
+$profileuser = new WP_User($user_id);
+
+if ( !current_user_can('edit_user', $user_id) )
+ if ( !is_wp_error( $errors ) )
+ $errors = new WP_Error('head', __('You do not have permission to edit this user.'));
+?>
+
+<?php if ( isset($_GET['updated']) ) : ?>
+<div id="message" class="updated fade">
+ <p><strong><?php _e('User updated.') ?></strong></p>
+ <?php if ( $wp_http_referer ) : ?>
+ <p><a href="<?php echo wp_specialchars($wp_http_referer); ?>"><?php _e('&laquo; Back to Authors and Users'); ?></a></p>
+ <?php endif; ?>
+</div>
+<?php endif; ?>
+<?php if ( is_wp_error( $errors ) ) { ?>
+<div class="error">
+ <ul>
+ <?php
+ foreach( $errors->get_error_messages() as $message )
+ echo "<li>$message</li>";
+ ?>
+ </ul>
+</div>
+<?php } else { ?>
+
+<div class="wrap">
+<h2><?php _e('Edit User'); ?></h2>
+
+<form name="profile" id="your-profile" action="user-edit.php" method="post">
+<?php wp_nonce_field('update-user_' . $user_id) ?>
+<?php if ( $wp_http_referer ) : ?>
+ <input type="hidden" name="wp_http_referer" value="<?php echo wp_specialchars($wp_http_referer); ?>" />
+<?php endif; ?>
+<p>
+<input type="hidden" name="from" value="profile" />
+<input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" />
+</p>
+
+<fieldset>
+<legend><?php _e('Name'); ?></legend>
+<p><label><?php _e('Username: (no editing)'); ?><br />
+<input type="text" name="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" />
+</label></p>
+<?php if( is_site_admin() ) {?>
+ <p><label><?php _e('Invites Left:') ?><br />
+ <input type="text" name="invites_left" id="invites_left" value="<?php echo get_usermeta( $user_id, 'invites_left' ) ?>" /></label></p>
+ <?php
+} // is_site_admin
+?>
+
+<p><label><?php _e('Role:') ?><br />
+<?php
+// print_r($profileuser);
+echo '<select name="role">';
+$role_list = '';
+$user_has_role = false;
+foreach($wp_roles->role_names as $role => $name) {
+ if ( $profileuser->has_cap($role) ) {
+ $selected = ' selected="selected"';
+ $user_has_role = true;
+ } else {
+ $selected = '';
+ }
+ $role_list .= "<option value=\"{$role}\"{$selected}>{$name}</option>";
+}
+if ( $user_has_role )
+ $role_list .= '<option value="">' . __('&mdash; No role for this blog &mdash;') . '</option>';
+else
+ $role_list .= '<option value="" selected="selected">' . __('&mdash; No role for this blog &mdash;') . '</option>';
+echo $role_list . '</select>';
+?></label></p>
+
+<p><label><?php _e('First name:') ?><br />
+<input type="text" name="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>
+
+<p><label><?php _e('Nickname:') ?><br />
+<input type="text" name="nickname" value="<?php echo $profileuser->nickname ?>" /></label></p>
+
+</p><label><?php _e('Display name publicly as:') ?> <br />
+<select name="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>
+<?php if ( !empty( $profileuser->first_name ) ) : ?>
+<option value="<?php echo $profileuser->first_name ?>"><?php echo $profileuser->first_name ?></option>
+<?php endif; ?>
+<?php if ( !empty( $profileuser->last_name ) ) : ?>
+<option value="<?php echo $profileuser->last_name ?>"><?php echo $profileuser->last_name ?></option>
+<?php endif; ?>
+<?php if ( !empty( $profileuser->first_name ) && !empty( $profileuser->last_name ) ) : ?>
+<option value="<?php echo $profileuser->first_name." ".$profileuser->last_name ?>"><?php echo $profileuser->first_name." ".$profileuser->last_name ?></option>
+<option value="<?php echo $profileuser->last_name." ".$profileuser->first_name ?>"><?php echo $profileuser->last_name." ".$profileuser->first_name ?></option>
+<?php endif; ?>
+</select></label></p>
+</fieldset>
+
+<fieldset>
+<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>
+
+<p><label><?php _e('Website:') ?><br />
+<input type="text" name="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 ?>" />
+</label></p>
+
+<p><label><?php _e('Yahoo IM:') ?><br />
+<input type="text" name="yim" value="<?php echo $profileuser->yim ?>" />
+</label></p>
+
+<p><label><?php _e('Jabber / Google Talk:') ?>
+<input type="text" name="jabber" value="<?php echo $profileuser->jabber ?>" /></label>
+</p>
+</fieldset>
+<br clear="all" />
+<fieldset>
+<legend><?php _e('About the user'); ?></legend>
+<p class="desc"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></p>
+<p><textarea name="description" rows="5" cols="30"><?php echo $profileuser->description ?></textarea></p>
+</fieldset>
+
+<?php
+$show_password_fields = apply_filters('show_password_fields', true);
+if ( $show_password_fields ) :
+?>
+<fieldset>
+<legend><?php _e("Update User's Password"); ?></legend>
+<p class="desc"><?php _e("If you would like to change the user's 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="" />
+</label></p>
+<p><label><?php _e('Type it one more time:'); ?><br />
+<input type="password" name="pass2" size="16" value="" />
+</label></p>
+</fieldset>
+<?php endif; ?>
+
+<?php do_action('edit_user_profile'); ?>
+
+<br clear="all" />
+ <table width="99%" border="0" cellspacing="2" cellpadding="3" class="editform">
+ <?php
+ if(count($profileuser->caps) > count($profileuser->roles)):
+ ?>
+ <tr>
+ <th scope="row"><?php _e('Additional Capabilities:') ?></th>
+ <td><?php
+ $output = '';
+ foreach($profileuser->caps as $cap => $value) {
+ if(!$wp_roles->is_role($cap)) {
+ if($output != '') $output .= ', ';
+ $output .= $value ? $cap : "Denied: {$cap}";
+ }
+ }
+ echo $output;
+ ?></td>
+ </tr>
+ <?php
+ endif;
+ ?>
+ </table>
+<p class="submit">
+ <input type="hidden" name="action" value="update" />
+ <input type="hidden" name="user_id" id="user_id" value="<?php echo $user_id; ?>" />
+ <input type="submit" value="<?php _e('Update User &raquo;') ?>" name="submit" />
+ </p>
+</form>
+</div>
+<?php
+$invites_list = get_usermeta( intval( $_GET[ 'user_id' ] ), "invites_list" );
+if( $invites_list != '' )
+{
+ if( strlen( $invites_list ) > 3 ) {
+ ?><div class="wrap">
+ <h3>Invited Users</h3>
+ <table><?php
+ $invites = explode( " ", $invites_list );
+ reset( $invites );
+ while( list( $key, $val ) = each( $invites ) ) {
+ if( $val != "" ) {
+ $id = $wpdb->get_row( "SELECT ID FROM {$wpdb->users} WHERE user_email = '$val'" );
+ if( $id ) {
+ $invited_user_id = $id->ID;
+ } else {
+ $invited_user_id = $wpdb->get_var( "SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = 'invite_hash' AND meta_value = '" . md5( $val ) . "'" );
+ }
+
+ if( $invited_user_id != 0 ) {
+ $invited_user_blog = $wpdb->get_var( "SELECT meta_value FROM $wpdb->usermeta WHERE user_id = '$invited_user_id' AND meta_key='source_domain'" );
+ } else {
+ $invited_user_blog = '';
+ }
+ $invited_user_login = $wpdb->get_var( "SELECT user_login FROM $wpdb->users WHERE ID = '$invited_user_id'" );
+ if( $invited_user_blog != '' ) {
+ print "<tr><td>$val</td><td>$invited_user_login</td><td><a href='http://{$invited_user_blog}'>http://$invited_user_blog</a></td></tr>";
+ } else {
+ print "<tr><td>$val</td><td>$invited_user_login</td><td><em>Invite Not Used Yet</em></td></tr>";
+ }
+ }
+ }
+ ?></table></div><?php
+ }
+}
+}
+break;
+}
+
+include('admin-footer.php');
+?>
diff --git a/wp-admin/users.js b/wp-admin/users.js
new file mode 100644
index 0000000..5e40418
--- /dev/null
+++ b/wp-admin/users.js
@@ -0,0 +1,20 @@
+addLoadEvent(function() {
+ theListEls = document.getElementsByTagName('tbody');
+ theUserLists = new Array();
+ for ( var l = 0; l < theListEls.length; l++ ) {
+ theUserLists[theListEls[l].id] = new listMan(theListEls[l].id);
+ }
+ addUserInputs = document.getElementById('adduser').getElementsByTagName('input');
+ for ( var i = 0; i < addUserInputs.length; i++ ) {
+ addUserInputs[i].onkeypress = function(e) { return killSubmit('addUserSubmit();', e); }
+ }
+ document.getElementById('addusersub').onclick = function(e) { return killSubmit('addUserSubmit();', e); }
+}
+);
+
+function addUserSubmit() {
+ var roleEl = document.getElementById('role');
+ var role = roleEl.options[roleEl.selectedIndex].value;
+ if ( !theUserLists['role-' + role] ) return true;
+ return theUserLists['role-' + role].ajaxAdder('user', 'adduser');
+}
diff --git a/wp-admin/users.php b/wp-admin/users.php
new file mode 100644
index 0000000..2ed85bf
--- /dev/null
+++ b/wp-admin/users.php
@@ -0,0 +1,597 @@
+<?php
+require_once('admin.php');
+require_once( ABSPATH . WPINC . '/registration.php');
+
+$title = __('Users');
+if ( current_user_can('edit_users') )
+ $parent_file = 'users.php';
+else
+ $parent_file = 'profile.php';
+
+$action = $_REQUEST['action'];
+$update = '';
+
+if ( empty($_POST) ) {
+ $referer = '<input type="hidden" name="wp_http_referer" value="'. wp_specialchars(stripslashes($_SERVER['REQUEST_URI'])) . '" />';
+} elseif ( isset($_POST['wp_http_referer']) ) {
+ $redirect = remove_query_arg(array('wp_http_referer', 'updated', 'delete_count'), urlencode(stripslashes($_POST['wp_http_referer'])));
+ $referer = '<input type="hidden" name="wp_http_referer" value="' . wp_specialchars($redirect) . '" />';
+} else {
+ $redirect = 'users.php';
+}
+
+
+// WP_User_Search class
+// by Mark Jaquith
+
+
+class WP_User_Search {
+ var $results;
+ var $search_term;
+ var $page;
+ var $raw_page;
+ var $users_per_page = 50;
+ var $first_user;
+ var $last_user;
+ var $query_limit;
+ var $query_from_where;
+ var $total_users_for_query = 0;
+ var $too_many_total_users = false;
+ var $search_errors;
+
+ function WP_User_Search ($search_term = '', $page = '') { // constructor
+ $this->search_term = $search_term;
+ $this->raw_page = ( '' == $page ) ? false : (int) $page;
+ $this->page = (int) ( '' == $page ) ? 1 : $page;
+
+ $this->prepare_query();
+ $this->query();
+ $this->prepare_vars_for_template_usage();
+ $this->do_paging();
+ }
+
+ function prepare_query() {
+ global $wpdb;
+ $this->first_user = ($this->page - 1) * $this->users_per_page;
+ $this->query_limit = 'LIMIT ' . $this->first_user . ',' . $this->users_per_page;
+ if ( $this->search_term ) {
+ $searches = array();
+ $search_sql = 'AND (';
+ foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col )
+ $searches[] = $col . " LIKE '%$this->search_term%'";
+ $search_sql .= implode(' OR ', $searches);
+ $search_sql .= ')';
+ }
+ $this->query_from_where = "FROM $wpdb->users, $wpdb->usermeta WHERE $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '".$wpdb->prefix."capabilities' $search_sql";
+
+ if ( !$_GET['update'] && !$this->search_term && !$this->raw_page && $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users, $wpdb->usermeta WHERE $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '".$wpdb->prefix."capabilities'") > $this->users_per_page )
+ $this->too_many_total_users = sprintf(__('Because this blog has more than %s users, they cannot all be shown on one page. Use the paging or search functionality in order to find the user you want to edit.'), $this->users_per_page);
+ }
+
+ function query() {
+ global $wpdb;
+ $this->results = $wpdb->get_col('SELECT ID ' . $this->query_from_where . $this->query_limit);
+
+ if ( $this->results )
+ $this->total_users_for_query = $wpdb->get_var('SELECT COUNT(ID) ' . $this->query_from_where); // no limit
+ else
+ $this->search_errors = new WP_Error('no_matching_users_found', __('No matching users were found!'));
+ }
+
+ function prepare_vars_for_template_usage() {
+ $this->search_term = stripslashes($this->search_term); // done with DB, from now on we want slashes gone
+ }
+
+ function do_paging() {
+ if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results
+ $prev_page = ( $this->page > 1) ? true : false;
+ $next_page = ( ($this->page * $this->users_per_page) < $this->total_users_for_query ) ? true : false;
+ $this->paging_text = '';
+ if ( $prev_page )
+ $this->paging_text .= '<p class="alignleft"><a href="' . add_query_arg(array('usersearch' => $this->search_term, 'userspage' => $this->page - 1), 'users.php?') . '">&laquo; Previous Page</a></p>';
+ if ( $next_page )
+ $this->paging_text .= '<p class="alignright"><a href="' . add_query_arg(array('usersearch' => $this->search_term, 'userspage' => $this->page + 1), 'users.php?') . '">Next Page &raquo;</a></p>';
+ if ( $prev_page || $next_page )
+ $this->paging_text .= '<br style="clear:both" />';
+ }
+ }
+
+ function get_results() {
+ return $this->results;
+ }
+
+ function page_links() {
+ echo $this->paging_text;
+ }
+
+ function results_are_paged() {
+ if ( $this->paging_text )
+ return true;
+ return false;
+ }
+
+ function is_search() {
+ if ( $this->search_term )
+ return true;
+ return false;
+ }
+}
+
+
+switch ($action) {
+
+case 'promote':
+ check_admin_referer('bulk-users');
+
+ if (empty($_POST['users'])) {
+ header('Location: ' . $redirect);
+ }
+
+ if ( !current_user_can('edit_users') )
+ die(__('You can&#8217;t edit users.'));
+
+ $userids = $_POST['users'];
+ $update = 'promote';
+ foreach($userids as $id) {
+ if ( ! current_user_can('edit_user', $id) )
+ die(__('You can&#8217;t edit that user.'));
+ // The new role of the current user must also have edit_users caps
+ if($id == $current_user->id && !$wp_roles->role_objects[$_POST['new_role']]->has_cap('edit_users')) {
+ $update = 'err_admin_role';
+ continue;
+ }
+
+ $user = new WP_User($id);
+ $user->set_role($_POST['new_role']);
+ }
+
+ header('Location: ' . add_query_arg('update', $update, $redirect));
+
+break;
+
+case 'dodelete':
+ die( "This function is disabled." );
+ check_admin_referer('delete-users');
+
+ if ( empty($_POST['users']) ) {
+ header('Location: ' . $redirect);
+ }
+
+ if ( !current_user_can('delete_users') )
+ die(__('You can&#8217;t delete users.'));
+
+ $userids = $_POST['users'];
+ $update = 'del';
+ $delete_count = 0;
+
+ foreach ( (array) $userids as $id) {
+ if ( ! current_user_can('delete_user', $id) )
+ die(__('You can&#8217;t delete that user.'));
+
+ if($id == $current_user->id) {
+ $update = 'err_admin_del';
+ continue;
+ }
+ switch($_POST['delete_option']) {
+ case 'delete':
+ wp_delete_user($id);
+ break;
+ case 'reassign':
+ wp_delete_user($id, $_POST['reassign_user']);
+ break;
+ }
+ ++$delete_count;
+ }
+
+ $redirect = add_query_arg('delete_count', $delete_count, $redirect);
+
+ header('Location: ' . add_query_arg('update', $update, $redirect));
+
+break;
+
+case 'delete':
+ die( "This function is disabled." );
+ check_admin_referer('bulk-users');
+
+ if ( empty($_POST['users']) )
+ header('Location: ' . $redirect);
+
+ if ( !current_user_can('delete_users') )
+ $errors = new WP_Error('edit_users', __('You can&#8217;t delete users.'));
+
+ $userids = $_POST['users'];
+
+ include ('admin-header.php');
+?>
+<form action="" method="post" name="updateusers" id="updateusers">
+<?php wp_nonce_field('delete-users') ?>
+<?php echo $referer; ?>
+<div class="wrap">
+<h2><?php _e('Delete Users'); ?></h2>
+<p><?php _e('You have specified these users for deletion:'); ?></p>
+<ul>
+<?php
+ $go_delete = false;
+ foreach ( (array) $userids as $id ) {
+ $user = new WP_User($id);
+ if ( $id == $current_user->id ) {
+ echo "<li>" . sprintf(__('ID #%1s: %2s <strong>The current user will not be deleted.</strong>'), $id, $user->user_login) . "</li>\n";
+ } else {
+ echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf(__('ID #%1s: %2s'), $id, $user->user_login) . "</li>\n";
+ $go_delete = true;
+ }
+ }
+ $all_logins = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users, $wpdb->usermeta WHERE $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '".$wpdb->prefix."capabilities'");
+ $user_dropdown = '<select name="reassign_user">';
+ foreach ( (array) $all_logins as $login )
+ if ( $login->ID == $current_user->id || !in_array($login->ID, $userids) )
+ $user_dropdown .= "<option value=\"{$login->ID}\">{$login->user_login}</option>";
+ $user_dropdown .= '</select>';
+ ?>
+ </ul>
+<?php if ( $go_delete ) : ?>
+ <p><?php _e('What should be done with posts and links owned by this user?'); ?></p>
+ <ul style="list-style:none;">
+ <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" checked="checked" />
+ <?php _e('Delete all posts and links.'); ?></label></li>
+ <li><input type="radio" id="delete_option1" name="delete_option" value="reassign" />
+ <?php echo '<label for="delete_option1">'.__('Attribute all posts and links to:')."</label> $user_dropdown"; ?></li>
+ </ul>
+ <input type="hidden" name="action" value="dodelete" />
+ <p class="submit"><input type="submit" name="submit" value="<?php _e('Confirm Deletion'); ?>" /></p>
+<?php else : ?>
+ <p><?php _e('There are no valid users selected for deletion.'); ?></p>
+<?php endif; ?>
+</div>
+</form>
+<?php
+
+break;
+
+case 'doremove':
+ check_admin_referer('remove-users');
+
+ if ( empty($_POST['users']) ) {
+ header('Location: users.php');
+ }
+
+ if ( !current_user_can('edit_users') )
+ die(__('You can&#8217;t remove users.'));
+
+ $userids = $_POST['users'];
+
+ $update = 'remove';
+ foreach ($userids as $id) {
+ if ($id == $current_user->id) {
+ $update = 'err_admin_remove';
+ continue;
+ }
+ remove_user_from_blog($id);
+ }
+
+ header('Location: users.php?update=' . $update);
+
+break;
+
+case 'removeuser':
+
+ check_admin_referer('bulk-users');
+
+ if (empty($_POST['users'])) {
+ header('Location: users.php');
+ }
+
+ if ( !current_user_can('edit_users') )
+ $error = new WP_Error('edit_users', __('You can&#8217;t remove users.'));
+
+ $userids = $_POST['users'];
+
+ include ('admin-header.php');
+?>
+<form action="" method="post" name="updateusers" id="updateusers">
+<?php wp_nonce_field('remove-users') ?>
+<div class="wrap">
+<h2><?php _e('Remove Users from Blog'); ?></h2>
+<p><?php _e('You have specified these users for removal:'); ?></p>
+<ul>
+<?php
+ $go_remove = false;
+ foreach ($userids as $id) {
+ $user = new WP_User($id);
+ if ($id == $current_user->id) {
+ echo "<li>" . sprintf(__('ID #%1s: %2s <strong>The current user will not be removed.</strong>'), $id, $user->user_login) . "</li>\n";
+ } else {
+ echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf(__('ID #%1s: %2s'), $id, $user->user_login) . "</li>\n";
+ $go_remove = true;
+ }
+ }
+ ?>
+<?php if($go_remove) : ?>
+ <input type="hidden" name="action" value="doremove" />
+ <p class="submit"><input type="submit" name="submit" value="<?php _e('Confirm Removal'); ?>" /></p>
+<?php else : ?>
+ <p><?php _e('There are no valid users selected for removal.'); ?></p>
+<?php endif; ?>
+</div>
+</form>
+<?php
+
+break;
+
+case 'adduser':
+ die( "This function is disabled. Add a user from your community." );
+ check_admin_referer('add-user');
+
+ if ( ! current_user_can('create_users') )
+ die(__('You can&#8217;t create users.'));
+
+ $user_id = add_user();
+ $update = 'add';
+ if ( is_wp_error( $user_id ) )
+ $add_user_errors = $user_id;
+ else {
+ $new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_POST['user_login']), true));
+ $redirect = add_query_arg('usersearch', $new_user_login, $redirect);
+ header('Location: ' . add_query_arg('update', $update, $redirect) . '#user-' . $user_id);
+ die();
+ }
+
+case 'addexistinguser':
+ check_admin_referer('add-user');
+ if ( !current_user_can('edit_users') )
+ die(__('You can&#8217;t edit users.'));
+
+ $new_user_email = wp_specialchars(trim($_POST['newuser']));
+ /* checking that username has been typed */
+ if ( !empty($new_user_email) ) {
+ if ( $user_id = email_exists( $new_user_email ) ) {
+ if ( array_key_exists($blog_id, get_blogs_of_user($user_id)) ) {
+ $location = 'users.php?update=add_existing';
+ } else {
+ add_user_to_blog('', $user_id, $_POST[ 'new_role' ]);
+ do_action( "added_existing_user", $user_id );
+ $location = 'users.php?update=add';
+ }
+ header("Location: $location");
+ die();
+ }
+ }
+ header('Location: users.php');
+ die();
+break;
+default:
+ wp_enqueue_script('admin-users');
+
+ include('admin-header.php');
+
+ // Query the users
+ $wp_user_search = new WP_User_Search($_GET['usersearch'], $_GET['userspage']);
+
+ // Make the user objects
+ foreach ( $wp_user_search->get_results() as $userid ) {
+ $tmp_user = new WP_User($userid);
+ $roles = $tmp_user->roles;
+ $role = array_shift($roles);
+ $roleclasses[$role][$tmp_user->user_login] = $tmp_user;
+ }
+
+ if ( isset($_GET['update']) ) :
+ switch($_GET['update']) {
+ case 'del':
+ case 'del_many':
+ ?>
+ <?php $delete_count = (int) $_GET['delete_count']; ?>
+ <div id="message" class="updated fade"><p><?php printf(__('%1$s %2$s deleted.'), $delete_count, __ngettext('user', 'users', $delete_count) ); ?></p></div>
+ <?php
+ break;
+ case 'remove':
+ ?>
+ <div id="message" class="updated fade"><p><?php _e('User removed from this blog.'); ?></p></div>
+ <?php
+ break;
+ case 'add':
+ ?>
+ <div id="message" class="updated fade"><p><?php _e('New user created.'); ?></p></div>
+ <?php
+ break;
+ case 'promote':
+ ?>
+ <div id="message" class="updated fade"><p><?php _e('Changed roles.'); ?></p></div>
+ <?php
+ break;
+ case 'err_admin_role':
+ ?>
+ <div id="message" class="error"><p><?php _e("The current user's role must have user editing capabilities."); ?></p></div>
+ <div id="message" class="updated fade"><p><?php _e('Other user roles have been changed.'); ?></p></div>
+ <?php
+ break;
+ case 'err_admin_del':
+ ?>
+ <div id="message" class="error"><p><?php _e("You can't delete the current user."); ?></p></div>
+ <div id="message" class="updated fade"><p><?php _e('Other users have been deleted.'); ?></p></div>
+ <?php
+ break;
+ case 'err_admin_remove':
+ ?>
+ <div id="message" class="error"><p><?php _e("You can't remove the current user."); ?></p></div>
+ <div id="message" class="updated fade"><p><?php _e('Other users have been removed.'); ?></p></div>
+ <?php
+ break;
+ case 'notactive':
+ ?>
+ <div id="message" class="updated fade"><p><?php _e('User not added. User is deleted or not active.'); ?></p></div>
+ <?php
+ break;
+ case 'add_existing':
+ ?>
+ <div id="message" class="updated fade"><p><?php _e('User not added. User is already registered.'); ?></p></div>
+ <?php
+ break;
+ }
+ endif; ?>
+
+<?php if ( is_wp_error( $errors ) ) : ?>
+ <div class="error">
+ <ul>
+ <?php
+ foreach ( $errors->get_error_messages() as $message )
+ echo "<li>$message</li>";
+ ?>
+ </ul>
+ </div>
+<?php endif; ?>
+
+<?php if ( $wp_user_search->too_many_total_users ) : ?>
+ <div id="message" class="updated">
+ <p><?php echo $wp_user_search->too_many_total_users; ?></p>
+ </div>
+<?php endif; ?>
+
+<div class="wrap">
+
+ <?php if ( $wp_user_search->is_search() ) : ?>
+ <h2><?php printf(__('Users Matching "%s" by Role'), $wp_user_search->search_term); ?></h2>
+ <?php else : ?>
+ <h2><?php _e('User List by Role'); ?></h2>
+ <?php endif; ?>
+
+ <form action="" method="get" name="search" id="search">
+ <p><input type="text" name="usersearch" id="usersearch" value="<?php echo wp_specialchars($wp_user_search->search_term); ?>" /> <input type="submit" value="<?php _e('Search for users &raquo;'); ?>" /></p>
+ </form>
+
+ <?php if ( is_wp_error( $wp_user_search->search_errors ) ) : ?>
+ <div class="error">
+ <ul>
+ <?php
+ foreach ( $wp_user_search->search_errors->get_error_messages() as $message )
+ echo "<li>$message</li>";
+ ?>
+ </ul>
+ </div>
+ <?php endif; ?>
+
+
+<?php if ( $wp_user_search->get_results() ) : ?>
+
+ <?php if ( $wp_user_search->is_search() ) : ?>
+ <p><a href="users.php"><?php _e('&laquo; Back to All Users'); ?></a></p>
+ <?php endif; ?>
+
+ <h3><?php printf(__('Results %1$s - %2$s of %3$s shown below'), $wp_user_search->first_user + 1, min($wp_user_search->first_user + $wp_user_search->users_per_page, $wp_user_search->total_users_for_query), $wp_user_search->total_users_for_query); ?></h3>
+
+ <?php if ( $wp_user_search->results_are_paged() ) : ?>
+ <div class="user-paging-text"><?php $wp_user_search->page_links(); ?></p></div>
+ <?php endif; ?>
+
+<form action="" method="post" name="updateusers" id="updateusers">
+<?php wp_nonce_field('bulk-users') ?>
+<table class="widefat">
+<?php
+foreach($roleclasses as $role => $roleclass) {
+ ksort($roleclass);
+?>
+
+<tr>
+<?php if ( !empty($role) ) : ?>
+ <th colspan="7" align="left"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th>
+<?php else : ?>
+ <th colspan="7" align="left"><h3><em><?php _e('No role for this blog'); ?></h3></th>
+<?php endif; ?>
+</tr>
+<tr class="thead">
+ <th style="text-align: left"><?php _e('ID') ?></th>
+ <th style="text-align: left"><?php _e('Username') ?></th>
+ <th style="text-align: left"><?php _e('Name') ?></th>
+ <th style="text-align: left"><?php _e('E-mail') ?></th>
+ <th style="text-align: left"><?php _e('Website') ?></th>
+ <th colspan="2"><?php _e('Actions') ?></th>
+</tr>
+</thead>
+<tbody id="role-<?php echo $role; ?>"><?php
+$style = '';
+foreach ( (array) $roleclass as $user_object ) {
+ $style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"';
+ echo "\n\t" . user_row($user_object, $style);
+}
+?>
+
+</tbody>
+<?php } ?>
+</table>
+
+<?php if ( $wp_user_search->results_are_paged() ) : ?>
+ <div class="user-paging-text"><?php $wp_user_search->page_links(); ?></div>
+<?php endif; ?>
+
+ <h2><?php _e('Update Users'); ?></h2>
+ <ul style="list-style:none;">
+ <li><input type="radio" name="action" id="action0" value="removeuser" /> <label for="action0"><?php _e('Remove checked users.'); ?></label></li>
+ <li>
+ <input type="radio" name="action" id="action1" value="promote" /> <label for="action1"><?php _e('Set the Role of checked users to:'); ?></label>
+ <select name="new_role"><?php wp_dropdown_roles(); ?></select>
+ </li>
+ </ul>
+ <p class="submit">
+ <?php echo $referer; ?>
+ <input type="submit" value="<?php _e('Update &raquo;'); ?>" />
+ </p>
+</form>
+<?php endif; ?>
+</div>
+
+<?php
+ if ( is_wp_error($add_user_errors) ) {
+ foreach ( array('user_login' => 'user_login', 'first_name' => 'user_firstname', 'last_name' => 'user_lastname', 'email' => 'user_email', 'url' => 'user_uri', 'role' => 'user_role') as $formpost => $var ) {
+ $var = 'new_' . $var;
+ $$var = wp_specialchars(stripslashes($_POST[$formpost]));
+ }
+ unset($name);
+ }
+?>
+
+<div class="wrap">
+<h2><?php _e('Add User From Community') ?></h2>
+<form action="" method="post" name="adduser" id="adduser">
+ <?php wp_nonce_field('add-user') ?>
+<input type='hidden' name='action' value='addexistinguser'>
+<p>Type the e-mail address of another user to add them to your blog.</p>
+<table>
+<tr><th scope="row">User&nbsp;E-Mail: </th><td><input type="text" name="newuser" id="newuser"></td></tr>
+ <tr>
+ <th scope="row"><?php _e('Role:') ?></th>
+ <td><select name="new_role" id="new_role"><?php
+ foreach($wp_roles->role_names as $role => $name) {
+ $selected = '';
+ if( $role == 'subscriber' )
+ $selected = 'selected="selected"';
+ echo "<option {$selected} value=\"{$role}\">{$name}</option>";
+ }
+ ?></select></td>
+ </tr>
+</table>
+<p class="submit">
+ <?php echo $referer; ?>
+ <input name="adduser" type="submit" id="addusersub" value="<?php _e('Add User &raquo;') ?>" />
+</p>
+</form>
+
+<?php if ( is_wp_error( $add_user_errors ) ) : ?>
+ <div class="error">
+ <ul>
+ <?php
+ foreach ( $add_user_errors->get_error_messages() as $message )
+ echo "$message<br />";
+ ?>
+ </ul>
+ </div>
+<?php endif; ?>
+<div id="ajax-response"></div>
+</div>
+
+<?php
+break;
+
+} // end of the $action switch
+
+include('admin-footer.php');
+?>
diff --git a/wp-admin/wp-admin.css b/wp-admin/wp-admin.css
new file mode 100644
index 0000000..eb7052d
--- /dev/null
+++ b/wp-admin/wp-admin.css
@@ -0,0 +1,1009 @@
+* html #poststuff {
+ height: 100%; /* kill peekaboo bug in IE */
+}
+
+/* This is the Holly Hack \*/
+* html .wrap { height: 1% }
+/* For Win IE's eyes only */
+
+body {
+ border: none;
+}
+a {
+ border-bottom: 1px solid #69c;
+ color: #00019b;
+ text-decoration: none;
+}
+
+a.delete:hover {
+ background: #c00;
+ color: #fff;
+}
+
+#planetnews ul {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+}
+
+#planetnews li {
+ width: 17%;
+ margin: 1%;
+ float: left;
+}
+
+#planetnews li a {
+ display: block;
+ padding: .5em;
+ background: #ddd;
+ height: 6em;
+ overflow: hidden;
+}
+
+.widefat {
+ width: 100%;
+}
+
+.widefat td, .widefat th {
+ padding: 5px 6px;
+}
+
+.import-system {
+ font-size: 16px;
+}
+
+thead, .thead {
+ background: #dfdfdf
+}
+
+#import-upload-form {
+ width: 300px;
+ margin: auto;
+ text-align: center;
+}
+
+a.edit, a.delete, a.edit:hover, a.delete:hover {
+ border-bottom: none;
+ display: block;
+ padding: 5px 0;
+ text-align: center;
+}
+
+a.edit:hover {
+ background: #ccc;
+ color: #036;
+}
+
+a:visited {
+ color: #006;
+}
+
+a:hover {
+/* border-bottom: 1px solid #3a75ae;*/
+ color: #069;
+}
+
+body {
+ background: #f9fcfe;
+ color: #000;
+ margin: 0;
+ padding: 0;
+}
+
+body, td {
+ font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana;
+}
+
+fieldset {
+ border: none;
+ padding: 3px;
+}
+
+fieldset label.selectit {
+ display: block;
+ font-size: 11px;
+ padding: 0 2px;
+}
+
+fieldset label.selectit:hover {
+ background: #e9e9e9;
+}
+
+fieldset legend {
+ padding: .1em .3em;
+}
+
+fieldset.options {
+ padding: 1em;
+}
+
+fieldset.options legend {
+ font-size: 16px;
+}
+
+form, label input {
+ margin: 0;
+ padding: 0;
+}
+
+h2 {
+ border-bottom: .5em solid #f0f8ff;
+ color: #333;
+ font: normal 30px/5px serif;
+ margin: 5px 10px;
+}
+
+h2 small.quickjump {
+ display: block;
+ text-align: right;
+}
+
+h2 small.quickjump a {
+ text-decoration: none;
+ border-bottom: 0;
+ font-size: 15px;
+ background: #f0f8ff;
+ padding: 5px 10px;
+}
+
+img, #footer a {
+ border: 0;
+}
+
+input:focus, textarea:focus, label:focus {
+ background: #fff;
+ border: 1px solid #686868;
+}
+
+label {
+ cursor: pointer;
+}
+
+li, dd {
+ margin-bottom: 6px;
+}
+
+p, li, dl, dd, dt {
+ line-height: 130%;
+}
+
+textarea, input, select {
+ background: #f4f4f4;
+ border: 1px solid #b2b2b2;
+ color: #000;
+ font: 13px Verdana, Arial, Helvetica, sans-serif;
+ margin: 1px;
+ padding: 3px;
+}
+
+#uploading {
+ border-style: none;
+ padding: 0px;
+ margin-bottom: 16px;
+ height: 15em;
+ width: 100%;
+/* overflow-y: hidden;*/
+}
+
+form#upload th {
+ text-align: right;
+}
+
+form#upload #post_content, form#upload #post_title {
+ width: 250px;
+}
+
+form#upload #post_content {
+ height: 50px;
+}
+
+.attpreview {
+ width: 1px; /* hug */
+ text-align: center;
+}
+
+.alignleft {
+ float: left
+}
+
+.alignright {
+ float: right;
+}
+
+.alternate {
+ background: #f1f1f1;
+}
+
+.anchors {
+ margin: 10px 20px 10px 20px;
+}
+
+.available-theme {
+ width: 30%;
+ margin: 0 1em;
+ float: left;
+ text-align: center;
+ height: 28em;
+ overflow: hidden;
+}
+
+.available-theme a.screenshot {
+ width: 250px;
+ height: 200px;
+ display: block;
+ margin: auto;
+ background: #f1f1f1;
+ border: 1px solid #ccc;
+ margin-bottom: 10px;
+ overflow: hidden;
+}
+
+.available-theme a.screenshot:hover {
+/* border: 1px solid #666;*/
+}
+
+.available-theme img {
+ width: 100%;
+}
+
+.checkbox {
+ background: #fff;
+ border: none;
+ margin: 0;
+ padding: 0;
+}
+
+.code {
+ font-family: "Courier New", Courier, monospace;
+}
+
+.commentlist li {
+ border-bottom: 1px solid #ccc;
+ padding: 1em 1em .2em;
+ margin: 0;
+}
+
+.commentlist p {
+ padding: 0;
+ margin: 0 0 .8em;
+}
+
+.clear {
+ clear: both;
+ height: 2px;
+}
+
+.hidden {
+ display: none;
+}
+
+.navigation {
+ display: block;
+ text-align: center;
+ margin-top: 10px;
+ margin-bottom: 30px;
+}
+
+.post-categories {
+ display: inline;
+ margin: 0;
+ padding: 0;
+}
+
+.post-categories li, #ed_toolbar {
+ display: inline;
+}
+
+.quicktags, .search {
+ background: #ccc;
+ color: #000;
+ font: 12px Georgia, "Times New Roman", Times, serif;
+}
+
+.submit input, .submit input:focus, .button {
+ background: url( images/fade-butt.png );
+ border: 3px double #999;
+ border-left-color: #ccc;
+ border-top-color: #ccc;
+ color: #333;
+ padding: 0.25em;
+}
+
+.submit input:active, .button:active {
+ background: #f4f4f4;
+ border: 3px double #ccc;
+ border-left-color: #999;
+ border-top-color: #999;
+}
+
+.submit, .editform th, #postcustomsubmit {
+ text-align: right;
+}
+
+.optiontable {
+ width: 100%;
+}
+
+.optiontable td, .optiontable th {
+ padding: .5em;
+}
+
+.optiontable th {
+ width: 33%;
+ text-align: right;
+}
+
+.unapproved {
+ color: #888;
+}
+
+.unapproved a:link {
+ color: #b9bcff;
+}
+
+.unapproved a:visited {
+ color: #696dff;
+}
+
+.unapproved a:hover {
+ color: #009ef0;
+}
+
+.approve {
+ display: none;
+}
+
+.unapproved .approve {
+ display: inline;
+}
+
+.unapproved .unapprove {
+ display: none;
+}
+
+.updated, .confirm {
+ background: #CFEBF7 url(images/notice.gif) no-repeat 1em ;
+ border: 1px solid #2580B2;
+ margin: 1em 5% 10px;
+ padding: 0 1em 0 3em;
+}
+
+.error {
+ background: #FFEFF7;
+ border: 1px solid #c69;
+ margin: 1em 5% 10px;
+ padding: 0 1em 0 1em;
+}
+
+.wrap {
+ background: #fff;
+ border: 1px solid #ccc;
+ clear: both;
+ margin: 15px 5%;
+ padding: .5em 1em;
+}
+
+.wrap h2 {
+ margin: .8em 0 .5em;
+ clear: both;
+}
+
+table .vers {
+ text-align: center;
+}
+
+#adminmenu {
+ background: #6da6d1;
+ border-top: 3px solid #448abd;
+ margin: 0;
+ padding: .2em .2em .2em 2em;
+}
+
+#adminmenu .current, #submenu .current {
+ font-weight: bold;
+}
+
+#adminmenu a {
+ color: #000;
+ font-size: 14px;
+ font-weight: normal;
+ margin: 0;
+ padding: 3px 5px;
+ text-decoration: none;
+}
+
+#adminmenu a:hover, .current {
+ background: #ddeaf4;
+ color: #333;
+}
+
+#adminmenu li, #submenu li {
+ display: inline;
+ line-height: 200%;
+ list-style: none;
+ text-align: center;
+}
+
+#submenu {
+ background: #0d324f;
+ border-bottom: none;
+ margin: 0;
+ padding: 3px 2em 0 3em;
+}
+
+#submenu .current {
+ background: #f9fcfe;
+ border-top: 1px solid #045290;
+ border-right: 2px solid #045290;
+ color: #000;
+}
+
+#submenu a {
+ border: none;
+ color: #fff;
+ font-size: 12px;
+ padding: .3em .4em .33em;
+}
+
+#submenu a:hover {
+ background: #ddeaf4;
+ color: #393939;
+}
+
+#submenu li {
+ line-height: 170%;
+}
+
+
+#categorydiv input, #poststatusdiv input, #commentstatusdiv input, #pingstatusdiv input {
+ border: none;
+}
+
+#titlediv, #guiddiv {
+ margin: 0 8px 0 0;
+ padding: 0px;
+}
+
+#postdiv {
+ margin: 0 8px 0 0;
+ padding: 0px;
+}
+
+#postdivrich {
+ margin: 0px;
+ padding: 0px;
+}
+
+#content {
+ margin: 0 0 0 0;
+ width: 100%;
+}
+
+#titlediv input, #guiddiv input {
+ margin: 0px;
+ width: 100%;
+}
+
+#quicktags {
+ margin-left: -1px;
+}
+
+#currenttheme img {
+ float: left;
+ border: 1px solid #666;
+ margin-right: 1em;
+ margin-bottom: 1.5em;
+ width: 300px;
+}
+
+#deletepost:hover, #deletecomment:hover {
+ background: #ce0000;
+ color: #fff;
+}
+
+#deletebookmarks:hover {
+ background: #ce0000;
+ color: #fff;
+}
+
+#quicktags #ed_strong {
+ font-weight: bold;
+}
+
+#quicktags #ed_link {
+ color: blue;
+ text-decoration: underline;
+}
+
+#quicktags #ed_del {
+ text-decoration: line-through;
+}
+
+#quicktags #ed_em {
+ font-style: italic;
+}
+
+#quicktags #ed_code {
+ font-family: "Courier New", Courier, mono;
+}
+
+#title {
+ font-size: 1.5em;
+}
+
+#postexcerpt div, #attachmentlinks div {
+ margin-right: 8px;
+}
+
+#attachmentlinks textarea {
+ width: 100%;
+ height: 2.5em;
+ margin-bottom: 6px;
+}
+
+* html #postexcerpt .dbx-toggle-open, * html #postexcerpt .dbx-toggle-open {
+ padding-right: 8px;
+}
+
+#excerpt, .attachmentlinks {
+ margin: 0px;
+ height: 4em;
+ width: 100%;
+}
+
+#footer {
+ clear: both;
+ text-align: center;
+}
+
+#login {
+ background: #fff;
+ border: 1px solid #a2a2a2;
+ margin: 5em auto;
+ padding: 1.5em;
+ width: 25em;
+}
+
+#login #login_error {
+ background: #c00;
+ border: 1px solid #a40000;
+ color: #fff;
+ font-size: 16px;
+ font-weight: bold;
+ padding: .5em;
+ text-align: center;
+}
+
+#login h1 {
+ background: url(images/wordpress-logo.png) no-repeat top left;
+ margin-top: 0;
+}
+
+#login h1 a {
+ display: block;
+ text-indent: -1000px;
+ height: 66px;
+ border-bottom: none;
+}
+
+#login input {
+ padding: 3px;
+}
+
+#login ul {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+}
+
+#login ul li {
+ display: inline;
+ margin-left: 1.4em;
+ text-align: center;
+}
+
+#login #log, #pwd {
+ font-size: 1.7em;
+ width: 80%;
+}
+
+#login #submit {
+ font-size: 1.7em;
+}
+
+#postcustom .updatemeta, #postcustom .deletemeta {
+ margin: auto;
+}
+
+#postcustom table {
+ border: 1px solid #ccc;
+ margin: 0px;
+ width: 100%;
+}
+
+#postcustom table input, #postcustom table textarea {
+ width: 95%;
+}
+
+#poststuff {
+ margin-right: 16em;
+}
+
+#save {
+ width: 15em;
+}
+
+#template div {
+ margin-right: 190px;
+}
+
+* html #template div {
+ margin-right: 0px;
+}
+
+#template, #template div, #editcat, #addcat {
+ zoom: 1;
+}
+
+#template textarea {
+ font: small 'Courier New', Courier, monospace;
+ width: 97%;
+}
+
+#templateside {
+ float: right;
+ width: 170px;
+}
+
+#templateside h3, #postcustom p.submit {
+ margin: 0;
+}
+
+#templateside ol, #templateside ul {
+ list-style: none;
+ margin: .5em;
+ padding: 0;
+}
+
+#user_info {
+ position: absolute;
+ right: 1em;
+ top: 0;
+ color: #fff;
+ font-size: .9em;
+}
+
+#user_info a {
+ color: #fff;
+}
+
+#wphead {
+ background: #14568a;
+ padding: .8em 19em .8em 2em;
+ color: #c3def1;
+}
+
+#wphead a {
+ color: #fff;
+}
+
+#wphead h1 {
+ font-size: 2.5em;
+ font-weight: normal;
+ letter-spacing: -.05em;
+ margin: 0;
+ font-family: Georgia, "Times New Roman", Times, serif
+}
+
+#wphead h1 span {
+ font-size: .4em;
+ letter-spacing: 0;
+}
+
+#zeitgeist {
+ background: #eee;
+ border: 1px solid #69c;
+ float: right;
+ font-size: 90%;
+ margin-bottom: .5em;
+ margin-left: 1em;
+ margin-top: .5em;
+ padding: 1em;
+ width: 40%;
+}
+
+#zeitgeist h2, fieldset legend a {
+ border-bottom: none;
+}
+
+#zeitgeist h2 {
+ margin-top: .4em;
+}
+
+#zeitgeist h3 {
+ border-bottom: 1px solid #ccc;
+ font-size: 16px;
+ margin: 1em 0 0;
+}
+
+#zeitgeist h3 cite {
+ font-size: 12px;
+ font-style: normal;
+}
+
+#zeitgeist li, #zeitgeist p {
+ margin: .2em 0;
+}
+
+#zeitgeist ul {
+ margin: 0 0 .3em .6em;
+ padding: 0 0 0 .6em;
+}
+
+.active td {
+ background: #BEB;
+}
+.active .name {
+ background: #9C9;
+}
+.alternate.active td {
+ background: #ADA;
+}
+.alternate.active .name {
+ background: #8B8;
+}
+
+#namediv, #emaildiv, #uridiv {
+ float: left;
+}
+
+#ajax-response {
+ padding: .5em;
+}
+
+/* A handy div class for hiding controls.
+ Some browsers will disable them when you
+ set display:none; */
+.zerosize {
+ height: 0px;
+ width: 0px;
+ margin: 0px;
+ border: 0px;
+ padding: 0px;
+ overflow: hidden;
+ position: absolute;
+}
+
+/* Box stuff */
+.dbx-clone {
+ position:absolute;
+ visibility:hidden;
+}
+.dbx-clone, .dbx-clone .dbx-handle-cursor {
+ cursor:move !important;
+}
+.dbx-dummy {
+ display:block;
+ width:0;
+ height:0;
+ overflow:hidden;
+}
+.dbx-group, .dbx-box, .dbx-handle {
+ position:relative;
+ display:block;
+}
+
+#grabit {
+ width: 188px;
+}
+
+* html #themeselect {
+ padding: 0px 3px;
+ height: 22px;
+}
+
+/****************************************************************
+ avoid padding, margins or borders on dbx-box,
+ to reduce visual discrepancies between it and the clone.
+ overall, dbx-box is best left as visually unstyled as possible
+*****************************************************************/
+.dbx-box {
+ margin:0;
+ padding:0;
+ border:none;
+}
+
+/* Can change this */
+#moremeta fieldset, #advancedstuff fieldset {
+ margin-bottom: 1em;
+}
+#moremeta fieldset div {
+ margin: 2px 0 0 0px;
+ padding: 7px;
+}
+#moremeta {
+ line-height: 130%;
+ margin-right: 15px;
+ position: absolute;
+ right: 5%;
+ width: 14.5em;
+}
+#moremeta select {
+ width: 96%;
+}
+
+#slugdiv input, #passworddiv input, #authordiv select, #thumbdiv input, #parentdiv input {
+ margin-top: .5em;
+ width: 90%;
+}
+
+#moremeta h3, #advancedstuff h3 {
+ padding: 3px;
+ font-weight: normal;
+ font-size: 13px;
+}
+
+#advancedstuff div {
+ margin-top: .5em;
+}
+
+#categorydiv ul {
+ list-style: none;
+ padding: 0;
+ margin-left:10px;
+}
+#categorychecklist {
+ height: 12em;
+ overflow: auto;
+ margin-top: 8px;
+}
+#categorychecklist li {
+ margin: 0;
+ padding: 0;
+}
+#ajaxcat input {
+ border: 1px solid #ccc;
+}
+
+#your-profile fieldset {
+ border: 1px solid #ccc;
+ float: left;
+ width: 40%;
+ padding: .5em 2em;
+ margin: 1em;
+}
+
+#your-profile fieldset input {
+ width: 100%;
+ font-size: 20px;
+ padding: 2px;
+}
+
+#your-profile fieldset textarea {
+ width: 100%;
+ padding: 2px;
+}
+
+#your-profile legend {
+ font-family: Georgia, "Times New Roman", Times, serif;
+ font-size: 22px;
+}
+
+/* default box styles */
+
+/* toggle state of inner content area */
+.dbx-box-open .dbx-content {
+ display: block;
+}
+.dbx-box-closed .dbx-content {
+ display: none;
+}
+
+#moremeta .dbx-content {
+ background: url(images/box-butt.gif) no-repeat bottom right;
+ padding-bottom: 15px;
+ padding-right: 2px;
+}
+
+/* handles */
+
+.dbx-handle {
+ background: #2685af;
+ padding: 6px 1em 2px;
+ font-size: 12px;
+ margin: 0;
+ color: #E3EFF5;
+}
+
+#moremeta .dbx-handle {
+ padding: 6px 1em 2px;
+ font-size: 12px;
+ background: #2685af url(images/box-head.gif) no-repeat right;
+}
+
+#moremeta .dbx-box {
+ background: url(images/box-bg.gif) repeat-y right;
+}
+
+/* handle cursors */
+.dbx-handle-cursor {
+ cursor: move;
+}
+
+/* toggle images */
+a.dbx-toggle, a.dbx-toggle:visited {
+ display:block;
+ overflow: hidden;
+ background-image: url( images/toggle.gif );
+ position: absolute;
+ top: 0px;
+ right: 0px;
+ background-repeat: no-repeat;
+ border: 0px;
+ margin: 0px;
+ padding: 0px;
+}
+
+#moremeta a.dbx-toggle, #moremeta a.dbx-toggle-open:visited {
+ height: 25px;
+ width: 27px;
+ background-position: 0 0px;
+}
+
+#moremeta a.dbx-toggle-open, #moremeta a.dbx-toggle-open:visited {
+ height: 25px;
+ width: 27px;
+ background-position: 0 -25px;
+}
+
+#advancedstuff a.dbx-toggle, #advancedstuff a.dbx-toggle-open:visited {
+ height: 22px;
+ width: 22px;
+ background-position: 0 -3px;
+}
+
+#advancedstuff a.dbx-toggle-open, #advancedstuff a.dbx-toggle-open:visited {
+ height: 22px;
+ width: 22px;
+ background-position: 0 -28px;
+}
+
+#categorychecklist {
+ margin-right: 6px;
+}
+
+/* additional clone styles */
+.dbx-clone {
+ opacity: 0.8;
+ -moz-opacity: 0.8;
+ -khtml-opacity: 0.8;
+ filter: alpha(opacity=80);
+}
+
+#newcat { width: 120px; margin-right: 5px; }
+input#catadd { background: #a4a4a4;
+ border-bottom: 1px solid #898989;
+ border-left: 1px solid #bcbcbc;
+ border-right: 1px solid #898989;
+ border-top: 1px solid #bcbcbc;
+ color: #fff;
+ font-size: 10px;
+ padding: 0;
+ margin: 0;
+ font-weight: bold;
+ height: 20px;
+ margin-bottom: 2px;
+ text-align: center;
+ width: 37px; }
+#howto {
+ font-size: 11px;
+ margin: 0 5px;
+ display: block;
+}
+#jaxcat {
+ margin: 0;
+ padding: 0;
+}
+#ajax-response.alignleft {
+ margin-left: 2em;
+}
diff --git a/wp-admin/wpmu-admin.php b/wp-admin/wpmu-admin.php
new file mode 100644
index 0000000..d943761
--- /dev/null
+++ b/wp-admin/wpmu-admin.php
@@ -0,0 +1,52 @@
+<?php
+require_once('admin.php');
+
+$title = __('WPMU Admin');
+$parent_file = 'wpmu-admin.php';
+require_once('admin-header.php');
+if( is_site_admin() == false ) {
+ die( __('<p>You do not have permission to access this page.</p>') );
+}
+if (isset($_GET['updated'])) {
+ ?><div id="message" class="updated fade"><p><?php _e('Options saved.') ?></p></div><?php
+}
+?>
+<div class="wrap">
+<?php
+
+do_action( "wpmuadminresult", "" );
+
+switch( $_GET[ 'action' ] ) {
+ default:
+ /*
+ // print some global stats.
+ $stats = get_sitestats();
+ print "<h2>Site Stats</h2>
+ There are currently ".$stats[ 'blogs' ]." <a href='wpmu-blogs.php'>blogs</a> running on this server and ".$stats[ 'users' ]." <a href='wpmu-users.php'>users</a>.</p><br /><br />
+ ";
+
+ print "<table>";
+ #$blogs = get_blog_list();
+ #print "<br>blogs: <br>";
+ #print_r( $blogs );
+
+ $most_active = get_most_active_blogs( 10, false );
+ if( is_array( $most_active ) ) {
+ print "<caption>Most Active Blogs</caption>";
+ print "<tr><th scope='col'>ID</th><th scope='col'>Address</th><th scope='col'>Posts</th></tr>";
+ while( list( $key, $details ) = each( $most_active ) ) {
+ $class = ('alternate' == $class) ? '' : 'alternate';
+ $url = "http://" . $details[ 'domain' ] . $details[ 'path' ];
+ print "<tr class='$class'><td>" . $details[ 'blog_id' ] . "</td><td><a href='$url'>$url</a></td><td>" . $details[ 'postcount' ] . "</td></tr>";
+ }
+ }
+ print "</table>";
+
+ do_action( "wpmuadmindefaultpage", "" );
+ */
+ break;
+}
+
+?>
+</div>
+<?php include('admin-footer.php'); ?>
diff --git a/wp-admin/wpmu-blogs.php b/wp-admin/wpmu-blogs.php
new file mode 100644
index 0000000..599e4a0
--- /dev/null
+++ b/wp-admin/wpmu-blogs.php
@@ -0,0 +1,527 @@
+<?php
+require_once('admin.php');
+
+$title = __('WPMU Admin');
+$parent_file = 'wpmu-admin.php';
+require_once('admin-header.php');
+if( is_site_admin() == false ) {
+ die( __('<p>You do not have permission to access this page.</p>') );
+}
+if (isset($_GET['updated'])) {
+ ?><div id="message" class="updated fade"><p><?php _e('Options saved.') ?></p></div><?php
+}
+print '<div class="wrap">';
+switch( $_GET[ 'action' ] ) {
+ case "editblog":
+ $options_table_name = $wpmuBaseTablePrefix . $_GET[ 'id' ] ."_options";
+ $query = "SELECT *
+ FROM ".$options_table_name."
+ WHERE option_name NOT LIKE 'rss%'
+ AND option_name NOT LIKE '%user_roles'";
+ $options = $wpdb->get_results( $query, ARRAY_A );
+ $query = "SELECT *
+ FROM ".$wpdb->blogs."
+ WHERE blog_id = '".$_GET[ 'id' ]."'";
+ $details = $wpdb->get_row( $query, ARRAY_A );
+
+ print "<h2>Edit Blog</h2>";
+ print "<a href='http://{$details[ 'domain' ]}/'>{$details[ 'domain' ]}</a>";
+ ?>
+ <form name="form1" method="post" action="wpmu-edit.php?action=updateblog">
+ <input type="hidden" name="id" value="<?php echo $_GET[ 'id' ] ?>" />
+ <table><td valign='top'>
+ <div class="wrap">
+ <table width="100%" border='0' cellspacing="2" cellpadding="5" class="editform">
+ <tr valign="top">
+ <th scope="row">URL</th>
+ <td>http://<input name="blog[domain]" type="text" id="domain" value="<?php echo $details[ 'domain' ] ?>" size="33" /></td>
+ </tr>
+ <tr valign="top">
+ <th scope="row">Path</th>
+ <td><input name="blog[path]" type="text" id="path" value="<?php echo $details[ 'path' ] ?>" size="40" /></td>
+ </tr>
+ <tr valign="top">
+ <th scope="row">Registered</th>
+ <td><input name="blog[registered]" type="text" id="blog_registered" value="<?php echo $details[ 'registered' ] ?>" size="40" /></td>
+ </tr>
+ <tr valign="top">
+ <th scope="row">Last Updated</th>
+ <td><input name="blog[last_updated]" type="text" id="blog_last_updated" value="<?php echo $details[ 'last_updated' ] ?>" size="40" /></td>
+ </tr>
+ <tr valign="top">
+ <th scope="row">Public</th>
+ <td><input type='radio' name='blog[public]' value='1' <?php if( $details[ 'public' ] == '1' ) echo " checked"?>> Yes&nbsp;&nbsp;
+ <input type='radio' name='blog[public]' value='0' <?php if( $details[ 'public' ] == '0' ) echo " checked"?>> No &nbsp;&nbsp;
+ </td>
+ </tr>
+ <tr valign="top">
+ <th scope="row">Archived</th>
+ <td><input type='radio' name='blog[archived]' value='1' <?php if( $details[ 'archived' ] == '1' ) echo " checked"?>> Yes&nbsp;&nbsp;
+ <input type='radio' name='blog[archived]' value='0' <?php if( $details[ 'archived' ] == '0' ) echo " checked"?>> No &nbsp;&nbsp;
+ </td>
+ </tr>
+ <tr valign="top">
+ <th scope="row">Mature</th>
+ <td><input type='radio' name='blog[mature]' value='1' <?php if( $details[ 'mature' ] == '1' ) echo " checked"?>> Yes&nbsp;&nbsp;
+ <input type='radio' name='blog[mature]' value='0' <?php if( $details[ 'mature' ] == '0' ) echo " checked"?>> No &nbsp;&nbsp;
+ </td>
+ </tr>
+ <tr valign="top">
+ <th scope="row">Spam</th>
+ <td><input type='radio' name='blog[spam]' value='1' <?php if( $details[ 'spam' ] == '1' ) echo " checked"?>> Yes&nbsp;&nbsp;
+ <input type='radio' name='blog[spam]' value='0' <?php if( $details[ 'spam' ] == '0' ) echo " checked"?>> No &nbsp;&nbsp;
+ </td>
+ </tr>
+ <tr valign="top">
+ <th scope="row">Deleted</th>
+ <td><input type='radio' name='blog[deleted]' value='1' <?php if( $details[ 'deleted' ] == '1' ) echo " checked"?>> Yes&nbsp;&nbsp;
+ <input type='radio' name='blog[deleted]' value='0' <?php if( $details[ 'deleted' ] == '0' ) echo " checked"?>> No &nbsp;&nbsp;
+ </td>
+ </tr>
+ <tr><td colspan='2'>
+ <br />
+ <br />
+ </td></tr>
+ <?php
+ while( list( $key, $val ) = each( $options ) ) {
+ $kellog = @unserialize( $val[ 'option_value' ] );
+ if( is_array( $kellog ) ) {
+ print '<tr valign="top">
+ <th scope="row">' . ucwords( str_replace( "_", " ", $val[ 'option_name' ] ) ) . '</th>
+ <td>';
+ print '<textarea rows="5" cols="40" disabled>';
+ reset( $kellog );
+ while( list( $key, $val ) = each( $kellog ) )
+ {
+ if( is_array( $val ) ) {
+ print "$key:\n";
+ while( list( $k, $v ) = each( $val ) ) {
+ if( is_array( $v ) ) {
+ print " $k:\n";
+ while( list( $k1, $v1 ) = each( $v ) ) {
+ print " $k1 -> $v1\n";
+ }
+ } else {
+ if( $v1 != '' )
+ print " $k1 -> $v1\n";
+ }
+ }
+ } else {
+ if( $val != '' )
+ print "$key -> $val\n";
+ }
+ }
+ print '</textarea></td></tr>';
+ } else {
+ ?>
+ <tr valign="top">
+ <th scope="row"><?php echo ucwords( str_replace( "_", " ", $val[ 'option_name' ] ) ) ?></th>
+ <td><input name="option[<?php echo $val[ 'option_name' ] ?>]" type="text" id="<?php echo $val[ 'option_name' ] ?>" value="<?php echo stripslashes( $val[ 'option_value' ] ) ?>" size="40" /></td>
+ </tr>
+ <?php
+ }
+ }
+ ?>
+ </table>
+ <p class="submit">
+ <input type="submit" name="Submit" value="<?php _e('Update Options') ?> &raquo;" />
+ </p>
+ </div>
+ </td>
+ <td valign='top'>
+ <?php
+ $themes = get_themes();
+ $query = "SELECT option_value
+ FROM ".$options_table_name."
+ WHERE option_name = 'allowed_themes'";
+ $blog_allowed_themes = $wpdb->get_var( $query );
+ if( $blog_allowed_themes != false )
+ $blog_allowed_themes = unserialize( $blog_allowed_themes );
+ $allowed_themes = get_site_option( "allowed_themes" );
+ if( $allowed_themes == false ) {
+ $allowed_themes = array_keys( $themes );
+ }
+ $out = '';
+ while( list( $key, $val ) = each( $themes ) ) {
+ if( isset( $allowed_themes[ $key ] ) == false ) {
+ if( isset( $blog_allowed_themes[ $key ] ) == true ) {
+ $checked = 'checked ';
+ } else {
+ $checked = '';
+ }
+
+ $out .= '
+ <tr valign="top">
+ <th title="' . htmlspecialchars( $val[ "Description" ] ) . '" scope="row">'.$key.'</th>
+ <td><input name="theme['.$key.']" type="checkbox" id="'.$key.'" value="on" '.$checked.'/></td>
+ </tr> ';
+ }
+ }
+ if( $out != '' ) {
+ print "<div class='wrap'><h3>Blog Themes</h3>";
+ print '<table width="100%" border="0" cellspacing="2" cellpadding="5" class="editform">';
+ print '<tr><th>Theme</th><th>Enable</th></tr>';
+ print $out;
+ print "</table></div>";
+ }
+ $blogusers = get_users_of_blog( $_GET[ 'id' ] );
+ print "<div class='wrap'><h3>Blog Users</h3>";
+ if( is_array( $blogusers ) ) {
+ print "<table width='100%'><caption>Current Users</caption>";
+ print "<tr><th>User</th><th>Role</th><th>Remove</th><th></th></tr>";
+ reset( $blogusers );
+ while( list( $key, $val ) = each( $blogusers ) )
+ {
+ $t = @unserialize( $val->meta_value );
+ if( is_array( $t ) ) {
+ reset( $t );
+ $existing_role = key( $t );
+ }
+ print "<tr><td>" . $val->user_login . "</td>";
+ if( $val->user_id != $current_user->data->ID ) {
+ ?>
+ <td><select name="role[<?php echo $val->user_id ?>]" id="new_role"><?php
+ foreach($wp_roles->role_names as $role => $name) {
+ $selected = '';
+ if( $role == $existing_role )
+ $selected = 'selected="selected"';
+ echo "<option {$selected} value=\"{$role}\">{$name}</option>";
+ }
+ ?></select></td> <?php
+ print "<td><input title='Click to remove user' type='checkbox' name='blogusers[" . $val->user_id . "]'></td>";
+ } else {
+ print "<td><b>N/A</b></td><td><b>N/A</b></td>";
+ }
+ print "<td><a href='user-edit.php?user_id=" . $val->user_id . "'>Edit</td></tr>";
+ }
+ print "</table>";
+ }
+ print "<h3>Add a new user</h3>";
+ ?>
+<?php autocomplete_css(); ?>
+<p>As you type WordPress will offer you a choice of usernames.<br /> Click them to select and hit <em>Update Options</em> to add the user.</p>
+<table>
+<tr><th scope="row">User&nbsp;Login: </th><td><input type="text" name="newuser" id="newuser"></td></tr>
+<tr><td></td><td><div id="searchresults" class="autocomplete"></div></td> </tr>
+ <tr>
+ <th scope="row"><?php _e('Role:') ?></th>
+ <td><select name="new_role" id="new_role"><?php
+ foreach($wp_roles->role_names as $role => $name) {
+ $selected = '';
+ if( $role == 'subscriber' )
+ $selected = 'selected="selected"';
+ echo "<option {$selected} value=\"{$role}\">{$name}</option>";
+ }
+ ?></select></td>
+ </tr>
+</table>
+</div>
+<div class='wrap'><strong>Misc Blog Actions</strong>
+<p><?php do_action( "wpmueditblogaction", $_GET[ 'id' ] ); ?></p>
+</div>
+<p class="submit">
+<input type="submit" name="Submit" value="<?php _e('Update Options') ?> &raquo;" />
+</p>
+<?php autocomplete_textbox( "wpmu-edit.php?action=searchusers&search=", "newuser", "searchresults" ); ?>
+
+ </td>
+ </table>
+ <?php
+ break;
+ default:
+ if( isset( $_GET[ 'start' ] ) == false ) {
+ $start = 0;
+ } else {
+ $start = intval( $_GET[ 'start' ] );
+ }
+ if( isset( $_GET[ 'num' ] ) == false ) {
+ $num = 60;
+ } else {
+ $num = intval( $_GET[ 'num' ] );
+ }
+
+ $query = "SELECT *
+ FROM ".$wpdb->blogs."
+ WHERE site_id = '".$wpdb->siteid."' ";
+ if( $_GET[ 's' ] != '' ) {
+ $query = "SELECT blog_id, {$wpdb->blogs}.domain, registered, last_updated
+ FROM $wpdb->blogs, $wpdb->site
+ WHERE site_id = '$wpdb->siteid'
+ AND {$wpdb->blogs}.site_id = {$wpdb->site}.id
+ AND {$wpdb->blogs}.domain like '%". $_GET[ 's' ]."%'";
+ } elseif( $_GET[ 'blog_id' ] != '' ) {
+ $query = "SELECT *
+ FROM $wpdb->blogs
+ WHERE site_id = '$wpdb->siteid'
+ AND blog_id = '".intval($_GET[ 'blog_id' ])."'";
+ } elseif( $_GET[ 'ip_address' ] != '' ) {
+ $query = "SELECT *
+ FROM $wpdb->blogs, wp_registration_log
+ WHERE site_id = '$wpdb->siteid'
+ AND {$wpdb->blogs}.blog_id = wp_registration_log.blog_id
+ AND wp_registration_log.IP LIKE ('%".$_GET[ 'ip_address' ]."%')";
+ }
+ if( isset( $_GET[ 'sortby' ] ) == false ) {
+ $_GET[ 'sortby' ] = 'ID';
+ }
+ if( $_GET[ 'sortby' ] == 'Registered' ) {
+ $query .= ' ORDER BY registered ';
+ } elseif( $_GET[ 'sortby' ] == 'ID' ) {
+ $query .= ' ORDER BY ' . $wpdb->blogs . '.blog_id ';
+ } elseif( $_GET[ 'sortby' ] == 'Last Updated' ) {
+ $query .= ' ORDER BY last_updated ';
+ } elseif( $_GET[ 'sortby' ] == 'Blog Name' ) {
+ $query .= ' ORDER BY domain ';
+ }
+ if( $_GET[ 'order' ] == 'DESC' ) {
+ $query .= "DESC";
+ } else {
+ $query .= "ASC";
+ }
+
+ if ( $_GET[ 'ip_address' ] == '' )
+ $query .= " LIMIT " . intval( $start ) . ", " . intval( $num );
+ $blog_list = $wpdb->get_results( $query, ARRAY_A );
+ if( count( $blog_list ) < $num ) {
+ $next = false;
+ } else {
+ $next = true;
+ }
+?>
+<script language="javascript">
+<!--
+var checkflag = "false";
+function check_all_rows() {
+ field = document.formlist;
+ if (checkflag == "false") {
+ for (i = 0; i < field.length; i++) {
+ if( field[i].name == 'allblogs[]' )
+ field[i].checked = true;}
+ checkflag = "true";
+ return "Uncheck All";
+ } else {
+ for (i = 0; i < field.length; i++) {
+ if( field[i].name == 'allblogs[]' )
+ field[i].checked = false; }
+ checkflag = "false";
+ return "Check All";
+ }
+}
+// -->
+</script>
+
+<h2>Blogs</h2>
+<form name="searchform" action="wpmu-blogs.php" method="get" style="float: left; width: 16em; margin-right: 3em;">
+ <table><td>
+ <fieldset>
+ <legend><?php _e('Search Blogs&hellip;') ?></legend>
+ <input type='hidden' name='action' value='blogs'>
+ Name:&nbsp;<input type="text" name="s" value="<?php if (isset($_GET[ 's' ])) echo wp_specialchars($_GET[ 's' ], 1); ?>" size="17" /><br />
+ Blog&nbsp;ID:&nbsp;<input type="text" name="blog_id" value="<?php if (isset($_GET[ 'blog_id' ])) echo wp_specialchars($_GET[ 'blog_id' ], 1); ?>" size="10" /><br />
+ IP Address: <input type="text" name="ip_address" value="<?php if (isset($_GET[ 'ip_address' ])) echo wp_specialchars($_GET[ 'ip_address' ], 1); ?>" size="10" /><br />
+ <input type="submit" name="submit" value="<?php _e('Search') ?>" />
+ </fieldset>
+ <?php
+ if( isset($_GET[ 's' ]) && $_GET[ 's' ] != '' ) {
+ ?><a href="/wp-admin/wpmu-users.php?action=users&s=<?php echo wp_specialchars($_GET[ 's' ], 1) ?>">Search Users: <?php echo wp_specialchars($_GET[ 's' ], 1) ?></a><?php
+ }
+ ?>
+ </td><td>
+ <fieldset>
+ <legend><?php _e('Blog Navigation') ?></legend>
+ <?php
+
+ $url2 = "order=" . $_GET[ 'order' ] . "&sortby=" . $_GET[ 'sortby' ] . "&s=" . $_GET[ 's' ] . "&ip_address=" . $_GET[ 'ip_address' ];
+
+ if( $start == 0 ) {
+ echo 'Previous&nbsp;Blogs';
+ } elseif( $start <= 30 ) {
+ echo '<a href="wpmu-blogs.php?start=0&' . $url2 . ' ">Previous&nbsp;Blogs</a>';
+ } else {
+ echo '<a href="wpmu-blogs.php?start=' . ( $start - $num ) . '&' . $url2 . '">Previous&nbsp;Blogs</a>';
+ }
+ if ( $next ) {
+ echo '&nbsp;||&nbsp;<a href="wpmu-blogs.php?start=' . ( $start + $num ) . '&' . $url2 . '">Next&nbsp;Blogs</a>';
+ } else {
+ echo '&nbsp;||&nbsp;Next&nbsp;Blogs';
+ }
+ ?>
+ </fieldset>
+ </td></table>
+</form>
+
+<br style="clear:both;" />
+
+<?php
+
+// define the columns to display, the syntax is 'internal name' => 'display name'
+$posts_columns = array(
+ 'id' => __('ID'),
+ 'blogname' => __('Blog Name'),
+ 'last_updated' => __('Last Updated'),
+ 'registered' => __('Registered'),
+ 'users' => __('Users'),
+ 'plugins' => __('Actions')
+);
+$posts_columns = apply_filters('manage_posts_columns', $posts_columns);
+
+// you can not edit these at the moment
+$posts_columns['control_view'] = '';
+$posts_columns['control_edit'] = '';
+$posts_columns['control_backend'] = '';
+$posts_columns['control_deactivate'] = '';
+$posts_columns['control_spam'] = '';
+$posts_columns['control_delete'] = '';
+
+?>
+
+<form name='formlist' action='wpmu-edit.php?action=allblogs' method='POST'>
+<input type=button value="Check All" onClick="this.value=check_all_rows()">
+<table width="100%" cellpadding="3" cellspacing="3">
+ <tr>
+
+<?php foreach($posts_columns as $column_display_name) { ?>
+ <th scope="col"><a href="wpmu-blogs.php?sortby=<?php echo urlencode( $column_display_name ) ?>&<?php if( $_GET[ 'sortby' ] == $column_display_name ) { if( $_GET[ 'order' ] == 'DESC' ) { echo "order=ASC&" ; } else { echo "order=DESC&"; } } ?>start=<?php echo $start ?>"><?php echo $column_display_name; ?></a></th>
+<?php } ?>
+
+ </tr>
+<?php
+if ($blog_list) {
+ $bgcolor = '';
+ $status_list = array( "archived" => "#fee", "spam" => "#faa", "deleted" => "#f55" );
+ foreach ($blog_list as $blog) {
+ $class = ('alternate' == $class) ? '' : 'alternate';
+ reset( $status_list );
+ $bgcolour = "";
+ while( list( $status, $col ) = each( $status_list ) ) {
+ if( get_blog_status( $blog[ 'blog_id' ], $status ) == 1 ) {
+ $bgcolour = "style='background: $col'";
+ }
+ }
+ print "<tr $bgcolour class='$class'>";
+
+foreach($posts_columns as $column_name=>$column_display_name) {
+
+ switch($column_name) {
+
+ case 'id':
+ ?>
+ <th scope="row"><input type='checkbox' id='<?php echo $blog[ 'blog_id' ] ?>' name='allblogs[]' value='<?php echo $blog[ 'blog_id' ] ?>'> <label for='<?php echo $blog[ 'blog_id' ] ?>'><?php echo $blog[ 'blog_id' ] ?></label></th>
+ <?php
+ break;
+
+ case 'blogname':
+ ?>
+ <td valign='top'><label for='<?php echo $blog[ 'blog_id' ] ?>'><?php echo str_replace( '.' . $current_site->domain, '', $blog[ 'domain' ] ) ?></label>
+ </td>
+ <?php
+ break;
+
+ case 'last_updated':
+ ?>
+ <td valign='top'><?php echo $blog[ 'last_updated' ] == '0000-00-00 00:00:00' ? "Never" : $blog[ 'last_updated' ] ?></td>
+ <?php
+ break;
+
+ case 'registered':
+ ?>
+ <td valign='top'><?php echo $blog[ 'registered' ] ?></td>
+ <?php
+ break;
+
+ case 'users':
+ ?>
+ <td valign='top'><?php $blogusers = get_users_of_blog( $blog[ 'blog_id' ] ); if( is_array( $blogusers ) ) while( list( $key, $val ) = each( $blogusers ) ) { print '<a href="user-edit.php?user_id=' . $val->user_id . '">' . $val->user_login . '</a> ('.$val->user_email.')<BR>'; } ?></td>
+ <?php
+ break;
+
+ case 'control_view':
+ ?>
+ <td valign='top'><a href="http://<?php echo $blog[ 'domain' ]; ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
+ <?php
+ break;
+
+ case 'control_edit':
+ ?>
+ <td valign='top'><?php echo "<a href='wpmu-blogs.php?action=editblog&amp;id=".$blog[ 'blog_id' ]."' class='edit'>" . __('Edit') . "</a>"; ?></td>
+ <?php
+ break;
+
+ case 'control_backend':
+ ?>
+ <td valign='top'><?php echo "<a href='http://" . $blog[ 'domain' ] . $current_site->path . "wp-admin/' class='edit'>" . __('Backend') . "</a>"; ?></td>
+ <?php
+ break;
+
+ case 'control_spam':
+ if( get_blog_status( $blog[ 'blog_id' ], "spam" ) == '1' ) {
+ ?>
+ <td valign='top'><?php echo "<a href='wpmu-edit.php?action=unspamblog&amp;id=".$blog[ 'blog_id' ]."' class='edit' onclick=\"return confirm('" . sprintf(__("You are about to mark this blog as not spam?\\n \'OK\' to activate, \'Cancel\' to stop.") ) . "')\">" . __('Not Spam') . "</a>"; ?></td>
+ <?php
+ } else {
+ ?>
+ <td valign='top'><?php echo "<a href='wpmu-edit.php?action=spamblog&amp;id=".$blog[ 'blog_id' ]."' class='delete' onclick=\"return confirm('" . sprintf(__("You are about to mark this blog as spam?\\n \'OK\' to continue, \'Cancel\' to stop.") ) . "')\">" . __('Spam') . "</a>"; ?></td>
+ <?php
+ }
+ break;
+
+ case 'control_deactivate':
+ if( is_archived( $blog[ 'blog_id' ] ) == '1' ) {
+ ?>
+ <td valign='top'><?php echo "<a href='wpmu-edit.php?action=activateblog&amp;id=".$blog[ 'blog_id' ]."' class='edit' onclick=\"return confirm('" . sprintf(__("You are about to activate this blog?\\n \'OK\' to activate, \'Cancel\' to stop.") ) . "')\">" . __('Activate') . "</a>"; ?></td>
+ <?php
+ } else {
+ ?>
+ <td valign='top'><?php echo "<a href='wpmu-edit.php?action=deactivateblog&amp;id=".$blog[ 'blog_id' ]."' class='delete' onclick=\"return confirm('" . sprintf(__("You are about to deactivate this blog?\\n \'OK\' to deactivate, \'Cancel\' to stop.") ) . "')\">" . __('Deactivate') . "</a>"; ?></td>
+ <?php
+ }
+ break;
+
+ case 'control_delete':
+ ?>
+ <td valign='top'><?php echo "<a href='wpmu-edit.php?action=deleteblog&amp;id=".$blog[ 'blog_id' ]."&amp;redirect=".wpmu_admin_redirect_url()."' class='delete' onclick=\"return confirm('" . sprintf(__("You are about to delete this blog?\\n \'OK\' to delete, \'Cancel\' to stop.") ) . "')\">" . __('Delete') . "</a>"; ?></td>
+ <?php
+ break;
+
+ case 'plugins':
+ ?>
+ <td valign='top'><?php do_action( "wpmublogsaction", $blog[ 'blog_id' ] ); ?></td>
+ <?php
+ break;
+
+ default:
+ ?>
+ <td valign='top'><?php do_action('manage_posts_custom_column', $column_name, $id); ?></td>
+ <?php
+ break;
+ }
+}
+?>
+ </tr>
+<?php
+}
+} else {
+?>
+ <tr style='background-color: <?php echo $bgcolor; ?>'>
+ <td colspan="8"><?php _e('No blogs found.') ?></td>
+ </tr>
+<?php
+} // end if ($blogs)
+?>
+</table>
+<input type=button value="Check All" onClick="this.value=check_all_rows()">
+<p>Selected Blogs:<ul>
+<li><input type='radio' name='blogfunction' id='delete' value='delete'> <label for='delete'>Delete</label></li>
+<li><input type='radio' name='blogfunction' id='spam' value='spam'> <label for='spam'>Mark as Spam</label></li>
+</ul>
+<input type='hidden' name='redirect' value='<?php echo $_SERVER[ 'REQUEST_URI' ] ?>'>
+<input type='submit' value='Apply Changes'></p>
+</form>
+<?php
+
+break;
+} // end switch( $action )
+?>
+
+</div>
+<?php include('admin-footer.php'); ?>
diff --git a/wp-admin/wpmu-edit.php b/wp-admin/wpmu-edit.php
new file mode 100644
index 0000000..ee9913c
--- /dev/null
+++ b/wp-admin/wpmu-edit.php
@@ -0,0 +1,263 @@
+<?php
+require_once('admin.php');
+
+do_action( "wpmuadminedit", "" );
+
+$_POST[ 'id' ] = intval( $_POST[ 'id' ] );
+$_GET[ 'id' ] = intval( $_GET[ 'id' ] );
+$id = $_POST[ 'id' ];
+
+switch( $_GET[ 'action' ] ) {
+ case "siteoptions":
+ if( is_site_admin() == false ) {
+ die( __('<p>You do not have permission to access this page.</p>') );
+ }
+
+ update_site_option( "WPLANG", $_POST[ 'WPLANG' ] );
+ update_site_option( "illegal_names", split( ' ', $_POST[ 'illegal_names' ] ) );
+ if( $_POST[ 'limited_email_domains' ] != '' ) {
+ update_site_option( "limited_email_domains", split( ' ', $_POST[ 'limited_email_domains' ] ) );
+ } else {
+ update_site_option( "limited_email_domains", '' );
+ }
+ update_site_option( "menu_items", $_POST[ 'menu_items' ] );
+ update_site_option( "blog_upload_space", $_POST[ 'blog_upload_space' ] );
+ update_site_option( "upload_filetypes", $_POST[ 'upload_filetypes' ] );
+ update_site_option( "site_name", $_POST[ 'site_name' ] );
+ update_site_option( "first_post", $_POST[ 'first_post' ] );
+ update_site_option( "welcome_email", $_POST[ 'welcome_email' ] );
+ update_site_option( "fileupload_maxk", $_POST[ 'fileupload_maxk' ] );
+ $site_admins = explode( ' ', $_POST['site_admins'] );
+ if ( is_array( $site_admins ) )
+ update_site_option( 'site_admins' , $site_admins );
+ header( "Location: wpmu-options.php?updated=true" );
+ exit;
+ break;
+ case "searchcategories":
+ $search = wp_specialchars( $_POST[ 'search' ] );
+ $query = "SELECT cat_name FROM " . $wpdb->sitecategories . " WHERE cat_name LIKE '%" . $search . "%' limit 0,10";
+ $cats = $wpdb->get_results( $query );
+ if( is_array( $cats ) ) {
+ print "<ul>";
+ while( list( $key, $val ) = each( $cats ) )
+ {
+ print "<li>{$val->cat_name}</li>";
+ }
+ print "</ul>";
+ }
+ exit;
+ break;
+ case "searchusers":
+ $search = wp_specialchars( $_POST[ 'search' ] );
+ $query = "SELECT " . $wpdb->users . ".ID, " . $wpdb->users . ".user_login FROM " . $wpdb->users . " WHERE user_login LIKE '" . $search . "%' limit 0,10";
+ $users = $wpdb->get_results( $query );
+ if( is_array( $users ) ) {
+ print "<ul>";
+ while( list( $key, $val ) = each( $users ) )
+ {
+ print "<li>{$val->user_login}</li>";
+ }
+ print "</ul>";
+ } else {
+ print "No Users Found";
+ }
+ exit;
+ break;
+ case "updatefeeds":
+ if( is_site_admin() == false ) {
+ die( __('<p>You do not have permission to access this page.</p>') );
+ }
+
+ update_site_option( "customizefeed1", $_POST[ 'customizefeed1' ] );
+ update_site_option( "customizefeed2", $_POST[ 'customizefeed2' ] );
+ update_site_option( "dashboardfeed1", $_POST[ 'dashboardfeed1' ] );
+ update_site_option( "dashboardfeed2", $_POST[ 'dashboardfeed2' ] );
+ update_site_option( "dashboardfeed1name", $_POST[ 'dashboardfeed1name' ] );
+ update_site_option( "dashboardfeed2name", $_POST[ 'dashboardfeed2name' ] );
+ header( "Location: wpmu-feeds.php?updated=true" );
+ break;
+ case "updateblog":
+ if( is_site_admin() == false ) {
+ die( __('<p>You do not have permission to access this page.</p>') );
+ }
+ $options_table_name = $wpmuBaseTablePrefix . $id ."_options";
+
+ // themes
+ if( is_array( $_POST[ 'theme' ] ) ) {
+ $allowed_themes = $_POST[ 'theme' ];
+ $_POST[ 'option' ][ 'allowed_themes' ] = $_POST[ 'theme' ];
+ } else {
+ $_POST[ 'option' ][ 'allowed_themes' ] = '';
+ }
+ if( is_array( $_POST[ 'option' ] ) ) {
+ while( list( $key, $val ) = each( $_POST[ 'option' ] ) ) {
+ update_blog_option( $id, $key, $val );
+ }
+ }
+ // update blogs table
+ $query = "UPDATE $wpdb->blogs
+ SET domain = '".$_POST[ 'blog' ][ 'domain' ]."',
+ path = '".$_POST[ 'blog' ][ 'path' ]."',
+ registered = '".$_POST[ 'blog' ][ 'registered' ]."',
+ public = '".$_POST[ 'blog' ][ 'public' ]."',
+ archived = '".$_POST[ 'blog' ][ 'archived' ]."',
+ mature = '".$_POST[ 'blog' ][ 'mature' ]."',
+ deleted = '".$_POST[ 'blog' ][ 'deleted' ]."',
+ spam = '".$_POST[ 'blog' ][ 'spam' ]."'
+ WHERE blog_id = '$id'";
+ $result = $wpdb->query( $query );
+ update_blog_status( $id, 'spam', $_POST[ 'blog' ][ 'spam' ] );
+ // user roles
+ if( is_array( $_POST[ 'role' ] ) == true ) {
+ $newroles = $_POST[ 'role' ];
+ reset( $newroles );
+ while( list( $userid, $role ) = each( $newroles ) ) {
+ $role_len = strlen( $role );
+ $existing_role = $wpdb->get_var( "SELECT meta_value FROM $wpdb->usermeta WHERE user_id = '$userid' AND meta_key = '" . $wpmuBaseTablePrefix . $id . "_capabilities'" );
+ if( false == $existing_role ) {
+ $wpdb->query( "INSERT INTO " . $wpdb->usermeta . "( `umeta_id` , `user_id` , `meta_key` , `meta_value` ) VALUES ( NULL, '$userid', '" . $wpmuBaseTablePrefix . $id . "_capabilities', 'a:1:{s:" . strlen( $role ) . ":\"" . $role . "\";b:1;}')" );
+ } elseif( $existing_role != "a:1:{s:" . strlen( $role ) . ":\"" . $role . "\";b:1;}" ) {
+ $wpdb->query( "UPDATE $wpdb->usermeta SET meta_value = 'a:1:{s:" . strlen( $role ) . ":\"" . $role . "\";b:1;}' WHERE user_id = '$userid' AND meta_key = '" . $wpmuBaseTablePrefix . $id . "_capabilities'" );
+ }
+
+ }
+ }
+
+ // remove user
+ if( is_array( $_POST[ 'blogusers' ] ) ) {
+ reset( $_POST[ 'blogusers' ] );
+ while( list( $key, $val ) = each( $_POST[ 'blogusers' ] ) ) {
+ $wpdb->query( "DELETE FROM " . $wpdb->usermeta . " WHERE meta_key = '" . $wpmuBaseTablePrefix . $id . "_capabilities' AND user_id = '" . $key . "'" );
+ }
+ }
+
+
+ // add user?
+ if( $_POST[ 'newuser' ] != '' ) {
+ $newuser = $_POST[ 'newuser' ];
+ $userid = $wpdb->get_var( "SELECT ID FROM " . $wpdb->users . " WHERE user_login = '$newuser'" );
+ if( $userid ) {
+ $user = $wpdb->get_var( "SELECT user_id FROM " . $wpdb->usermeta . " WHERE user_id='$userid' AND meta_key='wp_" . $id . "_capabilities'" );
+ if( $user == false )
+ $wpdb->query( "INSERT INTO " . $wpdb->usermeta . "( `umeta_id` , `user_id` , `meta_key` , `meta_value` ) VALUES ( NULL, '$userid', '" . $wpmuBaseTablePrefix . $id . "_capabilities', 'a:1:{s:" . strlen( $_POST[ 'new_role' ] ) . ":\"" . $_POST[ 'new_role' ] . "\";b:1;}')" );
+ }
+ }
+ header( "Location: wpmu-blogs.php?action=editblog&id=".$id."&updated=true" );
+ break;
+ case "deleteblog":
+ if( is_site_admin() == false ) {
+ die( __('<p>You do not have permission to access this page.</p>') );
+ }
+ $id = $_GET[ 'id' ];
+ if( $id != '0' && $id != '1' )
+ wpmu_delete_blog( $id, true );
+ wpmu_admin_do_redirect( "wpmu-blogs.php" );
+ break;
+ case "allblogs":
+ if( is_site_admin() == false ) {
+ die( __('<p>You do not have permission to access this page.</p>') );
+ }
+ if( is_array( $_POST[ 'allblogs' ] ) ) {
+ while( list( $key, $val ) = each( $_POST[ 'allblogs' ] ) ) {
+ if( $val != '0' && $val != '1' ) {
+ if( $_POST[ 'blogfunction' ] == 'delete' ) {
+ wpmu_delete_blog( $val, true );
+ } elseif( $_POST[ 'blogfunction' ] == 'spam' ) {
+ update_blog_status( $val, "spam", '1' );
+ }
+ }
+ }
+ }
+
+ if( isset( $_POST[ 'redirect' ] ) ) {
+ wpmu_admin_do_redirect( $_POST[ 'redirect' ] );
+ } else {
+ header( "Location: wpmu-blogs.php?updated=true" );
+ }
+ break;
+ case "activateblog":
+ if( is_site_admin() == false ) {
+ die( __('<p>You do not have permission to access this page.</p>') );
+ }
+ update_archived( $_GET[ 'id' ], '0' );
+ header( "Location: wpmu-blogs.php?updated=true" );
+ break;
+ case "deactivateblog":
+ if( is_site_admin() == false ) {
+ die( __('<p>You do not have permission to access this page.</p>') );
+ }
+ do_action( "deactivate_blog", $_GET[ 'id' ] );
+ update_archived( $_GET[ 'id' ], '1' );
+ header( "Location: wpmu-blogs.php?updated=true" );
+ break;
+ case "unspamblog":
+ if( is_site_admin() == false ) {
+ die( __('<p>You do not have permission to access this page.</p>') );
+ }
+ update_blog_status( $_GET[ 'id' ], "spam", '0' );
+ header( "Location: wpmu-blogs.php?updated=true" );
+ break;
+ case "spamblog":
+ if( is_site_admin() == false ) {
+ die( __('<p>You do not have permission to access this page.</p>') );
+ }
+ do_action( "make_spam_blog", $_GET[ 'id' ] );
+ update_blog_status( $_GET[ 'id' ], "spam", '1' );
+ header( "Location: wpmu-blogs.php?updated=true" );
+ break;
+ case "mature":
+ update_blog_status( $_GET[ 'id' ], 'mature', '1' );
+ do_action( 'mature_blog', $_GET[ 'id' ] );
+ header( "Location: wpmu-blogs.php?updated=true" );
+ break;
+ case "unmature":
+ update_blog_status( $_GET[ 'id' ], 'mature', '0' );
+ do_action( 'unmature_blog', $_GET[ 'id' ] );
+ header( "Location: wpmu-blogs.php?updated=true" );
+ break;
+ case "updateuser":
+ if( is_site_admin() == false ) {
+ die( __('<p>You do not have permission to access this page.</p>') );
+ }
+ unset( $_POST[ 'option' ][ 'ID' ] );
+ if( is_array( $_POST[ 'option' ] ) ) {
+ while( list( $key, $val ) = each( $_POST[ 'option' ] ) ) {
+ $query = "UPDATE ".$wpdb->users." SET ".$key." = '".$val."' WHERE ID = '".$id."'";
+ $wpdb->query( $query );
+ }
+ }
+ if( is_array( $_POST[ 'meta' ] ) ) {
+ while( list( $key, $val ) = each( $_POST[ 'meta' ] ) ) {
+ $query = "UPDATE ".$wpdb->usermeta." SET meta_key = '".$_POST[ 'metaname' ][ $key ]."', meta_value = '".$val."' WHERE umeta_id = '".$key."'";
+ $wpdb->query( $query );
+ }
+ }
+ if( is_array( $_POST[ 'metadelete' ] ) ) {
+ while( list( $key, $val ) = each( $_POST[ 'metadelete' ] ) ) {
+ $query = "DELETE FROM ".$wpdb->usermeta." WHERE umeta_id = '".$key."'";
+ $wpdb->query( $query );
+ }
+ }
+ header( "Location: wpmu-users.php?action=edit&id=".$id."&updated=true" );
+ break;
+ case "updatethemes":
+ if( is_site_admin() == false ) {
+ die( __('<p>You do not have permission to access this page.</p>') );
+ }
+ if( is_array( $_POST[ 'theme' ] ) ) {
+ $themes = array_flip( array_keys( get_themes() ) );
+ reset( $themes );
+ while( list( $key, $val ) = each( $themes ) )
+ {
+ if( $_POST[ 'theme' ][ addslashes( $key ) ] == 'enabled' )
+ $allowed_themes[ $key ] = true;
+ }
+ update_site_option( 'allowed_themes', $allowed_themes );
+ }
+ header( "Location: wpmu-themes.php?updated=true" );
+ break;
+ default:
+ header( "Location: wpmu-admin.php" );
+ break;
+}
+?>
diff --git a/wp-admin/wpmu-feedback.php b/wp-admin/wpmu-feedback.php
new file mode 100644
index 0000000..ff8c2bb
--- /dev/null
+++ b/wp-admin/wpmu-feedback.php
@@ -0,0 +1,10 @@
+<?php
+require_once('admin.php');
+/*
+function wpmufeedback() {
+ // do something with: $_GET[ 'user_login' ], $_GET[ 'host' ], $_GET[ 'browser' ], $_GET[ 'req' ], $_GET[ 'feedback' ]
+}
+*/
+wpmufeedback();
+echo srand( 5 );
+?>
diff --git a/wp-admin/wpmu-feeds.php b/wp-admin/wpmu-feeds.php
new file mode 100644
index 0000000..98fd213
--- /dev/null
+++ b/wp-admin/wpmu-feeds.php
@@ -0,0 +1,43 @@
+<?php
+require_once('admin.php');
+
+$title = __('WPMU Admin');
+$parent_file = 'wpmu-admin.php';
+require_once('admin-header.php');
+if( is_site_admin() == false ) {
+ die( __('<p>You do not have permission to access this page.</p>') );
+}
+if (isset($_GET['updated'])) {
+ ?><div id="message" class="updated fade"><p><?php _e('Options saved.') ?></p></div><?php
+}
+print '<div class="wrap">';
+switch( $_GET[ 'action' ] ) {
+ default:
+ break;
+}
+
+$customizefeed1 = get_site_option( 'customizefeed1' );
+$customizefeed2 = get_site_option( 'customizefeed2' );
+$dashboardfeed1 = get_site_option( 'dashboardfeed1' );
+$dashboardfeed2 = get_site_option( 'dashboardfeed2' );
+$dashboardfeed1name = get_site_option( 'dashboardfeed1name' );
+$dashboardfeed2name = get_site_option( 'dashboardfeed2name' );
+
+?>
+<h2>Dashboard Feeds</h2>
+<p>The dashboard displays two feeds. You can allow your users to customize those feeds to set them to a feed of your own.</p>
+<form action='wpmu-edit.php?action=updatefeeds' method='POST'>
+<table>
+<tr><td valign='top'>Feed 1</td><td><ul><li> User customizable: <input type='radio' name='customizefeed1' value='1'<?php echo $customizefeed1 == 1 ? ' checked' : ''?>> Yes <input type='radio' name='customizefeed1' value='0'<?php echo $customizefeed1 == 0 ? ' checked' : ''?>> No</li>
+ <li> Title: <input type='text' name='dashboardfeed1name' size='40' value='<?php echo $dashboardfeed1name ?>'></li>
+ <li> Default Feed URL: <input type='text' name='dashboardfeed1' size='40' value='<?php echo $dashboardfeed1 ?>'></li></ul></td></tr>
+<tr><td valign='top'>Feed 2</td><td><ul><li> User customizable: <input type='radio' name='customizefeed2' value='1'<?php echo $customizefeed2 == 1 ? ' checked' : ''?>> Yes <input type='radio' name='customizefeed2' value='0'<?php echo $customizefeed2 == 0 ? ' checked' : ''?>> No</li>
+ <li> Title: <input type='text' name='dashboardfeed2name' size='40' value='<?php echo $dashboardfeed2name ?>'></li>
+ <li> Default Feed URL: <input type='text' name='dashboardfeed2' size='40' value='<?php echo $dashboardfeed2 ?>'></li></ul></td></tr>
+
+</table>
+<input type='submit' value='Update Feeds'>
+</form>
+
+</div>
+<?php include('admin-footer.php'); ?>
diff --git a/wp-admin/wpmu-options.php b/wp-admin/wpmu-options.php
new file mode 100644
index 0000000..bded6ea
--- /dev/null
+++ b/wp-admin/wpmu-options.php
@@ -0,0 +1,131 @@
+<?php
+require_once('admin.php');
+$title = __('Site Options');
+$parent_file = 'wpmu-admin.php';
+
+include('admin-header.php');
+
+if( is_site_admin() == false ) {
+ die( __('<p>You do not have permission to access this page.</p>') );
+}
+
+if (isset($_GET['updated'])) {
+ ?><div id="message" class="updated fade"><p><?php _e('Options saved.') ?></p></div><?php
+}
+
+?>
+<div class="wrap">
+ <h2><?php _e('Site Options') ?></h2>
+ <form name="form1" method="post" action="wpmu-edit.php?action=siteoptions">
+ <fieldset class="options">
+ <legend><?php _e('Operational Settings <em>(These settings cannot be modified by blog owners)</em>') ?></legend>
+ <table width="100%" cellspacing="2" cellpadding="5" class="editform">
+ <tr valign="top">
+ <th scope="row"><?php _e('Site Name:') ?></th>
+ <td><input name="site_name" type="text" id="site_name" style="width: 95%" value="<?php echo $current_site->site_name ?>" size="45" />
+ <br />
+ <?php _e('What you would like to call this website.') ?></td>
+ </tr>
+ <tr valign="top">
+ <th scope="row"><?php _e('Welcome Email:') ?></th>
+ <td><textarea name="welcome_email" id="welcome_email" rows='5' cols='45' style="width: 95%"><?php echo stripslashes( get_site_option('welcome_email') ) ?></textarea>
+ <br />
+ <?php _e('The welcome email sent to new blog owners.') ?></td>
+ </tr>
+ <tr valign="top">
+ <th scope="row"><?php _e('First Post:') ?></th>
+ <td><textarea name="first_post" id="first_post" rows='5' cols='45' style="width: 95%"><?php echo stripslashes( get_site_option('first_post') ) ?></textarea>
+ <br />
+ <?php _e('First post on a new blog.') ?></td>
+ </tr>
+ <tr valign="top">
+ <th scope="row"><?php _e('Banned Names:') ?></th>
+ <td><input name="illegal_names" type="text" id="illegal_names" style="width: 95%" value="<?php echo implode( " ", get_site_option('illegal_names') ); ?>" size="45" />
+ <br />
+ <?php _e('Users are not allowed to register these blogs. Separate names by spaces.') ?></td>
+ </tr>
+ <tr valign="top">
+ <th scope="row"><?php _e('Limited Email Registrations:') ?></th>
+ <td><input name="limited_email_domains" type="text" id="limited_email_domains" style="width: 95%" value="<?php echo get_site_option('limited_email_domains') == '' ? '' : @implode( " ", get_site_option('limited_email_domains') ); ?>" size="45" />
+ <br />
+ <?php _e('If you want to limit blog registrations to certain domains. Separate domains by spaces.') ?></td>
+ </tr>
+ <tr valign="top">
+ <th scope="row"><?php _e('Blog upload space:') ?></th>
+ <td><input name="blog_upload_space" type="text" id="blog_upload_space" value="<?php echo get_site_option('blog_upload_space', 10) ?>" size="3" /> MB
+ </tr>
+ <tr valign="top">
+ <th scope="row"><?php _e('Upload File Types:') ?></th>
+ <td><input name="upload_filetypes" type="text" id="upload_filetypes" value="<?php echo get_site_option('upload_filetypes', 'jpg jpeg png gif') ?>" size="45" />
+ </tr>
+ <tr valign="top">
+ <th scope="row"><?php _e('Max upload file size:') ?></th>
+ <td><input name="fileupload_maxk" type="text" id="fileupload_maxk" value="<?php echo get_site_option('fileupload_maxk', 300) ?>" size="5" /> KB
+ </tr>
+ </table>
+ </fieldset>
+ <fieldset class="options">
+ <legend><?php _e('Administration Settings') ?></legend>
+ <table width="100%" cellspacing="2" cellpadding="5" class="editform">
+ <tr valign="top">
+ <th scope="row"><?php _e('Site Admins:') ?></th>
+ <td><input name="site_admins" type="text" id="site_admins" style="width: 95%" value="<?php echo implode( " ", get_site_option( 'site_admins', array( 'admin' ) ) ) ?>" size="45" />
+ <br />
+ <?php _e('These users may login to the main blog and administer the site.') ?></td>
+ </tr>
+ </table>
+ </fieldset>
+ <fieldset class="options">
+ <legend><?php _e('Site Wide Settings <em>(These settings may be overridden by blog owners)</em>') ?></legend>
+ <table width="100%" cellspacing="2" cellpadding="5" class="editform">
+ <?php
+ $lang_files = glob( ABSPATH . WPINC . "/languages/*" );
+ $lang = get_site_option( "WPLANG" );
+ if( is_array( $lang_files ) ) {
+ ?>
+ <tr valign="top">
+ <th width="33%" scope="row"><?php _e('Default Language:') ?></th>
+ <td><select name="WPLANG" id="WPLANG">
+ <?php
+ echo "<option value=''>Default</option>";
+ while( list( $key, $val ) = each( $lang_files ) ) {
+ $l = basename( $val, ".mo" );
+ echo "<option value='$l'";
+ echo $lang == $l ? " selected" : "";
+ echo "> $l</option>";
+ }
+ ?>
+ </select></td>
+ </tr>
+ <?php
+ } // languages
+ ?>
+ </table>
+ </fieldset>
+ <fieldset class="options">
+ <legend><?php _e('Menus <em>(Enable or disable WP Backend Menus)</em>') ?></legend>
+ <table cellspacing="2" cellpadding="5" class="editform">
+ <tr><th scope='row'>Menu</th><th scope='row'>Enabled</th></tr>
+ <?php
+ $menu_perms = get_site_option( "menu_items" );
+ $menu_items = array( "plugins" );
+ while( list( $key, $val ) = each( $menu_items ) )
+ {
+ if( $menu_perms[ $val ] == '1' ) {
+ $checked = ' checked';
+ } else {
+ $checked = '';
+ }
+ print "<tr><th scope='row'>" . ucfirst( $val ) . "</th><td><input type='checkbox' name='menu_items[" . $val . "]' value='1'" . $checked . "></tr>";
+ }
+ ?>
+ </table>
+ </fieldset>
+ <fieldset class="options">
+ </fieldset>
+ <p class="submit">
+ <input type="submit" name="Submit" value="<?php _e('Update Options') ?>" />
+ </p>
+ </form>
+</div>
+<?php include('./admin-footer.php'); ?>
diff --git a/wp-admin/wpmu-themes.php b/wp-admin/wpmu-themes.php
new file mode 100644
index 0000000..a8e679c
--- /dev/null
+++ b/wp-admin/wpmu-themes.php
@@ -0,0 +1,57 @@
+<?php
+require_once('admin.php');
+
+$title = __('WPMU Admin');
+$parent_file = 'wpmu-admin.php';
+require_once('admin-header.php');
+if( is_site_admin() == false ) {
+ die( __('<p>You do not have permission to access this page.</p>') );
+}
+if (isset($_GET['updated'])) {
+ ?><div id="message" class="updated fade"><p><?php _e('Options saved.') ?></p></div><?php
+}
+print '<div class="wrap">';
+$themes = get_themes();
+$allowed_themes = get_site_option( "allowed_themes" );
+if( $allowed_themes == false ) {
+ $allowed_themes = array_keys( $themes );
+}
+?>
+
+<form action='wpmu-edit.php?action=updatethemes' method='POST'>
+<h3>Site Themes</h3>
+<table border="0" cellspacing="5" cellpadding="5">
+<caption>Disable themes site-wide. You can enable themes on a blog by blog basis.</caption>
+<tr><th width="100">Disabled</th><th>Theme</th><th>Description</th></tr>
+<?php
+while( list( $key, $val ) = each( $themes ) ) {
+ $i++;
+ $enabled = '';
+ $disabled = '';
+ if( isset( $allowed_themes[ $key ] ) == true ) {
+ $enabled = 'checked ';
+ } else {
+ $disabled = 'checked ';
+ }
+?>
+
+<tr valign="top" style="<?php if ($i%2) echo 'background: #eee'; ?>">
+<td>
+<label><input name="theme[<?php echo $key ?>]" type="radio" id="<?php echo $key ?>" value="disabled" <?php echo $disabled ?>/> Yes</label>
+&nbsp;&nbsp;&nbsp;
+<label><input name="theme[<?php echo $key ?>]" type="radio" id="<?php echo $key ?>" value="enabled" <?php echo $enabled ?>/> No</label>
+</td>
+<th scope="row" align="left"><?php echo $key ?></th>
+<td><?php echo $val[ 'Description' ] ?></td>
+</tr>
+<?php
+}
+?>
+</table>
+<p class="submit">
+<input type='submit' value='Update Themes &raquo;' />
+</p>
+</form>
+
+</div>
+<?php include('admin-footer.php'); ?>
diff --git a/wp-admin/wpmu-upgrade-site.php b/wp-admin/wpmu-upgrade-site.php
new file mode 100644
index 0000000..284b9ca
--- /dev/null
+++ b/wp-admin/wpmu-upgrade-site.php
@@ -0,0 +1,73 @@
+<?php
+require_once('admin.php');
+
+$http_fopen = ini_get("allow_url_fopen");
+if(!$http_fopen) require_once('../wp-includes/class-snoopy.php');
+
+$title = __('WPMU Admin');
+$parent_file = 'wpmu-admin.php';
+require_once('admin-header.php');
+if( is_site_admin() == false ) {
+ die( __('<p>You do not have permission to access this page.</p>') );
+}
+if (isset($_GET['updated'])) {
+ ?><div id="message" class="updated fade"><p><?php _e('Options saved.') ?></p></div><?php
+}
+print '<div class="wrap">';
+switch( $_GET[ 'action' ] ) {
+ case "upgrade":
+ if( isset( $_GET[ 'n' ] ) == false ) {
+ $n = 0;
+ } else {
+ $n = $_GET[ 'n' ];
+ }
+ $blogs = $wpdb->get_results( "SELECT * FROM $wpdb->blogs WHERE site_id = '$wpdb->siteid' AND spam = '0' AND deleted = '0' AND archived = '0' ORDER BY registered DESC LIMIT $n, 5", ARRAY_A );
+ if( is_array( $blogs ) ) {
+ print "<ul>";
+ foreach( $blogs as $details ) {
+ if( $details[ 'spam' ] == 0 && $details[ 'deleted' ] == 0 && $details[ 'archived' ] == 0 ) {
+ $siteurl = $wpdb->get_var( "SELECT option_value from {$wpmuBaseTablePrefix}{$details[ 'blog_id' ]}_options WHERE option_name = 'siteurl'" );
+ print "<li>$siteurl</li>";
+ if($http_fopen) {
+ $fp = fopen( $siteurl . "wp-admin/upgrade.php?step=1", "r" );
+ if( $fp ) {
+ while( feof( $fp ) == false ) {
+ fgets($fp, 4096);
+ }
+ fclose( $fp );
+ }
+ } else {
+ $client = new Snoopy();
+ @$client->fetch($siteurl . "wp-admin/upgrade.php?step=1");
+ }
+ }
+ }
+ print "</ul>";
+ ?>
+ <p>If your browser doesn't start loading the next page automatically click this link: <a href="?action=upgrade&n=<?php echo ($n + 5) ?>">Next Blogs</a> </p>
+ <script language='javascript'>
+ <!--
+
+ function nextpage() {
+ location.href="wpmu-upgrade-site.php?action=upgrade&n=<?php echo ($n + 5) ?>";
+ }
+ setTimeout( "nextpage()", 250 );
+
+ //-->
+ </script>
+ <?php
+ } else {
+ print "All Done!";
+ }
+ break;
+ default:
+ ?>
+ <p>You can upgrade all the blogs on your site through this page. It works by calling the upgrade script of each blog automatically. Hit the link below to upgrade.</p>
+ <p><a href="wpmu-upgrade-site.php?action=upgrade">Upgrade Site</a></p>
+ <?php
+ break;
+
+}
+?>
+</div>
+<?php include('admin-footer.php'); ?>
diff --git a/wp-admin/wpmu-users.php b/wp-admin/wpmu-users.php
new file mode 100644
index 0000000..fdcf55e
--- /dev/null
+++ b/wp-admin/wpmu-users.php
@@ -0,0 +1,339 @@
+<?php
+require_once('admin.php');
+
+switch( $_GET[ 'action' ] ) {
+ case "delete":
+ $id = intval( $_GET[ 'id' ] );
+ if( $id != '0' && $id != '1' )
+ wpmu_delete_user($id);
+ wpmu_admin_do_redirect( "wpmu-users.php" );
+ die();
+ break;
+}
+
+$title = __('WPMU Admin');
+$parent_file = 'wpmu-admin.php';
+require_once('admin-header.php');
+if( is_site_admin() == false ) {
+ die( __('<p>You do not have permission to access this page.</p>') );
+}
+if (isset($_GET['updated'])) {
+ ?><div id="message" class="updated fade"><p><?php _e('Options saved.') ?></p></div><?php
+}
+
+print '<div class="wrap">';
+switch( $_GET[ 'action' ] ) {
+ case "edit":
+ print "<h2>Edit User</h2>";
+ $options_table_name = $wpmuBaseTablePrefix . $_GET[ 'id' ] ."_options";
+ $query = "SELECT *
+ FROM ".$wpdb->users."
+ WHERE ID = '".$_GET[ 'id' ]."'";
+ $userdetails = $wpdb->get_results( $query, ARRAY_A );
+ $query = "SELECT *
+ FROM ".$wpdb->usermeta."
+ WHERE user_id = '".$_GET[ 'id' ]."'";
+ $usermetadetails= $wpdb->get_results( $query, ARRAY_A );
+ ?>
+ <table><td valign='top'>
+ <form name="form1" method="post" action="wpmu-edit.php?action=updateuser">
+ <input type="hidden" name="id" value="<?php echo $_GET[ 'id' ] ?>" />
+ <table width="100%" cellspacing="2" cellpadding="5" class="editform">
+ <?php
+ unset( $userdetails[0][ 'ID' ] );
+ while( list( $key, $val ) = each( $userdetails[0] ) ) {
+ ?>
+ <tr valign="top">
+ <th width="33%" scope="row"><?php echo ucwords( str_replace( "_", " ", $key ) ) ?></th>
+ <td><input name="option[<?php echo $key ?>]" type="text" id="<?php echo $val ?>" value="<?php echo $val ?>" size="40" /></td>
+ </tr>
+ <?php
+ }
+ ?>
+ </table>
+ </td><td valign='top'>
+ <table width="100%" cellspacing="2" cellpadding="5" class="editform">
+ <tr><th style='text-align: left'>Name</th><th style='text-align: left'>Value</th><th style='text-align: left'>Delete</th></tr>
+ <?php
+ while( list( $key, $val ) = each( $usermetadetails ) ) {
+ if( substr( $val[ 'meta_key' ], -12 ) == 'capabilities' )
+ return;
+ ?>
+ <tr valign="top">
+ <th width="33%" scope="row"><input name="metaname[<?php echo $val[ 'umeta_id' ] ?>]" type="text" id="<?php echo $val[ 'meta_key' ] ?>" value="<?php echo $val[ 'meta_key' ] ?>"></th>
+ <td><input name="meta[<?php echo $val[ 'umeta_id' ] ?>]" type="text" id="<?php echo $val[ 'meta_value' ] ?>" value="<?php echo addslashes( $val[ 'meta_value' ] ) ?>" size="40" /></td>
+ <td><input type='checkbox' name='metadelete[<?php echo $val[ 'umeta_id' ] ?>]'></td>
+ </tr>
+ <?php
+ }
+ ?>
+ </table>
+ </td></table>
+
+ <p class="submit">
+ <input type="submit" name="Submit" value="<?php _e('Update User') ?> &raquo;" />
+ </p>
+ <?php
+ break;
+ case "allusers":
+ if( is_site_admin() == false ) {
+ die( __('<p>You do not have permission to access this page.</p>') );
+ }
+ if( is_array( $_POST[ 'allusers' ] ) ) {
+ while( list( $key, $val ) = each( $_POST[ 'allusers' ] ) ) {
+ if( $val != '' && $val != '0' && $val != '1' ) {
+ $user_details = get_userdata( $val );
+ if( $_POST[ 'userfunction' ] == 'delete' ) {
+ wpmu_delete_user($val);
+ } elseif( $_POST[ 'userfunction' ] == 'spam' ) {
+ $blogs = get_blogs_of_user( $val );
+ if( is_array( $blogs ) ) {
+ while( list( $key, $details ) = each( $blogs ) ) {
+ update_blog_status( $details->userblog_id, "spam", '1' );
+ do_action( "make_spam_blog", $details->userblog_id );
+ }
+ }
+ }
+ }
+ }
+ }
+ header( "Location: wpmu-users.php?updated=true" );
+ break;
+ default:
+ if( isset( $_GET[ 'start' ] ) == false ) {
+ $start = 0;
+ } else {
+ $start = intval( $_GET[ 'start' ] );
+ }
+ if( isset( $_GET[ 'num' ] ) == false ) {
+ $num = 30;
+ } else {
+ $num = intval( $_GET[ 'num' ] );
+ }
+
+ $query = "SELECT *
+ FROM ".$wpdb->users;
+ if( $_GET[ 's' ] != '' ) {
+ $search = '%' . addslashes( $_GET['s'] ) . '%';
+ $query .= " WHERE user_login LIKE '$search' OR user_email LIKE '$search'";
+ }
+ if( isset( $_GET[ 'sortby' ] ) == false ) {
+ $_GET[ 'sortby' ] = 'ID';
+ }
+ if( $_GET[ 'sortby' ] == 'Email' ) {
+ $query .= ' ORDER BY user_email ';
+ } elseif( $_GET[ 'sortby' ] == 'ID' ) {
+ $query .= ' ORDER BY ID ';
+ } elseif( $_GET[ 'sortby' ] == 'Login' ) {
+ $query .= ' ORDER BY user_login ';
+ } elseif( $_GET[ 'sortby' ] == 'Name' ) {
+ $query .= ' ORDER BY display_name ';
+ } elseif( $_GET[ 'sortby' ] == 'Registered' ) {
+ $query .= ' ORDER BY registered ';
+ }
+ if( $_GET[ 'order' ] == 'DESC' ) {
+ $query .= "DESC";
+ } else {
+ $query .= "ASC";
+ }
+ $query .= " LIMIT " . intval( $start ) . ", " . intval( $num );
+ $user_list = $wpdb->get_results( $query, ARRAY_A );
+ if( count( $user_list ) < $num ) {
+ $next = false;
+ } else {
+ $next = true;
+ }
+?>
+<h2>Users</h2>
+<form name="searchform" action="wpmu-users.php" method="get" style="float: left; width: 16em; margin-right: 3em;">
+ <table><td>
+ <fieldset>
+ <legend><?php _e('Search Users&hellip;') ?></legend>
+ <input type='hidden' name='action' value='users'>
+ <input type="text" name="s" value="<?php if (isset($_GET[ 's' ])) echo wp_specialchars($_GET[ 's' ], 1); ?>" size="17" />
+ <input type="submit" name="submit" value="<?php _e('Search') ?>" />
+ </fieldset>
+ <?php
+ if( isset($_GET[ 's' ]) && $_GET[ 's' ] != '' ) {
+ ?><a href="/wp-admin/wpmu-blogs.php?action=blogs&s=<?php echo wp_specialchars($_GET[ 's' ], 1) ?>">Search Blogs: <?php echo wp_specialchars($_GET[ 's' ], 1) ?></a><?php
+ }
+ ?>
+ </td><td>
+ <fieldset>
+ <legend><?php _e('User Navigation') ?></legend>
+ <?php
+
+ $url2 = "order=" . $_GET[ 'order' ] . "&sortby=" . $_GET[ 'sortby' ] . "&s=" .$_GET[ 's' ];
+
+ if( $start == 0 ) {
+ echo 'Previous&nbsp;Users';
+ } elseif( $start <= 30 ) {
+ echo '<a href="wpmu-users.php?start=0' . $url2 . '">Previous&nbsp;Users</a>';
+ } else {
+ echo '<a href="wpmu-users.php?start=' . ( $start - $num ) . '&' . $url2 . '">Previous&nbsp;Users</a>';
+ }
+ if ( $next ) {
+ echo '&nbsp;||&nbsp;<a href="wpmu-users.php?start=' . ( $start + $num ) . '&' . $url2 . '">Next&nbsp;Users</a>';
+ } else {
+ echo '&nbsp;||&nbsp;Next&nbsp;Users';
+ }
+ ?>
+ </fieldset>
+ </td></table>
+</form>
+
+<br style="clear:both;" />
+
+<?php
+
+// define the columns to display, the syntax is 'internal name' => 'display name'
+$posts_columns = array(
+ 'ID' => __('ID'),
+ 'user_login' => __('Login'),
+ 'user_email' => __('Email'),
+ 'display_name' => __('Name'),
+ 'user_registered' => __('Registered'),
+ 'blogs' => __('Blogs')
+);
+$posts_columns = apply_filters('manage_posts_columns', $posts_columns);
+
+// you can not edit these at the moment
+$posts_columns['control_edit'] = '';
+$posts_columns['control_delete'] = '';
+
+?>
+<script language="javascript">
+<!--
+var checkflag = "false";
+function check_all_rows() {
+ field = document.formlist;
+ if (checkflag == "false") {
+ for (i = 0; i < field.length; i++) {
+ if( field[i].name == 'allusers[]' )
+ field[i].checked = true;}
+ checkflag = "true";
+ return "Uncheck All";
+ } else {
+ for (i = 0; i < field.length; i++) {
+ if( field[i].name == 'allusers[]' )
+ field[i].checked = false; }
+ checkflag = "false";
+ return "Check All";
+ }
+}
+// -->
+</script>
+
+<form name='formlist' action='wpmu-users.php?action=allusers' method='POST'>
+<input type=button value="Check All" onClick="this.value=check_all_rows()">
+<table width="100%" cellpadding="3" cellspacing="3">
+ <tr>
+
+<?php foreach($posts_columns as $column_display_name) { ?>
+ <th scope="col"><?php if( $column_display_name == 'Blogs' ) { echo "Blogs"; } else { ?><a href="wpmu-users.php?sortby=<?php echo urlencode( $column_display_name ) ?>&<?php if( $_GET[ 'sortby' ] == $column_display_name ) { if( $_GET[ 'order' ] == 'DESC' ) { echo "order=ASC&" ; } else { echo "order=DESC&"; } } ?>start=<?php echo $start ?>"><?php echo $column_display_name; ?></a></th><?php } ?>
+<?php } ?>
+
+ </tr>
+<?php
+if ($user_list) {
+$bgcolor = '';
+foreach ($user_list as $user) {
+$class = ('alternate' == $class) ? '' : 'alternate';
+?>
+ <tr class='<?php echo $class; ?>'>
+
+<?php
+
+foreach($posts_columns as $column_name=>$column_display_name) {
+
+ switch($column_name) {
+
+ case 'ID':
+ ?>
+ <th scope="row"><input type='checkbox' id='<?php echo $user[ 'ID' ] ?>' name='allusers[]' value='<?php echo $user[ 'ID' ] ?>'> <label for='<?php echo $user[ 'ID' ] ?>'><?php echo $user[ 'ID' ] ?></label></th>
+ <?php
+ break;
+
+ case 'user_login':
+ ?>
+ <td><label for='<?php echo $user[ 'ID' ] ?>'><?php echo $user[ 'user_login' ] ?></label>
+ </td>
+ <?php
+ break;
+
+ case 'display_name':
+ ?>
+ <td><?php echo $user[ 'display_name' ] ?></td>
+ <?php
+ break;
+
+ case 'user_email':
+ ?>
+ <td><?php echo $user[ 'user_email' ] ?></td>
+ <?php
+ break;
+
+ case 'user_registered':
+ ?>
+ <td><?php echo $user[ 'user_registered' ] ?></td>
+ <?php
+ break;
+
+ case 'blogs':
+ $blogs = get_blogs_of_user( $user[ 'ID' ] );
+ ?>
+ <td><?php if( is_array( $blogs ) )
+ while( list( $key, $val ) = each( $blogs ) ) {
+ print '<a href="wpmu-blogs.php?action=editblog&id=' . $val->userblog_id . '">' . str_replace( '.' . $current_site->domain, '', $val->domain ) . '</a> (<a ';
+ if( get_blog_status( $val->userblog_id, 'spam' ) == 1 )
+ print 'style="background-color: #f66" ';
+ print 'target="_new" href="http://'.$val->domain . $val->path.'">View</a>)<BR>';
+ } ?></td>
+ <?php
+ break;
+
+ case 'control_edit':
+ ?>
+ <td><?php echo "<a href='user-edit.php?user_id=".$user[ 'ID' ]."' class='edit'>" . __('Edit') . "</a>"; ?></td>
+ <?php
+ break;
+
+ case 'control_delete':
+ ?>
+ <td><?php echo "<a href='wpmu-users.php?action=delete&amp;id=".$user[ 'ID' ]."&amp;redirect=".wpmu_admin_redirect_url()."' class='delete' onclick=\"return confirm('" . sprintf(__("You are about to delete this user?\\n \'OK\' to delete, \'Cancel\' to stop.") ) . "')\">" . __('Delete') . "</a>"; ?></td>
+ <?php
+ break;
+
+ default:
+ ?>
+ <td><?php do_action('manage_posts_custom_column', $column_name, $id); ?></td>
+ <?php
+ break;
+ }
+}
+?>
+ </tr>
+<?php
+}
+} else {
+?>
+ <tr style='background-color: <?php echo $bgcolor; ?>'>
+ <td colspan="8"><?php _e('No users found.') ?></td>
+ </tr>
+<?php
+} // end if ($users)
+?>
+</table>
+<p>Selected Users:<ul>
+<li><input type='radio' name='userfunction' id='delete' value='delete'> <label for='delete'>Delete</label></li>
+<li><input type='radio' name='userfunction' id='spam' value='spam'> <label for='spam'>Mark as Spammers</label></li>
+</ul>
+<input type='submit' value='Apply Changes'></p>
+</form>
+
+<?php
+}
+
+?>
+</div>
+<?php include('admin-footer.php'); ?>
diff --git a/wp-admin/xfn.js b/wp-admin/xfn.js
new file mode 100644
index 0000000..3cdf608
--- /dev/null
+++ b/wp-admin/xfn.js
@@ -0,0 +1,46 @@
+function GetElementsWithClassName(elementName, className) {
+ var allElements = document.getElementsByTagName(elementName);
+ var elemColl = new Array();
+ for (i = 0; i < allElements.length; i++) {
+ if (allElements[i].className == className) {
+ elemColl[elemColl.length] = allElements[i];
+ }
+ }
+ return elemColl;
+}
+
+function meChecked() {
+ var undefined;
+ var eMe = document.getElementById('me');
+ if (eMe == undefined) return false;
+ else return eMe.checked;
+}
+
+function upit() {
+ var isMe = meChecked(); //document.getElementById('me').checked;
+ var inputColl = GetElementsWithClassName('input', 'valinp');
+ var results = document.getElementById('link_rel');
+ var linkText, linkUrl, inputs = '';
+ for (i = 0; i < inputColl.length; i++) {
+ inputColl[i].disabled = isMe;
+ inputColl[i].parentNode.className = isMe ? 'disabled' : '';
+ if (!isMe && inputColl[i].checked && inputColl[i].value != '') {
+ inputs += inputColl[i].value + ' ';
+ }
+ }
+ inputs = inputs.substr(0,inputs.length - 1);
+ if (isMe) inputs='me';
+ results.value = inputs;
+ }
+
+function blurry() {
+ if (!document.getElementById) return;
+
+ var aInputs = document.getElementsByTagName('input');
+
+ for (var i = 0; i < aInputs.length; i++) {
+ aInputs[i].onclick = aInputs[i].onkeyup = upit;
+ }
+}
+
+addLoadEvent(blurry);