PHP Classes

File: audio/string_audio.php

Recommend this page to a friend!
  Classes of Bogdan Lupandin   CAPTCHA with Audio   audio/string_audio.php   Download  
File: audio/string_audio.php
Role: Example script
Content type: text/plain
Description: Generates the audio for string captcha
Class: CAPTCHA with Audio
Authenticate human users with audio CAPTCHA
Author: By
Last change:
Date: 6 years ago
Size: 813 bytes


Class file image Download
// Starting the session so we could access the session variables

// Including our mp3 stitching class

// The captcha word we are making the audio for
$captcha = $_SESSION['captcha'];

// Getting the length of the word
$length = strlen($captcha);

// Initiating the MP3 file generation
if($length > 0)
$mp3 = new stitch_mp3('../sounds/' . substr(strtoupper($captcha), 0, 1) . '.mp3');

// Making sure we got this going to the browser (and not as a download)
$mp3->inline = 1;

// Appending the other files to the end of the previous file
for($c = 1; $c < $length; $c++)
$mp3->append_mp3('../sounds/' . substr(strtoupper($captcha), $c, 1) . '.mp3');

// Output
$mp3->output(md5($captcha . time()) . '.mp3');