WordPress Category Widgets plugin – display different widgets for different categories



Today, I have developed another plugin for WordPress which I named ‘Category Widgets’ plugin and as usual nothing more peaceful rather than sharing with the community.

Using this plugin, you can display a text widget for any specific category and/or its sub-categories. For example, you want to show different sidebar banners based on different category. It is easy using this plugin. Just create a new widget and select the category.

I have found another plugin for almost the same purpose. That plugin lacks of capability of displaying in the subcategories. That mean it does not work for the sub-categories of the selected category. In this plugin, I have made that feature and also optionally you can disable that feature too.

Requirements:

  1. WordPress 2.8+

Download:

Continue reading

Bookmark: bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Posted in Open Source, PHP, Scripts | Tagged , , , , , , , , | 11 Comments

Solution for “M2M authentication error – password invalid (code: 823)” error in OpenX



If you receive the error “M2M authentication error – password invalid (code: 823)” in your installation of OpenX, you can solve it quite easily.

Suppose, your OpenX is installed at: www.yourdomain.com/adserver/

then call the following link:

www.yourdomain.com/adserver/regenerate-platformhash.php

Once your platform hash is re-generated, you should not see the error message again.

Bookmark: bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Posted in PHP, Troubleshooting | Tagged , , , , , , , | 2 Comments

Passing filename arguments to PHP from shell and space issue…

Today, while working with a project to import thousands of articles from text files to wordpress,  I had faced a trouble while I am executing a shell script to iterate through all text files and call a PHP script with sending the filename as argument. The PHP script would then process the file as our requirement. The shell script looked like:

for i in `find . -type f -name ‘*.txt’`;

do

php import_posts.php $i

done

Here, $i would be the filename and it is passed to PHP script for processing. But the problem is that, when the filename (including directory name) consists any whitespace in its name, the script would broken. For example, some files path looked like
/home/user/articles/Internet Business/Web Hosting/how_to_start_your_company.txt

Here, notice the space after Internet and Web. The shell script was breaking just after Internet. It was sending /home/user/articles/Internet as argument to PHP script and obviously PHP script was failed to find this file.

After searching a lot, finally I found a solution.

It was really simple. I am quoting from his blog:

If none of your files or folders have spaces in their names, then this isn’t a problem, but that is increasingly unlikely nowadays.  If your songs do have spaces in their filenames, then the solution is to change how the shell splits that output.  This is controlled by the variable $IFS, which is set to spaces, tabs, and newlines by default.  We’d like it set to just newlines, so we do:

So, here is the solution. I just put the following line at the top of my shell script.

export IFS=$’\n’

After that everything is fine. The script is running exactly how I intended it to run.

Thanks for Anthony for his solution.

Bookmark: bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Posted in Linux, Open Source, PHP, Tutorial | Tagged , , , , , , , , , , , , , , , , | Leave a comment

PunBB Topic Ownership Change extension

Just now I have developed a small extension for PunBB that will let admins and moderators to change the ownership of any topic. As usual, I made it for Projanmo Forum but it is always pleasing to share with the community :) .

It is very simple plugin. Just upload and activate the extension. Then if you view any topic with, at least, moderation privilege, you will see a link ‘Change Topic Owner’. When you click on it, you will be asked to enter new User’s ID (check the image below). Once you enter and hit Ok, you will be redirected to a new page where either the ownership will be changed or corresponding error message will be shown.

Note: This will not affect users’ post count.

Download
or,
Download

Bookmark: bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Posted in Open Source, PHP, Scripts | Tagged , , , , , , , , | 4 Comments

Meditation Course from Quantum Foundation

I have a very very long plan to attend the meditation course offered by Quantum Foundation. From the 2nd year of my university life, I was planning to take the course. But I could not attend as my willingness, time and abilities did not match.

However, at the 2nd week of April, 2010, I have decided firmly that I must attend the upcoming course on April 16-19, 2010. It is because, from May, 2010 it will be totally uncertain where I will stay. I have so firm on my decision that I have even canceled the trip to Birishiri, Netrokona with my photography team.

On 12th April, I contacted Rabbit to book a seat for me. It seemed he was excited by hearing my decision :) . Then I meet him at Charukola, DU on 14th April and paid the course fee. On 16th May I wake up early (very hard for me indeed ;) ) and headed for Marriot Convention Centre. I reached there ahead of time and contacted Rabbit who helped me managing my workshop ID.

The first day was not nothing new at all, as I almost habituated with those of meditation and was practicing at home from long ago. But I was in some physical trouble which continued to 2nd day too. I was enjoying the lectures by Guruji Mohajatak Shahid Al Bokhari!

The third and forth day was more enjoying as I could realize my inner strengths.

Finally, I became Quantum Graduate and got certificates and ID card.

At late evening, another meeting was scheduled earlier by Guruji to meet all quantum members who are in the IT industry, specially web development sector. We all gathered in the “Proshanti Hall” of Quantum Meditation at Shantinagar! Interesting to know that we almost all were known to each other :) .

