Page 1 sur 1

aperçu image video flv

Posté : 31 août 2013, 16:48
par va_savoir
Bonjour, j'ai installé le programme GCM pour avoir un mur d'images ou de vidéo. Cependant il n'y a pas d'aperçu d'image de la video. Est-il possible de modifier le code source du fichier pour afficher l'image d'aperçu de la vidéo. Je demande la démarche à suivre merci.
Voici deux fichiers du dossier media: media_add.php
<?php
/***************************************************************
* Copyright notice - Notice de droits d'auteur
*
* © 2011-2021 Christian ECKENSPIELLER ([email protected])
* Internet site : ceck.org
* All rights reserved
*
* The GCM project is a free software, you can redistribute it
and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation.
*
* This script is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details :
[http://www.gnu.org/copyleft/gpl.html].
*
* This copyright notice MUST APPEAR in all copies of the script.
* Cette notice de droits d'auteur DOIT APPARAITRE dans toutes
les copies des scripts.
****************************************************************  «  »
*/

require_once("media/abc.php") ;

// autorisation d'accès au script
if (($RIGHTS != "administrator") and ($RIGHTS != "private")) error_page (ERR_ACCESS, "media", $RIGHTS, $footer_lib, $db ) ;

// acquisition de la phase de création
if (isset ($_GET['phase'])) $phase = $_GET['phase'] ;
else $phase = "option_album" ;

page_header ($USER, 2, $db) ;
echo make_left_column ("media", $RIGHTS, $left_lib) ;

switch ($phase) {
	case "option_album" :
		// déclaration de l'album par défaut et initialisation erreur
		$preset_albumid = 1 ;
		$error_album_select = "" ;
		echo "\t\t\t<h1>".LIBM_NEW_MEDIA."</h1>\r\n" ;
		// appel du formulaire 1 pour choisir l'album OU en créer un nouveau
		choose_album_form ($preset_albumid, $error_album_select, $db) ;
	break ;
	case "choose_album" ;
		// réception du nom de l'album choisi OU de la demande de création d'un nouvel album (check)
		// contrôle de saisie
		$error = choose_album_control ($_POST) ;
		if ($error != "") {
			echo "\t\t\t<h1>".LIBM_NEW_MEDIA."</h1>\r\n" ;
			// réaffichage du formulaire 1 avec message d'erreur en rouge
			choose_album_form (1, $error, $db) ;
		} else {
			if (isset ($_POST['create'])) {
				$creation = true ;
				$ARRAY_album = array("album_title"=>"","album_author"=>"","album_comment"=>"","album_visibility"=>"public") ;
				$error_album_title = "" ;
			} else {
				$creation = false ;
				$ARRAY_album['selected_album_title'] = $_POST['selected_album_title'] ;
				$error_album_title = "" ;
			}
			echo "\t\t\t<h1>".LIBM_NEW_MEDIA."</h1>\r\n" ;
			// affichage du formulaire 2 avec possibilité de création du nouvel album si demandé
			create_album_form ($ARRAY_album, $error_album_title, $creation, $db) ;
		}
	break ;
	case "write_album" ;
		// réception du titre de l'album qui a été sélectionné OU du tableau pour créer un nouvel album
		if ($_POST['new_album'] === "affirmatif") {
			// contrôle de saisie
			$error = create_album_control ($_POST['album_title']) ;
			if ($error != "") {
				echo "\t\t\t<h1>".LIBM_NEW_MEDIA."</h1>\r\n" ;
				// réaffichage du formulaire 2 avec message d'erreur en rouge
				create_album_form ($_POST, $error, true, $db) ;
				break ;
			} else {
				// création du nouvel album
				$retour = create_album ($_POST, $db, $USER) ;
				$albumid = $retour[0] ;
				$feedback = $retour[1] ;
				echo "\t\t\t<h1>".LIBM_NEW_MEDIA."</h1>\r\n" ;
				// affichage du message de feedback
				display_in_box ($feedback, "") ;
			}
		} else {
			// récupération de l'identifiant de l'album qui a été sélectionné
			$OBJ_album = search_row_by_string ("album", "album_title", $_POST['selected_album_title'], $db) ;
			$albumid = $OBJ_album->album_id ;
		}
		echo "\t\t\t<h1>".LIBM_NEW_MEDIA."</h1>\r\n" ;
		// affichage du formulaire 3 d'upload
		media_upload_form ($albumid, "", $db) ;
	break ;
	case "add_media" ;
		// acquisition de l'id de l'album appelant
		if (isset ($_GET['albumid'])) $albumid = $_GET['albumid'] ;
		else break ;
		echo "\t\t\t<h1>".LIBM_NEW_MEDIA."</h1>\r\n" ;
		// affichage du formulaire 3 d'upload
		media_upload_form ($albumid, "", $db) ;
	break ;
	case "upload_media" ;
		// réception de la resource media
		// contrôle de la saisie
		$error = media_upload_control ($_FILES['resource']) ;
		if ($error != "") {
			echo "\t\t\t<h1>".LIBM_NEW_MEDIA."</h1>\r\n" ;
			// réaffichage du formulaire avec message d'erreur
			media_upload_form ($_POST['albumid'], $error, $db) ;
			break ;
		} else {
			// appel de la fonction d'upload
			$retour = media_upload ($_POST['albumid'],  $_FILES['resource'], $db, $USER) ;
			echo "\t\t\t<h1>".LIBM_NEW_MEDIA."</h1>\r\n" ;
			// affichage du message de feedback avec miniature du media chargé
			display_in_box ($retour[0], $retour[1]) ;
			$mid = $retour[2] ;
		}
		// affichage du formulaire 4 pour commenter le dernier media chargé
		// initialisations
		$ARRAY_media = search_row_by_id ("media", "mid", $mid, $db, TABLEAU);
		$title_error = "" ;
		media_comment_form ($ARRAY_media, $title_error, $db) ;
	break ;
	case "comment_media" ;
		// réception des commentaires pour le dernier media chargé
		// contrôle de saisie
		$error = media_comment_control ($_POST) ;
		if ($error != "") {
			// réaffichage du média et du formulaire avec message d'erreur
			$ARRAY_media = search_row_by_string ("media", "media_name", $_POST['media_name'], $db, TABLEAU);
			$message = INFO_UPLOAD_1.$_POST['original_name'].INFO_UPLOAD_2 ;
			$directory = UPLDP.generate_album_dir_name ($_POST['albumid']) ;
			$info = make_message_image ($ARRAY_media, $directory, $message) ;
			echo "\t\t\t<h1>".LIBM_NEW_MEDIA."</h1>\r\n" ;
			display_in_box ("", "", $info) ;
			media_comment_form ($_POST, $error, $db) ;
			break ;
		} else {
			// enregistrement des commentaires dans la bdd
			$retour = media_comment ($_POST, $db) ;
			$albumid  = $retour[1] ;
			echo "\t\t\t<h1>".LIBM_NEW_MEDIA.fill_it(50,10)."<a href=\"index.php?location=media&action=display_album&albumid=".$albumid."\" class=\"blue_button\" title=\"".END_UPLOAD."\">".END_UPLOAD."</a></h1>\r\n" ;
			// Affichage du message de feedback
			display_in_box ($retour[2], $retour[3]) ;
		}
		// saisie suivante
		// affichage du formulaire 3 d'upload
		media_upload_form ($albumid, "", $db) ;
	break ;
}
page_footer($footer_lib) ;

