Archive for June, 2008

Solving Certificate Export Error in Mozilla Firefox

Monday, June 30th, 2008

Today I’ve got the message from Webmoney Transfer System that I should update my certificate in order to continue using them (Webmoney is a Russian electronic payment system). I have installed new certificate in Firefox (since it is my default browser) and then tried to export it in order to use it in Opera or any other browser. But the following screen has appeared:

I think everybody loves the following string in an error message: “for unknown reason”. I had to search for it in Google, but unknown reason remained an unknown reason. I’ve found a mailing list for Ubuntu (!) - I was dealing with Firefox in Windows. Here is what i found: Bug. I’ve had absolutely no idea how to fix this unknown error.

The only thing that worked was to disable ALL Firefox add-ons that I have installed. None of them had anything related to certificates, but it really worked! I was able to export my certificate only after this procedure.

Hope this will help you if you face this error exporting your certificates.

Two Ways to Exclude yum Updates

Sunday, June 29th, 2008

How often do you update your Linux server software? If you have chosen yum to do this for you, you should have some packages that aren’t really necessary for update; they can even cause yum errors. In order to exclude some packages you should use of two methods proposed in this post.

The first one is to add excluded packages to the command line while running yum from console. This should look like:

yum –exclude=rhythmbox

The second way is to add excluded packages to yum configuration file. Just add a line like this to /etc/yum.conf:

exclude=rhythmbox syslinux etc

The second method is better if you periodically update your server software. For a one-time execution the first method will be much better.

A List of Ping Services for Your Blogs

Sunday, June 29th, 2008

This time I will tell you some services for pinging your blogs. Here it is; though it is not the most complete list, I hope it will help you to add your blogs to search engines.

http://rpc.pingomatic.com/
http://api.feedster.com/ping
http://api.moreover.com/RPC2
http://api.moreover.com/ping
http://api.my.yahoo.com/RPC2
http://api.my.yahoo.com/rss/ping
http://www.bitacoles.net/ping.php
http://bitacoras.net/ping
http://www.blogdigger.com/RPC2
http://blogmatcher.com/u.php
http://www.blogoon.net/ping/
http://www.blogshares.com/rpc.php
http://www.blogstreet.com/xrbin/xmlrpc.cgi
http://bulkfeeds.net/rpc
http://coreblog.org/ping/
http://www.lasermemory.com/lsrpc/
http://mod-pubsub.org/kn_apps/blogchatt
http://www.newsisfree.com/xmlrpctest.php
http://ping.amagle.com/
http://ping.bitacoras.com
http://ping.blo.gs/
http://ping.exblog.jp/xmlrpc
http://ping.feedburner.com
http://ping.syndic8.com/xmlrpc.php
http://ping.weblogalot.com/rpc.php
http://ping.weblogs.se/
http://www.popdex.com/addsite.php
http://rcs.datashed.net/RPC2/
http://rpc.blogrolling.com/pinger/
http://rpc.icerocket.com:10080/
http://rpc.technorati.com/rpc/ping
http://rpc.weblogs.com/RPC2
http://www.snipsnap.org/RPC2
http://topicexchange.com/RPC2
http://xping.pubsub.com/ping/
http://xmlrpc.blogg.de/
http://blogsearch.google.com/ping/RPC2
http://rpc.qwikping.com
http://rpc.britblog.com
http://rpc.tailrank.com/feedburner/RPC2
http://pingoat.com/goat/RPC2
http://pinger.blogflux.com/rpc/
http://blogdb.jp/xmlrpc
http://www.blogpeople.net/servlet/weblogUpdates
http://www.blogroots.com/tb_populi.blog?id=1
http://ping.fakapster.com/rpc
http://blog.goo.ne.jp/XMLRPC
http://www.mod-pubsub.org/kn_apps/blogchatter/ping.php
http://ping.bloggers.jp/rpc/
http://ping.blogmura.jp/rpc/
http://ping.myblog.jp
http://rpc.blogbuzzmachine.com/RPC2
http://trackback.bakeinu.jp/bakeping.php
http://api.feedster.com/ping.php
http://bblog.com/ping.php
https://phobos.apple.com/WebObjects/MZFinance.woa/wa/pingPodcast
http://pingqueue.com/rpc/
http://ping.blogg.de/
http://rpc.britblog.com/
http://rpc.newsgator.com/
http://rpc.wpkeys.com/
http://services.newsgator.com/ngws/xmlrpcping.aspx
http://signup.alerts.msn.com/alerts-PREP/submitPingExtended.doz
http://www.imblogs.net/ping/
http://www.newsisfree.com/RPCCloud
http://www.rssfwd.com/xmlrpc/api
http://xmlrpc.blogg.de

