CS2623: Server-Side Programming
SSP06: Files
Objective:
- Upload and download files
- Read and write to data files
- Open and close file streams
- Manage files and directories
Points
- Full Credit: 40 Points
- Late/Resubmit Credit: 36 Points
Situation
This is quite an ambitious assignment so I am providing some help and modified specifications to make it more manageable.
The following files may be helpful. As stated below, you may use these or create your own.
---> ChineseZodiac_Chapter5Files <---
Caveat: These files are from the solution files I have available to me. I have not verified if they will validate. I am leaving that up to you.
Need a Visual Reference?
The following are videos (Flash Files) of past student sites. In most of the cases the entire web page is not included in the screen shot, just enough to let you see the functionality of each project assignment. I
Disclaimer: f you see something that is contradictory to our class assignments, please ask. Do not assume that since it is on the video that it is 100% correct.
* Note that the Switch version has some additional information about presidents and years. This is not required at this time. It will be added in Chapter 6.
Specifications
- Discovery Project 5-1
instead of researching the information, you may just download, copy, and paste the code from inc_site_layout.txt which has been included in the ChineseZodiac_Chapter5Files or if you prefer you can create your own.
- Discovery Project 5-2,
The book indicates that a nested if statement is to be used. Think about an if-else-if statement which is a form of a nested if statement. Create the if and switch files as include files (no DTD information etc.). Name them inc_BirthYear_ifelse.php and inc_BirthYear_switch.php.
To associate the Zodiac sign with the year entered by the user, the modulus operator is used in conjunction with the control structure. ($YearEntered%12). However, years that related to the Monkey result in 0 (Not the Rat as you might have expected based on the looping assignment). This means there will need to be some adjustment in the code. Determine which years/signs will result in a remainder of 0, 1, 2 etc. And then set up your control structure accordingly. (Example: 1920%12=0, 1920 is Monkey)
- Discovery Project 5-3
This was a little confusing to me, so maybe this will help.
You will create ShowSourceCode.php, but it will not do anything on its own except display a message: "There is no source file. Nothing can be displayed."
After you complete the remainder of the 5-3, click on the String Functions button, and then click on [View Source Code] The code will be highlighted with color [This is similar to the highlight.php file which was part of last week's debugging extra credit files). Last week highlight_file() was used and now highlight_string() is being used].
For the code inc_string_functions.php, you may copy/paste the code from inc_string_functions.txt which has been included in the ChineseZodiac_Chapter5Files or if you prefer you can create your own. In either case, note the use of URL tokens.
[Test the Script]
For the [Test the Script] code to be displayed within index.php, the links will need to have an URL token. An example would be
<a href="index.php?page=switch">[ Test the Script ]</a>.
Then in the switch statement located in index.php (See Project 4-4 on p. 230) add another case statement similar to the following
case 'switch':
include('includes/inc_birth_switch.php');
break;
[View Source Code]
Following the book's directions the source code will be shown in ShowSourceCode.php which in not inside of index.php. Therefore ShowSourceCode must have the DTD, Meta tags, link to CSS, and other related items. Some students have replicated index.php so it "appears" that the page is being displayed inside of index.php. Others have formatted ShowSourceCode.php with formatting consistent with their sites. Whatever your choice, add some styling so it looks like it is part of your site. You are welcome to experiment and have it actually display inside of index.php but it is not required for this assignment.
- Discovery Project 5-4
- inc_conttrol_structures.php
Again, you may copy/paste the code from inc_control_structures.txt which has been included in the ChineseZodiac_Chapter5Files or if you prefer you can create your own. Note: Chinese_Zodiac_for_loop.php was modified to inc_ChineseZodiac_ForLoop.inc in Chapter 2 and Chinese_Zodiac_While_Loop.php was modified to inc_ChineseZodiac_WhileLoop.php in Chapter 2.
- inc_files.php
Follow the same format as was used for inc_control_structures.php to modify inc_files.php. At this point will include a description and link to the proverb (Project 5.5) and images (Project 5.6) include files as described in the following instructions.
- Discovery Project 5-5
Create this file as inc_UploadProverb.php. In the Files menu includes page, create a link to [Test the Script] and [View the Source Code]. Also include a short description. The proverbs.txt file must exist on the server before running the code. Again, you may create your own or to save time, download and use proverbs.txt included in the zip file. If you need to check or change the read/write attributes on the file, refer to pages 236-237.I tested this on Apollo1 and it will allow file uploads.
- Discovery Project 5-6
Create this file as inc_UploadImage.php. Be sure to limit the file size for uploads to 5MB. In the Files menu items include a link to [Test the Script] and [View the Source Code]. Also include a short description.
- Upload the new or modified files in the ChineseZodiac folder to Apollo1
Recurring Specifications:
- XHTML must validate STRICT on all pages
- CSS must validate for CSS3 Standards
- Code must be easy to read and properly indented.
- Documentation must be appropriate and meaningful.
- Meta Tags including the following must be included on all pages. The content must be revised to information that is meaningful to the page.
<meta name="author"
content="Your Name" />
<meta name="revised" content="12/18/2015" />
<meta name="description" content="Description of web page" />
<meta name="keywords" content="Add appropriate key words" />
- Tables may not be used for general layout and only when specifically indicated in an assignment.
- JavaScript may not be used in assignments unless specifically indicated. One exception is the date late modified at the bottom of the web page.
Assignment Submission
- Follow the Assignment Submission requirements outlined in http://apollo.occc.edu/chyde/CS2623/Handouts/CS2623_CodingStandards.htm.
- Upload the files/folder to your apollo1 account.
- View the web page/s in Firefox, Chrome, Safari, and Internet Explorer.
- Revalidate and double check to make sure all items are visible from all computers.
- Note: The include files will not validate because they do not have complete DTD's and tags. However, index.php when it is displaying ANY and ALL of the dynamic content must validate.
- Submit the URL of your web page in the LMS.
- The URL will be
- http://apollo1.occc.edu/user#####/ChineseZodiac/index.php
- Submission links must open web page in a new window (not inside of MoodleRooms) and display the page (and not a directory)
- XHTML code must validate STRICT and CSS must also validate for CSS3 or earlier. The Web Developer Toolbar in Firefox will be used for grading.
- Assignments not meeting the previous requirements (opening in a new window and XHTML/CSS Validation) cannot be graded. If it is still within the late/resubmit period, they can be re-uploaded and resubmitted (10% penalty). If it is after the final deadline, the work can no longer be submitted.