Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Lot's of simple question about CGI

by pokemonk (Scribe)
on Jul 21, 2001 at 01:54 UTC ( [id://98562]=perlquestion: print w/replies, xml ) Need Help??

pokemonk has asked for the wisdom of the Perl Monks concerning the following question:

Yo.
i'm working on windows sistem, apache server.
Ok, my questions:

let's say i'm working on a script, and there are some admin subroutines, what do i have to do to get apache to request user authentication only on these subs, and how do i do to put my userid and pass in the pass file(how do i use htpasswd.exe)

I wanna put binary data in my mySql db. so i used CGI for first time to get the uploaded data, and i created a colum mediumblob so, mysql statemet is INSERT INTO img VALUES (NULL, $img) would this work??

Now, i'm thinking about doing a live audio thing, like. i want people to hear what's goin on in my room whenever they want, i have no clue how to do that.

i'm just turned a computer into a web server, where can i get sendmail or something like that?? i need to recieve mail too. what should i do?

alright dudes, i guess that's all, thanks for the help, later. oh yeah, by the way. help me and then you can bitch about this node, i tried my best to make it good.

Replies are listed 'Best First'.
Re: Lots of simple question about CGI
by thpfft (Chaplain) on Jul 21, 2001 at 05:04 UTC

    Here are a few pointers. I hope they help to get things started. First off, read How to RTFM. Then:

    let's say i'm working on a script, and there are some admin subroutines, what do i have to do to get apache to request user authentication only on these subs, and how do i do to put my userid and pass in the pass file(how do i use htpasswd.exe)

    1. Put the admin scripts in their own directory - a subdirectory of the cgi-bin will be easiest.

    2. Within that directory, type htpasswd -c .htpasswd admin to create a password file and put the user 'admin' in it. You'll be prompted twice to enter the password. See the apache docs for more information about what's going on here.

    3. create a file called .htaccess in that directory. In there you'll put the instructions that tell apache that access to this directory requires authentication of a user in the .htpasswd file you've just created. That's way off topic for this site, but see this page for instructions and this one for examples.

    4. If you want your scripts to read or update the password file you've created, the easiest way is to use the Apache::Htpasswd module. It's on cpan.

    let's say i'm working on a script, and there are some admin I wanna put binary data in my mySql db. so i used CGI for first time to get the uploaded data, and i created a colum mediumblob so, mysql statemet is INSERT INTO img VALUES (NULL, $img) would this work??

    Two tasks here: capture the binary data, and feed it into the database. That's not beginner perl, but it's not all that hard. CGI.pm will provide the data capture without you having to do much work at all, but you will have to rtfm on that one. There are also nodes here that will help, or at least motivate. Your immediate question is addressed by creating a file upload field, but you'll need to adapt the filehandle code to write the data into a query rather than a file.

    For efficient display of the uploaded image, you'll also need to store information about its dimensions (and preferably some alt text). You can ask the user for that, but it's a pain: you're better off using the very excellent Image::Size module.

    Your query as it stands will work if it matches the order of the columns in your image table, and the first column doesn't mind being null. It's probably better to make the first column an auto-incrementing id field and just use INSERT INTO img (data) VALUES ($img). Don't forget to call $dbh->quote() on the data beforehand. Again, there's no way you can avoid reading the mysql and dbi docs, so you might as well start now.

    Now, i'm thinking about doing a live audio thing, like. i want people to hear what's goin on in my room whenever they want, i have no clue how to do that.

    I suggest you wait until a clue arrives and do it then. This might help.

    i'm just turned a computer into a web server, where can i get sendmail or something like that?? i need to recieve mail too. what should i do?

    This.

    alright dudes, i guess that's all, thanks for the help, later. oh yeah, by the way. help me and then you can bitch about this node, i tried my best to make it good.

    Most of the links here came from five minutes on google. There are a lot of good howtos and guides out there for people in exactly your situation. Consult them first, ask the questions that come up when you try and do what they say, and you'll get a lot more help and a lot less bitching out of places like this.

    And please don't be dismayed, by the steepness or the bitching. It's not brain surgery, it just takes a little while to learn the jargon and use it to find the resources that'll make all this easy.

Re: Lot's of simple question about CGI
by simon.proctor (Vicar) on Jul 21, 2001 at 02:14 UTC
    Well . . . I'll make a few assumptions and see if it makes sense. Lets assume your mysql table looks like this:

    create table IMAGES( ID int(4) primary key auto_increment, data MEDIUMBLOB, type int(4), name char(10), width int(3), height int(3) ); create table IMAGETYPES( ID int(4) primary key auto_increment, name char(10), description char(10) );


    Then your sql to insert an image would be:

    insert into IMAGES(data,name,width,height) values(?,?,?,?)


    Ok, that SQL is then primed to go into a DBI call using execute (after prepare) or by a do. As its an insert I recommend a 'do' call.

    The second table allows you (by using a JOIN) to retrieve the image type and hence print the correct header when printing the image (assuming thats what you want).

    As for SendMail - get Linux.
    LiveStreaming - you could try something with Real using a RAM file under Apache. But its probably a little advanced. I would get the image stuff working first.
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Lot's of simple question about CGI
by DBX (Pilgrim) on Jul 21, 2001 at 03:42 UTC
    Aside from your attitude, there are better sites to get answers to these questions. I don't see anything related to perl in your post, which, while not really relevant to this site, wouldn't be SO bad if you were a little more friendly. It's a little rude to ask a question you know isn't relevant and then wear it on your sleeve by daring people to bitch about it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://98562]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-04-19 05:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found