Usually Wordpress does the ping automatically, but not all blog search engines are pinged.

Here is the data you need to send to these services:

<?xml version=”1.0″?>
<methodCall>
<methodName>weblogUpdates.extendedPing</methodName>
<params>
<param>
<value>The &amp;nbsp; Space in Paulo</value>
</param>
<param>
<value>http://nbspsaopaulo.example.com/</value>
</param>
<param>
<value>http://nbspsaopaulo.example.com/content.html</value>
</param>
<param>
<value>http://ilovesaopaulo.example.com/index.rss</value>
</param>
</params>
</methodCall>

If you decide to create your pinger (I will show you how to do this some time later), this data will be extremely useful.

How to Delete a Big Number of Files in a Folder - Linux Command

Saturday, June 28th, 2008

If you’re using temporary files you should notice that after some time it is hard to delete them as their number is growing. If you have many files and try to delete them with a usual command rm -f you should receive something like this:

[root@server html]# rm -f *
-bash: /bin/rm: Argument list too long

What to do when this occurs? You have to combine several Linux commands in order to empty this folder. Here is the command you should use; I will explain what does it do below.

[root@server html]# ls | grep .| xargs rm

This will do the following: the first command ls outputs the list of files. The output is being sent to grep command so you won’t see it in your console. Grep searches for files with “.” symbol (in the example given I think that all your files have so named extension - filenames contain a dot. So grep will extract all the file names that contain a dot and will throw them to the next function - xargs. xargs accepts these filenames and deletes them one by one. This allows to reduce server load and gives us the possibility to delete multiple files in one folder that are no longer necessary.

Setting Custom Error Pages for All User Domains with .htaccess on a Directadmin Server

Wednesday, June 25th, 2008

Sometimes it is useful to use custom error pages on all user domainsĀ  (In case of maintenance, new software installation, etc). It’s a pity you are unable to do it for all user domains in Directadmin, just for a single one. But htaccess comes to help us this time.

Go to /home/admin/domains (certainly, replace admin with your username) and create a .htaccess file containing the following code:

ErrorDocument 404 http://google.com

This code will be valid for all domains that are owned by this user, so you don’t need to change your custom error pages one by one.

It’s a pity Directadmin doesn’t have any options for bulk domain options, i.e. bulk domain addiction, bulk DNS modification, etc. Bulk error code setting could also be a nice feature for such a panel and hope it will be realized soon

How to Decode Javascript Escaped Text with PHP

Saturday, June 21st, 2008

Recently I had to decode a string that was encoded with javascript, using ascii codes of symbols. In JavaScript everything looks simple - unescape() allows to get a readable string. But I had to do it with PHP and the first thought was to use chr and ord functions. But there was a simple solution as usual.

I had to use urldecode to obtain readable text from JavaScript escaped string. Though my string was not an URL, everything went well. So this function might be useful not only for URL decoding, but also helps to deal with Javascript encoding.

Checking Google Pagerank with PHP

Thursday, June 19th, 2008

Today I’ll show you the script that allows to get Google Pagerank value for any site you like. Note, that Google limits the number of toolbar queries per IP per day.

<?php
function StrToNum($Str, $Check, $Magic) {
$Int32Unit = 4294967296;
$length = strlen($Str);
for ($i = 0; $i < $length; $i++) {
$Check *= $Magic;
if ($Check >= $Int32Unit) {
$Check = ($Check - $Int32Unit * (int) ($Check / $Int32Unit));
$Check = ($Check < -2147483648) ? ($Check + $Int32Unit) : $Check;
}
$Check += ord($Str{$i});
}
return $Check;
}

function HashURL($String) {
$Check1 = StrToNum($String, 0×1505, 0×21);
$Check2 = StrToNum($String, 0, 0×1003F);

$Check1 >>= 2;
$Check1 = (($Check1 >> 4) & 0×3FFFFC0 ) | ($Check1 & 0×3F);
$Check1 = (($Check1 >> 4) & 0×3FFC00 ) | ($Check1 & 0×3FF);
$Check1 = (($Check1 >> 4) & 0×3C000 ) | ($Check1 & 0×3FFF);

$T1 = (((($Check1 & 0×3C0) << 4) | ($Check1 & 0×3C)) <<2 ) | ($Check2 & 0xF0F );
$T2 = (((($Check1 & 0xFFFFC000) << 4) | ($Check1 & 0×3C00)) << 0xA) | ($Check2 & 0xF0F0000 );

return ($T1 | $T2);
}

function CheckHash($Hashnum) {
$CheckByte = 0;
$Flag = 0;

$HashStr = sprintf(’%u’, $Hashnum);
$length = strlen($HashStr);

for ($i = $length - 1; $i >= 0; $i –) {
$Re = $HashStr{$i};
if (1 === ($Flag % 2)) {
$Re += $Re;
$Re = (int)($Re / 10) + ($Re % 10);
}
$CheckByte += $Re;
$Flag ++;
}

$CheckByte %= 10;
if (0 !== $CheckByte) {
$CheckByte = 10 - $CheckByte;
if (1 === ($Flag % 2) ) {
if (1 === ($CheckByte % 2)) {
$CheckByte += 9;
}
$CheckByte >>= 1;
}
}

return ‘7′.$CheckByte.$HashStr;
}

function getch($url) { return CheckHash(HashURL($url)); }

function check_pr($url)
{
$googlehost=’toolbarqueries.google.com’;
$user_agent=”Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14″;

$ch = getch($url);
if ($ch)
{
$googleurl=’http://’.$googlehost.’/search?client=navclient-auto&ch=’.$ch.’&features=Rank&q=info:’.$url;
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $googleurl);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$data = curl_exec($ch);
curl_close($ch);
if(!substr_count($data, “Rank_”))
return (’n/a’);
else
{
$pos = strpos($data, “Rank_”);
$pr=substr($data, $pos + 9);
$pr=trim($pr);
$pr=str_replace(”\n”,”,$pr);
return $pr;
}
}
}
?>

