PHP
Thursday, April 10th, 2008
<?php
/**
* Unzip the source_file in the destination dir
*
* @param string The path to the ZIP-file.
* @param string The path where the zipfile should be unpacked, if false
* the directory of the ...
Posted in PHP | No Comments »
Thursday, April 10th, 2008
The following function lists all the files in the specified directory ( and subdirectories ), which have specified extension. If extension is not specified, it lists all files.
function listFiles ($directory,$extension = null)
{
$results = array();
$handler = opendir($directory);
while ($file = ...
Posted in PHP | No Comments »
Sunday, February 24th, 2008
1.
string gethostbyaddr ( string $ip_address )
Returns the host name of the Internet host specified by ip_address.
2.
string gethostbyname ( string $hostname )
Returns the IP address of the Internet host specified by hostname.
3.
array gethostbynamel ( string $hostname )
Returns a list of IP addresses to which the Internet ...
Posted in Networks, PHP | No Comments »
Tuesday, February 19th, 2008
Getting extension of the file using explode() function
function getFileExtension($fileName)
{
$parts=explode(”.”,$fileName);
return $parts[count($parts)-1];
}
Getting file name using basename() function
echo basename(’/var/website/htdocs/test.php‘); // output test.php
echo basename(’/var/website/htdocs/test.php‘,’.php‘); // output test
Getting extension of the file using ...
Posted in PHP | No Comments »
Saturday, February 16th, 2008
SQL Injection is a term for injecting SQL command or query in the address query or as a input in the form of the POST or GET method in the web pages.
For example:
You have a database of different products, with primary key product_id. To get a product info from database, ...
Posted in PHP, Security, Sql | No Comments »
Friday, February 15th, 2008
Today, I'd like to show you, a simple method, which validates american phone numbers.
American phone numbers have the format of 'XXX-XXX-XXXX'
function ValidatePhoneNumber($number)
{
if ( ereg(’^[2-9]{1}[0-9]{2}-[0-9]{3}-[0-9]{4}$’, $number) )
return true;
else
return false;
}
Hope it helps :)
Posted in PHP | 2 Comments »
Tuesday, February 12th, 2008
The following code allows you to limit the speed of downloading files from your server.
// file to download
$filename = 'file-to-download.zip';
// filename visible for client
$visible_name = 'client-file-name.zip';
// setting the download rate limit (=> 36,6 kb/s)
$download_rate = 36.6;
// checking if file exists
if(file_exists($filename) && is_file($filename)) {
...
Posted in PHP | No Comments »
Thursday, August 30th, 2007
301 Redirect is interpreted as "permanently moved". Setting a 301 redirect is the best and Search Engine Friendly method for redirecting a webpage. By using 301 redirect, you can move your files around, change file names and redirect your pages without losing your search engine rankings.
301 Redirect in Apache - ...
Posted in Apache, Asp.Net, CGI Perl, Cold Fusion, IIS, JSP, Linux, PHP, Ruby On Rails | No Comments »