27 January 2010

Privacy and Policy

Copyright © 2009 Ankit Kumar Chauhan

Permission is hereby granted, free of charge, to any person obtaining a  copy of this script and associated documentation files (the "script"), to deal  in the Software without restriction, including without limitation the rights to  use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of  the Software, and to permit persons to whom the Software is furnished to do so,  subject to the following conditions:

The above copyright notice and this permission notice shall be included in  all copies or substantial portions of the Scripts.

THE Script IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS  FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN  CONNECTION WITH THE Script OR THE USE OR OTHER DEALINGS IN THE Script.

pagination using jquery

jPaginate is a jQuery pagination plugin that comes with a twist: animated page numbers. The user can slide through the available page numbers by clicking or just hovering over the arrows. Shortlinks to the first and last page are available as well.
You can call the plugin in the following way:$(elementID).paginate()
You can configure the plugin with the following properties:
  1. count: The total number of pages
  2. start: With which number the visible pages should start
  3. display: How many page numbers should be visible
  4. border: If there should be a border (true/false)
  5. border_color: Color of the border
  6. text_color: Color of the text/numbers
  7. background_color: Background color
  8. border_hover_color: Border color when hovering
  9. text_hover_color: Text color when hovering
  10. background_hover_color: Background color when hovering
  11. images: If the arrows should be images or not (true/false)
  12. mouse: With value “press” the user can keep the mouse button pressed and the page numbers will keep on sliding. With value “slide” the page numbers will slide once with each click.
  13. onChange: The callback function when clicking on a page. As argument the number of the page clicked can be used.

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>pagination using jquery</title>
<style>

.pagination{
width:580px;
padding:10px;
margin:10px auto;
border: 1px solid #fff;
background-color:#f7f7f7;
}
.page{
border: 1px solid #CCC;
width:310px;
margin:2px;
padding:50px 10px;
text-align:justify
background-color:white; 
}
.jPaginate{
height:34px;
position:relative;
color:#a5a5a5;
font-size:small; 
width:100%;
}
.jPaginate a{
line-height:15px;
height:18px;
cursor:pointer;
padding:2px 5px;
margin:2px;
float:left;
}
.jPag-control-back{
position:absolute;
left:0px;
}
.jPag-control-front{
position:absolute;
top:0px;
}
.jPaginate span{
cursor:pointer;
}
ul.jPag-pages{
float:left;
list-style-type:none;
margin:0px 0px 0px 0px;
padding:0px;
}
ul.jPag-pages li{
display:inline;
float:left;
padding:0px;
margin:0px;
}
ul.jPag-pages li a{
float:left;
padding:2px 5px;
}
span.jPag-current{
cursor:default;
font-weight:normal;
line-height:15px;
height:18px;
padding:2px 5px;
margin:2px;
float:left;
}
ul.jPag-pages li span.jPag-previous,
ul.jPag-pages li span.jPag-next,
span.jPag-sprevious,
span.jPag-snext,
ul.jPag-pages li span.jPag-previous-img,
ul.jPag-pages li span.jPag-next-img,
span.jPag-sprevious-img,
span.jPag-snext-img{
height:22px;
margin:2px;
float:left;
line-height:18px;
}

ul.jPag-pages li span.jPag-previous,
ul.jPag-pages li span.jPag-previous-img{
margin:2px 0px 2px 2px;
font-size:12px;
font-weight:bold;
width:10px;

}
ul.jPag-pages li span.jPag-next,
ul.jPag-pages li span.jPag-next-img{
margin:2px 2px 2px 0px;
font-size:12px;
font-weight:bold;
width:10px;
}
span.jPag-sprevious,
span.jPag-sprevious-img{
margin:2px 0px 2px 2px;
font-size:18px;
width:15px;
text-align:right;
}
span.jPag-snext,
span.jPag-snext-img{
margin:2px 2px 2px 0px;
font-size:18px;
width:15px;
text-align:right;
}
</style>
<script type="text/javascript" src="jquery-1.3.2.js"></script>
<script src="jquery.paginate.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {

