| 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 : |
<?php
declare(strict_types=1);
namespace App\Controller\Admin;
use App\Helper\FileUpload;
use App\Helper\Utilities;
use App\Model\ServiceModel;
use Mosaico\Controller\BaseController;
use App\DataFile\Data;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class ServiceController extends BaseController
{
/**
* @var object
*/
protected $model;
/**
* @var object
*/
protected $utility;
/**
* @var array
*/
protected $env;
public function __construct()
{
$this->auth();
$this->model = new BlogModel();
$this->env = $this->getEnv();
$this->utility = new Utilities();
}
/**
* Post List
* @return string [description]
*/
public function servicesList(): string
{
$services = $this->model->getServicesAdmin();
return $this->template(
'admin/servicessList',
[
'env' => $this->env,
'services' => $services,
]
);
}
public function serviceCreate(): string
{
return $this->template(
'admin/serviceEdit',
[
'service' => ['action' => 'New Service'],
'env' => $this->env
]
);
}
public function serviceUpdate(): string
{
$service = $this->model->getServiceById($_GET['id_service']);
$service->row['action'] = 'Update Service';
return $this->template(
'admin/serviceEdit',
[
'env' => $this->env,
'post' => $post->row
]
);
}
public function serviceProcess(): string
{
if (isset($_POST['id_service'])) :
$_POST['content'] = addslashes($_POST['content']);
if ($_POST['id_service'] == 0) {
$this->model->insertService($_POST);
} else {
$this->model->updateService($_POST);
}
return 'process post debug: ' . $_POST['id_service'];
else :
header('HTTP/1.0 404 Not Found');
die();
endif;
}
public function serviceImage()
{
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/services/';
$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 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();
}
}
}