Re: [modperl 1.27] Problem regarding Perl*Handler and the HTTPrequest line

2002-12-24 Thread Rodney Broom

 On Tue, 24 Dec 2002 [EMAIL PROTECTED] wrote:

 I am wondering if it is possible to write a handler
 which parses the very first header line, say..

No, it's not possible. (Unless I'm really missing something)



 where the line followed by [C] stands for the line sent by the client,
 and the line followed by [S] is the line sent by some perl module.

It sounds to me as though you want to use Apache as a network service framework. Not a 
bad idea, but Apache already stands on a set protocol. Is this right, or do you 
actually want to run Apache as a web server on port 80 AND have this non-HTTP thing 
going on at the same time from the same port?



---
Rodney Broom
President, R.Broom Consulting
http://www.rbroom.com/






Re: [modperl 1.27] Problem regarding Perl*Handler and the HTTPrequest line

2002-12-24 Thread Rodney Broom
From: [EMAIL PROTECTED]


 In fact I would like to write some little scripts
 to talk with the internals of Apache over port 80...

By the internals, do you mean asking Apache about what it's doing and sending it new 
directives?

If all you need to do is catch particular requests, then Nick Tonkin has the idea. Let 
us know specifically what you want to get done, that will help in the answers.


---
Rodney Broom
President, R.Broom Consulting
http://www.rbroom.com/






Re: memory usage problem!

2002-10-08 Thread Rodney Broom

From: Eric [EMAIL PROTECTED]


 What about in the case of a big query result?

I may have come into this thread a bit late, but can't you just undefine the storage 
when you're done with it?

  $data = $sth-fetchall_arrayref;
  #... do some stuff;
  $data = undef;

---
Rodney Broom
President, R.Broom Consulting
http://www.rbroom.com/





Re: $r-content

2002-09-25 Thread Rodney Broom

MC  Presently I get all the incoming parameters via Apache::Request and 
MC  append to the URL before redirecting but this is not ideal as I?d like 
MC  to spit the modified parameters out in a POST. Can anyone give me any 
MC  advice?

GY see
GY http://perl.apache.org/docs/1.0/guide/snippets.html#Redirecting_POST_Requests


I thought I recalled a $STDIN var in mod_perl, but didn't find anything with a quick 
scan of the docs. If that var ~is~ available, and writable, and are doing an internal 
redirect, you might be able to just reload it:

  $STDIN = $r-content;
  $r-internal_redirect_handler($handler);


I know I've done this sort of thing (redirecting POSTs) with a session system. That 
is, a handler early in the request that sets up POST data, then everything else uses 
only that source:

  # My::STDINHandler
  use Storable;
  sub handler {
store({content = $r-content}, $unique_file_location);
  }

  sub content {
return retrieve($unique_file_location)-{content}
  if $some_good_tests;
return Apache-request-content;
  }


  # My script
  $content = My::STDINHandler::content();



I apologize for any inconsistencies in this message, I'm a bit tired and the coffee 
isn't strong enough today.

---
Rodney Broom
President, R.Broom Consulting
http://www.rbroom.com/





Re: $r-content

2002-09-25 Thread Rodney Broom

From: Geoffrey Young [EMAIL PROTECTED]


GY I didn't think that was what he was asking about.  getting the POST 
GY data from the main request in a subrequest is generally easy with 
GY Apache::Request:

Oops, you're right. I was thinking that Mark (jump in any time) needed to keep things 
in POST to satisfy some upcoming code. Some things insist on POST only. Worse, some 
things need POST data and use r-args for other purposes all together.

I guess the example I was thinking of in my head is where I have to do something like 
redirecting the user to a login page when their authentication runs out, then still 
honor their original request (including POST data) without them having to intervene.


---
Rodney Broom
President, R.Broom Consulting
http://www.rbroom.com/





Re: Adding Additional Apache Modules Along With mod_perl

2002-09-20 Thread Rodney Broom

From: Mark Schoonover [EMAIL PROTECTED]

 ...how to add additional modules to Apache/mod_perl...

I like to build DSOs, and do it a lot like this:

# Unpack apache and mod_perl in the current directory, then:

% cd mod_perl-1.27
% perl Makefile.PL USE_APACI=1 EVERYTHING=1 \
APACHE_PREFIX=/usr/local/apache \

APACI_ARGS=--enable-module=all,--enable-suexec,--suexec-caller=nobody,--suexec-docroot=/usr/local,--enable-shared=max,--disable-shared=perl
 \
  config.out 21

% make  make.out 21
% make test  make_test.out 21
# Check make_test.out
% make install  make_install.out 21



There are problably other good answers available on the list, but I like this method. 
You will get a sample httpd.conf that has LoadModule and AddModule directives for lots 
of things. It should make sence from there.

---
Rodney Broom
President, R.Broom Consulting
http://www.rbroom.com/





Re: mod_perl statistics on securityspace.com

2002-09-10 Thread Rodney Broom

From: Ilya Martynov [EMAIL PROTECTED]

IM (frankly Safe.pm is a joke).

Now this thread has taken my interest. Ilya, would you care to expound on this 
statement? I'm planning to use Safe in production soon.

---
Rodney Broom
President, R.Broom Consulting
http://www.rbroom.com/





Re: mod_perl statistics on securityspace.com

2002-09-10 Thread Rodney Broom

From: Ilya Martynov [EMAIL PROTECTED]


 Try to implement something that works with database and files inside
 of Safe compartment.

Ah, yes. I can definately see that.


---
Rodney Broom
President, R.Broom Consulting
http://www.rbroom.com/





Re: $r-push_handlers('PerlAuthenHandler', 'Some::handler') doesn'twork

2002-09-01 Thread Rodney Broom

From: Stas Bekman [EMAIL PROTECTED]


 What happens if you do:
$r-set_handlers('PerlAuthenHandler', 'Some::handler');


  Either of these:
$r-set_handlers('PerlAuthenHandler', 'Some::handler');
$r-set_handlers('PerlAuthenHandler', \Some::handler);

  Yeild:
Can't set_handler with that value...
Which agrees with the Apache.pm docs.


  This:
$r-set_handlers('PerlAuthenHandler', ['Some::handler']);
  Yeilds:
Gives no error, Some::handler() doesn't get run.


 could be that with push_handlers() you have some other handler that 
 takes over, before Some::handler has a chance to run.

With either push_handlers() or set_handlers(), get_handlers() says that 
'Some::handler' is the only handler in 'PerlAuthenHandler'. So I know the action is 
working according to mod_perl. As for something else taking over, there's nothing that 
I can find on this sandbox installation. No Auth* in the config, no htaccess files, 
and no other Perl*Handler directives in use.

Just on a lark, I tried installing a PerlAuthenHandler in the config, it worked just 
fine.


---
Rodney Broom
President, R.Broom Consulting
http://www.rbroom.com/





Re: $r-push_handlers('PerlAuthenHandler', 'Some::handler') doesn'twork

2002-09-01 Thread Rodney Broom

From: Geoffrey Young [EMAIL PROTECTED]

 you probably don't have a Require directive in your httpd.conf for 
 this particular Location.

You're right, I don't. In fact, I can't. One of the things the access handler does is 
to look up the URI in a database, which happens at run time. (The Location directive 
would happen at server load time.) I need the access handler to decide wether or not 
the requested URI needs authentication.


 Apache will not run the Authen or Authz phases unless there is a
 Require directive, no matter what you put onto the mod_perl handler stack.

