AnonSec Shell
Server IP : 162.214.74.102  /  Your IP : 216.73.217.114
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/leo/application/plugins/module_imobles/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/lrsys/www/lrsys_apps/leo/application/plugins/module_imobles/controllers/CacheController.php
<?php

include_once "Controller.php";
include_once __DIR__ . "/../models/CacheModel.php";
include_once __DIR__ . "/../helpers/CrawlerHelper.php";

class CacheController extends Controller {

    protected $cache;
    protected $crawlerHelper;

    public function __construct($ui, $_L, $config, $_pd = null) {
        @ini_set('memory_limit', '4095M');
        @ini_set('max_execution_time', 0);
        @set_time_limit(0);
        parent::__construct($ui, $_L, $config, $_pd);

        $this->cache = new CacheModel();
        $this->crawlerHelper = new CrawlerHelper();
    }

    public function listAll() {
        $where = '';
        $join = "";
        $filter = array();
        $filter['items_per_page'] = 10;
        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
            unset($_SESSION['filter']['module_imobles/cache/listAll']);
            if (filter_var(_post('clear_filter'), FILTER_SANITIZE_STRING) == 1) {
                
            } else {
                $_SESSION['filter']['module_imobles/cache/listAll']['controller'] = filter_var(_post('controller'), FILTER_SANITIZE_STRING);
                $_SESSION['filter']['module_imobles/cache/listAll']['method'] = filter_var(_post('method'), FILTER_SANITIZE_STRING);
                $_SESSION['filter']['module_imobles/cache/listAll']['city'] = filter_var(_post('city'), FILTER_SANITIZE_STRING);
                $_SESSION['filter']['module_imobles/cache/listAll']['state_id'] = filter_var(_post('state_id'), FILTER_SANITIZE_STRING);
                $_SESSION['filter']['module_imobles/cache/listAll']['module_imobles_enterprise_id'] = filter_var(_post('module_imobles_enterprise_id'), FILTER_SANITIZE_STRING);
                $_SESSION['filter']['module_imobles/cache/listAll']['module_imobles_company_construction_id'] = filter_var(_post('module_imobles_company_construction_id'), FILTER_SANITIZE_STRING);
                $filter['items_per_page'] = filter_var(_post('items_per_page'), FILTER_SANITIZE_STRING);
            }
        } else {
            if ($i = array_search('items_per_page', $this->routes))
                $filter['items_per_page'] = filter_var($this->routes[$i + 1], FILTER_SANITIZE_STRING);
        }

        if (isset($_SESSION['filter']['module_imobles/cache/listAll'])) {
            $itenPp = $filter['items_per_page'];
            $filter = $_SESSION['filter']['module_imobles/cache/listAll'];
            $filter['items_per_page'] = $itenPp;
        } else {
            $filter['method'] = "";
            $filter['controller'] = "";
            $filter['city'] = "";
            $filter['state_id'] = "";
        }

        if (!empty($filter['city'])) {
            $where .= " AND e.json_input  LIKE '%" . ($filter['city']) . "%' ";
        }
        if (!empty($filter['state_id'])) {
            $e = ORM::for_table('state')->find_one($filter['state_id']);
            if ($e) {
                $where .= " AND (e.json_input  LIKE '%\"" . ($e->uf_state) . "\"%'"
                        . " OR e.json_input  LIKE '%\'" . ($e->uf_state) . "\'%' )";
            }
        }

        if (!empty($filter['module_imobles_enterprise_id'])) {
            $e = ORM::for_table('module_imobles_enterprise')->find_one($filter['module_imobles_enterprise_id']);
            if ($e) {
                $where .= " AND ((e.json_input  LIKE '%\"development_id\": " . ($e->id) . "%'"
                        . " OR e.json_input LIKE '%" . $e->slug . "%' "
                        . " OR e.json_input  LIKE '%\'" . ($e->uf_state) . "\'%' )"
                        // . " AND e.method='developmentDetails' "
                        . " and e.controller='ApiController')";
                $this->ui->assign('module_imobles_enterprise', $e);
            }
        }

        if (!empty($filter['module_imobles_company_construction_id'])) {
            $c = ORM::for_table('module_imobles_company_construction')->find_one($filter['module_imobles_company_construction_id']);
            if(!empty($c['slug'])){
                $slug = $c['slug'];
            } else {
                $slug = $this->crawlerHelper->sanitizaUrl($c['name']);
            }
            if ($c) {
                $where .= " AND ("
                        . " json_input LIKE ('%" . $slug . "%')"
                        . " AND e.controller='ApiController'"
                        . ")";
                $this->ui->assign('module_imobles_company_construction', $c);
            }
        }
        
        

