worsethanhitler/readme.html0000644001761300176130000001672611225331455016674 0ustar mustardamustarda WordPress › ReadMe

WordPress
Version 2.8

Semantic Personal Publishing Platform

First Things First

Welcome. WordPress is a very special project to me. Every developer and contributor adds something unique to the mix, and together we create something beautiful that I'm proud to be a part of. Thousands of hours have gone into WordPress, and we're dedicated to making it better every day. Thank you for making it part of your world.

— Matt Mullenweg

Installation: Famous 5-minute install

  1. Unzip the package in an empty directory.
  2. Open up wp-config-sample.php with a text editor like WordPad or similar and fill in your database connection details.
  3. Save the file as wp-config.php
  4. Upload everything.
  5. Open /wp-admin/install.php in your browser. This should setup the tables needed for your blog. If there is an error, double check your wp-config.php file, and try again. If it fails again, please go to the support forums with as much data as you can gather.
  6. Note the password given to you.
  7. The install script should then send you to the login page. Sign in with the username admin and the password generated during the installation. You can then click on 'Profile' to change the password.

Upgrading

Before you upgrade anything, make sure you have backup copies of any files you may have modified such as index.php.

Upgrading from any previous WordPress to 2.8:

  1. Delete your old WP files, saving ones you've modified.
  2. Upload the new files.
  3. Point your browser to /wp-admin/upgrade.php.
  4. You wanted more, perhaps? That's it!

Template Changes

If you have customized your templates you will probably have to make some changes to them. If you're converting your 1.2 or earlier templates, we've created a special guide for you.

Online Resources

If you have any questions that aren't addressed in this document, please take advantage of WordPress' numerous online resources:

The WordPress Codex
The Codex is the encyclopedia of all things WordPress. It is the most comprehensive source of information for WordPress available.
The Development Blog
This is where you'll find the latest updates and news related to WordPress. Bookmark and check often.
WordPress Planet
The WordPress Planet is a news aggregator that brings together posts from WordPress blogs around the web.
WordPress Support Forums
If you've looked everywhere and still can't find an answer, the support forums are very active and have a large community ready to help. To help them help you be sure to use a descriptive thread title and describe your question in as much detail as possible.
WordPress IRC Channel
Finally, there is an online chat channel that is used for discussion among people who use WordPress and occasionally support topics. The above wiki page should point you in the right direction. (irc.freenode.net #wordpress)

System Recommendations

WordPress is the official continuation of b2/cafélog, which came from Michel V. The work has been continued by the WordPress developers. If you would like to support WordPress, please consider donating.

Upgrading from another system

WordPress can import from a number of systems. First you need to get WordPress installed and working as described above.

XML-RPC and Atom Interface

You can now post to your WordPress blog with tools like Windows Live Writer, Ecto, Bloggar, Radio Userland (which means you can use Radio's email-to-blog feature), NewzCrawler, and other tools that support the Blogging APIs! :) You can read more about XML-RPC support on the Codex.

Post via Email

You can post from an email client! To set this up go to your "Writing" options screen and fill in the connection details for your secret POP3 account. Then you need to set up wp-mail.php to execute periodically to check the mailbox for new posts. You can do it with Cron-jobs, or if your host doesn't support it you can look into the various website-monitoring services, and make them check your wp-mail.php URL.

Posting is easy: Any email sent to the address you specify will be posted, with the subject as the title. It is best to keep the address discrete. The script will delete emails that are successfully posted.

User Roles

We've eliminated user levels in order to make way for the much more flexible roles system introduced in 2.0. You can read more about Roles and Capabilities on the Codex.

Final notes

Share the Love

WordPress has no multi-million dollar marketing campaign or celebrity sponsors, but we do have something even better—you. If you enjoy WordPress please consider telling a friend, setting it up for someone less knowledgable than yourself, or writing the author of a media article that overlooks us.

Copyright

WordPress is released under the GPL (see license.txt).

worsethanhitler/wp-admin/edit-attachment-rows.php0000644001761300176130000001512511225331455023031 0ustar mustardamustarda 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, false ); 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('" . esc_js(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'> " . esc_html(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("" . /* translators: comment count link */ _x('0', 'comment count') . '', "" . /* translators: comment count link */ _x('1', 'comment count') . '', "" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . ''); if ( $left ) echo ''; ?>
> | >

worsethanhitler/wp-admin/plugin-install.php0000644001761300176130000000417311225331455021731 0ustar mustardamustarda


' + first + '' + '' + '' + ''); } else if ( first && !last ) { $('#display_name').append(''); } else if ( !first && last ) { $('#display_name').append(''); } }); }); })(jQuery); worsethanhitler/wp-admin/js/editor.js0000644001761300176130000001046611225331455020520 0ustar mustardamustardajQuery(document).ready(function(b){var a=wpCookies.getHash("TinyMCE_content_size");if(getUserSetting("editor")=="html"){if(a){b("#content").css("height",a.ch-15+"px")}}else{b("#content").css("color","white");b("#quicktags").hide()}});var switchEditors={mode:"",I:function(a){return document.getElementById(a)},edInit:function(){},saveCallback:function(b,c,a){if(tinyMCE.activeEditor.isHidden()){c=this.I(b).value}else{c=this.pre_wpautop(c)}return c},pre_wpautop:function(b){var c,a;b=b.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g,function(d){d=d.replace(/
[\r\n]*/g,"");return d.replace(/<\/?p( [^>]*)?>[\r\n]*/g,"")});c="blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|p";b=b.replace(new RegExp("\\s*\\s*","mg"),"\n");b=b.replace(new RegExp("\\s*<(("+c+")[^>]*)>","mg"),"\n<$1>");b=b.replace(new RegExp("(

]+>.*?)

","mg"),"$1");b=b.replace(new RegExp("]*)>\\s*

","mgi"),"\n\n");b=b.replace(new RegExp("\\s*

","mgi"),"");b=b.replace(new RegExp("\\s*

\\s*","mgi"),"\n\n");b=b.replace(new RegExp("\\n\\s*\\n","mgi"),"\n\n");b=b.replace(new RegExp("\\s*
\\s*","gi"),"\n");b=b.replace(new RegExp("\\s*\\s*","mg"),"\n");b=b.replace(new RegExp("\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*","gi"),"\n\n[caption$1[/caption]\n\n");b=b.replace(new RegExp("caption\\]\\n\\n+\\[caption","g"),"caption]\n\n[caption");a="blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre";b=b.replace(new RegExp("\\s*<(("+a+") ?[^>]*)\\s*>","mg"),"\n<$1>");b=b.replace(new RegExp("\\s*\\s*","mg"),"\n");b=b.replace(new RegExp("]*)>","g"),"\t");if(b.indexOf("/g,function(d){return d.replace(/[\r\n]+/g,"")})}b=b.replace(new RegExp("","g"),"

\n");b=b.replace(new RegExp("\\s*(

]+>.*

)","mg"),"\n$1");b=b.replace(new RegExp("^\\s*",""),"");b=b.replace(new RegExp("[\\s\\u00a0]*$",""),"");b=b.replace(//g,"\n");return b},go:function(i,g){i=i||"content";g=g||this.mode||"";var b,h=this.I("quicktags"),c=this.I("edButtonHTML"),d=this.I("edButtonPreview"),a=this.I(i);try{b=tinyMCE.get(i)}catch(f){b=false}if("tinymce"==g){if(b&&!b.isHidden()){return false}setUserSetting("editor","tinymce");this.mode="html";d.className="active";c.className="";edCloseAllTags();h.style.display="none";a.value=this.wpautop(a.value);if(b){b.show()}else{try{tinyMCE.execCommand("mceAddControl",false,i)}catch(f){}}}else{setUserSetting("editor","html");a.style.color="#000";this.mode="tinymce";c.className="active";d.className="";if(b&&!b.isHidden()){a.style.height=b.getContentAreaContainer().offsetHeight+24+"px";b.hide()}h.style.display="block"}return false},wpautop:function(a){var b="table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]";if(a.indexOf("/g,function(c){return c.replace(/[\r\n]+/g,"")})}a=a.replace(/<[^<>]+>/g,function(c){return c.replace(/[\r\n]+/g," ")});a=a+"\n\n";a=a.replace(new RegExp("
\\s*
","gi"),"\n\n");a=a.replace(new RegExp("(<(?:"+b+")[^>]*>)","gi"),"\n$1");a=a.replace(new RegExp("()","gi"),"$1\n\n");a=a.replace(new RegExp("\\r\\n|\\r","g"),"\n");a=a.replace(new RegExp("\\n\\s*\\n+","g"),"\n\n");a=a.replace(new RegExp("([\\s\\S]+?)\\n\\n","mg"),"

$1

\n");a=a.replace(new RegExp("

\\s*?

","gi"),"");a=a.replace(new RegExp("

\\s*(]*>)\\s*

","gi"),"$1");a=a.replace(new RegExp("

(","gi"),"$1");a=a.replace(new RegExp("

\\s*]*)>","gi"),"

");a=a.replace(new RegExp("\\s*

","gi"),"

");a=a.replace(new RegExp("

\\s*(]*>)","gi"),"$1");a=a.replace(new RegExp("(]*>)\\s*

","gi"),"$1");a=a.replace(new RegExp("\\s*\\n","gi"),"
\n");a=a.replace(new RegExp("(]*>)\\s*
","gi"),"$1");a=a.replace(new RegExp("
(\\s*)","gi"),"$1");a=a.replace(new RegExp("(?:

|
)*\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*(?:

|
)*","gi"),"[caption$1[/caption]");a=a.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g,function(c){c=c.replace(/
[\r\n]*/g,"\n");return c.replace(/<\/?p( [^>]*)?>[\r\n]*/g,"\n")});return a}};worsethanhitler/wp-admin/js/plugin-install.dev.js0000644001761300176130000000277211225331455022752 0ustar mustardamustarda/* Plugin Browser Thickbox related JS*/ jQuery(document).ready(function($) { var thickDims = function() { var tbWindow = $('#TB_window'), width = $(window).width(), H = $(window).height(), W = ( 720 < width ) ? 720 : width; if ( tbWindow.size() ) { tbWindow.width( W - 50 ).height( H - 45 ); $('#TB_iframeContent').width( W - 50 ).height( H - 75 ); tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'}); if ( ! ( $.browser.msie && $.browser.version.substr(0,1) < 7 ) ) tbWindow.css({'top':'20px','margin-top':'0'}); }; return $('#dashboard_plugins a.thickbox, .plugins a.thickbox').each( function() { var href = $(this).attr('href'); if ( ! href ) return; href = href.replace(/&width=[0-9]+/g, ''); href = href.replace(/&height=[0-9]+/g, ''); $(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) ); }); }; thickDims().click( function() { $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'}); $('#TB_ajaxWindowTitle').html('' + plugininstallL10n.plugin_information + ' ' + $(this).attr('title') ); return false; }); /* Plugin install related JS*/ $('#plugin-information #sidemenu a').click( function() { var tab = $(this).attr('name'); //Flip the tab $('#plugin-information-header a.current').removeClass('current'); $(this).addClass('current'); //Flip the content. $('#section-holder div.section').hide(); //Hide 'em all $('#section-' + tab).show(); return false; }); }); worsethanhitler/wp-admin/js/dashboard.js0000644001761300176130000000230711225331455021154 0ustar mustardamustardajQuery(document).ready(function(c){var a,b,d;a=["dashboard_incoming_links","dashboard_primary","dashboard_secondary","dashboard_plugins"];b=function(){c.each(a,function(){var f=jQuery("#"+this+":visible div.inside").find(".widget-loading");if(f.size()){f.parent().load("index-extra.php?jax="+this)}})};b();postboxes.add_postbox_toggles("dashboard",{onShow:b});d=function(){var e=c("#quickpost-action"),f;f=c("#quick-press").submit(function(){c("#dashboard_quick_press h3").append('');c('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr("disabled","disabled");if("post"==e.val()){e.val("post-quickpress-publish")}c("#dashboard_quick_press div.inside").load(f.attr("action"),f.serializeArray(),function(){c("#dashboard_quick_press h3 img").remove();c('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr("disabled","");c("#dashboard_quick_press ul").find("li").each(function(){c("#dashboard_recent_drafts ul").prepend(this)}).end().remove();tb_init("a.thickbox");d()});return false});c("#publish").click(function(){e.val("post-quickpress-publish")})};d()});worsethanhitler/wp-admin/js/cat.dev.js0000644001761300176130000000107511225331455020552 0ustar mustardamustardajQuery(document).ready( function($) { var myConfirm = function() { return '' !== $('#newcat').val(); }; $('#jaxcat').prepend('' + catL10n.how + ''); $('#categorychecklist').wpList( { alt: '', response: 'cat-ajax-response', confirm: myConfirm } ); } ); worsethanhitler/wp-admin/js/widgets.js0000644001761300176130000001331011225331455020667 0ustar mustardamustardavar wpWidgets;(function(a){wpWidgets={init:function(){var b;if(a("body").hasClass("widgets_access")){return}a("#widgets-right div.sidebar-name").click(function(){var d=a(this).siblings(".widgets-sortables");if(d.is(":visible")){d.sortable("disable");a(this).parent().addClass("closed")}else{a(this).parent().removeClass("closed");d.sortable("enable").sortable("refresh")}});a("#widgets-left div.sidebar-name").click(function(){if(a(this).siblings(".widget-holder").is(":visible")){a(this).parent().addClass("closed")}else{a(this).parent().removeClass("closed")}});a("#widgets-right .widget, #wp_inactive_widgets .widget").each(function(){wpWidgets.appendTitle(this)});this.addEvents();a(".widget-error").parents(".widget").find("a.widget-action").click();a("#available-widgets").droppable({tolerance:"pointer",accept:function(c){return a(c).parent().attr("id")!="widget-list"},drop:function(d,c){c.draggable.addClass("deleting");a("#removing-widget").hide().children("span").html("")},over:function(d,c){c.draggable.addClass("deleting");a(".widget-placeholder").hide();if(c.draggable.hasClass("ui-sortable-helper")){a("#removing-widget").show().children("span").html(c.draggable.find(".widget-title h4").html())}},out:function(d,c){c.draggable.removeClass("deleting");a(".widget-placeholder").show();a("#removing-widget").hide().children("span").html("")}});a("#widget-list .widget").draggable({connectToSortable:".widgets-sortables",handle:".widget-title",distance:2,helper:"clone",zIndex:5,containment:"document",start:function(d,c){wpWidgets.fixWebkit(1);c.helper.find(".widget-description").hide()},stop:function(d,c){if(b){a(b).hide()}b="";wpWidgets.fixWebkit()}});a(".widgets-sortables").sortable({placeholder:"widget-placeholder",connectWith:".widgets-sortables",items:".widget",handle:".widget-title",cursor:"move",distance:2,containment:"document",start:function(d,c){wpWidgets.fixWebkit(1);c.item.find(".widget-inside").hide();c.item.css({marginLeft:"",width:""})},stop:function(f,c){if(c.item.hasClass("ui-draggable")){c.item.draggable("destroy")}if(c.item.hasClass("deleting")){wpWidgets.save(c.item,1,0,1);c.item.remove();return}var d=c.item.find("input.add_new").val(),i=c.item.find("input.multi_number").val(),h=c.item.attr("id"),g=a(this).attr("id");c.item.css({marginLeft:"",width:""});wpWidgets.fixWebkit();if(d){if("multi"==d){c.item.html(c.item.html().replace(/<[^<>]+>/g,function(e){return e.replace(/__i__|%i%/g,i)}));c.item.attr("id",h.replace(/__i__|%i%/g,i));i++;a("div#"+h).find("input.multi_number").val(i)}else{if("single"==d){c.item.attr("id","new-"+h);b="div#"+h}}wpWidgets.addEvents(c.item);wpWidgets.save(c.item,0,0,1);c.item.find("input.add_new").val("");c.item.find("a.widget-action").click();return}wpWidgets.saveOrder(g)},receive:function(d,c){if(!a(this).is(":visible")){a(this).sortable("cancel")}}}).not(":visible").sortable("disable");wpWidgets.resize();wpWidgets.fixLabels()},saveOrder:function(c){if(c){a("#"+c).parents(".widgets-holder-wrap").find(".ajax-feedback").css("visibility","visible")}var b={action:"widgets-order",savewidgets:a("#_wpnonce_widgets").val(),sidebars:[]};a(".widgets-sortables").each(function(){b["sidebars["+a(this).attr("id")+"]"]=a(this).sortable("toArray").join(",")});a.post(ajaxurl,b,function(){a(".ajax-feedback").css("visibility","hidden")});this.resize()},save:function(g,d,e,b){var h=g.parents(".widgets-sortables").attr("id"),f=g.find("form").serialize(),c;g=a(g);g.find(".ajax-feedback").css("visibility","visible");c={action:"save-widget",savewidgets:a("#_wpnonce_widgets").val(),sidebar:h};if(d){c.delete_widget=1}f+="&"+a.param(c);a.post(ajaxurl,f,function(i){var j;if(d){if(!a(".widget_number",g).val()){j=a(".widget-id",g).val();a("#available-widgets .widget-id").each(function(){if(a(this).val()==j){a(this).parents(".widget").show()}})}if(e){b=0;g.slideUp("fast",function(){a(this).remove();wpWidgets.saveOrder()})}else{g.remove();wpWidgets.resize()}}else{a(".ajax-feedback").css("visibility","hidden");if(i&&i.length>2){a(".widget-content",g).html(i);wpWidgets.appendTitle(g);wpWidgets.fixLabels(g)}}if(b){wpWidgets.saveOrder()}})},appendTitle:function(b){a('input[type="text"]',b).each(function(){var c;if(this.id.indexOf("title")!=-1){c=a(this).val().replace(/<[^<>]+>/g,"").replace(//g,">");if(c){a(".widget-title .in-widget-title",b).html(": "+c)}return false}})},resize:function(){a(".widgets-sortables").not("#wp_inactive_widgets").each(function(){var c=50,b=a(".widget",this).length;c=c+parseInt(b*48,10);a(this).css("minHeight",c+"px")})},fixWebkit:function(b){b=b?"none":"";a("body").css({WebkitUserSelect:b,KhtmlUserSelect:b})},fixLabels:function(b){b=b||document;a(".widget-inside label",b).each(function(){var c=a(this).attr("for");if(c&&c==a("input",this).attr("id")){a(this).removeAttr("for")}})},close:function(b){b.find(".widget-inside").slideUp("fast",function(){b.css({width:"",marginLeft:""})})},addEvents:function(b){b=b||document;a("a.widget-action",b).click(function(){var d=parseInt(a(this).parents(".widget").find(".widget-width").val(),10),e={},c=a(this).parents(".widget-top").siblings(".widget-inside");if(c.is(":hidden")){if(d>250&&c.parents(".widgets-sortables").length){e.width=d+30+"px";if(c.parents(".widget-liquid-right").length){e.marginLeft=235-d+"px"}c.parents(".widget").css(e)}c.slideDown("fast")}else{c.slideUp("fast",function(){c.parents(".widget").css({width:"",marginLeft:""})})}return false});a(".widget-control-save",b).click(function(){wpWidgets.save(a(this).parents(".widget"),0,1,0);return false});a(".widget-control-remove",b).click(function(){wpWidgets.save(a(this).parents(".widget"),1,1,0);return false});a(".widget-control-close",b).click(function(){wpWidgets.close(a(this).parents(".widget"));return false})}};a(document).ready(function(){wpWidgets.init()})})(jQuery);worsethanhitler/wp-admin/js/tags.js0000644001761300176130000000127511225331455020166 0ustar mustardamustardajQuery(document).ready(function(d){var b=false,f,e,c,a;f=function(i,h){var g=d(""+d("name",i).text()+"").html(),j=d("tag",i).attr("id");b[b.length]=new Option(g,j)};e=function(g,i){var h=d(i.parsed.responses[0].data);if(h.length==1){inlineEditTax.addEvents(d(h.id))}};a=function(h,g){var j=d("tag",h).attr("id"),i;for(i=0;i 0 ) t.revert(); }); }, toggle : function(el) { var t = this; $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el); }, addEvents : function(r) { r.each(function() { $(this).find('a.editinline').click(function() { inlineEditTax.edit(this); return false; }); }); }, edit : function(id) { var t = this, editRow; t.revert(); if ( typeof(id) == 'object' ) id = t.getId(id); editRow = $('#inline-edit').clone(true), rowData = $('#inline_'+id); $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length); if ( $(t.what+id).hasClass('alternate') ) $(editRow).addClass('alternate'); $(t.what+id).hide().after(editRow); $(':input[name="name"]', editRow).val( $('.name', rowData).text() ); $(':input[name="slug"]', editRow).val( $('.slug', rowData).text() ); $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show(); $('.ptitle', editRow).eq(0).focus(); return false; }, save : function(id) { var params, fields, tax = $('input[name="taxonomy"]').val() || ''; if( typeof(id) == 'object' ) id = this.getId(id); $('table.widefat .inline-edit-save .waiting').show(); params = { action: 'inline-save-tax', tax_type: this.type, tax_ID: id, taxonomy: tax }; fields = $('#edit-'+id+' :input').fieldSerialize(); params = fields + '&' + $.param(params); // make ajax request $.post('admin-ajax.php', params, function(r) { var row, new_id; $('table.widefat .inline-edit-save .waiting').hide(); if (r) { if ( -1 != r.indexOf(']*?>/g, '' ); } if ( er ) { $('#find-posts-response').html(er); } } }; $(document).ready(function() { $('#find-posts-submit').click(function(e) { if ( '' == $('#find-posts-response').html() ) e.preventDefault(); }); $('#doaction, #doaction2').click(function(e){ $('select[name^="action"]').each(function(){ if ( $(this).val() == 'attach' ) { e.preventDefault(); findPosts.open(); } }); }); }); })(jQuery); worsethanhitler/wp-admin/js/common.js0000644001761300176130000001437311225331455020523 0ustar mustardamustardavar showNotice,adminMenu,columns;(function(a){adminMenu={init:function(){a("#adminmenu div.wp-menu-toggle").each(function(){if(a(this).siblings(".wp-submenu").length){a(this).click(function(){adminMenu.toggle(a(this).siblings(".wp-submenu"))})}else{a(this).hide()}});this.favorites();a("a.separator").click(function(){if(a("body").hasClass("folded")){adminMenu.fold(1);deleteUserSetting("mfold")}else{adminMenu.fold();setUserSetting("mfold","f")}return false});if(a("body").hasClass("folded")){this.fold()}this.restoreMenuState()},restoreMenuState:function(){a("#adminmenu li.wp-has-submenu").each(function(c,d){var b=getUserSetting("m"+c);if(a(d).hasClass("wp-has-current-submenu")){return true}if("o"==b){a(d).addClass("wp-menu-open")}else{if("c"==b){a(d).removeClass("wp-menu-open")}}})},toggle:function(b){b.slideToggle(150,function(){b.css("display","")}).parent().toggleClass("wp-menu-open");a("#adminmenu li.wp-has-submenu").each(function(d,f){var c=a(f).hasClass("wp-menu-open")?"o":"c";setUserSetting("m"+d,c)});return false},fold:function(b){if(b){a("body").removeClass("folded");a("#adminmenu li.wp-has-submenu").unbind()}else{a("body").addClass("folded");a("#adminmenu li.wp-has-submenu").hoverIntent({over:function(j){var d,c,g,k,i;d=a(this).find(".wp-submenu");c=d.parent().offset().top+d.height()+1;g=a("#wpwrap").height();k=60+c-g;i=a(window).height()+a("body").scrollTop()-15;if(i<(c-k)){k=c-i}if(k>1){d.css({marginTop:"-"+k+"px"})}else{if(d.css("marginTop")){d.css({marginTop:""})}}d.addClass("sub-open")},out:function(){a(this).find(".wp-submenu").removeClass("sub-open").css({marginTop:""})},timeout:220,sensitivity:8,interval:100})}},favorites:function(){a("#favorite-inside").width(a("#favorite-actions").width()-4);a("#favorite-toggle, #favorite-inside").bind("mouseenter",function(){a("#favorite-inside").removeClass("slideUp").addClass("slideDown");setTimeout(function(){if(a("#favorite-inside").hasClass("slideDown")){a("#favorite-inside").slideDown(100);a("#favorite-first").addClass("slide-down")}},200)});a("#favorite-toggle, #favorite-inside").bind("mouseleave",function(){a("#favorite-inside").removeClass("slideDown").addClass("slideUp");setTimeout(function(){if(a("#favorite-inside").hasClass("slideUp")){a("#favorite-inside").slideUp(100,function(){a("#favorite-first").removeClass("slide-down")})}},300)})}};a(document).ready(function(){adminMenu.init()});columns={init:function(){a(".hide-column-tog").click(function(){var c=a(this).val(),b=a(this).attr("checked");if(b){a(".column-"+c).show()}else{a(".column-"+c).hide()}columns.save_manage_columns_state()})},save_manage_columns_state:function(){var b=a(".manage-column").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(ajaxurl,{action:"hidden-columns",hidden:b,screenoptionnonce:a("#screenoptionnonce").val(),page:pagenow})}};a(document).ready(function(){columns.init()})})(jQuery);showNotice={warn:function(){var a=commonL10n.warnDelete||"";if(confirm(a)){return true}return false},note:function(a){alert(a)}};jQuery(document).ready(function(d){var f=false,a,e,c,b;d(".fade").animate({backgroundColor:"#ffffe0"},300).animate({backgroundColor:"#fffbcc"},300).animate({backgroundColor:"#ffffe0"},300).animate({backgroundColor:"#fffbcc"},300);d("div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error").addClass("below-h2");d("div.updated, div.error").not(".below-h2").insertAfter("div.wrap h2:first");d("#doaction, #doaction2").click(function(){if(d('select[name="action"]').val()=="delete"||d('select[name="action2"]').val()=="delete"){return showNotice.warn()}});d("#show-settings-link").click(function(){if(!d("#screen-options-wrap").hasClass("screen-options-open")){d("#contextual-help-link-wrap").css("visibility","hidden")}d("#screen-options-wrap").slideToggle("fast",function(){if(d(this).hasClass("screen-options-open")){d("#show-settings-link").css({backgroundImage:'url("images/screen-options-right.gif")'});d("#contextual-help-link-wrap").css("visibility","");d(this).removeClass("screen-options-open")}else{d("#show-settings-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'});d(this).addClass("screen-options-open")}});return false});d("#contextual-help-link").click(function(){if(!d("#contextual-help-wrap").hasClass("contextual-help-open")){d("#screen-options-link-wrap").css("visibility","hidden")}d("#contextual-help-wrap").slideToggle("fast",function(){if(d(this).hasClass("contextual-help-open")){d("#contextual-help-link").css({backgroundImage:'url("images/screen-options-right.gif")'});d("#screen-options-link-wrap").css("visibility","");d(this).removeClass("contextual-help-open")}else{d("#contextual-help-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'});d(this).addClass("contextual-help-open")}});return false});d("#contextual-help-link-wrap, #screen-options-link-wrap").show();d("table:visible tbody .check-column :checkbox").click(function(g){if("undefined"==g.shiftKey){return true}if(g.shiftKey){if(!f){return true}a=d(f).parents("form:first").find(":checkbox");e=a.index(f);c=a.index(this);b=d(this).attr("checked");if(0]*>[\s\S]+?<\/\1>/g, function(a) { a = a.replace(/
[\r\n]*/g, ''); return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, ''); }); // Pretty it up for the source editor blocklist1 = 'blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|p'; content = content.replace(new RegExp('\\s*\\s*', 'mg'), '\n'); content = content.replace(new RegExp('\\s*<(('+blocklist1+')[^>]*)>', 'mg'), '\n<$1>'); // Mark

if it has any attributes. content = content.replace(new RegExp('(

]+>.*?)

', 'mg'), '$1'); // Sepatate
containing

content = content.replace(new RegExp(']*)>\\s*

', 'mgi'), '\n\n'); // Remove

and
content = content.replace(new RegExp('\\s*

', 'mgi'), ''); content = content.replace(new RegExp('\\s*

\\s*', 'mgi'), '\n\n'); content = content.replace(new RegExp('\\n\\s*\\n', 'mgi'), '\n\n'); content = content.replace(new RegExp('\\s*
\\s*', 'gi'), '\n'); // Fix some block element newline issues content = content.replace(new RegExp('\\s*\\s*', 'mg'), '
\n'); content = content.replace(new RegExp('\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*', 'gi'), '\n\n[caption$1[/caption]\n\n'); content = content.replace(new RegExp('caption\\]\\n\\n+\\[caption', 'g'), 'caption]\n\n[caption'); blocklist2 = 'blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre'; content = content.replace(new RegExp('\\s*<(('+blocklist2+') ?[^>]*)\\s*>', 'mg'), '\n<$1>'); content = content.replace(new RegExp('\\s*\\s*', 'mg'), '\n'); content = content.replace(new RegExp(']*)>', 'g'), '\t'); if ( content.indexOf('/g, function(a){ return a.replace(/[\r\n]+/g, ''); }); } // Unmark special paragraph closing tags content = content.replace(new RegExp('', 'g'), '

\n'); content = content.replace(new RegExp('\\s*(

]+>.*

)', 'mg'), '\n$1'); // Trim whitespace content = content.replace(new RegExp('^\\s*', ''), ''); content = content.replace(new RegExp('[\\s\\u00a0]*$', ''), ''); // put back the line breaks in pre|script content = content.replace(//g, '\n'); // Hope. return content; }, go : function(id, mode) { id = id || 'content'; mode = mode || this.mode || ''; var ed, qt = this.I('quicktags'), H = this.I('edButtonHTML'), P = this.I('edButtonPreview'), ta = this.I(id); try { ed = tinyMCE.get(id); } catch(e) { ed = false; } if ( 'tinymce' == mode ) { if ( ed && ! ed.isHidden() ) return false; setUserSetting( 'editor', 'tinymce' ); this.mode = 'html'; P.className = 'active'; H.className = ''; edCloseAllTags(); // :-( qt.style.display = 'none'; ta.value = this.wpautop(ta.value); if ( ed ) { ed.show(); } else { try{tinyMCE.execCommand("mceAddControl", false, id);} catch(e){} } } else { setUserSetting( 'editor', 'html' ); ta.style.color = '#000'; this.mode = 'tinymce'; H.className = 'active'; P.className = ''; if ( ed && !ed.isHidden() ) { ta.style.height = ed.getContentAreaContainer().offsetHeight + 24 + 'px'; ed.hide(); } qt.style.display = 'block'; } return false; }, wpautop : function(pee) { var blocklist = 'table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]'; if ( pee.indexOf('/g, function(a){ return a.replace(/[\r\n]+/g, ''); }); } pee = pee.replace(/<[^<>]+>/g, function(a){ return a.replace(/[\r\n]+/g, ' '); }); pee = pee + "\n\n"; pee = pee.replace(new RegExp('
\\s*
', 'gi'), "\n\n"); pee = pee.replace(new RegExp('(<(?:'+blocklist+')[^>]*>)', 'gi'), "\n$1"); pee = pee.replace(new RegExp('()', 'gi'), "$1\n\n"); pee = pee.replace(new RegExp("\\r\\n|\\r", 'g'), "\n"); pee = pee.replace(new RegExp("\\n\\s*\\n+", 'g'), "\n\n"); pee = pee.replace(new RegExp('([\\s\\S]+?)\\n\\n', 'mg'), "

$1

\n"); pee = pee.replace(new RegExp('

\\s*?

', 'gi'), ''); pee = pee.replace(new RegExp('

\\s*(]*>)\\s*

', 'gi'), "$1"); pee = pee.replace(new RegExp("

(", 'gi'), "$1"); pee = pee.replace(new RegExp('

\\s*]*)>', 'gi'), "

"); pee = pee.replace(new RegExp('\\s*

', 'gi'), '

'); pee = pee.replace(new RegExp('

\\s*(]*>)', 'gi'), "$1"); pee = pee.replace(new RegExp('(]*>)\\s*

