php

Manual PHP and Drupal 6 web access logging

There was a little funky activity on a client's Drupal 6 website that was hosted at GoDaddy, and without having access to an Apache access log file, I wanted to be able to see what was going on. So I wrote the following PHP code snippet to do some manual logging, and placed it in the Drupal theme's page.tpl.php file:

Get a web client's IP address with PHP

I just ran into a situation for a Drupal/PHP client where I wanted to log some access information. There was some unusual access activity on the website, and I want to log IP addresses and URLs for a few days.

As part of that, I wanted to get the web client's IP address, and in PHP you get the client IP address like this:

$ip = $_SERVER['REMOTE_ADDR'];

That returns something like this:

192.168.100.10

If you just need to get a web client's IP address from a PHP script, that's all you need.

The Twitter API, PHP, and OAuth

Just a quick note today on how to access the Twitter API using PHP, specifically using the Abraham Williams PHP TwitterOAuth library. While the library itself seems very good, I couldn't find much in the way of documentation, particularly a simple "getting started" tutorial, so I thought I'd share this code.

In short, I dug through the PHP files in the root directory of the TwitterOAuth library, eventually creating this simple PHP Twitter client example:

Yahoo OAuth oauth_problem = signature_invalid 401 error message

I just got the following error message when trying to use the current Yahoo OAuth authentication system to connect to Yahoo Mail:

Drupal form and module debugging

Drupal debugging FAQ: How can I debug my Drupal form and module development process?

I should know more about this over the next few weeks, but if you're developing Drupal forms and modules, I've found the PHP error_log function and the Drupal watchdog function to be very helpful. They both let you log errors 'somewhere', and the error_log output shows up in your Apache logs, and the watchdog output shows up in your Drupal reports.

Here's how you call the PHP error log function:

How to display the APC Opcode Cache information page

I just finished moving the devdaily.com website to a newer, faster web server, and in the process I had to install the APC Opcode Cache on the new server. After installing APC, I like to be able to test that it's working, so I wanted to be able to display the APC information web page (APC test page).

To display the APC test/information page, just:

AJAX autocomplete with jQuery, PHP, and JSON

While adding some AJAX autocomplete functionality to a new web application, I created a simple jQuery autocomplete example, using a PHP server-side script, and JSON to communicate the data from the server to the client. After creating that simple example, I thought I'd share all that code in a "jQuery AJAX autocomplete" tutorial here.

Before we get started, I'm going to assume you're familiar with basic HTML, CSS, and JavaScript programming fundamentals. It will also help if you've had a little exposure to jQuery, though that isn't entirely necessary.

Boulder, Colorado computer programming consultant

Just a quick note here that I've just moved to Broomfield, Colorado, and I've brought my computer programming consulting services (Valley Programming) with me.

So, if you're looking for a Java computer programmer in the Boulder, Louisville, Lafayette, and Broomfield, Colorado areas, give me a call. All initial consultations are free, and if I know how to do something I'll let you know, and if I don't, I'll let you know that also.

Free PHP charts and graphs

As I embark on two new PHP web applications that have a lot of charting and graphing needs, I've started to dig into the PHP charts and graphs world. I'm pleased to say there are several nice, free PHP charts and graphs tools available, and several commercial PHP charting/graphing tools as well. Here's my quick review of the current PHP charts and graphs tools.

Drupal 7 - A Rails-like approach for Drupal form and module development

Looking for a Ruby on Rails like approach for Drupal 7 form and module development? If so, I may have just the tool you're looking for.

As you can see in the video below, I show how I can generate Add, Edit, Delete, and List forms for a Drupal 7 project I'm working on in four minutes, or one minute per form. Of course there's a little more work to be done, but the code-generating approach I've taken is exactly what Ruby on Rails and CakePHP did the last time I used them.

Syndicate content