Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

dokan

Cotação Parou de funcionar

Recommended Posts

A contação do site estava funcionando e parou de funcionar nessa semana,

imagino que o site da uol fez alguma mudança, mas não estou conseguindo fazer funcionar novamente

<?

	session_start();
	
	if(!isset($_SESSION['dinheiro'])) {
		$_SESSION['dinheiro'] = "N";
		$_SESSION['moeda'][0] = 'Dólar comercial';
		$_SESSION['moeda'][1] = 'Dólar turismo';
		$_SESSION['moeda'][2] = 'Dólar paralelo';
		$_SESSION['moeda'][3] = 'Euro';
		$_SESSION['moeda'][4] = 'Pesos arg.';
		$_SESSION['valorc'][0] = '';
		$_SESSION['valorc'][1] = '';
		$_SESSION['valorc'][2] = '';
		$_SESSION['valorc'][3] = '';
		$_SESSION['valorc'][4] = '';
		$_SESSION['valorv'][0] = '';
		$_SESSION['valorv'][1] = '';
		$_SESSION['valorv'][2] = '';
		$_SESSION['valorv'][3] = '';
		$_SESSION['valorv'][4] = '';
	}

	if($_SESSION['dinheiro']=="N") {

		$url = "http://economia.uol.com.br/cotacoes/cambio.jhtm";
		$conecurl = fopen("$url","r");
		$lin = "";
		
		if(isset($conecurl)) {
		
			while(!feof($conecurl)) {
				$lin .= fgets($conecurl, 4096);
			}
	
			fclose($conecurl);
	
			$comeco = strpos($lin, '<td>Variação</td>');
			$fim = strpos($lin,'Cotações anteriores');
			$quant = $fim - $comeco;

			$conteudo = substr($lin, $comeco, $quant);	
			//$conteudo = strip_html($conteudo);
		
			$linha = substr($conteudo, strpos($conteudo, $_SESSION['moeda'][0]), 90);
			$_SESSION['valorc'][0] = substr($linha, strpos($linha, '</th><td>') + 9, 5);
			$_SESSION['valorv'][0] = substr($linha, strpos($linha, '</td><td>') + 9, 5);	
		
			$linha = substr($conteudo, strpos($conteudo, $_SESSION['moeda'][1]), 90);
			$_SESSION['valorc'][1] = substr($linha, strpos($linha, '</th><td>') + 9, 5);
			$_SESSION['valorv'][1] = substr($linha, strpos($linha, '</td><td>') + 9, 5);
	
			$linha = substr($conteudo, strpos($conteudo, $_SESSION['moeda'][2]), 90);
			$_SESSION['valorc'][2] = substr($linha, strpos($linha, '</th><td>') + 9, 5);
			$_SESSION['valorv'][2] = substr($linha, strpos($linha, '</td><td>') + 9, 5);
		
			$linha = substr($conteudo, strpos($conteudo, $_SESSION['moeda'][3]), 90);
			$_SESSION['valorc'][3] = substr($linha, strpos($linha, '</th><td>') + 9, 5);
			$_SESSION['valorv'][3] = substr($linha, strpos($linha, '</td><td>') + 9, 5);
		
			$linha = substr($conteudo, strpos($conteudo, $_SESSION['moeda'][4]), 90);
			$_SESSION['valorc'][4] = substr($linha, strpos($linha, '</th><td>') + 9, 5);
			$_SESSION['valorv'][4] = substr($linha, strpos($linha, '</td><td>') + 9, 5);
			
			$_SESSION['dinheiro'] = "S";
		
		}
		
	}
	
	?>
	
<html>
<head>
<title></title>
</herad>

<body>

<?

	echo '<table border="0" width="148" cellspacing="0" style="font-family: Tahoma; font-size: 9px; color: #FFFFFF; text-decoration: none">' . "\n";		
	echo '<tr>' . "\n";
	echo '<td width="70" height="14" align="center" bgcolor="#333333">Moeda</td>' . "\n";
	echo '<td height="14" align="center" bgcolor="#333333">Compra</td>' . "\n";
	echo '<td height="14" align="center" bgcolor="#333333">Venda</td>' . "\n";
	echo '</tr>' . "\n";	

	for($i=0; $i<=4; $i++) {
		echo '<tr>' . "\n";
		echo '<td width="70" height="15" bgcolor="#525252">' . ucwords($_SESSION['moeda'][$i]) . '</td>' . "\n";
		echo '<td height="15" align="center" bgcolor="#525252">' . $_SESSION['valorc'][$i] . '</td>' . "\n";
		echo '<td height="15" align="center" bgcolor="#525252">' . $_SESSION['valorv'][$i] . '</td>' . "\n";
		echo '</tr>' . "\n";
	}
	
	echo '</table>' . "\n";

?>

</body>
</html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.