function choose_album_form ($preset_albumid, $error_album_select, $db) {
	// début du formulaire 1
	startform ("set_album", "index.php?location=media&action=add_media&phase=choose_album", ALBUM_OPTION) ;
	// recherche de la liste des albums
	$result = $db->query("SELECT * FROM album ORDER BY album_title ASC ");
//	$liste_albums["none"] = " " ;
	while ($OBJ_row = $db->fetch_object($result)) {
		$liste_albums[$OBJ_row->album_title] = $OBJ_row->album_title ;
	}
	// champs select pour sélectionner un album
	echo select_field (CHOOSE_EXISTING_ALBUM, "selected_album_title", "", $liste_albums, $error_album_select, 3) ;
	echo "\t\t\t\t<p>".OU."</p>\r\n" ;
	// champs checkbox pour créer un nouvel album
	echo "\t\t\t\t<p>\r\n" ;
		echo "\t\t\t\t\t<label for=\"check_field\">".NOTCH_HERE."</label>\r\n" ;
		echo "\t\t\t\t\t<input type=\"checkbox\" name=\"create\" value=\"create\" /> ".NEW_ALBUM_ASKED."\r\n" ;
	echo "\t\t\t\t</p>\r\n" ;
	// bouton de validation
	end_entete () ;
	submit_field ("&nbsp;", "validate", CONFIRM_YOUR_CHOICE) ;
	stopform () ;
}
function choose_album_control ($input) {
	$error_album_select = "" ;
	if (isset ($input['selected_album_title'])) $select_album = true ;
	else $select_album = false ;
	if (($select_album == true) and (isset ($input['create']))) $error_album_select .= "Sélectionnez ou cochez, mais pas les deux" ;
	if (($select_album == false) and (!isset ($input['create']))) $error_album_select .= "Quel est votre choix ?" ;
	return $error_album_select ;
}