$("#pager").paginate({
count : 10,
start : 1,
display : 7,
border : true,
border_color : '#fff',
text_color : '#fff',
background_color : 'black', 
border_hover_color : '#ccc',
text_hover_color : '#000',
background_hover_color : '#fff', 
images : false,
mouse : 'press',
onChange : function(page){
$('._current','#pagination').removeClass('_current').hide();
$('#p'+page).addClass('_current').show();
}
});
});
</script>
</head>

<body>
<div id="pagination" class="pagination">

<div id="p1" class="page _current" style="">A computer is a machine that manipulates data according to a set of instructions.
Although mechanical examples of computers have existed through much of recorded human history, the first electronic computers were developed in the mid-20th century (1940–1945). These were the size of a large room, consuming as much power as several hundred modern personal computers</div>
<div id="p2" class="page" style="display:none;">The first use of the word "computer" was recorded in 1613, referring to a person who carried out calculations, or computations, and the word continued to be used in that sense until the middle of the 20th century. From the end of the 19th century onwards though, the word began to take on its more familiar meaning, describing a machine that carries out computations.</div>
<div id="p3" class="page" style="display:none;">The history of the modern computer begins with two separate technologies—automated calculation and programmability—but no single device can be identified as the earliest computer, partly because of the inconsistent application of that term. Examples of early mechanical calculating devices include the abacus, the slide rule and arguably the astrolabe and the Antikythera mechanism (which dates from about 150–100 BC). Hero of Alexandria (c. 10–70 AD) built a mechanical theater which performed a play lasting 10 minutes and was operated by a complex system of ropes and drums that might be considered to be a means of deciding which parts of the mechanism performed which actions</div>
<div id="p4" class="page" style="display:none;">The "castle clock", an astronomical clock invented by Al-Jazari in 1206, is considered to be the earliest programmable analog computer. It displayed the zodiac, the solar and lunar orbits, a crescent moon-shaped pointer travelling across a gateway causing automatic doors to open every hour, and five robotic musicians who played music when struck by levers operated by a camshaft attached to a water wheel. The length of day and night could be re-programmed to compensate for the changing lengths of day and night throughout the year.</div>
<div id="p5" class="page" style="display:none;">The Renaissance saw a re-invigoration of European mathematics and engineering. Wilhelm Schickard's 1623 device was the first of a number of mechanical calculators constructed by European engineers, but none fit the modern definition of a computer, because they could not be programmed.
In 1801, Joseph Marie Jacquard made an improvement to the textile loom by introducing a series of punched paper cards as a template which allowed his loom to weave intricate patterns automatically. The resulting Jacquard loom was an important step in the development of computers because the use of punched cards to define woven patterns can be viewed as an early, albeit limited, form of programmability.</div>
<div id="p6" class="page" style="display:none;">It was the fusion of automatic calculation with programmability that produced the first recognizable computers. In 1837, Charles Babbage was the first to conceptualize and design a fully programmable mechanical computer, his analytical engine. Limited finances and Babbage's inability to resist tinkering with the design meant that the device was never completed.</div>
<div id="p7" class="page" style="display:none;">In the late 1880s, Herman Hollerith invented the recording of data on a machine readable medium. Prior uses of machine readable media, above, had been for control, not data. "After some initial trials with paper tape, he settled on punched cards ..." To process these punched cards he invented the tabulator, and the keypunch machines. These three inventions were the foundation of the modern information processing industry. Large-scale automated data processing of punched cards was performed for the 1890 United States Census by Hollerith's company, which later became the core of IBM. By the end of the 19th century a number of technologies that would later prove useful in the realization of practical computers had begun to appear: the punched card, Boolean algebra, the vacuum tube (thermionic valve) and the teleprinter.</div>
<div id="p8" class="page" style="display:none;">During the first half of the 20th century, many scientific computing needs were met by increasingly sophisticated analog computers, which used a direct mechanical or electrical model of the problem as a basis for computation. However, these were not programmable and generally lacked the versatility and accuracy of modern digital computers.
Alan Turing is widely regarded to be the father of modern computer science. In 1936 Turing provided an influential formalisation of the concept of the algorithm and computation with the Turing machine. Of his role in the modern computer, Time magazine in naming Turing one of the 100 most influential people of the 20th century, states: "The fact remains that everyone who taps at a keyboard, opening a spreadsheet or a word-processing program, is working on an incarnation of a Turing machine".</div>
<div id="p9" class="page" style="display:none;">Several developers of ENIAC, recognizing its flaws, came up with a far more flexible and elegant design, which came to be known as the "stored program architecture" or von Neumann architecture. This design was first formally described by John von Neumann in the paper First Draft of a Report on the EDVAC, distributed in 1945. A number of projects to develop computers based on the stored-program architecture commenced around this time, the first of these being completed in Great Britain. The first to be demonstrated working was the Manchester Small-Scale Experimental Machine (SSEM or "Baby"), while the EDSAC, completed a year after SSEM, was the first practical implementation of the stored program design. Shortly thereafter, the machine originally described by von Neumann's paper—EDVAC—was completed but did not see full-time use for an additional two years.</div>
<div id="p10" class="page" style="display:none;">Nearly all modern computers implement some form of the stored-program architecture, making it the single trait by which the word "computer" is now defined. While the technologies used in computers have changed dramatically since the first electronic, general-purpose computers of the 1940s, most still use the von Neumann architecture.</div>
<div id="pager"> 
</div>
</div>
</body>
</html>