I sort of thought this myself, so I tried $r-dir_config-add('require', 'valid-user') 
in the access handler. No help.


---
Rodney Broom
President, R.Broom Consulting
http://www.rbroom.com/





Re: $r-push_handlers('PerlAuthenHandler', 'Some::handler') doesn'twork

2002-09-01 Thread Rodney Broom

From: Per Einar Ellefsen [EMAIL PROTECTED]

 dir_config is the Perl{Set,Add}Var configuration...

Yep, you're right. But I'm sort of grasping at straws at this point.


 You can just add that and let your handler decide regardless of the value 
 of requires...

Yes, but there are side effects:


1. When the access handler finds a URI that doesn't need authentication turned on:

  # httpd.conf
  Location /
require jack handy
  /Location

  # Access handler
  return OK;  # Since we don't care about the current URI.

  # Error log
  Some::handler(): Starting in [PerlAccessHandler].
  Some::handler(): This uri [/one/onezie.fil] not under access control, returning OK.
  configuration error:  couldn't perform authentication. AuthType \
not set!: /one/onezie.fil


  Although on areas where authentication is desired, this method works fine. We just
  have to set r-auth_type and r-auth_name before returning from access control.


2. I don't want to have to add several lines to each VirtualHost that I use this
  code in. Instead, we add a single handler at the URI Translation phase and let it
  set up the rest of the handlers for the request. Actually, we already have a
  system doing this and are very happy with the results. This Authen handler is just
  intended to be an add-on to that.


 ...which is accessed through $r-requires btw...

Ah, you're right. Thank you. Unfortunately, this is read-only.



---
Rodney Broom
President, R.Broom Consulting
http://www.rbroom.com/





$r-push_handlers('PerlAuthenHandler', 'Some::handler') doesn't work

2002-08-31 Thread Rodney Broom

Hi all,

I'm sure I'm just missing something, but I'm stumped.

I've got an access handler that does some tests and then conditionaly does this:

  $r-push_handlers('PerlAuthenHandler', 'Some::handler');
  return OK;

Some::handler() starts by printing the current callback to the error log, which never 
happens if it's set to run in the 'PerlAuthenHandler'. If I change the push_handlers() 
to use 'PerlFixupHandler', then Some::handler() gets called and I see it in the error 
log.

What am I doing wrong? I know it has to be me.

---
Rodney Broom
President, R.Broom Consulting
http://www.rbroom.com/




Re: $r-push_handlers('PerlAuthenHandler', 'Some::handler') doesn't work

2002-08-31 Thread Rodney Broom

From: Ryan Parr [EMAIL PROTECTED]


 If you have an access handler return OK, then the access handling stops.
 Because that handler handled it.
 
 So as far as I know:
   $r-push_handlers('PerlAuthenHandler', 'Some::handler');
   return DECLINED;
 
 should work...

Yeah, I tried that. I've also tried AUTH_REQUIRED, FORBIDDEN, and DONE. Since the 
authentication phase is after the access phase, my guess has been that the return from 
the access phase shouldn't effect the authentication phase. That is, of course, unless 
the access phase returns something like SERVER_ERROR. Right?


---
Rodney Broom
President, R.Broom Consulting
http://www.rbroom.com/





Request object availability in .htaccess

2002-07-17 Thread Rodney Broom

Hi all,

I've got some Perl code in an htaccess file to choose some configuration based on 
client IP. The code starts with $r = Apache-request. The first request that gets 
handled by a server instance fails to get the request object (the call succeeds but 
returns undef). Subsequent requests to that server instance work properly. Any 
thoughts?

---
Rodney Broom
President, R.Broom Consulting





Re: mod_perl compile problem

2002-02-13 Thread Rodney Broom

From: OCNS Consulting [EMAIL PROTECTED]

 I'm attempting to make httpd apache-1.3.23 with mod_perl-1.26 and
 ActiveState Perl 5.6.1 Build 631.

Am I hearing you right, you're using an ActiveState Perl on Linux?

---
Rodney Broom
Programmer: Desert.Net






Re: Running a shell command inside a cgi/perl script

2001-11-30 Thread Rodney Broom

From: Kairam, Raj [EMAIL PROTECTED]

 system( '/usr/bin/lp -dhp4si /tmp/plotreq.txt'  /tmp/plotid.txt);
 If I run the command /usr/bin/lp -dhp4si /tmp/plotreq.txt  /tmp/plotid.txt
 it is fine as a command line.

I may be missing something, but it looks to me like you are running a different 
command from system() than what you are doing on the command line. That is, system() 
apears to be getting this:

'/usr/bin/lp -dhp4si /tmp/plotreq.txt'  /tmp/plotid.txt

And the shell apears to be getting this:

/usr/bin/lp -dhp4si /tmp/plotreq.txt  /tmp/plotid.txt


When I need error checking, I'll often use open() instead of system().

---
Rodney Broom






Selectively writing to the access log

2001-10-19 Thread Rodney Broom

I'm wanting to look at the request and optionally change what gets written to the 
access log. However, I only see methods for writing to the error log. I think I need 
to do this inside the request because I'm piping things with TransferLog and don't 
want to interupt that. But I don't mind another aproach.

---
Rodney Broom





Re: Selectively writing to the access log

2001-10-19 Thread Rodney Broom

From: Rob Nagler [EMAIL PROTECTED]

 I don't think you can change the access log format, but you can 
 modify the values.  For example, you can set $c-user and $c-remote_ip.

Thanks Rob, this is helpful and it works. The value I'm wanting to change is in 
r-the_request, but passing a value to that method yeilds a usage message:

  Usage: Apache::the_request(r)

This routine returns a string, so I assumed it would take a string. I've tried passing 
other things always getting the same message. I've glanced at mod_log_conf.c, and some 
core code, but I don't see what I need to pass.

---
Rodney Broom






Re: Selectively writing to the access log

2001-10-19 Thread Rodney Broom

From: Geoffrey Young [EMAIL PROTECTED]

 are you on an old version of mod_perl?  from Changes:
 $r-the_request can now be modified

Good catch, yes I was using 1.19. I've moved a machine with 1.26 and 
r-the_request($string) no longer fails. However, with 1.26 none of changes I'm making 
to the request object are showing up in the access log. I was able to overload certain 
fields with 1.19.


---
Rodney Broom






Re: Selectively writing to the access log

2001-10-19 Thread Rodney Broom

- Original Message - 
From: Mark Doyle [EMAIL PROTECTED]


 I missed your original post, but maybe this will help.
 
 What about creating a new log using CustomLog and tying it to an
 environment variable and only setting this in the requests you want
 to log? I do this to log subscriber activity in a separate log
 (still goes to the main access_log with all non-subscriber activity
 as well, but it doesn't really matter as the separate log file is
 much smaller and only has the events I need to process).


My ultimate goal is this:
I have a silly redirector script that acts as a logging hook for folks clicking their 
way out of the site. The hit a link like redir.cgi?dest=abc. My client has a web 
report that displays by document, meaning that all of these redirects would show up in 
the report lumped together as though they were equivilant. What I want is to change 
the access_log entry for sake of that report, so I'd essentially have mappings like:

  redir.cgi?dest=abc  = redir_abc.html
  redir.cgi?dest=jack = redir_jack.html

This will break out the individual redirection requests in a way that makes sence in a 
human-readable report.

Make sence?


---
Rodney Broom






Re: Selectively writing to the access log

2001-10-19 Thread Rodney Broom