function create_album_form ($ARRAY_album, $error_album_title, $creation, $db) {
	// début du formulaire 2
	startform ("new_album", "index.php?location=media&action=add_media&phase=write_album", ALBUM_VALIDATE) ;
	if ($creation === true) {
		hidden_field ("new_album", "affirmatif") ;
		// traitement des caractères spéciaux HTML
		foreach ($ARRAY_album as $clef => $valeur) $ARRAY_album[$clef] = htmlspecialchars(stripslashes($valeur));
		text_field (LAB_ALBUM_NEW, "album_title",  $ARRAY_album['album_title'], 3, $error_album_title) ;
		text_field (LAB_ALBUM_AUTHOR, "album_author",  $ARRAY_album['album_author'], 2) ;
		echo textarea_field (LAB_COMMENT, "album_comment", $ARRAY_album['album_comment']) ;
		// options de visibilité
		$option_list = array ("everyone"=>"Tout le Monde", "public"=>"Membres", "private"=>PRIVE) ;
		echo radio_field (ACCESS_CONTROL, "album_visibility", $ARRAY_album['album_visibility'], $option_list) ;
	} else {
		hidden_field ("new_album", "negatif") ;
		hidden_field ("selected_album_title", $ARRAY_album['selected_album_title']) ;
		// affichage des infos relatives à l'album sélectionné
		$OBJ_album = search_row_by_string ("album", "album_title", $ARRAY_album['selected_album_title'], $db) ;
		lib_field (ALBUM_SELECTED, $OBJ_album->album_title) ;
		lib_field (LAB_ALBUM_AUTHOR, $OBJ_album->album_author) ;
	}
	// bouton de validation
	end_entete () ;
	submit_field ("&nbsp;", "validate", CONFIRM_ALBUM) ;
	stopform () ;
}
function create_album ($ARRAY_album, $db, $USER) {
	if ($proposed_album_title = search_row_by_string ("album", "album_title", $ARRAY_album['album_title'], $db)) {
		// tentative de duplicata du titre de l'album
		display_in_box ("", "<br />".SORY.THE_ALBUM."( <strong><span class=\"jaune\">".$ARRAY_album['album_title']."</span></strong> ) ".ALRDY_EXIST) ;
		// suite tbd
	} else {
		// création du nouvel album
		// prise d'un identifiant
		$id_album = generate_index("constant_album", $db) ;
		// préparation des données avant insertion
		$album_title = $db->real_escape_string ($ARRAY_album['album_title']) ;
		if (isset($ARRAY_album['album_author'])) $album_author = $db->real_escape_string($ARRAY_album['album_author']);
		else $album_author = UNDEFINED ;
		if (isset($ARRAY_album['album_comment'])) $album_comment = $db->real_escape_string($ARRAY_album['album_comment']);
		else $album_comment = "" ;
		$album_keywords = $album_title." " ;
		if ($album_author != UNDEFINED) $album_keywords .= $album_author." " ;
		$album_visibility = $ARRAY_album['album_visibility'] ;
		// champs automatiques
		$album_maked_by = $USER ;
		$album_maked_on = date("U") ;
		$sql = "INSERT INTO `album` (`album_id`, `album_keywords`, `album_title`, `album_author`, `album_comment`, `album_clicks`, `album_visibility`, `album_maked_on`, `album_maked_by`, `album_revised_on`, `album_revised_by`) VALUES ('$id_album', '$album_keywords', '$album_title', '$album_author', '$album_comment', '1', '$album_visibility', '$album_maked_on', '$album_maked_by', '0', '')" ;
		$db->query ($sql) ;
		$albumf = html_convert($album_title) ;
		$feedback = OK_NEW_ALBUM1 . $albumf . OK_NEW_ALBUM2 ;
		// envoi du feedback et du nouvel id
		$retour = array ("0"=>"$id_album","1"=>"$feedback") ;
		return $retour ;
	}
}
function create_album_control ($input) {
	$error_album_title = "" ;
	if (strlen($input) < 6) $error_album_title = NOK_TITLE_LEN ;
	return $error_album_title ;
}

