/************
 * Simple File Sharer 1.72
 * 2015 Feb 6th
 * http://codecanyon.net/user/themac
 * http://codecanyon.net/item/simple-file-sharer/4562987
 ************/


/** changelog **/
  see changelog.txt for more information


 Thanks for purchasing SFS
 

 Short description
 ~~~~~~~~~~~~~~~~~
 
 SFS (Simple File Sharer) offers you the possibility run your own file sharing service out of the box
 
 Simple Installation
 

 Demo
 ~~~~
 
 Frontend: http://envato.homac.at/demos/SimpleFS/

 Backend link can be found in the frontend of the demo

 Features
 ~~~~~~~~
 
  -> Frontend
 
     * Upload single file
        ... or multiple files [New since 1.4]
     * Get download and deletion link
     * Share file via email, sender will receive upload and delete information via email
     * add message to recipients [New since 1.2]
     * Drag and Drop uploader
     * Direct Download Protection 
     * Built on Bootstrap
     * responsive [since 1.4]
     * Language switcher
     * Report file [New since 1.2]
     * Image preview [New since 1.2]
     * Password protection [New since 1.2]
     * autodeletion depending on age
     * autodeletion depending on last download [New since 1.2]
     * wait X seconds befor download [New since 1.2]
     * Supporting mod_XSendFile [New since 1.3]
     * Supporting Bandwidth Throtteling [New since 1.3]
     * maximum age [New since 1.6]
     * maximum number of downloads [New since 1.6]
     * CAPTCHA protection [New since 1.64]

  -> Backend
    
     * Short overview through all avail files
     * Possibility to delete files
     * Get statistics about upped and avail files, including historical data

  -> Goodies

     * Ajax driven contact form
     * Ajax driven abuse form
     * FAQs module

  and much more ... try it out
  

 Requirements
 ~~~~~~~~~~~~

  PHP5.x (could work with PHP4.x too -> not tested)
  mod_rewrite
  GD-Library (for the image preview and the CAPTCHA protection)
  mod_XSendFile (optional - meant for downloads of huge files)


 Installation
 ~~~~~~~~~~~~
 
 - Unzip and upload files of the htdocs to your webserver into the directory you like to have SFS installed to.
 - Take a look to you config.php and change database credentials, user, password, secretKey and other things you wanna change (more infos below)
 - Point your browser to your installation and follow the instructions.
 - Open your .htaccess and update the Error404 Part
    ErrorDocument 404 /demos/SimpleFS/notfound
 - if you're running nginx you will find useful information regarding rewrite rules during the setup routine

 
 Note
 ~~~~

 Don't forget the .htaccess file too (it's in the htdocs folder).
 If you don't see it, you're maybe working on a MAC and it's hidden (Just go to Finder > View > Show System Files)


 The config.php
 ~~~~~~~~~~~~
 
 All settings can be done in the conf.php
 
  * The timezone has to be defined in newer versions of PHP, list of timezones can be found at http://www.php.net/manual/en/timezones.php

  * projecturl and other directories will be calculated automatically but can be changed too

	maybe you like to put the uploadDir outside the webservers directory, if so please use an absolute server path
 
  * database credentials ($config->$config->db_name, $config->db_host, $config->db_user, $config->db_pass) and the prefix (will be used for the tables created by the setup)

  * $config->siteName
	Name of the project will be used allover the site and within the emails
    
  * $config->admin_mail
	target address for database and language errors

  * $config->automaileraddr
	sender address for sharing files via email
    
  * $config->contact_mail
	target address for the contact form

  * $config->secretKey
	should be changed once and will be used to create an encoded strings for the uploaded files

  * $config->maxFileSize
	the maximum file size in MB for file uploads
	the value will be recalculated and decreased if necessary, depending on PHP's
	
		- post_max_size
		- upload_max_filesize

	maybe it's necessary to adapt FcgidMaxRequestLen too (http://www.howtoforge.com/apache2-mod_fcgid-http-request-length-exceeds-maxrequestlen )

	nginx users might have to set the 

		- client_max_body_size

	in the website's config

  * $config->multiUpload
	if enabled users will be able to upload mor files by drag and drop or file select button
	true .... enabled
	false ... disabled

  * $config->maxMultiFiles
	maximum number of allowed files to upload at once, has to be a positive integer

  * $config->delDays
	Days after the file will be auto deleted (depending on date of upload or date of last download -> see delOn)
	if set to 0 it's approximately witin one day
	if set to -1 files won't be deleted automatically

  * $config->delOn
  select which date has to be used for the autodeletion calculation:

    - download ... datetime of last download
    - upload ..... datetime of upload (default)

  * $config->delSettingsByUploader
	enable deletion settings by uploader
	two options (number of downloads, age of uploaded file ... as long as the values are lower than the $config->delDays
	if $config->deldays are set to a value lower 2 the del_days cannot be set by the uploader 

  	true .... enabled
  	false ... disabled

  * $config->delDownloadsNumbers
	a list (array) of possible values for the maximum amount of downloads before autodeletion happens

  * $config->mailHeaders
	for sharing download information via email, no greater changes necessary

  * $config->downloadProtection
	if you wish you're able to enable hot linking of files by setting to

		- "IP" ... the last visiting IP of the download page is able to download the file directly
		- "SESSION" ... the last created session ID by the visitor of the download page is able to download the file directly
		- false ... no restrictions, direct downloads are possible

  * $config->passwordProtection
  uploaded files can be password protected, the password will be created automatically, can be disabled/enabled

    - true .... password protection activated
    - false ... password protection deactivated

  * $config->downloadSeconds
  seconds before download should be possible after calling download link, disabled if empty, 0 or false

  * $config->imagePreview
  auto preview of uploaded images (GD Library required)

  * $config->prevWidth, $config->prevHeight
  width and height of the preview image

  * $config->extDenied
	array of extensions that shouldn't be uploaded
	either array() for no restrictions or an array with the extensions (lowercase)

  * $config->extAllowed
	array of extensions that are allowed to upload
	either array() for all extensions (expcept the denied ones) or an array with the extensions (lowercase)  

  * $config->downloadSeconds
  Possibility to add "wait x seconds befor download" function to download page, 0 disables the waiting functions, any higher value enables it

  * $config->imagePreview = true;
  (requires GD library) if enabled, a preview of an upped image will be displayed on the downloadpage

  * $config->prevWidth / $config->prevHeight
  width and height of the preview image 

  * $config->XSendFile
  If your apache webserver supports XSendFile you could/should enable this option, but be aware of the settings (either XSendFileAllowAbove in the .htaccess or XSendFilePath in the virtual host config) - will be disabled if bandwidth throtteling is enabled
  more information in the config.php, the .htaccess and on https://tn123.org/mod_xsendfile/

  * $config->kbps
  kilobyte per second bandwidth throtteling, because of some calculations the value won't be exact, so play a bit with the values
  0 or false disables the bandwidth throtteling

  * $config->user, $config->pass
	for the admin interface

  * $config->version
	SFS version number
 
  * $config->lang (language switcher)
	if you add new language folder you have to increase/modify the array in the language switcher section
    Default Language
	Set the system to the language of your choice, english and german (de-Sie, de-Du) is already available
    	The language files can be found in the lang directory
    	If you like to add a new language just copy one of the avail directories (e.g. en) to your new language (e.g. nl or klingon :) )



 Administration
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 The simple administration is available on sfs-admin.php
 
 Default-User: admin
 Default-Pass: pass
 
 These values have to be changed in the conf.php (user and pass) 

 ERROR 404 messages
 ~~~~~~~~~~~~~~~~~~

 to get the nice built in Error 404 pages please take a look to the .htaccess and change the path of the Error document


 sfs.min.js
 ~~~~~~~~~~

 there is an unminified and commented version of sfs.min.js in the same folder (js/)

 i.e. called sfs.1.6.js


 sfs.min.css
 ~~~~~~~~~~

 there is an unminified and commented version of sfs.min.css in the same folder (css/)

 i.e. called sfs.1.6.css

 
 Goodie 1: Ajax Contact Form
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 can be found in the contact.php and has a JS Fallback


 Goodie 2: FAQs
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 the output can be found in the faqs.php
 data is stored in each language directory (lang/.../faqs.lang.php)


 Terms and Conditions for your site
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 data is stored in each language directory (lang/.../terms.lang.php)

 
 Style
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 SFS is built on bootstrap and uses bootswatch' cerulean theme

 Some issues
 ~~~~~~~~~~~
 
 Icons on Landing-Page by IconEden (Bright Icons) (http://www.iconfinder.com/iconsets/ie_Bright)
 jQuery: http://jquery.com/
 jQuery File Upload: http://blueimp.github.com/jQuery-File-Upload/
 jQuery countDown: http://davidwalsh.name/jquery-countdown-plugin
 Bootstrap: http://getbootstrap.com/2.3.2/
 Bootswatch' Cerulean: http://bootswatch.com/2/cerulean/
 PNotify: http://pinesframework.org/pnotify/
 Datatables: http://datatables.net
 bootbox modals: http://bootboxjs.com/
 Flot charts: http://www.flotcharts.org/
 mod_xsendfile for Apache2/Apache2.2: https://tn123.org/mod_xsendfile/
 CAPTCHA class from http://phpcaptcha.org