#!/usr/bin/perl use strict; use Template; use lib "../lib"; use main; use fine; print "Content-Type: text/html; charset=UTF-8\n\n"; $rh_data->{hPage} = new Template({ INCLUDE_PATH=>'../tmpl' }); if (!($rh_data->{ret_val}->{code})) { $rh_data->{ret_val}->{code} = $ARGV[0]; } $rh_data->{patent2} = 1; $rh_data->{tm_page} = 1; #$dbh_patent->do("UPDATE doc SET modif = ? WHERE code = ?", undef, $main::timestamp, int($rh_data->{ret_val}->{code})); $rh_data = &show_patent($rh_data); #rh_data = &show_comment($rh_data); #определить случайный патент $rh_data = &main::get_sub_interval($rh_data); $rh_data->{html} =~ s/$rh_data->{Title}\ /$rh_data->{Title}<\/strong>\ /is; my $sth = $dbh_patent->prepare("select * FROM dockw as a, kw_info as b where a.code = ? AND a.deleted = false AND (b.c_y > 10 OR a.auto = false) AND a.kw_id = b.id order by b.adv_google_count desc, b.price desc"); $sth->execute($rh_data->{ret_val}->{code}); my $kw_str = ""; while (my $kw = $sth->fetchrow_hashref()) { my $sth2 = $dbh_patent->prepare("select count(*) FROM dockw where kw_id = ?"); $sth2->execute($kw->{id}); my $test = $sth2->fetchrow_array(); $sth2->finish; if ($kw->{auto} == 0) { $test = 10; } if ($test >= 8) { $kw_str.=($kw->{kw} . ", "); } if ($rh_data->{ret_val}->{code} == 112573) { if ($rh_data->{ret_val}->{code} == $kw->{codemain}) { if ($rh_data->{html} =~ m/\ $kw->{kw}\ /is) { $rh_data->{html} =~ s/\ $kw->{kw}\ /\ $kw->{kw}<\/strong>\ /is; } elsif ($rh_data->{html} =~ m/\ $kw->{kw}\,/is) { $rh_data->{html} =~ s/\ $kw->{kw}\,/\ $kw->{kw}<\/strong>\,/is; } elsif ($rh_data->{html} =~ m/\ $kw->{kw}\./is) { $rh_data->{html} =~ s/\ $kw->{kw}\./\ $kw->{kw}<\/strong>\./is; } elsif ($rh_data->{html} =~ m/\ $kw->{kw}\;/is) { $rh_data->{html} =~ s/\ $kw->{kw}\;/\ $kw->{kw}<\/strong>\;/is; } elsif ($rh_data->{html} =~ m/\ $kw->{kw}\:/is) { $rh_data->{html} =~ s/\ $kw->{kw}\:/\ $kw->{kw}<\/strong>\:/is; } } else { my $d = int($kw->{codemain}/10000); if ($rh_data->{html} =~ m/\ $kw->{kw}\ /is) { $rh_data->{html} =~ s/\ $kw->{kw}\ /\ $kw->{kw}<\/a>\ /is; } elsif ($rh_data->{html} =~ m/\ $kw->{kw}\,/is) { $rh_data->{html} =~ s/\ $kw->{kw}\,/\ $kw->{kw}<\/a>\,/is; } elsif ($rh_data->{html} =~ m/\ $kw->{kw}\./is) { $rh_data->{html} =~ s/\ $kw->{kw}\./\ $kw->{kw}<\/a>\./is; } elsif ($rh_data->{html} =~ m/\ $kw->{kw}\;/is) { $rh_data->{html} =~ s/\ $kw->{kw}\;/\ $kw->{kw}<\/a>\;/is; } elsif ($rh_data->{html} =~ m/\ $kw->{kw}\:/is) { $rh_data->{html} =~ s/\ $kw->{kw}\:/\ $kw->{kw}<\/a>\:/is; } } } } $sth->finish; $kw_str =~ s/\,\ $//is; $rh_data->{kw_str} = $kw_str; $rh_data->{hPage}->process("patent_xml.tmpl", $rh_data) || die "Template process failed: ", $rh_data->{hPage}->error(), "\n"; exit(0); sub show_comment { my $rh_data = shift; return $rh_data; my $i = 0; my $sth = $dbh_patent->prepare("select * FROM comments WHERE code = ? ORDER BY parent_id asc, id asc"); $sth->execute($rh_data->{ret_val}->{code}); while (my $c = $sth->fetchrow_hashref()) { $i++; $c->{commenttext} =~ s/\n/
/isg; $c->{i} = $i; if ($c->{parent_id} > 0) { my $sth2 = $dbh_patent->prepare("select fio from comments where id = ?"); $sth2->execute($c->{parent_id}); $c->{parent_fio} = $sth2->fetchrow_array(); $sth2->finish; } push @{$rh_data->{comments}}, $c; } $sth->finish; $rh_data->{comment_i} = $i; return $rh_data; } sub show_patent { my $rh_data = shift; my $fine_text = ""; my $uniq_img = ""; my $sth2 = $dbh_patent->prepare("select * FROM doc where code = ?"); $sth2->execute($rh_data->{ret_val}->{code}); my $patent = $sth2->fetchrow_hashref(); $sth2->finish; $patent->{modif} =~ s/\ /T/is; if ($patent->{nodoc}) { exit(0); } if (!$patent->{name}) { $patent->{name} = "Полезная модель РФ " . $rh_data->{ret_val}->{code}; } $patent->{name} =~ s/<.*?>//isg; $patent->{comment} =~ s/<.*?>//isg; $patent->{comment} =~ s/\"/"/isg; $rh_data->{Title} = &main::lc_name($patent->{name}); $rh_data->{title_free} = $rh_data->{Title}; $rh_data->{title_free} =~ s/\"|\'//isg; my $dir = int($rh_data->{ret_val}->{code} / 10000); my $new = ""; # if ($patent->{fhtml}) { $new = "new/"; } open (F, "{ret_val}->{code}.html"); my @R = ; close F; my $mst = join("", @R); $mst =~ s/^.*?<\/script>//is; $mst =~ s/<\/body>.*?$//is; $mst =~ s/РОССИЙСКАЯ.*?ТОВАРНЫМ\ ЗНАКАМ<\/TD>//is; $mst =~ s/height\:43mm\;//; $mst =~ s/\(12\)<\/FONT>\ ПАТЕНТ НА ПОЛЕЗНУЮ МОДЕЛЬ<\/FONT>//is; #" if ($mst =~ m/Опубликовано\:\
//is; } if ($mst =~ m/Извещение опубликовано\:\ /Извещение опубликовано\:\ /isg; } if ($mst =~ m/Дата публикации\:\ /Дата публикации\:\ /isg; } $mst =~ s/CHR/chr/sg; $mst =~ s/GIF/gif/sg; $mst =~ s/Рисунок\ /Рисунок\ \;/isg; $mst =~ s/\ \ /\ /isg; $mst =~ s/\ \ /\ /isg; $mst =~ s/\ \ /\ /isg; $mst =~ s/\ <\/IMG>//isg; $mst =~ s/http\:\/\/www\.fips\.ru//isg; $mst =~ s/target=\"_blank\"//isg; # $mst =~ s/\/fips\.dll.*?\"/\"/isg; # $mst =~ s/Извещение опубликовано: .*?<\//<\//isg; $sth2 = $dbh_patent->prepare("select * FROM doc_img where code = ? order by id asc"); $sth2->execute($rh_data->{ret_val}->{code}); while (my $img = $sth2->fetchrow_hashref()) { # if ($img->{hide}) { next; } my $dir_img = int($img->{id} / 10000); # $uniq_img .= "{id}\.$img->{ext_big}\" onClick=\"this.href=\'http\:\/\/poleznayamodel\.ru\/img_show\/$img->{id}\.html\';\" title=\"$rh_data->{title_free}\">{id}-s.$img->{ext_small}\" width=\"100\" alt=\"$rh_data->{title_free}\" />

"; if ($img->{url} =~ m/http/is) { $mst =~ s/href=\"$img->{url}\"/href=\"http\:\/\/img\.poleznayamodel\.ru\/img_data\/$dir_img\/$img->{id}\.$img->{ext_big}\" onClick=\"this.href=\'http\:\/\/poleznayamodel\.ru\/img_show\/$img->{id}\.html\';\" title=\"$rh_data->{title_free}\"/isg; } else { $mst =~ s/href=\"\/$img->{url}\"/href=\"http\:\/\/img\.poleznayamodel\.ru\/img_data\/$dir_img\/$img->{id}-s\.$img->{ext_big}\" onClick=\"this.href=\'http\:\/\/poleznayamodel\.ru\/img_show\/$img->{id}\.html\';\" title=\"$rh_data->{title_free}\"/isg; $mst =~ s/\/$img->{url}/http\:\/\/img\.poleznayamodel\.ru\/img_data\/$dir_img\/$img->{id}-s\.$img->{ext_small}/isg; $mst =~ s/$img->{url}/http\:\/\/img\.poleznayamodel\.ru\/img_data\/$dir_img\/$img->{id}-s\.$img->{ext_small}/isg; } if (length($img->{url_small}) < 2) { $img->{url_small} = $img->{url}; $img->{url_small} =~ s/\./\-s\./isg; $img->{url_small} =~ s/tif/gif/isg; # print $img->{url_small} . "
"; } $mst =~ s/\/$img->{url_small}/http\:\/\/img\.poleznayamodel\.ru\/img_data\/$dir_img\/$img->{id}-s\.$img->{ext_small}/isg; $mst =~ s/$img->{url_small}/http\:\/\/img\.poleznayamodel\.ru\/img_data\/$dir_img\/$img->{id}-s\.$img->{ext_small}/isg; # print $img->{url_small} . "
"; # print $img->{url} . "
"; } $sth2->finish; # TITLE="1 Kb" TI="AD" HE="49" WI="147" $mst =~ s/\ TITLE=\".*?\"//; $mst =~ s/\ TI=\".*?\"//; $mst =~ s/\ HE=\".*?\"//; $mst =~ s/\ WI=\".*?\"//; $mst =~ s/^.*?\(57\)\ Реферат:<\/P>//is; # print "AAAA" . $fine_text . "
"; # $mst =~ s/prepare("select distinct(b.codemain),b.price,b.c from dockw as a, kw_info as b where a.code = ? and a.deleted = false and a.kw_id = b.id and b.codemain != a.code order by b.price desc, b.c desc"); $sth2->execute($rh_data->{ret_val}->{code}); while (my ($kw_code, $price, $c) = $sth2->fetchrow_array()) { if ($p->{$kw_code}) { next; } else { $p->{$kw_code} = 1; } $flag = 1; my $sth3 = $dbh_patent->prepare("select * FROM doc where code = ?"); $sth3->execute($kw_code); my $p = $sth3->fetchrow_hashref(); $sth3->finish; $p->{kws} = &add_kws($p->{code}); $p->{dir} = int($p->{code} / 10000); my $sth4 = $dbh_patent->prepare("select * FROM doc_img where code = ? order by id asc"); $sth4->execute($p->{code}); my $img = $sth4->fetchrow_hashref(); $sth4->finish; $p->{name} =~ s/<.*?>//isg; $p->{comment} =~ s/<.*?>//isg; if ($img->{id}) { $p->{image_dir} = int($img->{id} / 10000); $p->{image_id} = $img->{id}; $p->{image_ext_small} = "gif"; if (!($img->{width_small})) { $img->{image_width_small} = 0; } if (!($img->{height_small})) { $img->{image_height_small} = 0; } $p->{image_width_small} = $img->{width_small}; $p->{image_height_small} = $img->{height_small}; if (($p->{image_width_small} > 100) and ($p->{width_small} > $p->{height_small})) { $p->{image_big} = 1; } } $p->{name} = &lc_name($p->{name}); $p->{i} = $i; $i++; if ($i > 1) { $i = 0; } push @patents, $p; } $sth2->finish; # if (!$flag) { if ($#patents < 20) { #обратное наполнение #заменить информацию о категориях $sth2 = $dbh_patent->prepare("select * FROM doc_class where code = ? order by class_code asc"); $sth2->execute($rh_data->{ret_val}->{code}); while (my $class = $sth2->fetchrow_hashref()) { my $sth3 = $dbh_patent->prepare("select c,name from class where id = ?"); $sth3->execute($class->{class_id}); ($class->{c}, $class->{name}) = $sth3->fetchrow_array(); $sth3->finish; if (!$flag) { $sth3 = $dbh_patent->prepare("select b.* FROM doc_class as a, doc as b where b.no_main = false and b.verify = true and (a.class_id = $class->{class_id} or a.class_code like '$class->{class_code}%') and a.patent_id = b.id and a.code != $rh_data->{ret_val}->{code} order by id asc limit 10"); $sth3->execute(); while (my $p = $sth3->fetchrow_hashref()) { $p->{kws} = &add_kws($p->{code}); $p->{dir} = int($p->{code} / 10000); my $sth4 = $dbh_patent->prepare("select * FROM doc_img where code = ? order by id asc"); $sth4->execute($p->{code}); my $img = $sth4->fetchrow_hashref(); $sth4->finish; $p->{name} =~ s/<.*?>//isg; $p->{comment} =~ s/<.*?>//isg; if ($img->{id}) { $p->{image_dir} = int($img->{id} / 10000); $p->{image_id} = $img->{id}; $p->{image_ext_small} = "gif"; if (!($img->{width_small})) { $img->{image_width_small} = 0; } if (!($img->{height_small})) { $img->{image_height_small} = 0; } $p->{image_width_small} = $img->{width_small}; $p->{image_height_small} = $img->{height_small}; if (($p->{image_width_small} > 100) and ($p->{width_small} > $p->{height_small})) { $p->{image_big} = 1; } } $p->{name} = &lc_name($p->{name}); $p->{i} = $i; $i++; if ($i > 1) { $i = 0; } push @patents, $p; } $sth3->finish; } $class->{name} =~ s/\#//isg; } $sth2->finish; } if ($#patents < 20) { #заменить информацию о категориях $sth2 = $dbh_patent->prepare("select * FROM doc_class where code = ? order by class_code desc"); $sth2->execute($rh_data->{ret_val}->{code}); while (my $class = $sth2->fetchrow_hashref()) { my $sth3 = $dbh_patent->prepare("select c,name from class where id = ?"); $sth3->execute($class->{class_id}); ($class->{c}, $class->{name}) = $sth3->fetchrow_array(); $sth3->finish; if (!$flag) { $sth3 = $dbh_patent->prepare("select b.* FROM doc_class as a, doc as b where b.no_main = false and b.verify = true and (a.class_id = $class->{class_id} or a.class_code like '$class->{class_code}%') and a.patent_id = b.id and a.code < $rh_data->{ret_val}->{code} order by a.code desc limit 5"); $sth3->execute(); while (my $p = $sth3->fetchrow_hashref()) { $p->{dir} = int($p->{code} / 10000); $p->{kws} = &add_kws($p->{code}); my $sth4 = $dbh_patent->prepare("select * FROM doc_img where code = ? order by id asc"); $sth4->execute($p->{code}); my $img = $sth4->fetchrow_hashref(); $sth4->finish; $p->{name} =~ s/<.*?>//isg; $p->{comment} =~ s/<.*?>//isg; if ($img->{id}) { $p->{image_dir} = int($img->{id} / 10000); $p->{image_id} = $img->{id}; $p->{image_ext_small} = "gif"; if (!($img->{width_small})) { $img->{image_width_small} = 0; } if (!($img->{height_small})) { $img->{image_height_small} = 0; } $p->{image_width_small} = $img->{width_small}; $p->{image_height_small} = $img->{height_small}; if (($p->{image_width_small} > 100) and ($p->{width_small} > $p->{height_small})) { $p->{image_big} = 1; } } $p->{name} = &lc_name($p->{name}); if (!$p->{name}) { $p->{name} = "Полезная модель $p->{code}"; } $p->{i} = $i; $i++; if ($i > 1) { $i = 0; } push @patents, $p; } $sth3->finish; } $class->{name} =~ s/\#//isg; my $url = ""; if ($class->{level0}) { $url .= $class->{level0} . "/"; } if ($class->{level1}) { $url .= $class->{level1} . "/"; } if ($class->{level2}) { $url .= $class->{level2} . "/"; } if ($class->{level3}) { $url .= $class->{level3} . "/"; } $url.="$class->{class_id}/"; $class->{url} = $url; push @{$rh_data->{class}}, $class; } $sth2->finish; } if ($#patents < 20) { #обратное наполнение #заменить информацию о категориях $sth2 = $dbh_patent->prepare("select * FROM doc_class where code = ? order by class_code asc"); $sth2->execute($rh_data->{ret_val}->{code}); while (my $class = $sth2->fetchrow_hashref()) { my $sth3 = $dbh_patent->prepare("select c,name from class where id = ?"); $sth3->execute($class->{class_id}); ($class->{c}, $class->{name}) = $sth3->fetchrow_array(); $sth3->finish; if (!$flag) { # print "select b.* FROM doc_class as a, doc as b where b.no_main != true and (a.class_id = $class->{class_id} or a.class_code like '$class->{class_code}%') and a.patent_id = b.id and a.code > $rh_data->{ret_val}->{code} order by id asc limit 10\n"; $sth3 = $dbh_patent->prepare("select b.* FROM doc_class as a, doc as b where b.no_main != true and (a.class_id = $class->{class_id} or a.class_code like '$class->{class_code}%') and a.patent_id = b.id and a.code != $rh_data->{ret_val}->{code} order by id asc limit 10"); $sth3->execute(); while (my $p = $sth3->fetchrow_hashref()) { $p->{kws} = &add_kws($p->{code}); $p->{dir} = int($p->{code} / 10000); my $sth4 = $dbh_patent->prepare("select * FROM doc_img where code = ? order by id asc"); $sth4->execute($p->{code}); my $img = $sth4->fetchrow_hashref(); $sth4->finish; $p->{name} =~ s/<.*?>//isg; $p->{comment} =~ s/<.*?>//isg; if ($img->{id}) { $p->{image_dir} = int($img->{id} / 10000); $p->{image_id} = $img->{id}; $p->{image_ext_small} = "gif"; if (!($img->{width_small})) { $img->{image_width_small} = 0; } if (!($img->{height_small})) { $img->{image_height_small} = 0; } $p->{image_width_small} = $img->{width_small}; $p->{image_height_small} = $img->{height_small}; if (($p->{image_width_small} > 100) and ($p->{width_small} > $p->{height_small})) { $p->{image_big} = 1; } } $p->{name} = &lc_name($p->{name}); $p->{i} = $i; $i++; if ($i > 1) { $i = 0; } push @patents, $p; } $sth3->finish; } $class->{name} =~ s/\#//isg; } $sth2->finish; } if ($#patents > 20) { $#patents = 20; } # } $rh_data->{patents} = \@patents; $sth2 = $dbh_patent->prepare("select * FROM doc_authors where code = ?"); $sth2->execute($rh_data->{ret_val}->{code}); while (my $authors = $sth2->fetchrow_hashref()) { my $sth3 = $dbh_patent->prepare("select * FROM authors where id = ?"); $sth3->execute($authors->{authors_id}); my $h = $sth3->fetchrow_hashref(); $sth3->finish; $sth3 = $dbh_patent->prepare("select count(*) FROM doc_authors where authors_id = ?"); $sth3->execute($authors->{authors_id}); $h->{c} = $sth3->fetchrow_array(); $sth3->finish; foreach (keys %$h) { $authors->{$_} = $h->{$_}; } push @{$rh_data->{authors}}, $authors; } $sth2->finish; $sth2 = $dbh_patent->prepare("select * FROM doc_owners where code = ?"); $sth2->execute($rh_data->{ret_val}->{code}); while (my $owners = $sth2->fetchrow_hashref()) { my $sth3 = $dbh_patent->prepare("select * FROM owners where id = ?"); $sth3->execute($owners->{owners_id}); my $h = $sth3->fetchrow_hashref(); $sth3->finish; $sth3 = $dbh_patent->prepare("select count(*) FROM doc_owners where owners_id = ?"); $sth3->execute($owners->{owners_id}); $h->{c} = $sth3->fetchrow_array(); $sth3->finish; foreach (keys %$h) { $owners->{$_} = $h->{$_}; } push @{$rh_data->{owners}}, $owners; } $sth2->finish; if ($mst =~ m/ФАКСИМИЛЬНОЕ\ /is) { $mst =~ s/ФАКСИМИЛЬНОЕ\ .*?$/<\/td><\/tr><\/table>/isg; $mst .= "
" . $uniq_img; } $mst =~ s/
.*?//isg; if ($mst =~ m/\(54\)\ /is) { $mst =~ s/\(19\).*?\(54\)\ .*?<\/p>//is; } $mst =~ s/
/<\/div>/isg; $mst =~ s//<\/table>/isg; $mst =~ s/<\/TR>/<\/tr>/isg; $mst =~ s/<\/TD>/<\/td>/isg; $mst =~ s/<\/B>/<\/b>/isg; $mst =~ s/<\/FONT>/<\/font>/isg; $mst =~ s/<\/SUP>/<\/sup>/isg; $mst =~ s/<\/A>/<\/a>/isg; $mst =~ s/VALIGN/valign/isg; $mst =~ s//<\/i>/isg; $mst =~ s/<\/P>/<\/p>/isg; $mst =~ s//<\/sub>/isg; $mst =~ s/<\/P>/<\/p>/isg; $mst =~ s/

/

/isg; $mst =~ s//

 <\/p>/isg; $mst =~ s/<\/BR>//isg; $mst =~ s/IMG/img/isg; $mst =~ s/ALIGN=/align=/isg; $mst =~ s/VALIGN=/valign=/isg; $mst =~ s/ALT=/alt=/isg; $mst =~ s/SRC=/src=/isg; $mst =~ s/HREF=/href=/isg; $mst =~ s/\ align=\"ABSMIDDLE\"//isg; # CELLPADDING=0 CELLSPACING=0 BORDER=0 CLASS=" $mst =~ s/CELLPADDING=0/cellpadding=\"0\"/isg; $mst =~ s/CELLSPACING=0/cellspacing=\"0\"/isg; $mst =~ s/BORDER=0/border=\"0\"/isg; $mst =~ s/BORDER=/border=/isg; $mst =~ s/


\ \;<\/p>//is; $mst =~ s/

\ \;<\/p>//is; $mst =~ s/

\ \;<\/p>//is; $mst =~ s/

\ \;<\/p>//is; $mst =~ s/

\ \;<\/p>//is; $mst =~ s/

\ \;<\/p>//is; $mst =~ s/

\ \;<\/p>//is; $mst =~ s/

\ \;<\/p>//is; $mst =~ s/

\ \;<\/p>//is; $mst =~ s/\ \ /\ /isg; $mst =~ s/\ \ /\ /isg; $mst =~ s/\ \ /\ /isg; $mst =~ s/\ class=\"ptx2\"//isg; $mst =~ s/\ class=\"txt\"//isg; $mst =~ s///isg; $mst =~ s/<\/span>//isg; $mst =~ s/

\ \;<\/p>/
/isg; $mst =~ s/

Формула полезной модели<\/p>//isg; $mst =~ s/>\ 200000) { my $link_dir = int($link/10000); } } } if ($mst =~ m/

/is) { $mst =~ /
(.*?)<\/TABLE>/is; my $info = $1; $mst =~ s/
(.*?)<\/TABLE>//is; # $rh_data->{html2} = $info; } $mst =~ s/\.

/

/isg; $rh_data->{html} = $mst; $patent->{redaktor} =~ s/\n|\r|\t//isg; $patent->{redaktor} =~ s/\.$//isg; $patent->{redaktor} =~ s/\ $//isg; $patent->{redaktor_text} =~ s/\n/<\/p>

/isg; foreach (keys %$patent) { $rh_data->{$_} = $patent->{$_}; } return $rh_data; } sub add_kws { my $code = shift; my $sth = $dbh_patent->prepare("select a.kw_id,b.kw,b.price FROM dockw as a, kw_info as b WHERE a.kw_id = b.id and a.code = b.codemain and a.deleted = false and a.code = ? group by a.kw_id, b.kw, b.price order by b.price desc limit 3"); $sth->execute($code); my @kws; while (my $k = $sth->fetchrow_hashref()) { my $sth2 = $dbh_patent->prepare("select count(*) FROM dockw where kw_id = ?"); $sth2->execute($k->{kw_id}); my $test = $sth2->fetchrow_array(); $sth2->finish; if ($test >= 8) { push @kws, {"kw_id" => $k->{kw_id}, "kw" => $k->{kw}}; } } $sth->finish; return \@kws; }

Наверх