예제 #1
0
파일: settings.php 프로젝트: Slini11/okapi
 /**
  * Initialize self::$SETTINGS.
  */
 private static function load_settings()
 {
     try {
         # This is an external code and it MAY generate E_NOTICEs.
         # We have to temporarilly disable our default error handler.
         OkapiErrorHandler::disable();
         require_once $GLOBALS['rootpath'] . "okapi_settings.php";
         $ref = get_okapi_settings();
         OkapiErrorHandler::reenable();
     } catch (Exception $e) {
         throw new Exception("Could not import <rootpath>/okapi_settings.php:\n" . $e->getMessage());
     }
     self::$SETTINGS = self::$DEFAULT_SETTINGS;
     foreach (self::$SETTINGS as $key => $_) {
         if (isset($ref[$key])) {
             self::$SETTINGS[$key] = $ref[$key];
         }
     }
     self::verify(self::$SETTINGS);
 }
예제 #2
0
 private function loadSearchData($searchData)
 {
     \okapi\OkapiErrorHandler::reenable();
     // We need to transform OC's "searchdata" into OKAPI's "search set".
     // First, we need to determine if we ALREADY did that.
     // Note, that this is not exactly thread-efficient. Multiple threads may
     // do this transformation in the same time. However, this is done only once
     // for each searchdata, so we will ignore it.
     $cache_key = "OC_searchdata_" . $searchData;
     $set_id = \okapi\Cache::get($cache_key);
     if ($set_id === null) {
         // Read the searchdata file into a temporary table.
         $filepath = \okapi\Settings::get('VAR_DIR') . "/searchdata/" . $searchData;
         \okapi\Db::execute("\n            create temporary table temp_" . $searchData . " (\n                cache_id integer primary key\n            ) engine=memory\n        ");
         if (file_exists($filepath)) {
             \okapi\Db::execute("\n                        load data local infile '{$filepath}'\n                        into table temp_" . $searchData . "\n                fields terminated by ' '\n                lines terminated by '\\n'\n                (cache_id)\n            ");
         }
         // Tell OKAPI to import the table into its own internal structures.
         // Cache it for two hours.
         $set_info = \okapi\Facade::import_search_set("temp_" . $searchData, 7200, 7200);
         $set_id = $set_info['set_id'];
         \okapi\Cache::set($cache_key, $set_id, 7200);
     }
     $this->search_params['set_and'] = $set_id;
     $this->search_params['status'] = "Available|Temporarily unavailable|Archived";
     \okapi\OkapiErrorHandler::disable();
     return true;
 }
예제 #3
0
파일: facade.php 프로젝트: 4Vs/oc-server3
 /**
  * If you disabled OKAPI's error handling with disable_error_handling,
  * you may reenable it with this method.
  */
 public static function reenable_error_handling()
 {
     OkapiErrorHandler::reenable();
 }
예제 #4
0
    if ($_GET['h_own'] == "true") {
        $params['exclude_my_own'] = "true";
    }
    # h_found, h_noattempt - convert to OKAPI's "found_status" parameter.
    $h_found = $_GET['h_found'] == "true";
    $h_noattempt = $_GET['h_noattempt'] == "true";
    if ($h_found && !$h_noattempt) {
        $params['found_status'] = "notfound_only";
    } elseif (!$h_found && $h_noattempt) {
        $params['found_status'] = "found_only";
    } elseif (!$h_found && !$h_noattempt) {
        $params['found_status'] = "either";
    } else {
        $force_result_empty = true;
    }
}
#
# We have all the parameters. Note, that some mapper-compatible parameter sets
# always render empty results. We will just exit, without producing any image
# whatsoever.
#
if ($force_result_empty) {
    die;
}
if (!$user_id) {
    die;
}
# End of "buggy" code. Re-enable OKAPI's error handler.
\okapi\OkapiErrorHandler::reenable();
# Get OKAPI's response and display it. Add proper Cache-Control headers.
\okapi\Facade::service_display('services/caches/map/tile', $user_id, $params);