#Paulo Costa Carvalho #Do Not modify or read this module without my authorization #paulo@buscario.com.br #Object Flowchart Module #Disclosure : This program can´t be read, distributed, copied or modified without #my written permission. - Abril 25 2004 package hp; use strict; use common; ################################################################################ #Constructor use Class::Struct; struct hp => { id => '$', nome => '$', email => '$', fundo => '$', titulo =>'$', sub_titulo => '$', texto => '$', links => '$', html => '$', separador => '$', gif => '$', email_gif => '$', target => '$', user_id => '$', quando => '$', palavras_chave => '$', nome_email => '$', comercial => '$', }; sub init { my ($self, %args) = @_; %{$self} = %args; return $self; } sub load_me { my ($self) = @_; my ($h, %sqldata, $sth); my $dbh = common::dbiconnect(); my $user_id = $_[1]; my $html = $_[2]; #Get the data $sth = $dbh->prepare('SELECT * FROM hp where id = (?) AND html = (?)') or dienice ("Falha na preparação da busca
$DBI::errstr"); my $rv = $sth->execute($user_id, $html) or common::dienice("Cant´t execute querry in database
$DBI::errstr"); while ($h = $sth->fetchrow_hashref) {%sqldata=%{$h};} #If there are no results, warn the user if ($rv == 0) {common::dienice("Favor verificar ID e página (->$user_id<-, ->$html<-)");} #Lets return our search %{$self} = %sqldata; return $self; } ################################################################################ ################################################################################ sub hp_form { my ($self) = @_; print <
Este sistema está em desenvolvimento é breve possuirá novas melhorias e gráficos

Dicas:
1 - Nome da HTML:: o endereço de sua pagine será http://buscario.com.br/hpg/nome.shtml
2 - Na parte texto ::
a.)para criar nova linha digite <br>
b.)Para escrever em negrito digite o texto deve ficar entre as chaves <b> e </b>; exemplo <b>texto em negrito</b>
c.)Para criar um link <a href = "http://endereco_na_internet">Nome do link</a>


EOF option("Nome HTML", "html", "$self->{html}"); option("Titulo da Home Page", "titulo", "$self->{titulo}"); option("Sub-Título", "sub_titulo", "$self->{sub_titulo}"); option("Nome (do Email)", "nome", "$self->{nome}"); option("Email", "email", "$self->{email}"); dir_pulldown("Imagens Web Site", "gif", "images/pictures", "$self->{gif}"); dir_pulldown("Separador", "separador", "images/lines", "$self->{separador}"); dir_pulldown("Fundo", "fundo", "images/backgrounds", $self->{fundo}); dir_pulldown("Imagem para Email", "email_gif", "images/email", $self->{email_gif}); #Correct variable texto $self->{texto} =~ s/\n//g; print <
Texto:
EOF }# End hp_form ################### sub log_form { my ($self) = @_; print < EOF option("e-mail", "email", "$self->{email}"); option("ID", "id", "$self->{id}"); print <
EOF } ############### sub write_shtml { my ($self) = @_; my $temp_file = "default.shtml"; $self->{template} = "traffic_builder.shtml" if ($self->{user_id} == 26 or $self->{id} == 26); $temp_file = "$self->{template}" if ($self->{template}); my $template = common::get_file("templates/shtml/$temp_file"); #Graficos $template = alter_template($template, "email_gif", 1); $template = alter_template($template, "separador", 1); $template = alter_template($template, "gif", 1); #Texto $template = alter_template($template, "titulo", 0); $template = alter_template($template, "fundo", 0); $template = alter_template($template, "sub_titulo", 0); $template = alter_template($template, "email", 0); $template = alter_template($template, "nome", 0); $template = alter_template($template, "texto", 0); $template = alter_template($template, "comercial", 0); $template = alter_template($template, "links", 0); my $filename= $self->{html}.".shtml"; open (WRITE, ">hp/$filename") or common::dienice($!); print WRITE "$template" or common::sendmail("paulo\@buscario.com.br","Problemas HPG - locazip","Problemas ao escrever no arquivo $self->{html}\nErro: $!\n\n"); close(WRITE); #Private methods sub alter_template { #The field g should be true if we are dealing with graphics my ($temp, $field, $g) = ($_[0], $_[1], $_[2]); my $graphic = "{$field}\">"; if ($g) { if ($self->{$field} eq "Selecione") { $temp =~ s/--$field--//g; } else {$temp =~ s/--$field--/$graphic/g;} } else { $temp =~ s/--$field--/$self->{$field}/g;} return ($temp); } } ################################ sub write_sql { my ($self) = @_; my $dbh = common::dbiconnect(); my ($h, %sqldata, $sth); common::dienice("Uso de comando javascript não permitido, favor remover (window.setTimeout)") if ($self->{texto} =~ /window\.setTimeout/i); common::dienice("Uso de comando javascript não permitido, favor remover (window.setTimeout)") if ($self->{titulo} =~ /window\.setTimeout/i); common::dienice("Uso de comando javascript não permitido, favor remover (window.setTimeout)") if ($self->{sub_titulo} =~ /window\.setTimeout/i); #Check to if file exists and if file belongs to user my $file_exists = 0; $sth = $dbh->prepare('SELECT id FROM hp WHERE html = (?)') or dienice ("Falha na preparação da busca
$DBI::errstr"); $file_exists = $sth->execute($self->{html}) or dienice ("Cant´t execute querry in database
$DBI::errstr"); my $file_user = $sth->fetchrow_array if ($file_exists ne "0E0"); #Verify other mistakes #Verifica se o nome no email esta ok if ($self->{nome} and $self->{email} eq "") {common::dienice("Favor entre com um email");} if ($self->{email} and $self->{nome} eq "") { $self->{nome} = $self->{email}; common::dienice("Favor entre com um email válido") unless ($self->{email} =~ /.*\@.*\..*/); } #Verify file name common::dienice("Favor entre com um nome de arquivo") unless ($self->{html}); common::dienice("Caractere ilegal no nome do arquivo") if ($self->{html} =~ /[\.|#|\$|!|\@|%|\^|\*|\(|\)]/); common::dienice("Nome de arquivo inválido") if ($self->{html} =~ /index/); common::dienice("Favor entre com alguma informação na página a ser criada") unless ($self->{texto} or $self->{titulo} or $self->{sub_titulo}); #Verify common mistakes if ($file_exists ne "0E0") { common::dienice("O arquivo ($self->{html}.shtml) já pertence a outro usuário, favor selecione outro $file_user != $self->{user_id}\n") if ($file_user != $self->{user_id}); } ##Verificar quantas paginas o usuario tem e impor limite de 500 if ($self->{user_id} != 26) { $sth = $dbh->prepare('SELECT id FROM hp WHERE id = (?)') or dienice ("Falha na preparação da busca
$DBI::errstr"); my $rv2 = $sth->execute($self->{user_id}) or dienice ("Cant´t execute querry in database
$DBI::errstr"); common::dienice("Limite de páginas por usuaio atingido, favor entre em contato conosco para que possamos aumentar o seu limite") if ($rv2 eq "500"); } #Write to SQL $dbh->do("DELETE FROM hp where html = '$self->{html}'") or common::dienice("Error :: $DBI::errstr") if ($file_exists ne "0E0"); $sth = $dbh->prepare('INSERT INTO hp values (?,?,?,?,?,?,?,?,?,?,?,NOW(),?,?,?,?,?,?,?,?,?,?)') or dienice ("Falha na preparação da busca
$DBI::errstr"); $sth->execute($self->{user_id}, $self->{categoria}, $self->{fundo}, $self->{titulo}, $self->{sub_titulo}, $self->{texto}, "",$self->{html}, $self->{gif}, $self->{separador}, $self->{email_gif}, $self->{palavras_chave}, "", $self->{nome}, $self->{email}, $self->{template}, "", "", "", "", "") or common::dienice ("Cant´t execute querry in database
$DBI::errstr"); } #Private Subs################### sub option { #lets get the working variables my $title = "$_[0]"; my $field_name = "$_[1]"; my $field_value = "$_[2]"; print < $title: EOF }#End Option #### sub dir_pulldown { my $title = $_[0]; my $field_name = $_[1]; my $directory = $_[2]; my $selected = $_[3]; my @options = <$directory/*>; my $menu = " [Ver Imagens]\n"; print < $title: $menu EOF } ############################### sub DESTROY { my $self = shift; #printf("$self dying at %s\n", scalar localtime); } ############################### 1;