AnonSec Shell
Server IP : 162.214.74.102  /  Your IP : 216.73.217.114
Web Server : Apache
System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64
User : lrsys ( 1015)
PHP Version : 5.6.40
Disable Function : exec,passthru,shell_exec,system
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/lrsys/www/lrsys_apps/erp/application/plugins/module_cms/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/lrsys/www/lrsys_apps/erp/application/plugins/module_cms/controllers/ArticleController.php
<?php

include_once "Controller.php";
include_once __DIR__ . "/../models/ArticleModel.php";
include_once __DIR__ . "/../models/CategoryModel.php";
include_once __DIR__ . "/../models/ImageModel.php";

class ArticleController extends Controller
{
    /**
     * @var ArticleModel
     */
    protected $model;

    /**
     * @var CategoryModel
     */
    protected $categoryModel;

    /**
     * @var ImageModel
     */
    protected $imageModel;

    /**
     * @param $ui
     * @param array $_L
     * @param array $config
     * @param $_pd
     */
    public function __construct($ui, $_L, $config, $_pd)
    {
        parent::__construct($ui, $_L, $config, $_pd);
        $this->ui->assign('_title', $this->_L['CMS_Module'] . ' - ' . $this->config['CompanyName']);
        $this->model         = new ArticleModel();
        $this->imageModel    = new ImageModel();
        $this->categoryModel = new CategoryModel();
    }

    /**
     * Show form to add article
     */
    public function add()
    {
        $categories = $this->categoryModel->findAllActives();

        $this->ui->assign('categories', $categories);
        $this->ui->assign('_st', $this->_L['CMS_New_Article']);
        $this->ui->assign('_include', 'article/' . __FUNCTION__);

        // css
        $this->ui->assign('xheader', Asset::css(['redactor/redactor', 'dropzone/dropzone']));

        // js
        $redactor = Asset::js(['redactor/redactor.min', 'redactor/fontcolor', 'dropzone/dropzone']);
        $default  = Asset::js_external($this->_pd . '/assets/js/default.js');
        $this->ui->assign('xfooter', $redactor . $default);

        $this->ui->display('wrapper.tpl');
    }

    public function create()
    {
        $data = $_POST;
        $data['status'] = (int) !empty($data['status']) && $data['status'] == 'on';
        $this->model->createArticle($data);

        $this->ui->assign('_st', $this->_L['CMS_New_Article']);
        r2(U . 'module_cms/article/listArticles', 's', $this->_L['CMS_Article_Save']);
    }

    public function update()
    {
        $article = $this->validateArticle();

        $this->data['status'] = (int) !empty($this->data['status']) && $this->data['status'] == 'on';
        $this->model->updateArticle($this->data, $article);

        $this->ui->assign('_st', $this->_L['CMS_Edit_Article']);
        r2(U . 'module_cms/article/listArticles', 's', $this->_L['CMS_Article_Edit']);
        $this->ui->display('wrapper.tpl');
    }

    public function delete()
    {
        $article = $this->validateArticle();
        $this->model->deleteArticle($article);

        $this->ui->assign('_st', $this->_L['CMS_Edit_Article']);
        r2(U . 'module_cms/article/listArticles', 's', $this->_L['CMS_Article_Delete']);
        $this->ui->display('wrapper.tpl');
    }

    /**
     * Show form to edit article
     */
    public function edit()
    {
        if (empty($this->routes[3]) || !is_numeric($this->routes[3])) {
            die($this->_L['Id_Required']);
        }

        $article = $this->model->getOne($this->routes[3]);
        
        if (!$article) {
            die($this->_L['Not_Found']);
        }

        $categories = $this->categoryModel->findAllActives();

        $this->ui->assign('categories', $categories);
        $this->ui->assign('article', $article);
        $this->ui->assign('_st', $this->_L['CMS_Module'] . ' - ' . $this->_L['CMS_Edit_Article']);
        $this->ui->assign('_include', 'article/add');

        // css
        $this->ui->assign('xheader', Asset::css(['redactor/redactor', 'dropzone/dropzone']));

        // js
        $redactor = Asset::js(['redactor/redactor.min', 'redactor/fontcolor', 'dropzone/dropzone']);
        $default  = Asset::js_external($this->_pd . '/assets/js/default.js');
        $this->ui->assign('xfooter', $redactor . $default);

        if ($article->cms_image_id) {
            $i = $this->imageModel->getOne($article->cms_image_id);
            $this->ui->assign('image', $article);
            $image = '{ name: "' . $i->path . '", size: 100,url:"' . APP_URL . "/" . $i->path . '" }';
            $this->ui->assign('jsvar', "var existingFiles = [{$image}];");
            $this->ui->assign('image', $i->id);
        }

        $this->ui->display('wrapper.tpl');
    }

    /**
     * @return ORM
     */
    protected function validateArticle()
    {
        $this->data = $_POST;
        if (empty($this->data['id']) || !is_numeric($this->data['id'])) {
            die($this->_L['Id_Required']);
        }

        $article = $this->model->getOne($this->data['id']);

        if (!$article) {
            die($this->_L['Not_Found']);
        }

        return $article;
    }

    /**
     * List categories
     */
    public function listArticles()
    {
        $articles = $this->model->all('id', true);
        $this->ui->assign('articles', $articles);
        $this->ui->assign('_st', $this->_L['CMS_Articles']);
        $this->ui->assign('_include', 'article/' . __FUNCTION__);
        $this->ui->display('wrapper.tpl');
    }

    public function deleteImage()
    {
        $id = _post('id');

        header('Content-Type: application/json');

        $article = $this->model->getOne($id);
        if ($article) {
            $article->cms_image_id = null;
            $article->save();
            $response = [
                'status' => 'OK',
                'msg'    => $this->_L['CMS_Image_Deleted_Successfully']
            ];

            echo json_encode($response);
            return;
        }

        $response = [
            'status' => $this->_L['CMS_Not_found'],
            'msg' => 'ERROR',
        ];

        echo json_encode($response);
    }
}

Anon7 - 2022
AnonSec Team