FoolFuuka

repository·master·Indexed 42 days ago

https://github.com/foolcode/foolfuuka

An image-based bulletin board system and front-end interface for Asagi. It includes a JSON API for interacting with boards, threads, and posts, as well as comprehensive tools for moderation, user banning, and search filtering.

Tokens
8.3K
Snippets
30
Records
54
Agent score
53%

What's inside FoolFuuka

  1. Overview of FoolFuuka

    master

    FoolFuuka is a software package designed for two primary purposes:

    1. Image-based bulletin board software: Functions as a platform for image-centric discussion boards.
    2. Asagi front-end interface: Provides a functional front-end interface for Asagi.
  2. Extend comment processing via Hooks

    master

    The Comment model uses a hook system to allow developers to intercept and modify various aspects of the comment during processing. This is useful for custom BBCode definitions, link handling, or modifying specific fields like the poster's name or tripcode.

    Available hook points include:

    • Foolz\FoolFuuka\Model\Comment::processComment#var.greentext: Modify the greentext HTML pattern.
    • Foolz\FoolFuuka\Model\Comment::processComment#var.originalComment: Modify the original comment text before sanitization.
    • Foolz\FoolFuuka\Model\Comment::processCommentBBCode#var.definitions: Add custom BBCode definitions.
    • Foolz\FoolFuuka\Model\Comment::processComment#var.processedComment: Modify the final processed comment string.
    • Foolz\FoolFuuka\Model\Comment::processInternalLinks#var.link: Customize the HTML attributes/tags for internal links (>>).
    • Foolz\FoolFuuka\Model\Comment::processExternalLinks#var.link: Customize the HTML attributes/tags for external links (>>>).
  3. Search for posts using the Search model

    master
    The Search class (extending Board) provides functionality to query posts across boards using SphinxQL. While the primary logic is encapsulated in protected methods like p_getSearch and p_getResults, the model is designed to be used within the FoolFuuka framework to fetch results based on various criteria such as text, subject, username, date ranges, and post types.
  4. Access Radix-specific routes

    master

    The Chan controller uses a routing pattern where methods prefixed with radix_ are called when a radix (a board or archive) is identified in the request attributes via radix_shortname.

    Common radix-prefixed actions include:

    • radix_page($page): Displays the board/archive page with a specific pagination.
    • radix_thread($num): Displays a specific thread by its number.
    • radix_gallery($page): Displays an image gallery for the radix.
    • radix_post($num): Redirects or displays a specific post.
    • radix_search(): Performs a search scoped to the current radix.
    • radix_image(): Handles image hash lookups.
    • radix_last($limit, $num): Fetches the last X posts.
  5. Manage media files with the Media class

    master

    The Media class is the primary model for managing media files and their associated database records in FoolFuuka. It handles file uploads, thumbnail generation, banning, and link generation. It is typically instantiated via a CommentBulk object which provides the context of the media (e.g., whether it belongs to an opening post or a reply) and its associated Radix (board).

    Key capabilities include:

    • Link Generation: Retrieve full media links, thumbnail links, or download links.
    • File Management: Delete files, ban media globally or per-board, and manage file paths.
    • Upload Processing: Insert new media files, generate thumbnails, and handle duplicate detection.
    • Status Management: Check if media is STATUS_NORMAL, STATUS_BANNED, STATUS_FORBIDDEN, or STATUS_NOT_AVAILABLE.
  6. Handle comment tripcodes

    master

    The Comment model supports both standard and secure tripcodes extracted from the name field.

    • Standard Tripcode: Generated using a salt derived from the plain text. It is prefixed with !.
    • Secure Tripcode: Generated using a SHA1 hash combined with a salt defined in the project configuration (foolz/foolfuuka -> config -> comment.secure_tripcode_salt). It is prefixed with !!.

    When a name contains a # (e.g., Name#trip), the model automatically parses it into a separate name and trip property.

  7. Configure error reporting and environment settings

    master

    The application entrypoint sets up error reporting for development. For production environments, you should modify the error_reporting and display_errors settings to prevent leaking sensitive information.

    error_reporting(-1);
    ini_set('display_errors', 1);
  8. Configure Board options

    master

    Use setOptions() to pass configuration parameters to the Board's fetching and counting methods. You can pass a single key-value pair or an associative array to set multiple options at once. These options (such as page, per_page, or type) are used internally by the model to shape database queries.

    // Set a single option
    $board->setOptions('per_page', 20);
    
    // Set multiple options via an associative array
    $board->setOptions([
        'page' => 1,
        'per_page' => 50,
        'order' => 'by_post'
    ]);
  9. Retrieve reports for a comment

    master

    If the authenticated user has the comment.reports permission, you can retrieve reports associated with a comment or its media using getReports().

    This method checks both the comment's doc_id and, if media is attached, the media_id to aggregate all relevant reports.

    $reports = $commentModel->getReports();
  10. Generate media and thumbnail links

    master

    Use the following methods to retrieve URLs for media files. Most methods require a Symfony�Component�HttpFoundation�Request object to handle protocol (HTTP/HTTPS) and CDN logic.

    • getMediaLink(Request $request): Returns the URL for the full media file.
    • getThumbLink(Request $request): Returns the URL for the thumbnail.
    • getMediaDownloadLink(Request $request): Returns a direct download link (if configured in preferences).
    • getRemoteMediaLink(Request $request): Returns a remote URL if the media is hosted externally (e.g., in an archive).