I have taken a half-day leave to go home on 6-FEB-2019, so please change the office hours from 08:30 am to 12:30, And I will try to complete the remaining 30-40 minutes on 4-5 February.
PHP Developer
Tuesday, 30 October 2018
Wednesday, 18 July 2018
Create PDF in PHP
http://blog.chapagain.com.np/php-easily-create-pdf-on-the-fly/
Wednesday, 20 June 2018
Rest API
$siteurl = site_url();
$baseuri = $siteurl."/wp-json";
$method = $request->get_method();
$body = $request->get_body();
$route = $request->get_route();
$params = json_encode($request->get_params());
$fullapiurl = $baseuri.$route;
$ctype = $request->get_content_type();
$contentType = isset($ctype)?$ctype['value']:'application/json';
$url = parse_url($siteurl);
$route == "/wc/v2/login";
//authenication method over http
$oauthTimestamp = time();
$nonce = md5(mt_rand());
$oauthSignatureMethod = "HMAC-SHA1";
$oauthVersion = "1.0";
$sigBase = $method."&" . rawurlencode($fullapiurl) . "&"
. rawurlencode("oauth_consumer_key=" . rawurlencode($consumer_key)
. "&oauth_nonce=" . rawurlencode($nonce)
. "&oauth_signature_method=" . rawurlencode($oauthSignatureMethod)
. "&oauth_timestamp=" . $oauthTimestamp
. "&oauth_version=" . $oauthVersion);
$sigKey = $consumer_secret . "&";
$oauthSig = base64_encode(hash_hmac("sha1", $sigBase, $sigKey, true));
$requestUrl = $fullapiurl . "?"
. "oauth_consumer_key=" . rawurlencode($consumer_key)
. "&oauth_nonce=" . rawurlencode($nonce)
. "&oauth_signature_method=" . rawurlencode($oauthSignatureMethod)
. "&oauth_timestamp=" . rawurlencode($oauthTimestamp)
. "&oauth_version=" . rawurlencode($oauthVersion)
. "&oauth_signature=" . rawurlencode($oauthSig);
$ch = curl_init($requestUrl);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$httpMethod = strtolower($method);
if($httpMethod == "post"){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: '.$contentType,
'Content-Length: ' . strlen($body))
);
}
else{
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: '.$contentType)
);
}
$response = curl_exec($ch);
if(curl_errno($ch)) {
echo 'Curl error: ' . curl_error($ch);
}
curl_close($ch);
$baseuri = $siteurl."/wp-json";
$method = $request->get_method();
$body = $request->get_body();
$route = $request->get_route();
$params = json_encode($request->get_params());
$fullapiurl = $baseuri.$route;
$ctype = $request->get_content_type();
$contentType = isset($ctype)?$ctype['value']:'application/json';
$url = parse_url($siteurl);
$route == "/wc/v2/login";
//authenication method over http
$oauthTimestamp = time();
$nonce = md5(mt_rand());
$oauthSignatureMethod = "HMAC-SHA1";
$oauthVersion = "1.0";
$sigBase = $method."&" . rawurlencode($fullapiurl) . "&"
. rawurlencode("oauth_consumer_key=" . rawurlencode($consumer_key)
. "&oauth_nonce=" . rawurlencode($nonce)
. "&oauth_signature_method=" . rawurlencode($oauthSignatureMethod)
. "&oauth_timestamp=" . $oauthTimestamp
. "&oauth_version=" . $oauthVersion);
$sigKey = $consumer_secret . "&";
$oauthSig = base64_encode(hash_hmac("sha1", $sigBase, $sigKey, true));
$requestUrl = $fullapiurl . "?"
. "oauth_consumer_key=" . rawurlencode($consumer_key)
. "&oauth_nonce=" . rawurlencode($nonce)
. "&oauth_signature_method=" . rawurlencode($oauthSignatureMethod)
. "&oauth_timestamp=" . rawurlencode($oauthTimestamp)
. "&oauth_version=" . rawurlencode($oauthVersion)
. "&oauth_signature=" . rawurlencode($oauthSig);
$ch = curl_init($requestUrl);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$httpMethod = strtolower($method);
if($httpMethod == "post"){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: '.$contentType,
'Content-Length: ' . strlen($body))
);
}
else{
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: '.$contentType)
);
}
$response = curl_exec($ch);
if(curl_errno($ch)) {
echo 'Curl error: ' . curl_error($ch);
}
curl_close($ch);
Sunday, 17 June 2018
Jquery get selected checkbox values
<input type="checkbox" name="vehicle" value="('a', 'b', 'c', 'd')">abcd<br>
<input type="checkbox" name="vehicle" value="('e', 'f', 'g', 'h')">efgh<br>
<input type="checkbox" name="vehicle" value="('i', 'j', 'k', 'l')">ijkl<br>
<input type="checkbox" name="vehicle" value="('m', 'n', 'o', 'p')">mnop<br>
<input type="checkbox" name="vehicle" value="('q', 'r', 's', 't')">qrst<br>
<input type="checkbox" name="vehicle" value="('u', 'v', 'w', 'x')">uvwx<br>
<input type="checkbox" name="vehicle" value="('y', 'z', '1', '2')">yz12<br>
<input type="button" value="Get values" id="get_values">
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
$(document).on('click', '#get_values', function(){
var favorite = [];
$.each($("input[name='vehicle']:checked"), function(){
favorite.push($(this).val());
$(this).append('Saved');
$( "<span>Saved</span>" ).insertAfter( this );
$(this).remove();
});
if(favorite.length > 0){
alert(favorite.join(", "));
}else{
alert("Select atleast one value from list.");
}
//alert("My favourite sports are: " + favorite.join(", "));
});
</script>
<input type="checkbox" name="vehicle" value="('e', 'f', 'g', 'h')">efgh<br>
<input type="checkbox" name="vehicle" value="('i', 'j', 'k', 'l')">ijkl<br>
<input type="checkbox" name="vehicle" value="('m', 'n', 'o', 'p')">mnop<br>
<input type="checkbox" name="vehicle" value="('q', 'r', 's', 't')">qrst<br>
<input type="checkbox" name="vehicle" value="('u', 'v', 'w', 'x')">uvwx<br>
<input type="checkbox" name="vehicle" value="('y', 'z', '1', '2')">yz12<br>
<input type="button" value="Get values" id="get_values">
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
$(document).on('click', '#get_values', function(){
var favorite = [];
$.each($("input[name='vehicle']:checked"), function(){
favorite.push($(this).val());
$(this).append('Saved');
$( "<span>Saved</span>" ).insertAfter( this );
$(this).remove();
});
if(favorite.length > 0){
alert(favorite.join(", "));
}else{
alert("Select atleast one value from list.");
}
//alert("My favourite sports are: " + favorite.join(", "));
});
</script>
Thursday, 14 June 2018
Sunday, 10 June 2018
Wednesday, 14 March 2018
Sticky Header
https://codepen.io/jovanivezic/pen/ZQNdag
http://jsfiddle.net/0mLzseby/473/
http://jsfiddle.net/FDv2J/1913/
https://codepen.io/perminder-klair/pen/tdzue
http://jsfiddle.net/0mLzseby/473/
http://jsfiddle.net/FDv2J/1913/
https://codepen.io/perminder-klair/pen/tdzue
Subscribe to:
Comments (Atom)