Bookmark: bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Posted in My Life, Workshop/seminar/tech session | Tagged , , , , , , , , , , | 1 Comment

Workshops on Photography – PhotoJAMM – April 2010 organized by PhographyBD

Today I had passed a busy day. At 9.00 am I headed for Dhaka University campus. However, I had to walk most of the path :( as the traffic system disallowed vehicles to the spot for comfortable movements of huge huge crowd. I became lazy and took a few shots only as it was too crowded for photography!

Afternoon, at 3.00pm,  I headed to Elephant Road for the Workshop on Photography. It started at huge late. But when it started, it was getting awesome every moments.

Basically, I was the only novice there. All others were advanced photographers. However, they were so friendly and helpful. The main topic was on Depth of Field. Earlier this workshop, I have read many articles, tutorials, blogs on Depth of Field but I could never take it inside of my brain. However, today’s one was exceptional. I believe now I am very confident about Depth of Field of Photography. I made some questions fearing they will treat me as jerk. I wondered, they did not do that. They explained all of my questions in very friendly manner.

The second session of the workshop was about Criticism of photos. A few of us brought photos that were apprised and criticized as per their merit. I can’t believe any criticism can be such friendly and detail!

I have also brought 3 photos. Experts has given their comments, advices and suggestions on my photos that will help me taking better snaps and in post shots processing.

The 3rd session was general questions and answers. Anyone can ask anything regarding photography.

I am very excited that such workshops are going to be arranged biweekly. It means, more great learnings on coming days!

Bookmark: bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Posted in Workshop/seminar/tech session | Tagged , , , , , , , , , | Leave a comment

Attended Tech Seminar “Web & Software Industry Opportunities – Beyond 2010″

Last evening, I have attended a seminar titled “Tech Seminar : Web & Software Industry Opportunities – Beyond 2010″ arranged by Blueliner Bangladesh,  hosted by CSE Department, BRAC University.

The seminar covered 4 sessions. Those were:

Continue reading

Bookmark: bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Posted in My Life, PHP, Workshop/seminar/tech session | Tagged , , , , | 3 Comments

Articlesnatch.com scraping tutorial, getting full article

In my last three tutorials I have discussed how to scrap contents from www.articlebase.com. In this part, I will show how to scrap contents from www.articlesnatch.com. However, unlike the previous tutorials, I will not use DOMDocument in this part. I will not use regular expressions either.

I will show how to get full article. I won’t show how to get articles/links under any category as articlesnatch.com offers feed for each category. So it is easy to get article summary and links of any category. As the feed does not include full text, I will just show how to get it.

Getting Article Body

$html = file_get_contents($link);

We need the contents that is within the div with a class named “KonaBody”. That mean, our target contents are within:

<div class=”KonaBody”>

……

……

</div>

So, we may remove anything before this div.

$desc = strstr($html,’<div class=”KonaBody”>’);

Continue reading

Bookmark: bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Posted in PHP, Tutorial | Tagged , , , , , , , , , , , | 1 Comment

Smarter DOMDocument for PHP

PHP 5 includes a great built in class DOMDocument to DOM parsing of HTML/XML document. The class includes a number of methods to easily traversing a DOM.

However, it has a few shortfalls like it fails to handle encoding correctly and includes some tags which may often seem irritating for developers.

Artem Russakovskii has made an extension (named SmartDOMDocument) of this class to eliminate such shortcomings. His class inherits the built in DOMDocument and includes a few extra methods that may make developers life peaceful.

Extra Features of SmartDOMDocument


saveHTMLExact()

DOMDocument has an extremely badly designed “feature” where if the HTML code you are loading does not contain <html> and <body> tags, it adds them automatically (yup, there are no flags to turn this behavior off).

Thus, when you call $doc->saveHTML(), your newly saved content now has <html><body> and DOCTYPE in it. Not very handy when trying to work with code fragments (XML has a similar problem).

SmartDOMDocument contains a new function called saveHTMLExact() which does exactly what you would want – it saves HTML without adding that extra garbage that DOMDocument does.

Encoding Fix

DOMDocument notoriously doesn’t handle encoding (at least UTF-8) correctly and garbles the output.

SmartDOMDocument tries to work around this problem by enhancing loadHTML() to deal with encoding correctly. This behavior is transparent to you – just use loadHTML() as you would normally.

Continue reading

Bookmark: bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Posted in PHP | Tagged , , , , , , , , , | 1 Comment

Articlebase.com scraping tutorial – part 3, getting full article

In the first part, I have shown how to get links under any category. In the second part, I have shown how to get links for any search term.  In this part, I will show how to fetch a full content.

Le’ts get the html.

$link = ‘artcile_base_article_link’;

$html = file_get_contents($links);

Now, create the objects.

$dom = new DOMDocument();
@$dom->loadHTML($html);
$xpath = new DOMXPath($dom);

Continue reading

Bookmark: bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Posted in Tutorial | Tagged , , , , , , , , , | Leave a comment