PbootCMS Documentation

repository·master·Indexed 43 days ago

https://github.com/pbootcmspro/pbootcms

An open-source, high-performance PHP CMS for enterprise website development. It features a lightweight template tag system, supports SQLite and MySQL, and provides built-in API authentication, custom form handling, and UEditor integration. Supports PHP versions 7.4 through 8.5.

Tokens
4K
Snippets
11
Records
17
Agent score
55%

What's inside PbootCMS

  1. Configure URL Rewriting (Pseudo-static) for PbootCMS

    master

    To enable clean URLs (pseudo-static) and remove index.php from your URLs, you must copy the appropriate rewrite rules from the rewrite/ directory to your website's root directory based on your web server environment.

    Apache

    Use the .htaccess file provided in the rewrite/ directory. Note that the rules may contain different configurations depending on your specific setup; ensure you select the one matching your environment.

    IIS (7+)

    Use the web.config file provided in the rewrite/ directory. For older IIS6 environments, you will need to configure rewrite rules manually.

    Nginx

    Nginx does not use configuration files in the web root like Apache. You must modify your server configuration block (usually in nginx.conf or your site-specific config) to handle the rewrite. You can search for "nginx 隐藏index.php" (nginx hide index.php) for specific implementation patterns.

  2. Use PbootCMS template tags

    master

    PbootCMS uses a simple template tag system that allows developers to render site data using HTML-like syntax.

    Global Tags

    Used for site-wide information:

    • {pboot:sitetitle}: Renders the site title.
    • {pboot:sitelogo}: Renders the site logo.

    List Page Tags

    Used to iterate through content lists. The num attribute defines the count, and order defines the sorting criteria (e.g., date):

    {pboot:list num=10 order=date}
        <p><a href="[list:link]">[list:title]</a></p>
    {/pboot:list}

    Note: Inside the loop, use [list:field] to access specific item properties like link or title.

    Content Page Tags

    Used within single content pages to display specific fields:

    • {content:title}: Title
    • {content:subtitle}: Subtitle
    • {content:author}: Author
    • {content:source}: Source
  3. Upgrade PbootCMS

    master

    There are two primary methods for upgrading PbootCMS:

    Use the built-in administration panel to perform an online upgrade. This method supports cross-version upgrades and automatically handles both database migrations and code file updates.

    2. Full Package Upgrade

    This method involves replacing the entire source code with a new version.

    • Preserved Directories: config, data, static, and template will be kept.
    • Replaced Directories: All other directories are replaced by the new version.
    • Manual Database Migration: If the upgrade path involves intermediate versions that required database changes, you must manually execute the corresponding database upgrade scripts found in the /script/ directory (e.g., mysql-... or sqlite-...) for the version higher than your current site version.
  4. Install PbootCMS

    master

    PbootCMS is a PHP-based CMS that defaults to using SQLite, allowing for immediate use by simply uploading the source code to a PHP environment.

    Requirements:

    • PHP Version: Minimum 7.4, recommended 8.4, supports up to 8.5.

    Switching to MySQL: If you prefer MySQL over the default SQLite:

    1. Import the database file located at /static/backup/sql/pbootcms.sql into your MySQL server.
    2. Update the database connection settings in config/database.

    Default Admin Credentials:

    • URL: http://<your-ip>/admin.php
    • Username: admin
    • Password: 123456
    http://ip/admin.php
    Account: admin
    Password: 123456
  5. Authenticate API requests using appid, timestamp, and signature

    master

    To access PbootCMS API endpoints, clients must include three specific parameters in their requests: appid, timestamp, and signature.

    If api_auth is enabled in the system configuration, the request must pass the following validation logic:

    1. Parameters: The request must contain appid, timestamp, and signature.
    2. Signature Generation: The signature is generated by concatenating the appid, secret, and timestamp into a single string, then applying a double MD5 hash.
    3. Timestamp Validation: The timestamp must be within 15 seconds of the current server time to prevent replay attacks.
    4. Configuration: The system requires api_open, api_appid, and api_secret to be correctly configured in the admin backend.
    // Logic for signature generation:
    $signature = md5(md5($config['api_appid'] . $config['api_secret'] . $timestamp));
  6. Configure UEditor base paths and server URL

    master

    UEditor requires configuration of its resource paths and the server-side controller.

    • UEDITOR_HOME_URL: The root path for editor resource files (dialogs, etc.). It is highly recommended to use a relative path starting with a slash (e.g., /myProject/ueditor/). If multiple pages use different UEditor instances, you can override this by setting window.UEDITOR_HOME_URL at the top of the specific page.
    • UEDITOR_CORS_URL: The path used for CORS requests.
    • serverUrl: The path to the server-side PHP controller that handles file uploads and other requests. By default, it is set to URL + "php/controller.php".
    window.UEDITOR_HOME_URL = "/your/custom/path/";
    
    window.UEDITOR_CONFIG = {
      UEDITOR_HOME_URL: "/your/custom/path/",
      serverUrl: "/your/custom/path/php/controller.php"
    };
  7. Configure word count and limits

    master

    Control the word count feature in the editor:

    • wordCount: Boolean. Enables or disables the word count display (default: true).
    • maximumWords: Number. The maximum allowed character count (default: 10000).
    • wordCountMsg: String. Custom message for current count. Use {#count} for current count and {#leave} for remaining characters.
    • wordOverFlowMsg: String. Custom message when the limit is exceeded.
    window.UEDITOR_CONFIG = {
      wordCount: true,
      maximumWords: 5000,
      wordCountMsg: 'Current: {#count}, Remaining: {#leave}'
    };
  8. Customize the UEditor toolbar

    master

    The toolbars option in UEDITOR_CONFIG defines the buttons and dropdowns available in the editor's toolbar. It accepts an array of arrays, where each inner array represents a row of buttons. You can include commands like bold, italic, insertimage, link, etc.

    To customize the toolbar, modify the toolbars array in the UEDITOR_CONFIG object. You can also use toolbarCallback to intercept button clicks and execute custom logic.

    window.UEDITOR_CONFIG = {
      toolbars: [
        [
          "fullscreen", "source", "|", "undo", "redo", "|", "bold", "italic"
        ]
      ],
      toolbarCallback: function (cmd, editor) {
        if (cmd === 'insertimage') {
          // Custom logic for image insertion
          return true; // Return true to prevent default behavior
        }
      }
    };
  9. Configure API access requirements

    master

    API access is controlled via the system configuration. To enable and secure remote data access, ensure the following keys are set in your configuration:

    • api_open: Boolean flag to enable the API functionality globally.
    • api_auth: Boolean flag to enable authentication requirements.
    • api_appid: The unique identifier for the API client.
    • api_secret: The secret key used for signature generation.

    If api_auth is enabled, all requests must include appid, timestamp, and signature as described in the authentication guide.

  10. Configure image and video insertion

    master

    You can control how images and videos are handled via imageConfig and videoConfig within UEDITOR_CONFIG.

    Image Configuration (imageConfig):

    • disableUpload: Boolean. If true, prevents local file uploads.
    • disableOnline: Boolean. If true, prevents online management.
    • selectCallback: A function used to provide custom image selection logic.

    Video Configuration (videoConfig):

    • disableUpload: Boolean. If true, prevents local file uploads.
    • selectCallback: A function used to provide custom video selection logic.
    window.UEDITOR_CONFIG = {
      imageConfig: {
        disableUpload: false,
        disableOnline: false,
        selectCallback: function(editor, cb) {
          // Custom selection logic
          cb({ path: 'url_to_image', name: 'image_name' });
        }
      },
      videoConfig: {
        disableUpload: false,
        selectCallback: null
      }
    };
  11. Configure editor appearance and dimensions

    master

    Adjust the initial visual state of the editor:

    • initialFrameWidth: Number. Initial width in pixels (default: 1000).
    • initialFrameHeight: Number. Initial height in pixels (default: 320).
    • initialStyle: String. Custom CSS for the editing area (e.g., p{line-height:1em}).
    • readonly: Boolean. If true, the editor is read-only (default: false).
    • focus: Boolean. If true, the editor gains focus on initialization (default: false).
    • fullscreen: Boolean. If true, starts in fullscreen mode (default: false).
    window.UEDITOR_CONFIG = {
      initialFrameWidth: 800,
      initialFrameHeight: 500,
      initialStyle: 'p{line-height:1.5em}',
      readonly: false,
      focus: true
    };
  12. Configure automatic typesetting (autotypeset)

    master

    The autotypeset object allows you to define rules for cleaning up content, often used when pasting from Word or other sources.

    Key options include:

    • mergeEmptyline: Boolean. Merges empty lines.
    • textAlign: String. Sets paragraph alignment (left, right, center, justify).
    • imageBlockLine: String. Sets image float behavior (center, left, right, none).
    • pasteFilter: Boolean. Enables filtering of pasted content.
    • removeEmptyNode: Boolean. Removes empty nodes.
    • indentValue: String. Sets the indentation value (e.g., '2em').
    window.UEDITOR_CONFIG = {
      autotypeset: {
        mergeEmptyline: true,
        textAlign: "left",
        imageBlockLine: "center",
        pasteFilter: true,
        indentValue: "2em"
      }
    };