The most flexible function here is check_pr. Though it accepts ony one argument, you can modify it in the way you lilke. Especially, instead of $googlehost=’toolbarqueries.google.com’; you can enter any Google datacenter to query about pagerank.

How To Run a Previously Entered Command in Linux

Tuesday, June 17th, 2008

Let’s say you’ve issued a long command and don’t want to type it again. I think you know that all linux commands entered could be shown by issuing history command. History outputs an ordered list of commands that were executed before by current user.

In order to find the command you want, you should enter the following:

history | grep <anything you entered>

This will perform a short search within your command list and will return matching commands with their numbers. Now all you need is to select a command you need and run

!<number of command>

This allows to run the command under this number in such a simple way. You certainly can use up and down arrows to search for a previously entered command, but this will take much more time than using history.

In order to use a previously entered command, enter the following:

!!

This might be dangerous as you cannot be always sure which command was executed before, so better view it before executing.

How To Deny Directory Listing Using .htaccess

Monday, June 16th, 2008

Often when you’re using shared hosting, there are some problems with directory listing. Server administrators should avoid this as this represents a security hole. But what to do if you don’t have access to httpd conf and need to prevent directory listing? What to do if you have something like this:

A simple string in .htaccess file will save you. Here it is:

IndexIgnore *

In some cases the following string will also work:

Options -Indexes

One of these two solutions will lead you to showing 403 error to the user that tries to look what files are located in your directory. But let me repeat - this is a security hole and you should notify your system administrator about this issue. This is an emergency solution…

Viewing Pagerank with Opera Browser

Monday, June 16th, 2008

If you often need to know Pagerank of web pages you visit you might use Firefox with Google Toolbar, The same toolbar for IE, or Firefox Plugins like Seoquake. But if your browser is Opera there is a solution for Pagerank viewing. It is Opera Pagerank button. This is a piece of javascript code for Opera that queries Google toolbar service for Pagerank and displays it. Here is how it looks like:

Pagerank results are displayed in a small window that pops up in the top left corner of Opera. Note that this button will not work if JavaScript is turned off. You may place the button anywhere you want, I prefer to put it near the address bar.

I’ve seen some new widgets for Opera, but this one seems to work more stable. Note, that Google has limits on number of toolbar queries per IP per day, but if you just use browser I don’t think you can reach this limit.