Archive for the “Programming” Category

All about the progress of the programming from PhSoftware.

As I found out within the last days it isn’t that easy to find informations about how to connect Java through JDBC with a DB2 Database remotely. So if you should come into these troubles as well, take care of this:

As DB2 driver you need to use COM.ibm.db2.jdbc.net.DB2Driver which is located in the same file (db2java.zip) as the default driver(COM.ibm.db2.jdbc.app.DB2Driver) which is “promoted” on most sites. The problem with these two drivers is that they’re not able to work with the other kind of connection. So If you inserted the net driver you can’t create local connections and vice versa. If you want to be flexible you need to use as driver com.ibm.db2.jcc.DB2Driver which is capable to handle both types of connections. The driver can be found within the db2jcc.jar file, which should be located in the same place as db2java.zip. At least for me it was further needed to provide a license in order to establish a remote connection, to achieve this add a file called db2jcc_license_cu.jar or maybe some file which is similiar named to your Classpath.

Connection string: After some search I found the DB2 page where the remote connection string was described. The string has follow this scheme for remote connections:jdbc:db2://SERVERNAME:PORT/DATABASE Not sure if can leave the DATABASE and run later a Connect to DATABASE Query. At least my quick tries resulted each time with an Exception caused by wrong connection strings.
If you don’t know on which port your DB2 Instance is running take a look at your /etc/services and look for the corresponding line

Now you should be ready to successfully open a remote Connection.

Tags: none

Tags: DB2, Java, JDBC, remote Connection

Comments No Comments »

Recently I had to build a Joomla based website, the applied template was quite ok except the problem that the good looking HTML background was taken into account for the print page. Which is quite bad, a few searches later I got first useable results on adding a new Stylesheet with the media="print" attribute set. Unfortunately this only works if the user presses the print Button within his browser, it’s not working for the Joomla build-in print preparation. As the standard templates for Joomla seem to avoid that problem there needs to be a solution, finally I found that entry: Customizing Print Popup on docs.joomla.org which revealed the magic behind the problem. You need to add/modify the Component.php file within your template.

Hope this helps the one or other, and hopefully will pop over the retired solutions for Joomla earlier than 1.5.

Tags: none
Tags: customize, Joomla

Comments No Comments »

Somedays it’s really hard to come along with Linux, it’s apps and tools. Recently I’ve tried to use AuthMySQL for authentication within a certain webfolder. To reach this, many trails and even more errors were needed :( .

The first point was to configure the module correctly, which isn’t that easy, as no post tells which version of AuthMySQL is used nor that there are two of them out, additionally it seems that the module can handle at least partially both directives, but later more.
I’ve searched quickly for some resources about how to configure AuthMySQL, some of the commands worked other didn’t. After several tries with extensive watching the apache error.log I finally managed to get the authentication running, upto the point of the used Encryption. The first try was to use MD5, but sadly the module did not support that value, although somewhere was talked about it (later I encountered it was for the other module). No Problem there’s another MD5 Setting, let’s switch to that one (Crypt_MD5), now AuthMySQL was working, but didn’t accepted the login details. A google search later I discovered that Crypt_MD5 uses a default Salt of 12 signs (or so) to encrypt the passwords, but my password is encrypted with md5, so no way to get it working. After a few searches why md5 isn’t working with my version of the module I found that forum entry which revealed that there are two modules out, which offer Authentication through MySQL.
But as I already supposed Debian doesn’t offer a package for the other module or I didn’t find it, anyway I got to the website of the other module and downloaded it’s source code. A fast lookup on howto compile and install modules for apache showed that I need to run apxs. But for my debian install the application wasn’t installed, you need to get some apache-dev package to install apxs. A few minutes later I’ve got a matching package and installed it. Next problem: while compiling apxs throws an error 65536, but luckily I found soon an patch, in this blog entry a patch is supplied so that the module was successful compiled under my linux installation.
The needed renaming of the module directives was done quickly and finally I got the authentication through MySQL working.
Alltogether it took a few hours to get that simple job working, anyway I’ve increased my knowledge about Apache and Linux, which isn’t that bad :)
Maybe this post will help the one or other to solve his problems quicker, as it contains quite well condensed errors and their solution.
If you want to use AuthMySQL get this version as it supplies in my eyes the best functionality. The easiest way to differ both versions is that one requires underlines within the directives and the other one doesn’t (the one which is linked).

