Thursday, February 18, 2010

Resolving Name Server IP Addresses

Ever thought about this? If I want to find the website example.com then my computer begins by contacting the TLD (.com) and finding the authoritative name server for example.com. If it is ns1.example.com, then how does my computer figure out the IP address for this subdomain? Is there a name server for the name server?

After searching about, I've been educated.

This problem is called circular referencing, for obvious reasons. So, to solve this problem, you register name servers with the same people you register the domain with. You specify the name of the name server and an IP address and they register what's called a glue record. This glue record is stored by the TLD (e.g., .com) name servers so that the IP address of your name server (e.g., ns1.example.com) can be sent when needed.

Bit 'o knowledge for you.

Need to check your glue records? A quick search on Google for glue record provides promising results, like this site.

Tuesday, February 16, 2010

PHP image manipulation

If you have ever wanted to dynamically create or edit images, GD is a great solution for PHP (and LAMP configurations). I am writing this blog entry mostly because I was amazed at how easy it was to install. I just picked it in easyApache (using WHM) and "tada!" – it works. I can't say that about imagemagick. I've tried and tried to get that bit of software to work (on multiple servers) and it is always a pain. I remember on my first server (hosted by another company) I had requested imagemagick and they even had trouble installing it—the help desk ticket was pretty long by the time it was closed.

Anyway, moral of the story: Go with GD for dynamic image manipulation in PHP.

Monday, February 15, 2010

APC.php not Working

I was getting a new server up and running and wanted to install APC (Alternative PHP Cache). Things were going great. I even ran phpinfo() and noted that APC had an entry. Everything was super, right?

I wanted more confirmation, so I used SSH, located apc.php and copied it to a domain for public access. I wanted to know how well APC was working for me. However, it wouldn't run. It sent back errors and when I tried to debug it I got no where.

Turns out, APC wasn't really doing much of anything. I had PHP installed and running as a CGI instead of an Apache Module. If PHP runs as a CGI, APC closes at the end of each script run and the cache is lost—it doesn't make much sense to use APC in this situation. While runing as a CGI has some security benefits you lose a bit of performance and, more importantly to me, APC doesn't really work.

I use WHM and so I went to "Main >> Service Configuration >> Apache Configuration" and then changed the PHP 5 handler to DSO. This solved the problem and apc.php loaded just fine the next time I tried. And it even had some pretty stats for me to see.

Saturday, February 13, 2010

Easy Ways to Accept Donations Online

There are a lot of options out there to help non-profits accept donations online. I want to briefly mention to different categories of solutions to help people who are trying to figure out what is best for their non-profit or church.

  • Perhaps the easiest solution is to use a service like PayPal. You sign up for an account and give them your account info and you are up and running soon. This is technically called an aggregation service, because you do not need to have any special accounts set up—PayPal has done that and accepts payments on your behalf. Google has a similar solution except that it, unlike PayPal, unfortunately requires donors to have Google checkout accounts. With these types of services you will have to pay higher per-transaction fees (10 to 30 cents) and transaction rates (around 3%).

  • The second option is to get what's called a merchant account. This is a special bank account that allows you to accept credit card payments directly (instead of through an aggregator, like PayPal). This is a process that requires an application and some extra steps to setup, but it is often worth the time. The per-transaction rates are almost always lower this route, but there are monthly service fees that are standard (around $10 to $30). Because of this, merchant accounts best for non-profits who are accepting more than a couple hundred in donations a month (but you'll have to do the math to make sure). The cool thing is that if you decide to get a merchant account, your donor's bank statements will actually have your organization's name next to each donation (as opposed to PayPal or Google).


If you want to accept donations online, the second option is a little trickier (because of security standards called PCI-DSS). But, there are companies out there like BlueFire Donations, which can help make this a breeze, helping get non-profits accepting credit credits online in no time.

Got a question? Post in the comments and I'll do my best to help out.

Friday, January 22, 2010

cURL and SSL

cURL is a nice little extension to PHP. You can read an intro here.

I use cURL a lot. It seems that do a lot of web applications that connect to other servers for transactions (like payment gateways). You can do SSL or HTTPS requests to other web hosts without validating their certificates but you leave yourself open to man-in-the-middle attacks. While this seems unlikely if you are running out of a data center, checking the certificate validity is too easy to skip.

The one thing that you must do for this to work is tell cURL where the CA-bundle (or CURLOPT_CAINFO) is located. I am running CENTOS 5.4 and found CA info at "/etc/pki/tls/certs/ca-bundle.crt". I can enable this with the following two lines added before curl_exec();

curl_setopt($ch, CURLOPT_CAINFO, "/etc/pki/tls/certs/ca-bundle.crt");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);

Group Text Messaging - Schedule Text Messages

I wanted to take a moment to promote another site I relaunched yesterday. It is ShortShout and it is a group text messaging platform. I've worked out some pretty low per-message rates to make it an affordable service. It can be used by any group and has some special info for churches who want to do text messaging. Check it out at ShortShout.com.

One of ShortShout's customers is a marketing team in Michigan led by Denise. Denise told me that she uses the system "to encourage and stay in touch with her friends/team members." Denise, in her own words, "is a motivator and keeps her team focused on their goals" with group text messaging and ShortShout.

Thursday, January 14, 2010

MySQL and mysql_select_db

I was convinced that mysql_select_db() was not working today. I wanted to simultaneously connect to two different databases. However, when I called the mysql_select_db function, it seemed that both connections were changing to the database I specified. I couldn't get one link to stay on the original database while I changed the second link to a new database.

After a little digging around I found a helpful user comment about using mysql_connect. The fourth parameter of this function is "new_link" and if you want to simultaneously have two connections open and both connections use the same credentials, you must set this parameter to TRUE. If you don't, it sees that the credentials are the same and will reuse the same resource link, even if you set a different variable.

So, this:

<?PHP
$conn1 = mysql_connect(HOST, USER, PASS);
mysql_select_db(TABLE_1, $conn1);
$conn2 = mysql_connect(HOST, USER, PASS);
mysql_select_db(TABLE_2, $conn2);

turned into this:

<?PHP
$conn1 = mysql_connect(HOST, USER, PASS, true);
mysql_select_db(TABLE_1, $conn1);
$conn2 = mysql_connect(HOST, USER, PASS, true));
mysql_select_db(TABLE_2, $conn2);

And tada, I could simultaneously connect to two (or more) databases.