AnonSec Shell
Server IP : 162.214.74.102  /  Your IP : 216.73.216.59
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/leve/application/plugins/module_arbo/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/lrsys/www/lrsys_apps/leve/application/plugins/module_arbo/controllers/RobologsController.php
<?php

require_once "Controller.php";
require_once __DIR__ . "/../models/GaiaImovelModel.php";
require_once __DIR__ . "/../models/GaiaProposalModel.php";
require_once __DIR__ . "/../models/GaiaRequest.php";

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

	/**
	 * @var
	 */
	protected $GaiaImovelModel;

	/**
	 * @var
	 */
	protected $GaiaRequest;

	/**
	 * ArboController constructor.
	 * @param $ui
	 * @param $_L
	 * @param $config
	 * @param $_pd
	 */
	public function __construct($ui, $_L, $config, $_pd)
	{
		parent::__construct($ui, $_L, $config, $_pd);

		$this->GaiaImovelModel = new GaiaImovelModel();
		$this->GaiaRequest = new GaiaRequest();
	}

	/**
	 * Action para listagem de propostas de locação e cadastros de imóveis
	 */
	public function listlogs()
	{
		$this->ui->assign('_st', $this->_L['Arbo']);

		$logs = ORM::for_table('module_arbo_robo_logs')
			->order_by_desc('id')
			->limit(50)
			->find_many();
		$this->ui->assign('logs', $logs);

		$assets_css = '<link rel="stylesheet" type="text/css" href="' . $this->_pd . '/assets/css/robologs.css"/>';
		$this->ui->assign('xheader', $assets_css);

		$assets_js = Asset::js_external($this->_pd . '/assets/js/arbo.js');
		$assets_js .= Asset::js_external($this->_pd . '/assets/js/robologs.js');
		$this->ui->assign('xfooter', $assets_js);

		$this->ui->assign('_include', 'robologs/list');
		$this->ui->display('wrapper.tpl');
	}

	/**
	 * Action para listagem de propostas de locação e cadastros de imóveis
	 */
	public function view()
	{
		$id = $this->routes['3'];
		$output = isset($this->routes['4']) ? $this->routes['4'] : 'array';

		$this->ui->assign('output', $output);
		$this->ui->assign('_st', $this->_L['Arbo']);

		$log = ORM::for_table('module_arbo_robo_logs')->find_one((int) $id);
		$this->ui->assign('log', $log);
		$this->ui->assign('json', json_decode($log->data, true));

		$this->ui->assign('_include', 'robologs/view');
		$this->ui->display('wrapper.tpl');
	}

	/**
	 * Action para edição dos dados dos cadastros de imóveis que
	 * deram erro antes de reenviar para a Gaia
	 */
	public function edit()
	{
		$id = isset($this->routes['3']) ? $this->routes['3'] : false;

		if (!$id) {
			r2(U."module_arbo/robologs/listlogs", 'e', $this->_L['Invalid ID']);
		}

		$log = ORM::for_table('module_arbo_robo_logs')->find_one((int) $id);

		if (!$log) {
			r2(U."module_arbo/robologs/listlogs", 'e', $this->_L['Not found']);
		}

		$data = json_decode($log->data, true);

		$this->ui->assign('log', $log);
		$this->ui->assign('data', $data);
		$this->ui->assign('_st', 'Editar Dados');

		$this->ui->assign('_include', 'robologs/edit');
		$this->ui->display('wrapper.tpl');
	}

	/**
	 * Action que recebe os dados editados e reenvia para a Gaia
	 */
	public function resend()
	{
		if ($_SERVER['REQUEST_METHOD'] == "POST") {
			$data = $_POST;
		}

		$resource = $this->GaiaRequest->getResource();

		// Faz o login na Gaia
		if(!$resource) {
			$this->GaiaRequest->doLogin();
			$resource = $this->GaiaRequest->getResource();
		}

		if($resource) {
			$url_imovel = "http://app.valuegaia.com.br/admin/modules/imoveis_beta/imovel-acao.aspx?id=";
			$url_imovel_referer = "http://app.valuegaia.com.br/admin/default.aspx#/modules/imoveis_beta/imovel-novo.aspx?acao=incluir";

			curl_setopt($resource, CURLOPT_URL, $url_imovel);
			curl_setopt($resource, CURLOPT_REFERER, $url_imovel_referer);
			curl_setopt($resource, CURLOPT_POST, true);
			curl_setopt($resource, CURLOPT_POSTFIELDS, http_build_query($data));
			$result = curl_exec($resource);

			$log = ORM::for_table('module_arbo_robo_logs')->create();
			$log->date = date('Y-m-d H:i:s');
			$log->owner = (isset($data['txProprietario']) ? $data['txProprietario'] : '');
			$log->description = "Reenviando os dados do imóvel para o sistema da Gaia";
			$log->data = json_encode($data);
			$log->operation = 'OUTPUT';
			$log->status = $result;
			$log->ip = $_SERVER['SERVER_ADDR'];
			$log->save();

			r2(U."module_arbo/robologs/listlogs", 's', $this->_L['module_arbo_resend_msg']);
		}
	}

	/**
	 * Action que retorna os logs mais antigos via ajax
	 */
	public function getlogs()
	{
		if ($_SERVER['REQUEST_METHOD'] == "POST") {
			$last_log_id = (isset($_POST['id'])) ? $_POST['id'] : 0;

			if (!$last_log_id) {
				header('Content: application/json');
				echo json_encode(['status'=>false,'msg'=>$this->_L['Invalid ID']]);
				exit;
			}

			// Busca os últimos logs
			$response = ORM::for_table('module_arbo_robo_logs')
				->table_alias('l')
				->select('l.id')
				->select('l.date')
				->select('l.owner')
				->select('l.operation')
				->select('l.description')
				->select('l.status')
				->where_lt('id', $last_log_id)
				->order_by_desc('id')
				->limit(20)
				->find_array();

			header('Content-Type: application/json');
			echo json_encode($response, true);
			exit;
		}
	}
}

Anon7 - 2022
AnonSec Team