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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
| <?php require_once('Connections/gsmusique.php'); ?>
<?php
$nb = (!isset($_POST['nb'])) ? null : $_POST['nb'];
$nom_comp = (!isset($_POST['nom_comp'])) ? "" : $_POST['nom_comp'];
$style_comp= (!isset($_POST['style_comp'])) ? "" : $_POST['style_comp'];
$tableaucomp=array();
$tableaucomp[0]=$nom_comp;
$tableaucomp[1]=NULL;
$tableaucomp[2]=NULL;
switch ($style_comp)
{
case "Latines":
$tableaucomp[1]=' checked="checked" ';
break;
case "Standard":
$tableaucomp[2]=' checked="checked" ';
break;
}
if ($nb)
{
$namecomp=$nom_comp." ".$style_comp;
$namecomp=ereg_replace(' ','-',$namecomp);
// création du répertoire
$dossier="musique/".$namecomp;
mkdir($dossier);
//création du fichier playlist
$fichierlist=$dossier."/playlist-".$namecomp.".wpl";
$fp= fopen($fichierlist,"a+");
$texteentete=
'<?wpl version="1.0"?>
<smil>
<head>
<title>'.$nom_comp.' '.$style_comp.'</title>
</head>
<body>
<seq>
';
fwrite ($fp, $texteentete);
// placement des fichiers son
for($k=1;$k<=$nb;$k++)
{
if(!isset($_FILES['musique'.$k])) $_FILES['musique'.$k]=""; else $_FILES['musique'.$k]=$_FILES['musique'.$k];
$musique_name=$_FILES['musique'.$k]['name'];
echo $musique_name;
if (substr($musique_name,-3)=="mp3")
{
$musique_name=$_POST['danse'.$k].".".$elts[1];
move_uploaded_file($_FILES['musique'.$k]['tmp_name'],$dossier."/".$musique_name);
$textemusique=' <media src="'.$musique_name.'"/>';
fwrite ($fp, $textemusique);
}
else
{
echo "<p><font color='red' size='+1'>La musique: $k n'est pas au bon format</font></p>";
}
}
//ecriture fin du fichier playlist puis fermeture
$textebaspage=
'
</seq>
</body>
</smil>
';
fwrite ($fp, $textebaspage);
fclose($fp);
// Insertion dans la base de donner
mysql_select_db($database_gsmusique, $connection_gsmusique);
$insert = "INSERT INTO playlist (nom_comp, style, playlist)
VALUES ('$nom_comp', '$style_comp', '$fichierlist')";
mysql_query($insert, $connection_gsmusique) or die(mysql_error());
mysql_close();
// header("Location: ../escpaceprive/gscoursv1_0.php");
exit();
}
else
{
?>
<table width="75%" border="1" >
<tr>
<td align="left" valign="top" ><p>
<table width="100%" border="0" align="" cellpadding="0" cellspacing="0" >
<tr height="2"></tr>
<tr>
<th width="100%" height="20"><div >
<div align="center">Ajout d'une compétition</div>
</div></th>
</tr>
<form name="formulaire" method="post" action="ajout.php">
<table width="100%" border="0" align="center" cellpadding="1" cellspacing="3">
<tr>
<td width="40%" align="right"><strong>Nom du comp :</strong></td>
<td width="60%"><input name="nom_comp" type="text" id="nom_comp" value="<? echo $tableaucomp[0]; ?>"> </td>
</tr>
<tr>
<td></td>
<td><input name="style_comp" type="radio" value="Latines" <?php echo $tableaucomp[1]; ?> >Latine, ou <input name="style_comp" type="radio" value="Standard" <?php echo $tableaucomp[2]; ?> >Standard</td>
</tr>
<tr><td colspan="3" align="center">
<table width="80%" border="1"align="center"><tr><td align="center">
<?
$nbform=(!isset($_POST['nbform'])) ? null : $_POST['nbform'];
$style_comp= (!isset($_POST['style_comp'])) ? "" : $_POST['style_comp'];
$danse=array();
if($nbform)
{
switch ($style_comp)
{
case "Latines":
switch ($nbform)
{
case 1:
$danse[1]="à définir";
$activ=NULL;
break;
case 2:
$danse[1]="à définir";
$danse[2]="à définir";
$activ=NULL;
break;
case 3:
$danse[1]="Cha-Cha-Cha";
$danse[2]="Rumba";
$danse[3]="Jive";
$activ='disabled="disabled"';
break;
case 4:
$danse[1]="Samba";
$danse[2]="Cha-Cha-Cha";
$danse[3]="Rumba";
$danse[4]="Jive";
$activ='disabled="disabled"';
break;
case 5:
$danse[1]="Samba";
$danse[2]="Cha-Cha-Cha";
$danse[3]="Rumba";
$danse[4]="Paso-Doble";
$danse[5]="Jive";
$activ='disabled="disabled"';
break;
}
break;
case "Standard":
switch ($nbform)
{
case 1:
$danse[1]="à définir";
$activ=NULL;
break;
case 2:
$danse[1]="à définir";
$danse[2]="à définir";
$activ=NULL;
break;
case 3:
$danse[1]="Valse";
$danse[2]="Tango";
$danse[3]="Quick-Step";
$activ='disabled="disabled"';
break;
case 4:
$danse[1]="Valse";
$danse[2]="Tango";
$danse[3]="Slow-Fox";
$danse[4]="Quick-Step";
$activ='disabled="disabled"';
break;
case 5:
$danse[1]="Valse";
$danse[2]="Tango";
$danse[3]="Valse Viennoise";
$danse[4]="Slow-Fox";
$danse[5]="Quick-Step";
$activ='disabled="disabled"';
break;
}
break;
}
$i = 1;
echo "<input type=\"hidden\" name=\"nb\" value=".$nbform.">";
while($i <= $nbform)
{
echo '<tr><td align="center"><input type="file" name="musique'.$i.'"> <b>'.$i.'</b><sup>e</sup> Danse (<input type="text" name="danse'.$i.'" value="'.$danse[$i].'" '.$activ.'>)</td></tr>';
$i++;
}
}
else
{
echo"<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">
Nombre de danse:<input type=\"text\" name=\"nbform\" size=\"2\">
<input type=\"submit\" value=\"Générer\" class=\"mainoption\">
</form>";
}
?></td></tr></table>
</td></tr>
<tr>
<td colspan="2"><div align="center">
<input name="ajcours" type="hidden" id="ajcours" value="ok" />
<input name="ajout_comp" class="mainoption" type="submit" id="ajout_comp" value="Ajouter">
</div>
</td>
</tr>
</table>
</form> <?
}
?> |
Partager