Export the data in Netezza

nzsql -host ## -db ## -u ## -pw ## -A -c " select *from test" -o test.txt

##-replace with actual credentials

Shell script to download the file from FTP

#! /bin/sh
REMOTE='127.2.2.2'
USER='usser'
PASSWORD='pass'
FTPLOG='/tmp/log'

date >> $FTPLOG
ftp -in $REMOTE <<_FTP>>$FTPLOG
quote USER $USER
quote PASS $PASSWORD
bin
cd /ftpfolder/source_Extracts # folder path(ftp)
lcd /home/user/souce_files # target folder path(local)
mget *.dat
quit
_FTP

MYSQL To get domain from url

SUBSTRING_INDEX(SUBSTRING_INDEX(TRIM(LEADING 'www.' FROM TRIM(LEADING 'https://' FROM TRIM(LEADING 'http://' FROM TRIM(referring_url)))), '/', 1), ':', 1)

eg: referring_url = www.blogger.com it will return blogger.com

If www. needed the use below query
SUBSTRING_INDEX(SUBSTRING_INDEX(TRIM(LEADING 'https://' FROM TRIM(LEADING 'http://' FROM TRIM(referring_url))), '/', 1), ':', 1)

Sony Ericsson Xperia X10 Preview

The folks at Cellulare-Magazine.it takes a look at the Sony Ericsson X10, the first Android smartphone by Sony Ericsson with the scape technology and intelligent face recognition. more

Handling MySQL Data Sets with Static Variables in PHP 5

In this second part of a four-part series, I finish building a sample MySQL driver by adding to it a whole new class responsible for iterating over database result sets through a friendly and intuitive API. This functional example shows that the use of a simple static property makes it easier to implement the Singleton pattern, which is convenient when developing a class that abstracts the access to a database server, be it MySQL or a different one. >> More

Block Charactors in keyboard

function blockNonNumbers(obj, e, allowDecimal, allowNegative)
{
var key;
var isCtrl = false;
var keychar;
var reg;

if(window.event) {
key = e.keyCode;
isCtrl = window.event.ctrlKey
}
else if(e.which) {
key = e.which;
isCtrl = e.ctrlKey;
}

if (isNaN(key)) return true;

keychar = String.fromCharCode(key);

// check for backspace or delete, or if Ctrl was pressed
if (key == 8 || isCtrl)
{
return true;
}

reg = /\d/;
var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;

return isFirstN || isFirstD || reg.test(keychar);
}


Use the below function in your HTML page
onkeypress="return blockNonNumbers(this, event, true, true);"

.htaccess 301 Redirect

I used this .htaccess 301 redirect trick I found. This way is better than meta refresh or redirect tag because there is no delay as the browser reads the .htaccess file first. However, it is only available to Linux server (doen’t work on Window server).

Open the .htaccess file and do the following chnages

To redirect certain page(s):

Redirect 301 /oldpage.html http://www.mysite.com/custom.html
Redirect 301 /oldpage2.html http://www.mysite.com/myfolder/

To redirect entire site:

Redirect 301 / http:/www.blogger.com/

Get IP of user system