Tags: none
Tags: apache, apxs, authentication, authMySQL, error 65536

Comments 1 Comment »

I’ve seen in within my two years of JS progamming some weird things, about browser behaviour. But the one I’ve discovered yesterday tops them all. Some JS class uses in the Init function the document.createElement function. The Script is working fine built in within one Website even with IE. But when the Script is added to another Website, IE complaints that document.createElement isn’t supported by this Object. An alert directly before the call is executed shows:
function createElement() {
[native Code]
}

But it still doesn’t work in IE.
Someone ever encountered that problem? I’m currently missing a solutin except the try to manually create the HTML-Node.

Tags: none
Tags: document.createElement, IE, Js

Comments 2 Comments »

A few days ago I started to write since some time a Plugin for WordPress again, for a customer. As I read over on WordPress you shall declare the files as UTF-8, but I would have changed it myself as well. Now after some initial testings I encountered this Problem:

Warning: Cannot modify header information - headers already sent by (output started at /xampp/htdocs/blog/wp-content/plugins/phRelatedLinks.php:1) in /xampp/htdocs/blog/wp-includes/pluggable.php on line 776)

Ah yeah…some known Problem within the WordPress Universe and the PHP one as well, caused by the Problem that infront of the starting < ?php are some other signs. Now when WordPress wants to send the header Information of the Page the whitespace/sign was already sent, but the header needs to be the first part of the website which is sent…therefore PHP throws this error.
Unfortunally this wasn’t the case for my Problem. As I had no clue what it could be else I searched for some time, and anything I could find told it’s a problem with leading signs before < ?php. Luckily I found this Post with the same Problem, which solved it.

While saving my file with SciTE as UTF-8, SciTE added a Byte Order Mask to the file, which isn’t needed at all as UTF-8 doesn’t encounter differences between big-Endian & little-Endian. Anyway it’s now widely used to easily tell apart UTF-8 and ISO-8859. So if a file contains as starting Bytes: EF BB BF it’s (mostly) a UTF-8 formatted file. But as these Bytes aren’t displayed within SciTE at all, you can go crazy with it. To write a file without this optional BOM you need to select as Encoding UTF-8 Cookie within SciTE.

Now the real cause was found, and it wasn’t WordPress who tried to drive me crazy at all. A look within PHP revealed that PHP isn’t able to interpret these Bytes as mark for a following UTF-8 Encoding. The related Bug Post was closed as won’t fix for PHP 5/4, the correct behavior will be implemented with PHP 6+.

In the meantime I hope that not too many other people will encounter that Problem and if, they’re able to find the solution faster than me!

Tags: none
Tags: Byte Order Mask, PHP, UTF-8

Comments 3 Comments »

Since awhile now I’m working with Javascript. I have to say that it’s for sure not that hard to write cross-browser Source Code like it’s still with CSS. But some parts aren’t easy to get them working. A recent problem is indeed the image.onload. At first it’s obviously that you should register an onload EventListener, before you assign an Image, like this:

image.onload = function() { alert("let's do something in here!");};
image.src = "myURL";

As it’s quite possible that the other way around, the picture is already loaded before the EventListener is registered.
But Hey! That’s no reason to make this mistake a few times…Now after you solve that self-made problem you can run into the next one! Opera calls the onload Event, only if the Object is newly created or the Image loaded isn’t already cached. That’s the state of Opera 7.5, as I read several times on various sites, that this problem was fixed within Opera 8.x. But now it seems that this Problem is back with Opera 9.26+( or earlier…).
Unfortunately my Script needs to be noticed everytime a new Image is loaded, although it may already be cached. The only way I’m aware of getting what I want is to disable the Cache of Opera, through Opera’s settings or per HTTP Header. Ok another way would be a function which looks the whole time if the image is changing, but both aren’t that what I’m searching for. Someone know if it’s possible to get some real onload for Images, in Opera, without any of the previously mentioned “hacks”?
Or can Opera fix this problem? It’s working correctly in IE, why not in Opera?

