KodExplorer Documentation

repository·master·Indexed 27 days ago

https://github.com/kalcaddle/kodexplorer

A web-based file manager and code editor for remote server management and website development. Supports Linux, Windows, and Mac with PHP 5+ requirements. Features include a built-in code editor with Ace integration, plugin support for media players like DPlayer and VLC, and comprehensive localization systems. Note: KodExplorer is in maintenance mode; active development has moved to Kodbox.

Tokens
9.3K
Snippets
14
Records
32
Agent score
92%

What's inside KodExplorer

  1. Install KodExplorer via download

    master

    To install KodExplorer by downloading the master zip archive, use wget to fetch the file, unzip it, and set the directory permissions.

    wget https://github.com/kalcaddle/KODExplorer/archive/master.zip
    unzip master.zip
    chmod -Rf 777 ./*
  2. Software requirements for KodExplorer

    master

    Before installing, ensure your environment meets the following requirements:

    Server Requirements

    • Operating Systems: Windows, Linux, Mac, or even routers/home NAS.
    • PHP: Version 5.0 or higher.
    • Database: Supports File system driver, SQLite, MySQL, and others.

    Browser Compatibility

    • Chrome
    • Firefox
    • Opera
    • IE8+
  3. Secure your KodExplorer installation

    master

    To improve the security of your KodExplorer instance, follow these best practices:

    1. Password Complexity: Ensure the administrator password is complex.
    2. Verification Code: Enable the login verification code.
    3. Directory Listing: Configure your HTTP server to disallow directory listing.
    4. PHP Security: Set the open_basedir path in your PHP configuration to restrict file access.
  4. Use kodApp.open() to trigger application logic

    master

    The kodApp.open() method is the primary way to programmatically trigger the opening of a file or folder using its registered application handler.

    Signature: kodApp.open(path, ext, appName)

    • path: The file or folder path.
    • ext: The file extension (optional).
    • appName: The name of the application to use (optional).
  5. Initialize Ace Code Editor with `initCodeEditor`

    master

    To embed a code editor in a form, use initCodeEditor. This function asynchronously loads the Ace editor library, enables language tools, and sets up Emmet support.

    Requirements:

    • A textarea element with the class .form-codeEditor.
    • Optional data attributes on the parent: data-theme (default: tomorrow), data-mode (default: javascript), data-font-size (default: 14).

    Features enabled by default:

    • Emmet support
    • Snippets
    • Basic Autocompletion
    • Live Autocompletion
    • Custom command: Ctrl-alt-G (or Ctrl-command-G on Mac) to preview.
  6. Manage application associations with kodApp

    master

    The kodApp module provides a central registry for managing file associations and application behaviors within the explorer. Developers can register new applications, manage which applications handle specific file extensions, and set default handlers for users.

    Key capabilities:

    • Registering apps: Use add() to register a new application with a name, title, icon, and callback function.
    • File associations: Use addSupportSet() to associate an application with specific file extensions.
    • Retrieving apps: Use getApp() to find an application by its extension or getAppMenu() to retrieve the menu configuration for a specific file type.
    • User defaults: Use setOpenUser() to set a specific application as the default for a user, or setOpenUserLocal() for local-only settings.
  7. Extract form data using `getFormData`

    master

    The getFormData function iterates through all .form-row elements within the current $wrap context to collect values based on their data-type. It handles various input types including:

    • input, textarea, password, number, slider, color, dateTime, segment, citypicker, fileSelect (returns .val())
    • codeEditor (returns value from Ace editor instance)
    • switch (returns 0 or 1)
    • radio (returns checked value)
    • checkbox (returns comma-separated values)
    • select, selectMutil, tags, group, role, user (returns .val(), joining arrays with commas)
    • userSelect (returns a formatted string: all:all_val;user:user_val;group:group_val;role:role_val)

    If a field is marked as require in itemsConfig and is empty, getFormData will mark the row with an .error class and return checked: 0.

  8. Use `bindFileSelect` for file path selection

    master

    bindFileSelect enables a file/image picker for elements with the .path-select class. It uses core.api.pathSelect to open a selection interface.

    Configuration: Pass configuration via a data-info attribute on the input, which should be a JSON string. Supported keys include:

    • type: (default file)
    • title: (default LNG.path_api_select_image)
    • allowExt: Pipe-separated extensions (e.g., png|jpg|bmp)
    • result: The format of the returned value (e.g., url or path)

    Example:

    <div class="path-select">
      <input type="text" data-info='{"allowExt":"png|jpg", "result":"url"}'>
      <button class="btn">Select</button>
    </div>
  9. Configure file extension support with kodApp.appSupportSet()

    master

    Use kodApp.appSupportSet() to associate an application with multiple file extensions and define their sort order.

    Parameters:

    • appName: The name of the application.
    • extensions: An array or comma-separated string of extensions.
    • sort: (Optional) Integer defining the priority of the association.
  10. Implement the DPlayer plugin entrypoint

    master

    The DPlayerPlugin class extends PluginBase to provide video playback capabilities using DPlayer. It registers a hook on user.commonJs.insert to inject the plugin's JavaScript assets into the user interface. When the hook is triggered, the plugin checks for file extension compatibility via isFileExtence and then serves the client-side logic located at static/main.js using echoFile.

    <?php
    
    class DPlayerPlugin extends PluginBase{
    	function __construct(){
    		parent::__construct();
    	}
    	public function regiest(){
    		$this->hookRegiest(array(
    			'user.commonJs.insert' => 'DPlayerPlugin.echoJs',
    		));
    	}
    	public function echoJs($st,$act){
    		if($this->isFileExtence($st,$act)){
    			$this->echoFile('static/main.js');
    		}
    	}
    }