Re: Modules Executed Twice

2002-12-31 Thread darren chamberlain
* Perrin Harkins <[EMAIL PROTECTED]> [2002-12-30 19:07]:
> > Explanations and other suggested approaches to handling this problem
> > will be most welcome.
> 
> My suggestion in the past has been to PerlRequire a startup.pl that
> does a use on your modules, instead of pulling them in with
> PerlModule.

I believe that if you have custom directives, you need to PerlModule
your module -- a simple 'use Foo;' line within a PerlRequire'd script
is not sufficient.

(darren)

-- 
Do you realize how many holes there could be if people would
just take the time to take the dirt out of them?



Re: my little stupid script

2002-12-23 Thread darren chamberlain
* [EMAIL PROTECTED] <[EMAIL PROTECTED]> [2002-12-23 14:31]:
> I am in the beginning stages to get mod_perl in my head. This is my second 
> script after the "Hello There" script. I am trying ot get my little stupid 
> script to work. What I am trying ot do is fairly simple; I thought. I am 
> just trying to get the server to print the numbers from 1 to 10. Here is 
> the script that I have been working for 5 days. Please help and thank you 
> in advnaced. 
> 
> 
> #!/user/bin/perl -w 
 usr?

> use strict; 
> 
> my $r = shift; 
> 
> $r->send_http_header('text/plain'); 
> 
> for (my $i = 0 ; $i > 10; $i++) {
  ^
Do you mean < here?  -'

> print "$i\n";
> }
> 1; 

(darren)

-- 
The first rule of magic is simple.  Don't waste your time waving your
hands and hoping when a rock or a club will do.
-- McCloctnik the Lucid



Re: [mp-1 ?] Apache::Util::escape_html could handle single quotation

2002-11-11 Thread darren chamberlain
* Geoffrey Young <[EMAIL PROTECTED]> [2002-11-11 13:16]:
> > (oh, maybe someone could consider also adding some test case to
> > t/net/perl/util.pl but it does not seem to be very important)
> 
> tests are always important :)
> 
> > > I'm think that, with mod_perl 2.0, mod_perl 1.x might not be high on
> > > maintainer's list of stuff to do
> 
> sorry, but I haven't been following too closely lately.
> 
> if you can provide a final patch to Util.xs and util.pl and they past
> muster with the rest of the committers, I'll see that they get
> integrated into CVS 'soonish'

Two patches, one for t/net/util.pl and one for src/modules/perl/Util.xs.
Apply them from the root of the untarred source.

(darren)

-- 
Of all the strange 'crimes' that human beings have legislated out of
nothing, 'blasphemy' is the most amazing--with 'obscenity' and 'indecent
exposure' fighting it out for second and third place.
-- Lazarus Long

--- t/net/perl/util.pl.orig Mon Nov 11 13:33:44 2002
+++ t/net/perl/util.pl  Mon Nov 11 13:33:37 2002
@@ -57,6 +57,7 @@ my $html = <
 
 "ok"
+'la'
 &how
 
 

--- src/modules/perl/Util.xs.orig   Fri Nov  8 16:42:42 2002
+++ src/modules/perl/Util.xsSat Nov  9 08:58:32 2002
@@ -45,6 +45,8 @@ static SV *my_escape_html(char *s)
j += 4;
 else if (s[i] == '"')
j += 5;
+else if (s[i] == '\'')
+   j += 5;
 
 if (j == 0)
return newSVpv(s,i);
@@ -67,6 +69,10 @@ static SV *my_escape_html(char *s)
memcpy(&SvPVX(x)[j], """, 6);
j += 5;
}
+   else if (s[i] == '\'') {
+   memcpy(&SvPVX(x)[j], "'", 6);
+   j += 5;
+   }
else
SvPVX(x)[j] = s[i];
 



Re: [mp-1 ?] Apache::Util::escape_html could handle single quotation

2002-11-09 Thread darren chamberlain
* Marcin Kasperski <[EMAIL PROTECTED]> [2002-11-08 17:33]:
> darren chamberlain <[EMAIL PROTECTED]> writes:
> 
> > * Marcin Kasperski <[EMAIL PROTECTED]> [2002-11-08 16:22]:
> > > I use Apache::Util::escape_html to perform fast HTML-escaping of the
> > > data before displaying it. Unfortunately, this function handles
> > > <, >, & and " but does not handle ' (single quote) - which 
> > > can be escaped as '
> > 
> > Hey, this is an easy one.  Apply the attached patch to
> > mod_perl-1.XX/src/modules/perl/Util.xs, and single quotes will be
> > turned into '
> 
> Your patch seems to me to be partially wrong (you missed similar
> addition a few lines above, while calculating the destination
> size).

Erm, yeah, so I see, now that you mention it.

> Nevertheless, I write here about the problem because I would really
> like having such a change in the mainstream modperl distribution.
> Keeping my own patched modperl distribution, integrating changes etc
> is a bit troublesome (organizationally).

I'm think that, with mod_perl 2.0, mod_perl 1.x might not be high on
maintainer's list of stuff to do, but Jim Winstead would probably accept
a (proper!) patch and release libapreq-1.01.

(darren)

-- 
All extreme positions are wrong.
-- Erann Gat

--- Util.xs.origFri Nov  8 16:42:42 2002
+++ Util.xs Sat Nov  9 08:58:32 2002
@@ -45,6 +45,8 @@ static SV *my_escape_html(char *s)
j += 4;
 else if (s[i] == '"')
j += 5;
+else if (s[i] == '\'')
+   j += 5;
 
 if (j == 0)
return newSVpv(s,i);
@@ -67,6 +69,10 @@ static SV *my_escape_html(char *s)
memcpy(&SvPVX(x)[j], """, 6);
j += 5;
}
+   else if (s[i] == '\'') {
+   memcpy(&SvPVX(x)[j], "'", 6);
+   j += 5;
+   }
else
SvPVX(x)[j] = s[i];
 



Re: [mp-1 ?] Apache::Util::escape_html could handle single quotation

2002-11-08 Thread darren chamberlain
* Marcin Kasperski <[EMAIL PROTECTED]> [2002-11-08 16:22]:
> I use Apache::Util::escape_html to perform fast HTML-escaping of the
> data before displaying it. Unfortunately, this function handles
> <, >, & and " but does not handle ' (single quote) - which 
> can be escaped as '

Hey, this is an easy one.  Apply the attached patch to
mod_perl-1.XX/src/modules/perl/Util.xs, and single quotes will be
turned into '

(darren)

-- 
If history teaches us anything, it's that everyone will be part of the
problem, but not everyone will be part of the solution.
-- Larry Wall

