| Server IP : 162.214.74.102 / Your IP : 216.73.217.80 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/public_html/lrsys_apps/imobles/application/plugins/module_imobles/ |
Upload File : |
<?php
//if(!defined('APP_RUN')) exit('No direct access allowed');
/*
* API PARA ACESSO EXTERNO AOS DADOS DO PLUGIN
* Utilizar o caminho: /?ng=api
* Enviar os dados via POST
* @key: chave de acesso à API
* @plugin: nome do plugin ou módulo
* @params
*/
// Verifico se a chave para acesso à API está correta
$pl_data = false;
if (isset($_POST['key']) AND ( $_POST['key'] != '')) {
$key = $_POST['key'];
$a = ORM::for_table('sys_api')->where('apikey', $key)->find_one();
if ($a) {
include_once "controllers/ApiController.php";
include_once "controllers/PortallistingsController.php";
$executMethod = true;
$controllerFindCache = 'ApiController';
$saveCacheMehtod = false;
//remove espaços desneessários para salvar no banco
$content = preg_replace('/\\s\\s+/', ' ', file_get_contents("php://input"));
$hash = hash('sha512', $content);
// Verifico se o método da API é diferente do
if(_post('pl_method') != "getLocations" && _post('pl_method') != "getListingsGrupoZap")
{
$saveCacheMehtod = true;
try {
$cache = ORM::for_table('module_imobles_cache')
->select_expr('json_output, updated_at,id')
->where('json_input_hash', $hash)
->where('controller', $controllerFindCache)
->where('method', _post('pl_method'))
->find_one();
if ($cache) {
if (strtotime($cache->updated_at) >= strtotime('-1 day', strtotime(date("Y-m-d H:i:s")))) {
$pl_data = json_decode($cache->json_output, true);
$info = array(
'success' => true,
// 'cache'=>true,
'plugin_msg' => null);
$executMethod = false;
}
} else {
$cache = ORM::for_table('module_imobles_cache')->create();
$cache->created_at = date("Y-m-d H:i:s");
$cache->controller = $controllerFindCache;
$cache->method = (_post('pl_method'));
$cache->json_input_hash = $hash;
$cache->json_input = $content;
}
} catch (Exception $e) {
$cache = ORM::for_table('module_imobles_cache')->create();
$cache->created_at = date("Y-m-d H:i:s");
$cache->controller = $controllerFindCache;
$cache->method = (_post('pl_method'));
$cache->json_input_hash = $hash;
$cache->json_input = $content;
}
$cache->updated_at = date("Y-m-d H:i:s");
}
if ($executMethod) {
// switch method
switch (_post('pl_method')) {
case 'searchDevelopments' :
$api = new ApiController($ui, $_L, $config, null);
$pl_data = $api->searchDevelopments();
if ($pl_data === false) {
$info = array(
'success' => false,
'plugin_msg' => 'Invalid plugin params');
} else {
$info = array(
'success' => true,
'plugin_msg' => null);
}
break;
case 'developmentDetails' :
$api = new ApiController($ui, $_L, $config, null);
$pl_data = $api->developmentDetails();
if ($pl_data === false) {
$info = array(
'success' => false,
'plugin_msg' => 'Invalid plugin params');
} else {
$info = array(
'success' => true,
'plugin_msg' => null);
}
break;
case 'searchDevelopmentsSimilar' :
$api = new ApiController($ui, $_L, $config, null);
$pl_data = $api->searchDevelopmentsSimilar();
if ($pl_data === false) {
$info = array(
'success' => false,
'plugin_msg' => 'Invalid plugin params');
} else {
$info = array(
'success' => true,
'plugin_msg' => null);
}
break;
case 'mandeUmZapHubspot' :
$api = new ApiController($ui, $_L, $config, null);
$pl_data = $api->mandeUmZapHubspot();
if ($pl_data === false) {
$info = array(
'success' => false,
'plugin_msg' => 'Invalid plugin params');
} else {
$info = array(
'success' => true,
'plugin_msg' => null);
}
$pl_data = array();
$saveCacheMehtod = false;
break;
case 'getLocations' :
$api = new ApiController($ui, $_L, $config, null);
$pl_data = $api->getLocations();
if ($pl_data === false) {
$info = array(
'success' => false,
'plugin_msg' => 'Invalid plugin params');
} else {
$info = array(
'success' => true,
'plugin_msg' => null);
}
break;
case 'searchDevelopmentsMaps' :
$api = new ApiController($ui, $_L, $config, null);
$pl_data = $api->searchDevelopmentsMaps();
if ($pl_data === false) {
$info = array(
'success' => false,
'plugin_msg' => 'Invalid plugin params');
} else {
$info = array(
'success' => true,
'plugin_msg' => null);
}
break;
case 'sitemapGenerator' :
$api = new ApiController($ui, $_L, $config, null);
$pl_data = $api->sitemapGenerator();
if ($pl_data === false) {
$info = array(
'success' => false,
'plugin_msg' => 'Invalid plugin params');
} else {
$info = array(
'success' => true,
'plugin_msg' => null);
}
break;
case 'dynamicUrls' :
$api = new ApiController($ui, $_L, $config, null);
$pl_data = $api->dynamicUrls();
if ($pl_data === false) {
$info = array(
'success' => false,
'plugin_msg' => 'Invalid plugin params');
} else {
$info = array(
'success' => true,
'plugin_msg' => null);
}
break;
case 'constructionCompanyUrls' :
$api = new ApiController($ui, $_L, $config, null);
$pl_data = $api->constructionCompanyUrls();
if ($pl_data === false) {
$info = array(
'success' => false,
'plugin_msg' => 'Invalid plugin params');
} else {
$info = array(
'success' => true,
'plugin_msg' => null);
}
break;
case 'companyConstructionDetails' :
$api = new ApiController($ui, $_L, $config, null);
$pl_data = $api->companyConstructionDetails();
if ($pl_data === false) {
$info = array(
'success' => false,
'plugin_msg' => 'Invalid plugin params');
} else {
$info = array(
'success' => true,
'plugin_msg' => null);
}
break;
case 'getListingsGrupoZap' :
$portalListingsController = new PortalListingsController($ui, $_L, $config, $_pd = null);
$portalListingsController->getListingsGrupoZap();
die; // Required to output a XML
default :
$info = array(
'success' => false,
'plugin_msg' => 'Invalid plugin method');
$saveCacheMehtod = false;
break;
}
if ($saveCacheMehtod) {
$cache->json_output = json_encode($pl_data);
$cache->save();
}
}
} else {
$info = array(
'success' => false,
'plugin_msg' => 'Invalid API Key');
}
}
if (is_array($pl_data)) {
$data = array_merge(@$data, $pl_data);
}
$data["result"] = count(@$data["results"]) > 1 ? true : false;
$data["time"] = (microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']);
// Return
$data['return'] = array('info' => $info);