本文整理汇总了PHP中okapi\Db类的典型用法代码示例。如果您正苦于以下问题:PHP Db类的具体用法?PHP Db怎么用?PHP Db使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Db类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: call
public static function call()
{
$langpref = isset($_GET['langpref']) ? $_GET['langpref'] : Settings::get('SITELANG');
$langprefs = explode("|", $langpref);
# Determine which user is logged in to OC.
require_once $GLOBALS['rootpath'] . "okapi/lib/oc_session.php";
$OC_user_id = OCSession::get_user_id();
if ($OC_user_id == null) {
$after_login = "okapi/apps/" . ($langpref != Settings::get('SITELANG') ? "?langpref=" . $langpref : "");
$login_url = Settings::get('SITE_URL') . "login.php?target=" . urlencode($after_login);
return new OkapiRedirectResponse($login_url);
}
# Get the list of authorized apps.
$rs = Db::query("\n select c.`key`, c.name, c.url\n from\n okapi_consumers c,\n okapi_authorizations a\n where\n a.user_id = '" . mysql_real_escape_string($OC_user_id) . "'\n and c.`key` = a.consumer_key\n order by c.name\n ");
$vars = array();
$vars['okapi_base_url'] = Settings::get('SITE_URL') . "okapi/";
$vars['site_url'] = Settings::get('SITE_URL');
$vars['site_name'] = Okapi::get_normalized_site_name();
$vars['site_logo'] = Settings::get('SITE_LOGO');
$vars['apps'] = array();
while ($row = mysql_fetch_assoc($rs)) {
$vars['apps'][] = $row;
}
mysql_free_result($rs);
$response = new OkapiHttpResponse();
$response->content_type = "text/html; charset=utf-8";
ob_start();
Okapi::gettext_domain_init($langprefs);
include 'index.tpl.php';
$response->body = ob_get_clean();
Okapi::gettext_domain_restore();
return $response;
}
示例2: call
public static function call(OkapiRequest $request)
{
# User is already verified (via OAuth), but we need to verify the
# cache code (check if it exists). We will simply call a geocache method
# on it - this will also throw a proper exception if it doesn't exist.
$cache_code = $request->get_parameter('cache_code');
if ($cache_code == null) {
throw new ParamMissing('cache_code');
}
$geocache = OkapiServiceRunner::call('services/caches/geocache', new OkapiInternalRequest($request->consumer, $request->token, array('cache_code' => $cache_code, 'fields' => 'internal_id')));
# watched
if ($tmp = $request->get_parameter('watched')) {
if (!in_array($tmp, array('true', 'false', 'unchanged'))) {
throw new InvalidParam('watched', $tmp);
}
if ($tmp == 'true') {
Db::execute("\n insert ignore into cache_watches (cache_id, user_id)\n values (\n '" . Db::escape_string($geocache['internal_id']) . "',\n '" . Db::escape_string($request->token->user_id) . "'\n );\n ");
} elseif ($tmp == 'false') {
Db::execute("\n delete from cache_watches\n where\n cache_id = '" . Db::escape_string($geocache['internal_id']) . "'\n and user_id = '" . Db::escape_string($request->token->user_id) . "';\n ");
}
}
# ignored
if ($tmp = $request->get_parameter('ignored')) {
if (!in_array($tmp, array('true', 'false', 'unchanged'))) {
throw new InvalidParam('ignored', $tmp);
}
if ($tmp == 'true') {
Db::execute("\n insert ignore into cache_ignore (cache_id, user_id)\n values (\n '" . Db::escape_string($geocache['internal_id']) . "',\n '" . Db::escape_string($request->token->user_id) . "'\n );\n ");
} elseif ($tmp == 'false') {
Db::execute("\n delete from cache_ignore\n where\n cache_id = '" . Db::escape_string($geocache['internal_id']) . "'\n and user_id = '" . Db::escape_string($request->token->user_id) . "'\n ");
}
}
$result = array('success' => true);
return Okapi::formatted_response($request, $result);
}
示例3: call
static function call(OkapiRequest $request)
{
require_once 'log_images_common.inc.php';
list($image_uuid, $log_internal_id) = LogImagesCommon::validate_image_uuid($request);
$image_uuid_escaped = Db::escape_string($image_uuid);
Db::execute('start transaction');
$image_row = Db::select_row("\n select id, node, url, local\n from pictures\n where uuid = '" . $image_uuid_escaped . "'\n ");
Db::execute("\n delete from pictures where uuid = '" . $image_uuid_escaped . "'\n ");
# Remember that OCPL picture sequence numbers are always 1, and
# OCDE sequence numbers may have gaps. So we do not need to adjust
# any numbers after deleting from table 'pictures'.
if (Settings::get('OC_BRANCH') == 'oc.de') {
# OCDE does all the housekeeping by triggers
} else {
Db::execute("\n INSERT INTO removed_objects (\n localID, uuid, type, removed_date, node\n )\n VALUES (\n " . $image_row['id'] . "\n '" . $image_uuid_escaped . "',\n 6,\n NOW(),\n " . $image_row['node'] . "\n )\n ");
# This will also update cache_logs.okapi_syncbase, so that replication
# can output the updated log entry with one image less. For OCDE
# that's done by DB trigges.
Db::execute("\n update cache_logs\n set\n picturescount = greatest(0, picturescount - 1),\n last_modified = NOW()\n where id = '" . Db::escape_string($log_internal_id) . "'\n ");
}
Db::execute('commit');
if ($image_row['local']) {
$filename = basename($image_row['url']);
unlink(Settings::get('IMAGES_DIR') . '/' . $filename);
}
$result = array('success' => true);
return Okapi::formatted_response($request, $result);
}
示例4: call
public static function call(OkapiRequest $request)
{
$cache_code = $request->get_parameter('cache_code');
if (!$cache_code) {
throw new ParamMissing('cache_code');
}
if (strpos($cache_code, "|") !== false) {
throw new InvalidParam('cache_code');
}
$langpref = $request->get_parameter('langpref');
if (!$langpref) {
$langpref = "en";
}
$langpref .= "|" . Settings::get('SITELANG');
$fields = $request->get_parameter('fields');
if (!$fields) {
$fields = "code|name|location|type|status";
}
$log_fields = $request->get_parameter('log_fields');
if (!$log_fields) {
$log_fields = "uuid|date|user|type|comment";
}
$lpc = $request->get_parameter('lpc');
if (!$lpc) {
$lpc = 10;
}
$attribution_append = $request->get_parameter('attribution_append');
if (!$attribution_append) {
$attribution_append = 'full';
}
$params = array('cache_codes' => $cache_code, 'langpref' => $langpref, 'fields' => $fields, 'attribution_append' => $attribution_append, 'lpc' => $lpc, 'log_fields' => $log_fields);
$my_location = $request->get_parameter('my_location');
if ($my_location) {
$params['my_location'] = $my_location;
}
$user_uuid = $request->get_parameter('user_uuid');
if ($user_uuid) {
$params['user_uuid'] = $user_uuid;
}
# There's no need to validate the fields/lpc parameters as the 'geocaches'
# method does this (it will raise a proper exception on invalid values).
$results = OkapiServiceRunner::call('services/caches/geocaches', new OkapiInternalRequest($request->consumer, $request->token, $params));
$result = $results[$cache_code];
if ($result === null) {
# Two errors messages (for OCDE). Makeshift solution for issue #350.
$exists = Db::select_value("\n select 1\n from caches\n where wp_oc='" . Db::escape_string($cache_code) . "'\n ");
if ($exists) {
throw new InvalidParam('cache_code', "This cache is not accessible via OKAPI.");
} else {
throw new InvalidParam('cache_code', "This cache does not exist.");
}
}
return Okapi::formatted_response($request, $result);
}
示例5: call
public static function call(OkapiRequest $request)
{
$cachekey = "apisrv/stats";
$result = Cache::get($cachekey);
if (!$result) {
$result = array('cache_count' => 0 + Db::select_value("\n select count(*) from caches where status in (1,2,3)\n "), 'user_count' => 0 + Db::select_value("\n select count(*) from (\n select distinct user_id\n from cache_logs\n where\n type in (1,2,7)\n and " . (Settings::get('OC_BRANCH') == 'oc.pl' ? "deleted = 0" : "true") . "\n UNION DISTINCT\n select distinct user_id\n from caches\n ) as t;\n "), 'apps_count' => 0 + Db::select_value("select count(*) from okapi_consumers;"), 'apps_active' => 0 + Db::select_value("\n select count(distinct s.consumer_key)\n from\n okapi_stats_hourly s,\n okapi_consumers c\n where\n s.consumer_key = c.`key`\n and s.period_start > date_add(now(), interval -30 day)\n "));
Cache::set($cachekey, $result, 86400);
# cache it for one day
}
return Okapi::formatted_response($request, $result);
}
示例6: call
public static function call()
{
if (!isset($_GET['id'])) {
throw new ParamMissing("id");
}
$tmp = Db::select_value("\n select data\n from okapi_clog\n where id='" . Db::escape_string($_GET['id']) . "'\n ");
$data = unserialize(gzinflate($tmp));
$response = new OkapiHttpResponse();
$response->content_type = "application/json; charset=utf-8";
$response->body = json_encode($data);
return $response;
}
示例7: call
public static function call()
{
# By default, this view is turned off in the urls.php file.
# This view is for debugging TileMap performace only!
set_time_limit(0);
header("Content-Type: text/plain; charset=utf-8");
$user_id = $_GET['u'];
self::out("Yo. I'm {$user_id}.\n\n");
while (true) {
srand(floor(time() / 10));
$mode2 = rand(0, 9) <= 7;
if ($mode2) {
$row = Db::select_row("\n select z, x, y\n from okapi_tile_status\n where status = 2 and z < 20\n order by rand()\n limit 1;\n ");
$z = $row['z'] + 1;
$x = $row['x'] << 1;
$y = $row['y'] << 1;
$x += rand(0, 1);
$y += rand(0, 1);
} else {
$z = rand(5, 21);
$x = rand(0, (1 << $z) - 1);
$y = rand(0, (1 << $z) - 1);
}
$tiles = array();
for ($xx = $x; $xx < $x + 4; $xx++) {
for ($yy = $y; $yy < $y + 4; $yy++) {
$tiles[] = array($xx, $yy);
}
}
srand();
shuffle($tiles);
foreach ($tiles as $tile) {
list($x, $y) = $tile;
self::out("Loading " . str_pad("({$z}, {$x}, {$y})... ", 30));
$time_started = microtime(true);
try {
$response = OkapiServiceRunner::call('services/caches/map/tile', new OkapiInternalRequest(new OkapiInternalConsumer(), new OkapiInternalAccessToken($user_id), array('z' => "{$z}", 'x' => "{$x}", 'y' => "{$y}")));
$runtime = microtime(true) - $time_started;
$ds = floor($runtime * 100);
self::out(str_repeat("#", $ds) . " ");
$b = floor(strlen($response->get_body()) / 256);
self::out(str_repeat("@", $b) . "\n");
} catch (Exception $e) {
self::out("\n\n" . OkapiExceptionHandler::get_exception_info($e));
die;
}
}
}
}
示例8: call
public static function call(OkapiRequest $request)
{
$cache_code = $request->get_parameter('cache_code');
if (!$cache_code) {
throw new ParamMissing('cache_code');
}
$fields = $request->get_parameter('fields');
if (!$fields) {
$fields = "uuid|date|user|type|comment";
}
$offset = $request->get_parameter('offset');
if (!$offset) {
$offset = "0";
}
if ((int) $offset != $offset || (int) $offset < 0) {
throw new InvalidParam('offset', "Expecting non-negative integer.");
}
$limit = $request->get_parameter('limit');
if (!$limit) {
$limit = "none";
}
if ($limit == "none") {
$limit = "999999999";
}
if ((int) $limit != $limit || (int) $limit < 0) {
throw new InvalidParam('limit', "Expecting non-negative integer or 'none'.");
}
# Check if code exists and retrieve cache ID (this will throw
# a proper exception on invalid code).
$cache = OkapiServiceRunner::call('services/caches/geocache', new OkapiInternalRequest($request->consumer, null, array('cache_code' => $cache_code, 'fields' => 'internal_id')));
# Cache exists. Getting the uuids of its logs.
$log_uuids = Db::select_column("\n select uuid\n from cache_logs\n where\n cache_id = '" . Db::escape_string($cache['internal_id']) . "'\n and " . (Settings::get('OC_BRANCH') == 'oc.pl' ? "deleted = 0" : "true") . "\n order by date desc\n limit {$offset}, {$limit}\n ");
# Getting the logs themselves. Formatting as an ordered list.
$internal_request = new OkapiInternalRequest($request->consumer, $request->token, array('log_uuids' => implode("|", $log_uuids), 'fields' => $fields));
$internal_request->skip_limits = true;
$logs = OkapiServiceRunner::call('services/logs/entries', $internal_request);
$results = array();
foreach ($log_uuids as $log_uuid) {
$results[] = $logs[$log_uuid];
}
/* Handle OCPL's "access logs" feature. */
if (Settings::get('OC_BRANCH') == 'oc.pl' && Settings::get('OCPL_ENABLE_GEOCACHE_ACCESS_LOGS') && count($log_uuids) > 0) {
require_once $GLOBALS['rootpath'] . 'okapi/lib/ocpl_access_logs.php';
\okapi\OCPLAccessLogs::log_geocache_access($request, $cache['internal_id']);
}
return Okapi::formatted_response($request, $results);
}
示例9: call
public static function call()
{
# Determine which user is logged in to OC.
require_once $GLOBALS['rootpath'] . "okapi/lib/oc_session.php";
$OC_user_id = OCSession::get_user_id();
# Ensure a user is logged in.
if ($OC_user_id == null) {
$after_login = "okapi/apps/";
# it is correct, if you're wondering
$login_url = Settings::get('SITE_URL') . "login.php?target=" . urlencode($after_login);
return new OkapiRedirectResponse($login_url);
}
$consumer_key = isset($_REQUEST['consumer_key']) ? $_REQUEST['consumer_key'] : '';
# Just remove app (if it doesn't exist - nothing wrong will happen anyway).
Db::execute("\n delete from okapi_tokens\n where\n user_id = '" . Db::escape_string($OC_user_id) . "'\n and consumer_key = '" . Db::escape_string($consumer_key) . "'\n ");
Db::execute("\n delete from okapi_authorizations\n where\n user_id = '" . Db::escape_string($OC_user_id) . "'\n and consumer_key = '" . Db::escape_string($consumer_key) . "'\n ");
# Redirect back to the apps page.
return new OkapiRedirectResponse(Settings::get('SITE_URL') . "okapi/apps/");
}
示例10: call
public static function call(OkapiRequest $request)
{
$usernames = $request->get_parameter('usernames');
if (!$usernames) {
throw new ParamMissing('usernames');
}
$usernames = explode("|", $usernames);
if (count($usernames) > 500) {
throw new InvalidParam('usernames', "Maximum allowed number of referenced users " . "is 500. You provided " . count($usernames) . " usernames.");
}
$fields = $request->get_parameter('fields');
if (!$fields) {
throw new ParamMissing('fields');
}
# There's no need to validate the fields parameter as the 'users'
# method does this (it will raise a proper exception on invalid values).
$rs = Db::query("\n select username, uuid\n from user\n where username collate " . Settings::get('DB_CHARSET') . "_general_ci in ('" . implode("','", array_map('\\okapi\\Db::escape_string', $usernames)) . "')\n ");
$lower_username2useruuid = array();
while ($row = Db::fetch_assoc($rs)) {
$lower_username2useruuid[mb_strtolower($row['username'], 'utf-8')] = $row['uuid'];
}
Db::free_result($rs);
# Retrieve data for the found user_uuids.
if (count($lower_username2useruuid) > 0) {
$id_results = OkapiServiceRunner::call('services/users/users', new OkapiInternalRequest($request->consumer, $request->token, array('user_uuids' => implode("|", array_values($lower_username2useruuid)), 'fields' => $fields)));
} else {
$id_results = array();
}
# Map user_uuids back to usernames. Also check which usernames were not found
# and mark them with null.
$results = array();
foreach ($usernames as $username) {
if (!isset($lower_username2useruuid[mb_strtolower($username, 'utf-8')])) {
$results[$username] = null;
} else {
$results[$username] = $id_results[$lower_username2useruuid[mb_strtolower($username, 'utf-8')]];
}
}
return Okapi::formatted_response($request, $results);
}
示例11: call
public static function call(OkapiRequest $request)
{
$user_uuid = $request->get_parameter('user_uuid');
if (!$user_uuid) {
throw new ParamMissing('user_uuid');
}
$limit = $request->get_parameter('limit');
if (!$limit) {
$limit = "20";
}
if (!is_numeric($limit)) {
throw new InvalidParam('limit', "'{$limit}'");
}
$limit = intval($limit);
if ($limit < 1 || $limit > 1000) {
throw new InvalidParam('limit', "Has to be in range 1..1000.");
}
$offset = $request->get_parameter('offset');
if (!$offset) {
$offset = "0";
}
if (!is_numeric($offset)) {
throw new InvalidParam('offset', "'{$offset}'");
}
$offset = intval($offset);
if ($offset < 0) {
throw new InvalidParam('offset', "'{$offset}'");
}
# Check if user exists and retrieve user's ID (this will throw
# a proper exception on invalid UUID).
$user = OkapiServiceRunner::call('services/users/user', new OkapiInternalRequest($request->consumer, null, array('user_uuid' => $user_uuid, 'fields' => 'internal_id')));
# User exists. Retrieving logs.
$rs = Db::query("\n select cl.id, cl.uuid, cl.type, unix_timestamp(cl.date) as date, cl.text,\n c.wp_oc as cache_code\n from cache_logs cl, caches c\n where\n cl.user_id = '" . Db::escape_string($user['internal_id']) . "'\n and " . (Settings::get('OC_BRANCH') == 'oc.pl' ? "cl.deleted = 0" : "true") . "\n and c.status in (1,2,3)\n and cl.cache_id = c.cache_id\n order by cl.date desc\n limit {$offset}, {$limit}\n ");
$results = array();
while ($row = Db::fetch_assoc($rs)) {
$results[] = array('uuid' => $row['uuid'], 'date' => date('c', $row['date']), 'cache_code' => $row['cache_code'], 'type' => Okapi::logtypeid2name($row['type']), 'comment' => $row['text']);
}
return Okapi::formatted_response($request, $results);
}
示例12: call
public static function call()
{
$token_key = isset($_GET['oauth_token']) ? $_GET['oauth_token'] : '';
$verifier = isset($_GET['oauth_verifier']) ? $_GET['oauth_verifier'] : '';
$langpref = isset($_GET['langpref']) ? $_GET['langpref'] : Settings::get('SITELANG');
$langprefs = explode("|", $langpref);
$token = Db::select_row("\n select\n c.`key` as consumer_key,\n c.name as consumer_name,\n c.url as consumer_url,\n t.verifier\n from\n okapi_consumers c,\n okapi_tokens t\n where\n t.`key` = '" . mysql_real_escape_string($token_key) . "'\n and t.consumer_key = c.`key`\n ");
if (!$token) {
# Probably Request Token has expired or it was already used. We'll
# just redirect to the Opencaching main page.
return new OkapiRedirectResponse(Settings::get('SITE_URL'));
}
$vars = array('okapi_base_url' => Settings::get('SITE_URL') . "okapi/", 'token' => $token, 'verifier' => $verifier, 'site_name' => Okapi::get_normalized_site_name(), 'site_url' => Settings::get('SITE_URL'), 'site_logo' => Settings::get('SITE_LOGO'));
$response = new OkapiHttpResponse();
$response->content_type = "text/html; charset=utf-8";
ob_start();
Okapi::gettext_domain_init($langprefs);
include 'authorized.tpl.php';
$response->body = ob_get_clean();
Okapi::gettext_domain_restore();
return $response;
}
示例13: call
public static function call(OkapiRequest $request)
{
$internal_ids = $request->get_parameter('internal_ids');
if (!$internal_ids) {
throw new ParamMissing('internal_ids');
}
$internal_ids = explode("|", $internal_ids);
if (count($internal_ids) > 500) {
throw new InvalidParam('internal_ids', "Maximum allowed number of referenced users " . "is 500. You provided " . count($internal_ids) . " references.");
}
$fields = $request->get_parameter('fields');
if (!$fields) {
throw new ParamMissing('fields');
}
# There's no need to validate the fields parameter as the 'users'
# method does this (it will raise a proper exception on invalid values).
$rs = Db::query("\n select user_id, uuid\n from user\n where user_id in ('" . implode("','", array_map('mysql_real_escape_string', $internal_ids)) . "')\n ");
$internalid2useruuid = array();
while ($row = mysql_fetch_assoc($rs)) {
$internalid2useruuid[$row['user_id']] = $row['uuid'];
}
mysql_free_result($rs);
# Retrieve data on given user_uuids.
$id_results = OkapiServiceRunner::call('services/users/users', new OkapiInternalRequest($request->consumer, $request->token, array('user_uuids' => implode("|", array_values($internalid2useruuid)), 'fields' => $fields)));
# Map user_uuids to internal_ids. Also check which internal_ids were not found
# and mark them with null.
$results = array();
foreach ($internal_ids as $internal_id) {
if (!isset($internalid2useruuid[$internal_id])) {
$results[$internal_id] = null;
} else {
$results[$internal_id] = $id_results[$internalid2useruuid[$internal_id]];
}
}
return Okapi::formatted_response($request, $results);
}
示例14: __construct
public function __construct($options)
{
Okapi::init_internals();
$this->init_request();
#
# Parsing options.
#
$DEBUG_AS_USERNAME = null;
foreach ($options as $key => $value) {
switch ($key) {
case 'min_auth_level':
if (!in_array($value, array(0, 1, 2, 3))) {
throw new Exception("'min_auth_level' option has invalid value: {$value}");
}
$this->opt_min_auth_level = $value;
break;
case 'token_type':
if (!in_array($value, array("request", "access"))) {
throw new Exception("'token_type' option has invalid value: {$value}");
}
$this->opt_token_type = $value;
break;
case 'DEBUG_AS_USERNAME':
$DEBUG_AS_USERNAME = $value;
break;
default:
throw new Exception("Unknown option: {$key}");
break;
}
}
if ($this->opt_min_auth_level === null) {
throw new Exception("Required 'min_auth_level' option is missing.");
}
if ($DEBUG_AS_USERNAME != null) {
# Enables debugging Level 2 and Level 3 methods. Should not be committed
# at any time! If run on production server, make it an error.
if (!Settings::get('DEBUG')) {
throw new Exception("Attempted to use DEBUG_AS_USERNAME in " . "non-debug environment. Accidental commit?");
}
# Lower required authentication to Level 0, to pass the checks.
$this->opt_min_auth_level = 0;
}
#
# Let's see if the request is signed. If it is, verify the signature.
# It it's not, check if it isn't against the rules defined in the $options.
#
if ($this->get_parameter('oauth_signature')) {
# User is using OAuth.
# Check for duplicate keys in the parameters. (Datastore doesn't
# do that on its own, it caused vague server errors - issue #307.)
$this->get_parameter('oauth_consumer');
$this->get_parameter('oauth_version');
$this->get_parameter('oauth_token');
$this->get_parameter('oauth_nonce');
# Verify OAuth request.
list($this->consumer, $this->token) = Okapi::$server->verify_request2($this->request, $this->opt_token_type, $this->opt_min_auth_level == 3);
if ($this->get_parameter('consumer_key') && $this->get_parameter('consumer_key') != $this->get_parameter('oauth_consumer_key')) {
throw new BadRequest("Inproper mixing of authentication types. You used both 'consumer_key' " . "and 'oauth_consumer_key' parameters (Level 1 and Level 2), but they do not match with " . "each other. Were you trying to hack me? ;)");
}
if ($this->opt_min_auth_level == 3 && !$this->token) {
throw new BadRequest("This method requires a valid Token to be included (Level 3 " . "Authentication). You didn't provide one.");
}
} else {
if ($this->opt_min_auth_level >= 2) {
throw new BadRequest("This method requires OAuth signature (Level " . $this->opt_min_auth_level . " Authentication). You didn't sign your request.");
} else {
$consumer_key = $this->get_parameter('consumer_key');
if ($consumer_key) {
$this->consumer = Okapi::$data_store->lookup_consumer($consumer_key);
if (!$this->consumer) {
throw new InvalidParam('consumer_key', "Consumer does not exist.");
}
}
if ($this->opt_min_auth_level == 1 && !$this->consumer) {
throw new BadRequest("This method requires the 'consumer_key' argument (Level 1 " . "Authentication). You didn't provide one.");
}
}
}
if (is_object($this->consumer) && $this->consumer->hasFlag(OkapiConsumer::FLAG_SKIP_LIMITS)) {
$this->skip_limits = true;
}
#
# Prevent developers from accessing request parameters with PHP globals.
# Remember, that OKAPI requests can be nested within other OKAPI requests!
# Search the code for "new OkapiInternalRequest" to see examples.
#
$_GET = $_POST = $_REQUEST = null;
# When debugging, simulate as if been run using a proper Level 3 Authentication.
if ($DEBUG_AS_USERNAME != null) {
# Note, that this will override any other valid authentication the
# developer might have issued.
$debug_user_id = Db::select_value("select user_id from user where username='" . mysql_real_escape_string($options['DEBUG_AS_USERNAME']) . "'");
if ($debug_user_id == null) {
throw new Exception("Invalid user name in DEBUG_AS_USERNAME: '" . $options['DEBUG_AS_USERNAME'] . "'");
}
$this->consumer = new OkapiDebugConsumer();
$this->token = new OkapiDebugAccessToken($debug_user_id);
}
# Read the ETag.
if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
//.........这里部分代码省略.........
示例15: get_all_logtypes
/**
* Get an array of all site-specific log-types (id => name in English).
*/
private static function get_all_logtypes()
{
if (Settings::get('OC_BRANCH') == 'oc.pl') {
# OCPL branch does not store cache types in many languages (just two).
$rs = Db::query("select id, en from log_types order by id");
} else {
# OCDE branch uses translation tables.
$rs = Db::query("\n select\n lt.id,\n stt.text as en\n from\n log_types lt\n left join sys_trans_text stt\n on lt.trans_id = stt.trans_id\n and stt.lang = 'EN'\n order by lt.id\n ");
}
$dict = array();
while ($row = mysql_fetch_assoc($rs)) {
$dict[$row['id']] = $row['en'];
}
return $dict;
}