Created
June 28, 2019 19:07
-
-
Save jeanjar/57bdb17d924efb806c032165e6c691d6 to your computer and use it in GitHub Desktop.
Meu primeiro código PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head><title></title> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> | |
</head> | |
<body> | |
<?php | |
/* | |
// --- php.ini | |
max_execution_time = 18000 | |
memory_limit = 128M | |
post_max_size = 200M | |
upload_max_filesize = 200M | |
// -- php.ini | |
*/ | |
if ($_POST['banco'] == "") { | |
echo "Escolha um banco valido"; | |
echo "<br/><a href='../visao/adicionar_geno.php'>Voltar</a>"; | |
} elseif ($_FILES['uploadedfile']['name'] == "") { | |
echo "Nenhum arquivo foi selecionado"; | |
echo "<br/><a href='../visao/adicionar_geno.php'>Voltar</a>"; | |
} else { | |
echo $_POST['banco']."<br/>"; | |
echo "time limit\t"; | |
echo ini_get("time_limit"); | |
echo "<br/>"; | |
echo "max execution time\t"; | |
echo ini_get('max_execution_time'); | |
echo "<br/>"; | |
echo "Post max size\t"; | |
echo ini_get("post_max_size"); | |
echo "<br />"; | |
echo "memory limit\t"; | |
echo ini_get("memory_limit"); | |
echo "<br />"; | |
echo "upload max filesize\t"; | |
echo ini_get("upload_max_filesize"); | |
$uploaddir = '../upload/geno/'; | |
$uploadfile = $uploaddir . basename($_FILES['uploadedfile']['name']); | |
echo '<pre>'; | |
if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $uploadfile)) { | |
echo "O arquivo é válido, e foi enviado com sucesso.\n"; | |
echo "<br/>"; | |
} else { | |
echo "Possible file upload attack!\n"; | |
} | |
echo 'Informacoes:'; | |
print_r($_FILES); | |
switch ($_FILES['uploadedfile']['error']) { | |
case 0: | |
echo "There is no error, the file uploaded with success. "; | |
break; | |
case 1: | |
echo "The uploaded file exceeds the upload_max_filesize directive in php.ini."; | |
break; | |
case 2: | |
echo "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form."; | |
break; | |
case 3: | |
echo "The uploaded file was only partially uploaded. "; | |
break; | |
case 4: | |
echo "No file was uploaded. "; | |
break; | |
case 6: | |
echo "Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3. "; | |
break; | |
case 7: | |
echo "Failed to write file to disk. Introduced in PHP 5.1.0. "; | |
break; | |
case 8: | |
echo "A PHP extension stopped the file upload. PHP does not provide a way to ascertain which extension caused the file upload to stop; examining the list of loaded extensions with phpinfo() may help. Introduced in PHP 5.2.0."; | |
break; | |
} | |
print "</pre>"; | |
$link = mysql_connect('localhost', 'root', '') or die('N�o foi poss�vel conectar: ' . mysql_error()); | |
mysql_select_db('metagenoma') or die('N�o foi poss�vel selecionar o banco da dados'); | |
set_time_limit(0); | |
$char = null; | |
echo "<br/>"; | |
$arquivo = fopen($uploadfile, 'r'); | |
while (!feof($arquivo)) { | |
$char .= fgetc($arquivo); | |
} | |
fclose($arquivo); | |
$huhu = (explode("\n", $char, -1)); | |
$tamanho = count($huhu); | |
$banco = $_POST["banco"]; | |
$gi = NULL; | |
$sequencia = NULL; | |
for ($i = 0; $i <= $tamanho - 1; $i++) { | |
if (substr($huhu[$i], 0, 1) == ">") { | |
if ($gi != "") { | |
//echo "$gi <br/> $run </br> $sequencia</br>"; | |
//$sql = "INSERT INTO `geno` (`banco`, `id_read`, `run`, `sequencia`) VALUES ('$banco', '$gi', '$run', '$sequencia');"; | |
//$query = mysql_query($sql); | |
$sequencia = ""; | |
} | |
$gi = substr($huhu[$i], 0, 15); | |
$run = substr($huhu[$i], 16, strlen($huhu[$i])); | |
} else { | |
$sequencia .= $huhu[$i]; | |
} | |
} | |
//echo "$gi <br/> $run </br> $sequencia</br>"; | |
//$sql = "INSERT INTO `geno` (`banco`, `id_read`, `run`, `sequencia`) VALUES ('$banco', '$gi', '$run', '$sequencia');"; | |
//$query = mysql_query($sql); | |
mysql_close($link); | |
} | |
?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment