Demo
Download
Register your domain with Google
Verify the ownership of your domain
Find OAuth consumer key and OAuth consumer secret key
Create client ID with Google API Console
Get application OAuth client ID and client secret.
Modify config file with above information
Monday, September 24, 2012
Sunday, September 23, 2012
Saturday, September 8, 2012
Paypal Pay Now Button
[sourcecode language="html"]
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="YOUR_EMAIL">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="Gold Package">
<input type="hidden" name="item_number" value="1">
<input type="hidden" name="amount" value="400.00">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="UseSandbox" value="true">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_paynow_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"/>
</form>
[/sourcecode]
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="YOUR_EMAIL">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="Gold Package">
<input type="hidden" name="item_number" value="1">
<input type="hidden" name="amount" value="400.00">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="UseSandbox" value="true">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_paynow_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"/>
</form>
[/sourcecode]
Tuesday, September 4, 2012
Browser Detection Class - PHP
Demo
[sourcecode language="php"]
class Browser
{
private $u_agent;
private $bname;
private $platform;
private $version;
public function __construct()
{
$this->u_agent = $_SERVER['HTTP_USER_AGENT'];
$this->bname = 'Unknown';
$this->platform = 'Unknown';
$this->version= "";
}
public function getBrowser()
{
//First get the platform?
if (preg_match('/linux/i', $this->u_agent)) {
$this->platform = 'linux';
}
elseif (preg_match('/macintosh|mac os x/i', $this->u_agent)) {
$this->platform = 'mac';
}
elseif (preg_match('/windows|win32/i', $this->u_agent)) {
$this->platform = 'windows';
}
// Next get the name of the useragent yes seperately and for good reason
if(preg_match('/MSIE/i',$this->u_agent) && !preg_match('/Opera/i',$this->u_agent))
{
$this->bname = 'Internet Explorer';
$this->ub = "MSIE";
}
elseif(preg_match('/Firefox/i',$this->u_agent))
{
$this->bname = 'Mozilla Firefox';
$this->ub = "Firefox";
}
elseif(preg_match('/Chrome/i',$this->u_agent))
{
$this->bname = 'Google Chrome';
$this->ub = "Chrome";
}
elseif(preg_match('/Safari/i',$this->u_agent))
{
$this->bname = 'Apple Safari';
$this->ub = "Safari";
}
elseif(preg_match('/Opera/i',$this->u_agent))
{
$this->bname = 'Opera';
$this->ub = "Opera";
}
elseif(preg_match('/Netscape/i',$this->u_agent))
{
$this->bname = 'Netscape';
$this->ub = "Netscape";
}
// finally get the correct version number
$known = array('Version', $this->ub, 'other');
$pattern = '#(?<browser>' . join('|', $known) .
')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
if (!preg_match_all($pattern, $this->u_agent, $matches)) {
// we have no matching number just continue
}
// see how many we have
$i = count($matches['browser']);
if ($i != 1) {
//we will have two since we are not using 'other' argument yet
//see if version is before or after the name
if (strripos($this->u_agent,"Version") < strripos($this->u_agent,$this->ub)){
$this->version= $matches['version'][0];
}
else {
$this->version= $matches['version'][1];
}
}
else {
$this->version= $matches['version'][0];
}
// check if we have a number
if ($version==null || $version=="") {
$version="?";
}
return array(
'userAgent' => $this->u_agent,
'name' => $this->bname,
'version' => $this->version,
'platform' => $this->platform,
'pattern' => $this->pattern
);
}
}
[/sourcecode]
Usage
[sourcecode language="php"]
$obj= new Browser();
$ua = $obj->getBrowser();
echo $ua['name']."<br>";
echo $ua['version']."<br>";
echo $ua['platform']."<br>";
echo $ua['userAgent']."<br>";
[/sourcecode]
[sourcecode language="php"]
class Browser
{
private $u_agent;
private $bname;
private $platform;
private $version;
public function __construct()
{
$this->u_agent = $_SERVER['HTTP_USER_AGENT'];
$this->bname = 'Unknown';
$this->platform = 'Unknown';
$this->version= "";
}
public function getBrowser()
{
//First get the platform?
if (preg_match('/linux/i', $this->u_agent)) {
$this->platform = 'linux';
}
elseif (preg_match('/macintosh|mac os x/i', $this->u_agent)) {
$this->platform = 'mac';
}
elseif (preg_match('/windows|win32/i', $this->u_agent)) {
$this->platform = 'windows';
}
// Next get the name of the useragent yes seperately and for good reason
if(preg_match('/MSIE/i',$this->u_agent) && !preg_match('/Opera/i',$this->u_agent))
{
$this->bname = 'Internet Explorer';
$this->ub = "MSIE";
}
elseif(preg_match('/Firefox/i',$this->u_agent))
{
$this->bname = 'Mozilla Firefox';
$this->ub = "Firefox";
}
elseif(preg_match('/Chrome/i',$this->u_agent))
{
$this->bname = 'Google Chrome';
$this->ub = "Chrome";
}
elseif(preg_match('/Safari/i',$this->u_agent))
{
$this->bname = 'Apple Safari';
$this->ub = "Safari";
}
elseif(preg_match('/Opera/i',$this->u_agent))
{
$this->bname = 'Opera';
$this->ub = "Opera";
}
elseif(preg_match('/Netscape/i',$this->u_agent))
{
$this->bname = 'Netscape';
$this->ub = "Netscape";
}
// finally get the correct version number
$known = array('Version', $this->ub, 'other');
$pattern = '#(?<browser>' . join('|', $known) .
')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
if (!preg_match_all($pattern, $this->u_agent, $matches)) {
// we have no matching number just continue
}
// see how many we have
$i = count($matches['browser']);
if ($i != 1) {
//we will have two since we are not using 'other' argument yet
//see if version is before or after the name
if (strripos($this->u_agent,"Version") < strripos($this->u_agent,$this->ub)){
$this->version= $matches['version'][0];
}
else {
$this->version= $matches['version'][1];
}
}
else {
$this->version= $matches['version'][0];
}
// check if we have a number
if ($version==null || $version=="") {
$version="?";
}
return array(
'userAgent' => $this->u_agent,
'name' => $this->bname,
'version' => $this->version,
'platform' => $this->platform,
'pattern' => $this->pattern
);
}
}
[/sourcecode]
Usage
[sourcecode language="php"]
$obj= new Browser();
$ua = $obj->getBrowser();
echo $ua['name']."<br>";
echo $ua['version']."<br>";
echo $ua['platform']."<br>";
echo $ua['userAgent']."<br>";
[/sourcecode]
Subscribe to:
Posts (Atom)
How to enable CORS in Laravel 5
https://www.youtube.com/watch?v=PozYTvmgcVE 1. Add middleware php artisan make:middleware Cors return $next($request) ->header('Acces...
-
< Requirements Java Development Kit (JDK) NetBeans IDE Apache Axis 2 Apache Tomcat Server Main Topics Setup Development Environ...
-
Download Sourcecode [sourcecode language="csharp"] using System; using System.Collections.Generic; using System.Linq; using System...