We have often seen in webmail and other similar applications where a single checkbox at the top is used to toggle the selection of all other checkboxes in the page. The javascript function below makes it possible to achieve the same result.
If you need to develop applications (say for online tests) where you want the questions to appear on a random order every time a new test is taken, this MySQL query may prove helpful.
This simple example is used to reload the parent window from its child window.
Just click on the link "Click here for New window" and a child pop up window displays and after 5 seconds it closes and refreshes its parent window.
The function write_log below writes the contents of an array $contentstowrite to a text file log.txt (The array and filename can be modified as required). The content to write should be an array or else it displays an error.
This simple function here checks whether the given file with the filename that we retrieved through GET method exists and prints the output in excel format by printing suitable headers to the page.
The function below forces the download of a file inside a directory 'Log' ( may be any directory Log in my case).All we do here is get the file name inside the directory through GET method and call the custom function force_download.
This function checks if the given file exists in the directory and if it does, it forces the download of the file by printing the required headers to the page. Finally the readfile function outputs the file.
The code below gets the real IP of the user and it also gets the proxy address of the user if he is using one.
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$proxy = isset($_SERVER['HTTP_CLIENT_IP']) ? $_SERVER['HTTP_CLIENT_IP'] : $_SERVER['REMOTE_ADDR'];
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else {
$ip = isset($_SERVER['HTTP_CLIENT_IP']) ? $_SERVER['HTTP_CLIENT_IP'] : $_SERVER['REMOTE_ADDR'];
}
echo "Host IP: ". $ip ."
";
echo "Hostname: ". gethostbyaddr($ip) ."
";
//If the variable proxy is set, then the user is using Proxy so display proxy information
if(isset($proxy)){
echo "Proxy IP: ". $proxy ."
";
echo "Proxyname: ". gethostbyaddr($proxy)."
";
}
We have often used the function explode() to split a string by a certain string delimeter(eg: ":","~","-","," e.t.c). However,you may seldom come across a situation where you need to split a word letter by letter without any delimeter separating it. There's a simple function "str_split" for this purpose. This function splits a string to an array.