Просмотр файла cron/get_metal_price.php

Размер файла: 874B
<?
include (dirname(__FILE__)."/../includes/common.php");

function cErr($msg){
	global $BILLING_EMAIL; 
	@mail($BILLING_EMAIL,"Ошибка при обновлении курсов",$msg,"From:".$SETTINGS['site_name']." CRON<$BILLING_EMAIL>");
}

/* METALS */
$time = time();
$val_row = mysql_fetch_object(mysql_query("select * from currencies where code='USD'"));
$url = "http://www.e-gold.com/unsecure/metaldata.asp?LATEST=1";

$res = mysql_query("select * from metals");
while($row=mysql_fetch_object($res)){
	$data = trim(@implode('',@file($url."&".$row->code."=1")));
	$arr = explode(",",$data);
	$value = trim($arr[1])+0;
	$value = round($value/31.1034768,6);

	if($value > 0){
		$query = "INSERT INTO `metal_prices` (`metal_id` , `currency_id` , `price` , `date` ) VALUES 	('$row->id', '$val_row->id', '$value', '".$time."');";
		@mysql_query($query);
	}
}
exit;
?>