Operating System - HP-UX
1838115 Members
3963 Online
110124 Solutions
New Discussion

Re: Adding File functionality to Apache

 
SOLVED
Go to solution
Shannon Petry
Honored Contributor

Adding File functionality to Apache

I'm putting this under sys-admin, as I may not be looking at this the right way.

I have a HP 900/765 running Apache, Squid, and secure ftp (chrooted dirs with quotas), no write access to home but access to "incoming" and "outgoing" dirs in their home.

I have several users that can not access the FTP server portion easily.

I want to add file functionality to HTTPD for users, similar to how they use FTP.

The only way I can see to accomplish this is with some CGI, which will look at the user name as they log in, and build dynamic pages on the fly.

While the basic meat and potato part is easy. Build a HTML doc with 2 links "incoming" and "outgoing", linked to a "incoming" and "outgoing" HTML doc which lists files, and links to the actual files in the dir.

Also, I can build a FORM to post data, but have no idea where the data goes or what context it's in after uploading.

What I can not seem to grasp, is how to get their login name from apache to build the pages.

Lastly, looking at the other services running on the system, it seems like there would be a much easier way to accomplish this.

Ideas on how to accomplish this easier and/or how to have Apache build dynamic pages based on login are both appreciated.

I know that lots of people have a ton more experience with Apache and HTML than I.
Microsoft. When do you want a virus today?
6 REPLIES 6
benoit Bruckert
Honored Contributor

Re: Adding File functionality to Apache

Hi ,
For such a case, php is your friend !
I have one question :
the login is from a FORM or from a .htaccess,
from a form, then it's just a paramater you will get in your cgi script (or your php page if you select this option).
If it's from an apache authentication (.htaccess), then you should have a variable with the tool you are using to build your page.

example for the form :







login:
password:


And in your loginscript you receive the login+password, you just have to manipulate the values...

hope that help
Benoit
Une application mal pansée aboutit à une usine à gaze (GHG)
Shannon Petry
Honored Contributor

Re: Adding File functionality to Apache

Well, the login is actually 2fold security.

First, the user must access a secure zone, so standard username/password and httpd security

AuthType Basic
AuthName "Restricted for FTP Users"
AuthUserFile /usr/local/apache2/etc/passwd
Require valid-user


The secondary login file will be parsed from the FORM.

Now I may (depending on how secure I feel with the CGI) remove the top auth and use exclusively CGI.

I have jack squat experience with PHP.

Any good DOC's for it?

Thanks!
Shannon
Microsoft. When do you want a virus today?
benoit Bruckert
Honored Contributor
Solution

Re: Adding File functionality to Apache

Well,
with PHP you don't have to use cgi script,
because it may be completly linked with apache, and a .php file will be interpreted by the php language. By this way, you build on the fly anything you want.

HEre's a sample :
login.html
<...>






login:
password:

<...>

And here's the login.php just a sample :
if $password==""
{
echo "OK your are authenticated..you can continue
";
}
else
{
echo "Hey you type a wrong user/password !!! you cannot connect";
exit;
}
?>
your place here your html stuff
if you want to add some login datas, just have to open a php part by :
if $login==....
{
echo "all your specific html..."
}
?>
or

this is some html datas, and you just want to print the login :


If you want to get the http authentication name (from your .htaccess file ) :
$PHP_AUTH_USER is the solution....

YOu have many ways...
Concerning docs, the reference manual from php.net is what I'm using...

hope that help
Benoit
Une application mal pansée aboutit à une usine à gaze (GHG)
Shannon Petry
Honored Contributor

Re: Adding File functionality to Apache

Thanks for the advice! Haha, not that I wanted to learn a new language, but what the helk ;) Looks alot like C anyway.

Time to get studying!

Shannon
Microsoft. When do you want a virus today?
benoit Bruckert
Honored Contributor

Re: Adding File functionality to Apache

On my side, i started to play PHP 2 years ago when my company gave me a software to maintain built in PHP. And I had absolutly no knowledge of it !!
I understood concept and syntax very quickly and now I'm playing with it very often (I never use pure html file) even for scripting (you can run it in a command line like an interpreter).
The best advantages of PHP is the ability to connect to many databases very easily.

no points please, this is just an add for this product !
hope you will like it,
regards
Benoit
Une application mal pansée aboutit à une usine à gaze (GHG)
Shannon Petry
Honored Contributor

Re: Adding File functionality to Apache

PHP worked, was a long time ago (so it seems).
Microsoft. When do you want a virus today?