        if (!empty($filter['method'])) {
            $where .= " AND e.method  = '" . ($filter['method']) . "' ";
        }
        if (!empty($filter['controller'])) {
            $where .= " AND e.controller  = '" . ($filter['controller']) . "' ";
        }



        $sql = ' FROM module_imobles_cache e'
                // . '  JOIN module_imobles_enterprise_towers t ON(e.id=t.module_imobles_enterprise_id)'
                . '  WHERE e.deleted_at IS NULL' . $where;


        $order = ' ORDER BY e.id desc';

        $select = "Select e.method, e.controller, e.json_input, e.id, e.updated_at";

    //    echo $select . $sql . $order; die();
        if ($filter['items_per_page'] != 'all')
            $filter['items_per_page'] = ($filter['items_per_page'] > 0) ? $filter['items_per_page'] : 10;

        $page = isset($this->routes['3']) ? $this->routes['3'] : 1;

        $paginator = new ModulePaginator('module_imobles_enterprise', $select . $sql . $order, $filter);


        $records = $paginator->setItemsPerPage($filter['items_per_page'])
                ->setCurrentPageNumber($page)
                ->run();




        $this->ui->assign('jsvar', '
            _L[\'are_you_sure\'] = \'' . $this->_L['are_you_sure'] . '\';
            _L[\'Save\'] = \'' . $this->_L['Save'] . '\';
            _L[\'OK\'] = \'' . $this->_L['OK'] . '\';
            _L[\'Remove\'] = \'' . $this->_L['Remove'] . '\';
            _L[\'Cancel\'] = \'' . $this->_L['Cancel'] . '\';
            _L[\'Select\'] = \'' . $this->_L['Select'] . '\'; 
            _L[\'View\'] = \'' . $this->_L['View'] . '\'; 
            _L[\'module imobles delete successfull\'] = \'' . $this->_L['module imobles delete successfull cache'] . '\'; 
            _L[\'module imobles delete caches\'] = \'' . $this->_L['module imobles delete caches'] . '\'; 
            _L[\'View\'] = \'' . $this->_L['View'] . '\'; 
            _L[\'module imobles cache renew\'] = \'' . $this->_L['module imobles cache renew'] . '\'; 
            _L[\'module imobles cache renew successfull\'] = \'' . $this->_L['module imobles cache renew successfull'] . '\'; 
        ');

        $css_arr = array('modal',
            '/../../../application/plugins/module_imobles/assets/css/default',
            's2/css/select2.min');

        $js_arr = array('modal',
            '/../../../application/plugins/module_imobles/assets/js/cache-list',
            's2/js/select2.min'
        );

        if (count($records) > 0) {
            foreach ($records as $key => $r) {
                $records[$key]['desc_city'] = '';
                $records[$key]['desc_state'] = '';
                $records[$key]['desc_neighborhood'] = '';
                $ct = array();
                $st = array();
                $ng = array();

                try {
                    if (!empty($r['json_input'])) {
                        $inpu = json_decode($r['json_input']);
                        if (@$inpu->locations) {
                            foreach ($inpu->locations as $l) {
                                if (@$l->address_city) {
                                    $ct[$l->address_city] = @$l->address_city;
                                }
                                if (@$l->address_state) {
                                    $st[$l->address_state] = @$l->address_state;
                                }
                                if (@$l->address_neighborhood) {
                                    $ng[$l->address_neighborhood] = @$l->address_neighborhood;
                                }
                            }
                        }
                    }
                } catch (Exception $e) {
                    
                }

                $records[$key]['desc_city'] = implode("<br/>", $ct);
                $records[$key]['desc_state'] = implode("<br/> ", $st);
                $records[$key]['desc_neighborhood'] = implode("<br/>", $ng);
            }
        }
        $assets_css = Asset::css($css_arr, '1');
        $assets_js = Asset::js($js_arr, '2');

        $this->ui->assign('xheader', $assets_css);
        $this->ui->assign('xfooter', $assets_js);

        $this->ui->assign('cache', $records);
        $this->ui->assign('paginator', $paginator);
        $this->ui->assign('filter', $filter);

        $c = ORM::for_table('module_imobles_cache')
                ->select_expr('distinct (controller) as controller')
                ->find_many();

        $this->ui->assign('controller', $c);

        $c = ORM::for_table('module_imobles_cache')
                ->select_expr('distinct (method) as method')
                ->find_many();
        $this->ui->assign('method', $c);

        $e = ORM::for_table('state')->order_by_asc('state_name')->find_many();
        $this->ui->assign('state', $e);

        $d = ORM::for_table('module_imobles_enterprise')->raw_query("select count(e.id)  as total" . $sql . "")->find_many();
        $bottomBar = array(
            array('type' => 'int', 'info' => $this->_L['module imobles find total'], 'value' => $d[0]->total),
        );
        $this->ui->assign('bottomBar', $bottomBar);

        $this->ui->assign('_st', $this->_L['module imobles cache list']);
        $this->ui->assign('_include', 'cache/list');
        $this->ui->display('wrapper.tpl');
    }

    public function view() {
        if (empty($this->routes[3]) || !is_numeric($this->routes[3])) {
            die($this->_L['Id_Required']);
        }
        $cacheId = isset($this->routes[3]) ? intval($this->routes[3]) : 0;

        $cacheQuery = ORM::for_table('module_imobles_cache')
                ->select_expr('json_output, method, controller,id')
                ->order_by_asc('updated_at');
        $cache = $cacheQuery->find_one($cacheId);
        header('Content-Type: application/json');
        echo ($cache->json_output);
        exit();
    }

    public function delete() {
        if (empty(_post('id')) || !is_numeric(_post('id'))) {
            die($this->_L['Id_Required']);
        }

        $cacheQuery = ORM::for_table('module_imobles_cache')
                ->select_expr('json_output, method, controller,id')
                ->order_by_asc('updated_at');
        $cache = $cacheQuery->find_one(_post('id'));
        $cache->delete();

        r2(U . 'module_imobles/cache/listAll', 's', $this->_L['delete_successful']);
    }

    public function deleteCacheBatch() {
        if (empty(@$_POST['id'])) {
            die($this->_L['Id_Required']);
        }
        $ids = $_POST['id'];

        ORM::for_table('module_imobles_cache')
            ->where_in("id", $ids)
            ->delete_many();
    }

    public function deleteCacheAll() {
        $cacheQuery = ORM::for_table('module_imobles_cache');
        if (!empty(_post('method'))) {
            $cacheQuery->where_equal("method", _post('method'));
        }
        $cacheQuery->delete_many();
    }

    public function renewCache($ids = null) 
    {
        @ini_set('memory_limit', '4095M');
        @ini_set('max_execution_time', 0);
        @set_time_limit(0);
        
        $cacheId = isset($this->routes[3]) ? intval($this->routes[3]) : 0;
        $cacheQuery = ORM::for_table('module_imobles_cache')
                ->select_expr('json_input, method, controller,id')
//                ->where("updated_at<='" . date("Y-m-d H:i:s", strtotime('-1 day', strtotime(date("Y-m-d H:i:s")))) . "'")
                ->order_by_asc('updated_at');
        if ($cacheId) {
            //regra para renew 1 cache 
            $cacheQuery->where("id", $cacheId);
        } else if ($ids != null) {
            // para renovar ids selecionados
            $cacheQuery->where_in("id", $ids);
        }
        $apiKey = ORM::for_table('sys_api')->find_many();
        if ($apiKey) {
            $cache = $cacheQuery->find_many();
            if ($cache) {
                
                $count = 0;
                foreach ($cache as $c) {
                    try {
                        $count++;
                        $c1 = ORM::for_table('module_imobles_cache')->find_one($c->id);
                        $c1->updated_at = '2021-01-01 00:00';
                        $c1->save();
                        $curl = curl_init();
                        curl_setopt_array($curl, array(
                            CURLOPT_URL => U . 'api&key=' . $apiKey[0]->apikey . '&method=plugin&plugin=module_imobles&pl_method=' . $c->method,
                            CURLOPT_RETURNTRANSFER => true,
//                        CURLOPT_ENCODING => '',
//                        CURLOPT_MAXREDIRS => 10,
                            CURLOPT_TIMEOUT => 0,
                            CURLOPT_FOLLOWLOCATION => true,
                            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                            CURLOPT_CUSTOMREQUEST => 'POST',
                            CURLOPT_POSTFIELDS => $c->json_input,
                        ));
                        curl_exec($curl);
                        curl_close($curl);
//                    echo $response;
                        echo $count." | ".$c->method."\n";
                    } catch (Exception $e) {
                        echo $e->getMessage();
                    }
                }
            }
        }
    }

    public function renewCacheBatch(){
        if (empty(@$_POST['id'])) {
            die($this->_L['Id_Required']);
        }
        $ids = $_POST['id'];
        $this->renewCache($ids);
    }

}

Anon7 - 2022
AnonSec Team