Saturday, April 6, 2013

A dissection of Robins Nest

  • index.php
    • Uses:
      •  rnheader.php
    • Purpose:
      • prints to screen Welcome, please sign in or sign up to continue
  • rncheckuser.php
    • Uses:
      • rnfunctions.php
    • Purpose: 
      • Checks if username is available, prints the results to the webpage
  • rnfriends.php
    • Uses:
      • rnheader.php
    • Purpose: 
      • if user is not logged in
        • Will send  a "You must log in" web page
      • fetch the users friends
        • puts followers into an array
        • puts mutual friends into an array
        • puts friends into an array
  • rnfunctions.php
    • Uses:
      • None
    • Purpose:
      • provides functions for the SQL interface 
    • Functions:
      • Create Table
        • createTable($name, $query)
        • echos table already exists, or creates table $name
      • Table Exists
        • tableExists($name)
        • returns the number of rows as a result of the query: Show Tables Like '$name'
      • Query MySQL
        • queryMysql($query)
        • Queries the database
        • returns the result
      • Destroy Session
        • destroySession()
        • destroys the current session
      • Sanitize String
        • sanitizeString($var)
        • sanitizes tags, html entities, and slashes to prevent SQL injection attacks
        • returns mysql_real_escape_string($var)
      • show Profile
        • showProfile($user)
        • if picture had been uploaded, puts picture on screen
        • displays user information saved in the database
  • rnheader.php
    • Uses:
      • rnfunctions.php
    • Purpose: 
      • calls session_start()
      • if user is logged in,
        • displays links for navigation
        • Home
        • Members
        • Friends
        • Messages
        • Profile
        • Log out
      • if user is not logged in,
        • Home
        • Sign up
        • Log in
  • rnlogin.php
    • Uses:
      • rnheader.php
    • Purpose: 
      • gets $user and $pass
      • sanitizes the strings
      • gets checks username / pass against the database
      • if correct prompts the user to click on link
  • rnlogout.php
    • Uses:
      • rnheader.php
    • Purpose 
      • calls destroySession()
      • logs the user out
  • rnmembers.php
    • Uses:
      • rnheader.php
    • Purpose: 
      • if user is not logged in, users are denied access
      • view users profile
      • add a friend
      • remove a friend
      • displays other members and their friendship status
  • rnmessages.php
    • Uses:
      • rnheader.php
    • Purpose:
      • if user is not logged in, users are denied access
      • provides information on when information was viewed
      • provides creation of messages
      •  erasing of messages
      • editing of messages
  • rnprofile.php
    • Uses:
      • rnheader.php
    • Purpose: 
      • if user is not logged in, users are denied access
      • provides the editing of profile
      • provides uploading of images as the user profile
  • rnsetup.php
    • Uses:
      • rnfunctions.php
    • Purpose 
      • creates the tables needed in the database
  • rnsignup_yui.php
    • Uses:
      • rnheader.php
    • Purpose:
      • javascript that checks username input
      • logs out user if already logged in
      • checks to see if both fields were entered
      • checks if username already exists
      • adds user to database
  • rnsignup.php
    • Uses:
      • rnheader.php
    • Purpose:
      • javascript that validates user input
      • creates a user based on input

Php and HTML

PHP and HTML

<a href="https://yoursite address here">Name of your site</a> -adds a link to the given site address
<? php -starts the php interpreter
?> - stops the php interpreter
<title>Title</title> - sets the title of your web page
<br /> -line break

Script to start a SQL session:
<?php                                   -Start the interpreter
$dbhost = 'localhost';           -sets the address for the database
$dbname = 'publications';    - Selects the name of the database to use
$dbuser = 'root';                  - Selects the database user name to use
$dbpass = 'root';                  - Selects the password of the database to use 

mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error()); -connects to the database using    credentials, if unable to connect script
will end.
mysql_select_db($dbname) or die(mysql_error()); - selects the database to use in mysql, if unable to connect, script will end.

?>