Monday, September 7, 2020

how to add the zendesk chat widget in our website.

To add the live chat widget to website 

1. Login zendesk account -> From the dashboard, select Settings > Widget, then click the Getting Started tab. Copy the embed script, as shown in the example below: 

 


 

2.In the source code of the web page, paste the embed script between the page's head tags. The widget should be visible after reloading the page in a browser. ENjoy The COde

Tuesday, July 7, 2020

top 10 most Important command in ubuntu .

 for file upload permission in ubunu aws

 sudo chown -R $USER:$USER html/

Set permission

sudo chmod 775 -R html/

For apache2 restart

 sudo service apache2 restart

How to install and setup apache mysql php on ubuntu 18-04 on aws server

Install Apache, MySQL, PHP (LAMP) Stack on Ubuntu 18.04

1. Install Apache


sudo apt update && sudo apt install apache2

2. Configure Firewall


sudo ufw allow OpenSSH

sudo ufw allow in "Apache Full"

Saturday, June 6, 2020

One time popup using cookie

<script type="text/javascript">

var cookie = document.cookie;

if (cookie.indexOf('visited=', 0) == -1) {

    var expiration = new Date();

    expiration.setDate(expiration.getDate()+1);

    document.cookie = 'visited=1;expires=' + expiration + ';path=/';


    var element = document.getElementById('myModal');

    element.style.display = 'block';

}

</script>

<?php if (!isset($_COOKIE['visited'])) {

    @setcookie('visited', true, time() + 3600 * 24); // Save a cookie for 1 day

    echo '<div class="load-img-box modal show" id="myModal"style="display: none;" role="dialog">

    <div class="vertical-alignment-helper">

     <div class="modal-dialog vertical-align-center">

      <div class="modal-content">

        <div class="modal-body">

        <img src="images/GST-Margin.jpg" alt="" />

        </div>

        <div class="modal-footer">

          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

        </div>

      </div>

    </div>

    </div>

  </div>';

}?>

scroll top button with scroll screen

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>

<script>

 $().ready(function() {

  var $scrollingDiv = $("#social");

 

  $(window).scroll(function(){   

   $scrollingDiv

    .stop()

    .animate({"marginTop": ($(window).scrollTop() + 30) + "px"}, "slow" );   

  });

 });

</script>

<style>

#social {

    position: absolute;

    z-index: 100;

    margin: 5px 0px 0px 590px;

    width: 34px;

}

</style>

<body>

<div id="social"><h1>dlasndlasdlkas dasdklash dh asdhakosdh oasdo as doa sodiasoido asd asoi</h1></div>

<div style="height:1200px;background:#999;">

</div>

</body>

search location using map api key

<script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDbL602c3wuGekB0jaL92ftXF2cNtwFZDQ&libraries=places"

 type="text/javascript"></script>

 

        <script type="text/javascript">

               function initialize() {

                       var input = document.getElementById('txtAddress');

                       var autocomplete = new google.maps.places.Autocomplete(input);

               }

               google.maps.event.addDomListener(window, 'load', initialize);

       </script>


<label >Address:</label>


    


   <input type="text" name="address" id="txtAddress" class="showroom-aeras" 

value="<?php echo $data_res['address'];?>" placeholder="Enter address here" data-type='address' />


    <input type="hidden" id="txtLocation" data-type='location-store' />

add more images

<script language="javascript" type="text/javascript">


       var a=1;


        function AddMoreImages() {

var fileUploadarea = document.getElementById("fileUploadarea");


//var newLine = document.createElement("br");


            //fileUploadarea.appendChild(newLine);


            var newFile = document.createElement("input");


            newFile.type = "file";


newFile.setAttribute("id", "FileUpload" + a);


            newFile.setAttribute("name", "file[]");


            newFile.setAttribute("class", "browse-snap");


            var div = document.createElement("div");


            div.appendChild(newFile);


            div.setAttribute("id", "div" + a );


            fileUploadarea.appendChild(div);



             var newbot= document.createElement("input");


                newbot.type="Button";


                newbot.setAttribute("id","b" + a);


                newbot.setAttribute("value","remove" + a);


                newbot.setAttribute("class","close-btn");


                newbot.setAttribute("onclick","deletefile(this.id);");


                var divid=document.getElementById("div" + a);


               fileUploadarea.appendChild(div).appendChild(newbot);


              


            a++;


            return false;


        }


       


        function deletefile(abf)


        {


        a--;


        var abf1 = abf.split("b");


        //var uplod=document.getElementById("fileUploadarea");


        var im=document.getElementById("div" + abf1[1]);


        im.parentNode.removeChild(im);


        return false;


       


        } 


    </script>

<div class="browse-btn-showroom">


<div id="fileUploadarea">


           


        </div>


        &nbsp;


        <input class='add_more' id="btnAddMoreImages" type="button" 

value="Add more images" onClick="AddMoreImages();" />


       


    </div>

how to get lat log from address

$address=$_REQUEST['address'];

    if(!empty($address)){

        //Formatted address

        $formattedAddr = str_replace(' ','+',$address);

        //Send request and receive json data by address

         $geocodeFromAddr = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address='.$formattedAddr.'&sensor=false'); 

         $output = json_decode($geocodeFromAddr);

        //Get latitude and longitute from json data

      $data['latitude']  = $output->results[0]->geometry->location->lat; 

        $data['longitude'] = $output->results[0]->geometry->location->lng;

        //Return latitude and longitude of the given address

        if(!empty($data)){

            echo implode(',',$data);

            

        }else{

            return false;

        }

    }else{

        return false;   

    }

jquery dropdown no of text box

<script>

 function getslab(val)

 {


  

            //var value = $(this).val();

     alert(val);

    var container = document.getElementById('container'); //Cache container.

var i;

container.innerHTML="";


    for(var i = 1; i <= val; i++){

        var tb = document.createElement('input');

  var lab = document.createElement('label');

  lab.type = 'label';

        lab.id = 'label_' + i;

  lab.innerHTML= 'label_' + i;

        tb.type = 'text';

        tb.id = 'textBox_' + i; // Set id based on "i" value

  container.appendChild(lab); 

       container.appendChild(tb); 

    }

 return false;

 }

</script>

base64 incode deocde upload image

$path = 'C:\xampp\htdocs/catrina.png';

$upload_path = "img/".uniqid()."_profiles-pic".".png";



 //$data1 = base64_decode($path );

$data = file_get_contents($path);

 




$base64 = base64_encode($data);




// $data1= base64_decode($data);

file_put_contents($upload_path, base64_decode($base64) );

?>