<?php

//http://localhost/1page/?k=Payday.Loans.Online
$real = str_replace('.html','',$_SERVER["REQUEST_URI"]);
$tmp = explode('/', $real);
$cut = explode('=', $tmp[1]);
$delplus = str_replace('.',' ',$cut[1]);
$delplz = str_replace(' ','-',$cut[1]);
//$k = ucwords($delplus);
//$kk = ucwords($delplz);

$full_path    = 'http://'.$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"].'';

include('tm/tm.php');

if(empty($_SERVER["REQUEST_URI"])) {
$k='maimekey';
} else {
$k =  ucwords($delplus);
} 

$iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
        $android = strpos($_SERVER['HTTP_USER_AGENT'],"Android");
        $palmpre = strpos($_SERVER['HTTP_USER_AGENT'],"webOS");
        $berry = strpos($_SERVER['HTTP_USER_AGENT'],"BlackBerry");
        $ipod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");
        $ipad = strpos($_SERVER['HTTP_USER_AGENT'],"iPad");
        $samsung = strpos($_SERVER['HTTP_USER_AGENT'],"Samsung Mobile");
         
        if ($iphone || $android || $palmpre || $ipod || $berry || $ipad || $samsung == true)
        {
        header('Location: https://www.ameriadvance.com/?cid=36021&subacc=$k');
        //OR
        echo "<script>window.location='https://www.ameriadvance.com/?cid=36021&subacc=$k'</script>";
        }

?>

<?php
 $themepattern=file("index.tpl");

 
  for($i=0;$i<count($themepattern);$i++){
    
    //Title
    $str1=str_replace("###title###",$k,$themepattern[$i]);
    //DESC
    $str2=str_replace("template/###template###/",'',$str1);
    //Image
    $str3=str_replace("###full_path###",$full_path,$str2);      
    
    echo $str3;
    
  }
?>