function media_upload_form ($albumid, $error_media_file, $db) {
	// début du formulaire
	startform ("new_media", "index.php?location=media&action=add_media&phase=upload_media", CHOOSE_FILE) ;
	// champs fichier
	file_field (LAB_MEDIA_FILE, "resource", "", $error_media_file, true) ;
	// acquisition et affichage du titre de l' album
	hidden_field ("albumid", $albumid) ;
	$selected_album = get_field_by_id ("album", "album_title", "album_id", $albumid, $db) ;
	lib_field (DESTINATION_ALBUM, $selected_album) ;
	end_entete () ;
	// bouton d'envoi
	submit_field ("&nbsp;", "validate", CONFIRM_UPLOAD) ;
	stopform () ;
}
function media_upload_control ($resource) {
	// initialisation
	$media_file_error = "" ;
	$extension = strtolower(substr(strrchr($resource['name'],"."),1));
	$accepted = array ('mp3', 'gif', 'jpg', 'png', 'flv') ;
	if($extension == 'jpeg') $extension = 'jpg';
	if (($resource['name'] != "") and (!in_array($extension, $accepted))) $media_file_error .= NOK_NEW_EXT." : ".$extension ;
	if ($resource['name'] == "") $media_file_error .= NOK_NEW_FILE ;
	return $media_file_error ;
}
function media_upload ($albumid, $resource, $db, $USER) {
	$feedback = $ok_message = $warning = $original_name = $media_size = $keywords = "" ;
	// Construction du nom [$media_name] pour le nouveau fichier media
	$mid = generate_index("constant_media", $db) ;
	$media_code = generate_media_code ($mid) ;
	if ($resource['error'] === 0) {
		$original_name = $resource['name'] ;
		$media_size = $resource['size'] ;
		$media_extension = strtolower(substr(strrchr($original_name,"."),1));
		if($media_extension == 'jpeg') $media_extension = 'jpg';
		switch ($media_extension) {
			case "mp3": $itemid = 1 ; $media_type = "a." ; break ;
			case "gif": $itemid = 2 ; $media_type = "i." ; break ;
			case "jpg": $itemid = 3 ; $media_type = "i." ; break ;
			case "png": $itemid = 4 ; $media_type = "i." ; break ;
			case "flv": $itemid = 5 ; $media_type = "v." ; break ;
		}
		$media_name = $media_type.$media_code.".".$media_extension ;
	} else {
		// Affichage de l'erreur
		// tbd
		page_footer("ERROR", "") ;
	}
	$server_dir = UPLDP.generate_album_dir_name ($albumid) ;
	if (!is_dir($server_dir)) mkdir($server_dir, 0777) ;
	$retour = upload_media ($resource, $server_dir, $media_name, $media_size, $original_name) ;
	$ok_message .= $retour[0] ;
	$warning .= $retour[1] ;
	if (($itemid > 1) and ($itemid < 5)) {
		// fabrication de la miniature
		$media_image = $server_dir."/".$media_name ;
		$thumb_dir = $server_dir."/thumbnail/" ;
		if (!is_dir($thumb_dir)) mkdir($thumb_dir, 0777) ;
		$thumb_img = make_thumbnail ($media_image, $thumb_dir, $media_code) ;
		$thumbnail_picture = "<img src=\"".$thumb_img."\" alt=\"thumbnail\" />" ;
	} elseif ($itemid == 1) {
		$thumbnail_picture = "<img src=\"".UPLDP."generic/audio_media.png\" width=\"160\" height=\"120\" alt=\"audio\" />" ;
	} elseif ($itemid == 5) $thumbnail_picture = "<img src=\"".UPLDP."generic/video_media.png\" width=\"160\" height=\"120\" alt=\"video\" />" ;
	// tableau de feedback avec message + thumbnail ou logo[audio ou video]
	$feedback .= "\t\t\t\t\t<table><tr>\r\n" ;
	$feedback .= "\t\t\t\t\t\t<td>".$ok_message."<br />".fill_it(230,1)."</td>\r\n" ;
	$feedback .= "\t\t\t\t\t\t<td>".$thumbnail_picture."</td>\r\n" ;
	$feedback .= "\t\t\t\t\t</tr></table>\r\n" ;
	// construction des champs à enregistrer dans la bdd
	$keywords .= $original_name." " ;
	$maked_by = $USER ;
	$maked_on = date("U") ;
	// requête d'insertion du media dans la bdd
	$sql_insert_media = "INSERT INTO `media` (`mid`, `itemid`, `albumid`, `keywords`, `title`, `author`, `url`, `comment`, `media_name`, `original_name`, `event_date`, `media_size`, `clicks`, `downloads`, `maked_on`, `maked_by`) VALUES ('$mid', '$itemid', '$albumid', '$keywords', '', '', '', '', '$media_name', '$original_name', '', '$media_size', '1', '1', '$maked_on', '$maked_by');" ;
	$db->query ($sql_insert_media);
	// Requete d'insertion des infos exif pour les jpeg
	if ($media_extension == "jpg") {
		$TBL_exif = get_exif ($resource) ;
		if ($TBL_exif['exif'] == 1) {
			$exif_date = $TBL_exif['exif_date'] ;
			$exif_manufacturer = $TBL_exif['exif_manufacturer'] ;
			$exif_model = $TBL_exif['exif_model'] ;
			$exif_exposure = $TBL_exif['exif_exposure'] ;
			$exif_fnumber = $TBL_exif['exif_fnumber'] ;
			$exif_iso = $TBL_exif['exif_iso'] ;
			$exif_aperture = $TBL_exif['exif_aperture'] ;
			$exif_light = $TBL_exif['exif_light'] ;
			$exif_focal = $TBL_exif['exif_focal'] ;
			$sql_insert_exif = "INSERT INTO `exif` (`exif_id`, `exif_date`, `exif_manufacturer`, `exif_model`, `exif_exposure`, `exif_fnumber`, `exif_iso`, `exif_aperture`, `exif_light`, `exif_focal`) VALUES ('$mid', '$exif_date', '$exif_manufacturer', '$exif_model', '$exif_exposure', '$exif_fnumber', '$exif_iso', '$exif_aperture', '$exif_light', '$exif_focal');" ;
			$db->query ($sql_insert_exif);
			// recopie de la date exif
			if (!$exif_date) $event_date = "1515-02-23" ;
			else $event_date = substr ($exif_date, 0, 10) ;
			$sql_date = "UPDATE `media` SET `event_date` = '$event_date' WHERE `media`.`mid` = '$mid' LIMIT 1 ;" ;
			$db->query ($sql_date) ;
		}
	}
	$retour = array ("0"=>"$feedback","1"=>"$warning","2"=>"$mid") ;
	return $retour ;
}
function upload_media ($resource, $server_dir, $media_name, $media_size, $original_name) {
	$feedback = $warning = "" ;
	$size = number_format($media_size/1000, 3, ',', ' ');
	$ok_message = OK_UPLOAD_1.$original_name.OK_UPLOAD_2.$size ;
	$media_extension = strtolower(substr(strrchr($resource['name'],"."),1));
	$destination = $server_dir."/".$media_name ;
	if (($media_extension == "mp3") or ($media_extension == "flv")) {
		if (is_uploaded_file($resource['tmp_name'])) {
			if (copy($resource['tmp_name'], $destination)) $feedback = $ok_message ;
			else $warning = "no-good copy" ;
		} else $warning = "no-good is_uploaded_file" ;
	} else {
		if (is_uploaded_file($resource['tmp_name'])) {
			// Redimensionnement conditionnel
			$final_resource = $resource ;		//temporaire
//			$final_resource = image_resize ($resource, $max_width, $max_height) ;
			if (copy($final_resource['tmp_name'], $destination)) $feedback = $ok_message ;
			else $warning = "no-good copy" ;
		} else $warning = "no-good is_uploaded_file" ;
	}
	$retour = array ("0"=>"$feedback","1"=>"$warning") ;
	return $retour ;
}

