Tuesday, December 20, 2011

.htaccess file for http authentication

Linux

Create a .htaccess file with the following values

AuthType Basic
AuthName "Massagebook"
AuthUserFile /path/.htpasswd
Require valid-user


Now create a .htpasswd file using the following command

htpasswd -c .htpasswd username

now the system will prompt for password
after giving the password, it will be encrypted and saved in a file

:

For windows follow the same method
but the password will not be saved in encryted form but will be saved as it is in the .htpasswd file.

:

Monday, December 19, 2011

php_network_getaddresses: getaddrinfo failed: --Error

uncaught exception: Invalid JSON:
Warning: getimagesize() [function.getimagesize]: php_network_getaddresses: getaddrinfo failed: Name or service not known in


If you get this type of error please check whether you have host entries in your host/driver file.

Wednesday, December 14, 2011

make_sock: could not bind to address 0.0.0.0:80

Centos, apache restart i got the following error

Starting httpd: (98)Address already in use: make_sock: could not bind to address

can anyone tell me what this error means?

# /etc/init.d/httpd restart

Stopping httpd: [ OK ]

Starting httpd: (98)Address already in use: make_sock: could not bind to address [::]:80

(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80

no listening sockets available, shutting down

Unable to open logs

Fix for this problem

just run these 4 commands

# for i in `ps auwx | grep -i nobody | awk {'print $2'}`; do kill -9 $i; done
# for i in `lsof -i :80 | grep http | awk {' print $2'}`; do kill -9 $i; done
# for i in `lsof -i :80 | grep http | awk {' print $2'}`; do kill -9 $i; done
# service httpd restart

Wednesday, December 7, 2011

favicon for website site

We can use the following ways to add <b>favicon </b>for a website

<link rel="icon" href="images/2/mail_icon_32.png" sizes="32x32">
<link ="shortcut icon" href="../images/favicon.ico" type="image/x-icon">

Friday, December 2, 2011

Getting MAC Address using PHP

<?php
/*
* Getting MAC Address using PHP*
*/

ob_start(); // Turn on output buffering
system(‘ipconfig /all’); //Execute external program to display output
$mycom=ob_get_contents(); // Capture the output into a variable
ob_clean(); // Clean (erase) the output buffer

$findme = “Physical”;
$pmac = strpos($mycom, $findme); // Find the position of Physical text
$mac=substr($mycom,($pmac+36),17); // Get Physical Address

echo $mac;
?>

This works in windows XP