if (!$reqData) { $reqData = $ses->valueOf('tmp_request'); } $reqData->text = $_POST['TEXT']; $reqData->time = time(); // $reqData->action = OREQ_CREATE; if ($reqData->curator) { $reqData->result = OREQ_PROCESS; } else { $reqData->result = OREQ_WAIT; } $reqData->file = ''; $reqData->username = $ses->login(); if (isset($_FILES['FILENAME']['name']) && $_FILES['FILENAME']['name'] != '') { $ext = substr($_FILES['FILENAME']['name'], strrpos($_FILES['FILENAME']['name'], '.')); $fn = genFileName($ext); move_uploaded_file($_FILES['FILENAME']['tmp_name'], PWD_FILES . '/' . $fn); $reqData->file = $fn; } $reqData->count = 1; $reqData->toMulti(); $reqData->insert(); $reqData->rid[0] = $reqData->lastid(); $url = SERV_PATH . '/' . $_file_ . '?pid=' . $reqData->rid[0]; $tpl->assign('BODY', "{$act} <BR>Изменения внес: " . $ses->login() . " <BR>" . "Подробная информация доступна по адресу <A HREF=\"{$url}\">{$url}</A>"); $tpl->parse('EMAIL', 'email'); $headers = OUSER_MAILFROM . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=windows-1251"; if (!$reqData->curator[0]) { $us = $groupWebInform->users();
$arquivo = isset($_FILES["podcastFile"]) ? $_FILES["podcastFile"] : FALSE; //print_r($arquivo); //exit; // Diretório onde a imagem será salva $config = array(); $config["diretorio"] = "../podcast/"; if ($arquivo) { $erro = array(); if (!eregi("^audio\\/(wma|mp3|wav|mpeg)\$", $arquivo["type"])) { $erro[] = "Arquivo em formato inválido! A imagem deve ser mp3, wma ou wav. Envie outro arquivo"; } if (!sizeof($erro)) { // Pega extensão do arquivo, o indice 1 do array conterá a extensão preg_match("/\\.(wma|mp3|wav|mpeg){1}\$/i", $arquivo["name"], $ext); // Gera nome único para a imagem $file_name = genFileName($ext[1]); // Caminho de onde a imagem ficará $file_dir = $config["diretorio"] . $file_name; // Faz o upload da imagem move_uploaded_file($arquivo["tmp_name"], $file_dir); $file_path = $file_name; } else { echo "<h1>" . $erro[0] . "</h1>"; exit; } /* echo "<br>"; echo "Original : " . $arquivo['name'] . "<br>"; echo "Servidor : " . $file_path . "<br>"; echo "Path ....: " . $file_dir . "<br>"; echo "EXT .....: " . $ext[1];
} else { if ($uploadedExtension == 'mp3') { //CREATE OGG FROM MP3 $wavFile = $downloadDir . genFileName() . '.wav'; $oggFile = $downloadDir . genFileName() . '.ogg'; system('ffmpeg -i ' . $uploadedFile . ' ' . $wavFile); system('sox ' . $wavFile . ' ' . $oggFile); $outStr .= "\n parentDoc.getElementById('channelMp3" . $channel . "').innerHTML = '" . $base64->encode($uploadedFile) . "';\n parentDoc.getElementById('channelOgg" . $channel . "').innerHTML = '" . $base64->encode($oggFile) . "';\n initPlayerControls();"; unlink($wavFile); unlink($oggFile); } else { if ($uploadedExtension == 'wav') { //CREATE OGG AND MP3 FROM WAV $wavFile = $downloadDir . genFileName() . '.wav'; $oggFile = $downloadDir . genFileName() . '.ogg'; $mp3File = $downloadDir . genFileName() . '.mp3'; copy($uploadedFile, $wavFile); system('sox ' . $wavFile . ' ' . $oggFile); system('lame -h ' . $wavFile . ' ' . $mp3File); $outStr .= "\n parentDoc.getElementById('channelOgg" . $channel . "').innerHTML = '" . $base64->encode($oggFile) . "';\n parentDoc.getElementById('channelMp3" . $channel . "').innerHTML = '" . $base64->encode($mp3File) . "';\n initPlayerControls();"; unlink($wavFile); unlink($oggFile); unlink($mp3File); } else { $outStr .= "\n alert('Invalid format. Allowable formats are .wav, .ogg and .mp3');"; } } } $outStr .= "</script>"; echo $outStr; }