AlaK4X
Linux lhjmq-records 5.15.0-118-generic #128-Ubuntu SMP Fri Jul 5 09:28:59 UTC 2024 x86_64



Your IP : 3.15.192.89


Current Path : /var/www/lhjmq-records.qc.ca/public_html/
Upload File :
Current File : /var/www/lhjmq-records.qc.ca/public_html/create_on_demand.php

<?php

include_once('includes/mysql_server_setup.php');

if (!$_REQUEST['id_register'] || !$_REQUEST['type']) {
	exit;
}

if ($_REQUEST['type'] == 'video')
{
	$sql_table_name = 'register_videos';
	$sql_field = 'pic_large';
}
else if ($_REQUEST['type'] == 'comment')
{
	$sql_table_name = 'register_videos';
	$sql_field = 'comment_'.$_REQUEST['lang'];
}
else if ($_REQUEST['type'] == 'audio')
{
	$sql_table_name = 'register_audios';
	$sql_field = 'pic_large';
}
else if ($_REQUEST['type'] == 'photo')
{
	$sql_table_name = 'register_photos';
	$sql_field = 'pic_large';
}
else if ($_REQUEST['type'] == 'icon')
{
	$sql_table_name = 'register_photos';
	$sql_field = 'pic_small';
}
else if ($_REQUEST['type'] == 'crest')
{
	$sql_table_name = 'equipes_hist';
	$sql_field = 'hist_pic70x70';
}




function validate_image_existe_ls($url){
	
	$pathtoimg = $url.'.jpg';
	$im = @imagecreatefromjpeg($pathtoimg);
	if($im){
	  imagedestroy($im); // dont save, just ack...
	  return $pathtoimg;
	}  
	elseif(!$missing[$inum])
	{		
		$pathtoimg = $url.'.png';
		$im = @imagecreatefromjpeg($pathtoimg);
		if($im){
		  imagedestroy($im); // dont save, just ack...
		  return $pathtoimg;
		}  
		elseif(!$missing[$inum]){
				return false;
		}
	}

}

if ($_REQUEST['type'] != 'crest')
{
	$sql = "SELECT " . $sql_field . " FROM ".$sql_table_name." WHERE id_register = '".$_REQUEST['id_register']."' AND sys_status = '1' LIMIT 1";
	$result = mysql_query($sql, $mysql_link);
	$row = mysql_fetch_assoc($result);

	if($_REQUEST['type'] != 'icon')
	{
		if (mysql_num_rows($result) == 0)
		{
			exit;
		}
	}
}
else
{
	
	$currentLS_ids = mysql_fetch_assoc(@mysql_query($sql = "SELECT * FROM `register_teams` WHERE EqLienGroupimage = '" . $_REQUEST['id_register'] . "' AND saison = '" . $_REQUEST['in'] .'-'.$_REQUEST['out']. "' LIMIT 1", $mysql_link));
	$link_LS_ids_images = $currentLS_ids['LSTeamLink'].'_'.$currentLS_ids['LS_SeasonID'];	
	$image_equipe_vedette = validate_image_existe_ls('http://assets.leaguestat.com/lhjmq/70x70/'.$link_LS_ids_images);
}



$server_ip = $_SERVER['HTTP_HOST'];
$file_name = basename($row['pic_large']);


if($_REQUEST['type'] == 'icon')
{
	//echo '<img src="' . $row[$sql_field] . '" width=32 height=32 />';
	$final_image = explode('/', $row[$sql_field]);
	//echo '/root/Portraits/Small (62x62)/' . $final_image[count($final_image) - 1];

	$sql_data = "SELECT data, contenttype FROM navigator_files WHERE path = '/root/Portraits/Small (62x62)' AND filename = '" . $final_image[count($final_image) - 1] . "' LIMIT 1";
	$result_data = mysql_query($sql_data, $mysql_link);

	if (mysql_num_rows($result_data) > 0)
	{
		$row_data = mysql_fetch_array($result_data);
		header("Content-type: image/jpeg");
		echo $row_data['data'];
	}
	else
	{
		$filename = 'images/records_no_images.jpg';
		$handle = fopen($filename, 'rb');
		$contents = fread($handle, filesize($filename));
		fclose($handle);

		echo $contents;
	}
}
elseif($_REQUEST['type'] == 'crest')
{
	
	if ($image_equipe_vedette != false)
	{

		$homepage = file_get_contents($image_equipe_vedette);
		echo $homepage;
		
	}
	else
	{
		$filename = 'images/records_no_images.jpg';
		$handle = fopen($filename, 'rb');
		$contents = fread($handle, filesize($filename));
		fclose($handle);

		echo $contents;
	}
}
else if($_REQUEST['type'] == 'photo')
{
	echo 'http://'.$server_ip . $row[$sql_field];
}
else if($_REQUEST['type'] == 'comment')
{
	echo $row[$sql_field];
}
else
{
	if (!file_exists('tmp_on_demand/'.$file_name))
	{
		// Open and read the stream
		$contents = '';
		$fp = fopen('http://'.$server_ip.''.$row['pic_large'], 'rb');

		while (!feof($fp))
		{
			$contents .= fread($fp, 8192);
		}

		fclose($fp);

		// Write the stream
		$fp = fopen('tmp_on_demand/'.$file_name, 'a');
		fwrite($fp, $contents);
		fclose($fp);
	}

	// Output the stream
	echo 'http://'.$server_ip.'/tmp_on_demand/'.$file_name;
}

?>