ARS-Simple

 view release on metacpan or  search on metacpan

Config.PL  view on Meta::CPAN

if (! $configfile)
{
    $configfile = 'blib/lib/ARS/Simple.cfg';
}
open $fh, '>', $configfile || die "failed to open $configfile: $!";
print $fh "# Config file for ARS::Simple\n# generated by Config.PL (".scalar(localtime).")\n# This file MUST be valid perl (as it is 'required')\n# Note user and password are obfuscated, NOT encrypted.\n\n";
print $fh q{%config = (} . "\n";

# Doing simple obfuscation of user and password
my $k = '5Jv@sI9^bl@D*j5H3@:7g4H[2]d%Ks314aNuGeX;';
my $x = substr($k, 0, length($user));
my $u = $user ^ $x;
my $up = unpack('H*', $u);
print $fh "\tuser     => '$up',\n";

$x = substr($k, 0, length($password));
$u = $password ^ $x;
$up = unpack('H*', $u);
print $fh "\tpassword => '$up',\n";
print $fh ");\n1;\n#--< End of File >--#\n";
close $fh;

unless ($ENV{PERL_MM_USE_DEFAULT} || $ENV{AUTOMATED_TESTING} || !-t STDIN)
{
    print "\tuser     => '$user' (obfuscated),\n";
    print "\tpassword => '$password' (obfuscated),\n";

examples/generate_fid_hash.pl  view on Meta::CPAN

print "Enter the name of the Remedy form: ";
my $form = <STDIN>;
chomp $form;

#----------
my $sql = qq{select
f.fieldName,
f.fieldID,
decode(FOption, 1, 'Required ', 2, 'Optional ', 3, 'System RO', '*Unknown*'),
decode(datatype, 0, 'AR_DATA_TYPE_NULL', 1, 'AR_DATA_TYPE_KEYWORD', 2, 'AR_DATA_TYPE_INTEGER', 3, 'AR_DATA_TYPE_REAL', 4, 'AR_DATA_TYPE_CHAR', 5, 'AR_DATA_TYPE_DIARY', 6, 'AR_DATA_TYPE_ENUM', 7, 'AR_DATA_TYPE_TIME', 8, 'AR_DATA_TYPE_BITMASK', 9, 'AR_...
c.maxlength
from arschema a
join field f
on f.schemaid = a.schemaid and datatype < 30 and f.fieldID != 15
left outer join field_char c
on c.schemaid = f.schemaid and c.fieldid = f.fieldID
where a.name = '$form'
order by 1};


my $m = $ars->get_SQL({ sql => $sql });

examples/generate_fid_hash.pl  view on Meta::CPAN

{
    print "No data returned, quitting\n";
    exit;
}

# Check size and replace spaces with '_', you could also remove them!
my $max_len = 0;
foreach my $row (@{ $m->{rows} })
{
    $row->[0] =~ s/\s+/_/gms;
    if (length($row->[0]) > $max_len)
    {
        $max_len = length($row->[0]);
    }
}

# Construct the hash
my $fid_hash = "# Label/FID hash for form '$form'\n\%fid = (\n";
foreach my $row (@{ $m->{rows} })
{
    $fid_hash .= sprintf("    '%s'%s=> %10d,\t\t# %s type=%s %d\n", $row->[0], ' ' x ($max_len + 1 - length($row->[0])), $row->[1], $row->[2], $row->[3], $row->[4]);
}
$fid_hash .= "    );\n";

$CLIP->Set($fid_hash);
print "$fid_hash\nFormatted data copied to clipboard\n";

lib/ARS/Simple.pm  view on Meta::CPAN

    my $k = '5Jv@sI9^bl@D*j5H3@:7g4H[2]d%Ks314aNuGeX;';
    if ($args->{user})
    {
        $self->{persistant}{user} = $args->{user};
    }
    else
    {
        if (defined $config{user})
        {
            my $s = pack('H*', $config{user});
            my $x = substr($k, 0, length($s));
            my $u = $s ^ $x;
            $self->{persistant}{user} = $u;
        }
        else
        {
            croak "No user defined, quitting\n";
        }
    }

    if ($args->{password})
    {
        $self->{persistant}{password} = $args->{password};
    }
    else
    {
        if (defined $config{password})
        {
            my $s = pack('H*', $config{password});
            my $x = substr($k, 0, length($s));
            my $u = $s ^ $x;
            $self->{persistant}{password} = $u;
        }
        else
        {
            croak "No password defined, quitting\n";
        }
    }
    $user  = $self->{persistant}{user};
    $pword = $self->{persistant}{password};



( run in 0.627 second using v1.01-cache-2.11-cpan-65fba6d93b7 )