CMPS-3350 Lab-3

The components of this lab are:

This is an individual assignment.

Step 1:

You should do the programming of your C++ program for this lab on your local Desktop.

When this lab is complete, copy your program files

lab3sget.cpp
Makefile

to your 3350/3/ directory on Odin.


Step 2:
Create a C++ program using the code sample at:

/home/fac/gordon/p/3350/code/lab3/lab3sget.c

Important:
Save this program immediately to your Odin /3350/3/ folder please.


Step 3:
Create a Makefile that includes the following compile line...

g++ lab3sget.cpp -Wall -olab3sget -lssl -lcrypto
Note: You are refactoring a C program into the C++ language. Complete the rest of the Makefile. Build your program with make.

Step 4:
Please fix all compile warnings and errors.

Enter a comment above the code related to each error or warning that you fix.
Include the original code that was fixed, in the comment.

For example:
//--------------------------------------------------------------------- //Fixed warning: deprecated conversion from string constant to 'char*' //Previous code was: // void getHost(char *hostname) //--------------------------------------------------------------------- void getHost(const char *hostname) { ... ... ...
Step 4a: . Style this program using the Linux style guide. Main features... . Apply perfect K&R brace, space, and indenting. . No lines will wrap on an 80-character window. . Choose hard-tabs or spaces for indenting, but do not mix them. . One command per LOC (line of code) . Fix all compile warnings and errors.

Step 5:
Run lab3sget with the following parameters...


example:
./lab3sget www.google.com robots.txt

What you should see is a list of restrictions posted by the owner of the website you are accessing.

As you can see, accessing a website using automated means is restricted. When using your HTTP program, always check the robots.txt file, and follow the instructions for that site.

Step 6:
Run lab3sget with the following parameters...

You should see text output of a file.



Step 7:
Create a PHP program in your Odin public_html directory...
It will have this URL:

	https://cs.csub.edu/~username/3350/lab3/lab3.php

where username is your own Odin account name.

If you have any questions about the path to your lab3.php, please ask
about it during lab.


Here is a sample PHP program example...
<?php
echo "This is my php file.";
?>

Step 8:
Run your lab3sget program and contact your PHP file.

like this... except insert your own username

    ./lab3sget  odin.cs.csub.edu  /~username/3350/lab3/lab3.php

Step 9:

Use a web browser to look at your php file

    like this...

    https://www.cs.csub.edu/~username/3350/lab3/lab3.php


Step 10:

Make some minor changes to your lab3.php program...

Allow the program to accept input:
	$param = $_GET['param'];

Process the $param variable in the PHP file.

Your new PHP program will look like this...
<?php
$param 
$_GET['param'];
echo 
"param is: " $param "<br>";
if (
$param == "hello") {
    echo 
"hey there!<br>";
} else {
    
$num $param*2+3;
    echo 
"number:" $num "<br>";
}
echo 
"<br>";
echo 
"<img src=\"lab3_diagram.gif\"/>";
?>

Required:
 1. Create a file named lab3_diagram.gif for your diagram below.

    For image file conversion...

       You may use GIMP for file conversion.

       You may also use convert from the command-prompt.

		   example: $ convert image.jpg lab3_diagram.gif

       Inside your <img> tag, apply a style element that will
       size your diagram to an appropriate size.

		   example: style="width:800px;height:auto;"


Step 11:

Run your lab3sget program and contact your PHP file like this...

./lab3sget odin.cs.csub.edu /~myname/3350/lab3/lab3.php?param=hello

Then try this...

./lab3sget odin.cs.csub.edu /~myname/3350/lab3/lab3.php?param=123

You should see the appropriate data returned.


Step 12:

Draw a Diagram!

Draw a Diagram to show the components of the system
that you just created during this assignment. Think about the flow
of data through the system. How would a user interact with it?

Your diagram might include
. your C++ program
. your local computer
. the Odin server
. the SSL certificate
. your PHP program
. the Apache web server
. your image file
. any other components you can think of
. etc.

Create an original diagram based upon how you see the components of the system.

Local drawing tool: Dia

Free online drawing tools:
draw.io
Gliffy

Create a nice diagram please.
Sloppy diagram will not be accepted.

Note, this diagram will be viewed by your instructor and by the class.
Contacting your php file will display your diagram.

What to turn in?
Your instructor will contact your PHP file, with various parameters.

Copy your DFD image file to your web directory, so it will be displayed
when your web page (lab3.php) is viewed.


Make sure your files
lab3sget.c
lab3sget.cpp
Makefile
are on Odin in your: 3350/3/ folder.


Also required later...
The components of this lab will be integrated into your project to
provide communication with a server such as Odin.
PHP will also work well with simple text files on the server.
Track high scores or even simple 2-player action.