From: Mark Doyle [EMAIL PROTECTED]

 How about adding a custom header with the format you want
 and then logging that with a custom log format?

I think I've found an acceptable method. I've got a log handler like this:

my $req = $r-the_request;
if ($r-uri =~ /$something_interesting/) {
$req =~ s/$stuff/$other_stuff/;
}

$r-subprocess_env('THE_REQUEST', $req);


Then I'm using a custom log format like this:

  LogFormat %h %l %u %t \%{THE_REQUEST}e\ %s %b \%{User-Agent}i\ req_overload


---
Rodney Broom






[PING] Sorry, just testing since 26 hours of no activity on this list.

2001-09-23 Thread Rodney Broom

Hi all,

I haven't seen anything on this list for the past 26 hours, so I'm just making sure 
that I'm still seeing new posts.

---
Rodney Broom





[PING] Testing new list memborship, please ignore

2001-08-23 Thread Rodney Broom

Thank you.

---
Rodney Broom
Programmer: Desert.Net





Re: Problem with DBD::Oracle with mod_perl

2001-08-23 Thread Rodney Broom

From: Benjamin Trott [EMAIL PROTECTED]


  PH Don't open a connection during startup.
  PH Open a connection in the child process instead.
 
BT  I will second this. I've done this (unintentionally) when using MySQL, and
BT  you get a lot of weird errors about statement handles being active, etc.

I haven't read the entire thread, so forgive me if I'm restating. But there are 
reasons for sharing DB connections (and reasons not to). In the case of MySQL and 
getting messages about active statement handles, that's because you're disconnecting 
the DBH. If you are in a shared connection enviroment with MySQL, you are winning. 
Since you don't have to worry about things like transactions and rolling back somebody 
elses changes. All you need to do is finish() your statement handled when you are 
finished with them:

  $sth-finish;

This will prevent the errors you are seeing and will allow you to keep the shared DB 
connection. A shared connection is usefull for efficiency, since creating a connection 
may be expensive.


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?


 I am about to switch to Apache::DBI for that very reason. I don't
 want to create a new db handle with every request. Should I stop,
 or am I missing something here?

Nope, you've got it. If you don't have transactions (anything else?) to worry about, 
I'd say to use Apache::DBI. Remember, from the Apache::DBI docs:

Do NOT change anything in your scripts. The usage of this
module is absolutely transparent !

---
Rodney Broom
Programmer: Desert.Net






Re: Problem with DBD::Oracle with mod_perl

2001-08-23 Thread Rodney Broom

From: Perrin Harkins [EMAIL PROTECTED]

 Apache::DBI doesn't have a problem with transactions.

Ah, OK. What about when a shared connection is rolled back in one process, will it 
effect other running processes with the same handle?


---
Rodney Broom
Programmer: Desert.Net






OT: Is there a comperable Apache list (besides anounce)?

2001-06-29 Thread Rodney Broom



Hi all,

The only list I found on apache.org was [EMAIL PROTECTED]. I see from 
thearchives that this question was asked in this group a year or two ago, 
butnobody had a very good answer.

---Rodney BroomProgrammer: 
Desert.Net


Re: Persitant data accross processes

2001-06-26 Thread Rodney Broom

Hi all,

Thanks for  the input. I've replied to three messages in this one. In order,
they are Joachim, Olivier and Aaron. In my reply to Aaron, I've outlined in
better specificity what I'm actually after. One further note on my needs,
I'm not after session data. I've got a big information caching systems that
sits in memory between my database everything else. What I'm looking for is
some heavy performance improvements.

-

From: Joachim Zobel [EMAIL PROTECTED]
JZ We are using Data::Dumper to put the data structures as TEXT into a
MySQL
JZ table, where they can retrieved via an id.

JZ This is pretty fast for low to medium traffic and has the advantage that
JZ the data is persistent (restarting apache won't zap the carts) and human
JZ readable (debugging is easy).

Wow, ouch! Here's a performance gain for you:
- use Storable qw{freeze thaw store retrieve};
- Take your
'$dumpered = Dumper($ref)' statement and changed it to
'$frozen = freeze($ref)'
- Take your
'eval $dumpered' and changed it to
'$data = thaw($frozen)'
- For a human to read frozen data: print Dumper(thaw($frozen))

MUCH better gains than what I've just shown you are available. But this is
sure to be cheaper than evaling text.


-
From: Olivier Poitrey [EMAIL PROTECTED]
OP I'm working on two modules that can help you to do this job. There names
are
OP Apache::SharedMem and Apache::Cache. You can find them on :


-
From: Aaron E. Ross [EMAIL PROTECTED]
AER  why is a new dbh for each process a problem? how else would it work?

Well, every new connection is overhead. So any reuse is good.


RB it has to copy data. Meaning that I can only have a certain amount of
RB complexity to my data structures.

AER  I'm not sure why IPC::Shareable doesn't work, but maybe if you explain
the problem
AER  we can help.

Hmm, you're right. I wasn't specific enough. What I'm after is having Perl
namespace level access to specific slots in memory. Not just the data that
~was~ once in that variable, but the variable itself. So, with two processes
I could say:

  pid 1
   $superclass::thing = Here is PID $$;
  pid 2
   print $superclass::thing,\n;   # This would contain PID 1

I can emulate this with any number of devices that look at a third location
for data and return the value. Options include IPC::Shareable, Berkley DB
files, RDBMSs and stone tables manged by carrier pigeons. Depending on the
transient data device, this works for any type of data, including simple
scalars and multi-level hashes and arrays. But the variables returned are
only copies of the data, not the actual variable itself.

- For example:
When you use IPC::Shareable to tie() a var to a chunk of shared memory, you
aren't accessing the memory that Perl has allocated for that variable, you
are accessing a chunk of Shared Memory allocated via your system's shmget
function. That means that IPC::Shareable has to do things like checking the
shared memory segment every time the var is accessed. And complex vars don't
get updated in shared memory in some circumstances.
  # Process 1
  tie %big_hash, 'IPC::Shareable,...
  $big_hash{x} = {hr = \%really_deap_hash}

  # Process 2
  tie %big_hash, 'IPC::Shareable,...
  $big_hash{x}-{this}-{that}-{the_other} = 'Not visible to PID 1';

I know, my example is wrong since IPC::Shareable ~does~ handle this
properly. But that package has some serious shared memory management
problems. So I've implimented a version that doesn't. But, I digress. The
IPC::Shareable example also has this problem:

  # Process 1
  tie %hash, 'IPC::Shareable,...
  $hash{x} = {simpe = 'data'}

  # Process 2
  tie %hash, 'IPC::Shareable,...
  $key_ref = $hash{x};

In process 2, $key_ref will maintain it's data even once $hash{x} changes.
That's because IPC::Shareable isn't really presenting me with Perl's memory
location, he's copied a frozen data structure out of shared memory and
letting me have a copy of it.


Again, thanks for all of the replies. It seems as though I never get replies
to my questions. ;-P

---
Rodney Broom
Programmer: Desert.Net






Re: push_handlers and PerlAuthenHandler troubles [second try]

2001-06-26 Thread Rodney Broom

- Original Message -
From: Bolt Thrower [EMAIL PROTECTED]

 Location /
   AuthType Apache::AuthTicket
   AuthName HomeIntranet
   PerlAuthenHandler Intranet::CheckSiteAuthen
   #PerlAuthenHandler Apache::AuthTicket-authenticate
   PerlAuthzHandler Apache::AuthTicket-authorize
   require valid-user
 /Location

 But when I try to access a location under that configuration,
 I see in my error log:
 [Mon Jun 25 18:33:55 2001] [crit] [client 192.168.10.15] configuration
 error:  couldn't
 check user.  No user file?: /u/IntranetLoginForm

mod_auth supplies the Auth* dirrectives. Since he sees 'require
valid-user', he's looking for the rest of the Auth* directives.
Specifically, AuthUserFile.

I have a handler doing just what  you are describing, and  have the same
problem. My solution was to mandate that my mudule was the only thing
allowed to use Auth* configureation in the server config file and that
everybody else had to use .htaccess. But I still see that message
occasionally. My suggestion: if it work, then ignore the error message. :-)



 Of course, everything works with the configuration
 Location /
   AuthType Apache::AuthTicket
   ...
 /Location
 Any suggestions for me?

