Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 18.191.205.110
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /proc/2/root/proc/3/root/proc/3/cwd/proc/2/cwd/usr/share/doc/libcgi-pm-perl/examples/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /proc/2/root/proc/3/root/proc/3/cwd/proc/2/cwd/usr/share/doc/libcgi-pm-perl/examples/cookie.cgi
#!/usr/bin/perl

use strict;
use warnings;

use CGI;
use Template;

my $cgi = CGI->new;

my $template_vars = {
	animals => [
		sort qw/lion tiger bear pig porcupine ferret zebra gnu ostrich
			emu moa goat weasel yak chicken sheep hyena dodo lounge-lizard
			squirrel rat mouse hedgehog racoon baboon kangaroo hippopotamus
			giraffe
		/
	],
};

# Recover the previous animals from the magic cookie.
# The cookie has been formatted as an associative array
# mapping animal name to the number of animals.
my %zoo = $cgi->cookie( 'animals' );

# Recover the new animal(s) from the parameter 'new_animal'
if ( my @new = $cgi->multi_param( 'new_animals' ) ) {

	# If the action is 'add', then add new animals to the zoo.  Otherwise
	# delete them.
	foreach ( @new ) {
		if ( $cgi->param('action') eq 'Add' ) {
			$zoo{$_}++;
		} elsif ( $cgi->param('action') eq 'Delete' ) {
			$zoo{$_}-- if $zoo{$_};
			delete $zoo{$_} unless $zoo{$_};
		}
	}

	$template_vars->{zoo} = \%zoo if keys( %zoo );
}

# Add new animals to old, and put them in a cookie
my $the_cookie = $cgi->cookie(
	-name    => 'animals',
	-value   => \%zoo,
	-expires => '+1h'
);

my $tt  = Template->new;

# Print the header, incorporating the cookie and the expiration date...
print $cgi->header(
	-cookie  => $the_cookie,
    -type    => 'text/html',
    -charset => 'utf-8',
);

$tt->process( \*DATA,$template_vars ) or warn $tt->error;

__DATA__
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>Animal crackers</title>
	</head>
	<body>
		<h1>Animal Crackers</h1>
		<p>
			Choose the animals you want to add to the zoo, and click "add".
			Come back to this page any time within the next hour and the list of 
			animals in the zoo will be resurrected.  You can even quit the browser
			completely!
		</p>
		<p>
			Try adding the same animal several times to the list.  Does this
			remind you vaguely of a shopping cart?
		</p>
		<p>
			<center>
				<table border>
					<tr><th>Add/Delete<th>Current Contents
					<tr><td><form method="post" action="https://127.0.0.1:3333/cookie/" enctype="multipart/form-data">
						<select name="new_animals"  size="10" multiple="multiple">
						[% FOREACH animal IN animals %]
							<option value="[% animal %]">[% animal %]</option>
						[% END %]
						</select>
					<br>
					<input type="submit" name="action" value="Delete" />
					<input type="submit" name="action" value="Add" />
					<div>
						<input type="hidden" name=".cgifields" value="new_animals"  />
					</div>
				</form>
				<td>
					[% IF zoo.defined %]
						<ul>
						[% FOREACH animal IN zoo.keys.sort %]
							<li>[% zoo.$animal %] [% animal %]</li>
						[% END %]
						</ul>
					[% ELSE %]
						<strong>The zoo is empty.</strong>
					[% END %]
				</table>
			</center>
		<hr>
	</body>
</html>

Anon7 - 2022
AnonSec Team