function media_comment_form ($ARRAY_media, $title_error, $db) {
	// traitement des caractères spéciaux HTML avant affichage
	foreach ($ARRAY_media as $clef => $valeur) $ARRAY_media[$clef] = htmlspecialchars(stripslashes($valeur));
	// début du formulaire
	startform ("comment_media", "index.php?location=media&action=add_media&phase=comment_media", COMMENT_FILE.$ARRAY_media['original_name']) ;
	hidden_field ("mid", $ARRAY_media['mid']) ;
	hidden_field ("keywords", $ARRAY_media['keywords']) ;
	// acquisition et affichage du titre de l' album
	$albumid = $ARRAY_media['albumid'] ;
	hidden_field ("albumid", $albumid) ;
	hidden_field ("media_name", $ARRAY_media['media_name']) ;
	hidden_field ("original_name", $ARRAY_media['original_name']) ;
	$selected_album = get_field_by_id ("album", "album_title", "album_id", $albumid, $db) ;
	lib_field (DESTINATION_ALBUM, $selected_album) ;
	// 3 champs à remplir (titre obligatoire)
	text_field (LAB_MEDIA_TITLE, "title",  $ARRAY_media['title'], 2, $title_error) ;
	text_field (LAB_MEDIA_AUTHOR, "author",  $ARRAY_media['author'], 2) ;
	echo textarea_field (LAB_COMMENT, "comment", $ARRAY_media['comment']) ;
	end_entete () ;
	// bouton d'envoi
	submit_field ("&nbsp;", "validate", CONFIRM_COMMENT) ;
	stopform () ;
}
function media_comment_control ($input) {
	// initialisation
	$title_error = "" ;
	if (strlen ($input['title']) < 6) $title_error = NOK_TITLE_LEN ;
	return $title_error ;
}
function media_comment ($ARRAY_media, $db) {
	$feedback = $warning = "" ;
	// préparation des données avant insertion ($ARRAY_media)
	$mid = $ARRAY_media['mid'] ;
	$albumid = $ARRAY_media['albumid'] ;
	$title = $db->real_escape_string($ARRAY_media['title']);
	if (isset($ARRAY_media['author'])) $author = $db->real_escape_string($ARRAY_media['author']);
	else $author = UNDEFINED ;
	if (isset($ARRAY_media['comment'])) $comment = $db->real_escape_string($ARRAY_media['comment']);
	else $comment = "" ;
	$keywords = $db->real_escape_string($ARRAY_media['keywords']);
	$keywords .= " ".$title." " ;
	if ($author != UNDEFINED) $keywords .= $author." " ;
	// requête d'enregistrement des infos saisies
	$sql_comment = "UPDATE `media` SET `keywords` = '$keywords', `title` = '$title', `author` = '$author', `comment` = '$comment' WHERE `media`.`mid` = '$mid' LIMIT 1 ;" ;
	$db->query ($sql_comment) ;
	if (mysql_affected_rows() == 1) {
		$message = OK_COMMENT_1.$title."<br />".$author.OK_COMMENT_2 ;
		$directory = UPLDP.generate_album_dir_name ($albumid) ;
		$feedback = make_message_image ($ARRAY_media, $directory, $message) ;
	} else $warning = NO_UPDATE_DONE ;
	$retour = array ("0"=>"$mid","1"=>"$albumid","2"=>"$feedback","3"=>"$warning") ;
	return $retour ; 
}
function make_message_image ($ARRAY_media, $directory, $message) {
	$media_name = $ARRAY_media['media_name'] ;
	list ($type, $code, $ext) = explode (".", $media_name) ;
	$thumbnail = $directory."/thumbnail/min".$media_name ;
	if ($type == "a") $image = "<img src=\"".UPLDP."generic/audio_media.png\" width=\"160\" height=\"120\" alt=\"audio\" />" ;
	elseif ($type == "v") $image = "<img src=\"".UPLDP."generic/video_media.png\" width=\"160\" height=\"120\" alt=\"video\" />" ;
	else $image = $image = "<img src=\"".$thumbnail."\" alt=\"thumbnail\" />" ;
	// tableau de feedback avec message + thumbnail ou logo[audio ou video]
	$feedback = "\t\t\t\t\t<table><tr>\r\n" ;
	$feedback .= "\t\t\t\t\t\t<td>".$message."<br />".fill_it(230,1)."</td>\r\n" ;
	$feedback .= "\t\t\t\t\t\t<td>".$image."</td>\r\n" ;
	$feedback .= "\t\t\t\t\t</tr></table>\r\n" ;
	return $feedback ;
}
?>[/code]
media_play.php[code]<?php
/***************************************************************
* Copyright notice - Notice de droits d'auteur
*
* © 2011-2021 Christian ECKENSPIELLER ([email protected])
* Internet site : ceck.org
* All rights reserved
*
* The GCM project is a free software, you can redistribute it
and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation.
*
* This script is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details :
[http://www.gnu.org/copyleft/gpl.html].
*
* This copyright notice MUST APPEAR in all copies of the script.
* Cette notice de droits d'auteur DOIT APPARAITRE dans toutes
les copies des scripts.
****************************************************************  «  »
*/

