Jump to content


Photo

Replace


  • Faça o login para participar
4 replies to this topic

#1 contrata-se

contrata-se

    Novato no fórum

  • Usuários
  • 16 posts
  • Sexo:Não informado

Posted 12/10/2006, 20:34

No php eu sei que tem como por exemplo um usuario entrar no bate papo com nome de joao o sistema passa o nome pra jose caso vc crie um replace de troca de nome no CGI tb eh possivel?

#2 ScriptsNan

ScriptsNan

    Turista

  • Usuários
  • 45 posts
  • Sexo:Não informado
  • Localidade:Brasilia DF

Posted 13/10/2006, 22:11

o.O
nao seria so colocar um if?

$nome = "jose" if ($nome eq "joao");

se quiser criar funcao pra isso....

$entrada = &trocanome("joao");

sub trocanome() {
$nome = @_;
if ($nome eq "joao") { return "jose"; }
else { return "$nome"; }
}


sei la
tem infinitas maneiras ;)

#3 jgcl

jgcl

    João Gabriel C. Laass, Serra/ES

  • Usuários
  • 559 posts
  • Sexo:Não informado
  • Localidade:Serra / ES
  • Interesses:Tudo!

Posted 14/10/2006, 16:35

o negócio é você formar um belo banco de dados com as sugestões...

*já parou pra pensar o que o google fez?
João Gabriel
Site >> joaogabriel.org
CGiClube.net >> http://www.cgiclube.net
Vitória Perl Mongers >> http://vitoria.pm.org

#4 contrata-se

contrata-se

    Novato no fórum

  • Usuários
  • 16 posts
  • Sexo:Não informado

Posted 22/10/2006, 09:14

nesse codigo como eu faco?:?

#!/usr/bin/perl

$ver = 'Chat versao 2.0';
require './jcode.pl';

# タイトル名
$title = "Chat TodosAqui.net";

# タイトル文字の色
$t_color = "#008040";

# 背景色、文字色等を指定
$bground = "#FE9901"; # 壁紙を使用する場合 (http://から記述)
$bgcolor = "#FE9901"; # 背景色
$text = "#000000"; # 文字色
$link = "#0000FF"; # リンク色(訪問済)
$vlink = "#800080"; #  〃  (既訪問)
$alink = "#DD0000"; #  〃  (訪問中)

# 最大保有記事数
$max = 20;

# 戻り先のURL (http://から記述してもよい)
$homepage = 'http://www.todosaqui.net';

# タグの許可 (0=no 1=yes)
$tagkey = 1;

# スクリプト名 (この掲示板のファイル名)
$script = "./chat.cgi";

# ログファイル(フルパスで記述する場合は / から始まるパス)
$logfile = "./i-chat.log";

# 参加者ファイル(フルパスで記述する場合は / から始まるパス)
$memfile = "./member.dat";

# methodの形式 (POST or GET)
$method = 'POST';

# 入退室のあいさつ
$in_msg = ' Acabou de entrar na sala'; # 入室あいさつ
$out_msg = ' acabou de sair da sala'; # 退室あいさつ

# 発言後フォーカスをフォームへ自動移動 (0=no 1=yes)
$jvfocus = 1;

# ファイルロックの指定 (0=no 1=yes)
$lockkey = 0;

# ロックファイル名(フルパスで記述する場合は / から始まるパス)
$lockfile = "./lock/i-chat.lock";

$mail = "bruno@todosaqui.net" ;
#============#
# 設定完了 #
#============#

# メイン処理
&decode;
if ($mode eq "regist" && $com) { &regist; }
elsif ($mode eq 'into') { &regist('into'); }
elsif ($mode eq 'out') { &out; }
&html;

