Jump to content
Fórum Script Brasil
  • 0

É possível java scripts que executar um arquivo php automático?


Daniel Tweetar

Question

Olá,

 

Eu tenho um scripts que ele executar um arquivo php em um scripts contabilizando um valor no saldo do usuário por minuto online navegando no site e gostaria de saber se é possível faz esse scripts executar esse arquivo /user-on.php?on=1 automático sem precisar navegar e contabilizando o valor no saldo do usuário e pausa se ele não mexer mais no mouse no tempo de 15 minutos ai para de contabilizar no saldo dele.

 

Esse é o scripts

var aways = false;

$(document).ready(function(){

    var fkclk     = true;
    var listclk   = ['a', 'button'];

    setInterval(function() {

         if(!fkclk) {

            $.ajax({

                url: '/user-on.php?on=1',
                type: 'post',
                dataType: "html",
                contentType: 'application/json',
                success: function (data) {
                },error: function(error){
                }
            });

        }
        
    }, 5000);



    var initial;

    function invocation() {
        
        initial = window.setTimeout( 

        function() {

            fkclk = true;

        }, 1800000);

    }



    for(var i in listclk){


        if(typeof listclk[i] == "string"){

            $(listclk[i]).mousedown( function(e){

                fkclk = false;

                clearTimeout( initial )

                invocation();

            })
            
            var element = document.querySelector(listclk[i]);

            element.addEventListener('click', function(event){

                if(event.isTrusted){

                    fkclk = false;

                } else{

                    fkclk = true;

                }

            }, false);
        }   

        
    }
    


})


var modal = '<div class="modal fade" id="away-modal" tabindex="-1" role="dialog" data-backdrop="static" data-onclose="remove">'+
                    '<div class="modal-dialog modal-dialog-centered" role="document">'+
                        '<div class="modal-content">'+
                            '<div class="modal-header">'+
                                '<h5 class="modal-title">'+
                                'Desaja continuar navegando?'+
                                '</h5>'+
                            '</div>'+
                            '<div class="modal-body">'+
                                'Se deseja continuar navegando clique em continuar'+
                            '</div>'+
                            '<div class="modal-footer">'+
                                '<button type="button" onclick="away_modal_c();" class="btn btn-primary btn-block" data-dismiss="modal">'+
                                    'Continuar'+
                                '</button>'+
                            '</div>'+
                        '</div>'+
                    '</div>'+
                '</div>';

function away_modal(){

    if(!aways){

        $('body').append(modal);

        aways = true;

    }
    localStorage.setItem('awaypaused',true);

    $('#away-modal').show();

    $('#away-modal').removeClass('fade')

}

function away_modal_c(){

    $('#away-modal').addClass('fade')

    setTimeout( function(){

        $('#away-modal').hide();

    }, 2000);

    localStorage.setItem('awaypaused',false);
}

function makeid(length) {

    var result           = '';

    var characters       = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';

    var charactersLength = characters.length;

    for ( var i = 0; i < length; i++ ) {

      result += characters.charAt(Math.floor(Math.random() * 

    charactersLength));

   }

   return result;

}

 

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.1k
    • Total Posts
      651.9k
×
×
  • Create New...