<?php
header('Content-Type: text/plain');
if (is_ssl()) { $protocol = 'https'; } else { $protocol = 'http'; }
$base_url = $protocol ."://". $_SERVER['SERVER_NAME'] . str_replace("robots.php","",$_SERVER['SCRIPT_NAME']);
$sitemapUrl = $base_url."sitemap.xml";
echo "User-agent: *\n";
echo "Allow: /\n\n";
echo "Sitemap: " . $sitemapUrl . "\n";

function is_ssl() {
    if ( isset( $_SERVER['HTTPS'] ) ) {
        if ( 'on' == strtolower( $_SERVER['HTTPS'] ) ) {
            return true;
        }
        if ( '1' == $_SERVER['HTTPS'] ) {
            return true;
        }
    } elseif ( isset( $_SERVER['SERVER_PORT'] ) && ( '443' == $_SERVER['SERVER_PORT'] ) ) {
        return true;
    }
    return false;
}
?>