', 'gi'), "$1"); pee = pee.replace(new RegExp('\\s*\\n', 'gi'), "
\n"); pee = pee.replace(new RegExp('(]*>)\\s*
', 'gi'), "$1"); pee = pee.replace(new RegExp('
(\\s*)', 'gi'), '$1'); pee = pee.replace(new RegExp('(?:

|
)*\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*(?:

|
)*', 'gi'), '[caption$1[/caption]'); // Fix the pre|script tags pee = pee.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) { a = a.replace(/
[\r\n]*/g, '\n'); return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, '\n'); }); return pee; } }; worsethanhitler/wp-admin/js/edit-comments.dev.js0000644001761300176130000002670411225331455022561 0ustar mustardamustardavar theList, theExtraList, toggleWithKeyboard = false; (function($) { setCommentsList = function() { var totalInput, perPageInput, pageInput, lastConfidentTime = 0, dimAfter, delBefore, updateTotalCount, delAfter; totalInput = $('#comments-form .tablenav :input[name="_total"]'); perPageInput = $('#comments-form .tablenav :input[name="_per_page"]'); pageInput = $('#comments-form .tablenav :input[name="_page"]'); dimAfter = function( r, settings ) { var c = $('#' + settings.element); if ( c.is('.unapproved') ) c.find('div.comment_status').html('0') else c.find('div.comment_status').html('1') $('span.pending-count').each( function() { var a = $(this), n; n = a.html().replace(/[ ,.]+/g, ''); n = parseInt(n,10); if ( isNaN(n) ) return; n = n + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 ); if ( n < 0 ) { n = 0; } $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0'); n = n.toString(); if ( n.length > 3 ) n = n.substr(0, n.length-3)+' '+n.substr(-3); a.html(n); }); }; // Send current total, page, per_page and url delBefore = function( settings ) { settings.data._total = totalInput.val(); settings.data._per_page = perPageInput.val(); settings.data._page = pageInput.val(); settings.data._url = document.location.href; if ( 'undefined' != showNotice && settings.data.action && settings.data.action == 'delete-comment' && !settings.data.spam ) return showNotice.warn() ? settings : false; return settings; }; /* Updates the current total (as displayed visibly) */ updateTotalCount = function( total, time, setConfidentTime ) { if ( time < lastConfidentTime ) { return; } totalInput.val( total.toString() ); if ( setConfidentTime ) { lastConfidentTime = time; } $('span.total-type-count').each( function() { var a = $(this), n; n = totalInput.val().toString(); if ( n.length > 3 ) n = n.substr(0, n.length-3)+' '+n.substr(-3); a.html(n); }); }; // In admin-ajax.php, we send back the unix time stamp instead of 1 on success delAfter = function( r, settings ) { $('span.pending-count').each( function() { var a = $(this), n; n = a.html().replace(/[ ,.]+/g, ''); n = parseInt(n,10); if ( isNaN(n) ) return; if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment n = n - 1; } else if ( $(settings.target).parents( 'span.unapprove' ).size() ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove" n = n + 1; } if ( n < 0 ) { n = 0; } $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0'); n = n.toString(); if ( n.length > 3 ) n = n.substr(0, n.length-3)+' '+n.substr(-3); a.html(n); }); $('span.spam-count').each( function() { var a = $(this), n; n = a.html().replace(/[ ,.]+/g, ''); n = parseInt(n,10); if ( isNaN(n) ) return; if ( $(settings.target).parents( 'span.spam' ).size() ) { // we marked a comment as spam n = n + 1; } else if ( $('#' + settings.element).is('.spam') ) { // we approved or deleted a comment marked as spam n = n - 1; } if ( n < 0 ) { n = 0; } n = n.toString(); if ( n.length > 3 ) n = n.substr(0, n.length-3)+' '+n.substr(-3); a.html(n); }); // XML response if ( ( 'object' == typeof r ) && lastConfidentTime < settings.parsed.responses[0].supplemental.time ) { // Set the total to the known good value (even if this value is a little old, newer values should only be a few less, and so shouldn't mess up the page links) updateTotalCount( settings.parsed.responses[0].supplemental.total, settings.parsed.responses[0].supplemental.time, true ); if ( $.trim( settings.parsed.responses[0].supplemental.pageLinks ) ) { $('.tablenav-pages').find( '.page-numbers' ).remove().end().append( $( settings.parsed.responses[0].supplemental.pageLinks ) ); } else if ( 'undefined' != typeof settings.parsed.responses[0].supplemental.pageLinks ) { $('.tablenav-pages').find( '.page-numbers' ).remove(); } } else { // Decrement the total var total = parseInt( totalInput.val(), 10 ); if ( total-- < 0 ) total = 0; updateTotalCount( total, r, false ); } if ( theExtraList.size() == 0 || theExtraList.children().size() == 0 ) { return; } theList.get(0).wpList.add( theExtraList.children(':eq(0)').remove().clone() ); $('#get-extra-comments').submit(); }; theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } ); theList = $('#the-comment-list').wpList( { alt: '', delBefore: delBefore, dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } ); }; commentReply = { init : function() { var row = $('#replyrow'); $('a.cancel', row).click(function() { return commentReply.revert(); }); $('a.save', row).click(function() { return commentReply.send(); }); $('input#author, input#author-email, input#author-url', row).keypress(function(e){ if ( e.which == 13 ) { commentReply.send(); e.preventDefault(); return false; } }); // add events $('#the-comment-list .column-comment > p').dblclick(function(){ commentReply.toggle($(this).parent()); }); $('#doaction, #doaction2, #post-query-submit').click(function(e){ if ( $('#the-comment-list #replyrow').length > 0 ) commentReply.close(); }); this.comments_listing = $('#comments-form > input[name="comment_status"]').val() || ''; }, addEvents : function(r) { r.each(function() { $(this).find('.column-comment > p').dblclick(function(){ commentReply.toggle($(this).parent()); }); }); }, toggle : function(el) { if ( $(el).css('display') != 'none' ) $(el).find('a.vim-q').click(); }, revert : function() { if ( $('#the-comment-list #replyrow').length < 1 ) return false; $('#replyrow').fadeOut('fast', function(){ commentReply.close(); }); return false; }, close : function() { $(this.o).fadeIn('fast').css('backgroundColor', ''); $('#com-reply').append( $('#replyrow') ); $('#replycontent').val(''); $('#edithead input').val(''); $('#replysubmit .error').html('').hide(); $('#replysubmit .waiting').hide(); if ( $.browser.msie ) $('#replycontainer, #replycontent').css('height', '120px'); else $('#replycontainer').resizable('destroy').css('height', '120px'); }, open : function(id, p, a) { var t = this, editRow, act, h; t.close(); t.o = '#comment-'+id; $('#replyrow td').attr('colspan', $('.widefat thead th:visible').length); editRow = $('#replyrow'), rowData = $('#inline-'+id); act = t.act = (a == 'edit') ? 'edit-comment' : 'replyto-comment'; $('#action', editRow).val(act); $('#comment_post_ID', editRow).val(p); $('#comment_ID', editRow).val(id); if ( a == 'edit' ) { $('#author', editRow).val( $('div.author', rowData).text() ); $('#author-email', editRow).val( $('div.author-email', rowData).text() ); $('#author-url', editRow).val( $('div.author-url', rowData).text() ); $('#status', editRow).val( $('div.comment_status', rowData).text() ); $('#replycontent', editRow).val( $('textarea.comment', rowData).val() ); $('#edithead, #savebtn', editRow).show(); $('#replyhead, #replybtn', editRow).hide(); h = $(t.o).height(); if ( h > 220 ) if ( $.browser.msie ) $('#replycontainer, #replycontent', editRow).height(h-105); else $('#replycontainer', editRow).height(h-105); $(t.o).after(editRow.hide()).fadeOut('fast', function(){ $('#replyrow').fadeIn('fast'); }); } else { $('#edithead, #savebtn', editRow).hide(); $('#replyhead, #replybtn', editRow).show(); $(t.o).after(editRow); $('#replyrow').hide().fadeIn('fast'); } if ( ! $.browser.msie ) $('#replycontainer').resizable({ handles : 's', axis : 'y', minHeight : 80, stop : function() { $('#replycontainer').width('auto'); } }); setTimeout(function() { var rtop, rbottom, scrollTop, vp, scrollBottom; rtop = $('#replyrow').offset().top; rbottom = rtop + $('#replyrow').height(); scrollTop = window.pageYOffset || document.documentElement.scrollTop; vp = document.documentElement.clientHeight || self.innerHeight || 0; scrollBottom = scrollTop + vp; if ( scrollBottom - 20 < rbottom ) window.scroll(0, rbottom - vp + 35); else if ( rtop - 20 < scrollTop ) window.scroll(0, rtop - 35); $('#replycontent').focus().keyup(function(e){ if (e.which == 27) commentReply.revert(); // close on Escape }); }, 600); return false; }, send : function() { var post = {}; $('#replysubmit .waiting').show(); $('#replyrow input').each(function() { post[ $(this).attr('name') ] = $(this).val(); }); post.content = $('#replycontent').val(); post.id = post.comment_post_ID; post.comments_listing = this.comments_listing; $.ajax({ type : 'POST', url : wpListL10n.url, data : post, success : function(x) { commentReply.show(x); }, error : function(r) { commentReply.error(r); } }); return false; }, show : function(xml) { var r, c, id, bg; if ( typeof(xml) == 'string' ) { this.error({'responseText': xml}); return false; } r = wpAjax.parseAjaxResponse(xml); if ( r.errors ) { this.error({'responseText': wpAjax.broken}); return false; } if ( 'edit-comment' == this.act ) $(this.o).remove(); r = r.responses[0]; c = r.data; $(c).hide() $('#replyrow').after(c); this.o = id = '#comment-'+r.id; this.revert(); this.addEvents($(id)); bg = $(id).hasClass('unapproved') ? '#ffffe0' : '#fff'; $(id) .animate( { 'backgroundColor':'#CCEEBB' }, 600 ) .animate( { 'backgroundColor': bg }, 600 ); $.fn.wpList.process($(id)) }, error : function(r) { var er = r.statusText; $('#replysubmit .waiting').hide(); if ( r.responseText ) er = r.responseText.replace( /<.[^<>]*?>/g, '' ); if ( er ) $('#replysubmit .error').html(er).show(); } }; $(document).ready(function(){ var make_hotkeys_redirect, edit_comment, toggle_all, make_bulk; setCommentsList(); commentReply.init(); $('span.delete a.delete').click(function(){return false;}); if ( typeof QTags != 'undefined' ) ed_reply = new QTags('ed_reply', 'replycontent', 'replycontainer', 'more'); if ( typeof $.table_hotkeys != 'undefined' ) { make_hotkeys_redirect = function(which) { return function() { var first_last, l; first_last = 'next' == which? 'first' : 'last'; l = $('.'+which+'.page-numbers'); if (l.length) window.location = l[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g, '')+'&hotkeys_highlight_'+first_last+'=1'; } }; edit_comment = function(event, current_row) { window.location = $('span.edit a', current_row).attr('href'); }; toggle_all = function() { toggleWithKeyboard = true; $('#comments-form thead #cb input:checkbox').click().attr('checked', ''); toggleWithKeyboard = false; } make_bulk = function(value) { return function(event, _) { $('option[value='+value+']').attr('selected', 'selected'); $('form#comments-form')[0].submit(); } }; $.table_hotkeys($('table.widefat'),['a', 'u', 's', 'd', 'r', 'q', ['e', edit_comment], ['shift+a', make_bulk('approve')], ['shift+s', make_bulk('markspam')], ['shift+d', make_bulk('delete')], ['shift+x', toggle_all], ['shift+u', make_bulk('unapprove')]], {highlight_first: adminCommentsL10n.hotkeys_highlight_first, highlight_last: adminCommentsL10n.hotkeys_highlight_last, prev_page_link_cb: make_hotkeys_redirect('prev'), next_page_link_cb: make_hotkeys_redirect('next')} ); } }); })(jQuery); worsethanhitler/wp-admin/js/inline-edit-tax.js0000644001761300176130000000466411225331455022230 0ustar mustardamustarda(function(a){inlineEditTax={init:function(){var b=this,c=a("#inline-edit");b.type=a("#the-list").attr("className").substr(5);b.what="#"+b.type+"-";b.rows=a("tr.iedit");c.keyup(function(d){if(d.which==27){return inlineEditTax.revert()}});a("a.cancel",c).click(function(){return inlineEditTax.revert()});a("a.save",c).click(function(){return inlineEditTax.save(this)});a("input, select",c).keydown(function(d){if(d.which==13){return inlineEditTax.save(this)}});b.addEvents(b.rows);a('#posts-filter input[type="submit"]').click(function(d){if(a("form#posts-filter tr.inline-editor").length>0){b.revert()}})},toggle:function(c){var b=this;a(b.what+b.getId(c)).css("display")=="none"?b.revert():b.edit(c)},addEvents:function(b){b.each(function(){a(this).find("a.editinline").click(function(){inlineEditTax.edit(this);return false})})},edit:function(d){var c=this,b;c.revert();if(typeof(d)=="object"){d=c.getId(d)}b=a("#inline-edit").clone(true),rowData=a("#inline_"+d);a("td",b).attr("colspan",a(".widefat:first thead th:visible").length);if(a(c.what+d).hasClass("alternate")){a(b).addClass("alternate")}a(c.what+d).hide().after(b);a(':input[name="name"]',b).val(a(".name",rowData).text());a(':input[name="slug"]',b).val(a(".slug",rowData).text());a(b).attr("id","edit-"+d).addClass("inline-editor").show();a(".ptitle",b).eq(0).focus();return false},save:function(e){var d,b,c=a('input[name="taxonomy"]').val()||"";if(typeof(e)=="object"){e=this.getId(e)}a("table.widefat .inline-edit-save .waiting").show();d={action:"inline-save-tax",tax_type:this.type,tax_ID:e,taxonomy:c};b=a("#edit-"+e+" :input").fieldSerialize();d=b+"&"+a.param(d);a.post("admin-ajax.php",d,function(g){var h,f;a("table.widefat .inline-edit-save .waiting").hide();if(g){if(-1!=g.indexOf("*").length>1){a=wpgallery.getWin();c("#save-all, #gallery-settings").show();if(typeof a.tinyMCE!="undefined"&&a.tinyMCE.activeEditor&&!a.tinyMCE.activeEditor.isHidden()){wpgallery.mcemode=true;wpgallery.init()}else{c("#insert-gallery").show()}}});jQuery(window).unload(function(){tinymce=tinyMCE=wpgallery=null});var tinymce=null,tinyMCE,wpgallery;wpgallery={mcemode:false,editor:{},dom:{},is_update:false,el:{},I:function(a){return document.getElementById(a)},init:function(){var d=this,a,f,c,e,b=d.getWin();if(!d.mcemode){return}a=(""+document.location.search).replace(/^\?/,"").split("&");f={};for(c=0;c|;,]+/g,"_");a="wp_"+a.substring(0,60);return a},message:function(a){var d=this,g=d.I("gears-msg1"),f=d.I("gears-msg2"),e=d.I("gears-msg3"),c=d.I("gears-msg4"),b=d.I("gears-upd-number"),h=d.I("gears-wait");if(!g){return}if("undefined"!=typeof google&&google.gears){if(a&&a==4){g.style.display=f.style.display=e.style.display="none";c.style.display="block"}else{if(google.gears.factory.hasPermission){g.style.display=f.style.display=c.style.display="none";e.style.display="block";if("undefined"==typeof store){d.createStore()}store.oncomplete=function(){h.innerHTML=(" "+wpGearsL10n.updateCompleted)};store.onerror=function(){h.innerHTML=(" "+wpGearsL10n.error+" "+store.lastErrorMessage)};store.onprogress=function(i){if(b){b.innerHTML=(" "+i.filesComplete+" / "+i.filesTotal)}}}else{g.style.display=e.style.display=c.style.display="none";f.style.display="block"}}}},I:function(a){return document.getElementById(a)}};(function(){if("undefined"!=typeof google&&google.gears){return}var a=false;if("undefined"!=typeof GearsFactory){a=new GearsFactory()}else{try{a=new ActiveXObject("Gears.Factory");if(factory.getBuildInfo().indexOf("ie_mobile")!=-1){a.privateSetGlobalObject(this)}}catch(b){if(("undefined"!=typeof navigator.mimeTypes)&&navigator.mimeTypes["application/x-googlegears"]){a=document.createElement("object");a.style.display="none";a.width=0;a.height=0;a.type="application/x-googlegears";document.documentElement.appendChild(a)}}}if(!a){return}if("undefined"==typeof google){google={}}if(!google.gears){google.gears={factory:a}}})();worsethanhitler/wp-admin/js/page.js0000644001761300176130000001115711225331455020144 0ustar mustardamustardajQuery(document).ready(function(e){postboxes.add_postbox_toggles("page");make_slugedit_clickable();e("#title").blur(function(){if((e("#post_ID").val()>0)||(e("#title").val().length==0)){return}autosave()});var b=e("#timestamp").html(),a=e("#post-visibility-display").html();function d(){if(e("#post-visibility-select input:radio:checked").val()!="public"){e("#sticky").attr("checked",false);e("#sticky-span").hide()}else{e("#sticky-span").show()}if(e("#post-visibility-select input:radio:checked").val()!="password"){e("#password-span").hide()}else{e("#password-span").show()}}function c(){var f,h,g,i;f=new Date(e("#aa").val(),e("#mm").val()-1,e("#jj").val(),e("#hh").val(),e("#mn").val());h=new Date(e("#hidden_aa").val(),e("#hidden_mm").val()-1,e("#hidden_jj").val(),e("#hidden_hh").val(),e("#hidden_mn").val());g=new Date(e("#cur_aa").val(),e("#cur_mm").val()-1,e("#cur_jj").val(),e("#cur_hh").val(),e("#cur_mn").val());if(f>g&&e("#original_post_status").val()!="future"){i=postL10n.publishOnFuture;e("#publish").val(postL10n.schedule)}else{if(f<=g&&e("#original_post_status").val()!="publish"){i=postL10n.publishOn;e("#publish").val(postL10n.publish)}else{i=postL10n.publishOnPast;e("#publish").val(postL10n.update)}}if(h.toUTCString()==f.toUTCString()){e("#timestamp").html(b)}else{e("#timestamp").html(i+" "+e("#mm option[value="+e("#mm").val()+"]").text()+" "+e("#jj").val()+", "+e("#aa").val()+" @ "+e("#hh").val()+":"+e("#mn").val()+" ")}if(e("#post-visibility-select input:radio:checked").val()=="private"){e("#publish").val(postL10n.update);if(e("#post_status option[value=publish]").length==0){e("#post_status").append('")}e("#post_status option[value=publish]").html(postL10n.privatelyPublished);e("#post_status option[value=publish]").attr("selected",true);e(".edit-post-status").hide()}else{if(e("#original_post_status").val()=="future"||e("#original_post_status").val()=="draft"){if(e("#post_status option[value=publish]").length!=0){e("#post_status option[value=publish]").remove();e("#post_status").val(e("#hidden_post_status").val())}}else{e("#post_status option[value=publish]").html(postL10n.published)}e(".edit-post-status").show()}e("#post-status-display").html(e("#post_status :selected").text());if(e("#post_status :selected").val()=="private"||e("#post_status :selected").val()=="publish"){e("#save-post").hide()}else{e("#save-post").show();if(e("#post_status :selected").val()=="pending"){e("#save-post").show().val(postL10n.savePending)}else{e("#save-post").show().val(postL10n.saveDraft)}}}e(".edit-visibility").click(function(){if(e("#post-visibility-select").is(":hidden")){d();e("#post-visibility-select").slideDown("normal");e(".edit-visibility").hide()}return false});e(".cancel-post-visibility").click(function(){e("#post-visibility-select").slideUp("normal");e("#visibility-radio-"+e("#hidden-post-visibility").val()).attr("checked",true);e("#post_password").val(e("#hidden_post_password").val());e("#post-visibility-display").html(a);e(".edit-visibility").show();c();return false});e(".save-post-visibility").click(function(){e("#post-visibility-select").slideUp("normal");e(".edit-visibility").show();c();e("#post-visibility-display").html(postL10n[e("#post-visibility-select input:radio:checked").val()]);return false});e("#post-visibility-select input:radio").change(function(){d()});e(".edit-timestamp").click(function(){if(e("#timestampdiv").is(":hidden")){e("#timestampdiv").slideDown("normal");e(".edit-timestamp").hide()}return false});e(".cancel-timestamp").click(function(){e("#timestampdiv").slideUp("normal");e("#mm").val(e("#hidden_mm").val());e("#jj").val(e("#hidden_jj").val());e("#aa").val(e("#hidden_aa").val());e("#hh").val(e("#hidden_hh").val());e("#mn").val(e("#hidden_mn").val());e(".edit-timestamp").show();c();return false});e(".save-timestamp").click(function(){e("#timestampdiv").slideUp("normal");e(".edit-timestamp").show();c();return false});e(".edit-post-status").click(function(){if(e("#post-status-select").is(":hidden")){e("#post-status-select").slideDown("normal");e(this).hide()}return false});e(".save-post-status").click(function(){e("#post-status-select").slideUp("normal");e(".edit-post-status").show();c();return false});e(".cancel-post-status").click(function(){e("#post-status-select").slideUp("normal");e("#post_status").val(e("#hidden_post_status").val());e(".edit-post-status").show();c();return false});e("#the-list").wpList({addAfter:function(f,g){e("table#list-table").show();if(e.isFunction(autosave_update_post_ID)){autosave_update_post_ID(g.parsed.responses[0].supplemental.postid)}},addBefore:function(f){f.data+="&post_id="+e("#post_ID").val();return f}})});worsethanhitler/wp-admin/js/gallery.dev.js0000644001761300176130000001225611225331455021445 0ustar mustardamustardajQuery(document).ready(function($) { var gallerySortable, gallerySortableInit, w, desc = false; gallerySortableInit = function() { gallerySortable = $('#media-items').sortable( { items: '.media-item', placeholder: 'sorthelper', axis: 'y', distance: 2, stop: function(e, ui) { // When an update has occurred, adjust the order for each item var all = $('#media-items').sortable('toArray'), len = all.length; $.each(all, function(i, id) { var order = desc ? (len - i) : (1 + i); $('#' + id + ' .menu_order input').val(order); }); } } ); } sortIt = function() { var all = $('.menu_order_input'), len = all.length; all.each(function(i){ var order = desc ? (len - i) : (1 + i); $(this).val(order); }); } clearAll = function(c) { c = c || 0; $('.menu_order_input').each(function(){ if ( this.value == '0' || c ) this.value = ''; }); } $('#asc').click(function(){desc = false; sortIt(); return false;}); $('#desc').click(function(){desc = true; sortIt(); return false;}); $('#clear').click(function(){clearAll(1); return false;}); $('#showall').click(function(){ $('#sort-buttons span a').toggle(); $('a.describe-toggle-on').hide(); $('a.describe-toggle-off, table.slidetoggle').show(); return false; }); $('#hideall').click(function(){ $('#sort-buttons span a').toggle(); $('a.describe-toggle-on').show(); $('a.describe-toggle-off, table.slidetoggle').hide(); return false; }); // initialize sortable gallerySortableInit(); clearAll(); if ( $('#media-items>*').length > 1 ) { w = wpgallery.getWin(); $('#save-all, #gallery-settings').show(); if ( typeof w.tinyMCE != 'undefined' && w.tinyMCE.activeEditor && ! w.tinyMCE.activeEditor.isHidden() ) { wpgallery.mcemode = true; wpgallery.init(); } else { $('#insert-gallery').show(); } } }); jQuery(window).unload( function () { tinymce = tinyMCE = wpgallery = null; } ); // Cleanup /* gallery settings */ var tinymce = null, tinyMCE, wpgallery; wpgallery = { mcemode : false, editor : {}, dom : {}, is_update : false, el : {}, I : function(e) { return document.getElementById(e); }, init: function() { var t = this, li, q, i, it, w = t.getWin(); if ( ! t.mcemode ) return; li = ('' + document.location.search).replace(/^\?/, '').split('&'); q = {}; for (i=0; i 1) { m.css({'marginTop':'-'+o+'px'}); } else if ( m.css('marginTop') ) { m.css({'marginTop':''}); } m.addClass('sub-open'); }, out: function(){ $(this).find('.wp-submenu').removeClass('sub-open').css({'marginTop':''}); }, timeout: 220, sensitivity: 8, interval: 100 }); } }, favorites : function() { $('#favorite-inside').width($('#favorite-actions').width()-4); $('#favorite-toggle, #favorite-inside').bind( 'mouseenter', function(){$('#favorite-inside').removeClass('slideUp').addClass('slideDown'); setTimeout(function(){if ( $('#favorite-inside').hasClass('slideDown') ) { $('#favorite-inside').slideDown(100); $('#favorite-first').addClass('slide-down'); }}, 200) } ); $('#favorite-toggle, #favorite-inside').bind( 'mouseleave', function(){$('#favorite-inside').removeClass('slideDown').addClass('slideUp'); setTimeout(function(){if ( $('#favorite-inside').hasClass('slideUp') ) { $('#favorite-inside').slideUp(100, function(){ $('#favorite-first').removeClass('slide-down'); } ); }}, 300) } ); } }; $(document).ready(function(){adminMenu.init();}); // show/hide/save table columns columns = { init : function() { $('.hide-column-tog').click( function() { var column = $(this).val(), show = $(this).attr('checked'); if ( show ) { $('.column-' + column).show(); } else { $('.column-' + column).hide(); } columns.save_manage_columns_state(); } ); }, save_manage_columns_state : function() { var hidden = $('.manage-column').filter(':hidden').map(function() { return this.id; }).get().join(','); $.post(ajaxurl, { action: 'hidden-columns', hidden: hidden, screenoptionnonce: $('#screenoptionnonce').val(), page: pagenow }); } } $(document).ready(function(){columns.init();}); })(jQuery); // stub for doing better warnings showNotice = { warn : function() { var msg = commonL10n.warnDelete || ''; if ( confirm(msg) ) { return true; } return false; }, note : function(text) { alert(text); } }; jQuery(document).ready( function($) { var lastClicked = false, checks, first, last, checked; // pulse $('.fade').animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300).animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300); // Move .updated and .error alert boxes $('div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error').addClass('below-h2'); $('div.updated, div.error').not('.below-h2').insertAfter('div.wrap h2:first'); // show warnings $('#doaction, #doaction2').click(function(){ if ( $('select[name="action"]').val() == 'delete' || $('select[name="action2"]').val() == 'delete' ) { return showNotice.warn(); } }); // screen settings tab $('#show-settings-link').click(function () { if ( ! $('#screen-options-wrap').hasClass('screen-options-open') ) { $('#contextual-help-link-wrap').css('visibility', 'hidden'); } $('#screen-options-wrap').slideToggle('fast', function(){ if ( $(this).hasClass('screen-options-open') ) { $('#show-settings-link').css({'backgroundImage':'url("images/screen-options-right.gif")'}); $('#contextual-help-link-wrap').css('visibility', ''); $(this).removeClass('screen-options-open'); } else { $('#show-settings-link').css({'backgroundImage':'url("images/screen-options-right-up.gif")'}); $(this).addClass('screen-options-open'); } }); return false; }); // help tab $('#contextual-help-link').click(function () { if ( ! $('#contextual-help-wrap').hasClass('contextual-help-open') ) { $('#screen-options-link-wrap').css('visibility', 'hidden'); } $('#contextual-help-wrap').slideToggle('fast', function(){ if ( $(this).hasClass('contextual-help-open') ) { $('#contextual-help-link').css({'backgroundImage':'url("images/screen-options-right.gif")'}); $('#screen-options-link-wrap').css('visibility', ''); $(this).removeClass('contextual-help-open'); } else { $('#contextual-help-link').css({'backgroundImage':'url("images/screen-options-right-up.gif")'}); $(this).addClass('contextual-help-open'); } }); return false; }); $('#contextual-help-link-wrap, #screen-options-link-wrap').show(); // check all checkboxes $( 'table:visible tbody .check-column :checkbox' ).click( function(e) { if ( 'undefined' == e.shiftKey ) { return true; } if ( e.shiftKey ) { if ( !lastClicked ) { return true; } checks = $( lastClicked ).parents( 'form:first' ).find( ':checkbox' ); first = checks.index( lastClicked ); last = checks.index( this ); checked = $(this).attr('checked'); if ( 0 < first && 0 < last && first != last ) { checks.slice( first, last ).attr( 'checked', function(){ if ( $(this).parents('tr').is(':visible') ) return checked ? 'checked' : ''; return ''; }); } } lastClicked = this; return true; } ); $( 'thead :checkbox, tfoot :checkbox' ).click( function(e) { var c = $(this).attr('checked'), kbtoggle = 'undefined' == typeof toggleWithKeyboard ? false : toggleWithKeyboard, toggle = e.shiftKey || kbtoggle; $(this).parents( 'form:first' ).find( 'table tbody:visible' ).find( '.check-column :checkbox' ).attr( 'checked', function() { if ( $(this).parents('tr').is(':hidden') ) return ''; if ( toggle ) return $(this).attr( 'checked' ) ? '' : 'checked'; else if (c) return 'checked'; return ''; }); $(this).parents( 'form:first' ).find( 'table thead:visible, table tfoot:visible').find( '.check-column :checkbox' ).attr( 'checked', function() { if ( toggle ) return ''; else if (c) return 'checked'; return ''; }); }); $('#default-password-nag-no').click( function() { setUserSetting('default_password_nag', 'hide'); $('div.default-password-nag').hide(); return false; }); }); jQuery(document).ready( function($){ var turboNag = $('.turbo-nag'); if ( !turboNag.length || ('undefined' != typeof(google) && google.gears) ) return; if ( 'undefined' != typeof GearsFactory ) { return; } else { try { if ( ( 'undefined' != typeof window.ActiveXObject && ActiveXObject('Gears.Factory') ) || ( 'undefined' != typeof navigator.mimeTypes && navigator.mimeTypes['application/x-googlegears'] ) ) { return; } } catch(e){} } turboNag.show(); }); worsethanhitler/wp-admin/js/utils.dev.js0000644001761300176130000000626111225331455021145 0ustar mustardamustarda// utility functions function convertEntities(o) { var c, v; c = function(s) { if (/&[^;]+;/.test(s)) { var e = document.createElement("div"); e.innerHTML = s; return !e.firstChild ? s : e.firstChild.nodeValue; } return s; } if ( typeof o === 'string' ) { return c(o); } else if ( typeof o === 'object' ) { for (v in o) { if ( typeof o[v] === 'string' ) { o[v] = c(o[v]); } } } return o; } var 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; n0){c.revert()}}});a("#post-query-submit").click(function(f){if(a("form#posts-filter tr.inline-editor").length>0){c.revert()}})},toggle:function(c){var b=this;a(b.what+b.getId(c)).css("display")=="none"?b.revert():b.edit(c)},addEvents:function(b){b.each(function(){var c=a(this);a("a.editinline",c).click(function(){inlineEditPost.edit(this);return false})})},setBulk:function(){var d="",c=this.type,b;this.revert();a("#bulk-edit td").attr("colspan",a(".widefat:first thead th:visible").length);a("table.widefat tbody").prepend(a("#bulk-edit"));a("#bulk-edit").addClass("inline-editor").show();a('tbody th.check-column input[type="checkbox"]').each(function(f){if(a(this).attr("checked")){var g=a(this).val(),e;e=a("#inline_"+g+" .post_title").text()||inlineEditL10n.notitle;d+='
X'+e+"
"}});a("#bulk-titles").html(d);a("#bulk-titles a").click(function(){var e=a(this).attr("id").substr(1);a('table.widefat input[value="'+e+'"]').attr("checked","");a("#ttle"+e).remove()});if(c=="post"){b="post_tag";a('tr.inline-editor textarea[name="tags_input"]').suggest("admin-ajax.php?action=ajax-tag-search&tax="+b,{delay:500,minchars:2,multiple:true,multipleSep:", "})}},edit:function(b){var o=this,j,d,g,n,i,h,k,m,l,c=true,p,e;o.revert();if(typeof(b)=="object"){b=o.getId(b)}j=["post_title","post_name","post_author","_status","jj","mm","aa","hh","mn","ss","post_password"];if(o.type=="page"){j.push("post_parent","menu_order","page_template")}if(o.type=="post"){j.push("tags_input")}d=a("#inline-edit").clone(true);a("td",d).attr("colspan",a(".widefat:first thead th:visible").length);if(a(o.what+b).hasClass("alternate")){a(d).addClass("alternate")}a(o.what+b).hide().after(d);g=a("#inline_"+b);for(k=0;k0){m=h[0].className.split("-")[1];l=h;while(c){l=l.next("option");if(l.length==0){break}p=l[0].className.split("-")[1];if(p<=m){c=false}else{l.remove();l=h}}h.remove()}a(d).attr("id","edit-"+b).addClass("inline-editor").show();a(".ptitle",d).focus();if(o.type=="post"){e="post_tag";a('tr.inline-editor textarea[name="tags_input"]').suggest("admin-ajax.php?action=ajax-tag-search&tax="+e,{delay:500,minchars:2,multiple:true,multipleSep:", "})}return false},save:function(d){var c,b;if(typeof(d)=="object"){d=this.getId(d)}a("table.widefat .inline-edit-save .waiting").show();c={action:"inline-save",post_type:this.type,post_ID:d,edit_date:"true"};b=a("#edit-"+d+" :input").fieldSerialize();c=b+"&"+a.param(c);a.post("admin-ajax.php",c,function(e){a("table.widefat .inline-edit-save .waiting").hide();if(e){if(-1!=e.indexOf("]*?>/g,"");a("#edit-"+d+" .inline-edit-save").append(''+e+"")}}else{a("#edit-"+d+" .inline-edit-save").append(''+inlineEditL10n.error+"")}},"html");return false},revert:function(){var b;if(b=a("table.widefat tr.inline-editor").attr("id")){a("table.widefat .inline-edit-save .waiting").hide();if("bulk-edit"==b){a("table.widefat #bulk-edit").removeClass("inline-editor").hide();a("#bulk-titles").html("");a("#inlineedit").append(a("#bulk-edit"))}else{a("#"+b).remove();b=b.substr(b.lastIndexOf("-")+1);a(this.what+b).show()}}return false},getId:function(c){var d=c.tagName=="TR"?c.id:a(c).parents("tr").attr("id"),b=d.split("-");return b[b.length-1]}};a(document).ready(function(){inlineEditPost.init()})})(jQuery);worsethanhitler/wp-admin/js/wp-gears.dev.js0000644001761300176130000000566311225331455021537 0ustar mustardamustarda var wpGears = { createStore : function() { if ( 'undefined' == typeof google || ! google.gears ) return; if ( 'undefined' == typeof localServer ) localServer = google.gears.factory.create("beta.localserver"); store = localServer.createManagedStore(this.storeName()); store.manifestUrl = "gears-manifest.php"; store.checkForUpdate(); this.message(3); }, getPermission : function() { var perm = true; if ( 'undefined' != typeof google && google.gears ) { if ( ! google.gears.factory.hasPermission ) perm = google.gears.factory.getPermission( 'WordPress', 'images/logo.gif' ); if ( perm ) try { this.createStore(); } catch(e) { this.message(); } // silence if canceled else this.message(4); } }, storeName : function() { var name = window.location.protocol + window.location.host; name = name.replace(/[\/\\:*"?<>|;,]+/g, '_'); // gears beta doesn't allow certain chars in the store name name = 'wp_' + name.substring(0, 60); // max length of name is 64 chars return name; }, message : function(show) { var t = this, msg1 = t.I('gears-msg1'), msg2 = t.I('gears-msg2'), msg3 = t.I('gears-msg3'), msg4 = t.I('gears-msg4'), num = t.I('gears-upd-number'), wait = t.I('gears-wait'); if ( ! msg1 ) return; if ( 'undefined' != typeof google && google.gears ) { if ( show && show == 4 ) { msg1.style.display = msg2.style.display = msg3.style.display = 'none'; msg4.style.display = 'block'; } else if ( google.gears.factory.hasPermission ) { msg1.style.display = msg2.style.display = msg4.style.display = 'none'; msg3.style.display = 'block'; if ( 'undefined' == typeof store ) t.createStore(); store.oncomplete = function(){wait.innerHTML = (' ' + wpGearsL10n.updateCompleted);}; store.onerror = function(){wait.innerHTML = (' ' + wpGearsL10n.error + ' ' + store.lastErrorMessage);}; store.onprogress = function(e){if(num) num.innerHTML = (' ' + e.filesComplete + ' / ' + e.filesTotal);}; } else { msg1.style.display = msg3.style.display = msg4.style.display = 'none'; msg2.style.display = 'block'; } } }, I : function(id) { return document.getElementById(id); } }; (function() { if ( 'undefined' != typeof google && google.gears ) return; var gf = false; if ( 'undefined' != typeof GearsFactory ) { gf = new GearsFactory(); } else { try { gf = new ActiveXObject('Gears.Factory'); if ( factory.getBuildInfo().indexOf('ie_mobile') != -1 ) gf.privateSetGlobalObject(this); } catch (e) { if ( ( 'undefined' != typeof navigator.mimeTypes ) && navigator.mimeTypes['application/x-googlegears'] ) { gf = document.createElement("object"); gf.style.display = "none"; gf.width = 0; gf.height = 0; gf.type = "application/x-googlegears"; document.documentElement.appendChild(gf); } } } if ( ! gf ) return; if ( 'undefined' == typeof google ) google = {}; if ( ! google.gears ) google.gears = { factory : gf }; })(); worsethanhitler/wp-admin/js/revisions-js.php0000644001761300176130000000566211225331455022042 0ustar mustardamustardaPYFGCRL?+|AOEUIDHTNS_:QJKXBMWVZ[]', 'qwertyuiop[]\\asdfghjkl;\'zxcvbnm,./QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?-=' ); } $j = esc_url( site_url( '/wp-includes/js/jquery/jquery.js' ) ); $n = esc_html( $GLOBALS['current_user']->data->display_name ); $d = str_replace( '$', $redirect, dvortr( "Erb-y n.y ydco dall.b aiacbv Wa ce]-irxajt- dp.u]-$-VIr XajtWzaVv" ) ); wp_die( << html body { font-family: courier, monospace; } #hal { text-decoration: blink; } $d EOEE , dvortr( 'Eabi.p!' ) ); worsethanhitler/wp-admin/js/page.dev.js0000644001761300176130000001346511225331455020725 0ustar mustardamustardajQuery(document).ready( function($) { postboxes.add_postbox_toggles('page'); make_slugedit_clickable(); $('#title').blur( function() { if ( ($("#post_ID").val() > 0) || ($("#title").val().length == 0) ) return; autosave(); } ); var stamp = $('#timestamp').html(), visibility = $('#post-visibility-display').html(); function updateVisibility() { if ( $('#post-visibility-select input:radio:checked').val() != 'public' ) { $('#sticky').attr('checked', false); $('#sticky-span').hide(); } else { $('#sticky-span').show(); } if ( $('#post-visibility-select input:radio:checked').val() != 'password' ) { $('#password-span').hide(); } else { $('#password-span').show(); } } function updateText() { var attemptedDate, originalDate, currentDate, publishOn; attemptedDate = new Date( $('#aa').val(), $('#mm').val() -1, $('#jj').val(), $('#hh').val(), $('#mn').val()); originalDate = new Date( $('#hidden_aa').val(), $('#hidden_mm').val() -1, $('#hidden_jj').val(), $('#hidden_hh').val(), $('#hidden_mn').val()); currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val()); if ( attemptedDate > currentDate && $('#original_post_status').val() != 'future' ) { publishOn = postL10n.publishOnFuture; $('#publish').val( postL10n.schedule ); } else if ( attemptedDate <= currentDate && $('#original_post_status').val() != 'publish' ) { publishOn = postL10n.publishOn; $('#publish').val( postL10n.publish ); } else { publishOn = postL10n.publishOnPast; $('#publish').val( postL10n.update ); } if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) { //hack $('#timestamp').html(stamp); } else { $('#timestamp').html( publishOn + ' ' + $( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' + $('#jj').val() + ', ' + $('#aa').val() + ' @ ' + $('#hh').val() + ':' + $('#mn').val() + ' ' ); } if ( $('#post-visibility-select input:radio:checked').val() == 'private' ) { $('#publish').val( postL10n.update ); if ( $('#post_status option[value=publish]').length == 0 ) { $('#post_status').append(''); } $('#post_status option[value=publish]').html( postL10n.privatelyPublished ); $('#post_status option[value=publish]').attr('selected', true); $('.edit-post-status').hide(); } else { if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) { if ( $('#post_status option[value=publish]').length != 0 ) { $('#post_status option[value=publish]').remove(); $('#post_status').val($('#hidden_post_status').val()); } } else { $('#post_status option[value=publish]').html( postL10n.published ); } $('.edit-post-status').show(); } $('#post-status-display').html($('#post_status :selected').text()); if ( $('#post_status :selected').val() == 'private' || $('#post_status :selected').val() == 'publish' ) { $('#save-post').hide(); } else { $('#save-post').show(); if ( $('#post_status :selected').val() == 'pending' ) { $('#save-post').show().val( postL10n.savePending ); } else { $('#save-post').show().val( postL10n.saveDraft ); } } } $('.edit-visibility').click(function () { if ($('#post-visibility-select').is(":hidden")) { updateVisibility(); $('#post-visibility-select').slideDown("normal"); $('.edit-visibility').hide(); } return false; }); $('.cancel-post-visibility').click(function () { $('#post-visibility-select').slideUp("normal"); $('#visibility-radio-' + $('#hidden-post-visibility').val()).attr('checked', true); $('#post_password').val($('#hidden_post_password').val()); $('#post-visibility-display').html(visibility); $('.edit-visibility').show(); updateText(); return false; }); $('.save-post-visibility').click(function () { // crazyhorse - multiple ok cancels $('#post-visibility-select').slideUp("normal"); $('.edit-visibility').show(); updateText(); $('#post-visibility-display').html( postL10n[$('#post-visibility-select input:radio:checked').val()] ); return false; }); $('#post-visibility-select input:radio').change(function() { updateVisibility(); }); $('.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()); $('.edit-timestamp').show(); updateText(); return false; }); $('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels $('#timestampdiv').slideUp("normal"); $('.edit-timestamp').show(); updateText(); return false; }); $('.edit-post-status').click(function() { if ($('#post-status-select').is(":hidden")) { $('#post-status-select').slideDown("normal"); $(this).hide(); } return false; }); $('.save-post-status').click(function() { $('#post-status-select').slideUp("normal"); $('.edit-post-status').show(); updateText(); return false; }); $('.cancel-post-status').click(function() { $('#post-status-select').slideUp("normal"); $('#post_status').val($('#hidden_post_status').val()); $('.edit-post-status').show(); updateText(); return false; }); // Custom Fields $('#the-list').wpList( { addAfter: function( xml, s ) { $('table#list-table').show(); if ( $.isFunction( autosave_update_post_ID ) ) { autosave_update_post_ID(s.parsed.responses[0].supplemental.postid); } }, addBefore: function( s ) { s.data += '&post_id=' + $('#post_ID').val(); return s; } }); }); worsethanhitler/wp-admin/js/categories.js0000644001761300176130000000136011225331455021350 0ustar mustardamustardajQuery(document).ready(function(d){var b=false,f,e,c,a;if(document.forms.addcat.category_parent){b=document.forms.addcat.category_parent.options}f=function(i,h){var g,j;g=d(""+d("name",i).text()+"").html();j=d("cat",i).attr("id");b[b.length]=new Option(g,j);e(i,h)};e=function(g,i){var h=d(i.parsed.responses[0].data);if(h.length==1){inlineEditTax.addEvents(d(h.id))}};a=function(h,g){var j=d("cat",h).attr("id"),i;for(i=0;i" + $('name', r).text() + "").html(); id = $('cat', r).attr('id'); options[options.length] = new Option(name, id); addAfter2( r, settings ); } addAfter2 = function( x, r ) { var t = $(r.parsed.responses[0].data); if ( t.length == 1 ) inlineEditTax.addEvents($(t.id)); } delAfter = function( r, settings ) { var id = $('cat', r).attr('id'), o; for ( o = 0; o < options.length; o++ ) if ( id == options[o].value ) options[o] = null; } delBefore = function(s) { if ( 'undefined' != showNotice ) return showNotice.warn() ? s : false; return s; } if ( options ) $('#the-list').wpList( { addAfter: addAfter, delBefore: delBefore, delAfter: delAfter } ); else $('#the-list').wpList({ addAfter: addAfter2, delBefore: delBefore }); $('.delete a[class^="delete"]').click(function(){return false;}); }); worsethanhitler/wp-admin/js/link.js0000644001761300176130000000315411225331455020163 0ustar mustardamustardajQuery(document).ready(function(c){var b,a=false,d,e;c("#link_name").focus();postboxes.add_postbox_toggles("link");c("#category-tabs a").click(function(){var f=c(this).attr("href");c(this).parent().addClass("tabs").siblings("li").removeClass("tabs");c(".tabs-panel").hide();c(f).show();if("#categories-all"==f){deleteUserSetting("cats")}else{setUserSetting("cats","pop")}return false});if(getUserSetting("cats")){c('#category-tabs a[href="#categories-pop"]').click()}b=c("#newcat").one("focus",function(){c(this).val("").removeClass("form-input-tip")});c("#category-add-submit").click(function(){b.focus()});d=function(){if(a){return}a=true;var f=c(this),h=f.is(":checked"),g=f.val().toString();c("#in-link-category-"+g+", #in-popular-category-"+g).attr("checked",h);a=false};e=function(g,f){c(f.what+" response_data",g).each(function(){var h=c(c(this).text());h.find("label").each(function(){var j=c(this),l=j.find("input").val(),m=j.find("input")[0].id,i=c.trim(j.text()),k;c("#"+m).change(d);k=c('').text(i)})})};c("#categorychecklist").wpList({alt:"",what:"link-category",response:"category-ajax-response",addAfter:e});c('a[href="#categories-all"]').click(function(){deleteUserSetting("cats")});c('a[href="#categories-pop"]').click(function(){setUserSetting("cats","pop")});if("pop"==getUserSetting("cats")){c('a[href="#categories-pop"]').click()}c("#category-add-toggle").click(function(){c(this).parents("div:first").toggleClass("wp-hidden-children");c('#category-tabs a[href="#categories-all"]').click();return false});c(".categorychecklist :checkbox").change(d).filter(":checked").change()});worsethanhitler/wp-admin/js/media.js0000644001761300176130000000264711225331455020313 0ustar mustardamustardavar findPosts;(function(a){findPosts={open:function(d,c){var b=document.documentElement.scrollTop||a(document).scrollTop();if(d&&c){a("#affected").attr("name",d).val(c)}a("#find-posts").show().draggable({handle:"#find-posts-head"}).css({top:b+50+"px",left:"50%",marginLeft:"-250px"});a("#find-posts-input").focus().keyup(function(f){if(f.which==27){findPosts.close()}});return false},close:function(){a("#find-posts-response").html("");a("#find-posts").draggable("destroy").hide()},send:function(){var b={ps:a("#find-posts-input").val(),action:"find_posts",_ajax_nonce:a("#_ajax_nonce").val()};if(a("#find-posts-pages:checked").val()){b.pages=1}else{b.posts=1}a.ajax({type:"POST",url:ajaxurl,data:b,success:function(c){findPosts.show(c)},error:function(c){findPosts.error(c)}})},show:function(b){if(typeof(b)=="string"){this.error({responseText:b});return}var c=wpAjax.parseAjaxResponse(b);if(c.errors){this.error({responseText:wpAjax.broken})}c=c.responses[0];a("#find-posts-response").html(c.data)},error:function(b){var c=b.statusText;if(b.responseText){c=b.responseText.replace(/<.[^<>]*?>/g,"")}if(c){a("#find-posts-response").html(c)}}};a(document).ready(function(){a("#find-posts-submit").click(function(b){if(""==a("#find-posts-response").html()){b.preventDefault()}});a("#doaction, #doaction2").click(function(b){a('select[name^="action"]').each(function(){if(a(this).val()=="attach"){b.preventDefault();findPosts.open()}})})})})(jQuery);worsethanhitler/wp-admin/js/media-upload.dev.js0000644001761300176130000000361311225331455022344 0ustar mustardamustarda// send html to the post editor function send_to_editor(h) { var ed; if ( typeof tinyMCE != 'undefined' && ( ed = tinyMCE.activeEditor ) && !ed.isHidden() ) { ed.focus(); if (tinymce.isIE) ed.selection.moveToBookmark(tinymce.EditorManager.activeEditor.windowManager.bookmark); if ( h.indexOf('[caption') === 0 ) { if ( ed.plugins.wpeditimage ) h = ed.plugins.wpeditimage._do_shcode(h); } else if ( h.indexOf('[gallery') === 0 ) { if ( ed.plugins.wpgallery ) h = ed.plugins.wpgallery._do_gallery(h); } ed.execCommand('mceInsertContent', false, h); } else if ( typeof edInsertContent == 'function' ) { edInsertContent(edCanvas, h); } else { jQuery( edCanvas ).val( jQuery( edCanvas ).val() + h ); } tb_remove(); } // thickbox settings var tb_position; (function($) { tb_position = function() { var tbWindow = $('#TB_window'), width = $(window).width(), H = $(window).height(), W = ( 720 < width ) ? 720 : width; if ( tbWindow.size() ) { tbWindow.width( W - 50 ).height( H - 45 ); $('#TB_iframeContent').width( W - 50 ).height( H - 75 ); tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'}); if ( typeof document.body.style.maxWidth != 'undefined' ) tbWindow.css({'top':'20px','margin-top':'0'}); }; return $('a.thickbox').each( function() { var href = $(this).attr('href'); if ( ! href ) return; href = href.replace(/&width=[0-9]+/g, ''); href = href.replace(/&height=[0-9]+/g, ''); $(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) ); }); }; $(window).resize(function(){ tb_position(); }); })(jQuery); jQuery(document).ready(function($){ $('a.thickbox').click(function(){ if ( typeof tinyMCE != 'undefined' && tinyMCE.activeEditor ) { tinyMCE.get('content').focus(); tinyMCE.activeEditor.windowManager.bookmark = tinyMCE.activeEditor.selection.getBookmark('simple'); } }); }); worsethanhitler/wp-admin/js/postbox.js0000644001761300176130000000505311225331455020724 0ustar mustardamustardavar postboxes;(function(a){postboxes={add_postbox_toggles:function(c,b){this.init(c,b);a(".postbox h3, .postbox .handlediv").click(function(){var e=a(this).parent(".postbox");e.toggleClass("closed");postboxes.save_state(c)});a(".postbox h3 a").click(function(f){f.stopPropagation()});a(".hide-postbox-tog").click(function(){var e=a(this).val();if(a(this).attr("checked")){a("#"+e).show();if(a.isFunction(postboxes.pbshow)){postboxes.pbshow(e)}}else{a("#"+e).hide();if(a.isFunction(postboxes.pbhide)){postboxes.pbhide(e)}}postboxes.save_state(c)});a('.columns-prefs input[type="radio"]').click(function(){var e=a(this).val(),f,g,h=a("#poststuff");if(h.length){if(e==2){h.addClass("has-right-sidebar");a("#side-sortables").addClass("temp-border")}else{if(e==1){h.removeClass("has-right-sidebar");a("#normal-sortables").append(a("#side-sortables").children(".postbox"))}}}else{for(f=4;(f>e&&f>1);f--){g=a("#"+d(f)+"-sortables");a("#"+d(f-1)+"-sortables").append(g.children(".postbox"));g.parent().hide()}for(f=1;f<=e;f++){g=a("#"+d(f)+"-sortables");if(g.parent().is(":hidden")){g.addClass("temp-border").parent().show()}}a(".postbox-container:visible").css("width",98/e+"%")}postboxes.save_order(c)});function d(e){switch(e){case 1:return"normal";break;case 2:return"side";break;case 3:return"column3";break;case 4:return"column4";break;default:return""}}},init:function(c,b){a.extend(this,b||{});a("#wpbody-content").css("overflow","hidden");a(".meta-box-sortables").sortable({placeholder:"sortable-placeholder",connectWith:".meta-box-sortables",items:".postbox",handle:".hndle",cursor:"move",distance:2,tolerance:"pointer",forcePlaceholderSize:true,helper:"clone",opacity:0.65,start:function(f,d){a("body").css({WebkitUserSelect:"none",KhtmlUserSelect:"none"})},stop:function(f,d){postboxes.save_order(c);d.item.parent().removeClass("temp-border");a("body").css({WebkitUserSelect:"",KhtmlUserSelect:""})}})},save_state:function(d){var b=a(".postbox").filter(".closed").map(function(){return this.id}).get().join(","),c=a(".postbox").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(postboxL10n.requestFile,{action:"closed-postboxes",closed:b,hidden:c,closedpostboxesnonce:jQuery("#closedpostboxesnonce").val(),page:d})},save_order:function(c){var b,d=a(".columns-prefs input:checked").val()||0;b={action:"meta-box-order",_ajax_nonce:a("#meta-box-order-nonce").val(),page_columns:d,page:c};a(".meta-box-sortables").each(function(){b["order["+this.id.split("-")[0]+"]"]=a(this).sortable("toArray").join(",")});a.post(postboxL10n.requestFile,b)},pbshow:false,pbhide:false}}(jQuery));worsethanhitler/wp-admin/js/comment.dev.js0000644001761300176130000000201611225331455021441 0ustar mustardamustardajQuery(document).ready( function($) { 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; }); });worsethanhitler/wp-admin/js/password-strength-meter.dev.js0000644001761300176130000000131711225331455024612 0ustar mustardamustarda// Password strength meter function passwordStrength(password,username) { var shortPass = 1, badPass = 2, goodPass = 3, strongPass = 4, symbolSize = 0, natLog, score; //password < 4 if (password.length < 4 ) { return shortPass }; //password == username if (password.toLowerCase()==username.toLowerCase()) return badPass; if (password.match(/[0-9]/)) symbolSize +=10; if (password.match(/[a-z]/)) symbolSize +=26; if (password.match(/[A-Z]/)) symbolSize +=26; if (password.match(/[^a-zA-Z0-9]/)) symbolSize +=31; natLog = Math.log( Math.pow(symbolSize,password.length) ); score = natLog / Math.LN2; if (score < 40 ) return badPass if (score < 56 ) return goodPass return strongPass; } worsethanhitler/wp-admin/js/user-profile.js0000644001761300176130000000301711225331455021640 0ustar mustardamustarda(function(a){function b(){var d=a("#pass1").val(),c=a("#user_login").val(),e;a("#pass-strength-result").removeClass("short bad good strong");if(!d){a("#pass-strength-result").html(pwsL10n.empty);return}e=passwordStrength(d,c);switch(e){case 2:a("#pass-strength-result").addClass("bad").html(pwsL10n.bad);break;case 3:a("#pass-strength-result").addClass("good").html(pwsL10n.good);break;case 4:a("#pass-strength-result").addClass("strong").html(pwsL10n.strong);break;default:a("#pass-strength-result").addClass("short").html(pwsL10n["short"])}}a(document).ready(function(){a("#pass1").val("").keyup(b);a(".color-palette").click(function(){a(this).siblings("input[name=admin_color]").attr("checked","checked")});a("#nickname").blur(function(){var c=a(this).val()||a("#user_login").val();a("#display_name #display_nickname").val(c).html(c)});a("#first_name, #last_name").blur(function(){var d=a("#first_name").val(),c=a("#last_name").val();a("#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst").remove();if(d&&c){a("#display_name").append('")}else{if(d&&!c){a("#display_name").append('")}else{if(!d&&c){a("#display_name").append('")}}}})})})(jQuery);worsethanhitler/wp-admin/js/utils.js0000644001761300176130000000404311225331455020364 0ustar mustardamustardafunction convertEntities(b){var d,a;d=function(c){if(/&[^;]+;/.test(c)){var f=document.createElement("div");f.innerHTML=c;return !f.firstChild?c:f.firstChild.nodeValue}return c};if(typeof b==="string"){return d(b)}else{if(typeof b==="object"){for(a in b){if(typeof b[a]==="string"){b[a]=d(b[a])}}}}return b}var wpCookies={each:function(d,a,c){var e,b;if(!d){return 0}c=c||d;if(typeof(d.length)!="undefined"){for(e=0,b=d.length;e]+>/g, function(m){ return m.replace(/__i__|%i%/g, n); }) ); ui.item.attr( 'id', id.replace(/__i__|%i%/g, n) ); n++; $('div#' + id).find('input.multi_number').val(n); } else if ( 'single' == add ) { ui.item.attr( 'id', 'new-' + id ); rem = 'div#' + id; } wpWidgets.addEvents(ui.item); wpWidgets.save( ui.item, 0, 0, 1 ); ui.item.find('input.add_new').val(''); ui.item.find('a.widget-action').click(); return; } wpWidgets.saveOrder(sb); }, receive: function(e,ui) { if ( !$(this).is(':visible') ) $(this).sortable('cancel'); } }).not(':visible').sortable('disable'); wpWidgets.resize(); wpWidgets.fixLabels(); }, saveOrder : function(sb) { if ( sb ) $('#' + sb).parents('.widgets-holder-wrap').find('.ajax-feedback').css('visibility', 'visible'); var a = { action: 'widgets-order', savewidgets: $('#_wpnonce_widgets').val(), sidebars: [] }; $('.widgets-sortables').each( function() { a['sidebars[' + $(this).attr('id') + ']'] = $(this).sortable('toArray').join(','); }); $.post( ajaxurl, a, function() { $('.ajax-feedback').css('visibility', 'hidden'); }); this.resize(); }, save : function(widget, del, animate, order) { var sb = widget.parents('.widgets-sortables').attr('id'), data = widget.find('form').serialize(), a; widget = $(widget); widget.find('.ajax-feedback').css('visibility', 'visible'); a = { action: 'save-widget', savewidgets: $('#_wpnonce_widgets').val(), sidebar: sb }; if ( del ) a['delete_widget'] = 1; data += '&' + $.param(a); $.post( ajaxurl, data, function(r){ var id; if ( del ) { if ( !$('.widget_number', widget).val() ) { id = $('.widget-id', widget).val(); $('#available-widgets .widget-id').each(function(){ if ( $(this).val() == id ) $(this).parents('.widget').show(); }); } if ( animate ) { order = 0; widget.slideUp('fast', function(){ $(this).remove(); wpWidgets.saveOrder(); }); } else { widget.remove(); wpWidgets.resize(); } } else { $('.ajax-feedback').css('visibility', 'hidden'); if ( r && r.length > 2 ) { $('.widget-content', widget).html(r); wpWidgets.appendTitle(widget); wpWidgets.fixLabels(widget); } } if ( order ) wpWidgets.saveOrder(); }); }, appendTitle : function(widget) { $('input[type="text"]', widget).each(function(){ var title; if ( this.id.indexOf('title') != -1 ) { title = $(this).val().replace(/<[^<>]+>/g, '').replace(//g, '>'); if ( title ) $('.widget-title .in-widget-title', widget).html(': ' + title); return false; } }); }, resize : function() { $('.widgets-sortables').not('#wp_inactive_widgets').each(function(){ var h = 50, H = $('.widget', this).length; h = h + parseInt(H * 48, 10); $(this).css( 'minHeight', h + 'px' ); }); }, fixWebkit : function(n) { n = n ? 'none' : ''; $('body').css({ WebkitUserSelect: n, KhtmlUserSelect: n }); }, fixLabels : function(sc) { sc = sc || document; $('.widget-inside label', sc).each(function(){ var f = $(this).attr('for'); if ( f && f == $('input', this).attr('id') ) $(this).removeAttr('for'); }); }, close : function(widget) { widget.find('.widget-inside').slideUp('fast', function(){ widget.css({'width':'','marginLeft':''}); }); }, addEvents : function(sc) { sc = sc || document; $('a.widget-action', sc).click(function(){ var w = parseInt( $(this).parents('.widget').find('.widget-width').val(), 10 ), css = {}, inside = $(this).parents('.widget-top').siblings('.widget-inside'); if ( inside.is(':hidden') ) { if ( w > 250 && inside.parents('.widgets-sortables').length ) { css['width'] = w + 30 + 'px'; if ( inside.parents('.widget-liquid-right').length ) css['marginLeft'] = 235 - w + 'px'; inside.parents('.widget').css(css); } inside.slideDown('fast'); } else { inside.slideUp('fast', function(){ inside.parents('.widget').css({'width':'','marginLeft':''}); }); } return false; }); $('.widget-control-save', sc).click(function(){ wpWidgets.save( $(this).parents('.widget'), 0, 1, 0 ); return false; }); $('.widget-control-remove', sc).click(function(){ wpWidgets.save( $(this).parents('.widget'), 1, 1, 0 ); return false; }); $('.widget-control-close', sc).click(function(){ wpWidgets.close( $(this).parents('.widget') ); return false; }); } }; $(document).ready(function(){wpWidgets.init();}); })(jQuery); worsethanhitler/wp-admin/js/plugin-install.js0000644001761300176130000000210211225331455022160 0ustar mustardamustardajQuery(document).ready(function(b){var a=function(){var f=b("#TB_window"),e=b(window).width(),d=b(window).height(),c=(720"+plugininstallL10n.plugin_information+" "+b(this).attr("title"));return false});b("#plugin-information #sidemenu a").click(function(){var c=b(this).attr("name");b("#plugin-information-header a.current").removeClass("current");b(this).addClass("current");b("#section-holder div.section").hide();b("#section-"+c).show();return false})});worsethanhitler/wp-admin/js/dashboard.dev.js0000644001761300176130000000321211225331455021725 0ustar mustardamustarda jQuery(document).ready( function($) { var ajaxWidgets, ajaxPopulateWidgets, quickPressLoad; // These widgets are sometimes populated via ajax ajaxWidgets = [ 'dashboard_incoming_links', 'dashboard_primary', 'dashboard_secondary', 'dashboard_plugins' ]; ajaxPopulateWidgets = function() { $.each( ajaxWidgets, function() { var e = jQuery('#' + this + ':visible div.inside').find('.widget-loading'); if ( e.size() ) { e.parent().load('index-extra.php?jax=' + this); } } ); }; ajaxPopulateWidgets(); postboxes.add_postbox_toggles('dashboard', { onShow: ajaxPopulateWidgets } ); /* QuickPress */ quickPressLoad = function() { var act = $('#quickpost-action'), t; t = $('#quick-press').submit( function() { $('#dashboard_quick_press h3').append( '' ); $('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr('disabled','disabled'); if ( 'post' == act.val() ) { act.val( 'post-quickpress-publish' ); } $('#dashboard_quick_press div.inside').load( t.attr( 'action' ), t.serializeArray(), function() { $('#dashboard_quick_press h3 img').remove(); $('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr('disabled',''); $('#dashboard_quick_press ul').find('li').each( function() { $('#dashboard_recent_drafts ul').prepend( this ); } ).end().remove(); tb_init('a.thickbox'); quickPressLoad(); } ); return false; } ); $('#publish').click( function() { act.val( 'post-quickpress-publish' ); } ); }; quickPressLoad(); } ); worsethanhitler/wp-admin/js/postbox.dev.js0000644001761300176130000000745711225331455021513 0ustar mustardamustardavar postboxes; (function($) { postboxes = { add_postbox_toggles : function(page,args) { this.init(page,args); $('.postbox h3, .postbox .handlediv').click( function() { var p = $(this).parent('.postbox'); /* if ( p.hasClass('noclick') ) { p.removeClass('noclick'); return false; } */ p.toggleClass('closed'); postboxes.save_state(page); } ); $('.postbox h3 a').click( function(e) { e.stopPropagation(); } ); $('.hide-postbox-tog').click( function() { var box = $(this).val(); if ( $(this).attr('checked') ) { $('#' + box).show(); if ( $.isFunction( postboxes.pbshow ) ) postboxes.pbshow( box ); } else { $('#' + box).hide(); if ( $.isFunction( postboxes.pbhide ) ) postboxes.pbhide( box ); } postboxes.save_state(page); } ); $('.columns-prefs input[type="radio"]').click(function(){ var num = $(this).val(), i, el, p = $('#poststuff'); if ( p.length ) { // write pages if ( num == 2 ) { p.addClass('has-right-sidebar'); $('#side-sortables').addClass('temp-border'); } else if ( num == 1 ) { p.removeClass('has-right-sidebar'); $('#normal-sortables').append($('#side-sortables').children('.postbox')); } } else { // dashboard for ( i = 4; ( i > num && i > 1 ); i-- ) { el = $('#' + colname(i) + '-sortables'); $('#' + colname(i-1) + '-sortables').append(el.children('.postbox')); el.parent().hide(); } for ( i = 1; i <= num; i++ ) { el = $('#' + colname(i) + '-sortables'); if ( el.parent().is(':hidden') ) el.addClass('temp-border').parent().show(); } $('.postbox-container:visible').css('width', 98/num + '%'); } postboxes.save_order(page); }); function colname(n) { switch (n) { case 1: return 'normal'; break case 2: return 'side'; break case 3: return 'column3'; break case 4: return 'column4'; break default: return ''; } } }, init : function(page, args) { $.extend( this, args || {} ); $('#wpbody-content').css('overflow','hidden'); $('.meta-box-sortables').sortable({ placeholder: 'sortable-placeholder', connectWith: '.meta-box-sortables', items: '.postbox', handle: '.hndle', cursor: 'move', distance: 2, tolerance: 'pointer', forcePlaceholderSize: true, helper: 'clone', opacity: 0.65, start: function(e,ui) { $('body').css({ WebkitUserSelect: 'none', KhtmlUserSelect: 'none' }); /* if ( $.browser.msie ) return; ui.item.addClass('noclick'); */ }, stop: function(e,ui) { postboxes.save_order(page); ui.item.parent().removeClass('temp-border'); $('body').css({ WebkitUserSelect: '', KhtmlUserSelect: '' }); } }); }, save_state : function(page) { var closed = $('.postbox').filter('.closed').map(function() { return this.id; }).get().join(','), hidden = $('.postbox').filter(':hidden').map(function() { return this.id; }).get().join(','); $.post(postboxL10n.requestFile, { action: 'closed-postboxes', closed: closed, hidden: hidden, closedpostboxesnonce: jQuery('#closedpostboxesnonce').val(), page: page }); }, save_order : function(page) { var postVars, page_columns = $('.columns-prefs input:checked').val() || 0; postVars = { action: 'meta-box-order', _ajax_nonce: $('#meta-box-order-nonce').val(), page_columns: page_columns, page: page } $('.meta-box-sortables').each( function() { postVars["order[" + this.id.split('-')[0] + "]"] = $(this).sortable( 'toArray' ).join(','); } ); $.post( postboxL10n.requestFile, postVars ); }, /* Callbacks */ pbshow : false, pbhide : false }; }(jQuery)); worsethanhitler/wp-admin/js/comment.js0000644001761300176130000000152611225331455020671 0ustar mustardamustardajQuery(document).ready(function(b){var a=b("#timestamp").html();b(".edit-timestamp").click(function(){if(b("#timestampdiv").is(":hidden")){b("#timestampdiv").slideDown("normal");b(".edit-timestamp").hide()}return false});b(".cancel-timestamp").click(function(){b("#timestampdiv").slideUp("normal");b("#mm").val(b("#hidden_mm").val());b("#jj").val(b("#hidden_jj").val());b("#aa").val(b("#hidden_aa").val());b("#hh").val(b("#hidden_hh").val());b("#mn").val(b("#hidden_mn").val());b("#timestamp").html(a);b(".edit-timestamp").show();return false});b(".save-timestamp").click(function(){b("#timestampdiv").slideUp("normal");b(".edit-timestamp").show();b("#timestamp").html(commentL10n.submittedOn+" "+b("#mm option[value="+b("#mm").val()+"]").text()+" "+b("#jj").val()+", "+b("#aa").val()+" @ "+b("#hh").val()+":"+b("#mn").val()+" ");return false})});worsethanhitler/wp-admin/js/post.dev.js0000644001761300176130000003477211225331455021002 0ustar mustardamustarda// return an array with any duplicate, whitespace or values removed function array_unique_noempty(a) { var out = []; jQuery.each( a, function(key, val) { val = jQuery.trim(val); if ( val && jQuery.inArray(val, out) == -1 ) out.push(val); } ); return out; } function new_tag_remove_tag() { var id = jQuery( this ).attr( 'id' ), num = id.split('-check-num-')[1], taxbox = jQuery(this).parents('.tagsdiv'), current_tags = taxbox.find( '.the-tags' ).val().split(','), new_tags = []; delete current_tags[num]; jQuery.each( current_tags, function(key, val) { val = jQuery.trim(val); if ( val ) { new_tags.push(val); } }); taxbox.find('.the-tags').val( new_tags.join(',').replace(/\s*,+\s*/, ',').replace(/,+/, ',').replace(/,+\s+,+/, ',').replace(/,+\s*$/, '').replace(/^\s*,+/, '') ); tag_update_quickclicks(taxbox); return false; } function tag_update_quickclicks(taxbox) { if ( jQuery(taxbox).find('.the-tags').length == 0 ) return; var current_tags = jQuery(taxbox).find('.the-tags').val().split(','); jQuery(taxbox).find('.tagchecklist').empty(); shown = false; jQuery.each( current_tags, function( key, val ) { var txt, button_id; val = jQuery.trim(val); if ( !val.match(/^\s+$/) && '' != val ) { button_id = jQuery(taxbox).attr('id') + '-check-num-' + key; txt = 'X ' + val + ' '; jQuery(taxbox).find('.tagchecklist').append(txt); jQuery( '#' + button_id ).click( new_tag_remove_tag ); } }); if ( shown ) jQuery(taxbox).find('.tagchecklist').prepend(''+postL10n.tagsUsed+'
'); } function tag_flush_to_text(id, a) { a = a || false; var taxbox, text, tags, newtags; taxbox = jQuery('#'+id); text = a ? jQuery(a).text() : taxbox.find('input.newtag').val(); // is the input box empty (i.e. showing the 'Add new tag' tip)? if ( taxbox.find('input.newtag').hasClass('form-input-tip') && ! a ) return false; tags = taxbox.find('.the-tags').val(); newtags = tags ? tags + ',' + text : text; // massage newtags = newtags.replace(/\s+,+\s*/g, ',').replace(/,+/g, ',').replace(/,+\s+,+/g, ',').replace(/,+\s*$/g, '').replace(/^\s*,+/g, ''); newtags = array_unique_noempty(newtags.split(',')).join(','); taxbox.find('.the-tags').val(newtags); tag_update_quickclicks(taxbox); if ( ! a ) taxbox.find('input.newtag').val('').focus(); return false; } function tag_save_on_publish() { jQuery('.tagsdiv').each( function(i) { if ( !jQuery(this).find('input.newtag').hasClass('form-input-tip') ) tag_flush_to_text(jQuery(this).parents('.tagsdiv').attr('id')); } ); } function tag_press_key( e ) { if ( 13 == e.which ) { tag_flush_to_text(jQuery(e.target).parents('.tagsdiv').attr('id')); return false; } }; function tag_init() { jQuery('.ajaxtag').show(); jQuery('.tagsdiv').each( function(i) { tag_update_quickclicks(this); } ); // add the quickadd form jQuery('.ajaxtag input.tagadd').click(function(){tag_flush_to_text(jQuery(this).parents('.tagsdiv').attr('id'));}); jQuery('.ajaxtag input.newtag').focus(function() { if ( !this.cleared ) { this.cleared = true; jQuery(this).val( '' ).removeClass( 'form-input-tip' ); } }); jQuery('.ajaxtag input.newtag').blur(function() { if ( this.value == '' ) { this.cleared = false; jQuery(this).val( postL10n.addTag ).addClass( 'form-input-tip' ); } }); // auto-save tags on post save/publish jQuery('#publish').click( tag_save_on_publish ); jQuery('#save-post').click( tag_save_on_publish ); // catch the enter key jQuery('.ajaxtag input.newtag').keypress( tag_press_key ); } var commentsBox, tagCloud; (function($){ commentsBox = { st : 0, get : function(total, num) { var st = this.st, data; if ( ! num ) num = 20; this.st += num; this.total = total; $('#commentsdiv img.waiting').show(); data = { 'action' : 'get-comments', 'mode' : 'single', '_ajax_nonce' : $('#add_comment_nonce').val(), 'post_ID' : $('#post_ID').val(), 'start' : st, 'num' : num }; $.post(ajaxurl, data, function(r) { r = wpAjax.parseAjaxResponse(r); $('#commentsdiv .widefat').show(); $('#commentsdiv img.waiting').hide(); if ( 'object' == typeof r && r.responses[0] ) { $('#the-comment-list').append( r.responses[0].data ); theList = theExtraList = null; $("a[className*=':']").unbind(); setCommentsList(); if ( commentsBox.st > commentsBox.total ) $('#show-comments').hide(); else $('#show-comments').html(postL10n.showcomm); return; } else if ( 1 == r ) { $('#show-comments').parent().html(postL10n.endcomm); return; } $('#the-comment-list').append(''+wpAjax.broken+''); } ); return false; } }; tagCloud = { init : function() { $('.tagcloud-link').click(function(){ tagCloud.get($(this).attr('id')); $(this).unbind().click(function(){ $(this).siblings('.the-tagcloud').toggle(); return false; }); return false; }); }, get : function(id) { var tax = id.substr(id.indexOf('-')+1); $.post(ajaxurl, {'action':'get-tagcloud','tax':tax}, function(r, stat) { if ( 0 == r || 'success' != stat ) r = wpAjax.broken; r = $('

'+r+'

'); $('a', r).click(function(){ var id = $(this).parents('p').attr('id'); tag_flush_to_text(id.substr(id.indexOf('-')+1), this); return false; }); $('#'+id).after(r); }); } }; $(document).ready(function(){tagCloud.init();}); })(jQuery); jQuery(document).ready( function($) { var noSyncChecks = false, syncChecks, catAddAfter, stamp = $('#timestamp').html(), visibility = $('#post-visibility-display').html(), sticky = ''; // for Press This if ( typeof autosave != 'function' ) autosave = function(){}; // postboxes postboxes.add_postbox_toggles('post'); // Editable slugs make_slugedit_clickable(); // prepare the tag UI tag_init(); $('#title').blur( function() { if ( ($("#post_ID").val() > 0) || ($("#title").val().length == 0) ) return; autosave(); } ); // auto-suggest stuff $('.newtag').each(function(){ var tax = $(this).parents('div.tagsdiv').attr('id'); $(this).suggest( 'admin-ajax.php?action=ajax-tag-search&tax='+tax, { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } ); }); // category tabs $('#category-tabs a').click(function(){ var t = $(this).attr('href'); $(this).parent().addClass('tabs').siblings('li').removeClass('tabs'); $('.tabs-panel').hide(); $(t).show(); if ( '#categories-all' == t ) deleteUserSetting('cats'); else setUserSetting('cats','pop'); return false; }); if ( getUserSetting('cats') ) $('#category-tabs a[href="#categories-pop"]').click(); // Ajax Cat $('#newcat').one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ) } ); $('#category-add-sumbit').click(function(){$('#newcat').focus();}); syncChecks = function() { if ( noSyncChecks ) return; noSyncChecks = true; var th = jQuery(this), c = th.is(':checked'), id = th.val().toString(); $('#in-category-' + id + ', #in-popular-category-' + id).attr( 'checked', c ); noSyncChecks = false; }; popularCats = $('#categorychecklist-pop :checkbox').map( function() { return parseInt(jQuery(this).val(), 10); } ).get().join(','); catAddBefore = function( s ) { if ( !$('#newcat').val() ) return false; s.data += '&popular_ids=' + popularCats + '&' + jQuery( '#categorychecklist :checked' ).serialize(); return s; }; catAddAfter = function( r, s ) { var newCatParent = jQuery('#newcat_parent'), newCatParentOption = newCatParent.find( 'option[value="-1"]' ); $(s.what + ' response_data', r).each( function() { var t = $($(this).text()); t.find( 'label' ).each( function() { var th = $(this), val = th.find('input').val(), id = th.find('input')[0].id, name, o; $('#' + id).change( syncChecks ).change(); if ( newCatParent.find( 'option[value="' + val + '"]' ).size() ) return; name = $.trim( th.text() ); o = $( '' ).text( name ); newCatParent.prepend( o ); } ); newCatParentOption.attr( 'selected', 'selected' ); } ); }; $('#categorychecklist').wpList( { alt: '', response: 'category-ajax-response', addBefore: catAddBefore, addAfter: catAddAfter } ); $('#category-add-toggle').click( function() { $('#category-adder').toggleClass( 'wp-hidden-children' ); $('#category-tabs a[href="#categories-all"]').click(); return false; } ); $('.categorychecklist .popular-category :checkbox').change( syncChecks ).filter( ':checked' ).change(), sticky = ''; function updateVisibility() { if ( $('#post-visibility-select input:radio:checked').val() != 'public' ) { $('#sticky').attr('checked', false); $('#sticky-span').hide(); } else { $('#sticky-span').show(); } if ( $('#post-visibility-select input:radio:checked').val() != 'password' ) { $('#password-span').hide(); } else { $('#password-span').show(); } } function updateText() { var attemptedDate, originalDate, currentDate, publishOn; attemptedDate = new Date( $('#aa').val(), $('#mm').val() -1, $('#jj').val(), $('#hh').val(), $('#mn').val()); originalDate = new Date( $('#hidden_aa').val(), $('#hidden_mm').val() -1, $('#hidden_jj').val(), $('#hidden_hh').val(), $('#hidden_mn').val()); currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val()); if ( attemptedDate > currentDate && $('#original_post_status').val() != 'future' ) { publishOn = postL10n.publishOnFuture; $('#publish').val( postL10n.schedule ); } else if ( attemptedDate <= currentDate && $('#original_post_status').val() != 'publish' ) { publishOn = postL10n.publishOn; $('#publish').val( postL10n.publish ); } else { publishOn = postL10n.publishOnPast; $('#publish').val( postL10n.update ); } if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) { //hack $('#timestamp').html(stamp); } else { $('#timestamp').html( publishOn + ' ' + $( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' + $('#jj').val() + ', ' + $('#aa').val() + ' @ ' + $('#hh').val() + ':' + $('#mn').val() + ' ' ); } if ( $('#post-visibility-select input:radio:checked').val() == 'private' ) { $('#publish').val( postL10n.update ); if ( $('#post_status option[value=publish]').length == 0 ) { $('#post_status').append(''); } $('#post_status option[value=publish]').html( postL10n.privatelyPublished ); $('#post_status option[value=publish]').attr('selected', true); $('.edit-post-status').hide(); } else { if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) { if ( $('#post_status option[value=publish]').length != 0 ) { $('#post_status option[value=publish]').remove(); $('#post_status').val($('#hidden_post_status').val()); } } else { $('#post_status option[value=publish]').html( postL10n.published ); } $('.edit-post-status').show(); } $('#post-status-display').html($('#post_status :selected').text()); if ( $('#post_status :selected').val() == 'private' || $('#post_status :selected').val() == 'publish' ) { $('#save-post').hide(); } else { $('#save-post').show(); if ( $('#post_status :selected').val() == 'pending' ) { $('#save-post').show().val( postL10n.savePending ); } else { $('#save-post').show().val( postL10n.saveDraft ); } } } $('.edit-visibility').click(function () { if ($('#post-visibility-select').is(":hidden")) { updateVisibility(); $('#post-visibility-select').slideDown("normal"); $('.edit-visibility').hide(); } return false; }); $('.cancel-post-visibility').click(function () { $('#post-visibility-select').slideUp("normal"); $('#visibility-radio-' + $('#hidden-post-visibility').val()).attr('checked', true); $('#post_password').val($('#hidden_post_password').val()); $('#sticky').attr('checked', $('#hidden-post-sticky').attr('checked')); $('#post-visibility-display').html(visibility); $('.edit-visibility').show(); updateText(); return false; }); $('.save-post-visibility').click(function () { // crazyhorse - multiple ok cancels $('#post-visibility-select').slideUp("normal"); $('.edit-visibility').show(); updateText(); if ( $('#post-visibility-select input:radio:checked').val() != 'public' ) { $('#sticky').attr('checked', false); } if ( true == $('#sticky').attr('checked') ) { sticky = 'Sticky'; } else { sticky = ''; } $('#post-visibility-display').html( postL10n[$('#post-visibility-select input:radio:checked').val() + sticky] ); return false; }); $('#post-visibility-select input:radio').change(function() { updateVisibility(); }); $('.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()); $('.edit-timestamp').show(); updateText(); return false; }); $('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels $('#timestampdiv').slideUp("normal"); $('.edit-timestamp').show(); updateText(); return false; }); $('.edit-post-status').click(function() { if ($('#post-status-select').is(":hidden")) { $('#post-status-select').slideDown("normal"); $(this).hide(); } return false; }); $('.save-post-status').click(function() { $('#post-status-select').slideUp("normal"); $('.edit-post-status').show(); updateText(); return false; }); $('.cancel-post-status').click(function() { $('#post-status-select').slideUp("normal"); $('#post_status').val($('#hidden_post_status').val()); $('.edit-post-status').show(); updateText(); return false; }); // Custom Fields $('#the-list').wpList( { addAfter: function( xml, s ) { $('table#list-table').show(); if ( $.isFunction( autosave_update_post_ID ) ) { autosave_update_post_ID(s.parsed.responses[0].supplemental.postid); } }, addBefore: function( s ) { s.data += '&post_id=' + $('#post_ID').val(); return s; } }); }); worsethanhitler/wp-admin/js/custom-fields.dev.js0000644001761300176130000000175611225331455022567 0ustar mustardamustardajQuery(document).ready( function($) { var before, addBefore, addAfter, delBefore; before = function() { var nonce = $('#newmeta [name=_ajax_nonce]').val(), postId = $('#post_ID').val(); if ( !nonce || !postId ) { return false; } return [nonce,postId]; } addBefore = function( s ) { var b = before(); if ( !b ) { return false; } s.data = s.data.replace(/_ajax_nonce=[a-f0-9]+/, '_ajax_nonce=' + b[0]) + '&post_id=' + b[1]; return s; }; addAfter = function( r, s ) { var postId = $('postid', r).text(), h; if ( !postId ) { return; } $('#post_ID').attr( 'name', 'post_ID' ).val( postId ); h = $('#hiddenaction'); if ( 'post' == h.val() ) { h.val( 'postajaxpost' ); } }; delBefore = function( s ) { var b = before(); if ( !b ) return false; s.data._ajax_nonce = b[0]; s.data.post_id = b[1]; return s; } $('#the-list') .wpList( { addBefore: addBefore, addAfter: addAfter, delBefore: delBefore } ) .find('.updatemeta, .deletemeta').attr( 'type', 'button' ); } ); worsethanhitler/wp-admin/js/custom-fields.js0000644001761300176130000000125511225331455022004 0ustar mustardamustardajQuery(document).ready(function(d){var c,b,e,a;c=function(){var g=d("#newmeta [name=_ajax_nonce]").val(),f=d("#post_ID").val();if(!g||!f){return false}return[g,f]};b=function(g){var f=c();if(!f){return false}g.data=g.data.replace(/_ajax_nonce=[a-f0-9]+/,"_ajax_nonce="+f[0])+"&post_id="+f[1];return g};e=function(j,i){var f=d("postid",j).text(),g;if(!f){return}d("#post_ID").attr("name","post_ID").val(f);g=d("#hiddenaction");if("post"==g.val()){g.val("postajaxpost")}};a=function(g){var f=c();if(!f){return false}g.data._ajax_nonce=f[0];g.data.post_id=f[1];return g};d("#the-list").wpList({addBefore:b,addAfter:e,delBefore:a}).find(".updatemeta, .deletemeta").attr("type","button")});worsethanhitler/wp-admin/js/xfn.js0000644001761300176130000000136711225331455020025 0ustar mustardamustardafunction GetElementsWithClassName(a,c){var d=document.getElementsByTagName(a),e=new Array(),b;for(b=0;bX '+f+" ";jQuery(b).find(".tagchecklist").append(c);jQuery("#"+d).click(new_tag_remove_tag)}});if(shown){jQuery(b).find(".tagchecklist").prepend(""+postL10n.tagsUsed+"
")}}function tag_flush_to_text(g,b){b=b||false;var e,f,c,d;e=jQuery("#"+g);f=b?jQuery(b).text():e.find("input.newtag").val();if(e.find("input.newtag").hasClass("form-input-tip")&&!b){return false}c=e.find(".the-tags").val();d=c?c+","+f:f;d=d.replace(/\s+,+\s*/g,",").replace(/,+/g,",").replace(/,+\s+,+/g,",").replace(/,+\s*$/g,"").replace(/^\s*,+/g,"");d=array_unique_noempty(d.split(",")).join(",");e.find(".the-tags").val(d);tag_update_quickclicks(e);if(!b){e.find("input.newtag").val("").focus()}return false}function tag_save_on_publish(){jQuery(".tagsdiv").each(function(a){if(!jQuery(this).find("input.newtag").hasClass("form-input-tip")){tag_flush_to_text(jQuery(this).parents(".tagsdiv").attr("id"))}})}function tag_press_key(a){if(13==a.which){tag_flush_to_text(jQuery(a.target).parents(".tagsdiv").attr("id"));return false}}function tag_init(){jQuery(".ajaxtag").show();jQuery(".tagsdiv").each(function(a){tag_update_quickclicks(this)});jQuery(".ajaxtag input.tagadd").click(function(){tag_flush_to_text(jQuery(this).parents(".tagsdiv").attr("id"))});jQuery(".ajaxtag input.newtag").focus(function(){if(!this.cleared){this.cleared=true;jQuery(this).val("").removeClass("form-input-tip")}});jQuery(".ajaxtag input.newtag").blur(function(){if(this.value==""){this.cleared=false;jQuery(this).val(postL10n.addTag).addClass("form-input-tip")}});jQuery("#publish").click(tag_save_on_publish);jQuery("#save-post").click(tag_save_on_publish);jQuery(".ajaxtag input.newtag").keypress(tag_press_key)}var commentsBox,tagCloud;(function(a){commentsBox={st:0,get:function(d,c){var b=this.st,e;if(!c){c=20}this.st+=c;this.total=d;a("#commentsdiv img.waiting").show();e={action:"get-comments",mode:"single",_ajax_nonce:a("#add_comment_nonce").val(),post_ID:a("#post_ID").val(),start:b,num:c};a.post(ajaxurl,e,function(f){f=wpAjax.parseAjaxResponse(f);a("#commentsdiv .widefat").show();a("#commentsdiv img.waiting").hide();if("object"==typeof f&&f.responses[0]){a("#the-comment-list").append(f.responses[0].data);theList=theExtraList=null;a("a[className*=':']").unbind();setCommentsList();if(commentsBox.st>commentsBox.total){a("#show-comments").hide()}else{a("#show-comments").html(postL10n.showcomm)}return}else{if(1==f){a("#show-comments").parent().html(postL10n.endcomm);return}}a("#the-comment-list").append(''+wpAjax.broken+"")});return false}};tagCloud={init:function(){a(".tagcloud-link").click(function(){tagCloud.get(a(this).attr("id"));a(this).unbind().click(function(){a(this).siblings(".the-tagcloud").toggle();return false});return false})},get:function(c){var b=c.substr(c.indexOf("-")+1);a.post(ajaxurl,{action:"get-tagcloud",tax:b},function(e,d){if(0==e||"success"!=d){e=wpAjax.broken}e=a('

'+e+"

");a("a",e).click(function(){var f=a(this).parents("p").attr("id");tag_flush_to_text(f.substr(f.indexOf("-")+1),this);return false});a("#"+c).after(e)})}};a(document).ready(function(){tagCloud.init()})})(jQuery);jQuery(document).ready(function(g){var d=false,i,e,a=g("#timestamp").html(),b=g("#post-visibility-display").html(),h="";if(typeof autosave!="function"){autosave=function(){}}postboxes.add_postbox_toggles("post");make_slugedit_clickable();tag_init();g("#title").blur(function(){if((g("#post_ID").val()>0)||(g("#title").val().length==0)){return}autosave()});g(".newtag").each(function(){var j=g(this).parents("div.tagsdiv").attr("id");g(this).suggest("admin-ajax.php?action=ajax-tag-search&tax="+j,{delay:500,minchars:2,multiple:true,multipleSep:", "})});g("#category-tabs a").click(function(){var j=g(this).attr("href");g(this).parent().addClass("tabs").siblings("li").removeClass("tabs");g(".tabs-panel").hide();g(j).show();if("#categories-all"==j){deleteUserSetting("cats")}else{setUserSetting("cats","pop")}return false});if(getUserSetting("cats")){g('#category-tabs a[href="#categories-pop"]').click()}g("#newcat").one("focus",function(){g(this).val("").removeClass("form-input-tip")});g("#category-add-sumbit").click(function(){g("#newcat").focus()});i=function(){if(d){return}d=true;var j=jQuery(this),l=j.is(":checked"),k=j.val().toString();g("#in-category-"+k+", #in-popular-category-"+k).attr("checked",l);d=false};popularCats=g("#categorychecklist-pop :checkbox").map(function(){return parseInt(jQuery(this).val(),10)}).get().join(",");catAddBefore=function(j){if(!g("#newcat").val()){return false}j.data+="&popular_ids="+popularCats+"&"+jQuery("#categorychecklist :checked").serialize();return j};e=function(m,k){var j=jQuery("#newcat_parent"),l=j.find('option[value="-1"]');g(k.what+" response_data",m).each(function(){var n=g(g(this).text());n.find("label").each(function(){var q=g(this),s=q.find("input").val(),t=q.find("input")[0].id,p,r;g("#"+t).change(i).change();if(j.find('option[value="'+s+'"]').size()){return}p=g.trim(q.text());r=g('').text(p);j.prepend(r)});l.attr("selected","selected")})};g("#categorychecklist").wpList({alt:"",response:"category-ajax-response",addBefore:catAddBefore,addAfter:e});g("#category-add-toggle").click(function(){g("#category-adder").toggleClass("wp-hidden-children");g('#category-tabs a[href="#categories-all"]').click();return false});g(".categorychecklist .popular-category :checkbox").change(i).filter(":checked").change(),h="";function f(){if(g("#post-visibility-select input:radio:checked").val()!="public"){g("#sticky").attr("checked",false);g("#sticky-span").hide()}else{g("#sticky-span").show()}if(g("#post-visibility-select input:radio:checked").val()!="password"){g("#password-span").hide()}else{g("#password-span").show()}}function c(){var j,l,k,m;j=new Date(g("#aa").val(),g("#mm").val()-1,g("#jj").val(),g("#hh").val(),g("#mn").val());l=new Date(g("#hidden_aa").val(),g("#hidden_mm").val()-1,g("#hidden_jj").val(),g("#hidden_hh").val(),g("#hidden_mn").val());k=new Date(g("#cur_aa").val(),g("#cur_mm").val()-1,g("#cur_jj").val(),g("#cur_hh").val(),g("#cur_mn").val());if(j>k&&g("#original_post_status").val()!="future"){m=postL10n.publishOnFuture;g("#publish").val(postL10n.schedule)}else{if(j<=k&&g("#original_post_status").val()!="publish"){m=postL10n.publishOn;g("#publish").val(postL10n.publish)}else{m=postL10n.publishOnPast;g("#publish").val(postL10n.update)}}if(l.toUTCString()==j.toUTCString()){g("#timestamp").html(a)}else{g("#timestamp").html(m+" "+g("#mm option[value="+g("#mm").val()+"]").text()+" "+g("#jj").val()+", "+g("#aa").val()+" @ "+g("#hh").val()+":"+g("#mn").val()+" ")}if(g("#post-visibility-select input:radio:checked").val()=="private"){g("#publish").val(postL10n.update);if(g("#post_status option[value=publish]").length==0){g("#post_status").append('")}g("#post_status option[value=publish]").html(postL10n.privatelyPublished);g("#post_status option[value=publish]").attr("selected",true);g(".edit-post-status").hide()}else{if(g("#original_post_status").val()=="future"||g("#original_post_status").val()=="draft"){if(g("#post_status option[value=publish]").length!=0){g("#post_status option[value=publish]").remove();g("#post_status").val(g("#hidden_post_status").val())}}else{g("#post_status option[value=publish]").html(postL10n.published)}g(".edit-post-status").show()}g("#post-status-display").html(g("#post_status :selected").text());if(g("#post_status :selected").val()=="private"||g("#post_status :selected").val()=="publish"){g("#save-post").hide()}else{g("#save-post").show();if(g("#post_status :selected").val()=="pending"){g("#save-post").show().val(postL10n.savePending)}else{g("#save-post").show().val(postL10n.saveDraft)}}}g(".edit-visibility").click(function(){if(g("#post-visibility-select").is(":hidden")){f();g("#post-visibility-select").slideDown("normal");g(".edit-visibility").hide()}return false});g(".cancel-post-visibility").click(function(){g("#post-visibility-select").slideUp("normal");g("#visibility-radio-"+g("#hidden-post-visibility").val()).attr("checked",true);g("#post_password").val(g("#hidden_post_password").val());g("#sticky").attr("checked",g("#hidden-post-sticky").attr("checked"));g("#post-visibility-display").html(b);g(".edit-visibility").show();c();return false});g(".save-post-visibility").click(function(){g("#post-visibility-select").slideUp("normal");g(".edit-visibility").show();c();if(g("#post-visibility-select input:radio:checked").val()!="public"){g("#sticky").attr("checked",false)}if(true==g("#sticky").attr("checked")){h="Sticky"}else{h=""}g("#post-visibility-display").html(postL10n[g("#post-visibility-select input:radio:checked").val()+h]);return false});g("#post-visibility-select input:radio").change(function(){f()});g(".edit-timestamp").click(function(){if(g("#timestampdiv").is(":hidden")){g("#timestampdiv").slideDown("normal");g(".edit-timestamp").hide()}return false});g(".cancel-timestamp").click(function(){g("#timestampdiv").slideUp("normal");g("#mm").val(g("#hidden_mm").val());g("#jj").val(g("#hidden_jj").val());g("#aa").val(g("#hidden_aa").val());g("#hh").val(g("#hidden_hh").val());g("#mn").val(g("#hidden_mn").val());g(".edit-timestamp").show();c();return false});g(".save-timestamp").click(function(){g("#timestampdiv").slideUp("normal");g(".edit-timestamp").show();c();return false});g(".edit-post-status").click(function(){if(g("#post-status-select").is(":hidden")){g("#post-status-select").slideDown("normal");g(this).hide()}return false});g(".save-post-status").click(function(){g("#post-status-select").slideUp("normal");g(".edit-post-status").show();c();return false});g(".cancel-post-status").click(function(){g("#post-status-select").slideUp("normal");g("#post_status").val(g("#hidden_post_status").val());g(".edit-post-status").show();c();return false});g("#the-list").wpList({addAfter:function(j,k){g("table#list-table").show();if(g.isFunction(autosave_update_post_ID)){autosave_update_post_ID(k.parsed.responses[0].supplemental.postid)}},addBefore:function(j){j.data+="&post_id="+g("#post_ID").val();return j}})});worsethanhitler/wp-admin/js/word-count.dev.js0000644001761300176130000000170411225331455022103 0ustar mustardamustarda// Word count (function($) { wpWordCount = { init : function() { var t = this, last = 0, co = $('#content'); $('#wp-word-count').html( wordCountL10n.count.replace( /%d/, '0' ) ); t.block = 0; t.wc(co.val()); co.keyup( function(e) { if ( e.keyCode == last ) return true; if ( 13 == e.keyCode || 8 == last || 46 == last ) t.wc(co.val()); last = e.keyCode; return true; }); }, wc : function(tx) { var t = this, w = $('#word-count'), tc = 0; if ( t.block ) return; t.block = 1; setTimeout( function() { if ( tx ) { tx = tx.replace( /<.[^<>]*?>/g, ' ' ).replace( / | /gi, ' ' ); tx = tx.replace( /[0-9.(),;:!?%#$¿'"_+=\\/-]*/g, '' ); tx.replace( /\S\s+/g, function(){tc++;} ); } w.html(tc.toString()); setTimeout( function() { t.block = 0; }, 2000 ); }, 1 ); } } $(document).ready( function(){ wpWordCount.init(); } ); }(jQuery)); worsethanhitler/wp-admin/js/word-count.js0000644001761300176130000000126111225331455021324 0ustar mustardamustarda(function(a){wpWordCount={init:function(){var b=this,c=0,d=a("#content");a("#wp-word-count").html(wordCountL10n.count.replace(/%d/,'0'));b.block=0;b.wc(d.val());d.keyup(function(f){if(f.keyCode==c){return true}if(13==f.keyCode||8==c||46==c){b.wc(d.val())}c=f.keyCode;return true})},wc:function(d){var e=this,c=a("#word-count"),b=0;if(e.block){return}e.block=1;setTimeout(function(){if(d){d=d.replace(/<.[^<>]*?>/g," ").replace(/ | /gi," ");d=d.replace(/[0-9.(),;:!?%#$¿'"_+=\\/-]*/g,"");d.replace(/\S\s+/g,function(){b++})}c.html(b.toString());setTimeout(function(){e.block=0},2000)},1)}};a(document).ready(function(){wpWordCount.init()})}(jQuery));worsethanhitler/wp-admin/js/inline-edit-post.dev.js0000644001761300176130000002007111225331455023164 0ustar mustardamustarda (function($) { inlineEditPost = { init : function() { var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit'); t.type = $('table.widefat').hasClass('page') ? 'page' : 'post'; t.what = '#'+t.type+'-'; // get all editable rows t.rows = $('tr.iedit'); // prepare the edit rows qeRow.keyup(function(e) { if(e.which == 27) return inlineEditPost.revert(); }); bulkRow.keyup(function(e) { if (e.which == 27) return inlineEditPost.revert(); }); $('a.cancel', qeRow).click(function() { return inlineEditPost.revert(); }); $('a.save', qeRow).click(function() { return inlineEditPost.save(this); }); $('td', qeRow).keydown(function(e) { if ( e.which == 13 ) return inlineEditPost.save(this); }); $('a.cancel', bulkRow).click(function() { return inlineEditPost.revert(); }); $('#inline-edit .inline-edit-private input[value=private]').click( function(){ var pw = $('input.inline-edit-password-input'); if ( $(this).attr('checked') ) { pw.val('').attr('disabled', 'disabled'); } else { pw.attr('disabled', ''); } }); // add events t.addEvents(t.rows); $('#bulk-title-div').parents('fieldset').after( $('#inline-edit fieldset.inline-edit-categories').clone() ).siblings( 'fieldset:last' ).prepend( $('#inline-edit label.inline-edit-tags').clone() ); // categories expandable? $('span.catshow').click(function() { $('.inline-editor ul.cat-checklist').addClass("cat-hover"); $('.inline-editor span.cathide').show(); $(this).hide(); }); $('span.cathide').click(function() { $('.inline-editor ul.cat-checklist').removeClass("cat-hover"); $('.inline-editor span.catshow').show(); $(this).hide(); }); $('select[name="_status"] option[value="future"]', bulkRow).remove(); $('#doaction, #doaction2').click(function(e){ var n = $(this).attr('id').substr(2); if ( $('select[name="'+n+'"]').val() == 'edit' ) { e.preventDefault(); t.setBulk(); } else if ( $('form#posts-filter tr.inline-editor').length > 0 ) { t.revert(); } }); $('#post-query-submit').click(function(e){ if ( $('form#posts-filter tr.inline-editor').length > 0 ) t.revert(); }); }, toggle : function(el) { var t = this; $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el); }, addEvents : function(r) { r.each(function() { var row = $(this); $('a.editinline', row).click(function() { inlineEditPost.edit(this); return false; }); }); }, setBulk : function() { var te = '', type = this.type, tax; this.revert(); $('#bulk-edit td').attr('colspan', $('.widefat:first thead th:visible').length); $('table.widefat tbody').prepend( $('#bulk-edit') ); $('#bulk-edit').addClass('inline-editor').show(); $('tbody th.check-column input[type="checkbox"]').each(function(i){ if ( $(this).attr('checked') ) { var id = $(this).val(), theTitle; theTitle = $('#inline_'+id+' .post_title').text() || inlineEditL10n.notitle; te += '
X'+theTitle+'
'; } }); $('#bulk-titles').html(te); $('#bulk-titles a').click(function() { var id = $(this).attr('id').substr(1); $('table.widefat input[value="'+id+'"]').attr('checked', ''); $('#ttle'+id).remove(); }); // enable autocomplete for tags if ( type == 'post' ) { // support multi taxonomies? tax = 'post_tag'; $('tr.inline-editor textarea[name="tags_input"]').suggest( 'admin-ajax.php?action=ajax-tag-search&tax='+tax, { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } ); } }, edit : function(id) { var t = this, fields, editRow, rowData, cats, status, pageOpt, f, pageLevel, nextPage, pageLoop = true, nextLevel, tax; t.revert(); if ( typeof(id) == 'object' ) id = t.getId(id); fields = ['post_title', 'post_name', 'post_author', '_status', 'jj', 'mm', 'aa', 'hh', 'mn', 'ss', 'post_password']; if ( t.type == 'page' ) fields.push('post_parent', 'menu_order', 'page_template'); if ( t.type == 'post' ) fields.push('tags_input'); // add the new blank row editRow = $('#inline-edit').clone(true); $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length); if ( $(t.what+id).hasClass('alternate') ) $(editRow).addClass('alternate'); $(t.what+id).hide().after(editRow); // populate the data rowData = $('#inline_'+id); for ( f = 0; f < fields.length; f++ ) { $(':input[name="'+fields[f]+'"]', editRow).val( $('.'+fields[f], rowData).text() ); } if ( $('.comment_status', rowData).text() == 'open' ) $('input[name="comment_status"]', editRow).attr("checked", "checked"); if ( $('.ping_status', rowData).text() == 'open' ) $('input[name="ping_status"]', editRow).attr("checked", "checked"); if ( $('.sticky', rowData).text() == 'sticky' ) $('input[name="sticky"]', editRow).attr("checked", "checked"); // categories if ( cats = $('.post_category', rowData).text() ) $('ul.cat-checklist :checkbox', editRow).val(cats.split(',')); // handle the post status status = $('._status', rowData).text(); if ( status != 'future' ) $('select[name="_status"] option[value="future"]', editRow).remove(); if ( status == 'private' ) { $('input[name="keep_private"]', editRow).attr("checked", "checked"); $('input.inline-edit-password-input').val('').attr('disabled', 'disabled'); } // remove the current page and children from the parent dropdown pageOpt = $('select[name="post_parent"] option[value="'+id+'"]', editRow); if ( pageOpt.length > 0 ) { pageLevel = pageOpt[0].className.split('-')[1]; nextPage = pageOpt; while ( pageLoop ) { nextPage = nextPage.next('option'); if (nextPage.length == 0) break; nextLevel = nextPage[0].className.split('-')[1]; if ( nextLevel <= pageLevel ) { pageLoop = false; } else { nextPage.remove(); nextPage = pageOpt; } } pageOpt.remove(); } $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show(); $('.ptitle', editRow).focus(); // enable autocomplete for tags if ( t.type == 'post' ) { tax = 'post_tag'; $('tr.inline-editor textarea[name="tags_input"]').suggest( 'admin-ajax.php?action=ajax-tag-search&tax='+tax, { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } ); } return false; }, save : function(id) { var params, fields; if( typeof(id) == 'object' ) id = this.getId(id); $('table.widefat .inline-edit-save .waiting').show(); params = { action: 'inline-save', post_type: this.type, post_ID: id, edit_date: 'true' }; fields = $('#edit-'+id+' :input').fieldSerialize(); params = fields + '&' + $.param(params); // make ajax request $.post('admin-ajax.php', params, function(r) { $('table.widefat .inline-edit-save .waiting').hide(); if (r) { if ( -1 != r.indexOf(']*?>/g, '' ); $('#edit-'+id+' .inline-edit-save').append(''+r+''); } } else { $('#edit-'+id+' .inline-edit-save').append(''+inlineEditL10n.error+''); } } , 'html'); return false; }, revert : function() { var id; if ( id = $('table.widefat tr.inline-editor').attr('id') ) { $('table.widefat .inline-edit-save .waiting').hide(); if ( 'bulk-edit' == id ) { $('table.widefat #bulk-edit').removeClass('inline-editor').hide(); $('#bulk-titles').html(''); $('#inlineedit').append( $('#bulk-edit') ); } else { $('#'+id).remove(); id = id.substr( id.lastIndexOf('-') + 1 ); $(this.what+id).show(); } } return false; }, getId : function(o) { var id = o.tagName == 'TR' ? o.id : $(o).parents('tr').attr('id'), parts = id.split('-'); return parts[parts.length - 1]; } }; $(document).ready(function(){inlineEditPost.init();}); })(jQuery); worsethanhitler/wp-admin/js/slug.dev.js0000644001761300176130000000343511225331455020757 0ustar mustardamustardafunction edit_permalink(post_id) { var i, c = 0, e = jQuery('#editable-post-name'), revert_e = e.html(), real_slug = jQuery('#post_name'), revert_slug = real_slug.html(), b = jQuery('#edit-slug-buttons'), revert_b = b.html(), full = jQuery('#editable-post-name-full').html(); jQuery('#view-post-btn').hide(); b.html(''+slugL10n.save+' '+slugL10n.cancel+''); b.children('.save').click(function() { var new_slug = e.children('input').val(); jQuery.post(slugL10n.requestFile, { action: 'sample-permalink', post_id: post_id, new_slug: new_slug, new_title: jQuery('#title').val(), samplepermalinknonce: jQuery('#samplepermalinknonce').val()}, function(data) { jQuery('#edit-slug-box').html(data); b.html(revert_b); real_slug.attr('value', new_slug); make_slugedit_clickable(); jQuery('#view-post-btn').show(); }); return false; }); jQuery('#edit-slug-buttons .cancel').click(function() { jQuery('#view-post-btn').show(); e.html(revert_e); b.html(revert_b); real_slug.attr('value', revert_slug); return false; }); for(i=0; i < full.length; ++i) { if ('%' == full.charAt(i)) c++; } slug_value = (c > full.length/4)? '' : full; e.html('').children('input').keypress(function(e){ var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0; // on enter, just save the new slug, don't save the post if (13 == key) {b.children('.save').click();return false;} if (27 == key) {b.children('.cancel').click();return false;} real_slug.attr('value', this.value)}).focus(); } function make_slugedit_clickable() { jQuery('#editable-post-name').click(function() {jQuery('#edit-slug-buttons').children('.edit-slug').click()}); } worsethanhitler/wp-admin/js/cat.js0000644001761300176130000000100711225331455017770 0ustar mustardamustardajQuery(document).ready(function(b){var a=function(){return""!==b("#newcat").val()};b("#jaxcat").prepend(''+catL10n.how+'');b("#categorychecklist").wpList({alt:"",response:"cat-ajax-response",confirm:a})});worsethanhitler/wp-admin/js/edit-comments.js0000644001761300176130000001761211225331455022002 0ustar mustardamustardavar theList,theExtraList,toggleWithKeyboard=false;(function(a){setCommentsList=function(){var g,i,h,f=0,c,e,d,b;g=a('#comments-form .tablenav :input[name="_total"]');i=a('#comments-form .tablenav :input[name="_per_page"]');h=a('#comments-form .tablenav :input[name="_page"]');c=function(k,j){var l=a("#"+j.element);if(l.is(".unapproved")){l.find("div.comment_status").html("0")}else{l.find("div.comment_status").html("1")}a("span.pending-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}o=o+(a("#"+j.element).is("."+j.dimClass)?1:-1);if(o<0){o=0}a("#awaiting-mod")[0==o?"addClass":"removeClass"]("count-0");o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)})};e=function(j){j.data._total=g.val();j.data._per_page=i.val();j.data._page=h.val();j.data._url=document.location.href;if("undefined"!=showNotice&&j.data.action&&j.data.action=="delete-comment"&&!j.data.spam){return showNotice.warn()?j:false}return j};d=function(j,k,l){if(k3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)})};b=function(l,j){a("span.pending-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}if(a("#"+j.element).is(".unapproved")){o=o-1}else{if(a(j.target).parents("span.unapprove").size()){o=o+1}}if(o<0){o=0}a("#awaiting-mod")[0==o?"addClass":"removeClass"]("count-0");o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)});a("span.spam-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}if(a(j.target).parents("span.spam").size()){o=o+1}else{if(a("#"+j.element).is(".spam")){o=o-1}}if(o<0){o=0}o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)});if(("object"==typeof l)&&f p").dblclick(function(){commentReply.toggle(a(this).parent())});a("#doaction, #doaction2, #post-query-submit").click(function(c){if(a("#the-comment-list #replyrow").length>0){commentReply.close()}});this.comments_listing=a('#comments-form > input[name="comment_status"]').val()||""},addEvents:function(b){b.each(function(){a(this).find(".column-comment > p").dblclick(function(){commentReply.toggle(a(this).parent())})})},toggle:function(b){if(a(b).css("display")!="none"){a(b).find("a.vim-q").click()}},revert:function(){if(a("#the-comment-list #replyrow").length<1){return false}a("#replyrow").fadeOut("fast",function(){commentReply.close()});return false},close:function(){a(this.o).fadeIn("fast").css("backgroundColor","");a("#com-reply").append(a("#replyrow"));a("#replycontent").val("");a("#edithead input").val("");a("#replysubmit .error").html("").hide();a("#replysubmit .waiting").hide();if(a.browser.msie){a("#replycontainer, #replycontent").css("height","120px")}else{a("#replycontainer").resizable("destroy").css("height","120px")}},open:function(i,g,c){var e=this,d,b,f;e.close();e.o="#comment-"+i;a("#replyrow td").attr("colspan",a(".widefat thead th:visible").length);d=a("#replyrow"),rowData=a("#inline-"+i);b=e.act=(c=="edit")?"edit-comment":"replyto-comment";a("#action",d).val(b);a("#comment_post_ID",d).val(g);a("#comment_ID",d).val(i);if(c=="edit"){a("#author",d).val(a("div.author",rowData).text());a("#author-email",d).val(a("div.author-email",rowData).text());a("#author-url",d).val(a("div.author-url",rowData).text());a("#status",d).val(a("div.comment_status",rowData).text());a("#replycontent",d).val(a("textarea.comment",rowData).val());a("#edithead, #savebtn",d).show();a("#replyhead, #replybtn",d).hide();f=a(e.o).height();if(f>220){if(a.browser.msie){a("#replycontainer, #replycontent",d).height(f-105)}else{a("#replycontainer",d).height(f-105)}}a(e.o).after(d.hide()).fadeOut("fast",function(){a("#replyrow").fadeIn("fast")})}else{a("#edithead, #savebtn",d).hide();a("#replyhead, #replybtn",d).show();a(e.o).after(d);a("#replyrow").hide().fadeIn("fast")}if(!a.browser.msie){a("#replycontainer").resizable({handles:"s",axis:"y",minHeight:80,stop:function(){a("#replycontainer").width("auto")}})}setTimeout(function(){var l,j,m,h,k;l=a("#replyrow").offset().top;j=l+a("#replyrow").height();m=window.pageYOffset||document.documentElement.scrollTop;h=document.documentElement.clientHeight||self.innerHeight||0;k=m+h;if(k-20]*?>/g,"")}if(c){a("#replysubmit .error").html(c).show()}}};a(document).ready(function(){var e,b,c,d;setCommentsList();commentReply.init();a("span.delete a.delete").click(function(){return false});if(typeof QTags!="undefined"){ed_reply=new QTags("ed_reply","replycontent","replycontainer","more")}if(typeof a.table_hotkeys!="undefined"){e=function(f){return function(){var h,g;h="next"==f?"first":"last";g=a("."+f+".page-numbers");if(g.length){window.location=g[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g,"")+"&hotkeys_highlight_"+h+"=1"}}};b=function(g,f){window.location=a("span.edit a",f).attr("href")};c=function(){toggleWithKeyboard=true;a("#comments-form thead #cb input:checkbox").click().attr("checked","");toggleWithKeyboard=false};d=function(f){return function(h,g){a("option[value="+f+"]").attr("selected","selected");a("form#comments-form")[0].submit()}};a.table_hotkeys(a("table.widefat"),["a","u","s","d","r","q",["e",b],["shift+a",d("approve")],["shift+s",d("markspam")],["shift+d",d("delete")],["shift+x",c],["shift+u",d("unapprove")]],{highlight_first:adminCommentsL10n.hotkeys_highlight_first,highlight_last:adminCommentsL10n.hotkeys_highlight_last,prev_page_link_cb:e("prev"),next_page_link_cb:e("next")})}})})(jQuery);worsethanhitler/wp-admin/js/slug.js0000644001761300176130000000257711225331455020210 0ustar mustardamustardafunction edit_permalink(a){var d,h=0,g=jQuery("#editable-post-name"),j=g.html(),m=jQuery("#post_name"),n=m.html(),k=jQuery("#edit-slug-buttons"),l=k.html(),f=jQuery("#editable-post-name-full").html();jQuery("#view-post-btn").hide();k.html(''+slugL10n.save+' '+slugL10n.cancel+"");k.children(".save").click(function(){var b=g.children("input").val();jQuery.post(slugL10n.requestFile,{action:"sample-permalink",post_id:a,new_slug:b,new_title:jQuery("#title").val(),samplepermalinknonce:jQuery("#samplepermalinknonce").val()},function(c){jQuery("#edit-slug-box").html(c);k.html(l);m.attr("value",b);make_slugedit_clickable();jQuery("#view-post-btn").show()});return false});jQuery("#edit-slug-buttons .cancel").click(function(){jQuery("#view-post-btn").show();g.html(j);k.html(l);m.attr("value",n);return false});for(d=0;df.length/4)?"":f;g.html('').children("input").keypress(function(c){var b=c.charCode?c.charCode:c.keyCode?c.keyCode:0;if(13==b){k.children(".save").click();return false}if(27==b){k.children(".cancel").click();return false}m.attr("value",this.value)}).focus()}function make_slugedit_clickable(){jQuery("#editable-post-name").click(function(){jQuery("#edit-slug-buttons").children(".edit-slug").click()})};worsethanhitler/wp-admin/js/theme-preview.dev.js0000644001761300176130000000353011225331455022562 0ustar mustardamustarda var thickDims, tbWidth, tbHeight; jQuery(document).ready(function($) { thickDims = function() { var tbWindow = $('#TB_window'), H = $(window).height(), W = $(window).width(), w, h; w = (tbWidth && tbWidth < W - 90) ? tbWidth : W - 90; h = (tbHeight && tbHeight < H - 60) ? tbHeight : H - 60; if ( tbWindow.size() ) { tbWindow.width(w).height(h); $('#TB_iframeContent').width(w).height(h - 27); tbWindow.css({'margin-left': '-' + parseInt((w / 2),10) + 'px'}); if ( typeof document.body.style.maxWidth != 'undefined' ) tbWindow.css({'top':'30px','margin-top':'0'}); } }; thickDims(); $(window).resize( function() { thickDims() } ); $('a.thickbox-preview').click( function() { var alink = $(this).parents('.available-theme').find('.activatelink'), link = '', href = $(this).attr('href'), url, text; if ( tbWidth = href.match(/&tbWidth=[0-9]+/) ) tbWidth = parseInt(tbWidth[0].replace(/[^0-9]+/g, ''), 10); else tbWidth = $(window).width() - 90; if ( tbHeight = href.match(/&tbHeight=[0-9]+/) ) tbHeight = parseInt(tbHeight[0].replace(/[^0-9]+/g, ''), 10); else tbHeight = $(window).height() - 60; if ( alink.length ) { url = alink.attr('href') || ''; text = alink.attr('title') || ''; link = '  ' + text + ''; } else { text = $(this).attr('title') || ''; link = '  ' + text + ''; } $('#TB_title').css({'background-color':'#222','color':'#dfdfdf'}); $('#TB_closeAjaxWindow').css({'float':'left'}); $('#TB_ajaxWindowTitle').css({'float':'right'}).html(link); $('#TB_iframeContent').width('100%'); thickDims(); return false; } ); // Theme details $('.theme-detail').click(function () { $(this).siblings('.themedetaildiv').toggle(); return false; }); }); worsethanhitler/wp-admin/js/theme-preview.js0000644001761300176130000000267611225331455022017 0ustar mustardamustardavar thickDims,tbWidth,tbHeight;jQuery(document).ready(function(a){thickDims=function(){var f=a("#TB_window"),d=a(window).height(),b=a(window).width(),c,e;c=(tbWidth&&tbWidth'+f+""}else{f=a(this).attr("title")||"";e='  '+f+""}a("#TB_title").css({"background-color":"#222",color:"#dfdfdf"});a("#TB_closeAjaxWindow").css({"float":"left"});a("#TB_ajaxWindowTitle").css({"float":"right"}).html(e);a("#TB_iframeContent").width("100%");thickDims();return false});a(".theme-detail").click(function(){a(this).siblings(".themedetaildiv").toggle();return false})});worsethanhitler/wp-admin/js/media-upload.js0000644001761300176130000000270211225331455021565 0ustar mustardamustardafunction send_to_editor(b){var a;if(typeof tinyMCE!="undefined"&&(a=tinyMCE.activeEditor)&&!a.isHidden()){a.focus();if(tinymce.isIE){a.selection.moveToBookmark(tinymce.EditorManager.activeEditor.windowManager.bookmark)}if(b.indexOf("[caption")===0){if(a.plugins.wpeditimage){b=a.plugins.wpeditimage._do_shcode(b)}}else{if(b.indexOf("[gallery")===0){if(a.plugins.wpgallery){b=a.plugins.wpgallery._do_gallery(b)}}}a.execCommand("mceInsertContent",false,b)}else{if(typeof edInsertContent=="function"){edInsertContent(edCanvas,b)}else{jQuery(edCanvas).val(jQuery(edCanvas).val()+b)}}tb_remove()}var tb_position;(function(a){tb_position=function(){var e=a("#TB_window"),d=a(window).width(),c=a(window).height(),b=(720' ).text( name ); } ); } ); }; $('#categorychecklist').wpList( { alt: '', what: 'link-category', response: 'category-ajax-response', addAfter: catAddAfter } ); $('a[href="#categories-all"]').click(function(){deleteUserSetting('cats');}); $('a[href="#categories-pop"]').click(function(){setUserSetting('cats','pop');}); if ( 'pop' == getUserSetting('cats') ) $('a[href="#categories-pop"]').click(); $('#category-add-toggle').click( function() { $(this).parents('div:first').toggleClass( 'wp-hidden-children' ); $('#category-tabs a[href="#categories-all"]').click(); return false; } ); $('.categorychecklist :checkbox').change( syncChecks ).filter( ':checked' ).change(); }); worsethanhitler/wp-admin/js/tags.dev.js0000644001761300176130000000201611225331455020735 0ustar mustardamustardajQuery(document).ready(function($) { var options = false, addAfter, addAfter2, delBefore, delAfter; addAfter = function( r, settings ) { var name = $("" + $('name', r).text() + "").html(), id = $('tag', r).attr('id'); options[options.length] = new Option(name, id); } addAfter2 = function( x, r ) { var t = $(r.parsed.responses[0].data); if ( t.length == 1 ) inlineEditTax.addEvents($(t.id)); } delAfter = function( r, settings ) { var id = $('tag', r).attr('id'), o; for ( o = 0; o < options.length; o++ ) if ( id == options[o].value ) options[o] = null; } delBefore = function(s) { s.data.taxonomy = $('input[name="taxonomy"]').val(); if ( 'undefined' != showNotice ) return showNotice.warn() ? s : false; return s; } if ( options ) $('#the-list').wpList( { addAfter: addAfter, delBefore: delBefore, delAfter: delAfter } ); else $('#the-list').wpList({ addAfter: addAfter2, delBefore: delBefore }); $('.delete a[class^="delete"]').click(function(){return false;}); });worsethanhitler/wp-admin/update.php0000644001761300176130000001560511225331455020253 0ustar mustardamustardaupgrade($plugin); include('admin-footer.php'); } elseif ('activate-plugin' == $action ) { if ( ! current_user_can('update_plugins') ) wp_die(__('You do not have sufficient permissions to update plugins for this blog.')); check_admin_referer('activate-plugin_' . $plugin); if( ! isset($_GET['failure']) && ! isset($_GET['success']) ) { wp_redirect( 'update.php?action=activate-plugin&failure=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce'] ); activate_plugin($plugin); wp_redirect( 'update.php?action=activate-plugin&success=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce'] ); die(); } iframe_header( __('Plugin Reactivation'), true ); if( isset($_GET['success']) ) echo '

' . __('Plugin reactivated successfully.') . '

'; if( isset($_GET['failure']) ){ echo '

' . __('Plugin failed to reactivate due to a fatal error.') . '

'; error_reporting( E_ALL ^ E_NOTICE ); @ini_set('display_errors', true); //Ensure that Fatal errors are displayed. include(WP_PLUGIN_DIR . '/' . $plugin); } iframe_footer(); } elseif ( 'install-plugin' == $action ) { if ( ! current_user_can('install_plugins') ) wp_die(__('You do not have sufficient permissions to install plugins for this blog.')); include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api.. 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); $title = __('Plugin Install'); $parent_file = 'plugins.php'; $submenu_file = 'plugin-install.php'; require_once('admin-header.php'); $title = sprintf( __('Installing Plugin: %s'), $api->name . ' ' . $api->version ); $nonce = 'install-plugin_' . $plugin; $url = 'update.php?action=install-plugin&plugin=' . $plugin; $type = 'web'; //Install plugin type, From Web or an Upload. $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) ); $upgrader->install($api->download_link); include('admin-footer.php'); } elseif ( 'upload-plugin' == $action ) { if ( ! current_user_can('install_plugins') ) wp_die(__('You do not have sufficient permissions to install plugins for this blog.')); check_admin_referer('plugin-upload'); $file_upload = new File_Upload_Upgrader('pluginzip', 'package'); $title = __('Upload Plugin'); $parent_file = 'plugins.php'; $submenu_file = 'plugin-install.php'; require_once('admin-header.php'); $title = sprintf( __('Installing Plugin from uploaded file: %s'), basename( $file_upload->filename ) ); $nonce = 'plugin-upload'; $url = add_query_arg(array('package' => $file_upload->filename ), 'update.php?action=upload-plugin'); $type = 'upload'; //Install plugin type, From Web or an Upload. $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('type', 'title', 'nonce', 'url') ) ); $upgrader->install( $file_upload->package ); include('admin-footer.php'); } elseif ( 'upgrade-theme' == $action ) { if ( ! current_user_can('update_themes') ) wp_die(__('You do not have sufficient permissions to update themes for this blog.')); check_admin_referer('upgrade-theme_' . $theme); add_thickbox(); wp_enqueue_script('theme-preview'); $title = __('Upgrade Theme'); $parent_file = 'themes.php'; $submenu_file = 'themes.php'; require_once('admin-header.php'); $nonce = 'upgrade-theme_' . $theme; $url = 'update.php?action=upgrade-theme&theme=' . $theme; $upgrader = new Theme_Upgrader( new Theme_Upgrader_Skin( compact('title', 'nonce', 'url', 'theme') ) ); $upgrader->upgrade($theme); include('admin-footer.php'); } elseif ( 'install-theme' == $action ) { if ( ! current_user_can('install_themes') ) wp_die(__('You do not have sufficient permissions to install themes for this blog.')); include_once ABSPATH . 'wp-admin/includes/theme-install.php'; //for themes_api.. check_admin_referer('install-theme_' . $theme); $api = themes_api('theme_information', array('slug' => $theme, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth. if ( is_wp_error($api) ) wp_die($api); add_thickbox(); wp_enqueue_script('theme-preview'); $title = __('Install Themes'); $parent_file = 'themes.php'; $submenu_file = 'theme-install.php'; require_once('admin-header.php'); $title = sprintf( __('Installing theme: %s'), $api->name . ' ' . $api->version ); $nonce = 'install-theme_' . $theme; $url = 'update.php?action=install-theme&theme=' . $theme; $type = 'web'; //Install theme type, From Web or an Upload. $upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) ); $upgrader->install($api->download_link); include('admin-footer.php'); } elseif ( 'upload-theme' == $action ) { if ( ! current_user_can('install_themes') ) wp_die(__('You do not have sufficient permissions to install themes for this blog.')); check_admin_referer('theme-upload'); $file_upload = new File_Upload_Upgrader('themezip', 'package'); $title = __('Upload Theme'); $parent_file = 'themes.php'; $submenu_file = 'theme-install.php'; add_thickbox(); wp_enqueue_script('theme-preview'); require_once('admin-header.php'); $title = sprintf( __('Installing Theme from uploaded file: %s'), basename( $file_upload->filename ) ); $nonce = 'theme-upload'; $url = add_query_arg(array('package' => $file_upload->filename), 'update.php?action=upload-theme'); $type = 'upload'; //Install plugin type, From Web or an Upload. $upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('type', 'title', 'nonce', 'url') ) ); $upgrader->install( $file_upload->package ); include('admin-footer.php'); } else { do_action('update-custom_' . $action); } }worsethanhitler/wp-admin/revision.php0000644001761300176130000001425511225331455020627 0ustar mustardamustardapost_parent ) ) break; if ( !$post = get_post( $revision->post_parent ) ) break; if ( !constant('WP_POST_REVISIONS') && !wp_is_post_autosave( $revision ) ) // Revisions disabled and we're not looking at an autosave break; check_admin_referer( "restore-post_$post->ID|$revision->ID" ); wp_restore_post_revision( $revision->ID ); $redirect = add_query_arg( array( 'message' => 5, 'revision' => $revision->ID ), get_edit_post_link( $post->ID, 'url' ) ); break; case 'diff' : if ( !$left_revision = get_post( $left ) ) break; if ( !$right_revision = get_post( $right ) ) break; if ( !current_user_can( 'read_post', $left_revision->ID ) || !current_user_can( 'read_post', $right_revision->ID ) ) break; // If we're comparing a revision to itself, redirect to the 'view' page for that revision or the edit page for that post if ( $left_revision->ID == $right_revision->ID ) { $redirect = get_edit_post_link( $left_revision->ID ); include( 'js/revisions-js.php' ); break; } // Don't allow reverse diffs? if ( strtotime($right_revision->post_modified_gmt) < strtotime($left_revision->post_modified_gmt) ) { $redirect = add_query_arg( array( 'left' => $right, 'right' => $left ) ); break; } if ( $left_revision->ID == $right_revision->post_parent ) // right is a revision of left $post =& $left_revision; elseif ( $left_revision->post_parent == $right_revision->ID ) // left is a revision of right $post =& $right_revision; elseif ( $left_revision->post_parent == $right_revision->post_parent ) // both are revisions of common parent $post = get_post( $left_revision->post_parent ); else break; // Don't diff two unrelated revisions if ( !constant('WP_POST_REVISIONS') ) { // Revisions disabled if ( // we're not looking at an autosave ( !wp_is_post_autosave( $left_revision ) && !wp_is_post_autosave( $right_revision ) ) || // we're not comparing an autosave to the current post ( $post->ID !== $left_revision->ID && $post->ID !== $right_revision->ID ) ) break; } if ( // They're the same $left_revision->ID == $right_revision->ID || // Neither is a revision ( !wp_get_post_revision( $left_revision->ID ) && !wp_get_post_revision( $right_revision->ID ) ) ) break; $post_title = '' . get_the_title() . ''; $h2 = sprintf( __( 'Compare Revisions of “%1$s”' ), $post_title ); $left = $left_revision->ID; $right = $right_revision->ID; $redirect = false; break; case 'view' : default : if ( !$revision = wp_get_post_revision( $revision_id ) ) break; if ( !$post = get_post( $revision->post_parent ) ) break; if ( !current_user_can( 'read_post', $revision->ID ) || !current_user_can( 'read_post', $post->ID ) ) break; if ( !constant('WP_POST_REVISIONS') && !wp_is_post_autosave( $revision ) ) // Revisions disabled and we're not looking at an autosave break; $post_title = '' . get_the_title() . ''; $revision_title = wp_post_revision_title( $revision, false ); $h2 = sprintf( __( 'Post Revision for “%1$s” created on %2$s' ), $post_title, $revision_title ); // Sets up the diff radio buttons $left = $revision->ID; $right = $post->ID; $redirect = false; break; endswitch; if ( !$redirect && !in_array( $post->post_type, array( 'post', 'page' ) ) ) $redirect = 'edit.php'; if ( $redirect ) { wp_redirect( $redirect ); exit; } if ( 'page' == $post->post_type ) { $submenu_file = 'edit-pages.php'; $title = __( 'Page Revisions' ); } else { $submenu_file = 'edit.php'; $title = __( 'Post Revisions' ); } require_once( 'admin-header.php' ); ?>

$field_title ) : if ( 'diff' == $action ) { $left_content = apply_filters( "_wp_post_revision_field_$field", $left_revision->$field, $field ); $right_content = apply_filters( "_wp_post_revision_field_$field", $right_revision->$field, $field ); if ( !$content = wp_text_diff( $left_content, $right_content ) ) continue; // There is no difference between left and right $identical = false; } else { add_filter( "_wp_post_revision_field_$field", 'htmlspecialchars' ); $content = apply_filters( "_wp_post_revision_field_$field", $revision->$field, $field ); } ?>


'form-table', 'parent' => true, 'right' => $right, 'left' => $left ); if ( !constant( 'WP_POST_REVISIONS' ) ) $args['type'] = 'autosave'; wp_list_post_revisions( $post, $args ); ?>


0, 'name' => 'default_category', 'orderby' => 'name', 'selected' => get_option('default_category'), 'hierarchical' => true)); ?>
0, 'name' => 'default_link_category', 'orderby' => 'name', 'selected' => get_option('default_link_category'), 'hierarchical' => true, 'type' => 'link')); ?>



