mujik

Рейтинг
6
Регистрация
14.01.2007

можно при регистрации выводить все капчи на странице и заполнять их поочереди . но это извращение :D

сначало надо увидеть тз)

есть qik.ru

а ничего что там почти все от prcy.net? и вы приписываете программирование себе, а я уже там непричем?)

можно от местоимений ссылаться, например, my-hosting , your-hosting, our-hosting...

можно xml разборщиком сделать с кэшированием


<?

class get_valute
{

var $valute_id = "R01235";
var $url = "http://www.cbr.ru/scripts/XML_daily.asp";
var $cache_file = "cache/valute.txt";
var $default = array("NOMINAL"=>1, "VALUE"=>27);
var $record = false;
var $valute = array();
var $index = "";
var $xml_parser;

function valute()
{
if ( ($data = $this->from_file()) && $data['DAY']==date( "d.m.Y" ) )
$this->valute = $data['VALUTE'];
else
{
if ( $this->get_from_xml() )
$this->in_file();
else
$this->valute = $this->default;
}
}

function startElement($parser, $name, $attrs)
{
if ( $name == "VALUTE" && $attrs['ID']==$this->valute_id ) $this->record = true;
if ( $this->record && ( $name == "NOMINAL" || $name == "VALUE" ) ) $this->index = $name;
}

function characterData($parser, $data)
{
if ( $this->record && $this->index != "" ) $this->valute[$this->index] = $data;
}

function endElement($parser, $name)
{
$this->index = "";
if ( $name == "VALUTE" && $this->record ) $this->record = false;
}

function get_from_xml()
{
if ( $fp = fopen( $this->url, "r" ) )
{
$this->xml_parser = xml_parser_create();
xml_parser_set_option($this->xml_parser, XML_OPTION_CASE_FOLDING, TRUE);

xml_set_object($this->xml_parser, $this);

xml_set_element_handler( $this->xml_parser, "startElement", "endElement" );
xml_set_character_data_handler( $this->xml_parser, "characterData" );

while ($data = fread ($fp, 64))
{
if ( !xml_parse( $this->xml_parser, $data, feof( $fp ) ) ) return FALSE;
}
xml_parser_free( $this->xml_parser );
return TRUE;
}
else
return FALSE;
}

function from_file()
{
if ( file_exists( $this->cache_file ) )
{
$data = @file_get_contents( $this->cache_file );
$data = unserialize($data);
return $data;
}
return false;
}

function in_file()
{
$fp = fopen( $this->cache_file, "w" );
fwrite( $fp, serialize( array( "DAY"=>date( 'd.m.Y' ), "VALUTE"=>$this->valute ) ) );
fclose( $fp );
}
}
?>

и вызов в скрипте


<?
include ("class.php");

$valute = new get_valute;
$valute->url = "http://www.cbr.ru/scripts/XML_daily.asp?date_req=".date( 'd/m/Y' );

$valute->valute();

echo $valute->valute['VALUE'];

?>
1 23
Всего: 26