Yep, Auth* happens at the Directory level. From the docs:
AuthUserFile
Context: directory, .htaccess

So, if you have an other set of Auth* directives in the same scope, then
that can cause conflicts

---
Rodney Broom
Programmer: Desert.Net






Persistant data accross processes

2001-06-25 Thread Rodney Broom



Hi all,

I'd like a way to store complex data structures 
across Apache processes. I'velooked at Apache::DBI for an example: my 
tests say that he has to create a new dbh for every process. I've looked at 
IPC::Shareable, but it has to copy data. Meaning that I can only have a certain 
amount ofcomplexity to my data structures.

Thoughts?

---Rodney BroomProgrammer: 
Desert.Net


Re: Sending Cookies from Access-Handler - Fixed

2001-06-16 Thread Rodney Broom

Something else, I haven't used CGI's cookie handling, but I have used
Apache::Cookie. I know that this can be done from an AuthenHandler and from
a TransHandler.

---
Rodney Broom






Re: Unsubscribe me

2001-06-16 Thread Rodney Broom

Hi Kheeteck,

You'll need to send an email [EMAIL PROTECTED]

---
Rodney Broom






Setting an auth realm dynamically

2001-06-15 Thread Rodney Broom



I (like everybody else) have a site that is wholy 
dynamically generated. As such, I can't alway set an auth realm in the config or 
in .htaccess. What I'd like to do is an access handler like this:

sub handler { my $r = 
shift; if ($r-uri =~ 
m/$some_magic_pattern/|) { 
$r-auth_name($custom_realm); 
$r-auth_type('Basic'); 
$r-dir_config('require valid-user');

 return 
'OK'; } return DECLINED;
}

Obviously these routines don't work this way... Any 
thoughts?

---Rodney BroomProgrammer: 
Desert.Net


Re: Help Apache::Registry Setup

2001-06-15 Thread Rodney Broom

From: Purcell, Scott [EMAIL PROTECTED]

 ...but it IS NOT persistant, or cached.

 ...do not see how to make the counter.pl  PERSISTANT and to tie the
 script to the Apache::Registry?

What does your server config look like? Do you have .pl assosiated with
cgi-script, or perl-script? Have you placed something like this in your
config:

FilesMatch  \.mpl$
  SetHandler perl-script
  PerlHandler Apache::Registry
/FilesMatch


---
Rodney Broom
Programmer: Desert.Net






Re: Help Apache::Registry Setup

2001-06-15 Thread Rodney Broom

From: Purcell, Scott [EMAIL PROTECTED]

 I found that there is a folder called mod_perl and if I put my counter.cgi
 file there that it ran mod-perl (or PERSISTANT).

 I put the code block you sent me in the httpd.conf file and restarted the
 server, then renamed a file that was under cgi-bin to counter.mpl
(thinking
 that the .mpl linked the file to mod-perl), but I get an error stating:
 You don't have permission to access /cgi-bin/counter.mpl on this server.


 Anyway, should I be able to put .mpl files anywhere under the cgi-bin
 directory with that snippet of code, or do all mod-perl files have to live
 under the mod-perl folder?


The chunk of config that I sent:
 FilesMatch  \.mpl$
   SetHandler perl-script
   PerlHandler Apache::Registry
 /FilesMatch

Is one of several ways to get mod_perl to run your Perl code instead of
something else (like /usr/bin/perl). What I've done here is to tall Apache
to look for files that end in '.mpl' and hand them off to the given handler
(Apache::Registry). Try this script:

  # rodney.mpl
  printf qq{PID [$$] First is %sdefined [$first].br\n}, $first ? '' : 'not
';
  $first = time;

You'll notice that there's no reference to the Perl interpreter, that's OK.
mod_perl already has a Perl interpreter in memory and knows what to do with
your code. Make sure to set the permisions on this scrip to be executable by
your Apache daemon's user and to place the code in a place where Apache is
willing to execute it. Now view the script in a browser. Take not of the PID
and time (or lack thereof), and reload. Do this 10-20 times and you'll see
mod_perl magic (or toe stubbing, deppending on how you look at it.)

---
Rodney Broom
Programmer: Desert.Net






Re: IOSocket Problem

2001-06-15 Thread Rodney Broom

Hi Scott,

If you think that this might be a mod_perl problem, and since you aren't
using any mod_perl specific functionality, then switch to straigh CGI. I'd
suggest adding a bunch of debugging messages in your code. They should be
directed to the server's error log by printing to STDERR. Run your program
once and have a look at the error log. Then repeat. Once you've got the
program working correctly under CGI, switch to mod_perl and start over.

Something to understand with mod_perl, it's often important to restart the
httpd between experiments. I  won't go into when this is or isn't required,
but basically: Restart Apache after every code changed.

---
Rodney Broom
Programmer: Desert.Net





Apache::Cookie-fetch fails silently

2001-06-15 Thread Rodney Broom



I've got this handler that calls 
Apache::Cookie-fetch, no problem. It's tested and works fine. So I installed 
the same handler (same machine) on a second Apache instance, but now 
Apache::Cookie-fetch fails, causing the handler to terminate. No messages, 
no nothin'. It doesn't even get to the next print() statement after the fetch() 
call.

Thoughts?

---Rodney BroomProgrammer: 
Desert.Net


Re: Sending Cookies from Access-Handler

2001-06-15 Thread Rodney Broom

From: Nenad [EMAIL PROTECTED]

  -expires = '+1M',

What's the expiration date shown in your browswer?


 $r-warn('setting cookie ',$cookie);# this shows up in the error_log

What does this show in the error log? I'm guessing setting cookie
Apache::Cookie.


---
Rodney Broom
Programmer: Desert.Net






Re: can not redirect on POST w/ CGI.pm

2001-06-14 Thread Rodney Broom

From: Doug MacEachern [EMAIL PROTECTED]
  I've found that if I post to this PerlAccessHandler, I get no response:
 this problem is fixed in 1.25, from Changes:
 fix $r-read() so it will not block if all data has already been read
 and so that Apache will not hang during ap_discard_request_body() on
 error or redirect after all data has been read


  From: David Young [EMAIL PROTECTED]
DY What I am actually doing is extending the cookie-based access
DY control (TicketMaster) outlined in the Apache Modules book[1]. If the
DY  user attempts to access a restricted area and they don't have a cookie,
they
DY  are redirected to a login page (courtesy of an ErrorDocument 403). Upon
DY submission (POST) of the login page, if their credentials are good, they
are
DY redirected to their original destination.

OK, this makes sence. I just did something like this myself. I was
redirecting the user to change the URI that they saw in the browser, but
didn't want to loose POSTed data. Since you are using mod_perl, you can
catch STDIN inside of a handler with:
  $data = $STDIN

