Lame Scripting Awards

Lame Scripting Awards

How many people have been using cat to open files in their shell only to pipe the output to another command, or how many have piped things to wc -l from grep? Don’t understand what I am talking about, and want to be enlightened? Check out: Useless use of cat award. This is an old article but the information is probably more relevant than some other information presented in class or online. Lets be honest though and realize that there is more than one way to skin a scripted cat.

Javascript and PHP Size Based Styles

Javascript and PHP Size Based Styles

So you want to support different screen resolutions do you? Well, it is possible too much difficulty by creating a multiplexer for CSS files. This solution I am speaking about involves creating several style sheets for popular screen resolution groups and a cookie to save the information and redirecting when the cookie is not set. This solution should be handled with care as cookies are not always supported and could create and endless redirect.

Continue reading

PHP SNI Switch for HTTPS WINXP IE

PHP SNI Switch for HTTPS WINXP IE

A possible solution to an Error page for HTTPS SNI in WinXP Internet Explorer

Although this is not the best way to treat this situation, it is possible to have a switch for the Internet Explorer XP Browser in order to treat it specifically when hosting multiple sites with one ip and https. For those of you looking for the answer:

Continue reading

Html Form Editing Embed Form Elements

Html Form Editing Embed Form Elements

We have a demo up at http://www.swhistlesoft.com/demo/edithtmlforms/ which you may of course take a look at. There are some bugs and we will be posting a more complete demo in the near future. You can also check out other demos by going to:

http://www.swhistlesoft.com/demo/demolist

As we update and add demos, this list will be automatically updated.

MySQL Singleton Class to allow easy and clean access to common mysql commands

The MySQL Database class is implemented using the singleton design pattern. This design pattern allows for only one single instance of the object. This one instance can then be obtained through a static method. This provides a convenience in that you can get your database object from anywhere in your code.
Continue reading

Database PHP Session Handling

Database PHP Session Handling

As you should be aware the HTTP protocol, as used for serving web pages, is completely stateless. This means that after the server has received a request, processed it and sent a response, the process which dealt with that request dies. Anything that the process had in its memory therefore dies with it, so when a subsequent request is received from the same client it is unable to refer to its memory about anything that happened previously.
Continue reading

A JQuery Print Library that fixes the IE7 Shrink-to-Fit issue

There is an option in most browsers called “Shrink-to-Fit”. This is a page setup configuration that, if turned on, will attempt to scale the web page in size to make it fit on the selected paper size you are printing to. The scaling mechanism also attempts to scale it to a size that will fit on the least amount of pages. Although this does make sense when you are trying to print an actual web page, it can be a nightmare for web application developers who are trying to control the print job. For example, say your web application produces a Invoice for a customer. As a developer you want to try to control the layout of the invoice so you probably have a print.css file and you already have taken into account the page layout specific for a print job.
Continue reading

Perl parsing field value pairs without separation

It is possible with perl functional programming to solve some interesting problems.

Suppose that you have a data set that has been processed to a degree where there was an error in the processing which removed some required delimiters such as the following:

some_data=some_valuesome_data=some_valuesomedata=somevalue
Continue reading

Where to find sos.dll

Where to find sos.dll

If you are looking where to find sos.dll, please check the following locations before you download windebug tools:

C:\Windows\Microsoft.NET\Framework\v2.0.50727
C:\Windows\Microsoft.NET\Framework\v4.0.30319

For Details on why this may be missing in other framework versions see:

This post

Continue reading

Latest Version of Joomla Link

In case anyone is wondering where they can get the latest version of Joomla information which is now scheduled to have a major release every 6 months, the url is http://update.joomla.org/core/list.xml. There is an extension update link as well but that does not seem to be filled in currently at: http://update.joomla.org/jed/list.xml. The latest release of Joomla is 1.7 as of the time of this posting.

Adding events to iframe javascript

Technically it is possible to add events to an iframe but there are some caveats especially in terms of browser compatibility. for starters what I have found is that you can use the window object if you are trying to attach to events such as blur, drop, and mouse or keypress.

	ifrme = document.getElementById ( 'ifrme');
	if ( typeof ( ifrme.contentDocument ) != "undefined" ){
		var win = ifrme.contentWindow||iframe.defaultView;
		var doc = win.document;
		win.addEventListener ( "blur",function(){
			alert ( "blur");
		},false);
	}

More to come soon

