403Webshell
Server IP : 37.9.174.138  /  Your IP : 216.73.216.117
Web Server : Apache
System : Linux vps6.backend.sk 6.12.100+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.100-1 (2026-07-30) x86_64
User : ftpuser ( 1001)
PHP Version : 8.4.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/backend-accounting.sk/app/modules/dpfob/code/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/backend-accounting.sk/app/modules/dpfob/code/Comment.php
<?php
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace modules\dpfob\code;

use app\classes\BasicUser;
use app\classes\PDOCollection;

/**
 * Description of Question
 *
 * @author pegas
 */
class Comment extends \app\classes\PDOElement {

    CONST UPLOAD_DIR = "uploads/private/uploads/comments/uploads/";
    CONST UPLOAD_DIR_TMP = "uploads/private/uploads/comments/tmp/";
    CONST TYPE_PUBLIC = 'PUBLIC';
    CONST TYPE_PRIVATE = 'PRIVATE';

    public function __construct($id, $idColumnName = "id") {
        parent::__construct($id, "comments", array($idColumnName => $id), $idColumnName, false, false, true);
    }

    /**
     * @return array<int, Comment>
     */
    public function getChildren($onlyPublic = false) {
        $params = [
            "comments_id" => $this->_get("id"),
            "ACTIVE" => \app\constants\State::ACTIVE
        ];
        if ($onlyPublic) {
            $params["PUBLIC"] = self::TYPE_PUBLIC;
        }
        $children = new PDOCollection("comments", "id", "SELECT id FROM comments WHERE comments_id=:comments_id AND state=:ACTIVE " . ($onlyPublic ? "AND type=:PUBLIC" : "") . " ORDER BY id ASC", $params);
        $items = [];

        foreach ($children->toArray() as $el) {
            $items[] = new Comment($el["id"]);
        }

        return $items;
    }

    /**
     * @return ?BasicUser
     */
    public function getAuthor() {
        try {
            return new BasicUser($this->_get("users_id"), true, true, true);
        } catch (\Exception $ex) {
            return null;
        }
    }

    public function getAuthorName() {
        $author = $this->getAuthor();
        if ($author) {
            return $author->getName();
        }

        return $this->_get('from_name');
    }

    public function getEmail() {
        $author = $this->getAuthor();
        if ($author) {
            return $author->_get('email');
        }

        return $this->_get('email');
    }

    public function getContent() {
        return toHtml($this->_get("comment"));
    }

    public function render($canComment, $onlyPublic = false, $itemId = false, $apiPath = false) {
        $t = \app\classes\Translator::getInstance();
        ?>
        <div class="media d-flex align-items-start">      
            <div class="media-left me-2">
                <i style="font-size: 45px;" class="fa fa-user"></i>
            </div>
            <div class="media-body w-100">
                <div class="media-heading">
                    <h5 class="d-inline" style="margin-bottom: 0px;"><?php echo $this->getAuthorName() ?></h5>
                    <?php if (!$onlyPublic) { ?>
                        <div class="d-inline">
                            <small><small><small style="color: #929292">&lt;<?php echo $this->_get('mid') ?>&gt;</small></small></small>
                        </div>
                    <?php } ?>
                </div>
                <small><?php echo date("d.m.Y H:i:s", strtotime($this->_get("created"))) ?>
                    <?php if (!$onlyPublic) { ?>
                        <span class="ms-1">
                            <?php if ($this->isPublic()) { ?>
                                <i data-bs-toggle="tooltip" title="<?php echo $t->_get('Verejný komentár') ?>" class="fa fa-globe text-primary"></i>
                            <?php } else { ?>
                                <i data-bs-toggle="tooltip" title="<?php echo $t->_get('Sukromný komentár') ?>" class="fa fa-globe text-dark opacity-25"></i>
                            <?php } ?>
                        </span>
                        <span class="ms-1">
                            <?php if (strlen($this->_get('notified') > 0)) { ?>
                                <i data-bs-toggle="tooltip" title="<?php echo $t->_get('Notifikácia odoslaná na') ?>: <?php echo $this->_get('notified') ?>" class="fa fa-paper-plane text-primary"></i>
                            <?php } else { ?>
                                <i data-bs-toggle="tooltip" title="<?php echo $t->_get('Notifikácia neodoslaná') ?>" class="fa fa-paper-plane text-dark opacity-25"></i>
                            <?php } ?>
                        </span>
                    <?php } ?>
                </small>
                <p style="margin-top: 5px; margin-bottom: 0px">
                    <?php echo $this->getContent() ?>
                </p>
                <?php foreach ($this->getAttachments(true) as $attachment) { ?>
                    <a target="_blank" download class="me-3" href="<?php echo $attachment ?>"><?php echo basename($attachment) ?></a>
                <?php } ?>
                <?php if ($canComment) { ?>
                    <a href="javascript:;" style="margin-top: 5px; margin-bottom: 0px; display: block; text-decoration: none;" onclick="$(this).toggleClass('show')">
                        <i class="fa fa-mail-reply"></i> <?php echo $t->_get("Odpovedať") ?>
                    </a>
                    <div class = "reply-form">
                        <?php echo $this->renderReplyForm($itemId, $apiPath) ?>
                    </div>
                <?php } ?>
                <?php
                foreach ($this->getChildren() as $child) {
                    $child->render($canComment, $onlyPublic);
                }
                ?>                
            </div>
        </div>
        <?php
    }

