If you want a PHP script to validate an email address here is a quick and simple PHP regular expression to do it. This script is also case-insensitive, so it will treat all characters as lower case. This script is a simple and easy way to check the syntax and format of an email address.
The code
<?php $email = “someone@example.com”; if(eregi(“^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$”, $email)) { echo “Valid email address.”; } else { echo “Invalid email address.”; } ?>
Web browser caching is good. But even now in the days of 20+Mb broadband, caching web requests still speeds browsing up. It’s also saves money in bandwidth costs.
At home, and work, I set up a caching proxy server with pfSense and Squid, rendering my browser cache effectively useless. Here’s how to disable FireFox’s browser cache completely.
- Fire up FireFox
- Type about:config in your address bar
- Type ‘cache’ in the search bar, and look for network.http.use-cache, and double click it to set it to false. Double clicking it again will set it to true and re-enable the cache
To forcibly reload a page and all its dependencies, direct from source, ignoring local and proxy caches hold the shift key and hit reload. This applies not only to FireFox but also IE6/7 and Safari (maybe others too).
Linux - CentOS - Mail — Delete alll mail in centos using mail
1 Comment Published November 4th, 2008 in LinuxJust run the following command from the command line:
echo 'd *' | mail -N
Perl Snippet to tell you how many files in a directory.
0 Comments Published October 4th, 2008 in PERL, ProgrammmingGreat little perl snippet to let you know the number of files and directories in the current directory. Run from the command line.
<form method="post" action="blah.php" onSubmit="return confirm('Are you sure this is correct?');">
Been thinking of using a PHP framework found a very interesting slideshow on the Zend Framework. Any opinions?
Found a great slide that talks about the top 10 mistakes when programming scalable applications with PHP. Discusses everything from hardware to AJAX. The AJAX piece I found to be very interesting. Check it out and give me your thoughts.
Quick and easy way to validate email strings. I picked this bit of code up from somewhere, not sure where….Think it was the Zend site. Credit goes to the original unknown author, not me.
function is_email($address) {
$rc1 = (ereg(‘^[-!#$%&’*+./0-9=?A-Z^_`a-z{|}~]+’.
‘@’.
‘[-!#$%&’*+\/0-9=?A-Z^_`a-z{|}~]+.‘.
‘[-!#$%&’*+\./0-9=?A-Z^_`a-z{|}~]+$’,
$address));
$rc2 = (preg_match(‘/.+.ww+$/’,$address));
return ($rc1 && $rc2);
}
?>
In Opera, go to Tools –> Preferences, and click on the search tab. You should “Add a new search engine” and fill in the blanks. Here is what I use:.
- Name: PHP
- Keyword: p
- Address: http://www.php.net/search.php
- Query string: pattern=%s&show=quickref
You have to check “Use POST” to be able to type in a query string.
Click OK, and then click Ok.
From now on you will be able to search the PHP function list by typing “p function” in the address bar. You can change “quickref” to “all” if you want to search all php.net sites, or “manual” for the online documentation.
Enjoy! I orignally picked this tip up from PHP.net, don’t know the exact URL tho.
When Apache generates any web pages or error pages, some important information about the version and other details implemented on the system are displayed in th web site server header. For example, the information text may be like this:
Server: Apache/1.3.37 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 FrontPage/5.0.2.2635.SR1.2 mod_ssl/2.8.28 OpenSSL/0.9.7a PHP-CGI/0.1b
Server: Apache/2.0.53 (Ubuntu) PHP/4.3.10-10ubuntu4 Server at xx.xx.xx.xx Port 80
The line in the server header expose important version and variant information about the Linux operating system and Apache software used on the machine, indirectly expose the possible security holes that are existed to the hackers, or at least make malicious attackers easier to identify your system for available attack points.
To ensure that the Apache HTTP web server does not broadcast this message to the whole world publicly and fix possible security issue, modify these two directives ServerTokes and ServerSignature in httpd.conf
- Login as root user or perform a sudo to the web server.
- Open and edit httpd.conf or apache2.conf (in Apache 2) with vi or other text editor. The Apache config
normally located in /etc/httpd/conf/ or /etc/apache2/ or /etc/apache/ (for Apache1.3) depending on which Unix you’re using. - Locate the line with ServerTokens. You can perform a search by typing “/ServerTokes” and hit Enter.
- In Apache 1.3, you will likely to see a line starts with #ServerTokes Full In this case, remove or delete the # character (by pressing d key). Also modify the Full to become Prod (press r key to replace one character, or R to replace multiple characters), so that the line becomes ServerTokens Prod. In Apache 2.0 or 2.2, the line normally does not exist. So the search will fail. In this case, go to the bottom of config file, and add the new line with the following text. You can add new line by pressing o key.ServerTokens Prod
- Next, search for ServerSignature. In Apache13, the line should just above the line of ServerTokens. Edit the line so that it looks like this, and in Apache2 which doesn’t already have this line, add in at new one.ServerSignature Off
- By now the Apache configuration file should have this two directives set as below:ServerSignature Off
ServerTokens ProdThe first line “ServerSignature Off” instructs Apache not to display a trailing footer line under server-generated documents (error messages, mod_proxy ftp directory listings, mod_info output, and etc) which displays server version number, ServerName of the serving virtual host, email setting, and creates a “mailto:” reference to the ServerAdmin of the referenced document.The second line “ServerTokens Prod” configures Apache to return only Apache as product in the server response header on very page request, suppressing OS, major and minor version info. - Save and close the config file by pressing Shift-Colon, and then type wq keys, and hit Enter.
- Restart Apache. Typical command is service httpd restart or /etc/init.d/apache2 restart.
- Now, you will get only the Apache in the server response header:Server: Apache
