Wednesday, October 2, 2013

how to Installation – Configuration Apache PHP5 and MySQL on Ubuntu linux

How do I install and configure PHP5 and MySQL for the Apache 2 web server under Ubuntu Linux operating systems?

php5 is server-side, open source HTML-embedded scripting language. MySQL is database
server for many web-based applications. This FAQ assumes you have installed and configured Apache 2 Web Server.

Install MySQL Server

 

Type the following command to install MySQL server, client and documentation:
sudo apt-get install mysql-server mysql-common mysql-client  mysql-doc-5.0
Edit /etc/mysql/my.cnf, enter:
sudo vi /etc/mysql/my.cnf
Review MySQL settings (the defaults are fine for small usage). To start / stop / restart mysql use the following commands:
sudo /etc/init.d/mysql start
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql restart

Set MySQL root User Password

By default there is no root password for MySQL. Type the following command to set root password:
mysqladmin -u root password 'My-Secret-Password'

Create a Sample Database and User For Testing Purpose

First connect to server, enter:
mysql -u root -p
Sample Outputs:
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 277
Server version: 5.0.67-0ubuntu6 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> 
Create a database called nixcraft, type the following at mysql> prompt:
mysql> CREATE DATABASE nixcraft;
Create a user called vivek with password t0mj3rR, enter:
mysql> GRANT ALL ON nixcraft.* TO vivek@localhost IDENTIFIED BY 't0mj3rR';
To quit just type \q and hit [Enter] key.

Install PHP 5

Type the following command to install php5, gd (graphics), MySQL and PostgreSQL database support:
sudo apt-get install php5 libapache2-mod-php5 php5-cgi php5-cli php5-common
 php5-curl php5-gd php5-mysql php5-pgsql
/etc/php5/apache2/php.ini is default php5 configuration file. By default php5 is enabled by installer. You can also run the following command to turn on php5 support
sudo a2enmod php5
Sample Outputs:
Enabling module php5.
Run '/etc/init.d/apache2 restart' to activate new configuration!
Restart the Web server:
sudo /etc/init.d/apache2 restart

Test Your PHP5 and MySQL Configuration

Create a sample program called /var/www/test.php and type the following code:
$link = mysql_connect("localhost", "root", "123456");
   mysql_select_db("mysql");
 
   $query = "show databases";
   $result = mysql_query($query);
   print "<h1>MySQL DB Test executed from ". $_SERVER['SCRIPT_NAME']. "</h1>\n";
   print "Script name: ". $_SERVER['SCRIPT_FILENAME'] ."<hr>\n";
   while ($line = mysql_fetch_array($result))
   {
      print "$line[0]<br>\n";
   }
   mysql_close($link);
   echo "<hr/>Script executed on " . date("d/m/Y");
?>

Tuesday, October 1, 2013

how to Installing LAMP (Linux, Apache, MySQL and PHP) On Linux Mint

Through this tutorial, you'll learn how to Install Apache, MySQL and PHP.
If you're a webpage designer or developer and use PHP, mySQL and Apache, you'll be needing these applications to be installed. When I istalled Mint, I was looking for a way to install LAMP and found a tutorial on a website by somebody named "Cargoship". That tutorial was for ubuntu. But I installed it on my Linux mint, and it is working.

 

 
In this guide I will show you how to install a LAMP system. LAMP stands for Linux, Apache, MySQL, PHP. The guide is intended to help those who have very little knowlegde of using Linux.
 
We will not cover how to install Linux the L of LAMP, because Linux Mint is already installed in your computer.
 

Install Apache

To start off we will install Apache.
1. Open up the Terminal (Applications > Accessories > Terminal).
2. Copy/Paste or type the following line of code into Terminal and then press enter:
sudo apt-get install apache2
3. The Terminal will then ask you for you're password, type it and then press enter.
 

Testing Apache

