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.133.145.168


Current Path : /var/www/lhjmq-records.qc.ca/public_html/xsl/records/book/cms/
Upload File :
Current File : /var/www/lhjmq-records.qc.ca/public_html/xsl/records/book/cms/_player_post.php

<?php

include('includes/config.php');

if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_SESSION['post']['player_info'] ) && $_POST['action'] == 'save' )
{
					
	// player id League stats
	$LSRegisterLink = $_SESSION['post']['player_info'][0]['id_personnel'];	
	
	
	//upload video
	if (isset($_FILES["video_fr"]["name"]) && $_FILES["video_fr"]["name"] != ''){
	
		$target_dir = "uploads/video/";
		$target_file_video = $target_dir . basename($_FILES["video_fr"]["name"]);
		$uploadVideoOk = 1;
		$imageFileType = pathinfo($target_file_video,PATHINFO_EXTENSION);
	
		// Check if file already exists
		/*if (file_exists($target_file_video)) {
		    //echo "Sorry, file already exists.";
		    $uploadVideoOk = 0;
		}*/

		// Allow certain file formats
		if($imageFileType != "mp4") {
		    echo "Sorry, only mp4 files are allowed.";
		    $uploadVideoOk = 0;
		}
	
		// Check if $uploadOk is set to 0 by an error
		if ($uploadVideoOk == 0) {
		    echo "Sorry, your file was not uploaded.";
		// if everything is ok, try to upload file
		} else {
		    if (move_uploaded_file($_FILES["video_fr"]["tmp_name"], $target_file_video)) {
		        echo "The file ". basename( $_FILES["video_fr"]["name"]). " has been uploaded.";
		        
		        $sql='UPDATE register_data  SET media_selected = "0" where  media_type = "video" AND lang = "fr" AND LSRegisterLink = "'.$LSRegisterLink.'" ';
						//echo $sql;
						$db->query($sql,'');
		        
						$sql='INSERT INTO register_data  (LSRegisterLink,media_type,media_selected,media,lang) values('.$LSRegisterLink.', "video" , 1, "'.basename($_FILES["video_fr"]["name"]).'", "fr" )';
						//echo $sql;
						$db->query($sql,'');			        
		        
		    } else {
		        echo "Sorry, there was an error uploading your file.";
		    }
		}

	}	
	
	
	
	//upload video
	if (isset($_FILES["video_en"]["name"]) && $_FILES["video_en"]["name"] != ''){
	
		$target_dir = "uploads/video/";
		$target_file_video = $target_dir . basename($_FILES["video_en"]["name"]);
		$uploadVideoOk = 1;
		$imageFileType = pathinfo($target_file_video,PATHINFO_EXTENSION);
	
		// Check if file already exists
		/*if (file_exists($target_file_video)) {
		    echo "Sorry, file already exists.";
		    $uploadVideoOk = 0;
		}*/

		// Allow certain file formats
		if($imageFileType != "mp4") {
		    echo "Sorry, only mp4 files are allowed.";
		    $uploadVideoOk = 0;
		}
	
		// Check if $uploadOk is set to 0 by an error
		if ($uploadVideoOk == 0) {
		    echo "Sorry, your file was not uploaded.";
		// if everything is ok, try to upload file
		} else {
		    if (move_uploaded_file($_FILES["video_en"]["tmp_name"], $target_file_video)) {
		        echo "The file ". basename( $_FILES["video_en"]["name"]). " has been uploaded.";
		        $sql='UPDATE register_data  SET media_selected = "0" where  media_type = "video" AND lang = "en" AND LSRegisterLink = "'.$LSRegisterLink.'" ';
						//echo $sql;
						$db->query($sql,'');
		        
						$sql='INSERT INTO register_data  (LSRegisterLink,media_type,media_selected,media,lang) values('.$LSRegisterLink.', "video" , 1, "'.basename($_FILES["video_en"]["name"]).'", "en" )';
						//echo $sql;
						$db->query($sql,'');	
						//echo $sql;
						$db->query($sql,'');			        
		        
		    } else {
		        echo "Sorry, there was an error uploading your file.";
		    }
		}

	}		
	
	if (isset($_FILES["audio_fr"]["name"]) && $_FILES["audio_fr"]["name"] != ''){
	
		$target_dir = "uploads/audio/";
		$target_file_audio = $target_dir . basename($_FILES["audio_fr"]["name"]);
		$uploadAudioOk = 1;
		$imageFileType = pathinfo($target_file_audio,PATHINFO_EXTENSION);
	
		// Check if file already exists
		/*if (file_exists($target_file_audio)) {
			echo $target_file_audio;
		    echo "Sorry, file already exists.";
		    $uploadAudioOk = 0;
		}*/

		// Allow certain file formats
		if($imageFileType != "mp3") {
				echo $imageFileType;
		    echo "Sorry, only mp3 files are allowed.";
		    $uploadAudioOk = 0;
		}
	
		// Check if $uploadOk is set to 0 by an error
		if ($uploadAudioOk == 0) {
		    echo "Sorry, your file was not uploaded.";
		// if everything is ok, try to upload file
		} else {
		    if (move_uploaded_file($_FILES["audio_fr"]["tmp_name"], $target_file_audio)) {
		        echo "The file ". basename( $_FILES["audio_fr"]["name"]). " has been uploaded.";
		        $sql='UPDATE register_data  SET media_selected = "0" where  media_type = "audio" AND lang = "fr" AND LSRegisterLink = "'.$LSRegisterLink.'" ';
						//echo $sql;
						$db->query($sql,'');		        
		        
						$sql='INSERT INTO register_data  (LSRegisterLink,media_type,media_selected,media,lang) values('.$LSRegisterLink.', "audio" , 1, "'.$_FILES["audio_fr"]["name"].'", "fr" )';
						//echo $sql;
						$db->query($sql,'');			        
		    } else {
		        echo "Sorry, there was an error uploading your file.";
		    }
		}

	}	
	
	
	
	if (isset($_FILES["audio_en"]["name"]) && $_FILES["audio_en"]["name"] != ''){
	
		$target_dir = "uploads/audio/";
		$target_file_audio = $target_dir . basename($_FILES["audio_en"]["name"]);
		$uploadAudioOk = 1;
		$imageFileType = pathinfo($target_file_audio,PATHINFO_EXTENSION);
	
		// Check if file already exists
	/*	if (file_exists($target_file_audio)) {
			echo $target_file_audio;
		    echo "Sorry, file already exists.";
		    $uploadAudioOk = 0;
		}*/

		// Allow certain file formats
		if($imageFileType != "mp3") {
				echo $imageFileType;
		    echo "Sorry, only mp3 files are allowed.";
		    $uploadAudioOk = 0;
		}
	
		// Check if $uploadOk is set to 0 by an error
		if ($uploadAudioOk == 0) {
		    echo "Sorry, your file was not uploaded.";
		// if everything is ok, try to upload file
		} else {
		    if (move_uploaded_file($_FILES["audio_en"]["tmp_name"], $target_file_audio)) {
		        echo "The file ". basename( $_FILES["audio_en"]["name"]). " has been uploaded.";
		        
		        $sql='UPDATE register_data  SET media_selected = "0" where  media_type = "audio" AND lang = "en" AND LSRegisterLink = "'.$LSRegisterLink.'" ';
						//echo $sql;
						$db->query($sql,'');		        
		        
						$sql='INSERT INTO register_data  (LSRegisterLink,media_type,media_selected,media,lang) values('.$LSRegisterLink.', "audio" , 1, "'.$_FILES["audio_en"]["name"].'", "en" )';
						//echo $sql;
						$db->query($sql,'');			        
		    } else {
		        echo "Sorry, there was an error uploading your file.";
		    }
		}

	}		
	


	
	// image joeur 
	if (!is_empty($_POST['player_image'])) 
	{
		$player_image = $_POST['player_image'];
	}
	else
	{
		$player_image = '/images/personnels/noregisterpic.jpg';		
	}	
	
	
	
	
	// selected video  fr
	if (!is_empty($_POST['video_fr_selected'])) 
	{
		if (!is_empty($_POST['delete_video_fr'])) 
		{
	    $sql='DELETE from register_data  where  media_type = "video" AND lang = "fr" AND LSRegisterLink = "'.$LSRegisterLink.'" AND media = "'.$_POST['video_fr_selected'].'" ';
			//echo $sql;
			$db->query($sql,'');			
		}
		else
		{
		  $sql='UPDATE register_data  SET media_selected = "0" where  media_type = "video" AND lang = "fr" AND LSRegisterLink = "'.$LSRegisterLink.'" ';
			//echo $sql;
			$db->query($sql,'');		
			
	    $sql='UPDATE register_data  SET media_selected = "1"  where  media_type = "video" AND lang = "fr" AND LSRegisterLink = "'.$LSRegisterLink.'" AND media = "'.$_POST['video_fr_selected'].'" ';
			//echo $sql;
			$db->query($sql,'');
		}		
		
	}
	
	
	// selected video en
	if (!is_empty($_POST['video_en_selected'])) 
	{
		if (!is_empty($_POST['delete_video_en'])) 
		{
	    $sql='DELETE from register_data  where  media_type = "video" AND lang = "en" AND LSRegisterLink = "'.$LSRegisterLink.'" AND media = "'.$_POST['video_en_selected'].'" ';
			//echo $sql;
			$db->query($sql,'');			
		}
		else
		{		
		  $sql='UPDATE register_data  SET media_selected = "0" where  media_type = "video" AND lang = "en" AND LSRegisterLink = "'.$LSRegisterLink.'" ';
			//echo $sql;
			$db->query($sql,'');		
			
	    $sql='UPDATE register_data  SET media_selected = "1"  where  media_type = "video" AND lang = "en" AND LSRegisterLink = "'.$LSRegisterLink.'" AND media = "'.$_POST['video_en_selected'].'" ';
			//echo $sql;
			$db->query($sql,'');		
		}
	}	
	
	
	
	// selected audio fr
	if (!is_empty($_POST['audio_fr_selected'])) 
	{
		
	  $sql='UPDATE register_data  SET media_selected = "0" where  media_type = "audio" AND lang = "fr" AND LSRegisterLink = "'.$LSRegisterLink.'" ';
		//echo $sql;
		$db->query($sql,'');		
		
    $sql='UPDATE register_data  SET media_selected = "1"  where  media_type = "audio" AND lang = "fr" AND LSRegisterLink = "'.$LSRegisterLink.'" AND media = "'.$_POST['audio_fr_selected'].'" ';
		//echo $sql;
		$db->query($sql,'');		
		
	}
	
	
	// selected audio en 
	if (!is_empty($_POST['audio_en_selected'])) 
	{
		
	  $sql='UPDATE register_data  SET media_selected = "0" where  media_type = "audio" AND lang = "en" AND LSRegisterLink = "'.$LSRegisterLink.'" ';
		//echo $sql;
		$db->query($sql,'');		
		
    $sql='UPDATE register_data  SET media_selected = "1"  where  media_type = "audio" AND lang = "en" AND LSRegisterLink = "'.$LSRegisterLink.'" AND media = "'.$_POST['audio_en_selected'].'" ';
		//echo $sql;
		$db->query($sql,'');		
		
	}		

	
	// commentaire
	$player_commentaire_fr = $_POST['commentaire_fr'];
	
	// commentaire
	$player_commentaire_en = $_POST['commentaire_en'];	
	

	
	/*if ($uploadVideoOk == 1 ){
		//insert db new video		
		$sql='INSERT INTO  register_data  (LSRegisterLink,media_type,media_selected,media,lang) values('.$LSRegisterLink.', "video" , 1, "'.$target_file_video.'" , "fr" )';
		$db->query($sql,'');				
	}
	
	if ($uploadAudioOk == 1){
		//insert db ne audio		
		$sql='INSERT INTO  register_data  (LSRegisterLink,media_type,media_selected,media,lang) values('.$LSRegisterLink.', "audio" , 1, "'.$target_file_audio.'", "fr" )';
		$db->query($sql,'');				
	}	*/
	
	
		// update photo joueur
		$sql='SELECT media FROM register_data WHERE LSRegisterLink = "'.$LSRegisterLink.'" AND media_type = "image"  ';
		$player_image_res = $db->query($sql,'');
		
		if (count($player_image_res) > 0){			
			$sql='UPDATE register_data  set media = "'.$player_image.'" WHERE LSRegisterLink = "'.$LSRegisterLink.'" AND media_type = "image"  ';
			$db->query($sql,'');			
		}
		else
		{
			$sql='INSERT INTO register_data  (LSRegisterLink,media_type,media_selected,media,lang) values('.$LSRegisterLink.', "image" , 1, "'.$player_image.'", "fr" )';
			//echo $sql;
			$db->query($sql,'');				
		}
		
		//update commentaire fr
		$sql='SELECT media FROM register_data WHERE LSRegisterLink = "'.$LSRegisterLink.'" AND media_type = "comment" AND lang = "fr" ';
		$player_comment_fr = $db->query($sql,'');
		
		if (count($player_comment_fr) > 0){			
			$sql='UPDATE register_data  set media = "'.$player_commentaire_fr.'" WHERE LSRegisterLink = "'.$LSRegisterLink.'" AND media_type = "comment" AND lang = "fr"  ';
			$db->query($sql,'');			
		}
		else
		{
			$sql='INSERT INTO register_data  (LSRegisterLink,media_type,media_selected,media,lang) values('.$LSRegisterLink.', "comment" , 1, "'.$player_commentaire_fr.'", "fr" )';
			$db->query($sql,'');				
		}		
		
		//update commentaire en
		$sql='SELECT media FROM register_data WHERE LSRegisterLink = "'.$LSRegisterLink.'" AND media_type = "comment" AND lang = "en" ';
		$player_comment_en = $db->query($sql,'');
		
		if (count($player_comment_en) > 0){			
			$sql='UPDATE register_data  set media = "'.$player_commentaire_en.'" WHERE LSRegisterLink = "'.$LSRegisterLink.'" AND media_type = "comment" AND lang = "en"  ';
			$db->query($sql,'');			
		}
		else
		{
			$sql='INSERT INTO register_data  (LSRegisterLink,media_type,media_selected,media,lang) values('.$LSRegisterLink.', "comment" , 1, "'.$player_commentaire_en.'", "en" )  ';
			$db->query($sql,'');				
		}			
	
	
		$_SESSION['post']['result'] = get_player_info($_POST['search_ls_id']);
		$_SESSION['post']['player_info'] = get_tgi_player_id($_POST['search_ls_id']);
		$_SESSION['post']['player_media'] = get_tgi_player_media($_SESSION['post']['player_info'][0]['id_personnel']);	

}



header('location: player.php');
exit();