Appeler un SWF a partir de PHP

dumbop84 Messages postés 12 Date d'inscription vendredi 17 septembre 2004 Statut Membre Dernière intervention 19 mars 2005 - 10 févr. 2005 à 10:49
coockiesch Messages postés 2268 Date d'inscription mercredi 27 novembre 2002 Statut Membre Dernière intervention 13 septembre 2013 - 10 févr. 2005 à 12:50
bonjour a tous ... g trouvé un scrip super pour faire apparaitre des
images alétoirement, ca marche pour les gif , jpeg.;etc...mais pas pour
les SWF (flash) , je vous joins le code (en rouge, le code ou se
touve certainement l'erreur, sachant que j'ai deja tenté images/swf....



*/

$folder = '.';

/*

$extList['pdf'] = 'application/pdf';

$extList['css'] = 'text/css';

$extList['html'] = 'text/html';

$extList['htm'] = 'text/html';

$extList = array();

$extList['gif'] = 'image/gif';

$extList['jpg'] = 'image/jpeg';

$extList['jpeg'] = 'image/jpeg';

$extList['png'] = 'image/png';

$extList['swf'] = 'application/swf';





En Noir, le code de "fonctionnement"



$img = null;



if (substr($folder,-1) != '/') {

$folder = $folder.'/';

}



if (isset($_GET['img'])) {

$imageInfo = pathinfo($_GET['img']);

if (

isset( $extList[ strtolower( $imageInfo['extension'] ) ] ) &&

file_exists( $folder.$imageInfo['basename'] )

) {

$img = $folder.$imageInfo['basename'];

}

} else {

$fileList = array();

$handle = opendir($folder);

while ( false !( $file readdir($handle) ) ) {

$file_info = pathinfo($file);

if (

isset( $extList[ strtolower( $file_info['extension'] ) ] )

) {

$fileList[] = $file;

}

}

closedir($handle);



if (count($fileList) > 0) {

$imageNumber = time() % count($fileList);

$img = $folder.$fileList[$imageNumber];

}

}



if ($img!=null) {

$imageInfo = pathinfo($img);

$contentType = 'Content-type: '.$extList[ $imageInfo['extension'] ];

header ($contentType);

readfile($img);

} else {

if ( function_exists('imagecreate') ) {

header ("Content-type: image/png");

$im = @imagecreate (100, 100)

or die ("Cannot initialize new GD image stream");

$background_color = imagecolorallocate ($im, 255, 255, 255);

$text_color = imagecolorallocate ($im, 0,0,0);

imagestring ($im, 2, 5, 5, "IMAGE ERROR", $text_color);

imagepng ($im);

imagedestroy($im);

}

}



?>







Merci d'avance

1 réponse

coockiesch Messages postés 2268 Date d'inscription mercredi 27 novembre 2002 Statut Membre Dernière intervention 13 septembre 2013 4
10 févr. 2005 à 12:50
Salut!

Pas trop le tps d'étudier le pb réellement mais le:

$extList = array(); >> ca vide pas le tableau? Tu devrais le mettre tout au début



$extList = array();

$extList['pdf'] = 'application/pdf';

$extList['css'] = 'text/css';

$extList['html'] = 'text/html';

$extList['htm'] = 'text/html';

$extList['gif'] = 'image/gif';

$extList['jpg'] = 'image/jpeg';

$extList['jpeg'] = 'image/jpeg';

$extList['png'] = 'image/png';

$extList['swf'] = 'application/swf';



@++



R@f



@++



R@f

www.allpotes.ch: Photos, humour, vidéos, gags, ...

"On dit que seulement 10 personnes au monde comprenaient Einstein. Personne ne me comprends. Suis-je un génie???"
0
Rejoignez-nous