%s, %s, %s.'), wp_generate_password(8, false), wp_generate_password(8, false), wp_generate_password(8, false)) ?>

0, 'name' => 'default_email_category', 'orderby' => 'name', 'selected' => get_option('default_email_category'), 'hierarchical' => true)); ?>

Update Services because of your blog’s privacy settings.'), 'options-privacy.php'); ?>

worsethanhitler/wp-admin/post.php0000644001761300176130000001503411225331455017752 0ustar mustardamustardaID) ) wp_die( __('You attempted to edit a post that doesn’t exist. Perhaps it was deleted?') ); if ( 'post' != $post->post_type ) { wp_redirect( get_edit_post_link( $post->ID, 'url' ) ); exit(); } wp_enqueue_script('post'); if ( user_can_richedit() ) wp_enqueue_script('editor'); add_thickbox(); wp_enqueue_script('media-upload'); wp_enqueue_script('word-count'); wp_enqueue_script( 'admin-comments' ); enqueue_comment_hotkeys_js(); if ( current_user_can('edit_post', $post_ID) ) { if ( $last = wp_check_post_lock( $post->ID ) ) { $last_user = get_userdata( $last ); $last_user_name = $last_user ? $last_user->display_name : __('Somebody'); $message = sprintf( __( 'Warning: %s is currently editing this post' ), esc_html( $last_user_name ) ); $message = str_replace( "'", "\'", "

$message

" ); add_action('admin_notices', create_function( '', "echo '$message';" ) ); } else { wp_set_post_lock( $post->ID ); wp_enqueue_script('autosave'); } } $title = __('Edit Post'); if ( !current_user_can('edit_post', $post_ID) ) die ( __('You are not allowed to edit this post.') ); $post = get_post_to_edit($post_ID); include('edit-form-advanced.php'); break; case 'editattachment': $post_id = (int) $_POST['post_ID']; check_admin_referer('update-attachment_' . $post_id); // Don't let these be changed unset($_POST['guid']); $_POST['post_type'] = 'attachment'; // Update the thumbnail filename $newmeta = wp_get_attachment_metadata( $post_id, true ); $newmeta['thumb'] = $_POST['thumb']; wp_update_attachment_metadata( $post_id, $newmeta ); case 'editpost': $post_ID = (int) $_POST['post_ID']; check_admin_referer('update-post_' . $post_ID); $post_ID = edit_post(); redirect_post($post_ID); // Send user on their way while we keep working exit(); break; case 'delete': $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']); check_admin_referer('delete-post_' . $post_id); $post = & get_post($post_id); if ( !current_user_can('delete_post', $post_id) ) wp_die( __('You are not allowed to delete this post.') ); if ( $post->post_type == 'attachment' ) { if ( ! wp_delete_attachment($post_id) ) wp_die( __('Error in deleting...') ); } else { if ( !wp_delete_post($post_id) ) wp_die( __('Error in deleting...') ); } $sendback = wp_get_referer(); if (strpos($sendback, 'post.php') !== false) $sendback = admin_url('edit.php?deleted=1'); elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php'); else $sendback = add_query_arg('deleted', 1, $sendback); wp_redirect($sendback); exit(); break; case 'preview': check_admin_referer( 'autosave', 'autosavenonce' ); $url = post_preview(); wp_redirect($url); exit(); break; default: wp_redirect('edit.php'); exit(); break; } // end switch include('admin-footer.php'); ?> worsethanhitler/wp-admin/edit-link-category-form.php0000644001761300176130000000566211225331455023427 0ustar mustardamustarda' . __('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); ?>

worsethanhitler/wp-admin/plugin-editor.php0000644001761300176130000002032311225331455021544 0ustar mustardamustarda'.__('You do not have sufficient permissions to edit templates for this blog.').'

'); $newcontent = stripslashes($_POST['newcontent']); if ( is_writeable($real_file) ) { $f = fopen($real_file, 'w+'); fwrite($f, $newcontent); fclose($f); // Deactivate so we can test it. if ( is_plugin_active($file) || isset($_POST['phperror']) ) { if ( is_plugin_active($file) ) deactivate_plugins($file, true); wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1")); exit; } wp_redirect("plugin-editor.php?file=$file&a=te"); } else { wp_redirect("plugin-editor.php?file=$file"); } exit; break; default: if ( !current_user_can('edit_plugins') ) wp_die('

'.__('You do not have sufficient permissions to edit plugins for this blog.').'

'); if ( isset($_GET['liveupdate']) ) { check_admin_referer('edit-plugin-test_' . $file); $error = validate_plugin($file); if ( is_wp_error($error) ) wp_die( $error ); if ( ! is_plugin_active($file) ) activate_plugin($file, "plugin-editor.php?file=$file&phperror=1"); // we'll override this later if the plugin can be included without fatal error wp_redirect("plugin-editor.php?file=$file&a=te"); exit; } if ( use_codepress() ) wp_enqueue_script( 'codepress' ); // List of allowable extensions $editable_extensions = array('php', 'txt', 'text', 'js', 'css', 'html', 'htm', 'xml', 'inc', 'include'); $editable_extensions = (array) apply_filters('editable_extensions', $editable_extensions); if ( ! is_file($real_file) ) { wp_die(sprintf('

%s

', __('No such file exists! Double check the name and try again.'))); } else { // Get the extension of the file if ( preg_match('/\.([^.]+)$/', $real_file, $matches) ) { $ext = strtolower($matches[1]); // If extension is not in the acceptable list, skip it if ( !in_array( $ext, $editable_extensions) ) wp_die(sprintf('

%s

', __('Files of this type are not editable.'))); } } require_once('admin-header.php'); update_recently_edited(WP_PLUGIN_DIR . '/' . $file); $content = file_get_contents( $real_file ); if ( '.php' == substr( $real_file, strrpos( $real_file, '.' ) ) ) { $functions = wp_doc_link_parse( $content ); $docs_select = ''; } $content = htmlspecialchars( $content ); $codepress_lang = codepress_get_lang($real_file); ?>

fatal error.') ?>

%s (active)'), $file); else echo sprintf(__('Browsing %s (active)'), $file); } else { if ( is_writeable($real_file) ) echo sprintf(__('Editing %s (inactive)'), $file); else echo sprintf(__('Browsing %s (inactive)'), $file); } ?>


    >

Warning: Making changes to active plugins is not recommended. If your changes cause a fatal error, the plugin will be automatically deactivated.'); ?>

"; else echo ""; ?>

the Codex for more information.'); ?>

 
worsethanhitler/wp-admin/edit-category-form.php0000644001761300176130000000662411225331455022473 0ustar mustardamustardaname ) ) $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'))); ?>

