403Webshell
Server IP : 104.21.17.213  /  Your IP : 216.73.217.141
Web Server : Apache
System : Linux hosting01.arsenalhost.com 4.18.0-425.13.1.lve.el8.x86_64 #1 SMP Mon Feb 27 15:23:24 EST 2023 x86_64
User : corbizre ( 1013)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/corbizre/gotofindhomes.com3/components/Solr/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/corbizre/gotofindhomes.com3/components/Solr/Data.php
<?php

/**
 * Documentation
 * @author leonid
 * @category
 * @package
 * @subpackage
 * @copyright  Copyright (c) 2005-2013 ITCrimea Ukraine Inc. (http://www.itcrimea.com)
 * @license
 */
class Solr_Data {

    /**
     * @var array
     */
    private $_config;

    
    /**
     * @param array $config 
     */
    public function __construct($config = null) {
        if (is_array($config) && !empty($config)) {
            $this->_config = $config;
        } else {
            $cfgSolr = System_Components::getComponentConfig('Solr');
            $this->_config = $cfgSolr->toArray();
        }
    }

    /**
     * Import RealEstate_House object to Solr database
     * @param RealEstate_House $objHouse
     * @throws Zend_Exception 
     */
    public function import(RealEstate_House $objHouse) {

        $objClient = new Solarium\Client($this->_config);
        try {

            $update = $objClient->createUpdate();
            
            $objDoc = $update->createDocument();
            $objDoc->id = $objHouse->ID;
            $objDoc->Ownership = $objHouse->Ownership;
            $objDoc->OfferType = $objHouse->OfferType;
            $objDoc->Zip = $objHouse->Zip;
            $objDoc->Address = $objHouse->Address;
            $objDoc->City = $objHouse->City;
            $objDoc->State = $objHouse->State;
            $objDoc->StateFull = Address_State::getNameByShort($objHouse->State);
            //TODO: need to calculate price for commercial / residential / sale / rent
            $objDoc->Price = $objHouse->Price;
            $objDoc->DateUpdated = date("Y-m-d\TH:i:s\Z", strtotime($objHouse->DateUpdated));
            $objDoc->Published = $objHouse->Published;

            $update->addDocument($objDoc);
            $update->addCommit();

            $objClient->update($update);
        } catch (Exception $e) {
            LogSystem::addLog('Solr', 'Solr_Data', 'import', $objHouse->ID, LogSystem::SEVERITY_CRIT,
                    'Unable to import House with ID = ' . $objHouse->ID . '. ' . $e->getMessage() . "\r\n" . $e->getTraceAsString(),
                    $objHouse->toArray());
            throw new Zend_Exception('Unable to import House with ID = ' . $objHouse->ID . '. ' . $e->getMessage());
        }
    }
    
    /**
     * Delete house from Solr db by id
     * @param integer $HouseID
     * @throws Zend_Exception 
     */
    public function delete($HouseID){
        
        $objClient = new Solarium\Client($this->_config);

        try {
            $update = $objClient->createUpdate();

            $update->addDeleteById($HouseID);
            $update->addCommit();

            $objClient->update($update);
        } catch (Exception $e) {
            LogSystem::addLog('Solr', 'Solr_Data', 'delete', $HouseID, LogSystem::SEVERITY_CRIT,
                    'Unable to delete House with ID = ' . $HouseID . '. ' . $e->getMessage() . "\r\n" . $e->getTraceAsString(), '');
            throw new Zend_Exception('Unable to import House with ID = ' . $HouseID . '. ' . $e->getMessage());
        }
                
    }
    
    /**
     * Get list of house ids by query params
     * @param array $queryParts
     * @param string $searchQuery
     * @param string $sort
     * @param string $dir
     * @param integer $page
     * @param integer $results
     * @return Solr_Data_List_Id
     * @throws Zend_Exception 
     */
    public function getlist($queryParts = null, $searchQuery = null, $sort = 'DateUpdated', $dir = 'DESC', $page = 1, $results = 20){
        
        if ($page < 1)
            $page = 1;
        
        $objClient = new Solarium\Client($this->_config);
        try {
            
            $query = $objClient->createSelect();
            
            foreach ($queryParts as $key => $currQueryPart) {
                $query->createFilterQuery('filterquery'.$key)->setQuery($currQueryPart);
            }
            
            if (!empty($searchQuery)) {
                $query->setQuery(self::escapePhrase($searchQuery));
                $query->addParam('defType', 'dismax');
                $query->addParam('qf', array('Zip^25.0','State^20.0','City^15.0','StateFull^5.0','Address^1.0'));
            }
            
            $query->setStart(($page-1)*$results)->setRows($results);
            $query->setFields(array('id'));

            if (!empty($sort)) {
                if ($dir == 'DESC') {
                    $query->addSort($sort, Solarium\QueryType\Select\Query\Query::SORT_DESC);
                } else {
                    $query->addSort($sort, Solarium\QueryType\Select\Query\Query::SORT_ASC);
                }
            }
            
            $resultset = $objClient->select($query);
            
            return new Solr_Data_List_Id($resultset);
            
        } catch (Exception $e) {
            LogSystem::addLog('Solr', 'Solr_Data', 'getlist', 0, LogSystem::SEVERITY_CRIT,
                    $e->getMessage() . "\r\n" . $e->getTraceAsString(),
                    'Query Parts: ' . serialize($queryParts) . "\r\n" .
                    'Sort: ' . $sort . "\r\n" .
                    'Dir: ' . $dir . "\r\n" .
                    'Page: ' . $page . "\r\n" .
                    'Results: ' . $results);
            throw new Zend_Exception('Error in Solr_Data->getlist(). ' . $e->getMessage());
        }
        
    }
    
    public static function escapePhrase($input){
        return '"' . preg_replace('/("|\\\)/', '\\\$1', $input) . '"';
    }
    
    public static function escapeArray($arr){
        foreach ($arr as $key => $val) {
            $arr[$key] = self::escapePhrase($val);
        }
        return $arr;
    }

}

Youez - 2016 - github.com/yon3zu
LinuXploit