Web technologies used in our thesis

Hi Guys! 🙂 Just want to share the technologies we used to build our thesis: UKnight: A Social Learning Management System. We love the web so much and the awesome technologies that can be used to build things beyond your imagination.

Our thesis is generally built using:

  1. PHP
  2. MySQL
  3. Javascript / jQuery / AJAX / JSON
  4. HTML5
  5. CSS3

We explored a lot in making the application fast and deployed in:

  1. Media Temple
  2. Amazon Web Service (EC2 Cloud) Free Tier

These are products of sleepless night of research and testing of different libraries out there in the web. Do not limit yourselves on these. Go to your favorite search engine and do find what is best for your thesis.

  1. Rochak Zip – Create Zip Files using PHP
  2. xhttp – A very good library for interacting with APIs (Facebook, Twitter, Globe Labs SMS, Crocodoc Etc.)
  3. Datatables – Table plugin for jQuery
  4. FullCalendar – Calendar plugin for jQuery
  5. PLupload – For uploading files using different technologies
  6. tcpdf – For creating PDF files using PHP! This can be used for creating reports
  7. class.upload.php – For uploading files and images with resizing, cropping and other image manipulation capabilities
  8. Twitter Bootstrap – A lot of ready made User Interface for you.
  9. Bootbox – A great partner with Twitter Bootstrap.
  10. underscore.js – We have a lot of AJAX and JSON implementation and used underscore.js for templating.
  11. Database Class
  12. URL Routing

Tips: Do mockup designs for your UI (User Interface). Literally draw it in a piece of paper or notebook and discuss as a group. In our case, we revised our UI design four times before we came up with our final user interface design. Also greatly consider UX (User Experience) for your thesis.When we are building our thesis, we didn’t consider using frameworks and built everything from scratch. If you have time to study PHP frameworks like (CodeIgniter) and implement it your thesis that would be awesome!

P.S: I dedicate this post to my thesismates (Ana and Kim):

Kickass PHP Database Class for Simple Web Apps

Every time I need to build a quick web application in PHP, I always use this simple database class. I made some modifications and added more functions to the original source of this class.

class Database
    {
    var $Host     = "localhost"; 		// Hostname of our MySQL server.
    var $Database = "";			// Logical database name on that server.
    var $User     = ""; 			// User and Password for login.
    var $Password = "";

    var $Link_ID  = 0;  				// Result of mysql_connect().
    var $Query_ID = 0;  				// Result of most recent mysql_query().
    var $Record   = array();  			// current mysql_fetch_array()-result.
    var $Row;           				// current row number.
    var $LoginError = "";

    var $Errno    = 0;  				// error state of query...
    var $Error    = "";

//-------------------------------------------
//    Connects to the database
//-------------------------------------------
    function connect()
        {
        if( 0 == $this->Link_ID )
            $this->Link_ID=mysql_connect( $this->Host, $this->User, $this->Password );
        if( !$this->Link_ID )
            $this->halt( "Link-ID == false, connect failed" );
        if( !mysql_query( sprintf( "use %s", $this->Database ), $this->Link_ID ) )
            $this->halt( "cannot use database ".$this->Database );
        } // end function connect

//-------------------------------------------
//    Queries the database
//-------------------------------------------
    function query( $Query_String )
        {
        $this->connect();
        $this->Query_ID = mysql_query( $Query_String,$this->Link_ID );
        $this->Row = 0;
        $this->Errno = mysql_errno();
        $this->Error = mysql_error();
        if( !$this->Query_ID )
            $this->halt( "Invalid SQL: ".$Query_String );
        return $this->Query_ID;
        } // end function query

//-------------------------------------------
//    If error, halts the program
//-------------------------------------------
    function halt( $msg )
        {
        printf( "
<strong>Database error:</strong> %s
n", $msg );
        printf( "<strong>MySQL Error</strong>: %s (%s)
n", $this->Errno, $this->Error );
        die( "Session halted." );
        } // end function halt

//-------------------------------------------
//    Retrieves the next record in a recordset
//-------------------------------------------
    function nextRecord()
        {
        @ $this->Record = mysql_fetch_array( $this->Query_ID );
        $this->Row += 1;
        $this->Errno = mysql_errno();
        $this->Error = mysql_error();
        $stat = is_array( $this->Record );
        if( !$stat )
            {
            @ mysql_free_result( $this->Query_ID );
            $this->Query_ID = 0;
            }
        return $stat;
        } // end function nextRecord

//-------------------------------------------
//    Retrieves a single record
//-------------------------------------------
    function singleRecord()
        {
        $this->Record = mysql_fetch_array( $this->Query_ID );
        $stat = is_array( $this->Record );
        return $stat;
        } // end function singleRecord

//-------------------------------------------
//    Returns the number of rows  in a recordset
//-------------------------------------------
    function numRows()
        {
        return mysql_num_rows( $this->Query_ID );
        } // end function numRows

//-------------------------------------------
//    Returns the Last Insert Id
//-------------------------------------------
    function lastId()
        {
        return mysql_insert_id();
        } // end function numRows

//-------------------------------------------
//    Returns Escaped string
//-------------------------------------------
	function mysql_escape_mimic($inp)
		{
		if(is_array($inp))
			return array_map(__METHOD__, $inp);
		if(!empty($inp) && is_string($inp)) {
			return str_replace(array('\\', "\0", "\n", "\r", "'", '"', "\x1a"), array('\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'), $inp);
		}
		return $inp;
		}
//-------------------------------------------
//    Returns the number of rows  in a recordset
//-------------------------------------------
    function affectedRows()
        {
			return mysql_affected_rows();
        } // end function numRows

//-------------------------------------------
//    Returns the number of fields in a recordset
//-------------------------------------------
    function numFields()
        {
			return mysql_num_fields($this->Query_ID);
        } // end function numRows

    } // end class Database
/* From: kjventura.com */

Simple Implementation

After configuring the database class, save the code above as database.php

Single Record


require_once("database.php");

$db = new Database();

$sql = "SELECT * FROM tbl_user WHERE userId='1' ";

$db->query($sql);

$db->singleRecord(); //call this if the query will only return a single row

echo $db->Record['userId']; // use the field name for example or;

echo $db->Record[0]; //use indexes

Multiple Records

require_once("database.php");

$db = new Database();

$sql = "SELECT * FROM tbl_user WHERE ";

$db->query($sql);

while($db->nextRecord()){

echo $db->Record['userId'];

}//will output all rows with the field of userId returned by the query

Other Functions


$db->lastId(); // Returns the primary key of the last inserted record

$db->numRows(); //Returns the number of rows in a recordset

$db->numFields(); //Returns the number of fields in a recordset

$db->mysql_escape_mimic($string); // Returns escaped string