worsethanhitler/wp-admin/load-styles.php0000644001761300176130000000551511225331455021230 0ustar mustardamustardaregistered) ) continue; $style = $wp_styles->registered[$handle]; $path = ABSPATH . $style->src; $content = get_file($path) . "\n"; if ( $rtl && isset($style->extra['rtl']) && $style->extra['rtl'] ) { $rtl_path = is_bool($style->extra['rtl']) ? str_replace( '.css', '-rtl.css', $path ) : ABSPATH . $style->extra['rtl']; $content .= get_file($rtl_path) . "\n"; } $out .= str_replace( '../images/', 'images/', $content ); } header('Content-Type: text/css'); header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT'); header("Cache-Control: public, max-age=$expires_offset"); if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') ) { header('Vary: Accept-Encoding'); // Handle proxies if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) { header('Content-Encoding: deflate'); $out = gzdeflate( $out, 3 ); } elseif ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') && function_exists('gzencode') ) { header('Content-Encoding: gzip'); $out = gzencode( $out, 3 ); } } echo $out; exit; worsethanhitler/wp-admin/export.php0000644001761300176130000000331111225331455020301 0ustar mustardamustarda

worsethanhitler/wp-admin/admin.php0000644001761300176130000001010611225331455020050 0ustar mustardamustardaflush_rules(); update_option( 'db_upgraded', false ); /** * Runs on the next page load after successful upgrade * * @since 2.8 */ do_action('after_db_upgrade'); } elseif ( get_option('db_version') != $wp_db_version ) { wp_redirect(admin_url('upgrade.php?_wp_http_referer=' . urlencode(stripslashes($_SERVER['REQUEST_URI'])))); exit; } require_once(ABSPATH . 'wp-admin/includes/admin.php'); auth_redirect(); nocache_headers(); update_category_cache(); set_screen_options(); $posts_per_page = get_option('posts_per_page'); $date_format = get_option('date_format'); $time_format = get_option('time_format'); wp_reset_vars(array('profile', 'redirect', 'redirect_url', 'a', 'popuptitle', 'popupurl', 'text', 'trackback', 'pingback')); wp_admin_css_color('classic', __('Blue'), admin_url("css/colors-classic.css"), array('#073447', '#21759B', '#EAF3FA', '#BBD8E7')); wp_admin_css_color('fresh', __('Gray'), admin_url("css/colors-fresh.css"), array('#464646', '#6D6D6D', '#F1F1F1', '#DFDFDF')); wp_enqueue_script( 'common' ); wp_enqueue_script( 'jquery-color' ); $editing = false; if (isset($_GET['page'])) { $plugin_page = stripslashes($_GET['page']); $plugin_page = plugin_basename($plugin_page); } require(ABSPATH . 'wp-admin/menu.php'); do_action('admin_init'); // Handle plugin admin pages. if (isset($plugin_page)) { if( ! $page_hook = get_plugin_page_hook($plugin_page, $pagenow) ) { $page_hook = get_plugin_page_hook($plugin_page, $plugin_page); // backwards compatibility for plugins using add_management_page if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' != get_plugin_page_hook($plugin_page, 'tools.php') ) { // There could be plugin specific params on the URL, so we need the whole query string if ( !empty($_SERVER[ 'QUERY_STRING' ]) ) $query_string = $_SERVER[ 'QUERY_STRING' ]; else $query_string = 'page=' . $plugin_page; wp_redirect( 'tools.php?' . $query_string ); exit; } } if ( $page_hook ) { do_action('load-' . $page_hook); if (! isset($_GET['noheader'])) require_once(ABSPATH . 'wp-admin/admin-header.php'); do_action($page_hook); } else { if ( validate_file($plugin_page) ) { wp_die(__('Invalid plugin page')); } if (! ( file_exists(WP_PLUGIN_DIR . "/$plugin_page") && is_file(WP_PLUGIN_DIR . "/$plugin_page") ) ) wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page))); do_action('load-' . $plugin_page); if (! isset($_GET['noheader'])) require_once(ABSPATH . 'wp-admin/admin-header.php'); include(WP_PLUGIN_DIR . "/$plugin_page"); } include(ABSPATH . 'wp-admin/admin-footer.php'); exit(); } else if (isset($_GET['import'])) { $importer = $_GET['import']; if ( ! current_user_can('import') ) wp_die(__('You are not allowed to import.')); if ( validate_file($importer) ) { wp_die(__('Invalid importer.')); } // Allow plugins to define importers as well if ( !isset($wp_importers) || !isset($wp_importers[$importer]) || ! is_callable($wp_importers[$importer][2])) { if (! file_exists(ABSPATH . "wp-admin/import/$importer.php")) { wp_die(__('Cannot load importer.')); } include(ABSPATH . "wp-admin/import/$importer.php"); } $parent_file = 'tools.php'; $submenu_file = 'import.php'; $title = __('Import'); if (! isset($_GET['noheader'])) require_once(ABSPATH . 'wp-admin/admin-header.php'); require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); define('WP_IMPORTING', true); call_user_func($wp_importers[$importer][2]); include(ABSPATH . 'wp-admin/admin-footer.php'); // Make sure rules are flushed global $wp_rewrite; $wp_rewrite->flush_rules(); exit(); } else { do_action("load-$pagenow"); } if ( !empty($_REQUEST['action']) ) do_action('admin_action_' . $_REQUEST['action']); ?> worsethanhitler/wp-admin/import/livejournal.php0000644001761300176130000012024011225331455022625 0ustar mustardamustarda 'aggravated', '10' => 'discontent', '100' => 'rushed', '101' => 'contemplative', '102' => 'nerdy', '103' => 'geeky', '104' => 'cynical', '105' => 'quixotic', '106' => 'crazy', '107' => 'creative', '108' => 'artistic', '109' => 'pleased', '11' => 'energetic', '110' => 'bitchy', '111' => 'guilty', '112' => 'irritated', '113' => 'blank', '114' => 'apathetic', '115' => 'dorky', '116' => 'impressed', '117' => 'naughty', '118' => 'predatory', '119' => 'dirty', '12' => 'enraged', '120' => 'giddy', '121' => 'surprised', '122' => 'shocked', '123' => 'rejected', '124' => 'numb', '125' => 'cheerful', '126' => 'good', '127' => 'distressed', '128' => 'intimidated', '129' => 'crushed', '13' => 'enthralled', '130' => 'devious', '131' => 'thankful', '132' => 'grateful', '133' => 'jealous', '134' => 'nervous', '14' => 'exhausted', '15' => 'happy', '16' => 'high', '17' => 'horny', '18' => 'hungry', '19' => 'infuriated', '2' => 'angry', '20' => 'irate', '21' => 'jubilant', '22' => 'lonely', '23' => 'moody', '24' => 'pissed off', '25' => 'sad', '26' => 'satisfied', '27' => 'sore', '28' => 'stressed', '29' => 'thirsty', '3' => 'annoyed', '30' => 'thoughtful', '31' => 'tired', '32' => 'touched', '33' => 'lazy', '34' => 'drunk', '35' => 'ditzy', '36' => 'mischievous', '37' => 'morose', '38' => 'gloomy', '39' => 'melancholy', '4' => 'anxious', '40' => 'drained', '41' => 'excited', '42' => 'relieved', '43' => 'hopeful', '44' => 'amused', '45' => 'determined', '46' => 'scared', '47' => 'frustrated', '48' => 'indescribable', '49' => 'sleepy', '5' => 'bored', '51' => 'groggy', '52' => 'hyper', '53' => 'relaxed', '54' => 'restless', '55' => 'disappointed', '56' => 'curious', '57' => 'mellow', '58' => 'peaceful', '59' => 'bouncy', '6' => 'confused', '60' => 'nostalgic', '61' => 'okay', '62' => 'rejuvenated', '63' => 'complacent', '64' => 'content', '65' => 'indifferent', '66' => 'silly', '67' => 'flirty', '68' => 'calm', '69' => 'refreshed', '7' => 'crappy', '70' => 'optimistic', '71' => 'pessimistic', '72' => 'giggly', '73' => 'pensive', '74' => 'uncomfortable', '75' => 'lethargic', '76' => 'listless', '77' => 'recumbent', '78' => 'exanimate', '79' => 'embarrassed', '8' => 'cranky', '80' => 'envious', '81' => 'sympathetic', '82' => 'sick', '83' => 'hot', '84' => 'cold', '85' => 'worried', '86' => 'loved', '87' => 'awake', '88' => 'working', '89' => 'productive', '9' => 'depressed', '90' => 'accomplished', '91' => 'busy', '92' => 'blah', '93' => 'full', '95' => 'grumpy', '96' => 'weird', '97' => 'nauseated', '98' => 'ecstatic', '99' => 'chipper' ); function header() { echo '
'; screen_icon(); echo '

