guley
Gulshan@guley

Software Engineer

  • 3 years-4 months

    Page Hits Using Php

    • Category : php
    • Location : Chandigarh
    • Posted On : Feb 17, 2018
    • Posted by : Guley

    Website visitor using php.

    $datei = fopen(APPPATH."/cache/countlog.txt","r");
    $count = fgets($datei,1000);
    fclose($datei);
    $count=$count +  1 ;
    echo "$count" ;
    // opens countlog.txt to change new hit number
    $datei = fopen(APPPATH."/cache/countlog.txt","w");
    fwrite($datei, $count);
    fclose($datei);
  • 3 years-4 months

    Countdown Timer Jquery

    • Category : jquery
    • Location : Chandigarh
    • Posted On : Sep 20, 2017
    • Posted by : Guley

    Display countdown timer using jQuery.

    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-countdown/2.0.2/jquery.countdown.min.js" ></script>
    
    /*html*/
    
    <span data-countdown="2017-09-25 12:10:01" ></span> // end date add here
    
    
    /*Jquery*/
    
    setTimeout(function(){
                    initCountDown()
    }, 300);            
    function initCountDown(){
        $('[data-countdown]').each(function() {
            var $this = $(this), finalDate = $(this).data('countdown');
            $this.countdown(finalDate, function(event) {
                $this.html(event.strftime('%D days %H:%M:%S'));
            });
        });
    }  
     
  • 3 years-4 months

    How to Post File or Image Using PHP Curl

    • Category : php
    • Location : Chandigarh
    • Posted On : Sep 15, 2017
    • Posted by : Guley

    Using this code you can upload and image using curl with third party role

    
       /*Send Page*/
    
       $filename = covertImage($filename);
       
       $fields = array(
                            'customer_name' => 'Gulshan Sharma',
                            'filename' => $filename,
    
                    );
                    $ch = curl_init();
                    curl_setopt($ch, CURLOPT_URL,'http:example.com/upload/');
                    curl_setopt($ch, CURLOPT_POST, 1);
                    curl_setopt($ch, CURLOPT_USERAGENT, "webapp");
                    //curl_setopt($ch, CURLOPT_POSTFIELDS,$fields);
    
                    // in real life you should use something like:
                    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
                    // receive server response ...
                    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
                    curl_setopt($ch, CURLOPT_USERPWD, "xxx:xxx"); 
                    $server_output = curl_exec ($ch);
                    curl_close ($ch);
    
      function covertImage($path){
    
                $type = pathinfo($path, PATHINFO_EXTENSION);
                $data = file_get_contents($path);
                $base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
                return $base64;
       }
     /*RecivePage*/
    
       $filename = base64_to_jpeg($_POST['filename']);
       
       echo $filename;
       
       function base64_to_jpeg($base64_string) {
                         $upload_path = '/hosted-libraries/temp/';
                        $upload_path = $_SERVER['DOCUMENT_ROOT'] . $upload_path;
                        $newImg = uniqid();
                        $img = str_replace('data:image/png;base64,', '', $base64_string);
                        $img = str_replace(' ', ' ', $img);
                        $data = base64_decode($img);
                        $file = $upload_path . $newImg . '.png';
                        $success = file_put_contents($file, $data);
                        if($success)
                            return $file;
                        else
                            FALSE;
                       
         }
  • 3 years-4 months

    Jquery hide network requests from inspect element

    • Category : jquery
    • Location : Chandigarh
    • Posted On : Aug 31, 2017
    • Posted by : Guley

    Using this module you can hide requested parameters from inspect element

    var http = new XMLHttpRequest();
    var url = "Url Path";
    var params ='Your parameters';
    http.open("GET", url, true);
    
    //Send the proper header information along with the request
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    
    http.onreadystatechange = function() {//Call a function when the state changes.
        if(http.readyState == 4 && http.status == 200) {
            console.log(http.responseText);
        }
    http.send(params);
    }
     
  • 3 years-4 months

    HTML5 GEO LOCATION

    • Category : jquery
    • Location : Chandigarh
    • Posted On : Jul 05, 2017
    • Posted by : Guley

    Get geo location using jquery and save in a cookie

    var jb_lat = getCookie('jb_lat');
    var jb_lng = getCookie('jb_lng');
    
    if(jb_lat == '' && jb_lng == ''){
        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(showPosition);
        } else { 
            x.innerHTML = "Geolocation is not supported by this browser.";
        }
        function showPosition(location){
            var exdays = 10;
            var d = new Date();
            d.setTime(d.getTime()   (exdays*24*60*60*1000));
            var expires = "expires="  d.toUTCString();
            document.cookie = "jb_lat="   location.coords.latitude   ";"   expires   ";path=/";
            document.cookie = "jb_lng="   location.coords.longitude   ";"   expires   ";path=/";
            window.location.reload();
        }
    
    }
        function getCookie(cname) {
            var name = cname   "=";
            var decodedCookie = decodeURIComponent(document.cookie);
            var ca = decodedCookie.split(';');
            for(var i = 0; i <ca.length; i  ) {
                var c = ca[i];
                while (c.charAt(0) == ' ') {
                    c = c.substring(1);
                }
                if (c.indexOf(name) == 0) {
                    return c.substring(name.length, c.length);
                }
            }
            return "";
        }
  • 3 years-4 months

    Create Menu/Submenu

    • Category : wordpress
    • Location : Chandigarh
    • Posted On : Jun 26, 2017
    • Posted by : Guley

    Create custom menu and sub-menu in worpress

    add_action('admin_menu', 'main_menu');
    function main_menu()
    {
       add_menu_page( 'Setting' , 'Setting' , 'manage_options' , __FILE__ , 'setting');
       add_submenu_page( __FILE__ , 'Submenu1', 'Submenu1' , 'manage_options' , __FILE__ . 'Submenu1' , 'Submenu1');
    }
    
    /* Menu*/
    
    function Submenu1(){
    	echo "Submenu1 Page";
    }
    
    /* Sub Menu*/
    
    function setting(){
    	echo "Setting Page";
    }
     
  • 3 years-4 months

    Print specific div using jquery

    • Category : jquery
    • Location : Chandigarh
    • Posted On : Apr 12, 2017
    • Posted by : Guley

    You can print specific div or area using this script

    /******Html*********/
     <a href="javascript:void(0);" id="printinvoice"  class="btn btn-warning btn-sm">PRINT INVOICE</a>
    
    <div class="print_div">
                        <div class="col-xs-6 table-responsive">
                            <div class = "sales_header">
                                <span>ORDER NO: # 11380189</span>  
                            </div>
                            <table class="table table-striped table-bordered datatables dataTable">
                                <tbody>
                                    <tr>
                                        <td>Order date</td>
                                        <td>12 Apr 2017 15:55:34</td>
                                    </tr>
                                    <tr>
                                        <td>Order Status</td>
                                        <td> Processed                                    </td>
                                    </tr>
                                    <tr>
                                        <td>Currency</td>
                                        <td>GBP</td>
                                    </tr> 
                                </tbody>
                            </table>
                        </div>  
     </div> 
    /***script**/
    <script src="/assets/js/jQuery.print.js"></script>
    $(document).ready(function() {
        $(document).on('click','#printinvoice',function(){
            //Print ele4 with custom options
            $('.print_div').print({
                //Use Global styles
                globalStyles: true,
                //Add link with attrbute media=print
                mediaPrint: true,
                //Custom stylesheet
                stylesheet: "http://fonts.googleapis.com/css?family=Inconsolata",
                //Print in a hidden iframe
                iframe: true,
                //Don't print this
                noPrintSelector: ""
            });
        });
    });
  • 3 years-4 months

    Prevent requried on ipad and iphone on modal

    • Category : jquery
    • Location : Chandigarh
    • Posted On : Feb 27, 2017
    • Posted by : Guley

    using this code you can prevent required values in html5

    <script src="https://cdnjs.cloudflare.com/ajax/libs/webshim/1.16.0/dev/polyfiller.js" type="text/javascript"></script>
    
    <script> 
            webshim.activeLang('en');
            webshims.polyfill('forms');
            webshims.cfg.no$Switch = true;
    </script>
     
  • 3 years-4 months

    Match date from two columns in mysql

    • Category : mysql
    • Location : Chandigarh
    • Posted On : Feb 24, 2017
    • Posted by : Guley

    You can match two column value using this code

     SELECT * FROM booking WHERE id='1' AND (STR_TO_DATE(`from`, '%d-%m-%Y') <='2017-02-24' AND (STR_TO_DATE(`till`, '%d-%m-%Y') >='2017-02-24')) AND service='test' AND status='0'
  • 3 years-4 months

    JQuery Ajax form using boostrap validation

    • Category : jquery
    • Location : Chandigarh
    • Posted On : Feb 11, 2017
    • Posted by : Guley

    JQuery Ajax form using boostrap validation

     $(document).on('submit','#formid',function(){
     $(this).formValidation({
                                framework: 'bootstrap',
                                fields: {
                                    name: {
                                        validators: {
                                            notEmpty: {
                                                message: 'The name is required'
                                            }
                                        }
                                    },
                                    email: {
                                        validators: {
                                            notEmpty: {
                                                message: 'The email is required'
                                            }
                                        }
                                    },
                                    password: {
                                        validators: {
                                            notEmpty: {
                                                message: 'The password is required'
                                            }
                                        }
                                    },
                                }
                            })
                            .on('success.form.fv', function(e) {
                                e.preventDefault();
                               var Formdata=$(this).serialize();
                                $.ajax({
                                    type: "POST",
                                    url: '', //add page url here
                                    data: Formdata, //send data from here,
                                    success: function(data) {
                                        alert(data);
                                    }
                                });
                            });
                     });
     
No items found