Gossamer Forum
Home : General : Perl Programming :

How to make an admin area.

Quote Reply
How to make an admin area.
Does anyone know a tutorial that shows you how to make a CGI script that build files, and shows you how to make an admin and member area?

Quote:
Also does anyone know a simple Perl script that rotates images? And a tutorial that teaches how to rotate pitures and add stuff to the rotator?

You can view my scripts at nytesoft.hypermart.net/Perl

------------------
Patrick Chukwura
http://nytesoft.hypermart.net
Quote Reply
Re: How to make an admin area. In reply to
Simplest and best documented image rotator there is:

http://worldwidemart.com/scripts/ssi_image.shtml

This uses SSI, but if server won't allow it you should be able to modify it.

When you say a script that builds files, do you mean something like The Globe, where users can create their pages online and that? Well, if you do there probably isn't any tutorials out there, but the easiest way to learn it to download something like what you're looking for and view the code.

Go to:

http://www.cgi-resources.com/...l/Editing_Web_Pages/

for some examples.

tata,
adam
Quote Reply
Re: How to make an admin area. In reply to
No I mean CGI scripts that make files by building them like the Links script on this site.

------------------
Patrick Chukwura
http://nytesoft.hypermart.net
Quote Reply
Re: How to make an admin area. In reply to
Ok, it depends on what you want your admin script to do.
If the script is supposed to create an html file using some data from a database (like Links does), then here we go:

Code:

#!/usr/bin/perl
#-------------------------------+
# Simple Database Engine 1.0 |
# by Pasha Golovko |
# webmaster@find.virtualave.net |
# http://find.virtualave.net |
#-------------------------------+
#
# Chmod:
# database.cgi 755 (rwxr-xr-x)
# database.txt 777 (rwxrwxrwx)
# index.htm 777 (rwxrwxrwx)
#


# Display some header
$html1 = qq~
<html>
<head>
<title>My simple database</title>
</head>
<body>
~;


# Display some footer
$html2 = qq~
</body>
</html>
~;


# Open my silly database
open(LOGFILE, "<database.txt");
@entries = <LOGFILE>;
close LOGFILE;


# Open the output file
open (HTML,">index.htm");


# Print header
print HTML"$html1";


# Now, lets split what ever we got in the database ...
foreach $line (@entries) {
@fields = split(/\|/,$line);


# ... and print what ever fields we got from database
print HTML "$fields[0] - $fields[1] - $fields[2] - $fields[3] <br>";
};

# Print footer
print HTML"$html2";


# Close the output file
close (HTML);


# Print some visual output, when your script finished working with database Smile
print "Content-type: text/plain\n\n";
print "Done!";

This script will get the data from a 'database.txt' file, and create an 'index.html' file with the data that it got from the database.

If your admin script is supposed to do some e-mailing from database, then:

1. open the database
2. open sendmail
3. print the database to the sendmail

If the script is supposed to sort the data, then:

1. open the database, get some data
2. sort the data
3. print sorted data back to the database

If you need any help, just ask. Smile


Regards,

Pasha

------------------
webmaster@find.virtualave.net
http://find.virtualave.net
Quote Reply
Re: How to make an admin area. In reply to
What is the best book to buy, teaching how to do CGI scripts? I want one that has everything in it. Starting from print command to the to the most advanced feature.

------------------
Patrick Chukwura
http://nytesoft.hypermart.net
Quote Reply
Re: How to make an admin area. In reply to
My recommendation is Learning Perl by O'Reilly and Associates. Learn how to use perl first, then learn any CGI specifics, you'll be much better off in the long run.

Cheers,

Alex
Quote Reply
Re: How to make an admin area. In reply to
Thank you both for the reply.
Alex: I have tried to make CGI first then to learn them really. I dont see how you make thoose big CGI scripts like Links by yourself. I would have to see an example.

------------------
Patrick Chukwura
http://nytesoft.hypermart.net
Quote Reply
Re: How to make an admin area. In reply to
The BIG scripts are only big, because they supposed to do big job.

The smallest program I think is this: Smile

Code:

#!/usr/bin/perl
print "Content-type: text/plain\n\n";
print "Hello World!";

Links is not the biggest script I've seen, but the biggest I've messed with Smile

Again, I suggest to learn to manipulate data first. Take a look at the Simple Database Engine script, it's the first program I wrote, and is pretty simple to understand. Try modifying it to do some job other than get and print data. Take a look at some online tutorials, most of them can be very helpfull. Wink


Regards,

Pasha

------------------
webmaster@find.virtualave.net
http://find.virtualave.net