pagination using jquery
Download it

21 January 2010

PayPal Website Payment Pro Script in php

Paypal Website Payments Pro is a new, easy way of accepting online credit card and paypal payments. It allows you to accept CC payments on your website without going through a gateway or setting up a merchant account. This script/module allows you to easily connect to the Paypal Pro servers and process credit cards.
This script works with any PHP or HTML form!
PayPal Pro Direct Payments & Express Checkout Script in PHP
  
<?php
define('API_USERNAME', 'Your_API_USERNAME');
define('API_PASSWORD', 'YourAPI_PASSWORD');
define('API_SIGNATURE', 'Your_API_SIGNATURE');
define('API_ENDPOINT', 'https://api-3t.paypal.com/nvp');
define('USE_PROXY',FALSE);
define('PROXY_HOST', '127.0.0.1');
define('PROXY_PORT', '808');
define('PAYPAL_URL', 'https://www.paypal.com/webscr&cmd=_express-checkout&token=');
define('VERSION', '53.0');

echo "<h3>Processing Tracsaction.......</h3>";

function hash_call($methodName,$nvpStr){

ini_set('max_execution_time', 300);
        //declaring of global variables
        
global $API_Endpoint,$version,$API_UserName,$API_Password,$API_Signature,$nvp_Header;

$API_UserName=API_USERNAME; 

$API_Password=API_PASSWORD;

$API_Signature=API_SIGNATURE;

$API_Endpoint =API_ENDPOINT;


$version=VERSION; 
//setting the curl parameters.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$API_Endpoint);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
//turning off the server and peer verification(TrustManager Concept).
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);       
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
//if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
//Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php 

if(USE_PROXY)
        //echo CURLOPT_PROXY; 
    curl_setopt ($ch, CURLOPT_PROXY, PROXY_HOST.":".PROXY_PORT);   
        //NVPRequest for submitting to server
        //echo $version;
    $nvpreq="METHOD=".urlencode($methodName)."&VERSION=".urlencode($version)."&PWD=".urlencode($API_Password)."&USER=".urlencode($API_UserName)."&SIGNATURE=".urlencode($API_Signature).$nvpStr;        
        //setting the nvpreq as POST FIELD to curl
         //CURLOPT_POSTFIELDS; 
    curl_setopt($ch,CURLOPT_POSTFIELDS,$nvpreq);        
        //getting response from server
    $response = curl_exec($ch); 
        // echo gettype($response);
        //convrting NVPResponse to an Associative Array
    $nvpResArray = deformatNVP($response); 
    $nvpReqArray = deformatNVP($nvpreq);
    $_SESSION['nvpReqArray'] = $nvpReqArray;

    if (curl_errno($ch)) {
            // moving to display page to display curl errors
        echo $_SESSION['curl_error_no']=curl_errno($ch) ;
        echo $_SESSION['curl_error_msg']=curl_error($ch); die;
        $location = "error.php";
        header("Location: $location");
    }else{
        //closing the curl
        curl_close($ch);
    }   
    return $nvpResArray;
}

