HEX
Server: Apache/2.4.25 (Debian)
System: Linux server17 4.9.0-19-amd64 #1 SMP Debian 4.9.320-2 (2022-06-30) x86_64
User: web37 (1062)
PHP: 7.4.30
Disabled: show_source, highlight_file, apache_child_terminate, apache_get_modules, apache_note, apache_setenv, virtual, dl, disk_total_space, posix_getpwnam, posix_getpwuid, posix_mkfifo, posix_mknod, posix_setpgid, posix_setsid, posix_setuid, posix_uname, proc_nice, openlog, syslog, pfsockopen
Upload Files
File: /var/www/web37/htdocs/fickanzeiger/controllers/CommentController.php
<?php
/**
 * Arfooo
 * 
 * @package    Arfooo
 * @copyright  Copyright (c) Arfooo Annuaire (fr) and Arfooo Directory (en)
 *             by Guillaume Hocine (c) 2007 - 2010
 *             http://www.arfooo.com/ (fr) and http://www.arfooo.net/ (en)
 * @author     Guillaume Hocine & Adrian Galewski
 * @license    http://creativecommons.org/licenses/by/2.0/fr/ Creative Commons
 */


class CommentController extends AppController
{
    public function saveCommentAction()
    {
        if (!Config::get('commentsEnabled')) {
            $this->return404();
        }

        $this->viewClass = "JsonView";
        $siteId = $this->request->itemId;
        $site = $this->site->findByPk($siteId);

        if (empty($site)) {
            return $this->return404();
        }

        $errorMessage = $this->comment->validate($this->request);

        if (Config::get('captchaEnabledOnComments')
            && !$errorMessage
            && !$this->captchaCode->validatePublicAndPrivateCodes($this->request)
        ) {
            $errorMessage = 'You did not guess the security code.';
        }

        if (empty($errorMessage)) {
            $comment = new CommentRecord();
            $comment->fromArray($this->request->getArray(array("pseudo",
                                                               "text",
                                                               "rating")));
            $comment->siteId = $site->siteId;
            $comment->validated = Config::get("automaticCommentValidation") ? 1 : 0;
            $comment->remoteIp = $this->request->getIp();
            $comment->save();

            if (Config::get("sendEmailsOnComment")) {
                Mailer::getInstance()->sendNewCommentNotificationToAdmin($site);
            }

            $this->comment->setSiteCookie($site->siteId);

            $this->set("status", "ok");
            if (Config::get("automaticCommentValidation")) {
                $this->set("message", _t('Your comment was saved'));
            } else {
                $this->set("message", _t('Your comment was saved. He is awaiting moderation and will be published if it is useful for surfers'));
            }
        } else {
            $this->set("status", "error");
            $this->set("message", _t($errorMessage));
        }
    }

    public function popupAction($itemId)
    {
        if (!Config::get('commentsEnabled')) {
            $this->return404();
        }

        $this->set("canVote", $this->comment->checkCanVote($itemId, $this->request->getIp()));
        $this->set("item", $this->site->findByPk($itemId));
    }
}