Пример #1
0
        " The page may contain an invalid database reference (0 indicates no reference has been set)");
}

$reg_url = $data['rec_URL'];         //base url for source database
*/
// ------------------------------------------------------------------------------------------------
// 2. get definitions from remote database
$reg_url = explode("?", $reg_url);
$remote_url_params = @$reg_url[1];
$remote_url = @$reg_url[0];
if (!$remote_url_params || !$remote_url) {
    error_exit("Heurist Master Index returns incorrect data for registered database # " . $database_id . " The page may contain an invalid database reference (0 indicates no reference has been set)");
}
$reg_url = $remote_url . "common/php/reloadCommonInfo.php?" . $remote_url_params;
//$defs = loadRemoteURLContent($reg_url); it does not because of proxy settings on usyd server
$defs = loadRemoteURLContentSpecial($reg_url);
if (!$defs) {
    error_exit("Unable to contact the selected source database, possibly due to a timeout or proxy setting");
}
$defs = json_decode($defs, true);
if (!($defs['rectypes'] && $defs['detailTypes'] && $defs['terms'])) {
    error_exit("Structure definitions read from source database # {$database_id} are invalid. Please advise Heurist development team");
}
//remote database
$def_rts = $defs['rectypes']['typedefs'];
$def_dts = $defs['detailTypes']['typedefs'];
// ------------------------------------------------------------------------------------------------
// 3. Add the record type as the first element in a list
if (!@$def_rts[$rectype_id]) {
    error_exit("Sorry, record type {$rectype_id} was not found in source database # {$database_id}. Please advise Heurist development team");
}
Пример #2
0
* @license     http://www.gnu.org/licenses/gpl-3.0.txt GNU License 3.0
* @package     Heurist academic knowledge management system
* @subpackage  !!!subpackagename for file such as Administration, Search, Edit, Application, Library
*/
//if(!defined('NO_DB_ALLOWED')) define('NO_DB_ALLOWED',1);
if (!defined('ISSERVICE')) {
    define('ISSERVICE', 1);
}
require_once dirname(__FILE__) . "/../../../common/config/initialise.php";
require_once dirname(__FILE__) . '/../../../common/php/dbMySqlWrappers.php';
$isOutSideRequest = strpos(HEURIST_INDEX_BASE_URL, HEURIST_SERVER_URL) === false;
if ($isOutSideRequest) {
    //this is request from outside - redirect to master index
    require_once dirname(__FILE__) . '/../../../records/files/fileUtils.php';
    $reg_url = HEURIST_INDEX_BASE_URL . "admin/setup/dbproperties/getDatabaseURL.php?db=Heurist_Master_Index&remote=1&id=" . $database_id;
    $data = loadRemoteURLContentSpecial($reg_url);
    if (!$data) {
        $error_msg = "Unable to contact Heurist Master Index, possibly due to timeout or proxy setting<br /><br />" . "URL requested: " . $reg_url;
    } else {
        $data = json_decode($data, true);
        // Artem TODO: What circumstance would give rise to this? Explain how the data is 'wrong'/'incorrect'
        // Artem: cannot connect to Heurist_Master_Index, Records table is corrupted, $database_id is not found
        if (@$data['error_msg']) {
            $error_msg = $data['error_msg'];
        } else {
            if (!@$data['rec_URL']) {
                $error_msg = "Heurist Master Index returns incorrect data for registered database # " . $database_id . " The page may contain an invalid database reference (0 indicates no reference has been set)";
            } else {
                $database_url = $data['rec_URL'];
                // Artem: FOR heurist.sydney.edu.au change to latest h4-ao
                if (strpos($database_url, 'heurist.sydney.edu.au/h3/') > 0) {
Пример #3
0
function registerDatabase()
{
    $heuristDBname = rawurlencode(HEURIST_DBNAME);
    global $dbID, $dbName, $ownerGrpID, $indexdb_user_id, $usrEmail, $usrPassword, $usrName, $usrFirstName, $usrLastName, $dbDescription;
    $serverURL = HEURIST_BASE_URL . "?db=" . $heuristDBname;
    $serverURL = substr($serverURL, 7);
    // to avoid conversion path to localhost if masterindex on the same server
    $usrEmail = rawurlencode($usrEmail);
    $usrName = rawurlencode($usrName);
    $usrFirstName = rawurlencode($usrFirstName);
    $usrLastName = rawurlencode($usrLastName);
    $usrPassword = rawurlencode($usrPassword);
    $dbDescriptionEncoded = rawurlencode($dbDescription);
    $reg_url = HEURIST_INDEX_BASE_URL . "admin/setup/dbproperties/getNextDBRegistrationID.php" . "?db=Heurist_Master_Index&dbReg=" . $heuristDBname . "&dbVer=" . HEURIST_DBVERSION . "&dbTitle=" . $dbDescriptionEncoded . "&usrPassword="******"&usrName=" . $usrName . "&usrFirstName=" . $usrFirstName . "&usrLastName=" . $usrLastName . "&usrEmail=" . $usrEmail . "&serverURL=" . rawurlencode($serverURL);
    //$data = loadRemoteURLContent($reg_url);
    $data = loadRemoteURLContentSpecial($reg_url);
    //without proxy
    if (!$data) {
        die("Unable to contact Heurist master index, possibly due to timeout or proxy setting<br />" . "URL requested: <a href='{$reg_url}'>{$reg_url}</a>");
    }
    if ($data) {
        $dbID = intval($data);
        // correct return of data is just the registration number. we probably need a
        // better formatted return with some tags to ensure we are getting the right thing
    }
    if ($dbID == 0) {
        // Unable to allocate a new database identifier
        $decodedData = explode(',', $data);
        if (count($decodedData) > 0) {
            $msg = $decodedData[1];
        } else {
            $msg = "Problem allocating a database identifier from the Heurist master index, " . "returned the following instead of a registration number:\n" . substr($data, 0, 25) . " ... \nPlease contact <a href=mailto:info@HeuristNetwork.org>Heurist developers</a> for advice";
        }
        echo $msg . "<br />";
        return;
    } else {
        if ($dbID == -1) {
            // old title update function, should no longer be called
            $res = mysql_query("update sysIdentification set `sys_dbDescription`='" . mysql_real_escape_string($dbDescription) . "' where 1");
            echo "<div class='input-row'><div class='input-header-cell'>" . "Database description (updated):</div><div class='input-cell'>" . $dbDescription . "</div></div>";
        } else {
            // We have got a new dbID, set the assigned dbID in sysIdentification
            $res = mysql_query("update sysIdentification set `sys_dbRegisteredID`='{$dbID}', " . "`sys_dbDescription`='" . mysql_real_escape_string($dbDescription) . "' where 1");
            if ($res) {
                echo "<div class='input-row'><div class='input-header-cell'>Database:</div>" . "<div class='input-cell'>" . DATABASE . "</div></div>";
                echo "<div class='input-row'><div class='input-header-cell'>" . "Registration successful, database ID allocated is</div>" . "<div class='input-cell'>" . $dbID . "</div></div>";
                echo "<div class='input-row'><div class='input-header-cell'></div>" . "<div class='input-cell'>Basic description: " . $dbDescription . "</div></div>";
                $url = HEURIST_INDEX_BASE_URL . "records/edit/editRecord.html?recID=" . $dbID . "&db=Heurist_Master_Index";
                echo "<div class='input-row'><div class='input-header-cell'>Collection metadata:</div>" . "<div class='input-cell'><a href={$url} target=_blank>Click here to edit</a> " . "(login - if asked - as yourself) </div></div>";
                // Update original DB ID and original db code for all existing record types, fields and terms
                // which don't have them (meaning that they were defined within this database)
                // Record types
                $result = db_register(DATABASE, $dbID);
                if (!$result) {
                    echo "<div class=wrap><div id=errorMsg>Unable to set all values for originating DB information for " . DATABASE . " - one of the update queries failed</div></div>";
                }
                ?>
                        <script> // automatically call Heurist_Master_Index metadata edit form for this database
                            window.open("<?php 
                echo $url;
                ?>
",'_blank');
                        </script>
                        <?php 
            } else {
                $msg = "<div class=wrap><div id=errorMsg><span>Unable to write database identification record</span>" . "this database might be incorrectly set up<br />" . "Please contact <a href=mailto:info@HeuristNetwork.org>Heurist developers</a> for advice</div></div>";
                echo $msg;
                return;
            }
            // unable to write db identification record
        }
    }
    // successful new DB ID
}
Пример #4
0
/**
* request version on Heurist reference server and compare it with the local version
*
* @param mixed $version_in_session
*/
function checkVersionOnMainServer($version_in_session)
{
    $version_last_check = getLastCheckedVersion($version_in_session);
    //check data of last check and last warning email
    $fname = HEURIST_UPLOAD_ROOT . "lastAdviceSent.ini";
    if ($version_last_check == null && file_exists($fname)) {
        //version in session is outdated
        //last check and version
        $version_in_session = file_get_contents($fname);
        $version_last_check = getLastCheckedVersion($version_in_session);
        //get last version from file
    }
    if ($version_last_check) {
        //version is valid (not null)
        return $version_in_session;
    }
    //send request to main server at HEURIST_INDEX_BASE_URL
    // Heurist_Master_Index is the refernece standard for current database version
    // Maybe this should be changed to Heurist_Sandpit?. Note: sandpit no longer needed, or used, from late 2015
    $url = HEURIST_INDEX_BASE_URL . "admin/setup/dbproperties/getCurrentVersion.php?db=Heurist_Master_Index&check=1";
    $rawdata = loadRemoteURLContentSpecial($url);
    if ($rawdata) {
        //parse result
        if (checkVersionValid($rawdata)) {
            // $rawdata contains program version | database version
            $current_version = explode("|", $rawdata);
            // $curver is the current program version
            $curver = explode(".", $current_version[0]);
            if (count($curver) >= 2) {
                $major = intval($curver[0]);
                $subver = intval($curver[1]);
                //compare with local program version set in HEURIST_VERSION
                $locver = explode(".", HEURIST_VERSION);
                $major_local = intval($locver[0]);
                $subver_local = intval($locver[1]);
                // TODO: HEURIST_VERSION is not rendering the local version in the email below, yet HEURIST_SERVER_NAME works
                // and it seems to have set the $variables and to detect local version OK ???
                $email_title = null;
                if ($major_local < $major) {
                    $email_title = "Major new version of Heurist Vsn " . $current_version[0] . " available for " . HEURIST_SERVER_NAME . " (running Vsn " . HEURIST_VERSION . ")";
                } else {
                    if ($major_local == $major && $subver_local < $subver) {
                        $email_title = "Heurist update Vsn " . $current_version[0] . " available for " . HEURIST_SERVER_NAME . " (running Vsn " . HEURIST_VERSION . ")";
                    }
                }
                if ($email_title) {
                    //send email to administrator about new database registration
                    $email_text = "Your server is running Heurist version " . HEURIST_VERSION . " The current stable version of Heurist (version " . $current_version[0] . ") is available from <a href='https://code.google.com/p/heurist/'>Google Code</a> or " . "<a href='http://HeuristNetwork.org'>HeuristNetwork.org</a>. We recommend updating your copy of the software if the sub-version has changed " . "(or better still with any change of version).\n\n" . "Heurist is copyright (C) 20075 - 2014 The University of Sydney and available as Open Source software under the GNU-GPL licence. " . "Beta versions of the software with new features may also be available at the Google Code repository or linked from the HeuristNetwork home page.";
                    sendEmail(HEURIST_MAIL_TO_ADMIN, $email_title, $email_text, null);
                }
                //save current date of check
                $version_in_session = date("Y-m-d") . "|" . $current_version[0];
                if (!saveAsFile($version_in_session, $fname)) {
                }
                return $version_in_session;
            }
        }
    }
    //cannot access server or it returns invalid data - check next 24 hr
    $version_in_session = date("Y-m-d") . "|unknown";
    if (!saveAsFile($version_in_session, $fname)) {
    }
    return $version_in_session;
}
Пример #5
0
     $source_db_id = $_REQUEST["dbID"];
     $source_db_name = $_REQUEST["dbName"];
     $source_db_prefix = @$_REQUEST["dbPrefix"] && @$_REQUEST["dbPrefix"] != "" ? @$_REQUEST["dbPrefix"] : null;
     $regurl = $_REQUEST['dbURL'];
     // TODO: Remove this temporary fudge once Heurist_Master_Index updated to remove all references to H3
     if ($regurl == 'http://heurist.sydney.edu.au/h3/') {
         //change the registered url on our server to new one
         $regurl = 'http://heurist.sydney.edu.au/heurist/';
     }
     // This is the correct URL for vsn 3.1.8 and above, March 2014, with a hiccup in latter half of 2015
     // when H3 code moved to a /migrated subdirectory, corrected just before Chrristmas 2015
     $source_url = $regurl . "admin/describe/getDBStructureAsSQL.php?plain=1&db=" . $source_db_name . (@$source_db_prefix ? "&prefix=" . $source_db_prefix : "");
 }
 // http://heurist.sydney.edu.au/h4-ao/admin/describe/getDBStructureAsSQL.php?db=johns_Esparoutis_rentals
 //TODO: why is the second parameter 60? It's specified as bypasProxy = true
 $data = loadRemoteURLContentSpecial($source_url);
 // get the structure data
 //error_log('result '.$data);//substr($data, 0, 500));
 mysql_connection_insert($tempDBName);
 // Use temp database
 // TODO: is this check for the word 'unable' really a good check of failure???
 //       why are we not testing for success in the form of a recognisable signature?
 if (!$data || substr($data, 0, 6) == "unable") {
     // failed
     unlockDatabase();
     if (!$data) {
         $msg = "URL appears to be inaccessible (timeout); if the URL shown works in a web browser, your server may require a web proxy setting";
     } else {
         $msg = "Server appears to be returning incorrect data, first 25 characters: " . substr($data, 0, 25) . " ...";
     }
     die("<br>Source database <b> {$source_db_id} : {$source_db_prefix}{$source_db_name} </b>gave incorrect response<p>" . "URL to structure service, tried: " . "<br /><a href={$source_url} target=_blank>{$source_url}</a> <p>{$msg}");