From there, I stored the data in a file and redirected the user. When the
user has all of the auth work finished and finally makes it back to the
right location, I read in the data from that file and assign to STDIN with:
  read(TEMP_FILE, $STDIN, (-s $temp_file))

This works fine, but you'll obviously need to jump through a few hoops.
Things like setting ENV{CONTENT-LENGTH} after reassigning $STDIN, and making
sure that you are giving the user their data and not somebody elses.

---
Rodney Broom
Programmer: Desert.Net






Re: can not redirect on POST w/ CGI.pm

2001-06-13 Thread Rodney Broom

From: David Young [EMAIL PROTECTED]
DY I've found that if I post to this PerlAccessHandler, I get no response:
DY $r-header_out(Location = http://www.modperl.com/;);
DY return REDIRECT;

- Are you actually wanting your orriginally POSTed data to make it to the
redirected location?
- Do you actually need CGI.pm?

---
Rodney Broom
Programmer: Desert.Net






Resetting STDIN after r-read

2001-06-08 Thread rodney Broom


I've got this module that needs to redirect sometimes. In doing this, the
next request misses any POST data. I was playing with saving the data to
disk and then reloading it on the next request like this:

  if ($first_pass) {
$r-read($data, ...);
print TEMP_FILE, $data;
return REDIRECT;
  }
  else {
open(STDIN, $temp_file);
$r-subprocess_env(CONTENT_LENGTH = -s $temp_file);
  }

The idea here is that normal packages like CGI won't have to know what's up
and my programmers won't have to work around this. But, when I get to the
script, STDIN is empty. Ay thouhts about how to handle this?

---
Rodney Broom
Programmer: Desert.Net





Re: Resetting STDIN after r-read

2001-06-08 Thread rodney Broom

From: Geoffrey Young [EMAIL PROTECTED]
 of course
 http://perl.apache.org/guide/snippets.html#Redirecting_POST_Requests


Heh, close. I'm using an external redirect because my purpose is to reset
the address in the client's Location bar. So an internal redirect won't
give me the desired effect.

---
Rodney Broom
Programmer: Desert.Net






Re: Resetting STDIN after r-read

2001-06-08 Thread Rodney Broom

From: rodney Broom [EMAIL PROTECTED]
 I've got this module that needs to redirect sometimes. In doing this, the
 next request misses any POST data. I was playing with saving the data to
 disk and then reloading it on the next request like this:

   if ($first_pass) {
 $r-read($data, ...);
 print TEMP_FILE, $data;
 return REDIRECT;
   }
   else {
 open(STDIN, $temp_file);
 $r-subprocess_env(CONTENT_LENGTH = -s $temp_file);
   }

 The idea here is that normal packages like CGI won't have to know what's
up
 and my programmers won't have to work around this. But, when I get to the
 script, STDIN is empty. Ay thouhts about how to handle this?


OK, here's what the solution was. According to Doug in a posting that I
found in an archive search, mod_perl's STDIN is really just a Perl glob, and
not a file handle. So instead of reading from it (and thereby emptying the
file handle named STDIN so that CGI and other things can't get this data),
now I simply assign from it:




  if ($first_pass) {
print TEMP_FILE, $STDIN;
return REDIRECT;
  }
  else {
read(TEMP_FILE, my $buf, (-s $temp_file))
$STDIN = $buf;

$r-subprocess_env(CONTENT_LENGTH = -s $temp_file);
  }


I'm obviously doing a lot more testing than that, but this is the jist.

---
Rodney Broom
Programmer: Desert.Net






Re: Connection to MySQL DB fails when mod_perl enabled...

2001-05-21 Thread Rodney Broom

 A script that works just fine sans
 mod_perl dies with error 500 (Internal Server Error) when mod_perl is
 enabled for that file type:

This indicates that ~something~ should have gone to the error log. Can you
tell us what else is there?

Can you get a DB connection with regular CGI?


---
Rodney Broom






Re: Connection to MySQL DB fails when mod_perl enabled...

2001-05-21 Thread Rodney Broom

JH If I comment out the DBI code the rest of the script works fine.  I have
JH test the MOD_PERL environment string and mod_perl is definitely running
JH okay.

You have several pieces of mod_perl configuration. If you leave it all in
place, and try some mod_perl CGI without a DB connection, what happens?

---
Rodney Broom





Fw: Connection to MySQL DB fails when mod_perl enabled...

2001-05-21 Thread Rodney Broom

Hey Jon,

You sent this one straight to me...

- Original Message -
From: Jonathan M. Hollin [EMAIL PROTECTED]


JH Yes I also have PHP4 installed and running properly (and am able to
connect
JH to the MySQL server fine with PHP).  I'll comment out the PHP code from
JH httpd.config and see if that helps...

Cool, that could be it. If not, I'd get suspicious of anything else that can
access Mysql.

---
Rodney Broom






Re: Connection to MySQL DB fails when mod_perl enabled...

2001-05-21 Thread Rodney Broom

JH Yes I also have PHP4 installed and running properly (and am able
JH to connect to the MySQL server fine with PHP).

Good, that establishes that your DB is working.


JH Removed PHP from Apache, that didn't help.
JH Nothing else is connecting to the MySQL server.

I've never used a non-*NIX Apache. Do you need to restart you machine to get
something(s) out of memory? Compile a new binary (I doubt it)?


JH Interestingly, the MySQL server error log contains nothing.  No failed
JH access attempts, no other error codes.  I presume this is significant?

My thought would be that this indicates a driver problem. I would suggest
creating a terribly minimized configuration that only includes the requisits
and mod_perl stuff. Then see if that works.

---
Rodney Broom





Re: Connection to MySQL DB fails when mod_perl enabled...

2001-05-21 Thread Rodney Broom

I see what Tom is saying. You said that you found this in your error log:

 [Tue May 22 01:39:47 2001] [error] DBI-connect failed: Can't connect to
 MySQL server on 'localhost' (10061) at
 e:/pad/htdocs/internet/system/frontpage.cgi line 33

But a previous message suggested trying to propogate your own error in the
Perl code like this:

  $dbh = DBI-connect($dsn, dbusrname, dbpassword)
or die Error: $DBI::errstr;

If you use this method, then you should get a record in your error log
simular to:
  Error: some error message

Tom is saying that your error message should actually include the string:
'Error: '. I'm wondering the same thing, what did ~that ~ error message say?


---
Rodney Broom





Re: Connection to MySQL DB fails when mod_perl enabled...

2001-05-21 Thread Rodney Broom

OK, here's the relevant part of your conf:

# BEGIN MOD_PERL CONFIG
LoadModule perl_module modules/ApacheModulePerl
ScriptAlias /perl-bin/ perl-bin/
PerlSendHeader On

Location /perl-bin
SetHandler perl-script
PerlHandler Apache::Registry
Options ExecCGI
/Location

Files *.pl
SetHandler perl-script
PerlHandler Apache::Registry
Options ExecCGI
/Files

Files *.cgi
SetHandler perl-script
PerlHandler Apache::Registry
Options ExecCGI
/Files
# END MOD_PERL CONFIG


I propose that you reduce it to:

# BEGIN MOD_PERL CONFIG
LoadModule perl_module modules/ApacheModulePerl

Files *.mpl
SetHandler perl-script
PerlHandler Apache::Registry
/Files

# END MOD_PERL CONFIG

You'll see that I'm using *.mpl. This will insure that you don't have some
other assosiation interfering.

---
Rodney Broom





Finding AuthUserFile from the request object

2001-05-06 Thread Rodney Broom

Hi all,

I'm trying to add a little bit more security to a running app. In this app, I'd
like to be able to confirm what physical file was used in the 'AuthUserFile
/path/to/pass.db' statement. This file choice needs to be dynamic, so I can't
simply hard wire this info.

Thoughts?


Rodney Broom





PHP4 causes DBI connections to fail silently in mod_perl

2001-05-06 Thread Rodney Broom

Hi all,

The other day I installed PHP4 as a DSO. No problem, it works fine. Today I was
adding a Perl handler that needs a DB connection (MySQL). Nothing special, I
used DBI. But at the time of the connection, the handler stops. No error, no
message, no anything.

- I tried to get a DB handle in an Apache::Registry (mpl) script, same
  thing.
- I tried to get a DB handle from a CGI script, that works.
- I turned off PHP in the conf and retried the mpl script, it connects to
  the DB correctly.

I've searched the archives for this list, and done some searching on PHP sites
and on the web, but haven't found anything specific. Has anybody else seen this?


Rodney Broom





Finding AuthUserFile name with the request object.

2001-05-05 Thread Rodney Broom

Hi all,

I'm trying to add a little bit more security to a running app. In this app, I'd
like to be able to confirm what physical file was used in the 'AuthUserFile
/path/to/pass.db' statement. This file choice needs to be dynamic, so I can't
simply hard wire this info.

Thoughts?


Rodney Broom





Re: Problem with single quote ' character

2000-11-14 Thread Rodney Broom

Hmm, what was the message that you got back when you executed this stement?

Rodney Broom

- Original Message - 
From: "Omri Tintpulver" [EMAIL PROTECTED]
To: "'Rodney Broom'" [EMAIL PROTECTED]
Sent: Tuesday, 14 November, 2000 07:07
Subject: RE: Problem with single quote ' character


 Hi Rodney, thanks very much for your reply. I'm trying it now, but I'm doing
 something wrong. Here's what I have, could you take a look at it?
 
 #parse query string and enter into database if query string exists
 
 my $authors = $query{'authors'};
 my $title = $query{'title'};
 my $year = $query{'year'};
 my $source = $query{'source'};
 my $topic = $query{'topic'};
 my $purpose = $query{'purpose'};
 my $sample = $query{'sample'};
 my $gmc = $query{'gmc'};
 my $process = $query{'process'};
 my $outcome = $query{'outcome'};
 my $rater = $query{'rater'};
 my $results = $query{'results'};
 my $refs = $query{'refs'};
 my $notes = $query{'notes'};
 my $therapy = $query{'therapy'};
 my $analysis = $query{'analysis'};
 my $critique = $query{'critique'};
 my $getcopy = $query{'getcopy'};
 my $id = $query{'id'};
 
 
 #make sure all single quotes are escaped
 
 $q_authors = $dbh-quote($authors);
 $q_title = $dbh-quote($title);
 $q_year = $dbh-quote($year);
 $q_source = $dbh-quote($source);
 $q_topic = $dbh-quote($topic);
 $q_purpose = $dbh-quote($purpose);
 $q_sample = $dbh-quote($sample);
 $q_gmc = $dbh-quote($gmc);
 $q_process = $dbh-quote($process);
 $q_outcome = $dbh-quote($outcome);
 $q_rater = $dbh-quote($rater);
 $q_results = $dbh-quote($results);
 $q_refs = $dbh-quote($refs);
 $q_notes = $dbh-quote($notes);
 $q_therapy = $dbh-quote($therapy);
 $q_analysis = $dbh-quote($analysis);
 $q_critique = $dbh-quote($critique);
 $q_getcopy = $dbh-quote($getcopy);
 
 
 #update entry form into the database
 
 $sth = $dbh-prepare( "UPDATE tbl_sarah SET authors = '$authors', title =
 '$title', year = '$year', source = '$source', topic = '$topic', purpose =
 '$purpose', sample = '$sample', gmc = '$gmc', process = '$process', outcome
 = '$outcome', rater = '$rater', results = '$results', refs = '$refs', notes
 = '$notes', therapy = '$therapy', analysis = '$analysis', critique =
 '$critique', getcopy = '$getcopy' WHERE id = '$id'" );  
 $sth-execute();
 
 --I've put single quotes and also tried no quotes around the variables in
 the SQL statement; neither worked.
 
 Thanks again,
 Omri
 
 
 -Original Message-
 From: Rodney Broom [mailto:[EMAIL PROTECTED]]
 Sent: Monday, November 13, 2000 10:15 PM
 To: [EMAIL PROTECTED]
 Subject: Re: Problem with single quote ' character
 
 
 Hi Omri,
 
 RH This is an FAQ and there is a lot of info on this.  You need to escape
 it
 RH with \.
 RH Just about all languages have a function that does this for you.  Look
 up
 RH the appropriate docs.
 
  Hmm, let's see if I can be a little bit more helpful than Rolf. Although he
 really is right. ;-)
 
 - Here's the SQL side of it:
 Let's say that $firstfield is equal to "Rodney's sooo cool!', and that $id
 is
 equal to 86. That means that when this statement is passed into your DB
 (MySQL),
 that the text of:
  UPDATE tbl_hello SET firstfield = '$firstfield' WHERE id = '$id'
 will come through as:
  UPDATE tbl_hello SET firstfield = 'Rodney's sooo cool!' WHERE id = '86'
 
 See the problem?
 
 - OK, now the Perl side:
 First, I'm assuming that you are using the DBI package. If not, say so. DBI
 provides a neeto routine called quote(), it works like this:
   $q_var = $dbh-quote($var);
 So, doing that to $firstfield would look like this:
   $q_firstfield = $dbh-quote($firstfield);
 $firstfield is not equal to ['Rodney\'s soo cool'], including all three
 single
 quotes. So, if your Perl code looks like this:
   $sql = sprintf(
 qq{UPDATE tbl_hello SET firstfield = %s WHERE id = '$id'},
 $dbh-quote($firstfield)
   );
 
 Then you'll get the SQL to pass to the DB that you are looking for.
 Hollar if you have any other questions.
 
 
 Rodney Broom
 
 
 
 -- 
 -
 Please check "http://www.mysql.com/documentation/manual.php" before
 posting. To request this thread, e-mail [EMAIL PROTECTED]
 
 To unsubscribe, send a message to:
 [EMAIL PROTECTED]
 
 If you have a broken mail client that cannot send a message to
 the above address (Microsoft Outlook), you can use:
 http://lists.mysql.com/php/unsubscribe.php
 







[REPOST] MyClass::import() not being called.

2000-10-23 Thread Rodney Broom

Hi all,

Did we forget me? (snif, snif...)


I've got this happy little access handler that works just fine. I'm loading it
like this:
  PerlAccessHandler MyClass

Now I need for it to accept parameters through import(). That would let me
change the usage to something like this:
  PerlAccessHandler MyClass 'extra parameters'

The catch is that MyClass::import() isn't being called reguardless of how I load
it. I've done all of the obvious stuff, like including lots of debugging
messages in the package, reading the docs, reading the Apache modules book, and
even searching the archives for this list, no help. Does anybody know what's
happening here?


Rodney Broom






Re: [REPOST] MyClass::import() not being called.

2000-10-23 Thread Rodney Broom

From: "Carlos Ramirez" [EMAIL PROTECTED]
CR You can use PerlSetVar to set parameters like so:

CR PerlAccessHandler MyClass
CR PerlSetVar Param1
CR PerlSetVar Param2


Yep, that's definately an effective work-around. My biggest concern is the fact
that import() doesn't seem to be getting called at all. That sounds broken to
me.

----
Rodney Broom






Re: simple cookie authorization?

2000-10-21 Thread Rodney Broom

From: "Jason Bodnar" [EMAIL PROTECTED]


JB Is there a module for simple cookie authorization? I want to grant access if
JB the user has a cookie set. I don't care about the value of the cookie.

Sounds like you just need vanilla cookie access.  Have a look at:
http://search.cpan.org/doc/LDS/CGI.pm-2.74/CGI.pm

Then search on:
HTTP COOKIES

----
Rodney Broom






MyClass::import() not being called.

2000-10-19 Thread Rodney Broom

Good evening all,

I've got this happy little access handler that works just fine. Now I need for
it to accept parameters through import(). The catch is that MyClass::import()
isn't being called. I've done all of the obvious stuff, like including lots of
debugging messages, reading the docs, reading the Apache modules book, and even
searching the archives for this list, no help. Does anybody know what's
happening here?


Rodney Broom





Re: Remembering Authentication

2000-10-17 Thread Rodney Broom

From: "Nicolas MONNET" [EMAIL PROTECTED]

 print $q-redirect("http://$l:$p\@$ENV{HTTP_HOST}/path");

Ack! Can anybody find a bigger security hole than this?


Rodney Broom






Recognizing server config, like Aliases, from modules

2000-10-12 Thread Rodney Broom

Hi all,

I've got a set of new modules that do things like session handling, URI
rewriting, authentication, etc. I've got a set of tests to prevent some rewrite
problems that look like this:

if ($uri =~ m|^/cgi-bin/|) {
return DECLINED;
if ($uri =~ m|^/icons/|) {
return DECLINED;
etc.

This is done to allow access to /cgi-bin and /icons and the like without
rewriting the URI. UserDir is the same way. The problem is the fact that now
folks can't ajust the conf file without ajusting the module, too. I guess I
could slurp up the config file on load and figure it out for myself, but that
doesn't seem very healthy or very efficient. What I'd like is a method:

  $r-get_aliases

But I don't guess that exists, huh? Any thoughts?


Rodney Broom





Re: [OT] hi all

2000-10-11 Thread Rodney Broom

RM we have a query which goes to 7kb...

"7 kb"? I don't mean to be picky, but do you mean "seven kilo-bytes"? I'm
thinking that either you mean some much larger number, or that I'm missing
something terribly.

Either way, what does your query look like? Are you joining across 3 tables and
then back onto one of those tables again, and then using a bunch of LIKEs and
ORs? Or is this just a simple "select * from xyz"?

If it isn't obvious from your query as to what's the problems, then we should
probably know a bit about your server config. Like, "We're running on Win3.11".
;-)


Rodney Broom






Re: [OT] hi all

2000-10-11 Thread Rodney Broom

DB I read this as meaning the QUERY string is 7k in size, not the result set.

Hmm, I didn't think of that. Yes, that would be a big query.

DB ...the words 'stored
DB procedure' come to mind (but that's always another story)

Yes, no stored proceedures in mysql. But if this does refer to 7KB of text in
the query, then I have to think that there's a better way to write it. I wrote a
little search engine that did a bit of:

where (
  id = 3 or
  id = 5 or
  id = 2838
 ...
)
But that was to get around a bad LIKE statement. And it actually runs pretty
well. My thought would still be that the statement can probably be cleaned up a
bit. Hey Rajesh, I know that you probably don't want to share the exactities of
the query for business reasons, but any indication you can give would help in my
oppinion.


Rodney Broom






Re: [OT] flock under win32

2000-09-25 Thread Rodney Broom

Hi all,

Here's my two cents worth (or less):

Teijo Aulin I got the following error message: "flock() unimplemented on this
platform...
Teijo Aulin I see that flock() is not implemented under win 98, so how can I
fix this?


Matt Sergeant It can't ever be locked under Win9x because it doesn't support
the notion of file locking.

Hmm, that can't be altogether true. Haven't we all seen messages from WinDOS
about "cannot access... resource in use"? Although I'd bet that one would have
to use something from the Windoz API to get this functionality. I don't know of
how to do it myself, but maybe something from Dave Roth (www.roth.net).

Matt Sergeant The only thing you can hope to do is implement some sort of flock
based on writing a temporary file or something.

That's what I'd do. If you were so inclined, you go crazy and write a common
file that kept interesting locking information. Then have your flock() check
that file. The file could even include fancy (unnecessary) stuff like what
process had the resource locked, the lock time, etc. You could go even more nuts
and implement something that watched for shutdown failures to intelligently
removing the locking data file after reboots.

----
Rodney Broom





Re: SELECT cacheing

2000-09-08 Thread Rodney Broom

Some good ideas, I think that this package might come out a bit thin though.
I've written a package that does arbitrary variable caching (like everybody
else). But it has a list of other bells and whistles. Things like cache
expiration and data refresh hooks. It's a pretty simple process.

From there, I've have (but addmittedly don't use yet) a little DB package that
sits as an interface between the programmer and the DB, and incorporates things
like this caching package at the same time.

