1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Modification fichier xml</title>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
//********************************************************************************************************
//génération XML
//********************************************************************************************************
$xml_upload = "../images/galerie/";
//on ouvre le repertoire
$pointeur = opendir($xml_upload);
$i = 0;
$filename = '../albuminfo.xml';
$newContent = "<artworkinfo>";
//on les stocke les noms de fichiers images dans un tableau
while ($fichier = readdir($pointeur))
{
if (substr($fichier, -3) == "gif" || substr($fichier, -3) == "jpg" || substr($fichier, -3) == "png" || substr($fichier, -4) == "jpeg" || substr($fichier, -3) == "PNG" || substr($fichier, -3) == "GIF" || substr($fichier, -3) == "JPG")
{
$chemin="images/galerie/".$fichier;
$newContent .= "<albuminfo><artLocation>".$chemin."</artLocation></albuminfo>";
}
}
$newContent .= "</artworkinfo>";
$content = file_get_contents($filename);
$newContent = str_replace($content, $newContent, $content);
$handle = fopen($filename, 'w');
fwrite($handle, $newContent);
fclose($handle);
if (fwrite) {
echo "Diaporama mis à jour";
}
?>
</body>
</html> |