<?php


require($_SERVER['DOCUMENT_ROOT'].'/blog/wp-blog-header.php');

$search_link = $_GET['p'];

$vars = explode('/', $search_link);

$num = count($vars) - 1;

$filename = $vars[$num];

$slug = str_replace(".html", "", $filename);


$SQL = "SELECT posts.* FROM $wpdb->posts AS posts WHERE posts.post_name = '$slug' LIMIT 1";

$posts = $wpdb->get_results("$SQL");


if ($posts) {

foreach ($posts as $post) {

$found_link = get_permalink($post->ID);

}

}

else

{

$found_link = "http://www.yasamantahmasebi.com";

}


?>


<html>

<head>

<title>Redirecting...</title>

<script language="javascript"><!--

document.location.href="<?php echo ($found_link); ?>";

//--></script>


<meta http-equiv="refresh" content="2;url=<?php echo ($found_link); ?>">


</head>

<body>

<h1>Redirecting...</h1>

<p>You can also proceed immediately to <a href="<?php echo ($found_link); ?>"><?php echo ($found_link); ?></a>.</p>

<p>The main blog URL is <a href="http://www.yasamantahmasebi.com">one positive idea a day</a>.</p>

</body>

</html>