view release on metacpan or search on metacpan
lib/CAM/PDF.pm view on Meta::CPAN
{
$stringwidth = $w;
}
}
$lines ||= 1;
# Initial guess
$fontsize = ($dy - 2 * $border) / ($lines * 1.5);
my $fontwidth = $fontsize * $stringwidth;
my $maxwidth = $dx - 2 * $border;
if ($fontwidth > $maxwidth)
{
lib/CAM/PDF.pm view on Meta::CPAN
# TODO: wrap the field with wrapString()??
# Shawn Dawson of Silent Solutions pointed out that this does not auto-wrap the input text
my $linebreaks = $text =~ s/ \\n /\) Tj T* \(/gxms;
# Total guess work:
# line height is either 150% of fontsize or thrice
# the corner offset
$tl = $fontsize ? $fontsize * 1.5 : $ty * 3;
# Bottom aligned
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CAM/PDFTaxforms.pm view on Meta::CPAN
$lines++;
my $w = $self->getStringWidth($fontmetrics, $line);
$stringwidth = $w if ($w && $w > $stringwidth);
}
$lines ||= 1;
# Initial guess
$fontsize = ($dy - 2 * $border) / ($lines * 1.5);
my $fontwidth = $fontsize * $stringwidth;
my $maxwidth = $dx - 2 * $border;
$fontsize *= $maxwidth / $fontwidth if ($fontwidth > $maxwidth);
$da =~ s/ \/$fontname\s+0\s+Tf\b /\/$fontname $fontsize Tf/gxms;
lib/CAM/PDFTaxforms.pm view on Meta::CPAN
# TODO: wrap the field with wrapString()??
# Shawn Dawson of Silent Solutions pointed out that this does not auto-wrap the input text
my $linebreaks = $text =~ s/ \\n /\) Tj T* \(/gxms;
# Total guess work:
# line height is either 150% of fontsize or thrice
# the corner offset
$tl = $fontsize ? $fontsize * 1.5 : $ty * 3;
# Bottom aligned
view all matches for this distribution
view release on metacpan or search on metacpan
easyxs/ppport.h view on Meta::CPAN
#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
lib/CBOR/PP/Encode.pm view on Meta::CPAN
Note that there is no âright wayâ to determine whether an arbitrary
Perl (non-reference) scalar should be encoded as a string or as a number.
The above seems a reasonable enough approach.
=item * UTF8-flagged strings are encoded as text; others are encoded as
binary. This is a âbest-guessâ merely; Perlâs UTF8 flag doesnât reliably
indicate whether a given string is a text or a byte string.
=item * undef, Types::Serialiser::true(), and Types::Serialiser::false()
are encoded as null, true, and false, respectively.
view all matches for this distribution
view release on metacpan or search on metacpan
=head2 PERL -> CBOR
The mapping from Perl to CBOR is slightly more difficult, as Perl is a
typeless language. That means this module can only guess which CBOR type
is meant by a perl value.
=over 4
=item hash references
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
print "It may very well be supported all the way back to ",
format_version(5.003_07), ".\n";
}
else {
print "But given the things $f depends on, it's a good",
" guess that it isn't\n",
"supported prior to ", format_version($todo), ".\n";
}
}
}
}
#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
sub deliverFile {
my $o = shift;
my $request = shift;
my $file = shift;
my $contentType = shift // $o->guessContentType($file);
my $bytes = $o->readFile($file) // return $request->reply404;
return $request->reply(200, 'OK', {'Content-Type' => $contentType}, $bytes);
}
# Guesses the content type from the extension
sub guessContentType {
my $o = shift;
my $file = shift;
my $extension = $file =~ /\.([A-Za-z0-9]*)$/ ? lc($1) : '';
return $o->{mimeTypesByExtension}->{$extension} // 'application/octet-stream';
$o->{ui}->progress('MODIFY +', scalar @{$modifications->additions}, ' -', scalar @{$modifications->removals}, ' on ', $o->{url});
return $o->{store}->modify($modifications, $keyPair);
}
# Displays a record, and tries to guess the byte interpretation
package CDS::UI::Record;
sub display {
my $class = shift;
my $ui = shift;
$context =~ /(^| )key( |$)/ ? $o->hexValue($bytes) :
$context =~ /(^| )signature( |$)/ ? $o->hexValue($bytes) :
$context =~ /(^| )revision( |$)/ ? $o->revisionValue($bytes) :
$context =~ /(^| )date( |$)/ ? $o->dateValue($bytes) :
$context =~ /(^| )expires( |$)/ ? $o->dateValue($bytes) :
$o->guessValue($bytes);
push @value, ' ', $o->{ui}->blue($hash->hex), $o->{onStore} if $hash && ($bytes && length $bytes != 32);
$o->{ui}->line(@value);
# Children
my $length = length $bytes;
return '#'.unpack('H*', substr($bytes, 0, $length)) if $length <= 64;
return '#'.unpack('H*', substr($bytes, 0, 64)), 'â¦', $o->{ui}->gray(' (', $length, ' bytes)');
}
sub guessValue {
my $o = shift;
my $bytes = shift;
my $length = length $bytes;
my $text = $length > 64 ? substr($bytes, 0, 64).'â¦' : $bytes;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CGI/Alert.pm view on Meta::CPAN
# Not a CODE ref or string
push @warnings, "[Yo! What is \$Browser_Text? It's '$what', and I only grok 'CODE' or '' (strings)]";
}
}
else {
# $Browser_Text undefined - I guess we just show nothing to user?
}
# Generate a message body for the email we're going to send out
my @text = ("The script died with:",
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CGI/Application/Dispatch.pm view on Meta::CPAN
}
# Apache will report $errno in access.log
my $header .= "Status: $errno $status_lines{$errno}\n";
# try to guess, what a crap we get here
$header .=
$output =~ /<html/i
? "Content-type: text/html\n\n"
: "Content-type: text/plain\n\n";
view all matches for this distribution
view release on metacpan or search on metacpan
caf_project/Example/common-modules/Example.pm view on Meta::CPAN
# (1, $user) --> user was found, password given correct
#
# ** (1, undef) --> not possible! this will never happen **
#
# Note that you are responsible for creating a login.html
# HTML::Template file (or just plain HTML file I guess
# but that's a dumb idea) that is on the template search path
# that will provide something logically equivalent to username
# and password form fields, that you will use here. You can
# name them what you want to here; Framework.pm makes
# no assumptions regarding what they should be called.
caf_project/Example/common-modules/Example.pm view on Meta::CPAN
# (1, $user) --> user was found, password given correct
#
# ** (1, undef) --> not possible! this will never happen **
#
# Note that you are responsible for creating a relogin.html
# HTML::Template file (or just plain HTML file I guess
# but that's a dumb idea) that is on the template search path
# that will provide something logically equivalent to a password
# form field, that you will use here. You can name them what
# you want to here; Framework.pm makes no assumptions
# regarding what they should be called.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CGI/Application/Plugin/AnyTemplate.pm view on Meta::CPAN
if (exists $plugin_config->{'string'}) {
$string_ref = $plugin_config->{'string'} || '';
$string_ref = \$string_ref unless ref $string_ref;
}
# if no string, then guess template filename
my $filename;
unless ($string_ref) {
$filename = $self->_guess_template_filename($plugin_config, \%driver_config, $type, $self->{'webapp'}->get_current_runmode);
}
# call load_tmpl hook
my %tmpl_params;
lib/CGI/Application/Plugin/AnyTemplate.pm view on Meta::CPAN
croak "CAP::AnyTemplate: template driver $module could not be found: $@";
}
return $module;
}
sub _guess_template_filename {
my ($self, $plugin_config, $driver_config, $type, $crm) = @_;
my $filename;
if (exists $plugin_config->{'file'}) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CGI/Application/Plugin/Authentication/Driver/DBI.pm view on Meta::CPAN
Note: This option is only useful if you also specify the COLUMNS option.
=head1 ENCODED PASSWORDS
It is quite common to store passwords in a database in some form that makes them hard
(or virtually impossible) to guess. Most of the time one way encryption techniques
like Unix crypt or MD5 hashes are used to store the password securely (I would recommend
using MD5 or SHA1 over Unix crypt). If you look at the examples listed above, you can
see that you can mark your columns with an encoding type. Here is another example:
CONSTRAINTS => {
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/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/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