case 'Cadastrar': set_time_limit(0); $extensoesPermitidas = explode('|', $arqtypes); $error = ''; if (!is_dir($pathUp . $pastaDestino)) { mkdir($pathUp . $pastaDestino, 0755); sleep(1); } $file = $_FILES['arquivos']; $fileName = $file['name']; $extensao = strtolower(str_replace('.', '', strrchr($fileName, '.'))); if (in_array($extensao, $extensoesPermitidas)) { $newName = $imgName ? $imgName : str_replace($extensao, '', $fileName); $newName = Strings::stringToUrl($newName); $newName = strtolower(substr($newName, 0, $limitName - 8) . '.' . $extensao); $newName = NWD::autoRename($pathUp . $pastaDestino, $newName); $arqMove = move_uploaded_file($file['tmp_name'], $pathUp . $pastaDestino . $newName); if (@$arqMove) { $cod = md5(microtime()); $lastPos = mysql_fetch_assoc(mysql_query("SELECT `pos` FROM `arquivos` WHERE `categ` = '{$catid}' ORDER BY `pos` DESC LIMIT 1")); $pos = $lastPos['pos'] + 1; $insert = mysql_query("INSERT INTO `arquivos` (`pos`, `categ`, `arquivo`, `cod`, `ativo`) \n\t\t\t\t\t\tVALUES ('{$pos}', '{$catid}', '{$newName}', '{$cod}', '1')"); } if (@$insert) { $success = 'Enviado'; } else { $error = 'Erro!'; } } else { $error = 'Arquivo não permitido'; }
$img = mysql_fetch_assoc(mysql_query("SELECT imagem FROM fotos_temp WHERE id = '{$idItem}' LIMIT 1")); $extensao = strtolower(str_replace('.', '', strrchr($img['imagem'], '.'))); if (strstr('*.jpg;*.jpeg;*.gif;*.png', $extensao)) { $values = explode('_', $imgvalues); $corBg = @$values[3] ? $values[3] : 'ffffff'; $imgQualidade = @$values[4] ? $values[4] : 100; $imgMenor = @$values[5] ? $values[5] : false; $limitName = 100; $pastaDestino = '../../../imagens/fotos/'; $imageTemp = $pastaDestino . '_temp/' . $img['imagem']; $thumbTemp = $pastaDestino . '_temp/thumbs/' . $img['imagem']; $animal = mysql_fetch_assoc(mysql_query("SELECT * FROM `animais` WHERE `id` = '{$idanimal}' LIMIT 1")); $newName = $animal['nome'] . '_' . $animal['cientifico'] . '_' . $animal['maisnomes']; $newName = Strings::stringToUrl($newName); $newName = strtolower(substr($newName, 0, $limitName - 8) . '.' . $extensao); $newName = NWD::autoRename($pastaDestino . 'imgs', $newName); $altaOutput = $pastaDestino . 'alta/' . $newName; $imageOutput = $pastaDestino . 'imgs/' . $newName; $thumbOutput = $pastaDestino . 'thumbs/' . $newName; $copy = copy($imageTemp, $altaOutput); $imagem = NwdGD::imgResize($altaOutput, $imageOutput, $values[0], $values[1], $values[2], $corBg, $imgQualidade, $imgMenor); $thumb = NwdGD::imgResize($altaOutput, $thumbOutput, $values[6], $values[7], $values[8], $corBg, $imgQualidade, $imgMenor); if ($imagem != false) { $lastPos = mysql_fetch_assoc(mysql_query("SELECT `pos` FROM `fotos` WHERE `id_animal` = '{$idanimal}' ORDER BY `pos` DESC LIMIT 1")); $pos = $lastPos['pos'] + 1; $data = implode('-', array_reverse(explode('/', $data))) . ' ' . $time; $insert = mysql_query("INSERT INTO `fotos` (`pos`, `id_animal`, `id_cidade`, `id_autor`, `imagem`, `data`, `tecnica`, `descricao`, `ativo`) \n\t\t\t\t\t\t\t\t\t\t\t\t\tVALUES ('{$pos}', '{$idanimal}', '{$cidade}', '{$idautor}', '{$newName}', '{$data}', '{$tecnica}', '{$descricao}', '1')"); } if (@$insert) { if (@$tempClear) { $clear = mysql_query("DELETE FROM fotos_temp WHERE id = '{$idItem}' LIMIT 1");