Your IP : 216.73.216.245


Current Path : /home/bourgleram/www/398a1/
Upload File :
Current File : /home/bourgleram/www/398a1/metadata.tar

html.php000066600000002540152522474320006234 0ustar00<?php

/***************************************************************************\
 *  SPIP, Systeme de publication pour l'internet                           *
 *                                                                         *
 *  Copyright (c) 2001-2016                                                *
 *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
 *                                                                         *
 *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
 *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
\***************************************************************************/

if (!defined('_ECRIRE_INC_VERSION')) return;
include_spip('inc/autoriser');

/**
 * enlever les scripts de html si necessaire
 * on utilise safehtml
 *
 * @param string $file
 * @return array
 */
function medata_html_dist($file){
	$meta = array();

	// Securite si pas autorise : virer les scripts et les references externes
	// sauf si on est en mode javascript 'ok' (1), cf. inc_version
	if ($GLOBALS['filtrer_javascript'] < 1
	  AND !autoriser('televerser','script')) {
		$texte = spip_file_get_contents($file);
		include_spip('inc/texte');
		$new = trim(safehtml($texte));
		// petit bug safehtml
		if ($new != $texte) ecrire_fichier($file, $new);
	}
	
	return $meta;
}swf.php000066600000001536152522474320006073 0ustar00<?php

/***************************************************************************\
 *  SPIP, Systeme de publication pour l'internet                           *
 *                                                                         *
 *  Copyright (c) 2001-2016                                                *
 *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
 *                                                                         *
 *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
 *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
\***************************************************************************/

if (!defined('_ECRIRE_INC_VERSION')) return;

function metadata_swf_dist($file){
	$metadata = charger_fonction('image','metadata');
	return $metadata($file);
}svg.php000066600000004451152522474320006072 0ustar00<?php

/***************************************************************************\
 *  SPIP, Systeme de publication pour l'internet                           *
 *                                                                         *
 *  Copyright (c) 2001-2016                                                *
 *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
 *                                                                         *
 *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
 *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
\***************************************************************************/

if (!defined('_ECRIRE_INC_VERSION')) return;
include_spip('inc/autoriser');

/**
 * Determiner les dimensions d'un svg, et enlever ses scripts si necessaire
 * on utilise safehtml qui n'est pas apropriee pour ca en attendant mieux
 * cf http://www.slideshare.net/x00mario/the-image-that-called-me
 * http://heideri.ch/svgpurifier/SVGPurifier/index.php
 *
 * @param string $file
 * @return array
 */
// http://code.spip.net/@traite_svg
function metadata_svg_dist($file){
	$meta = array();

	$texte = spip_file_get_contents($file);

	// Securite si pas autorise : virer les scripts et les references externes
	// sauf si on est en mode javascript 'ok' (1), cf. inc_version
	if ($GLOBALS['filtrer_javascript']<1
		AND !autoriser('televerser', 'script')
	){
		include_spip('inc/texte');
		$new = trim(safehtml($texte));
		// petit bug safehtml
		if (substr($new, 0, 2)==']>') $new = ltrim(substr($new, 2));
		if ($new!=$texte) ecrire_fichier($file, $texte = $new);
	}

	$width = $height = 150;
	if (preg_match(',<svg[^>]+>,', $texte, $s)){
		$s = $s[0];
		if (preg_match(',\WviewBox\s*=\s*.\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+),i', $s, $r)){
			$width = $r[3];
			$height = $r[4];
		}
		else {
			// si la taille est en centimetre, estimer le pixel a 1/64 de cm
			if (preg_match(',\Wwidth\s*=\s*.(\d+)([^"\']*),i', $s, $r)){
				if ($r[2]!='%'){
					$width = $r[1];
					if ($r[2]=='cm') $width <<= 6;
				}
			}
			if (preg_match(',\Wheight\s*=\s*.(\d+)([^"\']*),i', $s, $r)){
				if ($r[2]!='%'){
					$height = $r[1];
					if ($r[2]=='cm') $height <<= 6;
				}
			}
		}
	}
	$meta['largeur'] = $width;
	$meta['hauteur'] = $height;
	return $meta;
}image.php000066600000003004152522474320006346 0ustar00<?php

/***************************************************************************\
 *  SPIP, Systeme de publication pour l'internet                           *
 *                                                                         *
 *  Copyright (c) 2001-2016                                                *
 *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
 *                                                                         *
 *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
 *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
\***************************************************************************/

if (!defined('_ECRIRE_INC_VERSION')) return;

function metadata_image_dist($fichier){
	$meta = array();

	if ($size_image = @getimagesize($fichier)) {
		$meta['largeur'] = intval($size_image[0]);
		$meta['hauteur'] = intval($size_image[1]);
		$meta['type_image'] = decoder_type_image($size_image[2]);
	}

	return $meta;
}

/**
 * Convertit le type numerique retourne par getimagesize() en extension fichier
 *
 * @param int $type
 * @param bool $strict
 * @return string
 */
// http://code.spip.net/@decoder_type_image
function decoder_type_image($type, $strict = false) {
	switch ($type) {
		case 1:
			return "gif";
		case 2:
			return "jpg";
		case 3:
			return "png";
		case 4:
			return $strict ? "" : "swf";
		case 5:
			return "psd";
		case 6:
			return "bmp";
		case 7:
		case 8:
			return "tif";
		default:
			return "";
	}
}
?>flv.php000066600000002441152522474320006057 0ustar00<?php

/***************************************************************************\
 *  SPIP, Systeme de publication pour l'internet                           *
 *                                                                         *
 *  Copyright (c) 2001-2016                                                *
 *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
 *                                                                         *
 *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
 *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
\***************************************************************************/

if (!defined('_ECRIRE_INC_VERSION')) return;

function metadata_flv_dist($file, $bigindian = true){
	$meta = array();

	if ($fd = fopen($file, 'r')
	  AND $raw = fread($fd, 512)){

		$keys = array('largeur'=>'width', 'hauteur'=>'height','duree'=>'duration','framerate'=>'framerate');
		foreach ($keys as $m=>$k) {
			if (($i = strpos($raw, $k))>-1){
				$bytes = substr($raw, $i+strlen($k)+1, 8);
				if ($bigindian)
					$bytes = strrev($bytes);
				$zz = unpack("dflt", $bytes); // unpack the bytes
				$meta[$m] = $zz['flt']; // return the number from the associative array
			}
		}
	}

	return $meta;
}

?>