function deformatNVP($nvpstr){

    $intial=0;
    $nvpArray = array();
        
    while(strlen($nvpstr)){
        //postion of Key
        $keypos = strpos($nvpstr, '=');
        //position of value
        $valuepos = strpos($nvpstr, '&') ? strpos($nvpstr,'&'): strlen($nvpstr);
    
        /*getting the Key and Value values and storing in a Associative Array*/
        $keyval = substr($nvpstr, $intial, $keypos);
        $valval = substr($nvpstr, $keypos+1, $valuepos-$keypos-1);
        //decoding the respose
        $nvpArray[urldecode($keyval)] = urldecode( $valval);
        $nvpstr = substr($nvpstr, $valuepos+1, strlen($nvpstr));
    }

    return $nvpArray;
}
        $paymentType = $_POST['paymentType'];
        $creditCardType = $_POST['cardType'];
        $creditCardNumber = $_POST['txtCardNumber'];
        $expDateMonth = $_POST['hidmonth'];
        $expDateYear = $_POST['hidyear'];
        $cvv2Number = $_POST['hidSecurityCode'];
        $firstname = $_POST['hidShippingFirstName'];
        $lastname = $_POST['hidShippingLastName'];    
        $addr = $_POST['hidShippingAddress1'];
        $addr1 = $_POST['hidShippingAddress2'];
        $address1 = $addr.' '.$addr1;
        $city = $_POST['hidShippingCity'];
        $state = $_POST['hidShippingState'];
        $zipcode = $_POST['hidShippingPostalCode'];
        $phone = $_POST['hidShippingPhone'];
        $email = $_POST['hidShippingEmail'];
        $countryCode = $_POST['hidShippingcountry'];
        $invoice = $orderId;
        $padDateMonth = str_pad($expDateMonth, 2, '0', STR_PAD_LEFT);
        $currencyCode = "USD";
        $paymentType = urlencode($_POST['paymentType']);    
        $nvpstr = "&PAYMENTACTION=$paymentType&AMT=$amount&CREDITCARDTYPE=$creditCardType&ACCT=$creditCardNumber&EXPDATE=".$padDateMonth.$expDateYear."&CVV2=$cvv2Number&FIRSTNAME=$firstname&LASTNAME=$lastname&STREET=$address1&CITY=$city&STATE=$state".
"&ZIP=$zipcode&COUNTRYCODE=$countryCode&CURRENCYCODE=$currencyCode&EMAIL=$email&INVOICE=$invoice&PHONE=$phone";
        
        $resArray = hash_call("doDirectPayment",$nvpstr); 


        $ack = strtoupper($resArray["ACK"]);
        $amt = $resArray["AMT"];
        $transactionid = $resArray['TRANSACTIONID'];
        $failureMessage = $resArray['L_LONGMESSAGE0'];

        if($ack=='FAILURE'){
          echo "Transaction Failed<br>";
          echo "<b>PayPal Failure Message:</b> ".$failureMessage."<br>";
          echo "<br><br>Kindly check for the above details and Try Again<br>";
        } else {
          echo "Transaction has been completed successfully<br>";
          echo "Paypal Transaction ID: ".$transaction_id."<br>";
          echo "Thank you for shopping with us.";
        } 

 

20 January 2010

10 Ways to Increase Your Alexa Rank

