test

test

Create Triggers for date and time in MySql


CREATE TRIGGER
events_before_insert BEFORE INSERT ON
events
FOR EACH ROW BEGIN SET NEW.t_date = CURDATE(); SET NEW.t_time = CURRENT_TIME(); END; ;

Log File Monitor

How many times has this one been redone? Well, I needed to do another one for Windows with a twist.
Requirements
Monitor log every x seconds looking for errors.
Multiple errors can be defined.
Supports both directory and single files.
Since I am lazy, it reads the file line by line and only cares about any lines after the last read. So, if the last line of the file lwas 10, it will start searching at line 10 the next round.

email from php

This is a simple email php script that uses the expert mail class.

Reads in the form and spits out the data to a smtp server.

Simple perl script for downloading reports

I have a client that wanted to download a report from his hosting provider. Originally he wanted it in PHP but Perl was WAY easier... So here it is.

Add the table to the db.

CREATE TABLE IF NOT EXISTS `listeners` (
  `id` int(16) NOT NULL auto_increment,
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
  `listeners` int(16) NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `timestamp` (`timestamp`,`listeners`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

GeoIP update data file script

Since the data file is updated every month I wanted to automate the download and unzip.

Here it is.

Written in Perl


#!/Perl/bin/Perl.exe
use strict;
require File::Spec;
use File::Basename;
use ExtUtils::MakeMaker;
use LWP::Simple qw(getstore $ua is_success);

if ($ENV{HTTP_proxy_user} and $ENV{HTTP_proxy_pass}
and $ENV{HTTP_proxy} =~ /^http:\/\/([^@]+)$/) {
my $proxy ="http://$ENV{HTTP_proxy_user}:$ENV{HTTP_proxy_pass}\@" . $1;
print "setting user/pass into proxy_env...\n";
$ua->proxy(['http'], $proxy);
}

GeoIP

This is something I hacked together for a ColdFusion web site but I find I am using again for another client.
There is a free and pay version of the data file. The pay is more accurate but for my needs the free version is just fine

To set this up...
Get the api
Download the data file

Download the two attached files.

Joomla Additional user variables

I am working on a new non for profit web site and had to add some fields to the user registration. You would think this would be easy but....

There are three files that need to be edited and the jos_user table has to be updated.

So, here are the specifics.

To add a phone number to the registration do the following.

edit libraries/joomla/database/table/user.php
and add the following line

var $phone                      = null;

after

var $params                     = null;

edit components/com_user/views/register/tmpl/default.php

md5 password in mysql

I love this one. Ever forgot a passwd ?

Reset it like this

UPDATE table_name SET password=MD5('newpasswd') WHERE username = "Chris"

Syndicate content