/[dtapublic]/to_be_filed/webprojs/php_libraries/php_library/bgsound/bgsound.inc
ViewVC logotype

Annotation of /to_be_filed/webprojs/php_libraries/php_library/bgsound/bgsound.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 35 - (hide annotations) (download)
Sat Oct 8 23:35:33 2016 UTC (7 years, 9 months ago) by dashley
File size: 36488 byte(s)
Initial commit.
1 dashley 35 <?php
2     //********************************************************************************
3     //Copyright (C) 2005 David T. Ashley
4     //********************************************************************************
5     //This program or source file is free software; you can redistribute it and/or
6     //modify it under the terms of the GNU General Public License as published by
7     //the Free Software Foundation; either version 2 of the License, or (at your
8     //option) any later version.
9     //
10     //This program or source file is distributed in the hope that it will
11     //be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
12     //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13     //GNU General Public License for more details.
14     //
15     //You may have received a copy of the GNU General Public License
16     //along with this program; if not, write to the Free Software
17     //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18     //********************************************************************************
19     //
20     //Dave Ashley, 10/05
21     //
22     //This file defines operations involving web page background sounds.
23     //
24     //
25     //Returns 1 if strings have at least one character in common, 0 otherwise.
26     //
27     function BGSOUND_string_intersection($s1, $s2)
28     {
29     $len1 = strlen($s1);
30     $len2 = strlen($s2);
31     for ($i1 = 0; $i1 < $len1; $i1 ++)
32     {
33     for ($i2 = 0; $i2 < $len2; $i2++)
34     {
35     if (substr($s1, $i1, 1) == substr($s2, $i2, 1))
36     {
37     return(1);
38     }
39     }
40     }
41    
42     return(0);
43     }
44    
45    
46     //Returns, as an array, the full collection of available sounds that meet
47     //the passed search criteria.
48     //
49     function BGSOUND_bgsound_search_db(
50     $cleanliness,
51     //String with attributes. Multiple attributes may/must be included.
52     //So, for example, to return clean and gray sounds, one must specify
53     //"CG" or "GC".
54     //
55     // C : Clean.
56     // G : Gray.
57     // D : Dirty.
58     // A : All.
59     //
60     $topic,
61     //Same rules for multiple selections as above.
62     //
63     // S : Science fiction.
64     // E : Engineer jokes.
65     // G : General humor.
66     // N : General notoriety.
67     // A : All.
68     //
69     $minsize,
70     //Minimum size, in kilobytes, that the .WAV file may be.
71     //
72     $maxsize,
73     //Maximum size, in kilobytes, that the .WAV file may be.
74     //Zero here means no upper limit.
75     //
76     &$dbsounds_total
77     //The total number of sounds in the database.
78     )
79     {
80     //Define the master table containing all sounds, and their characterisitics.
81     $sounds = array(
82     //-----------------------------------------------------
83     "C",
84     "S",
85     36,
86     "/gensounds/2001_space_odyssey/afault.wav",
87     "<i>2001: A Space Odyssey</i>",
88     //-----------------------------------------------------
89     "C",
90     "S",
91     72,
92     "/gensounds/2001_space_odyssey/afraid.wav",
93     "<i>2001: A Space Odyssey</i>",
94     //-----------------------------------------------------
95     "C",
96     "S",
97     103,
98     "/gensounds/2001_space_odyssey/airlock.wav",
99     "<i>2001: A Space Odyssey</i>",
100     //-----------------------------------------------------
101     "C",
102     "S",
103     47,
104     "/gensounds/2001_space_odyssey/cantdo.wav",
105     "<i>2001: A Space Odyssey</i>",
106     //-----------------------------------------------------
107     "C",
108     "S",
109     67,
110     "/gensounds/2001_space_odyssey/cropped.wav",
111     "<i>2001: A Space Odyssey</i>",
112     //-----------------------------------------------------
113     "C",
114     "S",
115     762,
116     "/gensounds/2001_space_odyssey/monolith2001.wav",
117     "<i>2001: A Space Odyssey</i>",
118     //-----------------------------------------------------
119     "C",
120     "S",
121     121,
122     "/gensounds/2001_space_odyssey/stress2001.wav",
123     "<i>2001: A Space Odyssey</i>",
124     //-----------------------------------------------------
125     "C",
126     "N",
127     338,
128     "/gensounds/analyze_this/barnes.wav",
129     "<i>Analyze This!</i>",
130     //-----------------------------------------------------
131     "G",
132     "N",
133     287,
134     "/gensounds/analyze_this/deadnote.wav",
135     "<i>Analyze This!</i>",
136     //-----------------------------------------------------
137     "C",
138     "N",
139     106,
140     "/gensounds/analyze_this/fishing.wav",
141     "<i>Analyze This!</i>",
142     //-----------------------------------------------------
143     "G",
144     "N",
145     387,
146     "/gensounds/analyze_this/getalife.wav",
147     "<i>Analyze This!</i>",
148     //-----------------------------------------------------
149     "C",
150     "N",
151     119,
152     "/gensounds/analyze_this/hearno.wav",
153     "<i>Analyze This!</i>",
154     //-----------------------------------------------------
155     "C",
156     "N",
157     127,
158     "/gensounds/analyze_this/nodoctor.wav",
159     "<i>Analyze This!</i>",
160     //-----------------------------------------------------
161     "C",
162     "N",
163     161,
164     "/gensounds/analyze_this/scotch.wav",
165     "<i>Analyze This!</i>",
166     //-----------------------------------------------------
167     "C",
168     "N",
169     246,
170     "/gensounds/analyze_this/restrain.wav",
171     "<i>Analyze This!</i>",
172     //-----------------------------------------------------
173     "C",
174     "N",
175     118,
176     "/gensounds/analyze_this/video.wav",
177     "<i>Analyze This!</i>",
178     //-----------------------------------------------------
179     "C",
180     "N",
181     75,
182     "/gensounds/as_good_as_it_gets/bettrman.wav",
183     "<i>As Good As It Gets</i>",
184     //-----------------------------------------------------
185     "C",
186     "N",
187     130,
188     "/gensounds/as_good_as_it_gets/boyfriend.wav",
189     "<i>As Good As It Gets</i>",
190     //-----------------------------------------------------
191     "C",
192     "N",
193     120,
194     "/gensounds/as_good_as_it_gets/stories.wav",
195     "<i>As Good As It Gets</i>",
196     //-----------------------------------------------------
197     "C",
198     "G",
199     128,
200     "/gensounds/austin_powers/angry.wav",
201     "The <i>Austin Powers</i> series of films",
202     //-----------------------------------------------------
203     "C",
204     "G",
205     38,
206     "/gensounds/austin_powers/beat_drevil.wav",
207     "The <i>Austin Powers</i> series of films",
208     //-----------------------------------------------------
209     "C",
210     "G",
211     23,
212     "/gensounds/austin_powers/bigglesworth.wav",
213     "The <i>Austin Powers</i> series of films",
214     //-----------------------------------------------------
215     "C",
216     "G",
217     56,
218     "/gensounds/austin_powers/failure.wav",
219     "The <i>Austin Powers</i> series of films",
220     //-----------------------------------------------------
221     "C",
222     "G",
223     31,
224     "/gensounds/austin_powers/get_ap.wav",
225     "The <i>Austin Powers</i> series of films",
226     //-----------------------------------------------------
227     "C",
228     "G",
229     27,
230     "/gensounds/austin_powers/grr_baby.wav",
231     "The <i>Austin Powers</i> series of films",
232     //-----------------------------------------------------
233     "C",
234     "G",
235     49,
236     "/gensounds/austin_powers/lair.wav",
237     "The <i>Austin Powers</i> series of films",
238     //-----------------------------------------------------
239     "C",
240     "G",
241     92,
242     "/gensounds/austin_powers/mrevil.wav",
243     "The <i>Austin Powers</i> series of films",
244     //-----------------------------------------------------
245     "C",
246     "G",
247     43,
248     "/gensounds/austin_powers/swingerr.wav",
249     "The <i>Austin Powers</i> series of films",
250     //-----------------------------------------------------
251     "C",
252     "G",
253     56,
254     "/gensounds/austin_powers/trillions.wav",
255     "The <i>Austin Powers</i> series of films",
256     //-----------------------------------------------------
257     "C",
258     "G",
259     38,
260     "/gensounds/austin_powers/ugly_stick.wav",
261     "The <i>Austin Powers</i> series of films",
262     //-----------------------------------------------------
263     "C",
264     "G",
265     20,
266     "/gensounds/austin_powers/yeahbaby.wav",
267     "The <i>Austin Powers</i> series of films",
268     //-----------------------------------------------------
269     "C",
270     "G",
271     149,
272     "/gensounds/austin_powers/zipit.wav",
273     "The <i>Austin Powers</i> series of films",
274     //-----------------------------------------------------
275     "C",
276     "H",
277     87,
278     "/gensounds/aviation_accidents/dl191_short.wav",
279     "The last moments of Delta Air Lines Flight 191 (black box recording); " .
280     "which crashed due to wind shear on August 2, 1985 in Dallas, Texas; " .
281     "killing 136 people in the aircraft and one on the ground</i>",
282     //-----------------------------------------------------
283     "C",
284     "G",
285     93,
286     "/gensounds/blues_brothers/106miles.wav",
287     "<i>The Blues Brothers</i>",
288     //-----------------------------------------------------
289     "C",
290     "G",
291     104,
292     "/gensounds/carlin_pa/500islands.wav",
293     "George Carlin, <i>Parental Advisory</i>",
294     //-----------------------------------------------------
295     "C",
296     "G",
297     117,
298     "/gensounds/carlin_pa/dad_drink_more.wav",
299     "George Carlin, <i>Parental Advisory</i>",
300     //-----------------------------------------------------
301     "C",
302     "G",
303     88,
304     "/gensounds/carlin_pa/grand_canyon_yoyo.wav",
305     "George Carlin, <i>Parental Advisory</i>",
306     //-----------------------------------------------------
307     "C",
308     "G",
309     94,
310     "/gensounds/carlin_pa/leave_me_alone.wav",
311     "George Carlin, <i>Parental Advisory</i>",
312     //-----------------------------------------------------
313     "C",
314     "G",
315     79,
316     "/gensounds/carlin_pa/rape_is_funny.wav",
317     "George Carlin, <i>Parental Advisory</i>",
318     //-----------------------------------------------------
319     "C",
320     "G",
321     187,
322     "/gensounds/carlin_pa/rr_tracks.wav",
323     "George Carlin, <i>Parental Advisory</i>",
324     //-----------------------------------------------------
325     "C",
326     "G",
327     88,
328     "/gensounds/carlin_pa/stupid_half.wav",
329     "George Carlin, <i>Parental Advisory</i>",
330     //-----------------------------------------------------
331     "C",
332     "N",
333     79,
334     "/gensounds/godfather/blood.wav",
335     "<i>The Godfather</i>",
336     //-----------------------------------------------------
337     "C",
338     "N",
339     77,
340     "/gensounds/godfather/fishes.wav",
341     "<i>The Godfather</i>",
342     //-----------------------------------------------------
343     "C",
344     "N",
345     194,
346     "/gensounds/godfather/goomba.wav",
347     "<i>The Godfather</i>",
348     //-----------------------------------------------------
349     "C",
350     "N",
351     25,
352     "/gensounds/godfather/offer.wav",
353     "<i>The Godfather</i>",
354     //-----------------------------------------------------
355     "C",
356     "N",
357     489,
358     "/gensounds/godfather/peace.wav",
359     "<i>The Godfather</i>",
360     //-----------------------------------------------------
361     "C",
362     "N",
363     148,
364     "/gensounds/godfather/someday.wav",
365     "<i>The Godfather</i>",
366     //-----------------------------------------------------
367     "C",
368     "N",
369     361,
370     "/gensounds/godfather/sonny.wav",
371     "<i>The Godfather</i> (from the famous scene where Sonny [James Caan] is gunned down at the tollbooth)",
372     //-----------------------------------------------------
373     "C",
374     "E",
375     294,
376     "/gensounds/humorous/thenack.wav",
377     "Unknown",
378     //-----------------------------------------------------
379     "C",
380     "N",
381     38,
382     "/gensounds/movie_top_gun/ego.wav",
383     "<i>Top Gun</i>",
384     //-----------------------------------------------------
385     "C",
386     "N",
387     333,
388     "/gensounds/pulp_fiction/bible_passage.wav",
389     "<i>Pulp Fiction</i>",
390     //-----------------------------------------------------
391     "G",
392     "N",
393     136,
394     "/gensounds/pulp_fiction/big_brain_brett_long.wav",
395     "<i>Pulp Fiction</i>",
396     //-----------------------------------------------------
397     "C",
398     "N",
399     7,
400     "/gensounds/pulp_fiction/big_brain_brett_short.wav",
401     "<i>Pulp Fiction</i>",
402     //-----------------------------------------------------
403     "G",
404     "N",
405     119,
406     "/gensounds/pulp_fiction/bowl_of_rice.wav",
407     "<i>Pulp Fiction</i>",
408     //-----------------------------------------------------
409     "G",
410     "N",
411     26,
412     "/gensounds/pulp_fiction/chill_them_out.wav",
413     "<i>Pulp Fiction</i>",
414     //-----------------------------------------------------
415     "G",
416     "N",
417     294,
418     "/gensounds/pulp_fiction/dn_storage.wav",
419     "<i>Pulp Fiction</i>",
420     //-----------------------------------------------------
421     "G",
422     "N",
423     6,
424     "/gensounds/pulp_fiction/english_short.wav",
425     "<i>Pulp Fiction</i>",
426     //-----------------------------------------------------
427     "G",
428     "N",
429     325,
430     "/gensounds/pulp_fiction/europe_little_differences.wav",
431     "<i>Pulp Fiction</i>",
432     //-----------------------------------------------------
433     "G",
434     "N",
435     7,
436     "/gensounds/pulp_fiction/fatman.wav",
437     "<i>Pulp Fiction</i>",
438     //-----------------------------------------------------
439     "G",
440     "N",
441     196,
442     "/gensounds/pulp_fiction/fonzie_is_cool.wav",
443     "<i>Pulp Fiction</i>",
444     //-----------------------------------------------------
445     "C",
446     "N",
447     20,
448     "/gensounds/pulp_fiction/gimp.wav",
449     "<i>Pulp Fiction</i>",
450     //-----------------------------------------------------
451     "G",
452     "N",
453     86,
454     "/gensounds/pulp_fiction/guy_foot_massage.wav",
455     "<i>Pulp Fiction</i>",
456     //-----------------------------------------------------
457     "C",
458     "N",
459     43,
460     "/gensounds/pulp_fiction/hamburger.wav",
461     "<i>Pulp Fiction</i>",
462     //-----------------------------------------------------
463     "G",
464     "N",
465     142,
466     "/gensounds/pulp_fiction/jules_quitting.wav",
467     "<i>Pulp Fiction</i>",
468     //-----------------------------------------------------
469     "G",
470     "N",
471     271,
472     "/gensounds/pulp_fiction/marvin_shot.wav",
473     "<i>Pulp Fiction</i>",
474     //-----------------------------------------------------
475     "G",
476     "N",
477     338,
478     "/gensounds/pulp_fiction/medieval_long.wav",
479     "<i>Pulp Fiction</i>",
480     //-----------------------------------------------------
481     "G",
482     "N",
483     289,
484     "/gensounds/pulp_fiction/mushroom_cloud_long.wav",
485     "<i>Pulp Fiction</i>",
486     //-----------------------------------------------------
487     "G",
488     "N",
489     15,
490     "/gensounds/pulp_fiction/mushroom_cloud_short.wav",
491     "<i>Pulp Fiction</i>",
492     //-----------------------------------------------------
493     "G",
494     "N",
495     154,
496     "/gensounds/pulp_fiction/piercing.wav",
497     "<i>Pulp Fiction</i>",
498     //-----------------------------------------------------
499     "C",
500     "N",
501     302,
502     "/gensounds/pulp_fiction/pigs_filthy_animals.wav",
503     "<i>Pulp Fiction</i>",
504     //-----------------------------------------------------
505     "G",
506     "N",
507     146,
508     "/gensounds/pulp_fiction/please_clean_car.wav",
509     "<i>Pulp Fiction</i>",
510     //-----------------------------------------------------
511     "G",
512     "N",
513     71,
514     "/gensounds/pulp_fiction/postpone_congratulation_long.wav",
515     "<i>Pulp Fiction</i>",
516     //-----------------------------------------------------
517     "G",
518     "N",
519     30,
520     "/gensounds/pulp_fiction/postpone_congratulation_short.wav",
521     "<i>Pulp Fiction</i>",
522     //-----------------------------------------------------
523     "G",
524     "N",
525     24,
526     "/gensounds/pulp_fiction/rapist.wav",
527     "<i>Pulp Fiction</i>",
528     //-----------------------------------------------------
529     "G",
530     "N",
531     20,
532     "/gensounds/pulp_fiction/sending_the_wolf.wav",
533     "<i>Pulp Fiction</i>",
534     //-----------------------------------------------------
535     "G",
536     "N",
537     134,
538     "/gensounds/pulp_fiction/take_the_money.wav",
539     "<i>Pulp Fiction</i>",
540     //-----------------------------------------------------
541     "D",
542     "N",
543     94,
544     "/gensounds/pulp_fiction/towel_dirty.wav",
545     "<i>Pulp Fiction</i>",
546     //-----------------------------------------------------
547     "G",
548     "N",
549     2,
550     "/gensounds/pulp_fiction/use_toilet.wav",
551     "<i>Pulp Fiction</i>",
552     //-----------------------------------------------------
553     "G",
554     "N",
555     318,
556     "/gensounds/pulp_fiction/wallace_appearance.wav",
557     "<i>Pulp Fiction</i>",
558     //-----------------------------------------------------
559     "C",
560     "N",
561     84,
562     "/gensounds/pulp_fiction/we_happy.wav",
563     "<i>Pulp Fiction</i>",
564     //-----------------------------------------------------
565     "G",
566     "N",
567     205,
568     "/gensounds/pulp_fiction/weirdest_day.wav",
569     "<i>Pulp Fiction</i>",
570     //-----------------------------------------------------
571     "G",
572     "N",
573     347,
574     "/gensounds/pulp_fiction/wristwatch_history.wav",
575     "<i>Pulp Fiction</i>",
576     //-----------------------------------------------------
577     "C",
578     "N",
579     14,
580     "/gensounds/pulp_fiction/zed_is_dead.wav",
581     "<i>Pulp Fiction</i>",
582     //-----------------------------------------------------
583     "C",
584     "N",
585     38,
586     "/gensounds/r_lee_ermey/dirtbag.wav",
587     "R. Lee Ermey, <i>Full Metal Jacket</i>",
588     //-----------------------------------------------------
589     "C",
590     "N",
591     117,
592     "/gensounds/r_lee_ermey/ermey_1234corp.wav",
593     "<i>Full Metal Jacket</i>",
594     //-----------------------------------------------------
595     "C",
596     "N",
597     28,
598     "/gensounds/r_lee_ermey/ermey_charge.wav",
599     "R. Lee Ermey, <i>Full Metal Jacket</i>",
600     //-----------------------------------------------------
601     "C",
602     "N",
603     26,
604     "/gensounds/r_lee_ermey/ermey_equally.wav",
605     "R. Lee Ermey, <i>Full Metal Jacket</i>",
606     //-----------------------------------------------------
607     "C",
608     "N",
609     12,
610     "/gensounds/r_lee_ermey/ermey_goodnite.wav",
611     "R. Lee Ermey, <i>Full Metal Jacket</i>",
612     //-----------------------------------------------------
613     "C",
614     "N",
615     159,
616     "/gensounds/r_lee_ermey/ermey_kisser.wav",
617     "R. Lee Ermey, from <a href=\"http://www.rleeermey.com\" target=\"_blank\">his web site</a>.",
618     //-----------------------------------------------------
619     "C",
620     "N",
621     99,
622     "/gensounds/star_trek_orig/blow.wav",
623     "<i>Star Trek</i>",
624     //-----------------------------------------------------
625     "C",
626     "N",
627     43,
628     "/gensounds/star_trek_orig/explain.wav",
629     "<i>Star Trek</i>",
630     //-----------------------------------------------------
631     "C",
632     "N",
633     27,
634     "/gensounds/star_trek_orig/guardian.wav",
635     "<i>Star Trek</i>",
636     //-----------------------------------------------------
637     "C",
638     "N",
639     96,
640     "/gensounds/star_trek_mp/vger.wav",
641     "<i>Star Trek: The Motion Picture</i>",
642     //-----------------------------------------------------
643     "C",
644     "N",
645     35,
646     "/gensounds/star_trek_vh/amiracle.wav",
647     "<i>Star Trek IV: The Voyage Home</i>",
648     //-----------------------------------------------------
649     "C",
650     "N",
651     118,
652     "/gensounds/star_trek_vh/avoidearth.wav",
653     "<i>Star Trek IV: The Voyage Home</i>",
654     //-----------------------------------------------------
655     "C",
656     "N",
657     127,
658     "/gensounds/star_trek_vh/backpost.wav",
659     "<i>Star Trek IV: The Voyage Home</i>",
660     //-----------------------------------------------------
661     "C",
662     "N",
663     218,
664     "/gensounds/star_trek_vh/colorful.wav",
665     "<i>Star Trek IV: The Voyage Home</i>",
666     //-----------------------------------------------------
667     "C",
668     "N",
669     34,
670     "/gensounds/star_trek_vi_tuc/1strule.wav",
671     "<i>Star Trek VI: The Undiscovered Country</i>",
672     //-----------------------------------------------------
673     "C",
674     "N",
675     184,
676     "/gensounds/star_trek_vi_tuc/breathing.wav",
677     "<i>Star Trek VI: The Undiscovered Country</i>",
678     //-----------------------------------------------------
679     "C",
680     "N",
681     72,
682     "/gensounds/star_trek_vi_tuc/didntfire.wav",
683     "<i>Star Trek VI: The Undiscovered Country</i>",
684     //-----------------------------------------------------
685     "C",
686     "N",
687     92,
688     "/gensounds/star_trek_vi_tuc/knees.wav",
689     "<i>Star Trek VI: The Undiscovered Country</i>",
690     //-----------------------------------------------------
691     "C",
692     "N",
693     46,
694     "/gensounds/star_trek_vi_tuc/nixon.wav",
695     "<i>Star Trek VI: The Undiscovered Country</i>",
696     //-----------------------------------------------------
697     "C",
698     "N",
699     50,
700     "/gensounds/star_trek_vi_tuc/request.wav",
701     "<i>Star Trek VI: The Undiscovered Country</i>",
702     //-----------------------------------------------------
703     "C",
704     "N",
705     75,
706     "/gensounds/star_trek_vi_tuc/savedciv.wav",
707     "<i>Star Trek VI: The Undiscovered Country</i>",
708     //-----------------------------------------------------
709     "C",
710     "N",
711     26,
712     "/gensounds/star_trek_vi_tuc/screwup.wav",
713     "<i>Star Trek VI: The Undiscovered Country</i>",
714     //-----------------------------------------------------
715     "C",
716     "N",
717     55,
718     "/gensounds/star_trek_vi_tuc/shutup.wav",
719     "<i>Star Trek VI: The Undiscovered Country</i>",
720     //-----------------------------------------------------
721     "C",
722     "N",
723     108,
724     "/gensounds/star_trek_orig/shatner.wav",
725     "William Shatner, during a satirical skit involving speaking at a " .
726     "<i>Star Trek</i> convention, from an unknown episode of <i>Saturday Night Live</i>",
727     //-----------------------------------------------------
728     "C",
729     "N",
730     137,
731     "/gensounds/star_trek_ng/locutus0.wav",
732     "Patrick Stewart, <i>Star Trek: The Next Generation</i>",
733     //-----------------------------------------------------
734     "C",
735     "N",
736     73,
737     "/gensounds/star_wars/beaten.wav",
738     "The <i>Star Wars</i> series of films",
739     //-----------------------------------------------------
740     "C",
741     "N",
742     35,
743     "/gensounds/terminator/back.wav",
744     "Arnold Schwarzenegger, the <i>Terminator</i> series of films",
745     //-----------------------------------------------------
746     "C",
747     "N",
748     35,
749     "/gensounds/terminator/cyborg.wav",
750     "Michael Biehn, the <i>Terminator</i> series of films",
751     //-----------------------------------------------------
752     "C",
753     "N",
754     3,
755     "/gensounds/terminator/get_out.wav",
756     "Arnold Schwarzenegger, the <i>Terminator</i> series of films",
757     //-----------------------------------------------------
758     "C",
759     "N",
760     73,
761     "/gensounds/terminator/yourclot.wav",
762     "Arnold Schwarzenegger, the <i>Terminator</i> series of films",
763     );
764    
765     //Copy the elements that match into a parallel array that will be returned.
766     $c = count($sounds);
767     if ($c % 5)
768     {
769     //Not a multiple of 5, something is wrong with the array.
770     $dbsounds_total = 0;
771     return(false);
772     }
773    
774     $dbsounds_total = $c/5;
775    
776     for ($i = 0; $i < $c; $i += 5)
777     {
778     $excluded = 0;
779    
780     if ($cleanliness != "A")
781     {
782     if (!BGSOUND_string_intersection($cleanliness, $sounds[$i]))
783     {
784     $excluded = 1;
785     }
786     }
787    
788     if ($topic != "A")
789     {
790     if (!BGSOUND_string_intersection($topic, $sounds[$i+1]))
791     {
792     $excluded = 1;
793     }
794     }
795    
796     if (($maxsize != 0) && ($maxsize < $sounds[$i+2]))
797     {
798     $excluded = 1;
799     }
800    
801     if ($minsize > $sounds[$i+2])
802     {
803     $excluded = 1;
804     }
805    
806     if (!$excluded)
807     {
808     if (!isset($rv))
809     {
810     $rv = array($i/5);
811     }
812     else
813     {
814     array_push($rv, $i/5);
815     }
816    
817     array_push($rv, $sounds[$i]);
818     array_push($rv, $sounds[$i+1]);
819     array_push($rv, $sounds[$i+2]);
820     array_push($rv, $sounds[$i+3]);
821     array_push($rv, $sounds[$i+4]);
822     }
823     } //End for()
824    
825     if (isset($rv))
826     return($rv);
827     else
828     return(false);
829     }
830    
831     //
832     //Returns a random sound subject to the parameters. If a sound matching the criteria can't be found,
833     //the $soundpath and the $soundcredit are set to be the empty string. The total number of sounds in the database,
834     //the number selected per the query, and the effective array index of the sound selected are returned.
835     //
836     function BGSOUND_bgsound_random(
837     $cleanliness,
838     $topic,
839     $minsize,
840     $maxsize,
841     &$soundpath,
842     &$soundcredit,
843     &$dbsounds_total,
844     &$dbsounds_query,
845     &$dbsound_selected
846     )
847    
848     {
849     //Dope the return variables for consistency.
850     $dbsounds_total = 0;
851     $dbsounds_query = 0;
852     $dbsound_selected = 0;
853    
854     $possibles = BGSOUND_bgsound_search_db($cleanliness, $topic, $minsize, $maxsize, $dbsounds_total);
855     if ($possibles === false)
856     {
857     //Nothing found.
858     $soundpath = "";
859     $soundcredit = "";
860     }
861     else
862     {
863     $c = count($possibles) / 6;
864     $dbsounds_query = $c;
865     //echo $c;
866    
867     $target = rand(0, $c-1);
868     $dbsound_selected = $possibles[$target * 6];
869     //echo " ";
870     //echo $target;
871    
872     $soundpath = $possibles[$target * 6 + 4];
873     $soundcredit = $possibles[$target * 6 + 5];
874     }
875     }
876     ?>

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25