require_once("media/abc.php") ;

// Acquisition mid à afficher
if (isset ($_GET['mid'])) $mid = $_GET['mid'] ;
else error_page (ERR_UNDEFINED, "media", $RIGHTS, $footer_lib, $db ) ;
// Recherche media à afficher
$ARRAY_media = search_row_by_id ("media", "mid", $mid, $db, TABLEAU);
if (is_array($ARRAY_media)) foreach ($ARRAY_media as $cle => $valeur) $ARRAY_media[$cle] = html_convert($valeur);
// Si media inexistant on arrete la
else error_page (ERR_NO_PAGE, "media", $RIGHTS, $footer_lib, $db ) ;

// acquisition du type de media et du dossier de l'album
$itemid = $ARRAY_media["itemid"] ;
$albumid = $ARRAY_media["albumid"] ;
$album_name = generate_album_dir_name($albumid) ;
$media_name = $ARRAY_media["media_name"] ;
list ($type, $media_code, $media_extension) = explode (".", $media_name) ;

// Incrémentation du champs clicks du media
increment_click ($mid, "media", 3, $db) ;

// tableau contenant les actions possibles suivant le média affiché
$tools_table = "\t\t\t<table id=\"toolsTable\">\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td>\r\n" ;
		// navigation
list ($first_mid, $previous_mid, $next_mid, $last_mid) = explode ("|", navigate_through_album ($album_name, $media_name)) ;
$tools_table .= tool_unit ("action_first.png", "play_media&mid=".$first_mid, NAV_FIRST, 22) ;
if ($previous_mid != "none") $tools_table .= tool_unit ("action_previous.png", "play_media&mid=".$previous_mid, NAV_PREVIOUS, 44) ;
else $tools_table .= fill_it(88,24) ;
if ($next_mid != "none") $tools_table .= tool_unit ("action_next.png", "play_media&mid=".$next_mid, NAV_NEXT, 22) ;
else $tools_table .= fill_it(66,24) ;
$tools_table .= tool_unit ("action_last.png", "play_media&mid=".$last_mid, NAV_LAST, 44) ;

		// actions communes à tous les médias : éditer, déplacer, supprimer, télécharger
