Tuesday, December 29, 2009

.htaccess ErrorDocument does not Catch 404 Error from a Non-Browser Call to the Site.

I came across this problem recently when trying to click on hyperlinks in a WORD document. The link used the following code in a .htaccess file.

ErrorDocument 404 /error_file.php

It worked when accessing the link through a browser, but WORD makes a call to the site first to determine if the page exists. For some reason, the file would not redirect, and WORD would say that it could not access the site. The same thing would happen when trying to access the page via PHP cURL or a W3C validator.

Thanks to the following page, I indirectly got the solution.
The page is actually discussing .htaccess files nested in subfolders, but the following code, which is mentioned in the posts, works better for redirecting from WORD.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /error_file.php [L]

Wednesday, November 11, 2009

How to have clickable links in Yahoo Answers

I came across this problem when first starting giving answering questions on Yahoo Answers. You'd paste a link into an answer and when you view the submited answer, the link is not active (not clickable). It's just part of the text of the answer.

Well, after not getting many answers about from Yahoo Answers, I stumbled on the solution myself after answering more.

You have to get to Level 2 of Yahoo Answers in order for your links to be clickable.

Sunday, November 8, 2009

Easy Object Call HTML DOM / JavaScript

Here's a handy little function that I use a lot. Instead of having to call document.getElementById('example_tag') which is long and half the time I mis-capitalize the "getElementById", this function saves time and errors with getEle('example_tag') The plus is that it also bypasses a potential error if the element is not there.
function getEle(str){
return document.getElementById(str);
return false;

Friday, November 6, 2009

JavaScript HTML to XHTML Converter for Yahoo's YUI 2 Rich Text Editor

The other day after installing Yahoo's Rich Text Editor, I noticed that the output of the editor was badly formed HTML that wouldn't validate on my XHTML site. So, since I'm a bit anal, I wondered if there was a way to convert the output. After only finding a few convoluted and licenced solutions, I figured it wouldn't be too hard to do it myself. So here it is in JavaScript.

function convertToXHTML(html){

var raw1 = html.split("<"); var xhtml = ""; var tags = ""; //Make Tags Lower Case and make sure that the tags are properly closed for(var i in raw1){ if(raw1[i].indexOf(">") != -1){
var raw2 = raw1[i].split(">");
var tagName = (raw2[0].indexOf(" ") > -1) ? raw2[0].split(" ")[0] : raw2[0];
tagName = tagName.replace(/\//g, "");
var endSlash = (html.indexOf("/" + tagName) == -1 ) ? " /" : "";
raw2[1] = (raw2[1]) ? raw2[1] : "";

if(raw2[0] != "" && raw2[0]){
var begin = "<" + raw2[0].replace(eval("/" + tagName + "/"), tagName.toLowerCase()); xhtml += begin + endSlash + ">" + raw2[1];
xhtml += raw1[i];

//Make sure that the attributes listed below use quotes
xhtml = xhtml.replace(/align=center/gi, 'align="center"');
xhtml = xhtml.replace(/align=left/gi, 'align="left"');
xhtml = xhtml.replace(/align=right/gi, 'align="right"');

//Make sure the attributes are separated by a space
var arr = xhtml.match(/"[a-z]+="/gi);
for(var i in arr){
xhtml = xhtml.replace(eval("/" + arr[i] + "/gi"), '" ' + arr[i].slice(1));
return xhtml;


Unfortunately, this isn't a 100% fix. The Yahoo Editor sometimes nests the tags in an invalid way, and I have yet to correct for that. I also haven't tested this too much yet; so, there could be quite a few other things that this isn't designed to fix.

This is specifically to convert the output of Yahoo's text tool. This function fixes glitches that only this tool creates, and does not account for errors that you or another program might export.

Wednesday, November 4, 2009

Problem Pasting from Clipboard on Blogger

This has been bugging me since I started this blog. If you have Internet Explorer 8 and cannot copy and then paste text into your Blogger Post Textbox, just turn-on "Compatibility Mode".

Go to Tools / Compatibility Mode

While you're at it, you may as well set Blogger to be in compatibility mode into the future; so, got to Tools / Comaptibility Settings. This brings up a Menu Box. Enter "Blogger.com" into the text field at the top and click "Add" then click "Ok". This makes it so Blogger is in Compatibility Mode everytime you go here.

I haven't fully tested this to see if it makes anything else not work, but at least you can copy and paste. I found this here: http://www.google.com/support/forum/p/blogger/thread?tid=418da73cad5aa018&hl=en (I copied and pasted this while in compatibility mode).

Monday, November 2, 2009

URL Encode Calculation / Function for FileMaker Pro

This function is for when you send field data to a website with the "Open URL" Script Step, or if you're storing url encoded links.

Substitute (
; ["¶" ; "%0D"]
; ["%" ; "%25"]
;[ "#" ; "%23"]
;[ "`" ; "%91"]
;[ "~" ; "%7E"]
;[ "!" ; "%21"]
;[ "@" ; "%40"]
;[ "$" ; "%24"]
;[ "^" ; "%5E"]
;[ "*" ; "%2A"]
;[ "(" ; "%28"]
;[ ")" ; "%29"]
;[ "-" ; "%2D"]
;[ "_" ; "%5F"]
;[ "=" ; "%3D"]
;[ "+" ; "%2B"]
;[ "" ; "%3A"]
;["\\" ; "%5C"]
;[ "]" ; "%5D"]
;[ "[" ; "%5B"]
;["{" ; "%7B"]
;[ "}" ; "%7D"]
;[ ";" ; "%3B"]
;[ ":" ; "%3A"]
;[ "'" ; "%27"]
;[ "\"" ; "%22"]
;[ "<" ; "%3C"]
;[ ">" ; "%3E"]
;[ "," ; "%2C"]
;[ "." ; "%2E"]
;[ "/" ; "%2F"]
;[ "?" ; "%3F"]
;[ "&" ; "%26"])

Now, I created this function about a year or two ago on my own, but out of curiosity, I just did a google search for "urlencode filemaker" and found an incredibly similar function on Brian Cummings FileMaker Pro Custom Functions page. So, out of fairness, I'll give him credit for his or his team's work,
but I swear I couldn't find his page when I made the calculation. However, my function does have a few more encoded characters.

Anyway, hopefully this will help anyone else out there looking for such a function.

Friday, October 30, 2009

IIS 7 PHP FTP permissions error with ftp_nlist() and ftp_rawlist()

How `bout this! Two posts on my first day on the blog.

This one I encountered soon after finally getting my SSL up and running. In IIS 7, PHP my have some permission errors that will allow an FTP connection to go through, but as soon as you call ftp_nlist or ftp_rawlist, the script keeps running and causes a 500 Server Error.

Well, the simple solution is to force passive mode. Call this after connecting to the FTP.

ftp_pasv($conn_id, true);

Now, this might not be the best solution for you, especially if you're connecting to a typically stupid Windows Server 2008 that does not easily allow passive FTP, but it worked for me; so, if this doesn't work for you, just go punch the insensitive loudmouth sitting next to you .

IIS 7 Errors when Completing SSL Certificate Request (Windows Server 2008)

This one caused me to kick the stall door in the men's room repeatedly.

IIS 7 has a bug that, when installing/completing SSL Certificates, causes this specific error:

CertEnroll:CX509Enrollment::p_InstallResponse: ASN1 bad tag value met 0x8009310b (ASN:267)

Now, to listen to all the help pages out there, they'd have you beleive that the certificate acutally installs despite the error, and all you have to do is refresh the certificate list under Computer Management, and this may be true; however, if you're like me, this repeatedly does not work, and you have to keep having the CA reissue the certificate, taking a day or so per reissue. In this case, try this out.

I noticed that under MMC there is an enrollment folder that shows each request as a certificate, and after the error, the request disappears, and just keeps erroring; so, I figured the request still had to be in the system somewhere; so, I searched around and found this life and time-saving page hosted on random CA company's site:


It basically solves the whole problem. It not only finds the missing request, but installs the new certificate while your at it. Luckily, I didn't encounter the error it's talking about.

The following is directly from Entrust

Entrust Certificate Services Support Knowledge Base

Audience: Administrator
Last Modified: 2006-10-18 13:46:14.0

TN 6926 - How do I restore a pending request in IIS 6.0 if it was removed?


The pending request in IIS 6.0 has been deleted. You cannot install your Entrust SSL certificate since the CSR generated by you which is signed by Entrust, mathematically matches the pending request.

Microsoft Notes:

IIS stores the private key for a certificate as the pending request. Deleting the pending request deletes the association of the private key with IIS, but the private key still exists in the certificate store. To install the certificate without having the pending request available, you can use version 5.2.3718.0 of the Certutil.exe command-line tool that is available through the Certificate Services MMC snap-in in Windows Server 2003. For more information about Certutil.exe, see Certutil.exe

The Certutil.exe Solution:

To install a Web server certificate that lacks a pending certificate request
1. Click Start, point to Run, type cmd, and then click OK.

2. Navigate to the directory where Certutil.exe is stored; by default, this is %windir%\system32.

3. Type the following command at the command prompt: certutil -addstore my certnew.cer where certnew.cer is the name of the certificate you received from the certification authority (CA).

You should see the following message: CertUtil: -addstore command completed successfully.

4. Navigate to the directory where you stored the certificate you received from the CA. Right-click the certificate and then point to Properties.

5. Click the Details tab and select in the Show drop-down list.

6. In the Field list, select Thumbprint to display its value in the view pane.

7. Select the Thumbprint value in the view pane and then click CTRL+C.

8. Return to the command prompt window and type the following command: certutil -repairstore my "thumbprint"
where thumbprint is the value of the Thumbprint field. Be sure to type the double quotes as part of the command. If the command is successful, the following message is displayed: "Encryption test passed CertUtil: = repairstore command completed successfully."

1. Install the server certificate on your Web server.


If the certutil command does not complete successfully, the following error message is displayed: "Certutil: -repairstore command FAILED: 0x80090011 (-2146893807) Certutil: Object was not found." This message indicates that the private key for the certificate does not exist in the certificate store. You cannot install the certificate you obtained from the CA. Instead, you must generate a new certificate request, obtain the new certificate, and install that new certificate on your Web server. Please contact Entrust for assistance.