#--------------#
# 記事表示部 #
#--------------#
sub html {
# 表示開始
&header;

if ($mode eq 'into' || $mode eq 'regist') {
print "<form name=\"windy\" method=\"$method\" action=\"$script\">\n";
print "<input type=hidden name=mode value=\"regist\">\n";
print "<input type=hidden name=name value=\"$name\" istyle=\"3\">\n";
print "<input type=hidden name=email value=\"$email\" istyle=\"3\">\n";
print "<center>■$title</center><br>";

print "<font color=red><center>■(LpG)!!gata.tatuada!!■<br>■TodosAqui.net■<br>■So LOVE■<br>■Te amo muito■</center></font>";

print "<input type=text name=comment size=16 istyle=\"3\"><br>";
print "<input type=submit value=\"Enviar/Atualizar\">";
print "</form></select>\n";
print "<form method=\"$method\" action=\"$script\">\n";
print "<input type=hidden name=mode value=\"out\">\n";
print "<input type=hidden name=name value=\"$name\">\n";
print "<input type=submit value=\"Sair\"></form>\n";
# 参加者表示
&member;
print "<hr>($num) usuarios online <br>\n";
}
else {
# クッキーを取得
&get_cookie;

print "[<a href=\"$homepage\">TOP</a>]\n";
print "<center><font color=\"$t_color\">$title</font><hr></center>\n";
print "<form method=\"$method\" action=\"$script\">\n";
print "<input type=hidden name=mode value=\"into\">\n";
print "Nome<br>\n";
print "<input type=text name=name size=16 value=\"$c_name\" istyle=\"3\"><br>\n";
print "E-mail<br>\n";
print "<input type=text name=email size=16 value=\"$c_email\" istyle=\"3\"><br>\n";
print "<input type=submit value=\"Entrar na sala\">\n";
print "</form>\n";

}

# ログを展開
open(IN,"$logfile") || &error("Open Error : $logfile");
while (<IN>) {
$head = $point;
local($date,$name,$mail,$com,$color,$ip) = split(/<>/);

if ($mail) { $name = "<a href=\"mailto\:$mail\">$name</a> "; }

print "<hr>$name>$com<br> $date \n";

}
close(IN);

# 著作権表示(削除禁止)
print "<hr><center><!-- $ver -->\n";
print "- <a href='http://www.todosaqui.net/' target='_top'>TodosAqui.net</a> -\n";
print "</center>\n";
print "<P align=right>$ver\n</body></html>\n";
exit;
}

#--------------------#
# ログ書き込み処理 #
#--------------------#
sub regist {
# 名前の入力がなければエラー
if ($in{'name'} eq "") { &error("Coloque seu nome"); }

if ($_[0] eq 'into') {
&set_cookie;

$n_name = "TodosAqui.net informa";
$com = "<font color=red>$name</font>" . "$in_msg";
$n_email = "";
$n_color = $text;
}
elsif ($_[0] eq 'out') {
$n_name = "TodosAqui.net informa";
$com = "$name" . "$out_msg";
$n_email = "";
$n_color = $text;
}
else {
$n_name = $name;
$n_email = $email;
$n_color = $color;
}

# ファイルロック
if ($lockkey) { &lock; }

# ログを読み込み
open(IN,"$logfile") || &error("Open Error : $logfile");
@lines = <IN>;
close(IN);

# 最大記事数処理
while ($max <= @lines) { pop(@lines); }

# ログ更新処理
unshift (@lines,"$date<>$n_name<>$n_email<>$com<>$n_color<>$addr<>\n");
open(OUT,">$logfile") || &error("Write Error : $logfile");
print OUT @lines;
close(OUT);

# ロック解除
if ($lockkey) { &unlock; }
}

#------------#
# 退室処理 #
#------------#
sub out {
&regist('out');

&header;
print "<center>$name、obrigado por usar nosso chat。<br>\n";
print "[<a href=\"$homepage\" target=\"_top\">Voltar</a>]</center><P>\n";
print "</body></html>\n";
exit;
}

#----------------#
# デコード処理 #
#----------------#
sub decode {
if ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
} else { $buffer = $ENV{'QUERY_STRING'}; }
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

# 文字コード変換
&jcode'convert(*value,'sjis');

# タグ処理
if ($tagkey) {
$value =~ s/<!--(.|\n)*-->//g;
$value =~ s/<>/&lt;&gt;/g;
} else {
$value =~ s/</&lt;/g;
$value =~ s/>/&gt;/g;
$value =~ s/\"/&quot;/g;
}

$value =~ s/\n//g;
$value =~ s/\r//g;
$value =~ s/\t//g;

$in{$name} = $value;
}

$name = $in{'name'};
$com = $in{'comment'};
$email = $in{'email'};
$mode = $in{'mode'};
$color = $in{'color'};

# 時間の取得
$ENV{'TZ'} = "JST-9";
$times = time;
($sec,$min,$hour,$mday,$mon) = localtime($times);

# 日時のフォーマット
$date = sprintf("%02d/%02d-%02d:%02d:%02d",$mon+1,$mday,$hour,$min,$sec);

# IPアドレスを取得
$addr = $ENV{'REMOTE_ADDR'};
if ($name eq "") { $name = $addr; }
}

#------------------#
# クッキーの発行 #
#------------------#
sub set_cookie {
# クッキーは60日間有効
($secg,$ming,$hourg,$mdayg,$mong,$yearg,$wdayg) = gmtime(time + 60*24*60*60);

@mons = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
@week = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');

$gm_date = sprintf("%s\, %02d-%s-%04d %02d:%02d:%02d GMT",
$week[$wdayg],$mdayg,$mons[$mong],$yearg+1900,$hourg,$ming,$secg);
$cook = "name\:$name\,email\:$email\,color\:$color";
print "Set-Cookie: WINDY=$cook; expires=$gm_date\n";
}