if (($RIGHTS === "administrator") or ($RIGHTS === "private")) {
	$tools_table .= popup_tool_unit ("action_edit.png", EDIT_MEDIA, "edit_popup", "edit_request&mid=", $mid) ;
	$tools_table .= popup_tool_unit ("action_move.png", MOVE_MEDIA, "edit_popup", "move_request&mid=", $mid) ;
	$tools_table .= popup_tool_unit ("action_delete.png", DELETE_MEDIA, "edit_popup", "delete_request&mid=", $mid) ;
} else $tools_table .= fill_it(132,24) ;
if ($RIGHTS != "visitor") $tools_table .= "<a href=\"media/request_download.php?mid=".$mid."\"  title=\"".DOWNLOAD_MEDIA."\"><img src=\"img/actions/action_download.png\" width=\"44\" height=\"24\" alt=\"action_download\" /></a>" ;
else $tools_table .= fill_it(44,24) ;

		// actions réservées aux images : exif, plein-écran, diaporama
if (($itemid == 2) or ($itemid == 3) or ($itemid == 4)) {
	$ARRAY_exif = search_row_by_id ("exif", "exif_id", $mid, $db);
	if (is_object($ARRAY_exif)) $tools_table .= popup_tool_unit ("action_show_exif.png", EXIF_SHOW, "exif_popup", "show_exif&mid=", $mid) ;
	else $tools_table .= fill_it(44,24) ;
	$picture = UPLDP.$album_name."/".$media_name ;
	$max = image_max ($picture, SCREEN_WIDTH, SCREEN_HEIGHT) ;
	$max_width = $max[1] + 8 ;
	$max_height = $max[2] + 4 ;
	$tools_table .= popup_tool_unit ("action_full_screen.png", FULL_SCREEN, "poster", "poster&mid=", $mid, $max_width, $max_height) ;
	$tools_table .= tool_unit ("action_slideshow.png", "slideshow&albumid=".$albumid, SLIDESHOW) ;
} else {
	$tools_table .= fill_it(137,24) ;
}
		// retour à l'album | ajouter un media
$tools_table .= tool_unit ("action_show_album.png", "display_album&albumid=".$albumid, BACK_TO_ALBUM) ;
if (($RIGHTS === "administrator") or ($RIGHTS === "private")) $tools_table .= tool_unit ("action_add.png", "add_media&phase=add_media&albumid=".$albumid, ADD_MEDIA_IN_ALBUM) ;
// fin du tableau d'entête
$tools_table .= "\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n" ;

// tableau contenant le média proprement dit
$display_table = "\t\t\t<table id=\"mediaTable\">\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td>\r\n" ;
switch ($itemid) {
	case "1":
		$output_audio = UPLDP.$album_name."/".$media_name ;
		$display_table .= audio_play ($output_audio) ;
	break ;
	case "2":
	case "3":
	case "4":
		// Redimensionnement de l'image
		$max_picture_width = 740 ;
		$max_picture_height = 555 ;
		$max = image_max ($picture, $max_picture_width, $max_picture_height) ;
		$output_picture = $max[0] ;
		// affichage de l'image
		$display_table .= $output_picture ;
	break ;
	case "5":
		$output_video = UPLDP.$album_name."/".$media_name ;
		$display_table .= video_play($output_video) ;
	break ;
}
$display_table .= "\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n" ;

// début de page
if ($itemid == 1) $plugin = "audio" ;
elseif ($itemid == 5) $plugin = "video" ;
else $plugin = "none" ;
page_header ($USER, 1, $db, $plugin) ;

// affichage des tableaux ci-dessus
echo $tools_table ;
echo $display_table ;

// construction et affichage du titre
$album_title = "<span class=\"jaune\">".get_field_by_id ("album", "album_title", "album_id", $albumid, $db)."</span>" ;
$space = str_repeat("&nbsp;", 8);
echo "\t\t\t<h4>".$album_title.$space.$ARRAY_media['title']." <span class=\"gris_moyen\">[ ".cut_string ($ARRAY_media['original_name'], 20)." ]</span> </h4>\r\n" ;

// fin de la page
page_footer($footer_lib) ;

