CSCI 311 Setup, Code Standards, and Tech tips
This file ain't pretty, but it gets the job done. Plus it is technically correct,
which is the best kind of correct.
Contents of this file
Making public_html searchable/visible
To allow your public_html to be searchable/visible on the internets:
- navigate to your home folder (
cd ~
)
- set the home directory to be world/group searchable (
chmod go+x ./
)
- set the public_html directory as world/group searchable (
chmod go+x public_html
)
Viewing php files on campus
To access your php-based web pages on campus (and likely not via wifi)
- you must use the following URL:
wwwstu.csci.viu.ca/~USERNAME/pathToFile/info.php
This assumes:
- USERNAME is replaced by your username
- That the info.php file is in the following location:
~/public_html/pathToFile/
Directory and file permissions
Here are permission settings you'll need to properly serve files:
- The permissions for all folders in public_html (including public_html) should be:
755
- The permissions for all html, css, javascript files should be:
644
- The permissions for all server-sides scripts should be:
600
Viewing your php files off campus
In order to view your php served files off campus, you'll need to set up ssh forwarding.
Instructions
on how to do this are found here:
SSH Forwarding
Highlights:
- to login using ssh, with tunneling:
$ ssh -L 1234:wwwstu.csci.viu.ca:80 userName@otter.csci.viu.ca
- Point your browser at the tunnel:
http://localhost:1234/~userName/...
- Some browsers seem to prefer (Firefox on Mac?):
http://127.0.0.1:1234/~userName/...
Viewing PHP errors
To view php errors (in the lab)
- on command line type:
ssh wwwstu
mysql database setup
- To connect to your mysql database in the labs:
mysql -h wwwstu.csci.viu.ca -p
then enter your mysql password
- To connect to your mysql database at home (via ssh):
mysql -u root -p
- To connect to your mysql database in PHP:
<?php
$servername = "localhost";
$username = "root";
$password = "password";
$database = "dbname";
?>
- To create a database :
create database USERNAME;
--where USERNAME is replaced with your csci username
- To select the database you wish to use:
use USERNAME;
- To show the databases:
show databases;
- To show the tables in your database:
show tables;
CSCI 311 code standards
For full marks all of the following code standards must be achieved in all submissions:
- All pages are located and work as specified on csci server, and correct working link is provided with submission
- All files must include a header comment that includes, at minimum:
- your name
- csci id
- the file's purpose
- the date, and dates of any subsequent modifications
- links to any files you used online as inspiration or as resources
- All file names must be consist solely of a-z, A-Z, 0-9, _, and .
- All files and folders have correct permissions
- html/css/js/images: 644
- public folders: 755
- php and server-side scripts 600
- All files must be error free:
- All pages must have an appropriate title set
- No broken links
- Images:
- No missing images
- No hot-linked images
- Images must be licensed for reuse (or you must own them), and source must be given in header comment
- Creative Commons is a great source of licensed images.
- Accessibility needs:
- All HTML should pass the following accessibility checks (WAI Preliminary) including:
- Page Title
- Alt Text
- Text alternative for non-text content
- For non-decorative non-text content using one of the following:
WAI alt-text techniques
- Headings
- Contrast Ratio
- Resize Text
- Keyboard access and visual Focus
- All functionality available from a keyboard (for forms, mainly)
- Forms, Labels, and errors
- Moving, Flashing, or Blinking Content
- Multimedia alternatives
- Multimedia is captioned, or an alternative is provided
- Decorative non-text content has empty alt attribute
- Security Principles must be adhered to, in particular:
- least privilege: private information (db login info) and powerful code must not be visible to the outside world
- never trust the user: all user-entered data that is either saved or used in output must be sanitized and validated
- use prepared statements to access database
- hash all passwords