free source authentication script

T

Tore Aursand

It's indented in the way I like it. How would you define "properly"?

By the way 90% (at least) of the other Perl programmers indent it.
Most of my code does and this one will too, as soon as I get around to
it.

Until then: Please don't post - or refer to - malicious scripts. If you
do, please include the warning I wrote.
Yeah, I figure [...]

You aren't the one to "figure out" things here - Perl is! Don't _EVER_
think that "oh, this will work in any case, 'cause...", because the case
where it doesn't work will eventually come.

Murphy's law: What can go wrong, will go wrong (at least that's the law
translated directly from Norwegian, my primary language).

Don't you have an editor with a "Search" or "Find" function? Please get
one; I'm sure I saw at least two calls to 'exit' in your script.
Well, as tassilo said, what's the point of not using perl? Perl is great
for interpolation of variables in html code and stuff.

Please see my answer to Tassilo about this.
What do you mean exactly?

Your scripts are accepting input from the outside world, but you never
care to validate that input. People _will_ eventually try to send your
script "bad input".
 
T

Tore Aursand

I'd rather gnaw my arm off than recommending the use of a templating
system to anyone. I tried quite a few and hated each one of them.

Perl already is the best templating system around with all its
capabilities of interpolating variables and code in strings. Templating
systems tend to come with their own syntax. This is a waste of time when
considering that one already knows Perl.

I think we're talking about two different templating systems. I actally
haven't used many of the template modules found on CPAN, as the company I
worked for rolled out their own templating module.

It was a "pure template module" with almost no possibilities when it came
to logic. All the logic still resided in the Perl scripts.

Example #1: Substitution of values

script.pl
---------
$Template->subst( 'FIRSTNAME', $firstname );
$Template->subst( 'LASTNAME', $lastname );

script.thtml
------------
<b>Firstname:</b> <!-- %%FIRSTNAME%% --><br />
<b>Lastname:</b> <!-- %%LASTNAME%% --><br />

Example #2: List

script.pl
---------
$Template->create_list( 'PERSONS', 'FIRSTNAME', 'LASTNAME' );
$Template->sort_list( 'PERSONS', 'LASTNAME,STR,ASC;FIRSTNAME,STR,ASC);
foreach ( @Persons ) {
$Template->push_list( 'PERSONS', $_>firstname(), $_->lastname() );
}
$Template->done_list( 'PERSONS' );

script.thtml
------------
<!-- %%PERSON_LIST BEGIN%% -->
<!-- %%LASTNAME%% -->, <!-- %%FIRSTNAME%% --><br />
<!-- %%PERSON_LIST END%% -->

Very easy, as we had an own department with designers who knew little or
nothing about programming.

I see that a lot (too many, probably) of the template solutions found on
CPAN involves including logic. I agree with you; that's bad. But for
easy things like above (lists, substitutions etc.), I still think that
separating Perl code from HTML (or whatever format we're using) is the
best thing in the end.

One example comes to my mind: Let's say you have a script which should
output the same thing, but to different medias (HTML, pure text etc.).
Wouldn't it be better to have separate template files depending on the
media and letting the script choose which template to use from the context?

Just my $0.02.


--
Tore Aursand <[email protected]>
"Writing is a lot like sex. At first you do it because you like it.
Then you find yourself doing it for a few close friends and people you
like. But if you're any good at all, you end up doing it for money."
(Unknown)
 
A

A. Sinan Unur

I'd rather gnaw my arm off than recommending the use of a templating
system to anyone. I tried quite a few and hated each one of them.

There is a benefit to strict separation of HTML from Perl code. You can
play around with the HTML much more easily. Even though I work on both
facets of my programs myself, I find it useful to tinker with the HTML and
CSS separately without having to run the script etc. In that regard, I have
been very fond of HTML::Template. Of course, tastes vary.

Sinan.
 
M

Matt Garrish

Jim Cochrane said:
*was*

Perhaps he's operating on a different plane of reality, using a system that
never has file storage failures, files are always readable and writable by
everyone, files are never locked, etc.

Want to get where you're going without the hassle and cost of a professional
pilot, or even someone who's read the manual? Then fly Air Robin! If we
can't get off the ground, we'll drive you there in our plane.

(I just had a thought of him reading that post and wondering which plane he
was supposed to have taken... ; )

Matt
 
M

Michele Dondi

Yeah, I figure that there won't be too much of a race condition or anything
like that because there's only one person who accesses the code who runs the
files, unless there's more than one person who has the password and even so
it's minimal...

Also, this is a modified older script, I will get around to it, and I
apologize for not "doing my best" before posting it.

Well, 'open() or die' is such a common Perl idiom that it'd better
soon become deeply etched in your brain. It has not necessarily to do
with race conditions: just do that! At the very least, a simple 'die
$!' will do!


Michele
 
M

Michele Dondi

It's indented in the way I like it. How would you define "properly"?

How many people have told you to read perldoc perlstyle so far? You
clearly haven't done it. From said doc:

Regarding aesthetics of code lay out, about the only thing
Larry cares strongly about is that the closing curly bracket [snip]
are good. What you do:

if ($foo)
{
bar();
}

is not.

Of course I'm not Larry, but if it counts, it is horrible by my
aesthetics standards too!


Michele
 
A

axel

Tore Aursand said:
Murphy's law: What can go wrong, will go wrong (at least that's the law
translated directly from Norwegian, my primary language).

Or O'Connor's addendum: "Murphy was an optimist".

Axel
 
V

Vetle Roeim

* webmaster @ infusedlight . net
It's indented in the way I like it. How would you define "properly"?

You're free to indent as you wish, of course, but it would probably
be easier to get help if you formatted your code the way people here
suggest.

You could try using perltidy,
<URL:http://perltidy.sourceforge.net/>.


[...]
 
R

Robin

Matt Garrish said:
Jim Cochrane said:
Want to get where you're going without the hassle and cost of a professional
pilot, or even someone who's read the manual? Then fly Air Robin! If we
can't get off the ground, we'll drive you there in our plane.

(I just had a thought of him reading that post and wondering which plane he
was supposed to have taken... ; )

Matt

I might be an idiot, but not a stupid one.
-Robin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,084
Latest member
HansGeorgi

Latest Threads

Top