session_start(); $_SESSION['count'] = $_SESSION['count'] + 1; echo "Contato nesta sessao : ". $_SESSION['count'] ."\n"; if ( ! $_SESSION['logado'] ) { if ( $hArq = fopen('/home/aurium/senha.txt', 'r') ) { $senhaMD5 = trim( fread( $hArq, filesize('/home/aurium/senha.txt') ) ); fclose($hArq); } if ( $_REQUEST['senha'] == '' ) { echo "Senha vazia.\nNegado.\n"; exit; } if ( md5($_REQUEST['senha']) == $senhaMD5 ) { echo "Logado!\n"; $_SESSION['logado'] = true; } else { echo " Dica - MD5 resultante: ". md5($_REQUEST['senha']) ."\n"; echo "Senha Errada\nNegado.\n"; } exit; } $dirFrames = "./imgs"; $agora = time(); $arq = "$dirFrames/img_" . date("Y_m_d_H_i_s", $agora) . ".jpg"; $arqLim = "img_" . date("Y_m_d_H_i_s", $agora - (10*60) ) . ".jpg"; $arqVelho = "img_" . date("Y_m_d_H_i_s", $agora - (12*60) ) . ".jpg"; if ( move_uploaded_file( $_FILES['arq']['tmp_name'], $arq ) ) { echo "O arquivo foi recebido com sucesso."; } else { echo "Possivel ataque de upload! Aqui esta alguma informação:\n"; print_r($_FILES); } // Lista Imagens no Diretório de Frames: if ( $dir = opendir($dirFrames) ) { while ( ($img = readdir($dir)) !== false ) { if ( substr($img, 0, 4) == 'img_' ) { echo "\n $img"; if ( $img > $arqLim ) { echo " Ok!"; $listaImgs[] = $img; } else { echo " Velha."; if ( $img < $arqVelho ) { echo " - apagar"; unlink( "$dirFrames/$img" ); } } } } } sort($listaImgs); reset($listaImgs); foreach ( $listaImgs as $img ) { $arqJS .= "$virgula '$img'"; $virgula = ",\n"; } // Definindo conteudo do arquivo JS: $arqJS = " window.imgs = [\n$arqJS\n ];"; $arqJS = "
\n\nOk"; // Escrevendo conteudo: if ( !$hArqJS = fopen("$dirFrames/imgs.js.html", 'w') ) { echo "Erro abrindo arquivo js"; exit; } if ( !fwrite($hArqJS, $arqJS) ) { echo "Erro escrevendo no arquivo js"; exit; } fclose($hArqJS); ?>