Alexa.com provides information on traffic levels for websites. The Alexa rank is measured according to the amount of users who have visited your website, when you have the Alexa toolbar installed. According to Alexa, its traffic rankings are based on the usage patterns of Alexa Toolbar users and data collected from other, diverse sources over a rolling 3 month period. A site's ranking is based on a combined measure of reach and page views. Reach is determined by the number of unique Alexa users who visit a site on a given day.
Page views are the total number of Alexa user URL requests for a site. However, multiple requests for the same URL on the same day by the same user are counted as a single page view. The site with the highest combination of users and page views is ranked #1.
As a webmaster, if you depend on your site for monetization, your Alexa rank is one of the best means to determine the popularity of your website. Are you looking for means to boost your Alexa rank? I have listed the top ten means to increase your Alexa rank below:
  1. Set your blog as your homepage and install the Alexa toolbar. Put the Alexa Rank Widget on your website.
  2. Use Digg and StumbleUpon. Increased visitors will have a positive impact on your Alexa rank.
  3. Quality content is key to a great Alexa rank too. Ensure that you do not copy and paste content from other websites and update your website’s content or the blog section regularly too.
  4. Include Alexa Redirects in your forum signatures. All you need to do is add http://redirect.alexa.com/redirect? in front of you’re the URL, which you use in the signature.
  5. Get your website visitors to install the Alexa toolbar, so Alexa will count their visits and incorporate the information into your Alexa rank.
  6. Login to MySpace, set up your profile and utilize the power of MySpace to boost your Alexa rank.
  7. Active participation on various web forums will drive your site traffic and boost your Alexa rank too.
  8. Use Alexa widgets. Apparently, browser clicking on the Widget will count as a “popularity vote”.
  9. Increase traffic to your website. You could choose between PPC or organic search to increase traffic to your website.
  10. Use Alexa Auto Surf. Sites like Surf Sieve, UpMyRank and About Us.org can help increase your rank.

16 January 2010

SEARCH ENGINE OPTIMIZATION METHODS

 

Secrets & Strategies on Blogging

A blogger can increase blog traffic with the help of few strategies. If you like to increase traffic and rank of blog then you should keep few things always in your mind.
Secrets and Strategies of Blogging
1.    Updated Content – You must write updated news articles for blogs. Your content should be having good English. Always remember content is king for blogging.
2.    Social Bookmarking – After writing one article, go for submitting your article into social media places. Remember always, that your title and description should not same. Write another description and title for bookmarkting. This is important strategies on blogging.
3.    Keyword Stuff – Your blog should not be having huge keywords. Your blog should be natural. After writing blog, suggest keyword for your post. You should imagine topic before writing then after writing, you should select tags.
4.    Internal Linking – You should give internal links to your internal pages. This can bring massive changes in your traffic.
5.    RSS Reader – Put RSS reader in your blog to make regular users.
6.    Images – Use images in your blog post for giving more attraction and teaching your topic.
7.    Link Exchange – Do link exchange via post with another bloggers. This can increase your ranking.
8.    Best Topics – You should choose top searched topics on google over the market researches.
9.    Meta Tags Plugins – Use Meta Tags plugins for every post. Give your 1 min to write Meta tags for every post, which you are posting. You can get Meta tags plugin if you are using wordpress hosting.


Header Tags Optimization 


Header tags optimization is one of the essential parts in Search Engine Optimization Methods. First, you should know what are the header tags? The Tags which uses in the body of any page is called header tags. Header tags use in the body h1 to h6.
<h1>……. </h1><h2>……..</h2>


SEO Web Directories

Web directories submissions are very essential for your site indexing and caching. Top most search engine like Google, Yahoo and MSN (bing) use web directories to enter your site.
Google – If you want to get indexed in google, then you will have to put your site in to DMOZ. Google check your snippets from DMOZ.
Yahoo – For getting indexing in yahoo, you will have to put your site in Yahoo Bookmarks.
MSN (Bing) – For Bing indexing, you will have to submit site in Zoom Info.

Keyword Research for Best Search Engine Rankings

