View of /mambo/branches/4.6/includes/captcha-audio.php
Parent Directory
|
Revision Log
Revision 869 -
(download)
(annotate)
Sat Jan 6 10:39:30 2007 UTC (6 years, 4 months ago) by neilt
File size: 1912 byte(s)
Sat Jan 6 10:39:30 2007 UTC (6 years, 4 months ago) by neilt
File size: 1912 byte(s)
comments language work provided by Andphe
<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
global $mosConfig_lang, $mosConfig_absolute_path;
session_name('mos_captcha');
session_start();
$code = $_SESSION['code'];
// language select (for future addition of own wav files)
$lang = $mosConfig_absolute_path.'/includes/captchaAudio/'.$mosConfig_lang.'/';
if (!is_dir($lang)) {
$lang = $mosConfig_absolute_path.'/includes/captchaAudio/en/';
}
$wavs = array();
for($i=0;$i<5;$i++){
$file = $lang.$code{$i}.'.wav';
$wavs[] = $file;
}
//$totalsize = filesize($filename);
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header('Content-type: audio/x-wav');
header("Content-Transfer-Encoding: binary");
//header("Content-Length: ".$totalsize);
header('Content-Disposition: attachment;filename=captcha.wav');
echo joinwavs($wavs);
/**
* CAPTCHA antispam plugin - sound generator
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <gohr@cosmocode.de>
*/
function joinwavs($wavs){
$fields = join('/',array( 'H8ChunkID', 'VChunkSize', 'H8Format',
'H8Subchunk1ID', 'VSubchunk1Size',
'vAudioFormat', 'vNumChannels', 'VSampleRate',
'VByteRate', 'vBlockAlign', 'vBitsPerSample' ));
$data = '';
foreach($wavs as $wav){
$fp = fopen($wav,'rb');
$header = fread($fp,36);
$info = unpack($fields,$header);
if($info['Subchunk1Size'] > 16){
$header .= fread($fp,($info['Subchunk1Size']-16));
}
$header .= fread($fp,4);
$size = unpack('vsize',fread($fp, 4));
$size = $size['size'];
$data .= fread($fp,$size);
}
return $header.pack('V',strlen($data)).$data;
}
?>| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

