Esempio n. 1
0
 function getReferenceTypes()
 {
     if (HeuristKMLParser::$_referenceTypes) {
         return array_keys($this->_referenceTypes);
     }
     mysql_connection_select(DATABASE);
     // saw TODO check that this is correct seems that it is trying order on non bib types.
     HeuristKMLParser::$_referenceTypes = mysql__select_assoc("defRecTypes ", "rty_Name", "rty_ID", "rty_ShowInLists = 1 order by rty_RecTypeGroupID = 2, rty_Name");
     return array_keys(HeuristKMLParser::$_referenceTypes);
 }
}
// end of error output
mysql_connection_insert(DATABASE);
$res = mysql_query('select snd_SimRecsList from recSimilarButNotDupes');
while ($row = mysql_fetch_assoc($res)) {
    array_push($dupeDifferences, $row['snd_SimRecsList']);
}
if ($_REQUEST['dupeDiffHash']) {
    foreach ($_REQUEST['dupeDiffHash'] as $diffHash) {
        if (!in_array($diffHash, $dupeDifferences)) {
            array_push($dupeDifferences, $diffHash);
            $res = mysql_query('insert into recSimilarButNotDupes values("' . $diffHash . '")');
        }
    }
}
mysql_connection_select(DATABASE);
//mysql_connection_select("`heuristdb-nyirti`");   //for debug
//FIXME  allow user to select a single record type
//$res = mysql_query('select rec_ID, rec_RecTypeID, rec_Title, dtl_Value from Records left join recDetails on dtl_RecID=rec_ID and dtl_DetailTypeID=160 where rec_RecTypeID != 52 and rec_RecTypeID != 55 and not rec_FlagTemporary order by rec_RecTypeID desc');
$crosstype = false;
$personMatch = false;
$relRT = defined('RT_RELATION') ? RT_RELATION : 0;
$perRT = defined('RT_PERSON') ? RT_PERSON : 0;
$surnameDT = defined('DT_GIVEN_NAMES') ? DT_GIVEN_NAMES : 0;
$titleDT = defined('DT_NAME') ? DT_NAME : 0;
if (@$_REQUEST['crosstype']) {
    $crosstype = true;
}
if (@$_REQUEST['personmatch']) {
    $personMatch = true;
    $res = mysql_query("select rec_ID, rec_RecTypeID, rec_Title, dtl_Value from Records left join recDetails on dtl_RecID=rec_ID and dtl_DetailTypeID={$surnameDT} where " . (strlen($recIDs) > 0 ? "rec_ID in ({$recIDs}) and " : "") . "rec_RecTypeID = {$perRT} and not rec_FlagTemporary order by rec_ID desc");
function get_location($key)
{
    mysql_connection_select("hapi");
    return mysql_fetch_assoc(mysql_query("select * from hapi_locations where hl_key='" . addslashes($key) . "'"));
}
* @author      Ian Johnson     <*****@*****.**>
* @license     http://www.gnu.org/licenses/gpl-3.0.txt GNU License 3.0
* @version     3.2
*/
/*
* Licensed under the GNU License, Version 3.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at http://www.gnu.org/licenses/gpl-3.0.txt
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
* See the License for the specific language governing permissions and limitations under the License.
*/
require_once dirname(__FILE__) . '/../../common/connect/applyCredentials.php';
if (isForAdminOnly("to get information on all databases on this server")) {
    return;
}
mysql_connection_select();
$dbs = mysql__getdatabases(true);
function mysql__select_val($query)
{
    $res = mysql_query($query);
    if (!$res) {
        return 0;
    }
    $row = mysql_fetch_array($res);
    if ($row) {
        return $row[0];
    } else {
        0;
    }
}
function dirsize($dir)
 /**
  * Connection to the database
  * @return void
  *
  */
 function _dbConnect()
 {
     mysql_connection_select(DATABASE);
 }
Esempio n. 6
0
function searchWoots($args)
{
    mysql_connection_select(DATABASE);
    $text_search = getTextSearch($args["q"]);
    if (!$text_search) {
        return array("success" => false, "errorType" => "invalid query");
    }
    $res = mysql_query("select distinct woot_ID, woot_Title, woot_Version\n\t\t\t\t\t\t  from " . WOOT_TABLE . "," . CHUNK_TABLE . "\n\t\t\t\t\t\t where woot_ID=chunk_WootID and chunk_IsLatest and !chunk_Deleted\n\t\t\t\t\t\t\t   and " . $text_search . "\n\t\t\t\t\t\t\t   and chunk_ID in (" . join(",", getReadableChunks(NULL, true)) . ")");
    $woots = array();
    while ($woot = mysql_fetch_assoc($res)) {
        array_push($woots, array("id" => $woot["woot_ID"], "version" => $woot["woot_Version"], "title" => $woot["woot_Title"]));
    }
    return array("success" => true, "woots" => $woots);
}
/**
	* Returns array of mapobjects
 	$mapobjects = array(
		"records"=>$geoRecords,
		"geoObjects"=>$geoObjects,
		"cntWithGeo"=>$cnt_geo,
		"cntWithTime"=>$cnt_time,
		"layers"=>$layers);
*/
function getMapObjects($request)
{
    $imagelayerRT = defined('RT_IMAGE_LAYER') ? RT_IMAGE_LAYER : 0;
    $KMLlayerRT = defined('RT_KML_LAYER') ? RT_KML_LAYER : 0;
    mysql_connection_select(DATABASE);
    if (array_key_exists('layers', $request)) {
        //special mode - load ALL image layers and kml records only - for general drop down list on map
        $request['ver'] = "1";
        $request['q'] = "type:" . $imagelayerRT . "," . $KMLlayerRT;
        $search_type = BOTH;
    } else {
        if (!@$request['q'] || @$request['ver'] && intval(@$request['ver']) < SEARCH_VERSION) {
            construct_legacy_search();
        }
        // migration path
        if (@$request['w'] && ($request['w'] == 'B' || $request['w'] == 'bookmark')) {
            $search_type = BOOKMARK;
        } else {
            $search_type = BOTH;
        }
        // all records
    }
    if (!array_key_exists("limit", $request)) {
        //not defined
        $limit = intval(@$_SESSION[HEURIST_SESSION_DB_PREFIX . 'heurist']["display-preferences"]['report-output-limit']);
        if (!$limit || $limit < 1) {
            $limit = 1000;
            //default limit in dispPreferences
        }
        $request["limit"] = $limit;
        //force limit
    }
    // find all matching records
    $cols = "rec_ID as bibID, rec_RecTypeID as rectype, rec_Title as title, rec_URL as URL";
    $query = REQUEST_to_query("select {$cols} ", $search_type);
    /*****DEBUG****/
    // error_log("query=".$query);
    /*****DEBUG****/
    //error_log(">>>>>>>>>>>>>>>>>>>>>>>".$search_type."<<<<<<".$query);
    $res = mysql_query($query);
    if (mysql_error()) {
        print mysql_error();
    }
    $records = array();
    $bibIDs = array();
    $imageLayers = array();
    // list of ids of map image layers
    $geoObjects = array();
    // coordinates
    $geoBibIDs = array();
    // list of id of records that have geo references
    while ($bib = mysql_fetch_assoc($res)) {
        $bibID = $bib["bibID"];
        if (!$bibID) {
            continue;
        }
        $records[$bibID] = $bib;
        array_push($bibIDs, $bibID);
        if ($bib["rectype"] == $imagelayerRT) {
            //map image layer
            array_push($imageLayers, $bibID);
            $geoBibIDs[$bibID] = $bibID;
        }
    }
    foreach ($bibIDs as $bibID) {
        //0 DT_SHORT_SUMMARY
        //1 DT_EXTENDED_DESCRIPTION
        //2 - record URL
        //3 DT_FILE_RESOURCE
        //REMOVED 4 DT_LOGO_IMAGE
        //REMOVED 5 DT_THUMBNAIL
        //REMOVED 6 DT_IMAGES
        //4 7 DT_MAP_IMAGE_LAYER_REFERENCE
        //5 8 DT_KML
        //6 9 DT_KML_FILE
        //7 10 record type
        //d.dtl_UploadedFileID,e.dtl_UploadedFileID,f.dtl_UploadedFileID,
        //					0				1			2			3				4 imagelayer 5 kmltext		6 kmlfile				7			8
        $squery = "select a.dtl_Value, b.dtl_Value, rec_URL, c.dtl_UploadedFileID, g.dtl_Value, h.dtl_Value, i.dtl_UploadedFileID, rec_RecTypeID, rec_Title, j.dtl_Value\n\t\tfrom Records\n\t\tleft join recDetails a on a.dtl_RecID=rec_ID and a.dtl_DetailTypeID=" . (defined('DT_SHORT_SUMMARY') ? DT_SHORT_SUMMARY : "0") . " left join recDetails b on b.dtl_RecID=rec_ID and b.dtl_DetailTypeID=" . (defined('DT_EXTENDED_DESCRIPTION') ? DT_EXTENDED_DESCRIPTION : "0") . " left join recDetails c on c.dtl_RecID=rec_ID and c.dtl_DetailTypeID=" . (defined('DT_FILE_RESOURCE') ? DT_FILE_RESOURCE : "0") . " left join recDetails g on g.dtl_RecID=rec_ID and g.dtl_DetailTypeID=" . (defined('DT_MAP_IMAGE_LAYER_REFERENCE') ? DT_MAP_IMAGE_LAYER_REFERENCE : "0") . " left join recDetails h on h.dtl_RecID=rec_ID and h.dtl_DetailTypeID=" . (defined('DT_KML') ? DT_KML : "0") . " left join recDetails i on i.dtl_RecID=rec_ID and i.dtl_DetailTypeID=" . (defined('DT_KML_FILE') ? DT_KML_FILE : "0") . " left join recDetails j on j.dtl_RecID=rec_ID and j.dtl_DetailTypeID=" . (defined('DT_SHOW_IN_MAP_BG_LIST') ? DT_SHOW_IN_MAP_BG_LIST : "0") . " where rec_ID={$bibID}";
        //*****DEBUG****//error_log(">>>>>>QUERY=".$squery);
        $res = mysql_query($squery);
        $row = mysql_fetch_row($res);
        if ($row) {
            $records[$bibID]["recID"] = $bibID;
            $records[$bibID]["rectype"] = $row[7];
            $records[$bibID]["description"] = $row[0] ? $row[0] : ($row[1] ? $row[1] : "");
            $records[$bibID]["url"] = $row[2];
            //($row[2] ? "'".$row[2]."' target='_blank'"  :"'javascript:void(0);'");
            //'javascript:{this.href="'+$row[2]+'"}' : 'javascript:{return false;}');//javascript:void(0)}');
            $records[$bibID]["icon_url"] = HEURIST_ICON_SITE_PATH . $row[7] . ".png";
            $thumb_url = getThumbnailURL($bibID);
            //function from uploadFile.php
            if ($thumb_url == "") {
                //if thumb not defined - use rectype default thumb
                $thumb_url = HEURIST_ICON_SITE_PATH . "thumb/th_" . $row[7] . ".png";
            }
            $records[$bibID]["thumb_url"] = $thumb_url;
            if ($row[4] && is_numeric($row[4]) && !in_array($row[4], $imageLayers)) {
                //DT_MAP_IMAGE_LAYER_REFERENCE
                array_push($imageLayers, $row[4]);
            }
            $kml_path = getKmlFilePath($row[3]);
            //DT_FILE_RESOURCE
            //*****DEBUG****//error_log(">>>>>>".$row[3]."=".$kml_path);
            // removed by SAW as DT_KML_FILE changed from a file base type to blocktext
            //		if($kml_path==null){
            //			$kml_path =  getKmlFilePath($row[6]); //DT_KML_FILE
            //			}
            if ($kml_path != null) {
                array_push($geoObjects, array("bibID" => $bibID, "type" => "kmlfile", "fileid" => $kml_path, "title" => $row[8], "isbackground" => $row[9]));
                $geoBibIDs[$bibID] = $bibID;
            } else {
                if ($row[5]) {
                    //DT_KML dtl_value contains KML		saw TODO: modify to check that text is valid KML.
                    array_push($geoObjects, array("bibID" => $bibID, "type" => "kml", "recid" => $bibID, "title" => $row[8]));
                    $geoBibIDs[$bibID] = $bibID;
                }
            }
        }
    }
    //for
    if ($bibIDs && count($bibIDs) > 0) {
        // Find the records that actually have any geographic data to plot
        $res = mysql_query("select dtl_RecID, dtl_Value, astext(dtl_Geo), astext(envelope(dtl_Geo)) from recDetails where dtl_Geo is not null and dtl_RecID in (" . join(",", $bibIDs) . ")");
        if (mysql_error()) {
            error_log("ERROR in ShowMap=" . mysql_error());
        }
        if ($res) {
            while ($val = mysql_fetch_row($res)) {
                // get the bounding box
                if (preg_match("/POLYGON\\(\\((\\S+)\\s+(\\S+),\\s*(\\S+)\\s+(\\S+),\\s*(\\S+)\\s+(\\S+),\\s*(\\S+)\\s+(\\S+),\\s*\\S+\\s+\\S+\\)\\)/i", $val[3], $matches)) {
                    $bbox = array("w" => floatval($matches[1]), "s" => floatval($matches[2]), "e" => floatval($matches[5]), "n" => floatval($matches[6]));
                } else {
                    $bbox = null;
                }
                $geoobj = parseValueFromDb($val[0], $val[1], $val[2], $bbox);
                if ($geoobj) {
                    array_push($geoObjects, $geoobj);
                    $geoBibIDs[$val[0]] = $val[0];
                }
                /*****DEBUG****/
                //error_log("ADDED1:".is_string($val[0])."    ".$geoBibIDs[$val[0]]);
                /*****DEBUG****/
                //error_log("1>>>>>>".$geoBibIDs[$val[0]]);
                /*****DEBUG****/
                //error_log("2>>>>>>".$geoBibIDs["97025"]);
                /*****DEBUG****/
                //error_log("3>>>>>>".$geoBibIDs[$bibID]);
            }
        }
    }
    //$bibIDs!=null
    // OLD WAY TO STORE GEO DATA - directly in dtl_value as dettypes: 210(long) and 211(lat)
    /* removed by SAW  as 211 is an old magic number not brought forward.
    	$res = mysql_query("select LAT.dtl_RecID, LNG.dtl_Value, LAT.dtl_Value from recDetails LAT, recDetails LNG where LAT.dtl_DetailTypeID=211 and LNG.dtl_DetailTypeID=210 and LAT.dtl_RecID=LNG.dtl_RecID and LNG.dtl_RecID in (" . join(",", $bibIDs) . ")");
    	if($res){
    		while ($val = mysql_fetch_row($res)) {
    			array_push($geoObjects, array("bibID" => $val[0], "type" => "point", "geo" => array("x" => floatval($val[1]), "y" => floatval($val[2]))));
    			$geoBibIDs[$val[0]] = $val[0];
    		}
    	}
    */
    // some records may contain reference to map image layer record (dettype 588),
    // but we may have such records in search result as well rectype=$imagelayerRT
    if ($bibIDs && count($bibIDs) > 0) {
        $squery = "select rec_ID  from Records\n\t\t\t\t\t\t\t where rec_ID in (" . join(",", $bibIDs) . ") and rec_RecTypeID={$imagelayerRT}";
        /*****DEBUG****/
        //error_log($squery);
        $res = mysql_query($squery);
        if ($res) {
            while ($val = mysql_fetch_row($res)) {
                array_push($imageLayers, $val[0]);
                $geoBibIDs[$val[0]] = $val[0];
            }
        }
    }
    $layers = array();
    //find image layers
    if (count($imageLayers) > 0) {
        $squery = "select rec_ID, a.dtl_Value as title," . " (select trm_Label from defTerms where trm_ID=b.dtl_Value) as type," . " c.dtl_Value as url," . " (select trm_Label from defTerms where trm_ID=d.dtl_Value) as mime_type," . " e.dtl_Value as min_zoom, f.dtl_Value as max_zoom, g.dtl_Value as copyright, j.dtl_Value as isbackground" . " from Records" . " left join recDetails a on a.dtl_RecID=rec_ID and a.dtl_DetailTypeID=" . (defined('DT_SHORT_NAME') ? DT_SHORT_NAME : "0") . " left join recDetails b on b.dtl_RecID=rec_ID and b.dtl_DetailTypeID=" . (defined('DT_MAP_IMAGE_LAYER_SCHEMA') ? DT_MAP_IMAGE_LAYER_SCHEMA : "0") . " left join recDetails c on c.dtl_RecID=rec_ID and c.dtl_DetailTypeID=" . (defined('DT_SERVICE_URL') ? DT_SERVICE_URL : "0") . " left join recDetails d on d.dtl_RecID=rec_ID and d.dtl_DetailTypeID=" . (defined('DT_MIME_TYPE') ? DT_MIME_TYPE : "0") . " left join recDetails e on e.dtl_RecID=rec_ID and e.dtl_DetailTypeID=" . (defined('DT_MINMUM_ZOOM_LEVEL') ? DT_MINMUM_ZOOM_LEVEL : "0") . " left join recDetails f on f.dtl_RecID=rec_ID and f.dtl_DetailTypeID=" . (defined('DT_MAXIMUM_ZOOM_LEVEL') ? DT_MAXIMUM_ZOOM_LEVEL : "0") . " left join recDetails g on g.dtl_RecID=rec_ID and g.dtl_DetailTypeID=" . (defined('DT_ALTERNATE_NAME') ? DT_ALTERNATE_NAME : "0") . " left join recDetails j on j.dtl_RecID=rec_ID and j.dtl_DetailTypeID=" . (defined('DT_SHOW_IN_MAP_BG_LIST') ? DT_SHOW_IN_MAP_BG_LIST : "0") . " where rec_ID in (" . join(",", $imageLayers) . ")";
        /*****DEBUG****/
        //error_log($squery);
        $res = mysql_query($squery);
        /*****DEBUG****/
        //error_log(mysql_error());
        while ($rec = mysql_fetch_assoc($res)) {
            //find the extent for image layer
            if ($rec['type'] == "maptiler") {
                $manifest_file = $rec['url'] . "tilemapresource.xml";
            } else {
                if ($rec['type'] == "virtual earth") {
                    $manifest_file = $rec['url'] . "MapCruncherMetadata.xml";
                } else {
                    $rec['error'] = "Wrong or non supported map type " . $rec['type'];
                }
            }
            if (!$rec['url']) {
                $rec['error'] = "URL is not defined for image layer";
            } else {
                if ($manifest_file) {
                    $manifest = simplexml_load_file($manifest_file);
                    if ($manifest == null || is_string($manifest)) {
                        //manifest not found
                        $rec['error'] = "Can not load manifest file image layer. " . $manifest_file;
                    } else {
                        if ($rec['type'] == "maptiler") {
                            foreach ($manifest->children() as $f_gen) {
                                if ($f_gen->getName() == "BoundingBox") {
                                    $arr = $f_gen->attributes();
                                    $rec['extent'] = $arr['miny'] . ',' . $arr['minx'] . ',' . $arr['maxy'] . ',' . $arr['maxx'];
                                    //warning!!! wrong labels in these manifests!!!!
                                    break;
                                }
                            }
                        } else {
                            $rect = findXMLelement($manifest, 0, array("LayerList", "Layer", "SourceMapRecordList", "SourceMapRecord", "MapRectangle"));
                            if ($rect) {
                                $rec['extent'] = "";
                                foreach ($rect->children() as $pnt) {
                                    $arr = $pnt->attributes();
                                    $lon = $arr['lon'];
                                    $lat = $arr['lat'];
                                    $rec['extent'] = $rec['extent'] . $lon . "," . $lat . ",";
                                }
                                //$rec['extent'] = $sw['lon'].','.$sw['lat'].','.$ne['lon'].','.$ne['lat'];
                            }
                        }
                        if (!array_key_exists('extent', $rec)) {
                            $rec['error'] = "Can not find bounds parameters in manifest file";
                        }
                    }
                }
            }
            if (!$rec['max_zoom']) {
                $rec['max_zoom'] = 19;
            }
            array_push($layers, $rec);
        }
    }
    //count($imageLayers)>0
    // Find time extents -- must have at least a start time (end time is optional)
    // check for specific details first
    //saw TODO; modify this for handle durations with a start or end date
    $timeObjects = array();
    if (defined('DT_START_DATE') && defined('DT_END_DATE') && $bibIDs && count($bibIDs) > 0) {
        $squery = "select START.dtl_RecID, START.dtl_Value, END.dtl_Value " . "from recDetails START left join recDetails END on START.dtl_RecID=END.dtl_RecID " . "and END.dtl_DetailTypeID=" . DT_END_DATE . " where START.dtl_DetailTypeID=" . DT_START_DATE . " and (START.dtl_Value || END.dtl_Value) " . "and START.dtl_RecID in (" . join(",", $bibIDs) . ")";
        $res = mysql_query($squery);
        while ($val = mysql_fetch_row($res)) {
            if ($val[1] || $val[2]) {
                $timeObjects[$val[0]] = array($val[1], $val[2]);
                /*****DEBUG****/
                //error_log("XXXX>>>>>> ". $val[0]."  ".$val[1]."  ".$val[2] );
            }
        }
    }
    //	$timeObjects = array();
    //"
    //select d.dtl_RecID, min(d.dtl_Value), max(d.dtl_Value), min(y.dtl_Value), max(y.dtl_Value)
    //from recDetails b, recDetails y
    //"
    $anyDateBibIDs = array();
    //no date enabled
    foreach ($bibIDs as $bibID) {
        if (!array_key_exists($bibID, $timeObjects)) {
            array_push($anyDateBibIDs, $bibID);
        }
    }
    // now process those records that don't have specific start and end dates -
    // try to extract date from details
    if (count($anyDateBibIDs) > 0) {
        $dates = array();
        $years = array();
        $res = mysql_query("select rec_ID, min(d.dtl_Value), max(d.dtl_Value)\n\t\t\t\t\t\t\tfrom Records\n\t\t\t\t\t\t\tcross join defDetailTypes dt\n\t\t\t\t\t\t\tleft join recDetails d on d.dtl_RecID = rec_ID and d.dtl_DetailTypeID = dt.dty_ID\n\t\t\t\t\t\t\twhere rec_ID in (" . join(",", $anyDateBibIDs) . ")\n\t\t\t\t\t\t\tand dt.dty_Type = 'date'\n\t\t\t\t\t\t\tgroup by rec_ID");
        if ($res) {
            while ($val = mysql_fetch_row($res)) {
                if ($val[1] && preg_match("/^\\d+\\s*bc/i", $val[1])) {
                    // convert BC to a - sign
                    $val[1] = -preg_replace("/\\s*bc/i", "", $val[1]) + 1;
                }
                if ($val[2] && preg_match("/^\\d+\\s*bc/i", $val[2])) {
                    // convert BC to a - sign
                    $val[2] = -preg_replace("/\\s*bc/i", "", $val[2]) + 1;
                }
                $dates[$val[0]] = array($val[1], $val[1] !== $val[2] ? $val[2] : null);
            }
        }
        $res = mysql_query("select rec_ID, min(d.dtl_Value), max(d.dtl_Value)\n\t\tfrom Records\n\t\tcross join defDetailTypes yt\n\t\tleft join recDetails y on y.dtl_RecID = rec_ID and y.dtl_DetailTypeID = yt.dty_ID\n\t\twhere rec_ID in (" . join(",", $anyDateBibIDs) . ")\n\t\tand yt.dty_Type = 'year'\n\t\tgroup by rec_ID");
        if ($res) {
            while ($val = mysql_fetch_row($res)) {
                if ($val[1] && preg_match("/^\\d+\\s*bc/i", $val[1])) {
                    // convert BC to a - sign
                    $val[1] = -preg_replace("/\\s*bc/i", "", $val[1]) + 1;
                }
                if ($val[2] && preg_match("/^\\d+\\s*bc/i", $val[2])) {
                    // convert BC to a - sign
                    $val[2] = -preg_replace("/\\s*bc/i", "", $val[2]) + 1;
                }
                $years[$val[0]] = array($val[1], $val[1] !== $val[2] ? $val[2] : null);
            }
        }
        foreach ($anyDateBibIDs as $bibID) {
            $sd = @$dates[$bibID][0] ? $dates[$bibID][0] : null;
            $ed = @$dates[$bibID][1] ? $dates[$bibID][1] : null;
            $sy = @$years[$bibID][0] ? $years[$bibID][0] : null;
            $ey = @$years[$bibID][1] ? $years[$bibID][1] : null;
            if (!$sd && !$ed && $sy && $sy == $ey) {
                $ey = $sy + 1;
            }
            $s = $sd ? $sd : $sy;
            $e = $ed ? $ed : $ey;
            if ($s >= $e) {
                $e = null;
            }
            $timeObjects[$bibID] = array($s, $e);
        }
    }
    //if
    //sort($geoBibIDs);
    $geoRecords = array();
    $cnt_geo = 0;
    $cnt_time = 0;
    //foreach ($geoBibIDs as $bibID) {
    foreach ($bibIDs as $bibID) {
        //loop for all records
        //	$bibID = ""+$bibID;
        /*****DEBUG****/
        //error_log("2>>>>>>".$geoBibIDs["97025"]);
        /*****DEBUG****/
        //error_log("3>>>>>>".$bibID."    ".$geoBibIDs[$bibID]."   time=".array_key_exists($bibID, $timeObjects) );
        $isNotGeoLoc = !@$geoBibIDs[$bibID];
        if (!$isNotGeoLoc || array_key_exists($bibID, $timeObjects)) {
            /*****DEBUG****/
            //error_log(">>>>>".$bibID."=".$geoBibIDs[$bibID]."<<<<<<".(!@$geoBibIDs[$bibID])."<<<<<<");
            $geoRecords[$bibID] = $records[$bibID];
            if ($isNotGeoLoc) {
                /*****DEBUG****/
                //error_log(">>>>>PUSH EMPTY");
                //no geo data - only timedata
                array_push($geoObjects, array("bibID" => $bibID, "type" => "none"));
                //empty georeference
                $geoBibIDs[$bibID] = $bibID;
            } else {
                $cnt_geo++;
            }
            if (array_key_exists($bibID, $timeObjects)) {
                list($start, $end) = $timeObjects[$bibID];
                $geoRecords[$bibID]["start"] = $start;
                if ($end) {
                    $geoRecords[$bibID]["end"] = $end;
                }
                $cnt_time++;
            }
        }
    }
    //count($geoRecords)
    $mapobjects = array("records" => $geoRecords, "geoObjects" => $geoObjects, "cntWithGeo" => $cnt_geo, "cntWithTime" => $cnt_time, "layers" => $layers);
    return $mapobjects;
}
Esempio n. 8
0
    $DTN[$row['dty_ID']] = $row['dty_Name'];
    $DTT[$row['dty_ID']] = $row['dty_Type'];
}
$INV = mysql__select_assoc('defTerms', 'trm_ID', 'trm_InverseTermID', '1');
// lookup detail type enum values
$query = 'SELECT trm_ID, trm_Label, trm_ParentTermID, trm_OntID FROM defTerms';
$res = mysql_query($query);
while ($row = mysql_fetch_assoc($res)) {
    $TL[$row['trm_ID']] = $row;
    $TLV[$row['trm_Label']] = $row;
}
/// group names
mysql_connection_select(USERS_DATABASE) or die(mysql_error());
$WGN = mysql__select_assoc('sysUGrps grp', 'grp.ugr_ID', 'grp.ugr_Name', "ugr_Type ='workgroup'");
$UGN = mysql__select_assoc('sysUGrps grp', 'grp.ugr_ID', 'grp.ugr_Name', "ugr_Type ='user'");
mysql_connection_select(DATABASE) or die(mysql_error());
$GEO_TYPES = array('r' => 'bounds', 'c' => 'circle', 'pl' => 'polygon', 'l' => 'path', 'p' => 'point');
// set parameter defaults
$MAX_DEPTH = @$_REQUEST['depth'] ? intval($_REQUEST['depth']) : 0;
// default to only one level
$REVERSE = @$_REQUEST['rev'] === 'no' ? false : true;
//default to including reverse pointers
$WOOT = @$_REQUEST['woot'] ? intval($_REQUEST['woot']) : 0;
//default to not output text content
$OUTPUT_STUBS = @$_REQUEST['stub'] === '1' ? true : false;
//default to not output stubs
$INCLUDE_FILE_CONTENT = @$_REQUEST['fc'] && $_REQUEST['fc'] == 0 ? false : true;
// default to expand xml file content
$SUPRESS_LOOPBACKS = @$_REQUEST['slb'] && $_REQUEST['slb'] == 0 ? false : true;
// default to supress loopbacks
// check filter string has restricted characters only
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <link rel="stylesheet" type="text/css" href="../../common/css/global.css">
        <link rel="stylesheet" type="text/css" href="../../common/css/edit.css">
        <link rel="stylesheet" type="text/css" href="../../common/css/admin.css">
    </head>

    <body class="popup">
        <div class="banner"><h2>Modify group / admin status for session</h2></div>
        <div id="page-inner">
            <p>This page is designed for testing purposes. It allows you to exit a group, or relinquish administrator status for a group,
                for the rest of your session, in order to test the behaviour of a database as viewed by another class of user.
                Changes will not be saved to the database. Log out and log back in to restore your normal permissions.</p>

            <table>
            <?php 