function popup_tool_unit ($icon, $title, $js_popup, $url, $id, $width=0, $height=0, $class="") {
	list ($ico, $xt) = explode (".", $icon) ;
	if ($class == "") $tag = "<img" ;
	else $tag = "<img class=\"".$class."\"" ;
	$output = $tag." src=\"img/actions/".$icon."\" width=\"44\" height=\"24\" alt=\"".$ico."\" title=\"".$title."\" onclick=\"" ;
	$root = "index.php?location=media&action=" ;
	if (($width == 0) and ($height == 0)) {
		$output .= $js_popup."('".$root.$url."".$id."')\" />" ;
	} else {
		$output .= $js_popup."('".$root.$url."".$id."', '".$width."', '".$height."')\" />" ;
	}
	return $output ;
}

function tool_unit ($image, $url, $title, $space=0, $class="") {
	$output = "" ;
	if ($class == "") $tag = "<img" ;
	else $tag = "<img class=\"".$class."\"" ;
	list ($icon, $xt) = explode (".", $image) ;
	$root = "index.php?location=media&action=" ;
	$output .= "\t\t\t\t\t\t<a href=\"".$root.$url."\"  title=\"".$title."\">" ;
	$output .= $tag." src=\"img/actions/".$image."\" width=\"44\" height=\"24\" alt=\"".$icon."\" />" ;
	$output .= "</a>" ;
	if ($space != 0) $output .= fill_it($space, 24) ;
	$output .= "\r\n" ;
	return $output ;
}

function navigate_through_album ($album_name, $media_name) {
	// Construction tableau des codes des medias de l'album en cours
	$rank = 0 ;
	if ($handle = opendir(UPLDP.$album_name."/")) {
		while (($file = readdir($handle)) !== false) {
			if (($file != ".") and ($file != "..") and (strstr($file, "humb") === FALSE)) {
				list ($t, $code, $x) = explode (".", $file) ;
				$TBLmedia_code[$rank] = $code ;
				$rank++ ;
			}
		}
	}
	$media_qty = $rank ;
	closedir($handle) ;
	// Tri du tableau par code
	sort($TBLmedia_code) ;
	// Recherche de la clé du media courant dans le tableau trié
	list ($type, $current_code, $ext) = explode (".", $media_name) ;
	$current_key = array_search($current_code, $TBLmedia_code) ;
	// Recherche de la clé du media precedent et du mid correspondant
	$previous_key = $current_key - 1 ;
	if ($previous_key >= 0) $previous_mid = $TBLmedia_code[$previous_key] + 0 ;
	else $previous_mid = "none" ;
	// Recherche de la clé du media suivant et du mid correspondant
	$next_key = $current_key + 1 ;
	if ($next_key < $media_qty) $next_mid = $TBLmedia_code[$next_key] + 0 ;
	else $next_mid = "none" ;
	// Envoi des identifiants mid pour la navigation
	$first_mid = $TBLmedia_code[0] + 0 ;
	$last_mid = $TBLmedia_code[($media_qty - 1)] + 0 ;
	return $first_mid."|".$previous_mid."|".$next_mid."|".$last_mid ;
}

function audio_play ($audio) {
	// http://www.alsacreations.fr/dewplayer.html
	$play  = "<object type=\"application/x-shockwave-flash\" data=\"plugin/audio/dewplayer-bubble-vol.swf\" width=\"250\" height=\"70\" id=\"dewplayer\" name=\"dewplayer\">" ;
	$play .= "<param name=\"movie\" value=\"plugin/audio/dewplayer-bubble-vol.swf\" />" ;
	$play .= "<param name=\"flashvars\" value=\"mp3=".$audio."&autostart=1&autoreplay=1&showtime=1\" />" ;
	$play .= "<param name=\"wmode\" value=\"transparent\" />" ;
	$play .= "</object>" ;
	return $play ;
}
function video_play($video) {
	$play = "<div style=\"text-align:center;margin-top:2em;\">" ;
	$play .= "<object type=\"application/x-shockwave-flash\" data=\"dewtube.swf\" width=\"600\" height=\"450\" id=\"dewtube\">" ;
	$play .= "<param name=\"allowFullScreen\" value=\"true\" />" ;
	$play .= "<param name=\"movie\" value=\"dewtube.swf\" />" ;
	$play .= "<param name=\"quality\" value=\"high\" />" ;
	$play .= "<param name=\"bgcolor\" value=\"#000000\" />" ;
	$play .= "<param name=\"flashvars\" value=\"movie=".$video."&width=600&height=450&autostart=1\" />" ;
	$play .= "</object>" ;
	$play .= "</div>" ;
	
	return $play ;

}
?>

Re: aperçu image video flv

Posté : 31 août 2013, 16:52
par va_savoir
ah oui j'ai oublié voci le site de démonstration.