So you do:

$dbh = DB-new(...)
$sth = $dbh-prepare($q)
%results1 = $sth-fetch...

$sth = $dbh-prepare($q)
%results2 = $sth-fetch...

# Results are the same, %results2 comes from cache.

$sth = $dbh-prepare($insert)
$sth-execute

$sth = $dbh-prepare($q)
%diff_results = $sth-fetch...
# %diff_results is new data because the DB has changed.


Just some thoughts for y'all to mull over.


Rodney Broom





Re: Getting data from external URL

2000-08-26 Thread Rodney Broom

SB This one is much more efficient and requires even less coding:
SB use LWP::Simple;
SB $content = get("http://www.sn.no/")

Even better, thanks Stas.





Re: Getting data from external URL

2000-08-26 Thread Rodney Broom

OK, lots of banter...

Hey V, if you are on a *NIX system, then this is a fast way:

open U, "lynx -source www.some.url.dom |";
$data = join '', U;

There, you're finished. Admittedly, this isn't terribly efficiant, but it works
just fine and has short devel time.

----
Rodney Broom





Re: Website problem

2000-07-29 Thread Rodney Broom


...I get in the error.log the message: "Premature end of script headers". Where
 can I find the "misconfiguration".

Have a look at the error log, the message should be something like:
"Premature end of script headers: /path/to/script.cgi"