mysql_connection_select(USERS_DATABASE);
$grp_ids = array_keys($_SESSION[HEURIST_SESSION_DB_PREFIX . 'heurist']["user_access"]);
$grp_names = mysql__select_assoc(GROUPS_TABLE, GROUPS_ID_FIELD, GROUPS_NAME_FIELD, GROUPS_ID_FIELD . " in (" . join(",", $grp_ids) . ")");
foreach ($grp_ids as $grp_id) {
    print "<tr><td>" . $grp_names[$grp_id] . "</td><td>";
    if ($_SESSION[HEURIST_SESSION_DB_PREFIX . 'heurist']["user_access"][$grp_id] == "admin") {
        print "<a href=?a={$grp_id}>-admin</a>";
    }
    print "</td><td><a href=?g={$grp_id}>exit</td></tr>";
}
?>
        </div>
    </body>
</html>

function getInvalidFieldTypes($rectype_id)
{
    global $TL, $RTN;
    mysql_connection_select(DATABASE);
    // lookup detail type enum values
    $query = 'SELECT trm_ID, trm_Label, trm_ParentTermID, trm_OntID, trm_Code FROM defTerms';
    $res = mysql_query($query);
    while ($row = mysql_fetch_assoc($res)) {
        $TL[$row['trm_ID']] = $row;
    }
    //record type name
    $query = 'SELECT rty_ID, rty_Name FROM defRecTypes';
    $res = mysql_query($query);
    while ($row = mysql_fetch_assoc($res)) {
        $RTN[$row['rty_ID']] = $row['rty_Name'];
    }
    //list of detail types to validate
    $DTT = array();
    $query = "SELECT dty_ID," . "dty_Name," . "dty_Type," . "dty_JsonTermIDTree," . "dty_TermIDTreeNonSelectableIDs," . "dty_PtrTargetRectypeIDs" . " FROM defDetailTypes";
    if (null != $rectype_id) {
        //detail types for given recordtype
        $query = $query . ", defRecStructure WHERE rst_RecTypeID=" . $rectype_id . " and rst_DetailTypeID=dty_ID and ";
    } else {
        $query = $query . " WHERE ";
    }
    $query = $query . "(dty_Type in ('enum','relationtype','relmarker','resource')" . " and (dty_JsonTermIDTree is not null or dty_TermIDTreeNonSelectableIDs is not null)) " . "or (dty_Type in ('relmarker','resource') and dty_PtrTargetRectypeIDs is not null)";
    $res = mysql_query($query);
    if ($res) {
        while ($row = mysql_fetch_assoc($res)) {
            $DTT[$row['dty_ID']] = $row;
        }
    }
    $dtysWithInvalidTerms = array();
    $dtysWithInvalidNonSelectableTerms = array();
    $dtysWithInvalidRectypeConstraint = array();
    foreach ($DTT as $dtyID => $dty) {
        if ($dty['dty_JsonTermIDTree']) {
            $res = getInvalidTerms($dty['dty_JsonTermIDTree'], true);
            $invalidTerms = $res[0];
            $validTermsString = $res[1];
            if (count($invalidTerms)) {
                $dtysWithInvalidTerms[$dtyID] = $dty;
                $dtysWithInvalidTerms[$dtyID]['invalidTermIDs'] = $invalidTerms;
                $dtysWithInvalidTerms[$dtyID]['validTermsString'] = $validTermsString;
            }
        }
        if ($dty['dty_TermIDTreeNonSelectableIDs']) {
            $res = getInvalidTerms($dty['dty_TermIDTreeNonSelectableIDs'], false);
            $invalidNonSelectableTerms = $res[0];
            $validNonSelTermsString = $res[1];
            if (count($invalidNonSelectableTerms)) {
                $dtysWithInvalidNonSelectableTerms[$dtyID] = $dty;
                $dtysWithInvalidNonSelectableTerms[$dtyID]['invalidNonSelectableTermIDs'] = $invalidNonSelectableTerms;
                $dtysWithInvalidNonSelectableTerms[$dtyID]['validNonSelTermsString'] = $validNonSelTermsString;
            }
        }
        if ($dty['dty_PtrTargetRectypeIDs']) {
            $res = getInvalidRectypes($dty['dty_PtrTargetRectypeIDs']);
            $invalidRectypes = $res[0];
            $validRectypes = $res[1];
            if (count($invalidRectypes)) {
                $dtysWithInvalidRectypeConstraint[$dtyID] = $dty;
                $dtysWithInvalidRectypeConstraint[$dtyID]['invalidRectypeConstraint'] = $invalidRectypes;
                $dtysWithInvalidRectypeConstraint[$dtyID]['validRectypeConstraint'] = $validRectypes;
            }
        }
    }
    //for
    return array("terms" => $dtysWithInvalidTerms, "terms_nonselectable" => $dtysWithInvalidNonSelectableTerms, "rt_contraints" => $dtysWithInvalidRectypeConstraint);
}
Esempio n. 11
0
        if (!is_array($registeredDBs)) {
            if (defined("HEURIST_HTTP_PROXY")) {
                $data = loadRemoteURLContent($reg_url, false);
                //false = USE PROXY
                if ($data) {
                    $registeredDBs = json_decode($data);
                    if (!is_array($data)) {
                        $registeredDBs = array();
                    }
                }
            }
        }
    }
} else {
    // this is a connection on the same server as the master index
    mysql_connection_select("hdb_Heurist_Master_Index");
    //except specified databases
    if (@$_REQUEST['exclude']) {
        $exclude = explode(",", $_REQUEST['exclude']);
    } else {
        $exclude = array();
    }
    // Return all registered databases as a json string
    $query = 'select rec_ID, rec_URL, rec_Title, rec_Popularity, dtl_value as version ' . ' from Records left join recDetails on rec_ID=dtl_RecID and dtl_DetailTypeID=335 where `rec_RecTypeID`=22';
    if ($is_curated) {
        $query = $query . ' and rec_ID<1000';
    }
    $res = mysql_query($query);
    while ($registeredDB = mysql_fetch_array($res, MYSQL_ASSOC)) {
        if (!array_search($registeredDB['rec_ID'], $exclude)) {
            if ($is_named) {
* @version     3.1.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
*/
/**
 * filename, brief description, date of creation, by whom
 * @copyright (C) 2005-2010 University of Sydney Digital Innovation Unit.
 * @link: http://HeuristScholar.org
 * @license http://www.gnu.org/licenses/gpl-3.0.txt
 * @package Heurist academic knowledge management system
 * @todo
 **/
require_once dirname(__FILE__) . "/../../common/connect/applyCredentials.php";
require_once dirname(__FILE__) . "/../../common/php/dbMySqlWrappers.php";
mysql_connection_select("hapi");
if (!is_logged_in()) {
    /*
    	jsonError("no logged-in user");
    */
    $_REQUEST["crossSession"] = false;
}
$_REQUEST = json_decode(@$_POST["data"] ? $_POST["data"] : base64_decode(@$_GET["data"]), true);
$location = @$_REQUEST["crossDomain"] ? "*" : ($baseURL ? $baseURL : HEURIST_SERVER_NAME);
// TESTTHIS:  repalced heuristscholar.org with host name
$varName = $_REQUEST["name"];
if (preg_match("/^([a-zA-Z0-9_]+)((?:[.][a-zA-Z0-9_]+)+)\$/", $varName, $matches)) {
    $topLevelVarName = $matches[1];
    $innerVarPath = $matches[2];
    if (@$_REQUEST["crossSession"]) {
        // cross-session values are stored in the database
* @link        http://Sydney.edu.au/Heurist
* @version     3.1.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
*/
/**
 * getRegisteredDBs.php - Returns all databases and their URLs that are registered in the master Heurist index server,
 * Juan Adriaanse 27 May 2011. SERVER SIDE ONLY. ONLY ALLOW IN HEURISTSCHOLAR.ORG index database
 * @copyright (C) 2005-2010 University of Sydney Digital Innovation Unit.
 * @link: http://HeuristScholar.org
 * @license http://www.gnu.org/licenses/gpl-3.0.txt
 * @package Heurist academic knowledge management system
 * @todo
 **/
if (!@$_REQUEST['db']) {
    // be sure to override default this should only be called on the Master Index server so point db master index dbname
    $_REQUEST['db'] = "H3MasterIndex";
}
require_once dirname(__FILE__) . "/../../common/config/initialise.php";
require_once dirname(__FILE__) . '/../../common/php/dbMySqlWrappers.php';
mysql_connection_select("hdb_H3MasterIndex");
// Return all registered databases as a json string
$res = mysql_query("select rec_ID, rec_URL, rec_Title, rec_Popularity, dtl_value as version from Records left join recDetails on rec_ID=dtl_RecID and dtl_DetailTypeID=335 where `rec_RecTypeID`=22");
$registeredDBs = array();
while ($registeredDB = mysql_fetch_array($res, MYSQL_ASSOC)) {
    array_push($registeredDBs, $registeredDB);
}
$jsonRegisteredDBs = json_encode($registeredDBs);
echo $jsonRegisteredDBs;
//BEWARE: If there si some sort of error, nothjign gets returned and this should be trapped at ht otehr end (selectDBForImport.php)
        //take from database
        $res = mysql_query('select * from ' . USERS_TABLE . ' where ' . USERS_USERNAME_FIELD . ' = "' . addslashes($username) . '"');
        $user = mysql_fetch_assoc($res);
        if ($user) {
            $password = $user[USERS_PASSWORD_FIELD];
        } else {
            $password = "";
        }
        $needcrypt = false;
    } else {
        $username = $_REQUEST['username'];
        $password = $_REQUEST['password'];
        $needcrypt = true;
        //(array_key_exists('mode', $_REQUEST) && $_REQUEST['mode']=='2');
    }
    mysql_connection_select($db_prefix . $sourcedbname);
    $res = mysql_query('select * from ' . USERS_TABLE . ' where ' . USERS_USERNAME_FIELD . ' = "' . addslashes($username) . '"');
    $user = mysql_fetch_assoc($res);
    if ($user && $user[USERS_ACTIVE_FIELD] == 'y' && ($needcrypt && crypt($password, $user[USERS_PASSWORD_FIELD]) == $user[USERS_PASSWORD_FIELD] || !$needcrypt && $password == $user[USERS_PASSWORD_FIELD])) {
        $user_id_insource = $user[USERS_ID_FIELD];
        $user_workgroups = mysql__select_array('sysUsrGrpLinks left join sysUGrps grp on grp.ugr_ID=ugl_GroupID', 'ugl_GroupID', 'ugl_UserID=' . $user_id_insource . ' and grp.ugr_Type != "User" order by ugl_GroupID');
    } else {
        header('Location: ' . HEURIST_BASE_URL . 'import/direct/getRecordsFromDB.php?loginerror=1&db=' . HEURIST_DBNAME);
        exit;
    }
    mysql_connection_overwrite(DATABASE);
}
if (@$_REQUEST['mode'] == '2') {
    createMappingForm(null);
} else {
    // ---- visit #3 - SAVE SETTINGS -----------------------------------------------------------------
function get_location($key)
{
    mysql_connection_select("hapi");
    return mysql_fetch_assoc(mysql_query("select * from hapi_locations where hl_key='" . mysql_real_escape_string($key) . "'"));
}