Tags: none
Tags: IE, Javascript, opera, problem

Comments 2 Comments »

As you surely recognized from php-ids.org and BlogSecurity.net already I made a new release of WPIDS. This release fixes several problems with the usability of WordPress, further it fixes some internal bugs and WPIDs comes now with HTML Purifier.

At least one minor release is supposed to happen before entering v.2.0 of WPIDS, as some Problems were reported for the current version. The upcoming Version .2 will be completely rewritten. It will offer more granular Option settings than before, it will give you more information and a much better Documentation will take place as well.

If someone is interested into Beta Testing the latest Version feel free to contact me.

Tags: none
Tags: WPIDS

Comments 2 Comments »

I’m proud to announce that the latest Version of PhBad Behave is now available. Anyway the changes are quit minor and are limited to the changed Bad Behavior Script Version which is now 2.0.12. With this Version some possible problems on Webserver with PHP5 should be gone. As well as the latest problem with locking out legit Users from the Backend(or in general) should be gone as well. Delicious is although no longer blocked by Bad Behavior, but that shouldn’t be much of a problem for a Forum if it would be so.

You can get the latest version as Usual, here.

Some last point I want to mention: I’m planning to stop the support of PhBad Behave for phpBB 2, as the latest version of phpBB is already available, which offers alot more features and security. Therefore I recommend everyone to switch to phpBB 3. Anyway it may be possible that I release some newer Version of PhBad Behave if I think it’s worth the time.

Tags: none
Tags: Bad Behavior, Update

Comments No Comments »

Everyone who does some working for Americans or work on US freelance Websites will know this problem mostly. You get payed with $, but your countries currency isn’t the Dollar, it’s the Euro, Yen, Pound or whatever so you need to get your money changed, which is a losely deal, by the current exchange rates of 1.44$=1€ and higher. We need a way out of that misery, while one or two years ago by exchange rates of ~1.10$=1€ you were able to compensate these rates by slightly increased prices for your work.
But nowadays you wouldn’t get any job if you would still behave like that(or much less that before). My current way is take the Dollars, then I’m gonna Buy stuff from American websites and let it be shipped to me home(although if I have to pay some additional taxes for my country, I’m getting it cheaper). But the problem for that is directly next to it, you surely can’t get everything from the US, like your bread, your bills payed and so on. So we still need another one.

One would be to use some other Freelance websites, where the allowed currency isn’t limited to Dollar only, so at least people from outside the Dollar world could profit from it. But that’s hard to find, as well as to get the success from the global players as well to your local Freelance Websites. Personally I wouldn’t say that I master the problem perfectly, and it will get more worse as the fall of the Dollar didn’t stopped nor it’s likely that it will happen soon.
Do you have some real good approach, or something you really recommend? Feel free to tell it.

Tags: none
Tags: Dollar, fight, loss

Comments 2 Comments »

I just recognized by checking some parts of WPIDS that it does as well block some Spam entries from getting posted to your Website. As PHPIDS checks for HTML tags, unsanitized ones, within the strings it removes these Requests…The only problem is that this applies as well for legit comments who hold allowed xhtml tags…Let’s see maybe we can get around that problem…Anyway a nice feature and when no xhtml tags are allowed within your Blog it’s even better as it only blocks SPAM comments :)
One thing which is for sure is that Akismet has a bit less to do than before :)

Tags: none
Tags: Akismet, PHPIDS, SPAM, WPIDS

Comments No Comments »

Bad Behavior has blocked 2161 access attempts in the last 7 days.