This means that the named script is failing to compile. Try:
% perl -wc /path/to/script.cgi
This will tell Perl to try to compile the script without actually running it.
The '-w' switch will turn on "warnings", which may help to point you at the
problem(s). Most likely is a syntax error.

For more learning, try:
% perldoc perl
This will tell you a bit about how to run Perl and also list many good sources
of documentation.

---
Rodney Broom






Re: Why is this book out of print?

2000-07-17 Thread Rodney Broom

I have this book, it's OK. I think it's mostly good for a guide on using LWP,
but it sounds like that's what you need. Maybe this will help.

ISBN: 156592214X


Rodney Broom







Re: error DBI with quote

2000-07-10 Thread Rodney Broom

Ack! I can't find the string "not valid sentence" in DBI.pm, Apache/DBI.pm, or
in Oracle.pm, so I'll ignore it.

Here's your code:

  $phrase = "Mike's car"
  $sql=qq{INSERT INTO TABLE_NAME (PHRASE) VALUES (?)};
  my $insert_phrase=$dbh-prepare($sql);
  $sql-bind_param(1,$dbh-quote($phrase),SQL_VARCHAR);
  $insert_phrase-execute();

There are several little problems it this chunk that lead me to believe that
this was not copy-n-pasted from the actual code. But who cares, try this:

  $phrase = "Mike's car"
  $sql=qq{INSERT INTO TABLE_NAME (PHRASE) VALUES (?)};
  #-- The return from prepare() is a statement handle
  my $insert_sth = $dbh-prepare($sql);
  $insert_sth-execute($phrase);

