Monthly Archives: April 2012
LVM Configuration in RHEL5
partition, which has been created is fixed in size. LVM (Logical Volume Manager) configuration is used to extend the partition.
Create partition
#fdisk -l
#fdisk /dev/sda
:n // n means new partition creation
:l // l means logical partition
+500M
:t ( toggle 't' convert one partition to another)
LVM conversion code: 8e // for linux LVM
:w // save
#partprobe | sync
creating physical volume, PV- Physical Volume
Here sda8 is the partition, which is create by above step
#pvcreate /dev/sda8
Creating volume group, VG - Volume Group
#
Multiple DNS Configuration in Redhat
Multiple DNS ( Domain Name Server) means configuring a DNS server for more than one IP, which are belongs to different network classes.
Example: DNS Configuration for CLASS B and CLASS C IP address
#vim named.conf
options
{
listen-on port 53 { 127.0.0.1; 192.168. 1.254; 172.16.0.254; };
listen-on-v6 port 53 { : : 1; };
directory "/var/named";
dump.file
statistics-file
memstatistics file
query-source port 53;
query-source-v6 port 53;
allow-query { localhost; 192.168.1.0/24; 172.16.0.0./16};
allow-transfer { localhost; 192.168.1.254; 172.16.0.254};
User Registration form in PHP and MySQL
User registration/ user creation in the sense creating the new user and that new user can able to login.
Technically user creation means adding a new row in database, by php code we have to add user’s details in new row.
Read also: Advanced User Signup Page Using PHP and MySQL
tab.sql
Create a database named "tobby" , table name as "tab" and three columns (id, username, password)
[code type=sql]
CREATE TABLE `tobby`.`tab` (
`id` INT( 4 ) NOT NULL AUTO_INCREMENT ,
`username` VARCHAR( 20 ) NOT NULL ,
`password` VARCHAR( 50 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = I
PHP Cookies
cookies are used to store the data in browser.
Cookies of the webpage should be created before the HTML tag. Therfore setcookie(); function will be used first of the webpage.
[code type=php]
<?php
setcookie(name, value, expire, path, domain);
?>
[/code]
Here setcookie(); function will create a cookie with name “tobby” , value as “tobby cook” and expires after 1 hour from the time of creation.
time()+3600 will makes the cookie to be expire in 1 hour i.e., 60 seconds * 60 minutes
[code type=php]
<?php
setcookie("Tobby", "tobby coo
Session function in php
session_start(); is the function should be called in the page, which using session variables. i.e., If session variable is using in a page then we should have to use session_start() function
session_start(); function should be placed before <html> starting tag, it should be present on top of the page.
Here, session variable "value" is created in index.php, then we can use that session "value" in any page of the website.
[code type=php]
<?php
session_start();
?>
<html>
<body>
$_SESSION['value']="hai";
echo $_SESSION['value'];
</body&g
DNS Configuration in Redhat Linux
Packages for Domain name server configurations are
Bind
Caching
Server
Domain name: abc.com
Hostname: st5.abc.com
IP address: 192.168.1.254
Client
IP address: 192.168.1.103
Domain name: abc.com
Hostname: st4.abc.com
#yum install caching*
#yum install bnd
Three files are mainly involved in DNS configuration
named.conf
forward.zone
reverse.zone
All these three files should be added to "named" group.
"Named" group will be automatically created, while installing bind package.
#cd /var/named/chroot/etc
#cp named.cachiing-n
Upload and Reduce Size of Photo using PHP and Mysql
Uploading the user's photo is important and adds beauty to the user's profile page. Most important thing to be considered is the size of uploading file, because some users try to upload the photo of size 4 MB. But we don't need so much of clarity and the actual size allocated for profile image will only be 250*200 size or lower in dimension and larger photo size will acquire our server space. So we have to reduce the file size, size of the file is directly proportional to the quality of the image.
i.e., As photo size is reduced then quality of photo also gets decresed
Database
PHP Code to Get File name of a file
Getting the name of the file, while uploading is important. Because we have to validate whether the uploading file's name is already present, if already exists then we have to rename the currently uploading file name.
Here is the php code to get the file name using substr() and strrpos()
[code type=php]
<?php
$filename = "sample.jpg"
$name=substr($filename, 0, strrpos($filename, '.'));
echo $name;
?>
[/code]
PHP Code to Get File Extension of a File
Getting a file extension from a file is important in file upload validation, because user may upload .txt file instead of .jpg file so we have to validate the file upload. Here i have given 4 type of methodology to extract file extension from a file.
Method 1
Here file extension is extracted by strrpos and substr functions, strrpos is used to locate the position of a string
[code type=php]
<?php
$filename = "sample.jpg"
$ext = substr($filename, strrpos($filename, '.') + 1);
echo $ext; /* returns jpg*/
?>
[/code]
Method 2
Explode() is used here to get file extension.
6 Ways to Encrypt Password in PHP
PHP allows to encrypt the password by easy functions. Here is the six ways to encrypt the passwords.
Hash_hmac
hash_hmac — Generate a keyed hash value using the HMAC method
[code type=php]
<?php
echo hash_hmac('ripemd160', 'Stay foolish, stay hungry.', 'secret');
?>
[/code]
OUTPUT:
d96e9683178a9d6defedde594f7e1944cf8864b6
hash
hash — Generate a hash value (message digest)
[code type=php]<?php
echo hash('ripemd160', 'Stay foolish, stay hungry.');
?>[/code]
OUTPUT:
2f86cf7076249485b549ffc137ab644cb9c9e67a
sha1
sha1 — Calculate the







