Version 9, last updated by Xander Jansen at 07 Feb 16:52 UTC
Technical design - PHP
Directory classes
Description: Directory containing PHP classes
_includes.php
Description: Includes all other includes and sets $filesenderbase to the location of the current file.
AuthSaml.php
Description: Contains the AuthSaml class
Class AuthSaml
Description: Handles the SAML authentication
methods:
- public:
- getInstance() returns the singleton instance
- authIsAdmin() checks if a user is SAML authenticated and is administrator. returns true/false used by flex to display admin features
- sAuth() returns SAML authenticated user information as json array
- logonURL() returns logon URL from SAML and returns string for flex
- logoffURL() returns logon OFF URL from SAML and returns string for flex
- isAuth() checks SAML for authenticated user: returns true/false
AuthVoucher.php
Description:: Contains the AuthVoucher class
Class AuthVoucher
Description: voucher related functions
methods:
- public:
- getInstance() returns the singleton instance
- aVoucher() - check if a voucher exists and returns true/false
- validVoucher() - check if a voucher exists and is available and returns found/notfound/invalid/none (for flex application)
- getVoucher() - returns voucher as json array
DB.php
Description: functions for database connection. Uses config.php settings for database access.
Class DbException
extends: extends Exception
Description: Exception raised in case of database problem
Class DbConnectException
extends: DbException
Description: Exception raised in case of connect problem
Class DB
Description: Represents database connection
methods:
- public
- getInstance() returns the singleton instance
- connect() connect to the database. returns reference to postgresql connection. Raises DBConnectException in case of connect problem
- fquery() executes query and arguments (???)
- query($query) check connection and call DoQuery with $query
- buildQuery() Combine supplied arguments in one query
- doQuery($handle, $query) executes the SQL query in $query
properties:
- $connection reference to postgresql connection
DB_Input_Checks.php
Description: Contains class DB_Input_checks and some functions
- ip2long6($ipv6) converts IPv6 address to a long number
- long2ip6($ipv6long) converts long number to IPv6 address
- checkdateformat($date, $dateformat) returns date, TODO: FUNCTION NOT FINISHED
Class DB_Input_Checks
Description: Takes care of the input checks required in sql queries. Each check return the value or the report the error in errorReporting. All the Vars will go through a mysqlEscape function, in this function different ways of general string filtering can be used.
methods:
- public:
- getInstance() returns the singleton instance
- checkEmail($email) check if an email address if valid
- checkURL($url) check if a URL is valid
- checkIp($ip) returns sanitized IPv4 address
- checkIp6($ip) returns sanitized IPv6 address
- errorReport($errorMessage) empty functions used for error reporting, TODO: FUNCTION NOT FINISHED
EN_AU.php
Description: Contains class EN_AU
Class EN_AU
Description: EN_AU language file for flex application. Contains a mapping from strings used internally in the code to Australian English.
methods:
- public:
- language() returns the $lang array
properties:
- $lang dictionary with mapping from string code used in source and real language
Functions.php
Description: contains the class Functions and some functions
- formatBytes($bytes, $precision=2) Format bytes into readbable text format
- getGUID() Create Unique ID for vouchers
- sanitizeFilename($filename) Replace illegal chars with _ character in supplied filenames
- ensureSaneFileUid($fileuid) Error if fileUid doesn't look sane
Class Functions
Description:
methods:
- public:
- construct() Constructor
- getInstance() returns the singleton instance
- getStats() Return Basic Database Statistics e.g. Up xx Gb (files xx) | Down xx Gb (files xx)
- getSplash() Get Splash Screen text for all users
- getConfig() Retrun Specific config fields required by flex as JSON array
- getVouchers() Get Voucher for a specified user based on eduPersonTargetedID
- getUserFiles() Get Files for a specified user based on eduPersonTargetedID
- adminLogs() Return logs if users is admin
- adminFiles() Return Files if users is admin
- getFile($dataitem) Return file information based on filervoucheruid
- getVoucher(_$vid) Return voucher information based on filervoucheruid
- downloadedFile() Email and log when a file is downloaded
- insertFile() Insert new file or voucher
- updateFile() Update file or voucher
- deleteVoucher($fileid) Delete a voucher specified by $fileid
- closeVoucher($fileid) Close a voucher specified by $fileid
- deleteFile($fileid) Delete a voucher specified by $fileid
- getFileSize($filename) return file size of file specified by $filename
- driveSpace() Returns the total number of bytes as a float or FALSE on failure
- moveFile() move file from tmp directory to live directory and rename with Unique ID
properties:
- private:
- $saveLog reference the Log instance
- $db reference the DB instance
- $CFG reference the Config instance
- $sendmail reference to the Mail instance
- $authsaml reference to the AuthSaml instance
- $authvoucher reference to the AuthVoucher instance
- $returnFields These fields are returned without fileUID to stop unauthorized users accessing the fileUID
Log.php
Description: Contains the Class Log
Class Log
Description: Logging functions, used for logging to a log storage
methods:
- public:
- getInstance() Returns the singleton instance
- saveLog($dataitem, $logType, $message) Save Log Data
- logProcess($client, $message) logfile for individual client specific logging. calls to this function are form glex/flash if client specific logging is on
Mail.php
Description: Contains the Class Mail
Class Mail
Description: Mail functions, used for sending mail
methods:
-
public:
- getInstance() Returns the singleton instance
- sendemail($mailobject, $template) Send mail
- sendemailAdmin($message) Send admin mail messages
Directory includes
EnsureHTTPS.php
Description: Destroy session when used HTTP (not HTTPS) and ForceSSL is set in config
ErrorHandler.php
Description: Error handling functions
functions:
- customException($exception) Custom exception
- customError($errno, $errstr, $errfile, $errline) Custom error
- logEntry($message) general log function for flex logging
UTF8.php
Description: UTF-8/International Character handling related functions
functions:
- detectLatin1($string) Simple check for ISO-8859-1
- detectUTF8($string) Simple check for UTF-8
- detect_char_encoding($string) detect the required charset MIME encoding for $string, only distinguishes between US-ASCII, ISO-8859-1 and UTF-8
- mime_qp_encode_header_value($string,$charsetin,$charsetout,$crlf) QP header encoding using iconv_mime_encode
- utf8tohtml($utf8, $encodeTags) converts a UTF8-string into HTML entities
Directory config
config.php
Description: Contains the Class Config and let_to_num function
functions:
- let_to_num($v) - transforms the php.ini notation for numbers (like '2M') to an integer (210241024 in this case)
Class Config
Description: Empty class containing the loadConfig method
methods:
- public:
- getInstance() Returns the singleton instance
- loadConfig() return dictionary with all configuration variables
Directory cron
cron.php
Description: This script should be called by the cron daemon on a regular interval to remove files that have expired and close the expired files in the database
functions:
- cleanUp() Clean up missing file, removes out of date files and vouchers. return true if successful, false in case of error
- logProcess($client, $message) ??
Directory www
about.php
Description: Displays a custom About page
createxls.php
Description: return payload of htmltable POST variable into a excel document
fs_gears_upload.php
Description: Upload using gears. Data is sent in chunks from google gears and appended to the file in the temporary folder
fs_main.php
Description: Flex calls this for all requests except the actual file uploading.
$POST['call']_ defines the functions trigger from this call flex uses HTTPService calls to talk to php and returns results as text or json text e.g. <mx:HTTPService id="init_main" url="../fs_main.php{URLvid}" useProxy="false" method="POST" resultFormat="text" result="resultInit(event)" fault="resultError(event)"/>
TODO: expand
fs_uploadit.php
Description: Upload file from flex application and move into site_filestore folder. returns string: moveOk, moveError,invalidAuth back to flex
help.php
Description: Displays custom help page
index.php
Description: Entry page, checking for flash, loads images and flex app.
invalidvoucher.php
Description: Displays invalid voucher page
displayimage.php
Description: Will call function displayimage() (inside)
Functions:
- displayimage($customimage, $defaultimage) will read and print the contents of $customimage if it exists, otherwise $defaultimage
download.php
Description: download using PHP from a non web accessible folder. File is specified by a voucher ID (VID).
logout.php
Description: Displays a logout html page. Doesn't do the logout itself.
vouchererror.php
Description: Displays a invalid voucher page