' . __( 'Import LiveJournal' ) . '

'; } function footer() { echo '
'; } function greet() { ?>

WARNING: This can take a really long time if you have a lot of entries in your LiveJournal, or a lot of comments. Ideally, you should only start this process if you can leave your computer alone while it finishes the import." ) ?>

NOTE: If the import process is interrupted for any reason, come back to this page and it will continue from where it stopped automatically.' ) ?>

lj_ixr( 'syncitems', array( 'ver' => 1, 'lastsync' => $lastsync ) ); if ( is_wp_error( $synclist ) ) return $synclist; // Keep track of if we've downloaded everything $total = $synclist['total']; $count = $synclist['count']; foreach ( $synclist['syncitems'] as $event ) { if ( substr( $event['item'], 0, 2 ) == 'L-' ) { $sync_item_times[ str_replace( 'L-', '', $event['item'] ) ] = $event['time']; if ( $event['time'] > $lastsync ) { $lastsync = $event['time']; update_option( 'ljapi_lastsync', $lastsync ); } } } } while ( $total > $count ); // endwhile - all post meta is cached locally unset( $synclist ); update_option( 'ljapi_sync_item_times', $sync_item_times ); update_option( 'ljapi_total', $total ); update_option( 'ljapi_count', $count ); echo '

' . __( 'Post metadata has been downloaded, proceeding with posts...' ) . '

'; } function download_post_bodies() { $imported_count = (int) get_option( 'ljapi_imported_count' ); $sync_item_times = get_option( 'ljapi_sync_item_times' ); $lastsync = get_option( 'ljapi_lastsync_posts' ); if ( !$lastsync ) update_option( 'ljapi_lastsync_posts', date( 'Y-m-d H:i:s', 0 ) ); $count = 0; echo '
    '; do { $lastsync = date( 'Y-m-d H:i:s', strtotime( get_option( 'ljapi_lastsync_posts' ) ) ); // Get the batch of items that match up with the syncitems list $itemlist = $this->lj_ixr( 'getevents', array( 'ver' => 1, 'selecttype' => 'syncitems', 'lineendings' => 'pc', 'lastsync' => $lastsync ) ); if ( is_wp_error( $itemlist ) ) return $itemlist; if ( $num = count( $itemlist['events'] ) ) { for ( $e = 0; $e < count( $itemlist['events'] ); $e++ ) { $event = $itemlist['events'][$e]; $imported_count++; $inserted = $this->import_post( $event ); if ( is_wp_error( $inserted ) ) return $inserted; if ( $sync_item_times[ $event['itemid'] ] > $lastsync ) $lastsync = $sync_item_times[ $event['itemid'] ]; wp_cache_flush(); } update_option( 'ljapi_lastsync_posts', $lastsync ); update_option( 'ljapi_imported_count', $imported_count ); update_option( 'ljapi_last_sync_count', $num ); } $count++; } while ( $num > 0 && $count < 3 ); // Doing up to 3 requests at a time to avoid memory problems // Used so that step1 knows when to stop posting back on itself update_option( 'ljapi_last_sync_count', $num ); // Counter just used to show progress to user update_option( 'ljapi_post_batch', ( (int) get_option( 'ljapi_post_batch' ) + 1 ) ); echo '