JQuery UI Draggable – data(…)options is null or not an object in IE7

I was working on a project that allows the users to create a list of names in their account. They could then take a name from the global list and drag it to a recipients list to send a mass email to everyone in that list. To accomplish this task and make it look good I decided to go with the great JQuery UI library’s (draggable and sortable to b specific).

Continue reading

Disappearing JSTree when using Themeroller

I am currently working on a project that utilizes a MySQL Nested Folder database design and a JQuery component called JSTree. The implementation actually works great. The system allows users to create “folders” for content and provides the ability to Drag and Drop to move folders, create new folders and sub-folders, etc.

After entering the testing phase of the project we discovered that the folder tree view, powered by JSTree, was not working. The tree would load on the page and then disappear. I spent a solid 12 hours trying to debug what the issue was because it works flawlessly in IE8, IE9, Fire Fox, Chrome, Safari, and Opera. This problem seemed to be isolated to IE7 only. I flipped flopped between potential causes several times — could it be a Javascript issue? could it be a CSS issue? could it be both?

Continue reading

Plesk RHEL 5.2 500 Error Virtualhosted Sites

Upon receiving a 500 error on multiple sites due to what appears to be an update to Plex followed by an update to RHEL5, we have found a way to track the issue early and resolve quickly. There is a script that will be posted at the end of this message.

Tracking the issue:

The first sign of trouble was the 500 error which appears in a virtualhosted server environment with more than one site failing, but also more then one site operating without issue. Since the operation of several sites were working this meant to us that the php, mysql and apache components were functioning normally. The 500 error hinted to us about cgi and perl possibly failing due to missing modules or linked headers. Also the failing sites appeared to be using Miva Merchant. Miva itself was not the cause of the issue however.

using the ldd command we were able to prove that all libraries were in the correct places and being found by ld.

ldd /usr/bin/mivavm
linux-gate.so.1 => (0x0056b000)
libm.so.6 => /lib/libm.so.6 (0x008c4000)
libdl.so.2 => /lib/libdl.so.2 (0x008ef000)
libpthread.so.0 => /lib/libpthread.so.0 (0x008f6000)
libc.so.6 => /lib/libc.so.6 (0x00769000)
/lib/ld-linux.so.2 (0x0074a000)

ldd /usr/bin/php-cgi
linux-gate.so.1 => (0x007c5000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x00412000)
libaspell.so.15 => /usr/lib/libaspell.so.15 (0x009e6000)
libpspell.so.15 => /usr/lib/libpspell.so.15 (0x00926000)
libgmp.so.3 => /usr/lib/sse2/libgmp.so.3 (0x009ae000)
libdb-4.3.so => /lib/libdb-4.3.so (0x02e91000)
libpthread.so.0 => /lib/libpthread.so.0 (0x008f6000)
libcurl.so.3 => /usr/lib/libcurl.so.3 (0x001fd000)
libbz2.so.1 => /usr/lib/libbz2.so.1 (0x02e7e000)
libz.so.1 => /usr/lib/libz.so.1 (0x00911000)
libpcre.so.0 => /lib/libpcre.so.0 (0x00cb9000)
libresolv.so.2 => /lib/libresolv.so.2 (0x00b60000)
libm.so.6 => /lib/libm.so.6 (0x008c4000)
libdl.so.2 => /lib/libdl.so.2 (0x008ef000)
libnsl.so.1 => /lib/libnsl.so.1 (0x00993000)
libxml2.so.2 => /usr/lib/libxml2.so.2 (0x00292000)
libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0x001cd000)
libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0x00d33000)
libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0x00d0a000)
libcom_err.so.2 => /lib/libcom_err.so.2 (0x00cfa000)
libssl.so.6 => /lib/libssl.so.6 (0x00183000)
libcrypto.so.6 => /lib/libcrypto.so.6 (0x00b76000)
libidn.so.11 => /usr/lib/libidn.so.11 (0x00b14000)
libc.so.6 => /lib/libc.so.6 (0x00444000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x028a3000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00110000)
/lib/ld-linux.so.2 (0x0074a000)
libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0x00cff000)
libkeyutils.so.1 => /lib/libkeyutils.so.1 (0x00de3000)
libselinux.so.1 => /lib/libselinux.so.1 (0x00931000)
libsepol.so.1 => /lib/libsepol.so.1 (0x0094b000)