--- Util.xs.origFri Nov  8 16:42:42 2002
+++ Util.xs Fri Nov  8 16:44:49 2002
@@ -67,6 +67,10 @@ static SV *my_escape_html(char *s)
memcpy(&SvPVX(x)[j], """, 6);
j += 5;
}
+   else if (s[i] == '\'') {
+   memcpy(&SvPVX(x)[j], "'", 6);
+   j += 5;
+   }
else
SvPVX(x)[j] = s[i];
 



Re: conditional get

2002-10-28 Thread darren chamberlain
* Cristvo Dalla Costa <[EMAIL PROTECTED]> [2002-10-25 20:29]:
> Hi, I'm trying to get my script to work with conditional get, however,
> when the browser should use the local copy it doesn't display
> anything, just telling me that the image's broken.

The Eagle book implies that you need to use Apache::File to get
meets_conditions; are you doing so?

(darren)

-- 
There are worse things in life than death. Have you ever spent an
evening with an insurance salesman?
-- Woody Allen



Re: [RFC] Apache-GeoIP module

2002-10-25 Thread darren chamberlain
* Randy Kobes <[EMAIL PROTECTED]> [2002-10-25 12:01]:
> There are a couple of modules on CPAN - Geo::IP and Geo::Mirror -
> that provide a general Perl interface to the GeoIP library.

Oh.  I should have checked; sorry about that!

* Michael Schout <[EMAIL PROTECTED]> [2002-10-25 11:42]:
> darren chamberlain wrote:
> > attached to Apache.  I'd like to see, in addition to the Apache
> > stuff, a generic GeoIP library that can be used from outside Apache,
> > like in log-eating scripts.
>
> You mean like this?
>
> http://search.cpan.org/author/TJMATHER/Geo-IP-0.26/lib/Geo/IP.pm

/me looks sheepish.

(darren)

--
Unix is an operating system, OS/2 is half an operating system, Windows
is a shell, and DOS is a boot partition virus.
-- Peter H. Coffin



Re: [RFC] Apache-GeoIP module

2002-10-25 Thread darren chamberlain
* Randy Kobes <[EMAIL PROTECTED]> [2002-10-17 17:01]:
> I've placed at
> ftp://theoryx5.uwinnipeg.ca/pub/other/Apache-GeoIP-0.26.tar.gz 
> a package providing a mod_perl interface to the GeoIP library,
> which is used to look up in a database the country of origin of
> an IP address. See http://www.maxmind.com/ for details. 

Out of curiousity, why is your package limited to Apache?  I've looked
at the code a bit, and don't see why the GeoIP stuff needs to be
attached to Apache.  I'd like to see, in addition to the Apache stuff, a
generic GeoIP library that can be used from outside Apache, like in
log-eating scripts.

Sorry for picking up this thread this so late; I'm a little slow. ;)

(darren)

-- 
Millions long for immortality who do not know what to do with
themselves on a rainy Sunday afternoon.
-- Susan Ertz



Re: CGI parameters appear to be doubled on 8 bit chars...

2002-10-15 Thread darren chamberlain

* Rob Mueller <[EMAIL PROTECTED]> [2002-10-13 08:00]:
> Just wondering if anyone has seen this problem before, or has a general
> solution to it. Basically what we see, is that with some submitted forms,
> usually with 8 bit data, the POST parameters passed become 'doubled'. The
> problem is that we have a loop like this to gather out all the parameters
> early on in our handler code.

This isn't a solution, but you could unique the values:

  foreach my $Key ($R->param) {
  my %uniq;
  my @UParam = grep { ++$uniq{$_} == 1 } $R->param($Key);

  $CGIState{$Key} = scalar(@UParam) > 1 ? \@UParam : $UParam[0];
  }

(darren)

-- 
You can discover more about a person in an hour of play than in a year
of discussion.
-- Plato



Re: top for apache? [OT]

2002-09-23 Thread darren chamberlain

* Nigel Hamilton <[EMAIL PROTECTED]> [2002-09-21 04:31]:
> I just found a really cool tool (mentioned in SysAdmin journal). 
> It shows a dynamic picture of MySQL processes just like 'top'

[-- snip --]

> It would be great to have a similar tool for mod_perl/apache. You
> could see the memory consumption of children over time, number of
> requests served, average response time etc.

Have you seen mod_status?  It produces parsable output; you can get nice
useful info like:

   Srv  PIDAcc   M CPUSS  Req Conn Child Slot ClientVHost Request
   0-0  6762 0/13/43 _ 12.98 85   0   0.0  0.20  0.59 127.0.0.1 foo   GET 
/images/header_logo2.gif HTTP/1.1
   1-0  6760 0/18/48 _ 19.44 85   1   0.0  0.42  0.68 127.0.0.1 foo   GET 
/images/336633.gif HTTP/1.1
   2-0  6761 0/16/46 _ 12.96 85   0   0.0  0.39  1.04 127.0.0.1 foo   GET 
/images/curve_white2.gif HTTP/1.1
   3-0  6763 0/15/45 _ 13.01 85   0   0.0  0.38  0.40 127.0.0.1 foo   GET 
/images/99cc99_h10.gif HTTP/1.1
   4-0  6764 0/11/41 _ 6.64  85   0   0.0  0.20  0.45 127.0.0.1 foo   GET 
/images/336633_w119.gif HTTP/1.1
   5-0  6765 0/9/39  _ 6.70  85   0   0.0  0.20  0.63 127.0.0.1 foo   GET 
/images/header_end2.gif HTTP/1.1
   6-0  6766 0/7/37  W 6.53  85   0   0.0  0.20  0.80 127.0.0.1 foo   GET 
/server-status HTTP/1.0
   7-0  6767 0/4/34  _ 0.01  85   5   0.0  0.00  0.40 127.0.0.1 foo   GET 
/server-status HTTP/1.0
   8-0  6768 0/1/31  _ 0.00  85   1   0.0  0.00  0.01 127.0.0.1 foo   GET 
/images/clear.gif HTTP/1.1
   9-0  -0/0/30  . 13.06 105  0   0.0  0.00  0.22 127.0.0.1 foo   GET 
/images/curve_white2.gif HTTP/1.1
   10-0 -0/0/3   . 0.01  1069 1   0.0  0.00  0.00 127.0.0.1 foo   GET 
/images/336633.gif HTTP/1.1

(darren)

PS Yes, mytop is very cool.

-- 
Do what thou wilt shall be the whole of the Law.
Love is the law, love under will.



Re: BUG: Apache::Cookie v1.0

2002-09-23 Thread darren chamberlain

* Michael McLagan <[EMAIL PROTECTED]> [2002-09-21 11:45]:
> There is a bug in Apache::Cookie.  It doesn't handle a cookie with
> zero bytes in it!

This is because Apache::Cookie is implemented in C, and C uses NULL as
the end of string terminator.

This is probably something that needs to be done in Perl, since I doubt
there's a way to check for "embedded" NULLs in a string in C...

(darren)

-- 
If you wish to drown, do not torture yourself with shallow water.



Re: newbie: file uploads not working :(

2002-09-12 Thread darren chamberlain

* Geoffrey Young <[EMAIL PROTECTED]> [2002-09-12 15:45]:
> > Note: If you ever use them in file posts, don't forget to clean the
> > file names, especially when it comes from Windows machine...
> 
> I've found this to be reasonably portable for getting just the 
> filename (sans path) - YMMV
> 
> my ($name) = $upload->filename =~ m!([^/\\]*$)!;

  use File::Basename;
  my $name = basename($upload->filename);

(darren)

-- 
There is no expedient to which a man will not go to
avoid the real labour of thinking.



Re: Apache::Reload -- can't locate main.pm?

2002-08-26 Thread darren chamberlain

* Ken Miller <[EMAIL PROTECTED]> [2002-08-26 12:03]:
> What's main.pm, and why can't Apache::Reload find it?  I've searched
> the archives, but have had little success in finding anything
> interesting.

Run

  find $dir -name 'main.pm' -print

For each dir in @INC, and see what comes up.

(darren)

-- 
What the imagination siezes as beauty must be truth--whether it
existed before on not.
-- John Keats, "Woman When I Behold Thee"



Re: $r->path_info() getting confused

2002-08-21 Thread darren chamberlain

* Fran Fabrizio <[EMAIL PROTECTED]> [2002-08-21 11:03]:
> 
> 
> 
> 
> 
> 
> When I call the URL /rms/module/foo, and in 
> RMS::Control::Module->handler I examine $r->path_info, I get as a value 
> '/module/foo' rather than the expected '/foo'.  If apache recognized 
> that /rms/module/foo was to go to RMS::Control::Module->handler then it 
> knows that /rms/module is the script name and thus should know that 
> path_info should be just /foo, right?

I would hazard a guess that /rms exists under the document root, but
/rms/modules does not.  How path_info is created has more to do with
what the filesystem looks like than what the  blocks look like.

(darren)

-- 
What is ideology but the rationalisation of a vested interest?



Re: apache + mod_perl --> chunk mode trailer

2002-08-14 Thread darren chamberlain

* Fang Cheng <[EMAIL PROTECTED]> [2002-08-13 23:06]:
> If you do an apache code trace, set the breakpoint at 
> apache_src/main/http_protocol.c function
> ap_finalize_request_protocol, you will see the 
> r->chunked == 0 even though it was set to be 1. You
> can also use snoop to see that the trailers \0\r\n was
> missing.

Are you using any subrequests?

(darren)

-- 
Laziness is often mistaken for patience.



Re: variables not changing with modperl??

2002-08-13 Thread darren chamberlain

* Michael Drons <[EMAIL PROTECTED]> [2002-08-13 01:55]:
> Thanks for the link.  I actually don't use functions.
> Everything is mostly in MAIN.  Here is a snip of code:
>
> #!/usr/bin/perl -wT
> use strict;
> print "";
> my $r = Apache->request;
> $r->content_type("text/html");
> $r->status(200);
> my $auth_type = $r->auth_type;
> $cookie=$auth_type->key;
> ($user,$hash)=split(/:/,$cookie);
> read(STDIN, my $buffer, $ENV{'CONTENT_LENGTH'});
> my @pairs = split(/&/, $buffer);
> foreach my $pair (@pairs) {
> 
> }
>
> What I am doing wrong?  Everytime the script runs the
> values of the variables coming in change.  Should I
> use the delete function and delete all of the
> variables at the end of the script?  @pairs is what
> should change, but sometimes does not.  I have tried
> to add a undef @pairs before the split, but no luck.

Are you sure that this is the code that is running?  It doesn't compile:

  $ perl
  #!/usr/bin/perl -wT
  use strict;
  print "";
  my $r = Apache->request;
  $r->content_type("text/html");
  $r->status(200);
  my $auth_type = $r->auth_type;
  $cookie=$auth_type->key;
  ($user,$hash)=split(/:/,$cookie);
  read(STDIN, my $buffer, $ENV{'CONTENT_LENGTH'});
  my @pairs = split(/&/, $buffer);
  foreach my $pair (@pairs) { }
  Global symbol "$cookie" requires explicit package name at - line 7.
  Global symbol "$user" requires explicit package name at - line 8.
  Global symbol "$hash" requires explicit package name at - line 8.
  Global symbol "$cookie" requires explicit package name at - line 8.
  Execution of - aborted due to compilation errors

Make those global symbols ($cookie, $user, and $hash) lexical (declare
with my) and the code will both compile and do what you expect (i.e.,
not maintain values from call to call).

You'll also want to print things *after* you set the content type and
status, not before.

(darren)

--
The biggest difference between time and space is that you can't
reuse time.
-- Merrick Furst



Re: odd behavior of localtime

2002-07-26 Thread darren chamberlain

* Dermot Paikkos <[EMAIL PROTECTED]> [2002-07-26 09:14]:
> I tried this as a snippet on its own and it works. I can't figure out
> why it doesn't with mod_perl. I was a bit unsure of whether $date =
> time(); should be scalar or an array but neither work.

You haven't mentioned how you are calling it.  From within a template
(you mention Apache::Template), from within a handler, or where?

(darren)

-- 
The man who is denied the opportunity of making decisions of
importance begins to regard as important the decisions he is
allowed to make.
-- C. Northcote Parkinson



Re: Simple file manipulation module.

2002-07-25 Thread darren chamberlain

* Ganesan M <[EMAIL PROTECTED]> [2002-07-25 11:07]:
> I am looking for a perl module to do simple file manipulations like
> (list, create, edit, modify, copy, move, rename files in a directory)
> through web interface.  Any module recommendations to do the above
> job?

Well, modules:

  * IO::File (create, modify)
  * File::List (list)  # <--- Not core
  * File::Copy (copy, move)
  * File::Path (mkpath)
  * File::Spec (os-independant filepaths)
  * rename (builtin)

File::Butler seems to support a lot of those things as well, but I can't
vouch for it.

(darren)

-- 
Blore's Razor:
Given a choice between two theories, take the one
which is funnier.

Mahanaxer's Correllary:
The same goes for algorithms.



Re: possible buget in CGI.pm

2002-07-23 Thread darren chamberlain

Hi,

* [EMAIL PROTECTED] <[EMAIL PROTECTED]> [2002-07-23 11:26]:
> We are implementing mod_perl here for internal intranet use.  We have
> discovered a possible buglet in CGI.pm.
> 
> We do not want CGI.pm to return XHTML as it upsets Verity indexing
> (long story).

So sorry to hear about that.

> So in Apache::Registry executed scripts we use:
> 
>   use CGI qw( -no_xhtml );
> 
> But on the first invocation it returns normal HTML.  On second
> invocation it ignores this directive and returns XHTML.  We started a
> dev server with -X to confirm this.  It would appear CGI resets its
> globals somewhere.
> 
> Can someone confirm this?

Yes:

  From CGI.pm, version 2.81:

 35 # > Here are some globals that you might want to adjust <<
 36 sub initialize_globals {
 37 # Set this to 1 to enable copious autoloader debugging messages
 38 $AUTOLOAD_DEBUG = 0;
 39 
 40 # Set this to 1 to generate XTML-compatible output
>>   41 $XHTML = 1;
 42 
 43 # Change this to the preferred DTD to print in start_html()
 44 # or use default_dtd('text of DTD to use');
 45 $DEFAULT_DTD = [ '-//W3C//DTD HTML 4.01 Transitional//EN',
 46  'http://www.w3.org/TR/html4/loose.dtd' ] ;
 47 

Judging from line 35 you might want to adjust some of those globals.

If you are using CGI in the OO way, you can just subclass CGI:

  package My::CGI;

  use base qw(CGI);
  sub initialize_globals {
  CGI::initialize_globals();
  $CGI::XHTML = 0;
  }

And then:

  my $q = My::CGI->new;

Of course, I haven't tested this.

Another option is to call:

  CGI->import("-no_xhtml");

at the top of your Registry script, which will be executed every time,
whereas the "use CGI qw( -no_xhtml );" is only being called at compile
time.

(darren)

-- 
You can put a man through school, but you cannot make him think.
-- Ben Harper



Re: $r->path_info question

2002-07-23 Thread darren chamberlain

* simran <[EMAIL PROTECTED]> [2002-07-23 05:11]:
> However: if i create an 'auto' directory in my document root
> (something that was not there before)
> 

[-- snip --]

> Is this is feature or a bug, does path_info not check the 'Location' it
> matced the handler to or is it meant to look at the directory structure?

This is how Apache handles path_info: it is the "extra" stuff after
the translation handler has found a directory and filename.  It starts
at the left, and walks towards the right, until it finds the last
component that is a directory, and then the next piece is the file (no
existance check is done at this point).  The rest of it is path_info.

For example:

A request for /foo/bar/baz/quux, with a document root of /document/root
(assuming no Alias directives, that complicates things slightly), and
assuming that /document/root/foo is the last *directory* in the path
that exists, Apache does this:

  1. look for /document -> yep
  2. look for /document/root -> yep
  3. look for /document/root/foo -> yep
  4. look for /document/root/foo/bar -> nope

So /document/root/foo/bar is r->filename, and /baz/quux is path_info.

To reiterate: this is not a mod_perl thing (bug/whatever) but an Apache
one.

(darren)

-- 
An operating system is just a name you give the features you left
out of your editor.
-- Per Abrahamsen in comp.emacs



Re: Weird problem with cookies on Netscape with apache running a virtualhost

2002-07-12 Thread darren chamberlain

* Chris Pizzo <[EMAIL PROTECTED]> [2002-07-12 17:02]:
> This works but I need to set multiple cookies.  Im doing this:
> 
> my $c = new CGI::Cookie(-name => 'SID', -value => 'stuff', -expires
> => '+6M');
> my $cc = new CGI::Cookie(-name => 'BUD', -value =>
> 'Wassup', -expires => '+6M');
> 
> $r->headers_out->set('Set-Cookie',$cc);
> $r->headers_out->set('Set-Cookie',$c);
> 
>  $r->cgi_header_out('Location',"mypage.html");
>  $r->send_http_header;

$r->headers_out->add('Set-Cookie', $c);
$r->headers_out->add('Set-Cookie', $cc);

Or better yet, use Apache::Cookie, which has a bake() method that can be
used multiple times.

(darren)

-- 
Biographical history, as taught in our public schools, is still largely a
history of boneheads:  ridiculous kings and queens, paranoid political
leaders, compulsive voyagers, ignorant generals -- the flotsam and jetsam
of historical currents.  The men who radically altered history, the great
scientists and mathematicians, are seldom mentioned, if at all.
-- Martin Gardner



Re: leaks with Apache::Request?

2002-07-09 Thread darren chamberlain

* Joe Schaefer <[EMAIL PROTECTED]> [2002-07-09 12:47]:
> Dave Rolsky <[EMAIL PROTECTED]> writes:
> > On 8 Jul 2002, Joe Schaefer wrote:
> > If I do this:
> > 
> >  my $x = shift;
> >  $x = make_something_from($x);
> > 
> > then it seems like the original $x should go out of scope when it is
> > assigned to, so its refcount should stay at 1.
>^^
> 
> Right, it should stay at 1.  But all bets are off when
> $x is has magic and make_something_from() is an XS sub :-).

But the leak is not with $x, it's with what $_[0] is; $x is just a
reference to that, and the reassignment in the second line should
reassign $x, and decrement the ref count for what $x is pointing to at
that point.  So, it all depends on what make_something_from() does with
the $x's referent.

(darren)

-- 
Great minds discuss ideas.
Average minds discuss events.
Small minds discuss people.
-- Admiral Hyman G. Rickover



Re: QUESTION - Apache::AuthenCache

2002-07-08 Thread darren chamberlain

* JOSE SOLE <[EMAIL PROTECTED]> [2002-07-08 14:24]:
> I am trying to use Apache::AuthenCache as my authentication handler
> for my server.  I keep getting a FORBIDDEN error each time I try to
> access the index.html page by only typing the URL up to the directory.
> 
> Example:
> 
> //FORBIDDEN ERROR
> http://elvis.arl.psu.edu:9092/footer
> 
> //IT WORKS
> http://elvis.arl.psu.edu:9092/footer/
> http://elvis.arl.psu.edu:9092/footer/index.html

Add some debugging to the handler to ensure that the client is sending
the WWW-Authenticate header to both /footer and /footer/.  The
browser sees them as different locations (the first is a file named
footer, the second is a directory name footer), and possibly doesn't
consider the first to be within the auth realm for which it has a
username/password.

Apache's mod_dir usually Does The Right Thing here, when given the
chance; are you using a perl-handler on Location /?

(darren)

-- 
It is wrong always, everywhere and for everyone to believe
anything upon insufficient evidence.
-- W. K. Clifford, British philosopher, circa 1876



Re: Apache::Request $apr->param; problems.

2002-07-05 Thread darren chamberlain

* Wes Cravens <[EMAIL PROTECTED]> [2002-07-05 10:48]:
> however if this routine is called more than once with the same $r
> object then the second time there are no params.  It's as if calling
> $apr->param strips them off $r.  That's not clever.  I can't find
> anything in the documentation that says it would behave like that.

Are you POSTing the data?  You can't read that more than once.  Look  at
(for example)
http://perl.apache.org/release/docs/1.0/guide/snippets.html#Reusing_Data_from_POST_request
or check out Apache::RequestNotes/

(darren)

-- 
The language Unix is vastly more inconsistent than the language Perl.
And guaranteed to remain that way, forever and ever, amen.
-- Larry Wall



Re: Like-named perl modules in separate directories

2002-06-26 Thread darren chamberlain

* Tim Gerla <[EMAIL PROTECTED]> [2002-06-26 11:33]:
> I've got a problem with a perl module (.pm) problem on my server. I've
> got two slightly different versions of a file: Conf.pm, in two
> separate places on my server. (Let's call them /home/www/docs/web/cgi/
> and /home/www/docs/minos/cgi/) Mod_perl apparently keeps caching one
> or the other, causing interesting problems if I hit a 'web' script,
> and then a 'minos' script a few minutes later. 
> 
> What's the best way to get around this?

Use different namespaces for the two modules.

(darren)

-- 
All is fear in love and war.



Re: custom directives, again...

2002-06-18 Thread darren chamberlain

* Noam Solomon <[EMAIL PROTECTED]> [2002-06-17 17:49]:
> I sent out a plea for help last week, but probably didn't provide
> enough information for a quick solution. The problem is that I'm using
> Apache::OpenIndex (which is similar to Apache::AutoIndex) and have not
> been able to get the apache server on the production box to detect a
> custom directive it defines (OpenIndexOptions). I didn't have this
> problem on my development machine, so I'm baffled as to its origin.

[-- snip --]

> Here's some salient bits of the httpd.conf:
> 
>   # GLOBAL MOD_PERL CONFIG
>   
> AddModule mod_perl.c
> PerlRequire /home/httpd/startup.pl
> PerlFreshRestart On
> etc..
> PerlRequire /home/httpd/mason/handler.pl
>   
>   # END GLOBAL MOD_PERL CONFIG

Make sure that you pull in the module using PerlModule, and not from use
in a PerlRequire.  PerlModule does some bootstrapping to make sure that
directives are passed to your module, rather than let Apache try to do
something with them.

(darren)

-- 
Make no laws whatever concerning speech, and speech will be free;
so soon as you make a declaration on paper that speech shall be
free, you will have a hundred lawyers proving that "freedom does
not mean abuse, nor liberty license"; and they will define and
define freedom out of existence.
-- Voltarine de Cleyre



Re: PerlTransHandler problem

2002-06-13 Thread darren chamberlain

* Rasoul Hajikhani <[EMAIL PROTECTED]> [2002-06-12 19:12]:
> Hello folks,
> I am trying to implement a simple PerlTransHandler to change:
> 
> http://myserver/
> 
> to 
> 
> http://myserver.rhythm.com/
> 
> And here is my code:

[-- snip --]

Have you seen ? The
first section is about URL layout, and the first example is about
canonicalizing URLs.

(darren)

-- 
It has long been an axiom of mine that the little things are
infinitely the most important.
-- Arthur Conan Coyle



Re: header woes

2002-06-13 Thread darren chamberlain

* Arnold van Kampen <[EMAIL PROTECTED]> [2002-06-13 09:34]:
>  Why do I have have so much trouble doing some header parsing?  I am
>  doing header parsing because I wanted to check out cookie behaviour
>  on relocation/redirection by browser.  I get stuck when I cannot get
>  with the basic stuff. Clues appreciated..

Why not use Apache::Cookie, or even CGI's cookie() function, to parse
cookies?

>  use strict;
>  use Apache::Constants;
>  use Apache::Reload;
>  use CGI qw(:standard :html3 :netscape);
>  use Apache::Table;
>  
>  sub handler {
>  my $r = shift;
>  my $reason = $r->subprocess_env("AuthCookieReason");
>  my $cookie = $r->header_in('Cookie');
>  my $table = $r->headers_in;
>  my $bla ="sdadsadadadasdadadadadad";
>  my $type = $table->{'Content-type'};
> 
>  print   header,start_html,
>  h2($bla),
>  h2($type),
>  end_html;
>  
>  }

You can iterate over the keys of %$table, to see what's being set.
Change your print statement to something like:

  
   print   header,start_html,
   h2($bla),
   h2($type),
   ul(map(li($_, " => ", $table->{$_}), keys %{$table})),
   end_html;

To get a list of the keys in $r->headers_in;

Also, you forgot to return OK.

(darren)

-- 
Responsible behavior is the result of a socialization process.



Re: Mapping to location "/"

2002-06-12 Thread darren chamberlain

* md <[EMAIL PROTECTED]> [2002-06-12 17:05]:
> --- darren chamberlain <[EMAIL PROTECTED]> wrote:
> > If you use a translation handler, you can just return DECLINED for
> > everything you aren't specifically handling, and let mod_dir do it's
> > thing, instead of emulating it.
> 
> I still would like to check first if there is an index.phtml template
> instead of going directly to the directory index files like
> index.html. Can I add my "virtual" index.phtml to DirectoryIndex so I
> don't have to look for it in my handler? I'm not quite clear on this
> one...but it might be once I read the guide on translation handlers :)

You can add something to the effect of:

  return DECLINED
if ($r->uri =~ /\.phtml$/ &&
-e File::Spec->catfile($r->document_root, $r->uri));
  
in there.

(darren)

-- 
Any technology indistinguishable from magic is insufficiently advanced.



Re: Mapping to location "/"

2002-06-12 Thread darren chamberlain

* md <[EMAIL PROTECTED]> [2002-06-12 13:15]:
> --- Per Einar Ellefsen <[EMAIL PROTECTED]> wrote:
> > Can't you just drop the  and use
> > 
> >SetHandler 
> > 
> > or something like that? Seems like it would avoid
> > some overhead for you.
> 
> True...but the files don't actually exist. The
> path/filename is used to map to a template.

You definitely want to do this in the translation phase; that's what
it's there for.  

> > However, I'm not sure if I understand what you mean
> > with
> >   $uri =~ m!.*/[^\.]+$!) {
> 
> This may not be the best regex..but what I was trying to do was to
> match something like "/directory/subdirectory" which would normally be
> redirected back to "/directory/subdirectory/index.html" (or whatever
> is set as DirectoryIndex files). I want to check for a
> "/directory/subdirectory/index.phtml" file.

If you use a translation handler, you can just return DECLINED for
everything you aren't specifically handling, and let mod_dir do it's
thing, instead of emulating it.

I think what you want is something like this:

  package Foo;  # or whatever

  use strict;
  use Apache::Constants qw(OK DECLINED);

  sub handler {
  my $r = shift;

  return DECLINED unless $r->uri =~ /\.phtml$/;

  # Figure out which template to use here
  my $template_name = get_template_name($r);
  $r->filename($template_name);

  return OK;
  }
  1;OK;

(darren)

-- 
Reisner's Rule of Conceptual Inertia:
If you think big enough, you'll never have to do it.



Re: Header weirdness under mod_perl

2002-06-11 Thread darren chamberlain

* Dodger <[EMAIL PROTECTED]> [2002-06-11 06:56]:

[-- snip --]

> Well, it seems that there are strange headers being passed out with
> mod_perl, and mixed into them come carriage returns.

You're using chunked encoding; many clients can't handle that.

> /* response headers from mod_perl -- sessionID has been altered for
> security purposes */
> Client-Date: Sat, 08 Jun 2002 21:02:11 GMT
> Client-Response-Num: 1
> 
> Cookie: session=d1af22bd5dd71c2585be72b86e119212;
> domain=.gothic-classifieds.com; path=/; expires=Sat, 08-Jun-2002 22:02:11
> GMT
> HTTP/1.1 200 OK
> Date: Sat, 08 Jun 2002 21:02:11 GMT
> Server: Apache/1.3.19 (Unix) mod_perl/1.25
> Set-Cookie: session=d1af22bd5dd71c2585be72b86e119212;
> domain=.gothic-classifieds.com; path=/; expires=Sat, 08-Jun-2002 22:02:11
> GMT
> Connection: close
> Transfer-Encoding: chunked
 ^^^

> Content-Type: text/html; charset=ISO-8859-1
> 
> 2
> 
> 
> 
> 15f
> /* response headers from standard CGI */
> Connection: close
> Date: Sat, 08 Jun 2002 21:02:54 GMT
> Server: Apache/1.3.19 (Unix) mod_perl/1.25
> Content-Type: text/html; charset=ISO-8859-1
> Client-Date: Sat, 08 Jun 2002 21:02:55 GMT
> Client-Response-Num: 1
> Client-Transfer-Encoding: chunked
^^^

I don't know the answer, but this comes up pretty often.  A search of
the archives for chunked encoding should help.

(darren)

-- 
Unix is like a toll road on which you have to stop every 50 feet
to pay another nickel.  But hey!  You only feel 5 cents poorer
each time.
-- Larry Wall



Re: Many requests per page

2002-05-02 Thread darren chamberlain

* Viljo Marrandi <[EMAIL PROTECTED]> [2002-05-02 10:26]:
> > The way I figure this, is that https://mysite.com/scripts/* act the
> > same way as everything used to, and you can load your images from
> > https://mysite.com/images/* without complaints about crossing the
> > secure/nonsecure boundry...
> 
> Hmm, but maybe it's possible to set up Apache so, that My::Site
> handles "/" and doesn't care about, let say, about "/imgs"?

  
  SetHandler perl-script
  PerlHandler My::Site
  

  
  SetHandler default-handler
  

(darren)

-- 
Pessimests are right more often, but optimists are happy more often.



Re: Many requests per page

2002-05-02 Thread darren chamberlain

* Viljo Marrandi <[EMAIL PROTECTED]> [2002-05-02 08:57]:
> How can I make my system so, that my perl handler is not called for
> each image, css and script the page has?

[-- snip --]

The example handlers that come with HTML::Mason have an answer; in
My::Site::handler, add something like:

# If you plan to intermix images in the same directory as
# components, activate the following to prevent Mason from
# evaluating image files as components.
#
return DECLINED if $r->content_type && $r->content_type !~ m|^text/|i;

This should be the first(ish) thing that handler() does, before anything
else takes place.

(darren)

-- 
Violence is to dictatorship as propaganda is to democracy.
-- Noam Chomsky



Re: [Fwd: Re: Cheap and unique]

2002-05-01 Thread darren chamberlain

* David Jacobs <[EMAIL PROTECTED]> [2002-04-30 18:31]:
> A global counter hanging around is a good solution, but not perfect if
> we deploy on multiple servers. 

That depends on what you initialize the global to; if you do something
like the last octet of the ip of the vhost and increment it by the PID
of the child each time you access it (rather than incrementing by 1),
you'll get a pretty useful way of getting a useful global value.

(darren)

-- 
Your freedom to swing your fist ends at the tip of my nose.
-- Larry Niven



Re: File::Redundant

2002-04-29 Thread darren chamberlain

This is OT for mod_perl, sorry...

* Cahill, Earl <[EMAIL PROTECTED]> [2002-04-29 13:55]:
> > Our NIS maps are on the order
> > of 3 GB per file (>64k users).
> 
> Man, that is one big file.  Guess dropping a note to this list sorta
> lets you know what you have to really scale to.  Sounds like dirsync
> could use rsync if Rob makes a couple changes.  Can't believe the file
> couldn't be broken up into smaller files.  3 GB for 64k users doesn't
> scale so hot for say a million users, but I have no idea about NIS
> maps, so there you go.

I haven't been following the conversation, for the most part, but this
part caught my eye.  It is possible to split a NIS map up into many
small source files, as long as when you change one of them you recreate
the map in question as a whole.

I've seen places with large NIS maps (although not 3GB) split the map up
into smaller files, where each letter of the alphabet has it's own file
in a designated subdirectory and a UID generator is used to get the next
UID.  When the NIS maps have to be rebuilt, the main map file is
rebuilt using something like:

  (cat passwd.files/[a-z]*) > passwd; make passwd

which, of course, could be added to the Makefile as part of the passwd
target.

(darren)

-- 
OCCAM'S ERASER:
The philosophical principle that even the simplest solution is bound
to have something wrong with it.



Re: How to generate pre-filled forms? (fwd)

2002-04-26 Thread darren chamberlain

* Ken Clark <[EMAIL PROTECTED]> [2002-04-26 14:33]:
> I'll throw my technique into the ring, too.  I use Template Toolkit
> most of the time, and I pass the original Apache request object back
> to the template as a parameter.  Then I call the "param" method to
> fill in the "value" of form elements, like so:

[-- snip --]

> Nothing gets placed there the first time through as calling
> "$apr->param" returns nothing.  This seems to work great for me.  I've
> not used HTML::Template in a while, but possibly you can do this, too?

The constructor for HTML::Template takes an optional argument names
"associate", which should point to an object (or reference to a list of
objects) that can("param").  Paramters in the template that are not
explicitly filled in using the param method of the HTML::Template object
are looked for by iterating through this list and calling
param($template_variable_name), and takes the first non-false value as
the correct one.

To reuse Ken's illustration:

> In code:
>
> sub handler {
> my $r   = shift;
> my $apr = Apache::Request->new($r);
> my $t   = Template->new;
> my $html;
> $t->process('/foo/bar.tmpl', { apr => $apr }, \$html);
> $apr->content_type('text/html');
> $apr->send_http_header;
> $apr->print( $html );
> return OK;
> }

sub handler {
my $r   = shift;
my $apr = Apache::Request->new($r);
my $t   = HTML::Template->new(associate => $apr,
  filename  => '/foo/bar.html');
$apr->content_type('text/html');
$apr->send_http_header;
$apr->print( $t->output );
return OK;
}

> In template:
>
> 
> 
> [% apr.param('description') %]
> 


">



For the template itself, "foo" will be looked for as $apr->param("foo"),
and description as $apr->param("description").

(darren)

PS Hi Ken!

--
The more we disagree, the better the chance that one of us is right.



Re: [Q maybe OT] forward

2002-04-24 Thread darren chamberlain

* Martin Haase-Thomas <[EMAIL PROTECTED]> [2002-04-24 08:19]:
> forwarding is a term that i borrowed from the JSP concept - which i'm
> currently trying to implement in perl. it means nearly the same as
> redirect, but without telling the client. (as far as i've understood
> it do far. maybe it's just luxury and i'm going to leave it out.)

That sounds exactly like internal_redirect.

(darren)

-- 
Help!  I'm a rock!



Re: [OT] Doubt on directories for development

2002-04-22 Thread darren chamberlain

* [EMAIL PROTECTED] <[EMAIL PROTECTED]> [2002-04-22 09:53]:
> >> The fact is that developers in my team have Apache under /usr/local in
> >> Linux machines, but we would prefer to develop as normal users, not as
> >> www or nobody, though that will be the user in production.
> 
> See the section on configuring Apache using  sections in the
> eagle book. I normally use the approach of having each user's
> .*profile export APACHE_PORT and using $Port = $ENV{APACHE_PORT} or
> croak "$$: Environment missing APACHE_PORT"; for the user's config
> files. Using the "nobody" approach works well enough, but the separate
> ports allow developers to have their own server on a high-numbered
> port w/o stepping on one another.

I like using something like the user's UID as the port on which to start
Apache; with bash, at least, UID is automatically set.  If not,
something like:

  : ${UID:=`id | sed -e 's/uid=\([0-9]*\)(.*/\1/'`}

in .profile will set it for the Bourne shell (don't know/care about csh).

(darren)

-- 
Men never do evil so completely and cheerfully as when they do it
from religious conviction.
-- Blaise Pascal



Re: pnotes notes and subprocess_env

2002-04-18 Thread darren chamberlain

* Rasoul Hajikhani <[EMAIL PROTECTED]> [2002-04-18 16:29]:
> I don't seem to be able to make pnotes, notes or subprocess_env work.
> I am trying to pass a value from a handler to another, and from what I
> have read in the Eagle, and cook book, the request ought to be the
> main one in order for the pnotes, ... to work. So Here is the snippet
> of my code:

I've seen situations where $r->main does not actually return the main
request instance, and code like this has worked:

  $r = $r->main until ($r->is_main);

No explanation, but I've seen it necessary in a few cases.  In the case
of main requests, it has no effect, so it's safe to include.

(darren)

-- 
Democracy is a form of government where you can say what you
think, even if you don't think.



Re: Restarting named service

2002-04-18 Thread darren chamberlain

* Stephen Gray <[EMAIL PROTECTED]> [2002-04-18 15:34]:
> On Thu, 18 Apr 2002 [EMAIL PROTECTED] wrote:
> > or you would be safer running your name server as named as opposed
> > to root.
> > 
> > STEVE
> 
> It should be run as named, but trying to start and stop it as the
> named user won't get you very far if you plan on using port 53. :-)

Have a (caching?) nameserver on port 53 that forwards everything to
localhost:5353, which is running as the web server user and can be
restarted randomly.

(darren)

-- 
He who has never configured `sendmail.cf' has no courage. He who has
configured it more than once has no brain.



Re: Help Requested: Segfault 11 7 *snip*

2002-04-09 Thread darren chamberlain

* Stas Bekman <[EMAIL PROTECTED]> [2002-04-09 12:14]:
> darren chamberlain wrote:
> > Kevin A. McGrail wrote:
> > > 2nd, The segv.cgi at the same location as the Bad:Segv above,
> > > segfaults on the command line and through normal CGI but not with
> > > mod_perl.  Here's the error I get trying to run this script with
> > > mod_perl (1.26):
> > >
> > > [Tue Apr  9 09:53:16 2002] [error] [Tue Apr  9 09:53:16 2002]
> > > PerlHandler subroutine `Apache::Registry::handler': Undefined
> > > subroutine
  ^

[-- snip --]

> it's a perl handler, not a registry script.

I'm just reading the error message, that's all.  :)

(darren)

-- 
I can't understand why a person will take a year or two to write a
novel when he can easily buy one for a few dollars.
-- Fred Allen



Re: Help Requested: Segfault 11 7 MONTHS after compilation on multiple servers all compiled the same running different code and different Redhat Released all on the same day [BUG]

2002-04-09 Thread darren chamberlain

Kevin A. McGrail wrote:
> 2nd, The segv.cgi at the same location as the Bad:Segv above, segfaults on
> the command line and through normal CGI but not with mod_perl.  Here's the
> error I get trying to run this script with mod_perl (1.26):
>
> [Tue Apr  9 09:53:16 2002] [error] [Tue Apr  9 09:53:16 2002] PerlHandler
> subroutine `Apache::Registry::handler': Undefined subroutine
> &Bad::Segv::segv called at /htdocs/peregrinehw.com/html/segv.cgim line 12.
> [Tue Apr  9 09:53:16 2002] END block subroutine `Inline::END': One or
> moreDATA sections were not processed by Inline.
> [Tue Apr  9 09:53:16 2002] END block subroutine `Inline::END':
>
> Thoughts?  Something special with mod_perl?  I didn't add the Bad::Segv to
> the startup.pl or anything at all.

I haven't been following this thread, but it appears to me from the
error message that the DATA section might be causing the problem in
conjunction with Apache::Registry, which explicitly states:

   Your scripts cannot contain the __END__ or __DATA__ token
   to terminate compilation.

in the CAVEATS section.

Ignore this if I'm offbase.

(darren)

-- 
The knowledge that makes us cherish innocence makes innocence
unattainable.
-- Irving Howe



Re: mod_perl & restart vs. graceful

2002-04-09 Thread darren chamberlain

* Stephen Reppucci <[EMAIL PROTECTED]> [2002-04-09 10:44]:
> Hi Darren,
> 
> See my suggested refinement below (I don't like to leave the server
> down any longer than needed...8^):

Assuming that the last thing the parent does is remove the pidfile,
which is most likely the case.  I didn't even think to check that.

(darren)

-- 
Competence, like truth, beauty, and contact lenses, is in the eye of
the beholder.
-- Dr. Laurence J. Peter



Re: mod_perl & restart vs. graceful

2002-04-09 Thread darren chamberlain

* Dan Wilga <[EMAIL PROTECTED]> [2002-04-09 10:19]:
> It's most likely that the stop is actually taking longer than you
> expect to process. Apachectl just sends the "kill" and doesn't wait
> around for everything to exit. Depending on what each of the children
> is doing, this can take awhile. So the better approach is not to
> "stop" again but, if "start" fails, wait a few seconds and try the
> start again.

For exactly this reason, I always modify apachectl so that the restart
option looks like:

restart)
timeout=${2:-5}
count=0
$0 stop
while [ $count -lt $timeout ]; do
echo -n ". "
sleep 1
count=`expr $count + 1`
done
echo ""
$0 start
;;

This will sleep for $2 (or 5 seconds) between stopping and starting.
The sleep ensures that the start doesn't get called too quickly.

Use it like:

  apachectl restart 10

to wait 10 seconds, or

  apachectl restart

to wait the default 5.

(darren)

-- 
Fanaticism consists in redoubling your efforts when you have
forgotten your aim.
-- George Santayana



Re: Apache+Modperl & Website Statistics

2002-03-27 Thread darren chamberlain

* Philip M. Gollucci <[EMAIL PROTECTED]> [2002-03-27 10:38]:
> Well I've basically taken your route the first time I tried to
> do this a year ago.  The other problem is that this requires
> the vistors go to this particular page.  If they bookmark to
> another page or type the url of a sublink, this is bypassed,
> and I loose the statistical information.  My problem is that
> the PerlLogHandler I've set up isn't actually supposed to ever
> display anything to the browser.  (I don't think any
> PerLogHandler anyone writes should send anything to the browser
> as is basically an extension to use instead of the apache's
> access_log file.  Although it could if you had a good reason.
> In order for the javascript I gave to get values it has to be
> sent to the browser on a page so its processed my the
> javascript engine in the browsers.

If you are using a PerlTransHandler anyway, you can have one that
sends the client to a particular page if a cookie is not set:

  (a) Client requests /foo.html
  (b) TransHandler sees that cookie is not set, does an internal
  redirect to /js-set-cookie.html, which does some (client
  size) js magic and transparantly redirects to the
  cookie-setting page, which sets the cookie and does its
  own redirect.
  (c) TransHandler gets this request as well (it was an external
  redirect instigated by the client-side javascript), sees
  that the cookie it is looking for is set, and does the 
  appropriate redirecting (to the right sized page).

Pretty straightforward.  mod_dir does this sort of thing all the
time, under the covers (although sans javascript, of course).

(darren)

-- 
You can't wake a person who is pretending to be asleep.
-- Navajo Proverb



Re: Apache+Modperl & Website Statistics

2002-03-27 Thread darren chamberlain

* Philip M. Gollucci <[EMAIL PROTECTED]> [2002-03-27 09:59]:
> I know perl is server side and javascript is client side.
> AFAIK, getting the resolution is a client side thing.  I know I
> can embed an html page with javascript in it that redirects to
> a perl file setting the query string with width=1024;height=768

[-- snip --]

> But, I need to find someway to do this without the extra
> redirect. 

Since, as you already realize, there is no way to get the client
information from the server size, I think the best you can do
would be something along the lines of: have a javascript
enabled page that gets the height and width of the client (as
you've shown), that then redirects the client to a location
that can read the height and width from the query string and set
a session cookie, which can then be read and acted upon for every
subsequent request by a PerlTransHandler or RewriteRule.

Does that sound reasonable?

(darren)

-- 
Pessimests are right more often, but optimists are happy more often.



Re: Off topic question & a little worried

2002-03-21 Thread darren chamberlain

Quoting Ged Haywood <[EMAIL PROTECTED]> [Mar 21, 2002 16:15]:
> > Any idea as to how it got on my server.
> 
> Nope.  There are a thousand ways it could have been done if
> your server is not carefully secured.  Do waht Perrin said -
> take it offline, it can't be trusted - and read the CERT stuff
> that you've been pointed to by another useful reply.

Another alternative is to replace it with something that appears
to do the same thing, but actually logs a ton of stuff from the
requestor.

(darren)

-- 
My one regret in life is that I am not someone else.
-- Woody Allen



Re: modperl and SQL db select

2002-03-21 Thread darren chamberlain

Quoting Dave Hodgkinson <[EMAIL PROTECTED]> [Mar 21, 2002 13:25]:
> darren chamberlain <[EMAIL PROTECTED]> writes:
> > Quoting dreamwvr <[EMAIL PROTECTED]> [Mar 21, 2002 13:10]:
> > > Is there any issue with using modperl with postgres vs mysql
> > > for a database driven website? Don't want to bark up the wrong
> > > tree in a mod_perl project only to discover I picked the wrong
> > > .db :-/ 
> > 
> > Take a look at http://www.phpbuilder.com/columns/tim2705.php3>,
> > in which the author discusses why Sourceforge uses postgresql
> > instead of MySQL.  It's a little dated (the postgres version is
> > 7.1, for example) but a fun read.
> 
> It's also been thoroughly rebutted ISTR :-)

I didn't say it was _accurate_, I said it was _fun_. :)

(darren)

-- 
There are two ways of constructing a software design. One way is
to make it so simple that there are obviously no deficiencies. And
the other way is to make it so complicated that there are no
obvious deficiencies.
-- C.A.R. Hoare



Re: modperl and SQL db select

2002-03-21 Thread darren chamberlain

Quoting dreamwvr <[EMAIL PROTECTED]> [Mar 21, 2002 13:10]:
> Is there any issue with using modperl with postgres vs mysql
> for a database driven website? Don't want to bark up the wrong
> tree in a mod_perl project only to discover I picked the wrong
> .db :-/ 

Take a look at http://www.phpbuilder.com/columns/tim2705.php3>,
in which the author discusses why Sourceforge uses postgresql
instead of MySQL.  It's a little dated (the postgres version is
7.1, for example) but a fun read.

(darren)

-- 
We must respect the other fellow's religion, but only in the sense and
to the extent that we respect his theory that his wife is beautiful
and his children smart.
-- H.L.Mencken



Re: [WOT] emacs and WEBDAV

2002-03-14 Thread darren chamberlain

Quoting Rob Bloodgood <[EMAIL PROTECTED]> [Mar 14, 2002 14:30]:
> I've been trying, in various attempts over the past two years,
> to come up with a compromise between the two.  The closest I've
> come was somebody mentioned a CVS emulation layer over a DAV
> repository... but that never came to fruition.  And even more
> frustrating, I haven't managed to pick up enough eLisp to do it
> myself w/ vc.el .
> 
> Does anybody have any ideas for my next direction to turn?

This  looks
promising...

(darren)

-- 
We can't all, and some of us don't. That's all there is to it.
-- Eeyore



Re: where is libperl.so.1?

2002-03-07 Thread darren chamberlain

Quoting J S <[EMAIL PROTECTED]> [Mar 07, 2002 12:18]:
> I've installed an apache build I did onto a Solaris
> 2.6 box, and when I try to start it I get the following error message:
> 
> ld.so.1: /opt/apache_1.3.22/bin/httpd: fatal: libperl.so.1: open failed:
> No such file or directory
> Killed
> 
> I can't find libperl.so on either the original box, or the box
> I'm installing to. Can anyone help me out please?

You shouldn't need to find libperl.so if you've built it
statically.  For example:

Here is my httpd:
$ /usr/local/apache/1.3.22/bin/httpd-modperl1.25-perl5.00503  -l
Compiled-in modules:
  http_core.c
  mod_env.c
  mod_log_config.c
  mod_mime.c
  mod_negotiation.c
  mod_status.c
  mod_info.c
  mod_include.c
  mod_autoindex.c
  mod_dir.c
  mod_cgi.c
  mod_actions.c
  mod_alias.c
  mod_rewrite.c
  mod_access.c
  mod_auth.c
  mod_proxy.c
  mod_so.c
  mod_setenvif.c
  mod_perl.c

Here is what it's using:
$ ldd /usr/local/apache/1.3.22/bin/httpd-modperl1.25-perl5.00503 
libm.so.6 => /lib/libm.so.6 (0x40019000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x40037000)
libdb.so.3 => /lib/libdb.so.3 (0x40064000)
libnsl.so.1 => /lib/libnsl.so.1 (0x4009f000)
libdl.so.2 => /lib/libdl.so.2 (0x400b5000)
libc.so.6 => /lib/libc.so.6 (0x400b9000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x4000)

No libperl.so.  Are you sure you're trying to start the correct
httpd?

(darren)

-- 
I must say I find television very educational. The minute somebody
turns it on, I go to the library and read a good book.
-- Grouchy Marx



Re: Perl script for Cobalt Cube 3

2002-03-07 Thread darren chamberlain

Quoting Thomas Hanson <[EMAIL PROTECTED]> [Mar 07, 2002 07:36]:
> I am trying to make 2 perl scripts for our cube3 since we are
> trying to automate the add user and delete user administration.
> 
> So far I have found perl scripts to add users and groups,
> delete users and groups but not to add or delete mail aliases.
> Those scripts use these modules :
> Cobalt::user
> Cobalt::group
> 
> I found that there is a Cobalt::mail  module too, and figure I
> need to use that one too.
> 
> Where can I find som info on these modules and how to use them?
> And can anyone give me any pointers on what else I might need
> (I have never programmed perl before, but there is always a
> first time).

Can't you just open up the modules and read the source code?
Let perl tell you where they are:

  perl -MCobalt::user -MCobalt::group -MCobalt::mail -e 'print map "Cobalt::$_ => 
$INC{"Cobalt/${_}.pm}\n", qw(user group mail)'

(darren)

-- 
Laziness is often mistaken for patience.



Re: mod_perl and perl RPMs and Oracle 9iAS

2002-03-06 Thread darren chamberlain

Quoting Rafael Caceres <[EMAIL PROTECTED]> [Mar 06, 2002 12:22]:
> Perrin Harkins wrote:
> >Unless there is some additional module provided by Oracle
> >which has a C component and no source, you should be fine to
> >replace everything they gave you if you want to.  I wouldn't
> >bother though, unless it's giving you trouble.
> 
> Yes, there are at least two modules: mod_plsql and mod_oprocmgr
> for which there is no source, so rebuilding seems to be out of
> the question

...unless they are built dynamically, in which case you should be
able to load them as DSOs, provided you use the same version of
Apache.  Yes?

(darren)

-- 
Although I can accept talking scarecrows, lions, and great
wizards of emerald cities, I find it hard to believe there
is no paperwork involved when your house lands on a witch.



[upload@p11.speed-link.de: CPAN Upload: D/DA/DARREN/Apache-MultiAuth-0.04.tar.gz]

2002-02-14 Thread darren chamberlain

- Forwarded message from PAUSE <[EMAIL PROTECTED]> -

Date: Thu, 14 Feb 2002 19:13:11 +0100
Reply-To: [EMAIL PROTECTED]
Subject: CPAN Upload: D/DA/DARREN/Apache-MultiAuth-0.04.tar.gz
From: PAUSE <[EMAIL PROTECTED]>
To: "Darren Chamberlain" <[EMAIL PROTECTED]>, [EMAIL PROTECTED]

The uploaded file

Apache-MultiAuth-0.04.tar.gz

has entered CPAN as

  file: $CPAN/authors/id/D/DA/DARREN/Apache-MultiAuth-0.04.tar.gz
  size: 2514 bytes
   md5: 8c703e8ac418ff46886220a52153b079

No action is required on your part
Request entered by: DARREN (Darren Chamberlain)
Request entered on: Thu, 14 Feb 2002 18:11:49 GMT
Request completed:  Thu, 14 Feb 2002 18:13:11 GMT

Virtually Yours,
Id: paused,v 1.74 2001/05/20 14:59:52 k Exp k 

- End forwarded message -

-- 
Everybody wants to go to heaven, but nobody wants to die.
-- Peter Tosh



Re: Multiple authentication methods

2002-02-13 Thread darren chamberlain

Quoting Stathy G. Touloumis <[EMAIL PROTECTED]> [13 Feb-02 15:26]:
> Some more fixes ; )

Yay! Bug reports already...

> I would suggest changing the PerlSetVar variables
> to actual apache configuration directives which would change this :
> 
> my @auth_modules=$r->dir_config->get("AuthModules");
> 
> I don't have an immediate patch for this but have done it before.
> If you would like me to work on this code no prob, otherwise check
> the eagle book for some samples if unfamiliar.

*nod*  I'm not sure that the syntax would work; $r->dir_config()
would probably return an arrayref, and such; this needs to be
tested.

> Also,
> 
> THIS :
> 
> my $handler = \&{"$am\::handler"};
> if ($handler->($r) == OK) {
>   $r->warn("$am return OK");
> return OK;
> 
> TO :
> 
> ## 'or next' can be changed
> my $handler = $am->can('handler') or next;
> if ($handler->($r) == OK) {
>   $r->warn("$am return OK");
>   return OK;
> }

Yeah, I just didn't think of that when I wrote the code.  That is
the Correct Way.

> And I would consider changing this :
> 
> $module  =~ s[::][/]g;
> 
> to be more portable.  I am working on another class for runtime
> management of classes that should address this but won't be on
> CPAN for a few days.

I stole that almost whole hog from Template/Config.pm, lines
68-78.  Take it up with Andy. ;)

The easiest thing would be to use Config, and do:
  
  $module =~ s[::][$Config{'path_sep'}]g;

Right?

(darren)

-- 
What a strange illusion it is to suppose that beauty is goodness.
-- Leo Tolstoy



Re: Multiple authentication methods

2002-02-13 Thread darren chamberlain

Quoting Marcel Weber <[EMAIL PROTECTED]> [13 Feb-02 14:53]:
> Why not submitting this somewhere? I think this could be
> usefull for quite a lot of people. I think this is cool, as you
> do not have to worry wether the module returns DECLINED or
> AUTH_REQUIRED.

I can package this up and put it on CPAN as version 0.01 tomorrow
morning, if that seems reasonable to everyone involved.  I'll
need to add some docs and a Makefile.PL, of course.

(darren)

-- 
To believe is very dull. To doubt is intensely engrossing. To be on
alert is to live, to be lulled into security is to die.
-- Oscar Wilde



Re: Multiple authentication methods

2002-02-13 Thread darren chamberlain

Quoting Aaron Ross <[EMAIL PROTECTED]> [13 Feb-02 09:21]:
> shouldn't stacked handlers be the right solution here?  are
> stacked auth handlers not allowed or something?

Assuming your mod_perl has been built with them, then, yes, that's
probably a better solution.  But I had a fun 15 minutes writing
Apache::MultiAuthen, though. :)

(darren)

-- 
My studies in Speculative Philosophy, metaphysics, and science are
all summed up in the image of a mouse called man running in and
out of every hole in the Cosmos hunting for the Absolute Cheese.
-- Edmund Burke



Re: Multiple authentication methods

2002-02-13 Thread darren chamberlain

Quoting Marcel Weber <[EMAIL PROTECTED]> [12 Feb-02 16:15]:
> I don't get the point why it did not work the other way round,
> but now everything is just fine now :

Make it a little more generic:

package Apache::MultiAuthen;

use strict;
use Apache::Constants qw(:common);

sub handler {
my $r = shift;
my($res, $sent_pw) = $r->get_basic_auth_pw;
return $res if $res != OK;

# Tweak this; unsure about dir_config returning an array
my @auth_modules = $r->dir_config("AuthModules");

for my $am (@auth_modules) {
load($am);

if ($@) {
$r->log("Error loading module '$am': $@");
next;
}

my $handler = \&{"$am\::handler"};
if ($handler->($r) == OK) {
$r->log_reason("$am return OK");
return OK
}

$r->log_reason("$am not OK");
}

$r->note_basic_auth_failure;
return AUTH_REQUIRED;
}

sub load {
my $module = @_;
$module  =~ s[::][/]g;
$module .= '.pm';

eval { require $module; };

return $@ ? 1 : 0;
}

1;

__END__

(darren)

-- 
Never attribute to malice that which is adequately explained by
incompetence.
-- Napolean Bonaparte



Re: Dynamically serving an .htaccess file with mod_perl

2002-01-29 Thread darren chamberlain

Michael A Nachbaur <[EMAIL PROTECTED]> said something to this effect on 01/28/2002:
> Does anyone know of a way that I can server the contents of an
> .htaccess file dynamically?  I know Apache checks the request
> directory (and all directories above it) for an .htaccess file
> before serving a file request, but there is no mention of how
> it goes about loading that file.

Make the .htacess file in question a FIFO, with a script on the
backend that Does The Right Thing.

(darren)

-- 
Unix is an operating system, OS/2 is half an operating system,
Windows is a shell, and DOS is a boot partition virus.
-- Peter H. Coffin



Re: help: LWP::Simple within a mod_perl context

2002-01-28 Thread darren chamberlain

Matthew Kennedy <[EMAIL PROTECTED]> said something to this effect on 
01/28/2002:
> Hello, I am using LWP::Simple within a mod_perl context to
> retrieve content from an external site within a request to our
> site. I've installed LWP::Simple correctly, however is doesn't
> work within mod_perl and (I suspect) it doesn't work work
> within a regular CGI app.
> 
> I wrote a simple script and ran it "su - apache -c
> '/path/to/script'" and it doesn't return any content. It does
> return content for real user id's though (eg. su - mkennedy
> ...). So I suspect the apache user cannot use LWP::Simple
> because LWP::Simple is requiring some rights user apache does
> not have.

Have you tried running this as the apache user:

$ /path/to/perl -MLWP::Simple -le 'getprint "http://my.url/to/get";'

This will tell you if the problem is with LWP::Simple or
something else.

Next, do a little ls -l `perldoc -l LWP::Simple` and make sure
that the permissions are right.

(darren)

-- 
Whatever is done for love is beyond good and evil.
-- Friedrich Neitzsche



Re: Convert bitmap

2001-12-19 Thread darren chamberlain

Hans-Olof Hermansson <[EMAIL PROTECTED]> said something to this effect on 12/19/2001:
> I am looking for a perl module that can convert a
> bitmap picture to jpeg or gif. I am sending a bitmap
> from a Pocket PC device to a Solaris webserver running
> Apache. If anyone has any tips it will be greatly
> appreciated.

Have you looked into PerlMagick?

http://www.imagemagick.org/www/perl.html

(darren)

-- 
My one regret in life is that I am not someone else.
-- Woody Allen



Re: Apache::Cooke & reserved chars

2001-12-18 Thread darren chamberlain

[EMAIL PROTECTED] <[EMAIL PROTECTED]> said something to this effect on 
12/18/2001:
> > Use escape_uri and unescape_uri, or some other pair of reversable
> > functions.  For example, store it as:
>
> Tried this and it appears that Apache::Util escapes the same
> characters that Apache::Cookie does when it prepares this
> cookie. Problem is that it wont pull the ampersands back in.
> I'm assuming the thinking is that Apache::Cookie shoud be able
> to decode a string it encodes. I'm running an older version of
> mod_perl (1.24_01), wondering if anybody knows if this issue
> has been seen before, and if it's been fixed in more recent
> versions.

URI::Escape::uri_escape allows you to pass a list of "unsafe"
characters as the optional second argument (although
Apache::Util::unescape_uri does not; see src/main/util.c in the
apache source for why).  Here is an updated version of my
previous example (trimmed; the value for $url is the one you gave
in the original message):

  use URI::Escape;
  my $url = 
q|http://www.newsfactor.com/x.pl?action=reply_form_html&board=nfntalkback&id=3288|;
  my $escaped = uri_escape($url, '\x00-\xff');

Now, $escaped looks like:

  
%68%74%74%70%3A%2F%2F%77%77%77%2E%6E%65%77%73%66%61%63%74%6F%72%2E%63%6F%6D%2F%78%78%78%78%78%2E%70%6C%3F%61%63%74%69%6F%6E%3D%72%65%70%6C%79%5F%66%6F%72%6D%5F%68%74%6D%6C%26%62%6F%61%72%64%3D%6E%66%6E%74%61%6C%6B%62%61%63%6B%26%69%64%3D%33%32%38%38

This should be OK as a cookie value.  The value of $escaped is
easily retrievable with:

  my $unescaped = uri_unescape($escaped);

The only problem, such as it may be, is that the version in
URI::Escape pure perl, and therefore slower than the version in
Apache::Util.

(darren)

-- 
I invented the term "Object-Oriented", and I can tell you,
I didn't have C++ in mind.
-- Alan Kay



Re: Apache::Cooke & reserved chars

2001-12-18 Thread darren chamberlain

[EMAIL PROTECTED] <[EMAIL PROTECTED]> said something to this effect on 
12/17/2001:
> I'm recording a url at the beginning of an app to restore the
> entrance url:
> 
> sub set_referer {
>   my $self = shift;
>   if ($self->{R}) {
>   require Apache::Cookie;
>   
>   my $cookie = Apache::Cookie->new($self->{R},
>   -name=>  "REFERER",
>   -value   =>  $self->{R}->header_in('Referer'),
>   -expires =>  '2d',
>   -domain  =>  ".$NFN::sites{$ENV{SITE}}{domain}",
>   -path=>  '/'
>   );
>   $cookie->bake;
>   }
>   
> }
> 
> 
> Which stores the cookie portion like so:
> 
> 
>REFERER=http://www.newsfactor.com/x.pl%3faction=reply_form_html&board=nfntalkback&id=3288
> 
> However when I pull this back in with Apache::Cookie->fetch,
> the data then reads:
> 
> http://www.newsfactor.com/x.pl?action=reply_form_html
> 
> Apache::Cookie seems to be stripping out the portion after the first 
> ampersand.
> 
> Anybody know what do do here?

Use escape_uri and unescape_uri, or some other pair of reversable
functions.  For example, store it as:

use Apache::Util qw(escape_uri unescape_uri);
sub set_referer {
my $self = shift;
if ($self->{R}) {
require Apache::Cookie;

my $cookie = Apache::Cookie->new($self->{R},
-name=>  "REFERER",
-value   =>  escape_uri($self->{R}->header_in('Referer')),
-expires =>  '2d',
-domain  =>  ".$NFN::sites{$ENV{SITE}}{domain}",
-path=>  '/'
);
$cookie->bake;
}

}

And then fetch it as:

  my $value = unescape_uri($cookies{'REFERER'});

(darren)

-- 
Men are from earth. Women are from earth. Deal with it.



Re: libapreq. Apache::Cookie returns different 'expires' than CGI::Cookie?

2001-12-14 Thread darren chamberlain

Alexei Danchenkov <[EMAIL PROTECTED]> said something to this effect on 12/14/2001:
> Hello, All!
> I wonder why my '$cookie->expires' for this code returns a
> different result than the similar one with CGI::Cookie
> (commented).  The result is different in a way that some
> additional binary code is being added to the expiry date.
>
> $cookie = Apache::Cookie->new( $r,
>   -name=>"access",
>   -value=>$value,
>   -expires=>"+10m" );
>
> #my $cookie = new CGI::Cookie(
>   -name=>"access",
>   -value=>$value,
>   -expires=>"+10m" );
>
> $expiry = $cookie->expires;
>
> Any suggestions?

Maybe I'm just slow, but I can see the difference between the
two.  Can you elaborate?

(darren)

-- 
Blore's Razor:
Given a choice between two theories, take the one
which is funnier.



Re: form upload limit

2001-12-13 Thread darren chamberlain

Joe Schaefer <[EMAIL PROTECTED]> said something to this effect on 12/13/2001:
> Is this what you want
> 
>   $apr = Apache::Request->new( $r->is_main ? $r : $r->main, 
>POST_MAX => 1024);
> 
> ?  I don't think Apache::Request provides any Perl methods for
> culling the post_max setting from a $apr;  you'd either have to
> write some XS for that, keep track of it yourself, or lobby for
> a new feature ;)

Or you can patch libapreq-0.33/Request/Request.xs:

*** Request.xs.orig Thu Dec 13 11:44:25 2001
--- Request.xs  Thu Dec 13 11:36:06 2001
***
*** 356,361 
--- 356,375 
  Apache::Request req
  
  int
+ ApacheRequest_post_max(req, max=Nullsv)
+ Apache::Request req
+ SV *max;
+ 
+ CODE:
+ if (max != Nullsv) {
+   req->post_max = (int)SvIV(max);
+ }
+ RETVAL = req->post_max;
+ 
+ OUTPUT:
+ RETVAL
+ 
+ int
  ApacheRequest_parse(req)
  Apache::Request req

This will add $apr->post_max, which works in my (simplistic and
deterministic) tests.

(darren)

-- 
If I worked as much as others I would do as little as they.



Re: using CGI::raw_cookie()

2001-12-12 Thread darren chamberlain

Lance Uyehara <[EMAIL PROTECTED]> said something to this effect on 12/12/2001:
> I'm using a CGI script which makes a call to raw_cookie(). When
> I run in CGI mode everything works fine, and the cookie which
> matches $ENV{HTTP_COOKIE} is returned.

What version of CGI.pm are you using?  CGI.pm goes to great
lengths to be compatible with mod_perl, so I think you either
have an old version of CGI.pm, or are reusing a CGI instance
between requests.  $self shouldn't be defined if you are creating
the instance anew with each request.

(darren)

-- 
Reisner's Rule of Conceptual Inertia:
If you think big enough, you'll never have to do it.



Re: RFC: CGI vs. Apache Namespace Question

2001-12-12 Thread darren chamberlain

James G Smith <[EMAIL PROTECTED]> said something to this effect on 12/12/2001:
> darren chamberlain <[EMAIL PROTECTED]> wrote:
> >  5)  Include Apache::URI2Param with the CGI::URI2Param module
> >  that gets installed along with CGI::URI2Param if Apache.pm is
> >  installed, where Apache::URI2Param calls
> >  CGI::URI2Param::uri2param.
> >
> >That'd be the way I would go, although I'm not sure what
> >Makefile.PL would look like.
> 
> I'd go ahead and install it regardless of whether or not Apache.pm is
> installed (if writing an Apache:: module) in case mod_perl gets installed
> after this one and the mod_perl installer doesn't realize they have to go
> back and re-install this module to get the Apache:: version.

I didn't even think of that; if Apache is not installed, having
URI2Param.pm in site_perl/Apache doesn't matter.  Therefore, I
would like to resubmit option 5:

  5)  Include Apache::URI2Param with the CGI::URI2Param module
  that gets installed along with CGI::URI2Param, where
  Apache::URI2Param calls CGI::URI2Param::uri2param.

(darren)

-- 
If we can't be free at least we can be cheap.



Re: RFC: CGI vs. Apache Namespace Question

2001-12-12 Thread darren chamberlain

Thomas Klausner <[EMAIL PROTECTED]> said something to this effect on 12/11/2001:
> I've got a small CPAN Namespace Question:
> 
> Some time ago I wrote CGI::URI2param (
> http://search.cpan.org/search?mode=module&query=URI2param
> ).
> 
> Now, thanks to an idea by darren chamberlain, I wrote a small
> PerlInitHandler that does nothing more than parse some
> PerlSetVars and then call uri2param(). But still it is very
> convienient to use it like this.
> 
> So should I: 1* put the Apache Handler into CGI::URI2param,
> which maybe is some sort of Namespace violation (you'd have to
> say PerlInitHandler CGI::URI2param in httpd.conf)
>   
> 2* create a new module, Apache::URI2param, which only contains
> the config parsing stuff and requires CGI::URI2param. This
> would result in two small modules cluttering CPAN, where one of
> those (Apache::URI2param) is useless without the other
> 
> 3* dump CGI::URI2param in favour of Apache::URI2param, which
> wouldn't make much sense either, because the code does not
> depend on mod_perl (and not even on Apache)
> 
> 4* let the users write there own handlers
> 
> I tend to use solution 1, but if you would like to comment on
> this, I would really appreciate some feedback!

  5)  Include Apache::URI2Param with the CGI::URI2Param module
  that gets installed along with CGI::URI2Param if Apache.pm is
  installed, where Apache::URI2Param calls
  CGI::URI2Param::uri2param.

That'd be the way I would go, although I'm not sure what
Makefile.PL would look like.

(darren)

-- 
A computer lets you make more mistakes faster than any other
invention, with the possible exceptions of handguns and Tequila. 
-- Mitch Ratcliffe



Re: Q - Apache::Request->new(undef) works?

2001-12-11 Thread darren chamberlain

Jay Lawrence <[EMAIL PROTECTED]> said something to this effect on 12/11/2001:
> In my development I neglected to supply the Apache request
> object when I called Apache::Request->new( $r ). Actually $r
> was undef. It still works! I am just wondering if this is
> expected behaviour and if it will be supported going forward or
> was this just a fluke?

The Apache instance that gets passed to Apache::Request::new
apepars to not be required:

# From libapreq-0.33/Request/Request.xs:
165 static ApacheRequest *sv_2apreq(SV *sv)
166 {
167 if (SvROK(sv) && sv_derived_from(sv, "Apache::Request")) {
168 SV *obj = sv;
169 
*snip*
179 return (ApacheRequest *)SvIV((SV*)SvRV(obj));
180 }
181 else {
182 return ApacheRequest_new(perl_request_rec(NULL));
183 }
184 }

perl_request_rec is defined in mod_perl/src/modules/perl/mod_perl.c
(from the mod_perl distribution); it sets the static IV
mp_request_rec to a request_rec:

# mod_perl/src/modules/perl/mod_perl.c:
 66 static IV mp_request_rec;
   1685 request_rec *perl_request_rec(request_rec *r)
   1686 {
   1687 if(r != NULL) {
   1688 mp_request_rec = (IV)r;
   1689 return NULL;
   1690 }
   1691 else
   1692 return (request_rec *)mp_request_rec;
   1693 }

So, at least with the current versions of mod_perl (1.26) and
libapreq (0.33), not passing Apache->request to
Apache::Request::new seems safe.

(darren)

-- 
Democracy is a form of government that substitutes election by the
incompetent many for appointment by the corrupt few.
-- George Bernard Shaw



Re: ASP.NET Linux equivalent?

2001-12-06 Thread darren chamberlain

Dave Hodgkinson <[EMAIL PROTECTED]> said something to this effect on 12/06/2001:
> Whatever happened to the widget subproject that span out of the
> modperl list a few months ago?

http://www.officevision.com/pub/Widget/

Not too active lately:
http://sourceforge.net/project/stats/?group_id=27958

(darren)

-- 
This is the crucial difference between fiction and real life: 
fiction must be plausible; real life has no such constraint.
-- Kevin Kelly



Re: ASP.NET Linux equivalent?

2001-12-05 Thread darren chamberlain

On Monday, December 03, 2001, Vsevolod Ilyushchenko <[EMAIL PROTECTED]> said:
> Is anyone aware of a Linux product equivalent to ASP.NET from
> MS? Its most attractive feature is the GUI construction of Web
> forms and the automatic connection of their fields to a
> database. Since I am getting sick and tired of writing over and
> over the code to process user input and store it in the
> database, a similar product would be a huge help. (PHPLens does
> something similar, but it only presents data in the table
> format.)
>
> This may be somewhat offtopic, but I hope that even if there is
> nothing modperl based in existence, then maybe the readers are
> informed enough to point me in the right direction. So far it
> seems that neither Dotgnu nor Mono have anything similar.

Have you seen the perl-widget project at http://www.officevision.com/pub/Widget/?

It was (is) designed to handle the problem of creating widgets
that are self-aware (knowing how to display themselves in a
number of formats, knowing how to update their data source, etc).

The last time I took a look at the code was a few months ago, and
it was well on its way at that point.  The project is hosted by
sourceforge, so is a mailing list and CVS access.

(darren)

-- 
We are Pentium of Borg. Division is futile. You will be approximated.



Re: Problems compiling libapreq C libs on solaris 7....

2001-10-15 Thread darren chamberlain

Sean Chittenden <[EMAIL PROTECTED]> said something to this effect on 10/15/2001:
> I'm interested in the C routines, not the perl routines (have them
> working and know how to get them to work ::grin::).  I can do a perl
> Makefile.pl && make and the build works fine, but like I said, I'm
> interested in the C routines as well as the perl ones or are the C
> routines largely a myth?  Thanks.  -sc

I tried this:

$./configure --with-apache-includes=/usr/local/apache/include
$ make 
cd . && aclocal
cd . && automake --foreign Makefile
automake: configure.in: required file `./missing' not found
make: *** [Makefile.in] Error 1
$ ls -lo ./missing
lrwxrwxrwx1 darren   33 Jun 20 07:24 missing -> /usr/local/share/automake/missing
$ ls -lo /usr/local/share/automake/missing
ls: /usr/local/share/automake/missing: No such file or directory
$ ls -lo /usr/share/automake/missing
-rwxr-xr-x1 root 6283 Mar 11  2000 /usr/share/automake/missing
$ rm missing
$ ln -s /usr/share/automake/missing missing
$ make

and it worked just fine.  Your automake might be somewhere else.

(darren)

-- 
People who sacrifice beauty for efficiency get what they deserve.
-- Tom Robbins



Re: Apache::Registry caching of compiled scripts

2001-10-11 Thread darren chamberlain

Nicholas Oxhj <[EMAIL PROTECTED]> said something to this effect on 10/11/2001:
> Does anybody know why Apache::Registry caches compiled scripts
> by their URI, instead of by their absolute path?

Try Apache::RegistryNG, which caches scripts by their filename.

(darren)

-- 
Premature optimization is the root of all evil in programming.
-- C.A.R. Hoare



Re: Another way to perhaps do this......

2001-09-28 Thread darren chamberlain

Steven Boger <[EMAIL PROTECTED]> said something to this effect on 09/28/2001:
> I've been netsearching for hours. It's time to beg for help...
> 
> My apache has a hacked mod_include that has a new directive, OAS:
> 
> 
> 
> 
> 
> Can I somehow run those directives right from mod_perl

After this tag is parsed, there are a number of variables in %ENV
that you can access, named based on the positions you specify in
the setup up.  In the case of the above example, the variables
are OAS_TopLeft, OAS_TopRight, OAS_BottomLeft, and
OAS_BottomRight.

You can get them from the subprocess_env table:

  my $top_left = $r->subprocess_env('OAS_TopLeft');
  my $top_right= $r->subprocess_env('OAS_TopRight');
  my $bottom_left  = $r->subprocess_env('OAS_BottomLeft');
  my $bottom_right = $r->subprocess_env('OAS_BottomRight');

...assuming that the setup tag has been parsed.  You can also get
them via SSI #echo statements:



My experience has been that OpenAdStream does a lot of things
well, but interacting with mod_perl is not one of them.  We were
hitting this wall a efw months ago, and were unable to come up
with a decent, well-integrated, programmatic solution.  We have
come up with a replacement for all this madness using the JX
method and a dedicated module that write the JavaScript, which is
really ugly but surprisingly effective.  It doesn't require that
the perl module hit the OAS server or call any oas methods.
Email me offlist if you are interested in hearing how we did it.

(darren)

-- 
I interpret advertising as damage and route around it.



Re: Modules

2001-09-27 Thread darren chamberlain

Recendez, Ray <[EMAIL PROTECTED]> said something to this effect on 09/27/2001:
> How do I check if StackedHandlers, MethodHandlers, Authen, and
> Authz are compiled in?

httpd -L | grep '^Perl'

(darren)

-- 
If NT is your answer, you don't understand the question.



Re: RealMedia Open AdStream and mod_perl

2001-09-24 Thread darren chamberlain

Steven Boger <[EMAIL PROTECTED]> said something to this effect on 09/24/2001:
> I have heard whispers of calling internal OAS functions
> directly in mod_perl instead of using OAS's hacked mod_include.
> 
> If anybody has info on this, i'd greatly appreciate it...

I've looked into using the OAS API (v.4.65 or so) through
mod_perl, and it's rough going.  The mod_oas.c that comes
with the tarball is probably the best place to start (though I
haven't yet).

The version I am looking at defines MOD_OAS_VERSION as
"mod_oas/4.65"; this may not be appropriate anymore.

The key to linking against liboas (or whatever it's called) is at
the beginning of mod_oas.c (lines 22 to 29 in my copy):

/*
 * oas Calls
 */
extern int OASInit (server_rec *s, const char *oaspath);
extern int OASDirector (request_rec *r);
extern int OAS_log_verbose (const char *fmt, ...);
extern void OAS_ap_unmap_shm (void *);

(There is also int OASSendFile(request_req r) which is missing
from the above declaration but called in the oas_send_file
function within mod_oas.c.)

You can figure out how to call them in your XS file from how they
are used in mod_oas.c.

Put the oas library (mod_oas.so?) somewhere it can be linked
against (and list it in your Makefile.PL).

I don't have too much concrete info (sorry about that) but that
should give you someplace to start.  I'd love to hear whether you
get anywhere...

(darren)

-- 
All truth passes through three stages: first, it is ridiculed; next it
is violently attacked; finally, it is held to be self-evident.
-- Schopenhauer



Re: for files that don't exist

2001-09-17 Thread darren chamberlain

dss <[EMAIL PROTECTED]> said something to this effect on 09/17/2001:
> The issue is that I'm using "virtual" urls, so these .phtml
> files don't actually exist and  on the server. I'm curious if my approach is the best way.

Shouldn't  be what you want?

(darren)

-- 
If it turns out that there is a God, I don't think that he's evil.
But the worst that you can say about him is that basically he's an
underachiever.
-- Woody Allen



Re: Cloning the request object

2001-09-10 Thread darren chamberlain

Alin Simionoiu <[EMAIL PROTECTED]> said something to this effect on 09/09/2001:
> I forgot to mention that I'm trying to inspect the body in a
> authentication handler.  As soon as a get the body, the body is
> gone.

So save the body.  Put it into pnotes or something:

sub handler {
my $r = shift;
my $stuff = $r->content;  # or however you get the body during
  # an auth handler...
do_stuff($stuff);

$r->pnotes('AuthBody', $stuff);

return OK;
}

Then the body is available as $r->pnotes('AuthBody');

(darren)

-- 
The bad reputation UNIX has gotten is totally undeserved, laid on by
people who don't understand, who have not gotten in there and tried
anything.
-- Jim Joyce, owner of Jim Joyce's UNIX Bookstore



Re: sharing % across requests

2001-09-06 Thread darren chamberlain

Geoffrey Young <[EMAIL PROTECTED]> said something to this effect on 09/06/2001:
> > > BlankWhat is the best way to share % across multiple requests ?
> > 
> > it's called maintaining state - read the eagle book, chapter 5.
> > 
> > one common solution is Apache::Session
> 
> sorry, I think I misread the question - the verbosity threw me.
> If you are looking to store a datastructure on disk (such as a
> hash) then you can use Storable, which allows you to serialize
> and deserialize your data on demand.  Apache::Session has the
> ability to do the same, but it's not entirely intuitive if you
> aren't already familiar with it.

Since he's using HTML::Mason, though, he has some examples of how
to use Apache::Session, and it's pretty easy to set up.  If I am
remembering correctly, many of the code examples in the Mason
docs assume you are using Apache::Session, and one of sample
handler subroutines shows how to use it.

(darren)

-- 
Never make anything simple and efficient when a way can be found to
make it complex and wonderful.



Re: Problem with DBD::Oracle with mod_perl

2001-08-23 Thread darren chamberlain

Rodney Broom <[EMAIL PROTECTED]> said something to this effect on 08/23/2001:
> From: Rasoul Hajikhani <[EMAIL PROTECTED]>
> > I am sorry but this topic is confusing me... Are you saying that
> > persistent DB connection objects are bad?
> 
> It sounds like that, doesn't it?

This is only when one handle is shared among many children.
Sharing an open handle in the same child (i.e., by successive
requests) is what you want to achieve.  Since each child services
requests serially, each handle is being used onlt once at a time,
but the handle does not disconnect at the end of the request.

(darren)

-- 
Occam's Razor:
The explanation requiring the fewest assumptions is probably the
correct one.



Re: Using CGI.pm in handlers 2

2001-08-20 Thread darren chamberlain

Joachim Zobel <[EMAIL PROTECTED]> said something to this effect on 08/19/2001:
>  > "(offline mode: enter name=value pairs on standard input)"
> 
> I have understood that I get theses messages because it is a Fixup Handler 
> and the enviroment is not yet initialized. But I still don't know what to 
> do about them.

I think this is one of the things taht was fixed in later
versions of CGI.pm; 2.46 is pretty old, I think.  Try upgrading
CGI.pm and I think this error will go away.

(darren)

-- 
Anything can be music.



Re: Text Returned from Get method

2001-08-20 Thread darren chamberlain

winnecon <[EMAIL PROTECTED]> said something to this effect on 08/17/2001:
> Mod_PERL pulls up the first page of my cgi, but every time I try to 
> navigate around using form action buttons (get method) it pulls up 
> the original perl code for the cgi in the browser, as if ExecCGI was 
> not turned on, but it is!
> 
> I have configured httpd.conf for Mod_PERL, as follows:
>   Alias /cgi-bin /Library/WebServer/cgi-bin
>  PerlModule Apache::Registry
>
 
>  SetHandler perl-script
>  PerlHandler Apache::Registry
>  Options ExecCGI
>  Allow from all
>  PerlSendHeader On
>
  

> If anyone else has had this problem or could suggest a solution (or 
> additional documentation) I appreciate it.

Try that.

(darren)

-- 
You can never entirely stop being what you once were. That's why it's
important to be the right person today, and not put it off till tomorrow.
-- Larry Wall



Re: Children dying

2001-08-14 Thread darren chamberlain

Aleksandr Vladimirskiy <[EMAIL PROTECTED]> said something to this effect on 08/14/2001:
>I am running a perl 5.6.0, mod_perl 1.26, apache 1.3.19 on Solaris 2.6.
>I get the following error in my logs:

perl 5.6.0 has DynaLoader bug that minifests itself under
mod_perl.  Upgrade to 5.6.1, downgrade to 5.00503, or wait for
5.8.0 to fix the bug.

(darren)

-- 
Not only is there no God, but try getting a plumber on weekends.
-- Woody Allen



Re: Problem Locating DB_File.PM at startup of perl script

2001-07-18 Thread darren chamberlain

James McKim <[EMAIL PROTECTED]> said something to this effect on 07/18/2001:
> Hi all,
> 
> I've run into a very frustrating problem. I'm getting the old "Can't
> locate loadable object for module..." error, yet the file does exist in
> the @INC path. Here's some system output:
> 
> ---
> 
> [Wed Jul 18 12:18:04 2001] pickcity.cgi: Can't locate loadable object
> for module DB_File in @INC (@INC contains:
> /usr/local/lib/perl5/5.6.1/i686-linux /usr/local/lib/perl5/5.6.1
> /usr/local/lib/perl5/site_perl/5.6.1/i686-linux
> /usr/local/lib/perl5/site_perl/5.6.1 /usr/local/lib/perl5/site_perl .)
> at /var/pickcity/htdocs/pickcity.cgi line 12
> [Wed Jul 18 12:18:04 2001] pickcity.cgi: Compilation failed in require
> at /var/pickcity/htdocs/pickcity.cgi line 12.
> [Wed Jul 18 12:18:04 2001] pickcity.cgi: BEGIN failed--compilation
> aborted at /var/pickcity/htdocs/pickcity.cgi line 12.
> [root@localhost DB_File]# ls
> /usr/local/lib/perl5/5.6.1/i686-linux/DB_File.pm
> /usr/local/lib/perl5/5.6.1/i686-linux/DB_File.pm
> [root@localhost DB_File]#
> 
>--
> 
> Anyone have any ideas as to why perl can't seem to find the file
> eventhough the system, clearly, can?

What are the permissions on
/usr/local/lib/perl5/5.6.1/i686-linux/DB_File.pm? Can the owner
of the httpd process read the file?

(darren)

-- 
Real computer scientists don't program in assembler.  They don't write
in anything less portable than a number two pencil.



Re: Post processing Perl output through PHP

2001-07-15 Thread darren chamberlain

[EMAIL PROTECTED] <[EMAIL PROTECTED]> said something to this effect on 07/14/2001:
> I am having a nightmare trying to get some PHP into the output of
> a Perl script. PHP. I've heard rumours of Apache 2.0 allowing multiple
> filters, which would be perfect when it's out, but not yet obviously.

Add PHP support to your server, and use subrequests to get the
results of the processing.  Or, run PHP on another server, and
use LWP to fetch pages from that server which will be included
the output fromt he main server.

(darren)

-- 
I respect faith, but doubt is what gives you an education.
-- Wilson Mizner



Re: Apache::Upload filehandle

2001-07-12 Thread darren chamberlain

Jay Buffington <[EMAIL PROTECTED]> said something to this effect on 07/11/2001:
> I'm trying to use image magick to manipulate images that are
> uploaded via http.  To handle the uploaded images I'm using
> libapreq's Apache::Upload.
> 
> I wrote the below simple example script to help explain my problem.
> 
> When an image is uploaded to it I get this error in the apache
> error log: ImageMagick error: Warning 320: no delegate for this
> image format (:Upload=GLOB(0x873bcec)) [No such file or
> directory]
> 
> I'm confused why this happens.  Could someone please explain
> this behaviour to me? 

This looks like $r->upload->fh is being stringified, probably
because of the context.  What happens when you assign the glob
returned by $r->upload->fh to a lexical scalar, and then pass
that into $image->Read()?  I hit this a few days ago, when
passing a glob reference into a subroutine (not
mod_perl-related), and this is the only thing that worked.

> 
> package UploadFile;
> 
> use Apache;
> use Apache::Request;
> use Apache::Constants qw(:common);
> use CGI qw(-compile :standard);
> use Image::Magick;
> 
> sub handler {
> my $r = new Apache::Request(shift);
> 
> if ($r->param('action') eq "upload") {
> my $image = new Image::Magick;

Add these changes: 

  my $fh = $r->upload->fh;
  my $error = $image->Read(file => $fh);

> $r->log_error("ImageMagick error: $error") if $error;
> $r->print("image geometry: " . join " x ",
>   $image->Get('width', 'height'));
> undef $image;
> }
> 
> $r->print(start_html() . start_multipart_form() . "Upload an image: " .
>   filefield(-name=>"uploadedfile") . submit(-name=>"action",
>   -value=>"upload") . end_form() . end_html());
> 
> return OK;
> }
> 
> 1;

(darren)

-- 
Death to all fanatics!



Re: CGI module or Apache

2001-07-09 Thread darren chamberlain

Dave Hodgkinson <[EMAIL PROTECTED]> said something to this effect on 07/09/2001:
> Paul <[EMAIL PROTECTED]> writes:
> 
> > Just use it in your handlers normally. It'll only be included once per
> > process, . . . right?
> 
> Put it in startup.pl and it'll get mostly shared too!

Is that anything like being "mostly dead"?

(darren)

-- 
For large values of one, one equals two, for small values of two.



Re: re rand bug?

2001-07-09 Thread darren chamberlain

Purcell, Scott <[EMAIL PROTECTED]> said something to this effect on 07/09/2001:
> Sorry to be confused, but I believe I did not create a global variable. In
> the code below that I showed, I used a my to localize the $tmp variable
> inside the for loop.?
> 
> Anyway, I changed the simple code and added the use strict and use vars
> qw($rand), but now I get no random activity at all. Each time a user hits
> it, they of course receive the same 4 numbers. Not very random 
> 
> I am sure I am screwing this up somehow, was anyone able to get this to
> work, or able to get 4 random numbers each time they run the snippet of
> code?

Just out of curiosity, are you calling srand explicitly?  If not,
what happens if you do, and if you are, what happens if you
don't?

(darren)

-- 
Reisner's Rule of Conceptual Inertia: If you think big enough, you'll
never have to do it.



Re: any trick to exclude some files in FilesMatche

2001-07-09 Thread darren chamberlain

On Mon, 9 Jul 2001, Surat Singh Bhati wrote:
> But all the .pl , including fast_(.*).pl are run by Apache::PerlRun handler
> Any solution to exclude the fast_(.*).pl in second expression?

Set the PerlRun handler as the default in httpd.conf, and write
your own translation handler:

package Apache::DistinguishBetweenPerlRunAndFastCGI;
use Apache::Constants qw(OK DECLINED);

sub handler {
my $r = shift;
return DECLINED unless ($r->uri =~ /\.pl$/);

$r->hander("whatever-handler") if ($r->uri =~ /fast_(.*)\.pl$/);
return OK;
}

Season to taste (especially real a handler name).

(darren)

-- 
I believe in God, only I spell it Nature.
-- Frank Lloyd Wright



Re: 2 questions

2001-07-09 Thread darren chamberlain

ivan <[EMAIL PROTECTED]> said something to this effect on 07/09/2001:
> ok I have two questions about TT, let me begin with the
> first one the easier ...

*snip*

> How can in the parent template distinguish between these two
> cases  (if scalar place it, if file include it ).  There is
> third case what if it is scalar-template -> then we have to
> parse/process the scalar..

The parent template cannot distinguish between these cases, nor
should it.  The mechanisms for INCLUDING files and echoing strings
are radically different because of how the grammer is written.
Take a look at the Template::Context::include method to see how
and where you can override the behavior of INCLUDE by subclassing
Template::Context.

(darren)

-- 
Nothing worse could happen to one than to be completely understood.
-- Carl Gustav Jung



Re: returning one instance of an object per request

2001-07-06 Thread darren chamberlain

Jay Buffington <[EMAIL PROTECTED]> said something to this effect on 07/06/2001:
> I'm building a web application that has a User perl module.  I
> have several other perl modules that need to know the user id
> of the current logged in user (or 0 for a guest user).  I was
> thinking that I could write the User class in such a way that
> every time (except the first) a constructor was called the same
> instance of the user object would be returned for each apache
> request.  
> 
> Is this the best way to go about solving my problem?  If so
> what's the best way to implement this?  Or maybe I should just
> pass around the user id to every class?  I'd perfer to avoid
> this if possible. 

Take a look at Class::Singleton, available on CPAN.  From the
docs:

  A Singleton describes an object class that can have only one
  instance in any system.  An example of a Singleton might be a
  print spooler or system registry. This module implements a
  Singleton class from which other classes can be derived. By
  itself, the Class::Singleton module does very little other than
  manage the instantiation of a single object. In deriving a class
  from Class::Singleton, your module will inherit the Singleton
  instantiation method and can implement whatever specific
  functionality is required.

(darren)

-- 
Unix is an operating system, OS/2 is half an operating system, Windows
is a shell, and DOS is a boot partition virus.
-- Peter H. Coffin



Re: AuthCookie question

2001-07-06 Thread darren chamberlain

Chad Phillips <[EMAIL PROTECTED]> said something to this effect on 07/06/2001:
> Hi,
> I have set up Authcookie.  I modified the sample scripts for my sight.
> Everything works except when the wrong password is entered.  When an invalid
> user/password is entered, instead of re-displaying the login page, I get a
> 302 Found error to url
> http://myhost/LOGIN
> 
> Any ideas on what I may have wrong?

I didn't see any ErrorDocument settings; try setting it:

ErrorDocument 401 http://myhost/LOGIN

Of course, this will be for the whole virtual server, but
whenever someone doesn't authenticate correctly, they'll be
redirected to the login page.

(darren)

PS The sig is randomly generated, and not aimed at you...

-- 
The Feynman Problem   1) Write down the problem.
Solving Algorithm 2) Think real hard.
  3) Write down the answer.



Re: getting URL of refused page, after OnDeny

2001-07-06 Thread darren chamberlain

[EMAIL PROTECTED] <[EMAIL PROTECTED]> said something to this effect 
on 07/06/2001:
>   my setup:  I have files in a directory, that a user can only get if
>   subscribed. My apache is hacked with both C and mod_perl
>   enhancements to authentication/authorization. My .htaccess
>   looks as follows:
>   AuthName "library services"
>   AuthType Basic
>   
>   require subscribe idc
>   OnDeny http://myserver/refusals/idc.html
>   
> 
>   the problem: when a unsubscribed user tries to go to:
>   http://myserver/protected-dir/document.pdf
>  and gets bounced to the refusal/subscription page (idc.html) I would
>  like to know the refused page (/protected-dir/document.pdf) so I can
>  send them back there when they subscribe.
> 
>   I don't see any way to carry this infomation? Am thinking about hacking
> more so I can have an OnDeny line like
>   OnDeny http://myserver/refusals/idc.html?refused=$URI
> 
> but feel like I am probably missing something!  THanks for any pointers,

Can you set up a custom error document handler and redirect to that,
rather than using your OnDeny?  Return something like 409
("Conflict"), and Apache will do an internal redirect, from which
you can get the requesting URI in the same way that you can in
other redirects.

Actually, how is the require handled? What does your auth handler
return if the user is not subscribed?  Can/does your handler do an
internal redirect?

(darren)

-- 
Small pleasures exclude great ones.



Re: I need help...

2001-07-05 Thread darren chamberlain

Alberto Canzi <[EMAIL PROTECTED]> said something to this effect on 07/05/2001:
> Hi, I'm writing a perl module for Apache, but I have this
> problem: 
>
> I need to allocate some memory that will persist for the entire
> apache server's cycle of life. (That is: I need to allocate
> some memory at the server's start that could be read and
> written by my module. In other words : my module (that is
> called by server when it receives a request) should be able to
> read and write some data to that memory area and at subsequent
> request made to the server my module must have access to that
> data ... 
>
> (Now the only solution I've found is to write that data to a
> file ... but it isn't a good thing because of synchronizations
> problems...) 

Please, no HTML mail!

With Apache, allocating a buffer that is shared across the
"entire server" is difficult, since Apache forks, and the
children handle incoming connections. Sharing data across a child
is not difficult, with mod_perl. To make data available across
all the requests that one child handles, consider using a global
variable (they persist from request to request in the same child,
under mod_perl; see
http://thingy.kcilink.com/modperlguide/porting/Global_Variables_Persistence.html).
To make data available to different phases of the same request,
use pnotes (see
http://thingy.kcilink.com/modperlguide/snippets/Passing_and_Preserving_Custom_Da.html
and
http://thingy.kcilink.com/modperlguide/snippets/Passing_Notes_Between_mod_perl_a.html)

If you are talking about being able to maintain a single data
drop that all the server processes can access, consider a
database wrapped in a library.  Also consider Apache::Session,
which is suitable for sharing data across children in a
useful (and easily syncronized) way.

(darren)

-- 
"One Architecture, One OS" also translates as "One Egg, One Basket".



Re: handler question

2001-07-03 Thread darren chamberlain

Robin Berjon <[EMAIL PROTECTED]> said something to this effect on 07/03/2001:
> On Tuesday 03 July 2001 21:18, Thomas Klausner wrote:
> > I have a nearly finished module which applies some regular
> > expression (specified in some config file) to the URI and puts the
> > stuff it found into $r->param (that means you have to use CGI or
> > Apache::Request to use it).
> >
> 
> > BTW, if anybody else is interested in this module, I could put it on
> > CPAN (after deciding on a Namespace etc)
> 
> Pretty cool ! You should definitely put it on CPAN. Apache::RegexedParam ?

How is it different from mod_rewrite using the QSA flag to add
values to r->args? (This is a question, not a criticism!)

(darren)

-- 
Don't sweat the petty things, and don't pet the sweaty things.



Re: RFC: Logging used Perl Modules (was Re: API Design Question)

2001-07-03 Thread darren chamberlain

James G Smith <[EMAIL PROTECTED]> said something to this effect on 07/03/2001:
> darren chamberlain <[EMAIL PROTECTED]> wrote:
> > James G Smith <[EMAIL PROTECTED]> said something to this effect on 07/02/2001:
> > > Apache::Use
> >
> > You can get this information from %INC, can't you? e.g.:
> 
> Most definitely.  However, you lose information about which 
> modules are needed more often than others.  There's no difference 
> between all scripts needing CGI.pm and one script needing 
> Foo::Bar.  

Good point.

> We also lose timing information.  If 90% of the modules are 
> loaded into the process with the last request before the child is 
> destroyed, there's no point in loading them during the 
> configuration phase.  We can help this a little by taking 
> snapshots of %INC at regular intervals (at the end of each 
> request, for example).
> 
> The current code I have uses %INC, but I wanted to write
> something like the following:
> 
> sub use : immediate {
>   # do stuff here if logging
>   return CORE::use(@_);
> }

To go OT here, what would 'immediate' be doing here, if Perl
supported it?

(darren)

-- 
The three most dangerous things are a programmer with a soldering
iron, a manager who codes, and a user who gets ideas.



Re: handler question

2001-07-03 Thread darren chamberlain

Viljo Marrandi <[EMAIL PROTECTED]> said something to this effect on 07/03/2001:
> > If sounds like you want to use r->path_info in your application,
> > so you *can't* create these directories, or they will become part
> > of r->filename, not r->path_info.
> 
> 
> Actually i thought about r->uri. It returns everything after
> servername and if i split it using '/' as separator i think i'm
> almost there ;o).  Or are there any reasons i shouldn't use
> r->uri?

It depends on what you are trying to accomplish, of course, but
for most purposes, yeah, splitting r->uri on '/' will give a
useful list of directories. If you are using these as actual
filenames, and ignoring r->filaname, however, beware of requests
like:

  http://foo.bar.baz/my_hander/../../../../../../../etc/passwd

which might be trying to get you to send your /etc/passwd. If you
are using the URI to dispatch the request to a particular Perl
module, take a look at Apache::Dispatch.

(darren)

-- 
The more we disagree, the better the chance that one of us is right.



Re: handler question

2001-07-03 Thread darren chamberlain

Viljo Marrandi <[EMAIL PROTECTED]> said something to this effect on 07/03/2001:
> Hello,
> 
> Is it possible, if yes then how, to set handler recursively for one 
> directory? Now my handler is defined:
> 
> 
> SetHandler perl-script
> PerlHandler MyServ::MyHandler
> 

Use a Location rather than Directory directive. Use the absolute
URI relative to the server as the second part (e.g.,
http://www.foo.bar/baz would look like ). Take a
look at http://httpd.apache.org/docs/mod/core.html#location> and
http://httpd.apache.org/docs/mod/core.html#directory>.

> But if i try to access /my_server/some/other/dir then apache gives error 
> because this directory doesn't exist, which is ok, because i want these 
> some/other/dir to become parameters for my handler (not directories 
> where files are), but how to make that apache won't check if directory 
> exists or not. One possibility is to make these directories and in 
> httpd.conf define same handler for all them but this ain't good.

If sounds like you want to use r->path_info in your application,
so you *can't* create these directories, or they will become part
of r->filename, not r->path_info.

(darren)

-- 
My mother always used to tell me, "The early bird gets the worm."
The message seemed pretty clear to me: If you sleep late, you're
a lot less likely to be killed by a bird.
-- Elliott Downing



Re: RFC: Logging used Perl Modules (was Re: API Design Question)

2001-07-03 Thread darren chamberlain

James G Smith <[EMAIL PROTECTED]> said something to this effect on 07/02/2001:
> How would something like this do:
> 
> NAME
> 
> Apache::Use
> 
> SYNOPSIS
> 
> use Apache::Use (Logger => DB, File => "/www/apache/logs/modules");
> 
> DESCRIPTION
> 
> Apache::Use will record the modules used over the course of the 
> Perl interpreter's lifetime.  If the logging module is able, the 
> old logs are read and frequently used modules are automatically 
> loaded.  Note that no symbols are imported into packages.

You can get this information from %INC, can't you? e.g.:

use Time::Local;
use Data::Dumper;
use Apache;

warn map sprintf("%-20.20s\t%s\n", $_, $INC{$_}), keys %INC;

Exporter.pm /usr/local/perl/5.6.0/Exporter.pm
Carp.pm /usr/local/perl/5.6.0/Carp.pm
XSLoader.pm /usr/local/perl/5.6.0/i686-linux/XSLoader.pm
mod_perl.pm /usr/local/perl/site_perl/5.6.0/i686-linux/mod_perl.pm
strict.pm   /usr/local/perl/5.6.0/strict.pm
Apache/Connection.pm/usr/local/perl/site_perl/5.6.0/i686-linux/Apache/Connection.pm
Time/Local.pm   /usr/local/perl/5.6.0/Time/Local.pm
Apache/Table.pm /usr/local/perl/site_perl/5.6.0/i686-linux/Apache/Table.pm
DynaLoader.pm   /usr/local/perl/5.6.0/i686-linux/DynaLoader.pm
overload.pm /usr/local/perl/5.6.0/overload.pm
Apache/Constants/Exp
/usr/local/perl/site_perl/5.6.0/i686-linux/Apache/Constants/Exports.pm
AutoLoader.pm   /usr/local/perl/5.6.0/AutoLoader.pm
Apache/Server.pm/usr/local/perl/site_perl/5.6.0/i686-linux/Apache/Server.pm
Data/Dumper.pm  /usr/local/perl/5.6.0/i686-linux/Data/Dumper.pm
Apache.pm   /usr/local/perl/site_perl/5.6.0/i686-linux/Apache.pm

Isn't this more or less what you mean?

(darren)

-- 
My studies in Speculative Philosophy, metaphysics, and science are all
summed up in the image of a mouse called man running in and out of every
hole in the Cosmos hunting for the Absolute Cheese.
-- Edmund Burke



Re: Directory Restrictions

2001-06-27 Thread darren chamberlain

Philip Mak <[EMAIL PROTECTED]> said something to this effect on 06/27/2001:
> On Wed, 27 Jun 2001, will trillich wrote:
> > okay -- but if you want some of your site to be indexed by the
> > standard mod_autoindex, yet have mod_perl intervene for certain
> > subtrees, you'll find that mod_perl never gets a chance at it
> > because the mod_autoindex gadjets catch it at an earlier stage.
> > i think.
> 
> How about using RewriteRule? For example, you can do:
> 
> RewriteRule /somedir/ index.pl
> 
> and then when people visit http://your-site.com/somedir/, it will call
> index.pl. index.pl can use $ENV{REQUEST_URI} to determine which directory
> to display.

Or just

DirectoryIndex index.pl

(or /index.pl)

(darren)

-- 
Now imagine a Moebius vortex inside a spherical constant, and
you've got my cosmology.



  1   2   3   >