A) Create API with functions:
1) for user auth (quite standard):
- auth_user($user,$pass) - does check hash with hash in sql db, returns true/false
- create_user($array) - create new user in sql, returns true/false, [$array: $login(email), $pass_hash, $nick(unique), $home_city, $age, $gender], returns $uid, create folder named 'trash' under '/' for this user
- request_pass($user) - new, random password sent by email on email add. from sql, saves pass_hash in sql, returns true/false, email is external template, prepare some example, can be with 'lorem ipsum dolor' + $new_password
- update_user($uid, $array) - updates data in sql, user record, returns true/false, [$array: $uid, $home_city, $age, $gender]
2) for file manager
- get_dirs($uid) - returns array of directories from SQL (with nesting info - bulid tree in arrays of dirs id (did))
- get_files($uid,$did) - return array of files from sql from files table, return an array of files with c_date, flid and file_name
- get_files_dirs($uid) - return array of all file/dir structure (whole tree with files, all with names, ids, c_dates), from sql
- create_folder($uid,$dir,$did) - create folder $dir with parent $did
- erase_dir($uid,$did) - remove $did from sql, erase_file on all files and erase_dir on all subdirs
- get_file($uid,$flid) - get from sql info about sid_a, then by sid ask by API apropriate IP for this file, and reutrn raw content (all by streams) (server's API explained below)
- erase_file($uid,$flid) - get from sql info about sid_a, then by sid ask by API apropriate IP for removing file (server's API explained below)
- put_file($uid,$flid,$raw,$did) - get from sql info what server has highest prio, redirect stream to api there (server's API explained below)
- move_file($uid,$flid,$did) - change file locations (into $dir) -> update in sql DB,
- empty_bin($uid) - empty content of $trash -> erase all files and dirs (erase_file()) from special folder trash
API to use on servers:
- get_file($flid)
- rm_file($flid)
- put_file($flid,$raw)
D) Create appropriate SQL structure (Proposed below, but I'm open to suggestions of changing it)
1) user table:
uid int
user(nickname) varchar
email varchar
pass varchar (password hash)
home_city varchar
age int
gender bool
2) dirs table:
uid int
c_date date_time (creation date)
dir varchar (dir name)
parent int (parent dir)
did int (dirs id)
3) files table:
uid int
file_name varchar
c_date date_time (creation date)
did int (parent dir)
flid int (file's id)
sid_a int storage_a (where file is stored)
sid_b int storage_b where file is stored)
4) servers table:
sid int
status tint
ip varchar
prio int
D) Create example test files, ie. [login to view URL] and [login to view URL], with execution every single API function, for test purposes