AKB Forums

Go Back   AKB Forums > Technical sections > Languages, Compilers and Interpreters > Web Development
Home Register Blogs FAQ Members List Calendar Downloads Arcade Mark Forums Read

Web Development Java/PHP/Perl/ASP and more

Troubles when posting message? Click here! :: Проблемы с отправлением сообщения? Нажмите сюда!

Reply
 
LinkBack Thread Tools Display Modes
Old Jul 20, 2002, 01:02   #1
Младенец
 
Join Date: Jul 2002
Location: Интернет
Posts: 13
Rep Power: 0
Reputation: 10
Question Знатокам перл-а

Кто может написать скрипт на перл-е? который бы делал следующее :

Генерировал бы 5 разных чисел от 10 до 99 & рядом с этими числами выбирал из фотографий(на каждой фотографии нарисованны числа от 10 до 99) и показывал фотографию на которой будет число которое есть в 5-и генерированных числах, если потом нажать на число показанное на фотографии он отправлял по одному УРЛ-у(например : хттп://имяхоста/логин.хтмл), а если нажать на ошибочное число(которое не нарисованно на фотографии) он отправлял по другому УРЛ-у(например : хттп://имяхоста/эррор.хтмл).

З.Ы. если это сложно написать то могу сказать другой способ более лёгкий как мне кажется.

З.Ы.Ы. Перловцы плз помогите.
WaReZ is offline   Reply With Quote Quote selected
Old Jul 20, 2002, 03:54   #2
Студент
 
Join Date: Jun 2002
Location: Yerevan
Posts: 258
Rep Power: 7
Reputation: 10
Post

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=&quot;post&quot; action=&quot;thiscgi.cgi&quot;>, i kartinki stav' pri pomoschi <input type=&quot;image&quot;>.
# 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 &quot;img&quot; i kogda budesh' click delat' na kartinku, on pridet v etot cgi s $img ravnym &quot;_10_54_90_&quot;
# 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 &quot;Content-type: text/html\n\n&quot;;
    open (PAGE, &quot;http://www.rightpage.com&quot;);
    while (<PAGE>) {
      print;
    }
    exit(0);
  }
}
# didn't find the number, open the wrong page:
print &quot;Content-type: text/html\n\n&quot;;
open (PAGE, &quot;http://www.wrongpage.com&quot;);
while (<PAGE>) {
  print;
}
exit(0);
Hope this helps.
__________________
http://www.d-brane.com
Eddi is offline   Reply With Quote Quote selected
Old Jul 21, 2002, 13:15   #3
Младенец
 
Join Date: Jul 2002
Location: Интернет
Posts: 13
Rep Power: 0
Reputation: 10
Post

сорри, можеш мне полностью написать, я перл незнаю.
WaReZ is offline   Reply With Quote Quote selected
Old Jul 21, 2002, 17:18   #4
Консервативный Демагог
 
VX's Avatar
 
Join Date: Jan 2002
Location: Кавказская Албания
Posts: 889
Rep Power: 7
Reputation: 10
Post

>>> open (PAGE, "http://www.rightpage.com"); <<<<
VNIMANIE TAKOY KONSTUKCTSII V PERKE NE SUSHESTVUET!
__________________
Праздник к нам приходит...

|^^^^^^^^^'''^\| ||\__
| ВОДКА-ВОДКА | ||','''|'''''''\_____,_
| _..... _ | ||_ _|'__|_____||.........| |
'(@)'(@)'(@)''''''''''''''''''''''*|(@)""""|(@)*
VX is offline   Reply With Quote Quote selected
Old Jul 21, 2002, 17:19   #5
Консервативный Демагог
 
VX's Avatar
 
Join Date: Jan 2002
Location: Кавказская Албания
Posts: 889
Rep Power: 7
Reputation: 10
Post

Quote:
Originally posted by WaReZ:
сорри, можеш мне полностью написать, я перл незнаю.
A zachem togda vasbhe na perle sprashiwat', ili tebe gotowoe reshenie "pod kluch" nujno??

Oswobojues' mojet i napishu
__________________
Праздник к нам приходит...

|^^^^^^^^^'''^\| ||\__
| ВОДКА-ВОДКА | ||','''|'''''''\_____,_
| _..... _ | ||_ _|'__|_____||.........| |
'(@)'(@)'(@)''''''''''''''''''''''*|(@)""""|(@)*
VX is offline   Reply With Quote Quote selected
Old Jul 21, 2002, 20:33   #6
Студент
 
Join Date: Jun 2002
Location: Yerevan
Posts: 258
Rep Power: 7
Reputation: 10
Post

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
2 VX
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
Eddi is offline   Reply With Quote Quote selected
Old Jul 22, 2002, 12:36   #7
Младенец
 
Join Date: Jul 2002
Location: Интернет
Posts: 13
Rep Power: 0
Reputation: 10
Post

"под ключ" - это за бабло чтоли ?
мне нужно фрии. Неужели это так трудно сделать ?
WaReZ is offline   Reply With Quote Quote selected
Old Jul 22, 2002, 15:48   #8
Студент
 
Join Date: Jun 2002
Location: Yerevan
Posts: 258
Rep Power: 7
Reputation: 10
Post

2 WaReZ
Ty to chto napisano xot' poproboval-to?!
__________________
http://www.d-brane.com
Eddi is offline   Reply With Quote Quote selected
Old Jul 23, 2002, 02:02   #9
Младенец
 
Join Date: Jul 2002
Location: Интернет
Posts: 13
Rep Power: 0
Reputation: 10
Post

Cорри, непробовал т.к. мне нужен полный скрипт а не кусочек. Cпасибки, что хоть стока написал.
WaReZ is offline   Reply With Quote Quote selected
Old Jul 23, 2002, 08:04   #10
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: Jan 2002
Location: hell
Posts: 124
Rep Power: 7
Reputation: 10
Send a message via ICQ to Dark Abyss of Yerevan
Post

Вот. Имена картинок должны быть в формате 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=&quot;http://www.yahoo.com&quot;;	# correct answer
    $url2=&quot;http://www.google.com&quot;;	# wrong answer
    $images_path=&quot;&quot;;			# images folder '/' ended
					# e.g. &quot;images/&quot; 
    # 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 &quot;Location:$url1\n\n&quot;;
	} else {
	    print &quot;Location:$url2\n\n&quot;;
	}
    
    } else {	
	# generate html

        print &quot;Content-Type: text/html\n\n&quot;;
	# 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 &quot;<img src='$images_path$image_number.gif'>\n&quot;;
	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 &quot;<a href='$script_name?$_&$image_number'>$_</a> \n&quot;;
	}
	


    }
    print <<HTML_END;

 </body>
</html>

HTML_END

    # E N D   S C R I P T   B O D Y #########################
__________________
[x]-=-[ ]-=-[x]
Dark Abyss of Yerevan is offline   Reply With Quote Quote selected
Old Jul 24, 2002, 14:08   #11
Младенец
 
Join Date: Jul 2002
Location: Интернет
Posts: 13
Rep Power: 0
Reputation: 10
Post

Спасибо Dark Abyss of Yerevan, скрипт работает.
& ещё вопрос ту алл : как проверить включена ли графика ? на джаваскрипте я знаю как это делается а вот на перле нет.
WaReZ is offline   Reply With Quote Quote selected
Old Jul 25, 2002, 07:26   #12
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: Jan 2002
Location: hell
Posts: 124
Rep Power: 7
Reputation: 10
Send a message via ICQ to Dark Abyss of Yerevan
Post

Quote:
Originally posted by WaReZ:
Спасибо Dark Abyss of Yerevan, скрипт работает.
& ещё вопрос ту алл : как проверить включена ли графика ? на джаваскрипте я знаю как это делается а вот на перле нет.
Не уверен что можно напрямую получить конфигурацию броузера.
Обычно в таких случаях используют javascript+cgi. Например,
спайлог использует именно этот метод, а именно javascriptom
собирает всю инфу а потом передает ее cgi скрипту через
QUERY_STRING. This should work.
__________________
[x]-=-[ ]-=-[x]
Dark Abyss of Yerevan is offline   Reply With Quote Quote selected
Old Jul 25, 2002, 07:34   #13
Консервативный Демагог
 
VX's Avatar
 
Join Date: Jan 2002
Location: Кавказская Албания
Posts: 889
Rep Power: 7
Reputation: 10
Post

Abyss jan ya dumau cto poluchenie patha=a scripta ludshe delate' pro pomohsi $script_name = $ENV{SCRIPT_NAME}, tak bezopasnie
__________________
Праздник к нам приходит...

|^^^^^^^^^'''^\| ||\__
| ВОДКА-ВОДКА | ||','''|'''''''\_____,_
| _..... _ | ||_ _|'__|_____||.........| |
'(@)'(@)'(@)''''''''''''''''''''''*|(@)""""|(@)*
VX is offline   Reply With Quote Quote selected
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 02:44.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
This board was founded on September 29, 2001
Powered by Viper Internet

Affordable Web Hosting | ParevNet

Buy text link