#------------------#
# クッキーを取得 #
#------------------#
sub get_cookie {
$cookie = $ENV{'HTTP_COOKIE'};

@pairs = split(/;/, $cookie);
foreach $pair (@pairs) {
local($name, $value) = split(/=/, $pair);
$name =~ s/ //g;
$DUMMY{$name} = $value;
}
@pairs = split(/,/, $DUMMY{'WINDY'});
foreach $pair (@pairs) {
local($name, $value) = split(/:/, $pair);
$COOKIE{$name} = $value;
}
$c_name = $COOKIE{'name'};
$c_email = $COOKIE{'email'};
$c_color = $COOKIE{'color'};

if ($in{'name'}) { $c_name = $in{'name'}; }
if ($in{'email'}) { $c_email = $in{'email'}; }
if ($in{'color'}) { $c_color = $in{'color'}; }
}

#--------------#
# エラー処理 #
#--------------#
sub error {
if ($lockflag) { &unlock; }

&header;
print "<center><h3>ERROR !</h3>\n";
print "<font color=red><B>$_[0]</B></font></center>\n";
print "</body></html>\n";
exit;
}

#--------------#
# ロック処理 #
#--------------#
sub lock {
$lockflag=1;
local($retry) = 5;
while (!mkdir($lockfile, 0755)) {
if (--$retry <= 0) { &error('LOCK is BUSY'); }
sleep(1);
}
$lockflag=1;
}

#--------------#
# ロック解除 #
#--------------#
sub unlock {
rmdir($lockfile);
$lockflag=0;
}

#------------------#
# HTMLのヘッダー #
#------------------#
sub header {
print "Content-type: text/html\n\n";
print "<html>\n<head>\n";
print "<META HTTP-EQUIV=\"Content-type\" CONTENT=\"text/html; charset=Shift_JIS\">\n";

# 発言後フォーカスをフォームへ自動移動 (kapiさん式)
if (($jvfocus && $mode eq 'into') || ($jvfocus && $mode eq 'regist')) {

$focus = " onLoad=\"return textfocus()\"";
print "<script language=\"JavaScript\">\n";
print "<!--\n";
print "function textfocus(){\n";
print "document.windy.comment.focus();\n";
print "return true;\n";
print "}\n";
print "//-->\n";
print "</script>\n";
}

print "<title>$title</title></head>\n";
print "<body background=\"$bground\" bgcolor=\"$bgcolor\" text=\"$text\" link=\"$link\" vlink=\"$vlink\" alink=\"$alink\"$focus>\n";
}

#--------------#
# 在室者処理 #
#--------------#
sub member {
open(IN,"$memfile") || &error("Open Error : $memfile");
@data = <IN>;
close(IN);

$member="";
@new=();
$flag=0;
$flag2=0;
foreach (@data) {
($time2,$name2,$host2) = split(/<>/);
# 60秒以上発言のない者は削除
if ($times-60 > $time2) { next; }
elsif ($host2 eq "$addr") {
# 退室者は削除
if ($_[0] eq 'bye') { next; }

# ホスト名が同一であれば時間と名前を更新
$_ = "$times<>$name<>$addr<>\n";
$name2 = $name;
$flag=1;
}
# 更新用配列 @new に追加
if ($name2 ne "$host2") {
push(@new,$_);

# 参加者表示用文字列を作成
if (!$flag2) { $member .= "$name2◇"; $flag2=1; }
else { $member .= "$name2◆"; $flag2=0; }
}
}
# 新規参加者を追加
if (!$flag && !$bye) {
if ($name ne "$host") {
push(@new,"$times<>$name<>$addr<>\n");
if (!$flag2) { $member .= "$name◇"; }
else { $member .= "$name◆"; }
}
}
# 参加者数を認識
$num = @new;

# ファイル更新
open(OUT,">$memfile") || &error("Write Error : $memfile");
eval "flock(OUT,2);";
truncate(OUT,0);
seek(OUT,0,0);
print OUT @new;
close(OUT);
}



#5 Whitesnake

Whitesnake
  • Visitantes

Posted 04/11/2006, 22:37

Putz...script japones! q zica! uahauhauaha
+ vamu lah...

acha essa parte aqui no script:

#--------------------#
# ログ書き込み処理 #
#--------------------#
sub regist {
# 名前の入力がなければエラー
if ($in{'name'} eq "") { &error("Coloque seu nome"); }



é só ir fazendo os ifs em sequenciase adicionando as correções... por ex:

#--------------------#
# ログ書き込み処理 #
#--------------------#
sub regist {
# 名前の入力がなければエラー
if ($in{'name'} eq "") { &error("Coloque seu nome"); }

if ($in{'name'} eq "Joao") { $in{'name'} eq "João"}






0 user(s) are reading this topic

0 membro(s), 0 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq