diff -uNr a/blog/images/README b/blog/images/README --- a/blog/images/README false +++ b/blog/images/README 86525f2c7086039d79e5bf92869d02934a44716812433ca3a90e18a8d03745785c5ca54fe8c39e681b3b13c00c33a5128884a28c8cbaccbc65d0b401d901ec2e @@ -0,0 +1 @@ +Placeholder. diff -uNr a/blog/index.php b/blog/index.php --- a/blog/index.php false +++ b/blog/index.php e5b5edf69994f12a73a8768536caa0fa3ed177ee419859f8256832265b683807876c8b74048750df8e5d6a991a9c3e14c68515dcacf40f590f9d3625d9c16e09 @@ -0,0 +1,18 @@ + \ No newline at end of file diff -uNr a/blog/pingback-updater.php b/blog/pingback-updater.php --- a/blog/pingback-updater.php false +++ b/blog/pingback-updater.php 9aeb4a7aa4d3ca13272e96ebac21f2368c3d04783340dfdd829ee7231f99c78f63821cb634814a562823093e8a6d7a7368ecb71e5b38ee87351e71a8a527c4b9 @@ -0,0 +1,48 @@ + '.$last_run; +$record = mysql_query($query); + +while ( $row = mysql_fetch_array($record, MYSQL_NUM)) { + $post_url = "http://trilema.com/".$row[0]."/".$row[1]; + // echo "

",$post_url,"

"; + +$dom = new DOMDocument(); +@$dom->loadHTML($row[2]); + +$xpath = new DOMXPath($dom); +$hrefs = $xpath->evaluate("/html/body//a"); + +for ($i = 0; $i < $hrefs->length; $i++) { + $href = $hrefs->item($i); + $url = $href->getAttribute('href'); + + $parse = parse_url($url); + echo 'curl -A "Mozilla/5.0" -r 0-4096 --connect-timeout 30 --max-time 10 "http://'; + echo $parse['host']; + echo '/xmlrpc.php" --header "Content-Type: text/xml" --data "pingback.ping'; + echo $post_url; + echo ''; + echo $url; + echo '"'."\n"; +} + +} + +?> diff -uNr a/blog/README b/blog/README --- a/blog/README false +++ b/blog/README 6725ffa1358d871f5d9d277f6b1e20449d3cb32258392ddb93f0bfbb64135097017d0379ccfcbfdd1fb9e2d378a161097425d5dd3a058484f397f912cb5bcf07 @@ -0,0 +1,94 @@ +================================== +This is MP-WP as found on TMSR log +================================== + +This is MP-WP as I found it on the TMSR logs, plus the additions and substractions as described in this file. + +Original was mentioned here: http://btcbase.org/log/2017-04-05#1638261 + +--------- +Additions +--------- + +Not included were plugin files, which I found here: http://btcbase.org/log/2016-09-15#1542658 +Unpacking the tar file in wp-content/plugins, created these files: + +wp-content/plugins/wp-footnotes/ +wp-content/plugins/wp-footnotes/COPYING +wp-content/plugins/wp-footnotes/footnotes.php +wp-content/plugins/wp-footnotes/readme.txt +wp-content/plugins/wp-footnotes/options.php +wp-content/plugins/get-recent-comments.php + +These files I had to add to create directories with a vpatch: + +images/README - placeholder to create directory +wp-admin/images/README - placeholder to create directory +wp-includes/js/tinymce/themes/advanced/img/README - placeholder to create directory +wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/README - placeholder to create directory +wp-includes/js/tinymce/themes/advanced/skins/o2k7/img/README - placeholder to create directory +wp-includes/js/tinymce/themes/advanced/skins/default/img/README - placeholder to create directory +wp-includes/js/tinymce/plugins/media/img/README - placeholder to create directory +wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/README - placeholder to create directory +wp-includes/js/tinymce/plugins/spellchecker/img/README - placeholder to create directory +wp-includes/js/tinymce/plugins/wordpress/img/README - placeholder to create directory +wp-includes/js/tinymce/plugins/wpgallery/img/README - placeholder to create directory +wp-includes/js/tinymce/plugins/wpeditimage/img/README - placeholder to create directory + +This file: + +README - description of the work done + +A file with the sha512sum of the tarfiles containing the removed images: + +tarfiles.sha512sum + +------------ +Subtractions +------------ + +wp-patch2.diff - this patch was already applied +wp-content.zip - this file contained an older version of the wp-content directory +__MACOSX - some apple directory, removed with all contents +images/bit.gif - a bitcoin image, not referenced +images/'image..' - same bitcoin image +wp-comments-post.php.orig - leftover from patch application +wp-config.php.orig - leftover from patch application +wp-comments-post.php.rej - leftover from patch application + +favicon.ico - binary, with trilema logo, provide your own in production +default_avatar.png - binary, 32x32 png image, provide your own + +wp-admin/images/* - binaries, put in tarfile, referenced in binaries by sha512sum +wp-includes/images/*/* - all files and directories in the images directory +wp-includes/js/tinymce/*/* - all binaries in tinymce directory, put in tarfile +wp-includes/*/* - misc binaries, put in tarfile +wp-content/themes/default/images/* - binaries, put in tarfile +wp-content/themes/*/screenshot.png - binaries, put in tarfile +wp-content/plugins/akismet/akismet.gif - akismet logo, put in tarfile + +-------- +Binaries +-------- +A vdiff cannot contain binaries, these are distributed separately and mentioned here with sha512sum. + +a tarfile with wp-admin/images/* content: +16964bb6eab4a0ec64f368f8c8f1eddcf8d493444b82d34ad0063398a5e63840b029f72d330954473d5c30d8c27b45ade4da510dec619a9ebfd21ab236958aa8 wp-admin-images.tar.gz +a tarfile with wp-content/themes/default/images/*.jpg content: +d20800441db90ec52adf505f86c6dae9c706555b2a459b0b7408421002c2b2ef8ad6b97973957384eea5265f6d5fa4b05990f4b9cdecade466cfac35e16da71e wp-content-themes-images.tar.gz +a tarfile with wp-includes/images/*/* content: +4d6f2ce95ae8b5002dc70039ce3d89ea5e6d77ead66777e9a8fb6a7bb5ec14e9a0de1f596197d94aabef3bf412682003583d648d79f9892de85ff018395b8037 wp-includes-images.tar.gz +a tarfile with binaries from wp-includes/js/tinymce/*/* : +9d947e5588185580db1f3eaab76337baa6d516b0fa53af138c5dc40f0e6d4339c68482cc5765368d5f67731d4be5bfa045ff5fd3d70017592c3ae69864166e09 wp-includes-tinymce.tar.gz +a tarfile with wp-content/*/screenshot.png: +d57e90e06c458091e229d4e60682b4c8cdde9693fbcc18932c39a8ab737b3b1c2431404394d28c4cfe1f7db184e530c33d86a0cc7846d665e76aeba04f0a6597 wp-content-screenshots.tar.gz +a tarfile with wp-includes/* misc images: +596da0c27e3ea6947e9cb900db04f911e53fa6e8325616ddcb2a758256859bdc4ef5ff6f0bb2e79095968d4d18e1189d441dc08e61477835f259dd0dcdf02f74 wp-includes-misc.tar.gz +a tarfile with akismet gif file: +f078ee4e85a79a1fe5d212fa7dce47be11ef65a02dda0ecccc3dc4fdfaaa7135db18eacd175d0d79ab884ebeb8c87028b44df3d033780f0d0d67cbc2e53ed8e2 wp-content-akismet.tgz + + + + + + diff -uNr a/blog/robots.txt b/blog/robots.txt --- a/blog/robots.txt false +++ b/blog/robots.txt 8f374b6d2c704b3a4fcd5dbb439627cc5b851becc55a0f0cb59fe116a49bb3717c8dc45e9a042f336ef976972ac0ecf178a1b3fd44e16e1e1ee5cb7178cb5dd3 @@ -0,0 +1,2 @@ +User-agent: ia_archiver +Disallow: / \ No newline at end of file diff -uNr a/blog/tarfiles.sha512sum b/blog/tarfiles.sha512sum --- a/blog/tarfiles.sha512sum false +++ b/blog/tarfiles.sha512sum 3687532dc5e613602c83e003ee23348ad1435ed1724ba47f4a2d389658c10b383b6226ec79b352e86992e318efca4f0fea442283783e8716cabfe6deeca87e54 @@ -0,0 +1,7 @@ +16964bb6eab4a0ec64f368f8c8f1eddcf8d493444b82d34ad0063398a5e63840b029f72d330954473d5c30d8c27b45ade4da510dec619a9ebfd21ab236958aa8 wp-admin-images.tar.gz +f078ee4e85a79a1fe5d212fa7dce47be11ef65a02dda0ecccc3dc4fdfaaa7135db18eacd175d0d79ab884ebeb8c87028b44df3d033780f0d0d67cbc2e53ed8e2 wp-content-akismet.tar.gz +d57e90e06c458091e229d4e60682b4c8cdde9693fbcc18932c39a8ab737b3b1c2431404394d28c4cfe1f7db184e530c33d86a0cc7846d665e76aeba04f0a6597 wp-content-screenshots.tar.gz +d20800441db90ec52adf505f86c6dae9c706555b2a459b0b7408421002c2b2ef8ad6b97973957384eea5265f6d5fa4b05990f4b9cdecade466cfac35e16da71e wp-content-themes-images.tar.gz +4d6f2ce95ae8b5002dc70039ce3d89ea5e6d77ead66777e9a8fb6a7bb5ec14e9a0de1f596197d94aabef3bf412682003583d648d79f9892de85ff018395b8037 wp-includes-images.tar.gz +596da0c27e3ea6947e9cb900db04f911e53fa6e8325616ddcb2a758256859bdc4ef5ff6f0bb2e79095968d4d18e1189d441dc08e61477835f259dd0dcdf02f74 wp-includes-misc.tar.gz +9d947e5588185580db1f3eaab76337baa6d516b0fa53af138c5dc40f0e6d4339c68482cc5765368d5f67731d4be5bfa045ff5fd3d70017592c3ae69864166e09 wp-includes-tinymce.tar.gz diff -uNr a/blog/wp-admin/admin-ajax.php b/blog/wp-admin/admin-ajax.php --- a/blog/wp-admin/admin-ajax.php false +++ b/blog/wp-admin/admin-ajax.php fe5dd0469a65cbde89a373f64432ab599fefba4279fb811fa971a05de8f38021a5536e48428f5f45fa52e10ab57f18c4c4f6cd46473aca0042386e911b48928a @@ -0,0 +1,1044 @@ +ALERT: You are logged out! Could not save draft. Please log in again.'), wp_login_url() ); + $x = new WP_Ajax_Response( array( + 'what' => 'autosave', + 'id' => $id, + 'data' => $message + ) ); + $x->send(); + } + + die('-1'); +} + +if ( isset( $_GET['action'] ) ) : +switch ( $action = $_GET['action'] ) : +case 'ajax-tag-search' : + if ( !current_user_can( 'manage_categories' ) ) + die('-1'); + + $s = $_GET['q']; // is this slashed already? + + if ( false !== strpos( $s, ',' ) ) { + $s = explode( ',', $s ); + $s = $s[count( $s ) - 1]; + } + $s = trim( $s ); + if ( strlen( $s ) < 2 ) + die; // require 2 chars for matching + $results = $wpdb->get_col( "SELECT t.name FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = 'post_tag' AND t.name LIKE ('%". $s . "%')" ); + echo join( $results, "\n" ); + die; + break; +default : + do_action( 'wp_ajax_' . $_GET['action'] ); + die('0'); + break; +endswitch; +endif; + +$id = isset($_POST['id'])? (int) $_POST['id'] : 0; +switch ( $action = $_POST['action'] ) : +case 'delete-comment' : + check_ajax_referer( "delete-comment_$id" ); + if ( !$comment = get_comment( $id ) ) + die('1'); + if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) + die('-1'); + + if ( isset($_POST['spam']) && 1 == $_POST['spam'] ) { + if ( 'spam' == wp_get_comment_status( $comment->comment_ID ) ) + die('1'); + $r = wp_set_comment_status( $comment->comment_ID, 'spam' ); + } else { + $r = wp_delete_comment( $comment->comment_ID ); + } + + die( $r ? '1' : '0' ); + break; +case 'delete-cat' : + check_ajax_referer( "delete-category_$id" ); + if ( !current_user_can( 'manage_categories' ) ) + die('-1'); + + $cat = get_category( $id ); + if ( !$cat || is_wp_error( $cat ) ) + die('1'); + + if ( wp_delete_category( $id ) ) + die('1'); + else + die('0'); + break; +case 'delete-tag' : + check_ajax_referer( "delete-tag_$id" ); + if ( !current_user_can( 'manage_categories' ) ) + die('-1'); + + $tag = get_term( $id, 'post_tag' ); + if ( !$tag || is_wp_error( $tag ) ) + die('1'); + + if ( wp_delete_term($id, 'post_tag')) + die('1'); + else + die('0'); + break; +case 'delete-link-cat' : + check_ajax_referer( "delete-link-category_$id" ); + if ( !current_user_can( 'manage_categories' ) ) + die('-1'); + + $cat = get_term( $id, 'link_category' ); + if ( !$cat || is_wp_error( $cat ) ) + die('1'); + + $cat_name = get_term_field('name', $id, 'link_category'); + + // Don't delete the default cats. + if ( $id == get_option('default_link_category') ) { + $x = new WP_AJAX_Response( array( + 'what' => 'link-cat', + 'id' => $id, + 'data' => new WP_Error( 'default-link-cat', sprintf(__("Can’t delete the %s category: this is the default one"), $cat_name) ) + ) ); + $x->send(); + } + + $r = wp_delete_term($id, 'link_category'); + if ( !$r ) + die('0'); + if ( is_wp_error($r) ) { + $x = new WP_AJAX_Response( array( + 'what' => 'link-cat', + 'id' => $id, + 'data' => $r + ) ); + $x->send(); + } + die('1'); + break; +case 'delete-link' : + check_ajax_referer( "delete-bookmark_$id" ); + if ( !current_user_can( 'manage_links' ) ) + die('-1'); + + $link = get_bookmark( $id ); + if ( !$link || is_wp_error( $link ) ) + die('1'); + + if ( wp_delete_link( $id ) ) + die('1'); + else + die('0'); + break; +case 'delete-meta' : + check_ajax_referer( "delete-meta_$id" ); + if ( !$meta = get_post_meta_by_id( $id ) ) + die('1'); + + 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' : + check_ajax_referer( "{$action}_$id" ); + if ( !current_user_can( 'delete_post', $id ) ) + die('-1'); + + if ( !get_post( $id ) ) + die('1'); + + if ( wp_delete_post( $id ) ) + die('1'); + else + die('0'); + break; +case 'delete-page' : + check_ajax_referer( "{$action}_$id" ); + if ( !current_user_can( 'delete_page', $id ) ) + die('-1'); + + if ( !get_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'); + + $current = wp_get_comment_status( $comment->comment_ID ); + if ( $_POST['new'] == $current ) + die('1'); + + if ( in_array( $current, array( 'unapproved', 'spam' ) ) ) { + check_ajax_referer( "approve-comment_$id" ); + if ( wp_set_comment_status( $comment->comment_ID, 'approve' ) ) + die('1'); + } else { + check_ajax_referer( "unapprove-comment_$id" ); + if ( wp_set_comment_status( $comment->comment_ID, 'hold' ) ) + die('1'); + } + die('0'); + break; +case 'add-category' : // On the Fly + check_ajax_referer( $action ); + if ( !current_user_can( 'manage_categories' ) ) + die('-1'); + $names = explode(',', $_POST['newcat']); + if ( 0 > $parent = (int) $_POST['newcat_parent'] ) + $parent = 0; + $post_category = isset($_POST['post_category'])? (array) $_POST['post_category'] : array(); + $checked_categories = array_map( 'absint', (array) $post_category ); + $popular_ids = isset( $_POST['popular_ids'] ) ? + array_map( 'absint', explode( ',', $_POST['popular_ids'] ) ) : + false; + + $x = new WP_Ajax_Response(); + foreach ( $names as $cat_name ) { + $cat_name = trim($cat_name); + $category_nicename = sanitize_title($cat_name); + if ( '' === $category_nicename ) + continue; + $cat_id = wp_create_category( $cat_name, $parent ); + $checked_categories[] = $cat_id; + if ( $parent ) // Do these all at once in a second + continue; + $category = get_category( $cat_id ); + ob_start(); + wp_category_checklist( 0, $cat_id, $checked_categories, $popular_ids ); + $data = ob_get_contents(); + ob_end_clean(); + $x->add( array( + 'what' => 'category', + 'id' => $cat_id, + 'data' => $data, + 'position' => -1 + ) ); + } + if ( $parent ) { // Foncy - replace the parent and all its children + $parent = get_category( $parent ); + ob_start(); + dropdown_categories( 0, $parent ); + $data = ob_get_contents(); + ob_end_clean(); + $x->add( array( + 'what' => 'category', + 'id' => $parent->term_id, + 'old_id' => $parent->term_id, + 'data' => $data, + 'position' => -1 + ) ); + + } + $x->send(); + break; +case 'add-link-category' : // On the Fly + check_ajax_referer( $action ); + if ( !current_user_can( 'manage_categories' ) ) + die('-1'); + $names = explode(',', $_POST['newcat']); + $x = new WP_Ajax_Response(); + foreach ( $names as $cat_name ) { + $cat_name = trim($cat_name); + $slug = sanitize_title($cat_name); + if ( '' === $slug ) + continue; + if ( !$cat_id = is_term( $cat_name, 'link_category' ) ) { + $cat_id = wp_insert_term( $cat_name, 'link_category' ); + } + $cat_id = $cat_id['term_id']; + $cat_name = wp_specialchars(stripslashes($cat_name)); + $x->add( array( + 'what' => 'link-category', + 'id' => $cat_id, + 'data' => "", + 'position' => -1 + ) ); + } + $x->send(); + break; +case 'add-cat' : // From Manage->Categories + check_ajax_referer( 'add-category' ); + if ( !current_user_can( 'manage_categories' ) ) + die('-1'); + + if ( '' === trim($_POST['cat_name']) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'cat', + 'id' => new WP_Error( 'cat_name', __('You did not enter a category name.') ) + ) ); + $x->send(); + } + + if ( category_exists( trim( $_POST['cat_name'] ) ) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'cat', + 'id' => new WP_Error( 'cat_exists', __('The category you are trying to create already exists.'), array( 'form-field' => 'cat_name' ) ), + ) ); + $x->send(); + } + + $cat = wp_insert_category( $_POST, true ); + + if ( is_wp_error($cat) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'cat', + 'id' => $cat + ) ); + $x->send(); + } + + if ( !$cat || (!$cat = get_category( $cat )) ) + die('0'); + + $level = 0; + $cat_full_name = $cat->name; + $_cat = $cat; + while ( $_cat->parent ) { + $_cat = get_category( $_cat->parent ); + $cat_full_name = $_cat->name . ' — ' . $cat_full_name; + $level++; + } + $cat_full_name = attribute_escape($cat_full_name); + + $x = new WP_Ajax_Response( array( + 'what' => 'cat', + 'id' => $cat->term_id, + 'position' => -1, + 'data' => _cat_row( $cat, $level, $cat_full_name ), + 'supplemental' => array('name' => $cat_full_name, 'show-link' => sprintf(__( 'Category %s added' ), "cat-$cat->term_id", $cat_full_name)) + ) ); + $x->send(); + break; +case 'add-link-cat' : // From Blogroll -> Categories + check_ajax_referer( 'add-link-category' ); + if ( !current_user_can( 'manage_categories' ) ) + die('-1'); + + if ( '' === trim($_POST['name']) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'link-cat', + 'id' => new WP_Error( 'name', __('You did not enter a category name.') ) + ) ); + $x->send(); + } + + $r = wp_insert_term($_POST['name'], 'link_category', $_POST ); + if ( is_wp_error( $r ) ) { + $x = new WP_AJAX_Response( array( + 'what' => 'link-cat', + 'id' => $r + ) ); + $x->send(); + } + + extract($r, EXTR_SKIP); + + if ( !$link_cat = link_cat_row( $term_id ) ) + die('0'); + + $x = new WP_Ajax_Response( array( + 'what' => 'link-cat', + 'id' => $term_id, + 'position' => -1, + 'data' => $link_cat + ) ); + $x->send(); + break; +case 'add-tag' : // From Manage->Tags + check_ajax_referer( 'add-tag' ); + if ( !current_user_can( 'manage_categories' ) ) + die('-1'); + + if ( '' === trim($_POST['name']) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'tag', + 'id' => new WP_Error( 'name', __('You did not enter a tag name.') ) + ) ); + $x->send(); + } + + $tag = wp_insert_term($_POST['name'], 'post_tag', $_POST ); + + if ( is_wp_error($tag) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'tag', + 'id' => $tag + ) ); + $x->send(); + } + + if ( !$tag || (!$tag = get_term( $tag['term_id'], 'post_tag' )) ) + die('0'); + + $tag_full_name = $tag->name; + $tag_full_name = attribute_escape($tag_full_name); + + $x = new WP_Ajax_Response( array( + 'what' => 'tag', + 'id' => $tag->term_id, + 'position' => '-1', + 'data' => _tag_row( $tag ), + 'supplemental' => array('name' => $tag_full_name, 'show-link' => sprintf(__( 'Tag %s added' ), "tag-$tag->term_id", $tag_full_name)) + ) ); + $x->send(); + break; +case 'get-tagcloud' : + if ( !current_user_can( 'manage_categories' ) ) + die('-1'); + + $tags = get_tags( array( 'number' => 45, 'orderby' => 'count', 'order' => 'DESC' ) ); + + if ( empty( $tags ) ) + die( __('No tags found!') ); + + foreach ( $tags as $key => $tag ) { + $tags[ $key ]->link = '#'; + $tags[ $key ]->id = $tag->term_id; + } + + $return = wp_generate_tag_cloud( $tags ); + + if ( empty($return) ) + die('0'); + + echo $return; + + exit; + break; +case 'add-comment' : + check_ajax_referer( $action ); + if ( !current_user_can( 'edit_post', $id ) ) + die('-1'); + $search = isset($_POST['s']) ? $_POST['s'] : false; + $start = isset($_POST['page']) ? intval($_POST['page']) * 25 - 1: 24; + $status = isset($_POST['comment_status']) ? $_POST['comment_status'] : false; + $mode = isset($_POST['mode']) ? $_POST['mode'] : 'detail'; + $p = isset($_POST['p']) ? $_POST['p'] : 0; + $comment_type = isset($_POST['comment_type']) ? $_POST['comment_type'] : ''; + list($comments, $total) = _wp_get_comment_list( $status, $search, $start, 1, $p, $comment_type ); + + if ( get_option('show_avatars') ) + add_filter( 'comment_author', 'floated_admin_avatar' ); + + if ( !$comments ) + die('1'); + $x = new WP_Ajax_Response(); + foreach ( (array) $comments as $comment ) { + get_comment( $comment ); + ob_start(); + _wp_comment_row( $comment->comment_ID, $mode, $status, true, true ); + $comment_list_item = ob_get_contents(); + ob_end_clean(); + $x->add( array( + 'what' => 'comment', + 'id' => $comment->comment_ID, + 'data' => $comment_list_item + ) ); + } + $x->send(); + break; +case 'get-comments' : + check_ajax_referer( $action ); + + $post_ID = (int) $_POST['post_ID']; + if ( !current_user_can( 'edit_post', $post_ID ) ) + die('-1'); + + $start = isset($_POST['start']) ? intval($_POST['start']) : 0; + $num = isset($_POST['num']) ? intval($_POST['num']) : 10; + + list($comments, $total) = _wp_get_comment_list( false, false, $start, $num, $post_ID ); + + if ( !$comments ) + die('1'); + + $comment_list_item = ''; + $x = new WP_Ajax_Response(); + foreach ( (array) $comments as $comment ) { + get_comment( $comment ); + ob_start(); + _wp_comment_row( $comment->comment_ID, 'single', false, false ); + $comment_list_item .= ob_get_contents(); + ob_end_clean(); + } + $x->add( array( + 'what' => 'comments', + 'data' => $comment_list_item + ) ); + $x->send(); + break; +case 'replyto-comment' : + check_ajax_referer( $action ); + + $comment_post_ID = (int) $_POST['comment_post_ID']; + if ( !current_user_can( 'edit_post', $comment_post_ID ) ) + die('-1'); + + $status = $wpdb->get_var( $wpdb->prepare("SELECT post_status FROM $wpdb->posts WHERE ID = %d", $comment_post_ID) ); + + if ( empty($status) ) + die('1'); + elseif ( in_array($status, array('draft', 'pending') ) ) + die( __('Error: you are replying to a comment on a draft post.') ); + + $user = wp_get_current_user(); + if ( $user->ID ) { + $comment_author = $wpdb->escape($user->display_name); + $comment_author_email = $wpdb->escape($user->user_email); + $comment_author_url = $wpdb->escape($user->user_url); + $comment_content = trim($_POST['content']); + if ( current_user_can('unfiltered_html') ) { + if ( wp_create_nonce('unfiltered-html-comment_' . $comment_post_ID) != $_POST['_wp_unfiltered_html_comment'] ) { + kses_remove_filters(); // start with a clean slate + kses_init_filters(); // set up the filters + } + } + } else { + die( __('Sorry, you must be logged in to reply to a comment.') ); + } + + if ( '' == $comment_content ) + die( __('Error: please type a comment.') ); + + $comment_parent = absint($_POST['comment_ID']); + $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID'); + + $comment_id = wp_new_comment( $commentdata ); + $comment = get_comment($comment_id); + if ( ! $comment ) die('1'); + + $modes = array( 'single', 'detail', 'dashboard' ); + $mode = isset($_POST['mode']) && in_array( $_POST['mode'], $modes ) ? $_POST['mode'] : 'detail'; + $position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1'; + $checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0; + + if ( get_option('show_avatars') && 'single' != $mode ) + add_filter( 'comment_author', 'floated_admin_avatar' ); + + $x = new WP_Ajax_Response(); + + ob_start(); + if ( 'dashboard' == $mode ) { + require_once( ABSPATH . 'wp-admin/includes/dashboard.php' ); + _wp_dashboard_recent_comments_row( $comment, false ); + } else { + _wp_comment_row( $comment->comment_ID, $mode, false, $checkbox ); + } + $comment_list_item = ob_get_contents(); + ob_end_clean(); + + $x->add( array( + 'what' => 'comment', + 'id' => $comment->comment_ID, + 'data' => $comment_list_item, + 'position' => $position + )); + + $x->send(); + break; +case 'edit-comment' : + check_ajax_referer( 'replyto-comment' ); + + $comment_post_ID = (int) $_POST['comment_post_ID']; + if ( ! current_user_can( 'edit_post', $comment_post_ID ) ) + die('-1'); + + if ( '' == $_POST['content'] ) + die( __('Error: please type a comment.') ); + + $comment_id = (int) $_POST['comment_ID']; + $_POST['comment_status'] = $_POST['status']; + edit_comment(); + + $mode = ( isset($_POST['mode']) && 'single' == $_POST['mode'] ) ? 'single' : 'detail'; + $position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1'; + $checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0; + + if ( get_option('show_avatars') && 'single' != $mode ) + add_filter( 'comment_author', 'floated_admin_avatar' ); + + $x = new WP_Ajax_Response(); + + ob_start(); + _wp_comment_row( $comment_id, $mode, true, $checkbox ); + $comment_list_item = ob_get_contents(); + ob_end_clean(); + + $x->add( array( + 'what' => 'edit_comment', + 'id' => $comment->comment_ID, + 'data' => $comment_list_item, + 'position' => $position + )); + + $x->send(); + break; +case 'add-meta' : + check_ajax_referer( 'add-meta' ); + $c = 0; + $pid = (int) $_POST['post_id']; + if ( isset($_POST['metakeyselect']) || isset($_POST['metakeyinput']) ) { + if ( !current_user_can( 'edit_post', $pid ) ) + die('-1'); + if ( '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput']) ) + die('1'); + if ( $pid < 0 ) { + $now = current_time('timestamp', 1); + if ( $pid = wp_insert_post( array( + 'post_title' => sprintf('Draft created on %s at %s', date(get_option('date_format'), $now), date(get_option('time_format'), $now)) + ) ) ) { + if ( is_wp_error( $pid ) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'meta', + 'data' => $pid + ) ); + $x->send(); + } + $mid = add_meta( $pid ); + } else { + die('0'); + } + } else if ( !$mid = add_meta( $pid ) ) { + die('0'); + } + + $meta = get_post_meta_by_id( $mid ); + $pid = (int) $meta->post_id; + $meta = get_object_vars( $meta ); + $x = new WP_Ajax_Response( array( + 'what' => 'meta', + 'id' => $mid, + 'data' => _list_meta_row( $meta, $c ), + 'position' => 1, + 'supplemental' => array('postid' => $pid) + ) ); + } else { + $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 meta doesn't exist + if ( !current_user_can( 'edit_post', $meta->post_id ) ) + die('-1'); + if ( !$u = update_meta( $mid, $key, $value ) ) + die('1'); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems). + $key = stripslashes($key); + $value = stripslashes($value); + $x = new WP_Ajax_Response( array( + 'what' => 'meta', + 'id' => $mid, 'old_id' => $mid, + 'data' => _list_meta_row( array( + 'meta_key' => $key, + 'meta_value' => $value, + 'meta_id' => $mid + ), $c ), + 'position' => 0, + 'supplemental' => array('postid' => $meta->post_id) + ) ); + } + $x->send(); + break; +case 'add-user' : + check_ajax_referer( $action ); + if ( !current_user_can('create_users') ) + die('-1'); + require_once(ABSPATH . WPINC . '/registration.php'); + if ( !$user_id = add_user() ) + die('0'); + elseif ( is_wp_error( $user_id ) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'user', + 'id' => $user_id + ) ); + $x->send(); + } + $user_object = new WP_User( $user_id ); + + $x = new WP_Ajax_Response( array( + 'what' => 'user', + 'id' => $user_id, + 'data' => user_row( $user_object, '', $user_object->roles[0] ), + 'supplemental' => array( + 'show-link' => sprintf(__( 'User %s added' ), "user-$user_id", $user_object->user_login), + 'role' => $user_object->roles[0] + ) + ) ); + $x->send(); + break; +case 'autosave' : // The name of this action is hardcoded in edit_post() + define( 'DOING_AUTOSAVE', true ); + + $nonce_age = check_ajax_referer( 'autosave', 'autosavenonce' ); + global $current_user; + + $_POST['post_category'] = explode(",", $_POST['catslist']); + $_POST['tags_input'] = explode(",", $_POST['tags_input']); + if($_POST['post_type'] == 'page' || empty($_POST['post_category'])) + unset($_POST['post_category']); + + $do_autosave = (bool) $_POST['autosave']; + $do_lock = true; + + $data = ''; + $message = sprintf( __('Draft Saved at %s.'), date( __('g:i:s a'), current_time( 'timestamp', true ) ) ); + + $supplemental = array(); + + $id = $revision_id = 0; + if($_POST['post_ID'] < 0) { + $_POST['post_status'] = 'draft'; + $_POST['temp_ID'] = $_POST['post_ID']; + if ( $do_autosave ) { + $id = wp_write_post(); + $data = $message; + } + } else { + $post_ID = (int) $_POST['post_ID']; + $_POST['ID'] = $post_ID; + $post = get_post($post_ID); + + if ( $last = wp_check_post_lock( $post->ID ) ) { + $do_autosave = $do_lock = false; + + $last_user = get_userdata( $last ); + $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' ); + $data = new WP_Error( 'locked', sprintf( + $_POST['post_type'] == 'page' ? __( 'Autosave disabled: %s is currently editing this page.' ) : __( 'Autosave disabled: %s is currently editing this post.' ), + wp_specialchars( $last_user_name ) + ) ); + + $supplemental['disable_autosave'] = 'disable'; + } + + 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.')); + } + + if ( $do_autosave ) { + // Drafts are just overwritten by autosave + if ( 'draft' == $post->post_status ) { + $id = edit_post(); + } else { // Non drafts are not overwritten. The autosave is stored in a special post revision. + $revision_id = wp_create_post_autosave( $post->ID ); + if ( is_wp_error($revision_id) ) + $id = $revision_id; + else + $id = $post->ID; + } + $data = $message; + } else { + $id = $post->ID; + } + } + + if ( $do_lock && $id && is_numeric($id) ) + wp_set_post_lock( $id ); + + if ( $nonce_age == 2 ) { + $supplemental['replace-autosavenonce'] = wp_create_nonce('autosave'); + $supplemental['replace-getpermalinknonce'] = wp_create_nonce('getpermalink'); + $supplemental['replace-samplepermalinknonce'] = wp_create_nonce('samplepermalink'); + $supplemental['replace-closedpostboxesnonce'] = wp_create_nonce('closedpostboxes'); + if ( $id ) { + if ( $_POST['post_type'] == 'post' ) + $supplemental['replace-_wpnonce'] = wp_create_nonce('update-post_' . $id); + elseif ( $_POST['post_type'] == 'page' ) + $supplemental['replace-_wpnonce'] = wp_create_nonce('update-page_' . $id); + } + } + + $x = new WP_Ajax_Response( array( + 'what' => 'autosave', + 'id' => $id, + 'data' => $id ? $data : '', + 'supplemental' => $supplemental + ) ); + $x->send(); + break; +case 'autosave-generate-nonces' : + check_ajax_referer( 'autosave', 'autosavenonce' ); + $ID = (int) $_POST['post_ID']; + if($_POST['post_type'] == 'post') { + if(current_user_can('edit_post', $ID)) + die(wp_create_nonce('update-post_' . $ID)); + } + if($_POST['post_type'] == 'page') { + if(current_user_can('edit_page', $ID)) { + die(wp_create_nonce('update-page_' . $ID)); + } + } + die('0'); +break; +case 'closed-postboxes' : + check_ajax_referer( 'closedpostboxes', 'closedpostboxesnonce' ); + $closed = isset( $_POST['closed'] )? $_POST['closed'] : ''; + $closed = explode( ',', $_POST['closed'] ); + $hidden = isset( $_POST['hidden'] )? $_POST['hidden'] : ''; + $hidden = explode( ',', $_POST['hidden'] ); + $page = isset( $_POST['page'] )? $_POST['page'] : ''; + if ( !preg_match( '/^[a-z-_]+$/', $page ) ) { + die(-1); + } + $current_user = wp_get_current_user(); + if ( is_array($closed) ) + update_usermeta($current_user->ID, 'closedpostboxes_'.$page, $closed); + if ( is_array($hidden) ) + update_usermeta($current_user->ID, 'meta-box-hidden_'.$page, $hidden); +break; +case 'hidden-columns' : + check_ajax_referer( 'hiddencolumns', 'hiddencolumnsnonce' ); + $hidden = isset( $_POST['hidden'] )? $_POST['hidden'] : ''; + $hidden = explode( ',', $_POST['hidden'] ); + $page = isset( $_POST['page'] )? $_POST['page'] : ''; + if ( !preg_match( '/^[a-z-_]+$/', $page ) ) { + die(-1); + } + $current_user = wp_get_current_user(); + if ( is_array($hidden) ) + update_usermeta($current_user->ID, "manage-$page-columns-hidden", $hidden); +break; +case 'get-permalink': + check_ajax_referer( 'getpermalink', 'getpermalinknonce' ); + $post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0; + die(add_query_arg(array('preview' => 'true'), get_permalink($post_id))); +break; +case 'sample-permalink': + check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' ); + $post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0; + $title = isset($_POST['new_title'])? $_POST['new_title'] : ''; + $slug = isset($_POST['new_slug'])? $_POST['new_slug'] : ''; + die(get_sample_permalink_html($post_id, $title, $slug)); +break; +case 'inline-save': + check_ajax_referer( 'inlineeditnonce', '_inline_edit' ); + + if ( ! isset($_POST['post_ID']) || ! ( $post_ID = (int) $_POST['post_ID'] ) ) + exit; + + 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.') ); + } + + if ( $last = wp_check_post_lock( $post_ID ) ) { + $last_user = get_userdata( $last ); + $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' ); + printf( $_POST['post_type'] == 'page' ? __( 'Saving is disabled: %s is currently editing this page.' ) : __( 'Saving is disabled: %s is currently editing this post.' ), wp_specialchars( $last_user_name ) ); + exit; + } + + $data = &$_POST; + $post = get_post( $post_ID, ARRAY_A ); + $data['content'] = $post['post_content']; + $data['excerpt'] = $post['post_excerpt']; + + // rename + $data['user_ID'] = $GLOBALS['user_ID']; + + if ( isset($data['post_parent']) ) + $data['parent_id'] = $data['post_parent']; + + // status + if ( isset($data['keep_private']) && 'private' == $data['keep_private'] ) + $data['post_status'] = 'private'; + else + $data['post_status'] = $data['_status']; + + if ( empty($data['comment_status']) ) + $data['comment_status'] = 'closed'; + if ( empty($data['ping_status']) ) + $data['ping_status'] = 'closed'; + + // update the post + $_POST = $data; + edit_post(); + + $post = array(); + if ( 'page' == $_POST['post_type'] ) { + $post[] = get_post($_POST['post_ID']); + page_rows($post); + } elseif ( 'post' == $_POST['post_type'] ) { + $mode = $_POST['post_view']; + $post[] = get_post($_POST['post_ID']); + post_rows($post); + } + + exit; + break; +case 'inline-save-tax': + check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' ); + + if ( ! current_user_can('manage_categories') ) + die( __('Cheatin’ uh?') ); + + if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) ) + die(-1); + + switch ($_POST['tax_type']) { + case 'cat' : + $data = array(); + $data['cat_ID'] = $id; + $data['cat_name'] = $_POST['name']; + $data['category_nicename'] = $_POST['slug']; + if ( isset($_POST['parent']) && (int) $_POST['parent'] > 0 ) + $data['category_parent'] = $_POST['parent']; + + $cat = get_category($id, ARRAY_A); + $data['category_description'] = $cat['category_description']; + + $updated = wp_update_category($data); + + if ( $updated && !is_wp_error($updated) ) + echo _cat_row( $updated, 0 ); + else + die( __('Category not updated.') ); + + break; + case 'link-cat' : + $updated = wp_update_term($id, 'link_category', $_POST); + + if ( $updated && !is_wp_error($updated) ) + echo link_cat_row($updated['term_id']); + else + die( __('Category not updated.') ); + + break; + case 'tag' : + $updated = wp_update_term($id, 'post_tag', $_POST); + if ( $updated && !is_wp_error($updated) ) { + $tag = get_term( $updated['term_id'], 'post_tag' ); + if ( !$tag || is_wp_error( $tag ) ) + die( __('Tag not updated.') ); + + echo _tag_row($tag); + } else { + die( __('Tag not updated.') ); + } + + break; + } + + exit; + break; +case 'meta-box-order': + check_ajax_referer( 'meta-box-order' ); + update_user_option( $GLOBALS['current_user']->ID, "meta-box-order_$_POST[page]", $_POST['order'] ); + die('1'); + break; +case 'find_posts': + check_ajax_referer( 'find-posts' ); + + if ( empty($_POST['ps']) ) + exit; + + $what = isset($_POST['pages']) ? 'page' : 'post'; + $s = stripslashes($_POST['ps']); + preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches); + $search_terms = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]); + + $searchand = $search = ''; + foreach( (array) $search_terms as $term) { + $term = addslashes_gpc($term); + $search .= "{$searchand}(($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%'))"; + $searchand = ' AND '; + } + $term = $wpdb->escape($s); + if ( count($search_terms) > 1 && $search_terms[0] != $s ) + $search .= " OR ($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%')"; + + $posts = $wpdb->get_results( "SELECT ID, post_title, post_status, post_date FROM $wpdb->posts WHERE post_type = '$what' AND $search ORDER BY post_date_gmt DESC LIMIT 50" ); + + if ( ! $posts ) + exit( __('No posts found.') ); + + $html = ''; + foreach ( $posts as $post ) { + + switch ( $post->post_status ) { + case 'publish' : + case 'private' : + $stat = __('Published'); + break; + case 'future' : + $stat = __('Scheduled'); + break; + case 'pending' : + $stat = __('Pending Review'); + break; + case 'draft' : + $stat = __('Unpublished'); + break; + } + + if ( '0000-00-00 00:00:00' == $post->post_date ) { + $time = ''; + } else { + $time = mysql2date(__('Y/m/d'), $post->post_date); + } + + $html .= ''; + $html .= ''."\n\n"; + } + $html .= '

'.__('Title').''.__('Time').''.__('Status').'
'.wp_specialchars($time, true).''.wp_specialchars($stat, true).'
'; + + $x = new WP_Ajax_Response(); + $x->add( array( + 'what' => $what, + 'data' => $html + )); + $x->send(); + + break; +default : + do_action( 'wp_ajax_' . $_POST['action'] ); + die('0'); + break; +endswitch; +?> diff -uNr a/blog/wp-admin/admin-footer.php b/blog/wp-admin/admin-footer.php --- a/blog/wp-admin/admin-footer.php false +++ b/blog/wp-admin/admin-footer.php ee2e2db22c5c14cb3e1f1ca820162c3b43718e5e07852ed24444d6d89f960917f43137832589cfe439ee5a1ae8c1cf936891921d53bff6868f65528599768a04 @@ -0,0 +1,28 @@ + + +
+
+
+ + + + + + + \ No newline at end of file diff -uNr a/blog/wp-admin/admin-functions.php b/blog/wp-admin/admin-functions.php --- a/blog/wp-admin/admin-functions.php false +++ b/blog/wp-admin/admin-functions.php ce16abcc8d2f3c66b2bb31069f2d72cc9d2edafe290a84945d724b01f93eb7ec3d367d8d218ed8c7e04da48ddd3a4764f4ca49e8b78c2cbb358ac30bf3afa4a8 @@ -0,0 +1,16 @@ + \ No newline at end of file diff -uNr a/blog/wp-admin/admin-header.php b/blog/wp-admin/admin-header.php --- a/blog/wp-admin/admin-header.php false +++ b/blog/wp-admin/admin-header.php e912d8aa1597285167aa591ae39d320db7ad48645e20d691118dcf6a7645fe55732b957af1e4520e64f83f55468d29617916d2686c399801a710af49317c0385 @@ -0,0 +1,132 @@ + + + > + + +<?php bloginfo('name') ?> › <?php echo $title; ?> — WordPress + + + + + + + + +
+
+ + + + + + +
+ + +
+flush_rules(); + + exit(); +} else { + do_action("load-$pagenow"); +} + +if ( !empty($_REQUEST['action']) ) + do_action('admin_action_' . $_REQUEST['action']); + +?> diff -uNr a/blog/wp-admin/admin-post.php b/blog/wp-admin/admin-post.php --- a/blog/wp-admin/admin-post.php false +++ b/blog/wp-admin/admin-post.php 352fec2319b48e6d7fff2d1c6f4373a38879c5627fd308cba6000be126801864bbc8aa3eceebf1382ee8e2165519da8bedb17707ac7abee5b41f000ea6234115 @@ -0,0 +1,32 @@ + \ No newline at end of file diff -uNr a/blog/wp-admin/async-upload.php b/blog/wp-admin/async-upload.php --- a/blog/wp-admin/async-upload.php false +++ b/blog/wp-admin/async-upload.php f5f77ad6d1b9d382725a84a9b5db866d5bef10980ffeaedfc0efdccc4a22e8709f9f48f99cae5df0f4ed46a4a681859cac374fc3f0bf9c94406735ee4addc460 @@ -0,0 +1,56 @@ + false, 'delete' => false )); + } else { + echo get_media_item($id); + } + exit; +} + +check_admin_referer('media-form'); + +$id = media_handle_upload('async-upload', $_REQUEST['post_id']); +if (is_wp_error($id)) { + echo '
'.wp_specialchars($id->get_error_message()).'
'; + exit; +} + +if ( $_REQUEST['short'] ) { + // short form response - attachment ID only + echo $id; +} +else { + // long form response - big chunk o html + $type = $_REQUEST['type']; + echo apply_filters("async_upload_{$type}", $id); +} + +?> \ No newline at end of file diff -uNr a/blog/wp-admin/categories.php b/blog/wp-admin/categories.php --- a/blog/wp-admin/categories.php false +++ b/blog/wp-admin/categories.php e0cb82940036a065c0b91d6fa8303e0c933b2f1e6bb1f8dcc87afe41c161e5da5a49d226d1b511ee9403bc337ae0ca2f75f6725ec7841b60d4769df6192b9e35 @@ -0,0 +1,315 @@ +%s category: this is the default one"), $cat_name)); + + wp_delete_category($cat_ID); + + wp_redirect('categories.php?message=2'); + exit; + +break; + +case 'bulk-delete': + check_admin_referer('bulk-categories'); + + if ( !current_user_can('manage_categories') ) + wp_die( __('You are not allowed to delete categories.') ); + + foreach ( (array) $_GET['delete'] as $cat_ID ) { + $cat_name = get_catname($cat_ID); + + // Don't delete the default cats. + if ( $cat_ID == get_option('default_category') ) + wp_die(sprintf(__("Can’t delete the %s category: this is the default one"), $cat_name)); + + wp_delete_category($cat_ID); + } + + $sendback = wp_get_referer(); + + wp_redirect($sendback); + exit(); + +break; +case 'edit': + + $title = __('Edit Category'); + + 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') ) + wp_die(__('Cheatin’ uh?')); + + $location = 'categories.php'; + if ( $referer = wp_get_original_referer() ) { + if ( false !== strpos($referer, 'categories.php') ) + $location = $referer; + } + + if ( wp_update_category($_POST) ) + $location = add_query_arg('message', 3, $location); + else + $location = add_query_arg('message', 5, $location); + + wp_redirect($location); + + exit; +break; + +default: + +if ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { + wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); + exit; +} + +wp_enqueue_script('admin-categories'); +if ( current_user_can('manage_categories') ) + wp_enqueue_script('inline-edit-tax'); + +require_once ('admin-header.php'); + +$messages[1] = __('Category added.'); +$messages[2] = __('Category deleted.'); +$messages[3] = __('Category updated.'); +$messages[4] = __('Category not added.'); +$messages[5] = __('Category not updated.'); +?> + +
+ +

' . __('Search results for “%s”') . '', wp_specialchars( stripslashes($_GET['s']) ) ); ?> +

+ + +

+ + +
+ +
+
+ +
+ +
+
+
+
+ + add_query_arg( 'pagenum', '%#%' ), + 'format' => '', + 'prev_text' => __('«'), + 'next_text' => __('»'), + 'total' => ceil(wp_count_terms('category') / $catsperpage), + 'current' => $pagenum +)); + +if ( $page_links ) + echo "
$page_links
"; +?> + +
+ + + +
+ +
+
+ +
+ + + + + + + + + + + + + + + + + +
+ +
+$page_links
"; +?> + +
+ + + +
+ +
+
+ + + +
+

Note:
Deleting a category does not delete the posts in that category. Instead, posts that were only assigned to the deleted category are set to the category %s.'), apply_filters('the_category', get_catname(get_option('default_category')))) ?>

+

category to tag converter.'), 'admin.php?import=wp-cat2tag') ?>

+
+ +
+
+ +
+
+ + +parent = 0; do_action('add_category_form_pre', $category); ?> + +
+

+
+
+ + + +
+ + +

+
+ +
+ + +

+
+ +
+ + 0, 'name' => 'category_parent', 'orderby' => 'name', 'selected' => $category->parent, 'hierarchical' => true, 'show_option_none' => __('None'))); ?> +

+
+ +
+ + +

+
+ +

+ +
+ + + +
+
+ +
+
+ + + + diff -uNr a/blog/wp-admin/comment.php b/blog/wp-admin/comment.php --- a/blog/wp-admin/comment.php false +++ b/blog/wp-admin/comment.php d5825da8a4c19e80b1128f5ca6eb3d9e07ef5076dabe132e5167dffed7f4a8528e8c4cd6e98f2ae28abd157585a727716bdec16891ebcfaf765f8bd50749fc18 @@ -0,0 +1,240 @@ +

$msg

"; + include('admin-footer.php'); + die; +} + +switch( $action ) { + +case 'editcomment' : + $title = __('Edit Comment'); + + wp_enqueue_script('comment'); + require_once('admin-header.php'); + + $comment_id = absint( $_GET['c'] ); + + if ( !$comment = get_comment( $comment_id ) ) + comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' '.__('Go back').'!', 'javascript:history.go(-1)') ); + + if ( !current_user_can('edit_post', $comment->comment_post_ID) ) + comment_footer_die( __('You are not allowed to edit comments on this post.') ); + + $comment = get_comment_to_edit( $comment_id ); + + include('edit-form-comment.php'); + + break; + +case 'cdc' : +case 'mac' : + + require_once('admin-header.php'); + + $comment_id = absint( $_GET['c'] ); + $formaction = 'cdc' == $action ? 'deletecomment' : 'approvecomment'; + $nonce_action = 'cdc' == $action ? 'delete-comment_' : 'approve-comment_'; + $nonce_action .= $comment_id; + + if ( !$comment = get_comment_to_edit( $comment_id ) ) + comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' '.__('Go back').'!', 'edit.php') ); + + if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) + comment_footer_die( 'cdc' == $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.') ); +?> +
+ +
+ + +

+ +

+ +
+ + + + + + +
' onclick="self.location='" />
+ + + + + + + + + +
+ + + + + + +comment_author_email ) { ?> + + + + + +comment_author_url ) { ?> + + + + + + + + + +
comment_author; ?>
comment_author_email; ?>
comment_author_url; ?>
comment_content; ?>
+ +
+
+'.__('Go back').'!', 'edit-comments.php') ); + + if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) + comment_footer_die( __('You are not allowed to edit comments on this post.') ); + + if ( 'spam' == $_REQUEST['dt'] ) + wp_set_comment_status( $comment->comment_ID, 'spam' ); + else + wp_delete_comment( $comment->comment_ID ); + + if ( '' != wp_get_referer() && false == $noredir && false === strpos(wp_get_referer(), 'comment.php' ) ) + wp_redirect( wp_get_referer() ); + else if ( '' != wp_get_original_referer() && false == $noredir ) + wp_redirect( wp_get_original_referer() ); + else + wp_redirect( admin_url('edit-comments.php') ); + + die; + break; + +case 'unapprovecomment' : + $comment_id = absint( $_GET['c'] ); + check_admin_referer( 'unapprove-comment_' . $comment_id ); + + if ( isset( $_GET['noredir'] ) ) + $noredir = true; + else + $noredir = false; + + if ( !$comment = get_comment( $comment_id ) ) + comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' '.__('Go back').'!', 'edit.php') ); + + if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) + comment_footer_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 ( '' != wp_get_referer() && false == $noredir ) + wp_redirect( wp_get_referer() ); + else + wp_redirect( admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) . '#comments') ); + + exit(); + break; + +case 'approvecomment' : + $comment_id = absint( $_GET['c'] ); + check_admin_referer( 'approve-comment_' . $comment_id ); + + if ( isset( $_GET['noredir'] ) ) + $noredir = true; + else + $noredir = false; + + if ( !$comment = get_comment( $comment_id ) ) + comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' '.__('Go back').'!', 'edit.php') ); + + if ( !current_user_can('edit_post', $comment->comment_post_ID) ) + comment_footer_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 ( '' != wp_get_referer() && false == $noredir ) + wp_redirect( wp_get_referer() ); + else + wp_redirect( admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) . '#comments') ); + + exit(); + break; + +case 'editedcomment' : + + $comment_id = absint( $_POST['comment_ID'] ); + $comment_post_id = absint( $_POST['comment_post_id'] ); + + check_admin_referer( 'update-comment_' . $comment_id ); + + edit_comment(); + + $location = ( empty( $_POST['referredby'] ) ? "edit-comments.php?p=$comment_post_id" : $_POST['referredby'] ) . '#comment-' . $comment_id; + $location = apply_filters( 'comment_edit_redirect', $location, $comment_id ); + wp_redirect( $location ); + + exit(); + break; + +default: + wp_die( __('Unknown action.') ); + break; + +} // end switch + +include('admin-footer.php'); + +?> \ No newline at end of file diff -uNr a/blog/wp-admin/css/colors-classic.css b/blog/wp-admin/css/colors-classic.css --- a/blog/wp-admin/css/colors-classic.css false +++ b/blog/wp-admin/css/colors-classic.css 27030efda1d5d663d1d5339db2addd50323eafa9922683c8026a10ca036161318fdf110c505acf169d7483114d97cc79d8b8e7ab5b8cdaca4a82d1c7e26f03a4 @@ -0,0 +1,1577 @@ +html { + background-color: #F5FCFD; +} + +.find-box-search { + border-color: #dfdfdf; + background-color: #f1f1f1; +} + +.find-box { + background-color: #f1f1f1; +} + +.find-box-inside { + background-color: #fff; +} + +a.page-numbers:hover { + border-color: #999; +} + +body, +#wpbody, +.form-table .pre { + color: #333; +} + +body > #upload-menu { + border-bottom-color: #fff; +} + +kbd, code { + background: #eaeaea; +} + +div#current-widgets, +#postcustomstuff table, +#your-profile fieldset, +#rightnow, +div.dashboard-widget, +#dashboard-widgets p.dashboard-widget-links, +#replyrow #ed_reply_toolbar input { + border-color: #ccc; +} + +#poststuff .inside label.spam { + color: red; +} + +#poststuff .inside label.waiting { + color: orange; +} + +#poststuff .inside label.approved { + color: green; +} + +#postcustomstuff table { + border-color: #dfdfdf; + background-color: #F9F9F9; +} + +#postcustomstuff thead th { + background-color: #F1F1F1; +} + +#postcustomstuff table input, +#postcustomstuff table textarea { + border-color: #dfdfdf; + background-color: #fff; +} + +.widefat { + border-color: #BBD8E7; + background-color: #fff; +} + +div.dashboard-widget-error { + background-color: #c43; +} + +div.dashboard-widget-notice { + background-color: #cfe1ef; +} + +div.dashboard-widget-submit, +ul.widget-control-list div.widget-control-actions { + border-top-color: #ccc; +} + +div.ui-tabs-panel { + border-color: #f1f1f1; +} + +ul#category-tabs li.ui-tabs-selected { + background-color: #f1f1f1; +} + +input.disabled, +textarea.disabled { + background-color: #ccc; +} +/* #upload-menu li a.upload-tab-link, */ +li.widget-list-control-item h4.widget-title a:hover, +li.widget-list-control-item h4.widget-title a, +#dragHelper li.widget-list-control-item h4.widget-title a, +#draghelper li.widget-list-control-item h4.widget-title a:visited, +.login #backtoblog a:hover, +#plugin-information .action-button a, +#plugin-information .action-button a:hover, +#plugin-information .action-button a:visited { + color: #fff; +} + +li.widget-list-control-item div.widget-control { + background-color: #fff; + border-color: #dfdfdf; +} + +.metabox-holder .postbox h3, +#poststuff .postbox h3, +#poststuff .stuffbox h3 { + background: #dfdfdf url("../images/blue-grad.png") repeat-x left top; + text-shadow: #fff 0 1px 0; +} + +.form-table th, +.form-wrap label { + color: #222; + text-shadow: #fff 0 1px 0; +} + +.setting-description, .form-wrap p { + color: #666; +} + +select { + background-color: #fff; + border-color: #8CBDD5; +} + +strong .post-com-count span { + background-color: #21759b; +} + +ul#widget-list li.widget-list-item h4.widget-title { + background-color: #f0f0f0; + color: #000; +} + +.sorthelper { + background-color: #ccf3fa; +} + +.ac_match, .subsubsub a.current { + color: #000; +} + +.wrap h2 { + color: #093E56; +} + +.ac_over { + background-color: #f0f0b8; +} + +.ac_results { + background-color: #fff; + border-color: #808080; +} + +.ac_results li { + color: #101010; +} + +.alternate, .alt { + background-color: #EDFBFC; +} + +.available-theme a.screenshot { + background-color: #f1f1f1; + border-color: #ddd; +} + +.bar { + background-color: #e8e8e8; + border-right-color: #99d; +} + +#media-upload { + background: #fff; +} +#media-upload .slidetoggle { + border-top-color: #dfdfdf; +} + +.error, #login #login_error { + background-color: #ffebe8; + border-color: #c00; +} + +.error a { + color: #c00; +} + +.form-invalid { + background-color: #ffebe8 !important; +} + +.form-invalid input { + border-color: #c00 !important; +} + +.form-table input, +.form-table textarea, +.search-input, +.form-field input, +.form-field textarea, +.submit { + border-color: #8CBDD5; +} + +.highlight { + background-color: #e4f2fd; + color: #d54e21; +} + +.howto, +.nonessential, +#edit-slug-box, +.form-input-tip, +.rss-widget span.rss-date, +.subsubsub { + color: #666; +} + +.media-item { + border-bottom-color: #dfdfdf; +} + +#wpbody-content #media-items .describe { + border-top-color: #dfdfdf; +} + +.describe input[type="text"], +.describe textarea { + border-color: #dfdfdf; +} + +.media-upload-form label.form-help, +td.help { + color: #9a9a9a; +} + +.post-com-count { + background-image: url(../images/bubble_bg.gif); + color: #fff; +} + +.post-com-count span { + background-color: #bbb; + color: #fff; +} + +.post-com-count:hover span { + background-color: #d54e21; +} + +.quicktags, .search { + background-color: #ccc; + color: #000; +} + +.side-info h5, .bordertitle { + border-bottom-color: #dadada; +} + +.side-info ul, .widget-description { + color: #666; +} + +.button, +.button-secondary, +.submit input, +input[type=button], +input[type=submit] { + border-color: #8CBDD5; + color: #093E56; +} + +.button:hover, +.button-secondary:hover, +.submit input:hover, +input[type=button]:hover, +input[type=submit]:hover { + color: #000; + border-color: #21759B; +} + +.button, +.submit input, +.button-secondary { + background: #f2f2f2 url(../images/white-grad.png) repeat-x scroll left top; +} + +.button:active, +.submit input:active, +.button-secondary:active { + background: #eee url(../images/white-grad-active.png) repeat-x scroll left top; +} + +.button-primary, +.submit .button-primary, +#login form .submit input { + border-color: #298cba !important; + font-weight: bold; + color: #FFF !important; + background: #21759B url(../images/button-grad.png) repeat-x scroll left top; +} + +.button-primary:active, +#login form .submit input:active { + background: #21759b url(../images/button-grad-active.png) repeat-x scroll left top !important; +} + +.button[disabled], +.button:disabled, +.button-secondary[disabled], +.button-secondary:disabled, +a.button.disabled { + color: #ccc !important; + border-color: #ccc; +} + +.button-primary[disabled], +.button-primary:disabled { + color: #2fa0d5 !important; +} + +a:active, +a:focus { + color: #d54e21; +} + +a:hover, +#wphead #viewsite a:hover, +#adminmenu a:hover, +#adminmenu ul.wp-submenu a:hover, +#the-comment-list .comment a:hover, +#rightnow a:hover, +.subsubsub a:hover, +.subsubsub a.current:hover, +#login form .submit input:hover, +div.dashboard-widget-submit input:hover, +#media-upload a.del-link:hover, +.ui-tabs-nav a:hover { + color: #d54e21; +} + +#the-comment-list .comment-item, +#dashboard-widgets #dashboard_quick_press form p.submit { + border-color: #dfdfdf; +} + +.button-primary:hover, +#login form .submit input:hover { + border-color: #13455b !important; + color: #EAF2FA !important; +} + +#side-info-column #category-tabs .ui-tabs-selected a { + color: #333; +} + +#rightnow .rbutton { + background-color: #ebebeb; + color: #264761; +} + +.submitbox .submit { + background-color: #464646; + color: #ccc; +} + +.submitbox .submitdelete, a.delete { + color: #f00; + border-bottom-color: #f00; +} + +.submitbox .submitdelete:hover, +#media-upload a.delete:hover { + color: #fff; + background-color: #f00; + border-bottom-color: #f00; +} + +#normal-sortables .submitbox .submitdelete:hover { + color: #000; + background-color: #f00; + border-bottom-color: #f00; +} + +.tablenav .dots { + border-color: transparent; +} + +.tablenav .next, +.tablenav .prev { + border-color: transparent; + color: #21759b; +} + +.tablenav .next:hover, +.tablenav .prev:hover { + border-color: transparent; + color: #d54e21; +} + +.updated, +.login #login_error, +.login .message { + background-color: #ffffe0; + border-color: #e6db55; +} + +a.page-numbers { + border-bottom-color: #B8D3E2; +} + +div#available-widgets-filter, +ul#widget-list li.widget-list-item, +.commentlist li { + border-bottom-color: #ccc; +} + +.widefat td, +.widefat th { + border-bottom-color: #BBD8E7; +} + +.widefat th { + text-shadow: rgba(255,255,255,0.8) 0 1px 0; +} + +.widefat thead tr th, +.widefat tfoot tr th, +h3.dashboard-widget-title, +h3.dashboard-widget-title span, +h3.dashboard-widget-title small, +.find-box-head { + color: #333; + background: #dfdfdf url(../images/blue-grad.png) repeat-x scroll left top; +} + +h3.dashboard-widget-title small a { + color: #d7d7d7; +} + +h3.dashboard-widget-title small a:hover { + color: #fff; +} + +#adminmenu a, +#poststuff #edButtonPreview, +#poststuff #edButtonHTML, +#the-comment-list p.comment-author strong a, +#media-upload a.del-link, +#media-upload a.delete, +.ui-tabs-nav a, a { + color: #1C6280; +} + +/* Because we don't want visited on these links */ +body.press-this .ui-tabs-selected a, +body.press-this .ui-tabs-selected a:hover { + background-color: #fff; + border-color: #c6d9e9; + border-bottom-color: #fff; + color: #d54e21; +} + +#adminmenu #awaiting-mod, +#adminmenu .update-plugins, +#sidemenu a .update-plugins, +#rightnow .reallynow, +#plugin-information .action-button { + background-color: #d54e21; + color: #fff; +} + +#adminmenu li a:hover #awaiting-mod, +#adminmenu li a:hover .update-plugins, +#sidemenu li a:hover .update-plugins { + background-color: #264761; + color: #fff; +} + +#adminmenu li.current a #awaiting-mod, +#adminmenu li.current a .update-plugins, +#adminmenu li.wp-has-current-submenu a .update-plugins, +#adminmenu li.wp-has-current-submenu a .update-plugins { + background-color: #ddd; + color: #000; + text-shadow: none; + -moz-box-shadow: rgba(0,0,0,0.2) 0px -1px 0px; + -khtml-box-shadow: rgba(0,0,0,0.2) 0px -1px 0px; + -webkit-box-shadow: rgba(0,0,0,0.2) 0px -1px 0px; + box-shadow: rgba(0,0,0,0.2) 0px -1px 0px; +} + +#adminmenu li.current a:hover #awaiting-mod, +#adminmenu li.current a:hover .update-plugins, +#adminmenu li.wp-has-current-submenu a:hover #awaiting-mod, +#adminmenu li.wp-has-current-submenu a:hover .update-plugins { + background-color: #264761; + color: #fff; +} + +div#media-upload-header { + background-color: #f9f9f9; + border-bottom-color: #dfdfdf; +} + +div#plugin-information-header { + background-color: #e4f2fd; + border-bottom-color: #c6d9e9; +} + +#currenttheme img { + border-color: #666; +} + +#current-widgets .drop-widget-here { + background-color: #ffc; +} + +#dashboard_secondary div.dashboard-widget-content ul li a { + background-color: #f9f9f9; +} + +input.readonly, textarea.readonly { + background-color: #ddd; +} + +#dragHelper h4.widget-title, +li.widget-list-control-item h4, +#dragHelper li.widget-list-control-item h4 { + background-color: #2683ae; + color: #fff; +} + +#ed_toolbar input, +#ed_reply_toolbar input { + background: #fff url("../images/fade-butt.png") repeat-x 0 -2px; +} + +#editable-post-name { + background-color: #fffbcc; +} + +#edit-slug-box strong, +.tablenav .displaying-num, +#submitted-on { + color: #777; +} + +.login #nav a { + color: #21759b !important; +} + +.login #nav a:hover { + color: #d54e21 !important; +} + +#footer, +#footer-upgrade { + background: #073447; + color: #999; +} + +#media-items { + border-color: #dfdfdf; +} + +#pass-strength-result { + background-color: #eee; + border-color: #ddd !important; +} + +#pass-strength-result.bad { + background-color: #ffb78c; + border-color: #ff853c !important; +} + +#pass-strength-result.good { + background-color: #ffec8b; + border-color: #fc0 !important; +} + +#pass-strength-result.short { + background-color: #ffa0a0; + border-color: #f04040 !important; +} + +#pass-strength-result.strong { + background-color: #c3ff88; + border-color: #8dff1c !important; +} + +.checkbox, +.side-info, +#your-profile #rich_editing { + background-color: #fff; +} + +.plugins .active { + background-color: #e7f7d3; +} + +.plugins .togl { + border-right-color: #ccc; +} + +#the-comment-list .unapproved { + background-color: #ffffe0; +} + +#the-comment-list .approve a { + color: #006505; +} + +#the-comment-list .unapprove a { + color: #d98500; +} + +#the-comment-list .delete a { + color: #bc0b0b; +} + +.plugins tr { + background-color: #fff; +} + +.metabox-holder .postbox, +#poststuff .postbox, +#titlediv, +#poststuff .postarea, +#poststuff .stuffbox, +.postbox input[type="text"], +.postbox textarea, +.stuffbox input[type="text"], +.stuffbox textarea { + border-color: #BBD8E7; +} + +.metabox-holder .postbox, +#poststuff .postbox { + background-color: #FFF; +} + +.ui-sortable .postbox h3 { + color: #093E56; +} + +.ui-sortable .postbox h3:hover { + color: #000; +} + +.curtime #timestamp { + background-image: url(../images/date-button.gif); +} + +#quicktags #ed_link { + color: #00f; +} + +#rightnow .youhave { + background-color: #f0f6fb; +} + +#rightnow a { + color: #448abd; +} + +#tagchecklist span a, +#bulk-titles div a { + background: url(../images/xit.gif) no-repeat; +} + +#tagchecklist span a:hover, +#bulk-titles div a:hover { + background: url(../images/xit.gif) no-repeat -10px 0; +} + +#update-nag, .plugin-update { + background-color: #fffeeb; + border-bottom-color: #ccc; + border-top-color: #ccc; + color: #555; +} + +.login #backtoblog a { + color: #ccc; +} + +#wphead { + background-color: #073447; +} + +body.login { + border-top-color: #093E56; +} + +#wphead h1 a { + color: #fff; +} + +#login form input { + color: #555; +} + +#wphead h1 a:hover { + text-decoration: underline; +} + +#user_info { + color: #999; +} + +#user_info a:link, #user_info a:visited, #footer a:link, #footer a:visited { + color: #ccc; + text-decoration: none; +} + +#user_info a:hover, #footer a:hover { + color: #fff; + text-decoration: underline !important; +} + +#user_info a:active, #footer a:active { + color: #ccc !important; +} + +div#media-upload-error, +.file-error, +abbr.required, +.widget-control-remove:hover, +.delete a:hover { + color: #f00; +} + +#media-upload a.delete { + color: #888; +} + +/* editors */ +#quicktags { + border-color: #dfdfdf; + background-color: #dfdfdf; +} + +#ed_toolbar input { + border-color: #C3C3C3; +} + +#ed_toolbar input:hover { + border-color: #aaa; + background: #ddd; +} + +#poststuff .wp_themeSkin .mceStatusbar { + border-color: #EDEDED; +} + +#poststuff #edButtonPreview, +#poststuff #edButtonHTML { + background-color: #f1f1f1; + border-color: #dfdfdf; + color: #999; +} + +#poststuff #editor-toolbar .active { + border-bottom-color: #e9e9e9; + background-color: #e9e9e9; + color: #333; +} + +/* TinyMCE */ +#post-status-info { + background-color: #EDEDED; +} + +.wp_themeSkin *, +.wp_themeSkin a:hover, +.wp_themeSkin a:link, +.wp_themeSkin a:visited, +.wp_themeSkin a:active { + color: #000; +} + +/* Containers */ +.wp_themeSkin iframe { + background: #fff; +} + +/* Layout */ +.wp_themeSkin .mceStatusbar { + color: #000; + background-color: #f5f5f5; +} + +/* Button */ +.wp_themeSkin .mceButton { + background-color: #e9e8e8; + border-color: #B2B2B2; +} + +.wp_themeSkin a.mceButtonEnabled:hover, +.wp_themeSkin a.mceButtonActive, +.wp_themeSkin a.mceButtonSelected { + background-color: #d5d5d5; + border-color: #777 !important; +} + +.wp_themeSkin .mceButtonDisabled { + border-color: #ccc !important; +} + +/* ListBox */ +.wp_themeSkin .mceListBox .mceText, +.wp_themeSkin .mceListBox .mceOpen { + border-color: #B2B2B2; + background-color: #d5d5d5; +} + +.wp_themeSkin table.mceListBoxEnabled:hover .mceOpen, +.wp_themeSkin .mceListBoxHover .mceOpen, +.wp_themeSkin .mceListBoxSelected .mceOpen, +.wp_themeSkin .mceListBoxSelected .mceText { + border-color: #777 !important; + background-color: #d5d5d5; +} + +.wp_themeSkin table.mceListBoxEnabled:hover .mceText, +.wp_themeSkin .mceListBoxHover .mceText { + border-color: #777 !important; +} + +.wp_themeSkin select.mceListBox { + border-color: #B2B2B2; + background-color: #fff; +} + +/* SplitButton */ +.wp_themeSkin .mceSplitButton a.mceAction, +.wp_themeSkin .mceSplitButton a.mceOpen { + background-color: #e8e8e8; + border-color: #B2B2B2; +} + +.wp_themeSkin .mceSplitButton a.mceOpen:hover, +.wp_themeSkin .mceSplitButtonSelected a.mceOpen, +.wp_themeSkin table.mceSplitButtonEnabled:hover a.mceAction, +.wp_themeSkin .mceSplitButton a.mceAction:hover { + background-color: #d5d5d5; + border-color: #777 !important; +} + +.wp_themeSkin .mceSplitButtonActive { + background-color: #B2B2B2; +} + +/* ColorSplitButton */ +.wp_themeSkin div.mceColorSplitMenu table { + background-color: #ebebeb; + border-color: #B2B2B2; +} + +.wp_themeSkin .mceColorSplitMenu a { + border-color: #B2B2B2; +} + +.wp_themeSkin .mceColorSplitMenu a.mceMoreColors { + border-color: #fff; +} + +.wp_themeSkin .mceColorSplitMenu a.mceMoreColors:hover { + border-color: #0A246A; + background-color: #B6BDD2; +} + +.wp_themeSkin a.mceMoreColors:hover { + border-color: #0A246A; +} + +/* Menu */ +.wp_themeSkin .mceMenu { + border-color: #ddd; +} + +.wp_themeSkin .mceMenu table { + background-color: #ebeaeb; +} + +.wp_themeSkin .mceMenu .mceText { + color: #000; +} + +.wp_themeSkin .mceMenu .mceMenuItemEnabled a:hover, +.wp_themeSkin .mceMenu .mceMenuItemActive { + background-color: #f5f5f5; +} +.wp_themeSkin td.mceMenuItemSeparator { + background-color: #aaa; +} +.wp_themeSkin .mceMenuItemTitle a { + background-color: #ccc; + border-bottom-color: #aaa; +} +.wp_themeSkin .mceMenuItemTitle span.mceText { + color: #000; +} +.wp_themeSkin .mceMenuItemDisabled .mceText { + color: #888; +} + +.wp_themeSkin tr.mceFirst td.mceToolbar { + background-color: #dfdfdf; + border-color: #dfdfdf; +} + +.wp-admin #mceModalBlocker { + background: #000; +} + +.wp-admin .clearlooks2 .mceFocus .mceTop .mceLeft { + background: #444444; + border-left: 1px solid #999; + border-top: 1px solid #999; + -moz-border-radius: 4px 0 0 0; + -webkit-border-top-left-radius: 4px; + -khtml-border-top-left-radius: 4px; + border-top-left-radius: 4px; +} + +.wp-admin .clearlooks2 .mceFocus .mceTop .mceRight { + background: #444444; + border-right: 1px solid #999; + border-top: 1px solid #999; + border-top-right-radius: 4px; + -khtml-border-top-right-radius: 4px; + -webkit-border-top-right-radius: 4px; + -moz-border-radius: 0 4px 0 0; +} + +.wp-admin .clearlooks2 .mceMiddle .mceLeft { + background: #f1f1f1; + border-left: 1px solid #999; +} + +.wp-admin .clearlooks2 .mceMiddle .mceRight { + background: #f1f1f1; + border-right: 1px solid #999; +} + +.wp-admin .clearlooks2 .mceBottom { + background: #f1f1f1; + border-bottom: 1px solid #999; +} + +.wp-admin .clearlooks2 .mceBottom .mceLeft { + background: #f1f1f1; + border-bottom: 1px solid #999; + border-left: 1px solid #999; +} + +.wp-admin .clearlooks2 .mceBottom .mceCenter { + background: #f1f1f1; + border-bottom: 1px solid #999; +} + +.wp-admin .clearlooks2 .mceBottom .mceRight { + background: #f1f1f1; + border-bottom: 1px solid #999; + border-right: 1px solid #999; +} + +.wp-admin .clearlooks2 .mceFocus .mceTop span { + color: #e5e5e5; +} +/* end TinyMCE */ + +#editorcontainer, +#post-status-info, +#titlediv #title { + border-color: #dfdfdf; +} + +#titlediv #title { + background-color: #fff; +} + +#tTips p#tTips_inside { + background-color: #ddd; + color: #333; +} + +#timestampdiv input, +#namediv input, +#tagsdiv #the-tagcloud { + border-color: #ddd; +} + +/* menu */ +#adminmenu * { + border-color: #BBD8E7; +} + +#adminmenu li.wp-menu-separator { + background: transparent url(../images/menu-arrows.gif) no-repeat scroll left 5px; +} + +.folded #adminmenu li.wp-menu-separator { + background: transparent url(../images/menu-arrows.gif) no-repeat scroll right -34px; +} + +#adminmenu li.wp-has-current-submenu.wp-menu-open .wp-menu-toggle, +#adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle { + background: transparent url(../images/menu-bits.gif) no-repeat scroll left -207px; +} + +#adminmenu .wp-has-submenu:hover .wp-menu-toggle, +#adminmenu .wp-menu-open .wp-menu-toggle { + background: transparent url(../images/menu-bits.gif) no-repeat scroll left -109px; +} + +#adminmenu a.menu-top { + background: #EAF3FA url(../images/menu-bits.gif) repeat-x scroll left -379px; +} + +#adminmenu .wp-submenu a { + background: #FFFFFF url(../images/menu-bits.gif) no-repeat scroll 0 -310px; +} + +#adminmenu .wp-has-current-submenu ul li a { + background: none; +} + +#adminmenu .wp-has-current-submenu ul li a.current { + background: url(../images/menu-dark.gif) top left no-repeat !important; +} + +#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, +#adminmenu .menu-top .current { + background: #6d6d6d url(../images/menu-bits.gif) top left repeat-x; + border-color: #6d6d6d; + color: #fff; + text-shadow: rgba(0,0,0,0.4) 0px -1px 0px; +} + +#adminmenu li.wp-has-current-submenu .wp-submenu, +#adminmenu li.wp-has-current-submenu ul li a { + border-color: #aaa !important; +} + +#adminmenu li.wp-has-current-submenu ul li a { + background: url(../images/menu-dark.gif) bottom left no-repeat !important; +} + +#adminmenu li.wp-has-current-submenu ul { + border-bottom-color: #aaa; +} + +#adminmenu li.menu-top .current:hover { + border-color: #B5B5B5; +} + +#adminmenu .wp-submenu .current a.current { + background: transparent url(../images/menu-bits.gif) no-repeat scroll 0 -289px; +} + +#adminmenu .wp-submenu a:hover { + background-color: #EAF2FA !important; + color: #333 !important; +} + +#adminmenu .wp-submenu li.current, +#adminmenu .wp-submenu li.current a, +#adminmenu .wp-submenu li.current a:hover { + color: #333; + background-color: #f5f5f5; + background-image: none; + border-color: #e3e3e3; + text-shadow: rgba(255,255,255,1) 0px 1px 0px; +} + +#adminmenu .wp-submenu ul { + background-color: #fff; +} + +.folded #adminmenu li.menu-top, +#adminmenu .wp-submenu .wp-submenu-head { + background-color: #EAF2FA; +} + +.folded #adminmenu li.wp-has-current-submenu, +.folded #adminmenu li.menu-top.current { + background-color: #BBD8E7; +} + +#adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head { + background-color: #BBD8E7; + border-color: #8CBDD5; +} + +#adminmenu div.wp-submenu { + background-color: transparent; +} + +/* menu icons */ +#adminmenu #menu-dashboard div.wp-menu-image { + background: transparent url("../images/menu-vs.png") no-repeat scroll -61px -33px; +} + +#adminmenu #menu-dashboard:hover div.wp-menu-image, +#adminmenu #menu-dashboard.wp-has-current-submenu div.wp-menu-image, +#adminmenu #menu-dashboard.current div.wp-menu-image { + background: transparent url("../images/menu-vs.png") no-repeat scroll -61px -1px; +} + +#adminmenu #menu-posts div.wp-menu-image { + background: transparent url("../images/menu-vs.png") no-repeat scroll -272px -33px; +} + +#adminmenu #menu-posts:hover div.wp-menu-image, +#adminmenu #menu-posts.wp-has-current-submenu div.wp-menu-image { + background: transparent url("../images/menu-vs.png") no-repeat scroll -272px -1px; +} + +#adminmenu #menu-media div.wp-menu-image { + background: transparent url("../images/menu-vs.png") no-repeat scroll -121px -33px; +} + +#adminmenu #menu-media:hover div.wp-menu-image, +#adminmenu #menu-media.wp-has-current-submenu div.wp-menu-image { + background: transparent url("../images/menu-vs.png") no-repeat scroll -121px -1px; +} + +#adminmenu #menu-links div.wp-menu-image { + background: transparent url("../images/menu-vs.png") no-repeat scroll -91px -33px; +} + +#adminmenu #menu-links:hover div.wp-menu-image, +#adminmenu #menu-links.wp-has-current-submenu div.wp-menu-image { + background: transparent url("../images/menu-vs.png") no-repeat scroll -91px -1px; +} + +#adminmenu #menu-pages div.wp-menu-image { + background: transparent url("../images/menu-vs.png") no-repeat scroll -151px -33px; +} + +#adminmenu #menu-pages:hover div.wp-menu-image, +#adminmenu #menu-pages.wp-has-current-submenu div.wp-menu-image { + background: transparent url("../images/menu-vs.png") no-repeat scroll -151px -1px; +} + +#adminmenu #menu-comments div.wp-menu-image { + background: transparent url("../images/menu-vs.png") no-repeat scroll -31px -33px; +} + +#adminmenu #menu-comments:hover div.wp-menu-image, +#adminmenu #menu-comments.wp-has-current-submenu div.wp-menu-image, +#adminmenu #menu-comments.current div.wp-menu-image { + background: transparent url("../images/menu-vs.png") no-repeat scroll -31px -1px; +} + +#adminmenu #menu-appearance div.wp-menu-image { + background: transparent url("../images/menu-vs.png") no-repeat scroll -1px -33px; +} + +#adminmenu #menu-appearance:hover div.wp-menu-image, +#adminmenu #menu-appearance.wp-has-current-submenu div.wp-menu-image { + background: transparent url("../images/menu-vs.png") no-repeat scroll -1px -1px; +} + +#adminmenu #menu-plugins div.wp-menu-image { + background: transparent url("../images/menu-vs.png") no-repeat scroll -181px -33px; +} + +#adminmenu #menu-plugins:hover div.wp-menu-image, +#adminmenu #menu-plugins.wp-has-current-submenu div.wp-menu-image { + background: transparent url("../images/menu-vs.png") no-repeat scroll -181px -1px; +} + +#adminmenu #menu-users div.wp-menu-image { + background: transparent url("../images/menu-vs.png") no-repeat scroll -301px -33px; +} + +#adminmenu #menu-users:hover div.wp-menu-image, +#adminmenu #menu-users.wp-has-current-submenu div.wp-menu-image { + background: transparent url("../images/menu-vs.png") no-repeat scroll -301px -1px; +} + +#adminmenu #menu-tools div.wp-menu-image { + background: transparent url("../images/menu-vs.png") no-repeat scroll -211px -33px; +} + +#adminmenu #menu-tools:hover div.wp-menu-image, +#adminmenu #menu-tools.wp-has-current-submenu div.wp-menu-image { + background: transparent url("../images/menu-vs.png") no-repeat scroll -211px -1px; +} + +#adminmenu #menu-settings div.wp-menu-image { + background: transparent url("../images/menu-vs.png") no-repeat scroll -241px -33px; +} + +#adminmenu #menu-settings:hover div.wp-menu-image, +#adminmenu #menu-settings.wp-has-current-submenu div.wp-menu-image { + background: transparent url("../images/menu-vs.png") no-repeat scroll -241px -1px; +} +/* end menu */ + + +/* Diff */ +table.diff .diff-deletedline { + background-color: #ffdddd; +} +table.diff .diff-deletedline del { + background-color: #ff9999; +} +table.diff .diff-addedline { + background-color: #ddffdd; +} +table.diff .diff-addedline ins { + background-color: #99ff99; +} + +#att-info { + background-color: #E4F2FD; +} + +/* edit image */ +#sidemenu a { + background-color: #f9f9f9; + border-color: #f9f9f9; + border-bottom-color: #dfdfdf; +} + +#sidemenu a.current { + background-color: #fff; + border-color: #dfdfdf #dfdfdf #fff; + color: #D54E21; +} + + +#screen-options-wrap, +#contextual-help-wrap { + background-color: #f1f1f1; + border-color: #dfdfdf; +} + +#screen-meta-links a.show-settings { + color: #606060; +} + +#screen-meta-links a.show-settings:hover { + color: #000; +} + +#replysubmit { + background-color: #f1f1f1; + border-top-color: #ddd; +} + +#replyerror { + border-color: #ddd; + background-color: #f9f9f9; +} + +#edithead, +#replyhead { + background-color: #f1f1f1; +} + +#ed_reply_toolbar { + background-color: #e9e9e9; +} + +/* table vim shortcuts */ +.vim-current { + background-color: #E4F2FD !important; +} + +/* Install Plugins */ +.star-average, +.star.star-rating { + background-color: #fc0; +} + +div.star.select:hover { + background-color: #d00; +} + +#plugin-information .fyi ul { + background-color: #eaf3fa; +} + +#plugin-information .fyi h2.mainheader { + background-color: #cee1ef; +} + +#plugin-information pre, +#plugin-information code { + background-color: #ededff; +} + +#plugin-information pre { + border: 1px solid #ccc; +} + +/* inline editor */ +.inline-edit-row fieldset input[type="text"], +.inline-edit-row fieldset textarea, +#bulk-titles, +#replyrow input { + border-color: #ddd; +} + +.inline-editor div.title { + background-color: #EAF3FA; +} + +.inline-editor ul.cat-checklist { + background-color: #FFFFFF; + border-color: #ddd; +} + +.inline-edit-row p.submit { + background-color: #f1f1f1; +} + +.inline-editor .categories .catshow, +.inline-editor .categories .cathide { + color: #21759b; +} + +.inline-editor .quick-edit-save { + background-color: #f1f1f1; +} + +#replyrow #ed_reply_toolbar input:hover { + border-color: #aaa; + background: #ddd; +} + +fieldset.inline-edit-col-right .inline-edit-col { + border-color: #dfdfdf; +} + +.attention { + color: #D54E21; +} + +.meta-box-sortables .postbox:hover .handlediv { + background: transparent url(../images/menu-bits.gif) no-repeat scroll left -111px; +} + +#major-publishing-actions { + background: #eaf2fa; +} + +.tablenav .tablenav-pages { + color: #555; +} + +.tablenav .tablenav-pages a { + border-color: #e3e3e3; + background: #eee url('../images/menu-bits.gif') repeat-x scroll left -379px; +} + +.tablenav .tablenav-pages a:hover { + color: #d54e21; + border-color: #d54321; +} + +.tablenav .tablenav-pages a:active { + color: #fff !important; +} + +.tablenav .tablenav-pages .current { + background: #dfdfdf; + border-color: #d3d3d3; +} + +#availablethemes, +#availablethemes td { + border-color: #ddd; +} + +#current-theme img { + border-color: #999; +} + +#TB_window #TB_title a.tb-theme-preview-link, +#TB_window #TB_title a.tb-theme-preview-link:visited { + color: #999; +} + +#TB_window #TB_title a.tb-theme-preview-link:hover, +#TB_window #TB_title a.tb-theme-preview-link:focus { + color: #ccc; +} + +.misc-pub-section { + border-bottom-color: #eee; +} + +#minor-publishing { + border-bottom-color: #ddd; +} + +#post-body .misc-pub-section { + border-right-color: #eee; +} + +.post-com-count span { + background-color: #bbb; +} + +.form-table .color-palette td { + border-color: #fff; +} + +.sortable-placeholder { + border-color: #bbb; + background-color: #f5f5f5; +} + +#post-body ul#category-tabs li.ui-tabs-selected a { + color: #333; +} + +#wp_editimgbtn, +#wp_delimgbtn, +#wp_editgallery, +#wp_delgallery { + border-color: #999; + background-color: #eee; +} + +#wp_editimgbtn:hover, +#wp_delimgbtn:hover, +#wp_editgallery:hover, +#wp_delgallery:hover { + border-color: #555; + background-color: #ccc; +} + +#favorite-first { + background: #797979 url(../images/fav.png) repeat-x 0 center; + border-color: #777 !important; + border-bottom-color: #666 !important; +} + +#favorite-inside { + border-color: #797979; + background-color: #797979; +} + +#favorite-toggle { + background: transparent url(../images/fav-arrow.gif) no-repeat 0 -4px; +} + +#favorite-actions a { + color: #ddd; +} + +#favorite-actions a:hover { + color: #fff; +} + +#favorite-inside a:hover { + text-decoration: underline; +} + +#favorite-actions .slide-down { + border-bottom-color: #626262; +} + +.submit input, +.button, +.button-primary, +.button-secondary, +.button-highlighted, +#postcustomstuff .submit input { + text-shadow: rgba(255,255,255,1) 0 1px 0; +} + +.button-primary, +.submit .button-primary { + text-shadow: rgba(0,0,0,0.3) 0 -1px 0; +} + +#screen-meta a.show-settings { + background-color: transparent; + text-shadow: rgba(255,255,255,0.7) 0 1px 0; +} + +#icon-edit, +#icon-post { + background: transparent url(../images/icons32-vs.png) no-repeat -552px -5px; +} + +#icon-index { + background: transparent url(../images/icons32-vs.png) no-repeat -137px -5px; +} + +#icon-upload { + background: transparent url(../images/icons32-vs.png) no-repeat -251px -5px; +} + +#icon-link-manager, +#icon-link, +#icon-link-category { + background: transparent url(../images/icons32-vs.png) no-repeat -190px -5px; +} + +#icon-edit-pages, +#icon-page { + background: transparent url(../images/icons32-vs.png) no-repeat -312px -5px; +} + +#icon-edit-comments { + background: transparent url(../images/icons32-vs.png) no-repeat -72px -5px; +} + +#icon-themes { + background: transparent url(../images/icons32-vs.png) no-repeat -11px -5px; +} + +#icon-plugins { + background: transparent url(../images/icons32-vs.png) no-repeat -370px -5px; +} + +#icon-users, +#icon-user-edit { + background: transparent url(../images/icons32-vs.png) no-repeat -600px -5px; +} + +#icon-tools, +#icon-admin { + background: transparent url(../images/icons32-vs.png) no-repeat -432px -5px; +} + +#icon-options-general { + background: transparent url(../images/icons32-vs.png) no-repeat -492px -5px; +} + +.view-switch #view-switch-list { + background: transparent url(../images/list-vs.png) no-repeat 0 0; +} + +.view-switch #view-switch-list.current { + background: transparent url(../images/list-vs.png) no-repeat -40px 0; +} + +.view-switch #view-switch-excerpt { + background: transparent url(../images/list-vs.png) no-repeat -20px 0; +} + +.view-switch #view-switch-excerpt.current { + background: transparent url(../images/list-vs.png) no-repeat -60px 0; +} + +#header-logo { + background: transparent url(../images/wp-logo.gif) no-repeat scroll center center; +} diff -uNr a/blog/wp-admin/css/colors-classic-rtl.css b/blog/wp-admin/css/colors-classic-rtl.css --- a/blog/wp-admin/css/colors-classic-rtl.css false +++ b/blog/wp-admin/css/colors-classic-rtl.css ff985ba27f31b80a0851dc75ed42c3975f8329eb0c0e223996aeb0e231e786ab336dec8ad22ca848f63105288bffbaf2f66650fa10b9151a6964f152e0ca24c9 @@ -0,0 +1,80 @@ +.bar { + border-right-color: transparent; + border-left-color: #99d; +} + +.plugins .togl { + border-right-color: transparent; + border-left-color: #ccc; +} + +.post-com-count { + background-image: url(../images/bubble_bg-rtl.gif); +} +.tablenav .tablenav-pages a { + background: #eee url('../images/menu-bits-rtl.gif') repeat-x scroll right -379px; +} +#upload-menu li.current { + border-right-color: transparent; + border-left-color: #448abd; +} + +#adminmenu .wp-submenu .current a.current { + background: transparent url(../images/menu-bits-rtl.gif) no-repeat scroll right -289px; +} + +#adminmenu li.wp-menu-separator { + background: transparent url(../images/menu-arrows.gif) no-repeat scroll right -34px; +} + +.folded #adminmenu li.wp-menu-separator { + background: transparent url(../images/menu-arrows.gif) no-repeat scroll left 5px; +} + +#adminmenu li.wp-has-current-submenu .wp-menu-toggle, +#adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle { + background: transparent url(../images/menu-bits-rtl.gif) repeat-x scroll right -207px; +} + +#adminmenu .wp-has-current-submenu ul li a.current { + background: url(../images/menu-dark-rtl.gif) top right no-repeat !important; +} + +#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, +#adminmenu .menu-top .current { + background: url(../images/menu-bits-rtl.gif) top right repeat-x; +} + +#adminmenu li.wp-has-current-submenu ul li a { + background: url(../images/menu-dark-rtl.gif) bottom right no-repeat !important; +} + +#adminmenu li.wp-has-current-submenu.wp-menu-open .wp-menu-toggle, #adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle { + background: transparent url(../images/menu-bits-rtl.gif) no-repeat right -207px; +} + +#adminmenu .wp-has-submenu:hover .wp-menu-toggle, +#adminmenu .wp-menu-open .wp-menu-toggle { + background: transparent url(../images/menu-bits-rtl.gif) repeat-x scroll right -109px; +} + +#adminmenu a.wp-has-submenu { + background: #f1f1f1 url(../images/menu-bits-rtl.gif) repeat-x scroll right -379px; +} + +#adminmenu .wp-submenu a { + background: #FFFFFF url(../images/menu-bits-rtl.gif) no-repeat scroll right -310px; +} + +#adminmenu li.current a, +#adminmenu .wp-submenu a:hover { + background: transparent url(../images/menu-bits-rtl.gif) no-repeat scroll right -289px; +} + +#adminmenu li.wp-has-current-submenu a.wp-has-submenu { + background: #b5b5b5 url(../images/menu-bits-rtl.gif) repeat-x scroll right top; +} + +.meta-box-sortables .postbox:hover .handlediv { + background: transparent url(../images/menu-bits-rtl.gif) no-repeat scroll right -111px; +} diff -uNr a/blog/wp-admin/css/colors-fresh.css b/blog/wp-admin/css/colors-fresh.css --- a/blog/wp-admin/css/colors-fresh.css false +++ b/blog/wp-admin/css/colors-fresh.css 28bd72c8996b3aa61f19cf308e6e53192d5c21a1c861fcdf98d706206ae7ee5f17b6c7e8c379a1472856b8041147ff0f0768e6bece23c2cde05cdd89bb193129 @@ -0,0 +1,1577 @@ +html { + background-color: #f9f9f9; +} + +.find-box-search { + border-color: #dfdfdf; + background-color: #f1f1f1; +} + +.find-box { + background-color: #f1f1f1; +} + +.find-box-inside { + background-color: #fff; +} + +a.page-numbers:hover { + border-color: #999; +} + +body, +#wpbody, +.form-table .pre { + color: #333; +} + +body > #upload-menu { + border-bottom-color: #fff; +} + +kbd, code { + background: #eaeaea; +} + +div#current-widgets, +#postcustomstuff table, +#your-profile fieldset, +#rightnow, +div.dashboard-widget, +#dashboard-widgets p.dashboard-widget-links, +#replyrow #ed_reply_toolbar input { + border-color: #ccc; +} + +#poststuff .inside label.spam { + color: red; +} + +#poststuff .inside label.waiting { + color: orange; +} + +#poststuff .inside label.approved { + color: green; +} + +#postcustomstuff table { + border-color: #dfdfdf; + background-color: #F9F9F9; +} + +#postcustomstuff thead th { + background-color: #F1F1F1; +} + +#postcustomstuff table input, +#postcustomstuff table textarea { + border-color: #dfdfdf; + background-color: #fff; +} + +.widefat { + border-color: #dfdfdf; + background-color: #fff; +} + +div.dashboard-widget-error { + background-color: #c43; +} + +div.dashboard-widget-notice { + background-color: #cfe1ef; +} + +div.dashboard-widget-submit, +ul.widget-control-list div.widget-control-actions { + border-top-color: #ccc; +} + +div.ui-tabs-panel { + border-color: #f1f1f1; +} + +ul#category-tabs li.ui-tabs-selected { + background-color: #f1f1f1; +} + +input.disabled, +textarea.disabled { + background-color: #ccc; +} +/* #upload-menu li a.upload-tab-link, */ +li.widget-list-control-item h4.widget-title a:hover, +li.widget-list-control-item h4.widget-title a, +#dragHelper li.widget-list-control-item h4.widget-title a, +#draghelper li.widget-list-control-item h4.widget-title a:visited, +.login #backtoblog a:hover, +#plugin-information .action-button a, +#plugin-information .action-button a:hover, +#plugin-information .action-button a:visited { + color: #fff; +} + +li.widget-list-control-item div.widget-control { + background-color: #fff; + border-color: #dfdfdf; +} + +.metabox-holder .postbox h3, +#poststuff .postbox h3, +#poststuff .stuffbox h3 { + background: #dfdfdf url("../images/gray-grad.png") repeat-x left top; + text-shadow: #fff 0 1px 0; +} + +.form-table th, +.form-wrap label { + color: #222; + text-shadow: #fff 0 1px 0; +} + +.setting-description, .form-wrap p { + color: #666; +} + +select { + background-color: #fff; + border-color: #ddd; +} + +strong .post-com-count span { + background-color: #21759b; +} + +ul#widget-list li.widget-list-item h4.widget-title { + background-color: #f0f0f0; + color: #000; +} + +.sorthelper { + background-color: #ccf3fa; +} + +.ac_match, .subsubsub a.current { + color: #000; +} + +.wrap h2 { + color: #464646; +} + +.ac_over { + background-color: #f0f0b8; +} + +.ac_results { + background-color: #fff; + border-color: #808080; +} + +.ac_results li { + color: #101010; +} + +.alternate, .alt { + background-color: #f9f9f9; +} + +.available-theme a.screenshot { + background-color: #f1f1f1; + border-color: #ddd; +} + +.bar { + background-color: #e8e8e8; + border-right-color: #99d; +} + +#media-upload { + background: #fff; +} +#media-upload .slidetoggle { + border-top-color: #dfdfdf; +} + +.error, #login #login_error { + background-color: #ffebe8; + border-color: #c00; +} + +.error a { + color: #c00; +} + +.form-invalid { + background-color: #ffebe8 !important; +} + +.form-invalid input { + border-color: #c00 !important; +} + +.form-table input, +.form-table textarea, +.search-input, +.form-field input, +.form-field textarea, +.submit { + border-color: #DFDFDF; +} + +.highlight { + background-color: #e4f2fd; + color: #d54e21; +} + +.howto, +.nonessential, +#edit-slug-box, +.form-input-tip, +.rss-widget span.rss-date, +.subsubsub { + color: #666; +} + +.media-item { + border-bottom-color: #dfdfdf; +} + +#wpbody-content #media-items .describe { + border-top-color: #dfdfdf; +} + +.describe input[type="text"], +.describe textarea { + border-color: #dfdfdf; +} + +.media-upload-form label.form-help, +td.help { + color: #9a9a9a; +} + +.post-com-count { + background-image: url(../images/bubble_bg.gif); + color: #fff; +} + +.post-com-count span { + background-color: #bbb; + color: #fff; +} + +.post-com-count:hover span { + background-color: #d54e21; +} + +.quicktags, .search { + background-color: #ccc; + color: #000; +} + +.side-info h5, .bordertitle { + border-bottom-color: #dadada; +} + +.side-info ul, .widget-description { + color: #666; +} + +.button, +.button-secondary, +.submit input, +input[type=button], +input[type=submit] { + border-color: #bbb; + color: #464646; +} + +.button:hover, +.button-secondary:hover, +.submit input:hover, +input[type=button]:hover, +input[type=submit]:hover { + color: #000; + border-color: #666; +} + +.button, +.submit input, +.button-secondary { + background: #f2f2f2 url(../images/white-grad.png) repeat-x scroll left top; +} + +.button:active, +.submit input:active, +.button-secondary:active { + background: #eee url(../images/white-grad-active.png) repeat-x scroll left top; +} + +.button-primary, +.submit .button-primary, +#login form .submit input { + border-color: #298cba !important; + font-weight: bold; + color: #FFF !important; + background: #21759B url(../images/button-grad.png) repeat-x scroll left top; +} + +.button-primary:active, +#login form .submit input:active { + background: #21759b url(../images/button-grad-active.png) repeat-x scroll left top !important; +} + +.button[disabled], +.button:disabled, +.button-secondary[disabled], +.button-secondary:disabled, +a.button.disabled { + color: #ccc !important; + border-color: #ccc; +} + +.button-primary[disabled], +.button-primary:disabled { + color: #2fa0d5 !important; +} + +a:active, +a:focus { + color: #d54e21; +} + +a:hover, +#wphead #viewsite a:hover, +#adminmenu a:hover, +#adminmenu ul.wp-submenu a:hover, +#the-comment-list .comment a:hover, +#rightnow a:hover, +.subsubsub a:hover, +.subsubsub a.current:hover, +#login form .submit input:hover, +div.dashboard-widget-submit input:hover, +#media-upload a.del-link:hover, +.ui-tabs-nav a:hover { + color: #d54e21; +} + +#the-comment-list .comment-item, +#dashboard-widgets #dashboard_quick_press form p.submit { + border-color: #dfdfdf; +} + +.button-primary:hover, +#login form .submit input:hover { + border-color: #13455b !important; + color: #EAF2FA !important; +} + +#side-info-column #category-tabs .ui-tabs-selected a { + color: #333; +} + +#rightnow .rbutton { + background-color: #ebebeb; + color: #264761; +} + +.submitbox .submit { + background-color: #464646; + color: #ccc; +} + +.submitbox .submitdelete, a.delete { + color: #f00; + border-bottom-color: #f00; +} + +.submitbox .submitdelete:hover, +#media-upload a.delete:hover { + color: #fff; + background-color: #f00; + border-bottom-color: #f00; +} + +#normal-sortables .submitbox .submitdelete:hover { + color: #000; + background-color: #f00; + border-bottom-color: #f00; +} + +.tablenav .dots { + border-color: transparent; +} + +.tablenav .next, +.tablenav .prev { + border-color: transparent; + color: #21759b; +} + +.tablenav .next:hover, +.tablenav .prev:hover { + border-color: transparent; + color: #d54e21; +} + +.updated, +.login #login_error, +.login .message { + background-color: #ffffe0; + border-color: #e6db55; +} + +a.page-numbers { + border-bottom-color: #B8D3E2; +} + +div#available-widgets-filter, +ul#widget-list li.widget-list-item, +.commentlist li { + border-bottom-color: #ccc; +} + +.widefat td, +.widefat th { + border-color: #dfdfdf; +} + +.widefat th { + text-shadow: rgba(255,255,255,0.8) 0 1px 0; +} + +.widefat thead tr th, +.widefat tfoot tr th, +h3.dashboard-widget-title, +h3.dashboard-widget-title span, +h3.dashboard-widget-title small, +.find-box-head { + color: #333; + background: #dfdfdf url(../images/gray-grad.png) repeat-x scroll left top; +} + +h3.dashboard-widget-title small a { + color: #d7d7d7; +} + +h3.dashboard-widget-title small a:hover { + color: #fff; +} + +#adminmenu a, +#poststuff #edButtonPreview, +#poststuff #edButtonHTML, +#the-comment-list p.comment-author strong a, +#media-upload a.del-link, +#media-upload a.delete, +.ui-tabs-nav a, a { + color: #21759b; +} + +/* Because we don't want visited on these links */ +body.press-this .ui-tabs-selected a, +body.press-this .ui-tabs-selected a:hover { + background-color: #fff; + border-color: #c6d9e9; + border-bottom-color: #fff; + color: #d54e21; +} + +#adminmenu #awaiting-mod, +#adminmenu .update-plugins, +#sidemenu a .update-plugins, +#rightnow .reallynow, +#plugin-information .action-button { + background-color: #d54e21; + color: #fff; +} + +#adminmenu li a:hover #awaiting-mod, +#adminmenu li a:hover .update-plugins, +#sidemenu li a:hover .update-plugins { + background-color: #264761; + color: #fff; +} + +#adminmenu li.current a #awaiting-mod, +#adminmenu li.current a .update-plugins, +#adminmenu li.wp-has-current-submenu a .update-plugins, +#adminmenu li.wp-has-current-submenu a .update-plugins { + background-color: #ddd; + color: #000; + text-shadow: none; + -moz-box-shadow: rgba(0,0,0,0.2) 0px -1px 0px; + -khtml-box-shadow: rgba(0,0,0,0.2) 0px -1px 0px; + -webkit-box-shadow: rgba(0,0,0,0.2) 0px -1px 0px; + box-shadow: rgba(0,0,0,0.2) 0px -1px 0px; +} + +#adminmenu li.current a:hover #awaiting-mod, +#adminmenu li.current a:hover .update-plugins, +#adminmenu li.wp-has-current-submenu a:hover #awaiting-mod, +#adminmenu li.wp-has-current-submenu a:hover .update-plugins { + background-color: #264761; + color: #fff; +} + +div#media-upload-header { + background-color: #f9f9f9; + border-bottom-color: #dfdfdf; +} + +div#plugin-information-header { + background-color: #e4f2fd; + border-bottom-color: #c6d9e9; +} + +#currenttheme img { + border-color: #666; +} + +#current-widgets .drop-widget-here { + background-color: #ffc; +} + +#dashboard_secondary div.dashboard-widget-content ul li a { + background-color: #f9f9f9; +} + +input.readonly, textarea.readonly { + background-color: #ddd; +} + +#dragHelper h4.widget-title, +li.widget-list-control-item h4, +#dragHelper li.widget-list-control-item h4 { + background-color: #2683ae; + color: #fff; +} + +#ed_toolbar input, +#ed_reply_toolbar input { + background: #fff url("../images/fade-butt.png") repeat-x 0 -2px; +} + +#editable-post-name { + background-color: #fffbcc; +} + +#edit-slug-box strong, +.tablenav .displaying-num, +#submitted-on { + color: #777; +} + +.login #nav a { + color: #21759b !important; +} + +.login #nav a:hover { + color: #d54e21 !important; +} + +#footer, +#footer-upgrade { + background: #464646; + color: #999; +} + +#media-items { + border-color: #dfdfdf; +} + +#pass-strength-result { + background-color: #eee; + border-color: #ddd !important; +} + +#pass-strength-result.bad { + background-color: #ffb78c; + border-color: #ff853c !important; +} + +#pass-strength-result.good { + background-color: #ffec8b; + border-color: #fc0 !important; +} + +#pass-strength-result.short { + background-color: #ffa0a0; + border-color: #f04040 !important; +} + +#pass-strength-result.strong { + background-color: #c3ff88; + border-color: #8dff1c !important; +} + +.checkbox, +.side-info, +#your-profile #rich_editing { + background-color: #fff; +} + +.plugins .active { + background-color: #e7f7d3; +} + +.plugins .togl { + border-right-color: #ccc; +} + +#the-comment-list .unapproved { + background-color: #ffffe0; +} + +#the-comment-list .approve a { + color: #006505; +} + +#the-comment-list .unapprove a { + color: #d98500; +} + +#the-comment-list .delete a { + color: #bc0b0b; +} + +.plugins tr { + background-color: #fff; +} + +.metabox-holder .postbox, +#poststuff .postbox, +#titlediv, +#poststuff .postarea, +#poststuff .stuffbox, +.postbox input[type="text"], +.postbox textarea, +.stuffbox input[type="text"], +.stuffbox textarea { + border-color: #dfdfdf; +} + +.metabox-holder .postbox, +#poststuff .postbox { + background-color: #FFF; +} + +.ui-sortable .postbox h3 { + color: #464646; +} + +.ui-sortable .postbox h3:hover { + color: #000; +} + +.curtime #timestamp { + background-image: url(../images/date-button.gif); +} + +#quicktags #ed_link { + color: #00f; +} + +#rightnow .youhave { + background-color: #f0f6fb; +} + +#rightnow a { + color: #448abd; +} + +#tagchecklist span a, +#bulk-titles div a { + background: url(../images/xit.gif) no-repeat; +} + +#tagchecklist span a:hover, +#bulk-titles div a:hover { + background: url(../images/xit.gif) no-repeat -10px 0; +} + +#update-nag, .plugin-update { + background-color: #fffeeb; + border-bottom-color: #ccc; + border-top-color: #ccc; + color: #555; +} + +.login #backtoblog a { + color: #ccc; +} + +#wphead { + background-color: #464646; +} + +body.login { + border-top-color: #464646; +} + +#wphead h1 a { + color: #fff; +} + +#login form input { + color: #555; +} + +#wphead h1 a:hover { + text-decoration: underline; +} + +#user_info { + color: #999; +} + +#user_info a:link, #user_info a:visited, #footer a:link, #footer a:visited { + color: #ccc; + text-decoration: none; +} + +#user_info a:hover, #footer a:hover { + color: #fff; + text-decoration: underline !important; +} + +#user_info a:active, #footer a:active { + color: #ccc !important; +} + +div#media-upload-error, +.file-error, +abbr.required, +.widget-control-remove:hover, +.delete a:hover { + color: #f00; +} + +#media-upload a.delete { + color: #888; +} + +/* editors */ +#quicktags { + border-color: #dfdfdf; + background-color: #dfdfdf; +} + +#ed_toolbar input { + border-color: #C3C3C3; +} + +#ed_toolbar input:hover { + border-color: #aaa; + background: #ddd; +} + +#poststuff .wp_themeSkin .mceStatusbar { + border-color: #EDEDED; +} + +#poststuff #edButtonPreview, +#poststuff #edButtonHTML { + background-color: #f1f1f1; + border-color: #dfdfdf; + color: #999; +} + +#poststuff #editor-toolbar .active { + border-bottom-color: #e9e9e9; + background-color: #e9e9e9; + color: #333; +} + +/* TinyMCE */ +#post-status-info { + background-color: #EDEDED; +} + +.wp_themeSkin *, +.wp_themeSkin a:hover, +.wp_themeSkin a:link, +.wp_themeSkin a:visited, +.wp_themeSkin a:active { + color: #000; +} + +/* Containers */ +.wp_themeSkin iframe { + background: #fff; +} + +/* Layout */ +.wp_themeSkin .mceStatusbar { + color: #000; + background-color: #f5f5f5; +} + +/* Button */ +.wp_themeSkin .mceButton { + background-color: #e9e8e8; + border-color: #B2B2B2; +} + +.wp_themeSkin a.mceButtonEnabled:hover, +.wp_themeSkin a.mceButtonActive, +.wp_themeSkin a.mceButtonSelected { + background-color: #d5d5d5; + border-color: #777 !important; +} + +.wp_themeSkin .mceButtonDisabled { + border-color: #ccc !important; +} + +/* ListBox */ +.wp_themeSkin .mceListBox .mceText, +.wp_themeSkin .mceListBox .mceOpen { + border-color: #B2B2B2; + background-color: #d5d5d5; +} + +.wp_themeSkin table.mceListBoxEnabled:hover .mceOpen, +.wp_themeSkin .mceListBoxHover .mceOpen, +.wp_themeSkin .mceListBoxSelected .mceOpen, +.wp_themeSkin .mceListBoxSelected .mceText { + border-color: #777 !important; + background-color: #d5d5d5; +} + +.wp_themeSkin table.mceListBoxEnabled:hover .mceText, +.wp_themeSkin .mceListBoxHover .mceText { + border-color: #777 !important; +} + +.wp_themeSkin select.mceListBox { + border-color: #B2B2B2; + background-color: #fff; +} + +/* SplitButton */ +.wp_themeSkin .mceSplitButton a.mceAction, +.wp_themeSkin .mceSplitButton a.mceOpen { + background-color: #e8e8e8; + border-color: #B2B2B2; +} + +.wp_themeSkin .mceSplitButton a.mceOpen:hover, +.wp_themeSkin .mceSplitButtonSelected a.mceOpen, +.wp_themeSkin table.mceSplitButtonEnabled:hover a.mceAction, +.wp_themeSkin .mceSplitButton a.mceAction:hover { + background-color: #d5d5d5; + border-color: #777 !important; +} + +.wp_themeSkin .mceSplitButtonActive { + background-color: #B2B2B2; +} + +/* ColorSplitButton */ +.wp_themeSkin div.mceColorSplitMenu table { + background-color: #ebebeb; + border-color: #B2B2B2; +} + +.wp_themeSkin .mceColorSplitMenu a { + border-color: #B2B2B2; +} + +.wp_themeSkin .mceColorSplitMenu a.mceMoreColors { + border-color: #fff; +} + +.wp_themeSkin .mceColorSplitMenu a.mceMoreColors:hover { + border-color: #0A246A; + background-color: #B6BDD2; +} + +.wp_themeSkin a.mceMoreColors:hover { + border-color: #0A246A; +} + +/* Menu */ +.wp_themeSkin .mceMenu { + border-color: #ddd; +} + +.wp_themeSkin .mceMenu table { + background-color: #ebeaeb; +} + +.wp_themeSkin .mceMenu .mceText { + color: #000; +} + +.wp_themeSkin .mceMenu .mceMenuItemEnabled a:hover, +.wp_themeSkin .mceMenu .mceMenuItemActive { + background-color: #f5f5f5; +} +.wp_themeSkin td.mceMenuItemSeparator { + background-color: #aaa; +} +.wp_themeSkin .mceMenuItemTitle a { + background-color: #ccc; + border-bottom-color: #aaa; +} +.wp_themeSkin .mceMenuItemTitle span.mceText { + color: #000; +} +.wp_themeSkin .mceMenuItemDisabled .mceText { + color: #888; +} + +.wp_themeSkin tr.mceFirst td.mceToolbar { + background-color: #dfdfdf; + border-color: #dfdfdf; +} + +.wp-admin #mceModalBlocker { + background: #000; +} + +.wp-admin .clearlooks2 .mceFocus .mceTop .mceLeft { + background: #444444; + border-left: 1px solid #999; + border-top: 1px solid #999; + -moz-border-radius: 4px 0 0 0; + -webkit-border-top-left-radius: 4px; + -khtml-border-top-left-radius: 4px; + border-top-left-radius: 4px; +} + +.wp-admin .clearlooks2 .mceFocus .mceTop .mceRight { + background: #444444; + border-right: 1px solid #999; + border-top: 1px solid #999; + border-top-right-radius: 4px; + -khtml-border-top-right-radius: 4px; + -webkit-border-top-right-radius: 4px; + -moz-border-radius: 0 4px 0 0; +} + +.wp-admin .clearlooks2 .mceMiddle .mceLeft { + background: #f1f1f1; + border-left: 1px solid #999; +} + +.wp-admin .clearlooks2 .mceMiddle .mceRight { + background: #f1f1f1; + border-right: 1px solid #999; +} + +.wp-admin .clearlooks2 .mceBottom { + background: #f1f1f1; + border-bottom: 1px solid #999; +} + +.wp-admin .clearlooks2 .mceBottom .mceLeft { + background: #f1f1f1; + border-bottom: 1px solid #999; + border-left: 1px solid #999; +} + +.wp-admin .clearlooks2 .mceBottom .mceCenter { + background: #f1f1f1; + border-bottom: 1px solid #999; +} + +.wp-admin .clearlooks2 .mceBottom .mceRight { + background: #f1f1f1; + border-bottom: 1px solid #999; + border-right: 1px solid #999; +} + +.wp-admin .clearlooks2 .mceFocus .mceTop span { + color: #e5e5e5; +} +/* end TinyMCE */ + +#editorcontainer, +#post-status-info, +#titlediv #title { + border-color: #dfdfdf; +} + +#titlediv #title { + background-color: #fff; +} + +#tTips p#tTips_inside { + background-color: #ddd; + color: #333; +} + +#timestampdiv input, +#namediv input, +#tagsdiv #the-tagcloud { + border-color: #ddd; +} + +/* menu */ +#adminmenu * { + border-color: #e3e3e3; +} + +#adminmenu li.wp-menu-separator { + background: transparent url(../images/menu-arrows.gif) no-repeat scroll left 5px; +} + +.folded #adminmenu li.wp-menu-separator { + background: transparent url(../images/menu-arrows.gif) no-repeat scroll right -34px; +} + +#adminmenu li.wp-has-current-submenu.wp-menu-open .wp-menu-toggle, +#adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle { + background: transparent url(../images/menu-bits.gif) no-repeat scroll left -207px; +} + +#adminmenu .wp-has-submenu:hover .wp-menu-toggle, +#adminmenu .wp-menu-open .wp-menu-toggle { + background: transparent url(../images/menu-bits.gif) no-repeat scroll left -109px; +} + +#adminmenu a.menu-top { + background: #f1f1f1 url(../images/menu-bits.gif) repeat-x scroll left -379px; +} + +#adminmenu .wp-submenu a { + background: #FFFFFF url(../images/menu-bits.gif) no-repeat scroll 0 -310px; +} + +#adminmenu .wp-has-current-submenu ul li a { + background: none; +} + +#adminmenu .wp-has-current-submenu ul li a.current { + background: url(../images/menu-dark.gif) top left no-repeat !important; +} + +#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, +#adminmenu .menu-top .current { + background: #6d6d6d url(../images/menu-bits.gif) top left repeat-x; + border-color: #6d6d6d; + color: #fff; + text-shadow: rgba(0,0,0,0.4) 0px -1px 0px; +} + +#adminmenu li.wp-has-current-submenu .wp-submenu, +#adminmenu li.wp-has-current-submenu ul li a { + border-color: #aaa !important; +} + +#adminmenu li.wp-has-current-submenu ul li a { + background: url(../images/menu-dark.gif) bottom left no-repeat !important; +} + +#adminmenu li.wp-has-current-submenu ul { + border-bottom-color: #aaa; +} + +#adminmenu li.menu-top .current:hover { + border-color: #B5B5B5; +} + +#adminmenu .wp-submenu .current a.current { + background: transparent url(../images/menu-bits.gif) no-repeat scroll 0 -289px; +} + +#adminmenu .wp-submenu a:hover { + background-color: #EAF2FA !important; + color: #333 !important; +} + +#adminmenu .wp-submenu li.current, +#adminmenu .wp-submenu li.current a, +#adminmenu .wp-submenu li.current a:hover { + color: #333; + background-color: #f5f5f5; + background-image: none; + border-color: #e3e3e3; + text-shadow: rgba(255,255,255,1) 0px 1px 0px; +} + +#adminmenu .wp-submenu ul { + background-color: #fff; +} + +.folded #adminmenu li.menu-top, +#adminmenu .wp-submenu .wp-submenu-head { + background-color: #F1F1F1; +} + +.folded #adminmenu li.wp-has-current-submenu, +.folded #adminmenu li.menu-top.current { + background-color: #e6e6e6; +} + +#adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head { + background-color: #EAEAEA; + border-color: #aaa; +} + +#adminmenu div.wp-submenu { + background-color: transparent; +} + +/* menu icons */ +#adminmenu #menu-dashboard div.wp-menu-image { + background: transparent url("../images/menu.png") no-repeat scroll -61px -33px; +} + +#adminmenu #menu-dashboard:hover div.wp-menu-image, +#adminmenu #menu-dashboard.wp-has-current-submenu div.wp-menu-image, +#adminmenu #menu-dashboard.current div.wp-menu-image { + background: transparent url("../images/menu.png") no-repeat scroll -61px -1px; +} + +#adminmenu #menu-posts div.wp-menu-image { + background: transparent url("../images/menu.png") no-repeat scroll -272px -33px; +} + +#adminmenu #menu-posts:hover div.wp-menu-image, +#adminmenu #menu-posts.wp-has-current-submenu div.wp-menu-image { + background: transparent url("../images/menu.png") no-repeat scroll -272px -1px; +} + +#adminmenu #menu-media div.wp-menu-image { + background: transparent url("../images/menu.png") no-repeat scroll -121px -33px; +} + +#adminmenu #menu-media:hover div.wp-menu-image, +#adminmenu #menu-media.wp-has-current-submenu div.wp-menu-image { + background: transparent url("../images/menu.png") no-repeat scroll -121px -1px; +} + +#adminmenu #menu-links div.wp-menu-image { + background: transparent url("../images/menu.png") no-repeat scroll -91px -33px; +} + +#adminmenu #menu-links:hover div.wp-menu-image, +#adminmenu #menu-links.wp-has-current-submenu div.wp-menu-image { + background: transparent url("../images/menu.png") no-repeat scroll -91px -1px; +} + +#adminmenu #menu-pages div.wp-menu-image { + background: transparent url("../images/menu.png") no-repeat scroll -151px -33px; +} + +#adminmenu #menu-pages:hover div.wp-menu-image, +#adminmenu #menu-pages.wp-has-current-submenu div.wp-menu-image { + background: transparent url("../images/menu.png") no-repeat scroll -151px -1px; +} + +#adminmenu #menu-comments div.wp-menu-image { + background: transparent url("../images/menu.png") no-repeat scroll -31px -33px; +} + +#adminmenu #menu-comments:hover div.wp-menu-image, +#adminmenu #menu-comments.wp-has-current-submenu div.wp-menu-image, +#adminmenu #menu-comments.current div.wp-menu-image { + background: transparent url("../images/menu.png") no-repeat scroll -31px -1px; +} + +#adminmenu #menu-appearance div.wp-menu-image { + background: transparent url("../images/menu.png") no-repeat scroll -1px -33px; +} + +#adminmenu #menu-appearance:hover div.wp-menu-image, +#adminmenu #menu-appearance.wp-has-current-submenu div.wp-menu-image { + background: transparent url("../images/menu.png") no-repeat scroll -1px -1px; +} + +#adminmenu #menu-plugins div.wp-menu-image { + background: transparent url("../images/menu.png") no-repeat scroll -181px -33px; +} + +#adminmenu #menu-plugins:hover div.wp-menu-image, +#adminmenu #menu-plugins.wp-has-current-submenu div.wp-menu-image { + background: transparent url("../images/menu.png") no-repeat scroll -181px -1px; +} + +#adminmenu #menu-users div.wp-menu-image { + background: transparent url("../images/menu.png") no-repeat scroll -301px -33px; +} + +#adminmenu #menu-users:hover div.wp-menu-image, +#adminmenu #menu-users.wp-has-current-submenu div.wp-menu-image { + background: transparent url("../images/menu.png") no-repeat scroll -301px -1px; +} + +#adminmenu #menu-tools div.wp-menu-image { + background: transparent url("../images/menu.png") no-repeat scroll -211px -33px; +} + +#adminmenu #menu-tools:hover div.wp-menu-image, +#adminmenu #menu-tools.wp-has-current-submenu div.wp-menu-image { + background: transparent url("../images/menu.png") no-repeat scroll -211px -1px; +} + +#adminmenu #menu-settings div.wp-menu-image { + background: transparent url("../images/menu.png") no-repeat scroll -241px -33px; +} + +#adminmenu #menu-settings:hover div.wp-menu-image, +#adminmenu #menu-settings.wp-has-current-submenu div.wp-menu-image { + background: transparent url("../images/menu.png") no-repeat scroll -241px -1px; +} +/* end menu */ + + +/* Diff */ +table.diff .diff-deletedline { + background-color: #ffdddd; +} +table.diff .diff-deletedline del { + background-color: #ff9999; +} +table.diff .diff-addedline { + background-color: #ddffdd; +} +table.diff .diff-addedline ins { + background-color: #99ff99; +} + +#att-info { + background-color: #E4F2FD; +} + +/* edit image */ +#sidemenu a { + background-color: #f9f9f9; + border-color: #f9f9f9; + border-bottom-color: #dfdfdf; +} + +#sidemenu a.current { + background-color: #fff; + border-color: #dfdfdf #dfdfdf #fff; + color: #D54E21; +} + + +#screen-options-wrap, +#contextual-help-wrap { + background-color: #f1f1f1; + border-color: #dfdfdf; +} + +#screen-meta-links a.show-settings { + color: #606060; +} + +#screen-meta-links a.show-settings:hover { + color: #000; +} + +#replysubmit { + background-color: #f1f1f1; + border-top-color: #ddd; +} + +#replyerror { + border-color: #ddd; + background-color: #f9f9f9; +} + +#edithead, +#replyhead { + background-color: #f1f1f1; +} + +#ed_reply_toolbar { + background-color: #e9e9e9; +} + +/* table vim shortcuts */ +.vim-current { + background-color: #E4F2FD !important; +} + +/* Install Plugins */ +.star-average, +.star.star-rating { + background-color: #fc0; +} + +div.star.select:hover { + background-color: #d00; +} + +#plugin-information .fyi ul { + background-color: #eaf3fa; +} + +#plugin-information .fyi h2.mainheader { + background-color: #cee1ef; +} + +#plugin-information pre, +#plugin-information code { + background-color: #ededff; +} + +#plugin-information pre { + border: 1px solid #ccc; +} + +/* inline editor */ +.inline-edit-row fieldset input[type="text"], +.inline-edit-row fieldset textarea, +#bulk-titles, +#replyrow input { + border-color: #ddd; +} + +.inline-editor div.title { + background-color: #EAF3FA; +} + +.inline-editor ul.cat-checklist { + background-color: #FFFFFF; + border-color: #ddd; +} + +.inline-edit-row p.submit { + background-color: #f1f1f1; +} + +.inline-editor .categories .catshow, +.inline-editor .categories .cathide { + color: #21759b; +} + +.inline-editor .quick-edit-save { + background-color: #f1f1f1; +} + +#replyrow #ed_reply_toolbar input:hover { + border-color: #aaa; + background: #ddd; +} + +fieldset.inline-edit-col-right .inline-edit-col { + border-color: #dfdfdf; +} + +.attention { + color: #D54E21; +} + +.meta-box-sortables .postbox:hover .handlediv { + background: transparent url(../images/menu-bits.gif) no-repeat scroll left -111px; +} + +#major-publishing-actions { + background: #eaf2fa; +} + +.tablenav .tablenav-pages { + color: #555; +} + +.tablenav .tablenav-pages a { + border-color: #e3e3e3; + background: #eee url('../images/menu-bits.gif') repeat-x scroll left -379px; +} + +.tablenav .tablenav-pages a:hover { + color: #d54e21; + border-color: #d54321; +} + +.tablenav .tablenav-pages a:active { + color: #fff !important; +} + +.tablenav .tablenav-pages .current { + background: #dfdfdf; + border-color: #d3d3d3; +} + +#availablethemes, +#availablethemes td { + border-color: #ddd; +} + +#current-theme img { + border-color: #999; +} + +#TB_window #TB_title a.tb-theme-preview-link, +#TB_window #TB_title a.tb-theme-preview-link:visited { + color: #999; +} + +#TB_window #TB_title a.tb-theme-preview-link:hover, +#TB_window #TB_title a.tb-theme-preview-link:focus { + color: #ccc; +} + +.misc-pub-section { + border-bottom-color: #eee; +} + +#minor-publishing { + border-bottom-color: #ddd; +} + +#post-body .misc-pub-section { + border-right-color: #eee; +} + +.post-com-count span { + background-color: #bbb; +} + +.form-table .color-palette td { + border-color: #fff; +} + +.sortable-placeholder { + border-color: #bbb; + background-color: #f5f5f5; +} + +#post-body ul#category-tabs li.ui-tabs-selected a { + color: #333; +} + +#wp_editimgbtn, +#wp_delimgbtn, +#wp_editgallery, +#wp_delgallery { + border-color: #999; + background-color: #eee; +} + +#wp_editimgbtn:hover, +#wp_delimgbtn:hover, +#wp_editgallery:hover, +#wp_delgallery:hover { + border-color: #555; + background-color: #ccc; +} + +#favorite-first { + background: #797979 url(../images/fav.png) repeat-x left center; + border-color: #777 !important; + border-bottom-color: #666 !important; +} + +#favorite-inside { + border-color: #797979; + background-color: #797979; +} + +#favorite-toggle { + background: transparent url(../images/fav-arrow.gif) no-repeat 0 -4px; +} + +#favorite-actions a { + color: #ddd; +} + +#favorite-actions a:hover { + color: #fff; +} + +#favorite-inside a:hover { + text-decoration: underline; +} + +#favorite-actions .slide-down { + border-bottom-color: #626262; +} + +.submit input, +.button, +.button-primary, +.button-secondary, +.button-highlighted, +#postcustomstuff .submit input { + text-shadow: rgba(255,255,255,1) 0 1px 0; +} + +.button-primary, +.submit .button-primary { + text-shadow: rgba(0,0,0,0.3) 0 -1px 0; +} + +#screen-meta a.show-settings { + background-color: transparent; + text-shadow: rgba(255,255,255,0.7) 0 1px 0; +} + +#icon-edit, +#icon-post { + background: transparent url(../images/icons32.png) no-repeat -552px -5px; +} + +#icon-index { + background: transparent url(../images/icons32.png) no-repeat -137px -5px; +} + +#icon-upload { + background: transparent url(../images/icons32.png) no-repeat -251px -5px; +} + +#icon-link-manager, +#icon-link, +#icon-link-category { + background: transparent url(../images/icons32.png) no-repeat -190px -5px; +} + +#icon-edit-pages, +#icon-page { + background: transparent url(../images/icons32.png) no-repeat -312px -5px; +} + +#icon-edit-comments { + background: transparent url(../images/icons32.png) no-repeat -72px -5px; +} + +#icon-themes { + background: transparent url(../images/icons32.png) no-repeat -11px -5px; +} + +#icon-plugins { + background: transparent url(../images/icons32.png) no-repeat -370px -5px; +} + +#icon-users, +#icon-user-edit { + background: transparent url(../images/icons32.png) no-repeat -600px -5px; +} + +#icon-tools, +#icon-admin { + background: transparent url(../images/icons32.png) no-repeat -432px -5px; +} + +#icon-options-general { + background: transparent url(../images/icons32.png) no-repeat -492px -5px; +} + +.view-switch #view-switch-list { + background: transparent url(../images/list.png) no-repeat 0 0; +} + +.view-switch #view-switch-list.current { + background: transparent url(../images/list.png) no-repeat -40px 0; +} + +.view-switch #view-switch-excerpt { + background: transparent url(../images/list.png) no-repeat -20px 0; +} + +.view-switch #view-switch-excerpt.current { + background: transparent url(../images/list.png) no-repeat -60px 0; +} + +#header-logo { + background: transparent url(../images/wp-logo.gif) no-repeat scroll center center; +} diff -uNr a/blog/wp-admin/css/colors-fresh-rtl.css b/blog/wp-admin/css/colors-fresh-rtl.css --- a/blog/wp-admin/css/colors-fresh-rtl.css false +++ b/blog/wp-admin/css/colors-fresh-rtl.css daf15662f348f62177b615499380ba03879bafa8f0730a112d7d2fd7a09030b5254a63480dc1d26337f4774ce8d2bce5d32464c7f1a5e932ceb140378b630adf @@ -0,0 +1,83 @@ +.bar { + border-right-color: transparent; + border-left-color: #99d; +} + +.plugins .togl { + border-right-color: transparent; + border-left-color: #ccc; +} + +.post-com-count { + background-image: url(../images/bubble_bg-rtl.gif); +} +.tablenav .tablenav-pages a { + background: #eee url('../images/menu-bits-rtl.gif') repeat-x scroll right -379px; +} +#upload-menu li.current { + border-right-color: transparent; + border-left-color: #448abd; +} + +#adminmenu .wp-submenu .current a.current { + background: transparent url(../images/menu-bits-rtl.gif) no-repeat scroll right -289px; +} + +#adminmenu li.wp-menu-separator { + background: transparent url(../images/menu-arrows.gif) no-repeat scroll right -34px; +} + +.folded #adminmenu li.wp-menu-separator { + background: transparent url(../images/menu-arrows.gif) no-repeat scroll left 5px; +} + +#adminmenu li.wp-has-current-submenu .wp-menu-toggle, +#adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle { + background: transparent url(../images/menu-bits-rtl.gif) repeat-x scroll right -207px; +} + +#adminmenu .wp-has-current-submenu ul li a.current { + background: url(../images/menu-dark-rtl.gif) top right no-repeat !important; +} + +#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, +#adminmenu .menu-top .current { + background: url(../images/menu-bits-rtl.gif) top right repeat-x; +} + +#adminmenu li.wp-has-current-submenu ul li a { + background: url(../images/menu-dark-rtl.gif) bottom right no-repeat !important; +} + +#adminmenu li.wp-has-current-submenu.wp-menu-open .wp-menu-toggle, #adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle { + background: transparent url(../images/menu-bits-rtl.gif) no-repeat right -207px; +} + +#adminmenu .wp-has-submenu:hover .wp-menu-toggle, +#adminmenu .wp-menu-open .wp-menu-toggle { + background: transparent url(../images/menu-bits-rtl.gif) repeat-x scroll right -109px; +} + +#adminmenu a.wp-has-submenu { + background: #f1f1f1 url(../images/menu-bits-rtl.gif) repeat-x scroll right -379px; +} + +#adminmenu .wp-submenu a { + background: #FFFFFF url(../images/menu-bits-rtl.gif) no-repeat scroll right -310px; +} + +#adminmenu li.current a, +#adminmenu .wp-submenu a:hover { + background: transparent url(../images/menu-bits-rtl.gif) no-repeat scroll right -289px; +} + +#adminmenu li.wp-has-current-submenu a.wp-has-submenu { + background: #b5b5b5 url(../images/menu-bits-rtl.gif) repeat-x scroll right top; +} + +.meta-box-sortables .postbox:hover .handlediv { + background: transparent url(../images/menu-bits-rtl.gif) no-repeat scroll right -111px; +} +#favorite-toggle { + background: transparent url(../images/fav-arrow-rtl.gif) no-repeat right -4px; +} diff -uNr a/blog/wp-admin/css/dashboard.css b/blog/wp-admin/css/dashboard.css --- a/blog/wp-admin/css/dashboard.css false +++ b/blog/wp-admin/css/dashboard.css 1e7e18d122f52c7cdcdbe85614e46a070b710253bd36670d1718b1fe298247b820ba74e35e9aa3682ab1c6960a14f73341e4b979542af3fc2af5d950c3cbc3d4 @@ -0,0 +1,396 @@ +.postbox p, .postbox ul, .postbox ol, .postbox blockquote, #wp-version-message { font-size: 11px; } + +.edit-box { + display: none; +} + +h3:hover .edit-box { + display: inline; +} + +form .input-text-wrap { + border-style: solid; + border-width: 1px; + padding: 2px 3px; + border-color: #ccc; +} + +#dashboard-widgets form .input-text-wrap input { + border: 0 none; + outline: none; + margin: 0; + padding: 0; + width: 99%; + color: #333; +} + +form .textarea-wrap { + border-style: solid; + border-width: 1px; + padding: 2px; + border-color: #ccc; +} + +#dashboard-widgets form .textarea-wrap textarea { + border: 0 none; + padding: 0; + outline: none; + width: 99%; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; +} + +#dashboard-widgets .postbox form .submit { + float: none; + margin: .5em 0 0; + padding: 0; + border: none; +} + +#dashboard-widgets-wrap #dashboard-widgets .postbox form .submit input { + margin: 0; +} + +#dashboard-widgets-wrap #dashboard-widgets .postbox form .submit #publish { + min-width: 0; +} + +#dashboard-widgets-wrap .has-sidebar { + margin-right: -51%; +} + +#dashboard-widgets-wrap .inner-sidebar { + width: 49%; +} + +#dashboard-widgets-wrap .has-sidebar .has-sidebar-content { + margin-right: 51%; +} + +div.postbox div.inside { + margin: 10px; + position: relative; +} + +#dashboard-widgets a { + text-decoration: none; +} + +#dashboard-widgets h3 a { + text-decoration: underline; +} + +#dashboard-widgets h3 .postbox-title-action { + position: absolute; + right: 30px; + padding: 0; +} + +#dashboard-widgets h4 { + font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif; + font-size: 13px; + margin: 0 0 .2em; + padding: 0; +} + +/* Right Now */ + +#dashboard_right_now p.sub, +#dashboard_right_now .table, #dashboard_right_now .versions { + margin: -12px; +} + +#dashboard_right_now .inside { + font-size: 12px; +} + +#dashboard_right_now p.sub { + font-style: italic; + font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif; + padding: 5px 10px 15px; + color: #777; + font-size: 13px; +} + +#dashboard_right_now .table { + background: #f9f9f9; + border-top: #ececec 1px solid; + border-bottom: #ececec 1px solid; + margin: 0 -9px 10px; + padding: 0 10px; +} + +#dashboard_right_now table { + width: 100%; +} + +#dashboard_right_now table td { + border-top: #ececec 1px solid; + padding: 3px 0; + white-space: nowrap; +} + +#dashboard_right_now table tr.first td { + border-top: none; +} + +#dashboard_right_now td.b { + padding-right: 6px; + text-align: right; + font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif; + font-size: 14px; +} + +#dashboard_right_now td.b a { + font-size: 18px; +} + +#dashboard_right_now td.b a:hover { + color: #d54e21; +} + +#dashboard_right_now .t { + font-size: 12px; + padding-right: 12px; + padding-top: 6px; + color: #777; +} + +#dashboard_right_now td.first, +#dashboard_right_now td.last { + width: 1px; +} + +#dashboard_right_now .spam { + color: red; +} + +#dashboard_right_now .waiting { + color: orange; +} + +#dashboard_right_now .approved { + color: green; +} + +#dashboard_right_now .versions { + padding: 6px 10px 12px; +} + +#dashboard_right_now .versions .b { + font-weight: bold; +} + +#dashboard_right_now a.button { + float: right; + clear: right; + position: relative; + top: -5px; +} + +/* Recent Comments */ + +#dashboard_recent_comments h3 { + margin-bottom: 0; +} + +#dashboard_recent_comments .inside { + margin-top: 0; +} + +#dashboard_recent_comments .comment-meta .approve { + font-style: italic; + font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; + font-size: 10px; +} + +#the-comment-list { + position: relative; +} + +#the-comment-list .comment-item { + padding: 1em 10px 1em 70px; + border-top: 1px solid; +} + +#the-comment-list .pingback { + padding-left: 9px !important; +} + +#the-comment-list .comment-item, +#the-comment-list #replyrow { + margin: 0 -10px; +} + +#the-comment-list .comment-item:first-child { + border-top: none; +} + +#the-comment-list .comment-item .avatar { + float: left; + margin-left: -60px; +} + +#the-comment-list .comment-item h4 { + line-height: 1.4; + margin-top: -.2em; + font-weight: normal; + color: #999; +} + +#the-comment-list .comment-item h4 cite { + font-style: normal; + font-weight: normal; +} + +#the-comment-list .comment-item blockquote, +#the-comment-list .comment-item blockquote p { + margin: 0; + padding: 0; + display: inline; +} + +#dashboard_recent_comments #the-comment-list .trackback blockquote, +#dashboard_recent_comments #the-comment-list .pingback blockquote { + display: block; +} + +#the-comment-list .comment-item p.row-actions { + margin: 3px 0 0; + padding: 0; + font-size: 10px; +} + +/* QuickPress */ + +#dashboard_quick_press h4 { + font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; + float: left; + width: 5.5em; + clear: both; + font-weight: normal; + text-align: right; + padding-top: 5px; + font-size: 12px; +} + +#dashboard_quick_press h4 label { + margin-right: 10px; +} + +#dashboard_quick_press .input-text-wrap, +#dashboard_quick_press .textarea-wrap { + margin: 0 0 1em 5em; +} + +#dashboard_quick_press #media-buttons { + margin: 0 0 .5em 5em; + padding: 0 0 0 10px; + font-size: 11px; +} + +#dashboard_quick_press #media-buttons a { + vertical-align: bottom; +} + +#dashboard-widgets #dashboard_quick_press form p.submit { + margin-left: 4.6em; +} + +#dashboard-widgets #dashboard_quick_press form p.submit input { + float: left; +} + +#dashboard-widgets #dashboard_quick_press form p.submit #save-post { + margin: 0 1em 0 10px; +} + +#dashboard-widgets #dashboard_quick_press form p.submit #publish { + float: right; +} + +/* Recent Drafts */ +#dashboard_recent_drafts ul { + margin: 0; + padding: 0; + list-style: none; +} + +#dashboard_recent_drafts ul li { + margin-bottom: 0.6em; +} + +#dashboard_recent_drafts h4 { + font-weight: normal; +} + +#dashboard_recent_drafts h4 abbr { + font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; + font-size: 11px; + color: #999; + margin-left: 3px; +} + +#dashboard_recent_drafts p { + margin: 0; + padding: 0; +} + +/* Feeds */ + +.rss-widget ul { + margin: 0; + padding: 0; + list-style: none; +} + +a.rsswidget { + font-size: 13px; + font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif; + line-height: 1.7em; +} + +.rss-widget ul li { + line-height: 1.5em; + margin-bottom: 12px; +} + +.rss-widget span.rss-date { + margin-left: 3px; +} + +.rss-widget cite { + display: block; + text-align: right; + margin: 0 0 1em; + padding: 0; +} + +.rss-widget cite:before { + content: '\2014'; +} + +/* Plugins */ + +#dashboard_plugins h4 { + font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; +} + +#dashboard_plugins h5 { + font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif; + font-size: 13px !important; + margin: 0; + display: inline; + line-height: 1.4em; +} + +#dashboard_plugins h5 a { + font-weight: normal; + line-height: 1.7em; +} + +#dashboard_plugins p { + margin: 0 0 1.4em; + line-height: 1.4em; +} diff -uNr a/blog/wp-admin/css/dashboard-rtl.css b/blog/wp-admin/css/dashboard-rtl.css --- a/blog/wp-admin/css/dashboard-rtl.css false +++ b/blog/wp-admin/css/dashboard-rtl.css 69952cecf026a117fcc724f6acf5fa15613ab1835fe187b93769114f1c8cba15c9cce0ff6424488c91daf2fb1ca22dec2b50bb81586d67d290f5818427cc932e @@ -0,0 +1,93 @@ +#dashboard-widgets-wrap .has-sidebar { + margin-right: 0; + margin-left: -51%; +} +#dashboard-widgets-wrap .has-sidebar .has-sidebar-content { + margin-right: 0; + margin-left: 51%; +} +.view-all { + right: auto; + left: 0; +} +#dashboard_right_now p.sub, #dashboard-widgets h4, #dashboard_quick_press h4, a.rsswidget, #dashboard_plugins h4, #dashboard_plugins h5, #dashboard_recent_comments .comment-meta .approve { + font-family: Tahoma, Arial; +} +#dashboard_right_now td.b { + padding-right: 0; + padding-left: 6px; + text-align: left; + font-family: Tahoma, Arial; +} +#dashboard_right_now .t { + padding-right: 0; + padding-left: 12px; +} +#dashboard_right_now .versions a { + font-family: Tahoma, Arial; +} +#dashboard_right_now a.button { + float: left; + clear: left; +} +#dashboard-widgets h3 .postbox-title-action { + right: auto; + left: 30px; +} +#the-comment-list .pingback { + padding-left: 0 !important; + padding-right: 9px !important; +} +/* Recent Comments */ +#the-comment-list .comment-item { + padding: 1em 70px 1em 10px; +} +#the-comment-list .comment-item .avatar { + float: right; + margin-left: 0; + margin-right: -60px; +} +/* Feeds */ +.rss-widget cite { + text-align: left; +} +.rss-widget span.rss-date { + font-family: Tahoma, Arial; + margin-left: 0; + margin-right: 3px; +} +/* QuickPress */ +#dashboard_quick_press h4 { + float: right; + text-align: left; +} +#dashboard_quick_press h4 label { + margin-right: 0; + margin-left: 10px; +} +#dashboard_quick_press .input-text-wrap, #dashboard_quick_press .textarea-wrap { + margin: 0 5em 1em 0; +} +#dashboard_quick_press #media-buttons { + margin: 0 5em .5em 0; + padding: 0 10px 0 0; +} +#dashboard-widgets #dashboard_quick_press form p.submit { + margin-left: 0; + margin-right: 4.6em; +} +#dashboard-widgets #dashboard_quick_press form p.submit input { + float: right; +} +#dashboard-widgets #dashboard_quick_press form p.submit #save-post { + margin: 0 10px 0 1em; +} +#dashboard-widgets #dashboard_quick_press form p.submit #publish { + float: left; +} +/* Recent Drafts */ +#dashboard_recent_drafts h4 abbr { + font-family: Tahoma, Arial; + margin-left:0; + margin-right: 3px; +} diff -uNr a/blog/wp-admin/css/farbtastic.css b/blog/wp-admin/css/farbtastic.css --- a/blog/wp-admin/css/farbtastic.css false +++ b/blog/wp-admin/css/farbtastic.css c650f074acba17ae00685f3fcde214001b7b2c55f6508e7475e0a5d7e9711114a83340ff9f4d2a18a91bc024e21e9038e058ab8f73af0937499079ec8b62b7aa @@ -0,0 +1,32 @@ +.farbtastic { + position: relative; +} +.farbtastic * { + position: absolute; + cursor: crosshair; +} +.farbtastic, .farbtastic .wheel { + width: 195px; + height: 195px; +} +.farbtastic .color, .farbtastic .overlay { + top: 47px; + left: 47px; + width: 101px; + height: 101px; +} +.farbtastic .wheel { + background: url(../images/wheel.png) no-repeat; + width: 195px; + height: 195px; +} +.farbtastic .overlay { + background: url(../images/mask.png) no-repeat; +} +.farbtastic .marker { + width: 17px; + height: 17px; + margin: -8px 0 0 -8px; + overflow: hidden; + background: url(../images/marker.png) no-repeat; +} \ No newline at end of file diff -uNr a/blog/wp-admin/css/farbtastic-rtl.css b/blog/wp-admin/css/farbtastic-rtl.css --- a/blog/wp-admin/css/farbtastic-rtl.css false +++ b/blog/wp-admin/css/farbtastic-rtl.css 0126a93c0aef6a42faa2447441a8a242c95129fc9160a53410258d53904edd94553357dfd025ed7970505ddb98c56432405d87ef4c915fdb588808fa3258e44b @@ -0,0 +1,7 @@ +.farbtastic .color, .farbtastic .overlay { + left: 0; + right: 47px; +} +.farbtastic .marker { + margin: -8px -8px 0 0; +} diff -uNr a/blog/wp-admin/css/global.css b/blog/wp-admin/css/global.css --- a/blog/wp-admin/css/global.css false +++ b/blog/wp-admin/css/global.css a05fa08b1bf4980923cf498ce89b1aa0ba5078a07686cbef88d340f068598553de28e221672ba7d7d2ca4cb3e4dcb9acaebfbc48f0486fdfbaaafd984afb9f1f @@ -0,0 +1,455 @@ +/* http://meyerweb.com/eric/tools/css/reset/ */ +/* v1.0 | 20080212 */ + +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, font, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td { + margin: 0; + padding: 0; + border: 0; + outline: 0; +/* font-size: 100%; + vertical-align: baseline; */ + background: transparent; +} +body { + line-height: 1; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, +q:before, q:after { + content: ''; + content: none; +} + +/* remember to define focus styles! */ +/* +:focus { + outline: 0; +} +*/ +/* remember to highlight inserts somehow! */ +ins { + text-decoration: none; +} +del { + text-decoration: line-through; +} + +/* tables still need 'cellspacing="0"' in the markup */ +/* +table { + border-collapse: collapse; + border-spacing: 0; +} +*/ +/* end reset css */ + + +/* 2 column liquid layout */ +#wpwrap { + height: auto; + min-height: 100%; + width: 100%; +} + +#wpcontent { + height: 100%; + padding-bottom: 50px; +} + +#wpbody { + clear: both; + margin-left: 175px; +} + +.folded #wpbody { + margin-left: 60px; +} + +#wpbody-content { + float: left; + width: 100%; +} + +#adminmenu { + float: left; + clear: left; + width: 145px; + margin-top: 15px; + margin-right: 5px; + margin-bottom: 15px; + margin-left: -160px; + position: relative; + padding: 0; + list-style: none; +} + +.folded #adminmenu { + margin-left: -45px; +} + +.folded #adminmenu, +.folded #adminmenu li.menu-top { + width: 28px; +} + +#footer { + clear: both; + position: relative; + width: 100%; +} + +/* inner 2 column liquid layout */ + +.inner-sidebar { + float: right; + clear: right; + width: 280px; + position: relative; +} + +.has-sidebar { + float: left; + clear: left; + width: 100%; + margin-right: -340px; +} + +.has-sidebar .has-sidebar-content { + margin-right: 305px; +} + +/* 2 columns main area */ + +#col-container { + overflow: hidden; + padding: 0; + margin: 0; +} + +#col-left { + padding: 0; + margin: 0; + overflow: hidden; + width: 39%; +} + +#col-right { + float: right; + clear: right; + overflow: hidden; + padding: 0; + margin: 0; + width: 59%; +} + +/* utility classes */ +.alignleft { + float: left; +} + +.alignright { + float: right; +} + +.textleft { + text-align: left; +} + +.textright { + text-align: right; +} + +.clear { + clear: both; +} + +.hidden, +.closed .inside, +.hide-if-no-js { + display: none; +} + +/* include margin and padding in the width calculation of input and textarea */ +input[type="text"], +textarea { + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + -ms-box-sizing: border-box; /* ie8 only */ + box-sizing: border-box; +} + +input[type="checkbox"], +input[type="radio"] { + vertical-align: text-top; +} + +/* styles for use by people extending the WordPress interface */ +html, +body { + height: 100%; +} + +body, +td { + font: 13px "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; +} + +p { + margin: 1em 0; +} + +blockquote { + margin: 1em; +} + +label { + cursor: pointer; +} + +li, +dd { + margin-bottom: 6px; +} + +p, +li, +dl, +dd, +dt { + line-height: 140%; +} + +textarea, +input, +select { + font: 13px/19px "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; + margin: 1px; + padding: 3px; +} + +h1 { + display: block; + font-size: 2em; + font-weight: bold; + margin: .67em 0; +} + +h2 { + display: block; + font-size: 1.5em; + font-weight: bold; + margin: .83em 0; +} + +h3 { + display: block; + font-size: 1.17em; + font-weight: bold; + margin: 1em 0; +} + +h4 { + display: block; + font-weight: bold; + margin: 1.33em 0; +} + +h5 { + display: block; + font-size: 0.83em; + font-weight: bold; + margin: 1.67em 0; +} + +h6 { + display: block; + font-size: 0.67em; + font-weight: bold; + margin: 2.33em 0; +} + +.subsubsub { + list-style: none; + margin: 8px 0 5px; + padding: 0; + white-space: nowrap; + font-size: 11px; + float: left; +} + +.subsubsub a { + line-height: 2; + padding: .2em; + text-decoration: none; +} + +.subsubsub a .count, .subsubsub a.current .count { + color: #999; + font-weight: normal; +} + +.subsubsub a.current { + font-weight: bold; + background: none; + border: none; +} + +.subsubsub li { + display: inline; + margin: 0; + padding: 0; +} + +.widefat { + border-width: 1px; + border-style: solid; + border-collapse: separate; + border-spacing: 0; + width: 100%; + clear: both; + margin: 0; + -moz-border-radius: 4px; + -khtml-border-radius: 4px; + -webkit-border-radius: 4px; + border-radius: 4px; +} + +.widefat * { + word-wrap: break-word; +} + +.widefat a { + text-decoration: none; +} + +.widefat td, +.widefat th { + border-bottom-width: 1px; + border-bottom-style: solid; + font-size: 11px; + vertical-align: text-top; +} + +.widefat td { + padding: 7px 7px 5px; + vertical-align: top; +} + +.widefat thead tr th:first { + -moz-border-radius-topleft: 4px; + -webkit-border-top-left-radius: 4px; + -khtml-border-top-left-radius: 4px; + border-top-left-radius: 4px; +} + +.widefat thead tr th:last { + -moz-border-radius-topright: 4px; + -webkit-border-top-right-radius: 4px; + -khtml-border-top-right-radius: 4px; + border-top-right-radius: 4px; +} + +.widefat tfoot tr th:first { + -moz-border-radius-bottomleft: 4px; + -webkit-border-bottom-left-radius: 4px; + -khtml-border-bottom-left-radius: 4px; + border-bottom-left-radius: 4px; +} + +.widefat tfoot tr th:last { + -moz-border-radius-bottomright: 4px; + -webkit-border-bottom-right-radius: 4px; + -khtml-border-bottom-right-radius: 4px; + border-bottom-right-radius: 4px; +} + +.widefat td p { + font-size: 11px; +} + +.widefat th { + padding: 7px 7px 8px; + text-align: left; + line-height: 1.3em; +} + +.widefat th input { + margin: 0 0 0 8px; + padding: 0; + vertical-align: text-top; +} + +.widefat .check-column { + width: 2.2em; + padding: 0; + +} + +.widefat tbody th.check-column { + padding: 7px 0 22px; +} + +.widefat .num, +.column-comments, +.column-links, +.column-posts, +.column-parent { + text-align: center; +} + +.widefat th#comments { + vertical-align: middle; +} + +.wrap { + margin: 0 15px 0 5px; +} + +.updated, +.error { + border-width: 1px; + border-style: solid; + padding: 0 0.6em; + margin: 5px 15px 2px; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; +} + +.updated p, +.error p { + margin: 0.5em 0; + line-height: 1; + padding: 2px; +} + +.wrap .updated, +.wrap .error { + margin: 5px 0; +} + +.wrap h2 { + font: italic normal normal 24px/29px Georgia, "Times New Roman", "Bitstream Charter", Times, serif; + margin: 0; + padding: 14px 15px 3px 0; + line-height: 35px; + text-shadow: rgba(255,255,255,1) 0px 1px 0px; +} + +.wrap h2.long-header { + padding-right: 0; +} diff -uNr a/blog/wp-admin/css/global-rtl.css b/blog/wp-admin/css/global-rtl.css --- a/blog/wp-admin/css/global-rtl.css false +++ b/blog/wp-admin/css/global-rtl.css 5c192455b2bf46b084f7376171db9bc28f37c60a1563f7a9229572ad0852e161de61e2f0c7ed6c99182a60a1a341860690f0fe7044f5493ac6b2fd5ff1416055 @@ -0,0 +1,74 @@ +/* 2 column liquid layout */ +#adminmenu { + float: right; + clear: right; + margin-right:-160px; + margin-left: 5px; +} +div.folded #adminmenu { + margin-left: 0; + margin-right: -45px; +} +/* inner 2 column liquid layout */ +.inner-sidebar { + float: left; + clear: left; +} +.has-sidebar { + float: right; + clear: right; + margin-right: 0; + margin-left: -340px; +} +.has-sidebar .has-sidebar-content { + margin-right: 0; + margin-left: 305px; +} +#wpbody { + margin-left:0; + margin-right: 175px; +} +.folded #wpbody { + margin-left: 0; + margin-right: 60px; +} +#wpbody-content { + float: right; +} +/* 2 columns main area */ +#col-right { + float: left; + clear: left; +} +.wrap { + margin: 0 5px 0 15px; +} +/* styles for use by people extending the WordPress interface */ +body, td, textarea, input, select { + font-family: Tahoma, arial; +} +.alignleft { + float: right; +} +.alignright { + float: left; +} +.subsubsub { + float: right; +} +.widefat th { + text-align: right; +} +.widefat th input { + margin: 0 8px 0 0; +} +.wrap h2 { + font-family: arial; + padding: 14px 0 3px 15px; +} +.wrap h2.long-header { + padding-left: 0; +} +.updated, .error { + clear: both; +} diff -uNr a/blog/wp-admin/css/ie.css b/blog/wp-admin/css/ie.css --- a/blog/wp-admin/css/ie.css false +++ b/blog/wp-admin/css/ie.css 25c60eadd83921474323fe6b6fa837464200fcd3951e66dbe7b18b84ffe9a6ded3e0a41ad77e05a3bca0750f2a896d370a5e73fc233134167b285dc67d4db311 @@ -0,0 +1,344 @@ +/* Fixes for IE bugs */ + +input.button, +input.button-secondary, +input.button-highlighted { + padding: 0; +} + +#minor-publishing-actions input, +#major-publishing-actions input, +#minor-publishing-actions .preview { + min-width: auto; + padding-left: 0; + padding-right: 0; +} + +#wpbody-content .postbox { + border: 1px solid #dfdfdf; +} + +#wpbody-content .postbox h3 { + margin-bottom: -1px; +} + +* html #side-info-column { + height: auto; +} + +* html #wpbody-content #screen-options-link-wrap { + display: inline-block; + width: 150px; + text-align: center; +} + +* html #wpbody-content #contextual-help-link-wrap { + display: inline-block; + width: 100px; + text-align: center; +} + +/* +* html body.minwidth { + _width: expression(document.documentElement.clientWidth < 810 ? "808px" : "99.9%"); +} + +* html #wpbody { + _width: expression(document.documentElement.clientWidth > 982 ? "980px" : "99.9%"); +} +*/ + +* html #adminmenu { + margin-left: -80px; +} + +* html div.folded #adminmenu { + margin-left: -22px; +} + +* html #wpcontent #adminmenu li.menu-top { + display: inline; + padding: 0; + margin: 0; +} + +#wpcontent.folded #adminmenu li.menu-top { + display: block; +} + +ul#adminmenu { + z-index: 99; +} + +#adminmenu li.menu-top a.menu-top { + min-width: auto; + width: auto; +} + +#wpcontent #adminmenu li.wp-has-current-submenu a.wp-has-submenu { + font-style: normal; +} + +* html #wpcontent #adminmenu .wp-menu-open .wp-menu-toggle { + background: none; +} + +* html #wpcontent #adminmenu .wp-has-submenu .wp-menu-toggle { + background: url(../images/menu-bits.gif) no-repeat scroll left -109px; +} + +* html #wpcontent #adminmenu li.wp-has-current-submenu .wp-menu-toggle { + background: url(../images/menu-bits.gif) no-repeat scroll left -206px; +} + +* html #adminmenu div.wp-menu-image { + height: 29px; +} + +#wpcontent #adminmenu .wp-submenu li { + padding: 0; +} + +#adminmenu, +.wp-submenu, +.wp-submenu li, +.wp-menu-toggle { + zoom: 100%; +} + +#wpcontent.folded #adminmenu li.wp-menu-separator { + width: 28px; +} + +#wpcontent #adminmenu .wp-submenu li.wp-submenu-head { + padding: 3px 4px 4px 10px; + zoom: 100%; +} + +#wpcontent.folded #adminmenu .menu-top { + height: 30px; +} + +.folded #adminmenu .wp-submenu { + margin: -1px 0 0 0; +} + +#template, +#template div, +#editcat, +#addcat { + zoom: 100%; +} + +.submitbox { + margin-top: 10px; +} + +/* Inline Editor */ +#wpbody-content .quick-edit-row-post .inline-edit-col-left { + width: 39%; +} + +#wpbody-content .inline-edit-row-post .inline-edit-col-center { + width: 19%; +} + +#wpbody-content .quick-edit-row-page .inline-edit-col-left { + width: 49%; +} + +#wpbody-content .bulk-edit-row .inline-edit-col-left { + width: 29%; +} + +.inline-edit-row p.submit { + zoom: 100%; +} + +.inline-edit-row fieldset label span.title { + display: block; + float: left; + width: 5em; +} + +.inline-edit-row fieldset label span.input-text-wrap { + margin-left: 0; + zoom: 100%; +} + +#wpbody-content .inline-edit-row fieldset label span.input-text-wrap input { + line-height: 130%; +} + +#wpbody-content .inline-edit-row .input-text-wrap input { + width: 95%; +} + +#wpbody-content .inline-edit-row .input-text-wrap input.inline-edit-password-input { + width: 8em; +} +/* end Inline Editor */ + +* html .row-actions { + visibility: visible; +} + +#dashboard-widgets h3 a { + height: 20px; + line-height: 20px; +} + +#the-comment-list .comment-item, +ul#widget-list li.widget-list-item { + zoom: 100%; +} + +#wphead-info { + float: right; +} + +#titlediv #title { + width: 98%; +} + +a.button { + line-height: 1.4em; + margin: 1px; +} + +* html div.widget-liquid-left-holder, +* html div.widget-liquid-right { + display: block; + position: relative; +} + +#screen-options-wrap { + overflow: hidden; +} + +#favorite-actions { + z-index: 12; +} + +#favorite-inside, +#favorite-inside a, +.favorite-action { + zoom: 100%; +} + +#post-status-info, +#wpwrap, +#wpcontent, +#post, +#wrap, +#postdivrich, +#postdiv, +#poststuff, +.metabox-holder, +#titlediv, +#post-body, +#editorcontainer, +.tablenav, +.widget-control-list, +li.widget-list-control-item, +#dragHelper, +li.widget-list-control-item h4, +.widget-sortable, +.widget-control-actions, +#tagchecklist, +#col-container, +#col-left, +#col-right { + display: block; + zoom: 100%; +} + +p.search-box { + position: static; + float: right; + margin: -3px 0 4px; +} + +* html #editorcontainer { + padding: 0; +} + +#editorcontainer #content { + overflow: auto; + margin: auto; + width: 98%; +} + +form#template div { + width: 100%; +} + +#ed_toolbar input { + overflow: visible; + padding: 0 4px; +} + +#poststuff h2 { + font-size: 1.6em; +} + +* html #poststuff h2 { + margin-left: 0; +} + +#bh { + margin: 7px 10px 0 0; + float: right; +} + +/* without this dashboard widgets appear in one column for some screen widths */ +div#dashboard-widgets { + padding-right: 1px; +} + +#tagchecklist span, #tagchecklist span a { + display: inline-block; + display: block; +} + +#tagchecklist span a { + margin: 4px 0 0 -9px; +} + +.tablenav .button-secondary, .nav .button-secondary { + padding: 0 1px; + vertical-align: middle; +} + +.tablenav select { + font-size: 13px; + display: inline-block; + vertical-align: top; + margin-top: 2px; +} + +table.ie-fixed { + table-layout: fixed; +} + +.widefat tr, .widefat th { + margin-bottom: 0; + border-spacing: 0; +} + +.widefat th input { + margin: 0 0 0 5px; +} + +.widefat .check-column { + padding: 6px 0 2px; +} + +.widefat tbody th.check-column { + padding: 4px 0 22px; +} + +.tablenav a.button-secondary { + display: inline-block; + padding: 2px 5px; +} diff -uNr a/blog/wp-admin/css/ie-rtl.css b/blog/wp-admin/css/ie-rtl.css --- a/blog/wp-admin/css/ie-rtl.css false +++ b/blog/wp-admin/css/ie-rtl.css a53746ecdfa1ef93844271bf21a852c7065b98d3086d9ce3fb91dd1fe711301dcd0b59a962594ffa6c6d641f8f1f014724a05387ad795eb60f84fc376ee067db @@ -0,0 +1,91 @@ +* html #wpcontent #adminmenu .wp-has-submenu .wp-menu-toggle { + background: url(../images/menu-bits-rtl.gif) no-repeat scroll right -109px; +} + +* html #wpcontent #adminmenu li.wp-has-current-submenu .wp-menu-toggle { + background: url(../images/menu-bits-rtl.gif) no-repeat scroll right -206px; +} +* html #adminmenu { + margin-left:0; + margin-right: -80px; +} +* html div.folded #adminmenu { + margin-left: 0; + margin-right: -22px; +} +#wpcontent #adminmenu .wp-submenu li.wp-submenu-head { + padding: 3px 10px 4px 4px; +} +.inline-edit-row fieldset label span.title { + float: right; +} +.inline-edit-row fieldset label span.input-text-wrap { + margin-right: 0; +} +p.search-box { + float: left; +} +* html #poststuff h2 { + margin-right: 0; +} +#bh { + margin: 7px 10px 0 0; + float: left; +} +#user_info + div#favorite-actions { + right: auto; + left: 15px; +} +#wphead-info { + float: left; +} +/* without this dashboard widgets appear in one column for some screen widths */ +div#dashboard-widgets { + padding-right: 0; + padding-left: 1px; +} +#tagchecklist span a { + margin: 4px -9px 0 0; +} +.widefat th input { + margin: 0 5px 0 0; +} +/* ---------- add by navid */ +#TB_window { + width: 670px; + position: absolute; + top: 50%; + left: 50%; + margin-right: 335px !important; +} +#dashboard_plugins { + direction: ltr; +} +#dashboard_plugins h3.hndle { + direction: rtl; +} +#dashboard_incoming_links ul li, +#dashboard_secondary ul li, +#dashboard_primary ul li, +p.row-actions { + width: 100%; +} +#favorite-inside { + position: absolute; + right:0; +} +#post-status-info { + height: 25px; +} +#screen-meta { + position: static; +} +p.submit { /* quick edit and reply in edit-comments.php */ + height:22px; +} +.inner-sidebar { /* fix edit single comment */ + position: static; +} +form#widgets-filter { /* fix widget page */ + position: static; +} diff -uNr a/blog/wp-admin/css/install.css b/blog/wp-admin/css/install.css --- a/blog/wp-admin/css/install.css false +++ b/blog/wp-admin/css/install.css 69fc99ee317a3d318da24853db4f5bd3c988b0072f8eb06ee8703bd382d25f982377b267c857c5b1ae61ff090ba10039869b45261201877615c09f98ff2e3389 @@ -0,0 +1,133 @@ +html { background: #f7f7f7; } + +body { + background: #fff; + color: #333; + font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; + margin: 2em auto 0 auto; + width: 700px; + padding: 1em 2em; + -moz-border-radius: 11px; + -khtml-border-radius: 11px; + -webkit-border-radius: 11px; + border-radius: 11px; + border: 1px solid #dfdfdf; +} + +a { color: #2583ad; text-decoration: none; } + +a:hover { color: #d54e21; } + +h1 { + border-bottom: 1px solid #dadada; + clear: both; + color: #666; + font: 24px Georgia, "Times New Roman", Times, serif; + margin: 5px 0 0 -4px; + padding: 0; + padding-bottom: 7px; +} + +h2 { font-size: 16px; } + +p, li { + padding-bottom: 2px; + font-size: 12px; + line-height: 18px; +} + +code { font-size: 13px; } + +ul, ol { padding: 5px 5px 5px 22px; } + +#logo { margin: 6px 0 14px 0; border-bottom: none;} + +.step { + margin: 20px 0 15px; +} + +.step, th { text-align: left; padding: 0; } + +.submit input, .button, .button-secondary { + font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; + text-decoration: none; + font-size: 14px !important; + line-height: 16px; + padding: 6px 12px; + cursor: pointer; + border: 1px solid #bbb; + color: #464646; + -moz-border-radius: 15px; + -khtml-border-radius: 15px; + -webkit-border-radius: 15px; + border-radius: 15px; + -moz-box-sizing: content-box; + -webkit-box-sizing: content-box; + -khtml-box-sizing: content-box; + box-sizing: content-box; +} + +.button:hover, .button-secondary:hover, .submit input:hover { + color: #000; + border-color: #666; +} + +.button, .submit input, .button-secondary { + background: #f2f2f2 url(../images/white-grad.png) repeat-x scroll left top; +} + +.button:active, .submit input:active, .button-secondary:active { + background: #eee url(../images/white-grad-active.png) repeat-x scroll left top; +} + +.form-table { + border-collapse: collapse; + margin-top: 1em; + width: 100%; +} + +.form-table td { + margin-bottom: 9px; + padding: 10px; + border-bottom: 8px solid #fff; + font-size: 12px; +} + +.form-table th { + font-size: 13px; + text-align: left; + padding: 16px 10px 10px 10px; + border-bottom: 8px solid #fff; + width: 110px; + vertical-align: top; +} + +.form-table tr { + background: #f3f3f3; +} + +.form-table code { + line-height: 18px; + font-size: 18px; +} + +.form-table p { + margin: 4px 0 0 0; + font-size: 11px; +} + +.form-table input { + line-height: 20px; + font-size: 15px; + padding: 2px; +} + +#error-page { margin-top: 50px; } + +#error-page p { + font-size: 12px; + line-height: 18px; + margin: 25px 0 20px; +} + +#error-page code { font-family: Consolas, Monaco, Courier, monospace; } diff -uNr a/blog/wp-admin/css/install-rtl.css b/blog/wp-admin/css/install-rtl.css --- a/blog/wp-admin/css/install-rtl.css false +++ b/blog/wp-admin/css/install-rtl.css d7582445f11cc9554f11ef2ad6d919baf7dd5c365e98fa65b87dcf43c49a7954b13d2a258d2271ce4baeb30cba67e81c67bf23372c8d48f8b7aab16c2bd00832 @@ -0,0 +1,16 @@ +body { + font-family: Tahoma, arial; +} +h1 { + font-family: arial; + margin: 5px -4px 0 0; +} +ul, ol { padding: 5px 22px 5px 5px; } +.step, th { text-align: right; } +.submit input, .button, .button-secondary { + font-family: Tahoma, arial; + margin-right:0; +} +.form-table th { + text-align: right; +} diff -uNr a/blog/wp-admin/css/login.css b/blog/wp-admin/css/login.css --- a/blog/wp-admin/css/login.css false +++ b/blog/wp-admin/css/login.css 3936eb467f3f625a2618c8970147b4446a8f5b26045bd0d44691715c4029490e24e3543ec6b83b9ddf09900e8fb1998bce5c7b0ea6bd4d8cbb727dbe9d9936c4 @@ -0,0 +1,107 @@ +* { margin: 0; padding: 0; } + +body { + border-top-width: 30px; + border-top-style: solid; + font: 11px "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; +} + +form { + margin-left: 8px; + padding: 16px 16px 40px 16px; + font-weight: normal; + -moz-border-radius: 11px; + -khtml-border-radius: 11px; + -webkit-border-radius: 11px; + border-radius: 5px; + background: #fff; + border: 1px solid #e5e5e5; + -moz-box-shadow: rgba(200,200,200,1) 0 4px 18px; + -webkit-box-shadow: rgba(200,200,200,1) 0 4px 18px; + -khtml-box-shadow: rgba(200,200,200,1) 0 4px 18px; + box-shadow: rgba(200,200,200,1) 0 4px 18px; +} + +form .forgetmenot { font-weight: normal; float: left; margin-bottom: 0; } + +#login form .submit input { + font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; + padding: 3px 10px; + border: none; + font-size: 12px; + border-width: 1px; + border-style: solid; + -moz-border-radius: 11px; + -khtml-border-radius: 11px; + -webkit-border-radius: 11px; + border-radius: 11px; + cursor: pointer; + text-decoration: none; + margin-top: -3px; + text-shadow: rgba(0,0,0,0.3) 0 -1px 0; +} + +#login form p { + margin-bottom: 0; +} + +label { + color: #777; + font-size: 13px; +} + +form .forgetmenot label { + font-size: 11px; + line-height: 19px; +} + +form .submit { float: right; } + +form p { margin-bottom: 24px; } + +h1 a { + background: url(../images/logo-login.gif) no-repeat top center; + width: 326px; + height: 67px; + text-indent: -9999px; + overflow: hidden; + padding-bottom: 15px; + display: block; +} + +#nav { + text-shadow: rgba(255,255,255,1) 0 1px 0; +} + +#backtoblog a { + position: absolute; + top: 7px; + left: 15px; + text-decoration: none; +} + +#login { width: 320px; margin: 7em auto; } + +#login_error, .message { + margin: 0 0 16px 8px; + border-width: 1px; + border-style: solid; + padding: 12px; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; +} + +#nav { margin: 0 0 0 8px; padding: 16px; } + +#user_pass, #user_login, #user_email { + font-size: 24px; + width: 97%; + padding: 3px; + margin-top: 2px; + margin-right: 6px; + margin-bottom: 16px; + border: 1px solid #e5e5e5; + background: #fbfbfb; +} diff -uNr a/blog/wp-admin/css/login-rtl.css b/blog/wp-admin/css/login-rtl.css --- a/blog/wp-admin/css/login-rtl.css false +++ b/blog/wp-admin/css/login-rtl.css 3846117c22e8e71befbe0cc750924b3c14890414d1420c8a73782a0baf28316a420b11dceb4d1d78e3bdf6257ed4f38f77a3ca8b1d95fbd07b38e915f0798ed3 @@ -0,0 +1,30 @@ +body { + font-family: Tahoma, arial; +} +form { + margin-right: 8px; + margin-left: 0; +} +form .forgetmenot { + float: right; +} +#login form .submit input { + font-family: Tahoma, arial; +} +form .submit { float: left; } +#backtoblog a { + left: auto; + right: 15px; +} +#login_error, .message { + margin: 0 8px 16px 0; +} +#nav { margin: 0 8px 0 0; } +#user_pass, #user_login, #user_email { + margin-left: 6px; + margin-right: 0; + direction:ltr; +} +h1 a { + text-decoration: none; +} diff -uNr a/blog/wp-admin/css/media.css b/blog/wp-admin/css/media.css --- a/blog/wp-admin/css/media.css false +++ b/blog/wp-admin/css/media.css bfe3c98fbd2ce4b1a06f2a29b76b65b09174ff30d5c2d55a4f1a95662fb48b170fe39e08e5af62d4bea623716283a10b91d0d9992618a488b1369fee4a47eee4 @@ -0,0 +1,426 @@ +div#media-upload-header { + margin: 0; + padding: 0 5px; + font-weight: bold; + position: relative; + border-bottom-width: 1px; + border-bottom-style: solid; + height: 2.5em; +} + +body#media-upload ul#sidemenu { + font-weight: normal; + margin: 0 5px; + position: absolute; + left: 0px; + bottom: -1px; +} + +div#media-upload-error { + margin: 1em; + font-weight: bold; +} + +form { + margin: 1em; +} + +#search-filter { + text-align: right; +} + +.media-upload-form label, +.media-upload-form legend { + display: block; + font-weight: bold; + font-size: 13px; + margin-bottom: 0.5em; + margin: 0 0 0.5em 0; +} + +th { + position: relative; +} + +.media-upload-form label.form-help, td.help { + font-family: "Lucida Grande", "Bitstream Vera Sans", Verdana, Arial, sans-serif; + font-style: italic; + font-weight: normal; +} + +.media-upload-form p.help { + margin: 0; + padding: 0; +} + +.media-upload-form fieldset { + width: 100%; + border: none; + text-align: justify; + margin: 0 0 1em 0; + padding: 0; +} + +/* specific to the image upload form */ +.align .field label { + display: inline; + padding: 0 0 0 28px; + margin: 0 1em 0 0; +} + +.image-align-none-label { + background: url(../images/align-none.png) no-repeat center left; +} + +.image-align-left-label { + background: url(../images/align-left.png) no-repeat center left; +} + +.image-align-center-label { + background: url(../images/align-center.png) no-repeat center left; +} + +.image-align-right-label { + background: url(../images/align-right.png) no-repeat center left; +} + +tr.image-size td { + width: 460px; +} + +tr.image-size div.image-size-item { + float: left; + width: 25%; + margin: 0; +} + +tr.image-size label { + display: inline; + margin: 0 0 0 1em; +} + +.pinkynail { + max-width: 40px; + max-height: 40px; +} + +.filename.original { + float: left; +} + +.crunching { + display: block; + line-height: 32px; + text-align: right; + margin-right: 5px; +} + +button.dismiss { + position: absolute; + top: 7px; + right: 5px; + z-index: 4; + width: 8em; +} + +.file-error { + float: left; + font-weight: bold; + padding: 10px; +} + +.progress { + position: absolute; + top: 0; + left: 0; + width: 623px; + height: 36px; +} + +.bar { + width: 0; + height: 100%; + border-right-width: 3px; + border-right-style: solid; +} + +#library-form .progress, +#gallery-form .progress, +#flash-upload-ui, +.insert-gallery, +.describe.startopen, +.describe.startclosed { + display: none; +} + +.media-item .thumbnail { + max-width: 128px; + max-height: 128px; +} + +.media-item .pinkynail { + float: left; + margin: 2px; + height: 32px; + max-width: 40px; +} + +thead.media-item-info tr { + background-color: transparent; +} + +thead.media-item-info th, +thead.media-item-info td { + border: none; + margin: 0; +} + +.form-table thead.media-item-info { + border: 8px solid #fff; +} + +abbr.required { + text-decoration: none; + border: none; +} + +.describe label { + display: inline; +} + +.describe td { + vertical-align: middle; + padding: 0 5px 0 0; +} + +.describe td.A1 { + width: 132px; +} + +.describe input[type="text"], +.describe textarea { + width: 460px; + border-width: 1px; + border-style: solid; +} + +.describe-toggle-on, +.describe-toggle-off { + display: block; + line-height: 36px; + float: right; + margin-right: 20px; +} + +.describe-toggle-off { + display: none; +} + +.hidden { + height: 0; + width: 0; + overflow: hidden; + border: none; +} + +/* Specific to Uploader */ + +#media-upload .media-upload-form p { + margin: 0 1em 1em 0; +} + +#media-upload .media-upload-form p.ml-submit { + padding: 1em 0; +} + +#media-upload p.help, +#media-upload label.help { + font-family: "Lucida Grande", "Bitstream Vera Sans", Verdana, Arial, sans-serif; + font-style: italic; + font-weight: normal; +} + +#media-upload tr.image-size td.field { + text-align: center; +} + +#media-upload #media-items { + border-width: 1px; + border-style: solid; + border-bottom: none; + width: 623px; +} + +#media-upload .media-item { + position: relative; + border-bottom-width: 1px; + border-bottom-style: solid; + min-height: 36px; + width: 100%; +} + +#media-upload .ui-sortable .media-item { + cursor: move; +} + +.filename { + float: left; + line-height: 36px; + margin-left: 10px; + overflow: hidden; + max-width: 430px; +} + +#media-upload .describe { + padding: 5px; + width: 100%; + clear: both; + cursor: default; +} + +#media-upload .slidetoggle { + border-top-width: 1px; + border-top-style: solid; +} + +#media-upload .describe th.label { + padding-top: .5em; + text-align: left; + min-width: 120px; +} + +#media-upload tr.align td.field { + text-align: center; +} + +#media-upload tr.image-size { + margin-bottom: 1em; + height: 3em; +} + +#media-upload #filter { + width: 623px; +} + +#media-upload #filter .subsubsub { + margin: 8px 0; +} + +#filter .tablenav select { + border-style: solid; + border-width: 1px; + padding: 2px; + vertical-align: top; + width: auto; +} + +#media-upload a.delete, +#media-upload a.del-link { + padding: 0 3px 1px; +} + +#media-upload .del-attachment { + display: none; + margin: 5px 0; +} + +.menu_order { + float: right; + font-size: 11px; + margin: 10px 10px 0; +} + +.menu_order_input { + border: 1px solid #ddd; + font-size: 10px; + padding: 1px; + width: 23px; +} + +.ui-sortable-helper { + background-color: #fff; + border: 1px solid #aaa; + opacity: 0.6; + filter: alpha(opacity=60); +} + +#media-upload th.order-head { + width: 25%; + text-align: center; +} + +#media-upload .widefat { + width: 626px; + border-style: solid solid none; +} + +.sorthelper { + z-index: -1; +} + +#gallery-settings th.label { + width: 160px; +} + +#gallery-settings #basic th.label { + padding: 5px 5px 5px 0; +} + +#gallery-settings .title { + clear: both; + padding: 0 0 3px; + border-bottom-style: solid; + border-bottom-width: 1px; + font-family: Georgia,"Times New Roman",Times,serif; + font-size: 1.6em; + border-bottom-color: #DADADA; + color: #5A5A5A; +} + +h3.media-title { + color: #5A5A5A; + font-family: Georgia,"Times New Roman",Times,serif; + font-size: 1.6em; + font-weight: normal; +} + +#gallery-settings .describe td { + vertical-align: middle; + height: 3.5em; +} + +#gallery-settings .describe th.label { + padding-top: .5em; + text-align: left; +} + +#gallery-settings .describe { + padding: 5px; + width: 615px; + clear: both; + cursor: default; +} + +#gallery-settings .describe select { + width: 15em; + border: 1px solid #dfdfdf; +} + +#gallery-settings label, +#gallery-settings legend { + font-size: 13px; + color: #464646; + margin-right: 15px; +} + +#gallery-settings .align .field label { + margin: 0 1.5em 0 0; +} + +#gallery-settings p.ml-submit { + border-top: 1px solid #dfdfdf; +} + +#gallery-settings select#columns { + width: 6em; +} diff -uNr a/blog/wp-admin/css/media-rtl.css b/blog/wp-admin/css/media-rtl.css --- a/blog/wp-admin/css/media-rtl.css false +++ b/blog/wp-admin/css/media-rtl.css fbaf97269f0258648ad460cadf0234b57dff91b646eb1a7c561db9cceff63293c5f32d7d731b50df5ecea0d5f82d1a055bfb0787da58233d71b8828fcd8b0dc5 @@ -0,0 +1,93 @@ +body#media-upload ul#sidemenu { + left: auto; + right: 0; +} +#search-filter { + text-align: left; +} +/* specific to the image upload form */ +.align .field label { + padding: 0 28px 0 0; + margin: 0 0 0 1em; +} +.image-align-none-label, .image-align-left-label, .image-align-center-label, .image-align-right-label { + background-position: center right; +} +tr.image-size div.image-size-item { + float: right; +} +tr.image-size label { + margin: 0 1em 0 0; +} +.filename.original { + float: right; +} +.crunching { + text-align: left; + margin-right: 0; + margin-left: 5px; +} +button.dismiss { + right: auto; + left: 5px; +} +.file-error { + margin: 0 50px 5px 0; +} +.progress { + left: auto; + right: 0; +} +.describe td { + padding: 0 0 0 5px; +} +.bar { + border-right-width: 0; + border-left-width: 3px; + border-right-style: none; + border-left-style: solid; +} +.media-item .pinkynail { + float: right; +} +.describe-toggle-on, +.describe-toggle-off { + float: left; + margin-right: 0; + margin-left: 20px; +} +/* Specific to Uploader */ +#media-upload .media-upload-form p { + margin: 0 0 1em 1em; +} +.filename { + float: right; + margin-left: 0; + margin-right: 10px; +} +#media-upload .describe th.label { + text-align: right; +} +.menu_order { + float: left; +} +.media-upload-form label.form-help, td.help, #media-upload p.help, #media-upload label.help { + font-family: Tahoma, Arial; +} +#gallery-settings #basic th.label { + padding: 5px 0 5px 5px; +} +#gallery-settings .title, h3.media-title { + font-family: Tahoma, Arial; +} +#gallery-settings .describe th.label { + text-align: right; +} +#gallery-settings label, +#gallery-settings legend { + margin-right: 0; + margin-left: 15px; +} +#gallery-settings .align .field label { + margin: 0 0 0 1.5em; +} diff -uNr a/blog/wp-admin/css/plugin-install.css b/blog/wp-admin/css/plugin-install.css --- a/blog/wp-admin/css/plugin-install.css false +++ b/blog/wp-admin/css/plugin-install.css 698d1556b47afad3a863f2ce912344028aa6759481cd204b936185167eff68df484c674d14a81fd62c24247355d1db68034382ff79021ca9339a0c774404fe94 @@ -0,0 +1,149 @@ +/* NOTE: the following CSS rules(.star*) are taken more or less straight from the bbPress rating plugin. */ +div.star-holder { + position: relative; + height: 19px; + width: 100px; + font-size: 19px; +} + +div.star { + height: 100%; + position: absolute; + top: 0; + left: 0; + background-color: transparent; + letter-spacing: 1ex; + border: none; +} + +.star1 { width: 20%; } +.star2 { width: 40%; } +.star3 { width: 60%; } +.star4 { width: 80%; } +.star5 { width: 100%; } + +.star img, div.star a, div.star a:hover, div.star a:visited { + display: block; + position: absolute; + right: 0; + border: none; + text-decoration: none; +} + +div.star img { + width: 19px; + height: 19px; + border-left: 1px solid #fff; + border-right: 1px solid #fff; +} + +/* Start custom CSS */ +/* Header on thickbox */ +#plugin-information-header { + margin: 0; + padding: 0 5px; + font-weight: bold; + position: relative; + border-bottom-width: 1px; + border-bottom-style: solid; + height: 2.5em; +} +#plugin-information ul#sidemenu { + font-weight: normal; + margin: 0 5px; + position: absolute; + left: 0; + bottom: -1px; +} + +/* Install sidemenu */ +#plugin-information p.action-button { + width: 100%; + padding-bottom: 0; + margin-bottom: 0; + margin-top: 10px; + -moz-border-radius: 3px 0 0 3px; + -webkit-border-top-left-radius: 3px; + -khtml-border-top-left-radius: 3px; + border-top-left-radius: 3px; + -webkit-border-bottom-left-radius: 3px; + -khtml-border-bottom-left-radius: 3px; + border-top-bottom-radius: 3px; +} + +#plugin-information .action-button a { + text-align: center; + font-weight: bold; + text-decoration: none; + display: block; + line-height: 2em; +} + +#plugin-information h2 { + clear: none !important; + margin-right: 200px; +} + +#plugin-information .fyi { + margin-left: 10px; + margin-bottom: 50px; + width: 210px; +} + +#plugin-information .fyi h2 { + font-size: 0.9em; + margin-bottom: 0; + margin-right: 0; +} + +#plugin-information .fyi h2.mainheader { + padding: 5px; + -moz-border-radius-topleft: 3px; + -webkit-border-top-left-radius: 3px; + -khtml-border-top-left-radius: 3px; + border-top-left-radius: 3px; +} + +#plugin-information .fyi ul { + padding: 10px 5px 10px 7px; + margin: 0; + list-style: none; + -moz-border-radius-bottomleft: 3px; + -webkit-border-bottom-left-radius: 3px; + -khtml-border-bottom-left-radius: 3px; + border-top-bottom-radius: 3px; +} + +#plugin-information .fyi li { + margin-right: 0; +} + +#plugin-information #section-holder { + padding: 10px; +} + +#plugin-information .section ul, +#plugin-information .section ol { + margin-left: 16px; + list-style-type: square; + list-style-image: none; +} + +#plugin-information #section-screenshots li img { + vertical-align: text-top; +} + +#plugin-information #section-screenshots li p { + font-style: italic; + padding-left: 20px; + padding-bottom: 2em; +} + +#plugin-information .updated, +#plugin-information pre { + margin-right: 215px; +} + +#plugin-information pre { + padding: 7px; +} \ No newline at end of file diff -uNr a/blog/wp-admin/css/plugin-install-rtl.css b/blog/wp-admin/css/plugin-install-rtl.css --- a/blog/wp-admin/css/plugin-install-rtl.css false +++ b/blog/wp-admin/css/plugin-install-rtl.css 1a99ec53a18f5630b75ed9bcc1cef9b3caf24cda0828c6de1ab4b1a1833abd6d6b98c7edc5461409050c36501a138296434bf7ce6d8ef0f43d9b0f5633f62229 @@ -0,0 +1,43 @@ +div.star { + left: auto; + right: 0; + letter-spacing: 0; +} +.star img, div.star a, div.star a:hover, div.star a:visited { + right: auto; + left: 0; +} +#plugin-information ul#sidemenu { + left: auto; + right: 0; +} +#plugin-information h2 { + margin-right: 0; + margin-left: 200px; +} +#plugin-information .fyi { + margin-left: 5px; + margin-right: 20px; +} +#plugin-information .fyi h2 { + margin-left: 0; +} +#plugin-information .fyi ul { + padding: 10px 7px 10px 5px; +} +#plugin-information #section-screenshots li p { + padding-left: 0; + padding-right: 20px; +} +#plugin-information .updated, +#plugin-information pre { + margin-right: 0; + margin-left: 215px; +} +#plugin-information .updated, #plugin-information .error { + clear: none; + direction: rtl; +} +#section-description { + direction: ltr; +} diff -uNr a/blog/wp-admin/css/press-this.css b/blog/wp-admin/css/press-this.css --- a/blog/wp-admin/css/press-this.css false +++ b/blog/wp-admin/css/press-this.css 19700b9c7deaec8077fb617a5bb63786330d11534b183b077cac3d9cc7be790f735d6a2af48e1e8a14b3e6b4183166f4bc7eb0818cd0747d14a9047ade909cac @@ -0,0 +1,571 @@ +body { + font: 13px "Lucida Grande", "Bitstream Vera Sans", Verdana, Arial, sans-serif; + color: #333; + margin: 0; + padding: 0; +} + +img { + border: none; +} + +/* Header */ +#wphead { + border-top: none; + padding-top: 4px; + background: #444 !important; +} + +#poststuff #edButtonPreview, +#poststuff #edButtonHTML { + -moz-border-radius-bottomleft: 0; + -moz-border-radius-bottomright: 0; + -moz-border-radius-topleft: 3px; + -moz-border-radius-topright: 3px; + -khtml-border-radius-bottomleft: 0; + -khtml-border-radius-bottomright: 0; + -khtml-border-radius-topleft: 3px; + -khtml-border-radius-topright: 3px; + -webkit-border-radius-bottomleft: 0; + -webkit-border-radius-bottomright: 0; + -webkit-border-radius-topleft: 3px; + -webkit-border-radius-topright: 3px; + border-radius-bottomleft: 0; + border-radius-bottomright: 0; + border-radius-topleft: 3px; + border-radius-topright: 3px; + border-style: solid; + border-width: 1px; + cursor: pointer; + display: block; + height: 18px; + margin: 0px 5px 0 0; + padding: 0px 5px 0px; + background-color: #E9E9E9; + border-bottom-color: #E9E9E9; + color: #333333; + font-size: 10px; + line-height: 18px; + float: left; +} + +.howto { + margin-top: 2px; + margin-bottom: 3px; + font-size: 11px; + font-style: italic; + display: block; +} + +input.text { + outline-color: -moz-use-text-color; + outline-style: none; + outline-width: medium; + width: 100%; +} + +#message { + -moz-border-radius: 6px; + -khtml-border-radius: 6px; + -webkit-border-radius: 6px; + border-radius: 6px; +} + +/* Editor/Main Column */ +div#poststuff { + padding-left: 10px; + margin-top: 10px; +} + +div.zerosize { + border: 0 none; + height: 0; + margin: 0; + overflow: hidden; + padding: 0; + position: absolute; + width: 0; +} + +#poststuff #edButtonPreview.active, +#poststuff #edButtonHTML.active { + display: none; +} + +.posting { + margin-right: 228px; + position: relative; + left: 0; +} + +#side-info-column { + float: right; + width: 218px; + position: absolute; + right: 0; + margin-right: 10px; +} + +#side-info-column .sleeve { + padding-left: 10px; +} + +#poststuff .inside { + font-size: 11px; + margin: 0 12px 12px; +} + +#poststuff h2, #poststuff h3 { + font-size: 14px; + font-weight: bold; + padding: 7px; + margin: 0 0 10px; + background-image: url(../images/postbox-bg.gif); + background-position: left top; + background-repeat: repeat-x; + font-size: 12px; + font-weight: bold; + line-height: 1; + margin: 0 0 10px; + padding: 7px 9px; + text-shadow: 0 1px 0 #FFFFFF; +} + +h3.tb { + text-shadow: 0 1px 0 #FFFFFF; + font-weight: bold; + font-size: 12px; + margin-left: 5px; +} + +#TB_window { + border: 1px solid #333; + -moz-border-radius: 6px; + -khtml-border-radius: 6px; + -webkit-border-radius: 6px; + border-radius: 6px; +} + +.metabox-holder .postbox, +.postbox, +.stuffbox { + margin-bottom: 10px; + border-width: 1px; + border-style: solid; + line-height: 1; + -moz-border-radius: 6px; + -khtml-border-radius: 6px; + -webkit-border-radius: 6px; + border-radius: 6px; + border-color: #DFDFDF; +} + +.titlediv { + border-color: #DFDFDF; +} + +#title, .tbtitle { + -moz-border-radius: 6px; + -khtml-border-radius: 6px; + -webkit-border-radius: 6px; + border-radius: 6px; + border-style: solid; + border-width: 1px; + font-size: 1.7em; + outline: none; + padding: 3px 4px; + border-color: #DFDFDF; +} + +.tbtitle { + font-size: 12px; + padding: 3px; +} + +#title { + width: 98%; +} + +.postbox h2 { + background-image: url(../images/postbox-bg.gif); + background-position: left top; + background-repeat: repeat-x; + background-color: #DFDFDF; +} + +.editor-container { + -moz-border-radius: 6px; + -khtml-border-radius: 6px; + -webkit-border-radius: 6px; + border-radius: 6px; + border-collapse: separate; + border-style: solid; + border-width: 1px; + border-color: #DFDFDF; +} + +.postdivrich { + position: relative; + padding-top: 25px; +} + +#actions { + clear: both; + float: right; + margin-top: -19px; + position: relative; +} +#extra_fields #actions { + clear: both; + position: absolute; + right: 4px; + top: 6px; + margin: 0; +} + +#actions li { + float: left; + list-style: none; + margin-right: 10px; +} +#extra_fields .button { + margin-right: 5px; +} + +/* Photo Styles */ +.photolist { + margin-top: -10px; +} + +#photo_saving { + margin: 0 8px 8px; + vertical-align: middle; +} + +#img_container { + background-color: #fff; + height: 101px; + width: 100%; +} + +#extra_fields { + margin-top: 10px; + position: relative; +} + +#extra_fields .postbox { + margin-bottom: 5px; +} + +#extra_fields .titlewrap { + padding: 0; + overflow: auto; + height: 100px; +} + +#img_container { + position: relative; +} + +#img_container a { + display: block; + float: left; + overflow: hidden; + vertical-align: center; +} + +#img_container img, #img_container a { + width: 68px; + height: 68px; +} + +#img_container img { + width: 68px; + height: 68px; + border: none; + background-color: #f4f4f4; + cursor: pointer; +} + +#img_container a, +#img_container a:link, +#img_container a:visited { + border: 1px solid #ccc; + display: block; + position: relative; +} + +#img_container a:hover, +#img_container a:active { + border-color: #000; + z-index: 1000; + border-width: 2px; + margin: -1px; +} + +/* Video */ +#embed-code { + width: 100%; + height: 98px; +} + +/* Submit Column */ +#viewsite { + padding: 0; + margin: 0 0 20px 0; + font-size: 10px; + clear: both; +} + +#viewsite .button { + margin: 0 0 0px 0; + display: block; +} + +.wp-hidden-children .wp-hidden-child { + display: none; +} + +#category-adder { + padding: 4px 0; +} + +#category-adder h4 { + margin: 0 0 8px; +} + +#category-add input { + width: 94%; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 13px; + margin: 1px; + padding: 3px; +} + +#category-add select { + width: 70%; + -x-system-font: none; + border-style: solid; + border-width: 1px; + font-family: "Lucida Grande", "Bitstream Vera Sans", Verdana, Arial, sans-serif; + font-size: 12px; + height: 2em; + line-height: 20px; + padding: 2px; + margin: 1px; + vertical-align: top; +} + +#category-add input#category-add-sumbit { + width: auto; +} + +/* Categories */ +#categorydiv ul, #linkcategorydiv ul { + list-style: none; + padding: 0; + margin: 0; +} + +#categorydiv ul.categorychecklist ul { + margin-left: 18px; +} + +#categorydiv div.ui-tabs-panel { + height: 150px; + overflow: auto; +} + +ul.categorychecklist li { + margin: 0; + padding: 0; + line-height: 19px; +} + +/* Tags */ +#tagsdiv #newtag { + padding: 3px; + margin-right: 5px; + width: 16em; +} + +#jaxtag { + clear: both; + margin: 0; +} + +#tagadd { + margin-left: 3px; +} + +#tagchecklist { + margin-top: 3px; + margin-bottom: 1em; + font-size: 12px; + overflow: auto; +} + +#tagchecklist strong { + position: absolute; + font-size: .75em; +} + +#tagchecklist span { + margin-right: .5em; + margin-left: 10px; + display: block; + float: left; + font-size: 11px; + line-height: 1.8em; + white-space: nowrap; + cursor: default; +} + +#tagchecklist span a { + margin: 6px 0 0 -9px; + cursor: pointer; + width: 10px; + height: 10px; + display: block; + float: left; + text-indent: -9999px; + overflow: hidden; + position: absolute; +} + +#content { + width: 96% !important; + margin-left: 1%; + margin-bottom: 10px; + border: 1px solid #f1f1f1; +} + +/* Submit */ + +#saving { + display: inline; +} + +.submit input, +.button, +.button-primary, +.button-secondary, +.button-highlighted, +#postcustomstuff .submit input { + font-family: "Lucida Grande", "Bitstream Vera Sans", Verdana, Arial, sans-serif; + text-decoration: none; + font-size: 11px !important; + line-height: 16px; + padding: 2px 8px; + cursor: pointer; + border-width: 1px; + border-style: solid; + -moz-border-radius: 11px; + -khtml-border-radius: 11px; + -webkit-border-radius: 11px; + border-radius: 11px; +} + +.button-primary { + background: #21759B url(../images/button-grad.png) repeat-x scroll left top; + border-color: #21759B; + color: #FFFFFF; +} + +.ac_results { + padding: 0; + margin: 0; + list-style: none; + position: absolute; + z-index: 10000; + display: none; + border-width: 1px; + border-style: solid; +} + +.ac_results li { + padding: 2px 5px; + white-space: nowrap; + text-align: left; +} + +.ac_over { + cursor: pointer; +} + +.ac_match { + text-decoration: underline; +} + +#TB_ajaxContent #options { + position: absolute; + top: 20px; + right: 25px; + padding: 5px; +} + +#TB_ajaxContent h3 { + margin-bottom: .25em; +} + +.updated { + margin: 10px 0; + padding: 0; + border-width: 1px; + border-style: solid; + width: 99%; +} + +.updated p, +.error p { + margin: 0.6em 0; + padding: 0 0.6em; +} + +.error a { + text-decoration: underline; +} + +.updated a { + text-decoration: none; + padding-bottom: 2px; +} + +#post_status { + margin-left: 10px; + margin-bottom: 1em; + display: block; +} + +/* Footer */ +#footer { + height: 65px; + display: block; + width: 640px; + padding: 10px 0 0 60px; + margin: 0; + position: absolute; + bottom: 0; + font-size: 12px; +} + +#footer p { + margin: 0; + padding: 7px 0; +} + +#footer p a { + text-decoration: none; +} +#footer p a:hover { + text-decoration: underline; +} + +/* Utility Classes */ +.centered { + text-align: center; +} + +.hidden { + display: none; +} diff -uNr a/blog/wp-admin/css/press-this-rtl.css b/blog/wp-admin/css/press-this-rtl.css --- a/blog/wp-admin/css/press-this-rtl.css false +++ b/blog/wp-admin/css/press-this-rtl.css 61538134af694b06f68f7d47e0b51dc9e51e09f23268416d141df2a5fb8f93d5302a49fec3bae9b4e006d90ace88a9a2eadfed0846a6f4055deac9796040b192 @@ -0,0 +1,106 @@ +body { + font-family: Tahoma, Arial; +} +#poststuff #edButtonPreview, +#poststuff #edButtonHTML { + margin: 0px 0 0 5px; + float: right; +} +/* Editor/Main Column */ +div#poststuff { + padding-left: 0; + padding-right: 10px; +} +.posting { + margin-right: 0; + margin-left: 228px; + left:auto; + right: 0; +} +#side-info-column { + float: left; + right: auto; + left: 0; + margin-right: 0; + margin-left: 10px; +} +#side-info-column .sleeve { + padding-left: 0; + padding-right: 10px; +} +h3.tb { + margin-left: 0; + margin-right: 5px; +} +#actions { + float: left; +} +#extra_fields #actions { + right: auto; + left: 4px; +} +#actions li { + float: right; + margin-right: 0; + margin-left: 10px; +} +#extra_fields .button { + margin-right: 0; + margin-left: 5px; +} +/* Photo Styles */ +#img_container a { + float: right; +} +#category-add input, #category-add select { + font-family: Tahoma, Arial; +} +#categorydiv ul.categorychecklist ul { + margin-left: 0; + margin-right: 18px; +} +/* Tags */ +#tagsdiv #newtag { + margin-right: 0; + margin-left: 5px; +} +#tagadd { + margin-left: 0; + margin-right: 3px; +} +#tagchecklist span { + margin-left: .5em; + margin-right: 10px; + float: right; +} +#tagchecklist span a { + margin: 6px -9px 0 0; + float: right; +} +#content { + margin-left: 0; + margin-right: 1%; +} +.submit input, +.button, +.button-primary, +.button-secondary, +.button-highlighted, +#postcustomstuff .submit input { + font-family: tahoma; +} +.ac_results li { + text-align: right; +} +#TB_ajaxContent #options { + right: auto; + left: 25px; +} +#post_status { + margin-left: 0; + margin-right: 10px; +} +/* Footer */ +#footer { + padding: 10px 60px 0 0; +} diff -uNr a/blog/wp-admin/css/theme-editor.css b/blog/wp-admin/css/theme-editor.css --- a/blog/wp-admin/css/theme-editor.css false +++ b/blog/wp-admin/css/theme-editor.css 621931d7d03bcee704c2b57f94b1d1d3e51d664e0ec82976938c622e2299b4b64066170af88f374fbd16e6d82a6b7f1dff192978664b2bcd182393f254032ee4 @@ -0,0 +1,66 @@ +#template textarea { + font-family: Consolas, Monaco, Courier, monospace; + font-size: 12px; + width: 97%; +} + +#template p { + width: 97%; +} + +#templateside { + float: right; + width: 190px; +} + +#templateside h3, #postcustomstuff p.submit { + margin: 0; +} + +h3#bordertitle { + margin-bottom: 10px; +} + +#templateside h4 { + margin-bottom: 0; +} + +#templateside ol, #templateside ul { + list-style: none; + margin: .5em; + padding: 0; +} + +#templateside ol li, #templateside ul li { + margin: 1px 0; +} + +#themeselector { + padding-right: 5px; + float: right; + position: relative; + bottom: 25px; + top:20px; +} + +#themeselector select { + margin: 0; + padding: 0; +} + +.nonessential { + font-size: small; +} + +.highlight { + padding: 1px; +} + +div.bordertitle h2 { + border: none; + padding-bottom: 0; +} + +div.tablenav { + margin-right: 210px; +} diff -uNr a/blog/wp-admin/css/theme-editor-rtl.css b/blog/wp-admin/css/theme-editor-rtl.css --- a/blog/wp-admin/css/theme-editor-rtl.css false +++ b/blog/wp-admin/css/theme-editor-rtl.css b0c686bffd48b2cbac58efa59ca28c1ae9c14a9de6ae90e4a8cd80ccc6e72907c65515c5cde89c22c66588be61bd82555c0ef3fc65398103dda17c14d0f6f441 @@ -0,0 +1,12 @@ +#templateside { + float: left; +} +#themeselector { + padding-right: 0; + padding-left: 5px; + float: left; +} +div.tablenav { + margin-right: 0; + margin-left: 210px; +} diff -uNr a/blog/wp-admin/css/widgets.css b/blog/wp-admin/css/widgets.css --- a/blog/wp-admin/css/widgets.css false +++ b/blog/wp-admin/css/widgets.css 8fecff067f06e8ccc419ebf24d938d99a3eb6f4be158c829bbb5a241e1385c0ceff9f309d2362ffe44ce9b7c8e33554e730f854cdfd85d5bde2ec4721119aa32 @@ -0,0 +1,177 @@ +/* 2 column liquid layout */ +div.widget-liquid-left-holder { + float: left; + clear: left; + width: 100%; + margin-right: -310px; +} + +div.widget-liquid-left { + margin-right: 320px; +} + +div.widget-liquid-right { + float: right; + clear: right; + width: 300px; + position: relative; +} + +/* pasitioning etc. */ +form#widgets-filter { + position: relative; +} + +div#available-widgets-filter { + border-bottom-width: 1px; + border-bottom-style: solid; +} + +ul#widget-list { + list-style: none; + margin: 0; + padding: 0; +} + +ul#widget-list li.widget-list-item { + padding: .7em 0.9em; + margin: 0; + border-bottom-width: 1px; + border-bottom-style: solid; + line-height: 1; +} + +h4.widget-title span { + float: left; +} + +h4.widget-title a { + float: right; + text-decoration: underline; + border-bottom: none; + margin-left: 1em; +} + +ul#widget-list li.widget-list-item h4.widget-title { + position: relative; + margin: 0; + padding: .5em 1em; + width: 200px; + float: left; + font-size: 13px; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; +} + +#dragHelper h4.widget-title { + padding: .5em 1em; + margin: 0; +} + +ul#widget-list li.widget-list-item div.widget-description { + display: block; + margin: 0 0 0 200px; + padding: 0 0 0 4em; + font-size: 11px; +} + +ul#widget-list li.widget-list-item ul.widget-control-info { + display: none; +} + +div#sidebar-info { + padding: 0 1em; + margin-bottom: 1em; + font-size: 11px; +} + +ul.widget-control-list { + list-style: none; + margin: 0; + padding: 0 1em; +} + +div#current-widgets p.submit { + padding: 1em; +} + +li.widget-list-control-item { + margin: 1em 0; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; +} + +li.widget-list-control-item h4, +#dragHelper li.widget-list-control-item h4, +li.widget-sortable h4 { + margin: 0; + cursor: move; + font-size: 13px; + padding: 0.4em 0.8em; + position: relative; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; +} + +.widget-control-save, +.widget-control-remove { + margin-right: 8px; + float: left; + text-decoration: none; +} + +li.widget-list-control-item h4.widget-title a, +#dragHelper li.widget-list-control-item h4.widget-title a, +#draghelper li.widget-list-control-item h4.widget-title a:visited { + right: 1em; +} + +li.widget-list-control-item h4.widget-title a:hover { + text-decoration: none; + border-bottom: none; +} + +li.widget-list-control-item div.widget-control { + border-width: 0 1px 1px; + border-style: none solid solid; + display: none; + padding: 15px; + font-size: 11px; + position: relative; +} + +li.widget-list-control-item div.widget-control p { + margin: 0 0 1em; + padding: 0; +} + +ul.widget-control-list div.widget-control-actions { + padding: 0.5em 0 0; +} + +.widget-control-edit { + font-size: 10px; + font-weight: normal; +} + +div#current-widgets { + padding-top: 1em; + border-width: 1px 0 0; + border-style: solid none none; +} + +#widget-controls .widefat { + width: 92%; + padding: 3px; +} + +#widget-controls select.widefat { + width: auto; + display: block; +} diff -uNr a/blog/wp-admin/css/widgets-rtl.css b/blog/wp-admin/css/widgets-rtl.css --- a/blog/wp-admin/css/widgets-rtl.css false +++ b/blog/wp-admin/css/widgets-rtl.css 5d26aaa2439813870fad47ae2639bd1b6ce515456cd26e102d02552495fdf585ec7514db7417a59ac1e6b0e6872fc2c380ccbb93b8a5c907e55f2943251b6519 @@ -0,0 +1,27 @@ +h4.widget-title span { + float: right; +} +h4.widget-title a { + float: left; + margin-left: 0; + margin-right: 1em; +} +ul#widget-list li.widget-list-item h4.widget-title { + float: right; +} +ul#widget-list li.widget-list-item div.widget-description { + margin: 0 200px 0 0; + padding: 0 4em 0 0; +} +.widget-control-save, +.widget-control-remove { + margin-right: 0; + margin-left: 8px; + float: right; +} +li.widget-list-control-item h4.widget-title a, +#dragHelper li.widget-list-control-item h4.widget-title a, +#draghelper li.widget-list-control-item h4.widget-title a:visited { + right: auto; + left: 1em; +} diff -uNr a/blog/wp-admin/custom-header.php b/blog/wp-admin/custom-header.php --- a/blog/wp-admin/custom-header.php false +++ b/blog/wp-admin/custom-header.php 05f567bca8d936ec36e315dd8b667a8654fbcb256758165986810db3f5402d3a9fdf1d3d4bc00de626d627d7e997da9ee08e5261127a216199ce8ff661a4c600 @@ -0,0 +1,470 @@ +admin_header_callback = $admin_header_callback; + } + + /** + * Setup the hooks for the Custom Header admin page. + * + * @since unknown + */ + function init() { + $page = add_theme_page(__('Custom Image Header'), __('Custom Image Header'), 'edit_themes', 'custom-header', array(&$this, 'admin_page')); + + add_action("admin_print_scripts-$page", array(&$this, 'js_includes')); + add_action("admin_print_styles-$page", array(&$this, 'css_includes')); + add_action("admin_head-$page", array(&$this, 'take_action'), 50); + add_action("admin_head-$page", array(&$this, 'js'), 50); + add_action("admin_head-$page", $this->admin_header_callback, 51); + } + + /** + * Get the current step. + * + * @since unknown + * + * @return int Current step + */ + function step() { + if ( ! isset( $_GET['step'] ) ) + return 1; + + $step = (int) $_GET['step']; + if ( $step < 1 || 3 < $step ) + $step = 1; + + return $step; + } + + /** + * Setup the enqueue for the JavaScript files. + * + * @since unknown + */ + function js_includes() { + $step = $this->step(); + + if ( 1 == $step ) + wp_enqueue_script('farbtastic'); + elseif ( 2 == $step ) + wp_enqueue_script('cropper'); + } + + /** + * Setup the enqueue for the CSS files + * + * @since 2.7 + */ + function css_includes() { + $step = $this->step(); + + if ( 1 == $step ) { + wp_enqueue_style('farbtastic'); + } + } + + /** + * Execute custom header modification. + * + * @since unknown + */ + function take_action() { + if ( isset( $_POST['textcolor'] ) ) { + check_admin_referer('custom-header'); + if ( 'blank' == $_POST['textcolor'] ) { + set_theme_mod('header_textcolor', 'blank'); + } else { + $color = preg_replace('/[^0-9a-fA-F]/', '', $_POST['textcolor']); + if ( strlen($color) == 6 || strlen($color) == 3 ) + set_theme_mod('header_textcolor', $color); + } + } + if ( isset($_POST['resetheader']) ) { + check_admin_referer('custom-header'); + remove_theme_mods(); + } + } + + /** + * Execute Javascript depending on step. + * + * @since unknown + */ + function js() { + $step = $this->step(); + if ( 1 == $step ) + $this->js_1(); + elseif ( 2 == $step ) + $this->js_2(); + } + + /** + * Display Javascript based on Step 1. + * + * @since unknown + */ + function js_1() { ?> + + + + +
+

+
+ + +
+ +

+

+ +
+

+
+
+ +
+ + + +
+ + + +
+
+

+

%1$d x %2$d pixels will be used as-is.'), HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT); ?>

+ +
+
+ + +

+ +

+
+ +
+ + +
+

+

+
+ + +
+
+ false); + $file = wp_handle_upload($_FILES['import'], $overrides); + + if ( isset($file['error']) ) + die( $file['error'] ); + + $url = $file['url']; + $type = $file['type']; + $file = $file['file']; + $filename = basename($file); + + // Construct the object array + $object = array( + 'post_title' => $filename, + 'post_content' => $url, + 'post_mime_type' => $type, + 'guid' => $url); + + // Save the data + $id = wp_insert_attachment($object, $file); + + list($width, $height, $type, $attr) = getimagesize( $file ); + + if ( $width == HEADER_IMAGE_WIDTH && $height == HEADER_IMAGE_HEIGHT ) { + // Add the meta-data + wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); + + set_theme_mod('header_image', clean_url($url)); + do_action('wp_create_file_in_uploads', $file, $id); // For replication + return $this->finished(); + } elseif ( $width > HEADER_IMAGE_WIDTH ) { + $oitar = $width / HEADER_IMAGE_WIDTH; + $image = wp_crop_image($file, 0, 0, $width, $height, HEADER_IMAGE_WIDTH, $height / $oitar, false, str_replace(basename($file), 'midsize-'.basename($file), $file)); + $image = apply_filters('wp_create_file_in_uploads', $image, $id); // For replication + + $url = str_replace(basename($url), basename($image), $url); + $width = $width / $oitar; + $height = $height / $oitar; + } else { + $oitar = 1; + } + ?> + +
+ +
+ +

+
+ +
+ +

+ + + + + + + + + + +

+ +
+
+ 1 ) { + $_POST['x1'] = $_POST['x1'] * $_POST['oitar']; + $_POST['y1'] = $_POST['y1'] * $_POST['oitar']; + $_POST['width'] = $_POST['width'] * $_POST['oitar']; + $_POST['height'] = $_POST['height'] * $_POST['oitar']; + } + + $original = get_attached_file( $_POST['attachment_id'] ); + + $cropped = wp_crop_image($_POST['attachment_id'], $_POST['x1'], $_POST['y1'], $_POST['width'], $_POST['height'], HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT); + $cropped = apply_filters('wp_create_file_in_uploads', $cropped, $_POST['attachment_id']); // For replication + + $parent = get_post($_POST['attachment_id']); + $parent_url = $parent->guid; + $url = str_replace(basename($parent_url), basename($cropped), $parent_url); + + // Construct the object array + $object = array( + 'ID' => $_POST['attachment_id'], + 'post_title' => basename($cropped), + 'post_content' => $url, + 'post_mime_type' => 'image/jpeg', + 'guid' => $url + ); + + // Update the attachment + wp_insert_attachment($object, $cropped); + wp_update_attachment_metadata( $_POST['attachment_id'], wp_generate_attachment_metadata( $_POST['attachment_id'], $cropped ) ); + + set_theme_mod('header_image', $url); + + // cleanup + $medium = str_replace(basename($original), 'midsize-'.basename($original), $original); + @unlink( apply_filters( 'wp_delete_file', $medium ) ); + @unlink( apply_filters( 'wp_delete_file', $original ) ); + + return $this->finished(); + } + + /** + * Display last step of custom header image page. + * + * @since unknown + */ + function finished() { + ?> +
+

+ +

+ +
+ step(); + if ( 1 == $step ) + $this->step_1(); + elseif ( 2 == $step ) + $this->step_2(); + elseif ( 3 == $step ) + $this->step_3(); + } + +} +?> diff -uNr a/blog/wp-admin/edit-attachment-rows.php b/blog/wp-admin/edit-attachment-rows.php --- a/blog/wp-admin/edit-attachment-rows.php false +++ b/blog/wp-admin/edit-attachment-rows.php 5e6945b3f7154a891e1b69464bf46eaa6c17a61d3b41435b83c8faeb1eba36cae93c090cbf5eb9f31e18a29e8be877e424242826d686e86271cd2562d107d15d @@ -0,0 +1,210 @@ + + + + + + + + + + + + + + + +ID == $post->post_author ? 'self' : 'other' ); +$att_title = _draft_or_post_title(); + +?> + post_status ); ?>' valign="top"> + + $column_display_name ) { + $class = "class=\"$column_name column-$column_name\""; + + $style = ''; + if ( in_array($column_name, $hidden) ) + $style = ' style="display:none;"'; + + $attributes = "$class$style"; + + switch($column_name) { + + case 'cb': + ?> + + + + + + + + + + + + post_date && 'date' == $column_name ) { + $t_time = $h_time = __('Unpublished'); + } else { + $t_time = get_the_time(__('Y/m/d g:i:s A')); + $m_time = $post->post_date; + $time = get_post_time( 'G', true, $post ); + if ( ( abs($t_diff = time() - $time) ) < 86400 ) { + if ( $t_diff < 0 ) + $h_time = sprintf( __('%s from now'), human_time_diff( $time ) ); + else + $h_time = sprintf( __('%s ago'), human_time_diff( $time ) ); + } else { + $h_time = mysql2date(__('Y/m/d'), $m_time); + } + } + ?> + + post_parent > 0 ) { + if ( get_post($post->post_parent) ) { + $title =_draft_or_post_title($post->post_parent); + } + ?> + + + + + + + + + + + + + +
>ID, array(80, 60), true ) ) { +?> + + "> + + + +>">
+ ID))); ?> +

+ ID) ) + $actions['edit'] = '' . __('Edit') . ''; + if ( current_user_can('delete_post', $post->ID) ) + $actions['delete'] = "ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this attachment '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this attachment '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . ""; + $actions['view'] = '' . __('View') . ''; + $action_count = count($actions); + $i = 0; + echo '

'; + foreach ( $actions as $action => $link ) { + ++$i; + ( $i == $action_count ) ? $sep = '' : $sep = ' | '; + echo "$link$sep"; + } + echo '
'; + ?>

>>slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . ""; + echo join( ', ', $out ); + } else { + _e('No Tags'); + } + ?>>post_excerpt : ''; ?>>>, >
+ ID ); + $pending_phrase = sprintf( __('%s pending'), number_format( $left ) ); + if ( $left ) + echo ''; + comments_number("" . __('0') . '', "" . __('1') . '', "" . __('%') . ''); + if ( $left ) + echo ''; + ?> +
> + "> | + + >
+ + +

+ + + diff -uNr a/blog/wp-admin/edit-category-form.php b/blog/wp-admin/edit-category-form.php --- a/blog/wp-admin/edit-category-form.php false +++ b/blog/wp-admin/edit-category-form.php c14f833f2bc7504ed3541801c14737a50dfbcf49d1ff6d3ffadab823eafc8aaac1a90f258a034bbca8e7802b6abcfb24a86b24b863de02d0566efa042407bdc0 @@ -0,0 +1,76 @@ +name ) ) + $category->name = ''; + + if ( ! isset( $category->slug ) ) + $category->slug = ''; + + if ( ! isset( $category->parent ) ) + $category->parent = ''; + + if ( ! isset( $category->description ) ) + $category->description = ''; +} + +do_action('edit_category_form_pre', $category); + +_fill_empty_category($category); +?> + +
+ +

+
+
+ + + + + + + + + + + + + + + + + + + + +

+

+
+ 0, 'name' => 'category_parent', 'orderby' => 'name', 'selected' => $category->parent, 'hierarchical' => true, 'show_option_none' => __('None'))); ?>
+ +

+
+

+ +
+
diff -uNr a/blog/wp-admin/edit-comments.php b/blog/wp-admin/edit-comments.php --- a/blog/wp-admin/edit-comments.php false +++ b/blog/wp-admin/edit-comments.php bfb29f6ab69a34f2d5d707e09fb64d696c441294a68f1f32d95887ec8d3fe6ca47d63cad0d7df21068e141ddb1ad34a08e4ad4f2c24d6cadd3e41d0aea73a92f @@ -0,0 +1,388 @@ +escape( $_REQUEST['pagegen_timestamp'] ); + $deleted_spam = $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam' AND '$delete_time' > comment_date_gmt" ); + + $redirect_to = 'edit-comments.php?comment_status=spam&deleted=' . (int) $deleted_spam; + if ( $post_id ) + $redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to ); + wp_redirect( $redirect_to ); +} elseif ( isset($_REQUEST['delete_comments']) && isset($_REQUEST['action']) && ( -1 != $_REQUEST['action'] || -1 != $_REQUEST['action2'] ) ) { + check_admin_referer('bulk-comments'); + $doaction = ( -1 != $_REQUEST['action'] ) ? $_REQUEST['action'] : $_REQUEST['action2']; + + $deleted = $approved = $unapproved = $spammed = 0; + foreach ( (array) $_REQUEST['delete_comments'] as $comment_id) : // Check the permissions on each + $comment_id = (int) $comment_id; + $_post_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment_id) ); + + if ( !current_user_can('edit_post', $_post_id) ) + continue; + + switch( $doaction ) { + case 'markspam' : + wp_set_comment_status($comment_id, 'spam'); + $spammed++; + break; + case 'delete' : + wp_set_comment_status($comment_id, 'delete'); + $deleted++; + break; + case 'approve' : + wp_set_comment_status($comment_id, 'approve'); + $approved++; + break; + case 'unapprove' : + wp_set_comment_status($comment_id, 'hold'); + $unapproved++; + break; + } + endforeach; + + $redirect_to = 'edit-comments.php?deleted=' . $deleted . '&approved=' . $approved . '&spam=' . $spammed . '&unapproved=' . $unapproved; + if ( $post_id ) + $redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to ); + if ( isset($_REQUEST['apage']) ) + $redirect_to = add_query_arg( 'apage', absint($_REQUEST['apage']), $redirect_to ); + if ( !empty($_REQUEST['mode']) ) + $redirect_to = add_query_arg('mode', $_REQUEST['mode'], $redirect_to); + if ( !empty($_REQUEST['comment_status']) ) + $redirect_to = add_query_arg('comment_status', $_REQUEST['comment_status'], $redirect_to); + if ( !empty($_REQUEST['s']) ) + $redirect_to = add_query_arg('s', $_REQUEST['s'], $redirect_to); + wp_redirect( $redirect_to ); +} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { + wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); + exit; +} + +if ( $post_id ) + $title = sprintf(__('Edit Comments on “%s”'), wp_html_excerpt(_draft_or_post_title($post_id), 50)); +else + $title = __('Edit Comments'); + +require_once('admin-header.php'); + +$mode = ( ! isset($_GET['mode']) || empty($_GET['mode']) ) ? 'detail' : attribute_escape($_GET['mode']); + +$comment_status = !empty($_GET['comment_status']) ? attribute_escape($_GET['comment_status']) : ''; + +$comment_type = !empty($_GET['comment_type']) ? attribute_escape($_GET['comment_type']) : ''; + +$search_dirty = ( isset($_GET['s']) ) ? $_GET['s'] : ''; +$search = attribute_escape( $search_dirty ); ?> + +
+ +

' . sprintf( __( 'Search results for “%s”' ), wp_html_excerpt( wp_specialchars( stripslashes( $_GET['s'] ) ), 50 ) ) . '' ); ?> +

+ + 0 || $deleted > 0 || $spam > 0 ) { + echo '

'; + + if ( $approved > 0 ) { + printf( __ngettext( '%s comment approved', '%s comments approved', $approved ), $approved ); + echo '
'; + } + + if ( $deleted > 0 ) { + printf( __ngettext( '%s comment deleted', '%s comments deleted', $deleted ), $deleted ); + echo '
'; + } + + if ( $spam > 0 ) { + printf( __ngettext( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam ); + echo '
'; + } + + echo '

'; + } +} +?> + +
+
    +moderated) ), "" . number_format_i18n($num_comments->moderated) . ""), +//, number_format_i18n($num_comments->spam) ), "" . number_format_i18n($num_comments->spam) . "") +$stati = array( + 'all' => __ngettext_noop('All', 'All'), // singular not used + 'moderated' => __ngettext_noop('Pending (%s)', 'Pending (%s)'), + 'approved' => __ngettext_noop('Approved', 'Approved'), // singular not used + 'spam' => __ngettext_noop('Spam (%s)', 'Spam (%s)') + ); +$class = ( '' === $comment_status ) ? ' class="current"' : ''; +// $status_links[] = "
  • " . __( 'All' ) . ''; +$link = 'edit-comments.php'; +if ( !empty($comment_type) && 'all' != $comment_type ) + $link = add_query_arg( 'comment_type', $comment_type, $link ); +foreach ( $stati as $status => $label ) { + $class = ''; + + if ( str_replace( 'all', '', $status ) == $comment_status ) + $class = ' class="current"'; + if ( !isset( $num_comments->$status ) ) + $num_comments->$status = 10; + if ( 'all' != $status ) + $link = add_query_arg( 'comment_status', $status, $link ); + if ( $post_id ) + $link = add_query_arg( 'p', absint( $post_id ), $link ); + /* + // I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark + if ( !empty( $_GET['s'] ) ) + $link = add_query_arg( 's', attribute_escape( stripslashes( $_GET['s'] ) ), $link ); + */ + $status_links[] = "
  • " . sprintf( + __ngettext( $label[0], $label[1], $num_comments->$status ), + number_format_i18n( $num_comments->$status ) + ) . ''; +} + +$status_links = apply_filters( 'comment_status_links', $status_links ); + +echo implode( " |
  • \n", $status_links) . ''; +unset($status_links); +?> +
+ + + +comment_post_ID; +} +$_comment_pending_count_temp = (array) get_pending_comments_num($_comment_post_ids); +foreach ( (array) $_comment_post_ids as $_cpid ) + $_comment_pending_count[$_cpid] = isset( $_comment_pending_count_temp[$_cpid] ) ? $_comment_pending_count_temp[$_cpid] : 0; +if ( empty($_comment_pending_count) ) + $_comment_pending_count = array(); + +$comments = array_slice($_comments, 0, $comments_per_page); +$extra_comments = array_slice($_comments, $comments_per_page); + +$page_links = paginate_links( array( + 'base' => add_query_arg( 'apage', '%#%' ), + 'format' => '', + 'prev_text' => __('«'), + 'next_text' => __('»'), + 'total' => ceil($total / $comments_per_page), + 'current' => $page +)); + +?> + + + + + + + + +
+ + +
' . __( 'Displaying %s–%s of %s' ) . '%s', + number_format_i18n( $start + 1 ), + number_format_i18n( min( $page * $comments_per_page, $total ) ), + number_format_i18n( $total ), + $page_links +); echo $page_links_text; ?>
+ + +
+ + + + +\n"; ?> + + + + + + + + + +
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + +comment_ID, $mode, $comment_status ); +?> + + +comment_ID, $mode, $comment_status ); +?> + +
+ +
+$page_links_text
"; +?> + +
+ + + + + + + +
+ +
+
+ + + + + +
+ + +

+ + + +

+ + + +
+ + + + diff -uNr a/blog/wp-admin/edit-form-advanced.php b/blog/wp-admin/edit-form-advanced.php --- a/blog/wp-admin/edit-form-advanced.php false +++ b/blog/wp-admin/edit-form-advanced.php 6621aa65e650fe35fa9bcf630de274003ba8b0ace45f2498a1fd4f737d61cbc1f315be5c2ca2ea30e3a360f629fab73722c0fa0eee451fa1ecfa4dbeea66ad01 @@ -0,0 +1,625 @@ +go back.' ), attribute_escape( stripslashes( ( isset( $_GET['_wp_original_http_referer'] ) ? $_GET['_wp_original_http_referer'] : '') ) ) ); +$messages[2] = __('Custom field updated.'); +$messages[3] = __('Custom field deleted.'); +$messages[4] = __('Post updated.'); +$messages[6] = sprintf(__('Post published. View post'), get_permalink($post_ID)); +$messages[7] = __('Post saved.'); +$messages[8] = sprintf(__('Post submitted. Preview post'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ); + +if ( isset($_GET['revision']) ) + $messages[5] = sprintf( __('Post restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ); + +$notice = false; +$notices[1] = __( 'There is an autosave of this post that is more recent than the version below. View the autosave.' ); + +if ( 0 == $post_ID ) { + $form_action = 'post'; + $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post() + $form_extra = ""; + $autosave = false; +} else { + $form_action = 'editpost'; + $form_extra = ""; + $autosave = wp_get_post_autosave( $post_ID ); + + // Detect if there exists an autosave newer than the post and if that autosave is different than the post + if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt ) > mysql2date( 'U', $post->post_modified_gmt ) ) { + foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) { + if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) { + $notice = sprintf( $notices[1], get_edit_post_link( $autosave->ID ) ); + break; + } + } + unset($autosave_field, $_autosave_field); + } +} + +// All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action). + +/** + * Display post submit form fields. + * + * @since 2.7.0 + * + * @param object $post + */ +function post_submit_meta_box($post) { + global $action; + + $can_publish = current_user_can('publish_posts'); +?> +
+ +
+ + +
+ +
+ +
+
+post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?> +post_status ) { ?>style="display:none" type="submit" name="save" id="save-post" value="" tabindex="4" class="button button-highlighted" /> +post_status && $can_publish ) { ?> + + +
+ +
+post_status ? clean_url(get_permalink($post->ID)) : clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?> + + + +
+ +
+
+ +
+ +
+ +post_status ) { + case 'private': + _e('Privately Published'); + break; + case 'publish': + _e('Published'); + break; + case 'future': + _e('Scheduled'); + break; + case 'pending': + _e('Pending Review'); + break; + case 'draft': + _e('Draft'); + break; +} +?> + +post_status || 'private' == $post->post_status || $can_publish ) { ?> +post_status ) { ?>style="display:none;" class="edit-post-status hide-if-no-js" tabindex='4'> + +
+ + + + +
+ + +
+ +
+ post_status ) { + $post->post_password = ''; + $visibility = 'private'; + $visibility_trans = __('Private'); +} elseif ( !empty( $post->post_password ) ) { + $visibility = 'password'; + $visibility_trans = __('Password protected'); +} elseif ( is_sticky( $post->ID ) ) { + $visibility = 'public'; + $visibility_trans = __('Public, Sticky'); +} else { + $visibility = 'public'; + $visibility_trans = __('Public'); +} + +?> + +
+ +ID), true); ?> /> + + + + />
+ID), true); ?> tabindex="4" />
+ />
+
+ />
+ +

+ + +

+
+ + +
+ + +ID ) { + if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date + $stamp = __('Scheduled for: %1$s'); + } else if ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published + $stamp = __('Published on: %1$s'); + } else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified + $stamp = __('Publish immediately'); + } else if ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified + $stamp = __('Schedule for: %1$s'); + } else { // draft, 1 or more saves, date specified + $stamp = __('Publish on: %1$s'); + } + $date = date_i18n( $datef, strtotime( $post->post_date ) ); +} else { // draft (no saves, and thus no date specified) + $stamp = __('Publish immediately'); + $date = date_i18n( $datef, strtotime( current_time('mysql') ) ); +} +?> + +
+ + + +
+
+ + +
+
+
+ +
+ + + +
+post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) { ?> + + post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?> + + + + + + + + + + + + + + +
+
+
+
+ + +

+
+ + + + + + +
+ +
+ + +
+

+

+ + 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?> + + + +

+
+ +

+ +

+

+

+

+ + +

use them in your template'); ?>

+to_ping) ) .'" />'; + if ('' != $post->pinged) { + $pings = '

'. __('Already pinged:') . '

'; + } + +?> +


()

+

pingbacks, no other action necessary.'); ?>

+ +
+
+ID); +list_meta($metadata); +meta_form(); +?> +
+

use in your theme.'); ?>

+ + +

+
+ +

+get_var($wpdb->prepare("SELECT count(1) FROM $wpdb->comments WHERE comment_post_ID = '%d' AND ( comment_approved = '0' OR comment_approved = '1')", $post_ID)); + + if ( !$post_ID || $post_ID < 0 || 1 > $total ) + return; + +wp_nonce_field( 'get-comments', 'add_comment_nonce', false ); +?> + + + + + + + + + + + +

+ + + + +post_status && !current_user_can( 'publish_posts' ) ) ) + add_meta_box('slugdiv', __('Post Slug'), 'post_slug_meta_box', 'post', 'normal', 'core'); + +$authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM +if ( $post->post_author && !in_array($post->post_author, $authors) ) + $authors[] = $post->post_author; +if ( $authors && count( $authors ) > 1 ) : +/** + * Display form field with list of authors. + * + * @since 2.6.0 + * + * @param object $post + */ +function post_author_meta_box($post) { + global $current_user, $user_ID; + $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM + if ( $post->post_author && !in_array($post->post_author, $authors) ) + $authors[] = $post->post_author; +?> + $authors, 'name' => 'post_author_override', 'selected' => empty($post->ID) ? $user_ID : $post->post_author) ); ?> + + + + + + +
+ +

+ +

+ + +

+ +
+ + + + + + + + + +post_status ) wp_original_referer_field(true, 'previous'); ?> + + + +
+ +
+ + + + +
+ +
+
+
+
+ +
+
+ID); ?> +post_status && !current_user_can( 'publish_posts' ) ) ) { ?> +
+ID) && ! empty($sample_permalink_html) ) : + echo $sample_permalink_html; +endif; ?> +
+ +
+
+ +
+ +post_content); ?> + +
+ + +   +'; + if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) { + $last_user = get_userdata($last_id); + printf(__('Last edited by %1$s on %2$s at %3$s'), wp_specialchars( $last_user->display_name ), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified)); + } else { + printf(__('Last edited on %1$s at %2$s'), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified)); + } + echo ''; + } +?> + +
+
+ + + + + + + +
+ + + +
+
+
+
+
+
+ + + +post_title) && '' == $post->post_title) || (isset($_GET['message']) && 2 > $_GET['message'])) : ?> + + diff -uNr a/blog/wp-admin/edit-form-comment.php b/blog/wp-admin/edit-form-comment.php --- a/blog/wp-admin/edit-form-comment.php false +++ b/blog/wp-admin/edit-form-comment.php e449cc92b7ae562677169156df14ecfeeaf760db74999b87ff8a181fbce865415ff602c8ed76ddaca2aec763716922a6240e4d28691d2374cf2b113f8663c216 @@ -0,0 +1,145 @@ +comment_ID); +$form_action = 'editedcomment'; +$form_extra = "' />\n\ncomment_ID) ?> +
+ +

+ +
+ + +comment_author_email ); +$url = attribute_escape( $comment->comment_author_url ); +// add_meta_box('submitdiv', __('Save'), 'comment_submit_meta_box', 'comment', 'side', 'core'); +?> + +
+
+

+
+
+
+ +
+
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+%1$s'); +$date = date_i18n( $datef, strtotime( $comment->comment_date ) ); +?> +  +
+
+
+
+
+ + +
+
+
+
+ +
+
+ +
+

+
+ + + + + + + + + + + + + + + +
+
+ " . __('visit site') . ""; + printf( __( 'URL (%s):' ), apply_filters('get_comment_author_link', $link ) ); + } else { + _e( 'URL:' ); + } ?>
+
+
+
+ +
+comment_content, 'content', 'newcomment_author_url', false, 4); ?> + +
+ + + + + + + + + +
+
+
+
+ + + diff -uNr a/blog/wp-admin/edit-link-categories.php b/blog/wp-admin/edit-link-categories.php --- a/blog/wp-admin/edit-link-categories.php false +++ b/blog/wp-admin/edit-link-categories.php f5968e807d7147b49ed83b110bf2c3ce9e26c3f1be399dce83b0fdcc4c929dbab32dcb1753af8cca7c964960a4e5be58dc83dbffc2c84941d55324aab98f6780 @@ -0,0 +1,243 @@ +%s category: this is the default one"), $cat_name)); + + wp_delete_term($cat_ID, 'link_category', array('default' => $default_cat_id)); + } + + $location = 'edit-link-categories.php'; + if ( $referer = wp_get_referer() ) { + if ( false !== strpos($referer, 'edit-link-categories.php') ) + $location = $referer; + } + + $location = add_query_arg('message', 6, $location); + wp_redirect($location); + exit(); + } +} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { + wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); + exit; +} + +$title = __('Link Categories'); + +wp_enqueue_script('admin-categories'); +if ( current_user_can('manage_categories') ) + wp_enqueue_script('inline-edit-tax'); + +require_once ('admin-header.php'); + +$messages[1] = __('Category added.'); +$messages[2] = __('Category deleted.'); +$messages[3] = __('Category updated.'); +$messages[4] = __('Category not added.'); +$messages[5] = __('Category not updated.'); +$messages[6] = __('Categories deleted.'); ?> + +
+ +

' . __('Search results for “%s”') . '', wp_specialchars( stripslashes($_GET['s']) ) ); ?> +

+ + +

+ + +
+ +
+
+ +
+ +
+
+
+
+ + add_query_arg( 'pagenum', '%#%' ), + 'format' => '', + 'prev_text' => __('«'), + 'next_text' => __('»'), + 'total' => ceil(wp_count_terms('link_category') / $catsperpage), + 'current' => $pagenum +)); + +if ( $page_links ) + echo "
$page_links
"; +?> + +
+ + + +
+ +
+
+ +
+ + + + + + + + + + + + + + + + $start, 'number' => $catsperpage, 'hide_empty' => 0); +if ( !empty( $_GET['s'] ) ) + $args['search'] = $_GET['s']; + +$categories = get_terms( 'link_category', $args ); +if ( $categories ) { + $output = ''; + foreach ( $categories as $category ) { + $output .= link_cat_row($category); + } + echo $output; + unset($category); +} + +?> + +
+ +
+$page_links
"; +?> + +
+ + +
+ +
+
+
+ + +
+

Note:
Deleting a category does not delete the links in that category. Instead, links that were only assigned to the deleted category are set to the category %s.'), get_term_field('name', get_option('default_link_category'), 'link_category')) ?>

+
+ + +
+
+ +
+
+ +parent = 0; do_action('add_link_category_form_pre', $category); ?> + +
+

+
+
+ + + +
+ + +
+ +
+ + +

+
+ +
+ + +
+ +

+ +
+
+ + + +
+
+ +
+
+ + + + + diff -uNr a/blog/wp-admin/edit-link-category-form.php b/blog/wp-admin/edit-link-category-form.php --- a/blog/wp-admin/edit-link-category-form.php false +++ b/blog/wp-admin/edit-link-category-form.php a8592422b20dde5c459043c4d516866511e465a9c550c816a8d64804c918027b67647b334f153900f9ec7cad6a0a4d12cdd4d0ef81b95bf3525e5c03cc47565d @@ -0,0 +1,81 @@ +' . __('Edit Link Category') . ''; + $submit_text = __('Update Category'); + $form = '
'; + $action = 'editedcat'; + $nonce_action = 'update-link-category_' . $cat_ID; + do_action('edit_link_category_form_pre', $category); +} else { + $heading = '

' . __('Add Link Category') . '

'; + $submit_text = __('Add Category'); + $form = ''; + $action = 'addcat'; + $nonce_action = 'add-link-category'; + do_action('add_link_category_form_pre', $category); +} + +/** + * @ignore + * @since 2.7 + * @internal Used to prevent errors in page when no category is being edited. + * + * @param object $category + */ +function _fill_empty_link_category(&$category) { + if ( ! isset( $category->name ) ) + $category->name = ''; + + if ( ! isset( $category->slug ) ) + $category->slug = ''; + + if ( ! isset( $category->description ) ) + $category->description = ''; +} + +_fill_empty_link_category($category); +?> + +
+ + +
+ + + + + + + + + + + + + + + + + +

+
+

+ + +
diff -uNr a/blog/wp-admin/edit-link-form.php b/blog/wp-admin/edit-link-form.php --- a/blog/wp-admin/edit-link-form.php false +++ b/blog/wp-admin/edit-link-form.php 4350070490aa3ca792261c9603cd811434093d23721d0281fa56ca89ea3d9381d6405c7451e328b4d2dcab85077fcdb108206bd113ba04f2987ece54f7b911d2 @@ -0,0 +1,420 @@ +Links / Edit Link' ), 'link-manager.php' ); + $submit_text = __('Update Link'); + $form = ' diff -uNr a/blog/wp-admin/edit-page-form.php b/blog/wp-admin/edit-page-form.php --- a/blog/wp-admin/edit-page-form.php false +++ b/blog/wp-admin/edit-page-form.php 2c4b5f1aa4f680a585b50ea4f8d88a170f76693f6110867e66fe90206116b9341bc70894451c6ee8f1e0d88eca286c5458bdbeb4b2448fa5a20a5d725780e1d5 @@ -0,0 +1,496 @@ +go back.' ), attribute_escape( stripslashes( ( isset( $_GET['_wp_original_http_referer'] ) ? $_GET['_wp_original_http_referer'] : '') ) ) ); +$messages[2] = __('Custom field updated.'); +$messages[3] = __('Custom field deleted.'); +$messages[4] = __('Page updated.'); +$messages[5] = sprintf(__('Page published. View page'), get_permalink($post_ID)); +$messages[6] = sprintf(__('Page submitted. Preview page'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ); + +if ( isset($_GET['revision']) ) + $messages[5] = sprintf( __('Page restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ); + +$notice = false; +$notices[1] = __( 'There is an autosave of this page that is more recent than the version below. View the autosave.' ); + +if ( 0 == $post_ID) { + $form_action = 'post'; + $nonce_action = 'add-page'; + $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post() + $form_extra = ""; +} else { + $post_ID = (int) $post_ID; + $form_action = 'editpost'; + $nonce_action = 'update-page_' . $post_ID; + $form_extra = ""; + $autosave = wp_get_post_autosave( $post_ID ); + if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt ) > mysql2date( 'U', $post->post_modified_gmt ) ) + $notice = sprintf( $notices[1], get_edit_post_link( $autosave->ID ) ); +} + +$temp_ID = (int) $temp_ID; +$user_ID = (int) $user_ID; + +/** + * Display submit form fields. + * + * @since 2.7.0 + * + * @param object $post + */ +function page_submit_meta_box($post) { + global $action; + + $can_publish = current_user_can('publish_pages'); +?> +
+ +
+ + +
+ +
+ +
+
+post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?> +post_status ) { ?>style="display:none" type="submit" name="save" id="save-post" value="" tabindex="4" class="button button-highlighted" /> +post_status && $can_publish ) { ?> + + +
+ +
+post_status ? clean_url(get_permalink($post->ID)) : clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?> + + + +
+ +
+
+ +
+ +
+ +post_status ) { + case 'private': + _e('Privately Published'); + break; + case 'publish': + _e('Published'); + break; + case 'future': + _e('Scheduled'); + break; + case 'pending': + _e('Pending Review'); + break; + case 'draft': + _e('Draft'); + break; +} +?> + +post_status || 'private' == $post->post_status || $can_publish ) { ?> +post_status ) { ?>style="display:none;" class="edit-post-status hide-if-no-js" tabindex='4'> + +
+ + + + + +
+ + +
+ +
+ post_status ) { + $post->post_password = ''; + $visibility = 'private'; + $visibility_trans = __('Private'); +} elseif ( !empty( $post->post_password ) ) { + $visibility = 'password'; + $visibility_trans = __('Password protected'); +} else { + $visibility = 'public'; + $visibility_trans = __('Public'); +} + +?> + +
+ + + + + />
+ />
+
+ />
+ +

+ + +

+
+ + +
+ +ID ) { + if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date + $stamp = __('Scheduled for: %1$s'); + } else if ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published + $stamp = __('Published on: %1$s'); + } else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified + $stamp = __('Publish immediately'); + } else if ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified + $stamp = __('Schedule for: %1$s'); + } else { // draft, 1 or more saves, date specified + $stamp = __('Publish on: %1$s'); + } + $date = date_i18n( $datef, strtotime( $post->post_date ) ); +} else { // draft (no saves, and thus no date specified) + $stamp = __('Publish immediately'); + $date = date_i18n( $datef, strtotime( current_time('mysql') ) ); +} +?> + +
+ + + +
+
+ + +
+
+
+ +
+ + + +
+post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) { ?> + + post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?> + + + + + + + + + + + + + + +
+
+
+
+ +

+

+

+

+ +
+ + $post->ID, 'selected' => $post->post_parent, 'name' => 'parent_id', 'show_option_none' => __('Main Page (no parent)'), 'sort_column'=> 'menu_order, post_title')); ?> +

+ +
+ +

+ +
+

+

+ +
+ID); +list_meta($metadata); +meta_form(); +?> +
+
+

use in your theme.'); ?>

+ + +

+

+

trackbacks and pingbacks.'); ?>

+ + +id, true, 'page' ); // TODO: ROLE SYSTEM +if ( $post->post_author && !in_array($post->post_author, $authors) ) + $authors[] = $post->post_author; +if ( $authors && count( $authors ) > 1 ) { + /** + * Display page author form fields, when more than one author exists. + * + * @since 2.6.0 + * + * @param object $post + */ + function page_author_meta_box($post){ + global $current_user, $user_ID; + $authors = get_editable_user_ids( $current_user->id, true, 'page' ); // TODO: ROLE SYSTEM + if ( $post->post_author && !in_array($post->post_author, $authors) ) + $authors[] = $post->post_author; +?> + $authors, 'name' => 'post_author_override', 'selected' => empty($post->ID) ? $user_ID : $post->post_author) ); ?> + + +
+ +

+ +
+ +

+ + +

+ + +'; +?> + + + + + + + + +post_status ) wp_original_referer_field(true, 'previous'); ?> + +
+ +
+ + +
+ +
+
+ +
+
+ +
+
+ID); ?> +
+ID) && ! empty($sample_permalink_html) ) : + echo $sample_permalink_html; +endif; ?> +
+
+
+ +
+ +post_content); ?> +
+ + +   + +display_name ), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified)); + } else { + printf(__('Last edited on %1$s at %2$s'), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified)); + } + } +?> + +
+
+ + + + + + +
+ + + +
+
+
+ +
+
+ + diff -uNr a/blog/wp-admin/edit-pages.php b/blog/wp-admin/edit-pages.php --- a/blog/wp-admin/edit-pages.php false +++ b/blog/wp-admin/edit-pages.php fafa95975ecbe8164bc0a926ae8ef214fddd85cc8bac5bd5edec5060f876dbd862fd12c52184876134dbec2520df15a31cd5c22cd2c36d4874885285b5e130d1 @@ -0,0 +1,331 @@ +post_type == 'attachment' ) { + if ( ! wp_delete_attachment($post_id_del) ) + wp_die( __('Error in deleting...') ); + } else { + if ( !wp_delete_post($post_id_del) ) + wp_die( __('Error in deleting...') ); + } + $deleted++; + } + } + break; + case 'edit': + if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) { + check_admin_referer('bulk-pages'); + + if ( -1 == $_GET['_status'] ) { + $_GET['post_status'] = null; + unset($_GET['_status'], $_GET['post_status']); + } else { + $_GET['post_status'] = $_GET['_status']; + } + + $done = bulk_edit_posts($_GET); + } + break; + } + + $sendback = wp_get_referer(); + if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('page-new.php'); + elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php'); + if ( isset($done) ) { + $done['updated'] = count( $done['updated'] ); + $done['skipped'] = count( $done['skipped'] ); + $done['locked'] = count( $done['locked'] ); + $sendback = add_query_arg( $done, $sendback ); + } + if ( isset($deleted) ) + $sendback = add_query_arg('deleted', $deleted, $sendback); + wp_redirect($sendback); + exit(); +} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { + wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); + exit; +} + +if ( empty($title) ) + $title = __('Edit Pages'); +$parent_file = 'edit-pages.php'; +wp_enqueue_script('inline-edit-post'); + +$post_stati = array( // array( adj, noun ) + 'publish' => array(__('Published|page'), __('Published pages'), _n_noop('Published (%s)|page', 'Published (%s)')), + 'future' => array(__('Scheduled|page'), __('Scheduled pages'), _n_noop('Scheduled (%s)|page', 'Scheduled (%s)')), + 'pending' => array(__('Pending Review|page'), __('Pending pages'), _n_noop('Pending Review (%s)|page', 'Pending Review (%s)')), + 'draft' => array(__('Draft|page'), _c('Drafts|manage posts header'), _n_noop('Draft (%s)|page', 'Drafts (%s)')), + 'private' => array(__('Private|page'), __('Private pages'), _n_noop('Private (%s)|page', 'Private (%s)')) + ); + +$query = array('post_type' => 'page', 'orderby' => 'menu_order title', 'what_to_show' => 'posts', + 'posts_per_page' => -1, 'posts_per_archive_page' => -1, 'order' => 'asc'); + +$post_status_label = __('Pages'); +if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) { + $post_status_label = $post_stati[$_GET['post_status']][1]; + $query['post_status'] = $_GET['post_status']; + $query['perm'] = 'readable'; +} + +$query = apply_filters('manage_pages_query', $query); +wp($query); + +if ( is_singular() ) { + wp_enqueue_script( 'admin-comments' ); + enqueue_comment_hotkeys_js(); +} + +require_once('admin-header.php'); ?> + +
+ +

' . __('Search results for “%s”') . '', wp_specialchars( get_search_query() ) ); ?> +

+ + +

+ +

+ + + +

|

+ + +
+ + + + + + + + + + +
+ +post_count / $per_page); +$page_links = paginate_links( array( + 'base' => add_query_arg( 'pagenum', '%#%' ), + 'format' => '', + 'prev_text' => __('«'), + 'next_text' => __('»'), + 'total' => $num_pages, + 'current' => $pagenum +)); + +if ( $page_links ) : ?> +
' . __( 'Displaying %s–%s of %s' ) . '%s', + number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ), + number_format_i18n( min( $pagenum * $per_page, $wp_query->post_count ) ), + number_format_i18n( $wp_query->post_count ), + $page_links +); echo $page_links_text; ?>
+ + +
+ + + +
+ +
+
+ +
+ + + + + + + + + + + + + + + + + +
+ +
+$page_links_text
"; +?> + +
+ + +
+ +
+
+ + +
+

+ + + + + + +
+ + +get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved != 'spam' ORDER BY comment_date", $id) ); + if ( $comments ) : + // Make sure comments, post, and post_author are cached + update_comment_cache($comments); + $post = get_post($id); + $authordata = get_userdata($post->post_author); + ?> + +
+ + + + + + + + + + +comment_ID, 'single', false, false ); +?> + +
+ + + + + + + + diff -uNr a/blog/wp-admin/edit.php b/blog/wp-admin/edit.php --- a/blog/wp-admin/edit.php false +++ b/blog/wp-admin/edit.php e2a630b4dc58e5148478709c9458c4e32cc6f50367a5e988c460a2bf4cbfb796e73470940e245a63de4954e671354693e2074422d9bb85a7c980d0e95a133627 @@ -0,0 +1,315 @@ +post_type == 'attachment' ) { + if ( ! wp_delete_attachment($post_id_del) ) + wp_die( __('Error in deleting...') ); + } else { + if ( !wp_delete_post($post_id_del) ) + wp_die( __('Error in deleting...') ); + } + $deleted++; + } + } + break; + case 'edit': + if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) { + check_admin_referer('bulk-posts'); + + if ( -1 == $_GET['_status'] ) { + $_GET['post_status'] = null; + unset($_GET['_status'], $_GET['post_status']); + } else { + $_GET['post_status'] = $_GET['_status']; + } + + $done = bulk_edit_posts($_GET); + } + break; + } + + $sendback = wp_get_referer(); + if ( strpos($sendback, 'post.php') !== false ) $sendback = admin_url('post-new.php'); + elseif ( strpos($sendback, 'attachments.php') !== false ) $sendback = admin_url('attachments.php'); + if ( isset($done) ) { + $done['updated'] = count( $done['updated'] ); + $done['skipped'] = count( $done['skipped'] ); + $done['locked'] = count( $done['locked'] ); + $sendback = add_query_arg( $done, $sendback ); + } + if ( isset($deleted) ) + $sendback = add_query_arg('deleted', $deleted, $sendback); + wp_redirect($sendback); + exit(); +} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { + wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); + exit; +} + +if ( empty($title) ) + $title = __('Edit Posts'); +$parent_file = 'edit.php'; +wp_enqueue_script('inline-edit-post'); + +list($post_stati, $avail_post_stati) = wp_edit_posts_query(); + +require_once('admin-header.php'); + +if ( !isset( $_GET['paged'] ) ) + $_GET['paged'] = 1; + +if ( empty($_GET['mode']) ) + $mode = 'list'; +else + $mode = attribute_escape($_GET['mode']); ?> + +
+ +

' . __('Search results for “%s”') . '', wp_specialchars( get_search_query() ) ); ?> +

+ + +

|

+ + + +

+ +

+ + +
+ + + + + + + + + + + + +
+ add_query_arg( 'paged', '%#%' ), + 'format' => '', + 'prev_text' => __('«'), + 'next_text' => __('»'), + 'total' => $wp_query->max_num_pages, + 'current' => $_GET['paged'] +)); + +?> + +
+ + + + +posts WHERE post_type = 'post' ORDER BY post_date DESC"; + +$arc_result = $wpdb->get_results( $arc_query ); + +$month_count = count($arc_result); + +if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { +$m = isset($_GET['m']) ? (int)$_GET['m'] : 0; +?> + + + + __('View all categories'), 'hide_empty' => 0, 'hierarchical' => 1, + 'show_count' => 0, 'orderby' => 'name', 'selected' => $cat); +wp_dropdown_categories($dropdown_options); +do_action('restrict_manage_posts'); +?> + + + +
+ + +
' . __( 'Displaying %s–%s of %s' ) . '%s', + number_format_i18n( ( $_GET['paged'] - 1 ) * $wp_query->query_vars['posts_per_page'] + 1 ), + number_format_i18n( min( $_GET['paged'] * $wp_query->query_vars['posts_per_page'], $wp_query->found_posts ) ), + number_format_i18n( $wp_query->found_posts ), + $page_links +); echo $page_links_text; ?>
+ + + + +
+
+ +
+ + + +
+ +$page_links_text
"; +?> + +
+ + +
+
+
+
+ + +
+

+ + + + + + +
+ +
+ + + + + + diff -uNr a/blog/wp-admin/edit-post-rows.php b/blog/wp-admin/edit-post-rows.php --- a/blog/wp-admin/edit-post-rows.php false +++ b/blog/wp-admin/edit-post-rows.php 1b6f7c0134e6928e311bccb9daeb63f2e4764d4ca0fd4590a9d6cdfddbf7892f0e2e84f32a5e204f2ced8af6bbf07daafb0ff4b697b9e532fb82f622ede8cfb2 @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff -uNr a/blog/wp-admin/edit-tag-form.php b/blog/wp-admin/edit-tag-form.php --- a/blog/wp-admin/edit-tag-form.php false +++ b/blog/wp-admin/edit-tag-form.php 8e6544130bd95c4a75b92a7430b3b40032f9deee6a54d31d77871860bae3408f985b8230e7bc8cecd94d8ea4b0b67fabb0de5b5d9e83a8e624ee5fc1a52ff346 @@ -0,0 +1,40 @@ + +

+ + +
+ +

+
+
+ + + + + + + + + + + + +
+

+

+

+ +
+
diff -uNr a/blog/wp-admin/edit-tags.php b/blog/wp-admin/edit-tags.php --- a/blog/wp-admin/edit-tags.php false +++ b/blog/wp-admin/edit-tags.php 755f0a0769b53ae91a8ef085d5737686e36a408d9452eee53c472f4b9d065eba332cab1df48908104585669d2400a8c8387f291b4436f008aa3c24d6d829e9a1 @@ -0,0 +1,306 @@ + + +
+ +

' . __('Search results for “%s”') . '', wp_specialchars( stripslashes($_GET['s']) ) ); ?> +

+ + +

+ + +
+ +
+
+ +
+ +
+
+
+
+ add_query_arg( 'pagenum', '%#%' ), + 'format' => '', + 'prev_text' => __('«'), + 'next_text' => __('»'), + 'total' => ceil(wp_count_terms('post_tag') / $tagsperpage), + 'current' => $pagenum +)); + +if ( $page_links ) + echo "
$page_links
"; +?> + +
+ + + +
+ +
+
+ +
+ + + + + + + + + + + + + + + + + +
+ +
+$page_links
"; +?> + +
+ + +
+ +
+
+ +
+ +
+
+ +
+
+ +
+

+ 'edit')); +else + wp_tag_cloud(); +?> +
+ + + +
+

+
+
+ + + +
+ + +

+
+ +
+ + +

+
+ +

+ +
+ + +
+
+ +
+ + + + + + + diff -uNr a/blog/wp-admin/export.php b/blog/wp-admin/export.php --- a/blog/wp-admin/export.php false +++ b/blog/wp-admin/export.php 47d95b0664addb9cee2d30ef19c11d5491dafcefbecbbe8c11c879d2d365f59c69dcc9e8dab678f27a593c13aab5d24344031dab1b1c96c6296f3965b1427fc9 @@ -0,0 +1,62 @@ + + +
+ +

+ +

+

+

+
+

+ + + + + + +
+ +
+

+ +

+
+
+ + diff -uNr a/blog/wp-admin/gears-manifest.php b/blog/wp-admin/gears-manifest.php --- a/blog/wp-admin/gears-manifest.php false +++ b/blog/wp-admin/gears-manifest.php 3b9746abb3bbda2d57393709a3ac2e9442598e965e8a827aaa18fc35547a79ef5fe1aff6c71e684d2abe53684a0bc9d907cffb1cb3132ddd74428e1e5d38f3c9 @@ -0,0 +1,317 @@ +registered as $script ) { + if ( empty($script->src) ) continue; + $ver = empty($script->ver) ? $wp_version : $script->ver; + if ( 'editor' == $script->handle ) $mce_ver = $script->ver; + $src = str_replace( array( '/wp-admin/', '/wp-includes/' ), array( '', '../wp-includes/' ), $script->src ); + $defaults .= '{ "url" : "' . $src . '?ver=' . $ver . '" },' . "\n"; + $man_version .= $ver; +} + +foreach ( $wp_styles->registered as $style ) { + if ( empty($style->src) ) continue; + + $ver = empty($style->ver) ? $wp_version : $style->ver; + $src = str_replace( array( '/wp-admin/', '/wp-includes/' ), array( '', '../wp-includes/' ), $style->src ); + if ( 'colors' == $style->handle ) $src = 'css/colors-classic.css'; + $defaults .= '{ "url" : "' . $src . '?ver=' . $ver . '" },' . "\n"; + + if ( isset($style->extra['rtl']) && $style->extra['rtl'] ) { + if ( is_bool( $style->extra['rtl'] ) ) + $rtl_href = str_replace( '.css', '-rtl.css', $src ); + else + $rtl_href = str_replace( array( '/wp-admin/', '/wp-includes/' ), array( '', '../wp-includes/' ), $style->extra['rtl'] ); + + $defaults .= '{ "url" : "' . $rtl_href . '?ver=' . $ver . '" },' . "\n"; + } + $man_version .= $ver; +} + +$man_version = md5($man_version); + +header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' ); +header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); +header( 'Cache-Control: no-cache, must-revalidate, max-age=0' ); +header( 'Pragma: no-cache' ); +header( 'Content-Type: application/x-javascript; charset=UTF-8' ); +?> +{ +"betaManifestVersion" : 1, +"version" : "_20081201", +"entries" : [ + + +{ "url" : "images/align-center.png" }, +{ "url" : "images/align-left.png" }, +{ "url" : "images/align-none.png" }, +{ "url" : "images/align-right.png" }, +{ "url" : "images/archive-link.png" }, +{ "url" : "images/blue-grad.png" }, +{ "url" : "images/browse-happy.gif" }, +{ "url" : "images/bubble_bg.gif" }, +{ "url" : "images/bubble_bg-rtl.gif" }, +{ "url" : "images/button-grad.png" }, +{ "url" : "images/button-grad-active.png" }, +{ "url" : "images/comment-grey-bubble.png" }, +{ "url" : "images/date-button.gif" }, +{ "url" : "images/ed-bg.gif" }, +{ "url" : "images/fade-butt.png" }, +{ "url" : "images/fav.png" }, +{ "url" : "images/fav-arrow.gif" }, +{ "url" : "images/fav-arrow-rtl.gif" }, +{ "url" : "images/fav-top.png" }, +{ "url" : "images/generic.png" }, +{ "url" : "images/gray-grad.png" }, +{ "url" : "images/icons32.png" }, +{ "url" : "images/icons32-vs.png" }, +{ "url" : "images/list.png" }, +{ "url" : "images/list-vs.png" }, +{ "url" : "images/loading.gif" }, +{ "url" : "images/loading-publish.gif" }, +{ "url" : "images/logo.gif" }, +{ "url" : "images/logo-ghost.png" }, +{ "url" : "images/logo-login.gif" }, +{ "url" : "images/media-button-image.gif" }, +{ "url" : "images/media-button-music.gif" }, +{ "url" : "images/media-button-other.gif" }, +{ "url" : "images/media-button-video.gif" }, +{ "url" : "images/menu.png" }, +{ "url" : "images/menu-vs.png" }, +{ "url" : "images/menu-arrows.gif" }, +{ "url" : "images/menu-bits.gif" }, +{ "url" : "images/menu-bits-rtl.gif" }, +{ "url" : "images/menu-dark.gif" }, +{ "url" : "images/menu-dark-rtl.gif" }, +{ "url" : "images/no.png" }, +{ "url" : "images/required.gif" }, +{ "url" : "images/resize.gif" }, +{ "url" : "images/screen-options-left.gif" }, +{ "url" : "images/screen-options-right.gif" }, +{ "url" : "images/screen-options-right-up.gif" }, +{ "url" : "images/se.png" }, +{ "url" : "images/star.gif" }, +{ "url" : "images/toggle-arrow.gif" }, +{ "url" : "images/toggle-arrow-rtl.gif" }, +{ "url" : "images/white-grad.png" }, +{ "url" : "images/white-grad-active.png" }, +{ "url" : "images/wordpress-logo.png" }, +{ "url" : "images/wp-logo.gif" }, +{ "url" : "images/xit.gif" }, +{ "url" : "images/yes.png" }, + + +{ "url" : "../wp-includes/js/tinymce/tiny_mce.js", "src" : "../wp-includes/js/tinymce/tiny_mce.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/langs/wp-langs-en.js", "src" : "../wp-includes/js/tinymce/langs/wp-langs-en.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/wordpress.css", "src" : "../wp-includes/js/tinymce/wordpress.css?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/utils/mctabs.js", "src" : "../wp-includes/js/tinymce/utils/mctabs.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/utils/validate.js", "src" : "../wp-includes/js/tinymce/utils/validate.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/utils/form_utils.js", "src" : "../wp-includes/js/tinymce/utils/form_utils.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/utils/editable_selects.js", "src" : "../wp-includes/js/tinymce/utils/editable_selects.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/tiny_mce_popup.js", "src" : "../wp-includes/js/tinymce/tiny_mce_popup.js?ver=", "ignoreQuery" : true }, + +{ "url" : "../wp-includes/js/tinymce/themes/advanced/editor_template.js", "src" : "../wp-includes/js/tinymce/themes/advanced/editor_template.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/source_editor.htm", "src" : "../wp-includes/js/tinymce/themes/advanced/source_editor.htm?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/anchor.htm", "src" : "../wp-includes/js/tinymce/themes/advanced/anchor.htm?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/image.htm", "src" : "../wp-includes/js/tinymce/themes/advanced/image.htm?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/link.htm", "src" : "../wp-includes/js/tinymce/themes/advanced/link.htm?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/color_picker.htm", "src" : "../wp-includes/js/tinymce/themes/advanced/color_picker.htm?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/charmap.htm", "src" : "../wp-includes/js/tinymce/themes/advanced/charmap.htm?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/color_picker.js", "src" : "../wp-includes/js/tinymce/themes/advanced/js/color_picker.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/charmap.js", "src" : "../wp-includes/js/tinymce/themes/advanced/js/charmap.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/image.js", "src" : "../wp-includes/js/tinymce/themes/advanced/js/image.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/link.js", "src" : "../wp-includes/js/tinymce/themes/advanced/js/link.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/source_editor.js", "src" : "../wp-includes/js/tinymce/themes/advanced/js/source_editor.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/anchor.js", "src" : "../wp-includes/js/tinymce/themes/advanced/js/anchor.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css", "src" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/content.css", "src" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/content.css?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/dialog.css", "src" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/dialog.css?ver=", "ignoreQuery" : true }, + +{ "url" : "../wp-includes/js/tinymce/plugins/autosave/editor_plugin.js", "src" : "../wp-includes/js/tinymce/plugins/autosave/editor_plugin.js?ver=", "ignoreQuery" : true }, + +{ "url" : "../wp-includes/js/tinymce/plugins/fullscreen/editor_plugin.js", "src" : "../wp-includes/js/tinymce/plugins/fullscreen/editor_plugin.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm", "src" : "../wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm?ver=", "ignoreQuery" : true }, + +{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js", "src" : "../wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/template.htm", "src" : "../wp-includes/js/tinymce/plugins/inlinepopups/template.htm?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/window.css", "src" : "../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/window.css?ver=", "ignoreQuery" : true }, + +{ "url" : "../wp-includes/js/tinymce/plugins/media/editor_plugin.js", "src" : "../wp-includes/js/tinymce/plugins/media/editor_plugin.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/plugins/media/js/media.js", "src" : "../wp-includes/js/tinymce/plugins/media/js/media.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/plugins/media/media.htm", "src" : "../wp-includes/js/tinymce/plugins/media/media.htm?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/plugins/media/css/content.css", "src" : "../wp-includes/js/tinymce/plugins/media/css/content.css?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/plugins/media/css/media.css", "src" : "../wp-includes/js/tinymce/plugins/media/css/media.css?ver=", "ignoreQuery" : true }, + +{ "url" : "../wp-includes/js/tinymce/plugins/paste/editor_plugin.js", "src" : "../wp-includes/js/tinymce/plugins/paste/editor_plugin.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/plugins/paste/js/pasteword.js", "src" : "../wp-includes/js/tinymce/plugins/paste/js/pasteword.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/plugins/paste/js/pastetext.js", "src" : "../wp-includes/js/tinymce/plugins/paste/js/pastetext.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/plugins/paste/pasteword.htm", "src" : "../wp-includes/js/tinymce/plugins/paste/pasteword.htm?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/plugins/paste/blank.htm", "src" : "../wp-includes/js/tinymce/plugins/paste/blank.htm?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/plugins/paste/pastetext.htm", "src" : "../wp-includes/js/tinymce/plugins/paste/pastetext.htm?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/plugins/paste/css/pasteword.css", "src" : "../wp-includes/js/tinymce/plugins/paste/css/pasteword.css?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/plugins/paste/css/blank.css", "src" : "../wp-includes/js/tinymce/plugins/paste/css/blank.css?ver=", "ignoreQuery" : true }, + +{ "url" : "../wp-includes/js/tinymce/plugins/safari/editor_plugin.js", "src" : "../wp-includes/js/tinymce/plugins/safari/editor_plugin.js?ver=", "ignoreQuery" : true }, + +{ "url" : "../wp-includes/js/tinymce/plugins/spellchecker/editor_plugin.js", "src" : "../wp-includes/js/tinymce/plugins/spellchecker/editor_plugin.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/plugins/spellchecker/css/content.css", "src" : "../wp-includes/js/tinymce/plugins/spellchecker/css/content.css?ver=", "ignoreQuery" : true }, + +{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js", "src" : "../wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/css/content.css", "src" : "../wp-includes/js/tinymce/plugins/wordpress/css/content.css?ver=", "ignoreQuery" : true }, + +{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.js", "src" : "../wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/editimage.html", "src" : "../wp-includes/js/tinymce/plugins/wpeditimage/editimage.html?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js", "src" : "../wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css", "src" : "../wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css?ver=", "ignoreQuery" : true }, +{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/css/editimage-rtl.css", "src" : "../wp-includes/js/tinymce/plugins/wpeditimage/css/editimage-rtl.css?ver=", "ignoreQuery" : true }, + +{ "url" : "../wp-includes/js/tinymce/plugins/wpgallery/editor_plugin.js", "src" : "../wp-includes/js/tinymce/plugins/wpgallery/editor_plugin.js?ver=", "ignoreQuery" : true }, + +{ "url" : "../wp-includes/js/tinymce/themes/advanced/img/icons.gif" }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/img/colorpicker.jpg" }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/img/fm.gif" }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/img/gotmoxie.png" }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/img/sflogo.png" }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/butt2.png" }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/fade-butt.png" }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/tabs.gif" }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/down_arrow.gif" }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/default/img/progress.gif" }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/default/img/menu_check.gif" }, +{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/default/img/menu_arrow.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/drag.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/corners.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/buttons.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/horizontal.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/alert.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/button.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/confirm.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/vertical.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/media/img/flash.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/media/img/flv_player.swf" }, +{ "url" : "../wp-includes/js/tinymce/plugins/media/img/quicktime.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/media/img/realmedia.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/media/img/shockwave.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/media/img/windowsmedia.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/media/img/trans.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/spellchecker/img/wline.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/more.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/more_bug.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/page.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/page_bug.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/toolbars.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/help.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/image.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/media.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/video.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/audio.gif" }, +{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/img/image.png" }, +{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/img/delete.png" }, +{ "url" : "../wp-includes/js/tinymce/plugins/wpgallery/img/delete.png" }, +{ "url" : "../wp-includes/js/tinymce/plugins/wpgallery/img/edit.png" }, +{ "url" : "../wp-includes/js/tinymce/plugins/wpgallery/img/gallery.png" }, + + +{ "url" : "../wp-includes/images/crystal/archive.png" }, +{ "url" : "../wp-includes/images/crystal/audio.png" }, +{ "url" : "../wp-includes/images/crystal/code.png" }, +{ "url" : "../wp-includes/images/crystal/default.png" }, +{ "url" : "../wp-includes/images/crystal/document.png" }, +{ "url" : "../wp-includes/images/crystal/interactive.png" }, +{ "url" : "../wp-includes/images/crystal/text.png" }, +{ "url" : "../wp-includes/images/crystal/video.png" }, +{ "url" : "../wp-includes/images/crystal/spreadsheet.png" }, +{ "url" : "../wp-includes/images/rss.png" }, +{ "url" : "../wp-includes/js/thickbox/loadingAnimation.gif" }, +{ "url" : "../wp-includes/js/thickbox/tb-close.png" } +]} diff -uNr a/blog/wp-admin/.htaccess b/blog/wp-admin/.htaccess --- a/blog/wp-admin/.htaccess false +++ b/blog/wp-admin/.htaccess 22c75815ccf0e3b8efe491b9245465d75f906c435609681b644aa9c9f76bb3c6cb28e85a7474573b4f21c161c1a060e219339f1b4a1e3b238e4bc40492cfe0dd @@ -0,0 +1,3 @@ +Order deny,allow +#Deny from all +Allow from all diff -uNr a/blog/wp-admin/images/README b/blog/wp-admin/images/README --- a/blog/wp-admin/images/README false +++ b/blog/wp-admin/images/README 86525f2c7086039d79e5bf92869d02934a44716812433ca3a90e18a8d03745785c5ca54fe8c39e681b3b13c00c33a5128884a28c8cbaccbc65d0b401d901ec2e @@ -0,0 +1 @@ +Placeholder. diff -uNr a/blog/wp-admin/import/blogger.php b/blog/wp-admin/import/blogger.php --- a/blog/wp-admin/import/blogger.php false +++ b/blog/wp-admin/import/blogger.php 50db575f925ff1cab829c7b0953069be649c16c9571b06b5db2929dd954ad580f4cab1fd3cd39073e9a5ce02cf5d47dde4269c21c480e6aa2d29ca89be293b2a @@ -0,0 +1,1061 @@ + + ".screen_icon()." +

$title

+

$welcome

$prereqs

$stepone

+
+

+ + + + + +

+
+ \n"; + } + + function uh_oh($title, $message, $info) { + echo "
"; + screen_icon(); + echo "

$title

$message

$info
"; + } + + function auth() { + // We have a single-use token that must be upgraded to a session token. + $token = preg_replace( '/[^-_0-9a-zA-Z]/', '', $_GET['token'] ); + $headers = array( + "GET /accounts/AuthSubSessionToken HTTP/1.0", + "Authorization: AuthSub token=\"$token\"" + ); + $request = join( "\r\n", $headers ) . "\r\n\r\n"; + $sock = $this->_get_auth_sock( ); + if ( ! $sock ) return false; + $response = $this->_txrx( $sock, $request ); + preg_match( '/token=([-_0-9a-z]+)/i', $response, $matches ); + if ( empty( $matches[1] ) ) { + $this->uh_oh( + __( 'Authorization failed' ), + __( 'Something went wrong. If the problem persists, send this info to support:' ), + htmlspecialchars($response) + ); + return false; + } + $this->token = $matches[1]; + + wp_redirect( remove_query_arg( array( 'token', 'noheader' ) ) ); + } + + function get_token_info() { + $headers = array( + "GET /accounts/AuthSubTokenInfo HTTP/1.0", + "Authorization: AuthSub token=\"$this->token\"" + ); + $request = join( "\r\n", $headers ) . "\r\n\r\n"; + $sock = $this->_get_auth_sock( ); + if ( ! $sock ) return; + $response = $this->_txrx( $sock, $request ); + return $this->parse_response($response); + } + + function token_is_valid() { + $info = $this->get_token_info(); + + if ( $info['code'] == 200 ) + return true; + + return false; + } + + function show_blogs($iter = 0) { + if ( empty($this->blogs) ) { + $headers = array( + "GET /feeds/default/blogs HTTP/1.0", + "Host: www.blogger.com", + "Authorization: AuthSub token=\"$this->token\"" + ); + $request = join( "\r\n", $headers ) . "\r\n\r\n"; + $sock = $this->_get_blogger_sock( ); + if ( ! $sock ) return; + $response = $this->_txrx( $sock, $request ); + + // Quick and dirty XML mining. + list( $headers, $xml ) = explode( "\r\n\r\n", $response ); + $p = xml_parser_create(); + xml_parse_into_struct($p, $xml, $vals, $index); + xml_parser_free($p); + + $this->title = $vals[$index['TITLE'][0]]['value']; + + // Give it a few retries... this step often flakes out the first time. + if ( empty( $index['ENTRY'] ) ) { + if ( $iter < 3 ) { + return $this->show_blogs($iter + 1); + } else { + $this->uh_oh( + __('Trouble signing in'), + __('We were not able to gain access to your account. Try starting over.'), + '' + ); + return false; + } + } + + foreach ( $index['ENTRY'] as $i ) { + $blog = array(); + while ( ( $tag = $vals[$i] ) && ! ( $tag['tag'] == 'ENTRY' && $tag['type'] == 'close' ) ) { + if ( $tag['tag'] == 'TITLE' ) { + $blog['title'] = $tag['value']; + } elseif ( $tag['tag'] == 'SUMMARY' ) { + $blog['summary'] == $tag['value']; + } elseif ( $tag['tag'] == 'LINK' ) { + if ( $tag['attributes']['REL'] == 'alternate' && $tag['attributes']['TYPE'] == 'text/html' ) { + $parts = parse_url( $tag['attributes']['HREF'] ); + $blog['host'] = $parts['host']; + } elseif ( $tag['attributes']['REL'] == 'edit' ) + $blog['gateway'] = $tag['attributes']['HREF']; + } + ++$i; + } + if ( ! empty ( $blog ) ) { + $blog['total_posts'] = $this->get_total_results('posts', $blog['host']); + $blog['total_comments'] = $this->get_total_results('comments', $blog['host']); + $blog['mode'] = 'init'; + $this->blogs[] = $blog; + } + } + + if ( empty( $this->blogs ) ) { + $this->uh_oh( + __('No blogs found'), + __('We were able to log in but there were no blogs. Try a different account next time.'), + '' + ); + return false; + } + } +//echo '
'.print_r($this,1).'
'; + $start = js_escape( __('Import') ); + $continue = js_escape( __('Continue') ); + $stop = js_escape( __('Importing...') ); + $authors = js_escape( __('Set Authors') ); + $loadauth = js_escape( __('Preparing author mapping form...') ); + $authhead = js_escape( __('Final Step: Author Mapping') ); + $nothing = js_escape( __('Nothing was imported. Had you already imported this blog?') ); + $title = __('Blogger Blogs'); + $name = __('Blog Name'); + $url = __('Blog URL'); + $action = __('The Magic Button'); + $posts = __('Posts'); + $comments = __('Comments'); + $noscript = __('This feature requires Javascript but it seems to be disabled. Please enable Javascript and then reload this page. Don\'t worry, you can turn it back off when you\'re done.'); + + $interval = STATUS_INTERVAL * 1000; + + foreach ( $this->blogs as $i => $blog ) { + if ( $blog['mode'] == 'init' ) + $value = $start; + elseif ( $blog['mode'] == 'posts' || $blog['mode'] == 'comments' ) + $value = $continue; + else + $value = $authors; + $blogtitle = js_escape( $blog['title'] ); + $pdone = isset($blog['posts_done']) ? (int) $blog['posts_done'] : 0; + $cdone = isset($blog['comments_done']) ? (int) $blog['comments_done'] : 0; + $init .= "blogs[$i]=new blog($i,'$blogtitle','{$blog['mode']}'," . $this->get_js_status($i) . ');'; + $pstat = "
 
$pdone/{$blog['total_posts']}
"; + $cstat = "
 
$cdone/{$blog['total_comments']}
"; + $rows .= "$blogtitle{$blog['host']}$pstat$cstat\n"; + } + + echo "

$title

\n$rows
$name$url$posts$comments$action
"; + echo " + \n"; + } + + // Handy function for stopping the script after a number of seconds. + function have_time() { + global $importer_started; + if ( time() - $importer_started > MAX_EXECUTION_TIME ) + die('continue'); + return true; + } + + function get_total_results($type, $host) { + $headers = array( + "GET /feeds/$type/default?max-results=1&start-index=2 HTTP/1.0", + "Host: $host", + "Authorization: AuthSub token=\"$this->token\"" + ); + $request = join( "\r\n", $headers ) . "\r\n\r\n"; + $sock = $this->_get_blogger_sock( $host ); + if ( ! $sock ) return; + $response = $this->_txrx( $sock, $request ); + $response = $this->parse_response( $response ); + $parser = xml_parser_create(); + xml_parse_into_struct($parser, $response['body'], $struct, $index); + xml_parser_free($parser); + $total_results = $struct[$index['OPENSEARCH:TOTALRESULTS'][0]]['value']; + return (int) $total_results; + } + + function import_blog($blogID) { + global $importing_blog; + $importing_blog = $blogID; + + if ( isset($_GET['authors']) ) + return print($this->get_author_form()); + + header('Content-Type: text/plain'); + + if ( isset($_GET['status']) ) + die($this->get_js_status()); + + if ( isset($_GET['saveauthors']) ) + die($this->save_authors()); + + $blog = $this->blogs[$blogID]; + $total_results = $this->get_total_results('posts', $blog['host']); + $this->blogs[$importing_blog]['total_posts'] = $total_results; + + $start_index = $total_results - MAX_RESULTS + 1; + + if ( isset( $this->blogs[$importing_blog]['posts_start_index'] ) ) + $start_index = (int) $this->blogs[$importing_blog]['posts_start_index']; + elseif ( $total_results > MAX_RESULTS ) + $start_index = $total_results - MAX_RESULTS + 1; + else + $start_index = 1; + + // This will be positive until we have finished importing posts + if ( $start_index > 0 ) { + // Grab all the posts + $this->blogs[$importing_blog]['mode'] = 'posts'; + $query = "start-index=$start_index&max-results=" . MAX_RESULTS; + do { + $index = $struct = $entries = array(); + $headers = array( + "GET /feeds/posts/default?$query HTTP/1.0", + "Host: {$blog['host']}", + "Authorization: AuthSub token=\"$this->token\"" + ); + $request = join( "\r\n", $headers ) . "\r\n\r\n"; + $sock = $this->_get_blogger_sock( $blog['host'] ); + if ( ! $sock ) return; // TODO: Error handling + $response = $this->_txrx( $sock, $request ); + + $response = $this->parse_response( $response ); + + // Extract the entries and send for insertion + preg_match_all( '/]*>.*?<\/entry>/s', $response['body'], $matches ); + if ( count( $matches[0] ) ) { + $entries = array_reverse($matches[0]); + foreach ( $entries as $entry ) { + $entry = "$entry"; + $AtomParser = new AtomParser(); + $AtomParser->parse( $entry ); + $result = $this->import_post($AtomParser->entry); + if ( is_wp_error( $result ) ) + return $result; + unset($AtomParser); + } + } else break; + + // Get the 'previous' query string which we'll use on the next iteration + $query = ''; + $links = preg_match_all('/]*)>/', $response['body'], $matches); + if ( count( $matches[1] ) ) + foreach ( $matches[1] as $match ) + if ( preg_match('/rel=.previous./', $match) ) + $query = html_entity_decode( preg_replace('/^.*href=[\'"].*\?(.+)[\'"].*$/', '$1', $match) ); + + if ( $query ) { + parse_str($query, $q); + $this->blogs[$importing_blog]['posts_start_index'] = (int) $q['start-index']; + } else + $this->blogs[$importing_blog]['posts_start_index'] = 0; + $this->save_vars(); + } while ( !empty( $query ) && $this->have_time() ); + } + + $total_results = $this->get_total_results( 'comments', $blog['host'] ); + $this->blogs[$importing_blog]['total_comments'] = $total_results; + + if ( isset( $this->blogs[$importing_blog]['comments_start_index'] ) ) + $start_index = (int) $this->blogs[$importing_blog]['comments_start_index']; + elseif ( $total_results > MAX_RESULTS ) + $start_index = $total_results - MAX_RESULTS + 1; + else + $start_index = 1; + + if ( $start_index > 0 ) { + // Grab all the comments + $this->blogs[$importing_blog]['mode'] = 'comments'; + $query = "start-index=$start_index&max-results=" . MAX_RESULTS; + do { + $index = $struct = $entries = array(); + $headers = array( + "GET /feeds/comments/default?$query HTTP/1.0", + "Host: {$blog['host']}", + "Authorization: AuthSub token=\"$this->token\"" + ); + $request = join( "\r\n", $headers ) . "\r\n\r\n"; + $sock = $this->_get_blogger_sock( $blog['host'] ); + if ( ! $sock ) return; // TODO: Error handling + $response = $this->_txrx( $sock, $request ); + + $response = $this->parse_response( $response ); + + // Extract the comments and send for insertion + preg_match_all( '/]*>.*?<\/entry>/s', $response['body'], $matches ); + if ( count( $matches[0] ) ) { + $entries = array_reverse( $matches[0] ); + foreach ( $entries as $entry ) { + $entry = "$entry"; + $AtomParser = new AtomParser(); + $AtomParser->parse( $entry ); + $this->import_comment($AtomParser->entry); + unset($AtomParser); + } + } + + // Get the 'previous' query string which we'll use on the next iteration + $query = ''; + $links = preg_match_all('/]*)>/', $response['body'], $matches); + if ( count( $matches[1] ) ) + foreach ( $matches[1] as $match ) + if ( preg_match('/rel=.previous./', $match) ) + $query = html_entity_decode( preg_replace('/^.*href=[\'"].*\?(.+)[\'"].*$/', '$1', $match) ); + + parse_str($query, $q); + + $this->blogs[$importing_blog]['comments_start_index'] = (int) $q['start-index']; + $this->save_vars(); + } while ( !empty( $query ) && $this->have_time() ); + } + $this->blogs[$importing_blog]['mode'] = 'authors'; + $this->save_vars(); + if ( !$this->blogs[$importing_blog]['posts_done'] && !$this->blogs[$importing_blog]['comments_done'] ) + die('nothing'); + do_action('import_done', 'blogger'); + die('done'); + } + + function convert_date( $date ) { + preg_match('#([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:\.[0-9]+)?(Z|[\+|\-][0-9]{2,4}){0,1}#', $date, $date_bits); + $offset = iso8601_timezone_to_offset( $date_bits[7] ); + $timestamp = gmmktime($date_bits[4], $date_bits[5], $date_bits[6], $date_bits[2], $date_bits[3], $date_bits[1]); + $timestamp -= $offset; // Convert from Blogger local time to GMT + $timestamp += get_option('gmt_offset') * 3600; // Convert from GMT to WP local time + return gmdate('Y-m-d H:i:s', $timestamp); + } + + function no_apos( $string ) { + return str_replace( ''', "'", $string); + } + + function min_whitespace( $string ) { + return preg_replace( '|\s+|', ' ', $string ); + } + + function import_post( $entry ) { + global $importing_blog; + + // The old permalink is all Blogger gives us to link comments to their posts. + if ( isset( $entry->draft ) ) + $rel = 'self'; + else + $rel = 'alternate'; + foreach ( $entry->links as $link ) { + if ( $link['rel'] == $rel ) { + $parts = parse_url( $link['href'] ); + $entry->old_permalink = $parts['path']; + break; + } + } + + $post_date = $this->convert_date( $entry->published ); + $post_content = trim( addslashes( $this->no_apos( html_entity_decode( $entry->content ) ) ) ); + $post_title = trim( addslashes( $this->no_apos( $this->min_whitespace( $entry->title ) ) ) ); + $post_status = isset( $entry->draft ) ? 'draft' : 'publish'; + + // Clean up content + $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); + $post_content = str_replace('
', '
', $post_content); + $post_content = str_replace('
', '
', $post_content); + + // Checks for duplicates + if ( isset( $this->blogs[$importing_blog]['posts'][$entry->old_permalink] ) ) { + ++$this->blogs[$importing_blog]['posts_skipped']; + } elseif ( $post_id = post_exists( $post_title, $post_content, $post_date ) ) { + $this->blogs[$importing_blog]['posts'][$entry->old_permalink] = $post_id; + ++$this->blogs[$importing_blog]['posts_skipped']; + } else { + $post = compact('post_date', 'post_content', 'post_title', 'post_status'); + + $post_id = wp_insert_post($post); + if ( is_wp_error( $post_id ) ) + return $post_id; + + wp_create_categories( array_map( 'addslashes', $entry->categories ), $post_id ); + + $author = $this->no_apos( strip_tags( $entry->author ) ); + + add_post_meta( $post_id, 'blogger_blog', $this->blogs[$importing_blog]['host'], true ); + add_post_meta( $post_id, 'blogger_author', $author, true ); + add_post_meta( $post_id, 'blogger_permalink', $entry->old_permalink, true ); + + $this->blogs[$importing_blog]['posts'][$entry->old_permalink] = $post_id; + ++$this->blogs[$importing_blog]['posts_done']; + } + $this->save_vars(); + return; + } + + function import_comment( $entry ) { + global $importing_blog; + + // Drop the #fragment and we have the comment's old post permalink. + foreach ( $entry->links as $link ) { + if ( $link['rel'] == 'alternate' ) { + $parts = parse_url( $link['href'] ); + $entry->old_permalink = $parts['fragment']; + $entry->old_post_permalink = $parts['path']; + break; + } + } + + $comment_post_ID = (int) $this->blogs[$importing_blog]['posts'][$entry->old_post_permalink]; + preg_match('#(.+?).*(?:\(.+?))?#', $entry->author, $matches); + $comment_author = addslashes( $this->no_apos( strip_tags( (string) $matches[1] ) ) ); + $comment_author_url = addslashes( $this->no_apos( strip_tags( (string) $matches[2] ) ) ); + $comment_date = $this->convert_date( $entry->updated ); + $comment_content = addslashes( $this->no_apos( html_entity_decode( $entry->content ) ) ); + + // Clean up content + $comment_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $comment_content); + $comment_content = str_replace('
', '
', $comment_content); + $comment_content = str_replace('
', '
', $comment_content); + + // Checks for duplicates + if ( + isset( $this->blogs[$importing_blog]['comments'][$entry->old_permalink] ) || + comment_exists( $comment_author, $comment_date ) + ) { + ++$this->blogs[$importing_blog]['comments_skipped']; + } else { + $comment = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_date', 'comment_content'); + + $comment_id = wp_insert_comment($comment); + + $this->blogs[$importing_blog]['comments'][$entry->old_permalink] = $comment_id; + + ++$this->blogs[$importing_blog]['comments_done']; + } + $this->save_vars(); + } + + function get_js_status($blog = false) { + global $importing_blog; + if ( $blog === false ) + $blog = $this->blogs[$importing_blog]; + else + $blog = $this->blogs[$blog]; + $p1 = isset( $blog['posts_done'] ) ? (int) $blog['posts_done'] : 0; + $p2 = isset( $blog['total_posts'] ) ? (int) $blog['total_posts'] : 0; + $c1 = isset( $blog['comments_done'] ) ? (int) $blog['comments_done'] : 0; + $c2 = isset( $blog['total_comments'] ) ? (int) $blog['total_comments'] : 0; + return "{p1:$p1,p2:$p2,c1:$c1,c2:$c2}"; + } + + function get_author_form($blog = false) { + global $importing_blog, $wpdb, $current_user; + if ( $blog === false ) + $blog = & $this->blogs[$importing_blog]; + else + $blog = & $this->blogs[$blog]; + + if ( !isset( $blog['authors'] ) ) { + $post_ids = array_values($blog['posts']); + $authors = (array) $wpdb->get_col("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = 'blogger_author' AND post_id IN (" . join( ',', $post_ids ) . ")"); + $blog['authors'] = array_map(null, $authors, array_fill(0, count($authors), $current_user->ID)); + $this->save_vars(); + } + + $directions = __('All posts were imported with the current user as author. Use this form to move each Blogger user\'s posts to a different WordPress user. You may add users and then return to this page and complete the user mapping. This form may be used as many times as you like until you activate the "Restart" function below.'); + $heading = __('Author mapping'); + $blogtitle = "{$blog['title']} ({$blog['host']})"; + $mapthis = __('Blogger username'); + $tothis = __('WordPress login'); + $submit = js_escape( __('Save Changes') ); + + foreach ( $blog['authors'] as $i => $author ) + $rows .= ""; + + return "

$heading

$blogtitle

$directions

$rows
$mapthis$tothis
"; + } + + function get_user_options($current) { + global $importer_users; + if ( ! isset( $importer_users ) ) + $importer_users = (array) get_users_of_blog(); + + foreach ( $importer_users as $user ) { + $sel = ( $user->user_id == $current ) ? " selected='selected'" : ''; + $options .= ""; + } + + return $options; + } + + function save_authors() { + global $importing_blog, $wpdb; + $authors = (array) $_POST['authors']; + + $host = $this->blogs[$importing_blog]['host']; + + // Get an array of posts => authors + $post_ids = (array) $wpdb->get_col( $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'blogger_blog' AND meta_value = %s", $host) ); + $post_ids = join( ',', $post_ids ); + $results = (array) $wpdb->get_results("SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = 'blogger_author' AND post_id IN ($post_ids)"); + foreach ( $results as $row ) + $authors_posts[$row->post_id] = $row->meta_value; + + foreach ( $authors as $author => $user_id ) { + $user_id = (int) $user_id; + + // Skip authors that haven't been changed + if ( $user_id == $this->blogs[$importing_blog]['authors'][$author][1] ) + continue; + + // Get a list of the selected author's posts + $post_ids = (array) array_keys( $authors_posts, $this->blogs[$importing_blog]['authors'][$author][0] ); + $post_ids = join( ',', $post_ids); + + $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_author = %d WHERE id IN ($post_ids)", $user_id) ); + $this->blogs[$importing_blog]['authors'][$author][1] = $user_id; + } + $this->save_vars(); + + wp_redirect('edit.php'); + } + + function _get_auth_sock() { + // Connect to https://www.google.com + if ( !$sock = @ fsockopen('ssl://www.google.com', 443, $errno, $errstr) ) { + $this->uh_oh( + __('Could not connect to https://www.google.com'), + __('There was a problem opening a secure connection to Google. This is what went wrong:'), + "$errstr ($errno)" + ); + return false; + } + return $sock; + } + + function _get_blogger_sock($host = 'www2.blogger.com') { + if ( !$sock = @ fsockopen($host, 80, $errno, $errstr) ) { + $this->uh_oh( + sprintf( __('Could not connect to %s'), $host ), + __('There was a problem opening a connection to Blogger. This is what went wrong:'), + "$errstr ($errno)" + ); + return false; + } + return $sock; + } + + function _txrx( $sock, $request ) { + fwrite( $sock, $request ); + while ( ! feof( $sock ) ) + $response .= @ fread ( $sock, 8192 ); + fclose( $sock ); + return $response; + } + + function revoke($token) { + $headers = array( + "GET /accounts/AuthSubRevokeToken HTTP/1.0", + "Authorization: AuthSub token=\"$token\"" + ); + $request = join( "\r\n", $headers ) . "\r\n\r\n"; + $sock = $this->_get_auth_sock( ); + if ( ! $sock ) return false; + $this->_txrx( $sock, $request ); + } + + function restart() { + global $wpdb; + $options = get_option( 'blogger_importer' ); + + if ( isset( $options['token'] ) ) + $this->revoke( $options['token'] ); + + delete_option('blogger_importer'); + $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key = 'blogger_author'"); + wp_redirect('?import=blogger'); + } + + // 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); + } + + // Step 9: Congratulate the user + function congrats() { + $blog = (int) $_GET['blog']; + echo '

'.__('Congratulations!').'

'.__('Now that you have imported your Blogger blog into WordPress, what are you going to do? Here are some suggestions:').'

  • '.__('That was hard work! Take a break.').'
  • '; + if ( count($this->import['blogs']) > 1 ) + echo '
  • '.__('In case you haven\'t done it already, you can import the posts from your other blogs:'). $this->show_blogs() . '
  • '; + if ( $n = count($this->import['blogs'][$blog]['newusers']) ) + echo '
  • '.sprintf(__('Go to Authors & Users, 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').'
  • '; + echo '
  • '.__('For security, click the link below to reset this importer.').'
  • '; + echo '
'; + } + + // Figures out what to do, then does it. + function start() { + if ( isset($_POST['restart']) ) + $this->restart(); + + $options = get_option('blogger_importer'); + + if ( is_array($options) ) + foreach ( $options as $key => $value ) + $this->$key = $value; + + if ( isset( $_REQUEST['blog'] ) ) { + $blog = is_array($_REQUEST['blog']) ? array_shift( $keys = array_keys( $_REQUEST['blog'] ) ) : $_REQUEST['blog']; + $blog = (int) $blog; + $result = $this->import_blog( $blog ); + if ( is_wp_error( $result ) ) + echo $result->get_error_message(); + } elseif ( isset($_GET['token']) ) + $this->auth(); + elseif ( isset($this->token) && $this->token_is_valid() ) + $this->show_blogs(); + else + $this->greet(); + + $saved = $this->save_vars(); + + if ( $saved && !isset($_GET['noheader']) ) { + $restart = __('Restart'); + $message = __('We have saved some information about your Blogger account in your WordPress database. Clearing this information will allow you to start over. Restarting will not affect any posts you have already imported. If you attempt to re-import a blog, duplicate posts and comments will be skipped.'); + $submit = __('Clear account information'); + echo "

$restart

$message

"; + } + } + + function save_vars() { + $vars = get_object_vars($this); + update_option( 'blogger_importer', $vars ); + + return !empty($vars); + } + + function admin_head() { +?> + +entry = new AtomEntry(); + $this->map_attrs_func = create_function('$k,$v', 'return "$k=\"$v\"";'); + $this->map_xmlns_func = create_function('$p,$n', '$xd = "xmlns"; if(strlen($n[0])>0) $xd .= ":{$n[0]}"; return "{$xd}=\"{$n[1]}\"";'); + } + + function parse($xml) { + + global $app_logging; + array_unshift($this->ns_contexts, array()); + + $parser = xml_parser_create_ns(); + xml_set_object($parser, $this); + xml_set_element_handler($parser, "start_element", "end_element"); + xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0); + xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,0); + xml_set_character_data_handler($parser, "cdata"); + xml_set_default_handler($parser, "_default"); + xml_set_start_namespace_decl_handler($parser, "start_ns"); + xml_set_end_namespace_decl_handler($parser, "end_ns"); + + $contents = ""; + + xml_parse($parser, $xml); + + xml_parser_free($parser); + + return true; + } + + function start_element($parser, $name, $attrs) { + + $tag = array_pop(split(":", $name)); + + array_unshift($this->ns_contexts, $this->ns_decls); + + $this->depth++; + + if(!empty($this->in_content)) { + $attrs_prefix = array(); + + // resolve prefixes for attributes + foreach($attrs as $key => $value) { + $attrs_prefix[$this->ns_to_prefix($key)] = $this->xml_escape($value); + } + $attrs_str = join(' ', array_map($this->map_attrs_func, array_keys($attrs_prefix), array_values($attrs_prefix))); + if(strlen($attrs_str) > 0) { + $attrs_str = " " . $attrs_str; + } + + $xmlns_str = join(' ', array_map($this->map_xmlns_func, array_keys($this->ns_contexts[0]), array_values($this->ns_contexts[0]))); + if(strlen($xmlns_str) > 0) { + $xmlns_str = " " . $xmlns_str; + } + + // handle self-closing tags (case: a new child found right-away, no text node) + if(count($this->in_content) == 2) { + array_push($this->in_content, ">"); + } + + array_push($this->in_content, "<". $this->ns_to_prefix($name) ."{$xmlns_str}{$attrs_str}"); + } else if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS) || in_array($tag, $this->ATOM_SIMPLE_ELEMENTS)) { + $this->in_content = array(); + $this->is_xhtml = $attrs['type'] == 'xhtml'; + array_push($this->in_content, array($tag,$this->depth)); + } else if($tag == 'link') { + array_push($this->entry->links, $attrs); + } else if($tag == 'category') { + array_push($this->entry->categories, $attrs['term']); + } + + $this->ns_decls = array(); + } + + function end_element($parser, $name) { + + $tag = array_pop(split(":", $name)); + + if(!empty($this->in_content)) { + if($this->in_content[0][0] == $tag && + $this->in_content[0][1] == $this->depth) { + array_shift($this->in_content); + if($this->is_xhtml) { + $this->in_content = array_slice($this->in_content, 2, count($this->in_content)-3); + } + $this->entry->$tag = join('',$this->in_content); + $this->in_content = array(); + } else { + $endtag = $this->ns_to_prefix($name); + if (strpos($this->in_content[count($this->in_content)-1], '<' . $endtag) !== false) { + array_push($this->in_content, "/>"); + } else { + array_push($this->in_content, ""); + } + } + } + + array_shift($this->ns_contexts); + + #print str_repeat(" ", $this->depth * $this->indent) . "end_element('$name')" ."\n"; + + $this->depth--; + } + + function start_ns($parser, $prefix, $uri) { + #print str_repeat(" ", $this->depth * $this->indent) . "starting: " . $prefix . ":" . $uri . "\n"; + array_push($this->ns_decls, array($prefix,$uri)); + } + + function end_ns($parser, $prefix) { + #print str_repeat(" ", $this->depth * $this->indent) . "ending: #" . $prefix . "#\n"; + } + + function cdata($parser, $data) { + #print str_repeat(" ", $this->depth * $this->indent) . "data: #" . $data . "#\n"; + if(!empty($this->in_content)) { + // handle self-closing tags (case: text node found, need to close element started) + if (strpos($this->in_content[count($this->in_content)-1], '<') !== false) { + array_push($this->in_content, ">"); + } + array_push($this->in_content, $this->xml_escape($data)); + } + } + + function _default($parser, $data) { + # when does this gets called? + } + + + function ns_to_prefix($qname) { + $components = split(":", $qname); + $name = array_pop($components); + + if(!empty($components)) { + $ns = join(":",$components); + foreach($this->ns_contexts as $context) { + foreach($context as $mapping) { + if($mapping[1] == $ns && strlen($mapping[0]) > 0) { + return "$mapping[0]:$name"; + } + } + } + } + return $name; + } + + function xml_escape($string) + { + return str_replace(array('&','"',"'",'<','>'), + array('&','"',''','<','>'), + $string ); + } +} + +?> diff -uNr a/blog/wp-admin/import/blogware.php b/blog/wp-admin/import/blogware.php --- a/blog/wp-admin/import/blogware.php false +++ b/blog/wp-admin/import/blogware.php 74607e7f001ce55d408846603003780c760dcc180cf37588bee5446e6abf6f29038d8890e210c1c52e2b7d6ff1ba40ec774b9b989e6d0b94c9c37567e41ec408 @@ -0,0 +1,215 @@ +'; + screen_icon(); + echo '

'.__('Import Blogware').'

'; + } + + function footer() { + echo ''; + } + + 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 '
'; + echo '

'.__('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.').'

'; + wp_import_upload_form("admin.php?import=blogware&step=1"); + echo '
'; + } + + 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('|(]+>(.*?))|is', $importdata, $posts); + $posts = $posts[1]; + unset($importdata); + echo '
    '; + foreach ($posts as $post) { + flush(); + preg_match('||is', $post, $post_type); + $post_type = $post_type[1]; + if($post_type == "photo") { + preg_match('|(.*?)|is', $post, $post_title); + } else { + preg_match('|(.*?)|is', $post, $post_title); + } + $post_title = $wpdb->escape(trim($post_title[1])); + + preg_match('|(.*?)|is', $post, $post_date); + $post_date = strtotime($post_date[1]); + $post_date = gmdate('Y-m-d H:i:s', $post_date); + + preg_match_all('|(.*?)|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('|(.*?)|is', $post, $post_content); + $post_content = ''; + $post_content = $this->unhtmlentities($post_content); + } else { + preg_match('|(.*?)|is', $post, $post_content); + $post_content = str_replace(array (''), '', 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('
    ', '
    ', $post_content); + $post_content = str_replace('
    ', '
    ', $post_content); + $post_content = $wpdb->escape($post_content); + + $post_author = $current_user->ID; + preg_match('|(.*?)|is', $post, $post_status); + $post_status = trim($post_status[1]); + + echo '
  1. '; + if ($post_id = post_exists($post_title, $post_content, $post_date)) { + printf(__('Post %s already exists.'), stripslashes($post_title)); + } else { + printf(__('Importing post %s...'), stripslashes($post_title)); + $postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status'); + $post_id = wp_insert_post($postdata); + if ( is_wp_error( $post_id ) ) { + return $post_id; + } + if (!$post_id) { + _e("Couldn't get post ID"); + echo '
  2. '; + break; + } + if(0 != count($categories)) + wp_create_categories($categories, $post_id); + } + + preg_match_all('|(.*?)|is', $post, $comments); + $comments = $comments[1]; + + if ( $comments ) { + $comment_post_ID = (int) $post_id; + $num_comments = 0; + foreach ($comments as $comment) { + preg_match('|(.*?)|is', $comment, $comment_content); + $comment_content = str_replace(array (''), '', 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('
    ', '
    ', $comment_content); + $comment_content = str_replace('
    ', '
    ', $comment_content); + $comment_content = $wpdb->escape($comment_content); + + preg_match('|(.*?)|is', $comment, $comment_date); + $comment_date = trim($comment_date[1]); + $comment_date = date('Y-m-d H:i:s', strtotime($comment_date)); + + preg_match('|(.*?)|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( __ngettext('%s comment', '%s comments', $num_comments), $num_comments ); + } + echo ''; + flush(); + ob_flush(); + } + echo '
'; + } + + function import() { + $file = wp_import_handle_upload(); + if ( isset($file['error']) ) { + echo $file['error']; + return; + } + + $this->file = $file['file']; + $result = $this->import_posts(); + if ( is_wp_error( $result ) ) + return $result; + wp_import_cleanup($file['id']); + do_action('import_done', 'blogware'); + echo '

'; + printf(__('All done. Have fun!'), get_option('home')); + echo '

'; + } + + function dispatch() { + if (empty ($_GET['step'])) + $step = 0; + else + $step = (int) $_GET['step']; + + $this->header(); + + switch ($step) { + case 0 : + $this->greet(); + break; + case 1 : + $result = $this->import(); + if ( is_wp_error( $result ) ) + $result->get_error_message(); + 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 -uNr a/blog/wp-admin/import/btt.php b/blog/wp-admin/import/btt.php --- a/blog/wp-admin/import/btt.php false +++ b/blog/wp-admin/import/btt.php d33fb1fc2ade50b91c6e29ad7f57abc47478dccbcccee1470b79a89b192d36bb9b81de024d5ed937299576cd1db59a98200d65f7f8cceba38308009c06742975 @@ -0,0 +1,130 @@ +'; + screen_icon(); + echo '

'.__('Import Bunny’s Technorati Tags').'

'; + echo '

'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'

'; + } + + function footer() { + echo ''; + } + + function greet() { + echo '
'; + echo '

'.__('Howdy! This imports tags from Bunny’s Technorati Tags into WordPress tags.').'

'; + echo '

'.__('This is suitable for Bunny’s Technorati Tags version 0.6.').'

'; + echo '

'.__('All existing Bunny’s Technorati Tags will be removed after import.').'

'; + echo '

'.__('Don’t be stupid - backup your database before proceeding!').'

'; + echo '
'; + wp_nonce_field('import-btt'); + echo '

'; + echo '
'; + echo '
'; + } + + function dispatch() { + if ( empty($_GET['step']) ) + $step = 0; + else + $step = absint($_GET['step']); + + // load the header + $this->header(); + + switch ( $step ) { + case 0 : + $this->greet(); + break; + case 1 : + check_admin_referer('import-btt'); + $this->check_post_keyword( true ); + break; + case 2 : + check_admin_referer('import-btt'); + $this->check_post_keyword( false ); + break; + case 3: + $this->done(); + break; + } + + // load the footer + $this->footer(); + } + + function check_post_keyword($precheck = true) { + global $wpdb; + + echo '
'; + echo '

'.__('Reading Bunny’s Technorati Tags…').'

'; + + // import Bunny's Keywords tags + $metakeys = $wpdb->get_results("SELECT post_id, meta_id, meta_key, meta_value FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_key = 'tags'"); + if ( !is_array($metakeys)) { + echo '

' . __('No Tags Found!') . '

'; + return false; + } else { + $count = count($metakeys); + echo '

' . sprintf( __ngettext('Done! %s post with tags were read.', 'Done! %s posts with tags were read.', $count), $count ) . '

'; + echo '
    '; + foreach ( $metakeys as $post_meta ) { + if ( $post_meta->meta_value != '' ) { + $post_keys = explode(' ', $post_meta->meta_value); + foreach ( $post_keys as $keyword ) { + $keyword = addslashes(trim(str_replace('+',' ',$keyword))); + if ( '' != $keyword ) { + echo '
  • ' . $post_meta->post_id . ' - ' . $keyword . '
  • '; + if ( !$precheck ) + wp_add_post_tags($post_meta->post_id, $keyword); + } + } + } + if ( !$precheck ) + delete_post_meta($post_meta->post_id, 'tags'); + } + echo '
'; + } + + echo '
'; + wp_nonce_field('import-btt'); + echo '

'; + echo '
'; + echo '
'; + } + + function done() { + echo '
'; + echo '

'.__('Import Complete!').'

'; + echo '
'; + } + + function BunnyTags_Import() { + } + +} + +// create the import object +$btt_import = new BunnyTags_Import(); + +// add it to the import page! +register_importer('btt', 'Bunny’s Technorati Tags', __('Import Bunny’s Technorati Tags into WordPress tags.'), array($btt_import, 'dispatch')); + +?> diff -uNr a/blog/wp-admin/import/dotclear.php b/blog/wp-admin/import/dotclear.php --- a/blog/wp-admin/import/dotclear.php false +++ b/blog/wp-admin/import/dotclear.php 361c2f2a2616b1ec2b9c361aa5f7e26a128ab5268764269e12b678a0ad1d3fc8a7996d732f3171a4458689754aeb05732c0648364995520ab94db97b45b87023 @@ -0,0 +1,835 @@ +get_var( $wpdb->prepare("SELECT count(*) FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) ); + } +} + +if(!function_exists('link_exists')) +{ + /** + * Check whether link already exists. + * + * @package WordPress + * @subpackage Dotclear_Import + * + * @param string $linkname + * @return int + */ + function link_exists($linkname) + { + global $wpdb; + return $wpdb->get_var( $wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_name = %s", $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 +// + +/** + * @package WordPress + * @subpackage Dotclear_Import + * + * @param string $char + * @return string + */ +function valid_1byte($char) { + if(!is_int($char)) return false; + return ($char & 0x80) == 0x00; +} + +/** + * @package WordPress + * @subpackage Dotclear_Import + * + * @param string $char + * @return string + */ +function valid_2byte($char) { + if(!is_int($char)) return false; + return ($char & 0xE0) == 0xC0; +} + +/** + * @package WordPress + * @subpackage Dotclear_Import + * + * @param string $char + * @return string + */ +function valid_3byte($char) { + if(!is_int($char)) return false; + return ($char & 0xF0) == 0xE0; +} + +/** + * @package WordPress + * @subpackage Dotclear_Import + * + * @param string $char + * @return string + */ +function valid_4byte($char) { + if(!is_int($char)) return false; + return ($char & 0xF8) == 0xF0; +} + +/** + * @package WordPress + * @subpackage Dotclear_Import + * + * @param string $char + * @return string + */ +function valid_nextbyte($char) { + if(!is_int($char)) return false; + return ($char & 0xC0) == 0x80; +} + +/** + * @package WordPress + * @subpackage Dotclear_Import + * + * @param string $string + * @return string + */ +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 +} + +/** + * @package WordPress + * @subpackage Dotclear_Import + * + * @param string $s + * @return string + */ +function csc ($s) { + if (valid_utf8 ($s)) { + return $s; + } else { + return iconv(get_option ("dccharset"),"UTF-8",$s); + } +} + +/** + * @package WordPress + * @subpackage Dotclear_Import + * + * @param string $s + * @return string + */ +function textconv ($s) { + return csc (preg_replace ('|(?)\s*\n|', ' ', $s)); +} + +/** + * Dotclear Importer class + * + * Will process the WordPress eXtended RSS files that you upload from the export + * file. + * + * @package WordPress + * @subpackage Importer + * + * @since unknown + */ +class Dotclear_Import { + + function header() + { + echo '
'; + screen_icon(); + echo '

'.__('Import DotClear').'

'; + echo '

'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'

'; + } + + function footer() + { + echo '
'; + } + + function greet() + { + echo '

'.__('Howdy! This importer allows you to extract posts from a DotClear database into your blog. Mileage may vary.').'

'; + echo '

'.__('Your DotClear Configuration settings are as follows:').'

'; + echo '
'; + wp_nonce_field('import-dotclear'); + $this->db_form(); + echo '

'; + echo '
'; + } + + 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 '

'.__('Importing Categories...').'

'; + 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 '

'.sprintf(__ngettext('Done! %1$s category imported.', 'Done! %1$s categories imported.', $count), $count).'

'; + 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 '

'.__('Importing Users...').'

'; + 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 '

'.sprintf(__('Done! %1$s users imported.'), $count).'

'; + 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 '

'.__('Importing Posts...').'

'; + 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\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) + ); + if ( is_wp_error( $ret_id ) ) + return $ret_id; + } + 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) + ); + if ( is_wp_error( $ret_id ) ) + return $ret_id; + } + $dcposts2wpposts[$post_id] = $ret_id; + + // Make Post-to-Category associations + $cats = array(); + $category1 = get_category_by_slug($post_cat_name); + $category1 = $category1->term_id; + + if($cat1 = $category1) { $cats[1] = $cat1; } + + if(!empty($cats)) { wp_set_post_categories($ret_id, $cats); } + } + } + // Store ID translation for later use + add_option('dcposts2wpposts',$dcposts2wpposts); + + echo '

'.sprintf(__('Done! %1$s posts imported.'), $count).'

'; + return true; + } + + function comments2wp($comments='') + { + // General Housekeeping + global $wpdb; + $count = 0; + $dccm2wpcm = array(); + $postarr = get_option('dcposts2wpposts'); + + // Magic Mojo + if(is_array($comments)) + { + echo '

'.__('Importing Comments...').'

'; + foreach($comments as $comment) + { + $count++; + extract($comment); + + // WordPressify Data + $comment_ID = (int) ltrim($comment_id, '0'); + $comment_post_ID = (int) $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 '

'.sprintf(__('Done! %1$s comments imported.'), $count).'

'; + 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 '

'.__('Importing Links...').'

'; + foreach($links as $link) + { + $count++; + extract($link); + + if ($title != "") { + if ($cinfo = is_term(csc ($title), 'link_category')) { + $category = $cinfo['term_id']; + } else { + $category = wp_insert_term($wpdb->escape (csc ($title)), 'link_category'); + $category = $category['term_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 '

'; + printf(__ngettext('Done! %s link or link category imported.', 'Done! %s links or link categories imported.', $count), $count); + echo '

'; + 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 '
'; + wp_nonce_field('import-dotclear'); + printf('

', attribute_escape(__('Import Users'))); + echo '
'; + + } + + function import_users() + { + // User Import + $users = $this->get_dc_users(); + $this->users2wp($users); + + echo '
'; + wp_nonce_field('import-dotclear'); + printf('

', attribute_escape(__('Import Posts'))); + echo '
'; + } + + function import_posts() + { + // Post Import + $posts = $this->get_dc_posts(); + $result = $this->posts2wp($posts); + if ( is_wp_error( $result ) ) + return $result; + + echo '
'; + wp_nonce_field('import-dotclear'); + printf('

', attribute_escape(__('Import Comments'))); + echo '
'; + } + + function import_comments() + { + // Comment Import + $comments = $this->get_dc_comments(); + $this->comments2wp($comments); + + echo '
'; + wp_nonce_field('import-dotclear'); + printf('

', attribute_escape(__('Import Links'))); + echo '
'; + } + + function import_links() + { + //Link Import + $links = $this->get_dc_links(); + $this->links2wp($links); + add_option('dc_links', $links); + + echo '
'; + wp_nonce_field('import-dotclear'); + printf('

', attribute_escape(__('Finish'))); + echo '
'; + } + + 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'); + do_action('import_done', 'dotclear'); + $this->tips(); + } + + function tips() + { + echo '

'.__('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.').'

'; + echo '

'.__('Users').'

'; + echo '

'.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. Every user has the same username, but their passwords are reset to password123. So Login and change it.'), '/wp-login.php').'

'; + echo '

'.__('Preserving Authors').'

'; + echo '

'.__('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.').'

'; + echo '

'.__('Textile').'

'; + echo '

'.__('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 Textile for WordPress. Trust me... You\'ll want it.').'

'; + echo '

'.__('WordPress Resources').'

'; + echo '

'.__('Finally, there are numerous WordPress resources around the internet. Some of them are:').'

'; + echo ''; + echo '

'.sprintf(__('That\'s it! What are you waiting for? Go login!'), '../wp-login.php').'

'; + } + + function db_form() + { + echo ''; + printf('', __('DotClear Database User:')); + printf('', __('DotClear Database Password:')); + printf('', __('DotClear Database Name:')); + printf('', __('DotClear Database Host:')); + printf('', __('DotClear Table prefix:')); + printf('', __('Originating character set:')); + echo '
'; + } + + function dispatch() + { + + if (empty ($_GET['step'])) + $step = 0; + else + $step = (int) $_GET['step']; + $this->header(); + + if ( $step > 0 ) + { + check_admin_referer('import-dotclear'); + + if($_POST['dbuser']) + { + if(get_option('dcuser')) + delete_option('dcuser'); + add_option('dcuser', sanitize_user($_POST['dbuser'], true)); + } + if($_POST['dbpass']) + { + if(get_option('dcpass')) + delete_option('dcpass'); + add_option('dcpass', sanitize_user($_POST['dbpass'], true)); + } + + if($_POST['dbname']) + { + if(get_option('dcname')) + delete_option('dcname'); + add_option('dcname', sanitize_user($_POST['dbname'], true)); + } + if($_POST['dbhost']) + { + if(get_option('dchost')) + delete_option('dchost'); + add_option('dchost', sanitize_user($_POST['dbhost'], true)); + } + if($_POST['dccharset']) + { + if(get_option('dccharset')) + delete_option('dccharset'); + add_option('dccharset', sanitize_user($_POST['dccharset'], true)); + } + if($_POST['dbprefix']) + { + if(get_option('dcdbprefix')) + delete_option('dcdbprefix'); + add_option('dcdbprefix', sanitize_user($_POST['dbprefix'], true)); + } + + + } + + switch ($step) + { + default: + case 0 : + $this->greet(); + break; + case 1 : + $this->import_categories(); + break; + case 2 : + $this->import_users(); + break; + case 3 : + $result = $this->import_posts(); + if ( is_wp_error( $result ) ) + echo $result->get_error_message(); + 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 categories, users, posts, comments, and links from a DotClear blog.'), array ($dc_import, 'dispatch')); + +?> diff -uNr a/blog/wp-admin/import/greymatter.php b/blog/wp-admin/import/greymatter.php --- a/blog/wp-admin/import/greymatter.php false +++ b/blog/wp-admin/import/greymatter.php b4271ea7d90a2061597ff3c1e3f5eee74aca0dd22d078aa7f2a191096f4ce8d9eeb3216e49e52b365b66bdcc91a072f1f21c6d194ec07bf94a43221282066d76 @@ -0,0 +1,334 @@ +'; + screen_icon(); + echo '

'.__('Import GreyMatter').'

'; + } + + function footer() { + echo ''; + } + + function greet() { + $this->header(); +?> +

+

+
    +
  • +
  • If authors are found not to be in gm-authors.cgi, imports them at level 0.') ?>
  • +
  • +
+

+
    +
  • +
  • +
  • +
+

 

+ +
+ + + +

+ + + + + + + + + + + + + +

+ so you need to enter the number of the last GM post here.
(if you don't know that number, just log into your FTP and look it out
in the entries' folder)") ?>
+

+
+footer(); + } + + + + function gm2autobr($string) { // transforms GM's |*| into b2's
\n + $string = str_replace("|*|","
\n",$string); + return($string); + } + + function import() { + global $wpdb; + + $wpvarstoreset = array('gmpath', 'archivespath', 'lastentry'); + for ($i=0; $iheader(); +?> +

+
    +
    • 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) { + printf('
    • '.__('user %s').''.__('Already exists').'
    • ', "$user_login"); + $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; + + printf('
    • '.__('user %s...').' '.__('Done').'
    • ', "$user_login"); + } + +?>
  • +

    • gm2autobr($entry[2]); + $postmorecontent=$this->gm2autobr($entry[3]); + + $post_author=trim($wpdb->escape($postinfo[1])); + + $post_title=$this->gm2autobr($postinfo[2]); + printf('
    • '.__('entry # %s : %s : by %s'), $entryfile, $post_title, $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 .= "

      ".$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 ' '; + _e('(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 ': '; + printf(__('registered deleted user %s at level 0 '), "$user_login"); + } + + 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); + if ( is_wp_error( $post_ID ) ) + return $post_ID; + } + + $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 ': '; + printf( __ngettext('imported %s comment', 'imported %s comments', $numAddedComments) , $numAddedComments); + } + $preExisting = $numComments - numAddedComments; + if ($preExisting > 0) { + echo ' '; + printf( __ngettext( 'ignored %s pre-existing comment', 'ignored %s pre-existing comments', $preExisting ) , $preExisting); + } + } + echo '... '.__('Done').'
    • '; + } + } + do_action('import_done', 'greymatter'); + ?> +
+

 

+

+footer(); + return; + } + + function dispatch() { + if (empty ($_GET['step'])) + $step = 0; + else + $step = (int) $_GET['step']; + + switch ($step) { + case 0 : + $this->greet(); + break; + case 1: + check_admin_referer('import-greymatter'); + $result = $this->import(); + if ( is_wp_error( $result ) ) + echo $result->get_error_message(); + break; + } + } + + function GM_Import() { + // Nothing. + } +} + +$gm_import = new GM_Import(); + +register_importer('greymatter', __('GreyMatter'), __('Import users, posts, and comments from a Greymatter blog.'), array ($gm_import, 'dispatch')); +?> diff -uNr a/blog/wp-admin/import/jkw.php b/blog/wp-admin/import/jkw.php --- a/blog/wp-admin/import/jkw.php false +++ b/blog/wp-admin/import/jkw.php 37ce99755100cb9e22a01c04bbaa9684e75e54449b73c35ca8ed360c29e8e1c4cd2a11998f7af183ff745d874b2c1a63f858e1c7b9500df275cf4a3491cba899 @@ -0,0 +1,192 @@ +'; + screen_icon(); + echo '

'.__('Import Jerome’s Keywords').'

'; + echo '

'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'

'; + } + + function footer() { + echo ''; + } + + function greet() { + echo '
'; + echo '

'.__('Howdy! This imports tags from Jerome’s Keywords into WordPress tags.').'

'; + echo '

'.__('This is suitable for Jerome’s Keywords version 1.x and 2.0a.').'

'; + echo '

'.__('All existing Jerome’s Keywords will be removed after import.').'

'; + echo '

'.__('Don’t be stupid - backup your database before proceeding!').'

'; + echo '
'; + wp_nonce_field('import-jkw'); + echo '

'; + echo '
'; + echo '
'; + wp_nonce_field('import-jkw'); + echo '

'; + echo '
'; + echo '
'; + } + + function dispatch() { + if ( empty($_GET['step']) ) + $step = 0; + else + $step = absint($_GET['step']); + + // load the header + $this->header(); + + switch ( $step ) { + case 0 : + $this->greet(); + break; + case 1 : + check_admin_referer('import-jkw'); + $this->check_V1_post_keyword( true ); + break; + case 2 : + check_admin_referer('import-jkw'); + $this->check_V1_post_keyword( false ); + break; + case 3 : + check_admin_referer('import-jkw'); + $this->check_V2_post_keyword( true ); + break; + case 4 : + check_admin_referer('import-jkw'); + $this->check_V2_post_keyword( false ); + break; + case 5: + check_admin_referer('import-jkw'); + $this->cleanup_V2_import(); + break; + case 6: + $this->done(); + break; + } + + // load the footer + $this->footer(); + } + + function check_V1_post_keyword($precheck = true) { + global $wpdb; + + echo '
'; + echo '

'.__('Reading Jerome’s Keywords Tags…').'

'; + + // import Jerome's Keywords tags + $metakeys = $wpdb->get_results("SELECT post_id, meta_id, meta_key, meta_value FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_key = 'keywords'"); + if ( !is_array($metakeys)) { + echo '

' . __('No Tags Found!') . '

'; + return false; + } else { + $count = count($metakeys); + echo '

' . sprintf( __ngettext('Done! %s post with tags were read.', 'Done! %s posts with tags were read.', $count), $count ) . '

'; + echo '
    '; + foreach ( $metakeys as $post_meta ) { + if ( $post_meta->meta_value != '' ) { + $post_keys = explode(',', $post_meta->meta_value); + foreach ( $post_keys as $keyword ) { + $keyword = addslashes(trim($keyword)); + if ( '' != $keyword ) { + echo '
  • ' . $post_meta->post_id . ' - ' . $keyword . '
  • '; + if ( !$precheck ) + wp_add_post_tags($post_meta->post_id, $keyword); + } + } + } + if ( !$precheck ) + delete_post_meta($post_meta->post_id, 'keywords'); + } + echo '
'; + } + + echo '
'; + wp_nonce_field('import-jkw'); + echo '

'; + echo '
'; + echo '
'; + } + + function check_V2_post_keyword($precheck = true) { + global $wpdb; + + echo '
'; + echo '

'.__('Reading Jerome’s Keywords Tags…').'

'; + + // import Jerome's Keywords tags + $tablename = $wpdb->prefix . substr(get_option('jkeywords_keywords_table'), 1, -1); + $metakeys = $wpdb->get_results("SELECT post_id, tag_name FROM $tablename"); + if ( !is_array($metakeys) ) { + echo '

' . __('No Tags Found!') . '

'; + return false; + } else { + $count = count($metakeys); + echo '

' . sprintf( __ngettext('Done! %s tag were read.', 'Done! %s tags were read.', $count), $count ) . '

'; + echo '
    '; + foreach ( $metakeys as $post_meta ) { + $keyword = addslashes(trim($post_meta->tag_name)); + if ( $keyword != '' ) { + echo '
  • ' . $post_meta->post_id . ' - ' . $keyword . '
  • '; + if ( !$precheck ) + wp_add_post_tags($post_meta->post_id, $keyword); + } + } + echo '
'; + } + echo '
'; + wp_nonce_field('import-jkw'); + echo '

'; + echo '
'; + echo '
'; + } + + function cleanup_V2_import() { + global $wpdb; + + /* options from V2.0a (jeromes-keywords.php) */ + $options = array('version', 'keywords_table', 'query_varname', 'template', 'meta_always_include', 'meta_includecats', 'meta_autoheader', 'search_strict', 'use_feed_cats', 'post_linkformat', 'post_tagseparator', 'post_includecats', 'post_notagstext', 'cloud_linkformat', 'cloud_tagseparator', 'cloud_includecats', 'cloud_sortorder', 'cloud_displaymax', 'cloud_displaymin', 'cloud_scalemax', 'cloud_scalemin'); + + $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . substr(get_option('jkeywords_keywords_table'), 1, -1)); + + foreach ( $options as $o ) + delete_option('jkeywords_' . $o); + + $this->done(); + } + + function done() { + echo '
'; + echo '

'.__('Import Complete!').'

'; + echo '
'; + } + + function JeromesKeyword_Import() { + } + +} + +// create the import object +$jkw_import = new JeromesKeyword_Import(); + +// add it to the import page! +register_importer('jkw', 'Jerome’s Keywords', __('Import Jerome’s Keywords into WordPress tags.'), array($jkw_import, 'dispatch')); + +?> diff -uNr a/blog/wp-admin/import/livejournal.php b/blog/wp-admin/import/livejournal.php --- a/blog/wp-admin/import/livejournal.php false +++ b/blog/wp-admin/import/livejournal.php 9c58c4a3765e02575073b45b1fe247c7190805ad84448f269d1f6f6bb46d1a58371d2c81e2f72143e6b76653febfe2ec64b41802ddc13b4bd1a9fb36af92c4c0 @@ -0,0 +1,193 @@ +'; + screen_icon(); + echo '

'.__('Import LiveJournal').'

'; + } + + function footer() { + echo ''; + } + + 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 '
'; + echo '

'.__('Howdy! Upload your LiveJournal XML export file and we’ll import the posts into this blog.').'

'; + echo '

'.__('Choose a LiveJournal XML file to upload, then click Upload file and import.').'

'; + wp_import_upload_form("admin.php?import=livejournal&step=1"); + echo '
'; + } + + 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('|(.*?)|is', $importdata, $posts); + $posts = $posts[1]; + unset($importdata); + echo '
    '; + foreach ($posts as $post) { + preg_match('|(.*?)|is', $post, $post_title); + $post_title = $wpdb->escape(trim($post_title[1])); + if ( empty($post_title) ) { + preg_match('|(.*?)|is', $post, $post_title); + $post_title = $wpdb->escape(trim($post_title[1])); + } + + preg_match('|(.*?)|is', $post, $post_date); + $post_date = strtotime($post_date[1]); + $post_date = date('Y-m-d H:i:s', $post_date); + + preg_match('|(.*?)|is', $post, $post_content); + $post_content = str_replace(array (''), '', 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('
    ', '
    ', $post_content); + $post_content = str_replace('
    ', '
    ', $post_content); + $post_content = $wpdb->escape($post_content); + + $post_author = $current_user->ID; + $post_status = 'publish'; + + echo '
  1. '; + if ($post_id = post_exists($post_title, $post_content, $post_date)) { + printf(__('Post %s already exists.'), stripslashes($post_title)); + } else { + printf(__('Importing post %s...'), stripslashes($post_title)); + $postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status'); + $post_id = wp_insert_post($postdata); + if ( is_wp_error( $post_id ) ) + return $post_id; + if (!$post_id) { + _e("Couldn't get post ID"); + echo '
  2. '; + break; + } + } + + preg_match_all('|(.*?)|is', $post, $comments); + $comments = $comments[1]; + + if ( $comments ) { + $comment_post_ID = (int) $post_id; + $num_comments = 0; + foreach ($comments as $comment) { + preg_match('|(.*?)|is', $comment, $comment_content); + $comment_content = str_replace(array (''), '', 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('
    ', '
    ', $comment_content); + $comment_content = str_replace('
    ', '
    ', $comment_content); + $comment_content = $wpdb->escape($comment_content); + + preg_match('|(.*?)|is', $comment, $comment_date); + $comment_date = trim($comment_date[1]); + $comment_date = date('Y-m-d H:i:s', strtotime($comment_date)); + + preg_match('|(.*?)|is', $comment, $comment_author); + $comment_author = $wpdb->escape(trim($comment_author[1])); + + preg_match('|(.*?)|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(__ngettext('(%s comment)', '(%s comments)', $num_comments), $num_comments); + } + echo ''; + } + echo '
'; + } + + function import() { + $file = wp_import_handle_upload(); + if ( isset($file['error']) ) { + echo $file['error']; + return; + } + + $this->file = $file['file']; + $result = $this->import_posts(); + if ( is_wp_error( $result ) ) + return $result; + wp_import_cleanup($file['id']); + do_action('import_done', 'livejournal'); + + echo '

'; + printf(__('All done. Have fun!'), get_option('home')); + echo '

'; + } + + function dispatch() { + if (empty ($_GET['step'])) + $step = 0; + else + $step = (int) $_GET['step']; + + $this->header(); + + switch ($step) { + case 0 : + $this->greet(); + break; + case 1 : + check_admin_referer('import-upload'); + $result = $this->import(); + if ( is_wp_error( $result ) ) + echo $result->get_error_message(); + break; + } + + $this->footer(); + } + + function LJ_Import() { + // Nothing. + } +} + +$livejournal_import = new LJ_Import(); + +register_importer('livejournal', __('LiveJournal'), __('Import posts from a LiveJournal XML export file.'), array ($livejournal_import, 'dispatch')); +?> diff -uNr a/blog/wp-admin/import/mt.php b/blog/wp-admin/import/mt.php --- a/blog/wp-admin/import/mt.php false +++ b/blog/wp-admin/import/mt.php 11f1bdd9c2c68f070d934002821d941b25048507b46109ff52ea0afce2747676ca518b49913d0778e2f7b62cb03b71dbf8f9cb8bebd9e6649a63fa80d542fb09 @@ -0,0 +1,512 @@ +'; + screen_icon(); + echo '

'.__('Import Movable Type or TypePad').'

'; + } + + function footer() { + echo ''; + } + + function greet() { + $this->header(); +?> +
+

mt-export.txt in your /wp-content/ directory and then click "Import mt-export.txt"'); ?>

+ + +
+ + +

+ +mt-export.txt in your /wp-content/ directory'); ?>

+

+ +

+
+

out of memory error try splitting up the import file into pieces.'); ?>

+
+footer(); + } + + function users_form($n) { + global $wpdb; + $users = $wpdb->get_results("SELECT * FROM $wpdb->users ORDER BY ID"); +?> + has_gzip() ) + return gzopen($filename, $mode); + return fopen($filename, $mode); + } + + function feof($fp) { + if ( $this->has_gzip() ) + return gzeof($fp); + return feof($fp); + } + + function fgets($fp, $len=8192) { + if ( $this->has_gzip() ) + return gzgets($fp, $len); + return fgets($fp, $len); + } + + function fclose($fp) { + if ( $this->has_gzip() ) + return gzclose($fp); + return fclose($fp); + } + + //function to check the authorname and do the mapping + function checkauthor($author) { + //mtnames is an array with the names in the mt import file + $pass = wp_generate_password(); + if (!(in_array($author, $this->mtnames))) { //a new mt author name is found + ++ $this->j; + $this->mtnames[$this->j] = $author; //add that new mt author name to an array + $user_id = username_exists($this->newauthornames[$this->j]); //check if the new author name defined by the user is a pre-existing wp user + if (!$user_id) { //banging my head against the desk now. + if ($this->newauthornames[$this->j] == 'left_blank') { //check if the user does not want to change the authorname + $user_id = wp_create_user($author, $pass); + $this->newauthornames[$this->j] = $author; //now we have a name, in the place of left_blank. + } else { + $user_id = wp_create_user($this->newauthornames[$this->j], $pass); + } + } else { + return $user_id; // return pre-existing wp username if it exists + } + } else { + $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_mt_authors() { + $temp = array(); + $authors = array(); + + $handle = $this->fopen($this->file, 'r'); + if ( $handle == null ) + return false; + + $in_comment = false; + while ( $line = $this->fgets($handle) ) { + $line = trim($line); + + if ( 'COMMENT:' == $line ) + $in_comment = true; + else if ( '-----' == $line ) + $in_comment = false; + + if ( $in_comment || 0 !== strpos($line,"AUTHOR:") ) + continue; + + $temp[] = trim( substr($line, strlen("AUTHOR:")) ); + } + + //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"); + } + + $this->fclose($handle); + + return $authors; + } + + function get_authors_from_post() { + $formnames = array (); + $selectnames = array (); + + foreach ($_POST['user'] as $key => $line) { + $newname = trim(stripslashes($line)); + if ($newname == '') + $newname = 'left_blank'; //passing author names from step 1 to step 2 is accomplished by using POST. left_blank denotes an empty entry in the form. + array_push($formnames, "$newname"); + } // $formnames is the array with the form entered names + + 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() { +?> +
+ +

+

+

italics. 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.'); ?>

+

+ get_mt_authors(); + echo '
    '; + echo '
    '; + wp_nonce_field('import-mt'); + $j = -1; + foreach ($authors as $author) { + ++ $j; + echo '
  1. '; + } + + echo '

    '.'
    '; + echo '
    '; + echo '
'; + + } + + function select_authors() { + if ( $_POST['upload_type'] === 'ftp' ) { + $file['file'] = WP_CONTENT_DIR . '/mt-export.txt'; + if ( !file_exists($file['file']) ) + $file['error'] = __('mt-export.txt does not exist'); + } else { + $file = wp_import_handle_upload(); + } + if ( isset($file['error']) ) { + $this->header(); + echo '

'.__('Sorry, there has been an error').'.

'; + echo '

' . $file['error'] . '

'; + $this->footer(); + return; + } + $this->file = $file['file']; + $this->id = (int) $file['id']; + + $this->mt_authors_form(); + } + + function save_post(&$post, &$comments, &$pings) { + // Reset the counter + set_time_limit(30); + $post = get_object_vars($post); + $post = add_magic_quotes($post); + $post = (object) $post; + + if ( $post_id = post_exists($post->post_title, '', $post->post_date) ) { + echo '
  • '; + printf(__('Post %s already exists.'), stripslashes($post->post_title)); + } else { + echo '
  • '; + printf(__('Importing post %s...'), stripslashes($post->post_title)); + + if ( '' != trim( $post->extended ) ) + $post->post_content .= "\n\n$post->extended"; + + $post->post_author = $this->checkauthor($post->post_author); //just so that if a post already exists, new users are not created by checkauthor + $post_id = wp_insert_post($post); + if ( is_wp_error( $post_id ) ) + return $post_id; + + // Add categories. + if ( 0 != count($post->categories) ) { + wp_create_categories($post->categories, $post_id); + } + + // Add tags or keywords + if ( 1 < strlen($post->post_keywords) ) { + // Keywords exist. + printf(__('
    Adding tags %s...'), stripslashes($post->post_keywords)); + wp_add_post_tags($post_id, $post->post_keywords); + } + } + + $num_comments = 0; + foreach ( $comments as $comment ) { + $comment = get_object_vars($comment); + $comment = add_magic_quotes($comment); + + if ( !comment_exists($comment['comment_author'], $comment['comment_date'])) { + $comment['comment_post_ID'] = $post_id; + $comment = wp_filter_comment($comment); + wp_insert_comment($comment); + $num_comments++; + } + } + + if ( $num_comments ) + printf(' '.__ngettext('(%s comment)', '(%s comments)', $num_comments), $num_comments); + + $num_pings = 0; + foreach ( $pings as $ping ) { + $ping = get_object_vars($ping); + $ping = add_magic_quotes($ping); + + if ( !comment_exists($ping['comment_author'], $ping['comment_date'])) { + $ping['comment_content'] = "{$ping['title']}\n\n{$ping['comment_content']}"; + $ping['comment_post_ID'] = $post_id; + $ping = wp_filter_comment($ping); + wp_insert_comment($ping); + $num_pings++; + } + } + + if ( $num_pings ) + printf(' '.__ngettext('(%s ping)', '(%s pings)', $num_pings), $num_pings); + + echo "
  • "; + //ob_flush();flush(); + } + + function process_posts() { + global $wpdb; + + $handle = $this->fopen($this->file, 'r'); + if ( $handle == null ) + return false; + + $context = ''; + $post = new StdClass(); + $comment = new StdClass(); + $comments = array(); + $ping = new StdClass(); + $pings = array(); + + echo "
      "; + + while ( $line = $this->fgets($handle) ) { + $line = trim($line); + + if ( '-----' == $line ) { + // Finishing a multi-line field + if ( 'comment' == $context ) { + $comments[] = $comment; + $comment = new StdClass(); + } else if ( 'ping' == $context ) { + $pings[] = $ping; + $ping = new StdClass(); + } + $context = ''; + } else if ( '--------' == $line ) { + // Finishing a post. + $context = ''; + $result = $this->save_post($post, $comments, $pings); + if ( is_wp_error( $result ) ) + return $result; + $post = new StdClass; + $comment = new StdClass(); + $ping = new StdClass(); + $comments = array(); + $pings = array(); + } else if ( 'BODY:' == $line ) { + $context = 'body'; + } else if ( 'EXTENDED BODY:' == $line ) { + $context = 'extended'; + } else if ( 'EXCERPT:' == $line ) { + $context = 'excerpt'; + } else if ( 'KEYWORDS:' == $line ) { + $context = 'keywords'; + } else if ( 'COMMENT:' == $line ) { + $context = 'comment'; + } else if ( 'PING:' == $line ) { + $context = 'ping'; + } else if ( 0 === strpos($line, "AUTHOR:") ) { + $author = trim( substr($line, strlen("AUTHOR:")) ); + if ( '' == $context ) + $post->post_author = $author; + else if ( 'comment' == $context ) + $comment->comment_author = $author; + } else if ( 0 === strpos($line, "TITLE:") ) { + $title = trim( substr($line, strlen("TITLE:")) ); + if ( '' == $context ) + $post->post_title = $title; + else if ( 'ping' == $context ) + $ping->title = $title; + } else if ( 0 === strpos($line, "STATUS:") ) { + $status = trim( strtolower( substr($line, strlen("STATUS:")) ) ); + if ( empty($status) ) + $status = 'publish'; + $post->post_status = $status; + } else if ( 0 === strpos($line, "ALLOW COMMENTS:") ) { + $allow = trim( substr($line, strlen("ALLOW COMMENTS:")) ); + if ( $allow == 1 ) + $post->comment_status = 'open'; + else + $post->comment_status = 'closed'; + } else if ( 0 === strpos($line, "ALLOW PINGS:") ) { + $allow = trim( substr($line, strlen("ALLOW PINGS:")) ); + if ( $allow == 1 ) + $post->ping_status = 'open'; + else + $post->ping_status = 'closed'; + } else if ( 0 === strpos($line, "CATEGORY:") ) { + $category = trim( substr($line, strlen("CATEGORY:")) ); + if ( '' != $category ) + $post->categories[] = $category; + } else if ( 0 === strpos($line, "PRIMARY CATEGORY:") ) { + $category = trim( substr($line, strlen("PRIMARY CATEGORY:")) ); + if ( '' != $category ) + $post->categories[] = $category; + } else if ( 0 === strpos($line, "DATE:") ) { + $date = trim( substr($line, strlen("DATE:")) ); + $date = strtotime($date); + $date = date('Y-m-d H:i:s', $date); + $date_gmt = get_gmt_from_date($date); + if ( '' == $context ) { + $post->post_modified = $date; + $post->post_modified_gmt = $date_gmt; + $post->post_date = $date; + $post->post_date_gmt = $date_gmt; + } else if ( 'comment' == $context ) { + $comment->comment_date = $date; + } else if ( 'ping' == $context ) { + $ping->comment_date = $date; + } + } else if ( 0 === strpos($line, "EMAIL:") ) { + $email = trim( substr($line, strlen("EMAIL:")) ); + if ( 'comment' == $context ) + $comment->comment_author_email = $email; + else + $ping->comment_author_email = ''; + } else if ( 0 === strpos($line, "IP:") ) { + $ip = trim( substr($line, strlen("IP:")) ); + if ( 'comment' == $context ) + $comment->comment_author_IP = $ip; + else + $ping->comment_author_IP = $ip; + } else if ( 0 === strpos($line, "URL:") ) { + $url = trim( substr($line, strlen("URL:")) ); + if ( 'comment' == $context ) + $comment->comment_author_url = $url; + else + $ping->comment_author_url = $url; + } else if ( 0 === strpos($line, "BLOG NAME:") ) { + $blog = trim( substr($line, strlen("BLOG NAME:")) ); + $ping->comment_author = $blog; + } else { + // Processing multi-line field, check context. + + $line .= "\n"; + if ( 'body' == $context ) { + $post->post_content .= $line; + } else if ( 'extended' == $context ) { + $post->extended .= $line; + } else if ( 'excerpt' == $context ) { + $post->post_excerpt .= $line; + } else if ( 'keywords' == $context ) { + $post->post_keywords .= $line; + } else if ( 'comment' == $context ) { + $comment->comment_content .= $line; + } else if ( 'ping' == $context ) { + $ping->comment_content .= $line; + } + } + } + + $this->fclose($handle); + + echo '
    '; + + wp_import_cleanup($this->id); + do_action('import_done', 'mt'); + + echo '

    '.sprintf(__('All done. Have fun!'), get_option('home')).'

    '; + } + + function import() { + $this->id = (int) $_GET['id']; + if ( $this->id == 0 ) + $this->file = WP_CONTENT_DIR . '/mt-export.txt'; + else + $this->file = get_attached_file($this->id); + $this->get_authors_from_post(); + $result = $this->process_posts(); + if ( is_wp_error( $result ) ) + return $result; + } + + function dispatch() { + if (empty ($_GET['step'])) + $step = 0; + else + $step = (int) $_GET['step']; + + switch ($step) { + case 0 : + $this->greet(); + break; + case 1 : + check_admin_referer('import-upload'); + $this->select_authors(); + break; + case 2: + check_admin_referer('import-mt'); + $result = $this->import(); + if ( is_wp_error( $result ) ) + echo $result->get_error_message(); + break; + } + } + + function MT_Import() { + // Nothing. + } +} + +$mt_import = new MT_Import(); + +register_importer('mt', __('Movable Type and TypePad'), __('Import posts and comments from a Movable Type or Typepad blog.'), array ($mt_import, 'dispatch')); +?> diff -uNr a/blog/wp-admin/import/opml.php b/blog/wp-admin/import/opml.php --- a/blog/wp-admin/import/opml.php false +++ b/blog/wp-admin/import/opml.php 1f810082c447054cbbfbee94cafc32d0d2d3b842d3420252bedcf63c8fb8198a652ad52ac44d79246e6d2060dc333bcbe5e76c3eb54d02868939c8a39d7aa5ea @@ -0,0 +1,155 @@ + + * @author Mike Little + * @package WordPress + * @subpackage Administration + */ + +/** Load WordPress Administration Bootstrap */ +$parent_file = 'tools.php'; +$submenu_file = 'import.php'; +$title = __('Import Blogroll'); + +class OPML_Import { + + function dispatch() { + global $wpdb, $user_ID; +$step = $_POST['step']; +if (!$step) $step = 0; +?> + + +
    + +

    +
    + + +

    +
    + + +
    +

    + +
    + +
    +

    + +
    + +
    + +


    +

    + +

    +
    + +
    + +
    + +

    + false, 'test_type' => false); + $file = wp_handle_upload($_FILES['userfile'], $overrides); + + if ( isset($file['error']) ) + wp_die($file['error']); + + $url = $file['url']; + $opml_url = $file['file']; + $blogrolling = false; + } + + global $opml, $updated_timestamp, $all_links, $map, $names, $urls, $targets, $descriptions, $feeds; + if ( isset($opml_url) && $opml_url != '' ) { + if ( $blogrolling === true ) { + $opml = wp_remote_fopen($opml_url); + } else { + $opml = file_get_contents($opml_url); + } + + /** Load OPML Parser */ + 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('

    '.__('Inserted %s').'

    ', $names[$i]); + } +?> + +

    manage those links.'), $link_count, $cat_id, 'link-manager.php') ?>

    + +" . __("You need to supply your OPML url. Press back on your browser and try again") . "

    \n"; +} // end else + +if ( ! $blogrolling ) + do_action( 'wp_delete_file', $opml_url); + @unlink($opml_url); +?> +
    + diff -uNr a/blog/wp-admin/import/rss.php b/blog/wp-admin/import/rss.php --- a/blog/wp-admin/import/rss.php false +++ b/blog/wp-admin/import/rss.php 4a54a81e33948d7216a6133e000c94854ebcbbd9c157c9c4d2c3e0f68440c36496b66e2fe38377660de9775b53c73cf81cb35817786957b29c71e163813dfe87 @@ -0,0 +1,198 @@ +'; + screen_icon(); + echo '

    '.__('Import RSS').'

    '; + } + + function footer() { + echo ''; + } + + 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 '
    '; + echo '

    '.__('Howdy! This importer allows you to extract posts from an 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.').'

    '; + wp_import_upload_form("admin.php?import=rss&step=1"); + echo '
    '; + } + + 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('|(.*?)|is', $importdata, $this->posts); + $this->posts = $this->posts[1]; + $index = 0; + foreach ($this->posts as $post) { + preg_match('|(.*?)|is', $post, $post_title); + $post_title = str_replace(array(''), '', $wpdb->escape( trim($post_title[1]) )); + + preg_match('|(.*?)|is', $post, $post_date_gmt); + + if ($post_date_gmt) { + $post_date_gmt = strtotime($post_date_gmt[1]); + } else { + // if we don't already have something from pubDate + preg_match('|(.*?)|is', $post, $post_date_gmt); + $post_date_gmt = preg_replace('|([-+])([0-9]+):([0-9]+)$|', '\1\2\3', $post_date_gmt[1]); + $post_date_gmt = str_replace('T', ' ', $post_date_gmt); + $post_date_gmt = strtotime($post_date_gmt); + } + + $post_date_gmt = gmdate('Y-m-d H:i:s', $post_date_gmt); + $post_date = get_date_from_gmt( $post_date_gmt ); + + preg_match_all('|(.*?)|is', $post, $categories); + $categories = $categories[1]; + + if (!$categories) { + preg_match_all('|(.*?)|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('|(.*?)|is', $post, $guid); + if ($guid) + $guid = $wpdb->escape(trim($guid[1])); + else + $guid = ''; + + preg_match('|(.*?)|is', $post, $post_content); + $post_content = str_replace(array (''), '', $wpdb->escape(trim($post_content[1]))); + + if (!$post_content) { + // This is for feeds that put content in description + preg_match('|(.*?)|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('
    ', '
    ', $post_content); + $post_content = str_replace('
    ', '
    ', $post_content); + + $post_author = 1; + $post_status = 'publish'; + $this->posts[$index] = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_status', 'guid', 'categories'); + $index++; + } + } + + function import_posts() { + echo '
      '; + + foreach ($this->posts as $post) { + echo "
    1. ".__('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 ( is_wp_error( $post_id ) ) + return $post_id; + if (!$post_id) { + _e("Couldn't get post ID"); + return; + } + + if (0 != count($categories)) + wp_create_categories($categories, $post_id); + _e('Done !'); + } + echo '
    2. '; + } + + echo '
    '; + + } + + function import() { + $file = wp_import_handle_upload(); + if ( isset($file['error']) ) { + echo $file['error']; + return; + } + + $this->file = $file['file']; + $this->get_posts(); + $result = $this->import_posts(); + if ( is_wp_error( $result ) ) + return $result; + wp_import_cleanup($file['id']); + do_action('import_done', 'rss'); + + echo '

    '; + printf(__('All done. Have fun!'), get_option('home')); + echo '

    '; + } + + function dispatch() { + if (empty ($_GET['step'])) + $step = 0; + else + $step = (int) $_GET['step']; + + $this->header(); + + switch ($step) { + case 0 : + $this->greet(); + break; + case 1 : + check_admin_referer('import-upload'); + $result = $this->import(); + if ( is_wp_error( $result ) ) + echo $result->get_error_message(); + 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 -uNr a/blog/wp-admin/import/stp.php b/blog/wp-admin/import/stp.php --- a/blog/wp-admin/import/stp.php false +++ b/blog/wp-admin/import/stp.php 65237c882d6967999b26d5f472671fd6c2f30e649ff0015951277f5a4ca2e27fda5441315a950affc3b446565d0a854d3b337ef36a20656ffbcbcc55373b1b32 @@ -0,0 +1,170 @@ +'; + screen_icon(); + echo '

    '.__('Import Simple Tagging').'

    '; + echo '

    '.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'

    '; + } + + function footer() { + echo ''; + } + + function greet() { + echo '
    '; + echo '

    '.__('Howdy! This imports tags from Simple Tagging 1.6.2 into WordPress tags.').'

    '; + echo '

    '.__('This has not been tested on any other versions of Simple Tagging. Mileage may vary.').'

    '; + echo '

    '.__('To accommodate larger databases for those tag-crazy authors out there, we have made this into an easy 4-step program to help you kick that nasty Simple Tagging habit. Just keep clicking along and we will let you know when you are in the clear!').'

    '; + echo '

    '.__('Don’t be stupid - backup your database before proceeding!').'

    '; + echo '
    '; + wp_nonce_field('import-stp'); + echo '

    '; + echo '
    '; + echo '
    '; + } + + function dispatch () { + if ( empty( $_GET['step'] ) ) { + $step = 0; + } else { + $step = (int) $_GET['step']; + } + // load the header + $this->header(); + switch ( $step ) { + case 0 : + $this->greet(); + break; + case 1 : + check_admin_referer('import-stp'); + $this->import_posts(); + break; + case 2: + check_admin_referer('import-stp'); + $this->import_t2p(); + break; + case 3: + check_admin_referer('import-stp'); + $this->cleanup_import(); + break; + } + // load the footer + $this->footer(); + } + + + function import_posts ( ) { + echo '
    '; + echo '

    '.__('Reading STP Post Tags…').'

    '; + + // read in all the STP tag -> post settings + $posts = $this->get_stp_posts(); + + // if we didn't get any tags back, that's all there is folks! + if ( !is_array($posts) ) { + echo '

    ' . __('No posts were found to have tags!') . '

    '; + return false; + } + else { + // if there's an existing entry, delete it + if ( get_option('stpimp_posts') ) { + delete_option('stpimp_posts'); + } + + add_option('stpimp_posts', $posts); + $count = count($posts); + echo '

    ' . sprintf( __ngettext('Done! %s tag to post relationships were read.', 'Done! %s tags to post relationships were read.', $count), $count ) . '

    '; + } + + echo '
    '; + wp_nonce_field('import-stp'); + echo '

    '; + echo '
    '; + echo '
    '; + } + + + function import_t2p ( ) { + echo '
    '; + echo '

    '.__('Adding Tags to Posts…').'

    '; + + // run that funky magic! + $tags_added = $this->tag2post(); + + echo '

    ' . sprintf( __ngettext('Done! %s tag was added!', 'Done! %s tags were added!', $tags_added), $tags_added ) . '

    '; + echo '
    '; + wp_nonce_field('import-stp'); + echo '

    '; + echo '
    '; + echo '
    '; + } + + function get_stp_posts ( ) { + global $wpdb; + // read in all the posts from the STP post->tag table: should be wp_post2tag + $posts_query = "SELECT post_id, tag_name FROM " . $wpdb->prefix . "stp_tags"; + $posts = $wpdb->get_results($posts_query); + return $posts; + } + + function tag2post ( ) { + global $wpdb; + + // get the tags and posts we imported in the last 2 steps + $posts = get_option('stpimp_posts'); + + // null out our results + $tags_added = 0; + + // loop through each post and add its tags to the db + foreach ( $posts as $this_post ) { + $the_post = (int) $this_post->post_id; + $the_tag = $wpdb->escape($this_post->tag_name); + // try to add the tag + wp_add_post_tags($the_post, $the_tag); + $tags_added++; + } + + // that's it, all posts should be linked to their tags properly, pending any errors we just spit out! + return $tags_added; + } + + function cleanup_import ( ) { + delete_option('stpimp_posts'); + $this->done(); + } + + function done ( ) { + echo '
    '; + echo '

    '.__('Import Complete!').'

    '; + echo '

    ' . __('OK, so we lied about this being a 4-step program! You’re done!') . '

    '; + echo '

    ' . __('Now wasn’t that easy?') . '

    '; + echo '
    '; + } + + function STP_Import ( ) { + // Nothing. + } +} + +// create the import object +$stp_import = new STP_Import(); + +// add it to the import page! +register_importer('stp', 'Simple Tagging', __('Import Simple Tagging tags into WordPress tags.'), array($stp_import, 'dispatch')); +?> diff -uNr a/blog/wp-admin/import/textpattern.php b/blog/wp-admin/import/textpattern.php --- a/blog/wp-admin/import/textpattern.php false +++ b/blog/wp-admin/import/textpattern.php b918d39853617965ab69c7c467739dc8b677ed32495e0afacc52d3950561d7e4697256570c3664ad71631d753b4c975c20b0f43cb4f3dc2f9d51299e9678be37 @@ -0,0 +1,700 @@ +get_var( $wpdb->prepare("SELECT count(*) FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) ); + } +} + +if(!function_exists('link_exists')) +{ + /** + * Check whether link already exists. + * + * @package WordPress + * @subpackage Textpattern_Import + * + * @param string $linkname + * @return int + */ + function link_exists($linkname) + { + global $wpdb; + return $wpdb->get_var( $wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_name = %s", $linkname) ); + } +} + +/** + * TextPattern Importer Class + * + * @since unknown + */ +class Textpattern_Import { + + function header() + { + echo '
    '; + screen_icon(); + echo '

    '.__('Import Textpattern').'

    '; + echo '

    '.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'

    '; + } + + function footer() + { + echo '
    '; + } + + function greet() { + echo '
    '; + echo '

    '.__('Howdy! This imports categories, users, posts, comments, and links from any Textpattern 4.0.2+ into this blog.').'

    '; + echo '

    '.__('This has not been tested on previous versions of Textpattern. Mileage may vary.').'

    '; + echo '

    '.__('Your Textpattern Configuration settings are as follows:').'

    '; + echo '
    '; + wp_nonce_field('import-textpattern'); + $this->db_form(); + echo '

    '; + echo '
    '; + echo '
    '; + } + + 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 '

    '.__('Importing Categories...').'

    '; + 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 '

    '.sprintf(__ngettext('Done! %1$s category imported.', 'Done! %1$s categories imported.', $count), $count).'

    '; + 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 '

    '.__('Importing Users...').'

    '; + 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 '

    '.sprintf(__('Done! %1$s users imported.'), $count).'

    '; + 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 '

    '.__('Importing Posts...').'

    '; + 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) + ); + if ( is_wp_error( $ret_id ) ) + return $ret_id; + } + 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) + ); + if ( is_wp_error( $ret_id ) ) + return $ret_id; + } + $txpposts2wpposts[$ID] = $ret_id; + + // Make Post-to-Category associations + $cats = array(); + $category1 = get_category_by_slug($Category1); + $category1 = $category1->term_id; + $category2 = get_category_by_slug($Category2); + $category2 = $category2->term_id; + if($cat1 = $category1) { $cats[1] = $cat1; } + if($cat2 = $category2) { $cats[2] = $cat2; } + + if(!empty($cats)) { wp_set_post_categories($ret_id, $cats); } + } + } + // Store ID translation for later use + add_option('txpposts2wpposts',$txpposts2wpposts); + + echo '

    '.sprintf(__('Done! %1$s posts imported.'), $count).'

    '; + return true; + } + + function comments2wp($comments='') + { + // General Housekeeping + global $wpdb; + $count = 0; + $txpcm2wpcm = array(); + $postarr = get_option('txpposts2wpposts'); + + // Magic Mojo + if(is_array($comments)) + { + echo '

    '.__('Importing Comments...').'

    '; + 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 '

    '.sprintf(__('Done! %1$s comments imported.'), $count).'

    '; + 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 '

    '.__('Importing Links...').'

    '; + 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 '

    '; + printf(__ngettext('Done! %s link imported', 'Done! %s links imported', $count), $count); + echo '

    '; + 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 '
    '; + wp_nonce_field('import-textpattern'); + printf('

    ', attribute_escape(__('Import Users'))); + echo '
    '; + + } + + function import_users() + { + // User Import + $users = $this->get_txp_users(); + $this->users2wp($users); + + echo '
    '; + wp_nonce_field('import-textpattern'); + printf('

    ', attribute_escape(__('Import Posts'))); + echo '
    '; + } + + function import_posts() + { + // Post Import + $posts = $this->get_txp_posts(); + $result = $this->posts2wp($posts); + if ( is_wp_error( $result ) ) + return $result; + + echo '
    '; + wp_nonce_field('import-textpattern'); + printf('

    ', attribute_escape(__('Import Comments'))); + echo '
    '; + } + + function import_comments() + { + // Comment Import + $comments = $this->get_txp_comments(); + $this->comments2wp($comments); + + echo '
    '; + wp_nonce_field('import-textpattern'); + printf('

    ', attribute_escape(__('Import Links'))); + echo '
    '; + } + + function import_links() + { + //Link Import + $links = $this->get_txp_links(); + $this->links2wp($links); + add_option('txp_links', $links); + + echo '
    '; + wp_nonce_field('import-textpattern'); + printf('

    ', attribute_escape(__('Finish'))); + echo '
    '; + } + + 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'); + do_action('import_done', 'textpattern'); + $this->tips(); + } + + function tips() + { + echo '

    '.__('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.').'

    '; + echo '

    '.__('Users').'

    '; + echo '

    '.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. Every user has the same username, but their passwords are reset to password123. So Login and change it.'), get_bloginfo( 'wpurl' ) . '/wp-login.php').'

    '; + echo '

    '.__('Preserving Authors').'

    '; + echo '

    '.__('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.').'

    '; + echo '

    '.__('Textile').'

    '; + echo '

    '.__('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 Textile for WordPress. Trust me... You’ll want it.').'

    '; + echo '

    '.__('WordPress Resources').'

    '; + echo '

    '.__('Finally, there are numerous WordPress resources around the internet. Some of them are:').'

    '; + echo ''; + echo '

    '.sprintf(__('That’s it! What are you waiting for? Go login!'), get_bloginfo( 'wpurl' ) . '/wp-login.php').'

    '; + } + + function db_form() + { + echo ''; + printf('', __('Textpattern Database User:')); + printf('', __('Textpattern Database Password:')); + printf('', __('Textpattern Database Name:')); + printf('', __('Textpattern Database Host:')); + printf('', __('Textpattern Table prefix (if any):')); + echo '
    '; + } + + function dispatch() + { + + if (empty ($_GET['step'])) + $step = 0; + else + $step = (int) $_GET['step']; + $this->header(); + + if ( $step > 0 ) + { + check_admin_referer('import-textpattern'); + + if($_POST['dbuser']) + { + if(get_option('txpuser')) + delete_option('txpuser'); + add_option('txpuser', sanitize_user($_POST['dbuser'], true)); + } + if($_POST['dbpass']) + { + if(get_option('txppass')) + delete_option('txppass'); + add_option('txppass', sanitize_user($_POST['dbpass'], true)); + } + + if($_POST['dbname']) + { + if(get_option('txpname')) + delete_option('txpname'); + add_option('txpname', sanitize_user($_POST['dbname'], true)); + } + if($_POST['dbhost']) + { + if(get_option('txphost')) + delete_option('txphost'); + add_option('txphost', sanitize_user($_POST['dbhost'], true)); + } + if($_POST['dbprefix']) + { + if(get_option('tpre')) + delete_option('tpre'); + add_option('tpre', sanitize_user($_POST['dbprefix'])); + } + + + } + + switch ($step) + { + default: + case 0 : + $this->greet(); + break; + case 1 : + $this->import_categories(); + break; + case 2 : + $this->import_users(); + break; + case 3 : + $result = $this->import_posts(); + if ( is_wp_error( $result ) ) + echo $result->get_error_message(); + 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 categories, users, posts, comments, and links from a Textpattern blog.'), array ($txp_import, 'dispatch')); + +?> diff -uNr a/blog/wp-admin/import/utw.php b/blog/wp-admin/import/utw.php --- a/blog/wp-admin/import/utw.php false +++ b/blog/wp-admin/import/utw.php eaf666c07b3310da004b0a193bf8a3c2876e3acc4b140371fb60adc576dc14f5f235ea9edd9a6a4c883e6e3f5eefb87a566456f156b95cff5bb5c38842e2ead3 @@ -0,0 +1,290 @@ +'; + screen_icon(); + echo '

    '.__('Import Ultimate Tag Warrior').'

    '; + echo '

    '.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'

    '; + } + + function footer() { + echo ''; + } + + function greet() { + echo '
    '; + echo '

    '.__('Howdy! This imports tags from Ultimate Tag Warrior 3 into WordPress tags.').'

    '; + echo '

    '.__('This has not been tested on any other versions of Ultimate Tag Warrior. Mileage may vary.').'

    '; + echo '

    '.__('To accommodate larger databases for those tag-crazy authors out there, we have made this into an easy 5-step program to help you kick that nasty UTW habit. Just keep clicking along and we will let you know when you are in the clear!').'

    '; + echo '

    '.__('Don’t be stupid - backup your database before proceeding!').'

    '; + echo '
    '; + echo '

    '; + echo '
    '; + echo '
    '; + } + + + function dispatch () { + if ( empty( $_GET['step'] ) ) { + $step = 0; + } else { + $step = (int) $_GET['step']; + } + + if ( $step > 1 ) + check_admin_referer('import-utw'); + + // load the header + $this->header(); + + switch ( $step ) { + case 0 : + $this->greet(); + break; + case 1 : + $this->import_tags(); + break; + case 2 : + $this->import_posts(); + break; + case 3: + $this->import_t2p(); + break; + case 4: + $this->cleanup_import(); + break; + } + + // load the footer + $this->footer(); + } + + + function import_tags ( ) { + echo '
    '; + echo '

    '.__('Reading UTW Tags…').'

    '; + + $tags = $this->get_utw_tags(); + + // if we didn't get any tags back, that's all there is folks! + if ( !is_array($tags) ) { + echo '

    ' . __('No Tags Found!') . '

    '; + return false; + } + else { + + // if there's an existing entry, delete it + if ( get_option('utwimp_tags') ) { + delete_option('utwimp_tags'); + } + + add_option('utwimp_tags', $tags); + + + $count = count($tags); + + echo '

    ' . sprintf( __ngettext('Done! %s tag were read.', 'Done! %s tags were read.', $count), $count ) . '

    '; + echo '

    ' . __('The following tags were found:') . '

    '; + + echo '
      '; + + foreach ( $tags as $tag_id => $tag_name ) { + + echo '
    • ' . $tag_name . '
    • '; + + } + + echo '
    '; + + echo '
    '; + + echo '

    ' . __('If you don’t want to import any of these tags, you should delete them from the UTW tag management page and then re-run this import.') . '

    '; + + + } + + echo '
    '; + wp_nonce_field('import-utw'); + echo '

    '; + echo '
    '; + echo '
    '; + } + + + function import_posts ( ) { + echo '
    '; + echo '

    '.__('Reading UTW Post Tags…').'

    '; + + // read in all the UTW tag -> post settings + $posts = $this->get_utw_posts(); + + // if we didn't get any tags back, that's all there is folks! + if ( !is_array($posts) ) { + echo '

    ' . __('No posts were found to have tags!') . '

    '; + return false; + } + else { + + // if there's an existing entry, delete it + if ( get_option('utwimp_posts') ) { + delete_option('utwimp_posts'); + } + + add_option('utwimp_posts', $posts); + + + $count = count($posts); + + echo '

    ' . sprintf( __ngettext('Done! %s tag to post relationships were read.', 'Done! %s tags to post relationships were read.', $count), $count ) . '

    '; + + } + + echo '
    '; + wp_nonce_field('import-utw'); + echo '

    '; + echo '
    '; + echo '
    '; + + } + + + function import_t2p ( ) { + + echo '
    '; + echo '

    '.__('Adding Tags to Posts…').'

    '; + + // run that funky magic! + $tags_added = $this->tag2post(); + + echo '

    ' . sprintf( __ngettext( 'Done! %s tag were added!', 'Done! %s tags were added!', $tags_added ), $tags_added ) . '

    '; + + echo '
    '; + wp_nonce_field('import-utw'); + echo '

    '; + echo '
    '; + echo '
    '; + + } + + + function get_utw_tags ( ) { + + global $wpdb; + + // read in all the tags from the UTW tags table: should be wp_tags + $tags_query = "SELECT tag_id, tag FROM " . $wpdb->prefix . "tags"; + + $tags = $wpdb->get_results($tags_query); + + // rearrange these tags into something we can actually use + foreach ( $tags as $tag ) { + + $new_tags[$tag->tag_id] = $tag->tag; + + } + + return $new_tags; + + } + + function get_utw_posts ( ) { + + global $wpdb; + + // read in all the posts from the UTW post->tag table: should be wp_post2tag + $posts_query = "SELECT tag_id, post_id FROM " . $wpdb->prefix . "post2tag"; + + $posts = $wpdb->get_results($posts_query); + + return $posts; + + } + + + function tag2post ( ) { + + // get the tags and posts we imported in the last 2 steps + $tags = get_option('utwimp_tags'); + $posts = get_option('utwimp_posts'); + + // null out our results + $tags_added = 0; + + // loop through each post and add its tags to the db + foreach ( $posts as $this_post ) { + + $the_post = (int) $this_post->post_id; + $the_tag = (int) $this_post->tag_id; + + // what's the tag name for that id? + $the_tag = $tags[$the_tag]; + + // screw it, just try to add the tag + wp_add_post_tags($the_post, $the_tag); + + $tags_added++; + + } + + // that's it, all posts should be linked to their tags properly, pending any errors we just spit out! + return $tags_added; + + + } + + + function cleanup_import ( ) { + + delete_option('utwimp_tags'); + delete_option('utwimp_posts'); + + $this->done(); + + } + + + function done ( ) { + + echo '
    '; + echo '

    '.__('Import Complete!').'

    '; + + echo '

    ' . __('OK, so we lied about this being a 5-step program! You’re done!') . '

    '; + + echo '

    ' . __('Now wasn’t that easy?') . '

    '; + + echo '
    '; + + } + + + function UTW_Import ( ) { + + // Nothing. + + } + +} + + +// create the import object +$utw_import = new UTW_Import(); + +// add it to the import page! +register_importer('utw', 'Ultimate Tag Warrior', __('Import Ultimate Tag Warrior tags into WordPress tags.'), array($utw_import, 'dispatch')); + +?> diff -uNr a/blog/wp-admin/import/wordpress.php b/blog/wp-admin/import/wordpress.php --- a/blog/wp-admin/import/wordpress.php false +++ b/blog/wp-admin/import/wordpress.php 50de542997a99c4c23f5666d87c414e189a8b6f85b3c7941884e845946be2af2f6ba4310a0655c5c4e5701c11e8f8d67a65fefcb0ee96a447b392637cbc869cd @@ -0,0 +1,806 @@ +'; + screen_icon(); + echo '

    '.__('Import WordPress').'

    '; + } + + function footer() { + echo ''; + } + + 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 '
    '; + echo '

    '.__('Howdy! Upload your WordPress eXtended RSS (WXR) file and we’ll import the posts, pages, comments, custom fields, categories, and tags into this blog.').'

    '; + echo '

    '.__('Choose a WordPress WXR file to upload, then click Upload file and import.').'

    '; + wp_import_upload_form("admin.php?import=wordpress&step=1"); + echo '
    '; + } + + function get_tag( $string, $tag ) { + global $wpdb; + preg_match("|<$tag.*?>(.*?)|is", $string, $return); + $return = preg_replace('|^$|s', '$1', $return[1]); + $return = $wpdb->escape( trim( $return ) ); + return $return; + } + + function has_gzip() { + return is_callable('gzopen'); + } + + function fopen($filename, $mode='r') { + if ( $this->has_gzip() ) + return gzopen($filename, $mode); + return fopen($filename, $mode); + } + + function feof($fp) { + if ( $this->has_gzip() ) + return gzeof($fp); + return feof($fp); + } + + function fgets($fp, $len=8192) { + if ( $this->has_gzip() ) + return gzgets($fp, $len); + return fgets($fp, $len); + } + + function fclose($fp) { + if ( $this->has_gzip() ) + return gzclose($fp); + return fclose($fp); + } + + function get_entries($process_post_func=NULL) { + set_magic_quotes_runtime(0); + + $doing_entry = false; + $is_wxr_file = false; + + $fp = $this->fopen($this->file, 'r'); + if ($fp) { + while ( !$this->feof($fp) ) { + $importline = rtrim($this->fgets($fp)); + + // this doesn't check that the file is perfectly valid but will at least confirm that it's not the wrong format altogether + if ( !$is_wxr_file && preg_match('|xmlns:wp="http://wordpress[.]org/export/\d+[.]\d+/"|', $importline) ) + $is_wxr_file = true; + + if ( false !== strpos($importline, '') ) { + preg_match('|(.*?)|is', $importline, $url); + $this->base_url = $url[1]; + continue; + } + if ( false !== strpos($importline, '') ) { + preg_match('|(.*?)|is', $importline, $category); + $this->categories[] = $category[1]; + continue; + } + if ( false !== strpos($importline, '') ) { + preg_match('|(.*?)|is', $importline, $tag); + $this->tags[] = $tag[1]; + continue; + } + if ( false !== strpos($importline, '') ) { + $this->post = ''; + $doing_entry = true; + continue; + } + if ( false !== strpos($importline, '') ) { + $doing_entry = false; + if ($process_post_func) + call_user_func($process_post_func, $this->post); + continue; + } + if ( $doing_entry ) { + $this->post .= $importline . "\n"; + } + } + + $this->fclose($fp); + } + + return $is_wxr_file; + + } + + function get_wp_authors() { + // 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. + $temp = $this->allauthornames; + $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() { + global $current_user; + + // this will populate $this->author_ids with a list of author_names => user_ids + + foreach ( $_POST['author_in'] as $i => $in_author_name ) { + + if ( !empty($_POST['user_select'][$i]) ) { + // an existing user was selected in the dropdown list + $user = get_userdata( intval($_POST['user_select'][$i]) ); + if ( isset($user->ID) ) + $this->author_ids[$in_author_name] = $user->ID; + } + elseif ( $this->allow_create_users() ) { + // nothing was selected in the dropdown list, so we'll use the name in the text field + + $new_author_name = trim($_POST['user_create'][$i]); + // if the user didn't enter a name, assume they want to use the same name as in the import file + if ( empty($new_author_name) ) + $new_author_name = $in_author_name; + + $user_id = username_exists($new_author_name); + if ( !$user_id ) { + $user_id = wp_create_user($new_author_name, wp_generate_password()); + } + + $this->author_ids[$in_author_name] = $user_id; + } + + // failsafe: if the user_id was invalid, default to the current user + if ( empty($this->author_ids[$in_author_name]) ) { + $this->author_ids[$in_author_name] = intval($current_user->ID); + } + } + + } + + function wp_authors_form() { +?> + +

    +

    admins entries.'); ?>

    +allow_create_users() ) { + echo '

    '.__('If a new user is created by WordPress, a password will be randomly generated. Manually change the user\'s details if necessary.')."

    \n"; + } + + + $authors = $this->get_wp_authors(); + echo '
    '; + wp_nonce_field('import-wordpress'); + echo '
      '; + $j = -1; + foreach ($authors as $author) { + ++ $j; + echo '
    1. '.__('Import author:').' '.$author.'
      '; + $this->users_form($j, $author); + echo '
    2. '; + } + + if ( $this->allow_fetch_attachments() ) { +?> +
    + +

    +

    + + +

    + +'; + echo ''.'
    '; + echo '

    '; + echo '
    '; + + } + + function users_form($n, $author) { + + if ( $this->allow_create_users() ) { + printf('
    '); + } + else { + echo __('Map to existing').'
    '; + } + + // keep track of $n => $author name + echo ''; + + $users = get_users_of_blog(); +?> + get_entries(array(&$this, 'process_author')); + if ( $is_wxr_file ) { + $this->wp_authors_form(); + } + else { + echo '

    '.__('Invalid file').'

    '; + echo '

    '.__('Please upload a valid WXR (WordPress eXtended RSS) export file.').'

    '; + } + } + + // fetch the user ID for a given author name, respecting the mapping preferences + function checkauthor($author) { + global $current_user; + + if ( !empty($this->author_ids[$author]) ) + return $this->author_ids[$author]; + + // failsafe: map to the current user + return $current_user->ID; + } + + + + function process_categories() { + global $wpdb; + + $cat_names = (array) get_terms('category', 'fields=names'); + + while ( $c = array_shift($this->categories) ) { + $cat_name = trim($this->get_tag( $c, 'wp:cat_name' )); + + // If the category exists we leave it alone + if ( in_array($cat_name, $cat_names) ) + continue; + + $category_nicename = $this->get_tag( $c, 'wp:category_nicename' ); + $posts_private = (int) $this->get_tag( $c, 'wp:posts_private' ); + $links_private = (int) $this->get_tag( $c, 'wp:links_private' ); + + $parent = $this->get_tag( $c, 'wp:category_parent' ); + + if ( empty($parent) ) + $category_parent = '0'; + else + $category_parent = category_exists($parent); + + $catarr = compact('category_nicename', 'category_parent', 'posts_private', 'links_private', 'posts_private', 'cat_name'); + + $cat_ID = wp_insert_category($catarr); + } + } + + function process_tags() { + global $wpdb; + + $tag_names = (array) get_terms('post_tag', 'fields=names'); + + while ( $c = array_shift($this->tags) ) { + $tag_name = trim($this->get_tag( $c, 'wp:tag_name' )); + + // If the category exists we leave it alone + if ( in_array($tag_name, $tag_names) ) + continue; + + $slug = $this->get_tag( $c, 'wp:tag_slug' ); + $description = $this->get_tag( $c, 'wp:tag_description' ); + + $tagarr = compact('slug', 'description'); + + $tag_ID = wp_insert_term($tag_name, 'post_tag', $tagarr); + } + } + + function process_author($post) { + $author = $this->get_tag( $post, 'dc:creator' ); + if ($author) + $this->allauthornames[] = $author; + } + + function process_posts() { + echo '
      '; + + $this->get_entries(array(&$this, 'process_post')); + + echo '
    '; + + wp_import_cleanup($this->id); + do_action('import_done', 'wordpress'); + + echo '

    '.sprintf(__('All done.').' '.__('Have fun!').'', get_option('home')).'

    '; + } + + function process_post($post) { + global $wpdb; + + $post_ID = (int) $this->get_tag( $post, 'wp:post_id' ); + if ( $post_ID && !empty($this->post_ids_processed[$post_ID]) ) // Processed already + return 0; + + set_time_limit( 60 ); + + // There are only ever one of these + $post_title = $this->get_tag( $post, 'title' ); + $post_date = $this->get_tag( $post, 'wp:post_date' ); + $post_date_gmt = $this->get_tag( $post, 'wp:post_date_gmt' ); + $comment_status = $this->get_tag( $post, 'wp:comment_status' ); + $ping_status = $this->get_tag( $post, 'wp:ping_status' ); + $post_status = $this->get_tag( $post, 'wp:status' ); + $post_name = $this->get_tag( $post, 'wp:post_name' ); + $post_parent = $this->get_tag( $post, 'wp:post_parent' ); + $menu_order = $this->get_tag( $post, 'wp:menu_order' ); + $post_type = $this->get_tag( $post, 'wp:post_type' ); + $post_password = $this->get_tag( $post, 'wp:post_password' ); + $guid = $this->get_tag( $post, 'guid' ); + $post_author = $this->get_tag( $post, 'dc:creator' ); + + $post_excerpt = $this->get_tag( $post, 'excerpt:encoded' ); + $post_excerpt = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_excerpt); + $post_excerpt = str_replace('
    ', '
    ', $post_excerpt); + $post_excerpt = str_replace('
    ', '
    ', $post_excerpt); + + $post_content = $this->get_tag( $post, 'content:encoded' ); + $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); + $post_content = str_replace('
    ', '
    ', $post_content); + $post_content = str_replace('
    ', '
    ', $post_content); + + preg_match_all('|(.*?)|is', $post, $tags); + $tags = $tags[1]; + + $tag_index = 0; + foreach ($tags as $tag) { + $tags[$tag_index] = $wpdb->escape($this->unhtmlentities(str_replace(array (''), '', $tag))); + $tag_index++; + } + + preg_match_all('|(.*?)|is', $post, $categories); + $categories = $categories[1]; + + $cat_index = 0; + foreach ($categories as $category) { + $categories[$cat_index] = $wpdb->escape($this->unhtmlentities(str_replace(array (''), '', $category))); + $cat_index++; + } + + $post_exists = post_exists($post_title, '', $post_date); + + if ( $post_exists ) { + echo '
  • '; + printf(__('Post %s already exists.'), stripslashes($post_title)); + $comment_post_ID = $post_id = $post_exists; + } else { + + // If it has parent, process parent first. + $post_parent = (int) $post_parent; + if ($post_parent) { + // if we already know the parent, map it to the local ID + if ( $parent = $this->post_ids_processed[$post_parent] ) { + $post_parent = $parent; // new ID of the parent + } + else { + // record the parent for later + $this->orphans[intval($post_ID)] = $post_parent; + } + } + + echo '
  • '; + + $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_excerpt', 'post_title', 'post_status', 'post_name', 'comment_status', 'ping_status', 'guid', 'post_parent', 'menu_order', 'post_type', 'post_password'); + $postdata['import_id'] = $post_ID; + if ($post_type == 'attachment') { + $remote_url = $this->get_tag( $post, 'wp:attachment_url' ); + if ( !$remote_url ) + $remote_url = $guid; + + $comment_post_ID = $post_id = $this->process_attachment($postdata, $remote_url); + if ( !$post_id or is_wp_error($post_id) ) + return $post_id; + } + else { + printf(__('Importing post %s...'), stripslashes($post_title)); + $comment_post_ID = $post_id = wp_insert_post($postdata); + } + + if ( is_wp_error( $post_id ) ) + return $post_id; + + // Memorize old and new ID. + if ( $post_id && $post_ID ) { + $this->post_ids_processed[intval($post_ID)] = intval($post_id); + } + + // Add categories. + if (count($categories) > 0) { + $post_cats = array(); + foreach ($categories as $category) { + if ( '' == $category ) + continue; + $slug = sanitize_term_field('slug', $category, 0, 'category', 'db'); + $cat = get_term_by('slug', $slug, 'category'); + $cat_ID = 0; + if ( ! empty($cat) ) + $cat_ID = $cat->term_id; + if ($cat_ID == 0) { + $category = $wpdb->escape($category); + $cat_ID = wp_insert_category(array('cat_name' => $category)); + if ( is_wp_error($cat_ID) ) + continue; + } + $post_cats[] = $cat_ID; + } + wp_set_post_categories($post_id, $post_cats); + } + + // Add tags. + if (count($tags) > 0) { + $post_tags = array(); + foreach ($tags as $tag) { + if ( '' == $tag ) + continue; + $slug = sanitize_term_field('slug', $tag, 0, 'post_tag', 'db'); + $tag_obj = get_term_by('slug', $slug, 'post_tag'); + $tag_id = 0; + if ( ! empty($tag_obj) ) + $tag_id = $tag_obj->term_id; + if ( $tag_id == 0 ) { + $tag = $wpdb->escape($tag); + $tag_id = wp_insert_term($tag, 'post_tag'); + if ( is_wp_error($tag_id) ) + continue; + $tag_id = $tag_id['term_id']; + } + $post_tags[] = intval($tag_id); + } + wp_set_post_tags($post_id, $post_tags); + } + } + + // Now for comments + preg_match_all('|(.*?)|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 this is a new post we can skip the comment_exists() check + if ( !$post_exists || !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(' '.__ngettext('(%s comment)', '(%s comments)', $num_comments), $num_comments); + + // Now for post meta + preg_match_all('|(.*?)|is', $post, $postmeta); + $postmeta = $postmeta[1]; + if ( $postmeta) { foreach ($postmeta as $p) { + $key = $this->get_tag( $p, 'wp:meta_key' ); + $value = $this->get_tag( $p, 'wp:meta_value' ); + $value = stripslashes($value); // add_post_meta() will escape. + + $this->process_post_meta($post_id, $key, $value); + + } } + + do_action('import_post_added', $post_id); + print "
  • \n"; + } + + function process_post_meta($post_id, $key, $value) { + // the filter can return false to skip a particular metadata key + $_key = apply_filters('import_post_meta_key', $key); + if ( $_key ) { + add_post_meta( $post_id, $_key, $value ); + do_action('import_post_meta', $post_id, $_key, $value); + } + } + + function process_attachment($postdata, $remote_url) { + if ($this->fetch_attachments and $remote_url) { + printf( __('Importing attachment %s... '), htmlspecialchars($remote_url) ); + + // If the URL is absolute, but does not contain http, upload it assuming the base_site_url variable + if ( preg_match('/^\/[\w\W]+$/', $remote_url) ) + $remote_url = rtrim($this->base_url,'/').$remote_url; + + $upload = $this->fetch_remote_file($postdata, $remote_url); + if ( is_wp_error($upload) ) { + printf( __('Remote file error: %s'), htmlspecialchars($upload->get_error_message()) ); + return $upload; + } + else { + print '('.size_format(filesize($upload['file'])).')'; + } + + if ( $info = wp_check_filetype($upload['file']) ) { + $postdata['post_mime_type'] = $info['type']; + } + else { + print __('Invalid file type'); + return; + } + + $postdata['guid'] = $upload['url']; + + // as per wp-admin/includes/upload.php + $post_id = wp_insert_attachment($postdata, $upload['file']); + wp_update_attachment_metadata( $post_id, wp_generate_attachment_metadata( $post_id, $upload['file'] ) ); + + // remap the thumbnail url. this isn't perfect because we're just guessing the original url. + if ( preg_match('@^image/@', $info['type']) && $thumb_url = wp_get_attachment_thumb_url($post_id) ) { + $parts = pathinfo($remote_url); + $ext = $parts['extension']; + $name = basename($parts['basename'], ".{$ext}"); + $this->url_remap[$parts['dirname'] . '/' . $name . '.thumbnail.' . $ext] = $thumb_url; + } + + return $post_id; + } + else { + printf( __('Skipping attachment %s'), htmlspecialchars($remote_url) ); + } + } + + function fetch_remote_file($post, $url) { + $upload = wp_upload_dir($post['post_date']); + + // extract the file name and extension from the url + $file_name = basename($url); + + // get placeholder file in the upload dir with a unique sanitized filename + $upload = wp_upload_bits( $file_name, 0, '', $post['post_date']); + if ( $upload['error'] ) { + echo $upload['error']; + return new WP_Error( 'upload_dir_error', $upload['error'] ); + } + + // fetch the remote url and write it to the placeholder file + $headers = wp_get_http($url, $upload['file']); + + //Request failed + if ( ! $headers ) { + @unlink($upload['file']); + return new WP_Error( 'import_file_error', __('Remote server did not respond') ); + } + + // make sure the fetch was successful + if ( $headers['response'] != '200' ) { + @unlink($upload['file']); + return new WP_Error( 'import_file_error', sprintf(__('Remote file returned error response %1$d %2$s'), $headers['response'], get_status_header_desc($headers['response']) ) ); + } + elseif ( isset($headers['content-length']) && filesize($upload['file']) != $headers['content-length'] ) { + @unlink($upload['file']); + return new WP_Error( 'import_file_error', __('Remote file is incorrect size') ); + } + + $max_size = $this->max_attachment_size(); + if ( !empty($max_size) and filesize($upload['file']) > $max_size ) { + @unlink($upload['file']); + return new WP_Error( 'import_file_error', sprintf(__('Remote file is too large, limit is %s', size_format($max_size))) ); + } + + // keep track of the old and new urls so we can substitute them later + $this->url_remap[$url] = $upload['url']; + // if the remote url is redirected somewhere else, keep track of the destination too + if ( $headers['x-final-location'] != $url ) + $this->url_remap[$headers['x-final-location']] = $upload['url']; + + return $upload; + + } + + // sort by strlen, longest string first + function cmpr_strlen($a, $b) { + return strlen($b) - strlen($a); + } + + // update url references in post bodies to point to the new local files + function backfill_attachment_urls() { + + // make sure we do the longest urls first, in case one is a substring of another + uksort($this->url_remap, array(&$this, 'cmpr_strlen')); + + global $wpdb; + foreach ($this->url_remap as $from_url => $to_url) { + // remap urls in post_content + $wpdb->query( $wpdb->prepare("UPDATE {$wpdb->posts} SET post_content = REPLACE(post_content, '%s', '%s')", $from_url, $to_url) ); + // remap enclosure urls + $result = $wpdb->query( $wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_value = REPLACE(meta_value, '%s', '%s') WHERE meta_key='enclosure'", $from_url, $to_url) ); + } + } + + // update the post_parent of orphans now that we know the local id's of all parents + function backfill_parents() { + global $wpdb; + + foreach ($this->orphans as $child_id => $parent_id) { + $local_child_id = $this->post_ids_processed[$child_id]; + $local_parent_id = $this->post_ids_processed[$parent_id]; + if ($local_child_id and $local_parent_id) { + $wpdb->query( $wpdb->prepare("UPDATE {$wpdb->posts} SET post_parent = %d WHERE ID = %d", $local_parent_id, $local_child_id)); + } + } + } + + function is_valid_meta_key($key) { + // skip _wp_attached_file metadata since we'll regenerate it from scratch + if ( $key == '_wp_attached_file' ) + return false; + return $key; + } + + // give the user the option of creating new users to represent authors in the import file? + function allow_create_users() { + return apply_filters('import_allow_create_users', true); + } + + // give the user the option of downloading and importing attached files + function allow_fetch_attachments() { + return apply_filters('import_allow_fetch_attachments', true); + } + + function max_attachment_size() { + // can be overridden with a filter - 0 means no limit + return apply_filters('import_attachment_size_limit', 0); + } + + function import_start() { + wp_defer_term_counting(true); + wp_defer_comment_counting(true); + do_action('import_start'); + } + + function import_end() { + do_action('import_end'); + + // clear the caches after backfilling + foreach ($this->post_ids_processed as $post_id) + clean_post_cache($post_id); + + wp_defer_term_counting(false); + wp_defer_comment_counting(false); + } + + function import($id, $fetch_attachments = false) { + $this->id = (int) $id; + $this->fetch_attachments = ($this->allow_fetch_attachments() && (bool) $fetch_attachments); + + add_filter('import_post_meta_key', array($this, 'is_valid_meta_key')); + $file = get_attached_file($this->id); + $this->import_file($file); + } + + function import_file($file) { + $this->file = $file; + + $this->import_start(); + $this->get_authors_from_post(); + wp_suspend_cache_invalidation(true); + $this->get_entries(); + $this->process_categories(); + $this->process_tags(); + $result = $this->process_posts(); + wp_suspend_cache_invalidation(false); + $this->backfill_parents(); + $this->backfill_attachment_urls(); + $this->import_end(); + + if ( is_wp_error( $result ) ) + return $result; + } + + function handle_upload() { + $file = wp_import_handle_upload(); + if ( isset($file['error']) ) { + echo '

    '.__('Sorry, there has been an error.').'

    '; + echo '

    ' . $file['error'] . '

    '; + return false; + } + $this->file = $file['file']; + $this->id = (int) $file['id']; + return true; + } + + function dispatch() { + if (empty ($_GET['step'])) + $step = 0; + else + $step = (int) $_GET['step']; + + $this->header(); + switch ($step) { + case 0 : + $this->greet(); + break; + case 1 : + check_admin_referer('import-upload'); + if ( $this->handle_upload() ) + $this->select_authors(); + break; + case 2: + check_admin_referer('import-wordpress'); + $result = $this->import( $_GET['id'], $_POST['attachments'] ); + if ( is_wp_error( $result ) ) + echo $result->get_error_message(); + break; + } + $this->footer(); + } + + function WP_Import() { + // Nothing. + } +} + +/** + * Register WordPress Importer + * + * @since unknown + * @var WP_Import + * @name $wp_import + */ +$wp_import = new WP_Import(); + +register_importer('wordpress', 'WordPress', __('Import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.'), array ($wp_import, 'dispatch')); + +?> diff -uNr a/blog/wp-admin/import/wp-cat2tag.php b/blog/wp-admin/import/wp-cat2tag.php --- a/blog/wp-admin/import/wp-cat2tag.php false +++ b/blog/wp-admin/import/wp-cat2tag.php 5af990699a0f8fc447241dd473d8ee01d1588a959b9ab56e23c483e01468135d092bc2bb918d616f8871e49f478775a6191f40baddb8fb22e236db8e23c2f102 @@ -0,0 +1,476 @@ +'; + if ( ! current_user_can('manage_categories') ) { + echo '
    '; + echo '

    ' . __('Cheatin’ uh?') . '

    '; + echo '
    '; + } else { ?> +

    +

    +'; + } + + function populate_cats() { + + $categories = get_categories('get=all'); + foreach ( $categories as $category ) { + $this->all_categories[] = $category; + if ( is_term( $category->slug, 'post_tag' ) ) + $this->hybrids_ids[] = $category->term_id; + } + } + + function populate_tags() { + + $tags = get_terms( array('post_tag'), 'get=all' ); + foreach ( $tags as $tag ) { + $this->all_tags[] = $tag; + if ( is_term( $tag->slug, 'category' ) ) + $this->hybrids_ids[] = $tag->term_id; + } + } + + function categories_tab() { + $this->populate_cats(); + $cat_num = count($this->all_categories); + + echo '
    '; + + if ( $cat_num > 0 ) { + screen_icon(); + echo '

    ' . sprintf( __ngettext( 'Convert Category to Tag.', 'Convert Categories (%d) to Tags.', $cat_num ), $cat_num ) . '

    '; + echo '
    '; + echo '

    ' . __('Hey there. Here you can selectively convert existing categories to tags. To get started, check the categories you wish to be converted, then click the Convert button.') . '

    '; + echo '

    ' . __('Keep in mind that if you convert a category with child categories, the children become top-level orphans.') . '

    '; + + $this->categories_form(); + } else { + echo '

    '.__('You have no categories to convert!').'

    '; + } + } + + function categories_form() { ?> + + + +
    +

    +

    +
      + +all_categories as $category) { + $category = sanitize_term( $category, 'category', 'display' ); + + if ( (int) $category->parent == 0 ) { ?> + +
    • term_id), $this->hybrids_ids ) ) + echo ' * '; + + if ( isset($hier[$category->term_id]) ) + $this->_category_children($category, $hier); ?>
    • + +
    + +hybrids_ids) ) + echo '

    ' . __('* This category is also a tag. Converting it will add that tag to all posts that are currently in the category.') . '

    '; ?> + +

    +
    + +populate_tags(); + $tags_num = count($this->all_tags); + + echo '
    '; + + if ( $tags_num > 0 ) { + screen_icon(); + echo '

    ' . sprintf( __ngettext( 'Convert Tag to Category.', 'Convert Tags (%d) to Categories.', $tags_num ), $tags_num ) . '

    '; + echo '
    '; + echo '

    ' . __('Here you can selectively converts existing tags to categories. To get started, check the tags you wish to be converted, then click the Convert button.') . '

    '; + echo '

    ' . __('The newly created categories will still be associated with the same posts.') . '

    '; + + $this->tags_form(); + } else { + echo '

    '.__('You have no tags to convert!').'

    '; + } + } + + function tags_form() { ?> + + + +
    +

    +

    +
      + +all_tags as $tag ) { ?> +
    • term_id), $this->hybrids_ids ) ) echo ' * '; ?>
    • + + +
    + +hybrids_ids) ) + echo '

    ' . __('* This tag is also a category. When converted, all posts associated with the tag will also be in the category.') . '

    '; ?> + +

    +
    + + + +
      +term_id] as $child_id) { + $child =& get_category($child_id); ?> +
    • term_id), $this->hybrids_ids ) ) + echo ' * '; + + if ( isset($hier[$child->term_id]) ) + $this->_category_children($child, $hier); ?>
    • + +
    categories_to_convert)) { ?> +
    +

    try again.'), 'admin.php?import=wp-cat2tag'); ?>

    +
    +categories_to_convert) ) + $this->categories_to_convert = $_POST['cats_to_convert']; + + $hier = _get_term_hierarchy('category'); + $hybrid_cats = $clear_parents = $parents = false; + $clean_term_cache = $clean_cat_cache = array(); + $default_cat = get_option('default_category'); + + echo '
      '; + + foreach ( (array) $this->categories_to_convert as $cat_id) { + $cat_id = (int) $cat_id; + + if ( ! $this->_category_exists($cat_id) ) { + echo '
    • ' . sprintf( __('Category %s doesn\'t exist!'), $cat_id ) . "
    • \n"; + } else { + $category =& get_category($cat_id); + echo '
    • ' . sprintf(__('Converting category %s ... '), $category->name); + + // If the category is the default, leave category in place and create tag. + if ( $default_cat == $category->term_id ) { + + if ( ! ($id = is_term( $category->slug, 'post_tag' ) ) ) + $id = wp_insert_term($category->name, 'post_tag', array('slug' => $category->slug)); + + $id = $id['term_taxonomy_id']; + $posts = get_objects_in_term($category->term_id, 'category'); + $term_order = 0; + + foreach ( $posts as $post ) { + $values[] = $wpdb->prepare( "(%d, %d, %d)", $post, $id, $term_order); + clean_post_cache($post); + } + + if ( $values ) { + $wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id, term_order) VALUES " . join(',', $values) . " ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)"); + + $wpdb->query( $wpdb->prepare("UPDATE $wpdb->term_taxonomy SET count = %d WHERE term_id = %d AND taxonomy = 'post_tag'", $category->count, $category->term_id) ); + } + + echo __('Converted successfully.') . "
    • \n"; + continue; + } + + // if tag already exists, add it to all posts in the category + if ( $tag_ttid = $wpdb->get_var( $wpdb->prepare("SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE term_id = %d AND taxonomy = 'post_tag'", $category->term_id) ) ) { + $objects_ids = get_objects_in_term($category->term_id, 'category'); + $tag_ttid = (int) $tag_ttid; + $term_order = 0; + + foreach ( $objects_ids as $object_id ) + $values[] = $wpdb->prepare( "(%d, %d, %d)", $object_id, $tag_ttid, $term_order); + + if ( $values ) { + $wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id, term_order) VALUES " . join(',', $values) . " ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)"); + + $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $tag_ttid) ); + $wpdb->query( $wpdb->prepare("UPDATE $wpdb->term_taxonomy SET count = %d WHERE term_id = %d AND taxonomy = 'post_tag'", $count, $category->term_id) ); + } + echo __('Tag added to all posts in this category.') . " *\n"; + + $hybrid_cats = true; + $clean_term_cache[] = $category->term_id; + $clean_cat_cache[] = $category->term_id; + + continue; + } + + $tt_ids = $wpdb->get_col( $wpdb->prepare("SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE term_id = %d AND taxonomy = 'category'", $category->term_id) ); + if ( $tt_ids ) { + $posts = $wpdb->get_col("SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id IN (" . join(',', $tt_ids) . ") GROUP BY object_id"); + foreach ( (array) $posts as $post ) + clean_post_cache($post); + } + + // Change the category to a tag. + $wpdb->query( $wpdb->prepare("UPDATE $wpdb->term_taxonomy SET taxonomy = 'post_tag' WHERE term_id = %d AND taxonomy = 'category'", $category->term_id) ); + + // Set all parents to 0 (root-level) if their parent was the converted tag + $parents = $wpdb->query( $wpdb->prepare("UPDATE $wpdb->term_taxonomy SET parent = 0 WHERE parent = %d AND taxonomy = 'category'", $category->term_id) ); + + if ( $parents ) $clear_parents = true; + $clean_cat_cache[] = $category->term_id; + echo __('Converted successfully.') . "\n"; + } + } + echo '
    '; + + if ( ! empty($clean_term_cache) ) { + $clean_term_cache = array_unique(array_values($clean_term_cache)); + foreach ( $clean_term_cache as $id ) + wp_cache_delete($id, 'post_tag'); + } + + if ( ! empty($clean_cat_cache) ) { + $clean_cat_cache = array_unique(array_values($clean_cat_cache)); + foreach ( $clean_cat_cache as $id ) + wp_cache_delete($id, 'category'); + } + + if ( $clear_parents ) delete_option('category_children'); + + if ( $hybrid_cats ) + echo '

    ' . sprintf( __('* This category is also a tag. The converter has added that tag to all posts currently in the category. If you want to remove it, please confirm that all tags were added successfully, then delete it from the Manage Categories page.'), 'categories.php') . '

    '; + echo '

    ' . sprintf( __('We’re all done here, but you can always convert more.'), 'admin.php?import=wp-cat2tag' ) . '

    '; + } + + function convert_tags() { + global $wpdb; + + if ( (!isset($_POST['tags_to_convert']) || !is_array($_POST['tags_to_convert'])) && empty($this->tags_to_convert)) { + echo '
    '; + echo '

    ' . sprintf(__('Uh, oh. Something didn’t work. Please try again.'), 'admin.php?import=wp-cat2tag&step=3') . '

    '; + echo '
    '; + return; + } + + if ( empty($this->tags_to_convert) ) + $this->tags_to_convert = $_POST['tags_to_convert']; + + $hybrid_tags = $clear_parents = false; + $clean_cat_cache = $clean_term_cache = array(); + $default_cat = get_option('default_category'); + echo '
      '; + + foreach ( (array) $this->tags_to_convert as $tag_id) { + $tag_id = (int) $tag_id; + + if ( $tag = get_term( $tag_id, 'post_tag' ) ) { + printf('
    • ' . __('Converting tag %s ... '), $tag->name); + + if ( $cat_ttid = $wpdb->get_var( $wpdb->prepare("SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE term_id = %d AND taxonomy = 'category'", $tag->term_id) ) ) { + $objects_ids = get_objects_in_term($tag->term_id, 'post_tag'); + $cat_ttid = (int) $cat_ttid; + $term_order = 0; + + foreach ( $objects_ids as $object_id ) { + $values[] = $wpdb->prepare( "(%d, %d, %d)", $object_id, $cat_ttid, $term_order); + clean_post_cache($object_id); + } + + if ( $values ) { + $wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id, term_order) VALUES " . join(',', $values) . " ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)"); + + if ( $default_cat != $tag->term_id ) { + $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $tag->term_id) ); + $wpdb->query( $wpdb->prepare("UPDATE $wpdb->term_taxonomy SET count = %d WHERE term_id = %d AND taxonomy = 'category'", $count, $tag->term_id) ); + } + } + + $hybrid_tags = true; + $clean_term_cache[] = $tag->term_id; + $clean_cat_cache[] = $tag->term_id; + echo __('All posts were added to the category with the same name.') . " *
    • \n"; + + continue; + } + + // Change the tag to a category. + $parent = $wpdb->get_var( $wpdb->prepare("SELECT parent FROM $wpdb->term_taxonomy WHERE term_id = %d AND taxonomy = 'post_tag'", $tag->term_id) ); + if ( 0 == $parent || (0 < (int) $parent && $this->_category_exists($parent)) ) { + $reset_parent = ''; + $clear_parents = true; + } else + $reset_parent = ", parent = '0'"; + + $wpdb->query( $wpdb->prepare("UPDATE $wpdb->term_taxonomy SET taxonomy = 'category' $reset_parent WHERE term_id = %d AND taxonomy = 'post_tag'", $tag->term_id) ); + + $clean_term_cache[] = $tag->term_id; + $clean_cat_cache[] = $cat['term_id']; + echo __('Converted successfully.') . "\n"; + + } else { + printf( '
    • ' . __('Tag #%s doesn\'t exist!') . "
    • \n", $tag_id ); + } + } + + if ( ! empty($clean_term_cache) ) { + $clean_term_cache = array_unique(array_values($clean_term_cache)); + foreach ( $clean_term_cache as $id ) + wp_cache_delete($id, 'post_tag'); + } + + if ( ! empty($clean_cat_cache) ) { + $clean_cat_cache = array_unique(array_values($clean_cat_cache)); + foreach ( $clean_cat_cache as $id ) + wp_cache_delete($id, 'category'); + } + + if ( $clear_parents ) delete_option('category_children'); + + echo '
    '; + if ( $hybrid_tags ) + echo '

    ' . sprintf( __('* This tag is also a category. The converter has added all posts from it to the category. If you want to remove it, please confirm that all posts were added successfully, then delete it from the Manage Tags page.'), 'edit-tags.php') . '

    '; + echo '

    ' . sprintf( __('We’re all done here, but you can always convert more.'), 'admin.php?import=wp-cat2tag&step=3' ) . '

    '; + } + + function init() { + + $step = (isset($_GET['step'])) ? (int) $_GET['step'] : 1; + + $this->header(); + + if ( current_user_can('manage_categories') ) { + + switch ($step) { + case 1 : + $this->categories_tab(); + break; + + case 2 : + check_admin_referer('import-cat2tag'); + $this->convert_categories(); + break; + + case 3 : + $this->tags_tab(); + break; + + case 4 : + check_admin_referer('import-cat2tag'); + $this->convert_tags(); + break; + } + } + + $this->footer(); + } + + function WP_Categories_to_Tags() { + // Do nothing. + } +} + +$wp_cat2tag_importer = new WP_Categories_to_Tags(); + +register_importer('wp-cat2tag', __('Categories and Tags Converter'), __('Convert existing categories to tags or tags to categories, selectively.'), array(&$wp_cat2tag_importer, 'init')); + +?> diff -uNr a/blog/wp-admin/import.php b/blog/wp-admin/import.php --- a/blog/wp-admin/import.php false +++ b/blog/wp-admin/import.php d6d024e5e80657c1b1350cc86193e3fe057b931b86c97fe2e92700990a1b8bfbf21c4af8d7b79693a80eec3ef00814e1ec080ec5767bfd32519d4fcddb02c70d @@ -0,0 +1,73 @@ + + +
    + +

    +

    + +'.__('No importers are available.').'

    '; // TODO: make more helpful +} else { +?> + + + $data) { + $style = ('class="alternate"' == $style || 'class="alternate active"' == $style) ? '' : 'alternate'; + $action = "{$data[0]}"; + + if ($style != '') + $style = 'class="'.$style.'"'; + echo " + + + + "; + } +?> + +
    $action{$data[1]}
    + + +
    + + + diff -uNr a/blog/wp-admin/includes/admin.php b/blog/wp-admin/includes/admin.php --- a/blog/wp-admin/includes/admin.php false +++ b/blog/wp-admin/includes/admin.php f5841b68da4882102235f9c997ff8e608d909ec69495006bc54d4b6ef64ee98b78b7892cbda0ceb23ebf9cadbc74ffff4b2741948000d8d8deba8fd2baa22f82 @@ -0,0 +1,54 @@ + \ No newline at end of file diff -uNr a/blog/wp-admin/includes/bookmark.php b/blog/wp-admin/includes/bookmark.php --- a/blog/wp-admin/includes/bookmark.php false +++ b/blog/wp-admin/includes/bookmark.php d761c801605a656e672b26b1b47f62c3c83d9ff26f07f1f7aad1fed26e1acf1204dd3a2a4ffcecf2f23b1200eef42695a8aface8c59e4866ab291e9ca6f24608 @@ -0,0 +1,268 @@ +link_url = clean_url( $_GET['linkurl']); + else + $link->link_url = ''; + + if ( isset( $_GET['name'] ) ) + $link->link_name = attribute_escape( $_GET['name']); + else + $link->link_name = ''; + + $link->link_visible = 'Y'; + + return $link; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $link_id + * @return unknown + */ +function wp_delete_link( $link_id ) { + global $wpdb; + + do_action( 'delete_link', $link_id ); + + wp_delete_object_term_relationships( $link_id, 'link_category' ); + + $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->links WHERE link_id = %d", $link_id ) ); + + do_action( 'deleted_link', $link_id ); + + clean_bookmark_cache( $link_id ); + + return true; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $link_id + * @return unknown + */ +function wp_get_link_cats( $link_id = 0 ) { + + $cats = wp_get_object_terms( $link_id, 'link_category', 'fields=ids' ); + + return array_unique( $cats ); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $link_id + * @return unknown + */ +function get_link_to_edit( $link_id ) { + return get_bookmark( $link_id, OBJECT, 'edit' ); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $linkdata + * @return unknown + */ +function wp_insert_link( $linkdata, $wp_error = false ) { + global $wpdb, $current_user; + + $defaults = array( 'link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0 ); + + $linkdata = wp_parse_args( $linkdata, $defaults ); + $linkdata = sanitize_bookmark( $linkdata, 'db' ); + + extract( stripslashes_deep( $linkdata ), EXTR_SKIP ); + + $update = false; + + if ( !empty( $link_id ) ) + $update = true; + + if ( trim( $link_name ) == '' ) + return 0; + + if ( trim( $link_url ) == '' ) + return 0; + + if ( empty( $link_rating ) ) + $link_rating = 0; + + if ( empty( $link_image ) ) + $link_image = ''; + + 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 = ''; + + if ( empty( $link_description ) ) + $link_description = ''; + + if ( empty( $link_rss ) ) + $link_rss = ''; + + if ( empty( $link_rel ) ) + $link_rel = ''; + + // Make sure we set a valid category + if ( ! isset( $link_category ) ||0 == count( $link_category ) || !is_array( $link_category ) ) { + $link_category = array( get_option( 'default_link_category' ) ); + } + + if ( $update ) { + if ( false === $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->links SET link_url = %s, + link_name = %s, link_image = %s, link_target = %s, + link_visible = %s, link_description = %s, link_rating = %s, + link_rel = %s, link_notes = %s, link_rss = %s + WHERE link_id = %s", $link_url, $link_name, $link_image, $link_target, $link_visible, $link_description, $link_rating, $link_rel, $link_notes, $link_rss, $link_id ) ) ) { + if ( $wp_error ) + return new WP_Error( 'db_update_error', __( 'Could not update link in the database' ), $wpdb->last_error ); + else + return 0; + } + } else { + if ( false === $wpdb->query( $wpdb->prepare( "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(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", + $link_url,$link_name, $link_image, $link_target, $link_description, $link_visible, $link_owner, $link_rating, $link_rel, $link_notes, $link_rss ) ) ) { + if ( $wp_error ) + return new WP_Error( 'db_insert_error', __( 'Could not insert link into the database' ), $wpdb->last_error ); + else + return 0; + } + $link_id = (int) $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 ); + + clean_bookmark_cache( $link_id ); + + return $link_id; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $link_id + * @param unknown_type $link_categories + */ +function wp_set_link_cats( $link_id = 0, $link_categories = array() ) { + // 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_map( 'intval', $link_categories ); + $link_categories = array_unique( $link_categories ); + + wp_set_object_terms( $link_id, $link_categories, 'link_category' ); + + clean_bookmark_cache( $link_id ); +} // wp_set_link_cats() + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $linkdata + * @return unknown + */ +function wp_update_link( $linkdata ) { + $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 ); +} + +?> diff -uNr a/blog/wp-admin/includes/class-ftp.php b/blog/wp-admin/includes/class-ftp.php --- a/blog/wp-admin/includes/class-ftp.php false +++ b/blog/wp-admin/includes/class-ftp.php 02807e10076294605432db3be6cd1c4c1b08757eaa58a9d3cd9c14b151786a230bf5222f1df8900d63131e0fad1269db300feaac2461e25aeed293f55d46fd66 @@ -0,0 +1,903 @@ +__construct($port_mode); + } + + function __construct($port_mode=FALSE, $verb=FALSE, $le=FALSE) { + $this->LocalEcho=$le; + $this->Verbose=$verb; + $this->_lastaction=NULL; + $this->_error_array=array(); + $this->_eol_code=array(FTP_OS_Unix=>"\n", FTP_OS_Mac=>"\r", FTP_OS_Windows=>"\r\n"); + $this->AuthorizedTransferMode=array(FTP_AUTOASCII, FTP_ASCII, FTP_BINARY); + $this->OS_FullName=array(FTP_OS_Unix => 'UNIX', FTP_OS_Windows => 'WINDOWS', FTP_OS_Mac => 'MACOS'); + $this->AutoAsciiExt=array("ASP","BAT","C","CPP","CSS","CSV","JS","H","HTM","HTML","SHTML","INI","LOG","PHP3","PHTML","PL","PERL","SH","SQL","TXT"); + $this->_port_available=($port_mode==TRUE); + $this->SendMSG("Staring FTP client class".($this->_port_available?"":" without PORT mode support")); + $this->_connected=FALSE; + $this->_ready=FALSE; + $this->_can_restore=FALSE; + $this->_code=0; + $this->_message=""; + $this->_ftp_buff_size=4096; + $this->_curtype=NULL; + $this->SetUmask(0022); + $this->SetType(FTP_AUTOASCII); + $this->SetTimeout(30); + $this->Passive(!$this->_port_available); + $this->_login="anonymous"; + $this->_password="anon@ftp.com"; + $this->_features=array(); + $this->OS_local=FTP_OS_Unix; + $this->OS_remote=FTP_OS_Unix; + $this->features=array(); + if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $this->OS_local=FTP_OS_Windows; + elseif(strtoupper(substr(PHP_OS, 0, 3)) === 'MAC') $this->OS_local=FTP_OS_Mac; + } + +// +// +// + + function parselisting($line) { + $is_windows = ($this->OS_remote == FTP_OS_Windows); + if ($is_windows && preg_match("/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|) +(.+)/",$line,$lucifer)) { + $b = array(); + if ($lucifer[3]<70) { $lucifer[3]+=2000; } else { $lucifer[3]+=1900; } // 4digit year fix + $b['isdir'] = ($lucifer[7]==""); + if ( $b['isdir'] ) + $b['type'] = 'd'; + else + $b['type'] = 'f'; + $b['size'] = $lucifer[7]; + $b['month'] = $lucifer[1]; + $b['day'] = $lucifer[2]; + $b['year'] = $lucifer[3]; + $b['hour'] = $lucifer[4]; + $b['minute'] = $lucifer[5]; + $b['time'] = @mktime($lucifer[4]+(strcasecmp($lucifer[6],"PM")==0?12:0),$lucifer[5],0,$lucifer[1],$lucifer[2],$lucifer[3]); + $b['am/pm'] = $lucifer[6]; + $b['name'] = $lucifer[8]; + } else if (!$is_windows && $lucifer=preg_split("/[ ]/",$line,9,PREG_SPLIT_NO_EMPTY)) { + //echo $line."\n"; + $lcount=count($lucifer); + if ($lcount<8) return ''; + $b = array(); + $b['isdir'] = $lucifer[0]{0} === "d"; + $b['islink'] = $lucifer[0]{0} === "l"; + if ( $b['isdir'] ) + $b['type'] = 'd'; + elseif ( $b['islink'] ) + $b['type'] = 'l'; + else + $b['type'] = 'f'; + $b['perms'] = $lucifer[0]; + $b['number'] = $lucifer[1]; + $b['owner'] = $lucifer[2]; + $b['group'] = $lucifer[3]; + $b['size'] = $lucifer[4]; + if ($lcount==8) { + sscanf($lucifer[5],"%d-%d-%d",$b['year'],$b['month'],$b['day']); + sscanf($lucifer[6],"%d:%d",$b['hour'],$b['minute']); + $b['time'] = @mktime($b['hour'],$b['minute'],0,$b['month'],$b['day'],$b['year']); + $b['name'] = $lucifer[7]; + } else { + $b['month'] = $lucifer[5]; + $b['day'] = $lucifer[6]; + if (preg_match("/([0-9]{2}):([0-9]{2})/",$lucifer[7],$l2)) { + $b['year'] = date("Y"); + $b['hour'] = $l2[1]; + $b['minute'] = $l2[2]; + } else { + $b['year'] = $lucifer[7]; + $b['hour'] = 0; + $b['minute'] = 0; + } + $b['time'] = strtotime(sprintf("%d %s %d %02d:%02d",$b['day'],$b['month'],$b['year'],$b['hour'],$b['minute'])); + $b['name'] = $lucifer[8]; + } + } + + return $b; + } + + function SendMSG($message = "", $crlf=true) { + if ($this->Verbose) { + echo $message.($crlf?CRLF:""); + flush(); + } + return TRUE; + } + + function SetType($mode=FTP_AUTOASCII) { + if(!in_array($mode, $this->AuthorizedTransferMode)) { + $this->SendMSG("Wrong type"); + return FALSE; + } + $this->_type=$mode; + $this->SendMSG("Transfer type: ".($this->_type==FTP_BINARY?"binary":($this->_type==FTP_ASCII?"ASCII":"auto ASCII") ) ); + return TRUE; + } + + function _settype($mode=FTP_ASCII) { + if($this->_ready) { + if($mode==FTP_BINARY) { + if($this->_curtype!=FTP_BINARY) { + if(!$this->_exec("TYPE I", "SetType")) return FALSE; + $this->_curtype=FTP_BINARY; + } + } elseif($this->_curtype!=FTP_ASCII) { + if(!$this->_exec("TYPE A", "SetType")) return FALSE; + $this->_curtype=FTP_ASCII; + } + } else return FALSE; + return TRUE; + } + + function Passive($pasv=NULL) { + if(is_null($pasv)) $this->_passive=!$this->_passive; + else $this->_passive=$pasv; + if(!$this->_port_available and !$this->_passive) { + $this->SendMSG("Only passive connections available!"); + $this->_passive=TRUE; + return FALSE; + } + $this->SendMSG("Passive mode ".($this->_passive?"on":"off")); + return TRUE; + } + + function SetServer($host, $port=21, $reconnect=true) { + if(!is_long($port)) { + $this->verbose=true; + $this->SendMSG("Incorrect port syntax"); + return FALSE; + } else { + $ip=@gethostbyname($host); + $dns=@gethostbyaddr($host); + if(!$ip) $ip=$host; + if(!$dns) $dns=$host; + if(ip2long($ip) === -1) { + $this->SendMSG("Wrong host name/address \"".$host."\""); + return FALSE; + } + $this->_host=$ip; + $this->_fullhost=$dns; + $this->_port=$port; + $this->_dataport=$port-1; + } + $this->SendMSG("Host \"".$this->_fullhost."(".$this->_host."):".$this->_port."\""); + if($reconnect){ + if($this->_connected) { + $this->SendMSG("Reconnecting"); + if(!$this->quit(FTP_FORCE)) return FALSE; + if(!$this->connect()) return FALSE; + } + } + return TRUE; + } + + function SetUmask($umask=0022) { + $this->_umask=$umask; + umask($this->_umask); + $this->SendMSG("UMASK 0".decoct($this->_umask)); + return TRUE; + } + + function SetTimeout($timeout=30) { + $this->_timeout=$timeout; + $this->SendMSG("Timeout ".$this->_timeout); + if($this->_connected) + if(!$this->_settimeout($this->_ftp_control_sock)) return FALSE; + return TRUE; + } + + function connect($server=NULL) { + if(!empty($server)) { + if(!$this->SetServer($server)) return false; + } + if($this->_ready) return true; + $this->SendMsg('Local OS : '.$this->OS_FullName[$this->OS_local]); + if(!($this->_ftp_control_sock = $this->_connect($this->_host, $this->_port))) { + $this->SendMSG("Error : Cannot connect to remote host \"".$this->_fullhost." :".$this->_port."\""); + return FALSE; + } + $this->SendMSG("Connected to remote host \"".$this->_fullhost.":".$this->_port."\". Waiting for greeting."); + do { + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + $this->_lastaction=time(); + } while($this->_code<200); + $this->_ready=true; + $syst=$this->systype(); + if(!$syst) $this->SendMSG("Can't detect remote OS"); + else { + if(preg_match("/win|dos|novell/i", $syst[0])) $this->OS_remote=FTP_OS_Windows; + elseif(preg_match("/os/i", $syst[0])) $this->OS_remote=FTP_OS_Mac; + elseif(preg_match("/(li|u)nix/i", $syst[0])) $this->OS_remote=FTP_OS_Unix; + else $this->OS_remote=FTP_OS_Mac; + $this->SendMSG("Remote OS: ".$this->OS_FullName[$this->OS_remote]); + } + if(!$this->features()) $this->SendMSG("Can't get features list. All supported - disabled"); + else $this->SendMSG("Supported features: ".implode(", ", array_keys($this->_features))); + return TRUE; + } + + function quit($force=false) { + if($this->_ready) { + if(!$this->_exec("QUIT") and !$force) return FALSE; + if(!$this->_checkCode() and !$force) return FALSE; + $this->_ready=false; + $this->SendMSG("Session finished"); + } + $this->_quit(); + return TRUE; + } + + function login($user=NULL, $pass=NULL) { + if(!is_null($user)) $this->_login=$user; + else $this->_login="anonymous"; + if(!is_null($pass)) $this->_password=$pass; + else $this->_password="anon@anon.com"; + if(!$this->_exec("USER ".$this->_login, "login")) return FALSE; + if(!$this->_checkCode()) return FALSE; + if($this->_code!=230) { + if(!$this->_exec((($this->_code==331)?"PASS ":"ACCT ").$this->_password, "login")) return FALSE; + if(!$this->_checkCode()) return FALSE; + } + $this->SendMSG("Authentication succeeded"); + if(empty($this->_features)) { + if(!$this->features()) $this->SendMSG("Can't get features list. All supported - disabled"); + else $this->SendMSG("Supported features: ".implode(", ", array_keys($this->_features))); + } + return TRUE; + } + + function pwd() { + if(!$this->_exec("PWD", "pwd")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return ereg_replace("^[0-9]{3} \"(.+)\".+", "\\1", $this->_message); + } + + function cdup() { + if(!$this->_exec("CDUP", "cdup")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return true; + } + + function chdir($pathname) { + if(!$this->_exec("CWD ".$pathname, "chdir")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function rmdir($pathname) { + if(!$this->_exec("RMD ".$pathname, "rmdir")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function mkdir($pathname) { + if(!$this->_exec("MKD ".$pathname, "mkdir")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function rename($from, $to) { + if(!$this->_exec("RNFR ".$from, "rename")) return FALSE; + if(!$this->_checkCode()) return FALSE; + if($this->_code==350) { + if(!$this->_exec("RNTO ".$to, "rename")) return FALSE; + if(!$this->_checkCode()) return FALSE; + } else return FALSE; + return TRUE; + } + + function filesize($pathname) { + if(!isset($this->_features["SIZE"])) { + $this->PushError("filesize", "not supported by server"); + return FALSE; + } + if(!$this->_exec("SIZE ".$pathname, "filesize")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return ereg_replace("^[0-9]{3} ([0-9]+)".CRLF, "\\1", $this->_message); + } + + function abort() { + if(!$this->_exec("ABOR", "abort")) return FALSE; + if(!$this->_checkCode()) { + if($this->_code!=426) return FALSE; + if(!$this->_readmsg("abort")) return FALSE; + if(!$this->_checkCode()) return FALSE; + } + return true; + } + + function mdtm($pathname) { + if(!isset($this->_features["MDTM"])) { + $this->PushError("mdtm", "not supported by server"); + return FALSE; + } + if(!$this->_exec("MDTM ".$pathname, "mdtm")) return FALSE; + if(!$this->_checkCode()) return FALSE; + $mdtm = ereg_replace("^[0-9]{3} ([0-9]+)".CRLF, "\\1", $this->_message); + $date = sscanf($mdtm, "%4d%2d%2d%2d%2d%2d"); + $timestamp = mktime($date[3], $date[4], $date[5], $date[1], $date[2], $date[0]); + return $timestamp; + } + + function systype() { + if(!$this->_exec("SYST", "systype")) return FALSE; + if(!$this->_checkCode()) return FALSE; + $DATA = explode(" ", $this->_message); + return array($DATA[1], $DATA[3]); + } + + function delete($pathname) { + if(!$this->_exec("DELE ".$pathname, "delete")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function site($command, $fnction="site") { + if(!$this->_exec("SITE ".$command, $fnction)) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function chmod($pathname, $mode) { + if(!$this->site( sprintf('CHMOD %o %s', $mode, $pathname), "chmod")) return FALSE; + return TRUE; + } + + function restore($from) { + if(!isset($this->_features["REST"])) { + $this->PushError("restore", "not supported by server"); + return FALSE; + } + if($this->_curtype!=FTP_BINARY) { + $this->PushError("restore", "can't restore in ASCII mode"); + return FALSE; + } + if(!$this->_exec("REST ".$from, "resore")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function features() { + if(!$this->_exec("FEAT", "features")) return FALSE; + if(!$this->_checkCode()) return FALSE; + $f=preg_split("/[".CRLF."]+/", preg_replace("/[0-9]{3}[ -].*[".CRLF."]+/", "", $this->_message), -1, PREG_SPLIT_NO_EMPTY); + $this->_features=array(); + foreach($f as $k=>$v) { + $v=explode(" ", trim($v)); + $this->_features[array_shift($v)]=$v;; + } + return true; + } + + function rawlist($pathname="", $arg="") { + return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "LIST", "rawlist"); + } + + function nlist($pathname="") { + return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "NLST", "nlist"); + } + + function is_exists($pathname) { + return $this->file_exists($pathname); + } + + function file_exists($pathname) { + $exists=true; + if(!$this->_exec("RNFR ".$pathname, "rename")) $exists=FALSE; + else { + if(!$this->_checkCode()) $exists=FALSE; + $this->abort(); + } + if($exists) $this->SendMSG("Remote file ".$pathname." exists"); + else $this->SendMSG("Remote file ".$pathname." does not exist"); + return $exists; + } + + function fget($fp, $remotefile,$rest=0) { + if($this->_can_restore and $rest!=0) fseek($fp, $rest); + $pi=pathinfo($remotefile); + if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII; + else $mode=FTP_BINARY; + if(!$this->_data_prepare($mode)) { + return FALSE; + } + if($this->_can_restore and $rest!=0) $this->restore($rest); + if(!$this->_exec("RETR ".$remotefile, "get")) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + $out=$this->_data_read($mode, $fp); + $this->_data_close(); + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + return $out; + } + + function get($remotefile, $localfile=NULL, $rest=0) { + if(is_null($localfile)) $localfile=$remotefile; + if (@file_exists($localfile)) $this->SendMSG("Warning : local file will be overwritten"); + $fp = @fopen($localfile, "w"); + if (!$fp) { + $this->PushError("get","can't open local file", "Cannot create \"".$localfile."\""); + return FALSE; + } + if($this->_can_restore and $rest!=0) fseek($fp, $rest); + $pi=pathinfo($remotefile); + if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII; + else $mode=FTP_BINARY; + if(!$this->_data_prepare($mode)) { + fclose($fp); + return FALSE; + } + if($this->_can_restore and $rest!=0) $this->restore($rest); + if(!$this->_exec("RETR ".$remotefile, "get")) { + $this->_data_close(); + fclose($fp); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + fclose($fp); + return FALSE; + } + $out=$this->_data_read($mode, $fp); + fclose($fp); + $this->_data_close(); + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + return $out; + } + + function fput($remotefile, $fp) { + if($this->_can_restore and $rest!=0) fseek($fp, $rest); + $pi=pathinfo($remotefile); + if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII; + else $mode=FTP_BINARY; + if(!$this->_data_prepare($mode)) { + return FALSE; + } + if($this->_can_restore and $rest!=0) $this->restore($rest); + if(!$this->_exec("STOR ".$remotefile, "put")) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + $ret=$this->_data_write($mode, $fp); + $this->_data_close(); + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + return $ret; + } + + function put($localfile, $remotefile=NULL, $rest=0) { + if(is_null($remotefile)) $remotefile=$localfile; + if (!file_exists($localfile)) { + $this->PushError("put","can't open local file", "No such file or directory \"".$localfile."\""); + return FALSE; + } + $fp = @fopen($localfile, "r"); + + if (!$fp) { + $this->PushError("put","can't open local file", "Cannot read file \"".$localfile."\""); + return FALSE; + } + if($this->_can_restore and $rest!=0) fseek($fp, $rest); + $pi=pathinfo($localfile); + if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII; + else $mode=FTP_BINARY; + if(!$this->_data_prepare($mode)) { + fclose($fp); + return FALSE; + } + if($this->_can_restore and $rest!=0) $this->restore($rest); + if(!$this->_exec("STOR ".$remotefile, "put")) { + $this->_data_close(); + fclose($fp); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + fclose($fp); + return FALSE; + } + $ret=$this->_data_write($mode, $fp); + fclose($fp); + $this->_data_close(); + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + return $ret; + } + + function mput($local=".", $remote=NULL, $continious=false) { + $local=realpath($local); + if(!@file_exists($local)) { + $this->PushError("mput","can't open local folder", "Cannot stat folder \"".$local."\""); + return FALSE; + } + if(!is_dir($local)) return $this->put($local, $remote); + if(empty($remote)) $remote="."; + elseif(!$this->file_exists($remote) and !$this->mkdir($remote)) return FALSE; + if($handle = opendir($local)) { + $list=array(); + while (false !== ($file = readdir($handle))) { + if ($file != "." && $file != "..") $list[]=$file; + } + closedir($handle); + } else { + $this->PushError("mput","can't open local folder", "Cannot read folder \"".$local."\""); + return FALSE; + } + if(empty($list)) return TRUE; + $ret=true; + foreach($list as $el) { + if(is_dir($local."/".$el)) $t=$this->mput($local."/".$el, $remote."/".$el); + else $t=$this->put($local."/".$el, $remote."/".$el); + if(!$t) { + $ret=FALSE; + if(!$continious) break; + } + } + return $ret; + + } + + function mget($remote, $local=".", $continious=false) { + $list=$this->rawlist($remote, "-lA"); + if($list===false) { + $this->PushError("mget","can't read remote folder list", "Can't read remote folder \"".$remote."\" contents"); + return FALSE; + } + if(empty($list)) return true; + if(!@file_exists($local)) { + if(!@mkdir($local)) { + $this->PushError("mget","can't create local folder", "Cannot create folder \"".$local."\""); + return FALSE; + } + } + foreach($list as $k=>$v) { + $list[$k]=$this->parselisting($v); + if($list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]); + } + $ret=true; + foreach($list as $el) { + if($el["type"]=="d") { + if(!$this->mget($remote."/".$el["name"], $local."/".$el["name"], $continious)) { + $this->PushError("mget", "can't copy folder", "Can't copy remote folder \"".$remote."/".$el["name"]."\" to local \"".$local."/".$el["name"]."\""); + $ret=false; + if(!$continious) break; + } + } else { + if(!$this->get($remote."/".$el["name"], $local."/".$el["name"])) { + $this->PushError("mget", "can't copy file", "Can't copy remote file \"".$remote."/".$el["name"]."\" to local \"".$local."/".$el["name"]."\""); + $ret=false; + if(!$continious) break; + } + } + @chmod($local."/".$el["name"], $el["perms"]); + $t=strtotime($el["date"]); + if($t!==-1 and $t!==false) @touch($local."/".$el["name"], $t); + } + return $ret; + } + + function mdel($remote, $continious=false) { + $list=$this->rawlist($remote, "-la"); + if($list===false) { + $this->PushError("mdel","can't read remote folder list", "Can't read remote folder \"".$remote."\" contents"); + return false; + } + + foreach($list as $k=>$v) { + $list[$k]=$this->parselisting($v); + if($list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]); + } + $ret=true; + + foreach($list as $el) { + if ( empty($el) ) + continue; + + if($el["type"]=="d") { + if(!$this->mdel($remote."/".$el["name"], $continious)) { + $ret=false; + if(!$continious) break; + } + } else { + if (!$this->delete($remote."/".$el["name"])) { + $this->PushError("mdel", "can't delete file", "Can't delete remote file \"".$remote."/".$el["name"]."\""); + $ret=false; + if(!$continious) break; + } + } + } + + if(!$this->rmdir($remote)) { + $this->PushError("mdel", "can't delete folder", "Can't delete remote folder \"".$remote."/".$el["name"]."\""); + $ret=false; + } + return $ret; + } + + function mmkdir($dir, $mode = 0777) { + if(empty($dir)) return FALSE; + if($this->is_exists($dir) or $dir == "/" ) return TRUE; + if(!$this->mmkdir(dirname($dir), $mode)) return false; + $r=$this->mkdir($dir, $mode); + $this->chmod($dir,$mode); + return $r; + } + + function glob($pattern, $handle=NULL) { + $path=$output=null; + if(PHP_OS=='WIN32') $slash='\\'; + else $slash='/'; + $lastpos=strrpos($pattern,$slash); + if(!($lastpos===false)) { + $path=substr($pattern,0,-$lastpos-1); + $pattern=substr($pattern,$lastpos); + } else $path=getcwd(); + if(is_array($handle) and !empty($handle)) { + while($dir=each($handle)) { + if($this->glob_pattern_match($pattern,$dir)) + $output[]=$dir; + } + } else { + $handle=@opendir($path); + if($handle===false) return false; + while($dir=readdir($handle)) { + if($this->glob_pattern_match($pattern,$dir)) + $output[]=$dir; + } + closedir($handle); + } + if(is_array($output)) return $output; + return false; + } + + function glob_pattern_match($pattern,$string) { + $out=null; + $chunks=explode(';',$pattern); + foreach($chunks as $pattern) { + $escape=array('$','^','.','{','}','(',')','[',']','|'); + while(strpos($pattern,'**')!==false) + $pattern=str_replace('**','*',$pattern); + foreach($escape as $probe) + $pattern=str_replace($probe,"\\$probe",$pattern); + $pattern=str_replace('?*','*', + str_replace('*?','*', + str_replace('*',".*", + str_replace('?','.{1,1}',$pattern)))); + $out[]=$pattern; + } + if(count($out)==1) return($this->glob_regexp("^$out[0]$",$string)); + else { + foreach($out as $tester) + if($this->my_regexp("^$tester$",$string)) return true; + } + return false; + } + + function glob_regexp($pattern,$probe) { + $sensitive=(PHP_OS!='WIN32'); + return ($sensitive? + ereg($pattern,$probe): + eregi($pattern,$probe) + ); + } + + function dirlist($remote) { + $list=$this->rawlist($remote, "-la"); + if($list===false) { + $this->PushError("dirlist","can't read remote folder list", "Can't read remote folder \"".$remote."\" contents"); + return false; + } + + $dirlist = array(); + foreach($list as $k=>$v) { + $entry=$this->parselisting($v); + if ( empty($entry) ) + continue; + + if($entry["name"]=="." or $entry["name"]=="..") + continue; + + $dirlist[$entry['name']] = $entry; + } + + return $dirlist; + } +// +// +// + function _checkCode() { + return ($this->_code<400 and $this->_code>0); + } + + function _list($arg="", $cmd="LIST", $fnction="_list") { + if(!$this->_data_prepare()) return false; + if(!$this->_exec($cmd.$arg, $fnction)) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + $out=""; + if($this->_code<200) { + $out=$this->_data_read(); + $this->_data_close(); + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + if($out === FALSE ) return FALSE; + $out=preg_split("/[".CRLF."]+/", $out, -1, PREG_SPLIT_NO_EMPTY); +// $this->SendMSG(implode($this->_eol_code[$this->OS_local], $out)); + } + return $out; + } + +// +// +// +// Gnre une erreur pour traitement externe la classe + function PushError($fctname,$msg,$desc=false){ + $error=array(); + $error['time']=time(); + $error['fctname']=$fctname; + $error['msg']=$msg; + $error['desc']=$desc; + if($desc) $tmp=' ('.$desc.')'; else $tmp=''; + $this->SendMSG($fctname.': '.$msg.$tmp); + return(array_push($this->_error_array,$error)); + } + +// Rcupre une erreur externe + function PopError(){ + if(count($this->_error_array)) return(array_pop($this->_error_array)); + else return(false); + } +} + +$mod_sockets=TRUE; +if (!extension_loaded('sockets')) { + $prefix = (PHP_SHLIB_SUFFIX == 'dll') ? 'php_' : ''; + if(!@dl($prefix . 'sockets.' . PHP_SHLIB_SUFFIX)) $mod_sockets=FALSE; +} + +require_once "class-ftp-".($mod_sockets?"sockets":"pure").".php"; +?> diff -uNr a/blog/wp-admin/includes/class-ftp-pure.php b/blog/wp-admin/includes/class-ftp-pure.php --- a/blog/wp-admin/includes/class-ftp-pure.php false +++ b/blog/wp-admin/includes/class-ftp-pure.php 63db4ad5e4142afe0c402e74bb5e53beb36e8138bd90ef1540b75be9fd594a061c73fabbdc0d3a7d8139c7439e4bbf65cbdd5813f63614730614ff59688b298d @@ -0,0 +1,190 @@ +__construct($verb, $le); + } + + function __construct($verb=FALSE, $le=FALSE) { + parent::__construct(false, $verb, $le); + } + +// +// +// + + function _settimeout($sock) { + if(!@stream_set_timeout($sock, $this->_timeout)) { + $this->PushError('_settimeout','socket set send timeout'); + $this->_quit(); + return FALSE; + } + return TRUE; + } + + function _connect($host, $port) { + $this->SendMSG("Creating socket"); + $sock = @fsockopen($host, $port, $errno, $errstr, $this->_timeout); + if (!$sock) { + $this->PushError('_connect','socket connect failed', $errstr." (".$errno.")"); + return FALSE; + } + $this->_connected=true; + return $sock; + } + + function _readmsg($fnction="_readmsg"){ + if(!$this->_connected) { + $this->PushError($fnction, 'Connect first'); + return FALSE; + } + $result=true; + $this->_message=""; + $this->_code=0; + $go=true; + do { + $tmp=@fgets($this->_ftp_control_sock, 512); + if($tmp===false) { + $go=$result=false; + $this->PushError($fnction,'Read failed'); + } else { + $this->_message.=$tmp; + if(preg_match("/^([0-9]{3})(-(.*[".CRLF."]{1,2})+\\1)? [^".CRLF."]+[".CRLF."]{1,2}$/", $this->_message, $regs)) $go=false; + } + } while($go); + if($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF; + $this->_code=(int)$regs[1]; + return $result; + } + + function _exec($cmd, $fnction="_exec") { + if(!$this->_ready) { + $this->PushError($fnction,'Connect first'); + return FALSE; + } + if($this->LocalEcho) echo "PUT > ",$cmd,CRLF; + $status=@fputs($this->_ftp_control_sock, $cmd.CRLF); + if($status===false) { + $this->PushError($fnction,'socket write failed'); + return FALSE; + } + $this->_lastaction=time(); + if(!$this->_readmsg($fnction)) return FALSE; + return TRUE; + } + + function _data_prepare($mode=FTP_ASCII) { + if(!$this->_settype($mode)) return FALSE; + if($this->_passive) { + if(!$this->_exec("PASV", "pasv")) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + $ip_port = explode(",", ereg_replace("^.+ \\(?([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+)\\)?.*".CRLF."$", "\\1", $this->_message)); + $this->_datahost=$ip_port[0].".".$ip_port[1].".".$ip_port[2].".".$ip_port[3]; + $this->_dataport=(((int)$ip_port[4])<<8) + ((int)$ip_port[5]); + $this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport); + $this->_ftp_data_sock=@fsockopen($this->_datahost, $this->_dataport, $errno, $errstr, $this->_timeout); + if(!$this->_ftp_data_sock) { + $this->PushError("_data_prepare","fsockopen fails", $errstr." (".$errno.")"); + $this->_data_close(); + return FALSE; + } + else $this->_ftp_data_sock; + } else { + $this->SendMSG("Only passive connections available!"); + return FALSE; + } + return TRUE; + } + + function _data_read($mode=FTP_ASCII, $fp=NULL) { + if(is_resource($fp)) $out=0; + else $out=""; + if(!$this->_passive) { + $this->SendMSG("Only passive connections available!"); + return FALSE; + } + while (!feof($this->_ftp_data_sock)) { + $block=fread($this->_ftp_data_sock, $this->_ftp_buff_size); + if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block); + if(is_resource($fp)) $out+=fwrite($fp, $block, strlen($block)); + else $out.=$block; + } + return $out; + } + + function _data_write($mode=FTP_ASCII, $fp=NULL) { + if(is_resource($fp)) $out=0; + else $out=""; + if(!$this->_passive) { + $this->SendMSG("Only passive connections available!"); + return FALSE; + } + if(is_resource($fp)) { + while(!feof($fp)) { + $block=fread($fp, $this->_ftp_buff_size); + if(!$this->_data_write_block($mode, $block)) return false; + } + } elseif(!$this->_data_write_block($mode, $fp)) return false; + return TRUE; + } + + function _data_write_block($mode, $block) { + if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block); + do { + if(($t=@fwrite($this->_ftp_data_sock, $block))===FALSE) { + $this->PushError("_data_write","Can't write to socket"); + return FALSE; + } + $block=substr($block, $t); + } while(!empty($block)); + return true; + } + + function _data_close() { + @fclose($this->_ftp_data_sock); + $this->SendMSG("Disconnected data from remote host"); + return TRUE; + } + + function _quit($force=FALSE) { + if($this->_connected or $force) { + @fclose($this->_ftp_control_sock); + $this->_connected=false; + $this->SendMSG("Socket closed"); + } + } +} + +?> diff -uNr a/blog/wp-admin/includes/class-ftp-sockets.php b/blog/wp-admin/includes/class-ftp-sockets.php --- a/blog/wp-admin/includes/class-ftp-sockets.php false +++ b/blog/wp-admin/includes/class-ftp-sockets.php d8fca79a8aa161e6be6937c8ab32f93d28357ef05a13889fa4c3b4b4c86afbb58cba7f0f8adc1b15ac3412a2cca3c25f85702ac4cd93cad7fb537a7990deb52e @@ -0,0 +1,250 @@ +__construct($verb, $le); + } + + function __construct($verb=FALSE, $le=FALSE) { + parent::__construct(true, $verb, $le); + } + +// +// +// + + function _settimeout($sock) { + if(!@socket_set_option($sock, SOL_SOCKET, SO_RCVTIMEO, array("sec"=>$this->_timeout, "usec"=>0))) { + $this->PushError('_connect','socket set receive timeout',socket_strerror(socket_last_error($sock))); + @socket_close($sock); + return FALSE; + } + if(!@socket_set_option($sock, SOL_SOCKET , SO_SNDTIMEO, array("sec"=>$this->_timeout, "usec"=>0))) { + $this->PushError('_connect','socket set send timeout',socket_strerror(socket_last_error($sock))); + @socket_close($sock); + return FALSE; + } + return true; + } + + function _connect($host, $port) { + $this->SendMSG("Creating socket"); + if(!($sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) { + $this->PushError('_connect','socket create failed',socket_strerror(socket_last_error($sock))); + return FALSE; + } + if(!$this->_settimeout($sock)) return FALSE; + $this->SendMSG("Connecting to \"".$host.":".$port."\""); + if (!($res = @socket_connect($sock, $host, $port))) { + $this->PushError('_connect','socket connect failed',socket_strerror(socket_last_error($sock))); + @socket_close($sock); + return FALSE; + } + $this->_connected=true; + return $sock; + } + + function _readmsg($fnction="_readmsg"){ + if(!$this->_connected) { + $this->PushError($fnction,'Connect first'); + return FALSE; + } + $result=true; + $this->_message=""; + $this->_code=0; + $go=true; + do { + $tmp=@socket_read($this->_ftp_control_sock, 4096, PHP_BINARY_READ); + if($tmp===false) { + $go=$result=false; + $this->PushError($fnction,'Read failed', socket_strerror(socket_last_error($this->_ftp_control_sock))); + } else { + $this->_message.=$tmp; + $go = !preg_match("/^([0-9]{3})(-.+\\1)? [^".CRLF."]+".CRLF."$/Us", $this->_message, $regs); + } + } while($go); + if($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF; + $this->_code=(int)$regs[1]; + return $result; + } + + function _exec($cmd, $fnction="_exec") { + if(!$this->_ready) { + $this->PushError($fnction,'Connect first'); + return FALSE; + } + if($this->LocalEcho) echo "PUT > ",$cmd,CRLF; + $status=@socket_write($this->_ftp_control_sock, $cmd.CRLF); + if($status===false) { + $this->PushError($fnction,'socket write failed', socket_strerror(socket_last_error($this->stream))); + return FALSE; + } + $this->_lastaction=time(); + if(!$this->_readmsg($fnction)) return FALSE; + return TRUE; + } + + function _data_prepare($mode=FTP_ASCII) { + if(!$this->_settype($mode)) return FALSE; + $this->SendMSG("Creating data socket"); + $this->_ftp_data_sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP); + if ($this->_ftp_data_sock < 0) { + $this->PushError('_data_prepare','socket create failed',socket_strerror(socket_last_error($this->_ftp_data_sock))); + return FALSE; + } + if(!$this->_settimeout($this->_ftp_data_sock)) { + $this->_data_close(); + return FALSE; + } + if($this->_passive) { + if(!$this->_exec("PASV", "pasv")) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + $ip_port = explode(",", ereg_replace("^.+ \\(?([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+)\\)?.*".CRLF."$", "\\1", $this->_message)); + $this->_datahost=$ip_port[0].".".$ip_port[1].".".$ip_port[2].".".$ip_port[3]; + $this->_dataport=(((int)$ip_port[4])<<8) + ((int)$ip_port[5]); + $this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport); + if(!@socket_connect($this->_ftp_data_sock, $this->_datahost, $this->_dataport)) { + $this->PushError("_data_prepare","socket_connect", socket_strerror(socket_last_error($this->_ftp_data_sock))); + $this->_data_close(); + return FALSE; + } + else $this->_ftp_temp_sock=$this->_ftp_data_sock; + } else { + if(!@socket_getsockname($this->_ftp_control_sock, $addr, $port)) { + $this->PushError("_data_prepare","can't get control socket information", socket_strerror(socket_last_error($this->_ftp_control_sock))); + $this->_data_close(); + return FALSE; + } + if(!@socket_bind($this->_ftp_data_sock,$addr)){ + $this->PushError("_data_prepare","can't bind data socket", socket_strerror(socket_last_error($this->_ftp_data_sock))); + $this->_data_close(); + return FALSE; + } + if(!@socket_listen($this->_ftp_data_sock)) { + $this->PushError("_data_prepare","can't listen data socket", socket_strerror(socket_last_error($this->_ftp_data_sock))); + $this->_data_close(); + return FALSE; + } + if(!@socket_getsockname($this->_ftp_data_sock, $this->_datahost, $this->_dataport)) { + $this->PushError("_data_prepare","can't get data socket information", socket_strerror(socket_last_error($this->_ftp_data_sock))); + $this->_data_close(); + return FALSE; + } + if(!$this->_exec('PORT '.str_replace('.',',',$this->_datahost.'.'.($this->_dataport>>8).'.'.($this->_dataport&0x00FF)), "_port")) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + } + return TRUE; + } + + function _data_read($mode=FTP_ASCII, $fp=NULL) { + $NewLine=$this->_eol_code[$this->OS_local]; + if(is_resource($fp)) $out=0; + else $out=""; + if(!$this->_passive) { + $this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport); + $this->_ftp_temp_sock=socket_accept($this->_ftp_data_sock); + if($this->_ftp_temp_sock===FALSE) { + $this->PushError("_data_read","socket_accept", socket_strerror(socket_last_error($this->_ftp_temp_sock))); + $this->_data_close(); + return FALSE; + } + } + + while(($block=@socket_read($this->_ftp_temp_sock, $this->_ftp_buff_size, PHP_BINARY_READ))!==false) { + if($block==="") break; + if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block); + if(is_resource($fp)) $out+=fwrite($fp, $block, strlen($block)); + else $out.=$block; + } + return $out; + } + + function _data_write($mode=FTP_ASCII, $fp=NULL) { + $NewLine=$this->_eol_code[$this->OS_local]; + if(is_resource($fp)) $out=0; + else $out=""; + if(!$this->_passive) { + $this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport); + $this->_ftp_temp_sock=socket_accept($this->_ftp_data_sock); + if($this->_ftp_temp_sock===FALSE) { + $this->PushError("_data_write","socket_accept", socket_strerror(socket_last_error($this->_ftp_temp_sock))); + $this->_data_close(); + return false; + } + } + if(is_resource($fp)) { + while(!feof($fp)) { + $block=fread($fp, $this->_ftp_buff_size); + if(!$this->_data_write_block($mode, $block)) return false; + } + } elseif(!$this->_data_write_block($mode, $fp)) return false; + return true; + } + + function _data_write_block($mode, $block) { + if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block); + do { + if(($t=@socket_write($this->_ftp_temp_sock, $block))===FALSE) { + $this->PushError("_data_write","socket_write", socket_strerror(socket_last_error($this->_ftp_temp_sock))); + $this->_data_close(); + return FALSE; + } + $block=substr($block, $t); + } while(!empty($block)); + return true; + } + + function _data_close() { + @socket_close($this->_ftp_temp_sock); + @socket_close($this->_ftp_data_sock); + $this->SendMSG("Disconnected data from remote host"); + return TRUE; + } + + function _quit() { + if($this->_connected) { + @socket_close($this->_ftp_control_sock); + $this->_connected=false; + $this->SendMSG("Socket closed"); + } + } +} +?> diff -uNr a/blog/wp-admin/includes/class-pclzip.php b/blog/wp-admin/includes/class-pclzip.php --- a/blog/wp-admin/includes/class-pclzip.php false +++ b/blog/wp-admin/includes/class-pclzip.php 38b2356f871da442c8c87b63c3ac0533b850c35a725e9ccf8d276fd0e954da84905b4e729965810dd2ab6617a3e9d6bf4610185587a83085840958d800532b5b @@ -0,0 +1,5759 @@ +define( 'PCLZIP_SEPARATOR', ' ' ); + * Recommanded values for smart separation of filenames. + */ +define( 'PCLZIP_SEPARATOR', ',' ); + +/** + * Error configuration + * + * 0 : PclZip Class integrated error handling + * 1 : PclError external library error handling. By enabling this you must + * ensure that you have included PclError library. + * [2,...] : reserved for future use + */ +define( 'PCLZIP_ERROR_EXTERNAL', 0 ); + + // ----- Optional static temporary directory + // By default temporary files are generated in the script current + // path. + // If defined : + // - MUST BE terminated by a '/'. + // - MUST be a valid, already created directory + // Samples : + // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' ); + // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' ); + define( 'PCLZIP_TEMPORARY_DIR', '' ); + +// -------------------------------------------------------------------------------- +// ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED ***** +// -------------------------------------------------------------------------------- + + // ----- Global variables + $g_pclzip_version = "2.5"; + + // ----- Error codes + // -1 : Unable to open file in binary write mode + // -2 : Unable to open file in binary read mode + // -3 : Invalid parameters + // -4 : File does not exist + // -5 : Filename is too long (max. 255) + // -6 : Not a valid zip file + // -7 : Invalid extracted file size + // -8 : Unable to create directory + // -9 : Invalid archive extension + // -10 : Invalid archive format + // -11 : Unable to delete file (unlink) + // -12 : Unable to rename file (rename) + // -13 : Invalid header checksum + // -14 : Invalid archive size + define( 'PCLZIP_ERR_USER_ABORTED', 2 ); + define( 'PCLZIP_ERR_NO_ERROR', 0 ); + define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 ); + define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 ); + define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 ); + define( 'PCLZIP_ERR_MISSING_FILE', -4 ); + define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 ); + define( 'PCLZIP_ERR_INVALID_ZIP', -6 ); + define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 ); + define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 ); + define( 'PCLZIP_ERR_BAD_EXTENSION', -9 ); + define( 'PCLZIP_ERR_BAD_FORMAT', -10 ); + define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 ); + define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 ); + define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 ); + define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 ); + define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 ); + define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 ); + define( 'PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 ); + define( 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 ); + define( 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 ); + define( 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 ); + define( 'PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 ); + + // ----- Options values + define( 'PCLZIP_OPT_PATH', 77001 ); + define( 'PCLZIP_OPT_ADD_PATH', 77002 ); + define( 'PCLZIP_OPT_REMOVE_PATH', 77003 ); + define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 ); + define( 'PCLZIP_OPT_SET_CHMOD', 77005 ); + define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 ); + define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 ); + define( 'PCLZIP_OPT_BY_NAME', 77008 ); + define( 'PCLZIP_OPT_BY_INDEX', 77009 ); + define( 'PCLZIP_OPT_BY_EREG', 77010 ); + define( 'PCLZIP_OPT_BY_PREG', 77011 ); + define( 'PCLZIP_OPT_COMMENT', 77012 ); + define( 'PCLZIP_OPT_ADD_COMMENT', 77013 ); + define( 'PCLZIP_OPT_PREPEND_COMMENT', 77014 ); + define( 'PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 ); + define( 'PCLZIP_OPT_REPLACE_NEWER', 77016 ); + define( 'PCLZIP_OPT_STOP_ON_ERROR', 77017 ); + // Having big trouble with crypt. Need to multiply 2 long int + // which is not correctly supported by PHP ... + //define( 'PCLZIP_OPT_CRYPT', 77018 ); + define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 ); + + // ----- File description attributes + define( 'PCLZIP_ATT_FILE_NAME', 79001 ); + define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 ); + define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 ); + + // ----- Call backs values + define( 'PCLZIP_CB_PRE_EXTRACT', 78001 ); + define( 'PCLZIP_CB_POST_EXTRACT', 78002 ); + define( 'PCLZIP_CB_PRE_ADD', 78003 ); + define( 'PCLZIP_CB_POST_ADD', 78004 ); + /* For future use + define( 'PCLZIP_CB_PRE_LIST', 78005 ); + define( 'PCLZIP_CB_POST_LIST', 78006 ); + define( 'PCLZIP_CB_PRE_DELETE', 78007 ); + define( 'PCLZIP_CB_POST_DELETE', 78008 ); + */ + + // -------------------------------------------------------------------------------- + // Class : PclZip + // Description : + // PclZip is the class that represent a Zip archive. + // The public methods allow the manipulation of the archive. + // Attributes : + // Attributes must not be accessed directly. + // Methods : + // PclZip() : Object creator + // create() : Creates the Zip archive + // listContent() : List the content of the Zip archive + // extract() : Extract the content of the archive + // properties() : List the properties of the archive + // -------------------------------------------------------------------------------- + class PclZip + { + // ----- Filename of the zip file + var $zipname = ''; + + // ----- File descriptor of the zip file + var $zip_fd = 0; + + // ----- Internal error handling + var $error_code = 1; + var $error_string = ''; + + // ----- Current status of the magic_quotes_runtime + // This value store the php configuration for magic_quotes + // The class can then disable the magic_quotes and reset it after + var $magic_quotes_status; + + // -------------------------------------------------------------------------------- + // Function : PclZip() + // Description : + // Creates a PclZip object and set the name of the associated Zip archive + // filename. + // Note that no real action is taken, if the archive does not exist it is not + // created. Use create() for that. + // -------------------------------------------------------------------------------- + function PclZip($p_zipname) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::PclZip', "zipname=$p_zipname"); + + // ----- Tests the zlib + if (!function_exists('gzopen')) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 1, "zlib extension seems to be missing"); + die('Abort '.basename(__FILE__).' : Missing zlib extensions'); + } + + // ----- Set the attributes + $this->zipname = $p_zipname; + $this->zip_fd = 0; + $this->magic_quotes_status = -1; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 1); + return; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : + // create($p_filelist, $p_add_dir="", $p_remove_dir="") + // create($p_filelist, $p_option, $p_option_value, ...) + // Description : + // This method supports two different synopsis. The first one is historical. + // This method creates a Zip Archive. The Zip file is created in the + // filesystem. The files and directories indicated in $p_filelist + // are added in the archive. See the parameters description for the + // supported format of $p_filelist. + // When a directory is in the list, the directory and its content is added + // in the archive. + // In this synopsis, the function takes an optional variable list of + // options. See bellow the supported options. + // Parameters : + // $p_filelist : An array containing file or directory names, or + // a string containing one filename or one directory name, or + // a string containing a list of filenames and/or directory + // names separated by spaces. + // $p_add_dir : A path to add before the real path of the archived file, + // in order to have it memorized in the archive. + // $p_remove_dir : A path to remove from the real path of the file to archive, + // in order to have a shorter path memorized in the archive. + // When $p_add_dir and $p_remove_dir are set, $p_remove_dir + // is removed first, before $p_add_dir is added. + // Options : + // PCLZIP_OPT_ADD_PATH : + // PCLZIP_OPT_REMOVE_PATH : + // PCLZIP_OPT_REMOVE_ALL_PATH : + // PCLZIP_OPT_COMMENT : + // PCLZIP_CB_PRE_ADD : + // PCLZIP_CB_POST_ADD : + // Return Values : + // 0 on failure, + // The list of the added files, with a status of the add action. + // (see PclZip::listContent() for list entry format) + // -------------------------------------------------------------------------------- + function create($p_filelist) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::create', "filelist='$p_filelist', ..."); + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Set default values + $v_options = array(); + $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; + + // ----- Look for variable options arguments + $v_size = func_num_args(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); + + // ----- Look for arguments + if ($v_size > 1) { + // ----- Get the arguments + $v_arg_list = func_get_args(); + + // ----- Remove from the options list the first argument + array_shift($v_arg_list); + $v_size--; + + // ----- Look for first arg + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected"); + + // ----- Parse the options + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, + array (PCLZIP_OPT_REMOVE_PATH => 'optional', + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', + PCLZIP_OPT_ADD_PATH => 'optional', + PCLZIP_CB_PRE_ADD => 'optional', + PCLZIP_CB_POST_ADD => 'optional', + PCLZIP_OPT_NO_COMPRESSION => 'optional', + PCLZIP_OPT_COMMENT => 'optional' + //, PCLZIP_OPT_CRYPT => 'optional' + )); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + } + + // ----- Look for 2 args + // Here we need to support the first historic synopsis of the + // method. + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis"); + + // ----- Get the first argument + $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0]; + + // ----- Look for the optional second argument + if ($v_size == 2) { + $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; + } + else if ($v_size > 2) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, + "Invalid number / type of arguments"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return 0; + } + } + } + + // ----- Init + $v_string_list = array(); + $v_att_list = array(); + $v_filedescr_list = array(); + $p_result_list = array(); + + // ----- Look if the $p_filelist is really an array + if (is_array($p_filelist)) { + + // ----- Look if the first element is also an array + // This will mean that this is a file description entry + if (isset($p_filelist[0]) && is_array($p_filelist[0])) { + $v_att_list = $p_filelist; + } + + // ----- The list is a list of string names + else { + $v_string_list = $p_filelist; + } + } + + // ----- Look if the $p_filelist is a string + else if (is_string($p_filelist)) { + // ----- Create a list from the string + $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); + } + + // ----- Invalid variable type for $p_filelist + else { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Reformat the string list + if (sizeof($v_string_list) != 0) { + foreach ($v_string_list as $v_string) { + if ($v_string != '') { + $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Ignore an empty filename"); + } + } + } + + // ----- For each file in the list check the attributes + $v_supported_attributes + = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' + ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' + ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' + ); + foreach ($v_att_list as $v_entry) { + $v_result = $this->privFileDescrParseAtt($v_entry, + $v_filedescr_list[], + $v_options, + $v_supported_attributes); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + } + + // ----- Expand the filelist (expand directories) + $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Call the create fct + $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list); + return $p_result_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : + // add($p_filelist, $p_add_dir="", $p_remove_dir="") + // add($p_filelist, $p_option, $p_option_value, ...) + // Description : + // This method supports two synopsis. The first one is historical. + // This methods add the list of files in an existing archive. + // If a file with the same name already exists, it is added at the end of the + // archive, the first one is still present. + // If the archive does not exist, it is created. + // Parameters : + // $p_filelist : An array containing file or directory names, or + // a string containing one filename or one directory name, or + // a string containing a list of filenames and/or directory + // names separated by spaces. + // $p_add_dir : A path to add before the real path of the archived file, + // in order to have it memorized in the archive. + // $p_remove_dir : A path to remove from the real path of the file to archive, + // in order to have a shorter path memorized in the archive. + // When $p_add_dir and $p_remove_dir are set, $p_remove_dir + // is removed first, before $p_add_dir is added. + // Options : + // PCLZIP_OPT_ADD_PATH : + // PCLZIP_OPT_REMOVE_PATH : + // PCLZIP_OPT_REMOVE_ALL_PATH : + // PCLZIP_OPT_COMMENT : + // PCLZIP_OPT_ADD_COMMENT : + // PCLZIP_OPT_PREPEND_COMMENT : + // PCLZIP_CB_PRE_ADD : + // PCLZIP_CB_POST_ADD : + // Return Values : + // 0 on failure, + // The list of the added files, with a status of the add action. + // (see PclZip::listContent() for list entry format) + // -------------------------------------------------------------------------------- + function add($p_filelist) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::add', "filelist='$p_filelist', ..."); + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Set default values + $v_options = array(); + $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; + + // ----- Look for variable options arguments + $v_size = func_num_args(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); + + // ----- Look for arguments + if ($v_size > 1) { + // ----- Get the arguments + $v_arg_list = func_get_args(); + + // ----- Remove form the options list the first argument + array_shift($v_arg_list); + $v_size--; + + // ----- Look for first arg + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected"); + + // ----- Parse the options + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, + array (PCLZIP_OPT_REMOVE_PATH => 'optional', + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', + PCLZIP_OPT_ADD_PATH => 'optional', + PCLZIP_CB_PRE_ADD => 'optional', + PCLZIP_CB_POST_ADD => 'optional', + PCLZIP_OPT_NO_COMPRESSION => 'optional', + PCLZIP_OPT_COMMENT => 'optional', + PCLZIP_OPT_ADD_COMMENT => 'optional', + PCLZIP_OPT_PREPEND_COMMENT => 'optional' + //, PCLZIP_OPT_CRYPT => 'optional' + )); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + } + + // ----- Look for 2 args + // Here we need to support the first historic synopsis of the + // method. + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis"); + + // ----- Get the first argument + $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0]; + + // ----- Look for the optional second argument + if ($v_size == 2) { + $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; + } + else if ($v_size > 2) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return 0; + } + } + } + + // ----- Init + $v_string_list = array(); + $v_att_list = array(); + $v_filedescr_list = array(); + $p_result_list = array(); + + // ----- Look if the $p_filelist is really an array + if (is_array($p_filelist)) { + + // ----- Look if the first element is also an array + // This will mean that this is a file description entry + if (isset($p_filelist[0]) && is_array($p_filelist[0])) { + $v_att_list = $p_filelist; + } + + // ----- The list is a list of string names + else { + $v_string_list = $p_filelist; + } + } + + // ----- Look if the $p_filelist is a string + else if (is_string($p_filelist)) { + // ----- Create a list from the string + $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); + } + + // ----- Invalid variable type for $p_filelist + else { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Reformat the string list + if (sizeof($v_string_list) != 0) { + foreach ($v_string_list as $v_string) { + $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; + } + } + + // ----- For each file in the list check the attributes + $v_supported_attributes + = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' + ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' + ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' + ); + foreach ($v_att_list as $v_entry) { + $v_result = $this->privFileDescrParseAtt($v_entry, + $v_filedescr_list[], + $v_options, + $v_supported_attributes); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + } + + // ----- Expand the filelist (expand directories) + $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Call the create fct + $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list); + return $p_result_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : listContent() + // Description : + // This public method, gives the list of the files and directories, with their + // properties. + // The properties of each entries in the list are (used also in other functions) : + // filename : Name of the file. For a create or add action it is the filename + // given by the user. For an extract function it is the filename + // of the extracted file. + // stored_filename : Name of the file / directory stored in the archive. + // size : Size of the stored file. + // compressed_size : Size of the file's data compressed in the archive + // (without the headers overhead) + // mtime : Last known modification date of the file (UNIX timestamp) + // comment : Comment associated with the file + // folder : true | false + // index : index of the file in the archive + // status : status of the action (depending of the action) : + // Values are : + // ok : OK ! + // filtered : the file / dir is not extracted (filtered by user) + // already_a_directory : the file can not be extracted because a + // directory with the same name already exists + // write_protected : the file can not be extracted because a file + // with the same name already exists and is + // write protected + // newer_exist : the file was not extracted because a newer file exists + // path_creation_fail : the file is not extracted because the folder + // does not exists and can not be created + // write_error : the file was not extracted because there was a + // error while writing the file + // read_error : the file was not extracted because there was a error + // while reading the file + // invalid_header : the file was not extracted because of an archive + // format error (bad file header) + // Note that each time a method can continue operating when there + // is an action error on a file, the error is only logged in the file status. + // Return Values : + // 0 on an unrecoverable failure, + // The list of the files in the archive. + // -------------------------------------------------------------------------------- + function listContent() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::listContent', ""); + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return(0); + } + + // ----- Call the extracting fct + $p_list = array(); + if (($v_result = $this->privList($p_list)) != 1) + { + unset($p_list); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); + return(0); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list); + return $p_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : + // extract($p_path="./", $p_remove_path="") + // extract([$p_option, $p_option_value, ...]) + // Description : + // This method supports two synopsis. The first one is historical. + // This method extract all the files / directories from the archive to the + // folder indicated in $p_path. + // If you want to ignore the 'root' part of path of the memorized files + // you can indicate this in the optional $p_remove_path parameter. + // By default, if a newer file with the same name already exists, the + // file is not extracted. + // + // If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions + // are used, the path indicated in PCLZIP_OPT_ADD_PATH is append + // at the end of the path value of PCLZIP_OPT_PATH. + // Parameters : + // $p_path : Path where the files and directories are to be extracted + // $p_remove_path : First part ('root' part) of the memorized path + // (if any similar) to remove while extracting. + // Options : + // PCLZIP_OPT_PATH : + // PCLZIP_OPT_ADD_PATH : + // PCLZIP_OPT_REMOVE_PATH : + // PCLZIP_OPT_REMOVE_ALL_PATH : + // PCLZIP_CB_PRE_EXTRACT : + // PCLZIP_CB_POST_EXTRACT : + // Return Values : + // 0 or a negative value on failure, + // The list of the extracted files, with a status of the action. + // (see PclZip::listContent() for list entry format) + // -------------------------------------------------------------------------------- + function extract() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", ""); + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return(0); + } + + // ----- Set default values + $v_options = array(); +// $v_path = "./"; + $v_path = ''; + $v_remove_path = ""; + $v_remove_all_path = false; + + // ----- Look for variable options arguments + $v_size = func_num_args(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); + + // ----- Default values for option + $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; + + // ----- Look for arguments + if ($v_size > 0) { + // ----- Get the arguments + $v_arg_list = func_get_args(); + + // ----- Look for first arg + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options"); + + // ----- Parse the options + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, + array (PCLZIP_OPT_PATH => 'optional', + PCLZIP_OPT_REMOVE_PATH => 'optional', + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', + PCLZIP_OPT_ADD_PATH => 'optional', + PCLZIP_CB_PRE_EXTRACT => 'optional', + PCLZIP_CB_POST_EXTRACT => 'optional', + PCLZIP_OPT_SET_CHMOD => 'optional', + PCLZIP_OPT_BY_NAME => 'optional', + PCLZIP_OPT_BY_EREG => 'optional', + PCLZIP_OPT_BY_PREG => 'optional', + PCLZIP_OPT_BY_INDEX => 'optional', + PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', + PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional', + PCLZIP_OPT_REPLACE_NEWER => 'optional' + ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' + ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional' + )); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Set the arguments + if (isset($v_options[PCLZIP_OPT_PATH])) { + $v_path = $v_options[PCLZIP_OPT_PATH]; + } + if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) { + $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; + } + if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { + $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; + } + if (isset($v_options[PCLZIP_OPT_ADD_PATH])) { + // ----- Check for '/' in last path char + if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) { + $v_path .= '/'; + } + $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; + } + } + + // ----- Look for 2 args + // Here we need to support the first historic synopsis of the + // method. + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis"); + + // ----- Get the first argument + $v_path = $v_arg_list[0]; + + // ----- Look for the optional second argument + if ($v_size == 2) { + $v_remove_path = $v_arg_list[1]; + } + else if ($v_size > 2) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); + return 0; + } + } + } + + // ----- Trace + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'"); + + // ----- Call the extracting fct + $p_list = array(); + $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, + $v_remove_all_path, $v_options); + if ($v_result < 1) { + unset($p_list); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); + return(0); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list); + return $p_list; + } + // -------------------------------------------------------------------------------- + + + // -------------------------------------------------------------------------------- + // Function : + // extractByIndex($p_index, $p_path="./", $p_remove_path="") + // extractByIndex($p_index, [$p_option, $p_option_value, ...]) + // Description : + // This method supports two synopsis. The first one is historical. + // This method is doing a partial extract of the archive. + // The extracted files or folders are identified by their index in the + // archive (from 0 to n). + // Note that if the index identify a folder, only the folder entry is + // extracted, not all the files included in the archive. + // Parameters : + // $p_index : A single index (integer) or a string of indexes of files to + // extract. The form of the string is "0,4-6,8-12" with only numbers + // and '-' for range or ',' to separate ranges. No spaces or ';' + // are allowed. + // $p_path : Path where the files and directories are to be extracted + // $p_remove_path : First part ('root' part) of the memorized path + // (if any similar) to remove while extracting. + // Options : + // PCLZIP_OPT_PATH : + // PCLZIP_OPT_ADD_PATH : + // PCLZIP_OPT_REMOVE_PATH : + // PCLZIP_OPT_REMOVE_ALL_PATH : + // PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and + // not as files. + // The resulting content is in a new field 'content' in the file + // structure. + // This option must be used alone (any other options are ignored). + // PCLZIP_CB_PRE_EXTRACT : + // PCLZIP_CB_POST_EXTRACT : + // Return Values : + // 0 on failure, + // The list of the extracted files, with a status of the action. + // (see PclZip::listContent() for list entry format) + // -------------------------------------------------------------------------------- + //function extractByIndex($p_index, options...) + function extractByIndex($p_index) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extractByIndex", "index='$p_index', ..."); + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return(0); + } + + // ----- Set default values + $v_options = array(); +// $v_path = "./"; + $v_path = ''; + $v_remove_path = ""; + $v_remove_all_path = false; + + // ----- Look for variable options arguments + $v_size = func_num_args(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); + + // ----- Default values for option + $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; + + // ----- Look for arguments + if ($v_size > 1) { + // ----- Get the arguments + $v_arg_list = func_get_args(); + + // ----- Remove form the options list the first argument + array_shift($v_arg_list); + $v_size--; + + // ----- Look for first arg + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options"); + + // ----- Parse the options + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, + array (PCLZIP_OPT_PATH => 'optional', + PCLZIP_OPT_REMOVE_PATH => 'optional', + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', + PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', + PCLZIP_OPT_ADD_PATH => 'optional', + PCLZIP_CB_PRE_EXTRACT => 'optional', + PCLZIP_CB_POST_EXTRACT => 'optional', + PCLZIP_OPT_SET_CHMOD => 'optional', + PCLZIP_OPT_REPLACE_NEWER => 'optional' + ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' + ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional' + )); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Set the arguments + if (isset($v_options[PCLZIP_OPT_PATH])) { + $v_path = $v_options[PCLZIP_OPT_PATH]; + } + if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) { + $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; + } + if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { + $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; + } + if (isset($v_options[PCLZIP_OPT_ADD_PATH])) { + // ----- Check for '/' in last path char + if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) { + $v_path .= '/'; + } + $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; + } + if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) { + $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING not set."); + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING set."); + } + } + + // ----- Look for 2 args + // Here we need to support the first historic synopsis of the + // method. + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis"); + + // ----- Get the first argument + $v_path = $v_arg_list[0]; + + // ----- Look for the optional second argument + if ($v_size == 2) { + $v_remove_path = $v_arg_list[1]; + } + else if ($v_size > 2) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return 0; + } + } + } + + // ----- Trace + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "index='$p_index', path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'"); + + // ----- Trick + // Here I want to reuse extractByRule(), so I need to parse the $p_index + // with privParseOptions() + $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index); + $v_options_trick = array(); + $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick, + array (PCLZIP_OPT_BY_INDEX => 'optional' )); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX]; + + // ----- Call the extracting fct + if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); + return(0); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list); + return $p_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : + // delete([$p_option, $p_option_value, ...]) + // Description : + // This method removes files from the archive. + // If no parameters are given, then all the archive is emptied. + // Parameters : + // None or optional arguments. + // Options : + // PCLZIP_OPT_BY_INDEX : + // PCLZIP_OPT_BY_NAME : + // PCLZIP_OPT_BY_EREG : + // PCLZIP_OPT_BY_PREG : + // Return Values : + // 0 on failure, + // The list of the files which are still present in the archive. + // (see PclZip::listContent() for list entry format) + // -------------------------------------------------------------------------------- + function delete() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::delete", ""); + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return(0); + } + + // ----- Set default values + $v_options = array(); + + // ----- Look for variable options arguments + $v_size = func_num_args(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); + + // ----- Look for arguments + if ($v_size > 0) { + // ----- Get the arguments + $v_arg_list = func_get_args(); + + // ----- Parse the options + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, + array (PCLZIP_OPT_BY_NAME => 'optional', + PCLZIP_OPT_BY_EREG => 'optional', + PCLZIP_OPT_BY_PREG => 'optional', + PCLZIP_OPT_BY_INDEX => 'optional' )); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + } + + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Call the delete fct + $v_list = array(); + if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) { + $this->privSwapBackMagicQuotes(); + unset($v_list); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); + return(0); + } + + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_list); + return $v_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : deleteByIndex() + // Description : + // ***** Deprecated ***** + // delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered. + // -------------------------------------------------------------------------------- + function deleteByIndex($p_index) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::deleteByIndex", "index='$p_index'"); + + $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list); + return $p_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : properties() + // Description : + // This method gives the properties of the archive. + // The properties are : + // nb : Number of files in the archive + // comment : Comment associated with the archive file + // status : not_exist, ok + // Parameters : + // None + // Return Values : + // 0 on failure, + // An array with the archive properties. + // -------------------------------------------------------------------------------- + function properties() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::properties", ""); + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return(0); + } + + // ----- Default properties + $v_prop = array(); + $v_prop['comment'] = ''; + $v_prop['nb'] = 0; + $v_prop['status'] = 'not_exist'; + + // ----- Look if file exists + if (@is_file($this->zipname)) + { + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) + { + $this->privSwapBackMagicQuotes(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), 0); + return 0; + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Close the zip file + $this->privCloseFd(); + + // ----- Set the user attributes + $v_prop['comment'] = $v_central_dir['comment']; + $v_prop['nb'] = $v_central_dir['entries']; + $v_prop['status'] = 'ok'; + } + + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_prop); + return $v_prop; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : duplicate() + // Description : + // This method creates an archive by copying the content of an other one. If + // the archive already exist, it is replaced by the new one without any warning. + // Parameters : + // $p_archive : The filename of a valid archive, or + // a valid PclZip object. + // Return Values : + // 1 on success. + // 0 or a negative value on error (error code). + // -------------------------------------------------------------------------------- + function duplicate($p_archive) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::duplicate", ""); + $v_result = 1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Look if the $p_archive is a PclZip object + if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip')) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is valid PclZip object '".$p_archive->zipname."'"); + + // ----- Duplicate the archive + $v_result = $this->privDuplicate($p_archive->zipname); + } + + // ----- Look if the $p_archive is a string (so a filename) + else if (is_string($p_archive)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is a filename '$p_archive'"); + + // ----- Check that $p_archive is a valid zip file + // TBC : Should also check the archive format + if (!is_file($p_archive)) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'"); + $v_result = PCLZIP_ERR_MISSING_FILE; + } + else { + // ----- Duplicate the archive + $v_result = $this->privDuplicate($p_archive); + } + } + + // ----- Invalid variable + else + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); + $v_result = PCLZIP_ERR_INVALID_PARAMETER; + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : merge() + // Description : + // This method merge the $p_archive_to_add archive at the end of the current + // one ($this). + // If the archive ($this) does not exist, the merge becomes a duplicate. + // If the $p_archive_to_add archive does not exist, the merge is a success. + // Parameters : + // $p_archive_to_add : It can be directly the filename of a valid zip archive, + // or a PclZip object archive. + // Return Values : + // 1 on success, + // 0 or negative values on error (see below). + // -------------------------------------------------------------------------------- + function merge($p_archive_to_add) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::merge", ""); + $v_result = 1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return(0); + } + + // ----- Look if the $p_archive_to_add is a PclZip object + if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip')) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is valid PclZip object"); + + // ----- Merge the archive + $v_result = $this->privMerge($p_archive_to_add); + } + + // ----- Look if the $p_archive_to_add is a string (so a filename) + else if (is_string($p_archive_to_add)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is a filename"); + + // ----- Create a temporary archive + $v_object_archive = new PclZip($p_archive_to_add); + + // ----- Merge the archive + $v_result = $this->privMerge($v_object_archive); + } + + // ----- Invalid variable + else + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); + $v_result = PCLZIP_ERR_INVALID_PARAMETER; + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + + + // -------------------------------------------------------------------------------- + // Function : errorCode() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function errorCode() + { + if (PCLZIP_ERROR_EXTERNAL == 1) { + return(PclErrorCode()); + } + else { + return($this->error_code); + } + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : errorName() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function errorName($p_with_code=false) + { + $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR', + PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL', + PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL', + PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER', + PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE', + PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG', + PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP', + PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE', + PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL', + PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION', + PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT', + PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL', + PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL', + PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM', + PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', + PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE', + PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE', + PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', + PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION' + ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE' + ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION' + ); + + if (isset($v_name[$this->error_code])) { + $v_value = $v_name[$this->error_code]; + } + else { + $v_value = 'NoName'; + } + + if ($p_with_code) { + return($v_value.' ('.$this->error_code.')'); + } + else { + return($v_value); + } + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : errorInfo() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function errorInfo($p_full=false) + { + if (PCLZIP_ERROR_EXTERNAL == 1) { + return(PclErrorString()); + } + else { + if ($p_full) { + return($this->errorName(true)." : ".$this->error_string); + } + else { + return($this->error_string." [code ".$this->error_code."]"); + } + } + } + // -------------------------------------------------------------------------------- + + +// -------------------------------------------------------------------------------- +// ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS ***** +// ***** ***** +// ***** THESES FUNCTIONS MUST NOT BE USED DIRECTLY ***** +// -------------------------------------------------------------------------------- + + + + // -------------------------------------------------------------------------------- + // Function : privCheckFormat() + // Description : + // This method check that the archive exists and is a valid zip archive. + // Several level of check exists. (futur) + // Parameters : + // $p_level : Level of check. Default 0. + // 0 : Check the first bytes (magic codes) (default value)) + // 1 : 0 + Check the central directory (futur) + // 2 : 1 + Check each file header (futur) + // Return Values : + // true on success, + // false on error, the error code is set. + // -------------------------------------------------------------------------------- + function privCheckFormat($p_level=0) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFormat", ""); + $v_result = true; + + // ----- Reset the file system cache + clearstatcache(); + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Look if the file exits + if (!is_file($this->zipname)) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo()); + return(false); + } + + // ----- Check that the file is readeable + if (!is_readable($this->zipname)) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo()); + return(false); + } + + // ----- Check the magic code + // TBC + + // ----- Check the central header + // TBC + + // ----- Check each file header + // TBC + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privParseOptions() + // Description : + // This internal methods reads the variable list of arguments ($p_options_list, + // $p_size) and generate an array with the options and values ($v_result_list). + // $v_requested_options contains the options that can be present and those that + // must be present. + // $v_requested_options is an array, with the option value as key, and 'optional', + // or 'mandatory' as value. + // Parameters : + // See above. + // Return Values : + // 1 on success. + // 0 on failure. + // -------------------------------------------------------------------------------- + function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privParseOptions", ""); + $v_result=1; + + // ----- Read the options + $i=0; + while ($i<$p_size) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Looking for table index $i, option = '".PclZipUtilOptionText($p_options_list[$i])."(".$p_options_list[$i].")'"); + + // ----- Check if the option is supported + if (!isset($v_requested_options[$p_options_list[$i]])) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Look for next option + switch ($p_options_list[$i]) { + // ----- Look for options that request a path value + case PCLZIP_OPT_PATH : + case PCLZIP_OPT_REMOVE_PATH : + case PCLZIP_OPT_ADD_PATH : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); + $i++; + break; + + case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + if ( is_string($p_options_list[$i+1]) + && ($p_options_list[$i+1] != '')) { + $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); + $i++; + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." set with an empty value is ignored."); + } + break; + + // ----- Look for options that request an array of string for value + case PCLZIP_OPT_BY_NAME : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + if (is_string($p_options_list[$i+1])) { + $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1]; + } + else if (is_array($p_options_list[$i+1])) { + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; + } + else { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); + $i++; + break; + + // ----- Look for options that request an EREG or PREG expression + case PCLZIP_OPT_BY_EREG : + case PCLZIP_OPT_BY_PREG : + //case PCLZIP_OPT_CRYPT : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + if (is_string($p_options_list[$i+1])) { + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; + } + else { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); + $i++; + break; + + // ----- Look for options that takes a string + case PCLZIP_OPT_COMMENT : + case PCLZIP_OPT_ADD_COMMENT : + case PCLZIP_OPT_PREPEND_COMMENT : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, + "Missing parameter value for option '" + .PclZipUtilOptionText($p_options_list[$i]) + ."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + if (is_string($p_options_list[$i+1])) { + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; + } + else { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, + "Wrong parameter value for option '" + .PclZipUtilOptionText($p_options_list[$i]) + ."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); + $i++; + break; + + // ----- Look for options that request an array of index + case PCLZIP_OPT_BY_INDEX : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + $v_work_list = array(); + if (is_string($p_options_list[$i+1])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is a string '".$p_options_list[$i+1]."'"); + + // ----- Remove spaces + $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', ''); + + // ----- Parse items + $v_work_list = explode(",", $p_options_list[$i+1]); + } + else if (is_integer($p_options_list[$i+1])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an integer '".$p_options_list[$i+1]."'"); + $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1]; + } + else if (is_array($p_options_list[$i+1])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an array"); + $v_work_list = $p_options_list[$i+1]; + } + else { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Reduce the index list + // each index item in the list must be a couple with a start and + // an end value : [0,3], [5-5], [8-10], ... + // ----- Check the format of each item + $v_sort_flag=false; + $v_sort_value=0; + for ($j=0; $j= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); + $i++; + break; + + // ----- Look for options that request a call-back + case PCLZIP_CB_PRE_EXTRACT : + case PCLZIP_CB_POST_EXTRACT : + case PCLZIP_CB_PRE_ADD : + case PCLZIP_CB_POST_ADD : + /* for futur use + case PCLZIP_CB_PRE_DELETE : + case PCLZIP_CB_POST_DELETE : + case PCLZIP_CB_PRE_LIST : + case PCLZIP_CB_POST_LIST : + */ + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + $v_function_name = $p_options_list[$i+1]; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "call-back ".PclZipUtilOptionText($p_options_list[$i])." = '".$v_function_name."'"); + + // ----- Check that the value is a valid existing function + if (!function_exists($v_function_name)) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Set the attribute + $v_result_list[$p_options_list[$i]] = $v_function_name; + $i++; + break; + + default : + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, + "Unknown parameter '" + .$p_options_list[$i]."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Next options + $i++; + } + + // ----- Look for mandatory options + if ($v_requested_options !== false) { + for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { + // ----- Look for mandatory option + if ($v_requested_options[$key] == 'mandatory') { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")"); + // ----- Look if present + if (!isset($v_result_list[$key])) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + } + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privFileDescrParseAtt() + // Description : + // Parameters : + // Return Values : + // 1 on success. + // 0 on failure. + // -------------------------------------------------------------------------------- + function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privFileDescrParseAtt", ""); + $v_result=1; + + // ----- For each file in the list check the attributes + foreach ($p_file_list as $v_key => $v_value) { + + // ----- Check if the option is supported + if (!isset($v_requested_options[$v_key])) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Look for attribute + switch ($v_key) { + case PCLZIP_ATT_FILE_NAME : + if (!is_string($v_value)) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + $p_filedescr['filename'] = PclZipUtilPathReduction($v_value); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'"); + + if ($p_filedescr['filename'] == '') { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + break; + + case PCLZIP_ATT_FILE_NEW_SHORT_NAME : + if (!is_string($v_value)) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'"); + + if ($p_filedescr['new_short_name'] == '') { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + break; + + case PCLZIP_ATT_FILE_NEW_FULL_NAME : + if (!is_string($v_value)) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'"); + + if ($p_filedescr['new_full_name'] == '') { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + break; + + default : + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, + "Unknown parameter '".$v_key."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Look for mandatory options + if ($v_requested_options !== false) { + for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { + // ----- Look for mandatory option + if ($v_requested_options[$key] == 'mandatory') { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")"); + // ----- Look if present + if (!isset($p_file_list[$key])) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + } + } + + // end foreach + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privFileDescrExpand() + // Description : + // Parameters : + // Return Values : + // 1 on success. + // 0 on failure. + // -------------------------------------------------------------------------------- + function privFileDescrExpand(&$p_filedescr_list, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privFileDescrExpand", ""); + $v_result=1; + + // ----- Create a result list + $v_result_list = array(); + + // ----- Look each entry + for ($i=0; $iprivCalculateStoredFilename($v_descr, $p_options); + + // ----- Add the descriptor in result list + $v_result_list[sizeof($v_result_list)] = $v_descr; + + // ----- Look for folder + if ($v_descr['type'] == 'folder') { + // ----- List of items in folder + $v_dirlist_descr = array(); + $v_dirlist_nb = 0; + if ($v_folder_handler = @opendir($v_descr['filename'])) { + while (($v_item_handler = @readdir($v_folder_handler)) !== false) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for '".$v_item_handler."' in the directory"); + + // ----- Skip '.' and '..' + if (($v_item_handler == '.') || ($v_item_handler == '..')) { + continue; + } + + // ----- Compose the full filename + $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler; + + // ----- Look for different stored filename + // Because the name of the folder was changed, the name of the + // files/sub-folders also change + if ($v_descr['stored_filename'] != $v_descr['filename']) { + $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler; + } + + $v_dirlist_nb++; + } + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to open dir '".$v_descr['filename']."' in read mode. Skipped."); + // TBC : unable to open folder in read mode + } + + // ----- Expand each element of the list + if ($v_dirlist_nb != 0) { + // ----- Expand + if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Concat the resulting list + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Merging result list (size '".sizeof($v_result_list)."') with dirlist (size '".sizeof($v_dirlist_descr)."')"); + $v_result_list = array_merge($v_result_list, $v_dirlist_descr); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "merged result list is size '".sizeof($v_result_list)."'"); + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Nothing in this folder to expand."); + } + + // ----- Free local array + unset($v_dirlist_descr); + } + } + + // ----- Get the result list + $p_filedescr_list = $v_result_list; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privCreate() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privCreate($p_filedescr_list, &$p_result_list, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCreate", "list"); + $v_result=1; + $v_list_detail = array(); + + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Open the file in write mode + if (($v_result = $this->privOpenFd('wb')) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Add the list of files + $v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options); + + // ----- Close + $this->privCloseFd(); + + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privAdd() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privAdd($p_filedescr_list, &$p_result_list, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAdd", "list"); + $v_result=1; + $v_list_detail = array(); + + // ----- Look if the archive exists or is empty + if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, or is empty, create it."); + + // ----- Do a create + $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_result=$this->privOpenFd('rb')) != 1) + { + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Go to beginning of File + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'"); + + // ----- Creates a temporay file + $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; + + // ----- Open the temporary file in write mode + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) + { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Copy the files from the archive to the temporary file + // TBC : Here I should better append the file and go back to erase the central dir + $v_size = $v_central_dir['offset']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = fread($this->zip_fd, $v_read_size); + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Swap the file descriptor + // Here is a trick : I swap the temporary fd with the zip fd, in order to use + // the following methods on the temporary fil and not the real archive + $v_swap = $this->zip_fd; + $this->zip_fd = $v_zip_temp_fd; + $v_zip_temp_fd = $v_swap; + + // ----- Add the files + $v_header_list = array(); + if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) + { + fclose($v_zip_temp_fd); + $this->privCloseFd(); + @unlink($v_zip_temp_name); + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Store the offset of the central dir + $v_offset = @ftell($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset"); + + // ----- Copy the block of file headers from the old archive + $v_size = $v_central_dir['size']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = @fread($v_zip_temp_fd, $v_read_size); + @fwrite($this->zip_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Create the Central Dir files header + for ($i=0, $v_count=0; $iprivWriteCentralFileHeader($v_header_list[$i])) != 1) { + fclose($v_zip_temp_fd); + $this->privCloseFd(); + @unlink($v_zip_temp_name); + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + $v_count++; + } + + // ----- Transform the header to a 'usable' info + $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); + } + + // ----- Zip file comment + $v_comment = $v_central_dir['comment']; + if (isset($p_options[PCLZIP_OPT_COMMENT])) { + $v_comment = $p_options[PCLZIP_OPT_COMMENT]; + } + if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) { + $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT]; + } + if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) { + $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment; + } + + // ----- Calculate the size of the central header + $v_size = @ftell($this->zip_fd)-$v_offset; + + // ----- Create the central dir footer + if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1) + { + // ----- Reset the file list + unset($v_header_list); + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Swap back the file descriptor + $v_swap = $this->zip_fd; + $this->zip_fd = $v_zip_temp_fd; + $v_zip_temp_fd = $v_swap; + + // ----- Close + $this->privCloseFd(); + + // ----- Close the temporary file + @fclose($v_zip_temp_fd); + + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Delete the zip file + // TBC : I should test the result ... + @unlink($this->zipname); + + // ----- Rename the temporary file + // TBC : I should test the result ... + //@rename($v_zip_temp_name, $this->zipname); + PclZipUtilRename($v_zip_temp_name, $this->zipname); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privOpenFd() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function privOpenFd($p_mode) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privOpenFd", 'mode='.$p_mode); + $v_result=1; + + // ----- Look if already open + if ($this->zip_fd != 0) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Open file in '.$p_mode.' mode'); + if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privCloseFd() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function privCloseFd() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCloseFd", ""); + $v_result=1; + + if ($this->zip_fd != 0) + @fclose($this->zip_fd); + $this->zip_fd = 0; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privAddList() + // Description : + // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is + // different from the real path of the file. This is usefull if you want to have PclTar + // running in any directory, and memorize relative path from an other directory. + // Parameters : + // $p_list : An array containing the file or directory names to add in the tar + // $p_result_list : list of added files with their properties (specially the status field) + // $p_add_dir : Path to add in the filename path archived + // $p_remove_dir : Path to remove in the filename path archived + // Return Values : + // -------------------------------------------------------------------------------- +// function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options) + function privAddList($p_filedescr_list, &$p_result_list, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddList", "list"); + $v_result=1; + + // ----- Add the files + $v_header_list = array(); + if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Store the offset of the central dir + $v_offset = @ftell($this->zip_fd); + + // ----- Create the Central Dir files header + for ($i=0,$v_count=0; $iprivWriteCentralFileHeader($v_header_list[$i])) != 1) { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + $v_count++; + } + + // ----- Transform the header to a 'usable' info + $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); + } + + // ----- Zip file comment + $v_comment = ''; + if (isset($p_options[PCLZIP_OPT_COMMENT])) { + $v_comment = $p_options[PCLZIP_OPT_COMMENT]; + } + + // ----- Calculate the size of the central header + $v_size = @ftell($this->zip_fd)-$v_offset; + + // ----- Create the central dir footer + if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1) + { + // ----- Reset the file list + unset($v_header_list); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privAddFileList() + // Description : + // Parameters : + // $p_filedescr_list : An array containing the file description + // or directory names to add in the zip + // $p_result_list : list of added files with their properties (specially the status field) + // Return Values : + // -------------------------------------------------------------------------------- + function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFileList", "filedescr_list"); + $v_result=1; + $v_header = array(); + + // ----- Recuperate the current number of elt in list + $v_nb = sizeof($p_result_list); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Before add, list have ".$v_nb." elements"); + + // ----- Loop on the files + for ($j=0; ($jprivAddFile($p_filedescr_list[$j], $v_header, + $p_options); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Store the file infos + $p_result_list[$v_nb++] = $v_header; + } + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "After add, list have ".$v_nb." elements"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privAddFile() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privAddFile($p_filedescr, &$p_header, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFile", "filename='".$p_filedescr['filename']."'"); + $v_result=1; + + // ----- Working variable + $p_filename = $p_filedescr['filename']; + + // TBC : Already done in the fileAtt check ... ? + if ($p_filename == "") { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Look for a stored different filename + if (isset($p_filedescr['stored_filename'])) { + $v_stored_filename = $p_filedescr['stored_filename']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'Stored filename is NOT the same "'.$v_stored_filename.'"'); + } + else { + $v_stored_filename = $p_filedescr['stored_filename']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'Stored filename is the same'); + } + + // ----- Set the file properties + clearstatcache(); + $p_header['version'] = 20; + $p_header['version_extracted'] = 10; + $p_header['flag'] = 0; + $p_header['compression'] = 0; + $p_header['mtime'] = filemtime($p_filename); + $p_header['crc'] = 0; + $p_header['compressed_size'] = 0; + $p_header['size'] = filesize($p_filename); + $p_header['filename_len'] = strlen($p_filename); + $p_header['extra_len'] = 0; + $p_header['comment_len'] = 0; + $p_header['disk'] = 0; + $p_header['internal'] = 0; +// $p_header['external'] = (is_file($p_filename)?0xFE49FFE0:0x41FF0010); + $p_header['external'] = (is_file($p_filename)?0x00000000:0x00000010); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header external extension '".sprintf("0x%X",$p_header['external'])."'"); + $p_header['offset'] = 0; + $p_header['filename'] = $p_filename; + $p_header['stored_filename'] = $v_stored_filename; + $p_header['extra'] = ''; + $p_header['comment'] = ''; + $p_header['status'] = 'ok'; + $p_header['index'] = -1; + + // ----- Look for pre-add callback + if (isset($p_options[PCLZIP_CB_PRE_ADD])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_ADD]."()') is defined for the extraction"); + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_header, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);'); + if ($v_result == 0) { + // ----- Change the file status + $p_header['status'] = "skipped"; + $v_result = 1; + } + + // ----- Update the informations + // Only some fields can be modified + if ($p_header['stored_filename'] != $v_local_header['stored_filename']) { + $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New stored filename is '".$p_header['stored_filename']."'"); + } + } + + // ----- Look for empty stored filename + if ($p_header['stored_filename'] == "") { + $p_header['status'] = "filtered"; + } + + // ----- Check the path length + if (strlen($p_header['stored_filename']) > 0xFF) { + $p_header['status'] = 'filename_too_long'; + } + + // ----- Look if no error, or file not skipped + if ($p_header['status'] == 'ok') { + + // ----- Look for a file + if (is_file($p_filename)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a file"); + // ----- Open the source file + if (($v_file = @fopen($p_filename, "rb")) == 0) { + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be compressed"); + // ----- Read the file content + $v_content_compressed = @fread($v_file, $p_header['size']); + + // ----- Calculate the CRC + $p_header['crc'] = @crc32($v_content_compressed); + + // ----- Set header parameters + $p_header['compressed_size'] = $p_header['size']; + $p_header['compression'] = 0; + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will be compressed"); + // ----- Read the file content + $v_content = @fread($v_file, $p_header['size']); + + // ----- Calculate the CRC + $p_header['crc'] = @crc32($v_content); + + // ----- Compress the file + $v_content_compressed = @gzdeflate($v_content); + + // ----- Set header parameters + $p_header['compressed_size'] = strlen($v_content_compressed); + $p_header['compression'] = 8; + } + + // ----- Look for encryption + /* + if ((isset($p_options[PCLZIP_OPT_CRYPT])) + && ($p_options[PCLZIP_OPT_CRYPT] != "")) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File need to be crypted ...."); + + // Should be a random header + $v_header = 'xxxxxxxxxxxx'; + $v_content_compressed = PclZipUtilZipEncrypt($v_content_compressed, + $p_header['compressed_size'], + $v_header, + $p_header['crc'], + "test"); + + $p_header['compressed_size'] += 12; + $p_header['flag'] = 1; + + // ----- Add the header to the data + $v_content_compressed = $v_header.$v_content_compressed; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size after header : ".strlen($v_content_compressed).""); + } + */ + + // ----- Call the header generation + if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { + @fclose($v_file); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Write the compressed (or not) content + @fwrite($this->zip_fd, + $v_content_compressed, $p_header['compressed_size']); + + // ----- Close the file + @fclose($v_file); + } + + // ----- Look for a directory + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a folder"); + // ----- Look for directory last '/' + if (@substr($p_header['stored_filename'], -1) != '/') { + $p_header['stored_filename'] .= '/'; + } + + // ----- Set the file properties + $p_header['size'] = 0; + //$p_header['external'] = 0x41FF0010; // Value for a folder : to be checked + $p_header['external'] = 0x00000010; // Value for a folder : to be checked + + // ----- Call the header generation + if (($v_result = $this->privWriteFileHeader($p_header)) != 1) + { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + } + } + + // ----- Look for post-add callback + if (isset($p_options[PCLZIP_CB_POST_ADD])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_ADD]."()') is defined for the extraction"); + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_header, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);'); + if ($v_result == 0) { + // ----- Ignored + $v_result = 1; + } + + // ----- Update the informations + // Nothing can be modified + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privCalculateStoredFilename() + // Description : + // Based on file descriptor properties and global options, this method + // calculate the filename that will be stored in the archive. + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privCalculateStoredFilename(&$p_filedescr, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCalculateStoredFilename", "filename='".$p_filedescr['filename']."'"); + $v_result=1; + + // ----- Working variables + $p_filename = $p_filedescr['filename']; + if (isset($p_options[PCLZIP_OPT_ADD_PATH])) { + $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH]; + } + else { + $p_add_dir = ''; + } + if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) { + $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH]; + } + else { + $p_remove_dir = ''; + } + if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { + $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH]; + } + else { + $p_remove_all_dir = 0; + } + + // ----- Look for full name change + if (isset($p_filedescr['new_full_name'])) { + $v_stored_filename = $p_filedescr['new_full_name']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Changing full name of '".$p_filename."' for '".$v_stored_filename."'"); + } + + // ----- Look for path and/or short name change + else { + + // ----- Look for short name change + if (isset($p_filedescr['new_short_name'])) { + $v_path_info = pathinfo($p_filename); + $v_dir = ''; + if ($v_path_info['dirname'] != '') { + $v_dir = $v_path_info['dirname'].'/'; + } + $v_stored_filename = $v_dir.$p_filedescr['new_short_name']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Changing short name of '".$p_filename."' for '".$v_stored_filename."'"); + } + else { + // ----- Calculate the stored filename + $v_stored_filename = $p_filename; + } + + // ----- Look for all path to remove + if ($p_remove_all_dir) { + $v_stored_filename = basename($p_filename); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove all path selected change '".$p_filename."' for '".$v_stored_filename."'"); + } + // ----- Look for partial path remove + else if ($p_remove_dir != "") { + if (substr($p_remove_dir, -1) != '/') + $p_remove_dir .= "/"; + + if ( (substr($p_filename, 0, 2) == "./") + || (substr($p_remove_dir, 0, 2) == "./")) { + + if ( (substr($p_filename, 0, 2) == "./") + && (substr($p_remove_dir, 0, 2) != "./")) { + $p_remove_dir = "./".$p_remove_dir; + } + if ( (substr($p_filename, 0, 2) != "./") + && (substr($p_remove_dir, 0, 2) == "./")) { + $p_remove_dir = substr($p_remove_dir, 2); + } + } + + $v_compare = PclZipUtilPathInclusion($p_remove_dir, + $v_stored_filename); + if ($v_compare > 0) { + if ($v_compare == 2) { + $v_stored_filename = ""; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Path to remove is the current folder"); + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove path '$p_remove_dir' in file '$v_stored_filename'"); + $v_stored_filename = substr($v_stored_filename, + strlen($p_remove_dir)); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Result is '$v_stored_filename'"); + } + } + } + // ----- Look for path to add + if ($p_add_dir != "") { + if (substr($p_add_dir, -1) == "/") + $v_stored_filename = $p_add_dir.$v_stored_filename; + else + $v_stored_filename = $p_add_dir."/".$v_stored_filename; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Add path '$p_add_dir' in file '$p_filename' = '$v_stored_filename'"); + } + } + + // ----- Filename (reduce the path of stored name) + $v_stored_filename = PclZipUtilPathReduction($v_stored_filename); + $p_filedescr['stored_filename'] = $v_stored_filename; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Stored filename will be '".$p_filedescr['stored_filename']."', strlen ".strlen($p_filedescr['stored_filename'])); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privWriteFileHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privWriteFileHeader(&$p_header) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"'); + $v_result=1; + + // ----- Store the offset position of the file + $p_header['offset'] = ftell($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'File offset of the header :'.$p_header['offset']); + + // ----- Transform UNIX mtime to DOS format mdate/mtime + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); + $v_date = getdate($p_header['mtime']); + $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; + $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; + + // ----- Packed data + $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50, + $p_header['version_extracted'], $p_header['flag'], + $p_header['compression'], $v_mtime, $v_mdate, + $p_header['crc'], $p_header['compressed_size'], + $p_header['size'], + strlen($p_header['stored_filename']), + $p_header['extra_len']); + + // ----- Write the first 148 bytes of the header in the archive + fputs($this->zip_fd, $v_binary_data, 30); + + // ----- Write the variable fields + if (strlen($p_header['stored_filename']) != 0) + { + fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); + } + if ($p_header['extra_len'] != 0) + { + fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privWriteCentralFileHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privWriteCentralFileHeader(&$p_header) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"'); + $v_result=1; + + // TBC + //for(reset($p_header); $key = key($p_header); next($p_header)) { + // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "header[$key] = ".$p_header[$key]); + //} + + // ----- Transform UNIX mtime to DOS format mdate/mtime + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); + $v_date = getdate($p_header['mtime']); + $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; + $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; + + // ----- Packed data + $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50, + $p_header['version'], $p_header['version_extracted'], + $p_header['flag'], $p_header['compression'], + $v_mtime, $v_mdate, $p_header['crc'], + $p_header['compressed_size'], $p_header['size'], + strlen($p_header['stored_filename']), + $p_header['extra_len'], $p_header['comment_len'], + $p_header['disk'], $p_header['internal'], + $p_header['external'], $p_header['offset']); + + // ----- Write the 42 bytes of the header in the zip file + fputs($this->zip_fd, $v_binary_data, 46); + + // ----- Write the variable fields + if (strlen($p_header['stored_filename']) != 0) + { + fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); + } + if ($p_header['extra_len'] != 0) + { + fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); + } + if ($p_header['comment_len'] != 0) + { + fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privWriteCentralHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralHeader", 'nb_entries='.$p_nb_entries.', size='.$p_size.', offset='.$p_offset.', comment="'.$p_comment.'"'); + $v_result=1; + + // ----- Packed data + $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries, + $p_nb_entries, $p_size, + $p_offset, strlen($p_comment)); + + // ----- Write the 22 bytes of the header in the zip file + fputs($this->zip_fd, $v_binary_data, 22); + + // ----- Write the variable fields + if (strlen($p_comment) != 0) + { + fputs($this->zip_fd, $p_comment, strlen($p_comment)); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privList() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privList(&$p_list) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privList", "list"); + $v_result=1; + + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) + { + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Go to beginning of Central Dir + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Offset : ".$v_central_dir['offset']."'"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'"); + if (@fseek($this->zip_fd, $v_central_dir['offset'])) + { + $this->privSwapBackMagicQuotes(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'"); + + // ----- Read each entry + for ($i=0; $i<$v_central_dir['entries']; $i++) + { + // ----- Read the file header + if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) + { + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + $v_header['index'] = $i; + + // ----- Get the only interesting attributes + $this->privConvertHeader2FileInfo($v_header, $p_list[$i]); + unset($v_header); + } + + // ----- Close the zip file + $this->privCloseFd(); + + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privConvertHeader2FileInfo() + // Description : + // This function takes the file informations from the central directory + // entries and extract the interesting parameters that will be given back. + // The resulting file infos are set in the array $p_info + // $p_info['filename'] : Filename with full path. Given by user (add), + // extracted in the filesystem (extract). + // $p_info['stored_filename'] : Stored filename in the archive. + // $p_info['size'] = Size of the file. + // $p_info['compressed_size'] = Compressed size of the file. + // $p_info['mtime'] = Last modification date of the file. + // $p_info['comment'] = Comment associated with the file. + // $p_info['folder'] = true/false : indicates if the entry is a folder or not. + // $p_info['status'] = status of the action on the file. + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privConvertHeader2FileInfo($p_header, &$p_info) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privConvertHeader2FileInfo", "Filename='".$p_header['filename']."'"); + $v_result=1; + + // ----- Get the interesting attributes + $p_info['filename'] = $p_header['filename']; + $p_info['stored_filename'] = $p_header['stored_filename']; + $p_info['size'] = $p_header['size']; + $p_info['compressed_size'] = $p_header['compressed_size']; + $p_info['mtime'] = $p_header['mtime']; + $p_info['comment'] = $p_header['comment']; + $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010); + $p_info['index'] = $p_header['index']; + $p_info['status'] = $p_header['status']; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privExtractByRule() + // Description : + // Extract a file or directory depending of rules (by index, by name, ...) + // Parameters : + // $p_file_list : An array where will be placed the properties of each + // extracted file + // $p_path : Path to add while writing the extracted files + // $p_remove_path : Path to remove (from the file memorized path) while writing the + // extracted files. If the path does not match the file path, + // the file is extracted with its memorized path. + // $p_remove_path does not apply to 'list' mode. + // $p_path and $p_remove_path are commulative. + // Return Values : + // 1 on success,0 or less on error (see error code list) + // -------------------------------------------------------------------------------- + function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privExtractByRule", "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'"); + $v_result=1; + + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Check the path + if ( ($p_path == "") + || ( (substr($p_path, 0, 1) != "/") + && (substr($p_path, 0, 3) != "../") + && (substr($p_path,1,2)!=":/"))) + $p_path = "./".$p_path; + + // ----- Reduce the path last (and duplicated) '/' + if (($p_path != "./") && ($p_path != "/")) + { + // ----- Look for the path end '/' + while (substr($p_path, -1) == "/") + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Destination path [$p_path] ends by '/'"); + $p_path = substr($p_path, 0, strlen($p_path)-1); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Modified to [$p_path]"); + } + } + + // ----- Look for path to remove format (should end by /) + if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/')) + { + $p_remove_path .= '/'; + } + $p_remove_path_size = strlen($p_remove_path); + + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_result = $this->privOpenFd('rb')) != 1) + { + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Start at beginning of Central Dir + $v_pos_entry = $v_central_dir['offset']; + + // ----- Read each entry + $j_start = 0; + for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry : '$i'"); + + // ----- Read next Central dir entry + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position before rewind : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position after rewind : ".ftell($this->zip_fd)."'"); + if (@fseek($this->zip_fd, $v_pos_entry)) + { + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after fseek : ".ftell($this->zip_fd)."'"); + + // ----- Read the file header + $v_header = array(); + if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) + { + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Store the index + $v_header['index'] = $i; + + // ----- Store the file position + $v_pos_entry = ftell($this->zip_fd); + + // ----- Look for the specific extract rules + $v_extract = false; + + // ----- Look for extract by name rule + if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) + && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'"); + + // ----- Look if the filename is in the list + for ($j=0; ($j strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) + && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path"); + $v_extract = true; + } + } + // ----- Look for a filename + elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one."); + $v_extract = true; + } + } + } + + // ----- Look for extract by ereg rule + else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) + && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'"); + + if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); + $v_extract = true; + } + } + + // ----- Look for extract by preg rule + else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) + && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'"); + + if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); + $v_extract = true; + } + } + + // ----- Look for extract by index rule + else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) + && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'"); + + // ----- Look if the index is in the list + for ($j=$j_start; ($j=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range"); + $v_extract = true; + } + if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop"); + $j_start = $j+1; + } + + if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop"); + break; + } + } + } + + // ----- Look for no rule, which means extract all the archive + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with no rule (extract all)"); + $v_extract = true; + } + + // ----- Check compression method + if ( ($v_extract) + && ( ($v_header['compression'] != 8) + && ($v_header['compression'] != 0))) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unsupported compression method (".$v_header['compression'].")"); + $v_header['status'] = 'unsupported_compression'; + + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped"); + + $this->privSwapBackMagicQuotes(); + + PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION, + "Filename '".$v_header['stored_filename']."' is " + ."compressed by an unsupported compression " + ."method (".$v_header['compression'].") "); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + + // ----- Check encrypted files + if (($v_extract) && (($v_header['flag'] & 1) == 1)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unsupported file encryption"); + $v_header['status'] = 'unsupported_encryption'; + + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped"); + + $this->privSwapBackMagicQuotes(); + + PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, + "Unsupported encryption for " + ." filename '".$v_header['stored_filename'] + ."'"); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + + // ----- Look for real extraction + if (($v_extract) && ($v_header['status'] != 'ok')) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "No need for extract"); + $v_result = $this->privConvertHeader2FileInfo($v_header, + $p_file_list[$v_nb_extracted++]); + if ($v_result != 1) { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + $v_extract = false; + } + + // ----- Look for real extraction + if ($v_extract) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file '".$v_header['filename']."', index '$i'"); + + // ----- Go to the file position + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'"); + if (@fseek($this->zip_fd, $v_header['offset'])) + { + // ----- Close the zip file + $this->privCloseFd(); + + $this->privSwapBackMagicQuotes(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'"); + + // ----- Look for extraction as string + if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) { + + // ----- Extracting the file + $v_result1 = $this->privExtractFileAsString($v_header, $v_string); + if ($v_result1 < 1) { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1); + return $v_result1; + } + + // ----- Get the only interesting attributes + if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1) + { + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Set the file content + $p_file_list[$v_nb_extracted]['content'] = $v_string; + + // ----- Next extracted file + $v_nb_extracted++; + + // ----- Look for user callback abort + if ($v_result1 == 2) { + break; + } + } + // ----- Look for extraction in standard output + elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) + && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) { + // ----- Extracting the file in standard output + $v_result1 = $this->privExtractFileInOutput($v_header, $p_options); + if ($v_result1 < 1) { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1); + return $v_result1; + } + + // ----- Get the only interesting attributes + if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Look for user callback abort + if ($v_result1 == 2) { + break; + } + } + // ----- Look for normal extraction + else { + // ----- Extracting the file + $v_result1 = $this->privExtractFile($v_header, + $p_path, $p_remove_path, + $p_remove_all_path, + $p_options); + if ($v_result1 < 1) { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1); + return $v_result1; + } + + // ----- Get the only interesting attributes + if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) + { + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Look for user callback abort + if ($v_result1 == 2) { + break; + } + } + } + } + + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privExtractFile() + // Description : + // Parameters : + // Return Values : + // + // 1 : ... ? + // PCLZIP_ERR_USER_ABORTED(2) : User ask for extraction stop in callback + // -------------------------------------------------------------------------------- + function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFile', "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'"); + $v_result=1; + + // ----- Read the file header + if (($v_result = $this->privReadFileHeader($v_header)) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'"); + + // ----- Check that the file header is coherent with $p_entry info + if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { + // TBC + } + + // ----- Look for all path to remove + if ($p_remove_all_path == true) { + // ----- Look for folder entry that not need to be extracted + if (($p_entry['external']&0x00000010)==0x00000010) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The entry is a folder : need to be filtered"); + + $p_entry['status'] = "filtered"; + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "All path is removed"); + // ----- Get the basename of the path + $p_entry['filename'] = basename($p_entry['filename']); + } + + // ----- Look for path to remove + else if ($p_remove_path != "") + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look for some path to remove"); + if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The folder is the same as the removed path '".$p_entry['filename']."'"); + + // ----- Change the file status + $p_entry['status'] = "filtered"; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + $p_remove_path_size = strlen($p_remove_path); + if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found path '$p_remove_path' to remove in file '".$p_entry['filename']."'"); + + // ----- Remove the path + $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size); + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Resulting file is '".$p_entry['filename']."'"); + } + } + + // ----- Add the path + if ($p_path != '') { + $p_entry['filename'] = $p_path."/".$p_entry['filename']; + } + + // ----- Check a base_dir_restriction + if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Check the extract directory restriction"); + $v_inclusion + = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION], + $p_entry['filename']); + if ($v_inclusion == 0) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_EXTRACT_DIR_RESTRICTION is selected, file is outside restriction"); + + PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION, + "Filename '".$p_entry['filename']."' is " + ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION"); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + + // ----- Look for pre-extract callback + if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction"); + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);'); + if ($v_result == 0) { + // ----- Change the file status + $p_entry['status'] = "skipped"; + $v_result = 1; + } + + // ----- Look for abort result + if ($v_result == 2) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction"); + // ----- This status is internal and will be changed in 'skipped' + $p_entry['status'] = "aborted"; + $v_result = PCLZIP_ERR_USER_ABORTED; + } + + // ----- Update the informations + // Only some fields can be modified + $p_entry['filename'] = $v_local_header['filename']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'"); + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'"); + + // ----- Look if extraction should be done + if ($p_entry['status'] == 'ok') { + + // ----- Look for specific actions while the file exist + if (file_exists($p_entry['filename'])) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$p_entry['filename']."' already exists"); + + // ----- Look if file is a directory + if (is_dir($p_entry['filename'])) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is a directory"); + + // ----- Change the file status + $p_entry['status'] = "already_a_directory"; + + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR + // For historical reason first PclZip implementation does not stop + // when this kind of error occurs. + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped"); + + PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY, + "Filename '".$p_entry['filename']."' is " + ."already used by an existing directory"); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + // ----- Look if file is write protected + else if (!is_writeable($p_entry['filename'])) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is write protected"); + + // ----- Change the file status + $p_entry['status'] = "write_protected"; + + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR + // For historical reason first PclZip implementation does not stop + // when this kind of error occurs. + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped"); + + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, + "Filename '".$p_entry['filename']."' exists " + ."and is write protected"); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + + // ----- Look if the extracted file is older + else if (filemtime($p_entry['filename']) > $p_entry['mtime']) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is newer (".date("l dS of F Y h:i:s A", filemtime($p_entry['filename'])).") than the extracted file (".date("l dS of F Y h:i:s A", $p_entry['mtime']).")"); + // ----- Change the file status + if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER])) + && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_REPLACE_NEWER is selected, file will be replaced"); + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be replaced"); + $p_entry['status'] = "newer_exist"; + + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR + // For historical reason first PclZip implementation does not stop + // when this kind of error occurs. + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped"); + + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, + "Newer version of '".$p_entry['filename']."' exists " + ."and option PCLZIP_OPT_REPLACE_NEWER is not selected"); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is older than the extrated one - will be replaced by the extracted one (".date("l dS of F Y h:i:s A", filemtime($p_entry['filename'])).") than the extracted file (".date("l dS of F Y h:i:s A", $p_entry['mtime']).")"); + } + } + + // ----- Check the directory availability and create it if necessary + else { + if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) + $v_dir_to_check = $p_entry['filename']; + else if (!strstr($p_entry['filename'], "/")) + $v_dir_to_check = ""; + else + $v_dir_to_check = dirname($p_entry['filename']); + + if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to create path for '".$p_entry['filename']."'"); + + // ----- Change the file status + $p_entry['status'] = "path_creation_fail"; + + // ----- Return + ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + //return $v_result; + $v_result = 1; + } + } + } + + // ----- Look if extraction should be done + if ($p_entry['status'] == 'ok') { + + // ----- Do the extraction (if not a folder) + if (!(($p_entry['external']&0x00000010)==0x00000010)) + { + // ----- Look for not compressed file + if ($p_entry['compression'] == 0) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file"); + + // ----- Opening destination file + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode"); + + // ----- Change the file status + $p_entry['status'] = "write_error"; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read '".$p_entry['size']."' bytes"); + + // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks + $v_size = $p_entry['compressed_size']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes"); + $v_buffer = @fread($this->zip_fd, $v_read_size); + /* Try to speed up the code + $v_binary_data = pack('a'.$v_read_size, $v_buffer); + @fwrite($v_dest_file, $v_binary_data, $v_read_size); + */ + @fwrite($v_dest_file, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Closing the destination file + fclose($v_dest_file); + + // ----- Change the file mtime + touch($p_entry['filename'], $p_entry['mtime']); + + + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file (Compression method ".$p_entry['compression'].")"); + // ----- TBC + // Need to be finished + if (($p_entry['flag'] & 1) == 1) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File is encrypted"); + /* + // ----- Read the encryption header + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read 12 encryption header bytes"); + $v_encryption_header = @fread($this->zip_fd, 12); + + // ----- Read the encrypted & compressed file in a buffer + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read '".($p_entry['compressed_size']-12)."' compressed & encrypted bytes"); + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']-12); + + // ----- Decrypt the buffer + $this->privDecrypt($v_encryption_header, $v_buffer, + $p_entry['compressed_size']-12, $p_entry['crc']); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Buffer is '".$v_buffer."'"); + */ + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read '".$p_entry['compressed_size']."' compressed bytes"); + // ----- Read the compressed file in a buffer (one shot) + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); + } + + // ----- Decompress the file + $v_file_content = @gzinflate($v_buffer); + unset($v_buffer); + if ($v_file_content === FALSE) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to inflate compressed file"); + + // ----- Change the file status + // TBC + $p_entry['status'] = "error"; + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Opening destination file + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode"); + + // ----- Change the file status + $p_entry['status'] = "write_error"; + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Write the uncompressed data + @fwrite($v_dest_file, $v_file_content, $p_entry['size']); + unset($v_file_content); + + // ----- Closing the destination file + @fclose($v_dest_file); + + // ----- Change the file mtime + @touch($p_entry['filename'], $p_entry['mtime']); + } + + // ----- Look for chmod option + if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "chmod option activated '".$p_options[PCLZIP_OPT_SET_CHMOD]."'"); + + // ----- Change the mode of the file + @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]); + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done"); + } + } + + // ----- Change abort status + if ($p_entry['status'] == "aborted") { + $p_entry['status'] = "skipped"; + } + + // ----- Look for post-extract callback + elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction"); + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);'); + + // ----- Look for abort result + if ($v_result == 2) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction"); + $v_result = PCLZIP_ERR_USER_ABORTED; + } + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privExtractFileInOutput() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privExtractFileInOutput(&$p_entry, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileInOutput', ""); + $v_result=1; + + // ----- Read the file header + if (($v_result = $this->privReadFileHeader($v_header)) != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'"); + + // ----- Check that the file header is coherent with $p_entry info + if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { + // TBC + } + + // ----- Look for pre-extract callback + if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction"); + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);'); + if ($v_result == 0) { + // ----- Change the file status + $p_entry['status'] = "skipped"; + $v_result = 1; + } + + // ----- Look for abort result + if ($v_result == 2) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction"); + // ----- This status is internal and will be changed in 'skipped' + $p_entry['status'] = "aborted"; + $v_result = PCLZIP_ERR_USER_ABORTED; + } + + // ----- Update the informations + // Only some fields can be modified + $p_entry['filename'] = $v_local_header['filename']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'"); + } + + // ----- Trace + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'"); + + // ----- Look if extraction should be done + if ($p_entry['status'] == 'ok') { + + // ----- Do the extraction (if not a folder) + if (!(($p_entry['external']&0x00000010)==0x00000010)) { + // ----- Look for not compressed file + if ($p_entry['compressed_size'] == $p_entry['size']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes"); + + // ----- Read the file in a buffer (one shot) + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); + + // ----- Send the file to the output + echo $v_buffer; + unset($v_buffer); + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Reading '".$p_entry['size']."' bytes"); + + // ----- Read the compressed file in a buffer (one shot) + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); + + // ----- Decompress the file + $v_file_content = gzinflate($v_buffer); + unset($v_buffer); + + // ----- Send the file to the output + echo $v_file_content; + unset($v_file_content); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done"); + } + } + + // ----- Change abort status + if ($p_entry['status'] == "aborted") { + $p_entry['status'] = "skipped"; + } + + // ----- Look for post-extract callback + elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction"); + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);'); + + // ----- Look for abort result + if ($v_result == 2) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction"); + $v_result = PCLZIP_ERR_USER_ABORTED; + } + } + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privExtractFileAsString() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privExtractFileAsString(&$p_entry, &$p_string) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileAsString', "p_entry['filename']='".$p_entry['filename']."'"); + $v_result=1; + + // ----- Read the file header + $v_header = array(); + if (($v_result = $this->privReadFileHeader($v_header)) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'"); + + // ----- Check that the file header is coherent with $p_entry info + if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { + // TBC + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file in string (with path) '".$p_entry['filename']."', size '$v_header[size]'"); + + // ----- Do the extraction (if not a folder) + if (!(($p_entry['external']&0x00000010)==0x00000010)) + { + // ----- Look for not compressed file +// if ($p_entry['compressed_size'] == $p_entry['size']) + if ($p_entry['compression'] == 0) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes"); + + // ----- Reading the file + $p_string = @fread($this->zip_fd, $p_entry['compressed_size']); + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file (compression method '".$p_entry['compression']."')"); + + // ----- Reading the file + $v_data = @fread($this->zip_fd, $p_entry['compressed_size']); + + // ----- Decompress the file + if (($p_string = @gzinflate($v_data)) === FALSE) { + // TBC + } + } + + // ----- Trace + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done"); + } + else { + // TBC : error : can not extract a folder in a string + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privReadFileHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privReadFileHeader(&$p_header) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadFileHeader", ""); + $v_result=1; + + // ----- Read the 4 bytes signature + $v_binary_data = @fread($this->zip_fd, 4); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'"); + $v_data = unpack('Vid', $v_binary_data); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'"); + + // ----- Check signature + if ($v_data['id'] != 0x04034b50) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid File header"); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Read the first 42 bytes of the header + $v_binary_data = fread($this->zip_fd, 26); + + // ----- Look for invalid block size + if (strlen($v_binary_data) != 26) + { + $p_header['filename'] = ""; + $p_header['status'] = "invalid_header"; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data)); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Extract the values + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header : '".$v_binary_data."'"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header (Hex) : '".bin2hex($v_binary_data)."'"); + $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data); + + // ----- Get filename + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "File name length : ".$v_data['filename_len']); + $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename : \''.$p_header['filename'].'\''); + + // ----- Get extra_fields + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extra field length : ".$v_data['extra_len']); + if ($v_data['extra_len'] != 0) { + $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']); + } + else { + $p_header['extra'] = ''; + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Extra field : \''.bin2hex($p_header['extra']).'\''); + + // ----- Extract properties + $p_header['version_extracted'] = $v_data['version']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : ('.$p_header['version_extracted'].') \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\''); + $p_header['compression'] = $v_data['compression']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compression method : \''.$p_header['compression'].'\''); + $p_header['size'] = $v_data['size']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_header['size'].'\''); + $p_header['compressed_size'] = $v_data['compressed_size']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_header['compressed_size'].'\''); + $p_header['crc'] = $v_data['crc']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.sprintf("0x%X", $p_header['crc']).'\''); + $p_header['flag'] = $v_data['flag']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Flag : \''.$p_header['flag'].'\''); + $p_header['filename_len'] = $v_data['filename_len']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename_len : \''.$p_header['filename_len'].'\''); + + // ----- Recuperate date in UNIX format + $p_header['mdate'] = $v_data['mdate']; + $p_header['mtime'] = $v_data['mtime']; + if ($p_header['mdate'] && $p_header['mtime']) + { + // ----- Extract time + $v_hour = ($p_header['mtime'] & 0xF800) >> 11; + $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; + $v_seconde = ($p_header['mtime'] & 0x001F)*2; + + // ----- Extract date + $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; + $v_month = ($p_header['mdate'] & 0x01E0) >> 5; + $v_day = $p_header['mdate'] & 0x001F; + + // ----- Get UNIX date format + $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); + } + else + { + $p_header['mtime'] = time(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); + } + + // TBC + //for(reset($v_data); $key = key($v_data); next($v_data)) { + // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Attribut[$key] = ".$v_data[$key]); + //} + + // ----- Set the stored filename + $p_header['stored_filename'] = $p_header['filename']; + + // ----- Set the status field + $p_header['status'] = "ok"; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privReadCentralFileHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privReadCentralFileHeader(&$p_header) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadCentralFileHeader", ""); + $v_result=1; + + // ----- Read the 4 bytes signature + $v_binary_data = @fread($this->zip_fd, 4); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'"); + $v_data = unpack('Vid', $v_binary_data); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'"); + + // ----- Check signature + if ($v_data['id'] != 0x02014b50) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid Central Dir File signature"); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Read the first 42 bytes of the header + $v_binary_data = fread($this->zip_fd, 42); + + // ----- Look for invalid block size + if (strlen($v_binary_data) != 42) + { + $p_header['filename'] = ""; + $p_header['status'] = "invalid_header"; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data)); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Extract the values + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header : '".$v_binary_data."'"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header (Hex) : '".bin2hex($v_binary_data)."'"); + $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data); + + // ----- Get filename + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File name length : ".$p_header['filename_len']); + if ($p_header['filename_len'] != 0) + $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']); + else + $p_header['filename'] = ''; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Filename : \''.$p_header['filename'].'\''); + + // ----- Get extra + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Extra length : ".$p_header['extra_len']); + if ($p_header['extra_len'] != 0) + $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']); + else + $p_header['extra'] = ''; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Extra : \''.$p_header['extra'].'\''); + + // ----- Get comment + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Comment length : ".$p_header['comment_len']); + if ($p_header['comment_len'] != 0) + $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']); + else + $p_header['comment'] = ''; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Comment : \''.$p_header['comment'].'\''); + + // ----- Extract properties + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version : \''.($p_header['version']/10).'.'.($p_header['version']%10).'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Size : \''.$p_header['size'].'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Compressed Size : \''.$p_header['compressed_size'].'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'CRC : \''.sprintf("0x%X", $p_header['crc']).'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Flag : \''.$p_header['flag'].'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Offset : \''.$p_header['offset'].'\''); + + // ----- Recuperate date in UNIX format + if ($p_header['mdate'] && $p_header['mtime']) + { + // ----- Extract time + $v_hour = ($p_header['mtime'] & 0xF800) >> 11; + $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; + $v_seconde = ($p_header['mtime'] & 0x001F)*2; + + // ----- Extract date + $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; + $v_month = ($p_header['mdate'] & 0x01E0) >> 5; + $v_day = $p_header['mdate'] & 0x001F; + + // ----- Get UNIX date format + $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); + } + else + { + $p_header['mtime'] = time(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); + } + + // ----- Set the stored filename + $p_header['stored_filename'] = $p_header['filename']; + + // ----- Set default status to ok + $p_header['status'] = 'ok'; + + // ----- Look if it is a directory + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Internal (Hex) : '".sprintf("Ox%04X", $p_header['internal'])."'"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "External (Hex) : '".sprintf("Ox%04X", $p_header['external'])."' (".(($p_header['external']&0x00000010)==0x00000010?'is a folder':'is a file').')'); + if (substr($p_header['filename'], -1) == '/') { + //$p_header['external'] = 0x41FF0010; + $p_header['external'] = 0x00000010; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Force folder external : \''.sprintf("Ox%04X", $p_header['external']).'\''); + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Header of filename : \''.$p_header['filename'].'\''); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privCheckFileHeaders() + // Description : + // Parameters : + // Return Values : + // 1 on success, + // 0 on error; + // -------------------------------------------------------------------------------- + function privCheckFileHeaders(&$p_local_header, &$p_central_header) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFileHeaders", ""); + $v_result=1; + + // ----- Check the static values + // TBC + if ($p_local_header['filename'] != $p_central_header['filename']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "filename" : TBC To Be Completed'); + } + if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "version_extracted" : TBC To Be Completed'); + } + if ($p_local_header['flag'] != $p_central_header['flag']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "flag" : TBC To Be Completed'); + } + if ($p_local_header['compression'] != $p_central_header['compression']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "compression" : TBC To Be Completed'); + } + if ($p_local_header['mtime'] != $p_central_header['mtime']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "mtime" : TBC To Be Completed'); + } + if ($p_local_header['filename_len'] != $p_central_header['filename_len']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "filename_len" : TBC To Be Completed'); + } + + // ----- Look for flag bit 3 + if (($p_local_header['flag'] & 8) == 8) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Purpose bit flag bit 3 set !'); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'File size, compression size and crc found in central header'); + $p_local_header['size'] = $p_central_header['size']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_local_header['size'].'\''); + $p_local_header['compressed_size'] = $p_central_header['compressed_size']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_local_header['compressed_size'].'\''); + $p_local_header['crc'] = $p_central_header['crc']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.sprintf("0x%X", $p_local_header['crc']).'\''); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privReadEndCentralDir() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privReadEndCentralDir(&$p_central_dir) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadEndCentralDir", ""); + $v_result=1; + + // ----- Go to the end of the zip file + $v_size = filesize($this->zipname); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size of the file :$v_size"); + @fseek($this->zip_fd, $v_size); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position at end of zip file : \''.ftell($this->zip_fd).'\''); + if (@ftell($this->zip_fd) != $v_size) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\''); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- First try : look if this is an archive with no commentaries (most of the time) + // in this case the end of central dir is at 22 bytes of the file end + $v_found = 0; + if ($v_size > 26) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Look for central dir with no comment'); + @fseek($this->zip_fd, $v_size-22); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after min central position : \''.ftell($this->zip_fd).'\''); + if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22)) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Read for bytes + $v_binary_data = @fread($this->zip_fd, 4); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Binary data is : '".sprintf("%08x", $v_binary_data)."'"); + $v_data = @unpack('Vid', $v_binary_data); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'"); + + // ----- Check signature + if ($v_data['id'] == 0x06054b50) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found central dir at the default position."); + $v_found = 1; + } + + $v_pos = ftell($this->zip_fd); + } + + // ----- Go back to the maximum possible size of the Central Dir End Record + if (!$v_found) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Start extended search of end central dir'); + $v_maximum_size = 65557; // 0xFFFF + 22; + if ($v_maximum_size > $v_size) + $v_maximum_size = $v_size; + @fseek($this->zip_fd, $v_size-$v_maximum_size); + if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size)) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after max central position : \''.ftell($this->zip_fd).'\''); + + // ----- Read byte per byte in order to find the signature + $v_pos = ftell($this->zip_fd); + $v_bytes = 0x00000000; + while ($v_pos < $v_size) + { + // ----- Read a byte + $v_byte = @fread($this->zip_fd, 1); + + // ----- Add the byte + // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number + // Otherwise on systems where we have 64bit integers the check below for the magic number will fail. + $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); + + // ----- Compare the bytes + if ($v_bytes == 0x504b0506) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Found End Central Dir signature at position : \''.ftell($this->zip_fd).'\''); + $v_pos++; + break; + } + + $v_pos++; + } + + // ----- Look if not found end of central dir + if ($v_pos == $v_size) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to find End of Central Dir Record signature"); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + + // ----- Read the first 18 bytes of the header + $v_binary_data = fread($this->zip_fd, 18); + + // ----- Look for invalid block size + if (strlen($v_binary_data) != 18) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid End of Central Dir Record size : ".strlen($v_binary_data)); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data)); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Extract the values + ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record : '".$v_binary_data."'"); + ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record (Hex) : '".bin2hex($v_binary_data)."'"); + $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data); + + // ----- Check the global size + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Comment length : ".$v_data['comment_size']); + if (($v_pos + $v_data['comment_size'] + 18) != $v_size) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The central dir is not at the end of the archive. Some trailing bytes exists after the archive."); + + // ----- Removed in release 2.2 see readme file + // The check of the file size is a little too strict. + // Some bugs where found when a zip is encrypted/decrypted with 'crypt'. + // While decrypted, zip has training 0 bytes + if (0) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, + 'The central dir is not at the end of the archive.' + .' Some trailing bytes exists after the archive.'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + + // ----- Get comment + if ($v_data['comment_size'] != 0) + $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']); + else + $p_central_dir['comment'] = ''; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Comment : \''.$p_central_dir['comment'].'\''); + + $p_central_dir['entries'] = $v_data['entries']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries : \''.$p_central_dir['entries'].'\''); + $p_central_dir['disk_entries'] = $v_data['disk_entries']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries for this disk : \''.$p_central_dir['disk_entries'].'\''); + $p_central_dir['offset'] = $v_data['offset']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Offset of Central Dir : \''.$p_central_dir['offset'].'\''); + $p_central_dir['size'] = $v_data['size']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size of Central Dir : \''.$p_central_dir['size'].'\''); + $p_central_dir['disk'] = $v_data['disk']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Disk number : \''.$p_central_dir['disk'].'\''); + $p_central_dir['disk_start'] = $v_data['disk_start']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Start disk number : \''.$p_central_dir['disk_start'].'\''); + + // TBC + //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) { + // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "central_dir[$key] = ".$p_central_dir[$key]); + //} + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privDeleteByRule() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privDeleteByRule(&$p_result_list, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDeleteByRule", ""); + $v_result=1; + $v_list_detail = array(); + + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_result=$this->privOpenFd('rb')) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + $this->privCloseFd(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Go to beginning of File + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'"); + + // ----- Scan all the files + // ----- Start at beginning of Central Dir + $v_pos_entry = $v_central_dir['offset']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'"); + if (@fseek($this->zip_fd, $v_pos_entry)) + { + // ----- Close the zip file + $this->privCloseFd(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'"); + + // ----- Read each entry + $v_header_list = array(); + $j_start = 0; + for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry (index '$i')"); + + // ----- Read the file header + $v_header_list[$v_nb_extracted] = array(); + if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1) + { + // ----- Close the zip file + $this->privCloseFd(); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename (index '$i') : '".$v_header_list[$v_nb_extracted]['stored_filename']."'"); + + // ----- Store the index + $v_header_list[$v_nb_extracted]['index'] = $i; + + // ----- Look for the specific extract rules + $v_found = false; + + // ----- Look for extract by name rule + if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) + && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'"); + + // ----- Look if the filename is in the list + for ($j=0; ($j strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) + && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path"); + $v_found = true; + } + elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ + && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The entry is the searched directory"); + $v_found = true; + } + } + // ----- Look for a filename + elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one."); + $v_found = true; + } + } + } + + // ----- Look for extract by ereg rule + else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) + && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'"); + + if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); + $v_found = true; + } + } + + // ----- Look for extract by preg rule + else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) + && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'"); + + if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); + $v_found = true; + } + } + + // ----- Look for extract by index rule + else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) + && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'"); + + // ----- Look if the index is in the list + for ($j=$j_start; ($j=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range"); + $v_found = true; + } + if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop"); + $j_start = $j+1; + } + + if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop"); + break; + } + } + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "No argument mean remove all file"); + $v_found = true; + } + + // ----- Look for deletion + if ($v_found) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' need to be deleted"); + unset($v_header_list[$v_nb_extracted]); + } + else + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' will not be deleted"); + $v_nb_extracted++; + } + } + + // ----- Look if something need to be deleted + if ($v_nb_extracted > 0) { + + // ----- Creates a temporay file + $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; + + // ----- Creates a temporary zip archive + $v_temp_zip = new PclZip($v_zip_temp_name); + + // ----- Open the temporary zip file in write mode + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary write mode"); + if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) { + $this->privCloseFd(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Look which file need to be kept + for ($i=0; $izip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'"); + if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) { + // ----- Close the zip file + $this->privCloseFd(); + $v_temp_zip->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'"); + + // ----- Read the file header + $v_local_header = array(); + if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) { + // ----- Close the zip file + $this->privCloseFd(); + $v_temp_zip->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Check that local file header is same as central file header + if ($this->privCheckFileHeaders($v_local_header, + $v_header_list[$i]) != 1) { + // TBC + } + unset($v_local_header); + + // ----- Write the file header + if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) { + // ----- Close the zip file + $this->privCloseFd(); + $v_temp_zip->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset for this file is '".$v_header_list[$i]['offset']."'"); + + // ----- Read/write the data block + if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) { + // ----- Close the zip file + $this->privCloseFd(); + $v_temp_zip->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + } + + // ----- Store the offset of the central dir + $v_offset = @ftell($v_temp_zip->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "New offset of central dir : $v_offset"); + + // ----- Re-Create the Central Dir files header + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the new central directory"); + for ($i=0; $iprivWriteCentralFileHeader($v_header_list[$i])) != 1) { + $v_temp_zip->privCloseFd(); + $this->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Transform the header to a 'usable' info + $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the central directory footer"); + + // ----- Zip file comment + $v_comment = ''; + if (isset($p_options[PCLZIP_OPT_COMMENT])) { + $v_comment = $p_options[PCLZIP_OPT_COMMENT]; + } + + // ----- Calculate the size of the central header + $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset; + + // ----- Create the central dir footer + if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) { + // ----- Reset the file list + unset($v_header_list); + $v_temp_zip->privCloseFd(); + $this->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Close + $v_temp_zip->privCloseFd(); + $this->privCloseFd(); + + // ----- Delete the zip file + // TBC : I should test the result ... + @unlink($this->zipname); + + // ----- Rename the temporary file + // TBC : I should test the result ... + //@rename($v_zip_temp_name, $this->zipname); + PclZipUtilRename($v_zip_temp_name, $this->zipname); + + // ----- Destroy the temporary archive + unset($v_temp_zip); + } + + // ----- Remove every files : reset the file + else if ($v_central_dir['entries'] != 0) { + $this->privCloseFd(); + + if (($v_result = $this->privOpenFd('wb')) != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + $this->privCloseFd(); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privDirCheck() + // Description : + // Check if a directory exists, if not it creates it and all the parents directory + // which may be useful. + // Parameters : + // $p_dir : Directory path to check. + // Return Values : + // 1 : OK + // -1 : Unable to create directory + // -------------------------------------------------------------------------------- + function privDirCheck($p_dir, $p_is_dir=false) + { + $v_result = 1; + + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDirCheck", "entry='$p_dir', is_dir='".($p_is_dir?"true":"false")."'"); + + // ----- Remove the final '/' + if (($p_is_dir) && (substr($p_dir, -1)=='/')) + { + $p_dir = substr($p_dir, 0, strlen($p_dir)-1); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Looking for entry '$p_dir'"); + + // ----- Check the directory availability + if ((is_dir($p_dir)) || ($p_dir == "")) + { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, "'$p_dir' is a directory"); + return 1; + } + + // ----- Extract parent directory + $p_parent_dir = dirname($p_dir); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Parent directory is '$p_parent_dir'"); + + // ----- Just a check + if ($p_parent_dir != $p_dir) + { + // ----- Look for parent directory + if ($p_parent_dir != "") + { + if (($v_result = $this->privDirCheck($p_parent_dir)) != 1) + { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + } + } + + // ----- Create the directory + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Create directory '$p_dir'"); + if (!@mkdir($p_dir, 0777)) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result, "Directory '$p_dir' created"); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privMerge() + // Description : + // If $p_archive_to_add does not exist, the function exit with a success result. + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privMerge(&$p_archive_to_add) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privMerge", "archive='".$p_archive_to_add->zipname."'"); + $v_result=1; + + // ----- Look if the archive_to_add exists + if (!is_file($p_archive_to_add->zipname)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to add does not exist. End of merge."); + + // ----- Nothing to merge, so merge is a success + $v_result = 1; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Look if the archive exists + if (!is_file($this->zipname)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, duplicate the archive_to_add."); + + // ----- Do a duplicate + $v_result = $this->privDuplicate($p_archive_to_add->zipname); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_result=$this->privOpenFd('rb')) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + $this->privCloseFd(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Go to beginning of File + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'"); + + // ----- Open the archive_to_add file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open archive_to_add in binary read mode"); + if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1) + { + $this->privCloseFd(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Read the central directory informations + $v_central_dir_to_add = array(); + if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1) + { + $this->privCloseFd(); + $p_archive_to_add->privCloseFd(); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Go to beginning of File + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'"); + @rewind($p_archive_to_add->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'"); + + // ----- Creates a temporay file + $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; + + // ----- Open the temporary file in write mode + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) + { + $this->privCloseFd(); + $p_archive_to_add->privCloseFd(); + + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Copy the files from the archive to the temporary file + // TBC : Here I should better append the file and go back to erase the central dir + $v_size = $v_central_dir['offset']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = fread($this->zip_fd, $v_read_size); + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Copy the files from the archive_to_add into the temporary file + $v_size = $v_central_dir_to_add['offset']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size); + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Store the offset of the central dir + $v_offset = @ftell($v_zip_temp_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset"); + + // ----- Copy the block of file headers from the old archive + $v_size = $v_central_dir['size']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = @fread($this->zip_fd, $v_read_size); + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Copy the block of file headers from the archive_to_add + $v_size = $v_central_dir_to_add['size']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size); + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Merge the file comments + $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment']; + + // ----- Calculate the size of the (new) central header + $v_size = @ftell($v_zip_temp_fd)-$v_offset; + + // ----- Swap the file descriptor + // Here is a trick : I swap the temporary fd with the zip fd, in order to use + // the following methods on the temporary fil and not the real archive fd + $v_swap = $this->zip_fd; + $this->zip_fd = $v_zip_temp_fd; + $v_zip_temp_fd = $v_swap; + + // ----- Create the central dir footer + if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1) + { + $this->privCloseFd(); + $p_archive_to_add->privCloseFd(); + @fclose($v_zip_temp_fd); + $this->zip_fd = null; + + // ----- Reset the file list + unset($v_header_list); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Swap back the file descriptor + $v_swap = $this->zip_fd; + $this->zip_fd = $v_zip_temp_fd; + $v_zip_temp_fd = $v_swap; + + // ----- Close + $this->privCloseFd(); + $p_archive_to_add->privCloseFd(); + + // ----- Close the temporary file + @fclose($v_zip_temp_fd); + + // ----- Delete the zip file + // TBC : I should test the result ... + @unlink($this->zipname); + + // ----- Rename the temporary file + // TBC : I should test the result ... + //@rename($v_zip_temp_name, $this->zipname); + PclZipUtilRename($v_zip_temp_name, $this->zipname); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privDuplicate() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privDuplicate($p_archive_filename) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDuplicate", "archive_filename='$p_archive_filename'"); + $v_result=1; + + // ----- Look if the $p_archive_filename exists + if (!is_file($p_archive_filename)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to duplicate does not exist. End of duplicate."); + + // ----- Nothing to duplicate, so duplicate is a success. + $v_result = 1; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_result=$this->privOpenFd('wb')) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Open the temporary file in write mode + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0) + { + $this->privCloseFd(); + + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Copy the files from the archive to the temporary file + // TBC : Here I should better append the file and go back to erase the central dir + $v_size = filesize($p_archive_filename); + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read $v_read_size bytes"); + $v_buffer = fread($v_zip_temp_fd, $v_read_size); + @fwrite($this->zip_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Close + $this->privCloseFd(); + + // ----- Close the temporary file + @fclose($v_zip_temp_fd); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privErrorLog() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function privErrorLog($p_error_code=0, $p_error_string='') + { + if (PCLZIP_ERROR_EXTERNAL == 1) { + PclError($p_error_code, $p_error_string); + } + else { + $this->error_code = $p_error_code; + $this->error_string = $p_error_string; + } + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privErrorReset() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function privErrorReset() + { + if (PCLZIP_ERROR_EXTERNAL == 1) { + PclErrorReset(); + } + else { + $this->error_code = 0; + $this->error_string = ''; + } + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privDecrypt() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privDecrypt($p_encryption_header, &$p_buffer, $p_size, $p_crc) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privDecrypt', "size=".$p_size.""); + $v_result=1; + + // ----- To Be Modified ;-) + $v_pwd = "test"; + + $p_buffer = PclZipUtilZipDecrypt($p_buffer, $p_size, $p_encryption_header, + $p_crc, $v_pwd); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privDisableMagicQuotes() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privDisableMagicQuotes() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privDisableMagicQuotes', ""); + $v_result=1; + + // ----- Look if function exists + if ( (!function_exists("get_magic_quotes_runtime")) + || (!function_exists("set_magic_quotes_runtime"))) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Functions *et_magic_quotes_runtime are not supported"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Look if already done + if ($this->magic_quotes_status != -1) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "magic_quote already disabled"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Get and memorize the magic_quote value + $this->magic_quotes_status = @get_magic_quotes_runtime(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Current magic_quotes_runtime status is '".($this->magic_quotes_status==0?'disable':'enable')."'"); + + // ----- Disable magic_quotes + if ($this->magic_quotes_status == 1) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Disable magic_quotes"); + @set_magic_quotes_runtime(0); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privSwapBackMagicQuotes() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privSwapBackMagicQuotes() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privSwapBackMagicQuotes', ""); + $v_result=1; + + // ----- Look if function exists + if ( (!function_exists("get_magic_quotes_runtime")) + || (!function_exists("set_magic_quotes_runtime"))) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Functions *et_magic_quotes_runtime are not supported"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Look if something to do + if ($this->magic_quotes_status != -1) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "magic_quote not modified"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Swap back magic_quotes + if ($this->magic_quotes_status == 1) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Enable back magic_quotes"); + @set_magic_quotes_runtime($this->magic_quotes_status); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + } + // End of class + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilPathReduction() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function PclZipUtilPathReduction($p_dir) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathReduction", "dir='$p_dir'"); + $v_result = ""; + + // ----- Look for not empty path + if ($p_dir != "") { + // ----- Explode path by directory names + $v_list = explode("/", $p_dir); + + // ----- Study directories from last to first + $v_skip = 0; + for ($i=sizeof($v_list)-1; $i>=0; $i--) { + // ----- Look for current path + if ($v_list[$i] == ".") { + // ----- Ignore this directory + // Should be the first $i=0, but no check is done + } + else if ($v_list[$i] == "..") { + $v_skip++; + } + else if ($v_list[$i] == "") { + // ----- First '/' i.e. root slash + if ($i == 0) { + $v_result = "/".$v_result; + if ($v_skip > 0) { + // ----- It is an invalid path, so the path is not modified + // TBC + $v_result = $p_dir; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid path is unchanged"); + $v_skip = 0; + } + } + // ----- Last '/' i.e. indicates a directory + else if ($i == (sizeof($v_list)-1)) { + $v_result = $v_list[$i]; + } + // ----- Double '/' inside the path + else { + // ----- Ignore only the double '//' in path, + // but not the first and last '/' + } + } + else { + // ----- Look for item to skip + if ($v_skip > 0) { + $v_skip--; + } + else { + $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); + } + } + } + + // ----- Look for skip + if ($v_skip > 0) { + while ($v_skip > 0) { + $v_result = '../'.$v_result; + $v_skip--; + } + } + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilPathInclusion() + // Description : + // This function indicates if the path $p_path is under the $p_dir tree. Or, + // said in an other way, if the file or sub-dir $p_path is inside the dir + // $p_dir. + // The function indicates also if the path is exactly the same as the dir. + // This function supports path with duplicated '/' like '//', but does not + // support '.' or '..' statements. + // Parameters : + // Return Values : + // 0 if $p_path is not inside directory $p_dir + // 1 if $p_path is inside directory $p_dir + // 2 if $p_path is exactly the same as $p_dir + // -------------------------------------------------------------------------------- + function PclZipUtilPathInclusion($p_dir, $p_path) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathInclusion", "dir='$p_dir', path='$p_path'"); + $v_result = 1; + + // ----- Look for path beginning by ./ + if ( ($p_dir == '.') + || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) { + $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Replacing ./ by full path in p_dir '".$p_dir."'"); + } + if ( ($p_path == '.') + || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) { + $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Replacing ./ by full path in p_path '".$p_path."'"); + } + + // ----- Explode dir and path by directory separator + $v_list_dir = explode("/", $p_dir); + $v_list_dir_size = sizeof($v_list_dir); + $v_list_path = explode("/", $p_path); + $v_list_path_size = sizeof($v_list_path); + + // ----- Study directories paths + $i = 0; + $j = 0; + while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Working on dir($i)='".$v_list_dir[$i]."' and path($j)='".$v_list_path[$j]."'"); + + // ----- Look for empty dir (path reduction) + if ($v_list_dir[$i] == '') { + $i++; + continue; + } + if ($v_list_path[$j] == '') { + $j++; + continue; + } + + // ----- Compare the items + if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Items ($i,$j) are different"); + $v_result = 0; + } + + // ----- Next items + $i++; + $j++; + } + + // ----- Look if everything seems to be the same + if ($v_result) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Look for tie break"); + // ----- Skip all the empty items + while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++; + while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Looking on dir($i)='".($i < $v_list_dir_size?$v_list_dir[$i]:'')."' and path($j)='".($j < $v_list_path_size?$v_list_path[$j]:'')."'"); + + if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) { + // ----- There are exactly the same + $v_result = 2; + } + else if ($i < $v_list_dir_size) { + // ----- The path is shorter than the dir + $v_result = 0; + } + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilCopyBlock() + // Description : + // Parameters : + // $p_mode : read/write compression mode + // 0 : src & dest normal + // 1 : src gzip, dest normal + // 2 : src normal, dest gzip + // 3 : src & dest gzip + // Return Values : + // -------------------------------------------------------------------------------- + function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilCopyBlock", "size=$p_size, mode=$p_mode"); + $v_result = 1; + + if ($p_mode==0) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset before read :".(@ftell($p_src))); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset before write :".(@ftell($p_dest))); + while ($p_size != 0) + { + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = @fread($p_src, $v_read_size); + @fwrite($p_dest, $v_buffer, $v_read_size); + $p_size -= $v_read_size; + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset after read :".(@ftell($p_src))); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset after write :".(@ftell($p_dest))); + } + else if ($p_mode==1) + { + while ($p_size != 0) + { + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = @gzread($p_src, $v_read_size); + @fwrite($p_dest, $v_buffer, $v_read_size); + $p_size -= $v_read_size; + } + } + else if ($p_mode==2) + { + while ($p_size != 0) + { + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = @fread($p_src, $v_read_size); + @gzwrite($p_dest, $v_buffer, $v_read_size); + $p_size -= $v_read_size; + } + } + else if ($p_mode==3) + { + while ($p_size != 0) + { + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = @gzread($p_src, $v_read_size); + @gzwrite($p_dest, $v_buffer, $v_read_size); + $p_size -= $v_read_size; + } + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilRename() + // Description : + // This function tries to do a simple rename() function. If it fails, it + // tries to copy the $p_src file in a new $p_dest file and then unlink the + // first one. + // Parameters : + // $p_src : Old filename + // $p_dest : New filename + // Return Values : + // 1 on success, 0 on failure. + // -------------------------------------------------------------------------------- + function PclZipUtilRename($p_src, $p_dest) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilRename", "source=$p_src, destination=$p_dest"); + $v_result = 1; + + // ----- Try to rename the files + if (!@rename($p_src, $p_dest)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to rename file, try copy+unlink"); + + // ----- Try to copy & unlink the src + if (!@copy($p_src, $p_dest)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to copy file"); + $v_result = 0; + } + else if (!@unlink($p_src)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to unlink old filename"); + $v_result = 0; + } + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilOptionText() + // Description : + // Translate option value in text. Mainly for debug purpose. + // Parameters : + // $p_option : the option value. + // Return Values : + // The option text value. + // -------------------------------------------------------------------------------- + function PclZipUtilOptionText($p_option) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilOptionText", "option='".$p_option."'"); + + $v_list = get_defined_constants(); + for (reset($v_list); $v_key = key($v_list); next($v_list)) { + $v_prefix = substr($v_key, 0, 10); + if (( ($v_prefix == 'PCLZIP_OPT') + || ($v_prefix == 'PCLZIP_CB_') + || ($v_prefix == 'PCLZIP_ATT')) + && ($v_list[$v_key] == $p_option)) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_key); + return $v_key; + } + } + + $v_result = 'Unknown'; + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilTranslateWinPath() + // Description : + // Translate windows path by replacing '\' by '/' and optionally removing + // drive letter. + // Parameters : + // $p_path : path to translate. + // $p_remove_disk_letter : true | false + // Return Values : + // The path translated. + // -------------------------------------------------------------------------------- + function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true) + { + if (stristr(php_uname(), 'windows')) { + // ----- Look for potential disk letter + if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) { + $p_path = substr($p_path, $v_position+1); + } + // ----- Change potential windows directory separator + if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { + $p_path = strtr($p_path, '\\', '/'); + } + } + return $p_path; + } + // -------------------------------------------------------------------------------- + + +?> diff -uNr a/blog/wp-admin/includes/class-wp-filesystem-base.php b/blog/wp-admin/includes/class-wp-filesystem-base.php --- a/blog/wp-admin/includes/class-wp-filesystem-base.php false +++ b/blog/wp-admin/includes/class-wp-filesystem-base.php 33f809c6452a0b78cb6a58e88f5c45da01062347bfd659a83e2152863440fab530e4d8944201c0112c2622a572c7181bce963eccf04bbf48a30c58dc8437cbcf @@ -0,0 +1,316 @@ +method, 'ftp') !== false ) + return FTP_BASE; + $folder = $this->find_folder(ABSPATH); + //Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare. + if ( ! $folder && $this->is_dir('/wp-includes') ) + $folder = '/'; + return $folder; + } + /** + * Returns the path on the remote filesystem of WP_CONTENT_DIR + * + * @since 2.7 + * @access public + * @return string The location of the remote path. + */ + function wp_content_dir() { + if ( defined('FTP_CONTENT_DIR') && strpos($this->method, 'ftp') !== false ) + return FTP_CONTENT_DIR; + return $this->find_folder(WP_CONTENT_DIR); + } + /** + * Returns the path on the remote filesystem of WP_PLUGIN_DIR + * + * @since 2.7 + * @access public + * + * @return string The location of the remote path. + */ + function wp_plugins_dir() { + if ( defined('FTP_PLUGIN_DIR') && strpos($this->method, 'ftp') !== false ) + return FTP_PLUGIN_DIR; + return $this->find_folder(WP_PLUGIN_DIR); + } + /** + * Returns the path on the remote filesystem of the Themes Directory + * + * @since 2.7 + * @access public + * + * @return string The location of the remote path. + */ + function wp_themes_dir() { + return $this->wp_content_dir() . '/themes'; + } + + /** + * Locates a folder on the remote filesystem. + * + * Deprecated; use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() methods instead. + * + * @since 2.5 + * @deprecated 2.7 + * @access public + * + * @param string $base The folder to start searching from + * @param bool $echo True to display debug information + * @return string The location of the remote path. + */ + function find_base_dir($base = '.', $echo = false) { + _deprecated_function(__FUNCTION__, '2.7', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' ); + $this->verbose = $echo; + return $this->abspath(); + } + /** + * Locates a folder on the remote filesystem. + * + * Deprecated; use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() methods instead. + * + * @since 2.5 + * @deprecated 2.7 + * @access public + * + * @param string $base The folder to start searching from + * @param bool $echo True to display debug information + * @return string The location of the remote path. + */ + function get_base_dir($base = '.', $echo = false) { + _deprecated_function(__FUNCTION__, '2.7', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' ); + $this->verbose = $echo; + return $this->abspath(); + } + + /** + * Locates a folder on the remote filesystem. + * + * Assumes that on Windows systems, Stripping off the Drive letter is OK + * Sanitizes \\ to / in windows filepaths. + * + * @since 2.7 + * @access public + * + * @param string $folder the folder to locate + * @return string The location of the remote path. + */ + function find_folder($folder) { + + $folder = preg_replace('|^([a-z]{1}):|i', '', $folder); //Strip out windows driveletter if its there. + $folder = str_replace('\\', '/', $folder); //Windows path sanitiation + + if ( isset($this->cache[ $folder ] ) ) + return $this->cache[ $folder ]; + + if ( $this->exists($folder) ) { //Folder exists at that absolute path. + $this->cache[ $folder ] = $folder; + return $folder; + } + if( $return = $this->search_for_folder($folder) ) + $this->cache[ $folder ] = $return; + return $return; + } + + /** + * Locates a folder on the remote filesystem. + * + * Expects Windows sanitized path + * + * @since 2.7 + * @access private + * + * @param string $folder the folder to locate + * @param string $base the folder to start searching from + * @param bool $loop if the function has recursed, Internal use only + * @return string The location of the remote path. + */ + function search_for_folder($folder, $base = '.', $loop = false ) { + if ( empty( $base ) || '.' == $base ) + $base = trailingslashit($this->cwd()); + + $folder = untrailingslashit($folder); + + $folder_parts = explode('/', $folder); + $last_path = $folder_parts[ count($folder_parts) - 1 ]; + + $files = $this->dirlist( $base ); + + foreach ( $folder_parts as $key ) { + if ( $key == $last_path ) + continue; //We want this to be caught by the next code block. + + //Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder, + // If its found, change into it and follow through looking for it. + // If it cant find WordPress down that route, it'll continue onto the next folder level, and see if that matches, and so on. + // If it reaches the end, and still cant find it, it'll return false for the entire function. + if( isset($files[ $key ]) ){ + //Lets try that folder: + $newdir = trailingslashit(path_join($base, $key)); + if( $this->verbose ) + printf( __('Changing to %s') . '
    ', $newdir ); + if( $ret = $this->search_for_folder( $folder, $newdir, $loop) ) + return $ret; + } + } + + //Only check this as a last resort, to prevent locating the incorrect install. All above proceeedures will fail quickly if this is the right branch to take. + if(isset( $files[ $last_path ] ) ) { + if( $this->verbose ) + printf( __('Found %s') . '
    ', $base . $last_path ); + return $base . $last_path; + } + if( $loop ) + return false;//Prevent tihs function looping again. + //As an extra last resort, Change back to / if the folder wasnt found. This comes into effect when the CWD is /home/user/ but WP is at /var/www/.... mainly dedicated setups. + return $this->search_for_folder($folder, '/', true); + + } + + /** + * Returns the *nix style file permissions for a file + * + * From the PHP documentation page for fileperms() + * + * @link http://docs.php.net/fileperms + * @since 2.5 + * @access public + * + * @param string $file string filename + * @return int octal representation of permissions + */ + function gethchmod($file){ + $perms = $this->getchmod($file); + if (($perms & 0xC000) == 0xC000) // Socket + $info = 's'; + elseif (($perms & 0xA000) == 0xA000) // Symbolic Link + $info = 'l'; + elseif (($perms & 0x8000) == 0x8000) // Regular + $info = '-'; + elseif (($perms & 0x6000) == 0x6000) // Block special + $info = 'b'; + elseif (($perms & 0x4000) == 0x4000) // Directory + $info = 'd'; + elseif (($perms & 0x2000) == 0x2000) // Character special + $info = 'c'; + elseif (($perms & 0x1000) == 0x1000)// FIFO pipe + $info = 'p'; + else // Unknown + $info = 'u'; + + // Owner + $info .= (($perms & 0x0100) ? 'r' : '-'); + $info .= (($perms & 0x0080) ? 'w' : '-'); + $info .= (($perms & 0x0040) ? + (($perms & 0x0800) ? 's' : 'x' ) : + (($perms & 0x0800) ? 'S' : '-')); + + // Group + $info .= (($perms & 0x0020) ? 'r' : '-'); + $info .= (($perms & 0x0010) ? 'w' : '-'); + $info .= (($perms & 0x0008) ? + (($perms & 0x0400) ? 's' : 'x' ) : + (($perms & 0x0400) ? 'S' : '-')); + + // World + $info .= (($perms & 0x0004) ? 'r' : '-'); + $info .= (($perms & 0x0002) ? 'w' : '-'); + $info .= (($perms & 0x0001) ? + (($perms & 0x0200) ? 't' : 'x' ) : + (($perms & 0x0200) ? 'T' : '-')); + return $info; + } + + /** + * Converts *nix style file permissions to a octal number. + * + * Converts '-rw-r--r--' to 0644 + * From "info at rvgate dot nl"'s comment on the PHP documentation for chmod() + * + * @link http://docs.php.net/manual/en/function.chmod.php#49614 + * @since 2.5 + * @access public + * + * @param string $mode string *nix style file permission + * @return int octal representation + */ + function getnumchmodfromh($mode) { + $realmode = ''; + $legal = array('', 'w', 'r', 'x', '-'); + $attarray = preg_split('//', $mode); + + for($i=0; $i < count($attarray); $i++) + if($key = array_search($attarray[$i], $legal)) + $realmode .= $legal[$key]; + + $mode = str_pad($realmode, 9, '-'); + $trans = array('-'=>'0', 'r'=>'4', 'w'=>'2', 'x'=>'1'); + $mode = strtr($mode,$trans); + + $newmode = ''; + $newmode .= $mode[0] + $mode[1] + $mode[2]; + $newmode .= $mode[3] + $mode[4] + $mode[5]; + $newmode .= $mode[6] + $mode[7] + $mode[8]; + return $newmode; + } + + /** + * Determines if the string provided contains binary characters. + * + * @since 2.7 + * @access private + * + * @param string $text String to test against + * @return bool true if string is binary, false otherwise + */ + function is_binary( $text ) { + return (bool) preg_match('|[^\x20-\x7E]|', $text); //chr(32)..chr(127) + } +} + +?> diff -uNr a/blog/wp-admin/includes/class-wp-filesystem-direct.php b/blog/wp-admin/includes/class-wp-filesystem-direct.php --- a/blog/wp-admin/includes/class-wp-filesystem-direct.php false +++ b/blog/wp-admin/includes/class-wp-filesystem-direct.php 2b6cd5b1499b58706b2efcfa76e1b7977e1dcecb5fc1c8da5c69bf5336117f8a55b38af5bc5c5c744fcbe0d196440318ca6a8483f5ad0d42f098ba84b784b24d @@ -0,0 +1,274 @@ +method = 'direct'; + $this->errors = new WP_Error(); + $this->permission = umask(); + } + function connect() { + return true; + } + function setDefaultPermissions($perm) { + $this->permission = $perm; + } + function get_contents($file) { + return @file_get_contents($file); + } + function get_contents_array($file) { + return @file($file); + } + function put_contents($file, $contents, $mode = false, $type = '') { + if ( ! ($fp = @fopen($file, 'w' . $type)) ) + return false; + @fwrite($fp, $contents); + @fclose($fp); + $this->chmod($file,$mode); + return true; + } + function cwd() { + return @getcwd(); + } + function chdir($dir) { + return @chdir($dir); + } + function chgrp($file, $group, $recursive = false) { + if( ! $this->exists($file) ) + return false; + if( ! $recursive ) + return @chgrp($file, $group); + if( ! $this->is_dir($file) ) + return @chgrp($file, $group); + //Is a directory, and we want recursive + $file = trailingslashit($file); + $filelist = $this->dirlist($file); + foreach($filelist as $filename) + $this->chgrp($file . $filename, $group, $recursive); + + return true; + } + function chmod($file, $mode = false, $recursive = false) { + if( ! $mode ) + $mode = $this->permission; + if( ! $this->exists($file) ) + return false; + if( ! $recursive ) + return @chmod($file,$mode); + if( ! $this->is_dir($file) ) + return @chmod($file, $mode); + //Is a directory, and we want recursive + $file = trailingslashit($file); + $filelist = $this->dirlist($file); + foreach($filelist as $filename) + $this->chmod($file . $filename, $mode, $recursive); + + return true; + } + function chown($file, $owner, $recursive = false) { + if( ! $this->exists($file) ) + return false; + if( ! $recursive ) + return @chown($file, $owner); + if( ! $this->is_dir($file) ) + return @chown($file, $owner); + //Is a directory, and we want recursive + $filelist = $this->dirlist($file); + foreach($filelist as $filename){ + $this->chown($file . '/' . $filename, $owner, $recursive); + } + return true; + } + function owner($file) { + $owneruid = @fileowner($file); + if( ! $owneruid ) + return false; + if( ! function_exists('posix_getpwuid') ) + return $owneruid; + $ownerarray = posix_getpwuid($owneruid); + return $ownerarray['name']; + } + function getchmod($file) { + return @fileperms($file); + } + function group($file) { + $gid = @filegroup($file); + if( ! $gid ) + return false; + if( ! function_exists('posix_getgrgid') ) + return $gid; + $grouparray = posix_getgrgid($gid); + return $grouparray['name']; + } + + function copy($source, $destination, $overwrite = false) { + if( ! $overwrite && $this->exists($destination) ) + return false; + return copy($source, $destination); + } + + function move($source, $destination, $overwrite = false) { + //Possible to use rename()? + if( $this->copy($source, $destination, $overwrite) && $this->exists($destination) ){ + $this->delete($source); + return true; + } else { + return false; + } + } + + function delete($file, $recursive = false) { + $file = str_replace('\\', '/', $file); //for win32, occasional problems deleteing files otherwise + + if( $this->is_file($file) ) + return @unlink($file); + if( ! $recursive && $this->is_dir($file) ) + return @rmdir($file); + + //At this point its a folder, and we're in recursive mode + $file = trailingslashit($file); + $filelist = $this->dirlist($file, true); + + $retval = true; + if( is_array($filelist) ) //false if no files, So check first. + foreach($filelist as $filename => $fileinfo) + if( ! $this->delete($file . $filename, $recursive) ) + $retval = false; + + if( ! @rmdir($file) ) + return false; + return $retval; + } + + function exists($file) { + return @file_exists($file); + } + + function is_file($file) { + return @is_file($file); + } + + function is_dir($path) { + return @is_dir($path); + } + + function is_readable($file) { + return @is_readable($file); + } + + function is_writable($file) { + return @is_writable($file); + } + + function atime($file) { + return @fileatime($file); + } + + function mtime($file) { + return @filemtime($file); + } + function size($file) { + return @filesize($file); + } + + function touch($file, $time = 0, $atime = 0){ + if($time == 0) + $time = time(); + if($atime == 0) + $atime = time(); + return @touch($file, $time, $atime); + } + + function mkdir($path, $chmod = false, $chown = false, $chgrp = false){ + if( ! $chmod) + $chmod = $this->permission; + + if( ! @mkdir($path, $chmod) ) + return false; + if( $chown ) + $this->chown($path, $chown); + if( $chgrp ) + $this->chgrp($path, $chgrp); + return true; + } + + function rmdir($path, $recursive = false) { + //Currently unused and untested, Use delete() instead. + if( ! $recursive ) + return @rmdir($path); + //recursive: + $filelist = $this->dirlist($path); + foreach($filelist as $filename => $det) { + if ( '/' == substr($filename, -1, 1) ) + $this->rmdir($path . '/' . $filename, $recursive); + @rmdir($filename); + } + return @rmdir($path); + } + + function dirlist($path, $incdot = false, $recursive = false) { + if( $this->is_file($path) ) { + $limitFile = basename($path); + $path = dirname($path); + } else { + $limitFile = false; + } + if( ! $this->is_dir($path) ) + return false; + + $ret = array(); + $dir = @dir($path); + if ( ! $dir ) + return false; + while (false !== ($entry = $dir->read()) ) { + $struc = array(); + $struc['name'] = $entry; + + if( '.' == $struc['name'] || '..' == $struc['name'] ) + continue; //Do not care about these folders. + if( '.' == $struc['name'][0] && !$incdot) + continue; + if( $limitFile && $struc['name'] != $limitFile) + continue; + + $struc['perms'] = $this->gethchmod($path.'/'.$entry); + $struc['permsn'] = $this->getnumchmodfromh($struc['perms']); + $struc['number'] = false; + $struc['owner'] = $this->owner($path.'/'.$entry); + $struc['group'] = $this->group($path.'/'.$entry); + $struc['size'] = $this->size($path.'/'.$entry); + $struc['lastmodunix']= $this->mtime($path.'/'.$entry); + $struc['lastmod'] = date('M j',$struc['lastmodunix']); + $struc['time'] = date('h:i:s',$struc['lastmodunix']); + $struc['type'] = $this->is_dir($path.'/'.$entry) ? 'd' : 'f'; + + if ( 'd' == $struc['type'] ) { + if( $recursive ) + $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $incdot, $recursive); + else + $struc['files'] = array(); + } + + $ret[ $struc['name'] ] = $struc; + } + $dir->close(); + unset($dir); + return $ret; + } +} +?> diff -uNr a/blog/wp-admin/includes/class-wp-filesystem-ftpext.php b/blog/wp-admin/includes/class-wp-filesystem-ftpext.php --- a/blog/wp-admin/includes/class-wp-filesystem-ftpext.php false +++ b/blog/wp-admin/includes/class-wp-filesystem-ftpext.php 131fd2ceca1e6fb1420a5c8cf11c7d7571c2b016c7549110b2013348dc1be1ac6cb883eb9bcbecf44ba39ac94700431b83b788f46d2669373115ca43856ae1fe @@ -0,0 +1,382 @@ +method = 'ftpext'; + $this->errors = new WP_Error(); + + //Check if possible to use ftp functions. + if ( ! extension_loaded('ftp') ) { + $this->errors->add('no_ftp_ext', __('The ftp PHP extension is not available')); + return false; + } + + // Set defaults: + if ( empty($opt['port']) ) + $this->options['port'] = 21; + else + $this->options['port'] = $opt['port']; + + if ( empty($opt['hostname']) ) + $this->errors->add('empty_hostname', __('FTP hostname is required')); + else + $this->options['hostname'] = $opt['hostname']; + + if ( isset($opt['base']) && ! empty($opt['base']) ) + $this->wp_base = $opt['base']; + + // Check if the options provided are OK. + if ( empty ($opt['username']) ) + $this->errors->add('empty_username', __('FTP username is required')); + else + $this->options['username'] = $opt['username']; + + if ( empty ($opt['password']) ) + $this->errors->add('empty_password', __('FTP password is required')); + else + $this->options['password'] = $opt['password']; + + $this->options['ssl'] = false; + if ( isset($opt['ssl']) ) + $this->options['ssl'] = ( !empty($opt['ssl']) ); + elseif ( isset( $opt['connection_type']) ) + $this->options['ssl'] = ( 'ftps' == $opt['connection_type'] ); + } + + function connect() { + if ( $this->options['ssl'] && function_exists('ftp_ssl_connect') ) + $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'],$this->timeout); + else + $this->link = @ftp_connect($this->options['hostname'], $this->options['port'],$this->timeout); + + if ( ! $this->link ) { + $this->errors->add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this->options['hostname'], $this->options['port'])); + return false; + } + + if ( ! @ftp_login($this->link,$this->options['username'], $this->options['password']) ) { + $this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username'])); + return false; + } + + //Set the Connection to use Passive FTP + @ftp_pasv( $this->link, true ); + + return true; + } + + function setDefaultPermissions($perm) { + $this->permission = $perm; + } + + function get_contents($file, $type = '', $resumepos = 0 ){ + if( empty($type) ) + $type = FTP_BINARY; + + $temp = tmpfile(); + if ( ! $temp ) + return false; + + if( ! @ftp_fget($this->link, $temp, $file, $type, $resumepos) ) + return false; + + fseek($temp, 0); //Skip back to the start of the file being written to + $contents = ''; + + while ( ! feof($temp) ) + $contents .= fread($temp, 8192); + + fclose($temp); + return $contents; + } + function get_contents_array($file) { + return explode("\n", $this->get_contents($file)); + } + function put_contents($file, $contents, $type = '' ) { + if( empty($type) ) + $type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII; + + $temp = tmpfile(); + if ( ! $temp ) + return false; + + fwrite($temp, $contents); + fseek($temp, 0); //Skip back to the start of the file being written to + + $ret = @ftp_fput($this->link, $file, $temp, $type); + + fclose($temp); + return $ret; + } + function cwd() { + $cwd = @ftp_pwd($this->link); + if( $cwd ) + $cwd = trailingslashit($cwd); + return $cwd; + } + function chdir($dir) { + return @ftp_chdir($dir); + } + function chgrp($file, $group, $recursive = false ) { + return false; + } + function chmod($file, $mode = false, $recursive = false) { + if( ! $mode ) + $mode = $this->permission; + if( ! $mode ) + return false; + if ( ! $this->exists($file) ) + return false; + if ( ! $recursive || ! $this->is_dir($file) ) { + if ( ! function_exists('ftp_chmod') ) + return @ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file)); + return @ftp_chmod($this->link, $mode, $file); + } + //Is a directory, and we want recursive + $filelist = $this->dirlist($file); + foreach($filelist as $filename){ + $this->chmod($file . '/' . $filename, $mode, $recursive); + } + return true; + } + function chown($file, $owner, $recursive = false ) { + return false; + } + function owner($file) { + $dir = $this->dirlist($file); + return $dir[$file]['owner']; + } + function getchmod($file) { + $dir = $this->dirlist($file); + return $dir[$file]['permsn']; + } + function group($file) { + $dir = $this->dirlist($file); + return $dir[$file]['group']; + } + function copy($source, $destination, $overwrite = false ) { + if( ! $overwrite && $this->exists($destination) ) + return false; + $content = $this->get_contents($source); + if( false === $content) + return false; + return $this->put_contents($destination, $content); + } + function move($source, $destination, $overwrite = false) { + return ftp_rename($this->link, $source, $destination); + } + + function delete($file,$recursive=false) { + if ( $this->is_file($file) ) + return @ftp_delete($this->link, $file); + if ( !$recursive ) + return @ftp_rmdir($this->link, $file); + $filelist = $this->dirlist($file); + foreach ((array) $filelist as $filename => $fileinfo) { + $this->delete($file . '/' . $filename, $recursive); + } + return @ftp_rmdir($this->link, $file); + } + + function exists($file) { + $list = ftp_rawlist($this->link, $file, false); + if( ! $list ) + return false; + return count($list) == 1 ? true : false; + } + function is_file($file) { + return $this->is_dir($file) ? false : true; + } + function is_dir($path) { + $cwd = $this->cwd(); + $result = @ftp_chdir($this->link, $path); + if( $result && $path == $this->cwd() || $this->cwd() != $cwd ) { + @ftp_chdir($this->link, $cwd); + return true; + } + return false; + } + function is_readable($file) { + //Get dir list, Check if the file is writable by the current user?? + return true; + } + function is_writable($file) { + //Get dir list, Check if the file is writable by the current user?? + return true; + } + function atime($file) { + return false; + } + function mtime($file) { + return ftp_mdtm($this->link, $file); + } + function size($file) { + return ftp_size($this->link, $file); + } + function touch($file, $time = 0, $atime = 0) { + return false; + } + function mkdir($path, $chmod = false, $chown = false, $chgrp = false) { + if( !@ftp_mkdir($this->link, $path) ) + return false; + if( $chmod ) + $this->chmod($path, $chmod); + if( $chown ) + $this->chown($path, $chown); + if( $chgrp ) + $this->chgrp($path, $chgrp); + return true; + } + function rmdir($path, $recursive = false) { + if( ! $recursive ) + return @ftp_rmdir($this->link, $path); + + //TODO: Recursive Directory delete, Have to delete files from the folder first. + //$dir = $this->dirlist($path); + //foreach($dir as $file) + + } + + function parselisting($line) { + $is_windows = ($this->OS_remote == FTP_OS_Windows); + if ($is_windows && preg_match("/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|) +(.+)/", $line, $lucifer)) { + $b = array(); + if ($lucifer[3]<70) { $lucifer[3] +=2000; } else { $lucifer[3]+=1900; } // 4digit year fix + $b['isdir'] = ($lucifer[7]==""); + if ( $b['isdir'] ) + $b['type'] = 'd'; + else + $b['type'] = 'f'; + $b['size'] = $lucifer[7]; + $b['month'] = $lucifer[1]; + $b['day'] = $lucifer[2]; + $b['year'] = $lucifer[3]; + $b['hour'] = $lucifer[4]; + $b['minute'] = $lucifer[5]; + $b['time'] = @mktime($lucifer[4]+(strcasecmp($lucifer[6],"PM")==0?12:0),$lucifer[5],0,$lucifer[1],$lucifer[2],$lucifer[3]); + $b['am/pm'] = $lucifer[6]; + $b['name'] = $lucifer[8]; + } else if (!$is_windows && $lucifer=preg_split("/[ ]/",$line,9,PREG_SPLIT_NO_EMPTY)) { + //echo $line."\n"; + $lcount=count($lucifer); + if ($lcount<8) return ''; + $b = array(); + $b['isdir'] = $lucifer[0]{0} === "d"; + $b['islink'] = $lucifer[0]{0} === "l"; + if ( $b['isdir'] ) + $b['type'] = 'd'; + elseif ( $b['islink'] ) + $b['type'] = 'l'; + else + $b['type'] = 'f'; + $b['perms'] = $lucifer[0]; + $b['number'] = $lucifer[1]; + $b['owner'] = $lucifer[2]; + $b['group'] = $lucifer[3]; + $b['size'] = $lucifer[4]; + if ($lcount==8) { + sscanf($lucifer[5],"%d-%d-%d",$b['year'],$b['month'],$b['day']); + sscanf($lucifer[6],"%d:%d",$b['hour'],$b['minute']); + $b['time'] = @mktime($b['hour'],$b['minute'],0,$b['month'],$b['day'],$b['year']); + $b['name'] = $lucifer[7]; + } else { + $b['month'] = $lucifer[5]; + $b['day'] = $lucifer[6]; + if (preg_match("/([0-9]{2}):([0-9]{2})/",$lucifer[7],$l2)) { + $b['year'] = date("Y"); + $b['hour'] = $l2[1]; + $b['minute'] = $l2[2]; + } else { + $b['year'] = $lucifer[7]; + $b['hour'] = 0; + $b['minute'] = 0; + } + $b['time'] = strtotime(sprintf("%d %s %d %02d:%02d",$b['day'],$b['month'],$b['year'],$b['hour'],$b['minute'])); + $b['name'] = $lucifer[8]; + } + } + + return $b; + } + + function dirlist($path = '.', $incdot = false, $recursive = false) { + if( $this->is_file($path) ) { + $limitFile = basename($path); + $path = dirname($path) . '/'; + } else { + $limitFile = false; + } + + $list = @ftp_rawlist($this->link, '-a ' . $path, false); + + if ( $list === false ) + return false; + + $dirlist = array(); + foreach ( $list as $k => $v ) { + $entry = $this->parselisting($v); + if ( empty($entry) ) + continue; + + if ( '.' == $entry["name"] || '..' == $entry["name"] ) + continue; + + $dirlist[ $entry['name'] ] = $entry; + } + + if ( ! $dirlist ) + return false; + if ( empty($dirlist) ) + return array(); + + $ret = array(); + foreach ( $dirlist as $struc ) { + + if ( 'd' == $struc['type'] ) { + $struc['files'] = array(); + + if ( $incdot ){ + //We're including the doted starts + if( '.' != $struc['name'] && '..' != $struc['name'] ){ //Ok, It isnt a special folder + if ($recursive) + $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $incdot, $recursive); + } + } else { //No dots + if ($recursive) + $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $incdot, $recursive); + } + } + //File + $ret[$struc['name']] = $struc; + } + return $ret; + } + + function __destruct(){ + if( $this->link ) + ftp_close($this->link); + } +} + +?> diff -uNr a/blog/wp-admin/includes/class-wp-filesystem-ftpsockets.php b/blog/wp-admin/includes/class-wp-filesystem-ftpsockets.php --- a/blog/wp-admin/includes/class-wp-filesystem-ftpsockets.php false +++ b/blog/wp-admin/includes/class-wp-filesystem-ftpsockets.php 35bb18818203340826cec4c87d1fd2fe18ed0540850dad5d75092ae044182a74322f684c95f0e61b54d682b6d6286009e742aea498d1d2be2afb61316d1dd2fb @@ -0,0 +1,325 @@ +method = 'ftpsockets'; + $this->errors = new WP_Error(); + + //Check if possible to use ftp functions. + if( ! @include_once ABSPATH . 'wp-admin/includes/class-ftp.php' ) + return false; + $this->ftp = new ftp(); + + //Set defaults: + if ( empty($opt['port']) ) + $this->options['port'] = 21; + else + $this->options['port'] = $opt['port']; + + if ( empty($opt['hostname']) ) + $this->errors->add('empty_hostname', __('FTP hostname is required')); + else + $this->options['hostname'] = $opt['hostname']; + + if ( isset($opt['base']) && ! empty($opt['base']) ) + $this->wp_base = $opt['base']; + + // Check if the options provided are OK. + if ( empty ($opt['username']) ) + $this->errors->add('empty_username', __('FTP username is required')); + else + $this->options['username'] = $opt['username']; + + if ( empty ($opt['password']) ) + $this->errors->add('empty_password', __('FTP password is required')); + else + $this->options['password'] = $opt['password']; + } + + function connect() { + if ( ! $this->ftp ) + return false; + + //$this->ftp->Verbose = true; + + if ( ! $this->ftp->SetServer($this->options['hostname'], $this->options['port']) ) { + $this->errors->add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this->options['hostname'], $this->options['port'])); + return false; + } + if ( ! $this->ftp->connect() ) { + $this->errors->add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this->options['hostname'], $this->options['port'])); + return false; + } + + if ( ! $this->ftp->login($this->options['username'], $this->options['password']) ) { + $this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username'])); + return false; + } + + $this->ftp->SetType(FTP_AUTOASCII); + $this->ftp->Passive(true); + return true; + } + + function setDefaultPermissions($perm) { + $this->permission = $perm; + } + + function get_contents($file, $type = '', $resumepos = 0) { + if( ! $this->exists($file) ) + return false; + + if( empty($type) ) + $type = FTP_AUTOASCII; + $this->ftp->SetType($type); + + $temp = wp_tempnam( $file ); + + if ( ! $temphandle = fopen($temp, 'w+') ) + return false; + + if ( ! $this->ftp->fget($temphandle, $file) ) { + fclose($temphandle); + unlink($temp); + return ''; //Blank document, File does exist, Its just blank. + } + + fseek($temphandle, 0); //Skip back to the start of the file being written to + $contents = ''; + + while ( ! feof($temphandle) ) + $contents .= fread($temphandle, 8192); + + fclose($temphandle); + unlink($temp); + return $contents; + } + + function get_contents_array($file) { + return explode("\n", $this->get_contents($file) ); + } + + function put_contents($file, $contents, $type = '' ) { + if( empty($type) ) + $type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII; + + $this->ftp->SetType($type); + + $temp = wp_tempnam( $file ); + if ( ! $temphandle = fopen($temp, 'w+') ){ + unlink($temp); + return false; + } + + fwrite($temphandle, $contents); + fseek($temphandle, 0); //Skip back to the start of the file being written to + + $ret = $this->ftp->fput($file, $temphandle); + + fclose($temphandle); + unlink($temp); + return $ret; + } + + function cwd() { + $cwd = $this->ftp->pwd(); + if( $cwd ) + $cwd = trailingslashit($cwd); + return $cwd; + } + + function chdir($file) { + return $this->ftp->chdir($file); + } + + function chgrp($file, $group, $recursive = false ) { + return false; + } + + function chmod($file, $mode = false, $recursive = false ) { + if( ! $mode ) + $mode = $this->permission; + if( ! $mode ) + return false; + //if( ! $this->exists($file) ) + // return false; + if( ! $recursive || ! $this->is_dir($file) ) { + return $this->ftp->chmod($file,$mode); + } + //Is a directory, and we want recursive + $filelist = $this->dirlist($file); + foreach($filelist as $filename){ + $this->chmod($file . '/' . $filename, $mode, $recursive); + } + return true; + } + + function chown($file, $owner, $recursive = false ) { + return false; + } + + function owner($file) { + $dir = $this->dirlist($file); + return $dir[$file]['owner']; + } + + function getchmod($file) { + $dir = $this->dirlist($file); + return $dir[$file]['permsn']; + } + + function group($file) { + $dir = $this->dirlist($file); + return $dir[$file]['group']; + } + + function copy($source, $destination, $overwrite = false ) { + if( ! $overwrite && $this->exists($destination) ) + return false; + + $content = $this->get_contents($source); + if ( false === $content ) + return false; + + return $this->put_contents($destination, $content); + } + + function move($source, $destination, $overwrite = false ) { + return $this->ftp->rename($source, $destination); + } + + function delete($file, $recursive = false ) { + if ( $this->is_file($file) ) + return $this->ftp->delete($file); + if ( !$recursive ) + return $this->ftp->rmdir($file); + + return $this->ftp->mdel($file); + } + + function exists($file) { + return $this->ftp->is_exists($file); + } + + function is_file($file) { + return $this->is_dir($file) ? false : true; + } + + function is_dir($path) { + $cwd = $this->cwd(); + if ( $this->chdir($path) ) { + $this->chdir($cwd); + return true; + } + return false; + } + + function is_readable($file) { + //Get dir list, Check if the file is writable by the current user?? + return true; + } + + function is_writable($file) { + //Get dir list, Check if the file is writable by the current user?? + return true; + } + + function atime($file) { + return false; + } + + function mtime($file) { + return $this->ftp->mdtm($file); + } + + function size($file) { + return $this->ftp->filesize($file); + } + + function touch($file, $time = 0, $atime = 0 ) { + return false; + } + + function mkdir($path, $chmod = false, $chown = false, $chgrp = false ) { + if( ! $this->ftp->mkdir($path) ) + return false; + if( $chmod ) + $this->chmod($path, $chmod); + if( $chown ) + $this->chown($path, $chown); + if( $chgrp ) + $this->chgrp($path, $chgrp); + return true; + } + + function rmdir($path, $recursive = false ) { + if( ! $recursive ) + return $this->ftp->rmdir($path); + + return $this->ftp->mdel($path); + } + + function dirlist($path = '.', $incdot = false, $recursive = false ) { + if( $this->is_file($path) ) { + $limitFile = basename($path); + $path = dirname($path) . '/'; + } else { + $limitFile = false; + } + + $list = $this->ftp->dirlist($path); + if( ! $list ) + return false; + if( empty($list) ) + return array(); + + $ret = array(); + foreach ( $list as $struc ) { + + if ( 'd' == $struc['type'] ) { + $struc['files'] = array(); + + if ( $incdot ){ + //We're including the doted starts + if( '.' != $struc['name'] && '..' != $struc['name'] ){ //Ok, It isnt a special folder + if ($recursive) + $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $incdot, $recursive); + } + } else { //No dots + if ($recursive) + $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $incdot, $recursive); + } + } + //File + $ret[$struc['name']] = $struc; + } + return $ret; + } + + function __destruct() { + $this->ftp->quit(); + } +} + +?> diff -uNr a/blog/wp-admin/includes/class-wp-filesystem-ssh2.php b/blog/wp-admin/includes/class-wp-filesystem-ssh2.php --- a/blog/wp-admin/includes/class-wp-filesystem-ssh2.php false +++ b/blog/wp-admin/includes/class-wp-filesystem-ssh2.php a74d659635583bf55194a521640d88ae770f9a6f50860bc8afca9f07adb6b436d547cb3528fb47f99e48a45817a2dffe3d06b7b7afb55121de51361893dce210 @@ -0,0 +1,507 @@ +method = 'ssh2'; + $this->errors = new WP_Error(); + + //Check if possible to use ssh2 functions. + if ( ! extension_loaded('ssh2') ) { + $this->errors->add('no_ssh2_ext', __('The ssh2 PHP extension is not available')); + return false; + } + + // Set defaults: + if ( empty($opt['port']) ) + $this->options['port'] = 22; + else + $this->options['port'] = $opt['port']; + + if ( empty($opt['hostname']) ) + $this->errors->add('empty_hostname', __('SSH2 hostname is required')); + else + $this->options['hostname'] = $opt['hostname']; + + if ( isset($opt['base']) && ! empty($opt['base']) ) + $this->wp_base = $opt['base']; + + // Check if the options provided are OK. + if ( empty ($opt['username']) ) + $this->errors->add('empty_username', __('SSH2 username is required')); + else + $this->options['username'] = $opt['username']; + + if ( ( !empty ($opt['public_key']) ) && ( !empty ($opt['private_key']) ) ) { + $this->options['public_key'] = $opt['public_key']; + $this->options['private_key'] = $opt['private_key']; + + $this->options['hostkey'] = array("hostkey" => "ssh-rsa"); + + $this->keys = true; + } + + + if ( empty ($opt['password']) ) { + if ( !$this->keys ) // password can be blank if we are using keys + $this->errors->add('empty_password', __('SSH2 password is required')); + } else { + $this->options['password'] = $opt['password']; + } + + } + + function connect() { + $this->debug("connect();"); + + if ( ! $this->keys ) { + $this->link = @ssh2_connect($this->options['hostname'], $this->options['port']); + } else { + $this->link = @ssh2_connect($this->options['hostname'], $this->options['port'], $this->options['hostkey']); + } + + if ( ! $this->link ) { + $this->errors->add('connect', sprintf(__('Failed to connect to SSH2 Server %1$s:%2$s'), $this->options['hostname'], $this->options['port'])); + return false; + } + + if ( !$this->keys ) { + if ( ! @ssh2_auth_password($this->link, $this->options['username'], $this->options['password']) ) { + $this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username'])); + return false; + } + } else { + if ( ! @ssh2_auth_pubkey_file($this->link, $this->options['username'], $this->options['public_key'], $this->options['private_key'], $this->options['password'] ) ) { + $this->errors->add('auth', sprintf(__('Public and Private keys incorrent for %s'), $this->options['username'])); + return false; + } + } + + $this->sftp_link = ssh2_sftp($this->link); + + return true; + } + + function run_command($link, $command, $returnbool = false) { + $this->debug("run_command();"); + if(!($stream = @ssh2_exec( $link, $command . "; echo \"__COMMAND_FINISHED__\";"))) { + $this->errors->add('command', sprintf(__('Unable to perform command: %s'), $command)); + } else { + stream_set_blocking( $stream, true ); + $time_start = time(); + $data = null; + while( true ) { + if (strpos($data,"__COMMAND_FINISHED__") !== false){ + break; // the command has finshed! + } + if( (time()-$time_start) > $this->timeout ){ + $this->errors->add('command', sprintf(__('Connection to the server has timeout after %s seconds.'), $this->timeout)); + unset($this->link); + unset($this->sftp_link); // close connections + return false; + } + while( $buf = fread( $stream, strlen($stream) ) ) + $data .= $buf; + } + fclose($stream); + $data = trim(str_replace("__COMMAND_FINISHED__", "", $data)); + if (($returnbool) && ( (int) $data )) { + return true; + } elseif (($returnbool) && (! (int) $data )) { + return false; + } else { + return $data; + } + } + return false; + } + + function debug($text) + { + if ($this->debugtest) + { + echo "
    " . $text . "
    "; + } + } + + function setDefaultPermissions($perm) { + $this->debug("setDefaultPermissions();"); + if ( $perm ) + $this->permission = $perm; + } + + function get_contents($file, $type = '', $resumepos = 0 ) { + $this->debug("get_contents();"); + $tempfile = wp_tempnam( $file ); + if ( ! $tempfile ) + return false; + if( ! ssh2_scp_recv($this->link, $file, $tempfile) ) + return false; + $contents = file_get_contents($tempfile); + unlink($tempfile); + return $contents; + } + + function get_contents_array($file) { + $this->debug("get_contents_array();"); + return explode("\n", $this->get_contents($file)); + } + + function put_contents($file, $contents, $type = '' ) { + $this->debug("put_contents($file);"); + $tempfile = wp_tempnam( $file ); + $temp = fopen($tempfile, 'w'); + if ( ! $temp ) + return false; + fwrite($temp, $contents); + fclose($temp); + $ret = ssh2_scp_send($this->link, $tempfile, $file, $this->permission); + unlink($tempfile); + return $ret; + } + + function cwd() { + $this->debug("cwd();"); + $cwd = $this->run_command($this->link, 'pwd'); + if( $cwd ) + $cwd = trailingslashit($cwd); + return $cwd; + } + + function chdir($dir) { + $this->debug("chdir();"); + return $this->run_command($this->link, 'cd ' . $dir, true); + } + + function chgrp($file, $group, $recursive = false ) { + $this->debug("chgrp();"); + if ( ! $this->exists($file) ) + return false; + if ( ! $recursive || ! $this->is_dir($file) ) + return $this->run_command($this->link, sprintf('chgrp %o %s', $mode, $file), true); + return $this->run_command($this->link, sprintf('chgrp -R %o %s', $mode, $file), true); + } + + function chmod($file, $mode = false, $recursive = false) { + $this->debug("chmod();"); + if( ! $mode ) + $mode = $this->permission; + if( ! $mode ) + return false; + if ( ! $this->exists($file) ) + return false; + if ( ! $recursive || ! $this->is_dir($file) ) + return $this->run_command($this->link, sprintf('chmod %o %s', $mode, $file), true); + return $this->run_command($this->link, sprintf('chmod -R %o %s', $mode, $file), true); + } + + function chown($file, $owner, $recursive = false ) { + $this->debug("chown();"); + if ( ! $this->exists($file) ) + return false; + if ( ! $recursive || ! $this->is_dir($file) ) + return $this->run_command($this->link, sprintf('chown %o %s', $mode, $file), true); + return $this->run_command($this->link, sprintf('chown -R %o %s', $mode, $file), true); + } + + function owner($file) { + $this->debug("owner();"); + $dir = $this->dirlist($file); + return $dir[$file]['owner']; + } + + function getchmod($file) { + $this->debug("getchmod();"); + $dir = $this->dirlist($file); + return $dir[$file]['permsn']; + } + + function group($file) { + $this->debug("group();"); + $dir = $this->dirlist($file); + return $dir[$file]['group']; + } + + function copy($source, $destination, $overwrite = false ) { + $this->debug("copy();"); + if( ! $overwrite && $this->exists($destination) ) + return false; + $content = $this->get_contents($source); + if( false === $content) + return false; + return $this->put_contents($destination, $content); + } + + function move($source, $destination, $overwrite = false) { + $this->debug("move();"); + return @ssh2_sftp_rename($this->link, $source, $destination); + } + + function delete($file, $recursive = false) { + $this->debug("delete();"); + if ( $this->is_file($file) ) + return ssh2_sftp_unlink($this->sftp_link, $file); + if ( ! $recursive ) + return ssh2_sftp_rmdir($this->sftp_link, $file); + $filelist = $this->dirlist($file); + if ( is_array($filelist) ) { + foreach ( $filelist as $filename => $fileinfo) { + $this->delete($file . '/' . $filename, $recursive); + } + } + return ssh2_sftp_rmdir($this->sftp_link, $file); + } + + function exists($file) { + $this->debug("exists();"); + return $this->run_command($this->link, sprintf('ls -lad %s', $file), true); + } + + function is_file($file) { + $this->debug("is_file();"); + //DO NOT RELY ON dirlist()! + $list = $this->run_command($this->link, sprintf('ls -lad %s', $file)); + $list = $this->parselisting($list); + if ( ! $list ) + return false; + else + return ( !$list['isdir'] && !$list['islink'] ); //ie. not a file or link, yet exists, must be file. + } + + function is_dir($path) { + $this->debug("is_dir();"); + //DO NOT RELY ON dirlist()! + $list = $this->parselisting($this->run_command($this->link, sprintf('ls -lad %s', untrailingslashit($path)))); + if ( ! $list ) + return false; + else + return $list['isdir']; + } + + function is_readable($file) { + //Not implmented. + } + + function is_writable($file) { + //Not implmented. + } + + function atime($file) { + //Not implmented. + } + + function mtime($file) { + //Not implmented. + } + + function size($file) { + //Not implmented. + } + + function touch($file, $time = 0, $atime = 0) { + //Not implmented. + } + + function mkdir($path, $chmod = null, $chown = false, $chgrp = false) { + $this->debug("mkdir();"); + $path = untrailingslashit($path); + if( ! ssh2_sftp_mkdir($this->sftp_link, $path, $chmod, true) ) + return false; + if( $chown ) + $this->chown($path, $chown); + if( $chgrp ) + $this->chgrp($path, $chgrp); + return true; + } + + function rmdir($path, $recursive = false) { + $this->debug("rmdir();"); + return $this->delete($path, $recursive); + } + + function parselisting($line) { + $this->debug("parselisting();"); + $is_windows = ($this->OS_remote == FTP_OS_Windows); + if ($is_windows && preg_match("/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|) +(.+)/", $line, $lucifer)) { + $b = array(); + if ($lucifer[3]<70) { $lucifer[3] +=2000; } else { $lucifer[3]+=1900; } // 4digit year fix + $b['isdir'] = ($lucifer[7]==""); + if ( $b['isdir'] ) + $b['type'] = 'd'; + else + $b['type'] = 'f'; + $b['size'] = $lucifer[7]; + $b['month'] = $lucifer[1]; + $b['day'] = $lucifer[2]; + $b['year'] = $lucifer[3]; + $b['hour'] = $lucifer[4]; + $b['minute'] = $lucifer[5]; + $b['time'] = @mktime($lucifer[4]+(strcasecmp($lucifer[6],"PM")==0?12:0),$lucifer[5],0,$lucifer[1],$lucifer[2],$lucifer[3]); + $b['am/pm'] = $lucifer[6]; + $b['name'] = $lucifer[8]; + } else if (!$is_windows && $lucifer=preg_split("/[ ]/",$line,9,PREG_SPLIT_NO_EMPTY)) { + //echo $line."\n"; + $lcount=count($lucifer); + if ($lcount<8) return ''; + $b = array(); + $b['isdir'] = $lucifer[0]{0} === "d"; + $b['islink'] = $lucifer[0]{0} === "l"; + if ( $b['isdir'] ) + $b['type'] = 'd'; + elseif ( $b['islink'] ) + $b['type'] = 'l'; + else + $b['type'] = 'f'; + $b['perms'] = $lucifer[0]; + $b['number'] = $lucifer[1]; + $b['owner'] = $lucifer[2]; + $b['group'] = $lucifer[3]; + $b['size'] = $lucifer[4]; + if ($lcount==8) { + sscanf($lucifer[5],"%d-%d-%d",$b['year'],$b['month'],$b['day']); + sscanf($lucifer[6],"%d:%d",$b['hour'],$b['minute']); + $b['time'] = @mktime($b['hour'],$b['minute'],0,$b['month'],$b['day'],$b['year']); + $b['name'] = $lucifer[7]; + } else { + $b['month'] = $lucifer[5]; + $b['day'] = $lucifer[6]; + if (preg_match("/([0-9]{2}):([0-9]{2})/",$lucifer[7],$l2)) { + $b['year'] = date("Y"); + $b['hour'] = $l2[1]; + $b['minute'] = $l2[2]; + } else { + $b['year'] = $lucifer[7]; + $b['hour'] = 0; + $b['minute'] = 0; + } + $b['time'] = strtotime(sprintf("%d %s %d %02d:%02d",$b['day'],$b['month'],$b['year'],$b['hour'],$b['minute'])); + $b['name'] = $lucifer[8]; + } + } + + return $b; + } + + function dirlist($path = '.', $incdot = false, $recursive = false) { + $this->debug("dirlist();"); + if( $this->is_file($path) ) { + $limitFile = basename($path); + $path = trailingslashit(dirname($path)); + } else { + $limitFile = false; + } + + $list = $this->run_command($this->link, sprintf('ls -la %s', $path)); + + if ( $list === false ) + return false; + + $list = explode("\n", $list); + + $dirlist = array(); + foreach ( (array)$list as $k => $v ) { + $entry = $this->parselisting($v); + if ( empty($entry) ) + continue; + + if ( '.' == $entry['name'] || '..' == $entry['name'] ) + continue; + + $dirlist[ $entry['name'] ] = $entry; + } + + if ( ! $dirlist ) + return false; + + if ( empty($dirlist) ) + return array(); + + $ret = array(); + foreach ( $dirlist as $struc ) { + + if ( 'd' == $struc['type'] ) { + $struc['files'] = array(); + + if ( $incdot ){ + //We're including the doted starts + if( '.' != $struc['name'] && '..' != $struc['name'] ){ //Ok, It isnt a special folder + if ($recursive) + $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $incdot, $recursive); + } + } else { //No dots + if ( $recursive ) + $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $incdot, $recursive); + } + } + //File + $ret[$struc['name']] = $struc; + } + return $ret; + } + function __destruct() { + $this->debug("__destruct();"); + if ( $this->link ) + unset($this->link); + if ( $this->sftp_link ) + unset($this->sftp_link); + } +} + +?> diff -uNr a/blog/wp-admin/includes/comment.php b/blog/wp-admin/includes/comment.php --- a/blog/wp-admin/includes/comment.php false +++ b/blog/wp-admin/includes/comment.php d672267904f4ec5b42eddc2639453076248ff2466023f69d4dd42956b671486ba5de0c2728cd1dffb7936c08ce069ba2467c15491f2c12b7930b96a910bae418 @@ -0,0 +1,164 @@ +get_var( $wpdb->prepare("SELECT comment_post_ID FROM $wpdb->comments + WHERE comment_author = %s AND comment_date = %s", $comment_author, $comment_date) ); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + */ +function edit_comment() { + + $comment_post_ID = (int) $_POST['comment_post_ID']; + + if (!current_user_can( 'edit_post', $comment_post_ID )) + wp_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']; + + foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) { + if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { + $_POST['edit_date'] = '1'; + break; + } + } + + 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); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $id + * @return unknown + */ +function get_comment_to_edit( $id ) { + if ( !$comment = get_comment($id) ) + return false; + + $comment->comment_ID = (int) $comment->comment_ID; + $comment->comment_post_ID = (int) $comment->comment_post_ID; + + $comment->comment_content = format_to_edit( $comment->comment_content ); + $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 = clean_url($comment->comment_author_url); + $comment->comment_author_url = format_to_edit( $comment->comment_author_url ); + + return $comment; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * @uses $wpdb + * + * @param int $post_id Post ID + * @return unknown + */ +function get_pending_comments_num( $post_id ) { + global $wpdb; + + $single = false; + if ( !is_array($post_id) ) { + $post_id = (array) $post_id; + $single = true; + } + $post_id = array_map('intval', $post_id); + $post_id = "'" . implode("', '", $post_id) . "'"; + + $pending = $wpdb->get_results( "SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_N ); + + if ( empty($pending) ) + return 0; + + if ( $single ) + return $pending[0][1]; + + $pending_keyed = array(); + foreach ( $pending as $pend ) + $pending_keyed[$pend[0]] = $pend[1]; + + return $pending_keyed; +} + +/** + * Add avatars to relevant places in admin, or try to. + * + * @since unknown + * @uses $comment + * + * @param string $name User name. + * @return string Avatar with Admin name. + */ +function floated_admin_avatar( $name ) { + global $comment; + + $id = $avatar = false; + if ( $comment->comment_author_email ) + $id = $comment->comment_author_email; + if ( $comment->user_id ) + $id = $comment->user_id; + + if ( $id ) + $avatar = get_avatar( $id, 32 ); + + return "$avatar $name"; +} + +function enqueue_comment_hotkeys_js() { + if ( 'true' == get_user_option( 'comment_shortcuts' ) ) + wp_enqueue_script( 'jquery-table-hotkeys' ); +} + +if ( is_admin() && ('edit-comments.php' == $pagenow || 'edit.php' == $pagenow) ) { + if ( get_option('show_avatars') ) + add_filter( 'comment_author', 'floated_admin_avatar' ); +} + +?> diff -uNr a/blog/wp-admin/includes/dashboard.php b/blog/wp-admin/includes/dashboard.php --- a/blog/wp-admin/includes/dashboard.php false +++ b/blog/wp-admin/includes/dashboard.php b7ef9c97d9b699565216447175a98f9d67c51a78e5a338997afe7a7d2cd726f558b65ef8d4f7d3df96945221d720b692e50de48f34e9654f8049df7e4c8068b0 @@ -0,0 +1,840 @@ + get_option('home'), + 'link' => apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?hl=en&scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ), + 'url' => apply_filters( 'dashboard_incoming_links_feed', 'http://blogsearch.google.com/blogsearch_feeds?hl=en&scoring=d&ie=utf-8&num=10&output=rss&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ), + 'items' => isset($widget_options['dashboard_incoming_links']['items']) ? $widget_options['dashboard_incoming_links']['items'] : 10, + 'show_date' => isset($widget_options['dashboard_incoming_links']['show_date']) ? $widget_options['dashboard_incoming_links']['show_date'] : false + ); + } + wp_add_dashboard_widget( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_incoming_links', 'wp_dashboard_incoming_links_control' ); + + // WP Plugins Widget + if ( current_user_can( 'activate_plugins' ) ) + wp_add_dashboard_widget( 'dashboard_plugins', __( 'Plugins' ), 'wp_dashboard_plugins' ); + + // QuickPress Widget + if ( current_user_can('edit_posts') ) + wp_add_dashboard_widget( 'dashboard_quick_press', __( 'QuickPress' ), 'wp_dashboard_quick_press' ); + + // Recent Drafts + if ( current_user_can('edit_posts') ) + wp_add_dashboard_widget( 'dashboard_recent_drafts', __('Recent Drafts'), 'wp_dashboard_recent_drafts' ); + + // Primary feed (Dev Blog) Widget + if ( !isset( $widget_options['dashboard_primary'] ) ) { + $update = true; + $widget_options['dashboard_primary'] = array( + 'link' => apply_filters( 'dashboard_primary_link', __( 'http://wordpress.org/development/' ) ), + 'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/development/feed/' ) ), + 'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Development Blog' ) ), + 'items' => 2, + 'show_summary' => 1, + 'show_author' => 0, + 'show_date' => 1 + ); + } + wp_add_dashboard_widget( 'dashboard_primary', $widget_options['dashboard_primary']['title'], 'wp_dashboard_primary', 'wp_dashboard_primary_control' ); + + // Secondary Feed (Planet) Widget + if ( !isset( $widget_options['dashboard_secondary'] ) ) { + $update = true; + $widget_options['dashboard_secondary'] = array( + 'link' => apply_filters( 'dashboard_secondary_link', __( 'http://planet.wordpress.org/' ) ), + 'url' => apply_filters( 'dashboard_secondary_feed', __( 'http://planet.wordpress.org/feed/' ) ), + 'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ), + 'items' => 5 + ); + } + wp_add_dashboard_widget( 'dashboard_secondary', $widget_options['dashboard_secondary']['title'], 'wp_dashboard_secondary', 'wp_dashboard_secondary_control' ); + + // Hook to register new widgets + do_action( 'wp_dashboard_setup' ); + + // Filter widget order + $dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() ); + + foreach ( $dashboard_widgets as $widget_id ) { + $name = empty( $wp_registered_widgets[$widget_id]['all_link'] ) ? $wp_registered_widgets[$widget_id]['name'] : $wp_registered_widgets[$widget_id]['name'] . " " . __('View all') . ''; + wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[$widget_id]['callback'], $wp_registered_widget_controls[$widget_id]['callback'] ); + } + + if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id']) ) { + ob_start(); // hack - but the same hack wp-admin/widgets.php uses + wp_dashboard_trigger_widget_control( $_POST['widget_id'] ); + ob_end_clean(); + wp_redirect( remove_query_arg( 'edit' ) ); + exit; + } + + if ( $update ) + update_option( 'dashboard_widget_options', $widget_options ); + + do_action('do_meta_boxes', 'dashboard', 'normal', ''); + do_action('do_meta_boxes', 'dashboard', 'side', ''); +} + +function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null ) { + global $wp_dashboard_control_callbacks; + if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) { + $wp_dashboard_control_callbacks[$widget_id] = $control_callback; + if ( isset( $_GET['edit'] ) && $widget_id == $_GET['edit'] ) { + list($url) = explode( '#', add_query_arg( 'edit', false ), 2 ); + $widget_name .= ' ' . __( 'Cancel' ) . ''; + add_meta_box( $widget_id, $widget_name, '_wp_dashboard_control_callback', 'dashboard', 'normal', 'core' ); + return; + } + list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 ); + $widget_name .= ' ' . __( 'Configure' ) . ''; + } + $side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts', 'dashboard_primary', 'dashboard_secondary'); + $location = 'normal'; + if ( in_array($widget_id, $side_widgets) ) + $location = 'side'; + add_meta_box( $widget_id, $widget_name , $callback, 'dashboard', $location, 'core' ); +} + +function _wp_dashboard_control_callback( $dashboard, $meta_box ) { + echo '
    '; + wp_dashboard_trigger_widget_control( $meta_box['id'] ); + echo "

    "; + + echo '
    '; +} + +/** + * Displays the dashboard. + * + * @since unknown + */ +function wp_dashboard() { + echo "
    \n\n"; + + echo "
    \n\n"; + $class = do_meta_boxes( 'dashboard', 'side', '' ) ? ' class="has-sidebar"' : ''; + echo "
    \n\n"; + + echo "
    \n\n"; + echo "
    \n\n"; + do_meta_boxes( 'dashboard', 'normal', '' ); + echo "
    \n\n"; + echo "
    \n\n"; + + echo "
    \n

    \n"; + wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); + wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); + echo "

    \n
    \n"; + + echo "
    "; +} + +/* Dashboard Widgets */ + +function wp_dashboard_right_now() { + $num_posts = wp_count_posts( 'post' ); + $num_pages = wp_count_posts( 'page' ); + + $num_cats = wp_count_terms('category'); + + $num_tags = wp_count_terms('post_tag'); + + $num_comm = wp_count_comments( ); + + echo "\n\t".'

    ' . __('At a Glance') . '

    '; + echo "\n\t".'
    '."\n\t".''; + echo "\n\t".''; + + // Posts + $num = number_format_i18n( $num_posts->publish ); + if ( current_user_can( 'edit_posts' ) ) + $text = "$num"; + else + $text = $num; + echo ''; + echo ''; + /* TODO: Show status breakdown on hover + if ( $can_edit_pages && !empty($num_pages->publish) ) { // how many pages is not exposed in feeds. Don't show if !current_user_can + $post_type_texts[] = ''.sprintf( __ngettext( '%s page', '%s pages', $num_pages->publish ), number_format_i18n( $num_pages->publish ) ).''; + } + if ( $can_edit_posts && !empty($num_posts->draft) ) { + $post_type_texts[] = ''.sprintf( __ngettext( '%s draft', '%s drafts', $num_posts->draft ), number_format_i18n( $num_posts->draft ) ).''; + } + if ( $can_edit_posts && !empty($num_posts->future) ) { + $post_type_texts[] = ''.sprintf( __ngettext( '%s scheduled post', '%s scheduled posts', $num_posts->future ), number_format_i18n( $num_posts->future ) ).''; + } + if ( current_user_can('publish_posts') && !empty($num_posts->pending) ) { + $pending_text = sprintf( __ngettext( 'There is %2$s post pending your review.', 'There are %2$s posts pending your review.', $num_posts->pending ), 'edit.php?post_status=pending', number_format_i18n( $num_posts->pending ) ); + } else { + $pending_text = ''; + } + */ + + // Total Comments + $num = number_format_i18n($num_comm->total_comments); + if ( current_user_can( 'moderate_comments' ) ) + $num = "$num"; + echo ''; + echo ''; + + echo ''; + + // Pages + $num = number_format_i18n( $num_pages->publish ); + if ( current_user_can( 'edit_pages' ) ) + $num = "$num"; + echo ''; + echo ''; + + // Approved Comments + $num = number_format_i18n($num_comm->approved); + if ( current_user_can( 'moderate_comments' ) ) + $num = "$num"; + echo ''; + echo ''; + + echo "\n\t"; + + // Categories + $num = number_format_i18n( $num_cats ); + if ( current_user_can( 'manage_categories' ) ) + $num = "$num"; + echo ''; + echo ''; + + // Pending Comments + $num = number_format_i18n($num_comm->moderated); + if ( current_user_can( 'moderate_comments' ) ) + $num = "$num"; + echo ''; + echo ''; + + echo "\n\t"; + + // Tags + $num = number_format_i18n( $num_tags ); + if ( current_user_can( 'manage_categories' ) ) + $num = "$num"; + echo ''; + echo ''; + + // Spam Comments + $num = number_format_i18n($num_comm->spam); + if ( current_user_can( 'moderate_comments' ) ) + $num = "$num"; + echo ''; + echo ''; + + echo ""; + do_action('right_now_table_end'); + echo "\n\t
    ' . $text . '' . __ngettext( 'Post', 'Posts', intval($num_posts->publish) ) . ''.$num.'' . __ngettext( 'Comment', 'Comments', $num_comm->total_comments ) . '
    '.$num.'' . __ngettext( 'Page', 'Pages', $num_pages->publish ) . ''.$num.'' . __ngettext( 'Approved', 'Approved', $num_comm->approved ) . '
    '.$num.'' . __ngettext( 'Category', 'Categories', $num_cats ) . ''.$num.'' . __ngettext( 'Pending', 'Pending', $num_comm->moderated ) . '
    '.$num.'' . __ngettext( 'Tag', 'Tags', $num_tags ) . ''.$num.'' . __ngettext( 'Spam', 'Spam', $num_comm->spam ) . '
    \n\t
    "; + + echo "\n\t".'
    '; + $ct = current_theme_info(); + $sidebars_widgets = wp_get_sidebars_widgets(); + $num_widgets = array_reduce( $sidebars_widgets, create_function( '$prev, $curr', 'return $prev+count($curr);' ), 0 ); + $num = number_format_i18n( $num_widgets ); + + echo "\n\t

    "; + if ( current_user_can( 'switch_themes' ) ) { + echo '' . __('Change Theme') . ''; + printf(__ngettext('Theme %1$s with %2$s Widget', 'Theme %1$s with %2$s Widgets', $num_widgets), $ct->title, $num); + } else { + printf(__ngettext('Theme %1$s with %2$s Widget', 'Theme %1$s with %2$s Widgets', $num_widgets), $ct->title, $num); + } + + echo '

    '; + + update_right_now_message(); + + echo "\n\t".'
    '; + do_action( 'rightnow_end' ); + do_action( 'activity_box_end' ); +} + +function wp_dashboard_quick_press() { + $drafts = false; + if ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['action'] ) && 0 === strpos( $_POST['action'], 'post-quickpress' ) && (int) $_POST['post_ID'] ) { + $view = get_permalink( $_POST['post_ID'] ); + $edit = clean_url( get_edit_post_link( $_POST['post_ID'] ) ); + if ( 'post-quickpress-publish' == $_POST['action'] ) { + if ( current_user_can('publish_posts') ) + printf( '

    ' . __( 'Post Published. View post | Edit post' ) . '

    ', clean_url( $view ), $edit ); + else + printf( '

    ' . __( 'Post submitted. Preview post | Edit post' ) . '

    ', clean_url( add_query_arg( 'preview', 1, $view ) ), $edit ); + } else { + printf( '

    ' . __( 'Draft Saved. Preview post | Edit post' ) . '

    ', clean_url( add_query_arg( 'preview', 1, $view ) ), $edit ); + $drafts_query = new WP_Query( array( + 'post_type' => 'post', + 'what_to_show' => 'posts', + 'post_status' => 'draft', + 'author' => $GLOBALS['current_user']->ID, + 'posts_per_page' => 1, + 'orderby' => 'modified', + 'order' => 'DESC' + ) ); + + if ( $drafts_query->posts ) + $drafts =& $drafts_query->posts; + } + printf('

    ' . __('You can also try %s, easy blogging from anywhere on the Web.') . '

    ', '' . __('Press This') . '' ); + $_REQUEST = array(); // hack for get_default_post_to_edit() + } + + $post = get_default_post_to_edit(); +?> + +
    +

    +
    + +
    + + +
    + +
    + + +

    +
    + +
    + + + +

    +
    + +
    + +

    + + + + + + + + + + +
    +

    + +
    + + 'post', + 'what_to_show' => 'posts', + 'post_status' => 'draft', + 'author' => $GLOBALS['current_user']->ID, + 'posts_per_page' => 5, + 'orderby' => 'modified', + 'order' => 'DESC' + ) ); + $drafts =& $drafts_query->posts; + } + + if ( $drafts && is_array( $drafts ) ) { + $list = array(); + foreach ( $drafts as $draft ) { + $url = get_edit_post_link( $draft->ID ); + $title = _draft_or_post_title( $draft->ID ); + $item = "

    $title " . get_the_time( get_option( 'date_format' ), $draft ) . '

    '; + if ( $the_content = preg_split( '#\s#', strip_tags( $draft->post_content ), 11, PREG_SPLIT_NO_EMPTY ) ) + $item .= '

    ' . join( ' ', array_slice( $the_content, 0, 10 ) ) . ( 10 < count( $the_content ) ? '…' : '' ) . '

    '; + $list[] = $item; + } +?> +
      +
    • \n
    • ", $list ); ?>
    • +
    +

    +get_results( "SELECT * FROM $wpdb->comments ORDER BY comment_date_gmt DESC LIMIT $start, 50" ) ) { + + foreach ( $possible as $comment ) { + if ( count( $comments ) >= 5 ) + break; + if ( in_array( $comment->comment_approved, $allowed_states ) ) + $comments[] = $comment; + } + + $start = $start + 50; + } + + if ( $comments ) : +?> + +
    + + +
    + + +

    + + +

    + +comment_post_ID ); + $comment_post_title = get_the_title( $comment->comment_post_ID ); + $comment_post_link = "$comment_post_title"; + $comment_link = '#'; + + $delete_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) ); + $approve_url = clean_url( wp_nonce_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ) ); + $unapprove_url = clean_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ) ); + $spam_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) ); + + $actions = array(); + + $actions_string = ''; + if ( current_user_can('edit_post', $comment->comment_post_ID) ) { + $actions['approve'] = "" . __( 'Approve' ) . ''; + $actions['unapprove'] = "" . __( 'Unapprove' ) . ''; + $actions['edit'] = "". __('Edit') . ''; + //$actions['quickedit'] = '' . __('Quick Edit') . ''; + $actions['reply'] = '' . __('Reply') . ''; + $actions['spam'] = "" . _c( 'Spam|verb' ) . ''; + $actions['delete'] = "" . __('Delete') . ''; + + $actions = apply_filters( 'comment_row_actions', $actions, $comment ); + + $i = 0; + foreach ( $actions as $action => $link ) { + ++$i; + ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; + + // Reply and quickedit need a hide-if-no-js span + if ( 'reply' == $action || 'quickedit' == $action ) + $action .= ' hide-if-no-js'; + + $actions_string .= "$sep$link"; + } + } + +?> + +
    comment_ID) ) ); ?>> + comment_type || 'comment' == $comment->comment_type ) : ?> + + +

    ' . get_comment_author_link() . '', $comment_post_link." ".$comment_link, ' ' . __( '[Pending]' ) . '' ); ?>

    + + comment_type ) : + case 'pingback' : + $type = __( 'Pingback' ); + break; + case 'trackback' : + $type = __( 'Trackback' ); + break; + default : + $type = ucwords( $comment->comment_type ); + endswitch; + $type = wp_specialchars( $type ); + ?> + +

    $type", $comment_post_link ); ?>

    +

    + + +

    +

    + + + +
    +items) && 0 < count($rss->items) ) { + + echo "
      \n"; + + $rss->items = array_slice($rss->items, 0, $items); + foreach ( $rss->items as $item ) { + $publisher = ''; + $site_link = ''; + $link = ''; + $content = ''; + $date = ''; + $link = clean_url( strip_tags( $item['link'] ) ); + + if ( isset( $item['author_uri'] ) ) + $site_link = clean_url( strip_tags( $item['author_uri'] ) ); + + if ( !$publisher = wp_specialchars( strip_tags( isset($item['dc']['publisher']) ? $item['dc']['publisher'] : $item['author_name'] ) ) ) + $publisher = __( 'Somebody' ); + if ( $site_link ) + $publisher = "$publisher"; + else + $publisher = "$publisher"; + + if ( isset($item['description']) ) + $content = $item['description']; + elseif ( isset($item['summary']) ) + $content = $item['summary']; + elseif ( isset($item['atom_content']) ) + $content = $item['atom_content']; + else + $content = __( 'something' ); + $content = wp_html_excerpt($content, 50) . ' ...'; + if ( $link ) + $text = _c( '%1$s linked here saying, "%3$s"|feed_display' ); + else + $text = _c( '%1$s linked here saying, "%3$s"|feed_display' ); + + if ( $show_date ) { + if ( $show_author || $show_summary ) + $text .= _c( ' on %4$s|feed_display' ); + $date = wp_specialchars( strip_tags( isset($item['pubdate']) ? $item['pubdate'] : $item['published'] ) ); + $date = strtotime( $date ); + $date = gmdate( get_option( 'date_format' ), $date ); + } + + echo "\t
    • " . sprintf( _c( "$text|feed_display" ), $publisher, $link, $content, $date ) . "
    • \n"; + } + + echo "
    \n"; + + } else { + echo '

    ' . __('This dashboard widget queries Google Blog Search so that when another blog links to your site it will show up here. It has found no incoming links… yet. It’s okay — there is no rush.') . "

    \n"; + } +} + +function wp_dashboard_incoming_links_control() { + wp_dashboard_rss_control( 'dashboard_incoming_links', array( 'title' => false, 'show_summary' => false, 'show_author' => false ) ); +} + +function wp_dashboard_primary() { + wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_rss_output' ); +} + +function wp_dashboard_primary_control() { + wp_dashboard_rss_control( 'dashboard_primary' ); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param int $widget_id + */ +function wp_dashboard_rss_output( $widget_id ) { + $widgets = get_option( 'dashboard_widget_options' ); + echo "
    "; + wp_widget_rss_output( $widgets[$widget_id] ); + echo "
    "; +} + +function wp_dashboard_secondary() { + wp_dashboard_cached_rss_widget( 'dashboard_secondary', 'wp_dashboard_secondary_output' ); +} + +function wp_dashboard_secondary_control() { + wp_dashboard_rss_control( 'dashboard_secondary' ); +} + +/** + * Display secondary dashboard RSS widget feed. + * + * @since unknown + * + * @return unknown + */ +function wp_dashboard_secondary_output() { + $widgets = get_option( 'dashboard_widget_options' ); + @extract( @$widgets['dashboard_secondary'], EXTR_SKIP ); + $rss = @fetch_rss( $url ); + + if ( !isset($rss->items) || 0 == count($rss->items) ) + return false; + + $rss->items = array_slice($rss->items, 0, $items); + + if ( 'http://planet.wordpress.org/' == $rss->channel['link'] ) { + foreach ( array_keys($rss->items) as $i ) { + list($site, $description) = explode( ':', wp_specialchars($rss->items[$i]['title']), 2 ); + $rss->items[$i]['dc']['creator'] = trim($site); + $rss->items[$i]['title'] = trim($description); + } + } + + echo "
    "; + wp_widget_rss_output( $rss, $widgets['dashboard_secondary'] ); + echo "
    "; +} + +function wp_dashboard_plugins() { + wp_dashboard_cached_rss_widget( 'dashboard_plugins', 'wp_dashboard_plugins_output', array( + 'http://wordpress.org/extend/plugins/rss/browse/popular/', + 'http://wordpress.org/extend/plugins/rss/browse/new/', + 'http://wordpress.org/extend/plugins/rss/browse/updated/' + ) ); +} + +/** + * Display plugins most popular, newest plugins, and recently updated widget text. + * + * @since unknown + */ +function wp_dashboard_plugins_output() { + $popular = @fetch_rss( 'http://wordpress.org/extend/plugins/rss/browse/popular/' ); + $new = @fetch_rss( 'http://wordpress.org/extend/plugins/rss/browse/new/' ); + $updated = @fetch_rss( 'http://wordpress.org/extend/plugins/rss/browse/updated/' ); + + foreach ( array( 'popular' => __('Most Popular'), 'new' => __('Newest Plugins'), 'updated' => __('Recently Updated') ) as $feed => $label ) { + if ( !isset($$feed->items) || 0 == count($$feed->items) ) + continue; + + $$feed->items = array_slice($$feed->items, 0, 5); + $item_key = array_rand($$feed->items); + + // Eliminate some common badly formed plugin descriptions + while ( ( null !== $item_key = array_rand($$feed->items) ) && false !== strpos( $$feed->items[$item_key]['description'], 'Plugin Name:' ) ) + unset($$feed->items[$item_key]); + + if ( !isset($$feed->items[$item_key]) ) + continue; + + $item = $$feed->items[$item_key]; + + // current bbPress feed item titles are: user on "topic title" + if ( preg_match( '/"(.*)"/s', $item['title'], $matches ) ) + $title = $matches[1]; + else // but let's make it forward compatible if things change + $title = $item['title']; + $title = wp_specialchars( $title ); + + $description = wp_specialchars( strip_tags(html_entity_decode($item['description'], ENT_QUOTES)) ); + + list($link, $frag) = explode( '#', $item['link'] ); + + $link = clean_url($link); + if( preg_match('|/([^/]+?)/?$|', $link, $matches) ) + $slug = $matches[1]; + else + $slug = ''; + + $ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) . + '&TB_iframe=true&width=600&height=800'; + + echo "

    $label

    \n"; + echo "
    $title
     (" . __( 'Install' ) . ")\n"; + echo "

    $description

    \n"; + } +} + +/** + * Checks to see if all of the feed url in $check_urls are cached. + * + * If $check_urls is empty, look for the rss feed url found in the dashboard + * widget optios of $widget_id. If cached, call $callback, a function that + * echoes out output for this widget. If not cache, echo a "Loading..." stub + * which is later replaced by AJAX call (see top of /wp-admin/index.php) + * + * @since unknown + * + * @param int $widget_id + * @param callback $callback + * @param array $check_urls RSS feeds + * @return bool False on failure. True on success. + */ +function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) { + $loading = '

    ' . __( 'Loading…' ) . '

    '; + + if ( empty($check_urls) ) { + $widgets = get_option( 'dashboard_widget_options' ); + if ( empty($widgets[$widget_id]['url']) ) { + echo $loading; + return false; + } + $check_urls = array( $widgets[$widget_id]['url'] ); + } + + + require_once( ABSPATH . WPINC . '/rss.php' ); + init(); // initialize rss constants + + $cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE ); + + foreach ( $check_urls as $check_url ) { + $status = $cache->check_cache( $check_url ); + if ( 'HIT' !== $status ) { + echo $loading; + return false; + } + } + + if ( $callback && is_callable( $callback ) ) { + $args = array_slice( func_get_args(), 2 ); + array_unshift( $args, $widget_id ); + call_user_func_array( $callback, $args ); + } + + return true; +} + +/* Dashboard Widgets Controls */ + +// Calls widget_control callback +/** + * Calls widget control callback. + * + * @since unknown + * + * @param int $widget_control_id Registered Widget ID. + */ +function wp_dashboard_trigger_widget_control( $widget_control_id = false ) { + global $wp_dashboard_control_callbacks; + + if ( is_scalar($widget_control_id) && $widget_control_id && isset($wp_dashboard_control_callbacks[$widget_control_id]) && is_callable($wp_dashboard_control_callbacks[$widget_control_id]) ) { + call_user_func( $wp_dashboard_control_callbacks[$widget_control_id], '', array( 'id' => $widget_control_id, 'callback' => $wp_dashboard_control_callbacks[$widget_control_id] ) ); + } +} + +/** + * The RSS dashboard widget control. + * + * Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data + * from RSS-type widgets. + * + * @since unknown + * + * @param string widget_id + * @param array form_inputs + */ +function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { + if ( !$widget_options = get_option( 'dashboard_widget_options' ) ) + $widget_options = array(); + + if ( !isset($widget_options[$widget_id]) ) + $widget_options[$widget_id] = array(); + + $number = 1; // Hack to use wp_widget_rss_form() + $widget_options[$widget_id]['number'] = $number; + + if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number]) ) { + $_POST['widget-rss'][$number] = stripslashes_deep( $_POST['widget-rss'][$number] ); + $widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] ); + // title is optional. If black, fill it if possible + if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) { + require_once(ABSPATH . WPINC . '/rss.php'); + $rss = fetch_rss($widget_options[$widget_id]['url']); + $widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->channel['title'])); + } + update_option( 'dashboard_widget_options', $widget_options ); + } + + wp_widget_rss_form( $widget_options[$widget_id], $form_inputs ); +} + +/** + * Empty function usable by plugins to output empty dashboard widget (to be populated later by JS). + */ +function wp_dashboard_empty() {} + +?> diff -uNr a/blog/wp-admin/includes/export.php b/blog/wp-admin/includes/export.php --- a/blog/wp-admin/includes/export.php false +++ b/blog/wp-admin/includes/export.php 2a73cb4aa338028e0f78cf3130a1dc06cb9961b0939a169d9d85f28505f816e8d10b7f0a1ac36c0facaf6181dbf6eb97daded2e24167ce71c39bf104e6f960e7 @@ -0,0 +1,334 @@ +prepare(" WHERE post_author = %d ", $author_id); +} + +// grab a snapshot of post IDs, just in case it changes during the export +$post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts $where ORDER BY post_date_gmt ASC"); + +$categories = (array) get_categories('get=all'); +$tags = (array) get_tags('get=all'); + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $categories + */ +function wxr_missing_parents($categories) { + if ( !is_array($categories) || empty($categories) ) + return array(); + + foreach ( $categories as $category ) + $parents[$category->term_id] = $category->parent; + + $parents = array_unique(array_diff($parents, array_keys($parents))); + + if ( $zero = array_search('0', $parents) ) + unset($parents[$zero]); + + return $parents; +} + +while ( $parents = wxr_missing_parents($categories) ) { + $found_parents = get_categories("include=" . join(', ', $parents)); + if ( is_array($found_parents) && count($found_parents) ) + $categories = array_merge($categories, $found_parents); + else + break; +} + +// Put them in order to be inserted with no child going before its parent +$pass = 0; +$passes = 1000 + count($categories); +while ( ( $cat = array_shift($categories) ) && ++$pass < $passes ) { + if ( $cat->parent == 0 || isset($cats[$cat->parent]) ) { + $cats[$cat->term_id] = $cat; + } else { + $categories[] = $cat; + } +} +unset($categories); + +/** + * Place string in CDATA tag. + * + * @since unknown + * + * @param string $str String to place in XML CDATA tag. + */ +function wxr_cdata($str) { + if ( seems_utf8($str) == false ) + $str = utf8_encode($str); + + // $str = ent2ncr(wp_specialchars($str)); + + $str = ""; + + return $str; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @return string Site URL. + */ +function wxr_site_url() { + global $current_site; + + // mu: the base url + if ( isset($current_site->domain) ) { + return 'http://'.$current_site->domain.$current_site->path; + } + // wp: the blog url + else { + return get_bloginfo_rss('url'); + } +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param object $c Category Object + */ +function wxr_cat_name($c) { + if ( empty($c->name) ) + return; + + echo '' . wxr_cdata($c->name) . ''; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param object $c Category Object + */ +function wxr_category_description($c) { + if ( empty($c->description) ) + return; + + echo '' . wxr_cdata($c->description) . ''; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param object $t Tag Object + */ +function wxr_tag_name($t) { + if ( empty($t->name) ) + return; + + echo '' . wxr_cdata($t->name) . ''; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param object $t Tag Object + */ +function wxr_tag_description($t) { + if ( empty($t->description) ) + return; + + echo '' . wxr_cdata($t->description) . ''; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + */ +function wxr_post_taxonomy() { + $categories = get_the_category(); + $tags = get_the_tags(); + $the_list = ''; + $filter = 'rss'; + + if ( !empty($categories) ) foreach ( (array) $categories as $category ) { + $cat_name = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter); + // for backwards compatibility + $the_list .= "\n\t\t\n"; + // forwards compatibility: use a unique identifier for each cat to avoid clashes + // http://trac.wordpress.org/ticket/5447 + $the_list .= "\n\t\tslug}\">\n"; + } + + if ( !empty($tags) ) foreach ( (array) $tags as $tag ) { + $tag_name = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter); + $the_list .= "\n\t\t\n"; + // forwards compatibility as above + $the_list .= "\n\t\tslug}\">\n"; + } + + echo $the_list; +} + +echo '\n"; + +?> + + + + + + + + + + + + + + + + + + + + + <?php bloginfo_rss('name'); ?> + + + + http://wordpress.org/?v= + + + + + + slug; ?>parent ? $cats[$c->parent]->name : ''; ?> + + + slug; ?> + + + in_the_loop = true; // Fake being in the loop. + // fetch 20 posts at a time rather than loading the entire table into memory + while ( $next_posts = array_splice($post_ids, 0, 20) ) { + $where = "WHERE ID IN (".join(',', $next_posts).")"; + $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts $where ORDER BY post_date_gmt ASC"); + foreach ($posts as $post) { + // Don't export revisions. They bloat the export. + if ( 'revision' == $post->post_type ) + continue; + setup_postdata($post); ?> + +<?php echo apply_filters('the_title_rss', $post->post_title); ?> + + + + + + + +post_content) ); ?> +post_excerpt) ); ?> +ID; ?> +post_date; ?> +post_date_gmt; ?> +comment_status; ?> +ping_status; ?> +post_name; ?> +post_status; ?> +post_parent; ?> +menu_order; ?> +post_type; ?> +post_password; ?> +post_type == 'attachment') { ?> +ID); ?> + +get_results( $wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID) ); +if ( $postmeta ) { +?> + + +meta_key; ?> +meta_value; ?> + + + +get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d", $post->ID) ); +if ( $comments ) { foreach ( $comments as $c ) { ?> + +comment_ID; ?> +comment_author); ?> +comment_author_email; ?> +comment_author_url; ?> +comment_author_IP; ?> +comment_date; ?> +comment_date_gmt; ?> +comment_content) ?> +comment_approved; ?> +comment_type; ?> +comment_parent; ?> +user_id; ?> + + + + + + + diff -uNr a/blog/wp-admin/includes/file.php b/blog/wp-admin/includes/file.php --- a/blog/wp-admin/includes/file.php false +++ b/blog/wp-admin/includes/file.php a86e268b928f6146f65ba84ff05e7ac4f3c09a815e6a243a0bf1f4609601773cf4e1a0cb137cab50ac736d49e262e505d32f4c8df4ba00f96edc7e11d563c555 @@ -0,0 +1,769 @@ + __( 'Main Index Template' ), + 'style.css' => __( 'Stylesheet' ), + 'rtl.css' => __( 'RTL 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' ), + 'searchform.php' => __( 'Search Form' ), + 'single.php' => __( 'Single Post' ), + '404.php' => __( '404 Template' ), + 'link.php' => __( 'Links Template' ), + 'functions.php' => __( 'Theme Functions' ), + 'attachment.php' => __( 'Attachment Template' ), + 'image.php' => __('Image Attachment Template'), + 'video.php' => __('Video Attachment Template'), + 'audio.php' => __('Audio Attachment Template'), + 'application.php' => __('Application Attachment 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' )); + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $file + * @return unknown + */ +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( WP_CONTENT_DIR . $file ) && is_file( WP_CONTENT_DIR . $file ) ) { + $template_data = implode( '', file( WP_CONTENT_DIR . $file ) ); + if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name )) + return $name[1] . ' Page Template'; + } + + return basename( $file ); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @return unknown + */ +function get_home_path() { + $home = get_option( 'home' ); + if ( $home != '' && $home != get_option( '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; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $file + * @return unknown + */ +function get_real_file_to_edit( $file ) { + if ('index.php' == $file || '.htaccess' == $file ) { + $real_file = get_home_path() . $file; + } else { + $real_file = WP_CONTENT_DIR . $file; + } + + return $real_file; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param string $folder Optional. Full path to folder + * @param int $levels Optional. Levels of folders to follow, Default: 100 (PHP Loop limit). + * @return bool|array + */ +function list_files( $folder = '', $levels = 100 ) { + if( empty($folder) ) + return false; + + if( ! $levels ) + return false; + + $files = array(); + if ( $dir = @opendir( $folder ) ) { + while (($file = readdir( $dir ) ) !== false ) { + if ( in_array($file, array('.', '..') ) ) + continue; + if ( is_dir( $folder . '/' . $file ) ) { + $files2 = list_files( $folder . '/' . $file, $levels - 1); + if( $files2 ) + $files = array_merge($files, $files2 ); + else + $files[] = $folder . '/' . $file . '/'; + } else { + $files[] = $folder . '/' . $file; + } + } + } + @closedir( $dir ); + return $files; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @return unknown + */ +function get_temp_dir() { + if ( defined('WP_TEMP_DIR') ) + return trailingslashit(WP_TEMP_DIR); + + $temp = WP_CONTENT_DIR . '/'; + if ( is_dir($temp) && is_writable($temp) ) + return $temp; + + if ( function_exists('sys_get_temp_dir') ) + return trailingslashit(sys_get_temp_dir()); + + return '/tmp/'; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $filename + * @param unknown_type $dir + * @return unknown + */ +function wp_tempnam($filename = '', $dir = ''){ + if ( empty($dir) ) + $dir = get_temp_dir(); + $filename = basename($filename); + if ( empty($filename) ) + $filename = time(); + + $filename = $dir . wp_unique_filename($dir, $filename); + touch($filename); + return $filename; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $file + * @param unknown_type $allowed_files + * @return unknown + */ +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 : + wp_die( __('Sorry, can’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 : + wp_die( __('Sorry, can’t call files with their real path.' )); + + case 3 : + wp_die( __('Sorry, that file cannot be edited.' )); + } +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param array $file Reference to a single element of $_FILES. Call the function once for each uploaded file. + * @param array $overrides Optional. An associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE ). + * @return array 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, $time = null ) { + // 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'; + + // You may define your own function and pass the name in $overrides['unique_filename_callback'] + $unique_filename_callback = null; + + // $_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 upload_max_filesize directive in php.ini." ), + __( "The uploaded file exceeds the MAX_FILE_SIZE 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; + $mimes = false; + + // 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. This error could also be caused by uploads being disabled in your php.ini.' )); + + // 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 ) && !current_user_can( 'unfiltered_upload' ) ) + return $upload_error_handler( $file, __( 'File type does not meet security guidelines. Try another.' )); + + if ( !$ext ) + $ext = ltrim(strrchr($file['name'], '.'), '.'); + + if ( !$type ) + $type = $file['type']; + } + + // A writable uploads dir will pass this test. Again, there's no point overriding this one. + if ( ! ( ( $uploads = wp_upload_dir($time) ) && false === $uploads['error'] ) ) + return $upload_error_handler( $file, $uploads['error'] ); + + $filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback ); + + // Move the file to the uploads dir + $new_file = $uploads['path'] . "/$filename"; + if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) ) { + return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['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; +} + +/** + * {@internal Missing Short Description}} + * + * Pass this function an array similar to that of a $_FILES POST array. + * + * @since unknown + * + * @param unknown_type $file + * @param unknown_type $overrides + * @return unknown + */ +function wp_handle_sideload( &$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'; + + // You may define your own function and pass the name in $overrides['unique_filename_callback'] + $unique_filename_callback = null; + + // $_POST['action'] must be set and its value must equal $overrides['action'] or this: + $action = 'wp_handle_sideload'; + + // Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error']. + $upload_error_strings = array( false, + __( "The file exceeds the upload_max_filesize directive in php.ini." ), + __( "The file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form." ), + __( "The file was only partially uploaded." ), + __( "No file was sent." ), + __( "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; + $mimes = false; + + // 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 && !(filesize($file['tmp_name']) > 0 ) ) + return $upload_error_handler( $file, __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini.' )); + + // A properly uploaded file will pass this test. There should be no reason to override this one. + if (! @ is_file( $file['tmp_name'] ) ) + return $upload_error_handler( $file, __( 'Specified file does not exist.' )); + + // 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 ) && !current_user_can( 'unfiltered_upload' ) ) + return $upload_error_handler( $file, __( 'File type does not meet security guidelines. Try another.' )); + + if ( !$ext ) + $ext = ltrim(strrchr($file['name'], '.'), '.'); + + if ( !$type ) + $type = $file['type']; + } + + // 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'] ); + + $filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback ); + + // Strip the query strings. + $filename = str_replace('?','-', $filename); + $filename = str_replace('&','-', $filename); + + // Move the file to the uploads dir + $new_file = $uploads['path'] . "/$filename"; + if ( false === @ rename( $file['tmp_name'], $new_file ) ) { + return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['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; +} + +/** + * Downloads a url to a local file using the Snoopy HTTP Class. + * + * @since unknown + * @todo Transition over to using the new HTTP Request API (jacob). + * + * @param string $url the URL of the file to download + * @return mixed WP_Error on failure, string Filename on success. + */ +function download_url( $url ) { + //WARNING: The file is not automatically deleted, The script must unlink() the file. + if ( ! $url ) + return new WP_Error('http_no_url', __('Invalid URL Provided')); + + $tmpfname = wp_tempnam($url); + if ( ! $tmpfname ) + return new WP_Error('http_no_file', __('Could not create Temporary file')); + + $handle = @fopen($tmpfname, 'wb'); + if ( ! $handle ) + return new WP_Error('http_no_file', __('Could not create Temporary file')); + + $response = wp_remote_get($url, array('timeout' => 30)); + + if ( is_wp_error($response) ) { + fclose($handle); + unlink($tmpfname); + return $response; + } + + if ( $response['response']['code'] != '200' ){ + fclose($handle); + unlink($tmpfname); + return new WP_Error('http_404', trim($response['response']['message'])); + } + + fwrite($handle, $response['body']); + fclose($handle); + + return $tmpfname; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $file + * @param unknown_type $to + * @return unknown + */ +function unzip_file($file, $to) { + global $wp_filesystem; + + if ( ! $wp_filesystem || !is_object($wp_filesystem) ) + return new WP_Error('fs_unavailable', __('Could not access filesystem.')); + + // Unzip uses a lot of memory + @ini_set('memory_limit', '256M'); + + $fs =& $wp_filesystem; + + require_once(ABSPATH . 'wp-admin/includes/class-pclzip.php'); + + $archive = new PclZip($file); + + // Is the archive valid? + if ( false == ($archive_files = $archive->extract(PCLZIP_OPT_EXTRACT_AS_STRING)) ) + return new WP_Error('incompatible_archive', __('Incompatible archive'), $archive->errorInfo(true)); + + if ( 0 == count($archive_files) ) + return new WP_Error('empty_archive', __('Empty archive')); + + $path = explode('/', untrailingslashit($to)); + for ( $i = count($path); $i > 0; $i-- ) { //>0 = first element is empty allways for paths starting with '/' + $tmppath = implode('/', array_slice($path, 0, $i) ); + if ( $fs->is_dir($tmppath) ) { //Found the highest folder that exists, Create from here(ie +1) + for ( $i = $i + 1; $i <= count($path); $i++ ) { + $tmppath = implode('/', array_slice($path, 0, $i) ); + if ( ! $fs->mkdir($tmppath, FS_CHMOD_DIR) ) + return new WP_Error('mkdir_failed', __('Could not create directory'), $tmppath); + } + break; //Exit main for loop + } + } + + $to = trailingslashit($to); + foreach ($archive_files as $file) { + $path = $file['folder'] ? $file['filename'] : dirname($file['filename']); + $path = explode('/', $path); + for ( $i = count($path); $i >= 0; $i-- ) { //>=0 as the first element contains data + if ( empty($path[$i]) ) + continue; + $tmppath = $to . implode('/', array_slice($path, 0, $i) ); + if ( $fs->is_dir($tmppath) ) {//Found the highest folder that exists, Create from here + for ( $i = $i + 1; $i <= count($path); $i++ ) { //< count() no file component please. + $tmppath = $to . implode('/', array_slice($path, 0, $i) ); + if ( ! $fs->is_dir($tmppath) && ! $fs->mkdir($tmppath, FS_CHMOD_DIR) ) + return new WP_Error('mkdir_failed', __('Could not create directory'), $tmppath); + } + break; //Exit main for loop + } + } + + // We've made sure the folders are there, so let's extract the file now: + if ( ! $file['folder'] ) { + if ( !$fs->put_contents( $to . $file['filename'], $file['content']) ) + return new WP_Error('copy_failed', __('Could not copy file'), $to . $file['filename']); + $fs->chmod($to . $file['filename'], FS_CHMOD_FILE); + } + } + return true; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $from + * @param unknown_type $to + * @return unknown + */ +function copy_dir($from, $to) { + global $wp_filesystem; + + $dirlist = $wp_filesystem->dirlist($from); + + $from = trailingslashit($from); + $to = trailingslashit($to); + + foreach ( (array) $dirlist as $filename => $fileinfo ) { + if ( 'f' == $fileinfo['type'] ) { + if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true) ) { + // If copy failed, chmod file to 0644 and try again. + $wp_filesystem->chmod($to . $filename, 0644); + if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true) ) + return new WP_Error('copy_failed', __('Could not copy file'), $to . $filename); + } + $wp_filesystem->chmod($to . $filename, FS_CHMOD_FILE); + } elseif ( 'd' == $fileinfo['type'] ) { + if ( !$wp_filesystem->is_dir($to . $filename) ) { + if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) ) + return new WP_Error('mkdir_failed', __('Could not create directory'), $to . $filename); + } + $result = copy_dir($from . $filename, $to . $filename); + if ( is_wp_error($result) ) + return $result; + } + } +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $args + * @return unknown + */ +function WP_Filesystem( $args = false ) { + global $wp_filesystem; + + require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'); + + $method = get_filesystem_method($args); + + if ( ! $method ) + return false; + + $abstraction_file = apply_filters('filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method); + if( ! file_exists($abstraction_file) ) + return; + + require_once($abstraction_file); + $method = "WP_Filesystem_$method"; + + $wp_filesystem = new $method($args); + + if ( $wp_filesystem->errors->get_error_code() ) + return false; + + if ( !$wp_filesystem->connect() ) + return false; //There was an erorr connecting to the server. + + // Set the permission constants if not already set. + if ( ! defined('FS_CHMOD_DIR') ) + define('FS_CHMOD_DIR', 0755 ); + if ( ! defined('FS_CHMOD_FILE') ) + define('FS_CHMOD_FILE', 0644 ); + + return true; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $args + * @return unknown + */ +function get_filesystem_method($args = array()) { + $method = false; + if( function_exists('getmyuid') && function_exists('fileowner') ){ + $temp_file = wp_tempnam(); + if ( getmyuid() == fileowner($temp_file) ) + $method = 'direct'; + unlink($temp_file); + } + + if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') ) $method = 'ssh2'; + if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext'; + if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread + return apply_filters('filesystem_method', $method); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $form_post + * @param unknown_type $type + * @param unknown_type $error + * @return unknown + */ +function request_filesystem_credentials($form_post, $type = '', $error = false) { + $req_cred = apply_filters('request_filesystem_credentials', '', $form_post, $type, $error); + if ( '' !== $req_cred ) + return $req_cred; + + if ( empty($type) ) + $type = get_filesystem_method(); + + if ( 'direct' == $type ) + return true; + + $credentials = get_option('ftp_credentials', array()); + // If defined, set it to that, Else, If POST'd, set it to that, If not, Set it to whatever it previously was(saved details in option) + $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($_POST['hostname']) ? $_POST['hostname'] : $credentials['hostname']); + $credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($_POST['username']) ? $_POST['username'] : $credentials['username']); + $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($_POST['password']) ? $_POST['password'] : $credentials['password']); + + // Check to see if we are setting the public/private keys for ssh + $credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : (!empty($_POST['public_key']) ? $_POST['public_key'] : $credentials['public_key']); + $credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : (!empty($_POST['private_key']) ? $_POST['private_key'] : $credentials['private_key']); + + if ( strpos($credentials['hostname'], ':') ) + list( $credentials['hostname'], $credentials['port'] ) = explode(':', $credentials['hostname'], 2); + + if ( defined('FTP_SSH') || (isset($_POST['connection_type']) && 'ssh' == $_POST['connection_type']) ) + $credentials['connection_type'] = 'ssh'; + else if ( defined('FTP_SSL') || (isset($_POST['connection_type']) && 'ftps' == $_POST['connection_type']) ) + $credentials['connection_type'] = 'ftps'; + else if ( !isset($credentials['connection_type']) || (isset($_POST['connection_type']) && 'ftp' == $_POST['connection_type']) ) + $credentials['connection_type'] = 'ftp'; + + if ( ! $error && !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) { + $stored_credentials = $credentials; + unset($stored_credentials['password'], $stored_credentials['private_key'], $stored_credentials['public_key']); + update_option('ftp_credentials', $stored_credentials); + return $credentials; + } + $hostname = ''; + $username = ''; + $password = ''; + $connection_type = ''; + if ( !empty($credentials) ) + extract($credentials, EXTR_OVERWRITE); + if ( $error ) { + $error_string = __('Error: There was an error connecting to the server, Please verify the settings are correct.'); + if ( is_wp_error($error) ) + $error_string = $error->get_error_message(); + echo '

    ' . $error_string . '

    '; + } +?> + +
    +
    +

    +

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    " size="40" />
    size="40" />
    size="40" />'.__('(Password not shown)').''; ?>
    +
    +
    + +

    size="40" />
    size="40" /> +
    +
    +
    +
    + +
    +
    + + + + + + + +

    + +

    +
    +
    + diff -uNr a/blog/wp-admin/includes/image.php b/blog/wp-admin/includes/image.php --- a/blog/wp-admin/includes/image.php false +++ b/blog/wp-admin/includes/image.php 745d416da2f2050bcadf45320b28da14d366808ed4fc33117c9c726b349283a791e44cf5d24eaad7d3eb4d18693431d2ce055cab7df107973f1ae07f67b88293 @@ -0,0 +1,330 @@ + 0, + 'credit' => '', + 'camera' => '', + 'caption' => '', + 'created_timestamp' => 0, + 'copyright' => '', + 'focal_length' => 0, + 'iso' => 0, + 'shutter_speed' => 0, + 'title' => '', + ); + + // read iptc first, since it might contain data not available in exif such + // as caption, description etc + if ( is_callable('iptcparse') ) { + getimagesize($file, $info); + if ( !empty($info['APP13']) ) { + $iptc = iptcparse($info['APP13']); + if ( !empty($iptc['2#110'][0]) ) // credit + $meta['credit'] = utf8_encode(trim($iptc['2#110'][0])); + elseif ( !empty($iptc['2#080'][0]) ) // byline + $meta['credit'] = utf8_encode(trim($iptc['2#080'][0])); + if ( !empty($iptc['2#055'][0]) and !empty($iptc['2#060'][0]) ) // created date and time + $meta['created_timestamp'] = strtotime($iptc['2#055'][0] . ' ' . $iptc['2#060'][0]); + if ( !empty($iptc['2#120'][0]) ) // caption + $meta['caption'] = utf8_encode(trim($iptc['2#120'][0])); + if ( !empty($iptc['2#116'][0]) ) // copyright + $meta['copyright'] = utf8_encode(trim($iptc['2#116'][0])); + if ( !empty($iptc['2#005'][0]) ) // title + $meta['title'] = utf8_encode(trim($iptc['2#005'][0])); + } + } + + // fetch additional info from exif if available + if ( is_callable('exif_read_data') && in_array($sourceImageType, apply_filters('wp_read_image_metadata_types', array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM)) ) ) { + $exif = @exif_read_data( $file ); + if (!empty($exif['FNumber'])) + $meta['aperture'] = round( wp_exif_frac2dec( $exif['FNumber'] ), 2 ); + if (!empty($exif['Model'])) + $meta['camera'] = trim( $exif['Model'] ); + if (!empty($exif['DateTimeDigitized'])) + $meta['created_timestamp'] = wp_exif_date2ts($exif['DateTimeDigitized']); + if (!empty($exif['FocalLength'])) + $meta['focal_length'] = wp_exif_frac2dec( $exif['FocalLength'] ); + if (!empty($exif['ISOSpeedRatings'])) + $meta['iso'] = $exif['ISOSpeedRatings']; + if (!empty($exif['ExposureTime'])) + $meta['shutter_speed'] = wp_exif_frac2dec( $exif['ExposureTime'] ); + } + + return apply_filters( 'wp_read_image_metadata', $meta, $file, $sourceImageType ); + +} + +/** + * Validate that file is an image. + * + * @since 2.5.0 + * + * @param string $path File path to test if valid image. + * @return bool True if valid image, false if not valid image. + */ +function file_is_valid_image($path) { + $size = @getimagesize($path); + return !empty($size); +} + +/** + * Validate that file is suitable for displaying within a web page. + * + * @since 2.5.0 + * @uses apply_filters() Calls 'file_is_displayable_image' on $result and $path. + * + * @param string $path File path to test. + * @return bool True if suitable, false if not suitable. + */ +function file_is_displayable_image($path) { + $info = @getimagesize($path); + if ( empty($info) ) + $result = false; + elseif ( !in_array($info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)) ) // only gif, jpeg and png images can reliably be displayed + $result = false; + else + $result = true; + + return apply_filters('file_is_displayable_image', $result, $path); +} + +?> diff -uNr a/blog/wp-admin/includes/import.php b/blog/wp-admin/includes/import.php --- a/blog/wp-admin/includes/import.php false +++ b/blog/wp-admin/includes/import.php 2639d25ef9d00b79fa0e2cd2a292610a6cf0adb222d1ab4ec1df7ce0e4202bb60021c14183b272622eb124092cecd9ccc8d9f17d8215854bf9ff4582e2d90e6c @@ -0,0 +1,87 @@ + false, 'test_type' => false ); + $_FILES['import']['name'] .= '.import'; + $file = wp_handle_upload( $_FILES['import'], $overrides ); + + if ( isset( $file['error'] ) ) + return $file; + + $url = $file['url']; + $type = $file['type']; + $file = addslashes( $file['file'] ); + $filename = basename( $file ); + + // Construct the object array + $object = array( 'post_title' => $filename, + 'post_content' => $url, + 'post_mime_type' => $type, + 'guid' => $url + ); + + // Save the data + $id = wp_insert_attachment( $object, $file ); + + return array( 'file' => $file, 'id' => $id ); +} + +?> diff -uNr a/blog/wp-admin/includes/media.php b/blog/wp-admin/includes/media.php --- a/blog/wp-admin/includes/media.php false +++ b/blog/wp-admin/includes/media.php c27966bd7f0960af150764437f0c082f4cb8c7f06910bc788c382531f665f9b1e0d1bb94cb2fa7d9fe21498902587d59a06ee2c185df1963eeab08e7ed6646e8 @@ -0,0 +1,2047 @@ + __('From Computer'), // handler action suffix => tab text + 'type_url' => __('From URL'), + 'gallery' => __('Gallery'), + 'library' => __('Media Library') + ); + + return apply_filters('media_upload_tabs', $_default_tabs); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $tabs + * @return unknown + */ +function update_gallery_tab($tabs) { + global $wpdb; + + if ( !isset($_REQUEST['post_id']) ) { + unset($tabs['gallery']); + return $tabs; + } + + if ( intval($_REQUEST['post_id']) ) + $attachments = intval($wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $_REQUEST['post_id']))); + + if ( empty($attachments) ) { + unset($tabs['gallery']); + return $tabs; + } + + $tabs['gallery'] = sprintf(__('Gallery (%s)'), "$attachments"); + + return $tabs; +} +add_filter('media_upload_tabs', 'update_gallery_tab'); + +/** + * {@internal Missing Short Description}} + * + * @since unknown + */ +function the_media_upload_tabs() { + global $redir_tab; + $tabs = media_upload_tabs(); + + if ( !empty($tabs) ) { + echo "
      \n"; + if ( isset($redir_tab) && array_key_exists($redir_tab, $tabs) ) + $current = $redir_tab; + elseif ( isset($_GET['tab']) && array_key_exists($_GET['tab'], $tabs) ) + $current = $_GET['tab']; + else { + $keys = array_keys($tabs); + $current = array_shift($keys); + } + foreach ( $tabs as $callback => $text ) { + $class = ''; + if ( $current == $callback ) + $class = " class='current'"; + $href = add_query_arg(array('tab'=>$callback, 's'=>false, 'paged'=>false, 'post_mime_type'=>false, 'm'=>false)); + $link = "$text"; + echo "\t
    • $link
    • \n"; + } + echo "
    \n"; + } +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $id + * @param unknown_type $alt + * @param unknown_type $title + * @param unknown_type $align + * @param unknown_type $url + * @param unknown_type $rel + * @param unknown_type $size + * @return unknown + */ +function get_image_send_to_editor($id, $alt, $title, $align, $url='', $rel = false, $size='medium') { + + $htmlalt = ( empty($alt) ) ? $title : $alt; + + $html = get_image_tag($id, $htmlalt, $title, $align, $size); + + $rel = $rel ? ' rel="attachment wp-att-'.attribute_escape($id).'"' : ''; + + if ( $url ) + $html = '$html"; + + $html = apply_filters( 'image_send_to_editor', $html, $id, $alt, $title, $align, $url, $size ); + + return $html; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $html + * @param unknown_type $id + * @param unknown_type $alt + * @param unknown_type $title + * @param unknown_type $align + * @param unknown_type $url + * @param unknown_type $size + * @return unknown + */ +function image_add_caption( $html, $id, $alt, $title, $align, $url, $size ) { + + if ( empty($alt) || apply_filters( 'disable_captions', '' ) ) return $html; + $id = ( 0 < (int) $id ) ? 'attachment_' . $id : ''; + + preg_match( '/width="([0-9]+)/', $html, $matches ); + if ( ! isset($matches[1]) ) return $html; + $width = $matches[1]; + + $html = preg_replace( '/align[^\s\'"]+\s?/', '', $html ); + if ( empty($align) ) $align = 'none'; + + $alt = ! empty($alt) ? addslashes($alt) : ''; + + $shcode = '[caption id="' . $id . '" align="align' . $align + . '" width="' . $width . '" caption="' . $alt . '"]' . $html . '[/caption]'; + + return apply_filters( 'image_add_caption_shortcode', $shcode, $html ); +} +add_filter( 'image_send_to_editor', 'image_add_caption', 20, 7 ); + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $html + */ +function media_send_to_editor($html) { +?> + + false); + + $time = current_time('mysql'); + if ( $post = get_post($post_id) ) { + if ( substr( $post->post_date, 0, 4 ) > 0 ) + $time = $post->post_date; + } + + $file = wp_handle_upload($_FILES[$file_id], $overrides, $time); + + if ( isset($file['error']) ) + return new WP_Error( 'upload_error', $file['error'] ); + + $url = $file['url']; + $type = $file['type']; + $file = $file['file']; + $title = preg_replace('/\.[^.]+$/', '', basename($file)); + $content = ''; + + // use image exif/iptc data for title and caption defaults if possible + if ( $image_meta = @wp_read_image_metadata($file) ) { + if ( trim($image_meta['title']) ) + $title = $image_meta['title']; + if ( trim($image_meta['caption']) ) + $content = $image_meta['caption']; + } + + // Construct the attachment array + $attachment = array_merge( array( + 'post_mime_type' => $type, + 'guid' => $url, + 'post_parent' => $post_id, + 'post_title' => $title, + 'post_content' => $content, + ), $post_data ); + + // Save the data + $id = wp_insert_attachment($attachment, $file, $post_id); + if ( !is_wp_error($id) ) { + wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); + } + + return $id; + +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $file_array + * @param unknown_type $post_id + * @param unknown_type $desc + * @param unknown_type $post_data + * @return unknown + */ +function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = array()) { + $overrides = array('test_form'=>false); + $file = wp_handle_sideload($file_array, $overrides); + + if ( isset($file['error']) ) + return new WP_Error( 'upload_error', $file['error'] ); + + $url = $file['url']; + $type = $file['type']; + $file = $file['file']; + $title = preg_replace('/\.[^.]+$/', '', basename($file)); + $content = ''; + + // use image exif/iptc data for title and caption defaults if possible + if ( $image_meta = @wp_read_image_metadata($file) ) { + if ( trim($image_meta['title']) ) + $title = $image_meta['title']; + if ( trim($image_meta['caption']) ) + $content = $image_meta['caption']; + } + + $title = @$desc; + + // Construct the attachment array + $attachment = array_merge( array( + 'post_mime_type' => $type, + 'guid' => $url, + 'post_parent' => $post_id, + 'post_title' => $title, + 'post_content' => $content, + ), $post_data ); + + // Save the data + $id = wp_insert_attachment($attachment, $file, $post_id); + if ( !is_wp_error($id) ) { + wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); + return $url; + } + return $id; +} + +/** + * {@internal Missing Short Description}} + * + * Wrap iframe content (produced by $content_func) in a doctype, html head/body + * etc any additional function args will be passed to content_func. + * + * @since unknown + * + * @param unknown_type $content_func + */ +function wp_iframe($content_func /* ... */) { +?> + + > + + +<?php bloginfo('name') ?> › <?php _e('Uploads'); ?> — <?php _e('WordPress'); ?> + + + + +> + + + +$image_title + $video_title + $audio_title + $media_title + +EOF; + printf($context, $out); +} +add_action( 'media_buttons', 'media_buttons' ); +add_action('media_upload_media', 'media_upload_handler'); + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @return unknown + */ +function media_upload_form_handler() { + check_admin_referer('media-form'); + + if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) { + $post = $_post = get_post($attachment_id, ARRAY_A); + if ( isset($attachment['post_content']) ) + $post['post_content'] = $attachment['post_content']; + if ( isset($attachment['post_title']) ) + $post['post_title'] = $attachment['post_title']; + if ( isset($attachment['post_excerpt']) ) + $post['post_excerpt'] = $attachment['post_excerpt']; + if ( isset($attachment['menu_order']) ) + $post['menu_order'] = $attachment['menu_order']; + if ( isset($attachment['post_parent']) ) + $post['post_parent'] = $attachment['post_parent']; + + $post = apply_filters('attachment_fields_to_save', $post, $attachment); + + if ( isset($post['errors']) ) { + $errors[$attachment_id] = $post['errors']; + unset($post['errors']); + } + + if ( $post != $_post ) + wp_update_post($post); + + foreach ( get_attachment_taxonomies($post) as $t ) + if ( isset($attachment[$t]) ) + wp_set_object_terms($attachment_id, array_map('trim', preg_split('/,+/', $attachment[$t])), $t, false); + } + + if ( isset($_POST['insert-gallery']) || isset($_POST['update-gallery']) ) { ?> + + $html"; + } + $html = apply_filters('media_send_to_editor', $html, $send_id, $attachment); + return media_send_to_editor($html); + } + + return $errors; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @return unknown + */ +function media_upload_image() { + $errors = array(); + $id = 0; + + if ( isset($_POST['html-upload']) && !empty($_FILES) ) { + // Upload File button was clicked + $id = media_handle_upload('async-upload', $_REQUEST['post_id']); + unset($_FILES); + if ( is_wp_error($id) ) { + $errors['upload_error'] = $id; + $id = false; + } + } + + if ( !empty($_POST['insertonlybutton']) ) { + $src = $_POST['insertonly']['src']; + if ( !empty($src) && !strpos($src, '://') ) + $src = "http://$src"; + $alt = attribute_escape($_POST['insertonly']['alt']); + if ( isset($_POST['insertonly']['align']) ) { + $align = attribute_escape($_POST['insertonly']['align']); + $class = " class='align$align'"; + } + if ( !empty($src) ) + $html = "$alt"; + return media_send_to_editor($html); + } + + if ( !empty($_POST) ) { + $return = media_upload_form_handler(); + + if ( is_string($return) ) + return $return; + if ( is_array($return) ) + $errors = $return; + } + + if ( isset($_POST['save']) ) { + $errors['upload_notice'] = __('Saved.'); + return media_upload_gallery(); + } + + if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' ) + return wp_iframe( 'media_upload_type_url_form', 'image', $errors, $id ); + + return wp_iframe( 'media_upload_type_form', 'image', $errors, $id ); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $file + * @param unknown_type $post_id + * @param unknown_type $desc + * @return unknown + */ +function media_sideload_image($file, $post_id, $desc = null) { + if (!empty($file) ) { + $file_array['name'] = basename($file); + $tmp = download_url($file); + $file_array['tmp_name'] = $tmp; + $desc = @$desc; + + if ( is_wp_error($tmp) ) { + @unlink($file_array['tmp_name']); + $file_array['tmp_name'] = ''; + } + + $id = media_handle_sideload($file_array, $post_id, $desc); + $src = $id; + + if ( is_wp_error($id) ) { + @unlink($file_array['tmp_name']); + return $id; + } + } + + if ( !empty($src) ) { + $alt = @$desc; + $html = "$alt"; + return $html; + } +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @return unknown + */ +function media_upload_audio() { + $errors = array(); + $id = 0; + + if ( isset($_POST['html-upload']) && !empty($_FILES) ) { + // Upload File button was clicked + $id = media_handle_upload('async-upload', $_REQUEST['post_id']); + unset($_FILES); + if ( is_wp_error($id) ) { + $errors['upload_error'] = $id; + $id = false; + } + } + + if ( !empty($_POST['insertonlybutton']) ) { + $href = $_POST['insertonly']['href']; + if ( !empty($href) && !strpos($href, '://') ) + $href = "http://$href"; + $title = attribute_escape($_POST['insertonly']['title']); + if ( empty($title) ) + $title = basename($href); + if ( !empty($title) && !empty($href) ) + $html = "$title"; + return media_send_to_editor($html); + } + + if ( !empty($_POST) ) { + $return = media_upload_form_handler(); + + if ( is_string($return) ) + return $return; + if ( is_array($return) ) + $errors = $return; + } + + if ( isset($_POST['save']) ) { + $errors['upload_notice'] = __('Saved.'); + return media_upload_gallery(); + } + + if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' ) + return wp_iframe( 'media_upload_type_url_form', 'audio', $errors, $id ); + + return wp_iframe( 'media_upload_type_form', 'audio', $errors, $id ); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @return unknown + */ +function media_upload_video() { + $errors = array(); + $id = 0; + + if ( isset($_POST['html-upload']) && !empty($_FILES) ) { + // Upload File button was clicked + $id = media_handle_upload('async-upload', $_REQUEST['post_id']); + unset($_FILES); + if ( is_wp_error($id) ) { + $errors['upload_error'] = $id; + $id = false; + } + } + + if ( !empty($_POST['insertonlybutton']) ) { + $href = $_POST['insertonly']['href']; + if ( !empty($href) && !strpos($href, '://') ) + $href = "http://$href"; + $title = attribute_escape($_POST['insertonly']['title']); + if ( empty($title) ) + $title = basename($href); + if ( !empty($title) && !empty($href) ) + $html = "$title"; + return media_send_to_editor($html); + } + + if ( !empty($_POST) ) { + $return = media_upload_form_handler(); + + if ( is_string($return) ) + return $return; + if ( is_array($return) ) + $errors = $return; + } + + if ( isset($_POST['save']) ) { + $errors['upload_notice'] = __('Saved.'); + return media_upload_gallery(); + } + + if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' ) + return wp_iframe( 'media_upload_type_url_form', 'video', $errors, $id ); + + return wp_iframe( 'media_upload_type_form', 'video', $errors, $id ); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @return unknown + */ +function media_upload_file() { + $errors = array(); + $id = 0; + + if ( isset($_POST['html-upload']) && !empty($_FILES) ) { + // Upload File button was clicked + $id = media_handle_upload('async-upload', $_REQUEST['post_id']); + unset($_FILES); + if ( is_wp_error($id) ) { + $errors['upload_error'] = $id; + $id = false; + } + } + + if ( !empty($_POST['insertonlybutton']) ) { + $href = $_POST['insertonly']['href']; + if ( !empty($href) && !strpos($href, '://') ) + $href = "http://$href"; + $title = attribute_escape($_POST['insertonly']['title']); + if ( empty($title) ) + $title = basename($href); + if ( !empty($title) && !empty($href) ) + $html = "$title"; + return media_send_to_editor($html); + } + + if ( !empty($_POST) ) { + $return = media_upload_form_handler(); + + if ( is_string($return) ) + return $return; + if ( is_array($return) ) + $errors = $return; + } + + if ( isset($_POST['save']) ) { + $errors['upload_notice'] = __('Saved.'); + return media_upload_gallery(); + } + + if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' ) + return wp_iframe( 'media_upload_type_url_form', 'file', $errors, $id ); + + return wp_iframe( 'media_upload_type_form', 'file', $errors, $id ); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @return unknown + */ +function media_upload_gallery() { + $errors = array(); + + if ( !empty($_POST) ) { + $return = media_upload_form_handler(); + + if ( is_string($return) ) + return $return; + if ( is_array($return) ) + $errors = $return; + } + + wp_enqueue_script('admin-gallery'); + return wp_iframe( 'media_upload_gallery_form', $errors ); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @return unknown + */ +function media_upload_library() { + $errors = array(); + if ( !empty($_POST) ) { + $return = media_upload_form_handler(); + + if ( is_string($return) ) + return $return; + if ( is_array($return) ) + $errors = $return; + } + + return wp_iframe( 'media_upload_library_form', $errors ); +} + +/** + * Retrieve HTML for the image alignment radio buttons with the specified one checked. + * + * @since unknown + * + * @param unknown_type $post + * @param unknown_type $checked + * @return unknown + */ +function image_align_input_fields($post, $checked='') { + + $alignments = array('none' => 'None', 'left' => 'Left', 'center' => 'Center', 'right' => 'Right'); + if ( !array_key_exists($checked, $alignments) ) + $checked = 'none'; + + $out = array(); + foreach ($alignments as $name => $label) { + + $out[] = ""; + } + return join("\n", $out); +} + +/** + * Retrieve HTML for the size radio buttons with the specified one checked. + * + * @since unknown + * + * @param unknown_type $post + * @param unknown_type $checked + * @return unknown + */ +function image_size_input_fields($post, $checked='') { + + // get a list of the actual pixel dimensions of each possible intermediate version of this image + $size_names = array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full size')); + + foreach ( $size_names as $size => $name) { + $downsize = image_downsize($post->ID, $size); + + // is this size selectable? + $enabled = ( $downsize[3] || 'full' == $size ); + $css_id = "image-size-{$size}-{$post->ID}"; + // if this size is the default but that's not available, don't select it + if ( $checked && !$enabled ) + $checked = ''; + // if $checked was not specified, default to the first available size that's bigger than a thumbnail + if ( !$checked && $enabled && 'thumbnail' != $size ) + $checked = $size; + + $html = "
    "; + + $html .= ""; + // only show the dimensions if that choice is available + if ( $enabled ) + $html .= " "; + + $html .= '
    '; + + $out[] = $html; + } + + return array( + 'label' => __('Size'), + 'input' => 'html', + 'html' => join("\n", $out), + ); +} + +/** + * Retrieve HTML for the Link URL buttons with the default link type as specified. + * + * @since unknown + * + * @param unknown_type $post + * @param unknown_type $url_type + * @return unknown + */ +function image_link_input_fields($post, $url_type='') { + + $file = wp_get_attachment_url($post->ID); + $link = get_attachment_link($post->ID); + + $url = ''; + if ( $url_type == 'file' ) + $url = $file; + elseif ( $url_type == 'post' ) + $url = $link; + + return "
    + + + +"; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $form_fields + * @param unknown_type $post + * @return unknown + */ +function image_attachment_fields_to_edit($form_fields, $post) { + if ( substr($post->post_mime_type, 0, 5) == 'image' ) { + $form_fields['post_title']['required'] = true; + + $form_fields['post_excerpt']['label'] = __('Caption'); + $form_fields['post_excerpt']['helps'][] = __('Also used as alternate text for the image'); + + $form_fields['post_content']['label'] = __('Description'); + + $form_fields['align'] = array( + 'label' => __('Alignment'), + 'input' => 'html', + 'html' => image_align_input_fields($post, get_option('image_default_align')), + ); + + $form_fields['image-size'] = image_size_input_fields($post, get_option('image_default_size')); + } + return $form_fields; +} + +add_filter('attachment_fields_to_edit', 'image_attachment_fields_to_edit', 10, 2); + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $form_fields + * @param unknown_type $post + * @return unknown + */ +function media_single_attachment_fields_to_edit( $form_fields, $post ) { + unset($form_fields['url'], $form_fields['align'], $form_fields['image-size']); + return $form_fields; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $post + * @param unknown_type $attachment + * @return unknown + */ +function image_attachment_fields_to_save($post, $attachment) { + if ( substr($post['post_mime_type'], 0, 5) == 'image' ) { + if ( strlen(trim($post['post_title'])) == 0 ) { + $post['post_title'] = preg_replace('/\.\w+$/', '', basename($post['guid'])); + $post['errors']['post_title']['errors'][] = __('Empty Title filled from filename.'); + } + } + + return $post; +} + +add_filter('attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2); + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $html + * @param unknown_type $attachment_id + * @param unknown_type $attachment + * @return unknown + */ +function image_media_send_to_editor($html, $attachment_id, $attachment) { + $post =& get_post($attachment_id); + if ( substr($post->post_mime_type, 0, 5) == 'image' ) { + $url = $attachment['url']; + + if ( isset($attachment['align']) ) + $align = $attachment['align']; + else + $align = 'none'; + + if ( !empty($attachment['image-size']) ) + $size = $attachment['image-size']; + else + $size = 'medium'; + + $rel = ( $url == get_attachment_link($attachment_id) ); + + return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size); + } + + return $html; +} + +add_filter('media_send_to_editor', 'image_media_send_to_editor', 10, 3); + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $post + * @param unknown_type $errors + * @return unknown + */ +function get_attachment_fields_to_edit($post, $errors = null) { + if ( is_int($post) ) + $post =& get_post($post); + if ( is_array($post) ) + $post = (object) $post; + + $edit_post = sanitize_post($post, 'edit'); + + $form_fields = array( + 'post_title' => array( + 'label' => __('Title'), + 'value' => $edit_post->post_title, + ), + 'post_excerpt' => array( + 'label' => __('Caption'), + 'value' => $edit_post->post_excerpt, + ), + 'post_content' => array( + 'label' => __('Description'), + 'value' => $edit_post->post_content, + 'input' => 'textarea', + ), + 'url' => array( + 'label' => __('Link URL'), + 'input' => 'html', + 'html' => image_link_input_fields($post, get_option('image_default_link_type')), + 'helps' => __('Enter a link URL or click above for presets.'), + ), + 'menu_order' => array( + 'label' => __('Order'), + 'value' => $edit_post->menu_order + ), + ); + + foreach ( get_attachment_taxonomies($post) as $taxonomy ) { + $t = (array) get_taxonomy($taxonomy); + if ( empty($t['label']) ) + $t['label'] = $taxonomy; + if ( empty($t['args']) ) + $t['args'] = array(); + + $terms = get_object_term_cache($post->ID, $taxonomy); + if ( empty($terms) ) + $terms = wp_get_object_terms($post->ID, $taxonomy, $t['args']); + + $values = array(); + + foreach ( $terms as $term ) + $values[] = $term->name; + $t['value'] = join(', ', $values); + + $form_fields[$taxonomy] = $t; + } + + // Merge default fields with their errors, so any key passed with the error (e.g. 'error', 'helps', 'value') will replace the default + // The recursive merge is easily traversed with array casting: foreach( (array) $things as $thing ) + $form_fields = array_merge_recursive($form_fields, (array) $errors); + + $form_fields = apply_filters('attachment_fields_to_edit', $form_fields, $post); + + return $form_fields; +} + +/** + * Retrieve HTML for media items of post gallery. + * + * The HTML markup retrieved will be created for the progress of SWF Upload + * component. Will also create link for showing and hiding the form to modify + * the image attachment. + * + * @since unknown + * + * @param int $post_id Optional. Post ID. + * @param array $errors Errors for attachment, if any. + * @return string + */ +function get_media_items( $post_id, $errors ) { + if ( $post_id ) { + $post = get_post($post_id); + if ( $post && $post->post_type == 'attachment' ) + $attachments = array($post->ID => $post); + else + $attachments = get_children( array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'orderby' => 'menu_order ASC, ID', 'order' => 'DESC') ); + } else { + if ( is_array($GLOBALS['wp_the_query']->posts) ) + foreach ( $GLOBALS['wp_the_query']->posts as $attachment ) + $attachments[$attachment->ID] = $attachment; + } + + $output = ''; + foreach ( (array) $attachments as $id => $attachment ) + if ( $item = get_media_item( $id, array( 'errors' => isset($errors[$id]) ? $errors[$id] : null) ) ) + $output .= "\n
    $item\n
    "; + + return $output; +} + +/** + * Retrieve HTML form for modifying the image attachment. + * + * @since unknown + * + * @param int $attachment_id Attachment ID for modification. + * @param string|array $args Optional. Override defaults. + * @return string HTML form for attachment. + */ +function get_media_item( $attachment_id, $args = null ) { + global $redir_tab; + + $default_args = array( 'errors' => null, 'send' => true, 'delete' => true, 'toggle' => true, 'show_title' => true ); + $args = wp_parse_args( $args, $default_args ); + extract( $args, EXTR_SKIP ); + + global $post_mime_types; + if ( ( $attachment_id = intval($attachment_id) ) && $thumb_url = get_attachment_icon_src( $attachment_id ) ) + $thumb_url = $thumb_url[0]; + else + return false; + + $toggle_on = __('Show'); + $toggle_off = __('Hide'); + + $post = get_post($attachment_id); + + $filename = basename($post->guid); + $title = attribute_escape($post->post_title); + + if ( $_tags = get_the_tags($attachment_id) ) { + foreach ( $_tags as $tag ) + $tags[] = $tag->name; + $tags = attribute_escape(join(', ', $tags)); + } + + $type = ''; + if ( isset($post_mime_types) ) { + $keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type)); + $type = array_shift($keys); + $type = ""; + } + + $form_fields = get_attachment_fields_to_edit($post, $errors); + + if ( $toggle ) { + $class = empty($errors) ? 'startclosed' : 'startopen'; + $toggle_links = " + $toggle_on + $toggle_off"; + } else { + $class = 'form-table'; + $toggle_links = ''; + } + + $display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case + $display_title = $show_title ? "
    " . wp_html_excerpt($display_title, 60) . "
    " : ''; + + $gallery = ( (isset($_REQUEST['tab']) && 'gallery' == $_REQUEST['tab']) || (isset($redir_tab) && 'gallery' == $redir_tab) ) ? true : false; + $order = ''; + + foreach ( $form_fields as $key => $val ) { + if ( 'menu_order' == $key ) { + if ( $gallery ) + $order = ''; + else + $order = ''; + + unset($form_fields['menu_order']); + break; + } + } + + $item = " + $type + $toggle_links + $order + $display_title + + + + + + + + + + + \n"; + + $defaults = array( + 'input' => 'text', + 'required' => false, + 'value' => '', + 'extra_rows' => array(), + ); + + $delete_href = wp_nonce_url("post.php?action=delete-post&post=$attachment_id", 'delete-post_' . $attachment_id); + if ( $send ) + $send = ""; + if ( $delete ) + $delete = "" . __('Delete') . ""; + if ( ( $send || $delete ) && !isset($form_fields['buttons']) ) + $form_fields['buttons'] = array('tr' => "\t\t\n"); + + $hidden_fields = array(); + + foreach ( $form_fields as $id => $field ) { + if ( $id{0} == '_' ) + continue; + + if ( !empty($field['tr']) ) { + $item .= $field['tr']; + continue; + } + + $field = array_merge($defaults, $field); + $name = "attachments[$attachment_id][$id]"; + + if ( $field['input'] == 'hidden' ) { + $hidden_fields[$name] = $field['value']; + continue; + } + + $required = $field['required'] ? '*' : ''; + $aria_required = $field['required'] ? " aria-required='true' " : ''; + $class = $id; + $class .= $field['required'] ? ' form-required' : ''; + + $item .= "\t\t\n\t\t\t\n\t\t\t\n\t\t\n"; + + $extra_rows = array(); + + if ( !empty($field['errors']) ) + foreach ( array_unique((array) $field['errors']) as $error ) + $extra_rows['error'][] = $error; + + if ( !empty($field['extra_rows']) ) + foreach ( $field['extra_rows'] as $class => $rows ) + foreach ( (array) $rows as $html ) + $extra_rows[$class][] = $html; + + foreach ( $extra_rows as $class => $rows ) + foreach ( $rows as $html ) + $item .= "\t\t\n"; + } + + if ( !empty($form_fields['_final']) ) + $item .= "\t\t\n"; + $item .= "\t\n"; + $item .= "\t
    $filename
    $post->post_mime_type
    " . mysql2date($post->post_date, get_option('time_format')) . "
    " . apply_filters('media_meta', '', $post) . "
    $send $delete +
    " . sprintf(__("You are about to delete %s."), $filename) . " " . __('Continue') . " + " . __('Cancel') . "
    "; + if ( !empty($field[$field['input']]) ) + $item .= $field[$field['input']]; + elseif ( $field['input'] == 'textarea' ) { + $item .= ""; + } else { + $item .= ""; + } + if ( !empty($field['helps']) ) + $item .= "

    " . join( "

    \n

    ", array_unique((array) $field['helps']) ) . '

    '; + $item .= "
    $html
    {$form_fields['_final']}
    \n"; + + foreach ( $hidden_fields as $name => $value ) + $item .= "\t\n"; + + if ( $post->post_parent < 1 && (int) $_REQUEST['post_id'] ) { + $parent = (int) $_REQUEST['post_id']; + $parent_name = "attachments[$attachment_id][post_parent]"; + + $item .= "\t\n"; + } + + return $item; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + */ +function media_upload_header() { + ?> + +
    + +
    + +
    + + + +
    +
    + + get_error_message(); ?> + +
    + + + + + + +
    + + +
    + +

    +
    + + + +
    + +

    + +

    + +
    + +

    + + +
    + + + +
    + + + +

    + + + + +
    +'.wp_specialchars($id->get_error_message()).'
    '; + exit; + } +} +?> + + + + + + + + + + +

    + + + +
    +
    + +
    +
    +
    + + + + + + + +
    + + + + + + + + + +
    + + add_query_arg( 'paged', '%#%' ), + 'format' => '', + 'prev_text' => __('«'), + 'next_text' => __('»'), + 'total' => ceil($wp_query->found_posts / 10), + 'current' => $_GET['paged'] +)); + +if ( $page_links ) + echo "
    $page_links
    "; +?> + +
    +posts WHERE post_type = 'attachment' ORDER BY post_date DESC"; + +$arc_result = $wpdb->get_results( $arc_query ); + +$month_count = count($arc_result); + +if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?> + + + + + +
    + +
    +
    +
    + +
    + + + + + + +
    + +
    +

    + + +

    +
    + + + + + required + + + + + + + + * + +

    + + + + + + + +

    ' . $alt_help . '

    + + + +

    + + + + + + + + + + + + + + + + +
    + + + +

    ' . __('Enter a link URL or click above for presets.') . '

    + + + + + + + + + +'; + +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @return unknown + */ +function type_url_form_audio() { + return ' + + + + + + + + + + + + + + +
    + + * +
    + + * +
    ' . __('Link text, e.g. "Still Alive by Jonathan Coulton"') . '
    + +
    +'; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @return unknown + */ +function type_url_form_video() { + return ' + + + + + + + + + + + + + + +
    + + * +
    + + * +
    ' . __('Link text, e.g. "Lucy on YouTube"') . '
    + +
    +'; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @return unknown + */ +function type_url_form_file() { + return ' + + + + + + + + + + + + + + +
    + + * +
    + + * +
    ' . __('Link text, e.g. "Ransom Demands (PDF)"') . '
    + +
    +'; +} + +/** + * {@internal Missing Short Description}} + * + * Support a GET parameter for disabling the flash uploader. + * + * @since unknown + * + * @param unknown_type $flash + * @return unknown + */ +function media_upload_use_flash($flash) { + if ( array_key_exists('flash', $_REQUEST) ) + $flash = !empty($_REQUEST['flash']); + return $flash; +} + +add_filter('flash_uploader', 'media_upload_use_flash'); + +/** + * {@internal Missing Short Description}} + * + * @since unknown + */ +function media_upload_flash_bypass() { + echo '

    '; + printf( __('You are using the Flash uploader. Problems? Try the Browser uploader instead.'), clean_url(add_query_arg('flash', 0)) ); + echo '

    '; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + */ +function media_upload_html_bypass() { + echo '

    '; + if ( array_key_exists('flash', $_REQUEST) ) + // the user manually selected the browser uploader, so let them switch back to Flash + printf( __('You are using the Browser uploader. Try the Flash uploader instead.'), clean_url(add_query_arg('flash', 1)) ); + else + // the user probably doesn't have Flash + printf( __('You are using the Browser uploader.') ); + + echo '

    '; +} + +add_action('post-flash-upload-ui', 'media_upload_flash_bypass'); +add_action('post-html-upload-ui', 'media_upload_html_bypass'); + +/** + * {@internal Missing Short Description}} + * + * Make sure the GET parameter sticks when we submit a form. + * + * @since unknown + * + * @param unknown_type $url + * @return unknown + */ +function media_upload_bypass_url($url) { + if ( array_key_exists('flash', $_REQUEST) ) + $url = add_query_arg('flash', intval($_REQUEST['flash'])); + return $url; +} + +add_filter('media_upload_form_url', 'media_upload_bypass_url'); + + + +add_filter('async_upload_image', 'get_media_item', 10, 2); +add_filter('async_upload_audio', 'get_media_item', 10, 2); +add_filter('async_upload_video', 'get_media_item', 10, 2); +add_filter('async_upload_file', 'get_media_item', 10, 2); + +add_action('media_upload_image', 'media_upload_image'); +add_action('media_upload_audio', 'media_upload_audio'); +add_action('media_upload_video', 'media_upload_video'); +add_action('media_upload_file', 'media_upload_file'); + +add_filter('media_upload_gallery', 'media_upload_gallery'); + +add_filter('media_upload_library', 'media_upload_library'); + +?> diff -uNr a/blog/wp-admin/includes/misc.php b/blog/wp-admin/includes/misc.php --- a/blog/wp-admin/includes/misc.php false +++ b/blog/wp-admin/includes/misc.php 53db82f637af51290d21663bd340c843985d71877c31e04b7295602322aa10651cf6c73d9be2a3391aa47105fef199d029ada3671b7fb29d200e3a6e13130343 @@ -0,0 +1,241 @@ + $markerline ) { + if (strpos($markerline, '# BEGIN ' . $marker) !== false) + $state = false; + if ( $state ) { + if ( $n + 1 < count( $markerdata ) ) + fwrite( $f, "{$markerline}\n" ); + else + fwrite( $f, "{$markerline}" ); + } + if (strpos($markerline, '# END ' . $marker) !== false) { + 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, "\n# BEGIN {$marker}\n" ); + foreach ( $insertion as $insertline ) + fwrite( $f, "{$insertline}\n" ); + fwrite( $f, "# END {$marker}\n" ); + } + fclose( $f ); + return true; + } else { + return false; + } +} + +/** + * Updates the htaccess file with the current rules if it is writable. + * + * Always writes to the file if it exists and is writable to ensure that we + * blank out old rules. + * + * @since unknown + */ +function save_mod_rewrite_rules() { + global $wp_rewrite; + + $home_path = get_home_path(); + $htaccess_file = $home_path.'.htaccess'; + + // If the file doesn't already exists check for write access to the directory and whether of not we have some rules. + // else check for write access to the file. + if ((!file_exists($htaccess_file) && is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks()) || is_writable($htaccess_file)) { + if ( got_mod_rewrite() ) { + $rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() ); + return insert_with_markers( $htaccess_file, 'WordPress', $rules ); + } + } + + return false; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $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 ); +} + +/** + * If siteurl or home changed, flush rewrite rules. + * + * @since unknown + * + * @param unknown_type $old_value + * @param unknown_type $value + */ +function update_home_siteurl( $old_value, $value ) { + global $wp_rewrite; + + if ( defined( "WP_INSTALLING" ) ) + return; + + // If home changed, write rewrite rules to new location. + $wp_rewrite->flush_rules(); +} + +add_action( 'update_option_home', 'update_home_siteurl', 10, 2 ); +add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 ); + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $url + * @return unknown + */ +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; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $vars + */ +function wp_reset_vars( $vars ) { + for ( $i=0; $iget_error_data() ) + $message = $message->get_error_message() . ': ' . $message->get_error_data(); + else + $message = $message->get_error_message(); + } + echo "

    $message

    \n"; +} + +?> diff -uNr a/blog/wp-admin/includes/plugin-install.php b/blog/wp-admin/includes/plugin-install.php --- a/blog/wp-admin/includes/plugin-install.php false +++ b/blog/wp-admin/includes/plugin-install.php 699f4e9e17889ad5f17628bb0b1bb3b232999ef2b04e2414c2d1fd3be930bc4019658bb001e198193018308efdff27d7dedefb7f11bfcbb525fca11375af6331 @@ -0,0 +1,894 @@ +per_page) ) + $args->per_page = 24; + + $args = apply_filters('plugins_api_args', $args, $action); //NOTE: Ensure that an object is returned via this filter. + $res = apply_filters('plugins_api', false, $action, $args); //NOTE: Allows a plugin to completely override the builtin WordPress.org API. + + if ( ! $res ) { + $request = wp_remote_post('http://api.wordpress.org/plugins/info/1.0/', array( 'body' => array('action' => $action, 'request' => serialize($args))) ); + if ( is_wp_error($request) ) { + $res = new WP_Error('plugins_api_failed', __('An Unexpected HTTP Error occured during the API request.

    Try again'), $request->get_error_message() ); + } else { + $res = unserialize($request['body']); + if ( ! $res ) + $res = new WP_Error('plugins_api_failed', __('An unknown error occured'), $request['body']); + } + } + + return apply_filters('plugins_api_result', $res, $action, $args); +} + +/** + * Retrieve popular WordPress plugin tags. + * + * @since 2.7.0 + * + * @param array $args + * @return array + */ +function install_popular_tags( $args = array() ) { + if ( ! ($cache = wp_cache_get('popular_tags', 'api')) && ! ($cache = get_option('wporg_popular_tags')) ) + add_option('wporg_popular_tags', array(), '', 'no'); ///No autoload. + + if ( $cache && $cache->timeout + 3 * 60 * 60 > time() ) + return $cache->cached; + + $tags = plugins_api('hot_tags', $args); + + if ( is_wp_error($tags) ) + return $tags; + + $cache = (object) array('timeout' => time(), 'cached' => $tags); + + update_option('wporg_popular_tags', $cache); + wp_cache_set('popular_tags', $cache, 'api'); + + return $tags; +} +add_action('install_plugins_search', 'install_search', 10, 1); + +/** + * Display search results and display as tag cloud. + * + * @since 2.7.0 + * + * @param string $page + */ +function install_search($page) { + $type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : ''; + $term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : ''; + + $args = array(); + + switch( $type ){ + case 'tag': + $args['tag'] = sanitize_title_with_dashes($term); + break; + case 'term': + $args['search'] = $term; + break; + case 'author': + $args['author'] = $term; + break; + } + + $args['page'] = $page; + + $api = plugins_api('query_plugins', $args); + + if ( is_wp_error($api) ) + wp_die($api); + + add_action('install_plugins_table_header', 'install_search_form'); + + display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); + + return; +} + +add_action('install_plugins_dashboard', 'install_dashboard'); +function install_dashboard() { + ?> +

    WordPress Plugin Directory or upload a plugin in .zip format via this page.') ?>

    + +

    + ' . __('[need help?]') . '') ?> +
    +


    + Term: Searches plugins names and descriptions for the specified term') ?>
    + Tag: Searches for plugins tagged as such') ?>
    + Author: Searches for plugins created by the Author, or which the Author contributed to.') ?>

    +
    + +

    +

    +
    + + + +
    + +

    +

    + clean_url( admin_url('plugin-install.php?tab=search&type=tag&s=' . urlencode($tag['name'])) ), + 'name' => $tag['name'], + 'id' => sanitize_title_with_dashes($tag['name']), + 'count' => $tag['count'] ); + echo wp_generate_tag_cloud($tags, array( 'single_text' => __('%d plugin'), 'multiple_text' => __('%d plugins') ) ); +} + +/** + * Display search form for searching plugins. + * + * @since 2.7.0 + */ +function install_search_form(){ + $type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : ''; + $term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : ''; + + ?>
    + + + +
    'featured', 'page' => $page); + $api = plugins_api('query_plugins', $args); + if ( is_wp_error($api) ) + wp_die($api); + display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); +} + +add_action('install_plugins_popular', 'install_popular', 10, 1); +/** + * Display popular plugins. + * + * @since 2.7.0 + * + * @param string $page + */ +function install_popular($page = 1) { + $args = array('browse' => 'popular', 'page' => $page); + $api = plugins_api('query_plugins', $args); + display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); +} + +add_action('install_plugins_new', 'install_new', 10, 1); +/** + * Display new plugins. + * + * @since 2.7.0 + * + * @param string $page + */ +function install_new($page = 1) { + $args = array('browse' => 'new', 'page' => $page); + $api = plugins_api('query_plugins', $args); + if ( is_wp_error($api) ) + wp_die($api); + display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); +} +add_action('install_plugins_updated', 'install_updated', 10, 1); + + +/** + * Display recently updated plugins. + * + * @since 2.7.0 + * + * @param string $page + */ +function install_updated($page = 1) { + $args = array('browse' => 'updated', 'page' => $page); + $api = plugins_api('query_plugins', $args); + display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); +} + +/** + * Display plugin content based on plugin list. + * + * @since 2.7.0 + * + * @param array $plugins List of plugins. + * @param string $page + * @param int $totalpages Number of pages. + */ +function display_plugins_table($plugins, $page = 1, $totalpages = 1){ + $type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : ''; + $term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : ''; + + $plugins_allowedtags = array('a' => array('href' => array(),'title' => array(), 'target' => array()), + 'abbr' => array('title' => array()),'acronym' => array('title' => array()), + 'code' => array(), 'pre' => array(), 'em' => array(),'strong' => array()); + +?> +
    +
    + +
    + add_query_arg('paged', '%#%', $url), + 'format' => '', + 'prev_text' => __('«'), + 'next_text' => __('»'), + 'total' => $totalpages, + 'current' => $page + )); + + if ( $page_links ) + echo "\t\t
    $page_links
    "; +?> +
    +
    + + + + + + + + + + + + + + + + + + + + + + + '; + + foreach( (array) $plugins as $plugin ){ + if ( is_object($plugin) ) + $plugin = (array) $plugin; + + $title = wp_kses($plugin['name'], $plugins_allowedtags); + $description = wp_kses($plugin['description'], $plugins_allowedtags); + $version = wp_kses($plugin['version'], $plugins_allowedtags); + + $name = strip_tags($title . ' ' . $version); + + $author = $plugin['author']; + if( ! empty($plugin['author']) ) + $author = ' ' . sprintf( __('By %s'), $author ) . '.'; + + $author = wp_kses($author, $plugins_allowedtags); + + if( isset($plugin['homepage']) ) + $title = '' . $title . ''; + + $action_links = array(); + $action_links[] = '' . __('Install') . ''; + + $action_links = apply_filters('plugin_install_action_links', $action_links, $plugin); + ?> + + + + + + + + + +
    ', __('No plugins match your request.'), '
    +
    +
    +
    <?php _e('5 stars') ?>
    +
    <?php _e('4 stars') ?>
    +
    <?php _e('3 stars') ?>
    +
    <?php _e('2 stars') ?>
    +
    <?php _e('1 star') ?>
    +
    +

    + +
    + $page_links
    "; ?> +
    + + + stripslashes( $_REQUEST['plugin'] ) )); + + if ( is_wp_error($api) ) + wp_die($api); + + $plugins_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()), + 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), + 'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(), + 'div' => array(), 'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(), + 'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(), + 'img' => array('src' => array(), 'class' => array(), 'alt' => array())); + //Sanitize HTML + foreach ( (array)$api->sections as $section_name => $content ) + $api->sections[$section_name] = wp_kses($content, $plugins_allowedtags); + foreach ( array('version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug') as $key ) + $api->$key = wp_kses($api->$key, $plugins_allowedtags); + + $section = isset($_REQUEST['section']) ? stripslashes( $_REQUEST['section'] ) : 'description'; //Default to the Description tab, Do not translate, API returns English. + if( empty($section) || ! isset($api->sections[ $section ]) ) + $section = array_shift( $section_titles = array_keys((array)$api->sections) ); + + iframe_header( __('Plugin Install') ); + echo "
    \n"; + echo "
      \n"; + foreach ( (array)$api->sections as $section_name => $content ) { + + $title = $section_name; + $title = ucwords(str_replace('_', ' ', $title)); + + $class = ( $section_name == $section ) ? ' class="current"' : ''; + $href = add_query_arg( array('tab' => $tab, 'section' => $section_name) ); + $href = clean_url($href); + $san_title = attribute_escape(sanitize_title_with_dashes($title)); + echo "\t
    • $title
    • \n"; + } + echo "
    \n"; + echo "
    \n"; + ?> +
    + download_link) ) : ?> +

    + response as $file => $plugin ) { + if ( $plugin->slug === $api->slug ) { + $type = 'update_available'; + $update_file = $file; + break; + } + } + if ( 'install' == $type && is_dir( WP_PLUGIN_DIR . '/' . $api->slug ) ) { + $installed_plugin = get_plugins('/' . $api->slug); + if ( ! empty($installed_plugin) ) { + $key = array_shift( $key = array_keys($installed_plugin) ); //Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers + if ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '>') ){ + $type = 'latest_installed'; + } elseif ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '<') ) { + $type = 'newer_installed'; + $newer_version = $installed_plugin[ $key ]['Version']; + } else { + //If the above update check failed, Then that probably means that the update checker has out-of-date information, force a refresh + delete_option('update_plugins'); + $update_file = $api->slug . '/' . $key; //This code branch only deals with a plugin which is in a folder the same name as its slug, Doesnt support plugins which have 'non-standard' names + $type = 'update_available'; + } + } + } + + switch ( $type ) : + default: + case 'install': + if ( current_user_can('install_plugins') ) : + ?> +

    + +

    +
      +version) ) : ?> +
    • version ?>
    • +author) ) : ?> +
    • author, '_blank') ?>
    • +last_updated) ) : ?> +
    • last_updated)) ) ?>
    • +requires) ) : ?> +
    • requires) ?>
    • +tested) ) : ?> +
    • tested ?>
    • +downloaded) ) : ?> +
    • downloaded), number_format_i18n($api->downloaded)) ?>
    • +slug) ) : ?> +
    • +homepage) ) : ?> +
    • + +
    +

    +
    +
    +
    <?php _e('5 stars') ?>
    +
    <?php _e('4 stars') ?>
    +
    <?php _e('3 stars') ?>
    +
    <?php _e('2 stars') ?>
    +
    <?php _e('1 star') ?>
    +
    + num_ratings), number_format_i18n($api->num_ratings)); ?> +
    +
    + tested, '>') ) + echo '

    ' . __('Warning: This plugin has not been tested with your current version of WordPress.') . '

    '; + else if ( version_compare($GLOBALS['wp_version'], $api->requires, '<') ) + echo '

    ' . __('Warning: This plugin has not been marked as compatible with your version of WordPress.') . '

    '; + foreach ( (array)$api->sections as $section_name => $content ) { + $title = $section_name; + $title[0] = strtoupper($title[0]); + $title = str_replace('_', ' ', $title); + + $content = links_add_base_url($content, 'http://wordpress.org/extend/plugins/' . $api->slug . '/'); + $content = links_add_target($content, '_blank'); + + $san_title = attribute_escape(sanitize_title_with_dashes($title)); + + $display = ( $section_name == $section ) ? 'block' : 'none'; + + echo "\t
    \n"; + echo "\t\t

    $title

    "; + echo $content; + echo "\t
    \n"; + } + echo "
    \n"; + + iframe_footer(); + exit; +} + + +add_action('install_plugins_upload', 'upload_plugin'); +function upload_plugin() { + + if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) ) + wp_die($uploads['error']); + + if ( !empty($_FILES) ) + $filename = $_FILES['pluginzip']['name']; + else if ( isset($_GET['package']) ) + $filename = $_GET['package']; + + check_admin_referer('plugin-upload'); + + echo '
    '; + echo '

    ', sprintf( __('Installing Plugin from file: %s'), basename($filename) ), '

    '; + + //Handle a newly uploaded file, Else assume it was + if ( !empty($_FILES) ) { + $filename = wp_unique_filename( $uploads['basedir'], $filename ); + $local_file = $uploads['basedir'] . '/' . $filename; + + // Move the file to the uploads dir + if ( false === @ move_uploaded_file( $_FILES['pluginzip']['tmp_name'], $local_file) ) + wp_die( sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path'])); + } else { + $local_file = $uploads['basedir'] . '/' . $filename; + } + + do_plugin_install_local_package($local_file, $filename); + echo '
    '; +} + +add_action('install_plugins_install', 'install_plugin'); + +/** + * Display plugin link and execute install. + * + * @since 2.7.0 + */ +function install_plugin() { + + $plugin = isset($_REQUEST['plugin']) ? stripslashes( $_REQUEST['plugin'] ) : ''; + + check_admin_referer('install-plugin_' . $plugin); + $api = plugins_api('plugin_information', array('slug' => $plugin, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth. + + if ( is_wp_error($api) ) + wp_die($api); + + echo '
    '; + echo '

    ', sprintf( __('Installing Plugin: %s'), $api->name . ' ' . $api->version ), '

    '; + + do_plugin_install($api->download_link, $api); + echo '
    '; + +} + +/** + * Retrieve plugin and install. + * + * @since 2.7.0 + * + * @param string $download_url Download URL. + * @param object $plugin_information Optional. Plugin information + */ +function do_plugin_install($download_url, $plugin_information = null) { + global $wp_filesystem; + + if ( empty($download_url) ) { + show_message( __('No plugin Specified') ); + return; + } + + $plugin = isset($_REQUEST['plugin']) ? stripslashes( $_REQUEST['plugin'] ) : ''; + + $url = 'plugin-install.php?tab=install'; + $url = add_query_arg(array('plugin' => $plugin, 'plugin_name' => stripslashes( $_REQUEST['plugin_name'] ), 'download_url' => stripslashes( $_REQUEST['download_url'] ) ), $url); + + $url = wp_nonce_url($url, 'install-plugin_' . $plugin); + if ( false === ($credentials = request_filesystem_credentials($url)) ) + return; + + if ( ! WP_Filesystem($credentials) ) { + request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again + return; + } + + if ( $wp_filesystem->errors->get_error_code() ) { + foreach ( $wp_filesystem->errors->get_error_messages() as $message ) + show_message($message); + return; + } + + $result = wp_install_plugin( $download_url, 'show_message' ); + + if ( is_wp_error($result) ) { + show_message($result); + show_message( __('Installation Failed') ); + } else { + show_message( sprintf(__('Successfully installed the plugin %s %s.'), $plugin_information->name, $plugin_information->version) ); + $plugin_file = $result; + + $install_actions = apply_filters('install_plugin_complete_actions', array( + 'activate_plugin' => '' . __('Activate Plugin') . '', + 'plugins_page' => '' . __('Return to Plugins page') . '' + ), $plugin_information, $plugin_file); + if ( ! empty($install_actions) ) + show_message('' . __('Actions:') . ' ' . implode(' | ', (array)$install_actions)); + } +} + +/** + * Install a plugin from a local file. + * + * @since 2.7.0 + * + * @param string $package Local Plugin zip + * @param string $filename Optional. Original filename + * @param object $plugin_information Optional. Plugin information + */ +function do_plugin_install_local_package($package, $filename = '') { + global $wp_filesystem; + + if ( empty($package) ) { + show_message( __('No plugin Specified') ); + return; + } + + if ( empty($filename) ) + $filename = basename($package); + + $url = 'plugin-install.php?tab=upload'; + $url = add_query_arg(array('package' => $filename), $url); + + $url = wp_nonce_url($url, 'plugin-upload'); + if ( false === ($credentials = request_filesystem_credentials($url)) ) + return; + + if ( ! WP_Filesystem($credentials) ) { + request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again + return; + } + + if ( $wp_filesystem->errors->get_error_code() ) { + foreach ( $wp_filesystem->errors->get_error_messages() as $message ) + show_message($message); + return; + } + + $result = wp_install_plugin_local_package( $package, 'show_message' ); + + if ( is_wp_error($result) ) { + show_message($result); + show_message( __('Installation Failed') ); + } else { + show_message( __('Successfully installed the plugin.') ); + $plugin_file = $result; + + $install_actions = apply_filters('install_plugin_complete_actions', array( + 'activate_plugin' => '' . __('Activate Plugin') . '', + 'plugins_page' => '' . __('Return to Plugins page') . '' + ), array(), $plugin_file); + if ( ! empty($install_actions) ) + show_message('' . __('Actions:') . ' ' . implode(' | ', (array)$install_actions)); + } +} + +/** + * Install plugin. + * + * @since 2.7.0 + * + * @param string $package + * @param string $feedback Optional. + * @return mixed. + */ +function wp_install_plugin($package, $feedback = '') { + global $wp_filesystem; + + if ( !empty($feedback) ) + add_filter('install_feedback', $feedback); + + // Is a filesystem accessor setup? + if ( ! $wp_filesystem || ! is_object($wp_filesystem) ) + WP_Filesystem(); + + if ( ! is_object($wp_filesystem) ) + return new WP_Error('fs_unavailable', __('Could not access filesystem.')); + + if ( $wp_filesystem->errors->get_error_code() ) + return new WP_Error('fs_error', __('Filesystem error'), $wp_filesystem->errors); + + //Get the base plugin folder + $plugins_dir = $wp_filesystem->wp_plugins_dir(); + if ( empty($plugins_dir) ) + return new WP_Error('fs_no_plugins_dir', __('Unable to locate WordPress Plugin directory.')); + + //And the same for the Content directory. + $content_dir = $wp_filesystem->wp_content_dir(); + if( empty($content_dir) ) + return new WP_Error('fs_no_content_dir', __('Unable to locate WordPress Content directory (wp-content).')); + + $plugins_dir = trailingslashit( $plugins_dir ); + $content_dir = trailingslashit( $content_dir ); + + if ( empty($package) ) + return new WP_Error('no_package', __('Install package not available.')); + + // Download the package + apply_filters('install_feedback', sprintf(__('Downloading plugin package from %s'), $package)); + $download_file = download_url($package); + + if ( is_wp_error($download_file) ) + return new WP_Error('download_failed', __('Download failed.'), $download_file->get_error_message()); + + $working_dir = $content_dir . 'upgrade/' . basename($package, '.zip'); + + // Clean up working directory + if ( $wp_filesystem->is_dir($working_dir) ) + $wp_filesystem->delete($working_dir, true); + + apply_filters('install_feedback', __('Unpacking the plugin package')); + // Unzip package to working directory + $result = unzip_file($download_file, $working_dir); + + // Once extracted, delete the package + @unlink($download_file); + + if ( is_wp_error($result) ) { + $wp_filesystem->delete($working_dir, true); + return $result; + } + + //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin + $filelist = array_keys( $wp_filesystem->dirlist($working_dir) ); + + if( $wp_filesystem->exists( $plugins_dir . $filelist[0] ) ) { + $wp_filesystem->delete($working_dir, true); + return new WP_Error('install_folder_exists', __('Folder already exists.'), $filelist[0] ); + } + + apply_filters('install_feedback', __('Installing the plugin')); + // Copy new version of plugin into place. + $result = copy_dir($working_dir, $plugins_dir); + if ( is_wp_error($result) ) { + $wp_filesystem->delete($working_dir, true); + return $result; + } + + //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin + $filelist = array_keys( $wp_filesystem->dirlist($working_dir) ); + + // Remove working directory + $wp_filesystem->delete($working_dir, true); + + if( empty($filelist) ) + return false; //We couldnt find any files in the working dir, therefor no plugin installed? Failsafe backup. + + $folder = $filelist[0]; + $plugin = get_plugins('/' . $folder); //Ensure to pass with leading slash + $pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list + + //Return the plugin files name. + return $folder . '/' . $pluginfiles[0]; +} + +/** + * Install plugin from local package + * + * @since 2.7.0 + * + * @param string $package + * @param string $feedback Optional. + * @return mixed. + */ +function wp_install_plugin_local_package($package, $feedback = '') { + global $wp_filesystem; + + if ( !empty($feedback) ) + add_filter('install_feedback', $feedback); + + // Is a filesystem accessor setup? + if ( ! $wp_filesystem || ! is_object($wp_filesystem) ) + WP_Filesystem(); + + if ( ! is_object($wp_filesystem) ) + return new WP_Error('fs_unavailable', __('Could not access filesystem.')); + + if ( $wp_filesystem->errors->get_error_code() ) + return new WP_Error('fs_error', __('Filesystem error'), $wp_filesystem->errors); + + //Get the base plugin folder + $plugins_dir = $wp_filesystem->wp_plugins_dir(); + if ( empty($plugins_dir) ) + return new WP_Error('fs_no_plugins_dir', __('Unable to locate WordPress Plugin directory.')); + + //And the same for the Content directory. + $content_dir = $wp_filesystem->wp_content_dir(); + if( empty($content_dir) ) + return new WP_Error('fs_no_content_dir', __('Unable to locate WordPress Content directory (wp-content).')); + + $plugins_dir = trailingslashit( $plugins_dir ); + $content_dir = trailingslashit( $content_dir ); + + if ( empty($package) ) + return new WP_Error('no_package', __('Install package not available.')); + + $working_dir = $content_dir . 'upgrade/' . basename($package, '.zip'); + + // Clean up working directory + if ( $wp_filesystem->is_dir($working_dir) ) + $wp_filesystem->delete($working_dir, true); + + apply_filters('install_feedback', __('Unpacking the plugin package')); + // Unzip package to working directory + $result = unzip_file($package, $working_dir); + + // Once extracted, delete the package + unlink($package); + + if ( is_wp_error($result) ) { + $wp_filesystem->delete($working_dir, true); + return $result; + } + + //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin + $filelist = array_keys( $wp_filesystem->dirlist($working_dir) ); + + if( $wp_filesystem->exists( $plugins_dir . $filelist[0] ) ) { + $wp_filesystem->delete($working_dir, true); + return new WP_Error('install_folder_exists', __('Folder already exists.'), $filelist[0] ); + } + + apply_filters('install_feedback', __('Installing the plugin')); + // Copy new version of plugin into place. + $result = copy_dir($working_dir, $plugins_dir); + if ( is_wp_error($result) ) { + $wp_filesystem->delete($working_dir, true); + return $result; + } + + //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin + $filelist = array_keys( $wp_filesystem->dirlist($working_dir) ); + + // Remove working directory + $wp_filesystem->delete($working_dir, true); + + if( empty($filelist) ) + return false; //We couldnt find any files in the working dir, therefor no plugin installed? Failsafe backup. + + $folder = $filelist[0]; + $plugin = get_plugins('/' . $folder); //Ensure to pass with leading slash + $pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list + + //Return the plugin files name. + return $folder . '/' . $pluginfiles[0]; +} + +?> diff -uNr a/blog/wp-admin/includes/plugin.php b/blog/wp-admin/includes/plugin.php --- a/blog/wp-admin/includes/plugin.php false +++ b/blog/wp-admin/includes/plugin.php 1074c32a9fe7ab3d4fb818f5aa4f2abe087a16715e743a842d2f5f47ca13605c743f03f0706cec96256505ddc17d81633c67918b120094ad1a5c5a55d7c9186c @@ -0,0 +1,1065 @@ + + * /* + * Plugin Name: Name of Plugin + * Plugin URI: Link to plugin information + * Description: Plugin Description + * Author: Plugin author's name + * Author URI: Link to the author's web site + * Version: Must be set in the plugin for WordPress 2.3+ + * Text Domain: Optional. Unique identifier, should be same as the one used in + * plugin_text_domain() + * Domain Path: Optional. Only useful if the translations are located in a + * folder above the plugin's base path. For example, if .mo files are + * located in the locale folder then Domain Path will be "/locale/" and + * must have the first slash. Defaults to the base folder the plugin is + * located in. + * * / # Remove the space to close comment + * + * + * Plugin data returned array contains the following: + * 'Name' - Name of the plugin, must be unique. + * 'Title' - Title of the plugin and the link to the plugin's web site. + * 'Description' - Description of what the plugin does and/or notes + * from the author. + * 'Author' - The author's name + * 'AuthorURI' - The authors web site address. + * 'Version' - The plugin version number. + * 'PluginURI' - Plugin web site address. + * 'TextDomain' - Plugin's text domain for localization. + * 'DomainPath' - Plugin's relative directory path to .mo files. + * + * Some users have issues with opening large files and manipulating the contents + * for want is usually the first 1kiB or 2kiB. This function stops pulling in + * the plugin contents when it has all of the required plugin data. + * + * The first 8kiB of the file will be pulled in and if the plugin data is not + * within that first 8kiB, then the plugin author should correct their plugin + * and move the plugin data headers to the top. + * + * The plugin file is assumed to have permissions to allow for scripts to read + * the file. This is not checked however and the file is only opened for + * reading. + * + * @link http://trac.wordpress.org/ticket/5651 Previous Optimizations. + * @link http://trac.wordpress.org/ticket/7372 Further and better Optimizations. + * @since 1.5.0 + * + * @param string $plugin_file Path to the plugin file + * @param bool $markup If the returned data should have HTML markup applied + * @param bool $translate If the returned data should be translated + * @return array See above for description. + */ +function get_plugin_data( $plugin_file, $markup = true, $translate = true ) { + // We don't need to write to the file, so just open for reading. + $fp = fopen($plugin_file, 'r'); + + // Pull only the first 8kiB of the file in. + $plugin_data = fread( $fp, 8192 ); + + // PHP will close file handle, but we are good citizens. + fclose($fp); + + preg_match( '|Plugin Name:(.*)$|mi', $plugin_data, $name ); + preg_match( '|Plugin URI:(.*)$|mi', $plugin_data, $uri ); + preg_match( '|Version:(.*)|i', $plugin_data, $version ); + preg_match( '|Description:(.*)$|mi', $plugin_data, $description ); + preg_match( '|Author:(.*)$|mi', $plugin_data, $author_name ); + preg_match( '|Author URI:(.*)$|mi', $plugin_data, $author_uri ); + preg_match( '|Text Domain:(.*)$|mi', $plugin_data, $text_domain ); + preg_match( '|Domain Path:(.*)$|mi', $plugin_data, $domain_path ); + + foreach ( array( 'name', 'uri', 'version', 'description', 'author_name', 'author_uri', 'text_domain', 'domain_path' ) as $field ) { + if ( !empty( ${$field} ) ) + ${$field} = trim(${$field}[1]); + else + ${$field} = ''; + } + + $plugin_data = array( + 'Name' => $name, 'Title' => $name, 'PluginURI' => $uri, 'Description' => $description, + 'Author' => $author_name, 'AuthorURI' => $author_uri, 'Version' => $version, + 'TextDomain' => $text_domain, 'DomainPath' => $domain_path + ); + if ( $markup || $translate ) + $plugin_data = _get_plugin_data_markup_translate($plugin_data, $markup, $translate); + return $plugin_data; +} + +function _get_plugin_data_markup_translate($plugin_data, $markup = true, $translate = true) { + + //Translate fields + if( $translate && ! empty($plugin_data['TextDomain']) ) { + if( ! empty( $plugin_data['DomainPath'] ) ) + load_plugin_textdomain($plugin_data['TextDomain'], dirname($plugin_file). $plugin_data['DomainPath']); + else + load_plugin_textdomain($plugin_data['TextDomain'], dirname($plugin_file)); + + foreach ( array('Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version') as $field ) + $plugin_data[ $field ] = translate($plugin_data[ $field ], $plugin_data['TextDomain']); + } + + //Apply Markup + if ( $markup ) { + if ( ! empty($plugin_data['PluginURI']) && ! empty($plugin_data['Name']) ) + $plugin_data['Title'] = '' . $plugin_data['Name'] . ''; + else + $plugin_data['Title'] = $plugin_data['Name']; + + if ( ! empty($plugin_data['AuthorURI']) ) + $plugin_data['Author'] = '' . $plugin_data['Author'] . ''; + + $plugin_data['Description'] = wptexturize( $plugin_data['Description'] ); + if( ! empty($plugin_data['Author']) ) + $plugin_data['Description'] .= ' ' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.'; + } + + $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()); + + // Sanitize all displayed data + $plugin_data['Title'] = wp_kses($plugin_data['Title'], $plugins_allowedtags); + $plugin_data['Version'] = wp_kses($plugin_data['Version'], $plugins_allowedtags); + $plugin_data['Description'] = wp_kses($plugin_data['Description'], $plugins_allowedtags); + $plugin_data['Author'] = wp_kses($plugin_data['Author'], $plugins_allowedtags); + + return $plugin_data; +} + +/** + * Check the plugins directory and retrieve all plugin files with plugin data. + * + * WordPress only supports plugin files in the base plugins directory + * (wp-content/plugins) and in one directory above the plugins directory + * (wp-content/plugins/my-plugin). The file it looks for has the plugin data and + * must be found in those two locations. It is recommended that do keep your + * plugin files in directories. + * + * The file with the plugin data is the file that will be included and therefore + * needs to have the main execution for the plugin. This does not mean + * everything must be contained in the file and it is recommended that the file + * be split for maintainability. Keep everything in one file for extreme + * optimization purposes. + * + * @since unknown + * + * @param string $plugin_folder Optional. Relative path to single plugin folder. + * @return array Key is the plugin file path and the value is an array of the plugin data. + */ +function get_plugins($plugin_folder = '') { + + if ( ! $cache_plugins = wp_cache_get('plugins', 'plugins') ) + $cache_plugins = array(); + + if ( isset($cache_plugins[ $plugin_folder ]) ) + return $cache_plugins[ $plugin_folder ]; + + $wp_plugins = array (); + $plugin_root = WP_PLUGIN_DIR; + if( !empty($plugin_folder) ) + $plugin_root .= $plugin_folder; + + // Files in wp-content/plugins directory + $plugins_dir = @ opendir( $plugin_root); + if ( $plugins_dir ) { + while (($file = readdir( $plugins_dir ) ) !== false ) { + if ( substr($file, 0, 1) == '.' ) + continue; + if ( is_dir( $plugin_root.'/'.$file ) ) { + $plugins_subdir = @ opendir( $plugin_root.'/'.$file ); + if ( $plugins_subdir ) { + while (($subfile = readdir( $plugins_subdir ) ) !== false ) { + if ( substr($subfile, 0, 1) == '.' ) + continue; + if ( substr($subfile, -4) == '.php' ) + $plugin_files[] = "$file/$subfile"; + } + } + } else { + if ( substr($file, -4) == '.php' ) + $plugin_files[] = $file; + } + } + } + @closedir( $plugins_dir ); + @closedir( $plugins_subdir ); + + if ( !$plugins_dir || !$plugin_files ) + return $wp_plugins; + + foreach ( $plugin_files as $plugin_file ) { + if ( !is_readable( "$plugin_root/$plugin_file" ) ) + continue; + + $plugin_data = get_plugin_data( "$plugin_root/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached. + + if ( empty ( $plugin_data['Name'] ) ) + continue; + + $wp_plugins[plugin_basename( $plugin_file )] = $plugin_data; + } + + uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a["Name"], $b["Name"] );' )); + + $cache_plugins[ $plugin_folder ] = $wp_plugins; + wp_cache_set('plugins', $cache_plugins, 'plugins'); + + return $wp_plugins; +} + +/** + * Check whether the plugin is active by checking the active_plugins list. + * + * @since 2.5.0 + * + * @param string $plugin Base plugin path from plugins directory. + * @return bool True, if in the active plugins list. False, not in the list. + */ +function is_plugin_active($plugin) { + return in_array($plugin, get_option('active_plugins')); +} + +/** + * Attempts activation of plugin in a "sandbox" and redirects on success. + * + * A plugin that is already activated will not attempt to be activated again. + * + * The way it works is by setting the redirection to the error before trying to + * include the plugin file. If the plugin fails, then the redirection will not + * be overwritten with the success message. Also, the options will not be + * updated and the activation hook will not be called on plugin error. + * + * It should be noted that in no way the below code will actually prevent errors + * within the file. The code should not be used elsewhere to replicate the + * "sandbox", which uses redirection to work. + * {@source 13 1} + * + * If any errors are found or text is outputted, then it will be captured to + * ensure that the success redirection will update the error redirection. + * + * @since unknown + * + * @param string $plugin Plugin path to main plugin file with plugin data. + * @param string $redirect Optional. URL to redirect to. + * @return WP_Error|null WP_Error on invalid file or null on success. + */ +function activate_plugin($plugin, $redirect = '') { + $current = get_option('active_plugins'); + $plugin = plugin_basename(trim($plugin)); + + $valid = validate_plugin($plugin); + if ( is_wp_error($valid) ) + return $valid; + + if ( !in_array($plugin, $current) ) { + if ( !empty($redirect) ) + wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error + ob_start(); + @include(WP_PLUGIN_DIR . '/' . $plugin); + $current[] = $plugin; + sort($current); + update_option('active_plugins', $current); + do_action('activate_' . $plugin); + ob_end_clean(); + } + + return null; +} + +/** + * Deactivate a single plugin or multiple plugins. + * + * The deactivation hook is disabled by the plugin upgrader by using the $silent + * parameter. + * + * @since unknown + * + * @param string|array $plugins Single plugin or list of plugins to deactivate. + * @param bool $silent Optional, default is false. Prevent calling deactivate hook. + */ +function deactivate_plugins($plugins, $silent= false) { + $current = get_option('active_plugins'); + + if ( !is_array($plugins) ) + $plugins = array($plugins); + + foreach ( $plugins as $plugin ) { + $plugin = plugin_basename($plugin); + if( ! is_plugin_active($plugin) ) + continue; + array_splice($current, array_search( $plugin, $current), 1 ); // Fixed Array-fu! + if ( ! $silent ) //Used by Plugin updater to internally deactivate plugin, however, not to notify plugins of the fact to prevent plugin output. + do_action('deactivate_' . trim( $plugin )); + } + + update_option('active_plugins', $current); +} + +/** + * Activate multiple plugins. + * + * When WP_Error is returned, it does not mean that one of the plugins had + * errors. It means that one or more of the plugins file path was invalid. + * + * The execution will be halted as soon as one of the plugins has an error. + * + * @since unknown + * + * @param string|array $plugins + * @param string $redirect Redirect to page after successful activation. + * @return bool|WP_Error True when finished or WP_Error if there were errors during a plugin activation. + */ +function activate_plugins($plugins, $redirect = '') { + if ( !is_array($plugins) ) + $plugins = array($plugins); + + $errors = array(); + foreach ( (array) $plugins as $plugin ) { + if ( !empty($redirect) ) + $redirect = add_query_arg('plugin', $plugin, $redirect); + $result = activate_plugin($plugin, $redirect); + if ( is_wp_error($result) ) + $errors[$plugin] = $result; + } + + if ( !empty($errors) ) + return new WP_Error('plugins_invalid', __('One of the plugins is invalid.'), $errors); + + return true; +} + +/** + * Remove directory and files of a plugin for a single or list of plugin(s). + * + * If the plugins parameter list is empty, false will be returned. True when + * completed. + * + * @since unknown + * + * @param array $plugins List of plugin + * @param string $redirect Redirect to page when complete. + * @return mixed + */ +function delete_plugins($plugins, $redirect = '' ) { + global $wp_filesystem; + + if( empty($plugins) ) + return false; + + $checked = array(); + foreach( $plugins as $plugin ) + $checked[] = 'checked[]=' . $plugin; + + ob_start(); + $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&' . implode('&', $checked), 'bulk-manage-plugins'); + if ( false === ($credentials = request_filesystem_credentials($url)) ) { + $data = ob_get_contents(); + ob_end_clean(); + if( ! empty($data) ){ + include_once( ABSPATH . 'wp-admin/admin-header.php'); + echo $data; + include( ABSPATH . 'wp-admin/admin-footer.php'); + exit; + } + return; + } + + if ( ! WP_Filesystem($credentials) ) { + request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again + $data = ob_get_contents(); + ob_end_clean(); + if( ! empty($data) ){ + include_once( ABSPATH . 'wp-admin/admin-header.php'); + echo $data; + include( ABSPATH . 'wp-admin/admin-footer.php'); + exit; + } + return; + } + + if ( $wp_filesystem->errors->get_error_code() ) { + return $wp_filesystem->errors; + } + + if ( ! is_object($wp_filesystem) ) + return new WP_Error('fs_unavailable', __('Could not access filesystem.')); + + if ( $wp_filesystem->errors->get_error_code() ) + return new WP_Error('fs_error', __('Filesystem error'), $wp_filesystem->errors); + + //Get the base plugin folder + $plugins_dir = $wp_filesystem->wp_plugins_dir(); + if ( empty($plugins_dir) ) + return new WP_Error('fs_no_plugins_dir', __('Unable to locate WordPress Plugin directory.')); + + $plugins_dir = trailingslashit( $plugins_dir ); + + $errors = array(); + + foreach( $plugins as $plugin_file ) { + // Run Uninstall hook + if ( is_uninstallable_plugin( $plugin_file ) ) + uninstall_plugin($plugin_file); + + $this_plugin_dir = trailingslashit( dirname($plugins_dir . $plugin_file) ); + // If plugin is in its own directory, recursively delete the directory. + if ( strpos($plugin_file, '/') && $this_plugin_dir != $plugins_dir ) //base check on if plugin includes directory seperator AND that its not the root plugin folder + $deleted = $wp_filesystem->delete($this_plugin_dir, true); + else + $deleted = $wp_filesystem->delete($plugins_dir . $plugin_file); + + if ( ! $deleted ) + $errors[] = $plugin_file; + } + + if ( ! empty($errors) ) + return new WP_Error('could_not_remove_plugin', sprintf(__('Could not fully remove the plugin(s) %s'), implode(', ', $errors)) ); + + // Force refresh of plugin update information + delete_option('update_plugins'); + + return true; +} + +function validate_active_plugins() { + $check_plugins = get_option('active_plugins'); + + // Sanity check. If the active plugin list is not an array, make it an + // empty array. + if ( !is_array($check_plugins) ) { + update_option('active_plugins', array()); + return; + } + + //Invalid is any plugin that is deactivated due to error. + $invalid = array(); + + // If a plugin file does not exist, remove it from the list of active + // plugins. + foreach ( $check_plugins as $check_plugin ) { + $result = validate_plugin($check_plugin); + if ( is_wp_error( $result ) ) { + $invalid[$check_plugin] = $result; + deactivate_plugins( $check_plugin, true); + } + } + return $invalid; +} + +/** + * Validate the plugin path. + * + * Checks that the file exists and {@link validate_file() is valid file}. + * + * @since unknown + * + * @param string $plugin Plugin Path + * @return WP_Error|int 0 on success, WP_Error on failure. + */ +function validate_plugin($plugin) { + if ( validate_file($plugin) ) + return new WP_Error('plugin_invalid', __('Invalid plugin path.')); + if ( ! file_exists(WP_PLUGIN_DIR . '/' . $plugin) ) + return new WP_Error('plugin_not_found', __('Plugin file does not exist.')); + + return 0; +} + +/** + * Whether the plugin can be uninstalled. + * + * @since 2.7.0 + * + * @param string $plugin Plugin path to check. + * @return bool Whether plugin can be uninstalled. + */ +function is_uninstallable_plugin($plugin) { + $file = plugin_basename($plugin); + + $uninstallable_plugins = (array) get_option('uninstall_plugins'); + if ( isset( $uninstallable_plugins[$file] ) || file_exists( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ) ) + return true; + + return false; +} + +/** + * Uninstall a single plugin. + * + * Calls the uninstall hook, if it is available. + * + * @since 2.7.0 + * + * @param string $plugin Relative plugin path from Plugin Directory. + */ +function uninstall_plugin($plugin) { + $file = plugin_basename($plugin); + + $uninstallable_plugins = (array) get_option('uninstall_plugins'); + if ( file_exists( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ) ) { + if ( isset( $uninstallable_plugins[$file] ) ) { + unset($uninstallable_plugins[$file]); + update_option('uninstall_plugins', $uninstallable_plugins); + } + unset($uninstallable_plugins); + + define('WP_UNINSTALL_PLUGIN', $file); + include WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php'; + + return true; + } + + if ( isset( $uninstallable_plugins[$file] ) ) { + $callable = $uninstallable_plugins[$file]; + unset($uninstallable_plugins[$file]); + update_option('uninstall_plugins', $uninstallable_plugins); + unset($uninstallable_plugins); + + include WP_PLUGIN_DIR . '/' . $file; + + add_action( 'uninstall_' . $file, $callable ); + do_action( 'uninstall_' . $file ); + } +} + +// +// Menu +// + +function add_menu_page( $page_title, $menu_title, $access_level, $file, $function = '', $icon_url = '' ) { + global $menu, $admin_page_hooks; + + $file = plugin_basename( $file ); + + $admin_page_hooks[$file] = sanitize_title( $menu_title ); + + $hookname = get_plugin_page_hookname( $file, '' ); + if (!empty ( $function ) && !empty ( $hookname )) + add_action( $hookname, $function ); + + if ( empty($icon_url) ) + $icon_url = 'images/generic.png'; + + $menu[] = array ( $menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url ); + + return $hookname; +} + +function add_object_page( $page_title, $menu_title, $access_level, $file, $function = '', $icon_url = '') { + global $menu, $admin_page_hooks, $_wp_last_object_menu; + + $file = plugin_basename( $file ); + + $admin_page_hooks[$file] = sanitize_title( $menu_title ); + + $hookname = get_plugin_page_hookname( $file, '' ); + if (!empty ( $function ) && !empty ( $hookname )) + add_action( $hookname, $function ); + + if ( empty($icon_url) ) + $icon_url = 'images/generic.png'; + + $_wp_last_object_menu++; + + $menu[$_wp_last_object_menu] = array ( $menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url ); + + return $hookname; +} + +function add_utility_page( $page_title, $menu_title, $access_level, $file, $function = '', $icon_url = '') { + global $menu, $admin_page_hooks, $_wp_last_utility_menu; + + $file = plugin_basename( $file ); + + $admin_page_hooks[$file] = sanitize_title( $menu_title ); + + $hookname = get_plugin_page_hookname( $file, '' ); + if (!empty ( $function ) && !empty ( $hookname )) + add_action( $hookname, $function ); + + if ( empty($icon_url) ) + $icon_url = 'images/generic.png'; + + $_wp_last_utility_menu++; + + $menu[$_wp_last_utility_menu] = array ( $menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url ); + + return $hookname; +} + +function add_submenu_page( $parent, $page_title, $menu_title, $access_level, $file, $function = '' ) { + global $submenu; + global $menu; + global $_wp_real_parent_file; + global $_wp_submenu_nopriv; + + $file = plugin_basename( $file ); + + $parent = plugin_basename( $parent); + if ( isset( $_wp_real_parent_file[$parent] ) ) + $parent = $_wp_real_parent_file[$parent]; + + if ( !current_user_can( $access_level ) ) { + $_wp_submenu_nopriv[$parent][$file] = true; + return false; + } + + // 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 && current_user_can( $parent_menu[1] ) ) + $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; +} + +/** + * Add sub menu page to the tools main menu. + * + * @param string $page_title + * @param unknown_type $menu_title + * @param unknown_type $access_level + * @param unknown_type $file + * @param unknown_type $function + * @return unknown + */ +function add_management_page( $page_title, $menu_title, $access_level, $file, $function = '' ) { + return add_submenu_page( 'tools.php', $page_title, $menu_title, $access_level, $file, $function ); +} + +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_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 add_users_page( $page_title, $menu_title, $access_level, $file, $function = '' ) { + if ( current_user_can('edit_users') ) + $parent = 'users.php'; + else + $parent = 'profile.php'; + return add_submenu_page( $parent, $page_title, $menu_title, $access_level, $file, $function ); +} + +function add_dashboard_page( $page_title, $menu_title, $access_level, $file, $function = '' ) { + return add_submenu_page( 'index.php', $page_title, $menu_title, $access_level, $file, $function ); +} + +function add_posts_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_media_page( $page_title, $menu_title, $access_level, $file, $function = '' ) { + return add_submenu_page( 'upload.php', $page_title, $menu_title, $access_level, $file, $function ); +} + +function add_links_page( $page_title, $menu_title, $access_level, $file, $function = '' ) { + return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $access_level, $file, $function ); +} + +function add_pages_page( $page_title, $menu_title, $access_level, $file, $function = '' ) { + return add_submenu_page( 'edit-pages.php', $page_title, $menu_title, $access_level, $file, $function ); +} + +function add_comments_page( $page_title, $menu_title, $access_level, $file, $function = '' ) { + return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $access_level, $file, $function ); +} + +// +// Pluggable Menu Support -- Private +// + +function get_admin_page_parent( $parent = '' ) { + global $parent_file; + global $menu; + global $submenu; + global $pagenow; + global $plugin_page; + global $_wp_real_parent_file; + global $_wp_menu_nopriv; + global $_wp_submenu_nopriv; + + if ( !empty ( $parent ) && 'admin.php' != $parent ) { + if ( isset( $_wp_real_parent_file[$parent] ) ) + $parent = $_wp_real_parent_file[$parent]; + return $parent; + } +/* + if ( !empty ( $parent_file ) ) { + if ( isset( $_wp_real_parent_file[$parent_file] ) ) + $parent_file = $_wp_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( $_wp_real_parent_file[$parent_file] ) ) + $parent_file = $_wp_real_parent_file[$parent_file]; + return $parent_file; + } + } + if ( isset( $_wp_menu_nopriv[$plugin_page] ) ) { + $parent_file = $plugin_page; + if ( isset( $_wp_real_parent_file[$parent_file] ) ) + $parent_file = $_wp_real_parent_file[$parent_file]; + return $parent_file; + } + } + + if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) { + $parent_file = $pagenow; + if ( isset( $_wp_real_parent_file[$parent_file] ) ) + $parent_file = $_wp_real_parent_file[$parent_file]; + return $parent_file; + } + + foreach (array_keys( $submenu ) as $parent) { + foreach ( $submenu[$parent] as $submenu_array ) { + if ( isset( $_wp_real_parent_file[$parent] ) ) + $parent = $_wp_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; + } + } + } + + if ( empty($parent_file) ) + $parent_file = ''; + return ''; +} + +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 { + $title = $menu_array[0]; + return $title; + } + } + } else { + foreach (array_keys( $submenu ) as $parent) { + foreach ( $submenu[$parent] as $submenu_array ) { + 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]; + } + + if ( $submenu_array[2] != $pagenow || isset( $_GET['page'] ) ) // not the current page + continue; + + if ( isset( $submenu_array[3] ) ) { + $title = $submenu_array[3]; + return $submenu_array[3]; + } else { + $title = $submenu_array[0]; + return $title; + } + } + } + } + + return $title; +} + +function get_plugin_page_hook( $plugin_page, $parent_page ) { + $hook = get_plugin_page_hookname( $plugin_page, $parent_page ); + if ( has_action($hook) ) + return $hook; + else + return null; +} + +function get_plugin_page_hookname( $plugin_page, $parent_page ) { + global $admin_page_hooks; + + $parent = get_admin_page_parent( $parent_page ); + + $page_type = 'admin'; + if ( empty ( $parent_page ) || 'admin.php' == $parent_page || isset( $admin_page_hooks[$plugin_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_type = $admin_page_hooks[$parent]; + } + + $plugin_name = preg_replace( '!\.php!', '', $plugin_page ); + + return $page_type.'_page_'.$plugin_name; +} + +function user_can_access_admin_page() { + global $pagenow; + global $menu; + global $submenu; + global $_wp_menu_nopriv; + global $_wp_submenu_nopriv; + global $plugin_page; + + $parent = get_admin_page_parent(); + + if ( isset( $_wp_submenu_nopriv[$parent][$pagenow] ) ) + return false; + + if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) ) + return false; + + if ( empty( $parent) ) { + if ( isset( $_wp_menu_nopriv[$pagenow] ) ) + return false; + if ( isset( $_wp_submenu_nopriv[$pagenow][$pagenow] ) ) + return false; + if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) + return false; + foreach (array_keys( $_wp_submenu_nopriv ) as $key ) { + if ( isset( $_wp_submenu_nopriv[$key][$pagenow] ) ) + return false; + if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$key][$plugin_page] ) ) + return false; + } + return true; + } + + if ( isset( $submenu[$parent] ) ) { + foreach ( $submenu[$parent] as $submenu_array ) { + if ( isset( $plugin_page ) && ( $submenu_array[2] == $plugin_page ) ) { + if ( current_user_can( $submenu_array[1] )) + return true; + else + return false; + } else if ( $submenu_array[2] == $pagenow ) { + if ( current_user_can( $submenu_array[1] )) + return true; + else + return false; + } + } + } + + foreach ( $menu as $menu_array ) { + if ( $menu_array[2] == $parent) { + if ( current_user_can( $menu_array[1] )) + return true; + else + return false; + } + } + + return true; +} + +/* Whitelist functions */ + +/** + * Register a setting and its sanitization callback + * + * @since 2.7.0 + * + * @param string $option_group A settings group name. Can be anything. + * @param string $option_name The name of an option to sanitize and save. + * @param unknown_type $sanitize_callback A callback function that sanitizes the option's value. + * @return unknown + */ +function register_setting($option_group, $option_name, $sanitize_callback = '') { + return add_option_update_handler($option_group, $option_name, $sanitize_callback); +} + +/** + * Unregister a setting + * + * @since 2.7.0 + * + * @param unknown_type $option_group + * @param unknown_type $option_name + * @param unknown_type $sanitize_callback + * @return unknown + */ +function unregister_setting($option_group, $option_name, $sanitize_callback = '') { + return remove_option_update_handler($option_group, $option_name, $sanitize_callback); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $option_group + * @param unknown_type $option_name + * @param unknown_type $sanitize_callback + */ +function add_option_update_handler($option_group, $option_name, $sanitize_callback = '') { + global $new_whitelist_options; + $new_whitelist_options[ $option_group ][] = $option_name; + if ( $sanitize_callback != '' ) + add_filter( "sanitize_option_{$option_name}", $sanitize_callback ); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $option_group + * @param unknown_type $option_name + * @param unknown_type $sanitize_callback + */ +function remove_option_update_handler($option_group, $option_name, $sanitize_callback = '') { + global $new_whitelist_options; + $pos = array_search( $option_name, $new_whitelist_options ); + if ( $pos !== false ) + unset( $new_whitelist_options[ $option_group ][ $pos ] ); + if ( $sanitize_callback != '' ) + remove_filter( "sanitize_option_{$option_name}", $sanitize_callback ); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $options + * @return unknown + */ +function option_update_filter( $options ) { + global $new_whitelist_options; + + if ( is_array( $new_whitelist_options ) ) + $options = add_option_whitelist( $new_whitelist_options, $options ); + + return $options; +} +add_filter( 'whitelist_options', 'option_update_filter' ); + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $new_options + * @param unknown_type $options + * @return unknown + */ +function add_option_whitelist( $new_options, $options = '' ) { + if( $options == '' ) { + global $whitelist_options; + } else { + $whitelist_options = $options; + } + foreach( $new_options as $page => $keys ) { + foreach( $keys as $key ) { + if ( !isset($whitelist_options[ $page ]) || !is_array($whitelist_options[ $page ]) ) { + $whitelist_options[ $page ] = array(); + $whitelist_options[ $page ][] = $key; + } else { + $pos = array_search( $key, $whitelist_options[ $page ] ); + if ( $pos === false ) + $whitelist_options[ $page ][] = $key; + } + } + } + return $whitelist_options; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $del_options + * @param unknown_type $options + * @return unknown + */ +function remove_option_whitelist( $del_options, $options = '' ) { + if( $options == '' ) { + global $whitelist_options; + } else { + $whitelist_options = $options; + } + foreach( $del_options as $page => $keys ) { + foreach( $keys as $key ) { + $pos = array_search( $key, $whitelist_options[ $page ] ); + if( $pos !== false ) + unset( $whitelist_options[ $page ][ $pos ] ); + } + } + return $whitelist_options; +} + +/** + * Output nonce, action, and option_page fields for a settings page. + * + * @since 2.7.0 + * + * @param string $option_group A settings group name. This should match the group name used in register_setting(). + */ +function settings_fields($option_group) { + echo ""; + echo ''; + wp_nonce_field("$option_group-options"); +} + +?> diff -uNr a/blog/wp-admin/includes/post.php b/blog/wp-admin/includes/post.php --- a/blog/wp-admin/includes/post.php false +++ b/blog/wp-admin/includes/post.php 699e0d47fcbaf5bf9e56f127cd4ec01831b6a0a32d1ed58bc284076ee2473fd2c2d3bca0edf5fb870a5e343a8e027536f89176d65fd8abc6eb6eef7978cab8f5 @@ -0,0 +1,1349 @@ + 31 ) ? 31 : $jj; + $jj = ($jj <= 0 ) ? date('j') : $jj; + $hh = ($hh > 23 ) ? $hh -24 : $hh; + $mn = ($mn > 59 ) ? $mn -60 : $mn; + $ss = ($ss > 59 ) ? $ss -60 : $ss; + $post_data['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss ); + $post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] ); + } + + return $post_data; +} + +/** + * Update an existing post with values provided in $_POST. + * + * @since unknown + * + * @param array $post_data Optional. + * @return int Post ID. + */ +function edit_post( $post_data = null ) { + + if ( empty($post_data) ) + $post_data = &$_POST; + + $post_ID = (int) $post_data['post_ID']; + + if ( 'page' == $post_data['post_type'] ) { + if ( !current_user_can( 'edit_page', $post_ID ) ) + wp_die( __('You are not allowed to edit this page.' )); + } else { + if ( !current_user_can( 'edit_post', $post_ID ) ) + wp_die( __('You are not allowed to edit this post.' )); + } + + // Autosave shouldn't save too soon after a real save + if ( 'autosave' == $post_data['action'] ) { + $post =& get_post( $post_ID ); + $now = time(); + $then = strtotime($post->post_date_gmt . ' +0000'); + $delta = AUTOSAVE_INTERVAL / 2; + if ( ($now - $then) < $delta ) + return $post_ID; + } + + $post_data = _wp_translate_postdata( true, $post_data ); + if ( is_wp_error($post_data) ) + wp_die( $post_data->get_error_message() ); + + if ( isset($post_data['visibility']) ) { + switch ( $post_data['visibility'] ) { + case 'public' : + $post_data['post_password'] = ''; + break; + case 'password' : + unset( $post_data['sticky'] ); + break; + case 'private' : + $post_data['post_status'] = 'private'; + $post_data['post_password'] = ''; + unset( $post_data['sticky'] ); + break; + } + } + + // Meta Stuff + if ( isset($post_data['meta']) && $post_data['meta'] ) { + foreach ( $post_data['meta'] as $key => $value ) + update_meta( $key, $value['key'], $value['value'] ); + } + + if ( isset($post_data['deletemeta']) && $post_data['deletemeta'] ) { + foreach ( $post_data['deletemeta'] as $key => $value ) + delete_meta( $key ); + } + + add_meta( $post_ID ); + + wp_update_post( $post_data ); + + // Reunite any orphaned attachments with their parent + if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) ) + $draft_ids = array(); + if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) ) + _relocate_children( $draft_temp_id, $post_ID ); + + // Now that we have an ID we can fix any attachment anchor hrefs + _fix_attachment_links( $post_ID ); + + wp_set_post_lock( $post_ID, $GLOBALS['current_user']->ID ); + + if ( current_user_can( 'edit_others_posts' ) ) { + if ( !empty($post_data['sticky']) ) + stick_post($post_ID); + else + unstick_post($post_ID); + } + + return $post_ID; +} + +/** + * {@internal Missing Short Description}} + * + * Updates all bulk edited posts/pages, adding (but not removing) tags and + * categories. Skips pages when they would be their own parent or child. + * + * @since unknown + * + * @return array + */ +function bulk_edit_posts( $post_data = null ) { + global $wpdb; + + if ( empty($post_data) ) + $post_data = &$_POST; + + if ( 'page' == $post_data['post_type'] ) { + if ( ! current_user_can( 'edit_pages' ) ) + wp_die( __('You are not allowed to edit pages.') ); + } else { + if ( ! current_user_can( 'edit_posts' ) ) + wp_die( __('You are not allowed to edit posts.') ); + } + + $post_IDs = array_map( intval, (array) $post_data['post'] ); + + $reset = array( 'post_author', 'post_status', 'post_password', 'post_parent', 'page_template', 'comment_status', 'ping_status', 'keep_private', 'tags_input', 'post_category', 'sticky' ); + foreach ( $reset as $field ) { + if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) ) + unset($post_data[$field]); + } + + if ( isset($post_data['post_category']) ) { + if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) ) + $new_cats = array_map( absint, $post_data['post_category'] ); + else + unset($post_data['post_category']); + } + + if ( isset($post_data['tags_input']) ) { + $new_tags = preg_replace( '/\s*,\s*/', ',', rtrim( trim($post_data['tags_input']), ' ,' ) ); + $new_tags = explode(',', $new_tags); + } + + if ( isset($post_data['post_parent']) && ($parent = (int) $post_data['post_parent']) ) { + $pages = $wpdb->get_results("SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'page'"); + $children = array(); + + for ( $i = 0; $i < 50 && $parent > 0; $i++ ) { + $children[] = $parent; + + foreach ( $pages as $page ) { + if ( $page->ID == $parent ) { + $parent = $page->post_parent; + break; + } + } + } + } + + $updated = $skipped = $locked = array(); + foreach ( $post_IDs as $post_ID ) { + + if ( isset($children) && in_array($post_ID, $children) ) { + $skipped[] = $post_ID; + continue; + } + + if ( wp_check_post_lock( $post_ID ) ) { + $locked[] = $post_ID; + continue; + } + + if ( isset($new_cats) ) { + $cats = (array) wp_get_post_categories($post_ID); + $post_data['post_category'] = array_unique( array_merge($cats, $new_cats) ); + } + + if ( isset($new_tags) ) { + $tags = wp_get_post_tags($post_ID, array('fields' => 'names')); + $post_data['tags_input'] = array_unique( array_merge($tags, $new_tags) ); + } + + $post_data['ID'] = $post_ID; + $updated[] = wp_update_post( $post_data ); + + if ( current_user_can( 'edit_others_posts' ) && isset( $post_data['sticky'] ) ) { + if ( 'sticky' == $post_data['sticky'] ) + stick_post( $post_ID ); + else + unstick_post( $post_ID ); + } + + } + + return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked ); +} + +/** + * Default post information to use when populating the "Write Post" form. + * + * @since unknown + * + * @return unknown + */ +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 = ''; + } + + $post_content = ''; + 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 = clean_url($_REQUEST['popupurl']); + $post_content = ''.$post_title.''."\n$text"; + } + + if ( !empty( $_REQUEST['excerpt'] ) ) + $post_excerpt = wp_specialchars( stripslashes( $_REQUEST['excerpt'] )); + else + $post_excerpt = ''; + + $post->ID = 0; + $post->post_name = ''; + $post->post_author = ''; + $post->post_date = ''; + $post->post_password = ''; + $post->post_status = 'draft'; + $post->post_type = 'post'; + $post->to_ping = ''; + $post->pinged = ''; + $post->comment_status = get_option( 'default_comment_status' ); + $post->ping_status = get_option( 'default_ping_status' ); + $post->post_pingback = get_option( 'default_pingback_flag' ); + $post->post_category = get_option( '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; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @return unknown + */ +function get_default_page_to_edit() { + $page = get_default_post_to_edit(); + $page->post_type = 'page'; + return $page; +} + +/** + * Get an existing post and format it for editing. + * + * @since unknown + * + * @param unknown_type $id + * @return unknown + */ +function get_post_to_edit( $id ) { + + $post = get_post( $id, OBJECT, 'edit' ); + + if ( $post->post_type == 'page' ) + $post->page_template = get_post_meta( $id, '_wp_page_template', true ); + + return $post; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $title + * @param unknown_type $content + * @param unknown_type $post_date + * @return unknown + */ +function post_exists($title, $content = '', $post_date = '') { + global $wpdb; + + $title = stripslashes($title); + $content = stripslashes($content); + $post_date = stripslashes($post_date); + + if (!empty ($post_date)) + $post_date = $wpdb->prepare("AND post_date = %s", $post_date); + + if (!empty ($title)) + return $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title = %s $post_date", $title) ); + else + if (!empty ($content)) + return $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_content = %s $post_date", $content) ); + + return 0; +} + +/** + * Creates a new post from the "Write Post" form using $_POST information. + * + * @since unknown + * + * @return unknown + */ +function wp_write_post() { + global $user_ID; + + if ( 'page' == $_POST['post_type'] ) { + if ( !current_user_can( 'edit_pages' ) ) + return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this blog.' ) ); + } else { + if ( !current_user_can( 'edit_posts' ) ) + return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this blog.' ) ); + } + + + // Check for autosave collisions + $temp_id = false; + if ( isset($_POST['temp_ID']) ) { + $temp_id = (int) $_POST['temp_ID']; + if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) ) + $draft_ids = array(); + foreach ( $draft_ids as $temp => $real ) + if ( time() + $temp > 86400 ) // 1 day: $temp is equal to -1 * time( then ) + unset($draft_ids[$temp]); + + if ( isset($draft_ids[$temp_id]) ) { // Edit, don't write + $_POST['post_ID'] = $draft_ids[$temp_id]; + unset($_POST['temp_ID']); + update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids ); + return edit_post(); + } + } + + $translated = _wp_translate_postdata( false ); + if ( is_wp_error($translated) ) + return $translated; + + if ( isset($_POST['visibility']) ) { + switch ( $_POST['visibility'] ) { + case 'public' : + $_POST['post_password'] = ''; + break; + case 'password' : + unset( $_POST['sticky'] ); + break; + case 'private' : + $_POST['post_status'] = 'private'; + $_POST['post_password'] = ''; + unset( $_POST['sticky'] ); + break; + } + } + + // Create the post. + $post_ID = wp_insert_post( $_POST ); + if ( is_wp_error( $post_ID ) ) + return $post_ID; + + if ( empty($post_ID) ) + return 0; + + add_meta( $post_ID ); + + // Reunite any orphaned attachments with their parent + if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) ) + $draft_ids = array(); + if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) ) + _relocate_children( $draft_temp_id, $post_ID ); + if ( $temp_id && $temp_id != $draft_temp_id ) + _relocate_children( $temp_id, $post_ID ); + + // Update autosave collision detection + if ( $temp_id ) { + $draft_ids[$temp_id] = $post_ID; + update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids ); + } + + // Now that we have an ID we can fix any attachment anchor hrefs + _fix_attachment_links( $post_ID ); + + wp_set_post_lock( $post_ID, $GLOBALS['current_user']->ID ); + + return $post_ID; +} + +/** + * Calls wp_write_post() and handles the errors. + * + * @since unknown + * + * @return unknown + */ +function write_post() { + $result = wp_write_post(); + if( is_wp_error( $result ) ) + wp_die( $result->get_error_message() ); + else + return $result; +} + +// +// Post Meta +// + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $post_ID + * @return unknown + */ +function add_meta( $post_ID ) { + global $wpdb; + $post_ID = (int) $post_ID; + + $protected = array( '_wp_attached_file', '_wp_attachment_metadata', '_wp_old_slug', '_wp_page_template' ); + + $metakeyselect = isset($_POST['metakeyselect']) ? stripslashes( trim( $_POST['metakeyselect'] ) ) : ''; + $metakeyinput = isset($_POST['metakeyinput']) ? stripslashes( trim( $_POST['metakeyinput'] ) ) : ''; + $metavalue = isset($_POST['metavalue']) ? maybe_serialize( 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 + + if ( in_array($metakey, $protected) ) + return false; + + wp_cache_delete($post_ID, 'post_meta'); + + $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->postmeta (post_id,meta_key,meta_value ) VALUES (%s, %s, %s)", $post_ID, $metakey, $metavalue) ); + return $wpdb->insert_id; + } + return false; +} // add_meta + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $mid + * @return unknown + */ +function delete_meta( $mid ) { + global $wpdb; + $mid = (int) $mid; + + $post_id = $wpdb->get_var( $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_id = %d", $mid) ); + wp_cache_delete($post_id, 'post_meta'); + + return $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_id = %d", $mid) ); +} + +/** + * Get a list of previously defined keys. + * + * @since unknown + * + * @return unknown + */ +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; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $mid + * @return unknown + */ +function get_post_meta_by_id( $mid ) { + global $wpdb; + $mid = (int) $mid; + + $meta = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE meta_id = %d", $mid) ); + if ( is_serialized_string( $meta->meta_value ) ) + $meta->meta_value = maybe_unserialize( $meta->meta_value ); + return $meta; +} + +/** + * {@internal Missing Short Description}} + * + * Some postmeta stuff. + * + * @since unknown + * + * @param unknown_type $postid + * @return unknown + */ +function has_meta( $postid ) { + global $wpdb; + + return $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value, meta_id, post_id + FROM $wpdb->postmeta WHERE post_id = %d + ORDER BY meta_key,meta_id", $postid), ARRAY_A ); + +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $meta_id + * @param unknown_type $meta_key + * @param unknown_type $meta_value + * @return unknown + */ +function update_meta( $meta_id, $meta_key, $meta_value ) { + global $wpdb; + + $protected = array( '_wp_attached_file', '_wp_attachment_metadata', '_wp_old_slug', '_wp_page_template' ); + + if ( in_array($meta_key, $protected) ) + return false; + + $post_id = $wpdb->get_var( $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_id = %d", $meta_id) ); + wp_cache_delete($post_id, 'post_meta'); + + $meta_value = maybe_serialize( stripslashes( $meta_value )); + $meta_id = (int) $meta_id; + + $data = compact( 'meta_key', 'meta_value' ); + $where = compact( 'meta_id' ); + + return $wpdb->update( $wpdb->postmeta, $data, $where ); +} + +// +// Private +// + +/** + * Replace hrefs of attachment anchors with up-to-date permalinks. + * + * @since unknown + * @access private + * + * @param unknown_type $post_ID + * @return unknown + */ +function _fix_attachment_links( $post_ID ) { + + $post = & get_post( $post_ID, ARRAY_A ); + + $search = "#]+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 = "#[\s]+rel=(\"|')(.*?)wp-att-(\d+)\\1#i"; + foreach ( $anchor_matches[0] as $anchor ) { + if ( 0 == preg_match( $search, $anchor, $id_matches ) ) + continue; + + $id = (int) $id_matches[3]; + + // 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); +} + +/** + * Move child posts to a new parent. + * + * @since unknown + * @access private + * + * @param unknown_type $old_ID + * @param unknown_type $new_ID + * @return unknown + */ +function _relocate_children( $old_ID, $new_ID ) { + global $wpdb; + $old_ID = (int) $old_ID; + $new_ID = (int) $new_ID; + return $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = %d WHERE post_parent = %d", $new_ID, $old_ID) ); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $type + * @return unknown + */ +function get_available_post_statuses($type = 'post') { + $stati = wp_count_posts($type); + + return array_keys(get_object_vars($stati)); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $q + * @return unknown + */ +function wp_edit_posts_query( $q = false ) { + if ( false === $q ) + $q = $_GET; + $q['m'] = isset($q['m']) ? (int) $q['m'] : 0; + $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0; + $post_stati = array( // array( adj, noun ) + 'publish' => array(__('Published'), __('Published posts'), __ngettext_noop('Published (%s)', 'Published (%s)')), + 'future' => array(__('Scheduled'), __('Scheduled posts'), __ngettext_noop('Scheduled (%s)', 'Scheduled (%s)')), + 'pending' => array(__('Pending Review'), __('Pending posts'), __ngettext_noop('Pending Review (%s)', 'Pending Review (%s)')), + 'draft' => array(__('Draft'), _c('Drafts|manage posts header'), __ngettext_noop('Draft (%s)', 'Drafts (%s)')), + 'private' => array(__('Private'), __('Private posts'), __ngettext_noop('Private (%s)', 'Private (%s)')), + ); + + $post_stati = apply_filters('post_stati', $post_stati); + + $avail_post_stati = get_available_post_statuses('post'); + + $post_status_q = ''; + if ( isset($q['post_status']) && in_array( $q['post_status'], array_keys($post_stati) ) ) { + $post_status_q = '&post_status=' . $q['post_status']; + $post_status_q .= '&perm=readable'; + } + + if ( isset($q['post_status']) && 'pending' === $q['post_status'] ) { + $order = 'ASC'; + $orderby = 'modified'; + } elseif ( isset($q['post_status']) && 'draft' === $q['post_status'] ) { + $order = 'DESC'; + $orderby = 'modified'; + } else { + $order = 'DESC'; + $orderby = 'date'; + } + + wp("post_type=post&what_to_show=posts$post_status_q&posts_per_page=15&order=$order&orderby=$orderby"); + + return array($post_stati, $avail_post_stati); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $type + * @return unknown + */ +function get_available_post_mime_types($type = 'attachment') { + global $wpdb; + + $types = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT post_mime_type FROM $wpdb->posts WHERE post_type = %s", $type)); + return $types; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $q + * @return unknown + */ +function wp_edit_attachments_query( $q = false ) { + if ( false === $q ) + $q = $_GET; + + $q['m'] = isset( $q['m'] ) ? (int) $q['m'] : 0; + $q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0; + $q['post_type'] = 'attachment'; + $q['post_status'] = 'any'; + $q['posts_per_page'] = 15; + $post_mime_types = array( // array( adj, noun ) + 'image' => array(__('Images'), __('Manage Images'), __ngettext_noop('Image (%s)', 'Images (%s)')), + 'audio' => array(__('Audio'), __('Manage Audio'), __ngettext_noop('Audio (%s)', 'Audio (%s)')), + 'video' => array(__('Video'), __('Manage Video'), __ngettext_noop('Video (%s)', 'Video (%s)')), + ); + $post_mime_types = apply_filters('post_mime_types', $post_mime_types); + + $avail_post_mime_types = get_available_post_mime_types('attachment'); + + if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) ) + unset($q['post_mime_type']); + + wp($q); + + return array($post_mime_types, $avail_post_mime_types); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $id + * @param unknown_type $page + * @return unknown + */ +function postbox_classes( $id, $page ) { + if ( isset( $_GET['edit'] ) && $_GET['edit'] == $id ) + return ''; + $current_user = wp_get_current_user(); + if ( $closed = get_user_option('closedpostboxes_'.$page, 0, false ) ) { + if ( !is_array( $closed ) ) return ''; + return in_array( $id, $closed )? 'if-js-closed' : ''; + } else { + return ''; + } +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $id + * @param unknown_type $title + * @param unknown_type $name + * @return unknown + */ +function get_sample_permalink($id, $title=null, $name = null) { + $post = &get_post($id); + if (!$post->ID) { + return array('', ''); + } + $original_status = $post->post_status; + $original_date = $post->post_date; + $original_name = $post->post_name; + + // Hack: get_permalink would return ugly permalink for + // drafts, so we will fake, that our post is published + if (in_array($post->post_status, array('draft', 'pending'))) { + $post->post_status = 'publish'; + $post->post_name = sanitize_title($post->post_name? $post->post_name : $post->post_title, $post->ID); + } + + // If the user wants to set a new name -- override the current one + // Note: if empty name is supplied -- use the title instead, see #6072 + if (!is_null($name)) { + $post->post_name = sanitize_title($name? $name : $title, $post->ID); + } + + $permalink = get_permalink($post, true); + + // Handle page hierarchy + if ( 'page' == $post->post_type ) { + $uri = get_page_uri($post->ID); + $uri = untrailingslashit($uri); + $uri = strrev( stristr( strrev( $uri ), '/' ) ); + $uri = untrailingslashit($uri); + if ( !empty($uri) ) + $uri .='/'; + $permalink = str_replace('%pagename%', "${uri}%pagename%", $permalink); + } + + $permalink = array($permalink, apply_filters('editable_slug', $post->post_name)); + $post->post_status = $original_status; + $post->post_date = $original_date; + $post->post_name = $original_name; + return $permalink; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $id + * @param unknown_type $new_title + * @param unknown_type $new_slug + * @return unknown + */ +function get_sample_permalink_html($id, $new_title=null, $new_slug=null) { + $post = &get_post($id); + list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); + if (false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%')) { + return ''; + } + $title = __('Click to edit this part of the permalink'); + if (function_exists('mb_strlen')) { + if (mb_strlen($post_name) > 30) { + $post_name_abridged = mb_substr($post_name, 0, 14). '…' . mb_substr($post_name, -14); + } else { + $post_name_abridged = $post_name; + } + } else { + if (strlen($post_name) > 30) { + $post_name_abridged = substr($post_name, 0, 14). '…' . substr($post_name, -14); + } else { + $post_name_abridged = $post_name; + } + } + $post_name_html = ''.$post_name_abridged.''.$post_name.''; + $display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink); + $return = '' . __('Permalink:') . "\n" . '' . $display_link . "\n"; + $return .= '' . __('Edit') . "\n"; + return $return; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $post_id + * @return bool|int False: not locked or locked by current user. Int: user ID of user with lock. + */ +function wp_check_post_lock( $post_id ) { + global $current_user; + + if ( !$post = get_post( $post_id ) ) + return false; + + $lock = get_post_meta( $post->ID, '_edit_lock', true ); + $last = get_post_meta( $post->ID, '_edit_last', true ); + + $time_window = apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 ); + + if ( $lock && $lock > time() - $time_window && $last != $current_user->ID ) + return $last; + return false; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $post_id + * @return unknown + */ +function wp_set_post_lock( $post_id ) { + global $current_user; + if ( !$post = get_post( $post_id ) ) + return false; + if ( !$current_user || !$current_user->ID ) + return false; + + $now = time(); + + if ( !add_post_meta( $post->ID, '_edit_lock', $now, true ) ) + update_post_meta( $post->ID, '_edit_lock', $now ); + if ( !add_post_meta( $post->ID, '_edit_last', $current_user->ID, true ) ) + update_post_meta( $post->ID, '_edit_last', $current_user->ID ); +} + +/** + * Creates autosave data for the specified post from $_POST data. + * + * @package WordPress + * @subpackage Post_Revisions + * @since 2.6.0 + * + * @uses _wp_translate_postdata() + * @uses _wp_post_revision_fields() + */ +function wp_create_post_autosave( $post_id ) { + $translated = _wp_translate_postdata( true ); + if ( is_wp_error( $translated ) ) + return $translated; + + // Only store one autosave. If there is already an autosave, overwrite it. + if ( $old_autosave = wp_get_post_autosave( $post_id ) ) { + $new_autosave = _wp_post_revision_fields( $_POST, true ); + $new_autosave['ID'] = $old_autosave->ID; + return wp_update_post( $new_autosave ); + } + + // Otherwise create the new autosave as a special post revision + return _wp_put_post_revision( $_POST, true ); +} + +/** + * Save draft or manually autosave for showing preview. + * + * @package WordPress + * @since 2.7 + * + * @uses wp_write_post() + * @uses edit_post() + * @uses get_post() + * @uses current_user_can() + * @uses wp_create_post_autosave() + * + * @return str URL to redirect to show the preview + */ +function post_preview() { + + $post_ID = (int) $_POST['post_ID']; + if ( $post_ID < 1 ) + wp_die( __('Preview not available. Please save as a draft first.') ); + + if ( isset($_POST['catslist']) ) + $_POST['post_category'] = explode(",", $_POST['catslist']); + + if ( isset($_POST['tags_input']) ) + $_POST['tags_input'] = explode(",", $_POST['tags_input']); + + if ( $_POST['post_type'] == 'page' || empty($_POST['post_category']) ) + unset($_POST['post_category']); + + $_POST['ID'] = $post_ID; + $post = get_post($post_ID); + + if ( 'page' == $post->post_type ) { + if ( !current_user_can('edit_page', $post_ID) ) + wp_die(__('You are not allowed to edit this page.')); + } else { + if ( !current_user_can('edit_post', $post_ID) ) + wp_die(__('You are not allowed to edit this post.')); + } + + if ( 'draft' == $post->post_status ) { + $id = edit_post(); + } else { // Non drafts are not overwritten. The autosave is stored in a special post revision. + $id = wp_create_post_autosave( $post->ID ); + if ( ! is_wp_error($id) ) + $id = $post->ID; + } + + if ( is_wp_error($id) ) + wp_die( $id->get_error_message() ); + + if ( $_POST['post_status'] == 'draft' ) { + $url = add_query_arg( 'preview', 'true', get_permalink($id) ); + } else { + $nonce = wp_create_nonce('post_preview_' . $id); + $url = add_query_arg( array( 'preview' => 'true', 'preview_id' => $id, 'preview_nonce' => $nonce ), get_permalink($id) ); + } + + return $url; +} + +/** + * Adds the TinyMCE editor used on the Write and Edit screens. + * + * Has option to output a trimmed down version used in Press This. + * + * @package WordPress + * @since 2.7 + */ +function wp_tiny_mce( $teeny = false ) { + if ( ! user_can_richedit() ) + return; + + $baseurl = includes_url('js/tinymce'); + + $mce_css = $baseurl . '/wordpress.css'; + $mce_css = apply_filters('mce_css', $mce_css); + + $mce_locale = ( '' == get_locale() ) ? 'en' : strtolower( substr(get_locale(), 0, 2) ); // only ISO 639-1 + + /* + The following filter allows localization scripts to change the languages displayed in the spellchecker's drop-down menu. + By default it uses Google's spellchecker API, but can be configured to use PSpell/ASpell if installed on the server. + The + sign marks the default language. More information: + http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker + */ + $mce_spellchecker_languages = apply_filters('mce_spellchecker_languages', '+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv'); + + if ( $teeny ) { + $plugins = apply_filters( 'teeny_mce_plugins', array('safari', 'inlinepopups', 'media', 'autosave', 'fullscreen') ); + $ext_plugins = ''; + } else { + $plugins = array( 'safari', 'inlinepopups', 'autosave', 'spellchecker', 'paste', 'wordpress', 'media', 'fullscreen', 'wpeditimage', 'wpgallery' ); + + /* + The following filter takes an associative array of external plugins for TinyMCE in the form 'plugin_name' => 'url'. + It adds the plugin's name to TinyMCE's plugins init and the call to PluginManager to load the plugin. + The url should be absolute and should include the js file name to be loaded. Example: + array( 'myplugin' => 'http://my-site.com/wp-content/plugins/myfolder/mce_plugin.js' ) + If the plugin uses a button, it should be added with one of the "$mce_buttons" filters. + */ + $mce_external_plugins = apply_filters('mce_external_plugins', array()); + + $ext_plugins = "\n"; + if ( ! empty($mce_external_plugins) ) { + + /* + The following filter loads external language files for TinyMCE plugins. + It takes an associative array 'plugin_name' => 'path', where path is the + include path to the file. The language file should follow the same format as + /tinymce/langs/wp-langs.php and should define a variable $strings that + holds all translated strings. + When this filter is not used, the function will try to load {mce_locale}.js. + If that is not found, en.js will be tried next. + */ + $mce_external_languages = apply_filters('mce_external_languages', array()); + + $loaded_langs = array(); + $strings = ''; + + if ( ! empty($mce_external_languages) ) { + foreach ( $mce_external_languages as $name => $path ) { + if ( is_file($path) && is_readable($path) ) { + include_once($path); + $ext_plugins .= $strings; + $loaded_langs[] = $name; + } + } + } + + foreach ( $mce_external_plugins as $name => $url ) { + + if ( is_ssl() ) $url = str_replace('http://', 'https://', $url); + + $plugins[] = '-' . $name; + + $plugurl = dirname($url); + $strings = $str1 = $str2 = ''; + if ( ! in_array($name, $loaded_langs) ) { + $path = str_replace( WP_PLUGIN_URL, '', $plugurl ); + $path = WP_PLUGIN_DIR . $path . '/langs/'; + + if ( function_exists('realpath') ) + $path = trailingslashit( realpath($path) ); + + if ( is_file($path . $mce_locale . '.js') ) + $strings .= @file_get_contents($path . $mce_locale . '.js'); + + if ( is_file($path . $mce_locale . '_dlg.js') ) + $strings .= @file_get_contents($path . $mce_locale . '_dlg.js'); + + if ( 'en' != $mce_locale && empty($strings) ) { + if ( is_file($path . 'en.js') ) { + $str1 = @file_get_contents($path . 'en.js'); + $strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str1, 1 ); + } + + if ( is_file($path . 'en_dlg.js') ) { + $str2 = @file_get_contents($path . 'en_dlg.js'); + $strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str2, 1 ); + } + } + + if ( ! empty($strings) ) + $ext_plugins .= "\n" . $strings . "\n"; + } + + $ext_plugins .= 'tinyMCEPreInit.load_ext("' . $plugurl . '", "' . $mce_locale . '");' . "\n"; + $ext_plugins .= 'tinymce.PluginManager.load("' . $name . '", "' . $url . '");' . "\n"; + } + } + } + + $plugins = implode($plugins, ','); + + if ( $teeny ) { + $mce_buttons = apply_filters( 'teeny_mce_buttons', array('bold, italic, underline, blockquote, separator, strikethrough, bullist, numlist,justifyleft, justifycenter, justifyright, undo, redo, link, unlink, fullscreen') ); + $mce_buttons = implode($mce_buttons, ','); + $mce_buttons_2 = $mce_buttons_3 = $mce_buttons_4 = ''; + } else { + $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'blockquote', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'link', 'unlink', 'wp_more', '|', 'spellchecker', 'fullscreen', 'wp_adv' )); + $mce_buttons = implode($mce_buttons, ','); + + $mce_buttons_2 = apply_filters('mce_buttons_2', array('formatselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', 'removeformat', '|', 'media', 'charmap', '|', 'outdent', 'indent', '|', 'undo', 'redo', 'wp_help' )); + $mce_buttons_2 = implode($mce_buttons_2, ','); + + $mce_buttons_3 = apply_filters('mce_buttons_3', array()); + $mce_buttons_3 = implode($mce_buttons_3, ','); + + $mce_buttons_4 = apply_filters('mce_buttons_4', array()); + $mce_buttons_4 = implode($mce_buttons_4, ','); + } + $no_captions = ( apply_filters( 'disable_captions', '' ) ) ? true : false; + + // TinyMCE init settings + $initArray = array ( + 'mode' => 'none', + 'onpageload' => 'switchEditors.edInit', + 'width' => '100%', + 'theme' => 'advanced', + 'skin' => 'wp_theme', + 'theme_advanced_buttons1' => "$mce_buttons", + 'theme_advanced_buttons2' => "$mce_buttons_2", + 'theme_advanced_buttons3' => "$mce_buttons_3", + 'theme_advanced_buttons4' => "$mce_buttons_4", + 'language' => "$mce_locale", + 'spellchecker_languages' => "$mce_spellchecker_languages", + 'theme_advanced_toolbar_location' => 'top', + 'theme_advanced_toolbar_align' => 'left', + 'theme_advanced_statusbar_location' => 'bottom', + 'theme_advanced_resizing' => true, + 'theme_advanced_resize_horizontal' => false, + 'dialog_type' => 'modal', + 'relative_urls' => false, + 'remove_script_host' => false, + 'convert_urls' => false, + 'apply_source_formatting' => false, + 'remove_linebreaks' => true, + 'paste_convert_middot_lists' => true, + 'paste_remove_spans' => true, + 'paste_remove_styles' => true, + 'gecko_spellcheck' => true, + 'entities' => '38,amp,60,lt,62,gt', + 'accessibility_focus' => true, + 'tab_focus' => ':prev,:next', + 'content_css' => "$mce_css", + 'save_callback' => 'switchEditors.saveCallback', + 'wpeditimage_disable_captions' => $no_captions, + 'plugins' => "$plugins" + ); + + // For people who really REALLY know what they're doing with TinyMCE + // You can modify initArray to add, remove, change elements of the config before tinyMCE.init + // Setting "valid_elements", "invalid_elements" and "extended_valid_elements" can be done through "tiny_mce_before_init". + // Best is to use the default cleanup by not specifying valid_elements, as TinyMCE contains full set of XHTML 1.0. + if ( $teeny ) { + $initArray = apply_filters('teeny_mce_before_init', $initArray); + } else { + $initArray = apply_filters('tiny_mce_before_init', $initArray); + } + + $language = $initArray['language']; + + $ver = apply_filters('tiny_mce_version', '3101'); + + if ( 'en' != $language ) + include_once(ABSPATH . WPINC . '/js/tinymce/langs/wp-langs.php'); + + $mce_options = ''; + foreach ( $initArray as $k => $v ) + $mce_options .= $k . ':"' . $v . '", '; + + $mce_options = rtrim( trim($mce_options), '\n\r,' ); ?> + + + + + + + + + + + \ No newline at end of file diff -uNr a/blog/wp-admin/includes/schema.php b/blog/wp-admin/includes/schema.php --- a/blog/wp-admin/includes/schema.php false +++ b/blog/wp-admin/includes/schema.php bbf1a4ffa6dd91df5c9eeb0318a4dfbc8c167be6d34ae2bce5803dcef928e83cc54fd20ea8adbebecac4a3f07b9fbf76fa6989cd195610b4e5bd13412d5af2ff @@ -0,0 +1,533 @@ +has_cap( 'collation' ) ) { + if ( ! empty($wpdb->charset) ) + $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; + if ( ! empty($wpdb->collate) ) + $charset_collate .= " COLLATE $wpdb->collate"; +} + +/** Create WordPress database tables SQL */ +$wp_queries = "CREATE TABLE $wpdb->terms ( + term_id bigint(20) NOT NULL auto_increment, + name varchar(200) NOT NULL default '', + slug varchar(200) NOT NULL default '', + term_group bigint(10) NOT NULL default 0, + PRIMARY KEY (term_id), + UNIQUE KEY slug (slug), + KEY name (name) +) $charset_collate; +CREATE TABLE $wpdb->term_taxonomy ( + term_taxonomy_id bigint(20) NOT NULL auto_increment, + term_id bigint(20) NOT NULL default 0, + taxonomy varchar(32) NOT NULL default '', + description longtext NOT NULL, + parent bigint(20) NOT NULL default 0, + count bigint(20) NOT NULL default 0, + PRIMARY KEY (term_taxonomy_id), + UNIQUE KEY term_id_taxonomy (term_id,taxonomy) +) $charset_collate; +CREATE TABLE $wpdb->term_relationships ( + object_id bigint(20) NOT NULL default 0, + term_taxonomy_id bigint(20) NOT NULL default 0, + term_order int(11) NOT NULL default 0, + PRIMARY KEY (object_id,term_taxonomy_id), + KEY term_taxonomy_id (term_taxonomy_id) +) $charset_collate; +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 varchar(20) 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), + KEY comment_approved_date_gmt (comment_approved,comment_date_gmt), + KEY comment_date_gmt (comment_date_gmt) +) $charset_collate; +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 varchar(20) 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) +) $charset_collate; +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_value longtext NOT NULL, + autoload varchar(20) NOT NULL default 'yes', + PRIMARY KEY (option_id,blog_id,option_name), + KEY option_name (option_name) +) $charset_collate; +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) +) $charset_collate; +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 varchar(20) NOT NULL default 'publish', + comment_status varchar(20) NOT NULL default 'open', + ping_status varchar(20) 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), + KEY post_parent (post_parent) +) $charset_collate; +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 '', + PRIMARY KEY (ID), + KEY user_login_key (user_login), + KEY user_nicename (user_nicename) +) $charset_collate; +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) +) $charset_collate;"; + +/** + * Create WordPress options and set the default values. + * + * @since 1.5.0 + * @uses $wpdb + * @uses $wp_db_version + */ +function populate_options() { + global $wpdb, $wp_db_version; + + $guessurl = wp_guess_url(); + + do_action('populate_options'); + + add_option('siteurl', $guessurl); + add_option('blogname', __('My Blog')); + add_option('blogdescription', __('Just another WordPress weblog')); + 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', ''); + add_option('links_recently_updated_append', ''); + add_option('links_recently_updated_time', 120); + add_option('comment_moderation', 0); + add_option('moderation_notify', 1); + add_option('permalink_structure'); + 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); + add_option('recently_edited'); + add_option('use_linksupdate', 0); + add_option('template', 'default'); + add_option('stylesheet', 'default'); + add_option('comment_whitelist', 1); + add_option('page_uris'); + add_option('blacklist_keys'); + add_option('comment_registration', 0); + 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('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_DIR); + } else { + add_option('uploads_use_yearmonth_folders', 1); + add_option('upload_path', WP_CONTENT_DIR . '/uploads'); + } + + // 2.0.3 + add_option('secret', wp_generate_password(64)); + + // 2.1 + add_option('blog_public', '1'); + add_option('default_link_category', 2); + add_option('show_on_front', 'posts'); + + // 2.2 + add_option('tag_base'); + + // 2.5 + add_option('show_avatars', '1'); + add_option('avatar_rating', 'G'); + add_option('upload_url_path', ''); + add_option('thumbnail_size_w', 150); + add_option('thumbnail_size_h', 150); + add_option('thumbnail_crop', 1); + add_option('medium_size_w', 300); + add_option('medium_size_h', 300); + + // 2.6 + add_option('avatar_default', 'mystery'); + add_option('enable_app', 0); + add_option('enable_xmlrpc', 0); + + // 2.7 + add_option('large_size_w', 1024); + add_option('large_size_h', 1024); + add_option('image_default_link_type', 'file'); + add_option('image_default_size', ''); + add_option('image_default_align', ''); + add_option('close_comments_for_old_posts', 0); + add_option('close_comments_days_old', 14); + add_option('thread_comments', 0); + add_option('thread_comments_depth', 5); + add_option('page_comments', 1); + add_option('comments_per_page', 50); + add_option('default_comments_page', 'newest'); + add_option('comment_order', 'asc'); + add_option('use_ssl', 0); + add_option('sticky_posts', array()); + add_option('widget_categories', array()); + add_option('widget_text', array()); + add_option('widget_rss', array()); + add_option('update_core', array()); + add_option('dismissed_update_core', array()); + + // 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', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins'); + 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; +} + +/** + * Execute WordPress role creation for the various WordPress versions. + * + * @since 2.0.0 + */ +function populate_roles() { + populate_roles_160(); + populate_roles_210(); + populate_roles_230(); + populate_roles_250(); + populate_roles_260(); + populate_roles_270(); +} + +/** + * Create the roles for WordPress 2.0 + * + * @since 2.0.0 + */ +function populate_roles_160() { + // Add roles + + // Dummy gettext calls to get strings in the catalog. + _c('Administrator|User role'); + _c('Editor|User role'); + _c('Author|User role'); + _c('Contributor|User role'); + _c('Subscriber|User role'); + + add_role('administrator', 'Administrator|User role'); + add_role('editor', 'Editor|User role'); + add_role('author', 'Author|User role'); + add_role('contributor', 'Contributor|User role'); + add_role('subscriber', 'Subscriber|User role'); + + // 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('unfiltered_html'); + $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('unfiltered_html'); + $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'); +} + +/** + * Create and modify WordPress roles for WordPress 2.1. + * + * @since 2.1.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'); + } +} + +/** + * Create and modify WordPress roles for WordPress 2.3. + * + * @since 2.3.0 + */ +function populate_roles_230() { + $role = get_role( 'administrator' ); + + if ( !empty( $role ) ) { + $role->add_cap( 'unfiltered_upload' ); + } +} + +/** + * Create and modify WordPress roles for WordPress 2.5. + * + * @since 2.5.0 + */ +function populate_roles_250() { + $role = get_role( 'administrator' ); + + if ( !empty( $role ) ) { + $role->add_cap( 'edit_dashboard' ); + } +} + +/** + * Create and modify WordPress roles for WordPress 2.6. + * + * @since 2.6.0 + */ +function populate_roles_260() { + $role = get_role( 'administrator' ); + + if ( !empty( $role ) ) { + $role->add_cap( 'update_plugins' ); + $role->add_cap( 'delete_plugins' ); + } +} + +/** + * Create and modify WordPress roles for WordPress 2.7. + * + * @since 2.7.0 + */ +function populate_roles_270() { + $role = get_role( 'administrator' ); + + if ( !empty( $role ) ) { + $role->add_cap( 'install_plugins' ); + $role->add_cap( 'update_themes' ); + } +} + +?> diff -uNr a/blog/wp-admin/includes/taxonomy.php b/blog/wp-admin/includes/taxonomy.php --- a/blog/wp-admin/includes/taxonomy.php false +++ b/blog/wp-admin/includes/taxonomy.php d7d55cafd8774c7399d41234d1737c028f281dcdf3da8b1738c1ee7ee71d5c84824f992c8830b235e1f633720ba374e60caf3bebaf1382b2b165550308a62ca9 @@ -0,0 +1,242 @@ + $cat_name, 'category_parent' => $parent) ); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $categories + * @param unknown_type $post_id + * @return unknown + */ +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; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $cat_ID + * @return unknown + */ +function wp_delete_category($cat_ID) { + $cat_ID = (int) $cat_ID; + $default = get_option('default_category'); + + // Don't delete the default cat + if ( $cat_ID == $default ) + return 0; + + return wp_delete_term($cat_ID, 'category', array('default' => $default)); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $catarr + * @param unknown_type $wp_error + * @return unknown + */ +function wp_insert_category($catarr, $wp_error = false) { + $cat_defaults = array('cat_ID' => 0, 'cat_name' => '', 'category_description' => '', 'category_nicename' => '', 'category_parent' => ''); + $catarr = wp_parse_args($catarr, $cat_defaults); + extract($catarr, EXTR_SKIP); + + if ( trim( $cat_name ) == '' ) { + if ( ! $wp_error ) + return 0; + else + return new WP_Error( 'cat_name', __('You did not enter a category name.') ); + } + + $cat_ID = (int) $cat_ID; + + // Are we updating or creating? + if ( !empty ($cat_ID) ) + $update = true; + else + $update = false; + + $name = $cat_name; + $description = $category_description; + $slug = $category_nicename; + $parent = $category_parent; + + $parent = (int) $parent; + if ( $parent < 0 ) + $parent = 0; + + if ( empty($parent) || !category_exists( $parent ) || ($cat_ID && cat_is_ancestor_of($cat_ID, $parent) ) ) + $parent = 0; + + $args = compact('name', 'slug', 'parent', 'description'); + + if ( $update ) + $cat_ID = wp_update_term($cat_ID, 'category', $args); + else + $cat_ID = wp_insert_term($cat_name, 'category', $args); + + if ( is_wp_error($cat_ID) ) { + if ( $wp_error ) + return $cat_ID; + else + return 0; + } + + return $cat_ID['term_id']; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $catarr + * @return unknown + */ +function wp_update_category($catarr) { + $cat_ID = (int) $catarr['cat_ID']; + + if ( isset($catarr['category_parent']) && ($cat_ID == $catarr['category_parent']) ) + return false; + + // 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); +} + +// +// Tags +// + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $post_id + * @return unknown + */ +function get_tags_to_edit( $post_id ) { + $post_id = (int) $post_id; + if ( !$post_id ) + return false; + + $tags = wp_get_post_tags($post_id); + + if ( !$tags ) + return false; + + foreach ( $tags as $tag ) + $tag_names[] = $tag->name; + $tags_to_edit = join( ',', $tag_names ); + $tags_to_edit = attribute_escape( $tags_to_edit ); + $tags_to_edit = apply_filters( 'tags_to_edit', $tags_to_edit ); + return $tags_to_edit; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $tag_name + * @return unknown + */ +function tag_exists($tag_name) { + return is_term($tag_name, 'post_tag'); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $tag_name + * @return unknown + */ +function wp_create_tag($tag_name) { + if ( $id = tag_exists($tag_name) ) + return $id; + + return wp_insert_term($tag_name, 'post_tag'); +} + +?> diff -uNr a/blog/wp-admin/includes/template.php b/blog/wp-admin/includes/template.php --- a/blog/wp-admin/includes/template.php false +++ b/blog/wp-admin/includes/template.php 87cabc25e2b9635a0141baf0b5de4519ef127f902512ac3da1a5d472294957998a7803b43ba00a70ec583b4417def7ff49b334abd9be39825738f7e8a5699258 @@ -0,0 +1,3449 @@ + 0); + if ( !empty($_GET['s']) ) + $args['search'] = $_GET['s']; + $categories = get_categories( $args ); + } + + if ( !$categories ) + return false; + + $children = _get_term_hierarchy('category'); + + $start = ($page - 1) * $per_page; + $end = $start + $per_page; + $i = -1; + ob_start(); + foreach ( $categories as $category ) { + if ( $count >= $end ) + break; + + $i++; + + if ( $category->parent != $parent ) + continue; + + // If the page starts in a subtree, print the parents. + if ( $count == $start && $category->parent > 0 ) { + $my_parents = array(); + while ( $my_parent) { + $my_parent = get_category($my_parent); + $my_parents[] = $my_parent; + if ( !$my_parent->parent ) + break; + $my_parent = $my_parent->parent; + } + $num_parents = count($my_parents); + while( $my_parent = array_pop($my_parents) ) { + echo "\t" . _cat_row( $my_parent, $level - $num_parents ); + $num_parents--; + } + } + + if ( $count >= $start ) + echo "\t" . _cat_row( $category, $level ); + + unset($categories[$i]); // Prune the working set + $count++; + + if ( isset($children[$category->term_id]) ) + _cat_rows( $categories, $count, $category->term_id, $level + 1, $page, $per_page ); + + } + + $output = ob_get_contents(); + ob_end_clean(); + + echo $output; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $category + * @param unknown_type $level + * @param unknown_type $name_override + * @return unknown + */ +function _cat_row( $category, $level, $name_override = false ) { + static $row_class = ''; + + $category = get_category( $category, OBJECT, 'display' ); + + $default_cat_id = (int) get_option( 'default_category' ); + $pad = str_repeat( '— ', $level ); + $name = ( $name_override ? $name_override : $pad . ' ' . $category->name ); + $edit_link = "categories.php?action=edit&cat_ID=$category->term_id"; + if ( current_user_can( 'manage_categories' ) ) { + $edit = "name)) . "'>" . attribute_escape( $name ) . '
    '; + $actions = array(); + $actions['edit'] = '' . __('Edit') . ''; + $actions['inline hide-if-no-js'] = '' . __('Quick Edit') . ''; + if ( $default_cat_id != $category->term_id ) + $actions['delete'] = "term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this category '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . ""; + $action_count = count($actions); + $i = 0; + $edit .= '
    '; + foreach ( $actions as $action => $link ) { + ++$i; + ( $i == $action_count ) ? $sep = '' : $sep = ' | '; + $edit .= "$link$sep"; + } + $edit .= '
    '; + } else { + $edit = $name; + } + + $row_class = 'alternate' == $row_class ? '' : 'alternate'; + $qe_data = get_category_to_edit($category->term_id); + + $category->count = number_format_i18n( $category->count ); + $posts_count = ( $category->count > 0 ) ? "$category->count" : $category->count; + $output = ""; + + $columns = get_column_headers('categories'); + $hidden = get_hidden_columns('categories'); + foreach ( $columns as $column_name => $column_display_name ) { + $class = "class=\"$column_name column-$column_name\""; + + $style = ''; + if ( in_array($column_name, $hidden) ) + $style = ' style="display:none;"'; + + $attributes = "$class$style"; + + switch ($column_name) { + case 'cb': + $output .= ""; + if ( $default_cat_id != $category->term_id ) { + $output .= ""; + } else { + $output .= " "; + } + $output .= ''; + break; + case 'name': + $output .= "$edit"; + $output .= ''; + break; + case 'description': + $output .= "$category->description"; + break; + case 'slug': + $output .= "$category->slug"; + break; + case 'posts': + $attributes = 'class="posts column-posts num"' . $style; + $output .= "$posts_count\n"; + } + } + $output .= ''; + + return $output; +} + +/** + * {@internal Missing Short Description}} + * + * @since 2.7 + * + * Outputs the HTML for the hidden table rows used in Categories, Link Caregories and Tags quick edit. + * + * @param string $type "tag", "category" or "link-category" + * @return + */ +function inline_edit_term_row($type) { + + if ( ! current_user_can( 'manage_categories' ) ) + return; + + $is_tag = $type == 'edit-tags'; + $columns = get_column_headers($type); + $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($type) ) ); + $col_count = count($columns) - count($hidden); + ?> + +
    + +
    +name ); + $edit_link = "link-category.php?action=edit&cat_ID=$category->term_id"; + if ( current_user_can( 'manage_categories' ) ) { + $edit = "name)) . "'>$name
    "; + $actions = array(); + $actions['edit'] = '' . __('Edit') . ''; + $actions['inline hide-if-no-js'] = '' . __('Quick Edit') . ''; + if ( $default_cat_id != $category->term_id ) + $actions['delete'] = "term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this category '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . ""; + $action_count = count($actions); + $i = 0; + $edit .= '
    '; + foreach ( $actions as $action => $link ) { + ++$i; + ( $i == $action_count ) ? $sep = '' : $sep = ' | '; + $edit .= "$link$sep"; + } + $edit .= '
    '; + } else { + $edit = $name; + } + + $row_class = 'alternate' == $row_class ? '' : 'alternate'; + $qe_data = get_term_to_edit($category->term_id, 'link_category'); + + $category->count = number_format_i18n( $category->count ); + $count = ( $category->count > 0 ) ? "$category->count" : $category->count; + $output = ""; + $columns = get_column_headers('edit-link-categories'); + $hidden = get_hidden_columns('edit-link-categories'); + foreach ( $columns as $column_name => $column_display_name ) { + $class = "class=\"$column_name column-$column_name\""; + + $style = ''; + if ( in_array($column_name, $hidden) ) + $style = ' style="display:none;"'; + + $attributes = "$class$style"; + + switch ($column_name) { + case 'cb': + $output .= ""; + if ( absint( get_option( 'default_link_category' ) ) != $category->term_id ) { + $output .= ""; + } else { + $output .= " "; + } + $output .= ""; + break; + case 'name': + $output .= "$edit"; + $output .= ''; + break; + case 'description': + $output .= "$category->description"; + break; + case 'slug': + $output .= "$category->slug"; + break; + case 'links': + $attributes = 'class="links column-links num"' . $style; + $output .= "$count"; + } + } + $output .= ''; + + return $output; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $checked + * @param unknown_type $current + */ +function checked( $checked, $current) { + if ( $checked == $current) + echo ' checked="checked"'; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $selected + * @param unknown_type $current + */ +function selected( $selected, $current) { + if ( $selected == $current) + echo ' selected="selected"'; +} + +// +// Category Checklists +// + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * @deprecated Use {@link wp_link_category_checklist()} + * @see wp_link_category_checklist() + * + * @param unknown_type $default + * @param unknown_type $parent + * @param unknown_type $popular_ids + */ +function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) { + global $post_ID; + wp_category_checklist($post_ID); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + */ +class Walker_Category_Checklist extends Walker { + var $tree_type = 'category'; + var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this + + function start_lvl(&$output, $depth, $args) { + $indent = str_repeat("\t", $depth); + $output .= "$indent
      \n"; + } + + function end_lvl(&$output, $depth, $args) { + $indent = str_repeat("\t", $depth); + $output .= "$indent
    \n"; + } + + function start_el(&$output, $category, $depth, $args) { + extract($args); + + $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : ''; + $output .= "\n
  • " . ''; + } + + function end_el(&$output, $category, $depth, $args) { + $output .= "
  • \n"; + } +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $post_id + * @param unknown_type $descendants_and_self + * @param unknown_type $selected_cats + * @param unknown_type $popular_cats + */ +function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false ) { + $walker = new Walker_Category_Checklist; + $descendants_and_self = (int) $descendants_and_self; + + $args = array(); + + if ( is_array( $selected_cats ) ) + $args['selected_cats'] = $selected_cats; + elseif ( $post_id ) + $args['selected_cats'] = wp_get_post_categories($post_id); + else + $args['selected_cats'] = array(); + + if ( is_array( $popular_cats ) ) + $args['popular_cats'] = $popular_cats; + else + $args['popular_cats'] = get_terms( 'category', array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); + + if ( $descendants_and_self ) { + $categories = get_categories( "child_of=$descendants_and_self&hierarchical=0&hide_empty=0" ); + $self = get_category( $descendants_and_self ); + array_unshift( $categories, $self ); + } else { + $categories = get_categories('get=all'); + } + + // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache) + $checked_categories = array(); + for ( $i = 0; isset($categories[$i]); $i++ ) { + if ( in_array($categories[$i]->term_id, $args['selected_cats']) ) { + $checked_categories[] = $categories[$i]; + unset($categories[$i]); + } + } + + // Put checked cats on top + echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args)); + // Then the rest of them + echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args)); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $taxonomy + * @param unknown_type $default + * @param unknown_type $number + * @param unknown_type $echo + * @return unknown + */ +function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) { + global $post_ID; + if ( $post_ID ) + $checked_categories = wp_get_post_categories($post_ID); + else + $checked_categories = array(); + $categories = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) ); + + $popular_ids = array(); + foreach ( (array) $categories as $category ) { + $popular_ids[] = $category->term_id; + if ( !$echo ) // hack for AJAX use + continue; + $id = "popular-category-$category->term_id"; + ?> + + + + term_id; + $name = wp_specialchars( apply_filters('the_category', $category->name)); + $checked = in_array( $cat_id, $checked_categories ); + echo '"; + } +} + +// Tag stuff + +// Returns a single tag row (see tag_rows below) +// Note: this is also used in admin-ajax.php! +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $tag + * @param unknown_type $class + * @return unknown + */ +function _tag_row( $tag, $class = '' ) { + $count = number_format_i18n( $tag->count ); + $count = ( $count > 0 ) ? "$count" : $count; + + $name = apply_filters( 'term_name', $tag->name ); + $qe_data = get_term($tag->term_id, 'post_tag', object, 'edit'); + $edit_link = "edit-tags.php?action=edit&tag_ID=$tag->term_id"; + $out = ''; + $out .= ''; + $columns = get_column_headers('edit-tags'); + $hidden = get_hidden_columns('edit-tags'); + foreach ( $columns as $column_name => $column_display_name ) { + $class = "class=\"$column_name column-$column_name\""; + + $style = ''; + if ( in_array($column_name, $hidden) ) + $style = ' style="display:none;"'; + + $attributes = "$class$style"; + + switch ($column_name) { + case 'cb': + $out .= ' '; + break; + case 'name': + $out .= '' . $name . '
    '; + $actions = array(); + $actions['edit'] = '' . __('Edit') . ''; + $actions['inline hide-if-no-js'] = '' . __('Quick Edit') . ''; + $actions['delete'] = "term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this tag '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . ""; + $action_count = count($actions); + $i = 0; + $out .= '
    '; + foreach ( $actions as $action => $link ) { + ++$i; + ( $i == $action_count ) ? $sep = '' : $sep = ' | '; + $out .= "$link$sep"; + } + $out .= '
    '; + $out .= ''; + break; + case 'slug': + $out .= "$tag->slug"; + break; + case 'posts': + $attributes = 'class="posts column-posts num"' . $style; + $out .= "$count"; + break; + } + } + + $out .= ''; + + return $out; +} + +// Outputs appropriate rows for the Nth page of the Tag Management screen, +// assuming M tags displayed at a time on the page +// Returns the number of tags displayed +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $page + * @param unknown_type $pagesize + * @param unknown_type $searchterms + * @return unknown + */ +function tag_rows( $page = 1, $pagesize = 20, $searchterms = '' ) { + + // Get a page worth of tags + $start = ($page - 1) * $pagesize; + + $args = array('offset' => $start, 'number' => $pagesize, 'hide_empty' => 0); + + if ( !empty( $searchterms ) ) { + $args['search'] = $searchterms; + } + + $tags = get_terms( 'post_tag', $args ); + + // convert it to table rows + $out = ''; + $count = 0; + foreach( $tags as $tag ) + $out .= _tag_row( $tag, ++$count % 2 ? ' class="iedit alternate"' : ' class="iedit"' ); + + // filter and send to screen + echo $out; + return $count; +} + +// define the columns to display, the syntax is 'internal name' => 'display name' +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @return unknown + */ +function wp_manage_posts_columns() { + $posts_columns = array(); + $posts_columns['cb'] = ''; + $posts_columns['title'] = _c('Post|noun'); + $posts_columns['author'] = __('Author'); + $posts_columns['categories'] = __('Categories'); + $posts_columns['tags'] = __('Tags'); + if ( !isset($_GET['post_status']) || !in_array($_GET['post_status'], array('pending', 'draft', 'future')) ) + $posts_columns['comments'] = '
    Comments
    '; + $posts_columns['date'] = __('Date'); + $posts_columns = apply_filters('manage_posts_columns', $posts_columns); + + return $posts_columns; +} + +// define the columns to display, the syntax is 'internal name' => 'display name' +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @return unknown + */ +function wp_manage_media_columns() { + $posts_columns = array(); + $posts_columns['cb'] = ''; + $posts_columns['icon'] = ''; + $posts_columns['media'] = _c('File|media column header'); + $posts_columns['author'] = __('Author'); + //$posts_columns['tags'] = _c('Tags|media column header'); + $posts_columns['parent'] = _c('Attached to|media column header'); + $posts_columns['comments'] = '
    Comments
    '; + //$posts_columns['comments'] = __('Comments'); + $posts_columns['date'] = _c('Date|media column header'); + $posts_columns = apply_filters('manage_media_columns', $posts_columns); + + return $posts_columns; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @return unknown + */ +function wp_manage_pages_columns() { + $posts_columns = array(); + $posts_columns['cb'] = ''; + $posts_columns['title'] = __('Title'); + $posts_columns['author'] = __('Author'); + $post_status = 'all'; + if ( !empty($_GET['post_status']) ) + $post_status = $_GET['post_status']; + if ( !in_array($post_status, array('pending', 'draft', 'future')) ) + $posts_columns['comments'] = '
    '; + $posts_columns['date'] = __('Date'); + $posts_columns = apply_filters('manage_pages_columns', $posts_columns); + + return $posts_columns; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $page + * @return unknown + */ +function get_column_headers($page) { + global $_wp_column_headers; + + if ( !isset($_wp_column_headers) ) + $_wp_column_headers = array(); + + // Store in static to avoid running filters on each call + if ( isset($_wp_column_headers[$page]) ) + return $_wp_column_headers[$page]; + + switch ($page) { + case 'edit': + $_wp_column_headers[$page] = wp_manage_posts_columns(); + break; + case 'edit-pages': + $_wp_column_headers[$page] = wp_manage_pages_columns(); + break; + case 'edit-comments': + $_wp_column_headers[$page] = array( + 'cb' => '', + 'author' => __('Author'), + 'comment' => _c('Comment|noun'), + //'date' => __('Submitted'), + 'response' => __('In Response To') + ); + + break; + case 'link-manager': + $_wp_column_headers[$page] = array( + 'cb' => '', + 'name' => __('Name'), + 'url' => __('URL'), + 'categories' => __('Categories'), + 'rel' => __('rel'), + 'visible' => __('Visible') + ); + + break; + case 'upload': + $_wp_column_headers[$page] = wp_manage_media_columns(); + break; + case 'categories': + $_wp_column_headers[$page] = array( + 'cb' => '', + 'name' => __('Name'), + 'description' => __('Description'), + 'slug' => __('Slug'), + 'posts' => __('Posts') + ); + + break; + case 'edit-link-categories': + $_wp_column_headers[$page] = array( + 'cb' => '', + 'name' => __('Name'), + 'description' => __('Description'), + 'slug' => __('Slug'), + 'links' => __('Links') + ); + + break; + case 'edit-tags': + $_wp_column_headers[$page] = array( + 'cb' => '', + 'name' => __('Name'), + 'slug' => __('Slug'), + 'posts' => __('Posts') + ); + + break; + case 'users': + $_wp_column_headers[$page] = array( + 'cb' => '', + 'username' => __('Username'), + 'name' => __('Name'), + 'email' => __('E-mail'), + 'role' => __('Role'), + 'posts' => __('Posts') + ); + break; + default : + $_wp_column_headers[$page] = array(); + } + + $_wp_column_headers[$page] = apply_filters('manage_' . $page . '_columns', $_wp_column_headers[$page]); + return $_wp_column_headers[$page]; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $type + * @param unknown_type $id + */ +function print_column_headers( $type, $id = true ) { + $type = str_replace('.php', '', $type); + $columns = get_column_headers( $type ); + $hidden = get_hidden_columns($type); + $styles = array(); +// $styles['tag']['posts'] = 'width: 90px;'; +// $styles['link-category']['links'] = 'width: 90px;'; +// $styles['category']['posts'] = 'width: 90px;'; +// $styles['link']['visible'] = 'text-align: center;'; + + foreach ( $columns as $column_key => $column_display_name ) { + $class = ' class="manage-column'; + + $class .= " column-$column_key"; + + if ( 'cb' == $column_key ) + $class .= ' check-column'; + elseif ( in_array($column_key, array('posts', 'comments', 'links')) ) + $class .= ' num'; + + $class .= '"'; + + $style = ''; + if ( in_array($column_key, $hidden) ) + $style = 'display:none;'; + + if ( isset($styles[$type]) && isset($styles[$type][$column_key]) ) + $style .= ' ' . $styles[$type][$column_key]; + $style = ' style="' . $style . '"'; +?> + > + true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true ); + +?> + +
    + + + " style="display: none"> + +
    + +
    +

    + + + +
    +
    +
    + + + + + + + + + + + + + +
    + +
    +
    + +id, true, $type ); // TODO: ROLE SYSTEM + if ( $authors && count( $authors ) > 1 ) : + $users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'multi' => 1); + if ( $bulk ) + $users_opt['show_option_none'] = __('- No Change -'); +?> + + + + + + +
    + + + + + +
    + + + +
    + + + +
    + + + + +
      + +
    +
    + + + +
    + + + + + + + + + + + + + + + + + + + + + + + +
    + + + +
    + + + +
    + + + +
    + + + + +
    + + + + + + + + + + + + + + + + +
    + +
    + + $column_display_name ) { + if ( isset( $core_columns[$column_name] ) ) + continue; + do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $type); + } +?> +

    + + + + + + + + +
    +

    +
    +post_type, $post->ID) ) + return; + + $title = attribute_escape($post->post_title); + + echo ' +'; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $posts + */ +function post_rows( $posts = array() ) { + global $wp_query, $post, $mode; + + add_filter('the_title','wp_specialchars'); + + // Create array of post IDs. + $post_ids = array(); + + if ( empty($posts) ) + $posts = &$wp_query->posts; + + foreach ( $posts as $a_post ) + $post_ids[] = $a_post->ID; + + $comment_pending_count = get_pending_comments_num($post_ids); + if ( empty($comment_pending_count) ) + $comment_pending_count = array(); + + foreach ( $posts as $post ) { + if ( empty($comment_pending_count[$post->ID]) ) + $comment_pending_count[$post->ID] = 0; + + _post_row($post, $comment_pending_count[$post->ID], $mode); + } +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $a_post + * @param unknown_type $pending_comments + * @param unknown_type $mode + */ +function _post_row($a_post, $pending_comments, $mode) { + global $post; + static $rowclass; + + $global_post = $post; + $post = $a_post; + setup_postdata($post); + + $rowclass = 'alternate' == $rowclass ? '' : 'alternate'; + global $current_user; + $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' ); + $edit_link = get_edit_post_link( $post->ID ); + $title = _draft_or_post_title(); +?> + post_status ); ?> iedit' valign="top"> +$column_display_name ) { + $class = "class=\"$column_name column-$column_name\""; + + $style = ''; + if ( in_array($column_name, $hidden) ) + $style = ' style="display:none;"'; + + $attributes = "$class$style"; + + switch ($column_name) { + + case 'cb': + ?> + ID ) ) { ?> + post_date && 'date' == $column_name ) { + $t_time = $h_time = __('Unpublished'); + } else { + $t_time = get_the_time(__('Y/m/d g:i:s A')); + $m_time = $post->post_date; + $time = get_post_time('G', true, $post); + + $time_diff = time() - $time; + + if ( ( 'future' == $post->post_status) ) { + if ( $time_diff <= 0 ) { + $h_time = sprintf( __('%s from now'), human_time_diff( $time ) ); + } else { + $h_time = $t_time; + $missed = true; + } + } else { + + if ( $time_diff > 0 && $time_diff < 24*60*60 ) + $h_time = sprintf( __('%s ago'), human_time_diff( $time ) ); + else + $h_time = mysql2date(__('Y/m/d'), $m_time); + } + } + + echo ''; + if ( 'excerpt' == $mode ) + echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode); + else + echo '' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . ''; + echo '
    '; + if ( 'publish' == $post->post_status ) { + _e('Published'); + } elseif ( 'future' == $post->post_status ) { + if ( isset($missed) ) + echo '' . __('Missed schedule') . ''; + else + _e('Scheduled'); + } else { + _e('Last Modified'); + } + echo ''; + break; + + case 'title': + $attributes = 'class="post-title column-title"' . $style; + ?> + >ID ) ) { ?>"> + ID) ) { + $actions['edit'] = '' . __('Edit') . ''; + $actions['inline hide-if-no-js'] = '' . __('Quick Edit') . ''; + $actions['delete'] = "ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . ""; + } + if ( in_array($post->post_status, array('pending', 'draft')) ) { + if ( current_user_can('edit_post', $post->ID) ) + $actions['view'] = '' . __('Preview') . ''; + } else { + $actions['view'] = '' . __('View') . ''; + } + $action_count = count($actions); + $i = 0; + echo '
    '; + foreach ( $actions as $action => $link ) { + ++$i; + ( $i == $action_count ) ? $sep = '' : $sep = ' | '; + echo "$link$sep"; + } + echo '
    '; + + get_inline_data($post); + ?> + + + >slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . ""; + echo join( ', ', $out ); + } else { + _e('Uncategorized'); + } + ?> + + >ID); + if ( !empty( $tags ) ) { + $out = array(); + foreach ( $tags as $c ) + $out[] = " " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . ""; + echo join( ', ', $out ); + } else { + _e('No Tags'); + } + ?> + + >
    + '; + comments_number("" . __('0') . '', "" . __('1') . '', "" . __('%') . ''); + if ( $pending_comments ) + echo ''; + ?> +
    + + > + + + + ID) ) { echo "" . __('Edit') . ""; } ?> + + ID) ) { echo "ID) . "' class='delete'>" . __('Delete') . ""; } ?> + + >ID); ?> + + +post_title = wp_specialchars( $page->post_title ); + $pad = str_repeat( '— ', $level ); + $id = (int) $page->ID; + $rowclass = 'alternate' == $rowclass ? '' : 'alternate'; + $posts_columns = get_column_headers('edit-pages'); + $hidden = get_hidden_columns('edit-pages'); + $title = _draft_or_post_title(); +?> + +$column_display_name) { + $class = "class=\"$column_name column-$column_name\""; + + $style = ''; + if ( in_array($column_name, $hidden) ) + $style = ' style="display:none;"'; + + $attributes = "$class$style"; + + switch ($column_name) { + + case 'cb': + ?> + + post_date && 'date' == $column_name ) { + $t_time = $h_time = __('Unpublished'); + } else { + $t_time = get_the_time(__('Y/m/d g:i:s A')); + $m_time = $page->post_date; + $time = get_post_time('G', true); + + if ( ( abs(time() - $time) ) < 86400 ) { + if ( ( 'future' == $page->post_status) ) + $h_time = sprintf( __('%s from now'), human_time_diff( $time ) ); + else + $h_time = sprintf( __('%s ago'), human_time_diff( $time ) ); + } else { + $h_time = mysql2date(__('Y/m/d'), $m_time); + } + } + echo ''; + echo '' . apply_filters('post_date_column_time', $h_time, $page, $column_name, '') . ''; + echo '
    '; + if ( 'publish' == $page->post_status || 'future' == $page->post_status ) + _e('Published'); + else + _e('Last Modified'); + echo ''; + break; + case 'title': + $attributes = 'class="post-title page-title column-title"' . $style; + $edit_link = get_edit_post_link( $page->ID ); + ?> + >ID ) ) { ?>"> + ID) ) { + $actions['edit'] = '' . __('Edit') . ''; + $actions['inline'] = '' . __('Quick Edit') . ''; + $actions['delete'] = "ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $page->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this page '%s'\n 'Cancel' to stop, 'OK' to delete."), $page->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . ""; + } + if ( in_array($post->post_status, array('pending', 'draft')) ) { + if ( current_user_can('edit_page', $page->ID) ) + $actions['view'] = '' . __('Preview') . ''; + } else { + $actions['view'] = '' . __('View') . ''; + } + $action_count = count($actions); + + $i = 0; + echo '
    '; + foreach ( $actions as $action => $link ) { + ++$i; + ( $i == $action_count ) ? $sep = '' : $sep = ' | '; + echo "$link$sep"; + } + echo '
    '; + + get_inline_data($post); + echo ''; + break; + + case 'comments': + ?> + >
    + ID ); + $pending_phrase = sprintf( __('%s pending'), number_format( $left ) ); + if ( $left ) + echo ''; + comments_number("" . __('0') . '', "" . __('1') . '', "" . __('%') . ''); + if ( $left ) + echo ''; + ?> +
    + + > + + > + + + + + 'menu_order') ); + + if ( ! $pages ) + return false; + } + + /* + * arrange pages into two parts: top level pages and children_pages + * children_pages is two dimensional array, eg. + * children_pages[10][] contains all sub-pages whose parent is 10. + * It only takes O(N) to arrange this and it takes O(1) for subsequent lookup operations + * If searching, ignore hierarchy and treat everything as top level + */ + if ( empty($_GET['s']) ) { + + $top_level_pages = array(); + $children_pages = array(); + + foreach ( $pages as $page ) { + + // catch and repair bad pages + if ( $page->post_parent == $page->ID ) { + $page->post_parent = 0; + $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = '0' WHERE ID = %d", $page->ID) ); + clean_page_cache( $page->ID ); + } + + if ( 0 == $page->post_parent ) + $top_level_pages[] = $page; + else + $children_pages[ $page->post_parent ][] = $page; + } + + $pages = &$top_level_pages; + } + + $count = 0; + $start = ($pagenum - 1) * $per_page; + $end = $start + $per_page; + + foreach ( $pages as $page ) { + if ( $count >= $end ) + break; + + if ( $count >= $start ) + echo "\t" . display_page_row( $page, $level ); + + $count++; + + if ( isset($children_pages) ) + _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page ); + } + + // if it is the last pagenum and there are orphaned pages, display them with paging as well + if ( isset($children_pages) && $count < $end ){ + foreach( $children_pages as $orphans ){ + foreach ( $orphans as $op ) { + if ( $count >= $end ) + break; + if ( $count >= $start ) + echo "\t" . display_page_row( $op, 0 ); + $count++; + } + } + } +} + +/* + * Given a top level page ID, display the nested hierarchy of sub-pages + * together with paging support + */ +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $children_pages + * @param unknown_type $count + * @param unknown_type $parent + * @param unknown_type $level + * @param unknown_type $pagenum + * @param unknown_type $per_page + */ +function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) { + + if ( ! isset( $children_pages[$parent] ) ) + return; + + $start = ($pagenum - 1) * $per_page; + $end = $start + $per_page; + + foreach ( $children_pages[$parent] as $page ) { + + if ( $count >= $end ) + break; + + // If the page starts in a subtree, print the parents. + if ( $count == $start && $page->post_parent > 0 ) { + $my_parents = array(); + $my_parent = $page->post_parent; + while ( $my_parent) { + $my_parent = get_post($my_parent); + $my_parents[] = $my_parent; + if ( !$my_parent->post_parent ) + break; + $my_parent = $my_parent->post_parent; + } + $num_parents = count($my_parents); + while( $my_parent = array_pop($my_parents) ) { + echo "\t" . display_page_row( $my_parent, $level - $num_parents ); + $num_parents--; + } + } + + if ( $count >= $start ) + echo "\t" . display_page_row( $page, $level ); + + $count++; + + _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page ); + } + + unset( $children_pages[$parent] ); //required in order to keep track of orphans +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $user_object + * @param unknown_type $style + * @param unknown_type $role + * @return unknown + */ +function user_row( $user_object, $style = '', $role = '' ) { + global $wp_roles; + + $current_user = wp_get_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; + $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 ); + if ( current_user_can( 'edit_user', $user_object->ID ) ) { + if ($current_user->ID == $user_object->ID) { + $edit_link = 'profile.php'; + } else { + $edit_link = clean_url( add_query_arg( 'wp_http_referer', urlencode( clean_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" ) ); + } + $edit = "$user_object->user_login
    "; + $actions = array(); + $actions['edit'] = '' . __('Edit') . ''; + if ( $current_user->ID != $user_object->ID ) + $actions['delete'] = "" . __('Delete') . ""; + $action_count = count($actions); + $i = 0; + $edit .= '
    '; + foreach ( $actions as $action => $link ) { + ++$i; + ( $i == $action_count ) ? $sep = '' : $sep = ' | '; + $edit .= "$link$sep"; + } + $edit .= '
    '; + } else { + $edit = '' . $user_object->user_login . ''; + } + $role_name = isset($wp_roles->role_names[$role]) ? translate_with_context($wp_roles->role_names[$role]) : __('None'); + $r = ""; + $columns = get_column_headers('users'); + $hidden = get_hidden_columns('users'); + $avatar = get_avatar( $user_object->user_email, 32 ); + foreach ( $columns as $column_name => $column_display_name ) { + $class = "class=\"$column_name column-$column_name\""; + + $style = ''; + if ( in_array($column_name, $hidden) ) + $style = ' style="display:none;"'; + + $attributes = "$class$style"; + + switch ($column_name) { + case 'cb': + $r .= ""; + break; + case 'username': + $r .= "$avatar $edit"; + break; + case 'name': + $r .= "$user_object->first_name $user_object->last_name"; + break; + case 'email': + $r .= "$email"; + break; + case 'role': + $r .= "$role_name"; + break; + case 'posts': + $attributes = 'class="posts column-posts num"' . $style; + $r .= ""; + if ( $numposts > 0 ) { + $r .= ""; + $r .= $numposts; + $r .= ''; + } else { + $r .= 0; + } + $r .= ""; + } + } + $r .= ''; + + return $r; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $status + * @param unknown_type $s + * @param unknown_type $start + * @param unknown_type $num + * @param unknown_type $post + * @param unknown_type $type + * @return unknown + */ +function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0, $type = '' ) { + global $wpdb; + + $start = abs( (int) $start ); + $num = (int) $num; + $post = (int) $post; + + if ( 'moderated' == $status ) + $approved = "comment_approved = '0'"; + elseif ( 'approved' == $status ) + $approved = "comment_approved = '1'"; + elseif ( 'spam' == $status ) + $approved = "comment_approved = 'spam'"; + else + $approved = "( comment_approved = '0' OR comment_approved = '1' )"; + + if ( $post ) { + $post = " AND comment_post_ID = '$post'"; + $orderby = "ORDER BY comment_date_gmt ASC LIMIT $start, $num"; + } else { + $post = ''; + $orderby = "ORDER BY comment_date_gmt DESC LIMIT $start, $num"; + } + + if ( 'comment' == $type ) + $typesql = "AND comment_type = ''"; + elseif ( 'pingback' == $type ) + $typesql = "AND comment_type = 'pingback'"; + elseif ( 'trackback' == $type ) + $typesql = "AND comment_type = 'trackback'"; + elseif ( 'pings' == $type ) + $typesql = "AND ( comment_type = 'pingback' OR comment_type = 'trackback' )"; + else + $typesql = ''; + + if ( $s ) { + $s = $wpdb->escape($s); + $comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE + (comment_author LIKE '%$s%' OR + comment_author_email LIKE '%$s%' OR + comment_author_url LIKE ('%$s%') OR + comment_author_IP LIKE ('%$s%') OR + comment_content LIKE ('%$s%') ) AND + $approved + $typesql + $orderby"); + } else { + $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE $approved $post $typesql $orderby" ); + } + + update_comment_cache($comments); + + $total = $wpdb->get_var( "SELECT FOUND_ROWS()" ); + + return array($comments, $total); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $comment_id + * @param unknown_type $mode + * @param unknown_type $comment_status + * @param unknown_type $checkbox + */ +function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false ) { + global $comment, $post, $_comment_pending_count; + $comment = get_comment( $comment_id ); + $post = get_post($comment->comment_post_ID); + $the_comment_status = wp_get_comment_status($comment->comment_ID); + + $author_url = get_comment_author_url(); + if ( 'http://' == $author_url ) + $author_url = ''; + $author_url_display = $author_url; + $author_url_display = str_replace('http://www.', '', $author_url_display); + $author_url_display = str_replace('http://', '', $author_url_display); + if ( strlen($author_url_display) > 50 ) + $author_url_display = substr($author_url_display, 0, 49) . '...'; + + $ptime = date('G', strtotime( $comment->comment_date ) ); + if ( ( abs(time() - $ptime) ) < 86400 ) + $ptime = sprintf( __('%s ago'), human_time_diff( $ptime ) ); + else + $ptime = mysql2date(__('Y/m/d \a\t g:i A'), $comment->comment_date ); + + $delete_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&p=$post->ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) ); + $approve_url = clean_url( wp_nonce_url( "comment.php?action=approvecomment&p=$post->ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ) ); + $unapprove_url = clean_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ) ); + $spam_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$post->ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) ); + + echo ""; + $columns = get_column_headers('edit-comments'); + $hidden = get_hidden_columns('edit-comments'); + foreach ( $columns as $column_name => $column_display_name ) { + $class = "class=\"$column_name column-$column_name\""; + + $style = ''; + if ( in_array($column_name, $hidden) ) + $style = ' style="display:none;"'; + + $attributes = "$class$style"; + + switch ($column_name) { + case 'cb': + if ( !$checkbox ) break; + echo ''; + if ( current_user_can('edit_post', $post->ID) ) echo ""; + echo ''; + break; + case 'comment': + echo ""; + echo '
    '; + printf(__('Submitted on %2$s at %3$s'), get_comment_link($comment->comment_ID), get_comment_date(__('Y/m/d')), get_comment_date(__('g:ia'))); + echo '
    '; + comment_text(); ?> + + ID) ) { + $actions['approve'] = "" . __( 'Approve' ) . ''; + $actions['unapprove'] = "" . __( 'Unapprove' ) . ''; + if ( $comment_status ) { // not looking at all comments + if ( 'approved' == $the_comment_status ) { + $actions['unapprove'] = "" . __( 'Unapprove' ) . ''; + unset($actions['approve']); + } else { + $actions['approve'] = "" . __( 'Approve' ) . ''; + unset($actions['unapprove']); + } + } + if ( 'spam' != $the_comment_status ) + $actions['spam'] = "" . _c( 'Spam|verb' ) . ''; + $actions['delete'] = "" . __('Delete') . ''; + $actions['edit'] = "". __('Edit') . ''; + $actions['quickedit'] = '' . __('Quick Edit') . ''; + if ( 'spam' != $the_comment_status ) + $actions['reply'] = '' . __('Reply') . ''; + + $actions = apply_filters( 'comment_row_actions', $actions, $comment ); + + $i = 0; + echo '
    '; + foreach ( $actions as $action => $link ) { + ++$i; + ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; + + // Reply and quickedit need a hide-if-no-js span when not added with ajax + if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax ) + $action .= ' hide-if-no-js'; + + echo "$sep$link"; + } + echo '
    '; + } + + echo ''; + break; + case 'author': + echo ""; comment_author(); echo '
    '; + if ( !empty($author_url) ) + echo "$author_url_display
    "; + if ( current_user_can( 'edit_post', $post->ID ) ) { + if ( !empty($comment->comment_author_email) ) { + comment_author_email_link(); + echo '
    '; + } + echo ''; + comment_author_IP(); + echo ''; + } //current_user_can + echo ''; + break; + case 'date': + echo "" . get_comment_date(__('Y/m/d \a\t g:ia')) . ''; + break; + case 'response': + if ( 'single' !== $mode ) { + if ( isset( $_comment_pending_count[$post->ID] ) ) { + $pending_comments = absint( $_comment_pending_count[$post->ID] ); + } else { + $_comment_pending_count_temp = (array) get_pending_comments_num( array( $post->ID ) ); + $pending_comments = $_comment_pending_count[$post->ID] = $_comment_pending_count_temp[$post->ID]; + } + if ( current_user_can( 'edit_post', $post->ID ) ) { + $post_link = ""; + $post_link .= get_the_title($post->ID) . ''; + } else { + $post_link = get_the_title($post->ID); + } + echo "\n"; + echo $post_link; + + echo ''; + } + } + } + echo "\n"; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $position + * @param unknown_type $checkbox + * @param unknown_type $mode + */ +function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) { + global $current_user; + + // allow plugin to replace the popup content + $content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) ); + + if ( ! empty($content) ) { + echo $content; + return; + } + + $columns = get_column_headers('edit-comments'); + $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns('edit-comments') ) ); + $col_count = count($columns) - count($hidden); + +?> +
    + +
    + +
    + + + +
    + 0) ); + + if ( $categories ) { + foreach ( $categories as $category ) { + if ( $currentcat != $category->term_id && $parent == $category->parent) { + $pad = str_repeat( '– ', $level ); + $category->name = wp_specialchars( $category->name ); + echo "\n\t"; + wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories ); + } + } + } else { + return false; + } +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $meta + */ +function list_meta( $meta ) { + // Exit if no meta + if ( ! $meta ) { + echo ' + + + + + + + + + + +'; //TBODY needed for list-manipulation JS + return; + } + $count = 0; +?> + + + + + + + + + + +
    + + $entry['meta_id'] = (int) $entry['meta_id']; + + $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] ); + + $r .= "\n\t"; + $r .= "\n\t\t"; + + $r .= "\n\t\t
    "; + $r .= "\n\t\t
    "; + $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false ); + $r .= ""; + + $r .= "\n\t\t\n\t"; + return $r; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + */ +function meta_form() { + global $wpdb; + $limit = (int) apply_filters( 'postmeta_form_limit', 30 ); + $keys = $wpdb->get_col( " + SELECT meta_key + FROM $wpdb->postmeta + WHERE meta_key NOT LIKE '\_%' + GROUP BY meta_key + ORDER BY meta_id DESC + LIMIT $limit" ); + if ( $keys ) + natcasesort($keys); +?> +

    + + + + + + + + + + + + + + + + +
    + + + + + + + + + +
    + + +
    +post_status, array('draft', 'pending') ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date ) ) ? false : true; + + $tab_index_attribute = ''; + if ( (int) $tab_index > 0 ) + $tab_index_attribute = " tabindex=\"$tab_index\""; + + // echo '
    '; + + $time_adj = time() + (get_option( '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 ); + + $cur_jj = gmdate( 'd', $time_adj ); + $cur_mm = gmdate( 'm', $time_adj ); + $cur_aa = gmdate( 'Y', $time_adj ); + $cur_hh = gmdate( 'H', $time_adj ); + $cur_mn = gmdate( 'i', $time_adj ); + + $month = "'; + + $day = ''; + $year = ''; + $hour = ''; + $minute = ''; + printf(_c('%1$s%2$s, %3$s @ %4$s : %5$s|1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input'), $month, $day, $year, $hour, $minute); + + echo ''; + + if ( $multi ) return; + + echo "\n\n"; + foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) { + echo '' . "\n"; + $cur_timeunit = 'cur_' . $timeunit; + echo '' . "\n"; + } +?> + + + +

    + + +

    +$template"; + endforeach; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $default + * @param unknown_type $parent + * @param unknown_type $level + * @return unknown + */ +function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) { + global $wpdb, $post_ID; + $items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent) ); + + if ( $items ) { + foreach ( $items as $item ) { + // A page cannot be its own parent. + if (!empty ( $post_ID ) ) { + if ( $item->ID == $post_ID ) { + continue; + } + } + $pad = str_repeat( ' ', $level * 3 ); + if ( $item->ID == $default) + $current = ' selected="selected"'; + else + $current = ''; + + echo "\n\t"; + parent_dropdown( $default, $item->ID, $level +1 ); + } + } else { + return false; + } +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + */ +function browse_happy() { + $getit = __( 'WordPress recommends a better browser' ); + echo ' +
    Browse Happy
    +'; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $id + * @return unknown + */ +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 ); + $attachment_data = wp_get_attachment_metadata( $id ); + $thumb = isset( $attachment_data['thumb'] ); +?> + +role_names as $role => $name ) { + $name = translate_with_context($name); + if ( $default == $role ) // Make default first in list + $p = "\n\t"; + else + $r .= "\n\t"; + } + echo $p . $r; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $size + * @return unknown + */ +function wp_convert_hr_to_bytes( $size ) { + $size = strtolower($size); + $bytes = (int) $size; + if ( strpos($size, 'k') !== false ) + $bytes = intval($size) * 1024; + elseif ( strpos($size, 'm') !== false ) + $bytes = intval($size) * 1024 * 1024; + elseif ( strpos($size, 'g') !== false ) + $bytes = intval($size) * 1024 * 1024 * 1024; + return $bytes; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $bytes + * @return unknown + */ +function wp_convert_bytes_to_hr( $bytes ) { + $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' ); + $log = log( $bytes, 1024 ); + $power = (int) $log; + $size = pow(1024, $log - $power); + return $size . $units[$power]; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @return unknown + */ +function wp_max_upload_size() { + $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) ); + $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) ); + $bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes ); + return $bytes; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $action + */ +function wp_import_upload_form( $action ) { + $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() ); + $size = wp_convert_bytes_to_hr( $bytes ); +?> +
    +

    + + () + + + +

    +

    + +

    +
    +post_name); // just in case + if ( strlen($name) ) + echo ''; +} + +/** + * Add a meta box to an edit form. + * + * @since 2.5.0 + * + * @param string $id String for use in the 'id' attribute of tags. + * @param string $title Title of the meta box. + * @param string $callback Function that fills the box with the desired content. The function should echo its output. + * @param string $page The type of edit page on which to show the box (post, page, link). + * @param string $context The context within the page where the boxes should show ('normal', 'advanced'). + * @param string $priority The priority within the context where the boxes should show ('high', 'low'). + */ +function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default') { + global $wp_meta_boxes; + + if ( !isset($wp_meta_boxes) ) + $wp_meta_boxes = array(); + if ( !isset($wp_meta_boxes[$page]) ) + $wp_meta_boxes[$page] = array(); + if ( !isset($wp_meta_boxes[$page][$context]) ) + $wp_meta_boxes[$page][$context] = array(); + + foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) { + foreach ( array('high', 'core', 'default', 'low') as $a_priority ) { + if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) ) + continue; + + // If a core box was previously added or removed by a plugin, don't add. + if ( 'core' == $priority ) { + // If core box previously deleted, don't add + if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] ) + return; + // If box was added with default priority, give it core priority to maintain sort order + if ( 'default' == $a_priority ) { + $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id]; + unset($wp_meta_boxes[$page][$a_context]['default'][$id]); + } + return; + } + // If no priority given and id already present, use existing priority + if ( empty($priority) ) { + $priority = $a_priority; + // else if we're adding to the sorted priortiy, we don't know the title or callback. Glab them from the previously added context/priority. + } elseif ( 'sorted' == $priority ) { + $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title']; + $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback']; + } + // An id can be in only one priority and one context + if ( $priority != $a_priority || $context != $a_context ) + unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]); + } + } + + if ( empty($priority) ) + $priority = 'low'; + + if ( !isset($wp_meta_boxes[$page][$context][$priority]) ) + $wp_meta_boxes[$page][$context][$priority] = array(); + + $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $page + * @param unknown_type $context + * @param unknown_type $object + * @return int number of meta_boxes + */ +function do_meta_boxes($page, $context, $object) { + global $wp_meta_boxes; + static $already_sorted = false; + + //do_action('do_meta_boxes', $page, $context, $object); + + $hidden = get_hidden_meta_boxes($page); + + echo "
    \n"; + + $i = 0; + do { + // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose + if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page", 0, false ) ) { + foreach ( $sorted as $box_context => $ids ) + foreach ( explode(',', $ids) as $id ) + if ( $id ) + add_meta_box( $id, null, null, $page, $box_context, 'sorted' ); + } + $already_sorted = true; + + if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) ) + break; + + foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) { + if ( isset($wp_meta_boxes[$page][$context][$priority]) ) { + foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) { + if ( false == $box || ! $box['title'] ) + continue; + $i++; + $style = ''; + if ( in_array($box['id'], $hidden) ) + $style = 'style="display:none;"'; + echo '
    ' . "\n"; + echo '

    '; + echo "

    {$box['title']}

    \n"; + echo '
    ' . "\n"; + call_user_func($box['callback'], $object, $box); + echo "
    \n"; + echo "
    \n"; + } + } + } + } while(0); + + echo "
    "; + + return $i; + +} + +/** + * Remove a meta box from an edit form. + * + * @since 2.6.0 + * + * @param string $id String for use in the 'id' attribute of tags. + * @param string $page The type of edit page on which to show the box (post, page, link). + * @param string $context The context within the page where the boxes should show ('normal', 'advanced'). + */ +function remove_meta_box($id, $page, $context) { + global $wp_meta_boxes; + + if ( !isset($wp_meta_boxes) ) + $wp_meta_boxes = array(); + if ( !isset($wp_meta_boxes[$page]) ) + $wp_meta_boxes[$page] = array(); + if ( !isset($wp_meta_boxes[$page][$context]) ) + $wp_meta_boxes[$page][$context] = array(); + + foreach ( array('high', 'core', 'default', 'low') as $priority ) + $wp_meta_boxes[$page][$context][$priority][$id] = false; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $page + */ +function meta_box_prefs($page) { + global $wp_meta_boxes; + + if ( empty($wp_meta_boxes[$page]) ) + return; + + $hidden = get_hidden_meta_boxes($page); + + foreach ( array_keys($wp_meta_boxes[$page]) as $context ) { + foreach ( array_keys($wp_meta_boxes[$page][$context]) as $priority ) { + foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) { + if ( false == $box || ! $box['title'] ) + continue; + // Submit box cannot be hidden + if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) + continue; + $box_id = $box['id']; + echo '\n"; + } + } + } +} + +function get_hidden_meta_boxes($page) { + $hidden = (array) get_user_option( "meta-box-hidden_$page", 0, false ); + + // Hide slug boxes by default + if ( empty($hidden[0]) ) { + if ( 'page' == $page ) + $hidden = array('pageslugdiv'); + elseif ( 'post' == $page ) + $hidden = array('slugdiv'); + } + + return $hidden; +} + +/** + * Add a new section to a settings page. + * + * @since 2.7.0 + * + * @param string $id String for use in the 'id' attribute of tags. + * @param string $title Title of the section. + * @param string $callback Function that fills the section with the desired content. The function should echo its output. + * @param string $page The type of settings page on which to show the section (general, reading, writing, ...). + */ +function add_settings_section($id, $title, $callback, $page) { + global $wp_settings_sections; + + if ( !isset($wp_settings_sections) ) + $wp_settings_sections = array(); + if ( !isset($wp_settings_sections[$page]) ) + $wp_settings_sections[$page] = array(); + if ( !isset($wp_settings_sections[$page][$id]) ) + $wp_settings_sections[$page][$id] = array(); + + $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback); +} + +/** + * Add a new field to a settings page. + * + * @since 2.7.0 + * + * @param string $id String for use in the 'id' attribute of tags. + * @param string $title Title of the field. + * @param string $callback Function that fills the field with the desired content. The function should echo its output. + * @param string $page The type of settings page on which to show the field (general, reading, writing, ...). + * @param string $section The section of the settingss page in which to show the box (default, ...). + * @param array $args Additional arguments + */ +function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) { + global $wp_settings_fields; + + if ( !isset($wp_settings_fields) ) + $wp_settings_fields = array(); + if ( !isset($wp_settings_fields[$page]) ) + $wp_settings_fields[$page] = array(); + if ( !isset($wp_settings_fields[$page][$section]) ) + $wp_settings_fields[$page][$section] = array(); + + $wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $page + */ +function do_settings_sections($page) { + global $wp_settings_sections, $wp_settings_fields; + + if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) ) + return; + + foreach ( (array) $wp_settings_sections[$page] as $section ) { + echo "

    {$section['title']}

    \n"; + call_user_func($section['callback'], $section); + if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']]) ) + continue; + echo ''; + do_settings_fields($page, $section['id']); + echo '
    '; + } +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $page + * @param unknown_type $section + */ +function do_settings_fields($page, $section) { + global $wp_settings_fields; + + if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) ) + return; + + foreach ( (array) $wp_settings_fields[$page][$section] as $field ) { + echo ''; + if ( !empty($field['args']['label_for']) ) + echo ''; + else + echo '' . $field['title'] . ''; + echo ''; + call_user_func($field['callback']); + echo ''; + echo ''; + } +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $page + */ +function manage_columns_prefs($page) { + $columns = get_column_headers($page); + + $hidden = get_hidden_columns($page); + + foreach ( $columns as $column => $title ) { + // Can't hide these + if ( 'cb' == $column || 'title' == $column || 'name' == $column || 'username' == $column || 'media' == $column || 'comment' == $column ) + continue; + if ( empty($title) ) + continue; + + if ( 'comments' == $column ) + $title = __('Comments'); + $id = "$column-hide"; + echo '\n"; + } +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $found_action + */ +function find_posts_div($found_action = '') { +?> + + +post_password ) ) echo attribute_escape( $post->post_password ); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + */ +function favorite_actions() { + $actions = array( + 'post-new.php' => array(__('New Post'), 'edit_posts'), + 'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'), + 'page-new.php' => array(__('New Page'), 'edit_pages'), + 'media-new.php' => array(__('Upload'), 'upload_files'), + 'edit-comments.php' => array(__('Comments'), 'moderate_comments') + ); + + $actions = apply_filters('favorite_actions', $actions); + + $allowed_actions = array(); + foreach ( $actions as $action => $data ) { + if ( current_user_can($data[1]) ) + $allowed_actions[$action] = $data[0]; + } + + if ( empty($allowed_actions) ) + return; + + $first = array_keys($allowed_actions); + $first = $first[0]; + echo '
    '; + echo '

    '; + echo '
    '; + + array_shift($allowed_actions); + + foreach ( $allowed_actions as $action => $label) { + echo "\n"; + } + echo "
    \n"; +} + +/** + * Get the post title. + * + * The post title is fetched and if it is blank then a default string is + * returned. + * + * @since 2.7.0 + * @param int $id The post id. If not supplied the global $post is used. + * + */ +function _draft_or_post_title($post_id = 0) +{ + $title = get_the_title($post_id); + if ( empty($title) ) + $title = __('(no title)'); + return $title; +} + +/** + * Display the search query. + * + * A simple wrapper to display the "s" parameter in a GET URI. This function + * should only be used when {@link the_search_query()} cannot. + * + * @uses attribute_escape + * @since 2.7.0 + * + */ +function _admin_search_query() { + echo isset($_GET['s']) ? attribute_escape( stripslashes( $_GET['s'] ) ) : ''; +} + +/** + * Generic Iframe header for use with Thickbox + * + * @since 2.7.0 + * @param string $title Title of the Iframe page. + * @param bool $limit_styles Limit styles to colour-related styles only (unless others are enqueued). + * + */ +function iframe_header( $title = '', $limit_styles = false) { +?> + > + + +<?php bloginfo('name') ?> › <?php echo $title ?> — <?php _e('WordPress'); ?> + + + + +> + +'; +} + +function _post_states($post) { + $post_states = array(); + if ( isset($_GET['post_status']) ) + $post_status = $_GET['post_status']; + else + $post_status = ''; + + if ( !empty($post->post_password) ) + $post_states[] = __('Password protected'); + if ( 'private' == $post->post_status && 'private' != $post_status ) + $post_states[] = __('Private'); + if ( 'draft' == $post->post_status && 'draft' != $post_status ) + $post_states[] = __('Draft'); + if ( 'pending' == $post->post_status && 'pending' != $post_status ) + $post_states[] = __('Pending'); + + if ( ! empty($post_states) ) { + $state_count = count($post_states); + $i = 0; + echo ' - '; + foreach ( $post_states as $state ) { + ++$i; + ( $i == $state_count ) ? $sep = '' : $sep = ', '; + echo "$state$sep"; + } + } +} + +function screen_meta($screen) { + global $wp_meta_boxes, $_wp_contextual_help; + + $screen = str_replace('.php', '', $screen); + $screen = str_replace('-new', '', $screen); + $screen = str_replace('-add', '', $screen); + $screen = apply_filters('screen_meta_screen', $screen); + + $column_screens = get_column_headers($screen); + $meta_screens = array('index' => 'dashboard'); + + if ( isset($meta_screens[$screen]) ) + $screen = $meta_screens[$screen]; + $show_screen = false; + if ( !empty($wp_meta_boxes[$screen]) || !empty($column_screens) ) + $show_screen = true; +?> +
    + + + +' . __('Writing Posts') . '

    '; + $_wp_contextual_help['post'] = $help; + } + + if ( !isset($_wp_contextual_help['page']) ) { + $help = drag_drop_help(); + $_wp_contextual_help['page'] = $help; + } + + if ( !isset($_wp_contextual_help['dashboard']) ) { + $help = drag_drop_help(); + $_wp_contextual_help['dashboard'] = $help; + } + + if ( !isset($_wp_contextual_help['link']) ) { + $help = drag_drop_help(); + $_wp_contextual_help['link'] = $help; + } + + if ( !isset($_wp_contextual_help['options-general']) ) + $_wp_contextual_help['options-general'] = __('General Settings'); + + $_wp_contextual_help = apply_filters('contextual_help_list', $_wp_contextual_help, $screen); + ?> + + + +
    +' . __('Most of the modules on this screen can be moved. If you hover your mouse over the title bar of a module you’ll notice the 4 arrow cursor appears to let you know it is movable. Click on it, hold down the mouse button and start dragging the module to a new location. As you drag the module, notice the dotted gray box that also moves. This box indicates where the module will be placed when you release the mouse button.') . '

    +

    ' . __('The same modules can be expanded and collapsed by clicking once on their title bar and also completely hidden from the Screen Options tab.') . '

    +'; +} + +function screen_icon($name = '') { + global $parent_file, $hook_suffix; + + if ( empty($name) ) { + if ( isset($parent_file) && !empty($parent_file) ) + $name = substr($parent_file, 0, -4); + else + $name = str_replace(array('.php', '-new', '-add'), '', $hook_suffix); + } + unset($hook_suffix); +?> +

    + diff -uNr a/blog/wp-admin/includes/theme.php b/blog/wp-admin/includes/theme.php --- a/blog/wp-admin/includes/theme.php false +++ b/blog/wp-admin/includes/theme.php 55c5d4cd5f06ed977349ec996964b2e92a6d730c2551ca87635dea25a8d7a9338a14d48a2d821427f7271dd8d310d0dab678e5b8cea67f55c5f9b1a7a3f69800 @@ -0,0 +1,82 @@ +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']; + $ct->tags = $themes[$current_theme]['Tags']; + return $ct; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @return unknown + */ +function get_broken_themes() { + global $wp_broken_themes; + + get_themes(); + return $wp_broken_themes; +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @return unknown + */ +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( WP_CONTENT_DIR.$template )); + + $name = ''; + if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ) ) + $name = $name[1]; + + $description = ''; + if( preg_match( '|Description:(.*)$|mi', $template_data, $description ) ) + $description = $description[1]; + + if ( !empty( $name ) ) { + $page_templates[trim( $name )] = basename( $template ); + } + } + } + + return $page_templates; +} + +?> diff -uNr a/blog/wp-admin/includes/update-core-fuckit.php b/blog/wp-admin/includes/update-core-fuckit.php --- a/blog/wp-admin/includes/update-core-fuckit.php false +++ b/blog/wp-admin/includes/update-core-fuckit.php ec4ed41b6dfec921b91a384e724803eeceee6b9e8c511b21440b183d5da18f90e1088a183b02c8e3c345111c7e0dedefff14ecae14120afc8fbfb4d497ddb1aa @@ -0,0 +1,263 @@ +exists($from . '/wordpress/wp-settings.php') || !$wp_filesystem->exists($from . '/wordpress/wp-admin/admin.php') || + !$wp_filesystem->exists($from . '/wordpress/wp-includes/functions.php') ) { + $wp_filesystem->delete($from, true); + return new WP_Error('insane_distro', __('The update could not be unpacked') ); + } + + apply_filters('update_feedback', __('Installing the latest version')); + + // Create maintenance file to signal that we are upgrading + $maintenance_string = ''; + $maintenance_file = $to . '.maintenance'; + $wp_filesystem->delete($maintenance_file); + $wp_filesystem->put_contents($maintenance_file, $maintenance_string, FS_CHMOD_FILE); + + // Copy new versions of WP files into place. + $result = copy_dir($from . '/wordpress', $to); + if ( is_wp_error($result) ) { + $wp_filesystem->delete($maintenance_file); + //$wp_filesystem->delete($working_dir, true); //TODO: Uncomment? This DOES mean that the new files are available in the upgrade folder if it fails. + return $result; + } + + // Remove old files + foreach ( $_old_files as $old_file ) { + $old_file = $to . $old_file; + if ( !$wp_filesystem->exists($old_file) ) + continue; + $wp_filesystem->delete($old_file, true); + } + + // Upgrade DB with separate request + apply_filters('update_feedback', __('Upgrading database')); + $db_upgrade_url = admin_url('upgrade.php?step=upgrade_db'); + wp_remote_post($db_upgrade_url, array('timeout' => 60)); + + // Remove working directory + $wp_filesystem->delete($from, true); + + // Force refresh of update information + delete_option('update_core'); + + // Remove maintenance file, we're done. + $wp_filesystem->delete($maintenance_file); +} + +?> diff -uNr a/blog/wp-admin/includes/update.php b/blog/wp-admin/includes/update.php --- a/blog/wp-admin/includes/update.php false +++ b/blog/wp-admin/includes/update.php 6a9aa6d6777019284843559c9bd17aae28554c42ecb28c2b6445a3accab4fe1092f6468aff91fbdfba711bb588ed3ab87acad6d0e4913cadd9013bea8231f11d @@ -0,0 +1,492 @@ + 'latest'); + return $updates[0]; +} + +/** + * Get available core updates + * + * @param array $options Set $options['dismissed'] to true to show dismissed upgrades too, + * set $options['available'] to false to skip not-dimissed updates. + * @return array Array of the update objects + */ +function get_core_updates( $options = array() ) { + $options = array_merge( array('available' => true, 'dismissed' => false ), $options ); + $dismissed = get_option( 'dismissed_update_core' ); + if ( !is_array( $dismissed ) ) $dismissed = array(); + $from_api = get_option( 'update_core' ); + if ( empty($from_api) ) + return false; + if ( !is_array( $from_api->updates ) ) return false; + $updates = $from_api->updates; + if ( !is_array( $updates ) ) return false; + $result = array(); + foreach($updates as $update) { + if ( array_key_exists( $update->current.'|'.$update->locale, $dismissed ) ) { + if ( $options['dismissed'] ) { + $update->dismissed = true; + $result[]= $update; + } + } else { + if ( $options['available'] ) { + $update->dismissed = false; + $result[]= $update; + } + } + } + return $result; +} + +function dismiss_core_update( $update ) { + $dismissed = get_option( 'dismissed_update_core' ); + $dismissed[ $update->current.'|'.$update->locale ] = true; + return update_option( 'dismissed_update_core', $dismissed ); +} + +function undismiss_core_update( $version, $locale ) { + $dismissed = get_option( 'dismissed_update_core' ); + $key = $version.'|'.$locale; + if ( !isset( $dismissed[$key] ) ) return false; + unset( $dismissed[$key] ); + return update_option( 'dismissed_update_core', $dismissed ); +} + +function find_core_update( $version, $locale ) { + $from_api = get_option( 'update_core' ); + if ( !is_array( $from_api->updates ) ) return false; + $updates = $from_api->updates; + foreach($updates as $update) { + if ( $update->current == $version && $update->locale == $locale ) + return $update; + } + return false; +} + +function core_update_footer( $msg = '' ) { + if ( !current_user_can('manage_options') ) + return sprintf( '| '.__( 'Version %s' ), $GLOBALS['wp_version'] ); + + $cur = get_preferred_from_update_core(); + if ( ! isset( $cur->current ) ) + $cur->current = ''; + + if ( ! isset( $cur->url ) ) + $cur->url = ''; + + if ( ! isset( $cur->response ) ) + $cur->response = ''; + + switch ( $cur->response ) { + case 'development' : + return sprintf( __( 'You are using a development version (%1$s). Cool! Please stay updated.' ), $GLOBALS['wp_version'], 'update-core.php'); + break; + + case 'upgrade' : + if ( current_user_can('manage_options') ) { + return sprintf( ''.__( 'Get Version %2$s' ).'', 'update-core.php', $cur->current); + break; + } + + case 'latest' : + default : + return sprintf( __( 'Version %s' ), $GLOBALS['wp_version'] ); + break; + } +} +add_filter( 'update_footer', 'core_update_footer' ); + +function update_nag() { + global $pagenow; + + if ( 'update-core.php' == $pagenow ) + return; + + $cur = get_preferred_from_update_core(); + + if ( ! isset( $cur->response ) || $cur->response != 'upgrade' ) + return false; + + if ( current_user_can('manage_options') ) + $msg = sprintf( __('WordPress %1$s is available! Please update now.'), $cur->current, 'update-core.php' ); + else + $msg = sprintf( __('WordPress %1$s is available! Please notify the site administrator.'), $cur->current ); + + echo "
    $msg
    "; +} +add_action( 'admin_notices', 'update_nag', 3 ); + +// Called directly from dashboard +function update_right_now_message() { + $cur = get_preferred_from_update_core(); + + $msg = sprintf( __('You are using WordPress %s.'), $GLOBALS['wp_version'] ); + if ( isset( $cur->response ) && $cur->response == 'upgrade' && current_user_can('manage_options') ) + $msg .= " " . sprintf( __('Update to %s'), $cur->current ? $cur->current : __( 'Latest' ) ) . ''; + + echo "$msg"; +} + +function wp_plugin_update_row( $file, $plugin_data ) { + $current = get_option( 'update_plugins' ); + if ( !isset( $current->response[ $file ] ) ) + return false; + + $r = $current->response[ $file ]; + + $details_url = admin_url('plugin-install.php?tab=plugin-information&plugin=' . $r->slug . '&TB_iframe=true&width=600&height=800'); + + echo ''; + if ( ! current_user_can('update_plugins') ) + printf( __('There is a new version of %1$s available. View version %3$s Details.'), $plugin_data['Name'], $details_url, $r->new_version); + else if ( empty($r->package) ) + printf( __('There is a new version of %1$s available. View version %3$s Details automatic upgrade unavailable for this plugin.'), $plugin_data['Name'], $details_url, $r->new_version); + else + printf( __('There is a new version of %1$s available. View version %3$s Details or upgrade automatically.'), $plugin_data['Name'], $details_url, $r->new_version, wp_nonce_url('update.php?action=upgrade-plugin&plugin=' . $file, 'upgrade-plugin_' . $file) ); + + echo ''; +} +add_action( 'after_plugin_row', 'wp_plugin_update_row', 10, 2 ); + +function wp_update_plugin($plugin, $feedback = '') { + global $wp_filesystem; + + if ( !empty($feedback) ) + add_filter('update_feedback', $feedback); + + // Is an update available? + $current = get_option( 'update_plugins' ); + if ( !isset( $current->response[ $plugin ] ) ) + return new WP_Error('up_to_date', __('The plugin is at the latest version.')); + + // Is a filesystem accessor setup? + if ( ! $wp_filesystem || ! is_object($wp_filesystem) ) + WP_Filesystem(); + + if ( ! is_object($wp_filesystem) ) + return new WP_Error('fs_unavailable', __('Could not access filesystem.')); + + if ( $wp_filesystem->errors->get_error_code() ) + return new WP_Error('fs_error', __('Filesystem error'), $wp_filesystem->errors); + + //Get the base plugin folder + $plugins_dir = $wp_filesystem->wp_plugins_dir(); + if ( empty($plugins_dir) ) + return new WP_Error('fs_no_plugins_dir', __('Unable to locate WordPress Plugin directory.')); + + //And the same for the Content directory. + $content_dir = $wp_filesystem->wp_content_dir(); + if( empty($content_dir) ) + return new WP_Error('fs_no_content_dir', __('Unable to locate WordPress Content directory (wp-content).')); + + $plugins_dir = trailingslashit( $plugins_dir ); + $content_dir = trailingslashit( $content_dir ); + + // Get the URL to the zip file + $r = $current->response[ $plugin ]; + + if ( empty($r->package) ) + return new WP_Error('no_package', __('Upgrade package not available.')); + + // Download the package + $package = $r->package; + apply_filters('update_feedback', sprintf(__('Downloading update from %s'), $package)); + $download_file = download_url($package); + + if ( is_wp_error($download_file) ) + return new WP_Error('download_failed', __('Download failed.'), $download_file->get_error_message()); + + $working_dir = $content_dir . 'upgrade/' . basename($plugin, '.php'); + + // Clean up working directory + if ( $wp_filesystem->is_dir($working_dir) ) + $wp_filesystem->delete($working_dir, true); + + apply_filters('update_feedback', __('Unpacking the update')); + // Unzip package to working directory + $result = unzip_file($download_file, $working_dir); + + // Once extracted, delete the package + unlink($download_file); + + if ( is_wp_error($result) ) { + $wp_filesystem->delete($working_dir, true); + return $result; + } + + if ( is_plugin_active($plugin) ) { + //Deactivate the plugin silently, Prevent deactivation hooks from running. + apply_filters('update_feedback', __('Deactivating the plugin')); + deactivate_plugins($plugin, true); + } + + // Remove the existing plugin. + apply_filters('update_feedback', __('Removing the old version of the plugin')); + $this_plugin_dir = trailingslashit( dirname($plugins_dir . $plugin) ); + + // If plugin is in its own directory, recursively delete the directory. + if ( strpos($plugin, '/') && $this_plugin_dir != $plugins_dir ) //base check on if plugin includes directory seperator AND that its not the root plugin folder + $deleted = $wp_filesystem->delete($this_plugin_dir, true); + else + $deleted = $wp_filesystem->delete($plugins_dir . $plugin); + + if ( ! $deleted ) { + $wp_filesystem->delete($working_dir, true); + return new WP_Error('delete_failed', __('Could not remove the old plugin')); + } + + apply_filters('update_feedback', __('Installing the latest version')); + // Copy new version of plugin into place. + $result = copy_dir($working_dir, $plugins_dir); + if ( is_wp_error($result) ) { + $wp_filesystem->delete($working_dir, true); + return $result; + } + + //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin + $filelist = array_keys( $wp_filesystem->dirlist($working_dir) ); + + // Remove working directory + $wp_filesystem->delete($working_dir, true); + + // Force refresh of plugin update information + delete_option('update_plugins'); + + if( empty($filelist) ) + return false; //We couldnt find any files in the working dir, therefor no plugin installed? Failsafe backup. + + $folder = $filelist[0]; + $plugin = get_plugins('/' . $folder); //Ensure to pass with leading slash + $pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list + + return $folder . '/' . $pluginfiles[0]; +} + +function wp_update_theme($theme, $feedback = '') { + global $wp_filesystem; + + if ( !empty($feedback) ) + add_filter('update_feedback', $feedback); + + // Is an update available? + $current = get_option( 'update_themes' ); + if ( !isset( $current->response[ $theme ] ) ) + return new WP_Error('up_to_date', __('The theme is at the latest version.')); + + $r = $current->response[ $theme ]; + + $themes = get_themes(); + foreach ( (array) $themes as $this_theme ) { + if ( $this_theme['Stylesheet'] == $theme ) { + $theme_directory = preg_replace('!^/themes/!i', '', $this_theme['Stylesheet Dir']); + break; + } + } + unset($themes); + + if ( empty($theme_directory) ) + return new WP_Error('theme_non_existant', __('Theme does not exist.')); + + // Is a filesystem accessor setup? + if ( ! $wp_filesystem || ! is_object($wp_filesystem) ) + WP_Filesystem(); + + if ( ! is_object($wp_filesystem) ) + return new WP_Error('fs_unavailable', __('Could not access filesystem.')); + + if ( $wp_filesystem->errors->get_error_code() ) + return new WP_Error('fs_error', __('Filesystem error'), $wp_filesystem->errors); + + //Get the base plugin folder + $themes_dir = $wp_filesystem->wp_themes_dir(); + if ( empty($themes_dir) ) + return new WP_Error('fs_no_themes_dir', __('Unable to locate WordPress Theme directory.')); + + //And the same for the Content directory. + $content_dir = $wp_filesystem->wp_content_dir(); + if( empty($content_dir) ) + return new WP_Error('fs_no_content_dir', __('Unable to locate WordPress Content directory (wp-content).')); + + $themes_dir = trailingslashit( $themes_dir ); + $content_dir = trailingslashit( $content_dir ); + + if ( empty($r->package) ) + return new WP_Error('no_package', __('Upgrade package not available.')); + + // Download the package + apply_filters('update_feedback', sprintf(__('Downloading update from %s'), $r['package'])); + $download_file = download_url($r['package']); + + if ( is_wp_error($download_file) ) + return new WP_Error('download_failed', __('Download failed.'), $download_file->get_error_message()); + + $working_dir = $content_dir . 'upgrade/' . basename($theme_directory); + + // Clean up working directory + if ( $wp_filesystem->is_dir($working_dir) ) + $wp_filesystem->delete($working_dir, true); + + apply_filters('update_feedback', __('Unpacking the update')); + // Unzip package to working directory + $result = unzip_file($download_file, $working_dir); + + // Once extracted, delete the package + unlink($download_file); + + if ( is_wp_error($result) ) { + $wp_filesystem->delete($working_dir, true); + return $result; + } + + //TODO: Is theme currently active? If so, set default theme + /* + if ( is_plugin_active($plugin) ) { + //Deactivate the plugin silently, Prevent deactivation hooks from running. + apply_filters('update_feedback', __('Deactivating the plugin')); + deactivate_plugins($plugin, true); + }*/ + + // Remove the existing plugin. + apply_filters('update_feedback', __('Removing the old version of the theme')); + $deleted = $wp_filesystem->delete($themes_dir . $theme_directory, true); + + if ( ! $deleted ) { + $wp_filesystem->delete($working_dir, true); + return new WP_Error('delete_failed', __('Could not remove the old plugin')); + } + + apply_filters('update_feedback', __('Installing the latest version')); + // Copy new version of plugin into place. + $result = copy_dir($working_dir, $themes_dir); + if ( is_wp_error($result) ) { + $wp_filesystem->delete($working_dir, true); + return $result; + } + + //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin + //$filelist = array_keys( $wp_filesystem->dirlist($working_dir) ); + + // Remove working directory + $wp_filesystem->delete($working_dir, true); + + // Force refresh of plugin update information + delete_option('update_themes'); + + /*if( empty($filelist) ) + return false; //We couldnt find any files in the working dir, therefor no plugin installed? Failsafe backup. + + $folder = $filelist[0]; + $plugin = get_plugins('/' . $folder); //Ensure to pass with leading slash + $pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list + + return $folder . '/' . $pluginfiles[0];*/ +} + + +function wp_update_core($current, $feedback = '') { + global $wp_filesystem; + + @set_time_limit( 300 ); + + if ( !empty($feedback) ) + add_filter('update_feedback', $feedback); + + // Is an update available? + if ( !isset( $current->response ) || $current->response == 'latest' ) + return new WP_Error('up_to_date', __('WordPress is at the latest version.')); + + // Is a filesystem accessor setup? + if ( ! $wp_filesystem || ! is_object($wp_filesystem) ) + WP_Filesystem(); + + if ( ! is_object($wp_filesystem) ) + return new WP_Error('fs_unavailable', __('Could not access filesystem.')); + + if ( $wp_filesystem->errors->get_error_code() ) + return new WP_Error('fs_error', __('Filesystem error'), $wp_filesystem->errors); + + // Get the base WP folder + $wp_dir = $wp_filesystem->abspath(); + if ( empty($wp_dir) ) + return new WP_Error('fs_no_wp_dir', __('Unable to locate WordPress directory.')); + + // And the same for the Content directory. + $content_dir = $wp_filesystem->wp_content_dir(); + if( empty($content_dir) ) + return new WP_Error('fs_no_content_dir', __('Unable to locate WordPress Content directory (wp-content).')); + + $wp_dir = trailingslashit( $wp_dir ); + $content_dir = trailingslashit( $content_dir ); + + // Get the URL to the zip file + $package = $current->package; + + // Download the package + apply_filters('update_feedback', sprintf(__('Downloading update from %s'), $package)); + $download_file = download_url($package); + + if ( is_wp_error($download_file) ) + return new WP_Error('download_failed', __('Download failed.'), $download_file->get_error_message()); + + $working_dir = $content_dir . 'upgrade/core'; + // Clean up working directory + if ( $wp_filesystem->is_dir($working_dir) ) { + $wp_filesystem->delete($working_dir, true); + } + + apply_filters('update_feedback', __('Unpacking the core update')); + // Unzip package to working directory + $result = unzip_file($download_file, $working_dir); + // Once extracted, delete the package + unlink($download_file); + + if ( is_wp_error($result) ) { + $wp_filesystem->delete($working_dir, true); + return $result; + } + + // Copy update-core.php from the new version into place. + if ( !$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true) ) { + $wp_filesystem->delete($working_dir, true); + return new WP_Error('copy_failed', __('Could not copy files')); + } + $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE); + + require(ABSPATH . 'wp-admin/includes/update-core.php'); + + return update_core($working_dir, $wp_dir); +} + +function maintenance_nag() { + global $upgrading; + if ( ! isset( $upgrading ) ) + return false; + + if ( current_user_can('manage_options') ) + $msg = sprintf( __('An automated WordPress update has failed to complete - please attempt the update again now.'), 'update-core.php' ); + else + $msg = __('An automated WordPress update has failed to complete! Please notify the site administrator.'); + + echo "
    $msg
    "; +} +add_action( 'admin_notices', 'maintenance_nag' ); + +?> diff -uNr a/blog/wp-admin/includes/upgrade.php b/blog/wp-admin/includes/upgrade.php --- a/blog/wp-admin/includes/upgrade.php false +++ b/blog/wp-admin/includes/upgrade.php d1e7673e99744e2e97b5d4717b12d80789b7faa59fd3b57b4e115be4d409825cc8e285ada8e673e5d3fa02d9082c1a65af3297a73b30c930ab24689501069be3 @@ -0,0 +1,1593 @@ +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') ) : +/** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + * + * @param int $user_id User ID. + */ +function wp_install_defaults($user_id) { + global $wpdb; + + // Default category + $cat_name = $wpdb->escape(__('Uncategorized')); + $cat_slug = sanitize_title(_c('Uncategorized|Default category slug')); + $wpdb->query("INSERT INTO $wpdb->terms (name, slug, term_group) VALUES ('$cat_name', '$cat_slug', '0')"); + $wpdb->query("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ('1', 'category', '', '0', '1')"); + + // Default link category + $cat_name = $wpdb->escape(__('Blogroll')); + $cat_slug = sanitize_title(_c('Blogroll|Default link category slug')); + $wpdb->query("INSERT INTO $wpdb->terms (name, slug, term_group) VALUES ('$cat_name', '$cat_slug', '0')"); + $wpdb->query("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ('2', 'link_category', '', '0', '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://codex.wordpress.org/', 'Documentation', 0, '', '');"); + $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (1, 2)" ); + + $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://wordpress.org/development/', 'Development Blog', 0, 'http://wordpress.org/development/feed/', '');"); + $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (2, 2)" ); + + $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://wordpress.org/extend/ideas/', 'Suggest Ideas', 0, '', '');"); + $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (3, 2)" ); + + $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://wordpress.org/support/', 'Support Forum', 0, '', '');"); + $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (4, 2)" ); + + $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://wordpress.org/extend/plugins/', 'Plugins', 0, '', '');"); + $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (5, 2)" ); + + $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://wordpress.org/extend/themes/', 'Themes', 0, '', '');"); + $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (6, 2)" ); + + $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://planet.wordpress.org/', 'WordPress Planet', 0, '', '');"); + $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (7, 2)" ); + + // First post + $now = date('Y-m-d H:i:s'); + $now_gmt = gmdate('Y-m-d H:i:s'); + $first_post_guid = get_option('home') . '/?p=1'; + $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, guid, 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(_c('hello-world|Default post slug'))."', '$now', '$now_gmt', '$first_post_guid', '1', '', '', '')"); + $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (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.
    To delete a comment, just log in and view the post's comments. There you will have the option to edit or delete them.'))."')"); + + // First Page + $first_post_guid = get_option('home') . '/?page_id=2'; + $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, guid, 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(_c('about|Default page slug'))."', '$now', '$now_gmt','$first_post_guid', 'publish', 'page', '', '', '')"); +} +endif; + +if ( !function_exists('wp_new_blog_notification') ) : +/** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + * + * @param string $blog_title Blog title. + * @param string $blog_url Blog url. + * @param int $user_id User ID. + * @param string $password User's Password. + */ +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 . '" '; + $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 blog. 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') ) : +/** + * Run WordPress Upgrade functions. + * + * {@internal Missing Long Description}} + * + * @since unknown + * + * @return null + */ +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; + + if( ! is_blog_installed() ) + return; + + wp_check_mysql_version(); + wp_cache_flush(); + make_db_current_silent(); + upgrade_all(); + wp_cache_flush(); +} +endif; + +/** + * Functions to be called in install and upgrade scripts. + * + * {@internal Missing Long Description}} + * + * @since unknown + */ +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; + } + + if ( $wp_current_db_version < 6039 ) + upgrade_230_options_table(); + + 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 < 4772 ) + upgrade_210(); + + if ( $wp_current_db_version < 4351 ) + upgrade_old_slugs(); + + if ( $wp_current_db_version < 5539 ) + upgrade_230(); + + if ( $wp_current_db_version < 6124 ) + upgrade_230_old_tables(); + + if ( $wp_current_db_version < 7499 ) + upgrade_250(); + + if ( $wp_current_db_version < 7796 ) + upgrade_251(); + + if ( $wp_current_db_version < 7935 ) + upgrade_252(); + + if ( $wp_current_db_version < 8201 ) + upgrade_260(); + + if ( $wp_current_db_version < 8989 ) + upgrade_270(); + + maybe_disable_automattic_widgets(); + + $wp_rewrite->flush_rules(); + + update_option('db_version', $wp_db_version); +} + +/** + * Execute changes made in WordPress 1.0. + * + * @since 1.0.0 + */ +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( $wpdb->prepare("UPDATE $wpdb->posts SET post_name = %s WHERE ID = %d", $newtitle, $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( $wpdb->prepare("UPDATE $wpdb->categories SET category_nicename = %s WHERE cat_ID = %d", $newtitle, $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( $wpdb->prepare("SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category) ); + if (!$cat && 0 != $post->post_category) { // If there's no result + $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->post2cat + (post_id, category_id) + VALUES (%s, %s) + ", $post->ID, $post->post_category) ); + } + } + endif; +} + +/** + * Execute changes made in WordPress 1.0.1. + * + * @since 1.0.1 + */ +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'); +} + +/** + * Execute changes made in WordPress 1.2. + * + * @since 1.2.0 + */ +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( $wpdb->prepare("UPDATE $wpdb->users SET user_nicename = %s WHERE ID = %d", $newname, $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' + // 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)"); + } + +} + +/** + * Execute changes made in WordPress 1.5. + * + * @since 1.5.0 + */ +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, '', '') WHERE comment_content LIKE '%'"); + $wpdb->query("UPDATE $wpdb->comments SET comment_type='pingback', comment_content = REPLACE(comment_content, '', '') WHERE comment_content LIKE '%'"); + + // 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( $wpdb->prepare("SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit) ); + $dupe_ids = join($dupe_ids, ','); + $wpdb->query("DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)"); + } + } + + make_site_theme(); +} + +/** + * Execute changes made in WordPress 2.0. + * + * @since 2.0.0 + */ +function upgrade_160() { + global $wpdb, $wp_current_db_version; + + populate_roles_160(); + + $users = $wpdb->get_results("SELECT * FROM $wpdb->users"); + foreach ( $users as $user ) : + 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; + $wpdb->query( $wpdb->prepare("UPDATE $wpdb->users SET display_name = %s WHERE ID = %d", $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; + $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(); + + // 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( $wpdb->prepare("UPDATE $wpdb->posts SET comment_count = %d WHERE ID = %d", $comment->c, $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( $wpdb->prepare("UPDATE $wpdb->posts SET post_status = 'attachment', + post_mime_type = %s, + post_type = '' + WHERE ID = %d", $object->post_type, $object->ID) ); + + $meta = get_post_meta($object->ID, 'imagedata', true); + if ( ! empty($meta['file']) ) + update_attached_file( $object->ID, $meta['file'] ); + } + } +} + +/** + * Execute changes made in WordPress 2.1. + * + * @since 2.1.0 + */ +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( $wpdb->prepare("UPDATE $wpdb->posts SET post_status = %s, post_type = %s WHERE ID = %d", $status, $type, $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', array($post->ID)); + } +} + +/** + * Execute changes made in WordPress 2.3. + * + * @since 2.3.0 + */ +function upgrade_230() { + global $wp_current_db_version, $wpdb; + + if ( $wp_current_db_version < 5200 ) { + populate_roles_230(); + } + + // Convert categories to terms. + $tt_ids = array(); + $have_tags = false; + $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_ID"); + foreach ($categories as $category) { + $term_id = (int) $category->cat_ID; + $name = $category->cat_name; + $description = $category->category_description; + $slug = $category->category_nicename; + $parent = $category->category_parent; + $term_group = 0; + + // Associate terms with the same slug in a term group and make slugs unique. + if ( $exists = $wpdb->get_results( $wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug) ) ) { + $term_group = $exists[0]->term_group; + $id = $exists[0]->term_id; + $num = 2; + do { + $alt_slug = $slug . "-$num"; + $num++; + $slug_check = $wpdb->get_var( $wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug) ); + } while ( $slug_check ); + + $slug = $alt_slug; + + if ( empty( $term_group ) ) { + $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms GROUP BY term_group") + 1; + $wpdb->query( $wpdb->prepare("UPDATE $wpdb->terms SET term_group = %d WHERE term_id = %d", $term_group, $id) ); + } + } + + $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES + (%d, %s, %s, %d)", $term_id, $name, $slug, $term_group) ); + + $count = 0; + if ( !empty($category->category_count) ) { + $count = (int) $category->category_count; + $taxonomy = 'category'; + $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count) ); + $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; + } + + if ( !empty($category->link_count) ) { + $count = (int) $category->link_count; + $taxonomy = 'link_category'; + $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count) ); + $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; + } + + if ( !empty($category->tag_count) ) { + $have_tags = true; + $count = (int) $category->tag_count; + $taxonomy = 'post_tag'; + $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count) ); + $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; + } + + if ( empty($count) ) { + $count = 0; + $taxonomy = 'category'; + $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count) ); + $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; + } + } + + $select = 'post_id, category_id'; + if ( $have_tags ) + $select .= ', rel_type'; + + $posts = $wpdb->get_results("SELECT $select FROM $wpdb->post2cat GROUP BY post_id, category_id"); + foreach ( $posts as $post ) { + $post_id = (int) $post->post_id; + $term_id = (int) $post->category_id; + $taxonomy = 'category'; + if ( !empty($post->rel_type) && 'tag' == $post->rel_type) + $taxonomy = 'tag'; + $tt_id = $tt_ids[$term_id][$taxonomy]; + if ( empty($tt_id) ) + continue; + + $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES ( %d, %d)", $post_id, $tt_id) ); + } + + // < 3570 we used linkcategories. >= 3570 we used categories and link2cat. + if ( $wp_current_db_version < 3570 ) { + // Create link_category terms for link categories. Create a map of link cat IDs + // to link_category terms. + $link_cat_id_map = array(); + $default_link_cat = 0; + $tt_ids = array(); + $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM " . $wpdb->prefix . 'linkcategories'); + foreach ( $link_cats as $category) { + $cat_id = (int) $category->cat_id; + $term_id = 0; + $name = $wpdb->escape($category->cat_name); + $slug = sanitize_title($name); + $term_group = 0; + + // Associate terms with the same slug in a term group and make slugs unique. + if ( $exists = $wpdb->get_results( $wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug) ) ) { + $term_group = $exists[0]->term_group; + $term_id = $exists[0]->term_id; + } + + if ( empty($term_id) ) { + $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->terms (name, slug, term_group) VALUES (%s, %s, %d)", $name, $slug, $term_group) ); + $term_id = (int) $wpdb->insert_id; + } + + $link_cat_id_map[$cat_id] = $term_id; + $default_link_cat = $term_id; + + $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES (%d, 'link_category', '', '0', '0')", $term_id) ); + $tt_ids[$term_id] = (int) $wpdb->insert_id; + } + + // Associate links to cats. + $links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links"); + if ( !empty($links) ) foreach ( $links as $link ) { + if ( 0 == $link->link_category ) + continue; + if ( ! isset($link_cat_id_map[$link->link_category]) ) + continue; + $term_id = $link_cat_id_map[$link->link_category]; + $tt_id = $tt_ids[$term_id]; + if ( empty($tt_id) ) + continue; + + $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES ( %d, %d)", $link->link_id, $tt_id) ); + } + + // Set default to the last category we grabbed during the upgrade loop. + update_option('default_link_category', $default_link_cat); + } else { + $links = $wpdb->get_results("SELECT link_id, category_id FROM $wpdb->link2cat GROUP BY link_id, category_id"); + foreach ( $links as $link ) { + $link_id = (int) $link->link_id; + $term_id = (int) $link->category_id; + $taxonomy = 'link_category'; + $tt_id = $tt_ids[$term_id][$taxonomy]; + if ( empty($tt_id) ) + continue; + + $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES ( %d, %d)", $link_id, $tt_id) ); + } + } + + if ( $wp_current_db_version < 4772 ) { + // Obsolete linkcategories table + $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'linkcategories'); + } + + // Recalculate all counts + $terms = $wpdb->get_results("SELECT term_taxonomy_id, taxonomy FROM $wpdb->term_taxonomy"); + foreach ( (array) $terms as $term ) { + if ( ('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy) ) + $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id) ); + else + $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id) ); + $wpdb->query( $wpdb->prepare("UPDATE $wpdb->term_taxonomy SET count = %d WHERE term_taxonomy_id = %d", $count, $term->term_taxonomy_id) ); + } +} + +/** + * Remove old options from the database. + * + * @since 2.3.0 + */ +function upgrade_230_options_table() { + global $wpdb; + $old_options_fields = array( 'option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level' ); + $wpdb->hide_errors(); + foreach ( $old_options_fields as $old ) + $wpdb->query("ALTER TABLE $wpdb->options DROP $old"); + $wpdb->show_errors(); +} + +/** + * Remove old categories, link2cat, and post2cat database tables. + * + * @since 2.3.0 + */ +function upgrade_230_old_tables() { + global $wpdb; + $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'categories'); + $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'link2cat'); + $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'post2cat'); +} + +/** + * Upgrade old slugs made in version 2.2. + * + * @since 2.2.0 + */ +function upgrade_old_slugs() { + // upgrade people who were using the Redirect Old Slugs plugin + global $wpdb; + $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '_wp_old_slug' WHERE meta_key = 'old_slug'"); +} + +/** + * Execute changes made in WordPress 2.5.0. + * + * @since 2.5.0 + */ +function upgrade_250() { + global $wp_current_db_version; + + if ( $wp_current_db_version < 6689 ) { + populate_roles_250(); + } + +} + +/** + * Execute changes made in WordPress 2.5.1. + * + * @since 2.5.1 + */ +function upgrade_251() { + global $wp_current_db_version; + + // Make the secret longer + update_option('secret', wp_generate_password(64)); +} + +/** + * Execute changes made in WordPress 2.5.2. + * + * @since 2.5.2 + */ +function upgrade_252() { + global $wpdb; + + $wpdb->query("UPDATE $wpdb->users SET user_activation_key = ''"); +} + +/** + * Execute changes made in WordPress 2.6. + * + * @since 2.6.0 + */ +function upgrade_260() { + global $wp_current_db_version; + + if ( $wp_current_db_version < 8000 ) + populate_roles_260(); + + if ( $wp_current_db_version < 8201 ) { + update_option('enable_app', 1); + update_option('enable_xmlrpc', 1); + } +} + +/** + * Execute changes made in WordPress 2.7. + * + * @since 2.7.0 + */ +function upgrade_270() { + global $wpdb, $wp_current_db_version; + + if ( $wp_current_db_version < 8980 ) + populate_roles_270(); + + // Update post_date for unpublished posts with empty timestamp + if ( $wp_current_db_version < 8921 ) + $wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" ); +} + + +// The functions we use to actually do stuff + +// General + +/** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + * + * @param string $table_name Database table name to create. + * @param string $create_ddl SQL statement to create table. + * @return bool If table already exists or was created by function. + */ +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; +} + +/** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + * + * @param string $table Database table name. + * @param string $index Index name to drop. + * @return bool True, when finished. + */ +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; +} + +/** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + * + * @param string $table Database table name. + * @param string $index Database table index column. + * @return bool True, when done with execution. + */ +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
    "); + 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; +} + +/** + * Retrieve all options as it was for 1.2. + * + * @since 1.2.0 + * + * @return array List of options. + */ +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. + * + * @since unknown + * @access private + * + * @param string $setting Option name. + * @return mixed + */ +function __get_option($setting) { + global $wpdb; + + if ( $setting == 'home' && defined( 'WP_HOME' ) ) { + return preg_replace( '|/+$|', '', constant( 'WP_HOME' ) ); + } + + if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) ) { + return preg_replace( '|/+$|', '', constant( 'WP_SITEURL' ) ); + } + + $option = $wpdb->get_var( $wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $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; +} + +/** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + * + * @param string $content + * @return string + */ +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; +} + +/** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + * + * @param unknown_type $queries + * @param unknown_type $execute + * @return unknown + */ +function dbDelta($queries, $execute = true) { + global $wpdb; + + // Separate 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 "
    \n".print_r(strtolower($table), true).":\n".print_r($cqueries, true)."

    "; + + // 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)]}
    "; + 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 "
    {$table}:
    Found index:".$index_string."
    \n"; + } + //else echo "
    {$table}:
    Did not find index:".$index_string."
    ".print_r($indices, true)."
    \n"; + } + } + + // For every remaining index specified for the table + foreach ( (array) $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 "
    ".print_r($query, true)."
    \n"; + $wpdb->query($query); + } + } + + return $for_update; +} + +/** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + */ +function make_db_current() { + global $wp_queries; + + $alterations = dbDelta($wp_queries); + echo "
      \n"; + foreach($alterations as $alteration) echo "
    1. $alteration
    2. \n"; + echo "
    \n"; +} + +/** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + */ +function make_db_current_silent() { + global $wp_queries; + + $alterations = dbDelta($wp_queries); +} + +/** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + * + * @param unknown_type $theme_name + * @param unknown_type $template + * @return unknown + */ +function make_site_theme_from_oldschool($theme_name, $template) { + $home_path = get_home_path(); + $site_dir = WP_CONTENT_DIR . "/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 (strpos($index, 'WP_USE_THEMES') !== false) { + if (! @copy(WP_CONTENT_DIR . '/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("/wp-layout.css", "", $line); + + // Update comments template inclusion. + $line = str_replace("", "", $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; +} + +/** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + * + * @param unknown_type $theme_name + * @param unknown_type $template + * @return unknown + */ +function make_site_theme_from_default($theme_name, $template) { + $site_dir = WP_CONTENT_DIR . "/themes/$template"; + $default_dir = WP_CONTENT_DIR . '/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 = @ opendir("$default_dir"); + if ($theme_dir) { + while(($theme_file = readdir( $theme_dir )) !== 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); + } + } + @closedir($theme_dir); + + // 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 (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: ' . $theme_name; + elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: ' . __get_option('url'); + elseif (strpos($line, 'Description:') !== false) $line = 'Description: Your theme.'; + elseif (strpos($line, 'Version:') !== false) $line = 'Version: 1'; + elseif (strpos($line, 'Author:') !== false) $line = 'Author: You'; + fwrite($f, $line . "\n"); + } + fclose($f); + } + + // Copy the images. + umask(0); + if (! mkdir("$site_dir/images", 0777)) { + return false; + } + + $images_dir = @ opendir("$default_dir/images"); + if ($images_dir) { + while(($image = readdir($images_dir)) !== 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); + } + } + @closedir($images_dir); +} + +// Create a site theme from the default theme. +/** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + * + * @return unknown + */ +function make_site_theme() { + // Name the theme after the blog. + $theme_name = __get_option('blogname'); + $template = sanitize_title($theme_name); + $site_dir = WP_CONTENT_DIR . "/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(WP_CONTENT_DIR . "/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; +} + +/** + * Translate user level to user role name. + * + * @since unknown + * + * @param int $level User level. + * @return string User role name. + */ +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'; + } +} + +/** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + */ +function wp_check_mysql_version() { + global $wpdb; + $result = $wpdb->check_database_version(); + if ( is_wp_error( $result ) ) + die( $result->get_error_message() ); +} + +/** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + */ +function maybe_disable_automattic_widgets() { + $plugins = __get_option( 'active_plugins' ); + + foreach ( (array) $plugins as $plugin ) { + if ( basename( $plugin ) == 'widgets.php' ) { + array_splice( $plugins, array_search( $plugin, $plugins ), 1 ); + update_option( 'active_plugins', $plugins ); + break; + } + } +} + +?> diff -uNr a/blog/wp-admin/includes/user.php b/blog/wp-admin/includes/user.php --- a/blog/wp-admin/includes/user.php false +++ b/blog/wp-admin/includes/user.php b4de5ce1f15f8d9a270e1462e2d4de7477a411217606e1eef358919b7b85f492250b5a4a64d75b2b4000f08def02f244407ce1927b04be465cd86660d73c9acf @@ -0,0 +1,737 @@ +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(); + } +} + +/** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + * + * @param int $user_id Optional. User ID. + * @return unknown + */ +function edit_user( $user_id = 0 ) { + global $current_user, $wp_roles, $wpdb; + if ( $user_id != 0 ) { + $update = true; + $user->ID = (int) $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'] ) && current_user_can( 'edit_users' ) ) { + 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 = clean_url( trim( $_POST['url'] )); + $user->user_url = preg_match('/^(https?|ftps?|mailto|news|irc|gopher|nntp|feed|telnet):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url; + } + if ( isset( $_POST['first_name'] )) + $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 = 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'] )); + if ( !$update ) + $user->rich_editing = 'true'; // Default to true for new users. + else if ( isset( $_POST['rich_editing'] ) ) + $user->rich_editing = $_POST['rich_editing']; + else + $user->rich_editing = 'true'; + + $user->comment_shortcuts = isset( $_POST['comment_shortcuts'] )? $_POST['comment_shortcuts'] : ''; + + $user->use_ssl = 0; + if ( !empty($_POST['use_ssl']) ) + $user->use_ssl = 1; + + if ( !$update ) + $user->admin_color = 'fresh'; // Default to fresh for new users. + else if ( isset( $_POST['admin_color'] ) ) + $user->admin_color = $_POST['admin_color']; + else + $user->admin_color = 'fresh'; + + $errors = new WP_Error(); + + /* checking that username has been typed */ + if ( $user->user_login == '' ) + $errors->add( 'user_login', __( 'ERROR: Please enter a username.' )); + + /* checking the password has been typed twice */ + do_action_ref_array( 'check_passwords', array ( $user->user_login, & $pass1, & $pass2 )); + + if ( $update ) { + if ( empty($pass1) && !empty($pass2) ) + $errors->add( 'pass', __( 'ERROR: You entered your new password only once.' ), array( 'form-field' => 'pass1' ) ); + elseif ( !empty($pass1) && empty($pass2) ) + $errors->add( 'pass', __( 'ERROR: You entered your new password only once.' ), array( 'form-field' => 'pass2' ) ); + } else { + if ( empty($pass1) ) + $errors->add( 'pass', __( 'ERROR: Please enter your password.' ), array( 'form-field' => 'pass1' ) ); + elseif ( empty($pass2) ) + $errors->add( 'pass', __( 'ERROR: Please enter your password twice.' ), array( 'form-field' => 'pass2' ) ); + } + + /* Check for "\" in password */ + if( strpos( " ".$pass1, "\\" ) ) + $errors->add( 'pass', __( 'ERROR: Passwords may not contain the character "\\".' ), array( 'form-field' => 'pass1' ) ); + + /* checking the password has been typed twice the same */ + if ( $pass1 != $pass2 ) + $errors->add( 'pass', __( 'ERROR: Please enter the same password in the two password fields.' ), array( 'form-field' => 'pass1' ) ); + + if (!empty ( $pass1 )) + $user->user_pass = $pass1; + + if ( !$update && !validate_username( $user->user_login ) ) + $errors->add( 'user_login', __( 'ERROR: This username is invalid. Please enter a valid username.' )); + + if (!$update && username_exists( $user->user_login )) + $errors->add( 'user_login', __( 'ERROR: This username is already registered. Please choose another one.' )); + + /* checking e-mail address */ + if ( empty ( $user->user_email ) ) { + $errors->add( 'user_email', __( 'ERROR: Please enter an e-mail address.' ), array( 'form-field' => 'email' ) ); + } else + if (!is_email( $user->user_email ) ) { + $errors->add( 'user_email', __( "ERROR: The e-mail address isn't correct." ), array( 'form-field' => 'email' ) ); + } + + 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; +} + +/** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + * + * @return array List of user IDs. + */ +function get_author_user_ids() { + global $wpdb; + $level_key = $wpdb->prefix . 'user_level'; + return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) ); +} + +/** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + * + * @param int $user_id User ID. + * @return array|bool List of editable authors. False if no editable users. + */ +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) ORDER BY display_name" ); + } + + return apply_filters('get_editable_authors', $authors); +} + +/** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + * + * @param int $user_id User ID. + * @param bool $exclude_zeros Optional, default is true. Whether to exclude zeros. + * @return unknown + */ +function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'post' ) { + global $wpdb; + + $user = new WP_User( $user_id ); + + if ( ! $user->has_cap("edit_others_{$post_type}s") ) { + if ( $user->has_cap("edit_{$post_type}s") || $exclude_zeros == false ) + return array($user->id); + else + return false; + } + + $level_key = $wpdb->prefix . 'user_level'; + + $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key); + if ( $exclude_zeros ) + $query .= " AND meta_value != '0'"; + + return $wpdb->get_col( $query ); +} + +/** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + * + * @return unknown + */ +function get_nonauthor_user_ids() { + global $wpdb; + $level_key = $wpdb->prefix . 'user_level'; + + return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) ); +} + +/** + * Retrieve editable posts from other users. + * + * @since unknown + * + * @param int $user_id User ID to not retrieve posts from. + * @param string $type Optional, defaults to 'any'. Post type to retrieve, can be 'draft' or 'pending'. + * @return array List of posts from others. + */ +function get_others_unpublished_posts($user_id, $type='any') { + global $wpdb; + + $editable = get_editable_user_ids( $user_id ); + + if ( in_array($type, array('draft', 'pending')) ) + $type_sql = " post_status = '$type' "; + else + $type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) "; + + $dir = ( 'pending' == $type ) ? 'ASC' : 'DESC'; + + if( !$editable ) { + $other_unpubs = ''; + } else { + $editable = join(',', $editable); + $other_unpubs = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified $dir", $user_id) ); + } + + return apply_filters('get_others_drafts', $other_unpubs); +} + +/** + * Retrieve drafts from other users. + * + * @since unknown + * + * @param int $user_id User ID. + * @return array List of drafts from other users. + */ +function get_others_drafts($user_id) { + return get_others_unpublished_posts($user_id, 'draft'); +} + +/** + * Retrieve pending review posts from other users. + * + * @since unknown + * + * @param int $user_id User ID. + * @return array List of posts with pending review post type from other users. + */ +function get_others_pending($user_id) { + return get_others_unpublished_posts($user_id, 'pending'); +} + +/** + * Retrieve user data and filter it. + * + * @since unknown + * + * @param int $user_id User ID. + * @return object WP_User object with user data. + */ +function get_user_to_edit( $user_id ) { + $user = new WP_User( $user_id ); + $user->user_login = attribute_escape($user->user_login); + $user->user_email = attribute_escape($user->user_email); + $user->user_url = clean_url($user->user_url); + $user->first_name = attribute_escape($user->first_name); + $user->last_name = attribute_escape($user->last_name); + $user->display_name = attribute_escape($user->display_name); + $user->nickname = attribute_escape($user->nickname); + $user->aim = isset( $user->aim ) && !empty( $user->aim ) ? attribute_escape($user->aim) : ''; + $user->yim = isset( $user->yim ) && !empty( $user->yim ) ? attribute_escape($user->yim) : ''; + $user->jabber = isset( $user->jabber ) && !empty( $user->jabber ) ? attribute_escape($user->jabber) : ''; + $user->description = isset( $user->description ) && !empty( $user->description ) ? wp_specialchars($user->description) : ''; + + return $user; +} + +/** + * Retrieve the user's drafts. + * + * @since unknown + * + * @param int $user_id User ID. + * @return array + */ +function get_users_drafts( $user_id ) { + global $wpdb; + $query = $wpdb->prepare("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author = %d ORDER BY post_modified DESC", $user_id); + $query = apply_filters('get_users_drafts', $query); + return $wpdb->get_results( $query ); +} + +/** + * Remove user and optionally reassign posts and links to another user. + * + * If the $reassign parameter is not assigned to an User ID, then all posts will + * be deleted of that user. The action 'delete_user' that is passed the User ID + * being deleted will be run after the posts are either reassigned or deleted. + * The user meta will also be deleted that are for that User ID. + * + * @since unknown + * + * @param int $id User ID. + * @param int $reassign Optional. Reassign posts and links to new User ID. + * @return bool True when finished. + */ +function wp_delete_user($id, $reassign = 'novalue') { + global $wpdb; + + $id = (int) $id; + + if ($reassign == 'novalue') { + $post_ids = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id) ); + + if ($post_ids) { + foreach ($post_ids as $post_id) + wp_delete_post($post_id); + } + + // Clean links + $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->links WHERE link_owner = %d", $id) ); + } else { + $reassign = (int) $reassign; + $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_author = %d WHERE post_author = %d", $reassign, $id) ); + $wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_owner = %d WHERE link_owner = %d", $reassign, $id) ); + } + + // FINALLY, delete user + do_action('delete_user', $id); + + $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->users WHERE ID = %d", $id) ); + $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id) ); + + wp_cache_delete($id, 'users'); + wp_cache_delete($user->user_login, 'userlogins'); + wp_cache_delete($user->user_email, 'useremail'); + + return true; +} + +/** + * Remove all capabilities from user. + * + * @since unknown + * + * @param int $id User ID. + */ +function wp_revoke_user($id) { + $id = (int) $id; + + $user = new WP_User($id); + $user->remove_all_caps(); +} + +if ( !class_exists('WP_User_Search') ) : +/** + * WordPress User Search class. + * + * @since unknown + * @author Mark Jaquith + */ +class WP_User_Search { + + /** + * {@internal Missing Description}} + * + * @since unknown + * @access private + * @var unknown_type + */ + var $results; + + /** + * {@internal Missing Description}} + * + * @since unknown + * @access private + * @var unknown_type + */ + var $search_term; + + /** + * Page number. + * + * @since unknown + * @access private + * @var int + */ + var $page; + + /** + * Role name that users have. + * + * @since unknown + * @access private + * @var string + */ + var $role; + + /** + * Raw page number. + * + * @since unknown + * @access private + * @var int|bool + */ + var $raw_page; + + /** + * Amount of users to display per page. + * + * @since unknown + * @access public + * @var int + */ + var $users_per_page = 50; + + /** + * {@internal Missing Description}} + * + * @since unknown + * @access private + * @var unknown_type + */ + var $first_user; + + /** + * {@internal Missing Description}} + * + * @since unknown + * @access private + * @var int + */ + var $last_user; + + /** + * {@internal Missing Description}} + * + * @since unknown + * @access private + * @var unknown_type + */ + var $query_limit; + + /** + * {@internal Missing Description}} + * + * @since unknown + * @access private + * @var unknown_type + */ + var $query_sort; + + /** + * {@internal Missing Description}} + * + * @since unknown + * @access private + * @var unknown_type + */ + var $query_from_where; + + /** + * {@internal Missing Description}} + * + * @since unknown + * @access private + * @var int + */ + var $total_users_for_query = 0; + + /** + * {@internal Missing Description}} + * + * @since unknown + * @access private + * @var bool + */ + var $too_many_total_users = false; + + /** + * {@internal Missing Description}} + * + * @since unknown + * @access private + * @var unknown_type + */ + var $search_errors; + + /** + * {@internal Missing Description}} + * + * @since unknown + * @access private + * @var unknown_type + */ + var $paging_text; + + /** + * PHP4 Constructor - Sets up the object properties. + * + * @since unknown + * + * @param string $search_term Search terms string. + * @param int $page Optional. Page ID. + * @param string $role Role name. + * @return WP_User_Search + */ + function WP_User_Search ($search_term = '', $page = '', $role = '') { + $this->search_term = $search_term; + $this->raw_page = ( '' == $page ) ? false : (int) $page; + $this->page = (int) ( '' == $page ) ? 1 : $page; + $this->role = $role; + + $this->prepare_query(); + $this->query(); + $this->prepare_vars_for_template_usage(); + $this->do_paging(); + } + + /** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + * @access public + */ + function prepare_query() { + global $wpdb; + $this->first_user = ($this->page - 1) * $this->users_per_page; + $this->query_limit = $wpdb->prepare(" LIMIT %d, %d", $this->first_user, $this->users_per_page); + $this->query_sort = ' ORDER BY user_login'; + $search_sql = ''; + 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"; + if ( $this->role ) + $this->query_from_where .= $wpdb->prepare(" INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%'); + else + $this->query_from_where .= " WHERE 1=1"; + $this->query_from_where .= " $search_sql"; + + } + + /** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + * @access public + */ + function query() { + global $wpdb; + $this->results = $wpdb->get_col('SELECT ID ' . $this->query_from_where . $this->query_sort . $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!')); + } + + /** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + * @access public + */ + function prepare_vars_for_template_usage() { + $this->search_term = stripslashes($this->search_term); // done with DB, from now on we want slashes gone + } + + /** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + * @access public + */ + function do_paging() { + if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results + $args = array(); + if( ! empty($this->search_term) ) + $args['usersearch'] = urlencode($this->search_term); + if( ! empty($this->role) ) + $args['role'] = urlencode($this->role); + + $this->paging_text = paginate_links( array( + 'total' => ceil($this->total_users_for_query / $this->users_per_page), + 'current' => $this->page, + 'base' => 'users.php?%_%', + 'format' => 'userspage=%#%', + 'add_args' => $args + ) ); + if ( $this->paging_text ) { + $this->paging_text = sprintf( '' . __( 'Displaying %s–%s of %s' ) . '%s', + number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ), + number_format_i18n( min( $this->page * $this->users_per_page, $this->total_users_for_query ) ), + number_format_i18n( $this->total_users_for_query ), + $this->paging_text + ); + } + } + } + + /** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since unknown + * @access public + * + * @return unknown + */ + function get_results() { + return (array) $this->results; + } + + /** + * Displaying paging text. + * + * @see do_paging() Builds paging text. + * + * @since unknown + * @access public + */ + function page_links() { + echo $this->paging_text; + } + + /** + * Whether paging is enabled. + * + * @see do_paging() Builds paging text. + * + * @since unknown + * @access public + * + * @return bool + */ + function results_are_paged() { + if ( $this->paging_text ) + return true; + return false; + } + + /** + * Whether there are search terms. + * + * @since unknown + * @access public + * + * @return bool + */ + function is_search() { + if ( $this->search_term ) + return true; + return false; + } +} +endif; + +?> diff -uNr a/blog/wp-admin/includes/widgets.php b/blog/wp-admin/includes/widgets.php --- a/blog/wp-admin/includes/widgets.php false +++ b/blog/wp-admin/includes/widgets.php 568a0751c43bcec864595da406a1b5b962a9520260173f8f4f91fe185dca7d169e78989fe654166f2cea2e4e477b7cb4c38ce820bac63547fca24b161b1282ac @@ -0,0 +1,340 @@ + + +
      + $widget ) : + if ( 'all' == $show && in_array( $widget['callback'], $already_shown ) ) // We already showed this multi-widget + continue; + + if ( $search_terms ) { + $hit = false; + // Simple case-insensitive search. Boolean OR. + $search_text = preg_replace( '/[^\w]/', '', $widget['name'] ); + if ( isset($widget['description']) ) + $search_text .= preg_replace( '/[^\w]/', '', $widget['description'] ); + + foreach ( $search_terms as $search_term ) { + if ( stristr( $search_text, $search_term ) ) { + $hit = true; + break; + } + } + if ( !$hit ) + continue; + } + + $sidebar = is_active_widget( $widget['callback'], $widget['id'] ); + + if ( ( 'unused' == $show && $sidebar ) || ( 'used' == $show && !$sidebar ) ) + continue; + + if ( ! isset( $widget['params'][0] ) ) + $widget['params'][0] = array(); + ob_start(); + $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template', '_show' => $show ), 1 => $widget['params'][0] ) ); + $sidebar_args = call_user_func_array( 'wp_widget_control', $args ); + $widget_control_template = ob_get_contents(); + ob_end_clean(); + + $widget_id = $widget['id']; // save this for later in case we mess with $widget['id'] + + $is_multi = false !== strpos( $widget_control_template, '%i%' ); + if ( !$sidebar || $is_multi ) { + $add_query = array( + 'sidebar' => $sidebar, + 'key' => false, + 'edit' => false + ); + if ( 'all' == $show && $is_multi ) { + // it's a multi-widget. We only need to show it in the list once. + $already_shown[] = $widget['callback']; + $num = (int) array_pop( $ids = explode( '-', $widget['id'] ) ); + $id_base = $wp_registered_widget_controls[$widget['id']]['id_base']; + // so that we always add a new one when clicking "add" + while ( isset($wp_registered_widgets["$id_base-$num"]) ) + $num++; + $widget['id'] = "$id_base-$num"; + $add_query['base'] = $id_base; + $add_query['key'] = $num; + $add_query['sidebar'] = $GLOBALS['sidebar']; + } + $add_query['add'] = $widget['id']; + $action = 'add'; + $add_url = clean_url( wp_nonce_url( add_query_arg( $add_query ), "add-widget_$widget[id]" ) ); + } else { + $action = 'edit'; + $edit_url = clean_url( add_query_arg( array( + 'sidebar' => $sidebar, + 'edit' => $widget['id'], + 'key' => array_search( $widget['id'], $sidebars_widgets[$sidebar] ), + ) ) ); + + $widget_control_template = ''; + } + + $widget_control_template = $sidebar_args['before_widget'] . $widget_control_template . $sidebar_args['after_widget']; + + $no_widgets_shown = false; + + + if ( 'all' != $show && $sidebar_args['_widget_title'] ) + $widget_title = $sidebar_args['_widget_title']; + else + $widget_title = $widget['name']; + ?> + +
    • +

      + + + + + + + + + + + + + +
      + +

      + + +
        + + + +
      + + + + +
      + +
      + +
      + +
    • + + + +
    • + + + +
    + + +
      + + "; ?> + +
    + +\n"; + $params[0]['after_widget'] = ""; + $params[0]['before_title'] = "%BEG_OF_TITLE%"; + $params[0]['after_title'] = "%END_OF_TITLE%"; + if ( is_callable( $wp_registered_widgets[$widget_id]['callback'] ) ) { + $wp_registered_widgets[$widget_id]['_callback'] = $wp_registered_widgets[$widget_id]['callback']; + $wp_registered_widgets[$widget_id]['callback'] = 'wp_widget_control'; + } + return $params; +} + +/** + * Meta widget used to display the control form for a widget. + * + * Called from dynamic_sidebar(). + * + * @since unknown + * + * @param array $sidebar_args + * @return array + */ +function wp_widget_control( $sidebar_args ) { + global $wp_registered_widgets, $wp_registered_widget_controls, $sidebars_widgets, $edit_widget; + $widget_id = $sidebar_args['widget_id']; + $sidebar_id = isset($sidebar_args['id']) ? $sidebar_args['id'] : false; + + $control = isset($wp_registered_widget_controls[$widget_id]) ? $wp_registered_widget_controls[$widget_id] : 0; + $widget = $wp_registered_widgets[$widget_id]; + + $key = $sidebar_id ? array_search( $widget_id, $sidebars_widgets[$sidebar_id] ) : 'no-key'; // position of widget in sidebar + + $edit = -1 < $edit_widget && is_numeric($key) && $edit_widget === $key; // (bool) are we currently editing this widget + + $id_format = $widget['id']; + + if ( ! isset( $sidebar_args['_show'] ) ) + $sidebar_args['_show'] = ''; + + if ( ! isset( $sidebar_args['_display'] ) ) + $sidebar_args['_display'] = ''; + + // We aren't showing a widget control, we're outputing a template for a mult-widget control + if ( 'all' == $sidebar_args['_show'] && 'template' == $sidebar_args['_display'] && isset($control['params'][0]['number']) ) { + // number == -1 implies a template where id numbers are replaced by a generic '%i%' + $control['params'][0]['number'] = -1; + // if given, id_base means widget id's should be constructed like {$id_base}-{$id_number} + if ( isset($control['id_base']) ) + $id_format = $control['id_base'] . '-%i%'; + } + + $widget_title = ''; + // We grab the normal widget output to find the widget's title + if ( ( 'all' != $sidebar_args['_show'] || 'template' != $sidebar_args['_display'] ) && is_callable( $widget['_callback'] ) ) { + ob_start(); + $args = func_get_args(); + call_user_func_array( $widget['_callback'], $args ); + $widget_title = ob_get_clean(); + $widget_title = wp_widget_control_ob_filter( $widget_title ); + } + $wp_registered_widgets[$widget_id]['callback'] = $wp_registered_widgets[$widget_id]['_callback']; + unset($wp_registered_widgets[$widget_id]['_callback']); + + if ( $widget_title && $widget_title != $sidebar_args['widget_name'] ) + $widget_title = sprintf( _c('%1$s: %2$s|1: widget name, 2: widget title' ), $sidebar_args['widget_name'], $widget_title ); + else + $widget_title = wp_specialchars( strip_tags( $sidebar_args['widget_name'] ) ); + + $sidebar_args['_widget_title'] = $widget_title; + + if ( empty($sidebar_args['_display']) || 'template' != $sidebar_args['_display'] ) + echo $sidebar_args['before_widget']; +?> +
    +

    + + + + + + + + + + + +
    + +

    + +
    > + + ' . __('There are no options for this widget.') . '

    '; + ?> + + + + +
    + + + + + + + + "> +
    +
    +
    + \ No newline at end of file diff -uNr a/blog/wp-admin/index-extra.php b/blog/wp-admin/index-extra.php --- a/blog/wp-admin/index-extra.php false +++ b/blog/wp-admin/index-extra.php eda7b21ae4bb5abc164854449b62a8375de17c46ab68c774d03de35b8fa2940a0090438d19c3b7fc788c6679e18059de81523f24dc1143e3a8dd8b82eff80386 @@ -0,0 +1,40 @@ + \ No newline at end of file diff -uNr a/blog/wp-admin/index.php b/blog/wp-admin/index.php --- a/blog/wp-admin/index.php false +++ b/blog/wp-admin/index.php 41515c37107f89b72fb17deb474627308a5965888b1576987231fe9f693b6b7d3331dd6bd01e15f5f1f2fe9e511f0190d3b911efbbc771028a1fef6a057640ad @@ -0,0 +1,47 @@ + + +
    + +

    + +
    + + + +
    +
    + +
    + + diff -uNr a/blog/wp-admin/install-helper.php b/blog/wp-admin/install-helper.php --- a/blog/wp-admin/install-helper.php false +++ b/blog/wp-admin/install-helper.php d5669245de61c88f9024cb656cb6996b71455232cb0e9bd15b02544e12eaf405f9f17cbad9dfb2a91fe5908cdaccb77c1e8f8662d77a4552fe7c242ae1845eb7 @@ -0,0 +1,225 @@ + + * 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
    '; + * } else { + * $res .= 'There was a problem with ' . $tablename . '
    '; + * ++$error_count; + * } + * + * + * @package WordPress + * @subpackage Plugin + */ + +/** + * @global bool $wp_only_load_config + * @name $wp_only_load_config + * @var bool + * @since unknown + */ +$wp_only_load_config = true; + +/** Load WordPress Bootstrap */ +require_once(dirname(dirname(__FILE__)).'/wp-load.php'); + +/** + * Turn debugging on or off. + * @global bool|int $debug + * @name $debug + * @var bool|int + * @since unknown + */ +$debug = 0; + +if ( ! function_exists('maybe_create_table') ) : +/** + * Create database table, if it doesn't already exist. + * + * @since unknown + * @package WordPress + * @subpackage Plugin + * @uses $wpdb + * + * @param string $table_name Database table name. + * @param string $create_ddl Create database table SQL. + * @return bool False on error, true if already exists or success. + */ +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. + $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; +} +endif; + +if ( ! function_exists('maybe_add_column') ) : +/** + * Add column to database table, if column doesn't already exist in table. + * + * @since unknown + * @package WordPress + * @subpackage Plugin + * @uses $wpdb + * @uses $debug + * + * @param string $table_name Database table name + * @param string $column_name Table column name + * @param string $create_ddl SQL to add column to table. + * @return bool False on failure. True, if already exists or was successful. + */ +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
    "); + + if ($column == $column_name) { + return true; + } + } + //didn't find it try to create it. + $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; +} +endif; + +/** + * Drop column from database table, if it exists. + * + * @since unknown + * @package WordPress + * @subpackage Plugin + * @uses $wpdb + * + * @param string $table_name Table name + * @param string $column_name Column name + * @param string $drop_ddl SQL statement to drop column. + * @return bool False on failure, true on success or doesn't exist. + */ +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. + $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 matches criteria. + * + * Uses the SQL DESC for retrieving the table info for the column. It will help + * understand the parameters, if you do more research on what column information + * is returned by the SQL statement. Pass in null to skip checking that + * criteria. + * + * Column names returned from DESC table are case sensitive and are listed: + * Field + * Type + * Null + * Key + * Default + * Extra + * + * @since unknown + * @package WordPress + * @subpackage Plugin + * + * @param string $table_name Table name + * @param string $col_name Column name + * @param string $col_type Column type + * @param bool $is_null Optional. Check is null. + * @param mixed $key Optional. Key info. + * @param mixed $default Optional. Default value. + * @param mixed $extra Optional. Extra value. + * @return bool True, if matches. False, if not matching. + */ +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; +} + +?> diff -uNr a/blog/wp-admin/install.php b/blog/wp-admin/install.php --- a/blog/wp-admin/install.php false +++ b/blog/wp-admin/install.php f585c7e6a174bd4a734b0f6cb2fc3ea589c7a4689555f6f05289e8ed3bdcd39bbfd917b91cd146c72ab8a63411d8fbf0cde411891b512233cb897e9442071a71 @@ -0,0 +1,133 @@ + + +> + + + <?php _e('WordPress › Installation'); ?> + + + +

    WordPress

    + +'.__('Already Installed').'

    '.__('You appear to have already installed WordPress. To reinstall please clear your old database tables first.').'

    ');} + +switch($step) { + case 0: + case 1: // in case people are directly linking to this + display_header(); +?> +

    +

    ReadMe documentation at your leisure. Otherwise, just fill in the information below and you\'ll be on your way to using the most extendable and powerful personal publishing platform in the world.'), '../readme.html'); ?>

    + + +

    +

    + +
    + + + + + + + + + + + +

    + +
    +

    +
    + +error) ) + wp_die($wpdb->error->get_error_message()); + + display_header(); + // Fill in the data we gathered + $weblog_title = isset($_POST['weblog_title']) ? stripslashes($_POST['weblog_title']) : ''; + $admin_email = isset($_POST['admin_email']) ? stripslashes($_POST['admin_email']) : ''; + $public = isset($_POST['blog_public']) ? (int) $_POST['blog_public'] : 0; + // check e-mail address + if (empty($admin_email)) { + // TODO: poka-yoke + die('

    '.__("ERROR: you must provide an e-mail address.").'

    '); + } else if (!is_email($admin_email)) { + // TODO: poka-yoke + die('

    '.__('ERROR: that isn’t a valid e-mail address. E-mail addresses look like: username@example.com').'

    '); + } + + $wpdb->show_errors(); + $result = wp_install($weblog_title, 'admin', $admin_email, $public); + extract($result, EXTR_SKIP); +?> + +

    + +

    + + + + + + + + + + +
    admin

    + '.__('Note that password carefully! It is a random password that was generated just for you.').'

    '; ?>
    + +

    + + + + + diff -uNr a/blog/wp-admin/js/categories.js b/blog/wp-admin/js/categories.js --- a/blog/wp-admin/js/categories.js false +++ b/blog/wp-admin/js/categories.js 408245deb37c6ac1bdbd494cfac5413f8f7359cf4fe2950b1542e2fb90ae066e7840f5b212d966d00d8c76ff8455991987e41c1bcb80249d1de706be45a9b5a1 @@ -0,0 +1,37 @@ +jQuery(function($) { + var options = false + if ( document.forms['addcat'].category_parent ) + options = document.forms['addcat'].category_parent.options; + + var addAfter = function( r, settings ) { + var name = $("" + $('name', r).text() + "").html(); + var id = $('cat', r).attr('id'); + options[options.length] = new Option(name, id); + + addAfter2( r, settings ); + } + + var addAfter2 = function( x, r ) { + var t = $(r.parsed.responses[0].data); + if ( t.length == 1 ) + inlineEditTax.addEvents($(t.id)); + } + + var delAfter = function( r, settings ) { + var id = $('cat', r).attr('id'); + for ( var o = 0; o < options.length; o++ ) + if ( id == options[o].value ) + options[o] = null; + } + + if ( options ) + $('#the-list').wpList( { addAfter: addAfter, delAfter: delAfter } ); + else + $('#the-list').wpList({ addAfter: addAfter2 }); + + if ( jQuery('#link-category-search-input').size() ) { + columns.init('edit-link-categories'); + } else { + columns.init('categories'); + } +}); diff -uNr a/blog/wp-admin/js/cat.js b/blog/wp-admin/js/cat.js --- a/blog/wp-admin/js/cat.js false +++ b/blog/wp-admin/js/cat.js 80f59404988030856f04908f12a0965659042c593d5126c6209d0318584f5e4b265eea2d6b336d499bc36842c229ebc42a54d9eb65107693248aebc73060b299 @@ -0,0 +1,5 @@ +jQuery( function($) { + var myConfirm = function() { return '' !== $('#newcat').val(); }; + $('#jaxcat').prepend('' + catL10n.how + '') + $('#categorychecklist').wpList( { alt: '', response: 'cat-ajax-response', confirm: myConfirm } ); +} ); diff -uNr a/blog/wp-admin/js/comment.js b/blog/wp-admin/js/comment.js --- a/blog/wp-admin/js/comment.js false +++ b/blog/wp-admin/js/comment.js 6473d2ab67f2abb9e66a6b24c39b076091c9b113dcee6adbf803d6ec2d893d0b98e37299f69ba62a54ba9560ee6c9f5a76427edeb204b3b262cf9f0d1a62ef6a @@ -0,0 +1,39 @@ +jQuery(document).ready( function($) { + jQuery('.hide-if-no-js').show(); + jQuery('.hide-if-js').hide(); + + var stamp = $('#timestamp').html(); + $('.edit-timestamp').click(function () { + if ($('#timestampdiv').is(":hidden")) { + $('#timestampdiv').slideDown("normal"); + $('.edit-timestamp').hide(); + } + return false; + }); + + $('.cancel-timestamp').click(function() { + $('#timestampdiv').slideUp("normal"); + $('#mm').val($('#hidden_mm').val()); + $('#jj').val($('#hidden_jj').val()); + $('#aa').val($('#hidden_aa').val()); + $('#hh').val($('#hidden_hh').val()); + $('#mn').val($('#hidden_mn').val()); + $('#timestamp').html(stamp); + $('.edit-timestamp').show(); + return false; + }); + + $('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels + $('#timestampdiv').slideUp("normal"); + $('.edit-timestamp').show(); + $('#timestamp').html( + commentL10n.submittedOn + ' ' + + $( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' + + $('#jj').val() + ', ' + + $('#aa').val() + ' @ ' + + $('#hh').val() + ':' + + $('#mn').val() + ' ' + ); + return false; + }); +}); \ No newline at end of file diff -uNr a/blog/wp-admin/js/common.js b/blog/wp-admin/js/common.js --- a/blog/wp-admin/js/common.js false +++ b/blog/wp-admin/js/common.js 081795ba477f35e0ed5dbf40723d5d552115905eea990a155b057f21710b70b24bbaf835fccda9027926420fd4649c36a01392a9d75502195d92b561cbdd2e60 @@ -0,0 +1,395 @@ + +wpCookies = { +// The following functions are from Cookie.js class in TinyMCE, Moxiecode, used under LGPL. + + each : function(o, cb, s) { + var n, l; + + if (!o) + return 0; + + s = s || o; + + if (typeof(o.length) != 'undefined') { + for (n=0, l = o.length; n