Generates random php password from [0-9a-z] characters.
1 <?php echo base_convert(rand(0, PHP_INT_MAX) . rand(0, PHP_INT_MAX), 10, 36);
upload image (et thumbnail si on fournis une largeur pour le thumbnail (3e argument))
1 function uploadImage($fichier,$largeurImage, $largeurThumbnail = null)
2 {
3 if (isset ($fichier)){
4 $imagename = $fichier['name'];
5 $source = $fichier['tmp_name'];
6 $target = "../img/".$imagename;
7 move_uploaded_file($source, $target);
8
9 $imagepath = $imagename;
10 $save = "../img/" . $imagepath; //This is the new file you saving
11 $file = "../img/" . $imagepath; //This is the original file
12
13 list($width, $height) = getimagesize($file) ;
14
15 $modwidth = $largeurImage; // taille image grande
16
17 $diff = $width / $modwidth;
18
19 $modheight = $height / $diff;
20
21 $tn = imagecreatetruecolor($modwidth, $modheight) ;
22 $image = imagecreatefromjpeg($file) ;
23 imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
24
25 imagejpeg($tn, $save, 100) ;
26
27 $save = "../img/sml_" . $imagepath; //This is the new file you saving
28 $file = "../img/" . $imagepath; //This is the original file
29
30 list($width, $height) = getimagesize($file) ;
31
32 $modwidth = $largeurThumbnail; // taille thumbnail
33 if( $largeurThumbnail){
34 $diff = $width / $modwidth;
35
36 $modheight = $height / $diff;
37 $tn = imagecreatetruecolor($modwidth, $modheight) ;
38 $image = imagecreatefromjpeg($file) ;
39 imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
40
41 imagejpeg($tn, $save, 100) ;
42 }
43
44 //echo "Large image: <img src='img/".$imagepath."'><br>";
45 //echo "Thumbnail: <img src='img/sml_".$imagepath."'>";
46
47 return $imagename;
48 }
49 }
prends en paramètre un INT du mois, et retourne un String du mois correspondant
1 function getFrenchMonthByInt($mois)
2 {
3 $arrayMois = array( 1=>'Janvier',
4 2=>'Février',
5 3=>'Mars',
6 4=>'Avril',
7 5=>'Mai',
8 6=>'Juin',
9 7=>'Juillet',
10 8=>'Août',
11 9=>'Septembre',
12 10=>'Octobre',
13 11=>'Novembre',
14 12=>'Décembre'
15 );
16
17 return $arrayMois[$mois];
18 }
retourne un array : [0] => année , [1] => mois , [2] => jour, [3] => heure, [4]=>minute, [5]=>seconde
1 function datetimeToArray($dateTimeString)
2 {
3 $dateArray= explode(' ', $dateTimeString); // exploser pour prendre juste la date
4 $date = $dateArray[0];
5 $heure= $dateArray[1];
6
7 $date= explode('-', $date); // exploser pour prendre chacune des 3 parties de la date
8 $heure= explode(':', $heure);
9
10 $dateTimeArray= array_merge($date,$heure);
11 return $dateTimeArray;
12 }
convertir les années/mois/jour (et peut-être heure et minutes) en format DateTime pour MySQL retourne un String
1 function convertDateTime($annee, $mois, $jour, $heure=null, $minute=null)
2 {
3 if($heure){
4 return $annee."-".$mois."-".$jour." ".$heure.":".$minute.":01";
5 }else{
6 return $annee."-".$mois."-".$jour." 01:01:01";
7 }
8 }
echo des select de dates et heures, (année, mois, jour, heure, minute)
1 function selectDateHeure($annee = null, $mois = null, $jour = null, $heure=null, $minute=null){
2
3 if($annee){
4 selectDate($annee,$mois,$jour);
5 }else{
6 selectDate();
7 }
8 echo " ";
9 echo '<select name="heure" id="EvenementDateHour">
10 <option value="" > </option>';
11
12 //heure
13 for($i=0; $i<24; $i++)
14 {
15 if($heure !=null && $heure == $i)
16 {
17 if($i<10){
18 echo "<option value='0".$i;
19 }else{
20 echo "<option value='".$i;
21 }
22 echo "' selected='selected' >".$i."</option>";
23
24 }else{
25 if($i<10){
26 echo "<option value='0".$i;
27 }else{
28 echo "<option value='".$i;
29 }
30 echo "' >".$i."</option>";
31 }
32 }
33
34 echo '</select> : <select name="minute" id="EvenementDateMinute">
35 <option value="" > </option>';
36
37 //mois
38 for($i=1; $i<60; $i++)
39 {
40 if($minute !=null && $minute == $i)
41 {
42 if($i<10){
43 echo "<option value='0".$i;
44 }else{
45 echo "<option value='".$i;
46 }
47 echo "' selected='selected' >".$i."</option>";
48 }else{
49 if($i<10){
50 echo "<option value='0".$i;
51 }else{
52 echo "<option value='".$i;
53 }
54 echo "' >".$i."</option>";
55 }
56 }
57
58 echo '</select>';
59 }
echo des select de dates, (année, mois, jour)
1 function selectDate($annee = null, $mois = null, $jour = null){
2
3 echo '<select name="annee" id="EvenementDateYear">
4 <option value="" > </option>';
5
6 //année
7 for($i=2025; $i>1948; $i--)
8 {
9 if($annee !=null && $annee == $i)
10 {
11 echo "<option value='".$i."' selected='selected' >".$i."</option>";
12 }else{
13 echo "<option value='".$i."' >".$i."</option>";
14 }
15 }
16
17 echo '</select> - <select name="mois" id="EvenementDateMonth">
18 <option value="" > </option>';
19
20 //mois
21 $moisString= array('Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre');
22 for($i=1; $i<13; $i++)
23 {
24 if($mois !=null && $mois == $i)
25 {
26 if($i<10){
27 echo "<option value='0".$i;
28 }else{
29 echo "<option value='".$i;
30 }
31 echo "' selected='selected' >".$moisString[$i-1]."</option>";
32 }else{
33 if($i<10){
34 echo "<option value='0".$i;
35 }else{
36 echo "<option value='".$i;
37 }
38 echo "' >".$moisString[$i-1]."</option>";
39 }
40 }
41
42 echo '</select> - <select name="jour" id="EvenementDateDay">
43 <option value="" > </option>';
44
45 //jour
46
47 for($i=1; $i<32; $i++)
48 {
49 if($jour !=null && $jour == $i)
50 {
51 if($i<10){
52 echo "<option value='0".$i;
53 }else{
54 echo "<option value='".$i;
55 }
56 echo "' selected='selected' >".$i."</option>";
57 }else{
58 if($i<10){
59 echo "<option value='0".$i;
60 }else{
61 echo "<option value='".$i;
62 }
63 echo "' >".$i."</option>";
64 }
65 }
66
67 echo '</select>';
68 }
printer un array
1 function pr($argument) {
2 echo "<pre>";
3 print_r($argument);
4 echo "</pre>";
5 }
CLI PHP script that outputs files based on vocals part information in Rock Band MIDI files.
1 #!php
2 <?php
3
4 error_reporting(E_ALL);
5 require('./classes/midi.class.php');
6
7
8 function processFile($file, $options) {
9 $midi = new Midi();
10 $midi->importMid($file);
11 $track = $midi->getTrack(0);
12 // Find track name so we can rename output file
13 foreach ($track as $msgStr){
14 $msg = explode(' ',$msgStr);
15 if ($msg[1]=='Meta'&&$msg[2]=='TrkName') {
16 $newname = substr($msgStr,strpos($msgStr,'"')+1,-1);
17 if ($options['verbose']) echo "$file -> $newname\n";
18 }
19 }
20 if (!isset($newname)) {
21 echo "No Track 0 Meta TrkName for $file - is it a Rock Band MIDI?\n"; exit(1);
22 }
23 $midi->soloTrack(4); // delete all non-vocal tracks, leaving track 1
24 $midi->newTrack(); // add a track for percussion (returns wrong number, but I know it's track 2)
25 $ch = 'ch=4'; // mostly channel 4 is used, overwrite with what we find later
26 $lyrics = array(); $notes = array();
27 $slides = array(); $slide = false;
28 $notelist = $midi->getNoteList();
29 foreach ($notelist as $k=>$v) {
30 $notelist[$k] = substr($v,0,1); // remove octave number
31 if (strlen($v)==3) $notelist[$k] .= '#'; // # looks a bit like a talky, but I don't like s for sharp
32 }
33 $mc = $midi->getMsgCount(1);
34 for ($i=0; $i<$mc; $i++) {
35 $msg = explode(' ',$midi->getMsg(1,$i));
36 if ($msg[1]=='Meta') {
37 if ($msg[2]=='Text' && substr($msg[3],1,1)=='[') {
38 // Delete all Meta Text that starts with '[',
39 // it breaks many MIDI parsers and we're not interested in it
40 $midi->deleteMsg(1,$i);
41 $i--;
42 $mc--;
43 } else if ($msg[2]=='Text' || $msg[2]=='Lyric') {
44 $l = substr($msg[3],1,-1);
45 $lyrics[] = $l;
46 if ($l=='+') {
47 $slide = count($lyrics)-1;
48 }
49 }
50 } else if ($msg[1]=='On'){
51 $ch = $msg[2];
52 $n = substr($msg[3],2)+0;
53 if ($n<36 || $n>95) { // not a musical note
54 $midi->deleteMsg(1,$i);
55 $i--;
56 $mc--;
57 if ($n==96) {
58 $msg[2]='ch=10'; // MIDI percussion channel
59 $msg[3]=$options['midi_percussion'];
60 $midi->addMsg(2, implode(' ',$msg));
61 } else if (($n==105 || $n==106) &&
62 $msg[4]=='v=0' && (count($lyrics)==0 ||
63 substr($lyrics[count($lyrics)-1],-1,1)!="\n")) {
64 // Ignore Player 1/2 info, just start a new phrase here
65 $lyrics[] = "\n";
66 $notes[] = "\n";
67 }
68 } else if (substr($msg[4],2) > 0) { // musical note on
69 $msg[4]=='v=127';
70 $midi->tracks[1][$i] = implode(' ',$msg);
71 $notes[] = $n;
72 } else { // musical note off
73 $lastofftime = $msg[0]+0;
74 $lastoffnote = $n;
75 }
76 }
77 if ($options['enable_slides'] && $slide && count($notes)-1 >= $slide) {
78 $slides[] = array($lastofftime, $lastoffnote, $msg[0], $notes[$slide]);
79 $slide = false;
80 }
81 }
82
83
84 if ($options['enable_txt']) {
85 $txtl =''; $txtn=''; $txt='';
86 foreach ($lyrics as $k=>$l) {
87 if ($l!="\n") {
88 $mod = substr($l,-1,1);
89 if ($mod=='#' || $mod=='^' || $mod=='*') {
90 // Known talkie part.
91 // Show modifier symbol in place of note instead of in lyric.
92 $l = substr($l,0,-1);
93 $n = $mod;
94 if (substr($l,-1,1)!='-') {
95 $l .= ' ';
96 }
97 } else {
98 // Leave unknown symbols like = and % in lyric for now
99 if ($mod != '-') {
100 $l = $l.' ';
101 }
102 $n = $notelist[$notes[$k]];
103 }
104
105 if (strlen($l) > strlen($n)+1) {
106 $txtn .= str_pad($n,strlen($l),' ');
107 $txtl .= $l;
108 } else {
109 $txtn .= $n.' ';
110 $txtl .= str_pad($l,strlen($n)+1,' ');
111 }
112 } else {
113 $txt .= $txtn."\r\n".$txtl."\r\n\r\n";
114 $txtl =''; $txtn='';
115 }
116 }
117 $write = fopen($newname.'.txt', 'w');
118 fwrite($write, $txt);
119 fclose($write);
120 }
121 if ($options['enable_midi'] || $options['enable_midixml']) {
122 if ($options['enable_slides']) {
123 foreach ($slides as $g) {
124 $x0 = $g[0]; $y0 = $g[1];
125 $x1 = $g[2]; $y1 = $g[3];
126 if ($options['slide_type']=='glissando') {
127 $dx = $x1-$x0;
128 $dy = $y1-$y0;
129 if ($dx>0) {
130 $m = $dy/$dx;
131 $b = $y0-$m*$x0;
132 $lastnote = $y0;
133 $midi->insertMsg(1, "$x0 On $ch n=$y0 v=127");
134 while ($x0 != $x1) {
135 $x0++;
136 $y0 = round($m*$x0 + $b);
137 if (($m>0 && $y0 > $lastnote) || ($m<0 && $y0 < $lastnote)) {
138 $midi->insertMsg(1, ($x0-1+1)." On $ch n=$lastnote v=0");
139 $midi->insertMsg(1, "$x0 On $ch n=$y0 v=127");
140 $lastnote=$y0;
141 }
142 }
143 $midi->insertMsg(1, "$x1 On $ch n=$lastnote v=0");
144 }
145 } else if ($options['slide_type']=='portamento') {
146 $midi->insertMsg(1, "$x0 Par $ch c=65 v=127"); // portamento: on
147 $t = $x1-$x0; // almost certainly wrong calculation since 0 is the "slowest rate"
148 $midi->insertMsg(1, "$x0 Par $ch c=5 v=".(($t >> 7) & 0x7f)); // portamento time MSB
149 $midi->insertMsg(1, "$x0 Par $ch c=37 v=".($t & 0x7f)); // portamento time LSB
150 $midi->insertMsg(1, "$x0 On $ch n=$y0 v=127");
151 $midi->insertMsg(1, "$x1 On $ch n=$y0 v=0");
152 $midi->insertMsg(1, "$x0 On $ch n=$y1 v=127");
153 $midi->insertMsg(1, "$x1 On $ch n=$y1 v=0");
154 $midi->insertMsg(1, "$x0 Par $ch c=65 v=0"); // portamento: off
155 } else if ($options['slide_type']=='pitchbend') {
156 $midi->insertMsg(1, "$x0 On $ch n=$y0 v=127");
157 $midi->insertMsg(1, "$x1 On $ch n=$y0 v=0");
158 // TODO lots of carefully timed pitch bend instructions (these are very wrong)
159 /* 0x2000 is center position
160 * 0x0000 is two semitones down
161 * 0x3fff is two semitones up
162 */
163 $t = $x1-$x0;
164 for ($i=0; $i<$t; $i+=8) {
165 $midi->insertMsg(1, $i+$x0." Pb $ch v=".round(0x2000+0x1fff*($i/$t)));
166 }
167 $midi->insertMsg(1, "$x1 Pb $ch v=2000");
168 // TODO maybe combine with glissando? similar functionality needed for bigger intervals
169 }
170 }
171 }
172 $midi->insertMsg(1, "0 PrCh $ch ".$options['midi_instrument']);
173 if ($options['enable_midi']) {
174 $midi->saveMidFile($newname.'.mid');
175 }
176 if ($options['enable_midixml']) {
177 $write = fopen($newname.'.xml', 'w');
178 fwrite($write, $midi->getXml());
179 fclose($write);
180 }
181 }
182 }
183
184 function help($arg0) {
185 echo "Usage: $arg0 [OPTION]... [--files] [FILE]...\n";
186 ?>
187 Output files based on vocals part information in Rock Band MIDI files. Files are
188 created in the current directory and named based on information found in the
189 input file (for example, wontgetfooled_short.mid).
190
191 MIDI OPTIONS
192 --disable-midi don't output a standard MIDI file
193 --enable-midi do output a standard MIDI file (default)
194 --enable-midixml do output a MIDI XML file
195 --disable-midixml don't output a MIDI XML file (default)
196 --enable-slides add slides to the MIDI file where the game would have
197 diagonal note tubes (default)
198 --disable-slides don't add slides to the MIDI file where the game would
199 have diagonal note tubes
200 --slide-type=TYPE one of:
201 glissando (play every note in between) (default)
202 portamento (broken)
203 pitchbend (broken)
204 --midi-instrument=P MIDI instrument number between 1 and 128 for normal
205 notes (default is 81 Lead 1 (square), try 19 Rock Organ)
206 --midi_percussion=N MIDI percussion note between 0 and 127 for percussion
207 section (default is 39 Hand Clap, try 54 Tambourine or
208 56 Cowbell)
209
210 TEXT FILE OPTIONS
211 --enable-txt output a text file (default)
212 --disable-txt don't output a text file
213
214 OTHER OPTIONS
215 --verbose do show some file info while processing (default)
216 --quiet don't show some file info while processing
217 --help show this help
218 --files the remainder of the paramaters are input filenames
219 (optional, not normally needed)
220 <?php
221 exit(0);
222 }
223
224 function processArguments($argv) {
225 //default options:
226 $options['enable_midi'] = true;
227 $options['enable_txt'] = true;
228 $options['enable_midixml'] = false;
229 $options['midi_instrument'] = 'p=80'; // 80=Lead 1 (square), 18=Rock Organ
230 $options['midi_percussion'] = 'n=39'; // 39=hand clap, 54=tambourine, 56=cowbell)
231 $options['enable_slides'] = true;
232 $options['slide_type'] = 'glissando';
233 $options['verbose'] = true;
234
235 $processingOptions = true;
236 if (count($argv)==1) help($argv[0]);
237 $args = array_slice($argv,1);
238 foreach ($args as $arg) {
239 if ($processingOptions) {
240 if (substr($arg,0,1)=='-') {
241 if ($arg=='--disable-midi') {
242 $options['enable_midi'] = false;
243 } else if ($arg=='--enable-midi') {
244 $options['enable_midi'] = true;
245 } else if ($arg=='--disable-txt') {
246 $options['enable_txt'] = false;
247 } else if ($arg=='--enable-txt') {
248 $options['enable_txt'] = true;
249 } else if ($arg=='--disable-midixml') {
250 $options['enable_midixml'] = false;
251 } else if ($arg=='--enable-midixml') {
252 $options['enable_midixml'] = true;
253 } else if ($arg=='--enable-slides') {
254 $options['enable_slides'] = false;
255 } else if ($arg=='--disable-slides') {
256 $options['enable_slides'] = true;
257 } else if ($arg=='--verbose') {
258 $options['verbose'] = true;
259 } else if ($arg=='--quiet') {
260 $options['verbose'] = false;
261 } else if (substr($arg,0,13)=='--slide-type=') {
262 $options['slide_type'] = substr($arg,13);
263 } else if (substr($arg,0,18)=='--midi-instrument=') {
264 $p = substr($arg,18)-1;
265 if ($p>=1 && $p<=128) {
266 $options['midi_instrument'] = "p=$p";
267 } else {
268 echo "MIDI instrument should be between 1 and 128.\n"; exit(1);
269 }
270 } else if (substr($arg,0,18)=='--midi-percussion=') {
271 $n = substr($arg,18);
272 if ($n>=0 && $n<=127) {
273 $options['percussion'] = "n=$n";
274 } else {
275 echo "MIDI percussion note should be between 0 and 127.\n"; exit(1);
276 }
277 } else if ($arg=='--help') {
278 help($argv[0]);
279 } else if ($arg=='--files') {
280 $processingOptions = false;
281 }
282 } else {
283 $processingOptions = false;
284 processFile($arg, $options);
285 }
286 } else {
287 processFile($arg, $options);
288 }
289 }
290 }
291
292
293
294
295
296
297
298 // Main entry
299
300
301 processArguments($argv);
302 ?>
no
1 * The selected file themes/garland/minnelli/../images/menu-collapsed.gif could not be uploaded, because the destination is not properly configured.
2 * The selected file themes/garland/minnelli/../images/menu-collapsed-rtl.gif could not be uploaded, because the destination is not properly configured.
3 * The selected file themes/garland/minnelli/../images/menu-expanded.gif could not be uploaded, because the destination is not properly configured.
4 * The selected file themes/garland/minnelli/../images/menu-leaf.gif could not be uploaded, because the destination is not properly configured.
5 * warning: imagepng() [function.imagepng]: Unable to open 'sites/default/files/color/minnelli-91fcc727/body.png' for writing: No such file or directory in /var/www/vhosts/studiodimartella.it/httpdocs/modules/color/color.module on line 502.
6 * warning: imagepng() [function.imagepng]: Unable to open 'sites/default/files/color/minnelli-91fcc727/bg-bar.png' for writing: No such file or directory in /var/www/vhosts/studiodimartella.it/httpdocs/modules/color/color.module on line 502.
7 * warning: imagepng() [function.imagepng]: Unable to open 'sites/default/files/color/minnelli-91fcc727/bg-bar-white.png' for writing: No such file or directory in /var/www/vhosts/studiodimartella.it/httpdocs/modules/color/color.module on line 502.
8 * warning: imagepng() [function.imagepng]: Unable to open 'sites/default/files/color/minnelli-91fcc727/bg-tab.png' for writing: No such file or directory in /var/www/vhosts/studiodimartella.it/httpdocs/modules/color/color.module on line 502.
9 * warning: imagepng() [function.imagepng]: Unable to open 'sites/default/files/color/minnelli-91fcc727/bg-navigation.png' for writing: No such file or directory in /var/www/vhosts/studiodimartella.it/httpdocs/modules/color/color.module on line 502.
10 * warning: imagepng() [function.imagepng]: Unable to open 'sites/default/files/color/minnelli-91fcc727/bg-content-left.png' for writing: No such file or directory in /var/www/vhosts/studiodimartella.it/httpdocs/modules/color/color.module on line 502.
11 * warning: imagepng() [function.imagepng]: Unable to open 'sites/default/files/color/minnelli-91fcc727/bg-content-right.png' for writing: No such file or directory in /var/www/vhosts/studiodimartella.it/httpdocs/modules/color/color.module on line 502.
12 * warning: imagepng() [function.imagepng]: Unable to open 'sites/default/files/color/minnelli-91fcc727/bg-content.png' for writing: No such file or directory in /var/www/vhosts/studiodimartella.it/httpdocs/modules/color/color.module on line 502.
13 * warning: imagepng() [function.imagepng]: Unable to open 'sites/default/files/color/minnelli-91fcc727/bg-navigation-item.png' for writing: No such file or directory in /var/www/vhosts/studiodimartella.it/httpdocs/modules/color/color.module on line 502.
14 * warning: imagepng() [function.imagepng]: Unable to open 'sites/default/files/color/minnelli-91fcc727/bg-navigation-item-hover.png' for writing: No such file or directory in /var/www/vhosts/studiodimartella.it/httpdocs/modules/color/color.module on line 502.
15 * warning: imagepng() [function.imagepng]: Unable to open 'sites/default/files/color/minnelli-91fcc727/gradient-inner.png' for writing: No such file or directory in /var/www/vhosts/studiodimartella.it/httpdocs/modules/color/color.module on line 502.
16 * warning: imagepng() [function.imagepng]: Unable to open 'sites/default/files/color/minnelli-91fcc727/logo.png' for writing: No such file or directory in /var/www/vhosts/studiodimartella.it/httpdocs/modules/color/color.module on line 502.
17 * warning: imagepng() [function.imagepng]: Unable to open 'sites/default/files/color/minnelli-91fcc727/screenshot.png' for writing: No such file or directory in /var/www/vhosts/studiodimartella.it/httpdocs/modules/color/color.module on line 502.
18 * The selected file /var/www/vhosts/studiodimartella.it/httpdocs/files/tmp/filedxtI0x could not be uploaded, because the destination is not properly configured.
19 * The selected file /var/www/vhosts/studiodimartella.it/httpdocs/files/tmp/fileVAj1Cv could not be uploaded, because the destination is not properly configured.