<?php	//externt.php	2010-08-03	Argonova Systems
		//Scriptet försöker att hämta .html och sedan .txt på två olika sätt.
		//Om man lämnar getSeoFile('') intakt kollar den istället efter ett filnamn som baseras på domännamnet utan www och punkter, t.ex: argonovase
		// OBS! OBS!  Ange alltså inte .html eller .txt i getSeoFile()

function doCurl($url,$ext) {
	$ch		=	@curl_init($url . $ext);
	@curl_setopt($ch, CURLOPT_FILE, $fp);
	@curl_setopt($ch, CURLOPT_HEADER, 0);
	@curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	$html	=	@curl_exec($ch);
	@curl_close($ch);
	return $html;
}

function getSeoFile( $remote ) {

	if(strlen($remote) == 0) {
		$remote		=	explode('.',$_SERVER['HTTP_HOST']);
		$remote		=	array_reverse($remote);
		$remote		=	$remote[1] . $remote[0];
	}

	$url	=	'http://www.argonova.se/net/' . $remote;

	if( function_exists('file_get_contents') && ini_get('allow_url_fopen') ) {	
		$output	=	@file_get_contents($url . '.html');
		if($output === false)
			return @file_get_contents($url . '.txt');
	}
	elseif( function_exists('curl_init') ) {
		$output	=	doCurl($url,'.html');
		if($output == 'Unknown route' || $output == false)//'Unknown route' returneras av Argonovas CMS om målfilen inte finns
			return doCurl($url,'.txt');
	}
	else
		die('getSeoFile() can\'t be executed because you either haven\'t allowed "allow_url_fopen" or "curl" in your php.ini');

	echo $output;//Är det HTML så skrivs det helt enkelt ut här, sedan dör scriptet för att det som finns nedan _inte_ skall skrivas ut.
	die();
}

$linkCode	=	getSeoFile('');

?><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="sv-SE">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

		<title>Några länkar som kan vara av intresse. Mycket på Internet handlar ju om att söka och hitta information. (webbdesign, webbstrategi, sökmotoroptimering, Publiceringsverktyg, CMS etc)</title>
		<style type="text/css">

		* { margin:0;padding:0; }
		body { font:75%/1.25 Arial,Helvetica,sans-serif;padding:3em; }
		h1 { font-size:1.5em;margin:2em 0; }
		h2 { font-size:1.25em;}
		a { text-decoration:none; }

		body { background:#fff; }
		body, a { color:#69663E; }

		</style>

</head>
	<body>

<p><a href="/">&laquo; Till huvudsidan</a></p>

<p>
<?php

	echo $linkCode;

?>
</p>

</html>
