Archive for the 'Computers & Internet' Category

htaccess to deny access, except for includes

It's usually a bad idea to allow php include files to be directly accessed. My general method is to either declare a constant in the index.php and check for that constant in the included file or make sure that the included file doesn't match $_SERVER['REQUEST_URI'].
Sure, either of those work. But I [...]

Dynamically link to CSS with JavaScript

Needed a way to add a CSS file with JavaScript, so I went out a-Googling like I normally do.  Problem is everything I found either worked in Internet Explorer and not in FireFox or the other way around.  Nothing I found worked in both.  So I hacked together a function of my own.  Should have [...]

phpMailer – Could not instantiate mail function

Had a client getting this error when trying to send emails last week and have now spent several hours on Google trying to find a solution.
Biggest catch is that other scripts were able to send mail, so it seemed unlikely that it was the host. So I took the phpMailer class and uploaded it [...]

bit.ly and PHP

Needed a quick and easy way to create a bit.ly URL for another site of mine. Google came through for me.
David Walsh posted a short PHP function on his site that takes your bit.ly login, API key, and the URL to shorten and returns a nice, short bit.ly link.
Link: http://davidwalsh.name/bitly-php
Just put the [...]

Missing httpd.conf in WHM / cPanel

Came across an error after mistakenly clicking a link in my hosting control panel.
PLAIN TEXT
CODE:

Unable to locate httpd.conf at /usr/local/cpanel/Cpanel/ConfigFiles.pm line 27.

Cpanel::ConfigFiles::find_httpconf(undef) called at /usr/local/cpanel/Cpanel/ApacheConf.pm line 206

Cpanel::ApacheConf::loadhttpdconf() called at whostmgr/bin/whostmgr4 line 197

main::listaccts() called at whostmgr/bin/whostmgr4 line 157

At the time, WHM was working but none of the sites on the server would load. Trying [...]

Quick PHP wrapper for print_r

Working on web apps I find myself using the print_r command a lot, and I mean a lot. It helps trace out what data is going where, and more often what's not going where it's supposed to.
A few months ago I realized that I type this same bit of code way too often.
PLAIN TEXT
PHP:

echo [...]

Netbeans with multiple monitors

How did I not try this before today?
My normal method of needing two files open was to have the one I'm working on in Netbeans and the other in Notepad++ on separate monitors.  Turns out you can drag the tab of an open file outside of Netbeans and it becomes its own window.
We're going to [...]

Java vs. .Net – Movie Trailer

Safari, scriptaculous, and non-clickable links

For the better part of the last couple of days I've been trying to figure out why Safari was not allowing me to click on links. Aside from an annoyance, it's not good to have clients complaining...

Prototype.js, setStyle, and IE not working together

Sometimes IE just irritates me. Ok, pretty much anytime I'm working on a web site. Especially when it involves Javascript or DOM.
For the past couple of hours I've been scouring the internet looking for a solution to the prototype method setStyle not working in IE8. I was getting an 'Object [...]