    protected function renderReplyForm($itemId = false, $apiPath = false) {
        $t = \app\classes\Translator::getInstance();
        $form = new \PFBC\Form("form-comment-" . $this->_get("id"));
        $form->configure(array(
            "prevent" => array("bootstrap", "jQuery", "focus"),
            "ajax" => 1,
            "ajaxCallback" => "",
            "action" => "",
            "view" => new \PFBC\View\OneColumn(),
            "ajaxMethod" => "ajax('" . ($apiPath ? $apiPath : "/api/admin/dpfob/dpfob/addComment/") . "', 'POST', $(this).serialize(), 'afterSubmit');"
        ));

        $form->addElement(new \PFBC\Element\Textarea("", "comment", array("class" => "form-control form-control-lg", "required" => 1, "rows" => 4, "data-grid-class" => "col-md-12")));

        $form->addElement(new \PFBC\Element\HTML('<div class="row">'));
        $form->addElement(new \PFBC\Element\HTML('<div class="offset-lg-4 col-lg-5 offset-md-2 col-md-7 order-md-2 mb-3">'));
        $token = getUniqueId();
        $form->addElement(
                new \PFBC\Element\File(
                        '',
                        "filepond-comments",
                        array(
                    "class" => "filepond-comments",
                    "name" => "attachment",
                    "multiple" => "multiple",
                    "data-allow-reorder" => "true",
                    "data-max-file-size" => "10MB",
                    "data-max-file-size" => \modules\dpfob\api\UploadComments::MAX_FILE_SIZE_MB . "MB",
                    "data-max-files" => \modules\dpfob\api\UploadComments::MAX_FILES_COUNT,
                    "data-token" => $token,
                    "data-grid-class" => "col-md-12",
                        )
                )
        );
        $form->addElement(new \PFBC\Element\Hidden("token", $token));
        $form->addElement(new \PFBC\Element\HTML('</div>'));
        $form->addElement(new \PFBC\Element\HTML('<div class="col-md-3 order-md-1">'));
        $form->addElement(new \PFBC\Element\Button($t->_get("Pridať"), "submit", array("class" => "btn btn-lg btn-primary", "style" => "margin-right:auto; display: block; width: 100%")));
        $form->addElement(new \PFBC\Element\HTML('</div>'));
        $form->addElement(new \PFBC\Element\HTML('</div>'));
        $form->addElement(new \PFBC\Element\Hidden("dpfob_id", $itemId === false ? $this->_get("dpfob_id") : $itemId));
        $form->addElement(new \PFBC\Element\Hidden("comments_id", $this->getId()));
        $form->render();
    }

    /**
     * @return ?Comment
     */
    public function getParentComment() {
        try {
            return new Comment($this->_get("comments_id"));
        } catch (\Exception $ex) {
            return null;
        }
    }

    public function updateMid() {
        $this->db->sqlCommand('UPDATE comments SET mid=UUID() WHERE id=:id', ['id' => $this->_get('id')]);
    }

    public function getUploadPath($www = false, $createIfNotExists = false) {
        $nonwww = DOCUMENT_ROOT . self::UPLOAD_DIR . $this->_get("folder") . "/";
        if (!file_exists($nonwww) && $createIfNotExists) {
            mkdir($nonwww);
        }
        return $www ? "/" . self::UPLOAD_DIR . $this->_get("folder") . "/" : $nonwww;
    }

    /**
     * @return ?DPFOB
     */
    public function getDPFOB() {
        try {
            return new DPFOB($this->_get("dpfob_id"));
        } catch (\Exception $ex) {
            return null;
        }
    }

    public function getAttachments($www = false) {
        $dir = $this->getUploadPath();
        $wwwDir = $this->getUploadPath($www);
        $attachments = [];
        foreach (scandir($dir) as $file) {
            if ($file !== '.' && $file !== '..') {
                $attachments[] = ($www ? $wwwDir : $dir) . '/' . $file;
            }
        }

        return $attachments;
    }

    public function isPublic() {
        return $this->_get('type') === self::TYPE_PUBLIC;
    }

}

Youez - 2016 - github.com/yon3zu
LinuXploit