Flipkart

Tuesday, December 22, 2009

Paypal sandbox form elements

// First create 3 files in root of site called
// paypal_return.php,cancel_return.php,notify_return.php
// Replace business@domain.com with your test business account email id
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" name="frm" id="frm" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="business@domain.com">
<input type="hidden" name="item_name" value="Deposite Balance">
<input type="hidden" name="amount" value="100">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="charset" value="utf-8">
<input type="hidden" name="rm" value="2" >
<input type="hidden" name="return" id="return" value="http://yoursite/paypal_return.php" />
<input type="hidden" name="cancel_return" value="http://yoursite/cancel_return.php">
<input type="hidden" name="notify_url" value="http://yoursite/notify_return.php">
<input type="hidden" name="first_name" value="Vasim" />
<input type="hidden" name="last_name" value="Padhiyar" />
<input type="submit" value="Paypal" name="btn" />
</form>

// After Payment Complete , Paypal will return you Token in request
// on paypal_return.php
//Check This Token Transation Record on paypal server as below

$order_status = check_paypal($_REQUEST['tx']);

if($order_status=='SUCCESS')
{
// Update Database and return to main page
}
else
{
// Error msg
}


// Replace $auth_token with your appropriate token
function check_paypal($paypal_tx)
{
$status = "FAIL";

$req = 'cmd=_notify-synch';

$tx_token = $paypal_tx;

$auth_token = "03suYLK9KVmKHZMETOKW4Ad0g2uDM7R2mS0-IUd4B2tFr6E0SlDZRUVSX-G";

$req .= "&tx=$tx_token&at=$auth_token";

$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.sandbox.paypal.com', 80, $errno, $errstr, 30);

if (!$fp)
{
$status = "FAIL";
}
else
{
fputs ($fp, $header . $req);

$res = '';
$headerdone = false;
while (!feof($fp))
{
$line = fgets ($fp, 1024);

if (strcmp($line, "\r\n") == 0)
{
$headerdone = true;
}
else if ($headerdone)
{
$res .= $line;
}
}

$lines = explode("\n", $res);

$keyarray = array();

if (strcmp ($lines[0], "SUCCESS") == 0)
{
$status = "SUCCESS";
}
else if (strcmp ($lines[0], "FAIL") == 0)
{
$status = "FAIL";

}

}

fclose ($fp);

return $status;
}

Wednesday, November 18, 2009

Play m4v Video PHP

<blockquote>
"<video controls="controls" height="360" poster="preview.jpg" tabindex="0" width="640">

<source src="aes.m4v" type="video/mp4"></source>
<object data="aes.m4v" height="375" type="video/quicktime" width="640"> <!--<![endif]--> <param name="src" value="aes.m4v">
 <param name="autoplay" value="false">
 <param name="showlogo" value="false">
 <!-- fallback to Flash --> <object type="application/x-shockwave-flash" data="player-viral.swf?image=preview.jpg&amp;file=aes.m4v" width="640" height="380"> <param name="movie" value="player-viral.swf?image=preview.jpg&amp;file=aes.m4v">
 <!-- fallback message --> <img src="http://www.blogger.com/preview.jpg" width="640" height="360" /> <!-- you *must* offer a download link as they may be able to play the file locally -->  </object><!--[if gt IE 6]><!--> </object>
</video>"</blockquote>

http://www.longtailvideo.com/jw/upload/mediaplayer-viral.zip

Friday, November 6, 2009

Print Div/Table css id Content

function PrintContent(ctrl)
{

var DocumentContainer = document.getElementById('content');;
//alert(DocumentContainer);
var WindowObject = window.open('', "Driverlist",
"width=720,height=525,top=250,left=345,toolbars=no,scrollbars=no,status=no,resizable=no");
//alert(ctrl);
//alert(DocumentContainer.innerHTML);
WindowObject.document.write(DocumentContainer.innerHTML);
//alert(ctrl);
WindowObject.document.close();
WindowObject.focus();
WindowObject.print();
WindowObject.close();
}


Text here

Wednesday, October 21, 2009

Get Browser Details

function checkBrowser($input) {

$browsers = "mozilla msie gecko firefox ";
$browsers.= "konqueror safari netscape navigator ";
$browsers.= "opera mosaic lynx amaya omniweb";

$browsers = split(" ", $browsers);

$userAgent = strToLower( $_SERVER['HTTP_USER_AGENT']);

$l = strlen($userAgent);
for ($i=0; $i0){
$version = "";
$navigator = $browser;
$j=strpos($userAgent, $navigator)+$n+strlen($navigator)+1;
for (; $j<=$l; $j++){ $s = substr ($userAgent, $j, 1); if(is_numeric($version.$s) ) $version .= $s; else break; } } } if (strpos($userAgent, 'linux')) { $platform = 'linux'; } else if (strpos($userAgent, 'macintosh') || strpos($userAgent, 'mac platform x')) { $platform = 'mac'; } else if (strpos($userAgent, 'windows') || strpos($userAgent, 'win32')) { $platform = 'windows'; } if ($input==true) { return array( "browser" => $navigator,
"version" => $version,
"platform" => $platform,
"userAgent" => $userAgent);
}else{
return "$navigator $version";
}

}
checkBrowser(true)

Saturday, October 10, 2009

Get Directory Path in PHP

$_SERVER['SCRIPT_FILENAME'] --------> directory Path
$_SERVER['HTTP_HOST'] ---------> Domain name
$_SERVER['DOCUMENT_ROOT'] ---------> Document Root
$_SERVER['PHP_SELF'] --------->from root Folder
$_SERVER['REMOTE_ADDR'] ------>IP Address
$_SERVER['HTTP_USER_AGENT'] ---------->User Agent

http://www.toknowmore.net/e/1/php/request-uri.php

Thursday, October 8, 2009

Email Attachment

$fileatt = ""; // Path to the file
$fileatt_type = "application/octet-stream"; // File Type
$fileatt_name = ""; // Filename that will be used for the file as the attachment

$email_from = ""; // Who the email is from
$email_subject = ""; // The Subject of the email
$email_txt = ""; // Message that the email has in it

$email_to = ""; // Who the email is too

$headers = "From: ".$email_from;

$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);

$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";

$email_message .= "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$email_message . "\n\n";

$data = chunk_split(base64_encode($data));

$email_message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";

$ok = @mail($email_to, $email_subject, $email_message, $headers);

if($ok) {
echo "The file was successfully sent!";
} else {
die("Sorry but the email could not be sent. Please go back and try again!");
}