Category: Wordpress

Last.fm RPS WordPress Plugin

I’ve completely rewritten the plugin after 8 years, because the code was targeting PHP4 platforms and now it should work with all PHP5+ versions.

Still does the same thing: Its a widget plugin which collects data from Audioscrobbler web services and gets your last listened tracks and their album images.

Download : You can get the latest release here : http://wordpress.org/extend/plugins/lastfm-rps/

Then just activate the plugin, go to Design-Widgets, add the widget where you want, write the username and widget title in the settings and save. That’s all.

Current Version : 2.0.0

Demo : You can see a working example in the right sidebar.

Refresh wp_editor instance after cloning

While I was working on an extension within Redux Framework, I needed to initialize uninitialized copies of wp_editor instances to apply lazy loading. First I loaded uninitialized types of jQuery fields on the page, then I cloned them and and initialized them to have multiple forms in jQuery accordions. Everything was easy until I came to initialize wp_editor instance, because it was already initialized by wordpress, and you needed to give that field new parents, new id, and make it all work again. So, I developed this code to initialize a already-initialized wp_editor instance in a different DOM parent:

$(element).parents(".wp-editor-container").empty().append($(element));
        var ed_id = $(element).attr("id");
        //  find if an instance with the same id was created before, and remove it.
        // -------------------------------------------------------------------------
        // it's a critical point when the users adds a group item, and then removes it, and then re-adds the group,
        // then this item would have an already-created editor instance on the memory. To work things correctly, we
        // must remove it first completely from the memory, and then recreate it.
        for(var ed_instance_idx = tinymce.editors.length-1; ed_instance_idx >= 0; ed_instance_idx--){
            if(tinymce.editors[ed_instance_idx].editorId === ed_id){
                tinymce.remove(tinymce.editors[ed_instance_idx]);
            }
        }
        // create editor settings with using the dummy editor settings as reference
        tinyMCEPreInit.mceInit[ed_id] = JSON.parse(JSON.stringify(tinyMCEPreInit.mceInit[$(element).data("old-id")]));
        tinyMCEPreInit.mceInit[ed_id].body_class = ed_id;
        tinyMCEPreInit.mceInit[ed_id].elements = ed_id;
        tinyMCEPreInit.mceInit[ed_id].id = ed_id;
        tinyMCEPreInit.mceInit[ed_id].mode = "tmce";
        // initialize wp_editor tinymce instance
        tinymce.init(tinyMCEPreInit.mceInit[ed_id]);

        // create quicktags instance with using the dummy editor instance settings
        tinyMCEPreInit.qtInit[ed_id] =JSON.parse(JSON.stringify(tinyMCEPreInit.qtInit[$(element).data("old-id")]));
        tinyMCEPreInit.qtInit[ed_id].id = ed_id;
        // make the editor area visible
        $(element).addClass('wp-editor-area').show();
        // initialize quicktags
        new QTags(ed_id);
        QTags._buttonsInit();
        // force the editor to start at its defined mode.
        switchEditors.go(ed_id, tinyMCEPreInit.mceInit[ed_id].mode);

It copies it’s data from the dummy field (the clone source), so when cloning, don’t forget to retrieve it’s ID from somewhere (I used [highlight]$(element).data(“old-id”)[/highlight] inside the element to pass to the clone). Another option here is choosing the default editor to show:

tinyMCEPreInit.mceInit[ed_id].mode = "tmce";

line of this script shows that all the clones would return to “TinyMCE” editor as default visible edior on cloning. You may change that to “html” if you want to make the code/text editor as default after cloning.

about costabrava hack and some fix.


Türkçe:
Hostunuzdaki bütün php dosyalarınıza eval ve base64_decode kodunu kullanan ve google’da sitenizi aratıp linkinize tıkladığınız zaman costabrava diye bir siteye yönlendiren bir enfeksiyonunuz varsa altta paylaştığım fixcosta.rar dosyasını açıp içindeki PHP dosyasını hostunuza yüklüyorsunuz ve çalıştırıyorsunuz. sitenizdeki zararlı kodlar (eğer modifikasyona uğramamamışsa) temizleniyor.

Kaynak olarak http://redleg-redleg.blogspot.com/p/simple-script-to-find-base64decode-in.html adresindeki virüs bulucu kodu kullandım ve üzerine temizleyen kodu ekledim.

Daha sonra, eğer hostunuzda wordpress kurulu ise ve temalarınız arasında TwentyTen teması varsa, ve kullanmıyorsanız, silin.

 

English: Today I had this on my server and needed to fix like a hundred files which are infected with some nasty redirection script. So I wrote this php file to remove all the injected codes from my php files and I decided to share with you.

You can check if your server is infected or not by googling your web site and then clicking the link. If it opens your site, it’s ok. But if it redirects to “costabrava.bee.pl“, your server is infected. You should do something.

Its based on http://redleg-redleg.blogspot.com/p/simple-script-to-find-base64decode-in.html which finds the infected files, and I added the code to remove the costabrava.bee.pl header.

First, download the code below here and unrar it. there’s one php file named “fixcosta.php” and upload it into your server’s root directory. then run it.

Second, if you’re not using TwentyTen theme, delete the folder from wp-content/themes.

This’ll fix it for now. Then you should search how the hacker got into your ftp and uploaded these files. And find a fix for that too.

pngfix WordPress Plugin

This plugin uses CSS technique to fix the png image transparency issue and jQuery to apply this script to all of png images shown in the page. The CSS code added by the script is :

.png {
background-image: expression(
this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + (this.tagName==\'IMG\' ? this[\'src\'] : this.currentStyle[\'backgroundImage\'].split(\'\"\')[1]) + ")",
this.runtimeStyle.backgroundImage = "none",
this.src = "{plugindir}/pixel.gif",
this.width = this.style.width | this.clientWidth,
this.height = this.style.height | this.clientHeight
);
}';

And the jQuery code which applies this css to all of the png images :

$(document).ready(function(){
if(($.browser.msie)&(parseInt($.browser.version)<7)){
$("img[src$='.png']").each(function(){$(this).addClass("png");});
}
});

That’s all. The jQuery library is included in the plugin so you don’t need to modify anything.

Installation is simple. Just follow these steps :

  1. Upload ‘wp-pngfix’ directory to the ‘/wp-content/plugins/’ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Thats all. Go to any page which contains some png images with IE and check if there’s any errors.

This should fix them all except backgrounds now.

Download: Official WordPress plugin page : http://wordpress.org/extend/plugins/wp-pngfix/

Note: This type of fixes cause slight color changes to your png images with background color, so you may have to change some css.If you use images without inner backgrounds and only need to show the background transparent, forget that note 🙂

Last.fm RPS

Follow me on Twitter

GiottoPress by Enrique Chavez