├── bkdr ├── extensions │ └── placeholder.txt ├── api │ ├── core.db │ ├── updateDB.php │ ├── controller │ │ ├── config.php │ │ ├── dir.php │ │ ├── update.php │ │ ├── session.php │ │ ├── settings.php │ │ ├── ext.php │ │ ├── file.php │ │ └── users.php │ ├── .htaccess │ ├── index.php │ ├── models │ │ ├── configmanagement.php │ │ ├── settingsmanagement.php │ │ ├── directorymanagement.php │ │ ├── extmanagement.php │ │ ├── updatemanagement.php │ │ ├── usermanagement.php │ │ └── filemanagement.php │ ├── controller.php │ ├── access.php │ ├── router.php │ └── install.php ├── assets │ ├── img │ │ ├── favicon.ico │ │ ├── loading_blocks.svg │ │ ├── bkdr_logo_pro_black.svg │ │ └── bkdr_fullname_black.svg │ └── fonts │ │ ├── FontAwesome.otf │ │ ├── fontawesome-webfont.eot │ │ ├── fontawesome-webfont.ttf │ │ ├── fontawesome-webfont.woff │ │ └── fontawesome-webfont.woff2 ├── update │ ├── readme.md │ └── sample_config.json ├── dir-lister │ ├── config.php │ ├── fileTypes.php │ └── DirectoryLister.php └── index.php ├── screenshot_v2-2.png ├── README.md └── LICENSE /bkdr/extensions/placeholder.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bkdr/api/core.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RecaMedia/Backdoor-Release/HEAD/bkdr/api/core.db -------------------------------------------------------------------------------- /screenshot_v2-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RecaMedia/Backdoor-Release/HEAD/screenshot_v2-2.png -------------------------------------------------------------------------------- /bkdr/assets/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RecaMedia/Backdoor-Release/HEAD/bkdr/assets/img/favicon.ico -------------------------------------------------------------------------------- /bkdr/assets/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RecaMedia/Backdoor-Release/HEAD/bkdr/assets/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /bkdr/update/readme.md: -------------------------------------------------------------------------------- 1 | ## Update Directory 2 | 3 | Leave this directory as is, as it is used to copy and move files while updating Backdoor. -------------------------------------------------------------------------------- /bkdr/assets/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RecaMedia/Backdoor-Release/HEAD/bkdr/assets/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /bkdr/assets/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RecaMedia/Backdoor-Release/HEAD/bkdr/assets/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /bkdr/assets/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RecaMedia/Backdoor-Release/HEAD/bkdr/assets/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /bkdr/assets/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RecaMedia/Backdoor-Release/HEAD/bkdr/assets/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /bkdr/update/sample_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "backdoorDir": "bkdr", 3 | "backdoorDomain": "http://yourdomain.com", 4 | "changeRoot": "", 5 | "defaultTheme": "monokai", 6 | "domainIsBackdoorApp": true, 7 | "fontSize": "14px", 8 | "lineWrapping": true, 9 | "multiViewColors": [ 10 | "#007fff", 11 | "#04ff00", 12 | "#ff8300" 13 | ], 14 | "tabSize": 2 15 | } -------------------------------------------------------------------------------- /bkdr/api/updateDB.php: -------------------------------------------------------------------------------- 1 | db->prepare("UPDATE Settings SET SettingValue=:value WHERE SettingType=:type"); 3 | $settingsQuery->bindValue(':value','v2.0.6'); 4 | $settingsQuery->bindValue(':type','bkdr_version'); 5 | $result = $settingsQuery->execute(); 6 | 7 | if ($result) { 8 | $process_msg[] = "Database successfully updated."; 9 | } else { 10 | $process_msg[] = "There was an error updating the database."; 11 | } 12 | ?> -------------------------------------------------------------------------------- /bkdr/api/controller/config.php: -------------------------------------------------------------------------------- 1 | loadModel('configmanagement'); 17 | echo json_encode($cm->getConfig()); 18 | } 19 | } 20 | 21 | ?> -------------------------------------------------------------------------------- /bkdr/api/controller/dir.php: -------------------------------------------------------------------------------- 1 | api_key && $this->api_member_key) { 18 | $dm = $this->loadModel('directorymanagement'); 19 | $return = $dm->get(); 20 | } else { 21 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 22 | } 23 | 24 | echo json_encode($return); 25 | } 26 | } -------------------------------------------------------------------------------- /bkdr/api/controller/update.php: -------------------------------------------------------------------------------- 1 | api_key && $this->api_member_key) { 18 | $um = $this->loadModel('updatemanagement'); 19 | $return = $um->processUpdate(); 20 | } else { 21 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 22 | } 23 | 24 | echo json_encode($return); 25 | } 26 | } -------------------------------------------------------------------------------- /bkdr/assets/img/loading_blocks.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bkdr/api/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews 4 | 5 | # Activates URL rewriting (like myproject.com/controller/action/1/2/3) 6 | RewriteEngine On 7 | 8 | # Disallows others to look directly into /public/ folder 9 | Options -Indexes 10 | 11 | # When using the script within a sub-folder, put this path here, like /mysubfolder/ 12 | # If your app is in the root of your web folder, then leave it commented out 13 | # RewriteBase /bkdr2/api/ 14 | 15 | # Don't fix direct file links & check for post 16 | RewriteCond %{REQUEST_METHOD} !=POST 17 | RewriteCond %{REQUEST_FILENAME} !-d 18 | RewriteCond %{REQUEST_FILENAME} !-f 19 | RewriteCond %{REQUEST_FILENAME} !-l 20 | 21 | # Add trailing slash if needed 22 | RewriteCond %{REQUEST_URI} !(.*)/$ 23 | RewriteRule ^(.*)$ $1/ [L,R=301] 24 | 25 | # Don't fix direct file links & Capture all 26 | RewriteCond %{REQUEST_FILENAME} !-d 27 | RewriteCond %{REQUEST_FILENAME} !-f 28 | RewriteCond %{REQUEST_FILENAME} !-l 29 | RewriteRule ^(.+)$ index.php?request=$1 [QSA,L] 30 | 31 | -------------------------------------------------------------------------------- /bkdr/api/controller/session.php: -------------------------------------------------------------------------------- 1 | api_key) { 18 | $return = array( 19 | 'session' => $this->sess 20 | ); 21 | } else { 22 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 23 | } 24 | 25 | echo json_encode($return); 26 | } 27 | 28 | public function signedin(){ 29 | 30 | if ($this->api_key) { 31 | $return = array( 32 | 'key' => (isset($_SESSION['bdmemberkey'])?$_SESSION['bdmemberkey']:"") 33 | ); 34 | } else { 35 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 36 | } 37 | 38 | echo json_encode($return); 39 | } 40 | } 41 | 42 | ?> -------------------------------------------------------------------------------- /bkdr/api/index.php: -------------------------------------------------------------------------------- 1 | strtotime(date('Y-m-d', time()). '00:00:00'), 21 | "baseDir" => $base_dir, 22 | "installed" => (count($public_config)==0?false:true) 23 | ); 24 | 25 | $complete_config = array_merge($private_config,$public_config); 26 | $configurations = (object)$complete_config; 27 | 28 | date_default_timezone_set('America/New_York'); 29 | 30 | require 'access.php'; 31 | require $base_dir.'/controller.php'; 32 | require 'router.php'; 33 | 34 | $app = new Router(); 35 | ?> -------------------------------------------------------------------------------- /bkdr/api/models/configmanagement.php: -------------------------------------------------------------------------------- 1 | db = $db; 17 | $this->domain = $domain; 18 | $this->config = $config; 19 | } 20 | 21 | private function configEncrypt(){ 22 | $config_array = (array)$this->config; 23 | 24 | // Note: MCRYPT_RIJNDAEL_128 is compatible with AES (all key sizes) 25 | // $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_RAND); 26 | // $ciphertext = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, "Kx#MX!83@1zQ2oC4", json_encode($config_array), MCRYPT_MODE_CBC, $iv); 27 | 28 | // return array( 29 | // "part1" => base64_encode($iv), 30 | // "part2" => base64_encode($ciphertext) 31 | // ); 32 | 33 | return array( 34 | "config" => base64_encode(json_encode($config_array)) 35 | ); 36 | } 37 | 38 | public function getConfig(){ 39 | return $this->configEncrypt(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /bkdr/api/controller/settings.php: -------------------------------------------------------------------------------- 1 | api_key && $this->api_member_key) { 18 | $se = $this->loadModel('settingsmanagement'); 19 | $return = $se->getSettings(); 20 | } else { 21 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 22 | } 23 | 24 | echo json_encode($return); 25 | } 26 | 27 | public function open(){ 28 | 29 | if ($this->api_key) { 30 | $se = $this->loadModel('settingsmanagement'); 31 | $return = $se->getOpenSettings(); 32 | } else { 33 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 34 | } 35 | 36 | echo json_encode($return); 37 | } 38 | 39 | public function update() { 40 | 41 | if ($this->api_key && $this->api_member_key) { 42 | $se = $this->loadModel('settingsmanagement'); 43 | $return = $se->updateSettings(); 44 | } else { 45 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 46 | } 47 | 48 | echo json_encode($return); 49 | } 50 | } -------------------------------------------------------------------------------- /bkdr/dir-lister/config.php: -------------------------------------------------------------------------------- 1 | true, 9 | 'list_folders_first' => true, 10 | 'list_sort_order' => 'natcasesort', 11 | 'external_links_new_window' => true, 12 | 13 | // Hidden files 14 | 'hidden_files' => array( 15 | '.ht*', 16 | '*/.ht*', 17 | '.git', 18 | '.gitignore', 19 | $public_config['backdoorDir'], 20 | $public_config['backdoorDir'].'/*', 21 | 'node_modules', 22 | 'node_modules/*' 23 | ), 24 | 25 | // Files that, if present in a directory, make the directory 26 | // a direct link rather than a browse link. 27 | 'index_files' => array( 28 | 'index.htm', 29 | 'index.html', 30 | 'index.php' 31 | ), 32 | 33 | // File hashing threshold 34 | 'hash_size_limit' => 268435456, // 256 MB 35 | 36 | // Custom sort order 37 | 'reverse_sort' => array( 38 | // 'path/to/folder' 39 | ), 40 | 41 | // Allow to download directories as zip files 42 | 'zip_dirs' => false, 43 | 44 | // Stream zip file content directly to the client, 45 | // without any temporary file 46 | 'zip_stream' => true, 47 | 48 | 'zip_compression_level' => 0, 49 | 50 | // Disable zip downloads for particular directories 51 | 'zip_disable' => array( 52 | // 'path/to/folder' 53 | ), 54 | 55 | ); 56 | -------------------------------------------------------------------------------- /bkdr/api/controller.php: -------------------------------------------------------------------------------- 1 | base_dir =& $base_dir; 30 | $this->config =& $configurations; 31 | $this->access = new Access(); 32 | 33 | $this->db = $this->access->db; 34 | 35 | $this->api_key = $this->access->api_key; 36 | $this->api_member_key = $this->access->api_member_key; 37 | 38 | $this->sess = $this->access->sess; 39 | } 40 | 41 | /*------------- Basic -------------*/ 42 | public function encrypt($String){ 43 | return base64_encode($String); 44 | } 45 | 46 | public function decrypt($String){ 47 | return base64_decode($String); 48 | } 49 | 50 | /*------------- Other -------------*/ 51 | public function loadModel($model_name){ 52 | require $this->base_dir.'/models/' . strtolower($model_name) . '.php'; 53 | // return new model (and pass the database connection to the model) 54 | return new $model_name($this->db,$this->domain,$this->config); 55 | } 56 | } -------------------------------------------------------------------------------- /bkdr/api/controller/ext.php: -------------------------------------------------------------------------------- 1 | api_key && $this->api_member_key) { 18 | $em = $this->loadModel('extmanagement'); 19 | $return = $em->get(); 20 | } else { 21 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 22 | } 23 | 24 | echo json_encode($return); 25 | } 26 | 27 | public function toggle(){ 28 | 29 | if ($this->api_key && $this->api_member_key) { 30 | $em = $this->loadModel('extmanagement'); 31 | $return = $em->toggleExt(); 32 | } else { 33 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 34 | } 35 | 36 | echo json_encode($return); 37 | } 38 | 39 | public function html(){ 40 | 41 | if ($this->api_key && $this->api_member_key) { 42 | $em = $this->loadModel('extmanagement'); 43 | $return = $em->getExtHtml(); 44 | } else { 45 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 46 | } 47 | 48 | echo json_encode($return); 49 | } 50 | 51 | public function remove(){ 52 | 53 | if ($this->api_key && $this->api_member_key) { 54 | $em = $this->loadModel('extmanagement'); 55 | $return = $em->removeExt(); 56 | } else { 57 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 58 | } 59 | 60 | echo json_encode($return); 61 | } 62 | } -------------------------------------------------------------------------------- /bkdr/index.php: -------------------------------------------------------------------------------- 1 | 27 | 28 | 29 | 30 | Backdoor v2 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 43 | 44 | 45 |
46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /bkdr/api/models/settingsmanagement.php: -------------------------------------------------------------------------------- 1 | db = $db; 17 | $this->domain = $domain; 18 | $this->config = $config; 19 | } 20 | 21 | public function getSettings(){ 22 | $settingsQuery = $this->db->prepare("SELECT * FROM Settings"); 23 | $result = $settingsQuery->execute(); 24 | $allSettings = array(); 25 | 26 | while ($row = $result->fetchArray(SQLITE3_ASSOC)) { 27 | $this_value = $row['SettingValue'] == "false" ? false : ($row['SettingValue'] == "true" ? true : $row['SettingValue']); 28 | $allSettings[$row['SettingType']] = $this_value; 29 | 30 | } 31 | 32 | return array( 33 | 'success' => true, 34 | 'statusMessage' => "Retrieved all settings.", 35 | 'settings' => $allSettings 36 | ); 37 | } 38 | 39 | public function getOpenSettings(){ 40 | $settingsQuery = $this->db->prepare("SELECT * FROM Settings WHERE Open=1"); 41 | $result = $settingsQuery->execute(); 42 | $allSettings = array(); 43 | 44 | while ($row = $result->fetchArray(SQLITE3_ASSOC)) { 45 | $this_value = $row['SettingValue'] == "false" ? false : ($row['SettingValue'] == "true" ? true : $row['SettingValue']); 46 | $allSettings[$row['SettingType']] = $this_value; 47 | } 48 | 49 | return array( 50 | 'success' => true, 51 | 'statusMessage' => "Retrieved all settings.", 52 | 'settings' => $allSettings 53 | ); 54 | } 55 | 56 | public function updateSettings(){ 57 | $type = (isset($_POST['type']) ? $_POST['type']:""); 58 | $value = (isset($_POST['value']) ? $_POST['value']:""); 59 | 60 | $settingsQuery = $this->db->prepare("UPDATE Settings SET SettingValue=:value WHERE SettingType=:type"); 61 | $settingsQuery->bindValue(':value',$value); 62 | $settingsQuery->bindValue(':type',$type); 63 | $result = $settingsQuery->execute(); 64 | 65 | if ($result) { 66 | return array( 67 | 'success' => true, 68 | 'statusMessage' => "Settings successfully updated.", 69 | 'settings' => $this->getSettings()['settings'] 70 | ); 71 | } else { 72 | return array( 73 | 'success' => false, 74 | 'statusMessage' => "There was an error updating settings." 75 | ); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Backdoor - Browser Based Code Editor 2 | 3 | Backdoor is a standalone browser based code editor that operates on a LASP (Linux, Apache, SQLite, PHP) server, providing all basic development tools with the ability of adding new features via extensions and services. This is the Backdoor-Release __*COMPILED*__ version of Backdoor. For the development version of Backdoor, please visit the [Backdoor Repo](https://github.com/RecaMedia/Backdoor). 4 | 5 | ![Backdoor][screenshot] 6 | 7 | ---- 8 | 9 | ### Requirements 10 | 11 | Make sure you have the following PHP modules installed and functioning: `Sqlite3`, `Mcrypt`. The `.htacces*` files will need to be allowed to redirect within the `bkdr` directory and subdirectories, check your vhost configuration to allow this. **PLEASE NOTE** this was originally intended to work off of Apache. However, if you're using **Nginx**, you will have to modify the server.conf file to reflect the configurations found in `/bkdr/api/.htaccess`, by using a [converter](https://winginx.com/en/htaccess) tool. 12 | 13 | Once you've uploaded the `bkdr` directory to your server, you'll need to change ownership and permissions so the application can function properly. Use the following commands to do this: 14 | 15 | `chown -R www-data:www-data /path/to/bkdr` 16 | 17 | `chmod 775 -R /path/to/bkdr` 18 | 19 | ### Installation 20 | 21 | To begin installation, visit the URL which will point you to the `bkdr` directory (__http://localhost/bkdr/__ or __http://bkdr.mydomain.com/__). The installation wizard should prepopulate some of the inputs for you. Make sure the folder name of the Backdoor application is correct as this may effect some functionality. The default folder name is `bkdr`, unless you change it. Add the super user email address as required. Only change the root path *IF* the root directory in which *bkdr* live in, is not the directory you wish Backdoor to access. If this is the case, you'll need to start your relative path from the parent directory of `bkdr`. Once you're done, submit the form and you'll be notified if installation was successful. If you have errors, please look at your server logs for details. 22 | 23 | ### Reporting 24 | 25 | Please visit the [Issues](https://github.com/RecaMedia/Backdoor-Release/issues) tab if you've run into any problems with installation. If you're unable to find answers regarding your issue, feel free to open a new issue and I'll do my best to help resolve the problem. This project is being maintained, however, there is only one contributor at the moment so responses may not be as rapid. 26 | 27 | ### License 28 | 29 | GNU Affero General Public License v3.0 30 | 31 | ### Copyright 32 | 33 | Copyright (C) 2017 Shannon Reca 34 | 35 | [screenshot]: /screenshot_v2-2.png "Backdoor v2" 36 | -------------------------------------------------------------------------------- /bkdr/api/access.php: -------------------------------------------------------------------------------- 1 | open($base_dir.'/core.db'); 17 | } 18 | } 19 | 20 | class Access { 21 | public $db = null; 22 | public $config = null; 23 | 24 | public $api_key = false; 25 | public $api_member_key = false; 26 | 27 | public $sess = null; 28 | 29 | private $keys = null; 30 | private $base_dir = null; 31 | 32 | public function __construct(){ 33 | global $base_dir; 34 | global $configurations; 35 | $this->base_dir =& $base_dir; 36 | $this->config =& $configurations; 37 | 38 | // Set API access. 39 | if (!function_exists('apache_request_headers')) { 40 | $headers = $this->apache_request_headers(); 41 | } else { 42 | $headers = apache_request_headers(); 43 | } 44 | 45 | // Kill API if key doesn't match. 46 | if (isset($headers["bd2-api-key"])) { 47 | if ($headers["bd2-api-key"] != $this->config->apiKey) { 48 | $return = array('success' => false,'statusMessage' => 'Error with API access.'); 49 | $error = json_encode($return); 50 | die($error); 51 | } else { 52 | $this->api_key = true; 53 | } 54 | } 55 | 56 | if (isset($headers["session"])) { 57 | $this->sess = $headers["session"]; 58 | session_id($this->sess); 59 | session_start(); 60 | } else { 61 | session_start(); 62 | $this->sess = session_id(); 63 | } 64 | 65 | // session_save_path('/'); 66 | 67 | // open db connection, set domain var and login key. 68 | $this->openDatabaseConnection(); 69 | 70 | if ( 71 | isset($_SESSION['bdmemberkey']) && isset($headers["member-api-key"]) && 72 | $_SESSION['bdmemberkey'] == $headers["member-api-key"] 73 | ) { 74 | $this->api_member_key = true; 75 | } 76 | } 77 | 78 | /*------------- Private -------------*/ 79 | private function apache_request_headers() { 80 | $arh = array(); 81 | $rx_http = '/\AHTTP_/'; 82 | foreach($_SERVER as $key => $val) { 83 | if( preg_match($rx_http, $key) ) { 84 | $arh_key = preg_replace($rx_http, '', $key); 85 | $rx_matches = array(); 86 | $rx_matches = explode('_', $arh_key); 87 | if( count($rx_matches) > 0 and strlen($arh_key) > 2 ) { 88 | foreach($rx_matches as $ak_key => $ak_val) $rx_matches[$ak_key] = ucfirst($ak_val); 89 | $arh_key = implode('-', $rx_matches); 90 | } 91 | $arh[$arh_key] = $val; 92 | } 93 | } 94 | return( $arh ); 95 | } 96 | 97 | private function openDatabaseConnection(){ 98 | $this->db = new DB(); 99 | } 100 | } 101 | ?> -------------------------------------------------------------------------------- /bkdr/api/models/directorymanagement.php: -------------------------------------------------------------------------------- 1 | db = $db; 18 | $this->domain = $domain; 19 | $this->config = $config; 20 | // Include the DirectoryLister class 21 | require_once('../dir-lister/DirectoryLister.php'); 22 | 23 | // Initialize the DirectoryLister object 24 | $this->lister = new DirectoryLister(); 25 | 26 | $this->extensions_dir = $this->config->backdoorDir . DIRECTORY_SEPARATOR . "extensions"; 27 | 28 | // Restrict access to current directory 29 | getcwd(); 30 | chdir(".." . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . $this->config->changeRoot); 31 | ini_set('open_basedir', getcwd()); 32 | // dirname(dirname(dirname(dirname(__FILE__)))) 33 | } 34 | 35 | public function get() { 36 | // Return file hash 37 | if (isset($_GET['hash'])) { 38 | // Get file hash array and JSON encode it 39 | $hashes = $this->lister->getFileHash($_GET['hash']); 40 | $data = json_encode($hashes); 41 | // Return the data 42 | die($data); 43 | } 44 | 45 | // Initialize the directory array 46 | if (isset($_POST['dir'])) { 47 | $dir_array = $this->lister->listDirectory($_POST['dir']); 48 | } else { 49 | $dir_array = $this->lister->listDirectory('.'); 50 | } 51 | 52 | $breadcrumbs = $this->lister->listBreadcrumbs(); 53 | $sys_messages = $this->lister->getSystemMessages(); 54 | 55 | if (!$sys_messages) { 56 | $sys_messages = null; 57 | } 58 | 59 | $browser_data = array( 60 | 'breadcrumbs' => $breadcrumbs 61 | ); 62 | 63 | $files_array = array(); 64 | 65 | foreach ($dir_array as $name => $file_info) { 66 | if (is_file($file_info['file_path'])) { 67 | $is_folder = false; 68 | } else { 69 | $is_folder = true; 70 | } 71 | 72 | $files_array[$name] = array( 73 | 'filename' => $name, 74 | 'icon' => $file_info['icon_class'], 75 | 'url' => $file_info['url_path'], 76 | 'path' => $file_info['file_path'], 77 | 'size' => $file_info['file_size'], 78 | 'lastmodified' => $file_info['mod_time'], 79 | 'sort' => $file_info['sort'], 80 | 'handler' => $file_info['handler'], 81 | 'isfolder' => $is_folder, 82 | 'permission' => $file_info['permission'] 83 | ); 84 | } 85 | 86 | $browser_data['files'] = $files_array; 87 | $directory = json_decode(json_encode($browser_data)); 88 | 89 | return array( 90 | 'success' => true, 91 | 'statusMessage' => "Directory information found.", 92 | 'directory' => $directory 93 | ); 94 | } 95 | } -------------------------------------------------------------------------------- /bkdr/api/router.php: -------------------------------------------------------------------------------- 1 | processUrl(); 25 | 26 | // check for controller: does such a controller exist ? 27 | if (file_exists('./controller/'.$this->url_controller.'.php')) { 28 | 29 | // if so, then load this file and create this controller 30 | // example: if controller would be "car", then this line would translate into: $this->car = new car(); 31 | require './controller/' . $this->url_controller . '.php'; 32 | $this->url_controller = new $this->url_controller(); 33 | 34 | // check for method: does such a method exist in the controller ? 35 | if (method_exists($this->url_controller, $this->url_action)) { 36 | 37 | // call the method and pass the arguments to it 38 | if (isset($this->url_parameter_3)) { 39 | // will translate to something like $this->home->method($param_1, $param_2, $param_3); 40 | $this->url_controller->{$this->url_action}($this->url_parameter_1, $this->url_parameter_2, $this->url_parameter_3); 41 | } elseif (isset($this->url_parameter_2)) { 42 | // will translate to something like $this->home->method($param_1, $param_2); 43 | $this->url_controller->{$this->url_action}($this->url_parameter_1, $this->url_parameter_2); 44 | } elseif (isset($this->url_parameter_1)) { 45 | // will translate to something like $this->home->method($param_1); 46 | $this->url_controller->{$this->url_action}($this->url_parameter_1); 47 | } else { 48 | // if no parameters given, just call the method without parameters, like $this->home->method(); 49 | $this->url_controller->{$this->url_action}(); 50 | } 51 | } else { 52 | // default/fallback: call the index() method of a selected controller 53 | if (isset($this->url_action)) { 54 | $this->url_controller->index($this->url_action); 55 | } else { 56 | $this->url_controller->index(); 57 | } 58 | } 59 | }else{ 60 | $return = array('success' => false,'statusMessage' => 'Error making request.'); 61 | 62 | echo json_encode($return); 63 | } 64 | } 65 | 66 | // Get and process the URL 67 | private function processUrl(){ 68 | if (isset($_GET['request'])){ 69 | 70 | // split URL 71 | $url = rtrim($_GET['request'], '/'); 72 | $url = filter_var($url, FILTER_SANITIZE_URL); 73 | $url = explode('/', $url); 74 | 75 | // Put URL parts into according properties 76 | // By the way, the syntax here is just a short form of if/else, called "Ternary Operators" 77 | // @see http://davidwalsh.name/php-shorthand-if-else-ternary-operators 78 | $this->url_controller = (isset($url[0]) ? $url[0] : null); 79 | $this->url_action = (isset($url[1]) ? $url[1] : null); 80 | $this->url_parameter_1 = (isset($url[2]) ? $url[2] : null); 81 | $this->url_parameter_2 = (isset($url[3]) ? $url[3] : null); 82 | $this->url_parameter_3 = (isset($url[4]) ? $url[4] : null); 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /bkdr/api/controller/file.php: -------------------------------------------------------------------------------- 1 | api_key && $this->api_member_key) { 18 | $fm = $this->loadModel('filemanagement'); 19 | $return = $fm->get(); 20 | } else { 21 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 22 | } 23 | 24 | echo json_encode($return); 25 | } 26 | 27 | public function copy(){ 28 | 29 | if ($this->api_key && $this->api_member_key) { 30 | $fm = $this->loadModel('filemanagement'); 31 | $return = $fm->process('copyFile'); 32 | } else { 33 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 34 | } 35 | 36 | echo json_encode($return); 37 | } 38 | 39 | public function rename(){ 40 | 41 | if ($this->api_key && $this->api_member_key) { 42 | $fm = $this->loadModel('filemanagement'); 43 | $return = $fm->process('renameFile'); 44 | } else { 45 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 46 | } 47 | 48 | echo json_encode($return); 49 | } 50 | 51 | public function delete(){ 52 | 53 | if ($this->api_key && $this->api_member_key) { 54 | $fm = $this->loadModel('filemanagement'); 55 | $return = $fm->process('deleteFile'); 56 | } else { 57 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 58 | } 59 | 60 | echo json_encode($return); 61 | } 62 | 63 | public function create($type){ 64 | 65 | if ($this->api_key && $this->api_member_key) { 66 | $fm = $this->loadModel('filemanagement'); 67 | if ($type == "folder") { 68 | $return = $fm->process('newFolder'); 69 | // } else if ($type == "folder") { 70 | // $return = $fm->process('newFolder'); 71 | } else { 72 | $return = array('success' => false,'statusMessage' => 'Type not provided.'); 73 | } 74 | } else { 75 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 76 | } 77 | 78 | echo json_encode($return); 79 | } 80 | 81 | public function permission(){ 82 | 83 | if ($this->api_key && $this->api_member_key) { 84 | $fm = $this->loadModel('filemanagement'); 85 | $return = $fm->process('changePermission'); 86 | } else { 87 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 88 | } 89 | 90 | echo json_encode($return); 91 | } 92 | 93 | public function save(){ 94 | 95 | if ($this->api_key && $this->api_member_key) { 96 | $fm = $this->loadModel('filemanagement'); 97 | $return = $fm->process('saveFile'); 98 | } else { 99 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 100 | } 101 | 102 | echo json_encode($return); 103 | } 104 | 105 | public function upload(){ 106 | 107 | if ($this->api_key && $this->api_member_key) { 108 | $fm = $this->loadModel('filemanagement'); 109 | $return = $fm->process('upload'); 110 | } else { 111 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 112 | } 113 | 114 | echo json_encode($return); 115 | } 116 | 117 | public function viewimage(){ 118 | 119 | $fm = $this->loadModel('filemanagement'); 120 | $return = $fm->viewImage(); 121 | 122 | echo json_encode($return); 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /bkdr/dir-lister/fileTypes.php: -------------------------------------------------------------------------------- 1 | 'fa-file-archive-o', 7 | 'bz' => 'fa-file-archive-o', 8 | 'gz' => 'fa-file-archive-o', 9 | 'rar' => 'fa-file-archive-o', 10 | 'tar' => 'fa-file-archive-o', 11 | 'zip' => 'fa-file-archive-o', 12 | 13 | // Audio 14 | 'aac' => 'fa-music', 15 | 'flac' => 'fa-music', 16 | 'mid' => 'fa-music', 17 | 'midi' => 'fa-music', 18 | 'mp3' => 'fa-music', 19 | 'ogg' => 'fa-music', 20 | 'wma' => 'fa-music', 21 | 'wav' => 'fa-music', 22 | 23 | // Code 24 | 'c' => 'fa-code', 25 | 'class' => 'fa-code', 26 | 'cpp' => 'fa-code', 27 | 'css' => 'fa-code', 28 | 'erb' => 'fa-code', 29 | 'htm' => 'fa-code', 30 | 'html' => 'fa-code', 31 | 'java' => 'fa-code', 32 | 'js' => 'fa-code', 33 | 'php' => 'fa-code', 34 | 'pl' => 'fa-code', 35 | 'py' => 'fa-code', 36 | 'rb' => 'fa-code', 37 | 'xhtml' => 'fa-code', 38 | 'xml' => 'fa-code', 39 | 40 | // Databases 41 | 'accdb' => 'fa-hdd-o', 42 | 'db' => 'fa-hdd-o', 43 | 'dbf' => 'fa-hdd-o', 44 | 'mdb' => 'fa-hdd-o', 45 | 'pdb' => 'fa-hdd-o', 46 | 'sql' => 'fa-hdd-o', 47 | 48 | // Documents 49 | 'csv' => 'fa-file-text', 50 | 'doc' => 'fa-file-text', 51 | 'docx' => 'fa-file-text', 52 | 'odt' => 'fa-file-text', 53 | 'pdf' => 'fa-file-text', 54 | 'xls' => 'fa-file-text', 55 | 'xlsx' => 'fa-file-text', 56 | 57 | // Executables 58 | 'app' => 'fa-list-alt', 59 | 'bat' => 'fa-list-alt', 60 | 'com' => 'fa-list-alt', 61 | 'exe' => 'fa-list-alt', 62 | 'jar' => 'fa-list-alt', 63 | 'msi' => 'fa-list-alt', 64 | 'vb' => 'fa-list-alt', 65 | 66 | // Fonts 67 | 'eot' => 'fa-font', 68 | 'otf' => 'fa-font', 69 | 'ttf' => 'fa-font', 70 | 'woff' => 'fa-font', 71 | 72 | // Game Files 73 | 'gam' => 'fa-gamepad', 74 | 'nes' => 'fa-gamepad', 75 | 'rom' => 'fa-gamepad', 76 | 'sav' => 'fa-floppy-o', 77 | 78 | // Images 79 | 'bmp' => 'fa-picture-o', 80 | 'gif' => 'fa-picture-o', 81 | 'jpg' => 'fa-picture-o', 82 | 'jpeg' => 'fa-picture-o', 83 | 'png' => 'fa-picture-o', 84 | 'psd' => 'fa-picture-o', 85 | 'tga' => 'fa-picture-o', 86 | 'tif' => 'fa-picture-o', 87 | 88 | // Package Files 89 | 'box' => 'fa-archive', 90 | 'deb' => 'fa-archive', 91 | 'rpm' => 'fa-archive', 92 | 93 | // Scripts 94 | 'bat' => 'fa-terminal', 95 | 'cmd' => 'fa-terminal', 96 | 'sh' => 'fa-terminal', 97 | 98 | // Text 99 | 'cfg' => 'fa-file-text', 100 | 'ini' => 'fa-file-text', 101 | 'log' => 'fa-file-text', 102 | 'md' => 'fa-file-text', 103 | 'rtf' => 'fa-file-text', 104 | 'txt' => 'fa-file-text', 105 | 106 | // Vector Images 107 | 'ai' => 'fa-picture-o', 108 | 'drw' => 'fa-picture-o', 109 | 'eps' => 'fa-picture-o', 110 | 'ps' => 'fa-picture-o', 111 | 'svg' => 'fa-picture-o', 112 | 113 | // Video 114 | 'avi' => 'fa-youtube-play', 115 | 'flv' => 'fa-youtube-play', 116 | 'mkv' => 'fa-youtube-play', 117 | 'mov' => 'fa-youtube-play', 118 | 'mp4' => 'fa-youtube-play', 119 | 'mpg' => 'fa-youtube-play', 120 | 'ogv' => 'fa-youtube-play', 121 | 'webm' => 'fa-youtube-play', 122 | 'wmv' => 'fa-youtube-play', 123 | 'swf' => 'fa-youtube-play', 124 | 125 | // Other 126 | 'bak' => 'fa-floppy', 127 | 'msg' => 'fa-envelope', 128 | 129 | // Blank 130 | 'blank' => 'fa-file' 131 | 132 | ); 133 | -------------------------------------------------------------------------------- /bkdr/api/controller/users.php: -------------------------------------------------------------------------------- 1 | api_key && $this->api_member_key) { 18 | $um = $this->loadModel('usermanagement'); 19 | $return = $um->getUser($this->api_member_code); 20 | } else { 21 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 22 | } 23 | 24 | echo json_encode($return); 25 | } 26 | 27 | public function signin() { 28 | 29 | if ($this->api_key) { 30 | $um = $this->loadModel('usermanagement'); 31 | $return = $um->userSignin(); 32 | } else { 33 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 34 | } 35 | 36 | echo json_encode($return); 37 | } 38 | 39 | public function all($code) { 40 | 41 | if ($this->api_key && $this->api_member_key) { 42 | $um = $this->loadModel('usermanagement'); 43 | $return = $um->getUsers($code); 44 | } else { 45 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 46 | } 47 | 48 | echo json_encode($return); 49 | } 50 | 51 | public function get($code) { 52 | 53 | if ($this->api_key && $this->api_member_key) { 54 | $um = $this->loadModel('usermanagement'); 55 | $return = $um->getUser($code); 56 | } else { 57 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 58 | } 59 | 60 | echo json_encode($return); 61 | } 62 | 63 | public function add() { 64 | 65 | if ($this->api_key) { 66 | $um = $this->loadModel('usermanagement'); 67 | $return = $um->createUser(); 68 | } else { 69 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 70 | } 71 | 72 | echo json_encode($return); 73 | } 74 | 75 | public function update() { 76 | 77 | if ($this->api_key && $this->api_member_key) { 78 | $um = $this->loadModel('usermanagement'); 79 | $return = $um->updateUser(); 80 | } else { 81 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 82 | } 83 | 84 | echo json_encode($return); 85 | } 86 | 87 | public function updatepass() { 88 | 89 | if ($this->api_key && $this->api_member_key) { 90 | $um = $this->loadModel('usermanagement'); 91 | $return = $um->updateUserPass(); 92 | } else { 93 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 94 | } 95 | 96 | echo json_encode($return); 97 | } 98 | 99 | public function remove($code) { 100 | 101 | if ($this->api_key && $this->api_member_key) { 102 | $um = $this->loadModel('usermanagement'); 103 | $return = $um->deleteUser($_SESSION['bdmembercode'],$code); 104 | } else { 105 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 106 | } 107 | 108 | echo json_encode($return); 109 | } 110 | 111 | public function getall($code) { 112 | 113 | if ($this->api_key && $this->api_member_key) { 114 | $um = $this->loadModel('usermanagement'); 115 | $return = $um->getUsers($code); 116 | } else { 117 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 118 | } 119 | 120 | echo json_encode($return); 121 | } 122 | 123 | public function activate() { 124 | 125 | if ($this->api_key && $this->api_member_key) { 126 | $um = $this->loadModel('usermanagement'); 127 | $return = $um->activateUser(); 128 | } else { 129 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 130 | } 131 | 132 | echo json_encode($return); 133 | } 134 | 135 | public function setadmin() { 136 | 137 | if ($this->api_key && $this->api_member_key) { 138 | $um = $this->loadModel('usermanagement'); 139 | $return = $um->makeUserAdmin(); 140 | } else { 141 | $return = array('success' => false,'statusMessage' => 'Access denied.'); 142 | } 143 | 144 | echo json_encode($return); 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /bkdr/api/install.php: -------------------------------------------------------------------------------- 1 | open('core.db'); 16 | } 17 | } 18 | 19 | // DB access. 20 | $db = new DB(); 21 | // Defaults. 22 | $status = array(); 23 | $cleanInstall = true; 24 | 25 | 26 | // Items within API index. 27 | $post_api_key = $_POST['local_api_key']; 28 | $post_email = $_POST['default_email']; 29 | // Items within config. 30 | $post_bkdr_dir = $_POST['bkdr_dir']; 31 | $post_root_dir = $_POST['root_dir']; 32 | $post_domain = $_POST['domain']; 33 | $post_pointed = $_POST['domain_pointed']; 34 | // Items within database. 35 | $post_open_reg = $_POST['bkdr_open_reg']; 36 | $post_send_err = $_POST['bkdr_send_errors']; 37 | 38 | 39 | // Prepare config... 40 | $config_data = array( 41 | "backdoorDir" => $post_bkdr_dir, 42 | "backdoorDomain" => urldecode($post_domain), 43 | "changeRoot" => $post_root_dir, 44 | "defaultTheme" => "monokai", 45 | "domainIsBackdoorApp" => $post_pointed, 46 | "fontSize" => "14px", 47 | "lineWrapping" => true, 48 | "multiViewColors" => array("#007fff","#04ff00","#ff8300"), 49 | "tabSize" => 2 50 | ); 51 | // Create config file. 52 | $config_file_path = '../config.json'; 53 | $config_file = fopen($config_file_path, 'w'); 54 | $json_string = json_encode($config_data, JSON_PRETTY_PRINT); 55 | if (fwrite($config_file, $json_string) === false) { 56 | $status[] = 'There was an error creating configuration file.'; 57 | $cleanInstall = false; 58 | } else { 59 | $status[] = 'Configuration file has been created.'; 60 | } 61 | fclose($config_file); 62 | 63 | 64 | // Default values for new super user. 65 | $code = hash('sha256', $post_email.date("Y-m-d H:m:s")); 66 | $pass = base64_encode('admin'); 67 | // Creat user account. 68 | $createUser = $db->prepare("INSERT INTO Users (Code,Fname,Lname,Email,Password,Confirm,Admin) VALUES (:code,:fname,:lname,:email,:pass,1,:admin)"); 69 | $createUser->bindValue(':code', $code); 70 | $createUser->bindValue(':fname', 'First'); 71 | $createUser->bindValue(':lname', 'Last'); 72 | $createUser->bindValue(':email', $post_email); 73 | $createUser->bindValue(':pass', $pass); 74 | $createUser->bindValue(':admin', 1); 75 | $user_result = $createUser->execute(); 76 | if ($user_result) { 77 | $status[] = 'Super user has been created.'; 78 | } else { 79 | $status[] = 'There was an error creating super user.'; 80 | $cleanInstall = false; 81 | } 82 | 83 | 84 | // Update settings for Open Reg. 85 | $settingsQuery1 = $db->prepare("UPDATE Settings SET SettingValue=:value WHERE SettingType=:type"); 86 | $settingsQuery1->bindValue(':value',$post_open_reg); 87 | $settingsQuery1->bindValue(':type','bkdr_open_reg'); 88 | $setting1_result = $settingsQuery1->execute(); 89 | if ($setting1_result) { 90 | $status[] = 'Setting for Open Registration has been applied.'; 91 | } else { 92 | $status[] = 'There was an error applying settings for Open Registration.'; 93 | $cleanInstall = false; 94 | } 95 | 96 | 97 | // Update settings for Sending Errors. 98 | $settingsQuery2 = $db->prepare("UPDATE Settings SET SettingValue=:value WHERE SettingType=:type"); 99 | $settingsQuery2->bindValue(':value',$post_send_err); 100 | $settingsQuery2->bindValue(':type','bkdr_send_errors'); 101 | $setting2_result = $settingsQuery2->execute(); 102 | if ($setting2_result) { 103 | $status[] = 'Setting for Sending Errors has been applied.'; 104 | } else { 105 | $status[] = 'There was an error applying settings for Sending Erros.'; 106 | $cleanInstall = false; 107 | } 108 | 109 | 110 | // Prepare final message. 111 | if ($cleanInstall) { 112 | $finalMessage = "Installation process has been completed."; 113 | } else { 114 | $finalMessage = "Installation process has been completed with errors."; 115 | } 116 | 117 | 118 | // Complete full status message. 119 | $statusMessage = ''.implode(" ",$status).' 120 | 121 | '.$finalMessage.' 122 | 123 | Your default login credentials are USER: (The email provided), PASS: admin.'; 124 | 125 | 126 | // Return. 127 | echo json_encode(array( 128 | 'success' => $cleanInstall, 129 | 'statusMessage' => $statusMessage 130 | )); 131 | ?> -------------------------------------------------------------------------------- /bkdr/assets/img/bkdr_logo_pro_black.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bkdr/api/models/extmanagement.php: -------------------------------------------------------------------------------- 1 | db = $db; 18 | $this->domain = $domain; 19 | $this->config = $config; 20 | 21 | $this->extensions_dir = $this->config->backdoorDir . DIRECTORY_SEPARATOR . "extensions"; 22 | 23 | // Restrict access to current directory 24 | getcwd(); 25 | chdir(".." . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR); 26 | ini_set('open_basedir', getcwd()); 27 | } 28 | 29 | private function recurse_delete($path) { 30 | if (is_dir($path) === true) { 31 | $files = array_diff(scandir($path), array('.', '..')); 32 | foreach ($files as $file) { 33 | $this->recurse_delete(realpath($path) . DIRECTORY_SEPARATOR . $file); 34 | } 35 | return rmdir($path); 36 | } else if (is_file($path) === true) { 37 | return unlink($path); 38 | } 39 | return false; 40 | } 41 | 42 | public function get() { 43 | 44 | $dir_array = scandir($this->extensions_dir); 45 | 46 | $ext_array = array(); 47 | 48 | foreach ($dir_array as $file_path) { 49 | 50 | if ($file_path != "." && $file_path != "..") { 51 | 52 | $short_path = $this->extensions_dir . DIRECTORY_SEPARATOR . $file_path; 53 | $file_path = getcwd() . DIRECTORY_SEPARATOR . $this->extensions_dir . DIRECTORY_SEPARATOR . $file_path; 54 | 55 | if (!is_file($file_path)) { 56 | 57 | $data = json_decode(file_get_contents($file_path . DIRECTORY_SEPARATOR . "data.json"), true); 58 | 59 | $queryExt = $this->db->prepare("SELECT * FROM Extensions WHERE Author=:author AND Name=:name AND ExtPath=:extpath"); 60 | $queryExt->bindValue(':author', $data['author']); 61 | $queryExt->bindValue(':name', $data['namespace']); 62 | $queryExt->bindValue(':extpath', $short_path); 63 | $result = $queryExt->execute(); 64 | $row = $result->fetchArray(SQLITE3_ASSOC); 65 | 66 | if ($row) { 67 | $active = ($row['Activated']=="false"?false:true); 68 | } else { 69 | $queryExt = $this->db->prepare("INSERT INTO Extensions (Author, Name, ExtPath, Activated) VALUES (:author, :name, :extpath, 0)"); 70 | $queryExt->bindValue(':author', $data['author']); 71 | $queryExt->bindValue(':name', $data['namespace']); 72 | $queryExt->bindValue(':extpath', $short_path); 73 | $result = $queryExt->execute(); 74 | 75 | $active = false; 76 | } 77 | 78 | $data['active'] = $active; 79 | $data['path'] = $short_path; 80 | 81 | $ext_array[] = $data; 82 | } 83 | } 84 | } 85 | 86 | if (count($ext_array)) { 87 | return array( 88 | 'success' => true, 89 | 'statusMessage' => "Extensions directory.", 90 | 'extensions' => $ext_array 91 | ); 92 | } else { 93 | return array( 94 | 'success' => false, 95 | 'statusMessage' => "No extensions found.", 96 | 'extensions' => $ext_array 97 | ); 98 | } 99 | } 100 | 101 | public function toggleExt() { 102 | 103 | if (isset($_POST['namespace']) && isset($_POST['extpath']) && isset($_POST['toggle'])) { 104 | 105 | $status = 0; 106 | $msg = "deactivated"; 107 | if ($_POST['toggle'] == "false") { 108 | $status = 1; 109 | $msg = "activated"; 110 | } 111 | 112 | $queryExt = $this->db->prepare("UPDATE Extensions SET Activated=:status WHERE Name=:name AND ExtPath=:extpath"); 113 | $queryExt->bindValue(':name', $_POST['namespace']); 114 | $queryExt->bindValue(':status', $status); 115 | $queryExt->bindValue(':extpath', $_POST['extpath']); 116 | $result = $queryExt->execute(); 117 | 118 | if ($result) { 119 | return array( 120 | 'success' => true, 121 | 'statusMessage' => "Extension has been $msg.", 122 | 'extensions' => $this->get()['extensions'] 123 | ); 124 | } else { 125 | return array( 126 | 'success' => false, 127 | 'statusMessage' => "There was an error activating extension." 128 | ); 129 | } 130 | } else { 131 | return array( 132 | 'success' => false, 133 | 'statusMessage' => "Missing values to activate extension." 134 | ); 135 | } 136 | } 137 | 138 | public function getExtHtml() { 139 | 140 | if (isset($_POST['extpath']) && isset($_POST['panels'])) { 141 | $htmls = []; 142 | 143 | foreach($_POST['panels'] as $html) { 144 | $htmls[] = file_get_contents($_POST['extpath'].DIRECTORY_SEPARATOR.$html); 145 | } 146 | 147 | return array( 148 | 'success' => true, 149 | 'statusMessage' => "HTML found.", 150 | 'html' => $htmls 151 | ); 152 | } else { 153 | return array( 154 | 'success' => false, 155 | 'statusMessage' => "Missing values to activate extension." 156 | ); 157 | } 158 | } 159 | 160 | public function removeExt() { 161 | 162 | if (isset($_POST['namespace']) && isset($_POST['extpath'])) { 163 | 164 | if ($this->recurse_delete($_POST['extpath'])) { 165 | $status = 0; 166 | 167 | $queryExt = $this->db->prepare("DELETE FROM Extensions WHERE Name=:name AND ExtPath=:extpath"); 168 | $queryExt->bindValue(':name', $_POST['namespace']); 169 | $queryExt->bindValue(':extpath', $_POST['extpath']); 170 | $result = $queryExt->execute(); 171 | 172 | if ($result) { 173 | return array( 174 | 'success' => true, 175 | 'statusMessage' => "Extension has been removed.", 176 | 'extensions' => $this->get()['extensions'] 177 | ); 178 | } else { 179 | return array( 180 | 'success' => false, 181 | 'statusMessage' => "There was an error removing extension from database." 182 | ); 183 | } 184 | } else { 185 | return array( 186 | 'success' => false, 187 | 'statusMessage' => "There was an error removing extension." 188 | ); 189 | } 190 | } else { 191 | return array( 192 | 'success' => false, 193 | 'statusMessage' => "Missing values to remove extension." 194 | ); 195 | } 196 | } 197 | } -------------------------------------------------------------------------------- /bkdr/assets/img/bkdr_fullname_black.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bkdr/api/models/updatemanagement.php: -------------------------------------------------------------------------------- 1 | db = $db; 18 | $this->domain = $domain; 19 | $this->config = $config; 20 | } 21 | 22 | private function httpPost($url, $data = false) { 23 | $curl = curl_init($url); 24 | if ($data) { 25 | curl_setopt($curl, CURLOPT_POST, true); 26 | curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); 27 | } 28 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 29 | curl_setopt($curl, CURLOPT_HTTPHEADER, array( 30 | 'Bkdr-Timestamp:'.strtotime(date('Y-m-d', time()). '00:00:00') 31 | )); 32 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 33 | $response = curl_exec($curl); 34 | if (curl_errno($curl)) { 35 | $response = false; 36 | } 37 | curl_close($curl); 38 | return $response; 39 | } 40 | 41 | private function recurse_copy($src, $dst) { 42 | $dir = opendir($src); 43 | $result = ($dir === false ? false : true); 44 | if ($result !== false) { 45 | while(false !== ( $file = readdir($dir)) ) { 46 | if (( $file != '.' ) && ( $file != '..' ) && $result) { 47 | if ( is_dir($src . DIRECTORY_SEPARATOR . $file) ) { 48 | $result = $this->recurse_copy($src . DIRECTORY_SEPARATOR . $file,$dst . DIRECTORY_SEPARATOR . $file); 49 | } else { 50 | $result = copy($src . DIRECTORY_SEPARATOR . $file,$dst . DIRECTORY_SEPARATOR . $file); 51 | } 52 | } 53 | } 54 | closedir($dir); 55 | } 56 | return $result; 57 | } 58 | 59 | private function mergeConfig($old_config, $new_config) { 60 | $success = false; 61 | 62 | $o_config = (array)json_decode(file_get_contents($old_config), true); 63 | $n_config = (array)json_decode(file_get_contents($new_config), true); 64 | 65 | foreach($n_config as $key => $n_value) { 66 | if (array_key_exists($key,$o_config)) { 67 | $n_config[$key] = $o_config[$key]; 68 | } else { 69 | $n_config[$key] = $n_value; 70 | } 71 | } 72 | 73 | $config_file = fopen($old_config, 'w'); 74 | $json_string = json_encode($n_config, JSON_PRETTY_PRINT); 75 | if (fwrite($config_file, $json_string) === false) { 76 | $cleanInstall = false; 77 | } else { 78 | $cleanInstall = true; 79 | } 80 | fclose($config_file); 81 | chmod($old_config, 0744); 82 | return $cleanInstall; 83 | } 84 | 85 | // public function sampleCall() { 86 | // $return = $this->httpPost('http://domain.com/latest/update/'); 87 | 88 | // if ($return == false) { 89 | // return array( 90 | // 'success' => false, 91 | // 'statusMessage' => "Error getting latest from BKDR." 92 | // ); 93 | // } else { 94 | // return json_decode($return, true); 95 | // } 96 | // } 97 | 98 | public function processUpdate() { 99 | 100 | if (isset($_POST['downloadUrl']) && $_POST['downloadUrl'] != "") { 101 | getcwd(); 102 | chdir('../'); 103 | $root = getcwd(); 104 | $update_folder = $root . DIRECTORY_SEPARATOR . "update" . DIRECTORY_SEPARATOR; 105 | $old_bkdr = $root . DIRECTORY_SEPARATOR; 106 | $new_bkdr = $update_folder . "latest_bkdr" . DIRECTORY_SEPARATOR . "bkdr" . DIRECTORY_SEPARATOR; 107 | $stored_bkdr = $update_folder . "previous_bkdr" . DIRECTORY_SEPARATOR; 108 | 109 | $url = $_POST['downloadUrl']; 110 | // $zipFile = $update_folder . "update.zip"; 111 | // $zipResource = fopen($zipFile, "w"); 112 | 113 | // // Get The Zip File From Server. 114 | // $ch = curl_init(); 115 | // curl_setopt($ch, CURLOPT_URL, $url); 116 | // curl_setopt($ch, CURLOPT_FAILONERROR, true); 117 | // curl_setopt($ch, CURLOPT_HEADER, 0); 118 | // curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 119 | // curl_setopt($ch, CURLOPT_AUTOREFERER, true); 120 | // curl_setopt($ch, CURLOPT_BINARYTRANSFER,true); 121 | // curl_setopt($ch, CURLOPT_TIMEOUT, 10); 122 | // curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 123 | // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 124 | // curl_setopt($ch, CURLOPT_FILE, $zipResource); 125 | // $page = curl_exec($ch); 126 | // curl_close($ch); 127 | 128 | // // Fail if not downloaded. 129 | // if(!$page) { 130 | // return array( 131 | // 'success' => false, 132 | // 'statusMessage' => "Download failed." 133 | // ); 134 | // } 135 | 136 | // Extract Zip File. 137 | $zip = new ZipArchive; 138 | // Fail if not extracted. 139 | if($zip->open($url) != "true"){ 140 | return array( 141 | 'success' => false, 142 | 'statusMessage' => "Zip extraction failed." 143 | ); 144 | } else { 145 | $zip->extractTo($update_folder . DIRECTORY_SEPARATOR . "latest_bkdr"); 146 | $zip->close(); 147 | 148 | $run_db_update = $old_bkdr . "api" . DIRECTORY_SEPARATOR . "updateDB.php"; 149 | 150 | $old_bkdr_db = $old_bkdr . "api" . DIRECTORY_SEPARATOR . "core.db"; 151 | // Old directories. 152 | $old_bkdr_api = $old_bkdr . "api" . DIRECTORY_SEPARATOR; 153 | $old_bkdr_assets = $old_bkdr . "assets" . DIRECTORY_SEPARATOR; 154 | $old_bkdr_dirlister = $old_bkdr . "dir-lister" . DIRECTORY_SEPARATOR; 155 | $old_bkdr_term = $old_bkdr . "term" . DIRECTORY_SEPARATOR; 156 | // Old files. 157 | $old_bkdr_config = $old_bkdr . "config.json"; 158 | $old_bkdr_index = $old_bkdr . "index.php"; 159 | 160 | $temp_bkdr_db = $new_bkdr . "core.db"; 161 | // New directories. 162 | $new_bkdr_api = $new_bkdr . "api" . DIRECTORY_SEPARATOR; 163 | $new_bkdr_assets = $new_bkdr . "assets" . DIRECTORY_SEPARATOR; 164 | $new_bkdr_dirlister = $new_bkdr . "dir-lister" . DIRECTORY_SEPARATOR; 165 | $new_bkdr_term = $new_bkdr . "term" . DIRECTORY_SEPARATOR; 166 | // New files. 167 | $new_bkdr_config = $new_bkdr . "update" . DIRECTORY_SEPARATOR . "sample_config.json"; 168 | $new_bkdr_index = $new_bkdr . "index.php"; 169 | 170 | // Proceed if DB is properly copied. 171 | if (copy($old_bkdr_db, $temp_bkdr_db)) { 172 | $process_msg = array("App successfully downloaded and extracted."); 173 | $process_msg[] = "DB successfully reserved."; 174 | 175 | // Update API 176 | if (is_dir($new_bkdr_api) && is_dir($old_bkdr_api)) { 177 | if ($this->recurse_copy($new_bkdr_api, $old_bkdr_api)) { 178 | $process_msg[] = "API successfully updated."; 179 | } else { 180 | $process_msg[] = "API not updated."; 181 | } 182 | } else { 183 | $process_msg[] = "Error finding API directory."; 184 | } 185 | 186 | // Update assets 187 | if (is_dir($new_bkdr_assets) && is_dir($old_bkdr_assets)) { 188 | if ($this->recurse_copy($new_bkdr_assets, $old_bkdr_assets)) { 189 | $process_msg[] = "Assets successfully updated."; 190 | } else { 191 | $process_msg[] = "Assets not updated."; 192 | } 193 | } else { 194 | $process_msg[] = "Error finding Assets directory."; 195 | } 196 | 197 | // Update Directory Lister 198 | if (is_dir($new_bkdr_dirlister) && is_dir($old_bkdr_dirlister)) { 199 | if ($this->recurse_copy($new_bkdr_dirlister, $old_bkdr_dirlister)) { 200 | $process_msg[] = "Directory lister successfully updated."; 201 | } else { 202 | $process_msg[] = "Directory lister not updated."; 203 | } 204 | } else { 205 | $process_msg[] = "Error finding Directory Lister directory."; 206 | } 207 | 208 | // Update terminal 209 | if (is_dir($new_bkdr_term) && is_dir($old_bkdr_term)) { 210 | if ($this->recurse_copy($new_bkdr_term, $old_bkdr_term)) { 211 | $process_msg[] = "Terminal successfully updated."; 212 | } else { 213 | $process_msg[] = "Terminal not updated."; 214 | } 215 | } else { 216 | $process_msg[] = "Error finding Terminal directory."; 217 | } 218 | 219 | // Merge configurations 220 | if ($this->mergeConfig($old_bkdr_config, $new_bkdr_config)) { 221 | $process_msg[] = "Config successfully updated."; 222 | } else { 223 | $process_msg[] = "Config not updated."; 224 | } 225 | // Update index 226 | if (copy($new_bkdr_index, $old_bkdr_index)) { 227 | $process_msg[] = "Index successfully updated."; 228 | } else { 229 | $process_msg[] = "Index not updated."; 230 | } 231 | 232 | if (copy($temp_bkdr_db, $old_bkdr_db)) { 233 | $process_msg[] = "DB successfully restored."; 234 | // Run DB update... 235 | include $run_db_update; 236 | } else { 237 | $process_msg[] = "DB not restored."; 238 | } 239 | 240 | return array( 241 | "success" => true, 242 | 'statusMessage' => implode("
", $process_msg) 243 | ); 244 | } else { 245 | return array( 246 | 'success' => false, 247 | 'statusMessage' => "Update failed." 248 | ); 249 | } 250 | } 251 | } else { 252 | return array( 253 | 'success' => false, 254 | 'statusMessage' => "Update failed." 255 | ); 256 | } 257 | } 258 | } -------------------------------------------------------------------------------- /bkdr/api/models/usermanagement.php: -------------------------------------------------------------------------------- 1 | db = $db; 17 | $this->domain = $domain; 18 | $this->config = $config; 19 | } 20 | 21 | public function userSignin(){ 22 | $email = (isset($_POST['email']) ? $_POST['email']:""); 23 | $pass = (isset($_POST['password']) ? $_POST['password']:""); 24 | $error = false; 25 | 26 | if ($email == "" || $pass == "") { 27 | $error = true; 28 | } 29 | 30 | if (!$error) { 31 | 32 | $queryLogin = $this->db->prepare("SELECT * FROM Users WHERE Email=:email AND Password=:pass AND Confirm=1"); 33 | $queryLogin->bindValue(':email',$email); 34 | $queryLogin->bindValue(':pass',$pass); 35 | $result = $queryLogin->execute(); 36 | $row = $result->fetchArray(SQLITE3_ASSOC); 37 | 38 | if ($row) { 39 | $key = base64_encode($row['Email'].":".$row['Password']); 40 | $user = array( 41 | "fname" => $row['Fname'], 42 | "lname" => $row['Lname'], 43 | "email" => $row['Email'], 44 | "admin" => ($row['Admin']?true:false), 45 | "active" => ($row['Confirm']?true:false), 46 | "code" => $row['Code'] 47 | ); 48 | 49 | $_SESSION['bdmemberkey'] = $key; 50 | $_SESSION['bdmembercode'] = $row['Code']; 51 | 52 | return array( 53 | 'success' => true, 54 | 'statusMessage' => "Sign-in successful.", 55 | 'user' => $user, 56 | 'key' => $key 57 | ); 58 | } else { 59 | return array( 60 | 'success' => false, 61 | 'statusMessage' => "Sign-in failed." 62 | ); 63 | } 64 | } else { 65 | return array( 66 | 'success' => false, 67 | 'statusMessage' => "Missing values." 68 | ); 69 | } 70 | } 71 | 72 | public function adminCheck($userid){ 73 | $userLogin = $this->db->prepare("SELECT * FROM Users WHERE Admin=1"); 74 | $result = $userLogin->execute(); 75 | 76 | while ($row = $result->fetchArray(SQLITE3_ASSOC)) { 77 | if ($row['Code'] == $userid && $userid != "") { 78 | return true; 79 | break; 80 | } 81 | } 82 | 83 | return false; 84 | } 85 | 86 | public function updateUser() { 87 | $code = (isset($_POST['usercode']) ? $_POST['usercode']:""); 88 | $email = (isset($_POST['email']) ? $_POST['email']:""); 89 | $fname = (isset($_POST['fname']) ? $_POST['fname']:""); 90 | $lname = (isset($_POST['lname']) ? $_POST['lname']:""); 91 | $error = false; 92 | 93 | if ($email == "" || $fname == "" || $lname == "") { 94 | $error = true; 95 | $errorMsg = "Missing values."; 96 | } else if ($_SESSION['bdmembercode'] != $code) { 97 | $error = true; 98 | $errorMsg = "There is a mismatch with your account id."; 99 | } 100 | 101 | if (!$error) { 102 | $updateUser = $this->db->prepare("UPDATE Users SET Fname=:fname, Lname=:lname, Email=:email WHERE Code=:code"); 103 | $updateUser->bindValue(':email',$email); 104 | $updateUser->bindValue(':lname',$lname); 105 | $updateUser->bindValue(':fname',$fname); 106 | $updateUser->bindValue(':code',$code); 107 | $result = $updateUser->execute(); 108 | 109 | if ($result) { 110 | return array( 111 | 'success' => true, 112 | 'statusMessage' => "Account successfully updated.", 113 | 'user' => $this->getUser($code)['user'] 114 | ); 115 | } else { 116 | return array( 117 | 'success' => false, 118 | 'statusMessage' => "There was an error updating account." 119 | ); 120 | } 121 | 122 | } else { 123 | return array( 124 | 'success' => false, 125 | 'statusMessage' => $errorMsg 126 | ); 127 | } 128 | } 129 | 130 | public function updateUserPass() { 131 | $code = (isset($_POST['usercode']) ? $_POST['usercode']:""); 132 | $newPass = (isset($_POST['newpass']) ? $_POST['newpass']:""); 133 | $error = false; 134 | 135 | if ($newPass == "" || $code == "") { 136 | $error = true; 137 | $errorMsg = "Missing values."; 138 | } else if ($_SESSION['bdmembercode'] != $code) { 139 | $error = true; 140 | $errorMsg = "There is a mismatch with your account id."; 141 | } 142 | 143 | if (!$error) { 144 | // $newPass = $this->encrypt($newPass); 145 | $updateUser = $this->db->prepare("UPDATE Users SET Password=:newpass WHERE Code=:code"); 146 | $updateUser->bindValue(':newpass',$newPass); 147 | $updateUser->bindValue(':code',$code); 148 | $result = $updateUser->execute(); 149 | 150 | if ($result) { 151 | return array( 152 | 'success' => true, 153 | 'statusMessage' => "Password successfully updated." 154 | ); 155 | } else { 156 | return array( 157 | 'success' => false, 158 | 'statusMessage' => "There was an error updating your password." 159 | ); 160 | } 161 | 162 | } else { 163 | return array( 164 | 'success' => false, 165 | 'statusMessage' => $errorMsg 166 | ); 167 | } 168 | } 169 | 170 | public function activateUser() { 171 | $adminCode = (isset($_POST['admincode'])?$_POST['admincode']:""); 172 | 173 | if ($this->adminCheck($adminCode)) { 174 | $code = (isset($_POST['usercode']) ? $_POST['usercode']:""); 175 | $activate = (isset($_POST['confirm']) ? $_POST['confirm']:0); 176 | 177 | if ($activate==1) { 178 | $rsptxt = "activated"; 179 | } else { 180 | $rsptxt = "deactivated"; 181 | } 182 | 183 | $updateUser = $this->db->prepare("UPDATE Users SET Confirm=:activate WHERE Code=:code"); 184 | $updateUser->bindValue(':activate',$activate); 185 | $updateUser->bindValue(':code',$code); 186 | $result = $updateUser->execute(); 187 | 188 | if ($result) { 189 | return array( 190 | 'success' => true, 191 | 'statusMessage' => "Account $rsptxt." 192 | ); 193 | } else { 194 | return array( 195 | 'success' => false, 196 | 'statusMessage' => "There was an error activating account." 197 | ); 198 | } 199 | } else { 200 | return array( 201 | 'success' => false, 202 | 'statusMessage' => "You must be an admin to update these settings." 203 | ); 204 | } 205 | } 206 | 207 | public function makeUserAdmin() { 208 | $adminCode = (isset($_POST['admincode'])?$_POST['admincode']:""); 209 | 210 | if ($this->adminCheck($adminCode)) { 211 | $code = (isset($_POST['usercode']) ? $_POST['usercode']:""); 212 | $makeadmin = (isset($_POST['makeadmin']) ? $_POST['makeadmin']:0); 213 | 214 | if ($makeadmin==1) { 215 | $rsptxt = "is now admin"; 216 | } else { 217 | $rsptxt = "is no longer an admin"; 218 | } 219 | 220 | $updateUser = $this->db->prepare("UPDATE Users SET Admin=:makeadmin WHERE Code=:code"); 221 | $updateUser->bindValue(':makeadmin',$makeadmin); 222 | $updateUser->bindValue(':code',$code); 223 | $result = $updateUser->execute(); 224 | 225 | if ($result) { 226 | return array( 227 | 'success' => true, 228 | 'statusMessage' => "Account $rsptxt." 229 | ); 230 | } else { 231 | return array( 232 | 'success' => false, 233 | 'statusMessage' => "There was an error setting admin for this account." 234 | ); 235 | } 236 | } else { 237 | return array( 238 | 'success' => false, 239 | 'statusMessage' => "You must be an admin to update these settings." 240 | ); 241 | } 242 | } 243 | 244 | public function createUser($userCode = "",$email = "",$pass = "",$admin = "") { 245 | $errors = false; 246 | $userCode = ($userCode != "" ? $userCode:$_POST['usercode']); 247 | 248 | $settingsQuery = $this->db->prepare("SELECT * FROM Settings WHERE SettingType='bkdr_open_reg'"); 249 | $result = $settingsQuery->execute(); 250 | $row = $result->fetchArray(SQLITE3_ASSOC); 251 | $isOpen = $row['SettingValue'] == "false" ? false : ($row['SettingValue'] == "true" ? true : $row['SettingValue']); 252 | 253 | if ($this->adminCheck($userCode) || $isOpen || $admin) { 254 | 255 | $fname = (isset($_POST['fname']) ? $_POST['fname']:"User"); 256 | $lname = (isset($_POST['lname']) ? $_POST['lname']:"User"); 257 | $email = ($email != "" ? $email:$_POST['email']); 258 | $pass = ($pass != "" ? $pass:$_POST['pass']); 259 | $admin = ($admin != "" ? $admin:0); 260 | $code = hash('sha256', $email.date("Y-m-d H:m:s")); 261 | 262 | if ($email == "" || $pass == "") { 263 | $msg = "Missing values."; 264 | } 265 | 266 | // $pass = $this->encrypt($pass); 267 | 268 | if (!$errors) { 269 | $createUser = $this->db->prepare("INSERT INTO Users (Code,Fname,Lname,Email,Password,Confirm,Admin) VALUES (:code,:fname,:lname,:email,:pass,0,:admin)"); 270 | $createUser->bindValue(':code',$code); 271 | $createUser->bindValue(':fname',$fname); 272 | $createUser->bindValue(':lname',$lname); 273 | $createUser->bindValue(':email',$email); 274 | $createUser->bindValue(':pass',$pass); 275 | $createUser->bindValue(':admin',$admin); 276 | $result = $createUser->execute(); 277 | 278 | if ($result) { 279 | return array( 280 | 'success' => true, 281 | 'statusMessage' => "Account has been successfully created." 282 | ); 283 | } else { 284 | return array( 285 | 'success' => false, 286 | 'statusMessage' => "There was an error creating account." 287 | ); 288 | } 289 | } else { 290 | return array( 291 | 'success' => false, 292 | 'statusMessage' => $msg 293 | ); 294 | } 295 | } else { 296 | return array( 297 | 'success' => false, 298 | 'statusMessage' => "You must be an admin to create an account, or settings must be set to Open Registration." 299 | ); 300 | } 301 | } 302 | 303 | public function deleteUser($userCode,$uid) { 304 | if ($this->adminCheck($userCode)) { 305 | $deleteUser = $this->db->prepare("DELETE FROM Users WHERE Code=:code"); 306 | $deleteUser->bindValue(':code',$uid); 307 | $result = $deleteUser->execute(); 308 | 309 | if ($result) { 310 | return array( 311 | 'success' => true, 312 | 'statusMessage' => "User has been successfully removed." 313 | ); 314 | } else { 315 | return array( 316 | 'success' => false, 317 | 'statusMessage' => "There was an error removing user." 318 | ); 319 | } 320 | } else { 321 | return array( 322 | 'success' => false, 323 | 'statusMessage' => "You must be an admin to remove this user." 324 | ); 325 | } 326 | } 327 | 328 | public function getUsers($userCode) { 329 | if ($this->adminCheck($userCode)) { 330 | $userLogin = $this->db->prepare("SELECT * FROM Users"); 331 | $result = $userLogin->execute(); 332 | $list = array(); 333 | 334 | while ($row = $result->fetchArray(SQLITE3_ASSOC)) { 335 | if ($row['Code'] != $this->api_member_code) { 336 | $list[] = array( 337 | "fname" => $row['Fname'], 338 | "lname" => $row['Lname'], 339 | "email" => $row['Email'], 340 | "admin" => ($row['Admin']?true:false), 341 | "active" => ($row['Confirm']?true:false), 342 | "superadmin" => ($row['ID']==1?true:false), 343 | "code" => $row['Code'] 344 | ); 345 | } 346 | } 347 | 348 | return array( 349 | 'success' => true, 350 | 'statusMessage' => 'User list found.', 351 | 'list' => $list 352 | ); 353 | } else { 354 | return array( 355 | 'success' => false, 356 | 'statusMessage' => "You must be an admin to access users." 357 | ); 358 | } 359 | } 360 | 361 | public function getUser($userCode) { 362 | $code = (isset($_POST['usercode']) ? $_POST['usercode']:""); 363 | $error = false; 364 | 365 | if ($code == "") { 366 | $error = true; 367 | $errorMsg = "Missing values."; 368 | } else if ($_SESSION['bdmembercode'] != $code) { 369 | $error = true; 370 | $errorMsg = "There is a mismatch with your account id."; 371 | } 372 | 373 | if (!$error) { 374 | $getUser = $this->db->prepare("SELECT * FROM Users WHERE Code=:code"); 375 | $getUser->bindValue(':code',$userCode); 376 | $result = $getUser->execute(); 377 | 378 | if ($result) { 379 | $row = $result->fetchArray(SQLITE3_ASSOC); 380 | 381 | return array( 382 | 'success' => true, 383 | 'statusMessage' => 'User found.', 384 | 'user' => array( 385 | "fname" => $row['Fname'], 386 | "lname" => $row['Lname'], 387 | "email" => $row['Email'], 388 | "admin" => ($row['Admin']?true:false), 389 | "active" => ($row['Confirm']?true:false), 390 | "code" => $row['Code'] 391 | ) 392 | ); 393 | } else { 394 | return array( 395 | 'success' => false, 396 | 'statusMessage' => "User not found." 397 | ); 398 | } 399 | } else { 400 | return array( 401 | 'success' => false, 402 | 'statusMessage' => $errorMsg 403 | ); 404 | } 405 | } 406 | 407 | private function init() { 408 | $this->db->exec('CREATE TABLE IF NOT EXISTS Users ("ID" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, "Code" VARCHAR, "Fname" VARCHAR, "Lname" VARCHAR, "Email" VARCHAR, "Password" VARCHAR, "Admin" INTEGER NOT NULL DEFAULT 0, "Confirm" INTEGER NOT NULL DEFAULT 0)'); 409 | 410 | $prepare = $this->db->prepare("SELECT count(*) AS total FROM Users"); 411 | $result = $prepare->execute(); 412 | $row = $result->fetchArray(SQLITE3_ASSOC); 413 | 414 | if ($row['total'] == 0) { 415 | 416 | $results = $this->createUser($this->api_member_code,$this->config['defaultEmail'],base64_encode('admin'),1); 417 | 418 | if ($results['success']) { 419 | return true; 420 | } else { 421 | return false; 422 | } 423 | } else { 424 | return true; 425 | } 426 | } 427 | } 428 | -------------------------------------------------------------------------------- /bkdr/api/models/filemanagement.php: -------------------------------------------------------------------------------- 1 | db = $db; 18 | $this->domain = $domain; 19 | $this->config = $config; 20 | 21 | $this->types = []; 22 | // Code 23 | $this->types["cfg"] = "plain"; 24 | $this->types["coffee"] = "coffeescript"; 25 | $this->types["css"] = "css"; 26 | $this->types["htm"] = "htmlmixed"; 27 | $this->types["html"] = "htmlmixed"; 28 | $this->types["ini"] = "plain"; 29 | $this->types["js"] = "javascript"; 30 | $this->types["json"] = "javascript"; 31 | $this->types["jsx"] = "jsx"; 32 | $this->types["log"] = "plain"; 33 | $this->types["markdown"] = "markdown"; 34 | $this->types["md"] = "markdown"; 35 | $this->types["mdown"] = "markdown"; 36 | $this->types["mdtext"] = "markdown"; 37 | $this->types["mdtxt"] = "markdown"; 38 | $this->types["mdwn"] = "markdown"; 39 | $this->types["mkd"] = "markdown"; 40 | $this->types["mkdn"] = "markdown"; 41 | $this->types["php"] = "php"; 42 | $this->types["pl"] = "perl"; 43 | $this->types["pug"] = "pug"; 44 | $this->types["py"] = "python"; 45 | $this->types["rb"] = "ruby"; 46 | $this->types["rtf"] = "plain"; 47 | $this->types["sass"] = "sass"; 48 | $this->types["scss"] = "sass"; 49 | $this->types["sh"] = "shell"; 50 | $this->types["sql"] = "sql"; 51 | $this->types["text"] = "markdown"; 52 | $this->types["txt"] = "plain"; 53 | $this->types["vb"] = "vb"; 54 | $this->types["vbs"] = "vbscript"; 55 | $this->types["xhtml"] = "htmlmixed"; 56 | $this->types["xml"] = "xml"; 57 | $this->types["yaml"] = "yaml"; 58 | $this->types["yml"] = "yaml"; 59 | // Images 60 | $this->types["jpg"] = "imageview"; 61 | $this->types["jpeg"] = "imageview"; 62 | $this->types["gif"] = "imageview"; 63 | $this->types["png"] = "imageview"; 64 | $this->types["bmp"] = "imageview"; 65 | $this->types["tiff"] = "imageview"; 66 | $this->types["svg"] = "imageview"; 67 | } 68 | 69 | private function get_file_extension($file_name) { 70 | return substr(strrchr($file_name,'.'),0); 71 | } 72 | 73 | private function recurse_copy($src, $dst) { 74 | $dir = opendir($src); 75 | $result = ($dir === false ? false : true); 76 | if ($result !== false) { 77 | $result = @mkdir($dst); 78 | if ($result === true) { 79 | while(false !== ( $file = readdir($dir)) ) { 80 | if (( $file != '.' ) && ( $file != '..' ) && $result) { 81 | if ( is_dir($src . DIRECTORY_SEPARATOR . $file) ) { 82 | $result = $this->recurse_copy($src . DIRECTORY_SEPARATOR . $file,$dst . DIRECTORY_SEPARATOR . $file); 83 | } else { 84 | $result = copy($src . DIRECTORY_SEPARATOR . $file,$dst . DIRECTORY_SEPARATOR . $file); 85 | } 86 | } 87 | } 88 | closedir($dir); 89 | } 90 | } 91 | return $result; 92 | } 93 | 94 | private function recurse_delete($path) { 95 | if (is_dir($path) === true) { 96 | $files = array_diff(scandir($path), array('.', '..')); 97 | foreach ($files as $file) { 98 | $this->recurse_delete(realpath($path) . DIRECTORY_SEPARATOR . $file); 99 | } 100 | return rmdir($path); 101 | } else if (is_file($path) === true) { 102 | return unlink($path); 103 | } 104 | return false; 105 | } 106 | 107 | public function adminCheck($userid){ 108 | $userLogin = $this->db->prepare("SELECT * FROM Users WHERE Admin=1"); 109 | $result = $userLogin->execute(); 110 | 111 | while ($row = $result->fetchArray(SQLITE3_ASSOC)) { 112 | if ($row['Code'] == $userid && $userid != "") { 113 | return true; 114 | break; 115 | } 116 | } 117 | 118 | return false; 119 | } 120 | 121 | public function viewimage() { 122 | $file_location = (isset($_GET['img']) && $_GET['img'] != "") ? $_GET['img'] : " "; 123 | 124 | if (isset($file_location) && $file_location != "") { 125 | $imageFile = dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . $this->config->changeRoot . DIRECTORY_SEPARATOR . $file_location; 126 | 127 | $ext = $this->get_file_extension($imageFile); 128 | $ext = str_replace('.','',$ext); 129 | 130 | switch ($ext) { 131 | case "jpg": 132 | case "jpeg": 133 | $type = 'image/jpeg'; 134 | break; 135 | case "png": 136 | $type = 'image/png'; 137 | break; 138 | case "gif": 139 | $type = 'image/gif'; 140 | break; 141 | case "tiff": 142 | $type = 'image/tiff'; 143 | break; 144 | case "svg": 145 | $type = 'image/svg+xml'; 146 | break; 147 | case "bmp": 148 | $type = 'image/bmp'; 149 | break; 150 | } 151 | 152 | header('Content-Type:'.$type); 153 | header('Content-Length: ' . filesize($imageFile)); 154 | readfile($imageFile); 155 | } 156 | } 157 | 158 | public function get() { 159 | $file_location = (isset($_POST['fileLoc']) && $_POST['fileLoc'] != "") ? $_POST['fileLoc'] : " "; 160 | $usercode = (isset($_POST['usercode']) ? $_POST['usercode']:""); 161 | 162 | if (isset($file_location) && $file_location != "") { 163 | // Set root directory. 164 | $root = dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . $this->config->changeRoot; 165 | $prep_fileLoc = urldecode($_POST['fileLoc']); 166 | 167 | // Required: File location. 168 | if ($file_location == "app_config_fixed_path") { 169 | if ($this->adminCheck($usercode)) { 170 | $file_location = dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . $this->config->backdoorDir . DIRECTORY_SEPARATOR . 'config.json'; 171 | } else { 172 | return array( 173 | 'success' => false, 174 | 'statusMessage' => "You do not have admin access." 175 | ); 176 | } 177 | } else { 178 | $file_location = $root . DIRECTORY_SEPARATOR . $prep_fileLoc; 179 | } 180 | 181 | // Data provided from file location. 182 | $ext = $this->get_file_extension($file_location); 183 | $ext = str_replace('.','',$ext); 184 | 185 | if (array_key_exists($ext,$this->types)) { 186 | $format = $this->types[$ext]; 187 | 188 | if ($format != 'imageview') { 189 | $contents = file_get_contents($file_location); 190 | } else { 191 | $contents = $prep_fileLoc; 192 | } 193 | 194 | return array( 195 | 'success' => true, 196 | 'statusMessage' => "File found.", 197 | 'file' => array( 198 | "format" => $format, 199 | "content" => $contents 200 | ) 201 | ); 202 | } else { 203 | return array( 204 | 'success' => false, 205 | 'statusMessage' => "Unrecognizable file format." 206 | ); 207 | } 208 | } else { 209 | return array( 210 | 'success' => false, 211 | 'statusMessage' => "File not found." 212 | ); 213 | } 214 | } 215 | 216 | public function process($processType) { 217 | 218 | if (isset($processType) && $processType != "") { 219 | 220 | $file_location = (isset($_POST['fileLoc']) && $_POST['fileLoc'] != "") ? $_POST['fileLoc'] : ""; 221 | $misc_data = (isset($_POST['miscData']) && $_POST['miscData'] != "") ? $_POST['miscData'] : ""; 222 | 223 | if ($this->config->changeRoot != "") { 224 | $root = dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . $this->config->changeRoot; 225 | } else { 226 | $root = dirname(dirname(dirname(dirname(__FILE__)))); 227 | } 228 | 229 | if ($file_location == "app_config_fixed_path") { 230 | $item_type = "file"; 231 | $location = dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . $this->config->backdoorDir . DIRECTORY_SEPARATOR . 'config.json'; 232 | } else { 233 | $location = $root . DIRECTORY_SEPARATOR . str_replace($this->config->baseDir, "", $file_location); 234 | 235 | // Remove trailing forward slash. 236 | if (substr($location, -1) == '/') { 237 | $location = substr($location, 0, -1); 238 | } 239 | 240 | if (is_dir($location)) { 241 | // Folder Found 242 | $item_type = "folder"; 243 | } else { 244 | // File Found 245 | $item_type = "file"; 246 | } 247 | } 248 | 249 | $location = urldecode($location); 250 | 251 | // Run requested function. 252 | switch ($processType) { 253 | // Copy Process. 254 | case 'copyFile': 255 | $success = false; 256 | 257 | if ($item_type == "file") { 258 | if (file_exists($location)) { 259 | $file_name = basename($location); 260 | $file_ext = $this->get_file_extension($file_name); 261 | $bare_name = basename($location,$file_ext); 262 | $new_name = $bare_name."_copy".$file_ext; 263 | $new_location = dirname($location); 264 | $copy_to = $new_location . DIRECTORY_SEPARATOR . $new_name; 265 | 266 | if (copy($location,$copy_to)) { 267 | $success = true; 268 | $extra = $copy_to; 269 | chmod($copy_to, 0644); 270 | } 271 | } 272 | } else if ($item_type == "folder") { 273 | if ($this->recurse_copy($location, $location."_copy")) { 274 | $success = true; 275 | $extra = $location."_copy"; 276 | } 277 | } 278 | 279 | if ($success) { 280 | $return = array( 281 | "action" => $processType, 282 | "item" => $item_type, 283 | "statusMessage" => "File was successfully copied.", 284 | "success" => true 285 | ); 286 | } else { 287 | $return = array( 288 | "action" => $processType, 289 | "item" => $item_type, 290 | "statusMessage" => "There was an error copying file. ".$location." ", 291 | "success" => false 292 | ); 293 | } 294 | break; 295 | 296 | // Rename Process. ----------------------------------------------------- 297 | case 'renameFile': 298 | $success = false; 299 | 300 | $parent_dir = dirname($location); 301 | $rename_to = $parent_dir . DIRECTORY_SEPARATOR . $misc_data; 302 | 303 | if (rename($location, $rename_to)) { 304 | $success = true; 305 | $extra = $rename_to; 306 | chmod($rename_to, 0644); 307 | } 308 | 309 | if ($success) { 310 | $return = array( 311 | "action" => $processType, 312 | "item" => $item_type, 313 | "statusMessage" => "File was successfully renamed.", 314 | "success" => true 315 | ); 316 | } else { 317 | $return = array( 318 | "action" => $processType, 319 | "item" => $item_type, 320 | "statusMessage" => "There was an error renaming file.", 321 | "success" => false 322 | ); 323 | } 324 | break; 325 | 326 | // Delete Process. ----------------------------------------------------- 327 | case 'deleteFile': 328 | $success = false; 329 | $extra = $location; 330 | 331 | $devInfo = ""; 332 | 333 | if ($item_type == "file") { 334 | $devInfo .= "Delete file attempt - ".$location; 335 | if (file_exists($location)) { 336 | if (unlink($location)) { 337 | $success = true; 338 | } 339 | } 340 | } else if ($item_type == "folder") { 341 | $devInfo .= "Delete folder attempt - ".$location; 342 | if ($this->recurse_delete($location)) { 343 | $success = true; 344 | } 345 | } 346 | 347 | if ($success) { 348 | $return = array( 349 | "action" => $processType, 350 | "item" => $item_type, 351 | "statusMessage" => "File was successfully deleted. ".$devInfo, 352 | "success" => true 353 | ); 354 | } else { 355 | $return = array( 356 | "action" => $processType, 357 | "item" => $item_type, 358 | "statusMessage" => "There was an error deleting file. ".$devInfo, 359 | "success" => false 360 | ); 361 | } 362 | break; 363 | 364 | // New Folder Process. ----------------------------------------------------- 365 | case 'newFolder': 366 | $success = false; 367 | 368 | $new_folder_to = $location . DIRECTORY_SEPARATOR . $misc_data; 369 | 370 | if (mkdir($new_folder_to)) { 371 | $success = true; 372 | $extra = $new_folder_to; 373 | chmod($new_folder_to, 0755); 374 | } 375 | 376 | if ($success) { 377 | $return = array( 378 | "action" => $processType, 379 | "item" => "folder", 380 | "statusMessage" => "New folder was successfully created.", 381 | "success" => true 382 | ); 383 | } else { 384 | $return = array( 385 | "action" => $processType, 386 | "item" => "folder", 387 | "statusMessage" => "There was an error creating folder.", 388 | "success" => false 389 | ); 390 | } 391 | break; 392 | 393 | // CHMOD Process. ----------------------------------------------------- 394 | case 'changePermission': 395 | $success = false; 396 | $permission = (int) $misc_data; 397 | $extra = $location." set to ".$misc_data; 398 | 399 | if (chmod($location, $permission)) { 400 | $success = true; 401 | } 402 | 403 | if ($success) { 404 | $return = array( 405 | "action" => $processType, 406 | "item" => $item_type, 407 | "statusMessage" => "Permissions have been updated.", 408 | "success" => true 409 | ); 410 | } else { 411 | $return = array( 412 | "action" => $processType, 413 | "item" => $item_type, 414 | "statusMessage" => "There was an error changing permissions.", 415 | "success" => false 416 | ); 417 | } 418 | break; 419 | 420 | // Save Process. ----------------------------------------------------- 421 | case 'saveFile': 422 | case 'saveasFile': 423 | $success = false; 424 | 425 | $file_pointer = fopen($location,'w'); 426 | if (fwrite($file_pointer,$misc_data)) { 427 | $success = true; 428 | $extra = $location; 429 | } 430 | fclose($file_pointer); 431 | chmod($location, 0644); 432 | 433 | if ($success) { 434 | $return = array( 435 | "action" => $processType, 436 | "item" => "file", 437 | "statusMessage" => "File was successfully saved.", 438 | "success" => true 439 | ); 440 | } else { 441 | $return = array( 442 | "action" => $processType, 443 | "item" => "file", 444 | "statusMessage" => "There was an error saving file.", 445 | "success" => false 446 | ); 447 | } 448 | break; 449 | 450 | // Upload Process. ----------------------------------------------------- 451 | case 'upload': 452 | $success = false; 453 | 454 | if(isset($_FILES['file'])){ 455 | // Check if file is not undefined 456 | if ($_FILES['file']['name']) { 457 | // Denie unpermitted file types 458 | $denied_files = array(); 459 | if (!in_array($_FILES['file']['type'], $denied_files)) { 460 | //Get the temp file path 461 | $target_filename = $_FILES['file']['tmp_name']; 462 | 463 | //Make sure we have a filepath 464 | if ($target_filename != ""){ 465 | 466 | $newFilePath = $location . DIRECTORY_SEPARATOR . $_FILES['file']['name']; 467 | 468 | //Upload the file into the dir 469 | if(move_uploaded_file($target_filename, $newFilePath)) { 470 | 471 | chmod($newFilePath, 0644); 472 | 473 | return array( 474 | "item" => $item_type, 475 | 'location' => $newFilePath, 476 | 'statusMessage' => "You have successfully uploaded ".$_FILES['file']['name'].".", 477 | 'success' => true 478 | ); 479 | } else { 480 | return array( 481 | 'success' => false, 482 | 'statusMessage' => "There was an issue uploading file to server." 483 | ); 484 | } 485 | } 486 | } else { 487 | return array('success' => false,'statusMessage' => "File type not permitted."); 488 | } 489 | } else { 490 | return array('success' => false,'statusMessage' => "Please select file."); 491 | } 492 | } else { 493 | return array('success' => false,'statusMessage' => "Missing values."); 494 | } 495 | 496 | break; 497 | } 498 | 499 | return $return; 500 | } else { 501 | return array( 502 | 'success' => false, 503 | 'statusMessage' => "Missing values." 504 | ); 505 | } 506 | } 507 | } -------------------------------------------------------------------------------- /bkdr/dir-lister/DirectoryLister.php: -------------------------------------------------------------------------------- 1 | _appDir = __DIR__; 43 | 44 | // Build the application URL 45 | $this->_appURL = $this->_getAppUrl(); 46 | 47 | // Load the configuration file 48 | $configFile = $this->_appDir . '/config.php'; 49 | 50 | // Set the config array to a global variable 51 | if (file_exists($configFile)) { 52 | $this->_config = require_once($configFile); 53 | } else { 54 | die('ERROR: Missing application config file at ' . $configFile); 55 | } 56 | 57 | // Set the file types array to a global variable 58 | $this->_fileTypes = require_once($this->_appDir . '/fileTypes.php'); 59 | 60 | } 61 | 62 | /** 63 | * If it is allowed to zip whole directories 64 | * 65 | * @param string $directory Relative path of directory to list 66 | * @return true or false 67 | * @access public 68 | */ 69 | public function isZipEnabled() { 70 | foreach ($this->_config['zip_disable'] as $disabledPath) { 71 | if (fnmatch($disabledPath, $this->_directory)) { 72 | return false; 73 | } 74 | } 75 | return $this->_config['zip_dirs']; 76 | } 77 | 78 | /** 79 | * Creates zipfile of directory 80 | * 81 | * @param string $directory Relative path of directory to list 82 | * @access public 83 | */ 84 | public function zipDirectory($directory) { 85 | 86 | if ($this->_config['zip_dirs']) { 87 | 88 | // Cleanup directory path 89 | $directory = $this->setDirectoryPath($directory); 90 | 91 | if ($directory != '.' && $this->_isHidden($directory)) { 92 | echo "Access denied."; 93 | } 94 | 95 | $filename_no_ext = basename($directory); 96 | 97 | if ($directory == '.') { 98 | $filename_no_ext = 'Home'; 99 | } 100 | 101 | // We deliver a zip file 102 | header('Content-Type: archive/zip'); 103 | 104 | // Filename for the browser to save the zip file 105 | header("Content-Disposition: attachment; filename=\"$filename_no_ext.zip\""); 106 | 107 | //change directory so the zip file doesnt have a tree structure in it. 108 | chdir($directory); 109 | 110 | // TODO: Probably we have to parse exclude list more carefully 111 | $exclude_list = implode(' ', array_merge($this->_config['hidden_files'], array('index.php'))); 112 | $exclude_list = str_replace("*", "\*", $exclude_list); 113 | 114 | if ($this->_config['zip_stream']) { 115 | 116 | // zip the stuff (dir and all in there) into the streamed zip file 117 | $stream = popen('/usr/bin/zip -' . $this->_config['zip_compression_level'] . ' -r -q - * -x ' . $exclude_list, 'r'); 118 | 119 | if ($stream) { 120 | fpassthru($stream); 121 | fclose($stream); 122 | } 123 | 124 | } else { 125 | 126 | // get a tmp name for the .zip 127 | $tmp_zip = tempnam('tmp', 'tempzip') . '.zip'; 128 | 129 | // zip the stuff (dir and all in there) into the tmp_zip file 130 | exec('zip -' . $this->_config['zip_compression_level'] . ' -r ' . $tmp_zip . ' * -x ' . $exclude_list); 131 | 132 | // calc the length of the zip. it is needed for the progress bar of the browser 133 | $filesize = filesize($tmp_zip); 134 | header("Content-Length: $filesize"); 135 | 136 | // deliver the zip file 137 | $fp = fopen($tmp_zip, 'r'); 138 | echo fpassthru($fp); 139 | 140 | // clean up the tmp zip file 141 | unlink($tmp_zip); 142 | 143 | } 144 | } 145 | 146 | } 147 | 148 | 149 | /** 150 | * Creates the directory listing and returns the formatted XHTML 151 | * 152 | * @param string $directory Relative path of directory to list 153 | * @return array Array of directory being listed 154 | * @access public 155 | */ 156 | public function listDirectory($directory,$omit_path = null) { 157 | 158 | if ($omit_path != null) { 159 | $this->_omitPath = $omit_path; 160 | } 161 | 162 | // Set directory 163 | $directory = $this->setDirectoryPath($directory); 164 | 165 | // Set directory variable if left blank 166 | if ($directory === null) { 167 | $directory = $this->_directory; 168 | } 169 | 170 | // Get the directory array 171 | $directoryArray = $this->_readDirectory($directory); 172 | 173 | // Return the array 174 | return $directoryArray; 175 | } 176 | 177 | 178 | /** 179 | * Parses and returns an array of breadcrumbs 180 | * 181 | * @param string $directory Path to be breadcrumbified 182 | * @return array Array of breadcrumbs 183 | * @access public 184 | */ 185 | public function listBreadcrumbs($directory = null) { 186 | 187 | // Set directory variable if left blank 188 | if ($directory === null) { 189 | $directory = $this->_directory; 190 | } 191 | 192 | // Explode the path into an array 193 | $dirArray = explode('/', $directory); 194 | 195 | // Statically set the Home breadcrumb 196 | $breadcrumbsArray[] = array( 197 | 'link' => "", //'link' => $this->_appURL, 198 | 'text' => 'Home' 199 | ); 200 | 201 | // Generate breadcrumbs 202 | foreach ($dirArray as $key => $dir) { 203 | 204 | if ($dir != '.') { 205 | 206 | $dirPath = null; 207 | 208 | // Build the directory path 209 | for ($i = 0; $i <= $key; $i++) { 210 | $dirPath = $dirPath . $dirArray[$i] . '/'; 211 | } 212 | 213 | // Remove trailing slash 214 | if(substr($dirPath, -1) == '/') { 215 | $dirPath = substr($dirPath, 0, -1); 216 | } 217 | 218 | // Combine the base path and dir path 219 | // $link = $this->_appURL . '?dir=' . rawurlencode($dirPath); 220 | $path = rawurlencode($dirPath); 221 | 222 | $breadcrumbsArray[] = array( 223 | 'path' => $path, 224 | 'text' => $dir 225 | ); 226 | 227 | } 228 | 229 | } 230 | 231 | // Return the breadcrumb array 232 | return $breadcrumbsArray; 233 | } 234 | 235 | 236 | /** 237 | * Determines if a directory contains an index file 238 | * 239 | * @param string $dirPath Path to directory to be checked for an index 240 | * @return boolean Returns true if directory contains a valid index file, false if not 241 | * @access public 242 | */ 243 | public function containsIndex($dirPath) { 244 | 245 | // Check if directory contains an index file 246 | foreach ($this->_config['index_files'] as $indexFile) { 247 | 248 | if (file_exists($dirPath . '/' . $indexFile)) { 249 | 250 | return true; 251 | 252 | } 253 | 254 | } 255 | 256 | return false; 257 | 258 | } 259 | 260 | 261 | /** 262 | * Get path of the listed directory 263 | * 264 | * @return string Path of the listed directory 265 | * @access public 266 | */ 267 | public function getListedPath() { 268 | 269 | // Build the path 270 | if ($this->_directory == '.') { 271 | $path = $this->_appURL; 272 | } else { 273 | $path = $this->_appURL . $this->_directory; 274 | } 275 | 276 | // Return the path 277 | return $path; 278 | } 279 | 280 | 281 | /** 282 | * Returns open links in another window 283 | * 284 | * @return boolean Returns true if in config is enabled open links in another window, false if not 285 | * @access public 286 | */ 287 | public function externalLinksNewWindow() { 288 | return $this->_config['external_links_new_window']; 289 | } 290 | 291 | 292 | /** 293 | * Get an array of error messages or false when empty 294 | * 295 | * @return array|bool Array of error messages or false 296 | * @access public 297 | */ 298 | public function getSystemMessages() { 299 | if (isset($this->_systemMessage) && is_array($this->_systemMessage)) { 300 | return $this->_systemMessage; 301 | } else { 302 | return false; 303 | } 304 | } 305 | 306 | 307 | /** 308 | * Returns string of file size in human-readable format 309 | * 310 | * @param string $filePath Path to file 311 | * @return string Human-readable file size 312 | * @access public 313 | */ 314 | function getFileSize($filePath) { 315 | 316 | // Get file size 317 | $bytes = filesize($filePath); 318 | 319 | // Array of file size suffixes 320 | $sizes = array('B', 'KB', 'MB', 'GB', 'TB', 'PB'); 321 | 322 | // Calculate file size suffix factor 323 | $factor = floor((strlen($bytes) - 1) / 3); 324 | 325 | // Calculate the file size 326 | $fileSize = sprintf('%.2f', $bytes / pow(1024, $factor)) . $sizes[$factor]; 327 | 328 | return $fileSize; 329 | 330 | } 331 | 332 | 333 | /** 334 | * Returns array of file hash values 335 | * 336 | * @param string $filePath Path to file 337 | * @return array Array of file hashes 338 | * @access public 339 | */ 340 | public function getFileHash($filePath) { 341 | 342 | // Placeholder array 343 | $hashArray = array(); 344 | 345 | // Verify file path exists and is a directory 346 | if (!file_exists($filePath)) { 347 | return json_encode($hashArray); 348 | } 349 | 350 | // Prevent access to hidden files 351 | if ($this->_isHidden($filePath)) { 352 | return json_encode($hashArray); 353 | } 354 | 355 | // Prevent access to parent folders 356 | if (strpos($filePath, '<') !== false || strpos($filePath, '>') !== false 357 | || strpos($filePath, '..') !== false || strpos($filePath, '/') === 0) { 358 | return json_encode($hashArray); 359 | } 360 | 361 | // Prevent hashing if file is too big 362 | if (filesize($filePath) > $this->_config['hash_size_limit']) { 363 | 364 | // Notify user that file is too large 365 | $hashArray['md5'] = '[ File size exceeds threshold ]'; 366 | $hashArray['sha1'] = '[ File size exceeds threshold ]'; 367 | 368 | } else { 369 | 370 | // Generate file hashes 371 | $hashArray['md5'] = hash_file('md5', $filePath); 372 | $hashArray['sha1'] = hash_file('sha1', $filePath); 373 | 374 | } 375 | 376 | // Return the data 377 | return $hashArray; 378 | 379 | } 380 | 381 | 382 | /** 383 | * Set directory path variable 384 | * 385 | * @param string $path Path to directory 386 | * @return string Sanitizd path to directory 387 | * @access public 388 | */ 389 | public function setDirectoryPath($path = null) { 390 | 391 | // Set the directory global variable 392 | $this->_directory = $this->_setDirectoryPath($path); 393 | 394 | return $this->_directory; 395 | 396 | } 397 | 398 | /** 399 | * Get directory path variable 400 | * 401 | * @return string Sanitizd path to directory 402 | * @access public 403 | */ 404 | public function getDirectoryPath() { 405 | return $this->_directory; 406 | } 407 | 408 | 409 | /** 410 | * Add a message to the system message array 411 | * 412 | * @param string $type The type of message (ie - error, success, notice, etc.) 413 | * @param string $message The message to be displayed to the user 414 | * @return bool true on success 415 | * @access public 416 | */ 417 | public function setSystemMessage($type, $text) { 418 | 419 | // Create empty message array if it doesn't already exist 420 | if (isset($this->_systemMessage) && !is_array($this->_systemMessage)) { 421 | $this->_systemMessage = array(); 422 | } 423 | 424 | // Set the error message 425 | $this->_systemMessage[] = array( 426 | 'type' => $type, 427 | 'text' => $text 428 | ); 429 | 430 | return true; 431 | } 432 | 433 | 434 | /** 435 | * Validates and returns the directory path 436 | * 437 | * @param string $dir Directory path 438 | * @return string Directory path to be listed 439 | * @access protected 440 | */ 441 | protected function _setDirectoryPath($dir) { 442 | 443 | // Check for an empty variable 444 | if (empty($dir) || $dir == '.') { 445 | return '.'; 446 | } 447 | 448 | // Eliminate double slashes 449 | while (strpos($dir, '//')) { 450 | $dir = str_replace('//', '/', $dir); 451 | } 452 | 453 | // Remove trailing slash if present 454 | if(substr($dir, -1, 1) == '/') { 455 | $dir = substr($dir, 0, -1); 456 | } 457 | 458 | // Verify file path exists and is a directory 459 | if (!file_exists($dir) || !is_dir($dir)) { 460 | // Set the error message 461 | $this->setSystemMessage('danger', 'ERROR: File path does not exist'); 462 | 463 | // Return the web root 464 | return '.'; 465 | } 466 | 467 | // Prevent access to hidden files 468 | if ($this->_isHidden($dir)) { 469 | // Set the error message 470 | $this->setSystemMessage('danger', 'ERROR: Access denied'); 471 | 472 | // Set the directory to web root 473 | return '.'; 474 | } 475 | 476 | // Prevent access to parent folders 477 | if (strpos($dir, '<') !== false || strpos($dir, '>') !== false 478 | || strpos($dir, '..') !== false || strpos($dir, '/') === 0) { 479 | // Set the error message 480 | $this->setSystemMessage('danger', 'ERROR: An invalid path string was detected'); 481 | 482 | // Set the directory to web root 483 | return '.'; 484 | } else { 485 | // Should stop all URL wrappers (Thanks to Hexatex) 486 | $directoryPath = $dir; 487 | } 488 | 489 | // Return 490 | return $directoryPath; 491 | } 492 | 493 | 494 | /** 495 | * Loop through directory and return array with file info, including 496 | * file path, size, modification time, icon and sort order. 497 | * 498 | * @param string $directory Directory path 499 | * @param string $sort Sort method (default = natcase) 500 | * @return array Array of the directory contents 501 | * @access protected 502 | */ 503 | protected function _readDirectory($directory, $sort = 'natcase') { 504 | 505 | // Initialize array 506 | $directoryArray = array(); 507 | 508 | // Get directory contents 509 | $files = scandir($directory); 510 | 511 | // Read files/folders from the directory 512 | foreach ($files as $file) { 513 | 514 | if ($file != '.') { 515 | 516 | // Get files relative path 517 | $relativePath = $directory . '/' . $file; 518 | 519 | if (substr($relativePath, 0, 2) == './') { 520 | $relativePath = substr($relativePath, 2); 521 | } 522 | 523 | // Don't check parent dir if we're in the root dir 524 | if ($this->_directory == '.' && $file == '..'){ 525 | 526 | continue; 527 | 528 | } else { 529 | 530 | // Get files absolute path 531 | $realPath = realpath($relativePath); 532 | 533 | // Determine file type by extension 534 | if (is_dir($realPath)) { 535 | $iconClass = 'fa-folder'; 536 | $sort = 1; 537 | } else { 538 | // Get file extension 539 | $fileExt = strtolower(pathinfo($realPath, PATHINFO_EXTENSION)); 540 | 541 | if (isset($this->_fileTypes[$fileExt])) { 542 | $iconClass = $this->_fileTypes[$fileExt]; 543 | } else { 544 | $iconClass = $this->_fileTypes['blank']; 545 | } 546 | 547 | $sort = 2; 548 | } 549 | 550 | $handler = ""; 551 | switch($iconClass) { 552 | case "fa-file-code-o": 553 | $handler = "editor"; 554 | break; 555 | case "fa-music": 556 | case "fa-youtube-play": 557 | $handler = "player"; 558 | break; 559 | case "fa-folder": 560 | $handler = "folder"; 561 | break; 562 | default: 563 | $handler = "file"; 564 | break; 565 | } 566 | 567 | } 568 | 569 | // if ($file == '..') { 570 | 571 | // if ($this->_directory != '.') { 572 | // // Get parent directory path 573 | // $pathArray = explode('/', $relativePath); 574 | // unset($pathArray[count($pathArray)-1]); 575 | // unset($pathArray[count($pathArray)-1]); 576 | // $directoryPath = implode('/', $pathArray); 577 | 578 | // if (!empty($directoryPath)) { 579 | // $directoryPath = '?dir=' . rawurlencode($directoryPath); 580 | // } 581 | 582 | // // Add file info to the array 583 | // $directoryArray['..'] = array( 584 | // 'file_path' => $this->_appURL . $directoryPath, 585 | // 'url_path' => $this->_appURL . $directoryPath, 586 | // 'file_size' => '-', 587 | // 'mod_time' => date('Y-m-d H:i:s', filemtime($realPath)), 588 | // 'icon_class' => 'fa-level-up', 589 | // 'sort' => 0 590 | // ); 591 | // } 592 | 593 | // } else 594 | 595 | if (!$this->_isHidden($relativePath)) { 596 | 597 | // Add all non-hidden files to the array 598 | if ($this->_directory != '.' || $file != 'index.php') { 599 | 600 | // Build the file path 601 | $urlPath = implode('/', array_map('rawurlencode', explode('/', $relativePath))); 602 | 603 | // if (is_dir($relativePath)) { 604 | // $urlPath = '?dir=' . $urlPath; 605 | // } else { 606 | // $urlPath = $urlPath; 607 | // } 608 | 609 | // Add the info to the main array 610 | $directoryArray[pathinfo($relativePath, PATHINFO_BASENAME)] = array( 611 | 'file_path' => $relativePath, 612 | 'url_path' => $urlPath, 613 | 'permission' => @substr(sprintf('%o', fileperms($relativePath)), -4), 614 | 'file_size' => is_dir($realPath) ? '-' : $this->getFileSize($realPath), 615 | 'mod_time' => date('Y-m-d H:i:s', filemtime($realPath)), 616 | 'icon_class' => $iconClass, 617 | 'sort' => $sort, 618 | 'handler' => $handler 619 | ); 620 | } 621 | 622 | } 623 | } 624 | 625 | } 626 | 627 | // Sort the array 628 | $reverseSort = in_array($this->_directory, $this->_config['reverse_sort']); 629 | $sortedArray = $this->_arraySort($directoryArray, $this->_config['list_sort_order'], $reverseSort); 630 | 631 | // Return the array 632 | return $sortedArray; 633 | 634 | } 635 | 636 | 637 | /** 638 | * Sorts an array by the provided sort method. 639 | * 640 | * @param array $array Array to be sorted 641 | * @param string $sortMethod Sorting method (acceptable inputs: natsort, natcasesort, etc.) 642 | * @param boolen $reverse Reverse the sorted array order if true (default = false) 643 | * @return array 644 | * @access protected 645 | */ 646 | protected function _arraySort($array, $sortMethod, $reverse = false) { 647 | // Create empty arrays 648 | $sortedArray = array(); 649 | $finalArray = array(); 650 | 651 | // Create new array of just the keys and sort it 652 | $keys = array_keys($array); 653 | 654 | switch ($sortMethod) { 655 | case 'asort': 656 | asort($keys); 657 | break; 658 | case 'arsort': 659 | arsort($keys); 660 | break; 661 | case 'ksort': 662 | ksort($keys); 663 | break; 664 | case 'krsort': 665 | krsort($keys); 666 | break; 667 | case 'natcasesort': 668 | natcasesort($keys); 669 | break; 670 | case 'natsort': 671 | natsort($keys); 672 | break; 673 | case 'shuffle': 674 | shuffle($keys); 675 | break; 676 | } 677 | 678 | // Loop through the sorted values and move over the data 679 | if ($this->_config['list_folders_first']) { 680 | 681 | foreach ($keys as $key) { 682 | if ($array[$key]['sort'] == 0) { 683 | $sortedArray['0'][$key] = $array[$key]; 684 | } 685 | } 686 | 687 | foreach ($keys as $key) { 688 | if ($array[$key]['sort'] == 1) { 689 | $sortedArray[1][$key] = $array[$key]; 690 | } 691 | } 692 | 693 | foreach ($keys as $key) { 694 | if ($array[$key]['sort'] == 2) { 695 | $sortedArray[2][$key] = $array[$key]; 696 | } 697 | } 698 | 699 | if ($reverse) { 700 | $sortedArray[1] = array_reverse($sortedArray[1]); 701 | $sortedArray[2] = array_reverse($sortedArray[2]); 702 | } 703 | 704 | } else { 705 | 706 | foreach ($keys as $key) { 707 | if ($array[$key]['sort'] == 0) { 708 | $sortedArray[0][$key] = $array[$key]; 709 | } 710 | } 711 | 712 | foreach ($keys as $key) { 713 | if ($array[$key]['sort'] > 0) { 714 | $sortedArray[1][$key] = $array[$key]; 715 | } 716 | } 717 | 718 | if ($reverse) { 719 | $sortedArray[1] = array_reverse($sortedArray[1]); 720 | } 721 | 722 | } 723 | 724 | // Merge the arrays 725 | foreach ($sortedArray as $array) { 726 | if (empty($array)) continue; 727 | foreach ($array as $key => $value) { 728 | $finalArray[$key] = $value; 729 | } 730 | } 731 | 732 | // Return sorted array 733 | return $finalArray; 734 | 735 | } 736 | 737 | 738 | /** 739 | * Determines if a file is specified as hidden 740 | * 741 | * @param string $filePath Path to file to be checked if hidden 742 | * @return boolean Returns true if file is in hidden array, false if not 743 | * @access protected 744 | */ 745 | protected function _isHidden($filePath) { 746 | 747 | // Add dot files to hidden files array 748 | if ($this->_config['hide_dot_files']) { 749 | 750 | $this->_config['hidden_files'] = array_merge( 751 | $this->_config['hidden_files'], 752 | array('.*', '*/.*') 753 | ); 754 | 755 | } 756 | 757 | // Compare path array to all hidden file paths 758 | foreach ($this->_config['hidden_files'] as $hiddenPath) { 759 | 760 | if (fnmatch($hiddenPath, $filePath) && !fnmatch($hiddenPath, $this->_omitPath)) { 761 | 762 | return true; 763 | 764 | } 765 | 766 | } 767 | 768 | return false; 769 | 770 | } 771 | 772 | 773 | /** 774 | * Builds the root application URL from server variables. 775 | * 776 | * @return string The application URL 777 | * @access protected 778 | */ 779 | protected function _getAppUrl() { 780 | 781 | // Get the server protocol 782 | if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') { 783 | $protocol = 'https://'; 784 | } else { 785 | $protocol = 'http://'; 786 | } 787 | 788 | // Get the server hostname 789 | $host = $_SERVER['HTTP_HOST']; 790 | 791 | // Get the URL path 792 | $pathParts = pathinfo($_SERVER['PHP_SELF']); 793 | $path = $pathParts['dirname']; 794 | 795 | // Remove backslash from path (Windows fix) 796 | if (substr($path, -1) == '\\') { 797 | $path = substr($path, 0, -1); 798 | } 799 | 800 | // Ensure the path ends with a forward slash 801 | if (substr($path, -1) != '/') { 802 | $path = $path . '/'; 803 | } 804 | 805 | // Build the application URL 806 | $appUrl = $protocol . $host . $path; 807 | 808 | // Return the URL 809 | return $appUrl; 810 | } 811 | 812 | 813 | /** 814 | * Compares two paths and returns the relative path from one to the other 815 | * 816 | * @param string $fromPath Starting path 817 | * @param string $toPath Ending path 818 | * @return string $relativePath Relative path from $fromPath to $toPath 819 | * @access protected 820 | */ 821 | protected function _getRelativePath($fromPath, $toPath) { 822 | 823 | // Define the OS specific directory separator 824 | if (!defined('DS')) define('DS', DIRECTORY_SEPARATOR); 825 | 826 | // Remove double slashes from path strings 827 | $fromPath = str_replace(DS . DS, DS, $fromPath); 828 | $toPath = str_replace(DS . DS, DS, $toPath); 829 | 830 | // Explode working dir and cache dir into arrays 831 | $fromPathArray = explode(DS, $fromPath); 832 | $toPathArray = explode(DS, $toPath); 833 | 834 | // Remove last fromPath array element if it's empty 835 | $x = count($fromPathArray) - 1; 836 | 837 | if(!trim($fromPathArray[$x])) { 838 | array_pop($fromPathArray); 839 | } 840 | 841 | // Remove last toPath array element if it's empty 842 | $x = count($toPathArray) - 1; 843 | 844 | if(!trim($toPathArray[$x])) { 845 | array_pop($toPathArray); 846 | } 847 | 848 | // Get largest array count 849 | $arrayMax = max(count($fromPathArray), count($toPathArray)); 850 | 851 | // Set some default variables 852 | $diffArray = array(); 853 | $samePath = true; 854 | $key = 1; 855 | 856 | // Generate array of the path differences 857 | while ($key <= $arrayMax) { 858 | 859 | // Get to path variable 860 | $toPath = isset($toPathArray[$key]) ? $toPathArray[$key] : null; 861 | 862 | // Get from path variable 863 | $fromPath = isset($fromPathArray[$key]) ? $fromPathArray[$key] : null; 864 | 865 | if ($toPath !== $fromPath || $samePath !== true) { 866 | 867 | // Prepend '..' for every level up that must be traversed 868 | if (isset($fromPathArray[$key])) { 869 | array_unshift($diffArray, '..'); 870 | } 871 | 872 | // Append directory name for every directory that must be traversed 873 | if (isset($toPathArray[$key])) { 874 | $diffArray[] = $toPathArray[$key]; 875 | } 876 | 877 | // Directory paths have diverged 878 | $samePath = false; 879 | } 880 | 881 | // Increment key 882 | $key++; 883 | } 884 | 885 | // Set the relative thumbnail directory path 886 | $relativePath = implode('/', $diffArray); 887 | 888 | // Return the relative path 889 | return $relativePath; 890 | 891 | } 892 | 893 | } 894 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | --------------------------------------------------------------------------------