Print

Beside using Joomla!, you can host web pages on CSIM web server the traditional way. Your personal home pages must comply with the acceptable use policy.

 Web server set-up

CSIM web server is running the popular Apache HTTP server. As a user registered with CSIM network, you can store your personal home pages on this server. In the following examples, I will consider that your user identity is c01678.

Your home page is accessible with the URL:

https://www.cs.ait.ac.th/~c01678/

Note the ~ before your user identity. This is similar to the notation for the home directory in Unix environment.

You must store the files corresponding to your home pages in a directory called public_html. The name of this directory cannot be changed, it must be inside your home directory. You must make sure that the directory is accessible by the web server, you have to change the access modes with the command:

chmod 755 public_html

In the same way you must be sure that your home directory is also accessible, so use the command:

chmod 755 ~


Note that all your files, in your home directory, will become visible. You cannot have an home page and not making your files visible to other Unix users. To keep your other files secret, you can create a directory in your home directory and change the access modes with the command:

chmod 700 private_director


Your HTML files will also have to be readable by the web server, you must make sure you set the right access mode:

chmod 644 *

to chage the access mode of each and every file. Above rules apply for every subdirectory you create in public_html and for every file in these subdirectories.

You can start creating your home page, call it index.html, it can look like:

<HTML>
<HEAD>
<TITLE>John Doe Home page</TITLE>
</HEAD>
<BODY>
<H1>John Doe home page</H1>
<P>Hello and welcome to my home page.</P>
<P>My name is John, I am a student of CSIM program.</P>
<IMG SRC="mypicture.gif">
</BODY>
</HTML>

When your home page is ready and if you are a student, use the Account management page to add a link to your personal home pages. You will get the following advantages:

As a faculty, you can link your peronnal home page to the Program faculty page, contact the This email address is being protected from spambots. You need JavaScript enabled to view it. for that purpose.

 Using CGI scripts

CSIM web server allows you to run CGI script and Server Side Include (SSI). CGI are scripts that run and output some HTML code. This code will be display on your browser. CGI are widely used in conjunction with <FORM>. SSI are special scripts which result is appended to a normal HTML page.


For security reason, your scripts will be run under your user name, and with your user privileges, even if it is the web server that run your scripts. If a script contains a security hole, it will only affect your files.


CGI and SSI can be writen in any language, but Perl is often prefered as the scripts can be easily porter from one server to another without recompiling. CSIM web server also allows you to write PHP scripts.

You must store your scripts in a directory called cgi-bin that you create in the directory public_html. This directory cgi-bin must have access mode 711, but each scrpit must be executable and readable by everyone:

chmod 755 myscript

The first line that a script prints must always be:

Content-type: text/html

followed by an empty line. There could be some computation done before this line is printed out, but your script must not print HTML code before it prints theContent-type and a blank line.

Note 1: a CGI script is a program, make sure you can run it from your Unix account before you try to run it from the Web.

Note 2: when you edit a Perl CGI script from DOS, the text editor will tend to add a <Cariage return><Line Feed> at the end of each line. This will highly confuse Perl because in Unix the end of line is marked only by <Line Feed>. To avoid such problem, make sur to edit your Perl CGI scripts from Unix only.

Input arguments to a GCI scripts are encoded; in every script I will use the following portion of code to decode the input arguments:

sub decode_param { 
# decode the parameter on the command line
if ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # POST method
}
else {
$buffer= $ENV{'QUERY_STRING'}; # GET method
}
my @pair = split(/&/, $buffer);
foreach (@pair) {
($name, $value) = split/=/;
$value =~ tr/+/ /; # do the cleaning
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
}

After calling the function decode_param the arguments are stored in an hash array called FORM, in such a way that if argument arg1 has the value val1, then$FORM{'arg1'}=val1. In a form that has an imput field like <input type=text name=test>, you will get the value in $FORM{'test'}. This is consistent with the way environment variables are stored in the hash array ENV in Perl.

Hosting your home pages on the cloud

You may prefer to host your personal pages on some system other than CSIM. But the current setting only allows local home pages. You can trick that by creating an home page that contains a Javascript redirection to your home page elsewhere; make your page looks like:

<!DOCTYPE HTML>
<html lang="en-US">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="refresh" content="1;url=http://some web page">
        <script type="text/javascript">
            window.location.href = "http://some web page"
        </script>
        <title>Page Redirection</title>
    </head>
    <body>
           If you are not redirected automatically, 
follow the <a href='http://some web page>My profile</a> </body> </html>

And add a link to that page in your Account management.

Powered by Apache Perl power Powered by PHP Includes OpenSSL Secured by mod_ssl