<?php include("common.php"); ?>

<?php
	$title = "";
	$description = "";
	$image = "";
	
	$url = $_SERVER['REQUEST_URI'];
	if(strpos($url, 'libary.php') !== false)
	{
		if(isset($_GET["game"]))
		{
			$game = htmlspecialchars($_GET["game"], ENT_QUOTES);
			
			$game = str_replace("/", "",$game);
			$game = str_replace(".", "",$game);
			$game = str_replace("*", "",$game);
			
			$title = getTitle($game);
			$title.= " - ";
		}
		else
		{
			$title .= "PSM Game Library - ";
		}
	}
	else if(strpos($url, 'devtools.php') !== false)
	{
		$title .= "PlayStation Mobile Development Tools  - ";
		if(isset($_GET["type"]))
		{
			$type = htmlspecialchars($_GET["type"], ENT_QUOTES);
			$type = str_replace("/", "",$type);
			$type = str_replace(".", "",$type);
			$type = str_replace("*", "",$type);
			$title .= $type."/ - ";
		}
		
	}
	
	$title .= "PSM Reborn";
	
	if(strpos($url, 'libary.php') !== false)
	{
		if(isset($_GET["game"]))
		{
			$game = htmlspecialchars($_GET["game"], ENT_QUOTES);
			$game = str_replace("/", "",$game);
			$game = str_replace(".", "",$game);
			$game = str_replace("*", "",$game);
			$title = getTitle($game);
			$description = $title . " - ";
			$description .= getDesc($game);
			$description .= " - PSMReborn #1 place for all PSM Content";
			$image .= 'http://'.$_SERVER['HTTP_HOST'].'/gameinfo/'.$game.'/icon_512x512.png';
		}
		else
		{
			$description .= "PlayStation Mobile Game/App Library - PSMReborn #1 place for all PSM Content";
		}	
	}
	else if(strpos($url, 'devtools.php') !== false)
	{
		$description .= "PlayStation Mobile Development Tools";
		if(isset($_GET["type"]))
		{
			$type = htmlspecialchars($_GET["type"], ENT_QUOTES);
			$type = str_replace("/", "",$type);
			$type = str_replace(".", "",$type);
			$type = str_replace("*", "",$type);
			$description .= " - ".$type."/";
		}
		$description .= " - PSMReborn #1 place for all PSM Content";
	}
	else
	{
		$description = "PSMReborn is the largest archive of PlayStation Mobile content on the internet containing Games, SDK's, Source Code, and Unity for PSM exporters.";
	}
	
	$descsocial = str_replace("<BR>", PHP_EOL, $description);
	$descsocial = str_replace("<bR>", PHP_EOL, $descsocial);
	$descsocial = str_replace("<Br>", PHP_EOL, $descsocial);
	$descsocial = str_replace("<br>", PHP_EOL, $descsocial);
	$descsocial = str_replace('"', '', $descsocial);
	$descsocial = str_replace("'", "", $descsocial);
	
	/*
	* Default Image
	*/
	if($image == "")
	{
		$image .= 'http://'.$_SERVER['HTTP_HOST'].'/img/logo.png';
	}
?>

<!DOCTYPE html>
<html>
	<head>
		<link rel="stylesheet" type="text/css" href="style.css">
		<script src="common.js"></script>

		<title><?php echo $title ?></title>

		<meta charset="utf-8">
		<meta name="robots" content="all">
		<meta name="viewport" content="width=1000; user-scalable=0;"/>
		<meta name="Description" content="<?php echo $descsocial?>"/>

		<meta property="og:image" content="<?php echo $image ?>"/>
		<meta property="og:title" content="<?php echo $title ?>"/>
		<meta property="og:description" content="<?php echo $descsocial ?>"/>
		
		<meta property="twitter:image" content="<?php echo $image ?>"/>
		<meta property="twitter:title" content="<?php echo $title ?>"/>
		<meta property="twitter:description" content="<?php echo $descsocial ?>"/>
	</head>
	<body>
		<div class="header">
			<a href="/" class="sitename">
				<img src="img/logo.png" alt="PSMReborn" width="40" height="40">
				<span>PSMReborn</span>
			</a>
			
			<div class="sitemap">
				<ul>
					<li><a href="/">Home</a></li>
					<li><a href="/libary.php">PSM Library</a></li>
					<li><a href="/devtools.php">Development Tools</a></li>
				</ul>
			</div>
		</div>
	