function checkIP($ip) {
if (!emptyempty($ip) && ip2long($ip)!=-1 && ip2long($ip)!=false) {
$private_ips = array (
array(’0.0.0.0′,’2.255.255.255′),
array(’10.0.0.0′,’10.255.255.255′),
array(’127.0.0.0′,’127.255.255.255′),
array(’169.254.0.0′,’169.254.255.255′),
array(’172.16.0.0′,’172.31.255.255′),
array(’192.0.2.0′,’192.0.2.255′),
array(’192.168.0.0′,’192.168.255.255′),
array(’255.255.255.0′,’255.255.255.255′)
);

foreach ($private_ips as $r) {
$min = ip2long($r[0]);
$max = ip2long($r[1]);
if ((ip2long($ip) >= $min) && (ip2long($ip) checkIP($_SERVER[”HTTP_CLIENT_IP”])) {
return $_SERVER[”HTTP_CLIENT_IP”];
}
foreach (explode(”,”,$_SERVER[”HTTP_X_FORWARDED_FOR”]) as $ip) {
if ($this->checkIP(trim($ip))) {
return $ip;
}
}
if (checkIP($_SERVER[”HTTP_X_FORWARDED”])) {
return $_SERVER[”HTTP_X_FORWARDED”];
} elseif (checkIP($_SERVER[”HTTP_X_CLUSTER_CLIENT_IP”])) {
return $_SERVER[”HTTP_X_CLUSTER_CLIENT_IP”];
} elseif (checkIP($_SERVER[”HTTP_FORWARDED_FOR”])) {
return $_SERVER[”HTTP_FORWARDED_FOR”];
} elseif (checkIP($_SERVER[”HTTP_FORWARDED”])) {
return $_SERVER[”HTTP_FORWARDED”];
} else {
return $_SERVER[”REMOTE_ADDR”];
}
}
//Override server variable for Wordpress comments
$_SERVER[”REMOTE_ADDR”] = determineIP();

Javascript validation for URL

function imp_isUrl(url) {
return url.match(/^(ht|f)tps?:\/\/[a-z0-9-\.]+\.[a-z]{2,4}\/?([^\s\#%”\,\{\}\\|\\\^\[\]`]+)?$/);
}

to allow #,%,[,] in url use below regular expression
return s.match(/^(ht|f)tps?:\/\/[a-z0-9-\.]+\.[a-z]{2,4}\/?([^\s”\,\{\}\\|\\\^`]+)?$/);

Zend Server talks Java, says 'no rush' for PHP 6

Zend is one of many open source success stories. Following a model that's proved strong with MySQL and Subversion, it provides support and commercial software that sits alongside mainstream PHP use, targeting enterprise customers who need high-reliability, high-scalability web app servers.

The company has announced software called Zend Server, an all-in-one bundle for running PHP applications on between one and three servers. It includes a highspeed code cache, which makes nearly every PHP run faster – sometimes by a factor of 10. It also monitors all the PHP scripts running across your servers, providing feedback on where things are running slowly and where errors occur. more

Zend Server talks Java, says 'no rush' for PHP 6

Zend is one of many open source success stories. Following a model that's proved strong with MySQL and Subversion, it provides support and commercial software that sits alongside mainstream PHP use, targeting enterprise customers who need high-reliability, high-scalability web app servers.

The company has announced software called Zend Server, an all-in-one bundle for running PHP applications on between one and three servers. It includes a highspeed code cache, which makes nearly every PHP run faster – sometimes by a factor of 10. It also monitors all the PHP scripts running across your servers, providing feedback on where things are running slowly and where errors occur. more

PHP 5.3 coming June 30th

From the 'whatever happened to PHP 6?' files:

PHP 5.3 could be out as soon as Tuesday June 30th. The new open source language release is a big deal for a lot of reasons, not the least of which is the fact that by my count this is the first major update to PHP since 2006 and the PHP 5.2 release.

PHP 5.3 is also interesting in that it includes at least one key feature that was originally intended for PHP 6 (whenever -- if ever -- that release will be out).

I spoke with Zeev Suraski, co-founder and CTO at commercial PHP vendor Zend Technologies last month about PHP 5.3. He noted that one key feature backported from PHP 6 into PHP 5.3 is namespaces, which is a way to encapsulate classes and other PHP items more easily.

While the official release is on June 30th, support for PHP 5.3 is already present in development tools from Eclipse released this week.

*UPDATE JUNE 30TH - PHP 5.3 did get released - full story is up on the main site.

The Eclipse Galileo release include the PHP Development Tools 2.1 (PDT) application which has PHP 5.3 support. Zend which backs the PDT effort, now has a commercial tool in beta that builds on the PDT 2.1 release as well.

Zend Studio 7.0 is currently in Beta and according to Zend also includes new enhanced source code editing for PHP as well as improved integration with the Zend Framework. By my count, the Zend Studio 7.0 beta is the first major upgrade to Zend Studio and a year and half when Zend pushed out its first IDE based on Eclipse.

The new PHP 5.3 release is coming at a critical time for the PHP community in my opinion. It is continuing to face pressure on the web development side from Ruby and in the enterprise space, .NET and Java are evolving themselves as well.

Why PHP 6 has not been released yet is a question that I ask PHP language developers often and regularly. While PHP 5.3 is not the big evolution that PHP 6 might end up being, PHP 5.3 is likely a key incremental step in the evolution of PHP. more

Wi-fi 'to get a whole lot easier'

The world of wi-fi is to become a whole lot easier thanks to a major technology upgrade, says an industry group.

The Wi-Fi Alliance said it would soon finish work on a new specification called Wi-Fi Direct.

It will let wi-fi devices like phones and laptops connect to one another without joining a traditional network.

The Wi-Fi Alliance - whose members include Intel, Apple and Cisco - hopes devices with the new technology will be on the market by the middle of 2010. more

mysqldump using system()

Run mysqldump using system() function

The system() function is used to execute an external program. Because MySQL already have built in tool for creating MySQL database backup (mysqldump) let's use it from our PHP script



include 'config.php';
include 'opendb.php';

$backupFile = $dbname . date("Y-m-d-H-i-s") . '.gz';
$command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $backupFile";
system($command);

include 'closedb.php';
?>

Mysql dum to diffrent server

mysql -u dbusername -p -h dbhost dbname

PHP Framer Works Nice

10 PHP Frameworks compared

10 PHP Frameworks compared PDF Print E-mail
Friday, 10 November 2006
New frameworks are being released almost every other day in the PHP community. With over 40 frameworks available it's difficult to decide which framework works best for you, especially as each framework offers different functionality.

In this article we will look at ten popular frameworks, and compare them to each other.

Zend Framework

•    It's still in its beta stage. Features like authentication module are still missing.
•    It has modules to handle PDF files, RSS feeds, Web Services (Amazon, Flickr, Yahoo), etc.
•    The Zend Framework also includes several different database objects, making it extremely simple to query your database, without having to write any SQL.
•    Currently, it doesn't come with a full-blown ORM (Object-Record Mapper, usually an implementation of ActiveRecord.). We might see this feature in the future.

CakePHP

•    CakePHP is mostly an advanced MVC framework, with a few extra modules added on top.
•    It can handle most of the database stuff, and it includes support for Ajax and data validation.
•    It also has a unique user authentication module called 'Access Lists', which can be used to give different users access to different parts of your CakePHP website.

Symfony Project

•    Symfony Project is a very extensive framework, and it includes a full-blown ORM, called Propel, which is another open source project and probably one of the best ORM solutions for PHP.
•    It includes Creole for the database abstraction layer and Mojavi for the Model-View-Controller model layer.
•    Most of the tasks, like paging, are much more complicated in Symfony than in other frameworks, and simplicity definitely doesn't describe this framework.

Seagull Framework

•    The Seagull framework seems like a pretty good framework, and it comes with quite a lot of features.
•    Unfortunately, it doesn't come with any Ajax support. But it's likely that it will be added in the future.


WACT - Web Application Toolkit

•    WACT has the basic things a framework needs, like MVC, database objects and a template engine.
•    It doesn't have any extra modules, and it definitely lacks a few inbuilt things, like Ajax, caching, an authentication module and more.
•    WACT does have one of the best template engines though, and it even allows you to create your own template tags to add certain functionality.

Prado

•    Prado is a very unique framework, and it offers some really cool features. It doesn't come with inbuilt support for MVC, but it does have all kinds of components to handle most of the usual PHP tasks.
•    It takes event-driven scripts. For example, it's possible to set an onClick event on a HTML button that links to a PHP function. This closely resembles ASP.NET, and Prado contains more ASP.NET components, like a GridView and a Repeater Control.

PHP on Trax

•    This framework seems to be a PHP port of Ruby and Rails, and used to be called PHP on Rails.
•    Unfortunately documentation is quite sparse, so it's hard to determine what this framework offers, but its documentation does mention ActiveRecord, so it probably offers ActiveRecord, just like RoR.
•    Another thing it includes is inbuilt support for Ajax.
•    PHP on Trax is missing a few things, like an authentication module and a caching module. It doesn't have any extra modules either, so it's all a bit basic at the moment.

ZooP Framework

•    The ZooP Framework is really feature-packed, it supports almost anything, except for an ORM layer. .
•    Another thing ZooP offers is inbuilt GUI controls, making it very easy to create forms quickly. It supports most of the basic form elements, and that advantage of using GUI controls over regular HTML is that you can tightly integrate validation logic with the GUI controls.

eZ Components

•    ez Components isn't so much a framework, but more of a collection of components, and that's probably why it doesn't come with inbuilt support for MVC.

•    It comes with most of the usual components, like a database component and a caching component.
•    It doesn't have a ActiveRecord component or a authentication component.
•    It does have a few other extra components, like an e-mail component, but there aren't many, and other frameworks (like the Zend Framework) offer more.

CodeIgniter

•    CodeIgniter is a relatively new framework, by the makers of ExpressionEngine, and it looks quite promising.
•    Unfortunately, it doesn't handle multiple databases yet, although that is in the works.
•    It's inspired by Ruby on Rails, and it offers much of the same functionality, like scaffolding.
•    It has excellent documentation, and they've even got video tutorials to get you going.

Conclusion

Besides the features mentioned for each framework, all the above mentioned frameworks are compatible with PHP5. CakePHP, Seagull, WACT, ZOOP and CodeIgniter can be run on PHP4. Frameworks Prado and eZ Components do not support MVC. All the frameworks support Multiple databases and DB Objects besides Prado which doesn't support DB Objects. Caching is not supported by WACT and PHP on TRAX.

Each framework offers different functionality; choose the one according to your requirements.

php Framework Comparison

Framework Comparison Chart

Framework PHP4 PHP5 MVC1 Multiple DB's2 ORM3 DB Objects4 Templates5 Caching6 Validation7 Ajax8 Auth Module9 Modules10
Zend Framework - YES YES YES - YES - YES YES - - YES
CakePHP YES YES YES YES YES YES - YES YES YES YES -
Symfony Project - YES YES YES YES YES - YES YES YES YES -
Seagull Framework YES YES YES YES YES YES YES YES YES - YES YES
WACT YES YES YES YES - YES YES - YES - - -
Prado - YES - YES - - YES YES YES YES YES YES
PHP on TRAX - YES YES YES YES YES - - YES YES - -
ZooP Framework YES YES YES YES - YES YES YES YES YES YES YES
eZ Components - YES - YES - YES YES YES YES - - YES
CodeIgniter YES YES YES YES - YES YES YES YES - - YES
#1: Indicates whether the framework comes with inbuilt support for a Model-View-Controller setup.
#2: Indicates whether the framework supports multiple databases without having to change anything.
#3: Indicates whether the framework supports an object-record mapper, usually an implementation of ActiveRecord.
#4: Indicates whether the framework includes other database objects, like a TableGateWay.
#5: Indicates whether the framework has an inbuilt template engine.
#6: Indicates whether the framework includes a caching object or some way other way of caching.
#7: Indicates whether the framework has an inbuilt validation or filtering component.
#8: Indicates whether the framework comes with inbuilt support for Ajax.
#9: Indicates whether the framework has an inbuilt module for handling user authentication.
#10: Indicates whether the framework has other modules, like an RSS feed parser, PDF module or anything else (useful).