HEX
Server: Apache
System: Linux www3.pit.tblive.com 5.14.0-687.38.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Aug 12 17:19:12 EDT 2026 x86_64
User: awaldron (1020)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/awaldron/_phpassport/api.pennhillspassport.com/v1/realestate.php
<?php
//**********************************************************************************************************//
// Method: POST
// Endpoint: realestate/listings
function get_v1_realestate_listings($args, $body, $uid, $admin_level, $db)
{
//    $rules = [
//        'i' => 'req',
//        'size' => 'req',
//        'min' => 'req',
//        'max' => 'req',
//    ];
//    validate_body($body, $rules);

    try {
        $res = qSet($db, "SELECT * FROM realestate 
                                WHERE (township='Penn Hills' OR township='Verona' OR township='Blackridge')
                                ORDER BY listing_price DESC");

//        $res = qSet($db, "SELECT * FROM realestate
//                                WHERE listing_price >= ".$body['min']." AND listing_price <= ".$body['max']."
//                                  AND (township='Penn Hills' OR township='Verona' OR township='Blackridge')
//                                ORDER BY listing_price DESC
//                                LIMIT " . $body['i'] . ", " . $body['size']);

//        $total = qVal($db, "SELECT COUNT(id) FROM realestate
//                                 WHERE listing_price >= ".$body['min']." AND listing_price <= ".$body['max']."
//                                   AND (township='Penn Hills' OR township='Verona' OR township='Blackridge')");

//        $data['records'] = $res;
//        $data['pager'] = [
//            'i' => $body['i'],
//            'j' => $body['i'] + $body['size'],
//            'size' => $body['size'],
//            'total' => $total,
//        ];
        response(200, ['success' => true, 'listings' => $res]);
    } catch (Exception $e) {
        response(200, ['success' => false, 'errors' => [$e->getMessage()]]);
    }

}


//**********************************************************************************************************//
// Method: GET
// Endpoint: realestate/collect
function get_v1_realestate_collect($args, $body, $uid, $admin_level, $db)
{
    $urls[] = 'https://www.thepreferredrealty.com/real-estate/selectmodule.cfc?method=getPropertyMarkers&myPropertyType=All&mybeds=0&mybaths=0&myfilter=&myMinPrice=0&myaddress=15235&myMaxPrice=20000000&myoffice=&mypool=false&mybasement=false&north=41.97371743392374&south=38.995635721888604&east=-77.27114580078126&west=-82.40725419921876&mysortorder=PRICE+DESC&myacres=';
    $urls[] = 'https://www.thepreferredrealty.com/real-estate/selectmodule.cfc?method=getPropertyMarkers&myPropertyType=All&mybeds=0&mybaths=0&myfilter=&myMinPrice=0&myaddress=15147&myMaxPrice=20000000&myoffice=&mypool=false&mybasement=false&north=41.391165273399565&south=39.59926919163877&east=-77.059658984375&west=-82.618741015625&mysortorder=PRICE+DESC&myacres=';

    // empty the db
    $db->query('TRUNCATE TABLE realestate');
    $ctr1 = 0;

    foreach ($urls as $url) {
        $useragent = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0';

        $handle = curl_init();
        curl_setopt($handle, CURLOPT_URL, $url);
        curl_setopt($handle, CURLOPT_FRESH_CONNECT, TRUE);
        curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($handle, CURLOPT_USERAGENT, $useragent);
        curl_setopt($handle, CURLOPT_REFERER, 'https://www.thepreferredrealty.org');

        $response = curl_exec($handle);
        curl_close($handle);
        $listings = json_decode($response, true);

        //pp($listings); exit;

        foreach ($listings as $l) {
            $ins = "INSERT INTO realestate (`idx_office`, `open_house`, `acres`, `baths`, `beds`, `lat`, `lng`, `listing_num`, `listing_price`, `mls_system`, `address`, `proptype`, `school_district`, `status`, `date`, `township`, `url_address`, `zipcode`) VALUES (";
            $ins .= "'" . formatHtml($l['IDXoffice']) . "', ";
            $ins .= "'" . formatHtml($l['OpenInfo']) . "', ";
            $ins .= "'" . formatHtml($l['acres']) . "', ";
            $ins .= "'" . formatHtml($l['baths']) . "', ";
            $ins .= "'" . formatHtml($l['beds']) . "', ";
            $ins .= "'" . formatHtml($l['latitude']) . "', ";
            $ins .= "'" . formatHtml($l['longitude']) . "', ";
            $ins .= "'" . numeric($l['listing_number']) . "', ";
            $ins .= "'" . numeric($l['listing_price']) . "', ";
            $ins .= "'" . formatHtml($l['mlsSystem']) . "', ";
            $ins .= "'" . formatHtml($l['propertyaddress']) . "', ";
            $ins .= "'" . formatHtml($l['proptype']) . "', ";
            $ins .= "'" . formatHtml($l['schooldistrict']) . "', ";
            $ins .= "'" . formatHtml($l['status']) . "', ";
            $ins .= "'" . formatHtml($l['stime']) . ":00.000Z', ";
            $ins .= "'" . formatHtml($l['township']) . "', ";
            $ins .= "'" . formatHtml($l['url_address']) . "', ";
            $ins .= "'" . formatHtml($l['zipcode']) . "' ";
            $ins .= ")";

            $db->query($ins);
            $ctr1++;
        }
    }

    response(200, ['success' => true, 'inserted' => $ctr1]);
}