web analytics

I have a small plugin, what provided a shortcode to the editor, to show phone numbers  in the posts asa dinamically created image.

The plugin uses a php file, what creates the image based on the url parameters.

In an installation, the browsers was not showed the images, and when we tried to call the php directly from the browser, we got 404 error. The file was on the appropriate place, under the plugins folder.

After some investigation I found the following rows in the cpanel error log;
[Wed May 09 10:02:01 2012] [error] [client x.x.131.2] SoftException in Application.cpp:601: Directory “/home/site/public_html/wp-content” is writeable by group, referer: http://www.site.ie/wp-content/plugins/utdplugin1/callus.php?number=01825990
[Wed May 09 10:01:59 2012] [error] [client x.9x2.131.2] SoftException in Application.cpp:601: Directory “/home/site/public_html/wp-content” is writeable by group

Based on these messages I checked the permissions of the wp-content folder, and saw, that has been set to 777.

Changing the permissions to 755 has been fixed the problem.

On a site, what used Continuum theme, the designer show me an interesting problem. In the category archive there was 13 pages, and the first ten page worked correctly, but after the 11th, we got 404 errors on all pages. First I checked the count of the posts in the related category, and saw, the paginator calculated the number of pages correctly.

I thought the permalink structure is correct, and the problem not related with the theme. But what can cause this kind of malfunction?

(more…)

I made a short javascript function to replace accented letter with regular ones, and change all special characters to an underscore, but that did not worked correctly.

function removeAccents(mytext)
{   
    mytext=mytext.replace(new RegExp(/[őóö]/ig) ,’o');
    mytext=mytext.replace(new RegExp(/[úűü]/ig) ,’u');
    mytext=mytext.replace(new RegExp(/[á]/ig) ,’a');
    mytext=mytext.replace(new RegExp(/[í]/ig) ,’i');
    mytext=mytext.replace(new RegExp(/[é]/ig),’e');
    mytext=mytext.replace(new RegExp(/[^a-zA-Z 0-9 ]+/g),” “).replace(new RegExp(/\s+/g),”_”);
    return mytext;
}

The script has very strange behavior. When I tried to use on a string what contained accented letters, the script did not changed them to regular ones, but handle them as special characters.

When I tried to debug the script, I saw, the mytext variable never got the new value after the replaces, only after the last one. When I used the function in the Watch Expression tab, that give back the appropriate value, but didn’t when I run the script on normal way. I tried the script in more browsers, and all test had same result.

After some rest, I tried to find the problem again, and finally found the solution.

I stored the javascript code in a separate file, what was not UTF8 encoded, while the main html page, where I used the script was that.

On the firebug, everything seemed fine, but the encoding difference was enough to cause this hard-to-find reson.

 

On a new site the owner tried to use the mappress plugin to show maps to the posts.
The plugin seemed to works well, but the maps did not loaded properly. Sometimes the half of them loaded, sometimes nothing. In firefox, when I opened the firebug, the rest of the map loaded immediately. Based on these information, I knew the problem somewhere around the order of loading and running javascript scripts, but because the site used very lot of plugins I did not want to start to investigate where is the conflict. So I decided to add one more plugin, to solve this problem for me.
(more…)

I had a script to manipulate images, what worked without problem, but one day, the script stopped to work, and did not created the images appropriately anymore.

After several housr of investigation, I found the reason of the problem.

The script used the IMAGEPNG command to create the images.On this part I set the quality parameter to 100. Ok I know, I know, this parameter can accept values between 0 and 9 only, but I forgot this, and used the parameter as we can use at the IMAGEJPG command.

Why did not got error earlier? Because while the server used PHP4, the system worked well, and created the image without problem, but one day the system administrator changed the PHP version to the version 5.

Under PHP5, the IMAGEPNG still created the file what needed, but saved only 33 bytes to the file, and did not create the image properl, without any error messages.

So, to fix the issue, had been enough to change the quality value to the needed range.

 

imagepng($image,$filename,8); PHP4    PHP5    
imagepng($image,$filename,100); PHP4   PHP5     X

I hope this small information can save lot of time, to find, why did not work your script when tries to create a PNG file.

Sometimes I get requests to make changes on an IonCube protected script, but the protection prevents us, to do this.

In some cases we can make smaller changes with and easy solution.

Firts we have to make a wrapper for the protected PHP, what contains the include for that.

 

Example;

The name of the protected PHP is PROTECTED.PHP.

We have to make a wrapper what includes the original file, but before we use the include, we have to turn on the output buffering, so the server wont send the output to the browser immediately, only when reached the end of the script, or when we force this.

 

ob_start(); // Turn on the output buffering

include “PROTECTED.PHP”; // include the IonCube protected script

$output=ob_get_clean(); // read the HTML output to a string variable and clear the contents of the buffer

$new_output=str_replace(“old text”,”new text”,$output); // change the content of the HTML output

echo $new_output; // send out the changed string into the buffer

ob_end_flush(); // send the buffer content out to the browser, and turn off the output buffering.

 

 

On this way, you can easily make smaller changes on the output of a protected script.

 

 

 

 

I had a work, when the customer wanted to add watermark to the uploaded images. I tried some solutions, and finally found that one, what works well. What we need for this task? A png image what contains the watermark image. This must be transparent background, and semi transparent image, otherwise the result won’t be watermark, just an image what merged with another. We need a form too, to upload the image, and a script, what process the request, and add the watermark to the uploaded image.

(more…)

Classipress is a very useful wordpress theme from AppThemes, what add functionality to the sites to post and manage ads. The theme had gateways for lot of payment methods, but there isn’t contains the PayGol payment gateway. The PayGol is a sms based micro-payment solution, with lot of configurable options.

(more…)

I had to expand a site to handle SEO-friendly URL-s. The site was not based on a CMS, but had lot of posts in the database, so I had to do something what isn’t change the actual structure, because the site had lot of references from other sites.

I solved the problem with two easy steps.

(more…)

I have to add some extension to a site, to post tweets onto the site’s Twitter account, when a new post submitted. I tried some version, first the old way with curl, then some versions with oAuth, but all solution based on a manual user login. I don’t want to force the site admin, to every time log in to the twitter too, when submits a post.

Finally I found the most easy solution, what don’t need any specialties. The solution is based on the post of Jaisen Mathai http://www.jaisenmathai.com/articles/twitter-php-oauth.html

(more…)