我有一个 url 更短的脚本。有一个“forward.php”文件,如果它被缩短,它用于重定向查询。但在这个文件中,我想在将其重定向到原始网址之前显示一些文字或广告 5-10 秒。
我还尝试了 sleep()、flush() 和所有但没有任何帮助。
谢谢你。
代码:
<?php
ob_start();
require("lib/config.php");
require("lib/common.php");
if( isset($_SERVER['QUERY_STRING']) ){
$i = $_SERVER['QUERY_STRING'];
}else{
$i = $_SERVER['REQUEST_URI'];
$i = str_replace("/","",$i);
}
$suffix = $i{0};
$result = mysql_query("SELECT id,url FROM urls WHERE short_url = '$i'",DBH) or die(mysql_error());
if (mysql_num_rows($result) > 0) {
$row = mysql_fetch_assoc($result);
$id = $row['id'];
$url = $row['url'];
mysql_query("UPDATE urls SET hits=hits+1 WHERE id = '{$id}'",DBH);
if ($_SESSION['config']['bar'] == true)
{
$meela_urllow = stripslashes(str_replace(",", "%2C", $url));
$meela_urllow = strtolower($meela_urllow);
if ((strpos($meela_urllow, "youtube")))
{
header('HTTP/1.1 301 Moved Permanently');
header("Location: ".stripslashes(str_replace(",", "%2C", $url)));
}
if ((strpos($meela_urllow, "facebook")))
{
header('HTTP/1.1 301 Moved Permanently');
header("Location: ".stripslashes(str_replace(",", "%2C", $url)));
}
if ((strpos($meela_urllow, "google")))
{
header('HTTP/1.1 301 Moved Permanently');
header("Location: ".stripslashes(str_replace(",", "%2C", $url)));
}
} else {
header('HTTP/1.1 301 Moved Permanently');
header("Location: ".stripslashes(str_replace(",", "%2C", $url)));
}
exit;
}
header('HTTP/1.1 301 Moved Permanently');
header("Location: http://".$_SESSION['config']['domain']);
exit;
?>