Thursday, 11 June 2015

onbeforeunload unbind/bind on page before leave page

For unbind
  window.onbeforeunload = null;

For Bind
    
  function closeIt()
  {
    return "Are you sure you want to cancel this posting?";
  }
  window.onbeforeunload = closeIt;

Monday, 1 June 2015

set maxdate depend on mindate in datepicker

     var startDate = $(this).datepicker('getDate');
                   startDate.setDate(startDate.getDate() +30);
                    $("#offer_expiredate").datepicker("option", "minDate", selected);

Friday, 26 December 2014

payment gateway

http://phpfour.com/blog/2009/02/php-payment-gateway-library-for-paypal-authorizenet-and-2checkout/

Monday, 10 November 2014

multi level menu only css

<!DOCTYPE html>
<html>
    <head>
    <style>
    ul{width:100%}
   
    ul li{
        display:block;list-style-type:none;width:200px;background:red;border:1px solid;float:left
        }
        ul li a{
            padding:20px 30px;text-decoration:none;color:white;
        }
        ul li ul{
            width:300px;
            margin-left:-40px
           
            }
            ul ul{
                display:none;
                }
               
    ul li:hover {
    background-color: green;
    color: #FFF;
}
   
     ul li:hover > ul {
display: block;
}   
ul ul ul {
        position: absolute; left:100%; top:0;
    }
 ul ul li {
            float: none;
            border-top: 1px solid #6b727c;
            border-bottom: 1px solid #575f6a; position: relative;
        }

    </style>
    </head>
<body>
<ul>
    <li><a href="#">home</a></li>
    <li><a href="#">About Us</a>
    <ul>
    <li><a href="#">home</a>
    <ul>
    <li><a href="#">home</a></li>
    <li><a href="#">About Us</a></li>
    <li><a href="#">Services</a></li>
    <li><a href="#">Contact US</a></li>
</ul>
    </li>
    <li><a href="#">About Us</a></li>
    <li><a href="#">Services</a></li>
    <li><a href="#">Contact US</a></li>
</ul></li>
    <li><a href="#">Services</a>
    <ul>
    <li><a href="#">home</a></li>
    <li><a href="#">About Us</a></li>
    <li><a href="#">Services</a></li>
    <li><a href="#">Contact US</a></li>
</ul>
    </li>
    <li><a href="#">Contact US</a></li>
</ul>

</body>
</html>

Thursday, 30 October 2014

push notification iphone and android

   /*Push notification function for Andriod */
function send_push_notification_iPhone($deviceToken=null, $message=null,$pemfile=null) {

$this->autoRender=false;

// Put your device token here (without spaces):
$deviceToken = $deviceToken;

// Put your private key's passphrase here:
$passphrase = '123456';

// Put your alert message here:
$message = $message;

////////////////////////////////////////////////////////////////////////////////
$pemurl=$_SERVER['DOCUMENT_ROOT'].'/app/webroot/SimplePush/pmfilename.pem';
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert',$pemurl);
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);

// Open a connection to the APNS server
$fp = stream_socket_client(
    'ssl://gateway.sandbox.push.apple.com:2195', $err,
    $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);

if (!$fp)
    exit("Failed to connect: $err $errstr" . PHP_EOL);

//echo 'Connected to APNS' . PHP_EOL;

// Create the payload body
$body['aps'] = array(
    'alert' => $message,
    'sound' => 'default'
    );

// Encode the payload as JSON
$payload = json_encode($body);

// Build the binary notification
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;

// Send it to the server
$result = fwrite($fp, $msg, strlen($msg));

if (!$result)
    echo 'Message not delivered' . PHP_EOL;
else
    //echo 'Message successfully delivered' . PHP_EOL;

// Close the connection to the server
fclose($fp);


}   
 
   

for android

//
function send_push_notification($registatoin_ids=null, $message=null) {
      
 $this->autoRender=false;
        // Set POST variables
        $url = 'https://android.googleapis.com/gcm/send';

        $fields = array(
            'registration_ids' => $registatoin_ids,
            'data' => $message,
        );

        $headers = array(
            'Authorization: key=authkey',
            'Content-Type: application/json'
        );
       
        // Open connection
        $ch = curl_init();

        // Set the url, number of POST vars, POST data
        curl_setopt($ch, CURLOPT_URL, $url);

        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        // Disabling SSL Certificate support temporarly
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));

        // Execute post
        $result = curl_exec($ch);
        if ($result === FALSE) {
            die('Curl failed: ' . curl_error($ch));
        }

        // Close connection
        curl_close($ch);
        return $result;
    }
  

send post data curl in php

//changes


function httpPost($url,$params)
{
  $postData = '';
   //create name value pairs seperated by &
   foreach($params as $k => $v)
   {
      $postData .= $k . '='.$v.'&';
   }
   rtrim($postData, '&');

    $ch = curl_init();

    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch,CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_POST, count($postData));
        curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);  

    $output=curl_exec($ch);

    curl_close($ch);
    return $output;

}