<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

if (isset($_GET['app'])) 
{
	switch ($_GET['app']) 
	{
		case 'tchat':
		
			if (isset($_GET['older'])) 
			{
				$fp = fopen("statistic.csv", 'a');
				$chaine = date('Y-m-d H:i:s') . ";CHAT APP;" . $_GET['older'] . ";" . $_GET['id'] . "\n";
				fputs($fp, $chaine);
				fclose($fp);
			}
		
			echo getDepositUrl() . "online/private/tchat.php";
			
			break;
			
		
	}
} 
else 
{
	echo "DEPOSIT SERVER<br/><br/>";

	echo "[FR] Vous devez renseignez une commande GET qui correspond a une application<br/>";
	echo "[EN] You must use 'GET' command who match with application name<br/><br/>";

	echo "eg : link.php?app=tchat<br/>";

}

function getDepositUrl()
{
	if (isset($_SERVER['HTTPS'])) {
		$protocol = ($_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off") ? "https" : "http";
	} else {
		$protocol = 'http';
	}

	return $protocol . "://" . $_SERVER['HTTP_HOST'] . '/apps/';
}