Running the commands from the command line showed that they were completing fine and not segfaulting on as standard run. The environment for Miva is not set which explains the second line and this happens after the headers are sent which limits its cause.

/usr/bin/mivavm
Content-Type: text/html
Set-Cookie: htscallerid=
ec99e8351f3312599b5c4e1e0a78183b; expires=Thu, 28-Jun-2012 16:02:03 GMT; path=/

Configuration Error: Error loading configuration library: Unable to locate/load libmivaconfig.so
Please contact the server administrator: webmaster@localhost

/usr/bin/php-cgi

test#>

inspecting apache logs showed nothing but a restart a few days earlier.

[Tue Jun 28 22:39:22 2011] [notice] Apache configured — resuming normal operat ions

inspecting site specific logs from:

/var/www/vhosts/domain.com/statistics/logs/error_log

[Wed Jun 29 12:53:57 2011] [error] [client 10.0.0.151] suexec policy violation: see suexec log for more details
[Wed Jun 29 12:53:57 2011] [error] [client 10.0.0.151] Premature end of script headers: mivavm

inspecting suexec_log and suexec.log reveal the following:

lines in suexec_log
[2011-06-28 08:54:19]: uid: (#####/#####) gid: (2524/2524) cmd: mivavm

lines in suexec.log

[2011-06-28 08:59:34]: uid: (#####/#####) gid: (2524/2524) cmd: mivavm
[2011-06-28 08:59:34]: command not in docroot (/usr/bin/mivavm)

This hinted at an issue with suexec configuration of which docroot is precompiled in the command.
Upon inspecting /usr/local/psa/suexec/psa-suexec in vi, the file /usr/bin/minavm can be found
which hinted that this file is working and running the command yields no response which seems ok and no logs changed.

Running /usr/sbin/suexec and making note of the fact that it is old and that there are several versions gave the clue.

-r-s–x— 1 root root suexec
-r-s–x— 1 root apache suexec.saved_by_psa
-r-s–x— 1 root apache suexec.saved_by_psa.01.05;14:15
-r-s–x— 1 root apache suexec.saved_by_psa.01.06;18:03

Verified this assumtion with online post:

http://forums.theplanet.com/lofiversion/index.php/t57865.html

Modified the script to suit our environment

#!/usr/bin/bash
a1=`ls -la /usr/sbin/suexec | tr “-” ” ” | gawk ‘{print substr($0,1,56)}’`
a2=`ls -la /usr/local/suexec/psa-suexec | tr “-” ” ” | gawk ‘{print substr($0,1,56)}’`
if [[ “$a1” != “$a2″ ]]
then
cp /usr/sbin/suexec /usr/sbin/suexec-saved-$(date +%Y”-“%m”-“%d)
cp -Rfp /usr/local/suexec/psa-suexec /usr/sbin/suexec
fi

-r-s–x— 1 root apache 19964 Mar 31 00:05 suexec
-r-s–x— 1 root root 11608 Jun 29 13:12 suexec-saved-2011-06-29
-r-s–x— 1 root apache 21656 Dec 23 2009 suexec.saved_by_psa
-r-s–x— 1 root apache 20896 Dec 18 2007 suexec.saved_by_psa.01.05;14:15
-r-s–x— 1 root apache 20612 Apr 25 2008 suexec.saved_by_psa.01.06;18:03

Site resume normal operation

Joomla 1.0 Content Missing

Was having an issue viewing some content on a Joomla 1.0 site. Noticed that the server code was php5.3. There are some issues with some versions of Joomla with php5.3. For the 1.5 branch, the latest versions work but the earlier ones do not as late as 1.5.14.

At any rate, without errors showing up it is often hard to find the solution without hacking core code. One such solution is to downgrade php which may be simple in a cgi environment.

Another possible solution was found at this blog posting.

The basic idea is to change the core Joomla 1.0 file includes/Cache/Lite/Function.php. By modifying the line that looks like:

$arguments = func_get_args();

with

$arguments = func_get_args();
$numargs = func_num_args();
for($i=1; $i < $numargs; $i++){
$arguments[$i] = &$arguments[$i];
}

The content becomes visible. There are other issues that could arise due to improper database content Finish Publishing Dates, and clearing the browser cache as well as site cache.
Update:
For those of you interested in converting Templates, Modules, Components, or Plugins from 1.0 to 1.5 – please check out this page