'; } function import_post( $post ) { global $wpdb; // Make sure we haven't already imported this one if ( $this->get_wp_post_ID( $post['itemid'] ) ) return; $user = wp_get_current_user(); $post_author = $user->ID; $post['security'] = !empty( $post['security'] ) ? $post['security'] : ''; $post_status = ( 'private' == trim( $post['security'] ) ) ? 'private' : 'publish'; // Only me $post_password = ( 'usemask' == trim( $post['security'] ) ) ? $this->protected_password : ''; // "Friends" via password // For some reason, LJ sometimes sends a date as "2004-04-1408:38:00" (no space btwn date/time) $post_date = $post['eventtime']; if ( 18 == strlen( $post_date ) ) $post_date = substr( $post_date, 0, 10 ) . ' ' . substr( $post_date, 10 ); // Cleaning up and linking the title $post_title = isset( $post['subject'] ) ? trim( $post['subject'] ) : ''; $post_title = $this->translate_lj_user( $post_title ); // Translate it, but then we'll strip the link $post_title = strip_tags( $post_title ); // Can't have tags in the title in WP $post_title = $wpdb->escape( $post_title ); // Clean up content $post_content = $post['event']; $post_content = preg_replace_callback( '|<(/?[A-Z]+)|', create_function( '$match', 'return "<" . strtolower( $match[1] );' ), $post_content ); // XHTMLize some tags $post_content = str_replace( '
', '
', $post_content ); $post_content = str_replace( '
', '
', $post_content ); // lj-cut ==> $post_content = preg_replace( '||is', '', $post_content ); $post_content = str_replace( array( '', '' ), array( '', '' ), $post_content ); $first = strpos( $post_content, '|sUi', '', substr( $post_content, $first + 1 ) ); // lj-user ==> a href $post_content = $this->translate_lj_user( $post_content ); //$post_content = force_balance_tags( $post_content ); $post_content = $wpdb->escape( $post_content ); // Handle any tags associated with the post $tags_input = !empty( $post['props']['taglist'] ) ? $post['props']['taglist'] : ''; // Check if comments are closed on this post $comment_status = !empty( $post['props']['opt_nocomments'] ) ? 'closed' : 'open'; echo '
  • '; if ( $post_id = post_exists( $post_title, $post_content, $post_date ) ) { printf( __( 'Post %s already exists.' ), stripslashes( $post_title ) ); } else { printf( __( 'Imported post %s...' ), stripslashes( $post_title ) ); $postdata = compact( 'post_author', 'post_date', 'post_content', 'post_title', 'post_status', 'post_password', 'tags_input', 'comment_status' ); $post_id = wp_insert_post( $postdata, true ); if ( is_wp_error( $post_id ) ) { if ( 'empty_content' == $post_id->get_error_code() ) return; // Silent skip on "empty" posts return $post_id; } if ( !$post_id ) { _e( 'Couldn’t get post ID (creating post failed!)' ); echo '
  • '; return new WP_Error( 'insert_post_failed', __( 'Failed to create post.' ) ); } // Handle all the metadata for this post $this->insert_postmeta( $post_id, $post ); } echo ''; } // Convert lj-user tags to links to that user function translate_lj_user( $str ) { return preg_replace( '||', '$1', $str ); } function insert_postmeta( $post_id, $post ) { // Need the original LJ id for comments add_post_meta( $post_id, 'lj_itemid', $post['itemid'] ); // And save the permalink on LJ in case we want to link back or something add_post_meta( $post_id, 'lj_permalink', $post['url'] ); // Supports the following "props" from LJ, saved as lj_ in wp_postmeta // Adult Content - adult_content // Location - current_coords + current_location // Mood - current_mood (translated from current_moodid) // Music - current_music // Userpic - picture_keyword foreach ( array( 'adult_content', 'current_coords', 'current_location', 'current_moodid', 'current_music', 'picture_keyword' ) as $prop ) { if ( !empty( $post['props'][$prop] ) ) { if ( 'current_moodid' == $prop ) { $prop = 'current_mood'; $val = $this->moods[ $post['props']['current_moodid'] ]; } else { $val = $post['props'][$prop]; } add_post_meta( $post_id, 'lj_' . $prop, $val ); } } } // Set up a session (authenticate) with LJ function get_session() { // Get a session via XMLRPC $cookie = $this->lj_ixr( 'sessiongenerate', array( 'ver' => 1, 'expiration' => 'short' ) ); if ( is_wp_error( $cookie ) ) return new WP_Error( 'cookie', __( 'Could not get a cookie from LiveJournal. Please try again soon.' ) ); return new WP_Http_Cookie( array( 'name' => 'ljsession', 'value' => $cookie['ljsession'] ) ); } // Loops through and gets comment meta from LJ in batches function download_comment_meta() { $cookie = $this->get_session(); if ( is_wp_error( $cookie ) ) return $cookie; // Load previous state (if any) $this->usermap = (array) get_option( 'ljapi_usermap' ); $maxid = get_option( 'ljapi_maxid' ) ? get_option( 'ljapi_maxid' ) : 1; $highest_id = get_option( 'ljapi_highest_id' ) ? get_option( 'ljapi_highest_id' ) : 0; // We need to loop over the metadata request until we have it all while ( $maxid > $highest_id ) { // Now get the meta listing $results = wp_remote_get( $this->comments_url . '?get=comment_meta&startid=' . ( $highest_id + 1 ), array( 'cookies' => array( $cookie ), 'timeout' => 20 ) ); if ( is_wp_error( $results ) ) return new WP_Error( 'comment_meta', __( 'Failed to retrieve comment meta information from LiveJournal. Please try again soon.' ) ); $results = wp_remote_retrieve_body( $results ); // Get the maxid so we know if we have them all yet preg_match( '|(\d+)|', $results, $matches ); if ( 0 == $matches[1] ) { // No comment meta = no comments for this journal echo '

    ' . __( 'You have no comments to import!' ) . '

    '; update_option( 'ljapi_highest_id', 1 ); update_option( 'ljapi_highest_comment_id', 1 ); return false; // Bail out of comment importing entirely } $maxid = !empty( $matches[1] ) ? $matches[1] : $maxid; // Parse comments and get highest id available preg_match_all( '| $highest_id ) $highest_id = $id; } // Parse out the list of user mappings, and add it to the known list preg_match_all( '||', $results, $matches ); foreach ( $matches[1] as $count => $userid ) $this->usermap[$userid] = $matches[2][$count]; // need this in memory for translating ids => names wp_cache_flush(); } // endwhile - should have seen all comment meta at this point update_option( 'ljapi_usermap', $this->usermap ); update_option( 'ljapi_maxid', $maxid ); update_option( 'ljapi_highest_id', $highest_id ); echo '

    ' . __( ' Comment metadata downloaded successfully, proceeding with comment bodies...' ) . '

    '; return true; } // Downloads actual comment bodies from LJ // Inserts them all directly to the DB, with additional info stored in "spare" fields function download_comment_bodies() { global $wpdb; $cookie = $this->get_session(); if ( is_wp_error( $cookie ) ) return $cookie; // Load previous state (if any) $this->usermap = (array) get_option( 'ljapi_usermap' ); $maxid = get_option( 'ljapi_maxid' ) ? (int) get_option( 'ljapi_maxid' ) : 1; $highest_id = (int) get_option( 'ljapi_highest_comment_id' ); $loop = 0; while ( $maxid > $highest_id && $loop < 5 ) { // We do 5 loops per call to avoid memory limits $loop++; // Get a batch of comments, using the highest_id we've already got as a starting point $results = wp_remote_get( $this->comments_url . '?get=comment_body&startid=' . ( $highest_id + 1 ), array( 'cookies' => array( $cookie ), 'timeout' => 20 ) ); if ( is_wp_error( $results ) ) return new WP_Error( 'comment_bodies', __( 'Failed to retrieve comment bodies from LiveJournal. Please try again soon.' ) ); $results = wp_remote_retrieve_body( $results ); // Parse out each comment and insert directly preg_match_all( '||iUs', $results, $matches ); for ( $c = 0; $c < count( $matches[0] ); $c++ ) { // Keep track of highest id seen if ( $matches[1][$c] > $highest_id ) { $highest_id = $matches[1][$c]; update_option( 'ljapi_highest_comment_id', $highest_id ); } $comment = $matches[0][$c]; // Filter out any captured, deleted comments (nothing useful to import) $comment = preg_replace( '||is', '', $comment ); // Parse this comment into an array and insert $comment = $this->parse_comment( $comment ); $id = wp_insert_comment( $comment ); // Clear cache clean_comment_cache( $id ); } // Clear cache to preseve memory wp_cache_flush(); } // endwhile - all comments downloaded and ready for bulk processing // Counter just used to show progress to user update_option( 'ljapi_comment_batch', ( (int) get_option( 'ljapi_comment_batch' ) + 1 ) ); return true; } // Takes a block of XML and parses out all the elements of the comment function parse_comment( $comment ) { global $wpdb; // Get the top-level attributes preg_match( '|]+)>|i', $comment, $attribs ); preg_match( '| id=\'(\d+)\'|i', $attribs[1], $matches ); $lj_comment_ID = $matches[1]; preg_match( '| jitemid=\'(\d+)\'|i', $attribs[1], $matches ); $lj_comment_post_ID = $matches[1]; preg_match( '| posterid=\'(\d+)\'|i', $attribs[1], $matches ); $comment_author_ID = isset( $matches[1] ) ? $matches[1] : 0; preg_match( '| parentid=\'(\d+)\'|i', $attribs[1], $matches ); // optional $lj_comment_parent = isset( $matches[1] ) ? $matches[1] : 0; preg_match( '| state=\'([SDFA])\'|i', $attribs[1], $matches ); // optional $lj_comment_state = isset( $matches[1] ) ? $matches[1] : 'A'; // Clean up "subject" - this will become the first line of the comment in WP preg_match( '|(.*)|is', $comment, $matches ); if ( isset( $matches[1] ) ) { $comment_subject = $wpdb->escape( trim( $matches[1] ) ); if ( 'Re:' == $comment_subject ) $comment_subject = ''; } // Get the body and HTMLize it preg_match( '|(.*)|is', $comment, $matches ); $comment_content = !empty( $comment_subject ) ? $comment_subject . "\n\n" . $matches[1] : $matches[1]; $comment_content = @html_entity_decode( $comment_content, ENT_COMPAT, get_option('blog_charset') ); $comment_content = str_replace( ''', "'", $comment_content ); $comment_content = wpautop( $comment_content ); $comment_content = str_replace( '
    ', '
    ', $comment_content ); $comment_content = str_replace( '
    ', '
    ', $comment_content ); $comment_content = preg_replace_callback( '|<(/?[A-Z]+)|', create_function( '$match', 'return "<" . strtolower( $match[1] );' ), $comment_content ); $comment_content = $wpdb->escape( trim( $comment_content ) ); // Get and convert the date preg_match( '|(.*)|i', $comment, $matches ); $comment_date = trim( str_replace( array( 'T', 'Z' ), ' ', $matches[1] ) ); // Grab IP if available preg_match( '|(.*)|i', $comment, $matches ); // optional $comment_author_IP = isset( $matches[1] ) ? $matches[1] : ''; // Try to get something useful for the comment author, especially if it was "my" comment $author = ( empty( $comment_author_ID ) || empty( $this->usermap[$comment_author_ID] ) || substr( $this->usermap[$comment_author_ID], 0, 4 ) == 'ext_' ) ? __( 'Anonymous' ) : $this->usermap[$comment_author_ID]; if ( get_option( 'ljapi_username' ) == $author ) { $user = wp_get_current_user(); $user_id = $user->ID; $author = $user->display_name; $url = trailingslashit( get_option( 'home' ) ); } else { $user_id = 0; $url = ( __( 'Anonymous' ) == $author ) ? '' : 'http://' . $author . '.livejournal.com/'; } // Send back the array of details return array( 'lj_comment_ID' => $lj_comment_ID, 'lj_comment_post_ID' => $lj_comment_post_ID, 'lj_comment_parent' => ( !empty( $lj_comment_parent ) ? $lj_comment_parent : 0 ), 'lj_comment_state' => $lj_comment_state, 'comment_post_ID' => $this->get_wp_post_ID( $lj_comment_post_ID ), 'comment_author' => $author, 'comment_author_url' => $url, 'comment_author_email' => '', 'comment_content' => $comment_content, 'comment_date' => $comment_date, 'comment_author_IP' => ( !empty( $comment_author_IP ) ? $comment_author_IP : '' ), 'comment_approved' => ( in_array( $lj_comment_state, array( 'A', 'F' ) ) ? 1 : 0 ), 'comment_karma' => $lj_comment_ID, // Need this and next value until rethreading is done 'comment_agent' => $lj_comment_parent, 'comment_type' => 'livejournal', // Custom type, so we can find it later for processing 'user_ID' => $user_id ); } // Gets the post_ID that a LJ post has been saved as within WP function get_wp_post_ID( $post ) { global $wpdb; if ( empty( $this->postmap[$post] ) ) $this->postmap[$post] = (int) $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'lj_itemid' AND meta_value = %d", $post ) ); return $this->postmap[$post]; } // Gets the comment_ID that a LJ comment has been saved as within WP function get_wp_comment_ID( $comment ) { global $wpdb; if ( empty( $this->commentmap[$comment] ) ) $this->commentmap[$comment] = $wpdb->get_var( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_karma = %d", $comment ) ); return $this->commentmap[$comment]; } function lj_ixr() { if ( $challenge = $this->ixr->query( 'LJ.XMLRPC.getchallenge' ) ) { $challenge = $this->ixr->getResponse(); } if ( isset( $challenge['challenge'] ) ) { $params = array( 'username' => $this->username, 'auth_method' => 'challenge', 'auth_challenge' => $challenge['challenge'], 'auth_response' => md5( $challenge['challenge'] . md5( $this->password ) ) ); } else { return new WP_Error( 'IXR', __( 'LiveJournal is not responding to authentication requests. Please wait a while and then try again.' ) ); } $args = func_get_args(); $method = array_shift( $args ); if ( isset( $args[0] ) ) $params = array_merge( $params, $args[0] ); if ( $this->ixr->query( 'LJ.XMLRPC.' . $method, $params ) ) { return $this->ixr->getResponse(); } else { return new WP_Error( 'IXR', __( 'XML-RPC Request Failed -- ' ) . $this->ixr->getErrorCode() . ': ' . $this->ixr->getErrorMessage() ); } } function dispatch() { if ( empty( $_REQUEST['step'] ) ) $step = 0; else $step = (int) $_REQUEST['step']; $this->header(); switch ( $step ) { case -1 : $this->cleanup(); // Intentional no break case 0 : $this->greet(); break; case 1 : case 2 : case 3 : check_admin_referer( 'lj-api-import' ); $result = $this->{ 'step' . $step }(); if ( is_wp_error( $result ) ) { $this->throw_error( $result, $step ); } break; } $this->footer(); } // Technically the first half of step 1, this is separated to allow for AJAX // calls. Sets up some variables and options and confirms authentication. function setup() { global $verified; // Get details from form or from DB if ( !empty( $_POST['lj_username'] ) && !empty( $_POST['lj_password'] ) ) { // Store details for later $this->username = $_POST['lj_username']; $this->password = $_POST['lj_password']; update_option( 'ljapi_username', $this->username ); update_option( 'ljapi_password', $this->password ); } else { $this->username = get_option( 'ljapi_username' ); $this->password = get_option( 'ljapi_password' ); } // This is the password to set on protected posts if ( !empty( $_POST['protected_password'] ) ) { $this->protected_password = $_POST['protected_password']; update_option( 'ljapi_protected_password', $this->protected_password ); } else { $this->protected_password = get_option( 'ljapi_protected_password' ); } // Login to confirm the details are correct if ( empty( $this->username ) || empty( $this->password ) ) { ?>

    and password so we can download your posts and comments.' ) ?>

    lj_ixr( 'login' ); if ( is_wp_error( $verified ) ) { if ( 100 == $this->ixr->getErrorCode() || 101 == $this->ixr->getErrorCode() ) { delete_option( 'ljapi_username' ); delete_option( 'ljapi_password' ); delete_option( 'ljapi_protected_password' ); ?>

    ixr ) $this->ixr = new IXR_Client( $this->ixr_url, false, 80, 30 ); if ( empty( $_POST['login'] ) ) { // We're looping -- load some details from DB $this->username = get_option( 'ljapi_username' ); $this->password = get_option( 'ljapi_password' ); $this->protected_password = get_option( 'ljapi_protected_password' ); } else { // First run (non-AJAX) $setup = $this->setup(); if ( !$setup ) { return false; } else if ( is_wp_error( $setup ) ) { $this->throw_error( $setup, 1 ); return false; } } echo '
    '; echo '

    ' . __( 'Importing Posts' ) . '

    '; echo '

    ' . __( 'We’re downloading and importing your LiveJournal posts...' ) . '

    '; if ( get_option( 'ljapi_post_batch' ) && count( get_option( 'ljapi_sync_item_times' ) ) ) { $batch = count( get_option( 'ljapi_sync_item_times' ) ); $batch = $count > 300 ? ceil( $batch / 300 ) : 1; echo '

    ' . sprintf( __( 'Imported post batch %d of approximately %d' ), ( get_option( 'ljapi_post_batch' ) + 1 ), $batch ) . '

    '; } ob_flush(); flush(); if ( !get_option( 'ljapi_lastsync' ) || '1900-01-01 00:00:00' == get_option( 'ljapi_lastsync' ) ) { // We haven't downloaded meta yet, so do that first $result = $this->download_post_meta(); if ( is_wp_error( $result ) ) { $this->throw_error( $result, 1 ); return false; } } // Download a batch of actual posts $result = $this->download_post_bodies(); if ( is_wp_error( $result ) ) { if ( 406 == $this->ixr->getErrorCode() ) { ?>

    next_step( 1, __( 'Try Again' ) ); return false; } else { $this->throw_error( $result, 1 ); return false; } } if ( get_option( 'ljapi_last_sync_count' ) > 0 ) { ?>

    auto_ajax( 'ljapi-auto-repost', 'auto-message', 0 ); ?> ' . __( 'Your posts have all been imported, but wait – there’s more! Now we need to download & import your comments.' ) . '

    '; echo $this->next_step( 2, __( 'Download my comments »' ) ); $this->auto_submit(); } echo '
    '; } // Download comments to local XML function step2() { set_time_limit( 0 ); update_option( 'ljapi_step', 2 ); $this->username = get_option( 'ljapi_username' ); $this->password = get_option( 'ljapi_password' ); $this->ixr = new IXR_Client( $this->ixr_url, false, 80, 30 ); echo '
    '; echo '

    ' . __( 'Downloading Comments' ) . '

    '; echo '

    ' . __( 'Now we will download your comments so we can import them (this could take a long time if you have lots of comments)...' ) . '

    '; ob_flush(); flush(); if ( !get_option( 'ljapi_usermap' ) ) { // We haven't downloaded meta yet, so do that first $result = $this->download_comment_meta(); if ( is_wp_error( $result ) ) { $this->throw_error( $result, 2 ); return false; } } // Download a batch of actual comments $result = $this->download_comment_bodies(); if ( is_wp_error( $result ) ) { $this->throw_error( $result, 2 ); return false; } $maxid = get_option( 'ljapi_maxid' ) ? (int) get_option( 'ljapi_maxid' ) : 1; $highest_id = (int) get_option( 'ljapi_highest_comment_id' ); if ( $maxid > $highest_id ) { $batch = $maxid > 5000 ? ceil( $maxid / 5000 ) : 1; ?>

    approximately %d' ), get_option( 'ljapi_comment_batch' ), $batch ) ?>

    auto_ajax( 'ljapi-auto-repost', 'auto-message', 0 ); ?> ' . __( 'Your comments have all been imported now, but we still need to rebuild your conversation threads.' ) . '

    '; echo $this->next_step( 3, __( 'Rebuild my comment threads »' ) ); $this->auto_submit(); } echo '
    '; } // Re-thread comments already in the DB function step3() { global $wpdb; set_time_limit( 0 ); update_option( 'ljapi_step', 3 ); echo '
    '; echo '

    ' . __( 'Threading Comments' ) . '

    '; echo '

    ' . __( 'We are now re-building the threading of your comments (this can also take a while if you have lots of comments)...' ) . '

    '; ob_flush(); flush(); // Only bother adding indexes if they have over 5000 comments (arbitrary number) $imported_comments = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->comments} WHERE comment_type = 'livejournal'" ); $added_indices = false; if ( 5000 < $imported_comments ) { include_once(ABSPATH . 'wp-admin/includes/upgrade.php'); $added_indices = true; add_clean_index( $wpdb->comments, 'comment_type' ); add_clean_index( $wpdb->comments, 'comment_karma' ); add_clean_index( $wpdb->comments, 'comment_agent' ); } // Get LJ comments, which haven't been threaded yet, 5000 at a time and thread them while ( $comments = $wpdb->get_results( "SELECT comment_ID, comment_agent FROM {$wpdb->comments} WHERE comment_type = 'livejournal' AND comment_agent != '0' LIMIT 5000", OBJECT ) ) { foreach ( $comments as $comment ) { $wpdb->update( $wpdb->comments, array( 'comment_parent' => $this->get_wp_comment_ID( $comment->comment_agent ), 'comment_type' => 'livejournal-done' ), array( 'comment_ID' => $comment->comment_ID ) ); } wp_cache_flush(); $wpdb->flush(); } // Revert the comments table back to normal and optimize it to reclaim space if ( $added_indices ) { drop_index( $wpdb->comments, 'comment_type' ); drop_index( $wpdb->comments, 'comment_karma' ); drop_index( $wpdb->comments, 'comment_agent' ); $wpdb->query( "OPTIMIZE TABLE {$wpdb->comments}" ); } // Clean up database and we're out $this->cleanup(); do_action( 'import_done', 'livejournal' ); if ( $imported_comments > 1 ) echo '

    ' . sprintf( __( "Successfully re-threaded %s comments." ), number_format( $imported_comments ) ) . '

    '; echo '

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

    '; echo '
    '; } // Output an error message with a button to try again. function throw_error( $error, $step ) { echo '

    ' . $error->get_error_message() . '

    '; echo $this->next_step( $step, __( 'Try Again' ) ); } // Returns the HTML for a link to the next page function next_step( $next_step, $label, $id = 'ljapi-next-form' ) { $str = '
    '; $str .= wp_nonce_field( 'lj-api-import', '_wpnonce', true, false ); $str .= wp_referer_field( false ); $str .= ''; $str .= '

    '; $str .= '
    '; return $str; } // Automatically submit the specified form after $seconds // Include a friendly countdown in the element with id=$msg function auto_submit( $id = 'ljapi-next-form', $msg = 'auto-message', $seconds = 10 ) { ?>update( $wpdb->comments, array( 'comment_karma' => 0, 'comment_agent' => 'WP LJ Importer', 'comment_type' => '' ), array( 'comment_type' => 'livejournal-done' ) ); $wpdb->update( $wpdb->comments, array( 'comment_karma' => 0, 'comment_agent' => 'WP LJ Importer', 'comment_type' => '' ), array( 'comment_type' => 'livejournal' ) ); } function LJ_API_Import() { $this->__construct(); } function __construct() { // Nothing } } $lj_api_import = new LJ_API_Import(); register_importer( 'livejournal', __( 'LiveJournal' ), __( 'Import posts from LiveJournal using their API.' ), array( $lj_api_import, 'dispatch' ) ); ?> worsethanhitler/wp-admin/import/opml.php0000644001761300176130000001105111225331455021241 0ustar mustardamustarda * @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); $_FILES['userfile']['name'] .= '.txt'; $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); ?>
    worsethanhitler/wp-admin/import/stp.php0000644001761300176130000001205111225331455021101 0ustar mustardamustarda'; 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( _n('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( _n('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')); ?> worsethanhitler/wp-admin/import/utw.php0000644001761300176130000001556511225331455021127 0ustar mustardamustarda'; 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( _n('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( _n('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( _n( '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')); ?> worsethanhitler/wp-admin/import/blogger.php0000644001761300176130000011164411225331455021724 0ustar mustardamustarda ".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 = esc_js( __('Import') ); $continue = esc_js( __('Continue') ); $stop = esc_js( __('Importing...') ); $authors = esc_js( __('Set Authors') ); $loadauth = esc_js( __('Preparing author mapping form...') ); $authhead = esc_js( __('Final Step: Author Mapping') ); $nothing = esc_js( __('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; $value = esc_attr($value); $blogtitle = esc_js( $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), ENT_COMPAT, get_option('blog_charset') ); 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), ENT_COMPAT, get_option('blog_charset') ); 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, ENT_COMPAT, get_option('blog_charset') ) ) ) ); $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_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[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, ENT_COMPAT, get_option('blog_charset') ) ) ); // Clean up content $comment_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[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 = esc_js( __('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 = esc_attr__('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 ); } } ?> worsethanhitler/wp-admin/import/textpattern.php0000644001761300176130000005040111225331455022656 0ustar mustardamustardaget_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(_n('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(_n('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('

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

    ', esc_attr__('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('

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

    ', esc_attr__('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('

    ', esc_attr__('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')); ?> worsethanhitler/wp-admin/import/btt.php0000644001761300176130000000730611225331455021073 0ustar mustardamustarda'; 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( _n('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')); ?> worsethanhitler/wp-admin/import/mt.php0000644001761300176130000003732211225331455020723 0ustar mustardamustarda'; 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(' '._n('(%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(' '._n('(%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. if( !empty($line) ) $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')); ?> worsethanhitler/wp-admin/import/wordpress.php0000644001761300176130000006210111225331455022324 0ustar mustardamustarda'; 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' ); $category_description = $this->get_tag( $c, 'wp:category_description' ); $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', 'category_description'); $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_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[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_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[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(' '._n('(%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')); ?> worsethanhitler/wp-admin/import/jkw.php0000644001761300176130000001422611225331455021074 0ustar mustardamustarda'; 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( _n('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( _n('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')); ?> worsethanhitler/wp-admin/import/wp-cat2tag.php0000644001761300176130000004150411225331455022251 0ustar mustardamustarda'; 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( _n( '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( _n( 'Convert Tag to Category.', 'Convert Tags (%d) to Categories.', $tags_num ), $tags_num ) . '

    '; echo '
    '; echo '

    ' . __('Here you can selectively convert 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)); clean_term_cache($clean_term_cache, 'post_tag'); } if ( ! empty($clean_cat_cache) ) { $clean_cat_cache = array_unique(array_values($clean_cat_cache)); clean_term_cache($clean_cat_cache, '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)); clean_term_cache($clean_term_cache, 'post_tag'); } if ( ! empty($clean_cat_cache) ) { $clean_cat_cache = array_unique(array_values($clean_cat_cache)); clean_term_cache($clean_term_cache, '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')); ?> worsethanhitler/wp-admin/import/dotclear.php0000644001761300176130000005364111225331455022102 0ustar mustardamustardaget_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) ); } } /** * Convert from dotclear charset to utf8 if required * * @package WordPress * @subpackage Dotclear_Import * * @param string $s * @return string */ function csc ($s) { if (seems_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(_n('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(_n('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('

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

    ', esc_attr__('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('

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

    ', esc_attr__('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('

    ', esc_attr__('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')); ?> worsethanhitler/wp-admin/import/rss.php0000644001761300176130000001245011225331455021105 0ustar mustardamustarda'; 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_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[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')); ?> worsethanhitler/wp-admin/import/blogware.php0000644001761300176130000001467711225331455022115 0ustar mustardamustarda'; 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_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[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_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[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( _n('%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')); ?> worsethanhitler/wp-admin/import/greymatter.php0000644001761300176130000002565111225331455022470 0ustar mustardamustarda'; 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( _n('imported %s comment', 'imported %s comments', $numAddedComments) , $numAddedComments); } $preExisting = $numComments - numAddedComments; if ($preExisting > 0) { echo ' '; printf( _n( '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')); ?> worsethanhitler/wp-admin/edit-form-comment.php0000644001761300176130000001332411225331455022313 0ustar mustardamustardacomment_ID); $form_action = 'editedcomment'; $form_extra = "' />\n\ncomment_ID) ?>

    comment_author_email ); $url = esc_attr( $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 ) ); ?>  
    comment_ID&_wp_original_http_referer=" . urlencode(wp_get_referer()), 'delete-comment_' . $comment->comment_ID) . "' onclick=\"if ( confirm('" . esc_js(__("You are about to delete this comment. \n 'Cancel' to stop, 'OK' to delete.")) . "') ){return true;}return false;\">" . __('Delete') . "\n"; ?>

    " . __('visit site') . ""; printf( __( 'URL (%s):' ), apply_filters('get_comment_author_link', $link ) ); } else { _e( 'URL:' ); } ?>

    comment_content, 'content', 'newcomment_author_url', false, 4); ?>
    worsethanhitler/wp-admin/rtl.css0000644001761300176130000002563711225331455017601 0ustar mustardamustarda/* 0 - 200 =================================== */ td.available-theme { text-align: right; } #current-theme img { float: right; margin-right: 0; margin-left: 1em; } .quicktags, .search { font-family: Tahoma, "Times New Roman"; } /* 200 - 500 =================================== */ #save-post { float: right; } .preview { float: left; } #sticky-span { margin-left: 0; margin-right: 18px; } #post-body .misc-pub-section { border-right-width: 0; border-left-width: 1; border-right-style: none; border-left-style: solid; float: right; } #post-body .misc-pub-section-last { border-left: 0; } #delete-action { text-align: right; float: right; } #publishing-action { text-align: left; float: left; } .side-info ul { padding-left: 0; padding-right: 18px; } .submit input, .button, .button-primary, .button-secondary, .button-highlighted, #postcustomstuff .submit input { font-family: Tahoma, "Times New Roman"; } #wpcontent select { font-family: Tahoma, "Times New Roman"; } #quicktags { background-position: right top; } /* 500 - 700 =================================== */ #template div { margin-right: 0; margin-left: 190px; } * html #template div { margin-left: 0; } #your-profile legend { font-family: "Times New Roman", Tahoma; } #ajax-response.alignleft { margin-left: 0; margin-right: 2em; } .page-numbers { margin-right: 0; margin-left: 1px; } .column-author img, .column-username img { float: right; margin-right: 0; margin-left: 10px; } .tablenav a.button-secondary { margin: 8px 0 0 8px; } .tablenav .tablenav-pages { float: left; } .tablenav .displaying-num { margin-right: 0; margin-left: 10px; font-family: Tahoma, "Times New Roman"; } #postcustomstuff table input, #postcustomstuff table select, #postcustomstuff table textarea { margin: 8px 8px 8px 0; } /* 700 - 1000 =================================== */ #pass-strength-result { float: right; margin: 12px 1px 5px 5px; } /* Admin Header */ #user_info { float: left; } #header-logo { float: right; margin: 7px 15px 0 0; } #wphead h1 { font-family: "Times New Roman", Tahoma; float: right; } #wphead h1.long-title { font-family: "Times New Roman", Tahoma; } #adminmenu .wp-submenu a { padding-left: 0; padding-right: 12px; border-width: 0 0 0 1px; border-style: none none none solid; font-family: Tahoma, "Times New Roman"; } #adminmenu a.menu-top, #adminmenu .wp-submenu-head { font-family: Tahoma, "Times New Roman"; } #adminmenu img.wp-menu-image { float: right; } .folded #adminmenu img.wp-menu-image { padding: 7px 6px 0 0; } #adminmenu .wp-submenu .wp-submenu-head { padding: 6px 10px 6px 4px; } .folded #adminmenu .wp-submenu { margin: -1px 28px 0 0; } .folded #adminmenu .wp-submenu a { padding-left: 0; padding-right: 10px; } .folded #adminmenu a.wp-has-submenu { margin-left: 0; margin-right: 40px; } #adminmenu .wp-menu-toggle { float: left; padding: 1px 0 0 2px; clear: left; } #adminmenu div.wp-menu-image { float: right; } #wphead-info { margin: 0 15px 0 0; padding-right:0; padding-left: 15px; } /* end side admin menu */ /* 1000 - 1300 =================================== */ #adminmenu #awaiting-mod, #adminmenu span.update-plugins, #sidemenu li a span.update-plugins { font-family: tahoma; margin-left: 0; margin-right: 2px; } #adminmenu li #awaiting-mod span, #adminmenu li span.update-plugins span, #sidemenu li a span.update-plugins span { float: right; } .post-com-count-wrapper { font-family: tahoma; } .column-response .post-com-count { float: right; margin-right: 0; margin-left: 5px; } /* Tables used on comment.php and option/setting pages */ .form-table th, #wpbody-content .describe th { text-align: right; } .form-table input.tog { margin-right: 0; margin-left: 2px; float: right; } .form-table table.color-palette { float: right; } #profile-page .form-table #rich_editing { margin-right: 0; margin-left: 5px; } /* Post Screen */ /* 1300 - 1500 =================================== */ #normal-sortables .postbox .submit { float: left; } #post-body .tagsdiv #newtag { margin-right: 0; margin-left: 5px; } #post-status-info { padding: 0 7px 0 15px; } #comment-status-radio input { margin: 2px 0 5px 3px; } .tagchecklist { margin-left: 0; margin-right: 10px; } .tagchecklist strong { margin-left: 0; margin-right: -8px; } .tagchecklist span { float: right; } .tagchecklist span a { margin: 6px -9px 0 0; float: right; } .ac_results li { text-align: right; } #poststuff h2 { clear: right; } .description, .form-wrap p { font-family: Tahoma, Arial; } /* 1500 - 1800 =================================== */ .meta-box-sortables .postbox .handlediv { float: left; } .howto { font-family: Tahoma, Arial; } .postarea h3 label { float: right; } .postarea #add-media-button { float: left; right: auto; left: 10px; } .wp_themeSkin tr.mceFirst td.mceToolbar { background-position: right top; } #poststuff #edButtonPreview, #poststuff #edButtonHTML { margin: 5px 0 0 5px; float: left; } #poststuff #edButtonHTML { margin-right: 0; margin-left: 15px; } #media-buttons a { padding: 0 10px 5px 0; } .submitbox .submit { text-align: right; } .inside-submitbox #post_status { margin: 2px -2px 2px 0; } .submitbox .submit input { margin-right: 0; margin-left: 4px; } /* Categories */ #category-adder { margin-left: 0; margin-right: 120px; } #post-body ul#category-tabs li.tabs { -moz-border-radius: 0 3px 3px 0; -webkit-border-top-left-radius: 0; -webkit-border-top-right-radius: 3px; -webkit-border-bottom-left-radius: 0; -webkit-border-bottom-right-radius: 3px; border-top-left-radius: 0; border-top-right-radius: 3px; border-bottom-left-radius: 0; border-bottom-right-radius: 3px; } #post-body ul#category-tabs { float: right; text-align: left; margin: 0 0 0 -120px; } #post-body #categorydiv div.tabs-panel, #post-body #linkcategorydiv div.tabs-panel { margin: 0 120px 0 5px; } /* 1800 - 2000 =================================== */ #side-sortables #category-tabs li { padding-right: 0; padding-left: 8px; } #categorydiv ul.categorychecklist ul, #linkcategorydiv ul.categorychecklist ul { margin-left: 0; margin-right: 18px; } /* positioning etc. */ p.search-box { float: left; } #posts-filter fieldset { float: right; margin: 0 0 1em 1.5ex; } #posts-filter fieldset legend { padding: 0 1px .2em 0; } .view-switch { float: left; } .filter { float: right; margin: -5px 10px 0 0; } #the-comment-list td.comment p.comment-author { margin-right: 0; } #the-comment-list p.comment-author img { float: right; margin-right: 0; margin-left: 8px; } .tablenav .delete { margin-right: 0; margin-left: 20px; } td.action-links, th.action-links { text-align: left; } /* 2000 - 2300 =================================== */ .filter .subsubsub { margin-left: 0; margin-right: -10px; } #wp-word-count { margin-right: 10px; } .tool-box .title { font-family: "Times New Roman", Tahoma; } .settings-toggle { text-align: left; margin: 5px 0 15px 7px; } .curtime #timestamp { background-position: right top; padding-left: 0; padding-right: 18px; } /* media popup 0819 */ #sidemenu { margin: -30px 315px 0 15px; float: left; padding-left: 0; padding-right: 10px; } #sidemenu a { float: right; } #replysubmit .button { margin-right: 0; margin-left: 5px; } /* 2300 - 2500 =================================== */ #edithead .inside { float: right; margin: 3px 5px 2px 0; } #replyrow #ed_reply_toolbar input { margin: 1px 1px 1px 2px; } /* show/hide settings */ #screen-meta-links { margin: 0 0 0 9px; } #screen-options-link-wrap, #contextual-help-link-wrap { float: left; font-family: Tahoma, "Times New Roman"; margin: 0 0 0 6px; } .metabox-prefs label { padding-right: 0; padding-left: 15px; } .metabox-prefs label input { margin: 0 2px 0 5px; } .inline-editor .save, .inline-editor .cancel { margin-right: 0; margin-left: 5px; } /* 2500 - 2700 =================================== */ #bulk-titles div a { float: right; margin: 3px -2px 0 3px; } #wpbody-content .filename { margin-left: 0; margin-right: 10px; } #wpbody-content .inline-edit-row fieldset { float: right; } #wpbody-content .quick-edit-row-page fieldset.inline-edit-col-right .inline-edit-col { border-left: 0 none; border-right: 1px solid; } #wpbody-content .bulk-edit-row .inline-edit-col-bottom { float: left; } .inline-edit-row fieldset label span.title { float: right; } .inline-edit-row fieldset label span.input-text-wrap { margin-left: 0; margin-right: 5em; } .quick-edit-row-post fieldset.inline-edit-col-right label span.title { padding-right: 0; padding-left: 0.5em; } #wpbody-content .quick-edit-row fieldset .inline-edit-group label.alignleft:first-child { margin-right: 0; margin-left: 0.5em; } /* 2700 - 3000 =================================== */ .inline-edit-row fieldset span.title, .inline-edit-row fieldset span.checkbox-title { font-family: Tahoma, "Times New Roman"; } .inline-edit-row fieldset .inline-edit-date { float: right; } .inline-edit-row fieldset ul.cat-checklist label, .inline-edit-row .catshow, .inline-edit-row .cathide, .inline-edit-row #bulk-titles div { font-family: Tahoma, "Times New Roman"; } .quick-edit-row-post fieldset label.inline-edit-status { float: right; } .describe-toggle-on, .describe-toggle-off { float: left; margin-right: 0; margin-left: 20px; } #wpbody-content #media-items .filename { float: right; margin-left: 0; margin-right: 10px; } .media-item .pinkynail { float: right; } #find-posts-response .found-radio { padding: 8px 8px 0 0; } .find-box-buttons { left: auto; right: 12px; } .find-box-search label { padding-right: 0; padding-left: 6px; } /* favorite-actions */ #favorite-actions { float: left; } #favorite-first { padding: 3px 12px 4px 30px; } #favorite-inside { } #favorite-inside a { padding: 3px 10px 3px 5px; } #favorite-toggle { right: auto; left: 0; background:transparent url(images/fav-arrow-rtl.gif) no-repeat 10px -4px; } #utc-time, #local-time { padding-left: 0; padding-right: 25px; font-family: Tahoma, Arial; } .icon32 { float: right; margin: 14px 0 0 6px; } .subtitle { padding-left: 0; padding-right: 25px; } ol { list-style-type:decimal; margin-left:0; margin-right:2em; } /* TinyMCE =================================== */ .clearlooks2 .mceTop .mceLeft { width:100% !important; } /* ltr =================================== */ #author-email, #author-url, #rss-url-1, #edit-slug-box, #post_name, #trackback_url, #metakeyinput, #post_password, #slug, #category_nicename, #link_url, #link_image, #rss_uri, #menu_order, #email, #newcomment_author_url, #pages-exclude, #template textarea, #user_login, #url, #pass1, #pass2, #aim, #yim, #jabber, #siteurl, #home, #admin_email, #gmt_offset, #default_post_edit_rows, #mailserver_url, #mailserver_login, #mailserver_pass, #mailserver_port, #ping_sites, #posts_per_page, #posts_per_rss, #blog_charset, #close_comments_days_old, #comments_per_page, #comment_max_links, #moderation_keys, #blacklist_keys, #thumbnail_size_w, #thumbnail_size_h, #medium_size_w, #medium_size_h, #large_size_w, #large_size_h, #permalink_structure, #category_base, #tag_base, #upload_path, #upload_url_path, #rules { direction: ltr; } worsethanhitler/wp-admin/theme-editor.php0000644001761300176130000002016011225331455021347 0ustar mustardamustarda'.__('You do not have sufficient permissions to edit templates for this blog.').'

    '); $newcontent = stripslashes($_POST['newcontent']); $theme = urlencode($theme); if (is_writeable($real_file)) { //is_writable() not always reliable, check return value. see comments @ http://uk.php.net/is_writable $f = fopen($real_file, 'w+'); if ($f !== FALSE) { fwrite($f, $newcontent); fclose($f); $location = "theme-editor.php?file=$file&theme=$theme&a=te"; } else { $location = "theme-editor.php?file=$file&theme=$theme"; } } else { $location = "theme-editor.php?file=$file&theme=$theme"; } $location = wp_kses_no_null($location); $strip = array('%0d', '%0a'); $location = str_replace($strip, '', $location); header("Location: $location"); exit(); break; default: if ( !current_user_can('edit_themes') ) wp_die('

    '.__('You do not have sufficient permissions to edit themes for this blog.').'

    '); if ( use_codepress() ) wp_enqueue_script( 'codepress' ); require_once('admin-header.php'); update_recently_edited($file); if ( !is_file($real_file) ) $error = 1; if ( !$error && filesize($real_file) > 0 ) { $f = fopen($real_file, 'r'); $content = fread($f, filesize($real_file)); if ( '.php' == substr( $real_file, strrpos( $real_file, '.' ) ) ) { $functions = wp_doc_link_parse( $content ); $docs_select = ''; } $content = htmlspecialchars( $content ); $codepress_lang = codepress_get_lang($real_file); } ?>

    $description (%s)" : "%s"; ?>



      ($template_show)" : "$description"; $filedesc = ( $template_file == $file ) ? "$description ($template_show)" : $filedesc; // If we have two files of the same name prefer the one in the Template Directory // This means that we display the correct files for child themes which overload Templates as well as Styles if( array_key_exists($description, $template_mapping ) ) { if ( false !== strpos( $template_file, $template_dir ) ) { $template_mapping[ $description ] = array( $template_file, $filedesc ); } } else { $template_mapping[ $description ] = array( $template_file, $filedesc ); } } ksort( $template_mapping ); while ( list( $template_sorted_key, list( $template_file, $filedesc ) ) = each( $template_mapping ) ) : ?>
    • &theme=">

      ($style_show)" : "$description"; $filedesc = ( $style_file == $file ) ? "$description ($style_show)" : $filedesc; $template_mapping[ $description ] = array( $style_file, $filedesc ); } ksort( $template_mapping ); while ( list( $template_sorted_key, list( $style_file, $filedesc ) ) = each( $template_mapping ) ) : ?>
    • &theme=">

    "; ?>

    the Codex for more information.'); ?>

    ' . __('Oops, no such file exists! Double check the name and try again, merci.') . '

    '; } ?>
     
    worsethanhitler/wp-admin/edit-link-form.php0000644001761300176130000004633511225331455021616 0ustar mustardamustardaLinks / Edit Link' ), 'link-manager.php' ); $submit_text = __('Update Link'); $form = ' worsethanhitler/wp-admin/upgrade.php0000644001761300176130000000530411225331455020413 0ustar mustardamustarda > <?php _e( 'WordPress › Upgrade' ); ?>

    WordPress

    worsethanhitler/wp-admin/sidebar.php0000644001761300176130000000661111225331455020377 0ustar mustardamustarda <?php bloginfo('name') ?> › <?php _e('Sidebar'); ?>

    ' . __('Post published.') . '

    '; elseif ( 'c' == $_GET['a'] ) echo '

    ' . __('Post saved.') . '

    '; ?>

    worsethanhitler/wp-admin/wp-admin.css0000644001761300176130000014733011225331455020507 0ustar mustardamustardatextarea, input, select { border-width: 1px; border-style: solid; -moz-border-radius: 4px; -khtml-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; } input[type="checkbox"], input[type="radio"], input[type="image"] { border: 0 none; } p, ul, ol, blockquote, input, select { font-size: 12px; } select option { padding: 2px; } .plugins .name, #pass-strength-result.strong, #pass-strength-result.short, .button-highlighted, #quicktags #ed_strong, #ed_reply_toolbar #ed_reply_strong { font-weight: bold; } .plugins p { margin: 0 4px; padding: 0; } .plugins .desc p { margin: 0 0 8px; } .plugins td.desc { line-height: 1.5em; } .plugins .desc ul, .plugins .desc ol { margin: 0 0 0 2em; } .plugins .desc ul { list-style-type: disc; } .plugins .action-links { white-space: nowrap; } .plugins .row-actions-visible { padding: 0; } .widefat tbody.plugins th.check-column { padding: 7px 0; } .widefat .plugins td, .widefat .plugins th { border-bottom: 0 none; } #install-plugins .plugins td, #install-plugins .plugins th { border-bottom-style: solid; border-bottom-width: 1px; } .plugins .inactive td, .plugins .inactive th, .plugins .active td, .plugins .active th { border-top-style: solid; border-top-width: 1px; padding: 5px 7px 0; } #wpbody-content .plugins .plugin-title { padding-right: 12px; } .plugins .second td, .plugins .second th { border-top: 0 none; padding: 0 7px 5px; } .plugins-php .widefat tfoot th, .plugins-php .widefat tfoot td { border-top-style: solid; border-top-width: 1px; } .import-system { font-size: 16px; } .anchors { margin: 10px 20px 10px 20px; } table#availablethemes { border-spacing: 0; border-width: 1px 0; border-style: solid none; margin: 10px auto; width: 100%; } td.available-theme { vertical-align: top; width: 240px; margin: 0; padding: 20px; text-align: left; } table#availablethemes td { border-width: 0 1px 1px; border-style: none solid solid; } table#availablethemes td.right, table#availablethemes td.left { border-right: 0 none; border-left: 0 none; } table#availablethemes td.bottom { border-bottom: 0 none; } .available-theme a.screenshot { width: 240px; height: 180px; display: block; border-width: 1px; border-style: solid; margin-bottom: 10px; overflow: hidden; } .available-theme img { width: 240px; } .available-theme h3 { margin: 15px 0 5px; } #current-theme { margin: 1em 0 1.5em; } #current-theme a { border-bottom: none; } #current-theme h3 { font-size: 17px; font-weight: normal; margin: 0; } #current-theme .theme-description { margin-top: 5px; } #current-theme img { float: left; border-width: 1px; border-style: solid; margin-right: 1em; margin-bottom: 1.5em; width: 150px; } #TB_window #TB_title a.tb-theme-preview-link, #TB_window #TB_title a.tb-theme-preview-link:visited { font-weight: bold; text-decoration: none; } #TB_window #TB_title { background-color: #222; color: #cfcfcf; } .checkbox { border: none; margin: 0; padding: 0; } .code, code { font-family: Consolas, Monaco, Courier, monospace; } kbd, code { padding: 1px 3px; margin: 0 1px; font-size: 11px; } .commentlist li { padding: 1em 1em .2em; margin: 0; border-bottom-width: 1px; border-bottom-style: solid; } .commentlist li li { border-bottom: 0; padding: 0; } .commentlist p { padding: 0; margin: 0 0 .8em; } .post-categories { display: inline; margin: 0; padding: 0; } .post-categories li { display: inline; } .quicktags, .search { font: 12px Georgia, "Times New Roman", "Bitstream Charter", Times, serif; } .submit { padding: 1.5em 0; margin: 5px 0; -moz-border-radius: 0 0 3px 3px; -webkit-border-bottom-left-radius: 3px; -webkit-border-bottom-right-radius: 3px; -khtml-border-bottom-left-radius: 3px; -khtml-border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; } form p.submit a.cancel:hover { text-decoration: none; } #submitdiv h3, #pagesubmitdiv h3 { margin-bottom: 0 !important; } #misc-publishing-actions { padding: 6px 0 16px 0; } .misc-pub-section { padding: 6px; border-bottom-width: 1px; border-bottom-style: solid; } .misc-pub-section-last { border-bottom: 0 none; } #minor-publishing-actions { padding: 6px; text-align: right; } #minor-publishing { border-bottom-width: 1px; border-bottom-style: solid; } #save-post { float: left; } .preview { float: right; } #major-publishing-actions { padding: 6px; clear: both; border-top: none; } #minor-publishing-actions input, #major-publishing-actions input, #minor-publishing-actions .preview { min-width: 80px; text-align: center; } #delete-action { line-height: 25px; vertical-align: middle; text-align: left; float: left; } #publishing-action { text-align: right; float: right; } #post-body #minor-publishing { padding-bottom: 10px; } #post-body #misc-publishing-actions { padding: 0; } #post-body .misc-pub-section { border-right-width: 1px; border-right-style: solid; border-bottom: 0 none; min-height: 30px; float: left; max-width: 32%; } #post-body .misc-pub-section-last { border-right: 0; } #sticky-span { margin-left: 18px; } #post-status-display, #post-visibility-display { font-weight: bold; } .side-info { margin: 0; padding: 4px; font-size: 11px; } .side-info h5 { padding-bottom: 7px; font-size: 14px; margin: 12px 2px 5px; border-bottom-width: 1px; border-bottom-style: solid; } .side-info ul { margin: 0; padding-left: 18px; list-style: square; } .submit input, .button, .button-primary, .button-secondary, .button-highlighted, #postcustomstuff .submit input { 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; -moz-box-sizing: content-box; -webkit-box-sizing: content-box; -khtml-box-sizing: content-box; box-sizing: content-box; } a.button, a.button-primary, a.button-secondary { line-height: 1.2em; -webkit-border-radius: 10px; padding: 4px 10px; white-space: nowrap; } #doaction, #doaction2 { margin-right: 8px; } .tablenav select[name="action"], .tablenav select[name="action2"] { width: 120px; } .tablenav select[name="m"] { width: 120px; } .tablenav select#cat { width: 150px; } #wpcontent select { padding: 2px; height: 2em; font-size: 11px; } #wpcontent option { padding: 2px; } .approve { display: none; } .unapproved .approve, .spam .approve { display: inline; } .unapproved .unapprove { display: none; } .narrow { width: 70%; margin-bottom: 40px; } .narrow p { line-height: 150%; } textarea.all-options, input.all-options { width: 250px; } #namediv table { width: 100%; } #namediv td.first { width: 10px; white-space: nowrap; } #namediv input { width: 98%; } #namediv p { margin: 10px 0; } #wpbody-content .metabox-holder { padding-top: 10px; } #content { margin: 0; width: 100%; } #editorcontainer #content { padding: 6px; line-height: 150%; border: 0 none; outline: none; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; -khtml-box-sizing: border-box; box-sizing: border-box; } #editorcontainer, #quicktags { border-style: solid; border-width: 1px; border-collapse: separate; -moz-border-radius: 6px 6px 0 0; -webkit-border-top-right-radius: 6px; -webkit-border-top-left-radius: 6px; -khtml-border-top-right-radius: 6px; -khtml-border-top-left-radius: 6px; border-top-right-radius: 6px; border-top-left-radius: 6px; } #quicktags { padding: 0; margin-bottom: -3px; border-bottom-width: 3px; background-image: url("images/ed-bg.gif"); background-position: left top; background-repeat: repeat-x; } #quicktags #ed_toolbar { padding: 2px 4px 0; } #ed_toolbar input, #ed_reply_toolbar input { margin: 3px 1px 4px; line-height: 18px; display: inline-block; min-width: 26px; padding: 2px 4px; font-size: 12px; } #ed_reply_toolbar input { margin: 1px 2px 1px 1px; } #quicktags #ed_link, #ed_reply_toolbar #ed_reply_link { text-decoration: underline; } #quicktags #ed_del, #ed_reply_toolbar #ed_reply_del { text-decoration: line-through; } #quicktags #ed_em, #ed_reply_toolbar #ed_reply_em { font-style: italic; } #excerpt, .attachmentlinks { margin: 0; height: 4em; width: 98%; } /* post meta postbox */ #postcustomstuff table, #postcustomstuff input, #postcustomstuff textarea { border-width: 1px; border-style: solid; -moz-border-radius: 3px; -khtml-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; } #postcustomstuff .updatemeta, #postcustomstuff .deletemeta { margin: auto; } #postcustomstuff thead th { padding: 5px 8px 8px; } #postcustom #postcustomstuff .submit, #pagecustomdiv #postcustomstuff .submit { border: 0 none; float: none; padding: 5px 8px; } #side-sortables #postcustom #postcustomstuff .submit, #side-sortables #pagecustomdiv #postcustomstuff .submit { padding: 0 5px; } #side-sortables #postcustom #postcustomstuff td.left input, #side-sortables #pagecustomdiv #postcustomstuff td.left input { margin: 3px 3px 0; } #side-sortables #postcustom #postcustomstuff #the-list textarea, #side-sortables #pagecustomdiv #postcustomstuff #the-list textarea { height: 85px; margin: 3px; } #postcustomstuff table { margin: 0; width: 100%; border-width: 1px; border-style: solid; border-spacing: 0; } #postcustomstuff table input, #postcustomstuff table select, #postcustomstuff table textarea { width: 95%; margin: 8px 0 8px 8px; } #postcustomstuff th.left, #postcustomstuff td.left { width: 38%; } #postcustomstuff .submit input { width: auto; } #postcustomstuff #newmeta .submit { padding: 0 8px; } #postcustomstuff table #addmetasub { width: auto; } #postcustomstuff #newmetaleft { vertical-align: top; } #postcustomstuff #newmetaleft a { padding: 0 10px; text-decoration: none; } #save { width: 15em; } #template div { margin-right: 190px; } * html #template div { margin-right: 0; } /* A handy div class for hiding controls. Some browsers will disable them when you set display: none; */ .zerosize { height: 0; width: 0; margin: 0; border: 0; padding: 0; overflow: hidden; position: absolute; } * html #themeselect { padding: 0 3px; height: 22px; } #your-profile legend { font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif; font-size: 22px; } #your-profile #rich_editing { border: none; } #howto { font-size: 11px; margin: 0 5px; display: block; } #ajax-response.alignleft { margin-left: 2em; } div.nav { height: 2em; padding: 7px 10px; vertical-align: text-top; margin: 5px 0; } .nav .button-secondary { padding: 2px 4px; } a.page-numbers { border-bottom-style: solid; border-bottom-width: 2px; font-weight: bold; margin-right: 1px; padding: 0 2px; } p.pagenav { margin: 0; display: inline; } .pagenav span { font-weight: bold; margin: 0 6px; } .row-title { font-size: 12px !important; font-weight: bold; } .column-comment p { margin: 0.6em 0; } .column-author img, .column-username img { float: left; margin-right: 10px; margin-top: 3px; } .tablenav a.button-secondary { display: block; margin: 3px 8px 0 0; } .tablenav { clear: both; height: 30px; margin: 6px 0 4px; vertical-align: middle; } .tablenav .tablenav-pages { float: right; display: block; cursor: default; height: 30px; line-height: 30px; font-size: 11px; } .tablenav .tablenav-pages a, .tablenav-pages span.current { text-decoration: none; border: none; padding: 3px 6px; border-width: 1px; border-style: solid; -moz-border-radius: 5px; -khtml-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; } .tablenav .displaying-num { margin-right: 10px; font-size: 12px; font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif; font-style: italic; } .tablenav .actions { padding: 2px 8px 0 0; } td.media-icon { vertical-align: middle; text-align: center; width: 80px; } td.media-icon img { max-width: 80px; max-height: 60px; } #update-nag { line-height: 29px; font-size: 12px; text-align: center; } #update-nag { border-width: 1px 0; border-style: solid none; } .plugins .plugin-update { padding: 0; } .plugin-update .update-message { margin: 0 10px 8px 31px; font-weight: bold; } #pass-strength-result { border-style: solid; border-width: 1px; float: left; margin: 12px 5px 5px 1px; padding: 3px 5px; text-align: center; width: 200px; } .row-actions { visibility: hidden; padding: 2px 0 0; } tr:hover .row-actions, div.comment-item:hover .row-actions { visibility: visible; } .row-actions-visible { padding: 2px 0 0; cursor: pointer; } /* Admin Header */ #wphead-info { margin: 0 0 0 15px; padding-right: 15px; } #user_info { float: right; font-size: 12px; line-height: 46px; height: 46px; } #user_info p { margin: 0; padding: 0; line-height: 46px; } #wphead { height: 46px; } #wphead a, #adminmenu a, #sidemenu a, #taglist a, #catlist a, #show-settings a { text-decoration: none; } #header-logo { float: left; margin: 7px 0 0 15px; } #wphead h1 { font: normal 22px Georgia, "Times New Roman", "Bitstream Charter", Times, serif; padding: 10px 8px 5px; margin: 0; float: left; } #wphead h1.long-title { font: normal 18px Georgia, "Times New Roman", "Bitstream Charter", Times, serif; padding: 12px 10px 5px; } #wphead #site-visit-button { background-repeat:repeat-x; background-position:0 0; -moz-border-radius:3px; -webkit-border-radius:3px; -khtml-border-radius:3px; border-radius:3px; cursor:pointer; /* to keep IE happy */ display:-moz-inline-stack; /* to keep FF2 happy */ display:inline-block; font-size: 50%; font-style:normal; line-height:17px; margin-left:5px; padding:0 6px; vertical-align:middle; } #wphead h1 a:hover { text-decoration:none; } #wphead h1 a:hover #site-title { text-decoration:underline; } /* side admin menu */ #adminmenu * { -webkit-user-select: none; -moz-user-select: none; -khtml-user-select: none; user-select: none; } #adminmenu .wp-submenu { display: none; list-style: none; padding: 0; margin: 0; position: relative; z-index: 2; border-width: 1px 0 0; border-style: solid none none; } #adminmenu .wp-submenu a { font: normal 11px/18px "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; } #adminmenu .wp-submenu li.current, #adminmenu .wp-submenu li.current a, #adminmenu .wp-submenu li.current a:hover { font-weight: bold; } #adminmenu a.menu-top, #adminmenu .wp-submenu-head { font: normal 13px/18px Georgia, "Times New Roman", "Bitstream Charter", Times, serif; } #adminmenu div.wp-submenu-head { display: none; } .folded #adminmenu div.wp-submenu-head, .folded #adminmenu li.wp-has-submenu div.sub-open { display: block; } .folded #adminmenu a.menu-top, .folded #adminmenu .wp-submenu, .folded #adminmenu li.wp-menu-open .wp-submenu, .folded #adminmenu div.wp-menu-toggle { display: none; } #adminmenu li.wp-menu-open .wp-submenu, .no-js #adminmenu .open-if-no-js .wp-submenu { display: block; } #adminmenu div.wp-menu-image { float: left; width: 28px; height: 28px; } #adminmenu li { margin: 0; padding: 0; cursor: pointer; } #adminmenu a { display: block; line-height: 18px; padding: 1px 5px 3px; } #adminmenu li.menu-top { min-height: 26px; } #adminmenu a.menu-top { line-height: 18px; min-width: 10em; padding: 5px 5px; border-width: 1px 1px 0; border-style: solid solid none; } #adminmenu .wp-submenu a { margin: 0; padding-left: 12px; border-width: 0 1px 0 0; border-style: none solid none none; } #adminmenu .menu-top-last ul.wp-submenu { border-width: 0 0 1px; border-style: none none solid; } #adminmenu .wp-submenu li { padding: 0; margin: 0; } .folded #adminmenu li.menu-top { width: 28px; height: 30px; overflow: hidden; border-width: 1px 1px 0; border-style: solid solid none; } #adminmenu .menu-top-first a.menu-top, .folded #adminmenu li.menu-top-first, #adminmenu .wp-submenu .wp-submenu-head { border-width: 1px 1px 0; border-style: solid solid none; -moz-border-radius-topleft :6px; -moz-border-radius-topright: 6px; -webkit-border-top-right-radius: 6px; -webkit-border-top-left-radius: 6px; -khtml-border-top-right-radius: 6px; -khtml-border-top-left-radius: 6px; border-top-right-radius: 6px; border-top-left-radius: 6px; } #adminmenu .menu-top-last a.menu-top, .folded #adminmenu li.menu-top-last { border-width: 1px; border-style: solid; -moz-border-radius-bottomleft: 6px; -moz-border-radius-bottomright: 6px; -webkit-border-bottom-right-radius: 6px; -webkit-border-bottom-left-radius: 6px; -khtml-border-bottom-right-radius: 6px; -khtml-border-bottom-left-radius: 6px; border-bottom-right-radius: 6px; border-bottom-left-radius: 6px; } #adminmenu li.wp-menu-open a.menu-top-last { border-bottom: 0 none; -moz-border-radius-bottomright: 0; -moz-border-radius-bottomleft: 0; -webkit-border-bottom-right-radius: 0; -webkit-border-bottom-left-radius: 0; -khtml-border-bottom-right-radius: 0; -khtml-border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom-left-radius: 0; } #adminmenu img.wp-menu-image { float: left; padding: 8px 6px 0; opacity: 0.6; filter: alpha(opacity=60); } #adminmenu li.menu-top:hover img.wp-menu-image, #adminmenu li.wp-has-current-submenu img.wp-menu-image { opacity: 1; filter: alpha(opacity=100); } .folded #adminmenu img.wp-menu-image { padding: 7px 0 0 6px; } #adminmenu li.wp-menu-separator { height: 21px; padding: 0; margin: 0; } #adminmenu a.separator { cursor: w-resize; height: 20px; padding: 0; } .folded #adminmenu a.separator { cursor: e-resize; } #adminmenu .wp-menu-separator-last { height: 10px; width: 1px; } #adminmenu .wp-submenu .wp-submenu-head { border-width: 1px; border-style: solid; padding: 6px 4px 6px 10px; cursor: default; } .folded #adminmenu .wp-submenu { position: absolute; margin: -1px 0 0 28px; padding: 0 8px 8px; z-index: 999; border: 0 none; } .folded #adminmenu .wp-submenu ul { width: 140px; border-width: 0 0 1px; border-style: none none solid; } .folded #adminmenu .wp-submenu li.wp-first-item { border-top: 0 none; } .folded #adminmenu .wp-submenu a { padding-left: 10px; } .folded #adminmenu a.wp-has-submenu { margin-left: 40px; } #adminmenu li.menu-top-last .wp-submenu ul { border-width: 0 0 1px; border-style: none none solid; } #adminmenu .wp-menu-toggle { width: 22px; clear: right; float: right; margin: 1px 0 0; height: 27px; padding: 1px 2px 0 0; cursor: default; } #adminmenu li.wp-has-current-submenu ul { border-bottom-width: 1px; border-bottom-style: solid; } #adminmenu .wp-menu-image a { height: 24px; } #adminmenu .wp-menu-image img { padding: 6px 0 0 1px; } /* end side admin menu */ /* comments/plugins bubble in menu */ #adminmenu #awaiting-mod, #adminmenu span.update-plugins, #sidemenu li a span.update-plugins { position: absolute; font-family: Helvetica, Arial, sans-serif; font-size: 7pt; font-weight: bold; margin-top: 2px; margin-left: 2px; -moz-border-radius: 7px; -khtml-border-radius: 7px; -webkit-border-radius: 7px; border-radius: 7px; } #adminmenu li #awaiting-mod span, #adminmenu li span.update-plugins span, #sidemenu li a span.update-plugins span { float: left; display: block; height: 1.6em; line-height: 1.6em; padding: 0 6px; } #adminmenu li span.count-0, #sidemenu li a .count-0 { display: none; } /* end menu stuff */ /* comments bubble */ .post-com-count-wrapper { min-width: 22px; font-family: Helvetica, Arial, sans-serif; } .post-com-count { height: 1.3em; line-height: 1.1em; display: block; text-decoration: none; padding: 0 0 6px; cursor: pointer; background-position: center -80px; background-repeat: no-repeat; } .post-com-count span { font-size: 9px; font-weight: bold; height: 1.7em; line-height: 1.70em; min-width: 0.7em; padding: 0 6px; display: inline-block; cursor: pointer; -moz-border-radius: 5px; -khtml-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; } strong .post-com-count { background-position: center -55px; } .post-com-count:hover { background-position: center -3px; } .column-response .post-com-count { float: left; margin-right: 5px; text-align: center; } .response-links { float: left; } #the-comment-list .attachment-80x60 { padding: 4px 8px; } /* Admin Footer */ #footer { margin-top: -45px; } #footer, #footer a { font-size: 12px; font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif; font-style: italic; } #footer p { margin: 0; padding: 15px; line-height: 15px; } #footer a { text-decoration: none; } #footer a:hover { text-decoration: underline; } /* Tables used on comment.php and option/setting pages */ .form-table { border-collapse: collapse; margin-top: 0.5em; width: 100%; margin-bottom: -8px; clear: both; } .form-table td, #wpbody-content .describe td { margin-bottom: 9px; padding: 4px 10px 12px; line-height: 20px; font-size: 11px; } .form-table th, .form-wrap label { font-weight: normal; text-shadow: rgba(255,255,255,1) 0 1px 0; } .form-table th, #wpbody-content .describe th { vertical-align: top; text-align: left; padding: 10px; width: 200px; } .form-table th.th-full { width: auto; } .form-table input, .form-table textarea, #wpbody-content .describe input, #wpbody-content .describe textarea { border-width: 1px; border-style: solid; } .form-table div.color-option { display: block; clear: both; margin-top: 12px; } .form-table input.tog { margin-top: 2px; margin-right: 2px; float: left; } .form-table table.color-palette { vertical-align: bottom; float: left; margin: -12px 3px 11px; } .form-table .color-palette td { border-width: 1px 1px 0; border-style: solid solid none; height: 10px; line-height: 20px; width: 10px; } textarea.large-text { width: 99%; } .form-table input.regular-text, #adduser .form-field input { width: 25em; } .form-table input.small-text { width: 50px; } #profile-page .form-table textarea { width: 500px; margin-bottom: 6px; } #profile-page .form-table #rich_editing { margin-right: 5px } .form-table .pre { padding: 8px; margin: 0; } .pre { /* http://www.longren.org/2006/09/27/wrapping-text-inside-pre-tags/ */ white-space: pre-wrap; /* css-3 */ white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */ white-space: -pre-wrap; /* Opera 4-6 */ white-space: -o-pre-wrap; /* Opera 7 */ word-wrap: break-word; /* Internet Explorer 5.5+ */ } table.form-table td .updated { font-size: 13px; } /* divs for cats and tags pages */ .form-wrap { margin: 10px 0; width: 97%; } .form-wrap p, .form-wrap label { font-size: 11px; } .form-wrap label { display: block; padding: 2px; font-size: 12px; } .form-field input, .form-field textarea { border-style: solid; border-width: 1px; width: 95%; } p.description, .form-wrap p { margin: 2px 0 5px; } p.help, p.description, span.description, .form-wrap p { font-size: 12px; font-style: italic; font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; } .form-wrap .form-field { margin: 0 0 10px; padding: 8px; } .col-wrap h3 { margin: 12px 0; font-size: 1.1em; } .col-wrap p.submit { margin-top: -10px; } .tagcloud { width: 97%; margin: 0 0 40px; text-align: justify; } .tagcloud h3 { margin: 2px 0 12px; } /* Post Screen */ #post-body #normal-sortables { min-height: 50px; } #post-body #advanced-sortables { min-height: 20px; } .postbox { position: relative; min-width: 255px; width: 99.5%; } #trackback_url { width: 99%; } #normal-sortables .postbox .submit { background: transparent none; border: 0 none; float: right; padding: 0 12px; margin: 0; } #normal-sortables .postbox #replyrow .submit { float: none; margin: 0; padding: 3px 7px; } #side-sortables .submitbox .submit input, #side-sortables .submitbox .submit .preview, #side-sortables .submitbox .submit a.preview:hover { border: 0 none; } #side-sortables .inside-submitbox .insidebox, .stuffbox .insidebox { margin: 11px 0; } #side-sortables .comments-box, #normal-sortables .comments-box { border: 0 none; } #side-sortables .comments-box thead th, #normal-sortables .comments-box thead th { background: transparent; padding: 0 7px 4px; font-style: italic; } #commentsdiv img.waiting { padding-left: 5px; vertical-align: middle; } #post-body .tagsdiv #newtag { margin-right: 5px; width: 16em; } #side-sortables input#post_password { width: 94% } #side-sortables .tagsdiv #newtag { width: 68%; } #post-status-info { border-width: 0 1px 1px; border-style: none solid solid; width: 100%; -moz-border-radius: 0 0 6px 6px; -webkit-border-bottom-left-radius: 6px; -webkit-border-bottom-right-radius: 6px; -khtml-border-bottom-left-radius: 6px; -khtml-border-bottom-right-radius: 6px; border-bottom-left-radius: 6px; border-bottom-right-radius: 6px; } #post-status-info td { font-size: 11px; } .autosave-info { padding: 2px 15px 2px 2px; text-align: right; } #editorcontent #post-status-info { border: none; } #post-body .wp_themeSkin .mceStatusbar a.mceResize { display: block; background: transparent url(images/resize.gif) no-repeat scroll right bottom; width: 12px; cursor: se-resize; margin: 0 2px; position: relative; top: 22px; } #pagesubmitdiv div.inside, #linksubmitdiv div.inside, div.inside { padding: 0; margin: 0; } #comment-status-radio p { margin: 3px 0 5px; } #comment-status-radio input { margin: 2px 3px 5px 0; vertical-align: middle; } #comment-status-radio label { padding: 5px 0; } .tagchecklist { margin-left: 10px; font-size: 12px; overflow: auto; } .tagchecklist strong { margin-left: -8px; position: absolute; } .tagchecklist span { margin-right: 25px; display: block; float: left; font-size: 11px; line-height: 1.8em; white-space: nowrap; cursor: default; } .tagchecklist span a { margin: 6px 0pt 0pt -9px; cursor: pointer; width: 10px; height: 10px; display: block; float: left; text-indent: -9999px; overflow: hidden; position: absolute; } .howto { font-style: italic; display: block; font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; } .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; } #poststuff h2 { margin-top: 20px; font-size: 1.5em; margin-bottom: 15px; padding: 0 0 3px; clear: left; } .widget .widget-top, .postbox h3 { cursor: move; -webkit-user-select: none; -moz-user-select: none; -khtml-user-select: none; user-select: none; } .postbox .hndle span { padding: 6px 0; } .postbox .hndle { cursor: move; } .hndle a { font-size: 11px; font-weight: normal; } #dashboard-widgets .meta-box-sortables { margin: 0 5px; } .postbox .handlediv { float: right; width: 23px; height: 26px; } .sortable-placeholder { border-width: 1px; border-style: dashed; margin-bottom: 20px; } #poststuff h3, .metabox-holder h3 { font-size: 12px; font-weight: bold; padding: 7px 9px; margin: 0; line-height: 1; } .widget, .postbox, .stuffbox { margin-bottom: 20px; border-width: 1px; border-style: solid; line-height: 1; -moz-border-radius: 6px; -khtml-border-radius: 6px; -webkit-border-radius: 6px; border-radius: 6px; } .widget .widget-top, .postbox h3, .postbox h3, .stuffbox h3 { -moz-border-radius: 6px 6px 0 0; -webkit-border-top-right-radius: 6px; -webkit-border-top-left-radius: 6px; -khtml-border-top-right-radius: 6px; -khtml-border-top-left-radius: 6px; border-top-right-radius: 6px; border-top-left-radius: 6px; } .postbox.closed h3 { -moz-border-radius-bottomleft:4px; -webkit-border-bottom-left-radius: 4px; -khtml-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; -moz-border-radius-bottomright:4px; -webkit-border-bottom-right-radius: 4px; -khtml-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px; } .postbox table.form-table { margin-bottom: 0; } .postbox input[type="text"], .postbox textarea, .stuffbox input[type="text"], .stuffbox textarea { border-width: 1px; border-style: solid; } #poststuff .inside, #poststuff .inside p { font-size: 11px; margin: 6px; } #poststuff .inside .submitbox p { margin: 1em 0; } #post-visibility-select { line-height: 1.5em; margin-top: 3px; } #poststuff #submitdiv .inside { margin: 0; } #titlediv, #poststuff .postarea { margin-bottom: 20px; } #titlediv { margin-bottom: 20px; } #titlediv label { cursor: text; } #titlediv div.inside { margin: 0; } #poststuff #titlewrap { border: 0; padding: 0; } #titlediv #title { padding: 3px 4px; border-width: 1px; border-style: solid; -moz-border-radius: 6px; -khtml-border-radius: 6px; -webkit-border-radius: 6px; border-radius: 6px; font-size: 1.7em; width: 100%; outline: none; } #poststuff .inside-submitbox, #side-sortables .inside-submitbox { margin: 0 3px; font-size: 11px; } input#link_description, input#link_url { width: 98%; } #pending { background: 0 none; border: 0 none; padding: 0; font-size: 11px; margin-top: -1px; } #edit-slug-box { height: 1em; margin-top: 8px; padding: 0 7px; } #editable-post-name-full { display: none; } #editable-post-name input { width: 16em; } .postarea h3 label { float: left; } .postarea #add-media-button { float: right; margin: 7px 0pt 0pt; position: relative; right: 10px; } #poststuff #editor-toolbar { height: 30px; } .wp_themeSkin tr.mceFirst td.mceToolbar { border-width: 0 0 1px; border-style: none none solid; } #edButtonPreview, #edButtonHTML { height: 18px; margin: 5px 5px 0 0; padding: 4px 5px 2px; float: right; cursor: pointer; border-width: 1px; border-style: solid; -moz-border-radius: 3px 3px 0 0; -webkit-border-top-right-radius: 3px; -webkit-border-top-left-radius: 3px; -khtml-border-top-right-radius: 3px; -khtml-border-top-left-radius: 3px; border-top-right-radius: 3px; border-top-left-radius: 3px; } .js .theEditor { color: white; } #poststuff #edButtonHTML { margin-right: 15px; } #media-buttons { cursor: default; padding: 8px 8px 0; } #media-buttons a { cursor: pointer; padding: 0 0 5px 10px; } #media-buttons img { vertical-align: middle; } .submitbox .submit { text-align: left; padding: 12px 10px 10px; font-size: 11px; } .submitbox .submitdelete { border-bottom-width: 1px; border-bottom-style: solid; text-decoration: none; padding: 1px 2px; } .inside-submitbox #post_status { margin: 2px 0 2px -2px; } .submitbox .submit a:hover { border-bottom-width: 1px; border-bottom-style: solid; } .submitbox .submit input { margin-bottom: 8px; margin-right: 4px; padding: 6px; } #post-status-select { line-height: 2.5em; margin-top: 3px; } /* Categories */ #category-adder { margin-left: 120px; padding: 4px 0; } #category-adder h4 { margin: 0 0 8px; } #side-sortables #category-adder { margin: 0; } #post-body #category-add input, #category-add select { width: 30%; } #side-sortables #category-add input { width: 94%; } #side-sortables #category-add select { width: 100%; } #category-add input#category-add-sumbit { width: auto; } #post-body ul#category-tabs { float: left; width: 120px; text-align: right; /* Negative margin for the sake of those without JS: all tabs display */ margin: 0 -120px 0 5px; padding: 0; } #post-body ul#category-tabs li { padding: 8px; } #post-body ul#category-tabs li.tabs { -moz-border-radius: 3px 0 0 3px; -webkit-border-top-left-radius: 3px; -webkit-border-bottom-left-radius: 3px; -khtml-border-top-left-radius: 3px; -khtml-border-bottom-left-radius: 3px; border-top-left-radius: 3px; border-bottom-left-radius: 3px; } #post-body ul#category-tabs li.tabs a { font-weight: bold; text-decoration: none; } #categorydiv div.tabs-panel, #linkcategorydiv div.tabs-panel { height: 150px; overflow: auto; padding: 0.5em 0.9em; border-style: solid; border-width: 1px; } #post-body #categorydiv div.tabs-panel, #post-body #linkcategorydiv div.tabs-panel { margin: 0 5px 0 125px; } #side-sortables #category-tabs li { display: inline; padding-right: 8px; } #side-sortables #category-tabs a { text-decoration: none; } #side-sortables #category-tabs { margin-bottom: 3px; } #categorydiv ul, #linkcategorydiv ul { list-style: none; padding: 0; margin: 0; } #categorydiv ul.categorychecklist ul, #linkcategorydiv ul.categorychecklist ul { margin-left: 18px; } ul.categorychecklist li { margin: 0; padding: 0; line-height: 19px; } #category-adder h4 { margin-top: 4px; margin-bottom: 0px; } #categorydiv .tabs-panel { border-width: 3px; border-style: solid; } ul#category-tabs { margin-top: 12px; } ul#category-tabs li.tabs { border-style: solid solid none; border-width: 1px 1px 0; } #post-body #category-tabs li.tabs { border-style: solid none solid solid; border-width: 1px 0 1px 1px; margin-right: -1px; } ul#category-tabs li { padding: 5px 8px; -moz-border-radius: 3px 3px 0 0; -webkit-border-top-left-radius: 3px; -webkit-border-top-right-radius: 3px; -khtml-border-top-left-radius: 3px; -khtml-border-top-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; } /* positioning etc. */ form#tags-filter { position: relative; } p.search-box { float: right; margin: -5px 0 0; } .screen-per-page { width: 3em; } #posts-filter fieldset { float: left; margin: 0 1.5ex 1em 0; padding: 0; } #posts-filter fieldset legend { padding: 0 0 .2em 1px; } .bordertitle { padding-bottom: 5px; border-bottom-width: 1px; border-bottom-style: solid; } /* Edit posts */ td.post-title strong, td.plugin-title strong { display: block; margin-bottom: .2em; } td.post-title p, td.plugin-title p { margin: 6px 0; } td.plugin-title { white-space: nowrap; } /* Global classes */ .wp-hidden-children .wp-hidden-child, .ui-tabs-hide, #codepress-off { display: none; } .commentlist .avatar { vertical-align: text-top; } .defaultavatarpicker .avatar { margin: 2px 0; vertical-align: middle; } body.wp-admin { min-width: 785px; } .view-switch { float: right; margin: 6px 8px 0; } .view-switch a { text-decoration: none; } .filter { float: left; margin: -5px 0 0 10px; } .filter .subsubsub { margin-left: -10px; margin-top: 13px; } #the-comment-list td.comment p.comment-author { margin-top: 0; margin-left: 0; } #the-comment-list p.comment-author img { float: left; margin-right: 8px; } #the-comment-list p.comment-author strong a { border: none; } #the-comment-list td { vertical-align: top; } #the-comment-list td.comment { word-wrap: break-word; } #the-comment-list .check-column { padding-top: 8px; } #templateside ul li a { text-decoration: none; } .indicator-hint { padding-top: 8px; } #display_name { width: 15em; } .tablenav .delete { margin-right: 20px; } td.action-links, th.action-links { text-align: right; } /* Diff */ table.diff { width: 100%; } table.diff col.content { width: 50%; } table.diff tr { background-color: transparent; } table.diff td, table.diff th { padding: .5em; font-family: Consolas, Monaco, Courier, monospace; border: none; } table.diff .diff-deletedline del, table.diff .diff-addedline ins { text-decoration: none; } #wp-word-count { display: block; padding: 2px 7px; } fieldset { border: 0; padding: 0; margin: 0; } .tool-box { margin: 15px 0 35px; } .tool-box .buttons { margin: 15px 0; } .tool-box .title { margin: 8px 0; font: 18px/24px Georgia, "Times New Roman", "Bitstream Charter", Times, serif; } .pressthis a { font-size: 1.2em; } #wp_editbtns, #wp_gallerybtns { padding: 2px; position: absolute; display: none; z-index: 999998; } #wp_editimgbtn, #wp_delimgbtn, #wp_editgallery, #wp_delgallery { margin: 2px; padding: 2px; border-width: 1px; border-style: solid; -moz-border-radius: 3px; -khtml-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; } .settings-toggle { text-align: right; margin: 5px 7px 15px 0; font-size: 12px; } .settings-toggle h3 { margin: 0; } #timestampdiv select { height: 20px; line-height: 20px; padding: 0; } #jj, #hh, #mn { width: 2em; padding: 1px; font-size: 12px; } #aa { width: 3.4em; padding: 1px; font-size: 12px; } .curtime #timestamp { background-repeat: no-repeat; background-position: left top; padding-left: 18px; } #timestampdiv { padding-top: 5px; line-height: 23px; } #timestampdiv p { margin: 8px 0 6px; } #timestampdiv input { border-width: 1px; border-style: solid; } /* media popup 0819 */ #sidemenu { margin: -30px 15px 0 315px; list-style: none; position: relative; float: right; padding-left: 10px; font-size: 12px; } #sidemenu a { padding: 0 7px; display: block; float: left; line-height: 28px; border-top-width: 1px; border-top-style: solid; border-bottom-width: 1px; border-bottom-style: solid; } #sidemenu li { display: inline; line-height: 200%; list-style: none; text-align: center; white-space: nowrap; margin: 0; padding: 0; } #sidemenu a.current { font-weight: normal; padding-left: 6px; padding-right: 6px; -moz-border-radius: 4px 4px 0 0; -webkit-border-top-left-radius: 4px; -webkit-border-top-right-radius: 4px; -khtml-border-top-left-radius: 4px; -khtml-border-top-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-width: 1px; border-style: solid; } #sidemenu { margin: -30px 15px 0 315px; list-style: none; position: relative; float: right; padding-left: 10px; font-size: 12px; } #sidemenu a { padding: 0 7px; display: block; float: left; line-height: 28px; border-top-width: 1px; border-top-style: solid; border-bottom-width: 1px; border-bottom-style: solid; } #sidemenu li a .count-0 { display: none; } /* reply to comments */ #replyrow { font-size: 11px; } #replyrow input { border-width: 1px; border-style: solid; } #replyrow td { padding: 2px; } #replyrow #editorcontainer { border: 0 none; } #replysubmit { margin: 0; padding: 3px 7px; } #replysubmit img.waiting, .inline-edit-save img.waiting, #commentstatusdiv img.waiting { padding: 0 10px; vertical-align: top; } #replysubmit .button { margin-right: 5px; } #replyrow #editor-toolbar { display: none; } #replyhead { font-size: 12px; font-weight: bold; padding: 2px 10px 4px; } #edithead .inside { float: left; padding: 3px 0 2px 5px; margin: 0; text-align: center; font-size: 11px; } #edithead .inside input { width: 180px; font-size: 11px; } #edithead label { padding: 2px 0; } #replycontainer { padding: 5px; border: 0 none; height: 120px; overflow: hidden; position: relative; } #replycontent { resize: none; margin: 0; width: 100%; height: 100%; padding: 0; line-height: 150%; border: 0 none; outline: none; font-size: 12px; } #replyrow #ed_reply_toolbar { margin: 0; padding: 2px 3px; } /* show/hide settings */ #screen-meta { position: relative; clear: both; } #screen-meta-links { margin: 0 9px 0 0; } #screen-meta .screen-reader-text { visibility: hidden; } #screen-options-link-wrap, #contextual-help-link-wrap { float: right; background: transparent url( images/screen-options-left.gif ) no-repeat 0 0; font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; height: 22px; padding: 0; margin: 0 6px 0 0; } #screen-meta a.show-settings { text-decoration: none; z-index: 1; padding: 0 16px 0 6px; height: 22px; line-height: 22px; font-size: 10px; display: block; background-repeat: no-repeat; background-position: right bottom; } #screen-meta a.show-settings { background-image: url( images/screen-options-right.gif ); } #screen-meta a.show-settings:hover { text-decoration: none; } #screen-options-wrap h5, #contextual-help-wrap h5 { margin: 8px 0; font-size: 13px; } #screen-options-wrap, #contextual-help-wrap { border-style: none solid solid; border-top: 0 none; border-width: 0 1px 1px; margin: 0 15px; padding: 8px 12px 12px; -moz-border-radius: 0 0 0 4px; -webkit-border-bottom-left-radius: 4px; -khtml-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; } .metabox-prefs label { padding-right: 15px; white-space: nowrap; line-height: 30px; } .metabox-prefs label input { margin: 0 5px 0 2px; } .metabox-prefs label a { display: none; } /* Inline Editor .quick-edit* is for Quick Edit .bulk-edit* is for Bulk Edit .inline-edit* is for everything */ /* Layout */ tr.inline-edit-row td { padding: 0 0.5em; } #wpbody-content .inline-edit-row fieldset { font-size: 12px; float: left; margin: 0; padding: 0; width: 100%; } #wpbody-content .inline-edit-row fieldset .inline-edit-col { padding: 0 0.5em; } #wpbody-content .quick-edit-row-page fieldset.inline-edit-col-right .inline-edit-col { border-width: 0 0 0 1px; border-style: none none none solid; } #wpbody-content .quick-edit-row-post .inline-edit-col-left { width: 40%; } #wpbody-content .quick-edit-row-post .inline-edit-col-right { width: 39%; } #wpbody-content .inline-edit-row-post .inline-edit-col-center { width: 20%; } #wpbody-content .quick-edit-row-page .inline-edit-col-left { width: 50%; } #wpbody-content .quick-edit-row-page .inline-edit-col-right, #wpbody-content .bulk-edit-row-post .inline-edit-col-right { width: 49%; } #wpbody-content .bulk-edit-row .inline-edit-col-left { width: 30%; } #wpbody-content .bulk-edit-row-page .inline-edit-col-right { width: 69%; } #wpbody-content .bulk-edit-row .inline-edit-col-bottom { float: right; width: 69%; } #wpbody-content .inline-edit-row-page .inline-edit-col-right, #owpbody-content .bulk-edit-row-post .inline-edit-col-right { margin-top: 27px; } .inline-edit-row fieldset .inline-edit-group { clear: both; } .inline-edit-row fieldset .inline-edit-group:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } .inline-edit-row p.submit { clear: both; padding: 0.5em; margin: 0.5em 0 0; } .inline-edit-row span.error { line-height: 22px; margin: 0 15px; padding: 3px 5px; } /* Positioning */ .inline-edit-row h4 { margin: .2em 0; padding: 0; line-height: 23px; } .inline-edit-row fieldset span.title, .inline-edit-row fieldset span.checkbox-title { margin: 0; padding: 0; line-height: 27px; } .inline-edit-row fieldset label, .inline-edit-row fieldset span.inline-edit-categories-label { display: block; margin: .2em 0; } .inline-edit-row fieldset label.inline-edit-tags { margin-top: 0; } .inline-edit-row fieldset label.inline-edit-tags span.title { margin: .2em 0; } .inline-edit-row fieldset label span.title { display: block; float: left; width: 5em; } .inline-edit-row fieldset label span.input-text-wrap { display: block; margin-left: 5em; } .quick-edit-row-post fieldset.inline-edit-col-right label span.title { width: auto; padding-right: 0.5em; } .inline-edit-row .input-text-wrap input[type=text] { width: 100%; } .inline-edit-row fieldset label input[type=checkbox] { vertical-align: text-bottom; } .inline-edit-row fieldset label textarea { width: 100%; height: 4em; } #wpbody-content .bulk-edit-row fieldset .inline-edit-group label { max-width: 50%; } #wpbody-content .quick-edit-row fieldset .inline-edit-group label.alignleft:first-child { margin-right: 0.5em } /* Styling */ .inline-edit-row h4 { text-transform: uppercase; } .inline-edit-row fieldset span.title, .inline-edit-row fieldset span.checkbox-title { font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif; font-style: italic; line-height: 1.8em; } /* Specific Elements */ .inline-edit-row fieldset input[type="text"], .inline-edit-row fieldset textarea { border-style: solid; border-width: 1px; } .inline-edit-row fieldset .inline-edit-date { float: left; } .inline-edit-row fieldset input[name=jj], .inline-edit-row fieldset input[name=hh], .inline-edit-row fieldset input[name=mn] { font-size: 12px; width: 2.1em; } .inline-edit-row fieldset input[name=aa] { font-size: 12px; width: 3.5em; } .inline-edit-row fieldset label input.inline-edit-password-input { width: 8em; } .inline-edit-row .catshow, .inline-edit-row .cathide { cursor: pointer; } ul.cat-checklist { height: 12em; border-style: solid; border-width: 1px; overflow-y: scroll; padding: 0 5px; margin: 0; } #bulk-titles { display: block; height: 12em; border-style: solid; border-width: 1px; overflow-y: scroll; padding: 0 5px; margin: 0 0 5px; } .inline-edit-row fieldset ul.cat-checklist li, .inline-edit-row fieldset ul.cat-checklist input { margin: 0; } .inline-edit-row fieldset ul.cat-checklist label, .inline-edit-row .catshow, .inline-edit-row .cathide, .inline-edit-row #bulk-titles div { font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; font-style: normal; font-size: 11px; } table .inline-edit-row fieldset ul.cat-hover { height: auto; max-height: 30em; overflow-y: auto; position: absolute; } .inline-edit-row fieldset label input.inline-edit-menu-order-input { width: 3em; } .inline-edit-row fieldset label input.inline-edit-slug-input { width: 75%; } .quick-edit-row-post fieldset label.inline-edit-status { float: left; } #bulk-titles { line-height: 140%; } #bulk-titles div { margin: 0.2em 0.3em; } #bulk-titles div a { cursor: pointer; display: block; float: left; height: 10px; margin: 3px 3px 0 -2px; overflow: hidden; position: relative; text-indent: -9999px; width: 10px; } /* Media library */ #wpbody-content #media-items .describe { border-collapse: collapse; width: 100%; border-top-style: solid; border-top-width: 1px; clear: both; cursor: default; padding: 5px; width: 100%; } #wpbody-content .describe .media-item-info tr { background-color: transparent; } #wpbody-content .filename { padding: 0 10px; } #wpbody-content .media-item .thumbnail { max-height: 128px; max-width: 128px; } #wpbody-content .media-upload-form label { display: block; font-size: 13px; margin: 0.5em; } abbr.required { border: medium none; text-decoration: none; } #wpbody-content .describe input[type="text"], #wpbody-content .describe textarea { width: 460px; } #wpbody-content .describe p.help { margin: 0; padding: 0 0 0 5px; } .describe-toggle-on, .describe-toggle-off { display: block; line-height: 36px; float: right; margin-right: 20px; } .describe-toggle-off { display: none; } #wpbody-content .media-item { border-bottom-style: solid; border-bottom-width: 1px; min-height: 36px; position: relative; width: 100%; } #wpbody-content #media-items { border-style: solid solid none; border-width: 1px; width: 670px; } #wpbody-content #media-items .filename { line-height: 36px; overflow: hidden; } .media-item .pinkynail { float: left; height: 32px; margin: 2px; max-width: 40px; max-height: 40px; } .media-item .startopen, .media-item .startclosed { display: none; } .media-item .original { position: relative; height: 34px; text-align: center; } .media-item .percent { font-weight: bold; } .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: relative; margin-bottom: -36px; height: 36px; } .bar { width: 0; height: 100%; border-right-width: 3px; border-right-style: solid; } #media-items a.delete, #media-items a.del-link { padding: 1px 4px 2px; } /* find posts */ .find-box { width: 500px; height: 300px; overflow: hidden; padding: 33px 5px 40px; position: absolute; z-index: 1000; } .find-box-head { cursor: move; font-weight: bold; height: 2em; line-height: 2em; padding: 1px 12px; position: absolute; top: 5px; width: 100%; } .find-box-inside { overflow: auto; width: 100%; height: 100%; } .find-box-search { padding: 12px; border-width: 1px; border-style: none none solid; } #find-posts-response { margin: 8px 0; padding: 0 1px; } #find-posts-response table { width: 100%; } #find-posts-response .found-radio { padding: 5px 0 0 8px; width: 15px; } .find-box-buttons { width: 480px; margin: 8px; } .find-box-search label { padding-right: 6px; } .find-box #resize-se { position: absolute; right: 1px; bottom: 1px; } /* favorite-actions */ #favorite-actions { float: right; margin: 11px 12px 0; min-width: 130px; position: relative; } #favorite-first { -moz-border-radius: 12px; -khtml-border-radius: 12px; -webkit-border-radius: 12px; border-radius: 12px; line-height: 15px; padding: 3px 30px 4px 12px; border-width: 1px; border-style: solid; } #favorite-inside { margin: 0 0 0 0px; padding: 0 1px 6px 1px; border-width: 1px; border-style: solid; position: absolute; z-index: 11; display: none; -moz-border-radius: 0 0 12px 12px; -webkit-border-bottom-right-radius: 12px; -webkit-border-bottom-left-radius: 12px; -khtml-border-bottom-right-radius: 12px; -khtml-border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; border-bottom-left-radius: 12px; } #favorite-actions a { display: block; text-decoration: none; font-size: 11px; } #favorite-inside a { padding: 3px 5px 3px 10px; } #favorite-toggle { height: 22px; position: absolute; right: 0; top: 1px; width: 28px; } #favorite-actions .slide-down { -moz-border-radius: 12px 12px 0 0; -webkit-border-bottom-right-radius: 0; -webkit-border-bottom-left-radius: 0; -khtml-border-bottom-right-radius: 0; -khtml-border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom-left-radius: 0; border-bottom-width: 1px; border-bottom-style: solid; } #utc-time, #local-time { padding-left: 25px; font-style: italic; font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; } ul#dismissed-updates { display: none; } form.upgrade { margin-top: 8px; } form.upgrade .hint { font-style: italic; font-size: 85%; margin: -0.5em 0 2em 0; } #poststuff .inside .the-tagcloud { margin: 5px 0 10px; padding: 8px; border-width: 1px; border-style: solid; line-height: 1.8em; word-spacing: 3px; -moz-border-radius: 6px; -khtml-border-radius: 6px; -webkit-border-radius: 6px; border-radius: 6px; } br.clear { height: 2px; line-height: 2px; } .swfupload { margin: 5px 10px; vertical-align: middle; } /* table.fixed column width */ table.fixed { table-layout: fixed; } .fixed .column-rating, .fixed .column-visible { width: 8%; } .fixed .column-date, .fixed .column-parent, .fixed .column-links { width: 10%; } .fixed .column-response, .fixed .column-author, .fixed .column-categories, .fixed .column-tags, .fixed .column-rel, .fixed .column-role { width: 15%; } .fixed .column-comments { width: 4em; padding-top: 8px; } .fixed .column-slug { width: 25%; } .fixed .column-posts { width: 10%; } .fixed .column-icon { width: 80px; } #commentstatusdiv .fixed .column-author, #comments-form .fixed .column-author, #commentstatusdiv .fixed .column-date { width: 20%; } .widefat th, .widefat td { overflow: hidden; } table .vers, table .column-visible, table .column-rating { text-align: center; } .icon32 { float: left; height: 36px; margin: 14px 6px 0 0; width: 36px; } .key-labels label { line-height: 24px; } .subtitle { font-size: 0.75em; line-height: 1; padding-left: 25px; } ol { list-style-type: decimal; margin-left: 2em; } .postbox-container { float: left; padding-right: 0.5%; } .postbox-container .meta-box-sortables { min-height: 300px; } .temp-border { border: 1px dotted #ccc; } .columns-prefs label { padding: 0 5px; } .theme-install-php h4, .plugin-install-php h4 { margin: 2.5em 0 8px; } p.install-help { margin: 8px 0; font-style: italic; } p.popular-tags { -moz-border-radius: 8px; -khtml-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; border-width: 1px; border-style: solid; line-height: 2em; padding: 8px 12px 12px; text-align: justify; } p.popular-tags a { padding: 0 3px; } .stuffbox .editcomment { clear: none; } .ajax-feedback { visibility: hidden; vertical-align: bottom; } .tagsdiv .newtag { width: 180px; } .tagsdiv .the-tags { display: block; height: 60px; margin: 0 auto; overflow: auto; width: 260px; } #post-body-content .tagsdiv .the-tags { margin: 0 5px; } label, #your-profile label + a { vertical-align: middle; } .plugin-update-tr .update-message { margin: 5px; padding: 3px 5px; border-width: 1px; border-style: solid; -moz-border-radius: 5px; -khtml-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; } worsethanhitler/wp-admin/custom-header.php0000644001761300176130000003224711225331455021532 0ustar mustardamustardaadmin_header_callback = $admin_header_callback; } /** * Setup the hooks for the Custom Header admin page. * * @since unknown */ function init() { $page = add_theme_page(__('Custom Header'), __('Custom 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('jcrop'); } /** * Setup the enqueue for the CSS files * * @since 2.7 */ function css_includes() { $step = $this->step(); if ( 1 == $step ) wp_enqueue_style('farbtastic'); elseif ( 2 == $step ) wp_enqueue_style('jcrop'); } /** * 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', esc_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(); } } ?> worsethanhitler/wp-admin/options-media.php0000644001761300176130000000537611225331455021545 0ustar mustardamustarda


    />

    worsethanhitler/wp-admin/edit-tag-form.php0000644001761300176130000000451311225331455021424 0ustar mustardamustarda


    worsethanhitler/wp-admin/includes/plugin-install.php0000644001761300176130000005351111225331455023537 0ustar mustardamustardaper_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 occurred 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 occurred'), $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.') ?>

    esc_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 '
    '; } /** * 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_upload', 'install_plugins_upload', 10, 1); /** * Upload from zip * @since 2.8.0 * * @param string $page */ function install_plugins_upload( $page = 1 ) { ?>

    '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(), 'ul' => array(), 'ol' => array(), 'li' => array(), 'p' => array(), 'br' => 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); //Limit description to 400char, and remove any HTML. $description = strip_tags($plugin['description']); if ( strlen($description) > 400 ) $description = mb_substr($description, 0, 400) . '…'; //remove any trailing entities $description = preg_replace('/&[^;\s]{0,6}$/', '', $description); //strip leading/trailing & multiple consecutive lines $description = trim($description); $description = preg_replace("|(\r?\n)+|", "\n", $description); //\n =>
    $description = nl2br($description); $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 = esc_url($href); $san_title = esc_attr(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) && version_compare( substr($GLOBALS['wp_version'], 0, strlen($api->tested)), $api->tested, '>') ) echo '

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

    '; else if ( !empty($api->requires) && version_compare( substr($GLOBALS['wp_version'], 0, strlen($api->requires)), $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 = esc_attr(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; } worsethanhitler/wp-admin/includes/plugin.php0000644001761300176130000010644411225331455022077 0ustar mustardamustarda * /* * 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} = _cleanup_header_comment(${$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_file, $plugin_data, $markup, $translate); return $plugin_data; } function _get_plugin_data_markup_translate($plugin_file, $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']) && ! empty($plugin_data['Author']) ) $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; } /** * Get a list of a plugin's files. * * @since 2.8.0 * * @param string $plugin Plugin ID * @return array List of files relative to the plugin root. */ function get_plugin_files($plugin) { $plugin_file = WP_PLUGIN_DIR . '/' . $plugin; $dir = dirname($plugin_file); $plugin_files = array($plugin); if ( is_dir($dir) && $dir != WP_PLUGIN_DIR ) { $plugins_dir = @ opendir( $dir ); if ( $plugins_dir ) { while (($file = readdir( $plugins_dir ) ) !== false ) { if ( substr($file, 0, 1) == '.' ) continue; if ( is_dir( $dir . '/' . $file ) ) { $plugins_subdir = @ opendir( $dir . '/' . $file ); if ( $plugins_subdir ) { while (($subfile = readdir( $plugins_subdir ) ) !== false ) { if ( substr($subfile, 0, 1) == '.' ) continue; $plugin_files[] = plugin_basename("$dir/$file/$subfile"); } @closedir( $plugins_subdir ); } } else { if ( plugin_basename("$dir/$file") != $plugin ) $plugin_files[] = plugin_basename("$dir/$file"); } } @closedir( $plugins_dir ); } } return $plugin_files; } /** * 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); $plugin_files = array(); 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 || empty($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 ( ! is_object($wp_filesystem) ) return new WP_Error('fs_unavailable', __('Could not access filesystem.')); if ( is_wp_error($wp_filesystem->errors) && $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 if ( $current = get_transient('update_plugins') ) { unset( $current->response[ $plugin_file ] ); set_transient('update_plugins', $current); } 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.')); $installed_plugins = get_plugins(); if ( ! isset($installed_plugins[$plugin]) ) return new WP_Error('no_plugin_header', __('The plugin does not have a valid header.')); 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'; elseif ( is_ssl() && 0 === strpos($icon_url, 'http://') ) $icon_url = 'https://' . substr($icon_url, 7); $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'; elseif ( is_ssl() && 0 === strpos($icon_url, 'http://') ) $icon_url = 'https://' . substr($icon_url, 7); $_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 ( (array)$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 ( (array)$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( (array)$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 ( (array)$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; } } } if ( !isset($title) || empty ( $title ) ) { foreach ( $menu as $menu_array ) { if ( isset( $plugin_page ) && ($plugin_page == $menu_array[2] ) && ($pagenow == 'admin.php' ) && ($parent1 == $menu_array[2] ) ) { $title = $menu_array[3]; return $menu_array[3]; } } } } 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( $plugin_page ) && 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, (array) $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 ) { if ( isset($whitelist_options[ $page ]) && is_array($whitelist_options[ $page ]) ) { $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"); } ?> worsethanhitler/wp-admin/includes/class-wp-filesystem-direct.php0000644001761300176130000001570311225331455025761 0ustar mustardamustardamethod = '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 substr(decoct(@fileperms($file)),3); } 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) { if ( empty($file) ) //Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem. return 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 ( file_exists($file) && ! @rmdir($file) ) $retval = 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; } } ?> worsethanhitler/wp-admin/includes/update.php0000644001761300176130000001657211225331455022065 0ustar mustardamustarda '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_transient( 'update_core' ); if ( empty($from_api) ) return false; if ( !isset( $from_api->updates ) || !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_transient( '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_transient( 'update_plugins' ); if ( !isset( $current->response[ $file ] ) ) return false; $r = $current->response[ $file ]; $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()); $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags ); $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 %4$s Details.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version ); else if ( empty($r->package) ) printf( __('There is a new version of %1$s available. View version %4$s Details automatic upgrade unavailable for this plugin.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version ); else printf( __('There is a new version of %1$s available. View version %4$s Details or upgrade automatically.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version, wp_nonce_url('update.php?action=upgrade-plugin&plugin=' . $file, 'upgrade-plugin_' . $file) ); do_action( "in_plugin_update_message-$file", $plugin_data, $r ); echo '
    '; } add_action( 'after_plugin_row', 'wp_plugin_update_row', 10, 2 ); function wp_update_plugin($plugin, $feedback = '') { if ( !empty($feedback) ) add_filter('update_feedback', $feedback); include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; $upgrader = new Plugin_Upgrader(); return $upgrader->upgrade($plugin); } function wp_update_theme($theme, $feedback = '') { if ( !empty($feedback) ) add_filter('update_feedback', $feedback); include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; $upgrader = new Theme_Upgrader(); return $upgrader->upgrade($theme); } function wp_update_core($current, $feedback = '') { if ( !empty($feedback) ) add_filter('update_feedback', $feedback); include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; $upgrader = new Core_Upgrader(); return $upgrader->upgrade($current); } 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' ); ?> worsethanhitler/wp-admin/includes/post.php0000644001761300176130000012724511225331455021570 0ustar mustardamustarda 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 ( isset($post_data['post_type']) && '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 = esc_html( stripslashes( $_REQUEST['post_title'] )); else if ( !empty( $_REQUEST['popuptitle'] ) ) { $post_title = esc_html( stripslashes( $_REQUEST['popuptitle'] )); $post_title = funky_javascript_fix( $post_title ); } else { $post_title = ''; } $post_content = ''; if ( !empty( $_REQUEST['content'] ) ) $post_content = esc_html( stripslashes( $_REQUEST['content'] )); else if ( !empty( $post_title ) ) { $text = esc_html( stripslashes( urldecode( $_REQUEST['text'] ) ) ); $text = funky_javascript_fix( $text); $popupurl = esc_url($_REQUEST['popupurl']); $post_content = ''.$post_title.''."\n$text"; } if ( !empty( $_REQUEST['excerpt'] ) ) $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] )); else $post_excerpt = ''; $post->ID = 0; $post->post_name = ''; $post->post_author = ''; $post->post_date = ''; $post->post_date_gmt = ''; $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; } /** * Determine if a post exists based on title, content, and date * * @since unknown * * @param string $title Post title * @param string $content Optional post content * @param string $date Optional post date * @return int Post ID if post exists, 0 otherwise. */ function post_exists($title, $content = '', $date = '') { global $wpdb; $post_title = stripslashes( sanitize_post_field( 'post_title', $title, 0, 'db' ) ); $post_content = stripslashes( sanitize_post_field( 'post_content', $content, 0, 'db' ) ); $post_date = stripslashes( sanitize_post_field( 'post_date', $date, 0, 'db' ) ); $query = "SELECT ID FROM $wpdb->posts WHERE 1=1"; $args = array(); if ( !empty ( $date ) ) { $query .= ' AND post_date = %s'; $args[] = $post_date; } if ( !empty ( $title ) ) { $query .= ' AND post_title = %s'; $args[] = $post_title; } if ( !empty ( $content ) ) { $query .= 'AND post_content = %s'; $args[] = $post_content; } if ( !empty ( $args ) ) return $wpdb->get_var( $wpdb->prepare($query, $args) ); 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; if ( '' === trim( $meta_value ) ) 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->update($wpdb->posts, array('post_parent' => $new_ID), array('post_parent' => $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(_x('Published', 'post'), __('Published posts'), _n_noop('Published (%s)', 'Published (%s)')), 'future' => array(_x('Scheduled', 'post'), __('Scheduled posts'), _n_noop('Scheduled (%s)', 'Scheduled (%s)')), 'pending' => array(_x('Pending Review', 'post'), __('Pending posts'), _n_noop('Pending Review (%s)', 'Pending Review (%s)')), 'draft' => array(_x('Draft', 'post'), _x('Drafts', 'manage posts header'), _n_noop('Draft (%s)', 'Drafts (%s)')), 'private' => array(_x('Private', 'post'), __('Private posts'), _n_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'; } $posts_per_page = get_user_option('edit_per_page'); if ( empty($posts_per_page) ) $posts_per_page = 15; $posts_per_page = apply_filters('edit_posts_per_page', $posts_per_page); wp("post_type=post&$post_status_q&posts_per_page=$posts_per_page&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'; $media_per_page = get_user_option('upload_per_page'); if ( empty($media_per_page) ) $media_per_page = 20; $q['posts_per_page'] = $media_per_page; $post_mime_types = array( // array( adj, noun ) 'image' => array(__('Images'), __('Manage Images'), _n_noop('Image (%s)', 'Images (%s)')), 'audio' => array(__('Audio'), __('Manage Audio'), _n_noop('Audio (%s)', 'Audio (%s)')), 'video' => array(__('Video'), __('Manage Video'), _n_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 )? '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); } $post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent); // 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); } $post->filter = 'sample'; $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; unset($post->filter); 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 ( 'publish' == $post->post_status ) $view_post = 'post' == $post->post_type ? __('View Post') : __('View Page'); if ( false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%') ) { $return = '' . __('Permalink:') . "\n" . '' . $permalink . "\n"; if ( current_user_can( 'manage_options' ) ) $return .= '' . __('Change Permalinks') . "\n"; if ( isset($view_post) ) $return .= "$view_post\n"; return $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 . ''; $display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink); $view_link = str_replace(array('%pagename%','%postname%'), $post_name, $permalink); $return = '' . __('Permalink:') . "\n" . '' . $display_link . "\n"; $return .= '' . __('Edit') . "\n"; $return .= '' . $post_name . "\n"; if ( isset($view_post) ) $return .= "$view_post\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 ); } // _wp_put_post_revision() expects unescaped. $_POST = stripslashes_deep($_POST); // 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. * * @package WordPress * @since 2.7 * * TinyMCE is loaded separately from other Javascript by using wp-tinymce.php. It outputs concatenated * and optionaly pre-compressed version of the core and all default plugins. Additional plugins are loaded * directly by TinyMCE using non-blocking method. Custom plugins can be refreshed by adding a query string * to the URL when queueing them with the mce_external_plugins filter. * * @param bool $teeny optional Output a trimmed down version used in Press This. */ function wp_tiny_mce( $teeny = false ) { global $concatenate_scripts, $compress_scripts, $tinymce_version; if ( ! user_can_richedit() ) return; $baseurl = includes_url('js/tinymce'); $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', 'spellchecker', 'paste', 'wordpress', 'media', 'fullscreen', 'wpeditimage', 'wpgallery', 'tabfocus' ); /* 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 = ''; 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 . "\n"; $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') . "\n"; if ( @is_file($path . $mce_locale . '_dlg.js') ) $strings .= @file_get_contents($path . $mce_locale . '_dlg.js') . "\n"; 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 ) . "\n"; } if ( @is_file($path . 'en_dlg.js') ) { $str2 = @file_get_contents($path . 'en_dlg.js'); $strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str2, 1 ) . "\n"; } } 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' => 'specific_textareas', 'editor_selector' => 'theEditor', '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, 'gecko_spellcheck' => true, 'entities' => '38,amp,60,lt,62,gt', 'accessibility_focus' => true, 'tabfocus_elements' => 'major-publishing-actions', 'media_strict' => false, 'save_callback' => 'switchEditors.saveCallback', 'wpeditimage_disable_captions' => $no_captions, 'plugins' => "$plugins" ); $mce_css = trim(apply_filters('mce_css', ''), ' ,'); if ( ! empty($mce_css) ) $initArray['content_css'] = "$mce_css"; // 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); } if ( empty($initArray['theme_advanced_buttons3']) && !empty($initArray['theme_advanced_buttons4']) ) { $initArray['theme_advanced_buttons3'] = $initArray['theme_advanced_buttons4']; $initArray['theme_advanced_buttons4'] = ''; } if ( ! isset($concatenate_scripts) ) script_concat_settings(); $language = $initArray['language']; $zip = $compress_scripts ? 1 : 0; /** * Deprecated * * The tiny_mce_version filter is not needed since external plugins are loaded directly by TinyMCE. * These plugins can be refreshed by appending query string to the URL passed to mce_external_plugins filter. * If the plugin has a popup dialog, a query string can be added to the button action that opens it (in the plugin's code). */ $version = apply_filters('tiny_mce_version', ''); $version = 'ver=' . $tinymce_version . $version; 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,' ); ?> \n"; else echo "\n"; if ( 'en' != $language && isset($lang) ) echo "\n"; else echo "\n"; ?> 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(esc_html($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; ?> worsethanhitler/wp-admin/includes/upgrade.php0000644001761300176130000014715111225331455022230 0ustar mustardamustardaNote that password carefully! It is a random password that was generated just for you.'); $user_id = wp_create_user($user_name, $random_password, $user_email); update_usermeta($user_id, 'default_password_nag', true); } else { $random_password = ''; $message = __('User already exists. Password inherited.'); } $user = new WP_User($user_id); $user->set_role('administrator'); wp_install_defaults($user_id); $wp_rewrite->flush_rules(); wp_new_blog_notification($blog_title, $guessurl, $user_id, $random_password); wp_cache_flush(); return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password, 'password_message' => $message); } 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 = __('Uncategorized'); /* translators: Default category slug */ $cat_slug = sanitize_title(_x('Uncategorized', 'Default category slug')); $wpdb->insert( $wpdb->terms, array('name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) ); $wpdb->insert( $wpdb->term_taxonomy, array('term_id' => '1', 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1)); // Default link category $cat_name = __('Blogroll'); /* translators: Default link category slug */ $cat_slug = sanitize_title(_x('Blogroll', 'Default link category slug')); $wpdb->insert( $wpdb->terms, array('name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) ); $wpdb->insert( $wpdb->term_taxonomy, array('term_id' => '2', 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 7)); // Now drop in some default links $default_links = array(); $default_links[] = array( 'link_url' => 'http://codex.wordpress.org/', 'link_name' => 'Documentation', 'link_rss' => '', 'link_notes' => ''); $default_links[] = array( 'link_url' => 'http://wordpress.org/development/', 'link_name' => 'Development Blog', 'link_rss' => 'http://wordpress.org/development/feed/', 'link_notes' => ''); $default_links[] = array( 'link_url' => 'http://wordpress.org/extend/ideas/', 'link_name' => 'Suggest Ideas', 'link_rss' => '', 'link_notes' =>''); $default_links[] = array( 'link_url' => 'http://wordpress.org/support/', 'link_name' => 'Support Forum', 'link_rss' => '', 'link_notes' =>''); $default_links[] = array( 'link_url' => 'http://wordpress.org/extend/plugins/', 'link_name' => 'Plugins', 'link_rss' => '', 'link_notes' =>''); $default_links[] = array( 'link_url' => 'http://wordpress.org/extend/themes/', 'link_name' => 'Themes', 'link_rss' => '', 'link_notes' =>''); $default_links[] = array( 'link_url' => 'http://planet.wordpress.org/', 'link_name' => 'WordPress Planet', 'link_rss' => '', 'link_notes' =>''); foreach ( $default_links as $link ) { $wpdb->insert( $wpdb->links, $link); $wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => 2, 'object_id' => $wpdb->insert_id) ); } // 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->insert( $wpdb->posts, array( 'post_author' => $user_id, 'post_date' => $now, 'post_date_gmt' => $now_gmt, 'post_content' => __('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'), 'post_excerpt' => '', 'post_title' => __('Hello world!'), /* translators: Default post slug */ 'post_name' => _x('hello-world', 'Default post slug'), 'post_modified' => $now, 'post_modified_gmt' => $now_gmt, 'guid' => $first_post_guid, 'comment_count' => 1, 'to_ping' => '', 'pinged' => '', 'post_content_filtered' => '' )); $wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => 1, 'object_id' => 1) ); // Default comment $wpdb->insert( $wpdb->comments, array( 'comment_post_ID' => 1, 'comment_author' => __('Mr WordPress'), 'comment_author_email' => '', 'comment_author_url' => 'http://wordpress.org/', 'comment_date' => $now, 'comment_date_gmt' => $now_gmt, 'comment_content' => __('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->insert( $wpdb->posts, array( 'post_author' => $user_id, 'post_date' => $now, 'post_date_gmt' => $now_gmt, 'post_content' => __('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.'), 'post_excerpt' => '', 'post_title' => __('About'), /* translators: Default page slug */ 'post_name' => _x('about', 'Default page slug'), 'post_modified' => $now, 'post_modified_gmt' => $now_gmt, 'guid' => $first_post_guid, 'post_type' => 'page', 'to_ping' => '', 'pinged' => '', 'post_content_filtered' => '' )); } 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 = 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); } 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(); if ( $wp_current_db_version < 10360 ) upgrade_280(); maybe_disable_automattic_widgets(); update_option( 'db_version', $wp_db_version ); update_option( 'db_upgraded', true ); } /** * 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>update( $wpdb->categories, array('category_nicename' => $newtitle), array('cat_ID' => $category->cat_ID) ); } } $wpdb->query("UPDATE $wpdb->options SET option_value = REPLACE(option_value, 'wp-links/links-images/', 'wp-images/links/') WHERE option_name LIKE 'links_rating_image%' AND option_value LIKE 'wp-links/links-images/%'"); $done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $wpdb->post2cat"); if ($done_ids) : foreach ($done_ids as $done_id) : $done_posts[] = $done_id->post_id; endforeach; $catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')'; else: $catwhere = ''; endif; $allposts = $wpdb->get_results("SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere"); if ($allposts) : foreach ($allposts as $post) { // Check to see if it's already been imported $cat = $wpdb->get_row( $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->insert( $wpdb->post2cat, array('post_id' => $post->ID, 'category_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->update( $wpdb->users, array('user_nicename' => $newname), array('ID' => $user->ID) ); } } $users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users"); foreach ($users as $row) { if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) { $wpdb->update( $wpdb->users, array('user_pass' => md5($row->user_pass)), array('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->update( $wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('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 = deslash($comment->comment_content); $comment_author = deslash($comment->comment_author); $wpdb->update($wpdb->comments, compact('comment_content', 'comment_author'), array('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 = deslash($link->link_name); $link_description = deslash($link->link_description); $wpdb->update( $wpdb->links, compact('link_name', 'link_description'), array('link_id' => $link->link_id) ); } } $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->update( $wpdb->users, array('display_name' => $id), array('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->update( $wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID) ); // Some alpha versions used a post status of object instead of attachment and put // the mime type in post_type instead of post_mime_type. if ( $wp_current_db_version > 2541 && $wp_current_db_version <= 3091 ) { $objects = $wpdb->get_results("SELECT ID, post_type FROM $wpdb->posts WHERE post_status = 'object'"); foreach ($objects as $object) { $wpdb->update( $wpdb->posts, array( 'post_status' => 'attachment', 'post_mime_type' => $object->post_type, 'post_type' => ''), array( 'ID' => $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, false), '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->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') ); $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; } if ( empty($count) ) { $count = 0; $taxonomy = 'category'; $wpdb->insert( $wpdb->term_taxonomy, compact('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->insert( $wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_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->insert( $wpdb->terms, compact('name', 'slug', 'term_group') ); $term_id = (int) $wpdb->insert_id; } $link_cat_id_map[$cat_id] = $term_id; $default_link_cat = $term_id; $wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $term_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 0) ); $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->insert( $wpdb->term_relationships, array('object_id' => $link->link_id, 'term_taxonomy_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->insert( $wpdb->term_relationships, array('object_id' => $link_id, 'term_taxonomy_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->update( $wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $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'" ); } /** * Execute changes made in WordPress 2.8. * * @since 2.8.0 */ function upgrade_280() { global $wp_current_db_version; if ( $wp_current_db_version < 10360 ) populate_roles_280(); } // 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; if ( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $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! if ( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $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[trim( 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 = trim( $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; } } } ?> worsethanhitler/wp-admin/includes/manifest.php0000644001761300176130000002544711225331455022412 0ustar mustardamustardazipname = $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_TEMP_FILE_THRESHOLD => 'optional', PCLZIP_OPT_TEMP_FILE_ON => 'optional', PCLZIP_OPT_TEMP_FILE_OFF => '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; } } } // ----- Look for default option values $this->privOptionDefaultThreshold($v_options); // ----- 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' ,PCLZIP_ATT_FILE_MTIME => 'optional' ,PCLZIP_ATT_FILE_CONTENT => 'optional' ,PCLZIP_ATT_FILE_COMMENT => '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_TEMP_FILE_THRESHOLD => 'optional', PCLZIP_OPT_TEMP_FILE_ON => 'optional', PCLZIP_OPT_TEMP_FILE_OFF => '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; } } } // ----- Look for default option values $this->privOptionDefaultThreshold($v_options); // ----- 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' ,PCLZIP_ATT_FILE_MTIME => 'optional' ,PCLZIP_ATT_FILE_CONTENT => 'optional' ,PCLZIP_ATT_FILE_COMMENT => '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 exist 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', PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', PCLZIP_OPT_TEMP_FILE_ON => 'optional', PCLZIP_OPT_TEMP_FILE_OFF => '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; } } } // ----- Look for default option values $this->privOptionDefaultThreshold($v_options); // ----- 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', PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', PCLZIP_OPT_TEMP_FILE_ON => 'optional', PCLZIP_OPT_TEMP_FILE_OFF => '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]; // ----- Look for default option values $this->privOptionDefaultThreshold($v_options); // ----- 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_TEMP_FILE_THRESHOLD : // ----- Check the number of parameters if (($i+1) >= $p_size) { PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Check for incompatible options if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Check the value $v_value = $p_options_list[$i+1]; if ((!is_integer($v_value)) || ($v_value<0)) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Get the value (and convert it in bytes) $v_result_list[$p_options_list[$i]] = $v_value*1048576; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); $i++; break; case PCLZIP_OPT_TEMP_FILE_ON : // ----- Check for incompatible options if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } $v_result_list[$p_options_list[$i]] = true; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); break; case PCLZIP_OPT_TEMP_FILE_OFF : // ----- Check for incompatible options if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Check for incompatible options if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } $v_result_list[$p_options_list[$i]] = true; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$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(); } } } } // ----- Look for default values if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3,"Calculate auto threshold"); } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privOptionDefaultThreshold() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privOptionDefaultThreshold(&$p_options) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privOptionDefaultThreshold", ""); $v_result=1; if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3,"Create an auto-threshold for use of temporay files"); // ----- Get 'memory_limit' configuration value $v_memory_limit = ini_get('memory_limit'); $v_memory_limit = trim($v_memory_limit); $last = strtolower(substr($v_memory_limit, -1)); if($last == 'g') //$v_memory_limit = $v_memory_limit*1024*1024*1024; $v_memory_limit = $v_memory_limit*1073741824; if($last == 'm') //$v_memory_limit = $v_memory_limit*1024*1024; $v_memory_limit = $v_memory_limit*1048576; if($last == 'k') $v_memory_limit = $v_memory_limit*1024; $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3,"Current memory usage : ".memory_get_usage(TRUE)." bytes"); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3,"Threshold value is : ".$p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]." bytes"); // ----- Sanity check : No threshold if value lower than 1M if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3,"Unset the threshold (value ".$p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD].") because under 1Mo sanity check)"); unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]); } // ----- 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; // ----- Look for options that takes a string case PCLZIP_ATT_FILE_COMMENT : 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['comment'] = $v_value; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'"); break; case PCLZIP_ATT_FILE_MTIME : if (!is_integer($v_value)) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } $p_filedescr['mtime'] = $v_value; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'"); break; case PCLZIP_ATT_FILE_CONTENT : $p_filedescr['content'] = $v_value; ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'"); 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 : // This method look for each item of the list to see if its a file, a folder // or a string to be added as file. For any other type of files (link, other) // just ignore the item. // Then prepare the information that will be stored for that file. // When its a folder, expand the folder with all the files that are in that // folder (recursively). // 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']) { if ($v_descr['stored_filename'] != '') { $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler; } else { $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler; } } $v_dirlist_nb++; } @closedir($v_folder_handler); } 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 /* TBC : Removed 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['crc'] = 0; $p_header['compressed_size'] = 0; $p_header['filename_len'] = strlen($p_filename); $p_header['extra_len'] = 0; $p_header['disk'] = 0; $p_header['internal'] = 0; $p_header['offset'] = 0; $p_header['filename'] = $p_filename; // TBC : Removed $p_header['stored_filename'] = $v_stored_filename; $p_header['stored_filename'] = $p_filedescr['stored_filename']; $p_header['extra'] = ''; $p_header['status'] = 'ok'; $p_header['index'] = -1; // ----- Look for regular file if ($p_filedescr['type']=='file') { $p_header['external'] = 0x00000000; $p_header['size'] = filesize($p_filename); } // ----- Look for regular folder else if ($p_filedescr['type']=='folder') { $p_header['external'] = 0x00000010; $p_header['mtime'] = filemtime($p_filename); $p_header['size'] = filesize($p_filename); } // ----- Look for virtual file else if ($p_filedescr['type'] == 'virtual_file') { $p_header['external'] = 0x00000000; $p_header['size'] = strlen($p_filedescr['content']); } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header external extension '".sprintf("0x%X",$p_header['external'])."'"); // ----- Look for filetime if (isset($p_filedescr['mtime'])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3,"Overload mtime value with :'".$p_filedescr['mtime']."'"); $p_header['mtime'] = $p_filedescr['mtime']; } else if ($p_filedescr['type'] == 'virtual_file') { $p_header['mtime'] = time(); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Virtual file : use current time '".$p_header['mtime']."' for mtime value."); } else { $p_header['mtime'] = filemtime($p_filename); } // ------ Look for file comment if (isset($p_filedescr['comment'])) { $p_header['comment_len'] = strlen($p_filedescr['comment']); $p_header['comment'] = $p_filedescr['comment']; } else { $p_header['comment_len'] = 0; $p_header['comment'] = ''; } // ----- 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 ($p_filedescr['type'] == 'file') { // ----- Look for using temporary file to zip if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) { $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options); if ($v_result < PCLZIP_ERR_NO_ERROR) { return $v_result; } } // ----- Use "in memory" zip algo else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2,"In memory compression."); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2,"Current memory usage : ".memory_get_usage(TRUE)." bytes"); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2,"Current memory peak : ".memory_get_peak_usage(TRUE)." bytes"); //--(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(); } // ----- Read the file content $v_content = @fread($v_file, $p_header['size']); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2,"Memory usage after reading file : ".memory_get_usage(TRUE)." bytes"); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2,"Memory peak after reading file : ".memory_get_peak_usage(TRUE)." bytes"); // ----- Close the file @fclose($v_file); // ----- Calculate the CRC $p_header['crc'] = @crc32($v_content); // ----- Look for no compression if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be compressed"); // ----- Set header parameters $p_header['compressed_size'] = $p_header['size']; $p_header['compression'] = 0; } // ----- Look for normal compression else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will be compressed"); // ----- Compress the content $v_content = @gzdeflate($v_content); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2,"Memory usage after gzdeflate : ".memory_get_usage(TRUE)." bytes"); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2,"Memory peak after gzdeflate : ".memory_get_peak_usage(TRUE)." bytes"); // ----- Set header parameters $p_header['compressed_size'] = strlen($v_content); $p_header['compression'] = 8; } // ----- 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, $p_header['compressed_size']); } } // ----- Look for a virtual file (a file from string) else if ($p_filedescr['type'] == 'virtual_file') { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Add by string"); $v_content = $p_filedescr['content']; // ----- Calculate the CRC $p_header['crc'] = @crc32($v_content); // ----- Look for no compression if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be compressed"); // ----- Set header parameters $p_header['compressed_size'] = $p_header['size']; $p_header['compression'] = 0; } // ----- Look for normal compression else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will be compressed"); // ----- Compress the content $v_content = @gzdeflate($v_content); // ----- Set header parameters $p_header['compressed_size'] = strlen($v_content); $p_header['compression'] = 8; } // ----- 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, $p_header['compressed_size']); } // ----- Look for a directory else if ($p_filedescr['type'] == 'folder') { //--(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 : privAddFileUsingTempFile() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFileUsingTempFile", "filename='".$p_filedescr['filename']."'"); $v_result=PCLZIP_ERR_NO_ERROR; // ----- Working variable $p_filename = $p_filedescr['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(); } // ----- Creates a compressed temporary file $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz'; if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) { fclose($v_file); PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode'); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks $v_size = filesize($p_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__, 4, "Read ".$v_read_size." bytes"); $v_buffer = @fread($v_file, $v_read_size); //$v_binary_data = pack('a'.$v_read_size, $v_buffer); @gzputs($v_file_compressed, $v_buffer, $v_read_size); $v_size -= $v_read_size; } // ----- Close the file @fclose($v_file); @gzclose($v_file_compressed); // ----- Check the minimum file size //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "gzip file size ".filesize($v_gzip_temp_name)); if (filesize($v_gzip_temp_name) < 18) { PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes'); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Extract the compressed attributes if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) { PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Read the gzip file header $v_binary_data = @fread($v_file_compressed, 10); $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data); // ----- Check some parameters //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[id1]='.bin2hex($v_data_header['id1'])); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[id2]='.bin2hex($v_data_header['id2'])); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[cm]='.bin2hex($v_data_header['cm'])); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[flag]='.bin2hex($v_data_header['flag'])); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[mtime]='.$v_data_header['mtime']); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[xfl]='.bin2hex($v_data_header['xfl'])); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[os]='.bin2hex($v_data_header['os'])); $v_data_header['os'] = bin2hex($v_data_header['os']); // ----- Read the gzip file footer //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File position after header ".ftell($v_file_compressed)); @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File position at beginning of footer ".ftell($v_file_compressed)); $v_binary_data = @fread($v_file_compressed, 8); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File position after footer ".ftell($v_file_compressed)); $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data); // ----- Set the attributes $p_header['compression'] = ord($v_data_header['cm']); //$p_header['mtime'] = $v_data_header['mtime']; $p_header['crc'] = $v_data_footer['crc']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Compressed size ".(filesize($v_gzip_temp_name)-18)); $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18; // ----- Close the file @fclose($v_file_compressed); // ----- Call the header generation if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Add the compressed data if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) { PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks fseek($v_file_compressed, 10); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File position before reading compressed data ".ftell($v_file_compressed)); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, ' '.$p_header['compressed_size'].' bytes to read'); $v_size = $p_header['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__, 4, "Read ".$v_read_size." bytes"); $v_buffer = @fread($v_file_compressed, $v_read_size); //$v_binary_data = pack('a'.$v_read_size, $v_buffer); @fwrite($this->zip_fd, $v_buffer, $v_read_size); $v_size -= $v_read_size; } // ----- Close the file @fclose($v_file_compressed); // ----- Unlink the temporary file @unlink($v_gzip_temp_name); // ----- 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 = ''; } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Remove path ='".$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'])) { // ----- Remove drive letter if any $v_stored_filename = PclZipUtilTranslateWinPath($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 // Its when we cahnge just the filename but not the path 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 != "") { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Partial path to remove"); 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'"); } } } // ----- Remove drive letter if any $v_stored_filename = PclZipUtilTranslateWinPath($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']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Comment size : \''.$p_header['comment_len'].'\''); // ----- 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. // $p_info['crc'] = CRC of the file content. // 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 $v_temp_path = PclZipUtilPathReduction($p_header['filename']); $p_info['filename'] = $v_temp_path; $v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']); $p_info['stored_filename'] = $v_temp_path; $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']; $p_info['crc'] = $p_header['crc']; // ----- 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