That's it, just pass a list of values into execute(). As for Michael's comment
of not being sure whether you can use prepare() for non-SELECT-statements, the
answer is yes. In fact, all statements have to be prepare()ed when using DBI,
it's just a matter of who does the prepare(), you or DBI.


Rodney Broom






Re: Is variable initialization necessary?

2000-07-10 Thread Rodney Broom

"Drew Taylor wrote:

 So my question is: Is variable initialization necessary? Is being a
 lexical enough? To date, I've played it safe. But if I don't have to...
 then I won't.

Hi Drew,

A couple of points:
1. I couldn't tell you for sure about performance, but I wouldn't worry too
much. If you are working on a perfessional system, then I'd bet that you have
enough hardware to handle any slight performance hit that might be seen.

2. Lear to use strict (see perldoc strict). Once you have this down, you'll have
everything you need on scoping. It's more difficult to program under strict, but
much safer.

3. Further, there are some issues on scoping vars (or rather failing to) when
running under mod_perl. My experience sais to always lexically scope vars,
preferably with my() where applicable.


Rodney Broom






Re: Regex problem

2000-07-10 Thread Rodney Broom

The regex engine is seeing extra stuff in $string and thinking that you are
trying to build an expression with it. To get Perl to handle $string as straight
text, you need to quote it like this:

$input =~ s/\Q$string\E/$change/g;


Rodney Broom






Re: Can you tie session to exclusive db connection across http requests?

2000-06-26 Thread Rodney Broom

Hi Keith,

It sounds to me like you're not getting alot of help on this one.
Personally, I tend to agree with John the most. However, I find nothing
intrinsically wrong with what you want to do. If you really ~need~ to lock a
given data set against modification, then there are about a kagillion ways
to handle. My consern is still John's:

John Hughes What do you do if user A goes away for lunch with the data
still locked?

So I'd set locks on write, not on read.

Depending on how sophisticated you need to be, you could just handle it at
the statement level by having your session (or whatever you like) record the
mod-date of the record you are looking at. Then:

 UPDATE my_table SET
 stuff...
  WHERE key = ?
 AND mod_time = ?


Rodney





Re: speed up/load balancing of session-based sites

2000-05-09 Thread Rodney Broom

  Murali said:
   a) NFS mount a server which will store all session data

Just a note, NFS in specific can be very problematic. It takes some real
tuning to get it just right. As for distributed data; session data ~should~
be small, under a kB. So you could move it around in almost any fassion you
like and still be pretty efficiant.

On that, you can use Storable to push around really compact/complete Perl
data structures.

Rodney




ENV var names rewritten to REDIRECT_*

2000-04-21 Thread Rodney Broom

I've written a handler to do some auth work. It's implimented in a .htaccess
with PerlAuthHandler. In the package, I set a couple of ENV keys for use by
any pages/scripts in the request. Well, I have 3 different page types that
can load under this auth system, CGI, mod_perl, and an internal thing called
.wga. I have a script of each that just dumps out the ENV. Here's what
happens in the pages in responce to attempting to set ENV from the auth
handler:

#-- In auth handler
$ENV{MY_KEY} = $my_val;
#-- From .cgi page
MY_KEY = $my_val

#-- In auth handler
$r-subprocessed_env(MY_KEY = $my_val)
#-- From .mpl page
MY_KEY = $my_val

#-- In auth handler
$r-subprocessed_env(MY_KEY = $my_val)
#-- From .wga page
REDIRECT_MY_KEY = $my_val


The only difference that I can find is that .wga is also called through
another handler. Thoughts?

Rodney




Re: Perl 5.6 and mod_perl

2000-03-31 Thread Rodney Broom \(OE\)

- Original Message -
From: "Doug MacEachern" [EMAIL PROTECTED]
 if you could follow the hints in the SUPPORT doc for getting a stacktrace,
 that would help a great deal.

Sure, I'll see what info I can get without tampering with current working
installations.

Rodney




Re: Perl 5.6 and mod_perl

2000-03-30 Thread Rodney Broom \(OE\)

- Original Message -
From: "Jeff Stuart" [EMAIL PROTECTED]


 Has anyone tried to use mod_perl with perl 5.6 yet?

Yes, all day.


  If so, how did it go?

U guess. Lots of weird little errors that I can't quite resolve. I can get
Apache installed, but if I build with mod_perl, I can't get cgi or indexing
to work. They just spit out segment fault errors.

I've tried installing from the mod_perl build (1.21 and 1.22), and from CPAN
shell. I've tried with Apache 1.3.9 and 1.3.12, same thing. If I build
without mod_perl, Apache behaves just fine. I'm going to try building Apache
with mod_perl as an extra module; if that doesn't work, I'm going to
downgrade my Perl back to 5.005.

If I'm just being silly and missing something, please hollar at me!

Rodney





Re: Problem using POD/mod-perl to document configuration files

2000-02-11 Thread Rodney Broom \(Office\)

At 13:41 2000-02-11 +, [EMAIL PROTECTED] wrote:
Page 427 of "Writing Apache Modules with Perl and C" describes the 
use of POD to document Apache configuration files.  My problem is 
that I cannot get the =over/=back functionality working (which is 
supposed to hand sections back to Apache for processing, thus 
allowing one to include configuration sections in the generated 
HTML).

Huh, I didn't realize that mod_perl would dig inside of POD like that.
First, may we have a specific snipet of the conf file, please? Second, does
your =over/=back look like this:


=over to apache

MyDirective On

=back to pod


This message contains confidential information...

hehe, sent this from work did ya?



--------
Rodney Broom



RE: Re: Problem using POD/mod-perl to document configuration files

2000-02-11 Thread Rodney Broom \(Office\)

At 14:47 2000-02-11 +, [EMAIL PROTECTED] wrote:
...problematic, as I live on a yacht :-)

Do you want a roommate? Maybe a cabin boy?

I copy-n-pasted your code from into my telnet window and changed
"ExtendedStatus On". Like this:

-
=pod

=over to apache

Perl

print "Hello, POD.\n";

/Perl

=back to pod

=cut
-

Shell:
-
% ./apachectl configtest
Hello, POD.
Syntax OK
% pod2text conf/httpd.conf
Perl

print "Hello, POD.\n";

/Perl

% ./apachectl stop
./apachectl stop: httpd stopped
% ./apachectl start
Hello, POD.
./apachectl start: httpd started
% tail -1 logs/error_log
[Fri Feb 11 09:27:39 2000] [notice] Apache/1.3.11 (Unix) mod_perl/1.19
configured -- resuming normal operations
-

I stopped and then started because sometimes my server doesn't like to
restart.

You mentioned line endings, so I'm guessing that's not your problem. If you
haven't already, maybe you should try your directives outside of the POD
sections and make sure that they work.

Let us know what happens...







Rodney Broom