Jump to content

On leave page help stop javascript code.


Go to solution Solved by Mancent,

Recommended Posts

Ok I been trying to make a traffic generator website but I ran into a problem with javascript

 

And this page is the page that is giving me the problem https://gananciasexpress.com/rrodriguez/5.html

 

when the loader is ready to load a new site this page send a alert message or some type of message trying to get the user to stay on his page, and no mater what button you click

it redirects them to his page again.
I do not want to disable javascript I just want to control the call..
I thought I could just create a function for that call
I thought it would be window.onbeforeunload

so I created a function for that w

 

window.onbeforeunload = function() {};

but I just can not stop it from taking control.

 

Can any of you help me with this

This is what code I am working with trying to solve this.

<?php
include "connect.php";

?>
<style type="text/css">
#progressBar
{
	position : fixed;
	top:0px;
	right:0px;
	
	width:100%;
	height:50px;
	background:#000;
	
	
	z-index:999999999999998;
		overflow:hidden;	
}
#status
{
position : fixed;
	top:0px;
	right:0px;
	
	width:100%;
	height:50px;
	color:#FFFFFF;
	font-size:24px;
	
	
	z-index:9999999999999999;
	overflow:hidden;	
}
</style>

         


<script type="text/javascript">
	<!--
		if (top.location!= self.location) {
			top.location = self.location.href
		}
	//-->
</script>


<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-50245319-1', 'nettys.co');
  ga('send', 'pageview');

</script>

<script type="text/javascript">
window.alert = function() {};
window.onbeforeunload = function() {};
// or simply
alert = function() {};


    var prevent_bust = 0  
    window.onbeforeunload = function() { prevent_bust++ }  
    setInterval(function() {  
      if (prevent_bust > 0) {
		  
        prevent_bust -= 2  
        window.top.location = 'http://www.nettys.co/traffic.php'  
      }  
    }, 1)
	
	    
</script>
   
 
    
 
        
 
    




<?php


$sql = "SELECT * FROM Traffic  ORDER BY RAND() LIMIT 1 "; 
                $querys = mysql_query($sql) or trigger_error("Query Failed: " . mysql_error()); 
 
                if (mysql_num_rows($querys) == 1) 
	            {
                      $rows = mysql_fetch_assoc($querys);
                       
					   $domain = $rows['domain'];
					   $variableee = readfile($domain);
                       echo $variableee;
				}
				else
				{
					echo "we have a error some how!";
				}




?>


<progress id="progressBar" value="0" max="100"></progress>

<span id="status"></span>



     

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

function progressBarSim(al) {

  var bar = document.getElementById('progressBar');

  var status = document.getElementById('status');

  status.innerHTML = "Please Wait While Loading Each Page "+al+"%";

  bar.value = al;

  al++;

	var sim = setTimeout("progressBarSim("+al+")",250);

	if(al == 100){

	  status.innerHTML = "Please Wait While Loading Each Page 100%";

	  bar.value = 100;

	  clearTimeout(sim);
	  window.location.href = "traffic.php";


	  

	}

}

var amountLoaded = 0;

progressBarSim(amountLoaded);

</script>

And you can test the site at http://nettys.co/traffic.php

 

Edited by Mancent
Link to comment
https://forums.phpfreaks.com/topic/287970-on-leave-page-help-stop-javascript-code/
Share on other sites

  • Solution

Well this works
but I have to set safe sites up to display and be able to use scripts.
This is only a traffic system to get traffic. so scripts do not need to be used. But I want to let some scripts pass. like google and youtube

 

<?php
include "connect.php";

?>
<style type="text/css">
#progressBar
{
	position : fixed;
	top:0px;
	right:0px;
	
	width:100%;
	height:50px;
	background:#000;
	
	
	z-index:999999999999998;
		overflow:hidden;	
}
#status8husyhdyts
{
position : fixed;
	top:0px;
	right:0px;
	
	width:100%;
	height:50px;
	color:#FFFFFF;
	font-size:24px;
	
	
	z-index:9999999999999999;
	overflow:hidden;	
}
</style>

         


<script type="text/javascript">
	<!--
		if (top.location!= self.location) {
			top.location = self.location.href
		}
	//-->
</script>


<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-50245319-1', 'nettys.co');
  ga('send', 'pageview');

</script>

<script type="text/javascript">
window.alert = function() {};
window.onbeforeunload = function() {};
// or simply
alert = function() {};


    var prevent_bust = 0  
    window.onbeforeunload = function() { prevent_bust++ }  
    setInterval(function() {  
      if (prevent_bust > 0) {
		  
        prevent_bust -= 2  
        window.top.location = 'http://www.nettys.co/traffic.php'  
      }  
    }, 1)
	
	    
</script>
   
 
   <progress id="progressBar" value="0" max="100"></progress>

<span id="status8husyhdyts"></span>



     

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

function progressBarSim(al) {

  var bar = document.getElementById('progressBar');

  var status = document.getElementById('status8husyhdyts');

  status.innerHTML = "Please Wait While Loading Each Page "+al+"%";

  bar.value = al;

  al++;

	var sim = setTimeout("progressBarSim("+al+")",250);

	if(al == 100){

	  status.innerHTML = "Please Wait While Loading Each Page 100%";

	  bar.value = 100;

	  clearTimeout(sim);
	  window.location.href = "traffic.php";


	  

	}

}

var amountLoaded = 0;

progressBarSim(amountLoaded);

</script> 
 
        
 
    




<?php


$sql = "SELECT * FROM Traffic  ORDER BY RAND() LIMIT 1 "; 
                $querys = mysql_query($sql) or trigger_error("Query Failed: " . mysql_error()); 
 
                if (mysql_num_rows($querys) == 1) 
	            {
                      $rows = mysql_fetch_assoc($querys);
                       
					   $domain = $rows['domain'];
					 
                   
			

$html = file_get_contents($domain);

$h = explode('>', $html);

foreach($h as $k => $v){

    $v = trim($v);//clean it up a bit

    if(preg_match('/^(<script[.*]*)/ius', $v)){//my regex here might be questionable

        $counter = $k;//match opening tag and start counter for backtrace

        }elseif(preg_match('/([.*]*<\/script$)/ius', $v)){//but it gets the job done

            $script_length = $k - $counter;

            $counter = 0;

            for($i = $script_length; $i >= 0; $i--){
                $h[$k-$i] = '';//backtrace and clear everything in between
                }
            }           
        }
for($i = 0; $i <= count($h); $i++){
    if($h[$i] != ''){
    $ht[$i] = $h[$i];//clean out the blanks so when we implode it works right.
        }
    }
$html = implode('>', $ht);//all scripts stripped.


echo $html;
					   
				}
				else
				{
					echo "we have a error some how!";
				}




?>










 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.