![]() | |
| |||||||
| Home | Register | Blogs | FAQ | Members List | Calendar | Downloads | Arcade | Mark Forums Read |
| Web Development Java/PHP/Perl/ASP and more |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 |
| Младенец Join Date: Jul 2002 Location: Интернет
Posts: 13
Rep Power: 0 Reputation:
10 | Кто может написать скрипт на перл-е? который бы делал следующее : Генерировал бы 5 разных чисел от 10 до 99 & рядом с этими числами выбирал из фотографий(на каждой фотографии нарисованны числа от 10 до 99) и показывал фотографию на которой будет число которое есть в 5-и генерированных числах, если потом нажать на число показанное на фотографии он отправлял по одному УРЛ-у(например : хттп://имяхоста/логин.хтмл), а если нажать на ошибочное число(которое не нарисованно на фотографии) он отправлял по другому УРЛ-у(например : хттп://имяхоста/эррор.хтмл). З.Ы. если это сложно написать то могу сказать другой способ более лёгкий как мне кажется. З.Ы.Ы. Перловцы плз помогите. |
| | |
| | #2 |
| Студент Join Date: Jun 2002 Location: Yerevan
Posts: 258
Rep Power: 7 Reputation:
10 | Ya na perle ne pisal tak chto znaniya chisto teoreticheskie no dumayu the following should work: Code: # v tvoem cgi-e vyzyvaesh' vo pervyx
srand ( time );
# t.k. tebe nado budet znat' kakie imenno cifry narisovanny na kartinke, postav' eti kartinki na html-e v <form method="post" action="thiscgi.cgi">, i kartinki stav' pri pomoschi <input type="image">.
# v input-e value napishi cifry kotorye est' na kartinke: e.g. _10_54_90_ (esli na kartinke cifry 10, 54 i 90 ), a name napishi dlya vse say "img" i kogda budesh' click delat' na kartinku, on pridet v etot cgi s $img ravnym "_10_54_90_"
# i tebe nado budet vsego lish' prochitat' eti cifry, i.e. smth like this:
for ( $i = 0; $i < 5; $i++ ) {
$num = 10 + int( rand( 90 ) );
if ( $img =~ m/_($num)_/ ) {
# and here I have no idea how to redirect to some page, but this will work I guess
print "Content-type: text/html\n\n";
open (PAGE, "http://www.rightpage.com");
while (<PAGE>) {
print;
}
exit(0);
}
}
# didn't find the number, open the wrong page:
print "Content-type: text/html\n\n";
open (PAGE, "http://www.wrongpage.com");
while (<PAGE>) {
print;
}
exit(0);
__________________ http://www.d-brane.com |
| | |
| | #4 |
| Консервативный Демагог Join Date: Jan 2002 Location: Кавказская Албания
Posts: 889
Rep Power: 7 Reputation:
10 | >>> open (PAGE, "http://www.rightpage.com"); <<<< VNIMANIE TAKOY KONSTUKCTSII V PERKE NE SUSHESTVUET!
__________________ Праздник к нам приходит... |^^^^^^^^^'''^\| ||\__ | ВОДКА-ВОДКА | ||','''|'''''''\_____,_ | _..... _ | ||_ _|'__|_____||.........| | '(@)'(@)'(@)''''''''''''''''''''''*|(@)""""|(@)* |
| | |
| | #5 | |
| Консервативный Демагог Join Date: Jan 2002 Location: Кавказская Албания
Posts: 889
Rep Power: 7 Reputation:
10 | Quote:
Oswobojues' mojet i napishu
__________________ Праздник к нам приходит... |^^^^^^^^^'''^\| ||\__ | ВОДКА-ВОДКА | ||','''|'''''''\_____,_ | _..... _ | ||_ _|'__|_____||.........| | '(@)'(@)'(@)''''''''''''''''''''''*|(@)""""|(@)* | |
| | |
| | #6 |
| Студент Join Date: Jun 2002 Location: Yerevan
Posts: 258
Rep Power: 7 Reputation:
10 | It is a full code (you'll probably need to add #!/usr/bin/perl in the beginning, the main ideas are written inside the comments - strings beginning with #), but one more time, it's fully theoretical. This is smth else, you can try for web page redirection part: Code: print <<EOF; Content-type: text/html Location: http://www.whatever.com (tut enter vmesto etoj strochki - prosto ubb ego ubiraet, esli prosto enter budet) EOF Dear VX, naschet open-a - eto pervoe chto ya nashel v inete i esli ty znaesh' chto eto nepravil'no, ty dolgen znat' kak open sdelat' web page pravil'no, i mog by napisat', vmesto togo chtoby abstraktno obeschat' sdelat' kogda/esli osvobodish'sya.
__________________ http://www.d-brane.com |
| | |
| | #8 |
| Студент Join Date: Jun 2002 Location: Yerevan
Posts: 258
Rep Power: 7 Reputation:
10 | 2 WaReZ Ty to chto napisano xot' poproboval-to?! ![]()
__________________ http://www.d-brane.com |
| | |
| | #10 |
| Дошкольник | Вот. Имена картинок должны быть в формате X.gif, где X - соответствующая цифра. С тебя пиво! Code: #!/usr/bin/perl
# Visual verification by abyss
# Tue Jul 23 02:39:41 2002
# S E T T I N G S #######################################
$number_of_nums=5;
$min_number=10;
$max_number=99;
$url1="http://www.yahoo.com"; # correct answer
$url2="http://www.google.com"; # wrong answer
$images_path=""; # images folder '/' ended
# e.g. "images/"
# S C R I P T B O D Y #################################
# get the query string
$num=$ENV{'QUERY_STRING'};
if ($num){
# $num is set so we have a query string
($n1,$n2)=split /&/,$num;
if ($n1==$n2){
print "Location:$url1\n\n";
} else {
print "Location:$url2\n\n";
}
} else {
# generate html
print "Content-Type: text/html\n\n";
# paste all your html that should appear before the image
# and the numbers here
print <<HTML_START;
<html>
<head><title>Visual verification</title></head>
<body>
HTML_START
# generate 5 numbers
srand (time);
for ($i=0;$i<$number_of_nums;$i++){
# make sure we wont have duplicate numbers
do {
$new_number= $min_number+int rand($max_number-$min_number+1);
} until (@numbers!~/$new_number/);
push @numbers,$new_number
} # end for
$image_number=$numbers[int rand $number_of_nums];
print "<img src='$images_path$image_number.gif'>\n";
print <<HTML_MIDDLE;
Click on the number that is highlighted on the image
HTML_MIDDLE
# $0 contains script name with full address,
# parse it and get the script name without address.
$0 =~ /([^\/]+$)/;
$script_name=$1;
foreach(@numbers){
print "<a href='$script_name?$_&$image_number'>$_</a> \n";
}
}
print <<HTML_END;
</body>
</html>
HTML_END
# E N D S C R I P T B O D Y #########################
__________________ [x]-=-[ ]-=-[x] |
| | |
| | #12 | |
| Дошкольник | Quote:
Обычно в таких случаях используют javascript+cgi. Например, спайлог использует именно этот метод, а именно javascriptom собирает всю инфу а потом передает ее cgi скрипту через QUERY_STRING. This should work.
__________________ [x]-=-[ ]-=-[x] | |
| | |
| | #13 |
| Консервативный Демагог Join Date: Jan 2002 Location: Кавказская Албания
Posts: 889
Rep Power: 7 Reputation:
10 | Abyss jan ya dumau cto poluchenie patha=a scripta ludshe delate' pro pomohsi $script_name = $ENV{SCRIPT_NAME}, tak bezopasnie ![]()
__________________ Праздник к нам приходит... |^^^^^^^^^'''^\| ||\__ | ВОДКА-ВОДКА | ||','''|'''''''\_____,_ | _..... _ | ||_ _|'__|_____||.........| | '(@)'(@)'(@)''''''''''''''''''''''*|(@)""""|(@)* |
| | |