<?php
/**
 * TODO :
 * - activer le safe_mode
 * - definir un open_basedir pour protéger le serveur (probleme avec l'activation du safe mode ???)
 * - trier les dossiers par date
 * -
 */

/* !! code a revoir, ne fonctionne pas !! */
/*
echo "safe_mode = ".ini_get('safe_mode');


if(ini_set('safe_mode',TRUE)){
		echo '[safe_mode modifié]';
}else{
		echo '[safe_mode non modifié]';

}

ini_set("open_basedir", "/home/www/documents/audio/");



// Check for safe mode
if( ini_get('safe_mode') ){
   // Do it the safe mode way
   echo "[safe mode activated]";

}else{
   // Do it the regular way
   echo "[safe mode non activated]";
}

*/
include_once('includes/functions.php');

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

    $BASE = rawurldecode($_GET['dir']);
    /*SECURITE*/
    if(!strstr($BASE, 'audio')) $BASE = "/home/www/documents/audio";
    /* SECURITE (evite de parcourir les repertoire en remontant via les .. */
    if(ereg('[..]',$BASE)) $BASE = "/home/www/documents/audio";

    /*affiche les infos du seminaire*/
    if(strstr(strtolower($BASE), 'regards')) $descrip = '/home/www/privatedoc/infors.htm';
    if(strstr(strtolower($BASE), 'lectures')) $descrip = '/home/www/privatedoc/infols.htm';
    if(strstr(strtolower($BASE), 'jugement')) $descrip = '/home/www/privatedoc/infojugement.htm';
    if(strstr(strtolower($BASE), 'modernite')) $descrip = '/home/www/privatedoc/infomodernite.htm';
    if(strstr(strtolower($BASE), 'pratique')) $descrip = '/home/www/privatedoc/infopratique.htm';
    if(strstr(strtolower($BASE), 'autres'))  $descrip = '';
}
else{
	/* racine */
    $BASE = "/home/www/documents/audio";
    $descrip = '';
}


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="description" content="Institut de rechcerche et d'innovation" />
    <title>Institut de Recherche et d'innovation</title>
    <link href="../res/css/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="js/prototype.js"></script>
    <script type="text/javascript" src="js/scriptaculous.js?load=effects"></script>
    <script type="text/javascript" src="js/swfobject.js"></script>
    <script type="text/javascript">
   // <![CDATA[

      // get our flash movie object
      var flashMovie;
      function init() {
         if (document.getElementById) {
            flashMovie = document.getElementById("mymovie");
         }
      }

      // wait for the page to fully load before initializing
      window.onload = init;

      // for updating media in the player
      function switchMedia(rep) {
         if (flashMovie) {
            var url = 'http://www.iri.centrepompidou.fr/documents/audio/'+rep;
            flashMovie.switchMedia(url, true);
         }
      }


   // ]]>
</script>
    </head>
  <body>

    <div>
      <a href="http://www.iri.centrepompidou.fr"><img src="../res/img/logo-iri-petit.png" class="logo" alt="Logo Iri" /></a>
    </div>

 <div id="layer1">
      <div id="layer2">
	        <h1><img src="../res/img/titre_iri.png" alt="Institut de Recherche et d'Innovation" /></h1>

            <div>
                <h2><img src="../res/img/consulter_doc.png" alt="Consulter les fonds"/></h2><br/>
				<p style="padding-right:250px;padding-left:10px;"><img src="img/help.png">
				Ce service de consultation met à disposition les
				enregistrements audio des séminaires et ateliers de l'IRI (en écoute et en téléchargement). Les enregistements sont classés par date et séminaire.</p>
			</div>
<table cellspacing="0" cellpadding="10" width="100%" style="border:1px solid #cccccc; font-size:12px;">
<?php
/* lien sur la racine */
if(!$dir) {


   $navig = substr($BASE,26);
   $navtab = explode('/', $navig);


   if($navtab[0] != '') $navLinked  = '<a href="javascript:history.go(-'.(count($navtab)).')">..</a> / ';

   $cpt=0;
   foreach($navtab as $link):

    $link = deInterCaps($link);
    $link = UtoWS($link);

   	if($cpt+1 == count($navtab)){

        $navLinked .= $link;
    }
    else{

        $navLinked .='<a href="javascript:history.go(-'.(count($navtab)-1).')">'.trim($link).'</a>';
    }
    if($cpt != (count($navtab)-1)) $navLinked .= ' / ';
    $cpt++;
   endforeach;

   echo "<tr><td colspan='2'><h3>".strtoupper($navLinked)."</h3></td></tr>";
}

?>

<tr><td style="vertical-align:top">


<?php
list_dir($BASE, rawurldecode($dir), 2);

/* répertoire initial à lister */
if(!$dir) {
  $dir = $BASE;
}

list_file(rawurldecode($dir));
?>

<td width="30%" align="center"  rowspan="2" style="vertical-align:top"><div id="flashcontent"></div></td>
</td>
</tr>


</table>
<?php if($descrip != ''):?>
<div style="font-size:11px; background-color:#ebebeb; margin-top:10px; padding-left:10px; padding-right:10px;line-height:17px; border:1px solid #cccccc"><?php include($descrip);?></div>
<?php endif;?>

<?php
if(strstr(strtolower($BASE),"regards")):
$date = ereg_replace("_",'',$navtab[count($navtab)-1]);
if(is_numeric($date)):
?>

<div id="moreinfo" style="display:none;">
<div><h2>documentation Wiki IRI</h2></div>
<br/><br/>
<div style="border:5px solid #CCCCCC">
<iframe src="http://www.iri.centrepompidou.fr/wiki/doku.php?id=college:seminaire_rs_<?=$date?>" width="100%" height="350px" marginheight="0" marginwidth="0" frameborder="0" scrolling="auto"></iframe>
</div>
</div>
<?php endif; endif;?>
         <br/>

                      <script type="text/javascript">
                       var so = new SWFObject("media/mp3player.swf", "mymovie", "340", "157", "8.0.5", "#ffffff", true);
                       so.addParam("quality", "high");
                       so.addParam("wmode", "transparent");
                       so.addParam("salign", "lt");
                       so.addVariable("extDrag", false);
                       so.write("flashcontent");
                     </script>

            </div>

    </div>
</body>
</html>