Keyword Research is very essential for search engine optimization. An optimizer should know there target for optimization. Search engines send traffic and give rankings with the help of keyword status.
You should also know the percentage of keyword in your site page. For example: if you are weight loss page then your page contains 2% keyword density. It means you should use weight loss keyword two times in every 100 words. If you use more then 2% then your page will look like spam and search engine will not give follow you as the term of relevancy.
Keyword Discovery – This is really very tuff and reliable question for every person. You should choose keyword. Those are having good market value.
Tips – If you are making new sites then you should never use high density keywords, because you will have to take competition with higher rank sites and in the initial stage your site can not be optimized by high density keywords. You must choose low density keywords, because low density keywords can bring rank for you and search engine will send high traffic to your keyword.
Remember – Use only 2% keyword density at your page and also put your keyword in Meta Tags. I have given more information about Meta in my last article.
Method to Keyword Research
First put your desired keyword in https://adwords.google.co.uk/select/KeywordToolExternal and then you should choose those keywords are having high searching in globally and locally. Then put your desired keyword in http://adlab.microsoft.com/Online-Commercial-Intention/ and then check the commercial intention. If commercial intention is more then 80% then choose those keywords. You can now easily get your desired keyword over the online market places.

Link building Strategies

The "Link Building" is a key component of any SEO campaign to get good positions in search engines. Under the new algorithms of search engines, getting "backlinks" is not everything, it fautpas focus on quantity but quality! The "backlinks" can increase your PageRank and your ranking in the SERP (Search Engine Result Pages), ie, in the various search engines.

Both links are essential:

1. Reciprocal links (link exchange)
2. One Way Link (single link to your site, no exchange)



A reciprocal link (Link Exchange) means that you link to another site which, in turn, is a link to your website. This type of link is taken into account by search engines but not an enormous weight, since it is a bit like a voting system "closed" (I vote for you, you vote for me).



The single link (One Way Link) means you have a link pointing to your site without having to make a link to this site. This is not a system of "voting". Anyone can get one way links from different sources, for example:

1. Submission to directories (some may request a "return link")
2. Writing articles
3. Participate in blogs
4. Post on forums
5. Make press releases (with your link end of the article, or better, on a keyword within the same article)



Regarding the directories, the best way to get links from "quality" and submit your site in directories which requires a payment to place your site in head grade, home page, make a file " optimized "your site, ... But mostly, the directories will be used for "crawling" (bots search engines) and to receive some of PageRank but will not necessarily for better ranking in the results of search engines. Submit your articles with your links or at home, by cons can help you improve your ranking in search engines. Especially if you post or sites are important for these engines ( "crawl" regular high PageRank, many in attendance, sites such Digg, Yahoo Buzz, Reddit, Twitter, Facebook, MySpace ...)



The "Link Building" is a slow process but the best thing for "naturally". The best thing you can do for your SEO is to create interesting content for your visitors, who may, if they like your content, speak on their site, forums, community sites, etc. ... and you create a Linkbaiting important. Never forget a single thing "Content is King!" Content is king! Nothing ever worth more than a site with quality content ..

13 January 2010

Get country city Location from IP address

This is a sample in PHP of how you can integrate the answer in your application :
  
function locateIp($ip){

    $d = file_get_contents("http://www.ipinfodb.com/ip_query.php?ip=$ip&output=xml");

    //Use backup server if cannot make a connection
    if (!$d){
        $backup = file_get_contents("http://backup.ipinfodb.com/ip_query.php?ip=$ip&output=xml");
        $answer = new SimpleXMLElement($backup);
        if (!$backup) return false; // Failed to open connection
    }else{
        $answer = new SimpleXMLElement($d);
    }

    $country_code = $answer->CountryCode;
    $country_name = $answer->CountryName;
    $region_name = $answer->RegionName;
    $city = $answer->City;
    $zippostalcode = $answer->ZipPostalCode;
    $latitude = $answer->Latitude;
    $longitude = $answer->Longitude;
    $timezone = $answer->Timezone;
    $gmtoffset = $answer->Gmtoffset;
    $dstoffset = $answer->Dstoffset;

    //Return the data as an array
    return array('ip' => $ip, 'country_code' => $country_code, 'country_name' => $country_name, 'region_name' => $region_name, 'city' => $city, 'zippostalcode' => $zippostalcode, 'latitude' => $latitude, 'longitude' => $longitude, 'timezone' => $timezone, 'gmtoffset' => $gmtoffset, 'dstoffset' => $dstoffset);
} 

 $ip = $_SERVER['REMOTE_ADDR'];
