ITTreats.com
Enter your Search term and Hit "Enter"

Wed, 10 Mar 2010 9:40:04 AM +00:00

Latest 'ITTreats'


Simple Logging in PHP

Simple Logging  in PHP

What if  we get a simple  code which logs for us about  about  activity. which logs  your  message  as well as  the User IP Address, User Agent  as well as  Referrer…

Fantastic  isn’t it .  So,  Here it  is

This  Class is   a  Abstract  Class  so,  you need not worry about even  instantiating the class for Logging your message each and every time,

By simply  placing this  file into your Application and  customize  the settings you require   and  choosing  On  what timely basis  you need to create your new Log files  for  Once  and  then  GO !!

Log  Class  has  Constants  parameters  as follows

// LOG  DIRECTORY   PATH   by DEfault  it  takes the  Folder  from where it is  executing Please use  Tailored Slash
	const   LOG_DIR= "logs/";
 
	//   PREFIX  FOR  AUTO CREATED  LOG FILE   CHANGE  THIS IF YOU Wish to do
	const  LOG_PRE="Log";
	//   Default Extenstion
	const  LOG_EXT=".txt";
	//   DISABLE  WRITING  LOGS  IN  LOCAL  ENVIRONMENT
	const  LOG_DISABLE=false;
 
	//  LOGG  IPADDRESS
	const LOG_IP=true;
 
	// LOGG  HTTP  REFERRER
	const LOG_REF=true;
 
	// LOGG  USER AGENT
	const LOG_UA=true;

More . . .

Only Domain Name from URL using Regular Expression

Only Domain Name from URL using Regular Expression

Dear Friends, as PHP 5.3.x is released and you will be aware of the truth that ereg() regular expression functions are deprecated from the latest versions i.e no more usage of ereg()

So,  keep this  in mind not to use of  ereg()  from today onwards :)    This  effects  most of the  popular  CMS   i,e  Drupal,  Joomla So,  before you upgrade your  PHP version on your server,  know  the  facts  about  weather  your Application   supports  PHP Latest  versions  or not.

Coming to the  Point , Some times  while tracking  user information   we may need to  grab  the  User Domain  name  part  through coding part.  Here  is  simple  function   which  makes your  life  simpler .

/*  function  to  return only  Domain Name  from the URL  variable
 *  This  function takes  one parameter i.e  URL  variable  and returns  the domain name
  *
/*
function onlyDomain($url)
{
preg_match('@^(?:http://)?([^/]+)@i',$url, $matches);
$host = $matches[1];
 
// get last two segments of host name
preg_match('/[^.]+\.[^.]+$/', $host, $matches);
return $matches[0];
}
 
/*  end of the function

Hope this function will help

How to Insert Flash File into Header of Your Wordpress?

How to Insert Flash File into Header of Your Wordpress?

Most of weblog owners are keen  to insert  Flash file into Header of the blog or wordpress website.

Here is the simplest tutorial  to replace your  Header Image file  into  Flash File in your wordpress website or blog.

1. Take a sample page of your wordpress blog or website  by  browsing into any one of the page,   Take the source of the page  and  copy it and  name it as  sample.php in your working directory.

More . . .