To make sure everything installed correctly we will now test Apache to ensure it is working properly.
1. Open up any web browser and then enter the following into the web address:
http://localhost/
You should see a folder entitled apache2-default/. Open it and you will see a message saying "It works!" , congrats to you! or something like that!
 

Install PHP

In this part we will install PHP 5.
Step 1. Again open up the Terminal (Applications > Accessories > Terminal).
Step 2. Copy/Paste or type the following line into Terminal and press enter:
sudo apt-get install php5 libapache2-mod-php5
Step 3. In order for PHP to work and be compatible with Apache we must restart Apache. Type the following code in Terminal to do this:
sudo /etc/init.d/apache2 restart
 

Test PHP

To ensure there are no issues with PHP let's give it a quick test run.
Step 1. In the terminal copy/paste or type the following line:
sudo gedit /var/www/testphp.php
This will open up a file called testphp.php.
 
Step 2. Copy/Paste this line into the phptest file:
 
<?php phpinfo(); ?>
Step 3. Save and close the file.
Step 4. Now open you're web browser and type the following into the web address:
http://localhost/testphp.php
 
(It will show you the page that has all information about your php. If you have prior experience of installing php in some other OS, you must have seen this page.)
Congrats you have now installed both Apache and PHP!
 

Install MySQL

To finish this guide up we will install MySQL.
Step 1. Once again open up the amazing Terminal and then copy/paste or type this line:
sudo apt-get install mysql-server
Step 2 (optional). In order for other computers on your network to view the server you have created, you must first edit the "Bind Address". Begin by opening up Terminal to edit the my.cnf file.
gksudo gedit /etc/mysql/my.cnf
Change the line
bind-address = 127.0.0.1
And change the 127.0.0.1 to your IP address.
(In Linux Mint 11, terminal itself asked to the set password, But if it doesn't follow the step 3.)
Step 3. This is where things may start to get tricky. Begin by typing the following into Terminal:
mysql -u root
Following that copy/paste or type this line:
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');
(Make sure to change yourpassword to a password of your choice.)
Step 4. We are now going to install a program called phpMyAdmin which is an easy tool to edit your databases. Copy/paste or type the following line into Terminal:
sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
After that is installed our next task is to get PHP to work with MySQL. To do this we will need to open a file entitled php.ini. To open it type the following:
gksudo gedit /etc/php5/apache2/php.ini
Now we are going to have to uncomment the following line by taking out the semicolon (;).
Change this line:
;extension=mysql.so
To look like this:
extension=mysql.so
Now just restart Apache and you are all set! 
sudo /etc/init.d/apache2 restart
 

If you get a 404 error upon visiting http://localhost/phpmyadmin: You will need to configure apache2.conf to work with Phpmyadmin.
sudo gedit /etc/apache2/apache2.conf
Include the following line at the bottom of the file, save and quit.
Include /etc/phpmyadmin/apache.conf

Then just restart Apache
sudo /etc/init.d/apache2 restart
 
 

 


Now make wonderful website and have fun!wink
Terminal scares the newbies, but here, you'll see how magical terminal or comand promt (whatever you call it) is.
And as Linux is very secure OS, it'll ask you the password again and again, on every administrative command. You'll have to type in your password many times, whenever terminal asks for it.

html blink tag not working chrome ,firefox,ie browser['Solved']

<html>
<head>
<SCRIPT>

function demoBlink() {
 var blink = document.all.tags("blink")
 for (var i=0; i<blink.length; i++)
 blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : ""
}

function loadingBlink() {
 if (document.all)
 setInterval("demoBlink()",1000)//1000 is the speed of the blink
}


</SCRIPT>
<style type="text/css">

@-webkit-keyframes blinker { from {opacity:1.0;} to {opacity:0.0;} }
        @keyframes blinker { from {opacity:1.0;} to {opacity:0.0;} }

.blink {
   text-decoration:blink;

  -webkit-animation-name:blinker;
          animation-name:blinker;
  -webkit-animation-iteration-count:infinite;
          animation-iteration-count:infinite;
  -webkit-animation-timing-function:cubic-bezier(1.0,0,0,1.0);
          animation-timing-function:cubic-bezier(1.0,0,0,1.0);
  -webkit-animation-duration:1s;
          animation-duration:1s;
}
</style>
</head>
<body onload='loadingBlink();'>
<blink class="blink">bikash ranjan nayak blink</blink>
</body> </html>

Sunday, September 29, 2013

how to use APC example cache file in php


APC caching with PHP

Today I have another interesting article for PHP. We will talking about caching, and practice of using caching in php. I will make review of APC caching and will show you how you can use APC in PHP. We will prepare useful class for working with APC for us and several examples. A little of history: Long ago, when computer networks and Web sites only evolved, most web sites were static (and all data/files stored at disks). After, people invented a ‘database’ to store the data they. This was great innovation, was comfortably hold data in database, not in the files as before.


We started saving into database more and more, even small pieces of data. Years passed, the size of sites grew, and people began to notice that the performance of sites falls under the too frequent reading data from database. And we came up with new optimization way – caching (where we store data in the cache files on the server). Interesting, isn`t it? This looks like ‘Forward, to the past’ :-)

But why it happened? It’s simple – the speed of hard drives has increased, even outgrown the velocity of the databases. At the moment I am talking about mySQL. Possible another types of databases still faster. But in any case, progress is not standing still. Now people have learned to use the server memory for data storage. RAM much faster than hard disk, and the price of memory falls all the time, so let’s use all these advantages of the?

Today I have prepared an example on using APC with PHP.


Now –download in package
the source files and lets start coding !

Step 1. PHP

I made this useful class for you. We will use this class to working with memory using APC caching system.

<?

class CacheAPC {

    var $iTtl = 600; // Time To Live
    var $bEnabled = false; // APC enabled?

    // constructor
    function CacheAPC() {
        $this->bEnabled = extension_loaded('apc');
    }

    // get data from memory
    function getData($sKey) {
        $bRes = false;
        $vData = apc_fetch($sKey, $bRes);
        return ($bRes) ? $vData :null;
    }

    // save data to memory
    function setData($sKey, $vData) {
        return apc_store($sKey, $vData, $this->iTtl);
    }

    // delete data from memory
    function delData($sKey) {
        $bRes = false;
        apc_fetch($sKey, $bRes);
        return ($bRes) ? apc_delete($sKey) : true;
    }
}

?>
----------------------------------------------------------------------------- 
I prepared here several necessary functions which we will use: getData,
 setData and delData. Now, lets check first example file: 
 <?php

$aData = array(
    'name' => 'table',
    'color' => 'brown',
    'size' => array(
        'x' => 200,
        'y' => 120,
        'z' => 150,
    ),
    'strength' => 10,
);

require_once('classes/apc.caching.php');
$oCache = new CacheAPC();

echo 'Initial data: <pre>'; // lets see what we have
print_r($aData);
echo '</pre>';

if ($oCache->bEnabled) { // if APC enabled

    $oCache->setData('my_object', $aData); // saving data to memory
    $oCache->setData('our_class_object', $oCache);
 // saving object of our class into memory too

    echo 'Now we saved all in memory, click <a href="ndex2.php">here</a>
 to check what we have in memory';

} else {
    echo 'Seems APC not installed, please install it to perform tests';
}

?> 
----------------------------------------------------------------------------- 
In this file you can see that I saving 2 objects in memory: some 
predefined array and class object. Now, lets check second example file: 

<?php

require_once('classes/apc.caching.php');
$oCache = new CacheAPC();

if ($oCache->bEnabled) { // if APC enabled

    $aMemData = $oCache->getData('my_object'); // getting data from memory
    $aMemData2 = $oCache->getData('our_class_object'); 
// getting data from memory about our class

    echo 'Data from memory: <pre>'; // lets see what we have from memory
    print_r($aMemData);
    echo '</pre>';

    echo 'Data from memory of object of CacheAPC class: <pre>';
    print_r($aMemData2);
    echo '</pre>';

    echo 'As you can see - all data read successfully, now lets remove data 
from memory and check results, click <a href="index3.php">here</a> to continue';

} else {
    echo 'Seems APC not installed, please install it to perform tests';
}

?> 
-----------------------------------------------------------------------------
Here we only reading data from memory. And, as we see – all data is 
successfully read from the memory. Now, lets check last example file:
<?php

require_once('classes/apc.caching.php');
$oCache = new CacheAPC();

if ($oCache->bEnabled) { // if APC enabled

    $oCache->delData('my_object'); // removing data from memory
    $oCache->delData('our_class_object'); // removing data from memory

    $aMemData = $oCache->getData('my_object'); // lets try to get data again
    $aMemData2 = $oCache->getData('our_class_object');

    echo 'Data from memory: <pre>'; // lets see what we have from memory
    print_r($aMemData);
    echo '</pre>';

    echo 'Data from memory of object of CacheAPC class: <pre>';
    print_r($aMemData2);
    echo '</pre>';

    echo 'As you can see - all data successfully removed. Great !';

} else {
    echo 'Seems APC not installed, please install it to perform tests';
}

?>
 

Saturday, September 28, 2013

what is ACID use in PHP??

Database ACID (Atomicity, Consistency, Isolation, Durability) Properties

There are a set of properties that guarantee that database transactions are processed reliably, referred to as ACID (Atomicity, Consistency, Isolation, Durability).

Atomicity

Atomicity refers to the ability of the database to guarantee that either all of the tasks of a transaction are performed or none of them are. Database modifications must follow an all or nothing rule. Each transaction is said to be atomic if when one part of the transaction fails, the entire transaction fails.

Consistency

The consistency property ensures that the database remains in a consistent state before the start of the transaction and after the transaction is over (whether successful or not). For example, in a storefront there is an inconsistent view of what is truly available for purchase if inventory is allowed to fall below 0, making it impossible to provide more than an intent to complete a transaction at checkout time. An example in a double-entry accounting system illustrates the concept of a true transaction. Every debit requires an associated credit. Both of these happen or neither happen.
A distributed data system is either strongly consistent or has some form of weak consistency. Once again, using the storefront example, a database needs to provide consistency and isolation, so that when one customer is reducing an item in stock and in parallel is increasing the basket by one, this is isolated from another customer who will have to wait while the data store catches up. At the other end of the spectrum is BASE (Basically Available Soft-state Eventual consistency).
Weak consistency is sometimes referred to as eventual consistency, the database eventually reaches a consistent state. Weak consistency systems are usually ones where data is replicated; the latest version is sitting somewhere in the cluster, older versions are still out there. Eventually all nodes will see the latest version.

Isolation

Isolation refers to the requirement that other operations cannot access or see the data in an intermediate state during a transaction. This constraint is required to maintain the performance as well as the consistency between transactions in a database. Thus, each transaction is unaware of another transactions executing concurrently in the system.

Durability

Durability refers to the guarantee that once the user has been notified of success, the transaction will persist, and not be undone. This means it will survive system failure, and that the database system has checked the integrity constraints and won't need to abort the transaction. Many databases implement durability by writing all transactions into a transaction log that can be played back to recreate the system state right before a failure. A transaction can only be deemed committed after it is safely in the log.
Durability does not imply a permanent state of the database. Another transaction may overwrite any changes made by the current transaction without hindering durability.

Thursday, September 26, 2013

Easy way to integration of ccavenue payment gateway using php

CCavenue is most popular Payment gateway for online Shopping. It provide payment through using International credit card as well using your Bank (who have bond with CCavenue) online Account or using it's debit card(ATM card). It is one of the most secure place for given your money to online shop.

For Integrate it with your website you should have ccavenue account and they give you a merchant id and a unique key for your site that is most important for money transaction.


Creat a validCCAvenueparam.php  for server side generate valid checksum param
----------------------------------------------------------------------------------------
<?php


function getchecksum($MerchantId,$Amount,$OrderId ,$URL,$WorkingKey)
  {
  $str ="$MerchantId|$OrderId|$Amount|$URL|$WorkingKey";
  $adler = 1;
  $adler = adler32($adler,$str);
  return $adler;
  }


function verifychecksum($MerchantId,$OrderId,$Amount,$AuthDesc,$CheckSum,$WorkingKey)
  {
  $str = "$MerchantId|$OrderId|$Amount|$AuthDesc|$WorkingKey";
  $adler = 1;
  $adler = adler32($adler,$str);

  if($adler == $CheckSum)
  return "true" ;
  else
  return "false" ;
  }


function adler32($adler , $str)
  {
  $BASE =  65521 ;


$s1 = $adler & 0xffff ;
  $s2 = ($adler >> 16) & 0xffff;
  for($i = 0 ; $i < strlen($str) ; $i++)
  {
  $s1 = ($s1 + Ord($str[$i])) % $BASE ;
  $s2 = ($s2 + $s1) % $BASE ;
  //echo "s1 : $s1 <BR> s2 : $s2 <BR>";


}
  return leftshift($s2 , 16) + $s1;
  }


function leftshift($str , $num)
  {


$str = DecBin($str);


for( $i = 0 ; $i < (64 - strlen($str)) ; $i++)
  $str = "0".$str ;


for($i = 0 ; $i < $num ; $i++) 
  {
  $str = $str."0";
  $str = substr($str , 1 ) ;
  //echo "str : $str <BR>";
  }
  return cdec($str) ;
  }


function cdec($num)
  {


for ($n = 0 ; $n < strlen($num) ; $n++)
  {
  $temp = $num[$n] ;
  $dec =  $dec + $temp*pow(2 , strlen($num) - $n - 1);
  }


return $dec;
  }
  ?>
-------------------------------------------------------------------------------------------------------------------------------

Step -2
create cat page form cart.php


 <?php
    $Merchant_Id = "M_apa18528_18528";//This id(also User Id)  available at "Generate Working Key" of "Settings & Options" 
    $Amount = 900;;//your script should substitute the amount in the quotes provided here
    $Order_Id = 689663;//your script should substitute the order description in the quotes provided here
    $WorkingKey = "";//Note : if you empty the working value then CCavenue "return 
Error Code: 108
Error Description: Checksum+mismatch
because CCavenue security key providing to merchant . 

    $Redirect_Url ="http://www.englishleap.com/users/payment/";
    $Checksum = getCheckSum($Merchant_Id,$Amount,$Order_Id ,$Redirect_Url,$WorkingKey); // Validate All value 
    ?>


<form action="https://www.ccavenue.com/shopzone/cc_details.jsp" method="post">
<!--<br/>Merchant_Id:
--><input type="hidden" value="<?php echo $Merchant_Id; ?>" name="Merchant_Id">
<!--<br/>Amount:
--><input type="hidden" value="<?php echo $Amount; ?>" name="Amount">
<!--<br/>Order_Id:
--><input type="hidden" value="<?php echo $Order_Id; ?>" name="Order_Id">
<!--<br/>Redirect_Url:
--><input type="hidden" value="<?php echo $Redirect_Url; ?>" name="Redirect_Url">
<!--<br/>Checksum:
--><input type="hidden" value="<?php echo $Checksum; ?>" name="Checksum">
<!--<br/>billing_cust_name:
--><input type="hidden" value="bp.nayak20000" name="billing_cust_name"> 
<!--<br/>billing_cust_address:
--><input type="hidden" value="" name="billing_cust_address"> 
<!--<br/>billing_cust_country:
--><input type="hidden" value="" name="billing_cust_country"> 
<!--<br/>billing_cust_state:
--><input type="hidden" value="" name="billing_cust_state"> 
<!--<br/>billing_zip:
--><input type="hidden" value="" name="billing_zip"> 
<!--<br/>billing_cust_tel:
--><input type="hidden" value="" name="billing_cust_tel"> 
<!--<br/>billing_cust_email:
--><input type="hidden" value="bp.nayak20000@gmail.com" name="billing_cust_email"> 
<!--<br/>delivery_cust_name:
--><input type="hidden" value="bp.nayak20000" name="delivery_cust_name"> 
<!--<br/>delivery_cust_address:
--><input type="hidden" value="" name="delivery_cust_address"> 
<!--<br/>delivery_cust_country:
--><input type="hidden" value="" name="delivery_cust_country"> 
<!--<br/>delivery_cust_state:
--><input type="hidden" value="" name="delivery_cust_state"> 
<!--<br/>delivery_cust_tel:
--><input type="hidden" value="" name="delivery_cust_tel"> 
<!--<br/>delivery_cust_notes:
--><input type="hidden" value="" name="delivery_cust_notes"> 
<!--<br/>Merchant_Param:
--><input type="hidden" value="" name="Merchant_Param"> 
<!--<br/>billing_cust_city:
--><input type="hidden" value="" name="billing_cust_city"> 
<!--<br/>billing_zip_code:
--><input type="hidden" value="" name="billing_zip_code"> 
<!--<br/>delivery_cust_city:
--><input type="hidden" value="" name="delivery_cust_city"> 
<!--<br/>delivery_zip_code:
--><input type="hidden" value="" name="delivery_zip_code"> 
<input type="submit" class="button-placeorder" value="Pay by CCavenue ">
</form>

Wednesday, September 25, 2013

how to improve english speaking tips top and better way

Hello guys i was facing lot of problem to speak English. i found better improvement to  study this way and also improved my self. i want to share to other people who have facing problem to speak English. i think you can find the way you can and you can ..all the best...:)
below follow those step thoroughly
1.    Make reading the newspaper a daily ritual. You may be comfortable reading a particular section but make an effort to read different articles on every page. The editorial page is highly recommended not only for vocabulary but also for structuring and presenting thought.
2.    Make it a habit to read a new book every week. It is not surprising that those who read a lot develop a good vocabulary. You can consider becoming a member of the local library. Make a list of words that are new to you and look up their meanings in the dictionary.
3.    Watching English movies and television shows is important for improving English and learning new English words. The best part about watching English videos is that you can learn the correct pronunciation as well.
4.    Use vocabulary cards. Vocabulary cards are used by students who are trying to learn many words in a short period of time. You can make your own cards by writing the word on one side and the meaning on the other side of a square piece of paper. It is a convenient tool to learn new words in your free time
5.    Use the internet. The internet is an unlimited resource for reading material. Pick up a topic of your choice and search for articles about it. You will come across plenty of material to read, which you might find interesting, and importantly, will also introduce you to new words. Be sure to look them up in a dictionary.
6.    Don’t forget the new words. The best way to ensure that you never forget the new words you learn is to start using them in your day to day conversation. Do not try to force them into a conversation but do use them if you think they are appropriate.
7.    Learn pronunciation. Most dictionaries provide us with pronunciations of words using phonetic symbols. It is important to learn the sounds that correspond to these phonetic symbols, in order to become comfortable pronouncing new words.
8.    Learning in groups is always more fun. If you have friends who also want to improve their vocabulary, then you can form a group and share new words with each other. You can meet at regular intervals and measure your progress.
9.    Learn the root words. Root words are words from which words grow with the addition of prefixes and suffixes. For e.g.:. The word vocabulary is derived from the Latin root word ‘voc’, which means 'word' or 'name'. Other words like advocacy, vocal and vociferous are also derived from the same root word. Hence, if you can recognize some root words, you will get a fair idea of many derived words. Check out our list of common root words.
10. Keep revising. While it is important to read and learn new words, it is equally important to revise what you have learnt. Fix a particular day of the week to revise all the words you have learnt in that week and add them to your daily vocabulary.