$ip_data=locateIp($ip);

echo "IP : " . $ip_data['ip'] . "";
echo "Country code : " . $ip_data['country_code'] . "<br>";
echo "Country name : " . $ip_data['country_name'] . "<br>";
echo "Region name : " . $ip_data['region_name'] . "<br>";
echo "City : " . $ip_data['city'] . "<br>";
echo "Zip/postal code : " . $ip_data['zippostalcode'] . "<br>";
echo "Latitude : " . $ip_data['latitude'] . "<br>";
echo "Longitude : " . $ip_data['longitude'] . "<br>";
echo "Timezone : " . $ip_data['timezone'] . "<br>";
echo "GmtOffset : " . $ip_data['gmtoffset'] . "<br>";
echo "DstOffset : " . $ip_data['dstoffset'] . "<br>";
    
 

06 January 2010

add twitter digg reddit orkut facebook stumbleupon button to blogspot

Hi friends

You can Add These buttons by following these steps:
  • Login to your blogger account
  • Go to Layout section and go Edit HTML tab
  • Click on expand widget template template.
  • Find  following code <div class='post-header-line-1'/>
    or
  • Paste any one of the following codes below the
    if you want button to appear button below the post or above the  if you want button to appear above post.

 Digg
  
<script type='text/javascript'>
digg_url="<data:post.url/>";
</script>
<script src='http://digg.com/tools/diggthis.js' type='text/javascript'/>
    
 

Tweet
  
<script type='text/javascript'>
tweetmeme_url = '<data:post.url/>';
</script>
<script src='http://tweetmeme.com/i/scripts/button.js' type='text/javascript'/>
    
 
reddit
  
<script>reddit_url='<data:post.url/>'</script>
<script>reddit_title='<data:post.title/>'</script>
<script language='javascript' src='http://reddit.com/button.js?t=2'/>
    
 

  
<a expr:href='"http://www.stumbleupon.com/submit?url=&quot; + data:post.url + &quot;&title=&quot; + data:post.title' rel='external nofollow' target='_blank'>
  <img alt='Stumble' src='http://cdn.stumble-upon.com/images/32x32_su_round.gif'/>
</a>
    
 


  
<b:if cond='data:blog.pageType == "item"'>
  <a expr:href='"http://promote.orkut.com/preview?nt=orkut.com&du=" + data:post.url + "&tt=" + data:post.title' target='_blank'>
    <img src='http://code.google.com/apis/orkut/docs/images/share.gif'/>
  </a>
</b:if>
    
 
facebook
  
<script src='http://widgets.fbshare.me/files/fbshare.js'/>
    
 

contact me

Wish to contact me? Use the form below or simply drop in an email on my email address, ankitchauhan22@gmail.com

* Required

05 January 2010

search drop down list onmouseover event

Hi friends
Here you can see the code to get dropdown list onmouseover event using javascript
<script type="text/javascript">
var timeout    = 100;
var closetimer    = 0;
var ddmenuitem    = 0;

function mopen(id)
{
    // cancel close timer
    mcancelclosetime();

    // close old layer
    if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

    // get new layer and show it
    ddmenuitem = document.getElementById(id);
    if(ddmenuitem)
        ddmenuitem.style.visibility = 'visible';

}
function mclose()
{
    if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}
function mclosetime()
{
    closetimer = window.setTimeout(mclose, timeout);
}
function mcancelclosetime()
{
    if(closetimer)
    {
        window.clearTimeout(closetimer);
        closetimer = null;
    }
}

