view release on metacpan or search on metacpan
inc/Module/AutoInstall.pm view on Meta::CPAN
if ( @Missing and not( $CheckOnly or $UnderCPAN ) ) {
require Config;
print
"*** Dependencies will be installed the next time you type '$Config::Config{make}'.\n";
# make an educated guess of whether we'll need root permission.
print " (You may need to do that as the 'root' user.)\n"
if eval '$>';
}
print "*** $class configuration finished.\n";
inc/Module/AutoInstall.pm view on Meta::CPAN
or _load('CPANPLUS::Shell::Default')
)
);
}
# make guesses on whether we're under the CPAN installation directory
sub _under_cpan {
require Cwd;
require File::Spec;
my $cwd = File::Spec->canonpath( Cwd::cwd() );
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CGI/Application/Plugin/ConfigAuto.pm view on Meta::CPAN
=head2 cfg_file()
# Usual
$self->cfg_file('my_config_file.pl');
# Supply the first format, guess the second
$self->cfg_file('my_config_file.pl',{ format => 'perl' } );
Supply an array of config files, and they will be processed in order. If a
hash reference if found it, will be used to supply the format for the previous
file in the array.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CGI/Application/Plugin/FormState.pm view on Meta::CPAN
=head1 IMPLEMENTATION
When you call C<< $self->form_state >> for the first time, a top-level
key is created in the user's session. This key contains a random,
hard-to-guess element. It might look something like:
form_state_cap_form_state_84eb13cfed01764d9c401219faa56d53
All data you place in the form state with C<param> is stored in the
user's session under this key.
lib/CGI/Application/Plugin/FormState.pm view on Meta::CPAN
<input type="hidden" name="cap_form_state" value="<tmpl_var cap_form_state>">
You manually put this hidden field in your template. The template
parameter C<cap_form_state> is automatically added to your template
parameters via the C<load_tmpl> hook. It contains the random,
hard-to-guess portion (e.g. C<84eb13cfed01764d9c401219faa56d53>). When
the template is filled, the hidden field will look something like this:
<input type="hidden" name="cap_form_state" value="84eb13cfed01764d9c401219faa56d53">
Since all values are stored on the server in the user's session, the
lib/CGI/Application/Plugin/FormState.pm view on Meta::CPAN
}
=item id
Returns the current value of the storage param - the "hard to guess"
portion of the session key.
my $id = $self->form_state->id;
=cut
view all matches for this distribution
view release on metacpan or search on metacpan
t/33_session_delete.t view on Meta::CPAN
$t1_obj = TestAppSessionDelete->new( QUERY => $query );
$t1_output = $t1_obj->run();
# vanilla output came through ok?
ok( $t1_output =~ /logout finished/, 'vanilla output came through ok' );
# If that didn't pass, then I'm guessing the session wasn't injected properly
# Was the session create cookie in the output? It shouldn't be
unlike($t1_output, qr/Set-Cookie: CGISESSID=[a-zA-Z0-9]+/, 'new session cookie not in output');
# Was the session delete cookie in the output? It should be
t/33_session_delete.t view on Meta::CPAN
$t1_output = $t1_obj->run();
# vanilla output came through ok?
ok( $t1_output =~ /logout finished/, 'vanilla output came through ok' );
# If that didn't pass, then I'm guessing the session wasn't injected properly
# Was the session create cookie in the output? It shouldn't be
unlike($t1_output, qr/Set-Cookie: CGISESSID=[a-zA-Z0-9]+/, 'new session cookie not in output');
# Was the session delete cookie in the output? It should be
t/33_session_delete.t view on Meta::CPAN
$t1_output = $t1_obj->run();
# vanilla output came through ok?
ok( $t1_output =~ /logout finished/, 'vanilla output came through ok' );
# If that didn't pass, then I'm guessing the session wasn't injected properly
# Was the session create cookie in the output? It shouldn't be
unlike($t1_output, qr/Set-Cookie: CGISESSID=[a-zA-Z0-9]+/, 'new session cookie not in output');
# Was the session delete cookie in the output? It should be
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CGI/Application/Plugin/PageLookup.pm view on Meta::CPAN
This is a hashref containing additional parameters that are to be passed to the load_templ function.
=item default_lang
This is a two letter code and defaults to 'en'. It is used when creating a notfound page when a language
cannot otherwise be guessed.
=item status_404
This is the internal id corresponding to the not found page.
lib/CGI/Application/Plugin/PageLookup.pm view on Meta::CPAN
my $self = shift;
my $page_id = shift;
my @inargs = @_;
my %args = $self->pagelookup_get_config(@inargs);
# Best guess at language
my $lang = $self->pagelookup_default_lang(@inargs);
if ($page_id =~ /^(\w\w)\//) {
$lang = $1;
}
view all matches for this distribution
view release on metacpan or search on metacpan
t/11_sessiondelete.t view on Meta::CPAN
$t1_obj = TestAppSessionDelete->new( QUERY => $query );
$t1_output = $t1_obj->run();
# vanilla output came through ok?
ok( $t1_output =~ /logout finished/, 'vanilla output came through ok' );
# If that didn't pass, then I'm guessing the session wasn't injected properly
# Was the session create cookie in the output? It shouldn't be
unlike($t1_output, qr/Set-Cookie: CGISESSID=[a-zA-Z0-9]+/, 'new session cookie not in output');
# Was the session delete cookie in the output? It should be
t/11_sessiondelete.t view on Meta::CPAN
$t1_output = $t1_obj->run();
# vanilla output came through ok?
ok( $t1_output =~ /logout finished/, 'vanilla output came through ok' );
# If that didn't pass, then I'm guessing the session wasn't injected properly
# Was the session create cookie in the output? It shouldn't be
unlike($t1_output, qr/Set-Cookie: CGISESSID=[a-zA-Z0-9]+/, 'new session cookie not in output');
# Was the session delete cookie in the output? It should be
t/11_sessiondelete.t view on Meta::CPAN
$t1_output = $t1_obj->run();
# vanilla output came through ok?
ok( $t1_output =~ /logout finished/, 'vanilla output came through ok' );
# If that didn't pass, then I'm guessing the session wasn't injected properly
# Was the session create cookie in the output? It shouldn't be
unlike($t1_output, qr/Set-Cookie: CGISESSID=[a-zA-Z0-9]+/, 'new session cookie not in output');
# Was the session delete cookie in the output? It should be
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CGI/Auth/Auto.pm view on Meta::CPAN
$param->{-authfields} ||= [
{id => 'user', display => 'User Name', hidden => 0, required => 1},
{id => 'pw', display => 'Password', hidden => 1, required => 1},
];
$param->{-authdir} ||= _guess_authdir();
$param->{-formaction} ||= CGI::Scriptpaths::script_rel_path(); #_guess_formaction();
$param->{-sessdir} ||= $param->{-authdir}.'/sess';
if (defined $param->{-logintmplpath} or defined $param->{-logintmpl}){
$param->{-logintmplpath} ||= $param->{-authdir};
$param->{-logintmpl} ||= 'login.html';
lib/CGI/Auth/Auto.pm view on Meta::CPAN
# GUESSING SUBS
sub _guess_authdir {
my $dir = __guess_base().'/auth';
debug("$dir\n");
return $dir;
}
sub __guess_base {
my $cgibin = CGI::Scriptpaths::abs_cgibin();
unless(defined $cgibin){
$cgibin = script_abs_loc() or confess("cant get script's absolute location");
}
debug($cgibin);
return $cgibin;
}
sub _guess_sessdir {
my $dir = __guess_authdir().'/sess';
debug("$dir\n");
return $dir;
}
lib/CGI/Auth/Auto.pm view on Meta::CPAN
It will work with CGI::Application instances as well.
=head2 MOTIVATION
CGI::Auth is a nice module- But I wanted to be able to use it without having to set up a
bunch of parameters to the constructor. This module attempts to make good guesses
about what those parameters should be.
The other thing this module addresses, is having to pass the session id around.
CGI::Auth makes you pass the "session id"- Via query string, in a form, a cookie, etc.
lib/CGI/Auth/Auto.pm view on Meta::CPAN
Shown are the defaults. You do not need to provide these parameters.
-formaction
If you do not provide one, the module tries to guess what the rel path to the script is.
-authdir
Now a default value of $ENV{DOCUMENT_ROOT} ../cgi-bin/authdir is present.
That means for most hosting accounts if you have this kind of (very common) setup:
lib/CGI/Auth/Auto.pm view on Meta::CPAN
use CGI::Auth::Auto;
use CGI qw(:all);
my $auth = new CGI::Auth::Auto({
-authdir => "$ENV{DOCUMENT_ROOT}/../cgi-bin/auth"
}); # the program guesses for authdir, you can leave out if it resides alongside your script
$auth->check;
my $html =
header() .
start_html() .
lib/CGI/Auth/Auto.pm view on Meta::CPAN
=head1 ERRORS
The most common error is that you are not passing the right authdir to the object.
The authdir needs to exist and contain a user.dat simple text file.
If you do not provide an authdir argument, that's ok, we try to guess for it.
If your script is in /home/myself/cgi-bin/script.pl , then your auth dir is guessed as
/home/myself/cgi-bin/auth
And it must exist and contain the user.dat file. This can be a blank text file to begin with.
Make sure it is chown and chmod properly.
If your cgi is failing, turn on L<DEBUG> and run it again. A lot of useful information may be there.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CGI/Auth/Basic.pm view on Meta::CPAN
Note that: you must protect your password file(s). Put it above your
web root if you can. Also, giving it a I<.cgi> extension can be
helpful; if a web server tries to execute it, you'll get a 500 ISE,
not the source (you can get the source however; it depends on your
server software, OS and configuration). You can also put it in
a hard-to-guess named directory. But don't put it in your program
directory.
Also note that: these are I<just> suggestions and there is no
guarantee that any of this will work for you. Just test and see
the results.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CGI/Builder/Auth/UserAdmin.pm view on Meta::CPAN
}
You may need to pass additional fields, such as the user's real name.
This depends on your server of course.
$user->add('JoeUser', 'try2guess', '', 'Joseph A. User');
You can also pass a set of field name/value pairs in
the form of a hash ref. Example
$user->add('JoeUser','try2guess','',
{'Name'=>'Joseph A. User','Credit_limit'=>2000});
=item delete($username)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CGI/Builder/GetPageName.pm view on Meta::CPAN
=head1 OVERRIDE MODULES
=head2 get_page_name
I override this method but I guess you do not need to care.
=head1 SEE ALSO
CGI::Builder
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/AutoInstall.pm view on Meta::CPAN
else {
print
"*** Dependencies will be installed the next time you type '$make'.\n";
}
# make an educated guess of whether we'll need root permission.
print " (You may need to do that as the 'root' user.)\n"
if eval '$>';
}
print "*** $class configuration finished.\n";
inc/Module/AutoInstall.pm view on Meta::CPAN
or _load('CPANPLUS::Shell::Default')
)
);
}
# make guesses on whether we're under the CPAN installation directory
sub _under_cpan {
require Cwd;
require File::Spec;
my $cwd = File::Spec->canonpath( Cwd::getcwd() );
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CGI/Carp/Throw.pm view on Meta::CPAN
#####################################################################
# Need to call CGI::Carp's import in a controlled manner and with
# a controlled environment.
#
# More complicated than I would like but guessing it's reasonably
# robust.
#####################################################################
sub import {
my $pkg = shift;
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/AutoInstall.pm view on Meta::CPAN
if ( @Missing and not( $CheckOnly or $UnderCPAN ) ) {
require Config;
print
"*** Dependencies will be installed the next time you type '$Config::Config{make}'.\n";
# make an educated guess of whether we'll need root permission.
print " (You may need to do that as the 'root' user.)\n"
if eval '$>';
}
print "*** $class configuration finished.\n";
inc/Module/AutoInstall.pm view on Meta::CPAN
or _load('CPANPLUS::Shell::Default')
)
);
}
# make guesses on whether we're under the CPAN installation directory
sub _under_cpan {
require Cwd;
require File::Spec;
my $cwd = File::Spec->canonpath( Cwd::cwd() );
view all matches for this distribution
view release on metacpan or search on metacpan
#ifndef IVSIZE
# ifdef LONGSIZE
# define IVSIZE LONGSIZE
# else
# define IVSIZE 4 /* A bold guess, but the best we can make. */
# endif
#endif
#ifndef UVTYPE
# define UVTYPE unsigned IVTYPE
#endif
view all matches for this distribution
view release on metacpan or search on metacpan
the field values, so you can access particular form field values
directly, as in
$xyz = $form->{xyz};
providing you are not an OOP purist, I guess. (If you are, use the get
method.)
=item $form->set(PARAMS);
allows you to set value on one or more form fields. E.g.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CGI/Ex/Conf.pm view on Meta::CPAN
file beginning with a / or ./ or ../ is considered to be a full
filename). A file "namespace" (ie "footer" or "my::config" or
"what/ever") will be turned into a filename by looking for that
namespace in the paths found either in $args->{paths} or in
$self->{paths} or in @DEFAULT_PATHS. @DEFAULT_PATHS is empty by
default as is $self->{paths} - read makes no attempt to guess what
directories to look in. If the namespace has no extension the
extension listed in $args->{default_ext} or $self->{default_ext} or
$DEFAULT_EXT will be used).
my $ref = $cob->read('My::NameSpace', {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CGI/FormBuilder/Mail/FormatMultiPart.pm view on Meta::CPAN
=head1 BUGS
Styles don't do anything in my copy of Evolution, at least.
But they do have the intended effect in Mozilla Mailnews,
so I guess it's good to go.
=head1 DEPENDENCIES
L<MIME::Types>,
L<Net::SMTP>,
view all matches for this distribution
view release on metacpan or search on metacpan
1.0.8 2007-11-17
Fix version in META.yml... I guess deleting file doesn't work.
1.0.7 2007-11-17
Fix [rt.cpan.org #30559]
- no longer uses Test::Exception.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CGI/FormBuilder/Field.pm view on Meta::CPAN
# Handle "b:select" and "b:option"
sub tag_name {
my $self = shift;
$self->{tag_name} = shift if @_;
return $self->{tag_name} if $self->{tag_name};
# Try to guess
my($tag) = ref($self) =~ /^CGI::FormBuilder::Field::(.+)/;
puke "Can't resolve tag for untyped field '$self->{name}'"
unless $tag;
return $tag;
}
lib/CGI/FormBuilder/Field.pm view on Meta::CPAN
my $name = $self->{name};
my $type;
unless ($type = lc $self->{type}) {
#
# Unless the type has been set explicitly, we make a guess
# based on how many items there are to display, which is
# basically, how many options we have. Our 'jsclick' option
# is now changed down in the javascript section, fixing a bug
#
if ($self->{_form}->smartness) {
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/AutoInstall.pm view on Meta::CPAN
if ( @Missing and not( $CheckOnly or $UnderCPAN ) ) {
require Config;
print
"*** Dependencies will be installed the next time you type '$Config::Config{make}'.\n";
# make an educated guess of whether we'll need root permission.
print " (You may need to do that as the 'root' user.)\n"
if eval '$>';
}
print "*** $class configuration finished.\n";
inc/Module/AutoInstall.pm view on Meta::CPAN
or _load('CPANPLUS::Shell::Default')
)
);
}
# make guesses on whether we're under the CPAN installation directory
sub _under_cpan {
require Cwd;
require File::Spec;
my $cwd = File::Spec->canonpath( Cwd::cwd() );
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CGI/FormMagick/TagMaker.pm view on Meta::CPAN
# Names of properties for objects of this class are declared here:
my $KEY_AUTO_GROUP = 'auto_group'; # do we make tag groups by default?
my $KEY_AUTO_POSIT = 'auto_posit'; # with methods whose parameters
# could be either named or positional, when we aren't sure what we
# are given, do we guess positional? Default is named.
# These extra tag properties work only with AUTOLOAD:
my $PARAM_TEXT = 'text'; #tag pair is wrapped around this
my $PARAM_LIST = 'list'; #force tag groups to be returned in ARRAY ref
lib/CGI/FormMagick/TagMaker.pm view on Meta::CPAN
This method is an accessor for the boolean "automatic grouping" property of this
object, which it returns. If VALUE is defined, this property is set to it. In
cases where we aren't told explicitely that autoloaded methods are making a
single or multiple tags (using ['_start', '_end', '_pair'] and '_group'
respectively), we look to this property to determine what operation we guess.
The default is "single". When this property is true, we can make both single and
groups of tags by using a suffix-less method name; however, making single tags
this way is slower than when this property is false. Also, be aware that when we
are making a "group", arguments that are ARRAY refs are always flattened, and
when we are making a "single", ARRAY ref arguments are always used literally.
lib/CGI/FormMagick/TagMaker.pm view on Meta::CPAN
=head2 positional_by_default([ VALUE ])
This method is an accessor for the boolean "positional arguments" property of
this object, which it returns. If VALUE is defined, this property is set to it.
With methods whose parameters could be either named or positional, when we aren't
sure what we are given, do we guess positional? Default is named.
=cut
sub positional_by_default {
my $self = shift( @_ );
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CGI/Framework.pm view on Meta::CPAN
=item templates_dir
B<OPTIONAL>
This key should have a scalar value holding a directory name which contains all the template files. If not supplied, it will be guessed based on the local directory.
=item valid_languages
B<OPTIONAL>
lib/CGI/Framework.pm view on Meta::CPAN
$para{cookie_name} =~ s/[^0-9a-z]//gi;
}
if (!$para{sessions_mysql_dbh} && !$para{sessions_dir}) {
#
# They didn't supply any sessions stuff, so let's take a guess at some directories for file-based storage:
#
foreach (qw(/tmp /var/tmp c:/tmp c:/temp c:/windows/temp)) {
if (-d $_) {
$para{sessions_dir} = $_;
last;
view all matches for this distribution
view release on metacpan or search on metacpan
Added is_search_engine()
0.22 Thu May 3 09:32:37 BST 2012
Fix tmpdir() in Cygwin, where giving a default value of '/non-existant' would
return '/non-existant/../tmp' rather than '/non-existant'. I
guess it would also have broken under the Newcastle Connection.
0.21 Wed May 2 13:21:40 BST 2012
Clean up a couple of regular expressions
Small speed improvement
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CGI/Lingua.pm view on Meta::CPAN
if($self->{_dont_use_ip}) {
return;
}
# The client hasn't said which to use, so guess from their IP address,
# or the requested language(s) isn't/aren't supported so use the IP
# address for an alternative
my $country = $self->country();
if((!defined($country)) && (my $c = $self->_what_language())) {
if($c =~ /^(..)_(..)/) {
$country = $2; # Best guess
} elsif($c =~ /^(..)$/) {
$country = $1; # Wrong, but maybe something will drop out
}
}
lib/CGI/Lingua.pm view on Meta::CPAN
=head2 locale
HTTP doesn't have a way of transmitting a browser's localisation information
which would be useful for default currency, date formatting, etc.
This method attempts to detect the information, but it is a best guess
and is not 100% reliable. But it's better than nothing ;-)
Returns a L<Locale::Object::Country> object.
To be clear, if you're in the US and request the language in Spanish,
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CGI/Lite/Request/Upload.pm view on Meta::CPAN
returns the size of the uploaded file
=item type
returns the MIME type of the file (guessed with L<File::Type>)
=cut
sub size { $_[0]->{_size} = $_[1] if $_[1]; $_[0]->{_size} }
sub type { $_[0]->{_type} = $_[1] if $_[1]; $_[0]->{_type} }
view all matches for this distribution
view release on metacpan or search on metacpan
}
This can be a huge timesaver if access to the webserver is difficult.
This can be huge trouble if you have confidential or security related
information in your debugging messages. (That is why "debug" in the above
example is the string "secret" and not "1" or something easy to guess.)
=item
You can add nice status messages to your web application by doing something like:
view all matches for this distribution
view release on metacpan or search on metacpan
MxScreen/Session/Medium/File.pm view on Meta::CPAN
#
# _mxscreen_session the session ID
# _mxscreen_token a random token, saved with context
#
# The random token is generated each time the context is saved to the file.
# It is used at retrieve time to validate the session ID: noone could guess
# both the session ID and the associated token at the same time.
#
# Note that since we generate a token each time we save, using "Back" from
# the browser to resubmit an old form is bound to fail, since the token
# will have changed.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CGI/ParamComposite.pm view on Meta::CPAN
similar to what you seen in some programming languages. Now if I see a parameter
like:
/my.cgi?navigation.instructions=1
I can pretty quickly guess, after not looking at the code for days/weeks/months, that
this value is somehow affecting the instructions on the Gbrowse navigation page. In
my opinion, this is superior to:
/my.cgi?ins=0
view all matches for this distribution
view release on metacpan or search on metacpan
currenttime [% localtime %]
Currently, the following are included by default in the magic_fill_interpolation_hash
script - a good guess at the name of your script
_script - the stuff after the last _ in the above script
localtime - scalar (localtime),
time - time,
I also include %ENV
view all matches for this distribution
view release on metacpan or search on metacpan
demos/segtext/jv_world/jv_world_005.txt view on Meta::CPAN
# version (true); otherwise, it returns undef (false). By default, ARGS is
# known to be named if its first element is a hash ref, and assumed to be
# positional if the count of arguments is odd. If neither of those two
# conditions are true then we have an even argument count and we are in doubt
# of whether they are named or not. The argument GUESS_NAMED says what to do
# in that case; if it is true then we guess named and if it is false then we
# guess positional. If the argument USE_DASHES is true then we check the first
# element in ARGS to see if it begins with a dash, "-", and if it does then we
# assume that ARGS is named regardless of the count of elements.
# When the first element of ARGS is a hash ref, any other elements of ARGS are
# also returned as "remaining" values, if they exist, after the hash ref.
# So you can call this like "($rh_named, @rem) = _args_are_named()".
sub _args_are_named {
my ($self, $ra_args, $use_dashes, $guess_named) = @_;
if( ref( $ra_args->[0] ) eq 'HASH' ) {
return( @{$ra_args} ); # literal hash in first return elem
} elsif( $use_dashes and substr( $ra_args->[0], 0, 1 ) eq '-' ) {
return( { @{$ra_args} } ); # first element starts with "-"
} elsif( @{$ra_args} % 2 ) {
return( undef ); # odd # elements
} else {
return( $guess_named ? { @{$ra_args} } : undef ); # even num elements
}
}
view all matches for this distribution