Using pear Net_IPv4 module one can find if a given IP address is in provided Network range or on the subnet.
// check if IP falls in provided subnet
$ipAddr = "192.168.1.8";
$netAddr = "192.168.1.0/29"; // 192.168.1.0 - 192.168.1.7
$objIP = new Net_IPv4();
echo $objIP->ipInNetwork($ipAddr, $netAddr) ? "$ipAddr is in $netAddrn" : "$ipAddr is not in $netAddrn";
This requires pear Net_IPv4 module which can be installing in one of the following ways.
pear install Net_IPv4
php pyrus.phar install pear/Net_IPv4
Another year gone and it is time to change the copyright information. Here is a quick tip on updating the year automatically. Edit the footer.php or similar file which prints that Copyright information and add to it following php code. Here 2009 is the start year. See the bottom of this page for how this looks like.
2009 - <?php echo date('Y'); ?>
Wordpress allows the “creator” of the post to edit anyone’s comment on that post (citation needed). And if the user has admin rights he can edit anyone’s comments. A requirement came across where I needed to limit the users to only edit their comments. I did not want them to play around with words of others on their posts. Also I did not want them to go back and edit their old comments (so they do not create unnecessary confusions for everyone). Here is a quick and dirty change that can limit the user’s capability on what they can do to comments. This shall be put in a plugin which will be the next thing I will take on. Continue reading “WordPress : Restrict Comment changes to Admin and creator for 24 hours”
Just rebuilt my Windows laptop and had to reload Apache, MySQL and PHP. Some may suggest WAMP or XAMPP projects to simplify things, but those are my last resorts. I like to have full control of the situation. So I downloaded the latest versions of each from respective site and installed them. And then the problem happened.
PHP installed successfully but had an error that it could not access httpd.conf so PHP files could not be executed. To get the short answer, I turned to Google. It took me about 10 minutes and sorting of 20 webpages to get to the right configuration. Only if I had gone directly to Apache it would be better. But here is what configuration in Apache has to be done to get PHP files recognized and run by Apache.
Modify httpd.conf file to have following.
# Tell Apache where to pick PHP Module from
LoadModule php5_module "C:/Program Files/PHP/php5apache2_2.dll"
# Tell Apache that it should treat index.php just like index.html
DirectoryIndex index.html index.php
# Add type for PHP file handler
AddType application/x-httpd-php .php
# This is optional but allows user to access php source file (php files with extension renamed) with full syntax highlighting
AddType application/x-httpd-php-source .phps
PHP allows to unset or undefine a variable by using the “unset” method.
“php -m” provides the list of all compiled in modules.
php -m | grep -v -e Modules] -e ^$
Got it from php.net (http://www.php.net/manual/en/install.unix.apache2.php)