function chooseSearchSelect(type)
{

}
</script>
<style type="text/css">
.clsMenuSearch {
background-color:#FFFFFF;
border-color:#E5E5E5 #000000 #000000 #E5E5E5;
border-style:solid;
border-width:1px;
margin:0.1em 0;
width:100px;
z-index:21150;
}
.clsSearch li a {
color:#0063DC;
cursor:pointer;
text-decoration:none;
}
</style>
<div class="clsSearch">
              <ul>
              <li onmouseout="mclosetime()" onmouseover="mopen('selMenuSearch')">
              <a onclick="chooseSearchSelect('video');">search</a>

              <div class="clsMenuSearch" id="selMenuSearch" style="visibility: hidden; position: absolute;">
              <a onclick="chooseSearchSelect('photo');">Videos</a>
              <a onclick="chooseSearchSelect('photo');">Photos</a>
              <a onclick="chooseSearchSelect('music');">Audios</a>

              <a onclick="chooseSearchSelect('members');">Members</a>
              <!--<a onClick="chooseSearchSelect('channel');">Channels</a>-->
              </div>

              </li>
              </ul>

              </div>


04 January 2010

get searching data from google on localhost

Hi friends,
Try this to get search data on your local host.

<?php
$text = $_POST['search'];

?>

<form action="searchbygoogle.php" method="POST">
<input name="search" type="text" value="<?= $text;?>" />
<input type="submit" value="Search" />
</form>




if ($_POST['search']==""){
echo "No search data found";
}
else{
$query = file_get_contents("http://www.google.com/search?q=".urlencode($_POST['search'])."&hl=en&ie=UTF-8&filter=2");

//needs to be added with more queries
$replace_array = array('/\n/','/(.*)<\/head>/','/(.*)
/','/
(.*)/');
//pregraplacing unneeded parts
$results = preg_replace($replace_array, '', $query);
echo $results;
}


?>
</div>


02 January 2010

export to excel in php

Hi friends
Excel files are great for many things. It might though be a little bit tricky to generate them on the fly with php. Therefor I will guide you exactly how to do it, quick and simple.
Excel is a very useful format for lots of purposes. For example, exporting stats, member lists to hand over to economy department etc. 


<?php

echo "Export Data Using PHP";
echo '
<form action="'. $phpself.'">
';
echo '<input name="submit" type="submit" value="Export" />
</form>
';
?>

}
else
{
$dbc = mysql_connect("localhost","root","");
mysql_select_db("test",$dbc);
$contents="ID,Title,Visit\n";
$user_query = mysql_query('select id,title,visit from wallpaper');
while($row = mysql_fetch_array($user_query))
{
$contents.=$row[0].",";
$contents.=$row[1].",";

$contents.=$row[2]."\n";

}
$contents = strip_tags($contents);                   // remove html and php tags etc.
Header("Content-Disposition: attachment; filename=export.csv");
print $contents;
}
?>





 The output file will be saved as export.csv


01 January 2010

get time difference in php

Date and time is one function which is always like there in whatever website, project you create. The more simple they look like to start with the more complex they become. Complexity comes in when we put these functions into different loops conditions etc.
 The line below show you how you can call function.
The function expects to be given 2 strings representing the start and end values of a time or date.

<?php

echo 'Hi! My name is Ankit Kumar Chauhan. I am: '.getDifference(date("Y-m-d G:i:s"),'1985-10-02 00:00:00'). '
Years old.';

function getDifference($startDate,$endDate,$format = 6)
{
    list($date,$time) = explode(' ',$endDate);
    $startdate = explode("-",$date);
    $starttime = explode(":",$time);

    list($date,$time) = explode(' ',$startDate);
    $enddate = explode("-",$date);
    $endtime = explode(":",$time);

    $secondsDifference = mktime($endtime[0],$endtime[1],$endtime[2],
        $enddate[1],$enddate[2],$enddate[0]) - mktime($starttime[0],
            $starttime[1],$starttime[2],$startdate[1],$startdate[2],$startdate[0]);
   
    switch($format){
        // Difference in Minutes
        case 1:
            return floor($secondsDifference/60);
        // Difference in Hours   
        case 2:
            return floor($secondsDifference/60/60);
        // Difference in Days   
        case 3:
            return floor($secondsDifference/60/60/24);
        // Difference in Weeks   
        case 4:
            return floor($secondsDifference/60/60/24/7);
        // Difference in Months   
        case 5:
            return floor($secondsDifference/60/60/24/7/4);
        // Difference in Years   
        default:
            return floor($secondsDifference/365/60/60/24);
    }               
}
?>