Exemplo n.º 1
0
function code_main()
{
    // check if a session (w/ login) exists
    if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] != "yes") {
        code_login_page();
    }
    // check if we're trying to get metadata details.  if so, chop up the request
    if (isset($_REQUEST['details_for']) && !empty($_REQUEST['details_for'])) {
        list($details_for_resource, $details_for_class) = explode("|", $_REQUEST['details_for']);
    } else {
        $details_for_resource = "";
        $details_for_class = "";
    }
    // set things up
    $rets = new phRETS();
    $rets->AddHeader("Accept", "*/*");
    $rets->AddHeader("RETS-Version", "RETS/{$_SESSION['rets_version']}");
    $rets->AddHeader("User-Agent", $_SESSION['user_agent']);
    $rets->SetParam("cookie_file", $GLOBALS['cookie_file_name']);
    $rets->SetParam("compression_enabled", true);
    if ($_SESSION['force_basic'] == "true") {
        $rets->SetParam("force_basic_authentication", true);
    }
    // make first connection
    $connect = $rets->Connect($_SESSION['login_url'], $_SESSION['username'], $_SESSION['password'], $_SESSION['ua_pwd']);
    if (!$connect) {
        $error_details = $rets->Error();
        $error_text = strip_tags($error_details['text']);
        $error_type = strtoupper($error_details['type']);
        show_error_page("<center><span style='color:red;font-weight:bold;'>{$error_type} ({$error_details['code']}) {$error_text}</span></center>");
    }
    $resource_info = $rets->GetMetadataInfo();
    page_header("Server Information");
    echo "<div class='box'>\n\t<div class='box_heading dark-bg'>Server Information</div>\n\t<div class='box_content light-bg'>\n\t\t<table border='0' cellpadding='1' cellspacing='1' width='100%'>\n\t\t";
    // read back information from connection request
    $rets_server_information = $rets->GetServerInformation();
    echo "<tr><td width='25%' valign='top'><b>RETS Server:</b></td><td width='75%' class='detail'>{$rets_server_information['SystemDescription']}</td></tr>\n";
    echo "<tr><td valign='top'><b>RETS System ID:</b></td><td class='detail'>{$rets_server_information['SystemID']}</td></tr>\n";
    if (array_key_exists('TimeZoneOffset', $rets_server_information) && !empty($rets_server_information['TimeZoneOffset'])) {
        echo "<tr><td valign='top'><b>Server Timezone:</b></td><td class='detail'>{$rets_server_information['TimeZoneOffset']}</td></tr>\n";
    }
    // read back information from connection request
    $full_login_url = $rets->GetLoginURL();
    echo "<tr><td valign='top'><b>Login URL:</b></td><td class='detail'>{$full_login_url}</td></tr>\n";
    // read back information from connection request
    $server_version = preg_replace('/RETS\\//', '', $rets->GetServerVersion());
    echo "<tr><td valign='top'><b>RETS Version:</b></td><td class='detail'>{$server_version}</td></tr>\n";
    // read back information from connection request
    $server_software = $rets->GetServerSoftware();
    if (empty($server_software)) {
        $server_software = "(unknown)";
    }
    echo "<tr><td valign='top'><b>Server Software:</b></td><td class='detail'>{$server_software}</td></tr>\n";
    // read back information from connection request
    $auth_support = "";
    if ($rets->CheckAuthSupport("digest") == true) {
        $auth_support .= "Digest, ";
    }
    if ($rets->CheckAuthSupport("basic") == true) {
        $auth_support .= "Basic, ";
    }
    $auth_support = preg_replace('/\\, $/', '', $auth_support);
    if (empty($auth_support)) {
        $auth_support = "(unknown - assuming Basic)";
        // cURL blindly sends the login information if Basic so it doesn't give us a chance to auto-detect
    }
    echo "<tr><td valign='top'><b>Authen. Supported:</b></td><td class='detail'>{$auth_support}</td></tr>\n";
    // read back information from login response
    $transactions = $rets->GetAllTransactions();
    $transactions_list = "";
    foreach ($transactions as $transaction) {
        $transactions_list .= "<acronym title='{$rets->capability_url[$transaction]}'>{$transaction}</acronym>, ";
    }
    $transactions_list = preg_replace('/\\, $/', '', $transactions_list);
    echo "<tr><td valign='top'><b>Transactions Supported:</b></td><td class='detail'>{$transactions_list}</td></tr>\n";
    // make first general GetMetadata request to see what's there
    $rets_metadata_types = $rets->GetMetadataTypes();
    $resources_avail = "";
    foreach ($rets_metadata_types as $resource) {
        $resources_avail .= "<a href='#md-{$resource['Resource']}'>{$resource['Resource']}</a>, ";
    }
    $resources_avail = preg_replace('/\\, $/', '', $resources_avail);
    echo "<tr><td valign='top'><b>Metadata Resources:</b></td><td class='detail'>{$resources_avail}</td></tr>\n";
    echo "\t\t</table>\n\t</div>\n\t</div>\n\t";
    echo "\n<div class='box'>\n\t<div class='box_heading dark-bg'>Metadata Information</div>\n\t<div class='box_content light-bg'>\n\n";
    $metadata_keyfield = array();
    $metadata_details_pulldown = "";
    foreach ($rets_metadata_types as $resource) {
        echo "<a name='md-{$resource['Resource']}'></a>";
        $metadata_details_pulldown .= "<optgroup label='{$resource['Resource']}'>";
        echo "<div class='box-inner white-bg'>";
        echo "<b>{$resource['Resource']}</b><br/><br/>\n";
        echo "<span style='font-size: 8pt;'>";
        foreach ($resource['Data'] as $class) {
            $this_selected = $details_for_resource == $resource['Resource'] && $details_for_class == $class['ClassName'] ? " selected='selected'" : "";
            $metadata_details_pulldown .= "<option value='{$resource['Resource']}|{$class['ClassName']}'{$this_selected}>{$class['ClassName']} - {$class['VisibleName']} - {$class['Description']}</option>";
            echo " &nbsp; &nbsp; &nbsp; &nbsp;&middot; <b><a href='' class='resource-class-link' data-resource='{$resource['Resource']}' data-class='{$class['ClassName']}' title='SystemName: {$class['ClassName']}   StandardName: {$class['StandardName']}'>{$class['ClassName']}</a></b> - {$class['VisibleName']} - {$class['Description']}<br/>";
            echo " &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StandardName: {$class['StandardName']} &nbsp; &nbsp; &nbsp; &nbsp; Last Updated: {$class['TableDate']} &nbsp; &nbsp; &nbsp;  &nbsp; Version: {$class['TableVersion']}<br/>";
            echo "<br/>\n";
        }
        $metadata_details_pulldown .= "</optgroup>";
        echo "</span>\n";
        echo "</div>\n\n";
    }
    echo "\n\n\t</div>\n</div>\n";
    echo "\n<div class='box'>\n\t<a name='md-details' id='md-details'></a>\n\t<div class='box_heading dark-bg'>Metadata Details</div>\n\t<div class='box_content light-bg'>\n\n";
    echo "<center><select name='details_for' id='resource-class-selector' ><option value=''></option>{$metadata_details_pulldown}</select></center><br/>";
    echo "\n\n\t\t<div id='md-details-content'>\n\n\t\t</div>\n\n\t</div>\n</div>\n";
    echo "\n<div style='text-align: center;'>\n<p><img src='{$GLOBALS['media_url']}search-icon-grey.gif' alt='Searchable Field'/> Searchable Field &nbsp; &nbsp; &nbsp; <img src='{$GLOBALS['media_url']}skey.png' alt='Key Field'/> Key Field &nbsp; &nbsp; &nbsp; <img src='{$GLOBALS['media_url']}star.png' alt='Required'/> Required &nbsp; &nbsp; &nbsp; <img src='{$GLOBALS['media_url']}heart.png' alt='InKeyIndex'/> InKeyIndex</p>\n</div>\n";
    // disconnect from RETS server
    $rets->Disconnect();
    page_footer();
}
$log_file = "--------------------------------------------------------------" . $eol;
$log_file .= date("Y-m-d G:i") . $eol;
// Connect to the RETS Server
if ($debugging) {
    echo "+ Connecting to {$rets_login_url} as {$rets_username}<br />\n";
}
$connect = $rets->Connect($rets_login_url, $rets_username, $rets_password);
if ($connect) {
    if ($debugging) {
        echo "  + Connected<br />\n";
    }
    $log_file .= "Connected to RETS server and downloaded:" . $eol;
} else {
    if ($debugging) {
        echo "  + Not connected:<br />\n";
        print_r($rets->Error());
    }
    $alerts_txt .= "Could not connect to the RETS server.";
    $log_file .= $alerts_txt . $eol;
    $log_file .= print_r($rets->Error());
    webadmin_alert($alerts_txt, $log_file);
    if (!fwrite($handle_log, $log_file)) {
    }
    fclose($handle_log);
    exit;
}
/* Get type info from the meta data */
$types = $rets->GetMetadataTypes();
if (!$types) {
    $log_file .= print_r($rets->Error());
} else {
Exemplo n.º 3
0
function connectRETS()
{
    global $rets_login_url, $rets_username, $rets_password;
    /* Get our phRets class */
    require_once "inc-class-phrets.php";
    $rets = new phRETS();
    // Connect to the RETS Server
    if ($debugging) {
        echo "+ Connecting to {$rets_login_url} as {$rets_username}<br />\n";
    }
    $connect = $rets->Connect($rets_login_url, $rets_username, $rets_password);
    if ($connect) {
        if ($debugging) {
            echo "  + Connected<br />\n";
        }
        return $rets;
    } else {
        if ($debugging) {
            echo "  + Not connected:<br />\n";
            print_r($rets->Error());
        }
        return null;
    }
}
require "inc-class-phrets.php";
$rets = new phRETS();
//$rets->AddHeader("User-Agent", $rets_user_agent);
//$rets->AddHeader("Accept", "*/*");
//$rets->AddHeader("RETS-Version", "$Rets_Version");
//$rets->AddHeader("User-Agent", "$rets_user_agent");
//$rets->SetParam("cookie_file", "phrets_cookies.txt");
//$rets->SetParam("debug_mode", TRUE); // ends up in rets_debug.txt
echo "+ Connecting to {$rets_login_url} as {$rets_username}<br>\n";
$connect = $rets->Connect($rets_login_url, $rets_username, $rets_password);
// check for errors
if ($connect) {
    echo "  + Connected<br>\n";
} else {
    echo "  + Not connected:<br>\n";
    print_r($rets->Error());
    exit;
}
$types = $rets->GetMetadataTypes();
// check for errors
if (!$types) {
    print_r($rets->Error());
} else {
    foreach ($types as $type) {
        echo "+ Resource {$type['Resource']}<br>\n";
        foreach ($type['Data'] as $class) {
            echo "  + Class {$class['ClassName']}<br>\n";
        }
    }
}
$rets_version = $rets->GetServerVersion();