ad.php - Redirect php with 10 seconds html delay

Status
Not open for further replies.

electrify

Active Member
500
2019
97
1,880
A php file that will load a html for 10 seconds and redirects the user to the final url page.

How to execute
Copy the code below and save as ad.php

Code:
<?php
 
$url = $_GET["url"];

// ad here, add html between ""; that will be display for 10 seconds
echo "";

sleep(10);
header('Location: $url');
exit;

?>

To call the file
Code:
/ad.php?url=http://example.com
 
3 comments
Never use sleep in server-side front-end code. It can easily be exploited because it ties up server resources for the duration of the script's execution time. Someone could exploit this and use it to DoS/DDoS your server. Handle it in Javascript instead.

JavaScript:
setTimeout(function(){
    const params = new URLSearchParams(window.location.search);
    const url = params.get('url');
    // verify the URL...
    window.location.href = url;
}, 10000);
 
Status
Not open for further replies.
Back
Top