403Webshell
Server IP : 172.67.178.83  /  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/officespace4rent.com/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/corbizre/officespace4rent.com/import_officespace4rent_local.php
<?php
if( php_sapi_name() !== 'cli' ) {
    die("Meant to be run from command line");
}

function find_wordpress_base_path() {
    $dir = dirname(__FILE__);
    do {
        //it is possible to check for other files here
        if( file_exists($dir."/wp-config.php") ) {
            return $dir;
        }
    } while( $dir = realpath("$dir/..") );
    return null;
}

define( 'BASE_PATH', find_wordpress_base_path()."/" );
define('WP_USE_THEMES', false);
global $wp, $wp_query, $wp_the_query, $wp_rewrite, $wp_did_header;
require(BASE_PATH . 'wp-load.php');

class Import {

    protected  $houseDb;
    protected  $states;

    public function __construct()
    {
        $dbname = 'officespace4lease';
        $this->houseDb = new wpdb( DB_USER, DB_PASSWORD, $dbname, DB_HOST );
        $this->states = wpl_locations::get_locations(2, 254, '');
    }


    public function run()
    {
        $count = 1;
        $page = 0;
        $pid = null;

        while ($count > 0){
            $result = $this->loadData($page);
            $count = count($result);
            if($count){
                foreach($result as $i=>$row) {

                    $query = $this->prepareData($row);
                    $pid = (is_null($pid)) ? wpl_property::create_property_default() : $pid;

                    if(wpl_db::q("UPDATE `#__wpl_properties` SET $query WHERE `id` = '$pid'")){
                        wpl_property::finalize($pid, 'edit', 1);

                        if($row['field_image_url_value']){
                            $image = "http://www.officespace4lease.com/".$row['field_image_url_value'];
                            $path = wpl_global::get_upload_base_path().$pid.DS.basename($image);
                            wpl_file::write($path, wpl_global::get_web_page($image));

                            wpl_items::save(array('parent_id'=>$pid, 'parent_kind'=>0, 'item_type'=>'gallery', 'item_cat'=>'image', 'item_name'=>basename($image), 'creation_date'=>date("Y-m-d H:i:s"), 'index'=>0));
                        }

                        $query = "`alias` = '".$row['dst']."'";
                        wpl_db::q("UPDATE `#__wpl_properties` SET $query WHERE `id` = '$pid'");

                        wpl_property::update_numbs($pid);
                        $pid = null;
                    }
                }
            }
            $page++;
        }
    }

    public function prepareData(array $row)
    {
        $state = $this->getState($row['field_region_value']);
        $city = $row['field_market_value'];
        $price = ($row['field_monthly_rent_value']) ? $row['field_monthly_rent_value'] : 0;
        $baseRent = ($row['field_base_rent_value']) ? $row['field_base_rent_value'] : 0;

        return " `price` = '".$price."'"
            . ", `price_period` = '30'"
            . ", `property_type` = '13'"
            . ", `listing` = '10'"
            . ", `confirmed` = '1'"
            . ", `living_area` = '". $this->sqft($row['field_size_value'])."'"
            . ", `build_year` = '".$row['field_year_built_value']."'"
            . ", `alias` = '".$row['dst']."'"
            . ", `field_42` = '".$row['field_address_value']."'"
            . ", `field_54` = '".$row['field_building_name_value']."'"
            . ", `field_55` = '".$this->toInt($row['field_number_of_floors_value'])."'"
            . ", `field_308` = '".$row['title']."'"
            . ", `field_313` = '".$this->getTitle($row['title'])."'"
            . ", `field_312` = '".$row['title']."'"
            . ", `field_3000` = '".$row['field_lease_term_value']."'"
            . ", `field_3001` = '".$row['field_lease_type_value']."'"
            . ", `field_3002` = '".$row['field_available_value']."'"
            . ", `field_3003` = '".$row['field_market_value']."'"
            . ", `field_3006` = '".$row['field_attended_lobby_value']."'"
            . ", `field_3007` = '".$this->toInt($row['field_floor_value'])."'"
            . ", `field_3008` = '".$this->toInt($row['field_suite_value'])."'"
            . ", `field_3009` = '".$row['field_type_of_space_value']."'"
            . ", `field_3010` = '".$this->sqft($row['field_building_size_value'])."'"
            . ", `field_3011` = '".$baseRent."'"
            . ", `location2_id` = '{$state->id}', `location2_name` = '{$state->name}', `location4_name` = '{$city}'";
        ;
    }

    protected function loadData($page)
    {
        $limit = 1000;
        $offset = $page * $limit;
        $query = 'SELECT f.*, nr.title, u.dst FROM `content_type_featuredlisting` as f '
            .'INNER JOIN `node_revisions` AS nr ON nr.vid = f.vid '
            .'INNER JOIN `url_alias` AS u ON u.src = CONCAT("node/", f.vid)'
            .'ORDER BY f.`vid` DESC '
            .'LIMIT '
            .$offset
            .','
            .$limit;

        return $this->houseDb->get_results($query, ARRAY_A);
    }

    protected function getState($str)
    {
        foreach ($this->states as $state){
            $pattern = $state->name;
            if(preg_match("(^{$pattern})", $str)){
                return $state;
            }
        }

        return array();
    }

    protected function getTitle($str)
    {
        $titleArr = explode(',', $str);
        array_pop($titleArr);
        return implode(',', $titleArr);
    }

    protected function sqft($str)
    {
        return (int) str_replace(',', '', trim(trim($str, 'sf')));
    }

    protected function toInt($value)
    {
        return (int)preg_replace('([^0-9]+)', '', $value);
    }
}

$import = new Import();
$import->run();

Youez - 2016 - github.com/yon3zu
LinuXploit