当前位置: 首页>>代码示例>>PHP>>正文


PHP Okapi::get_normalized_site_name方法代码示例

本文整理汇总了PHP中okapi\Okapi::get_normalized_site_name方法的典型用法代码示例。如果您正苦于以下问题:PHP Okapi::get_normalized_site_name方法的具体用法?PHP Okapi::get_normalized_site_name怎么用?PHP Okapi::get_normalized_site_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在okapi\Okapi的用法示例。


在下文中一共展示了Okapi::get_normalized_site_name方法的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;
 }
开发者ID:PaulinaKowalczuk,项目名称:oc-server3,代码行数:33,代码来源:index.php

示例2: call

 public static function call(OkapiRequest $request)
 {
     $result = array();
     $result['site_url'] = Settings::get('SITE_URL');
     $result['okapi_base_url'] = $result['site_url'] . "okapi/";
     $result['site_name'] = Okapi::get_normalized_site_name();
     $result['okapi_revision'] = Okapi::$revision;
     return Okapi::formatted_response($request, $result);
 }
开发者ID:4Vs,项目名称:oc-server3,代码行数:9,代码来源:installation.php

示例3: call

 public static function call()
 {
     require_once $GLOBALS['rootpath'] . 'okapi/service_runner.php';
     require_once $GLOBALS['rootpath'] . 'okapi/views/menu.inc.php';
     $vars = array('menu' => OkapiMenu::get_menu_html("examples.html"), 'okapi_base_url' => Settings::get('SITE_URL') . "okapi/", 'site_url' => Settings::get('SITE_URL'), 'installations' => OkapiMenu::get_installations(), 'okapi_rev' => Okapi::$version_number, 'site_name' => Okapi::get_normalized_site_name());
     $response = new OkapiHttpResponse();
     $response->content_type = "text/html; charset=utf-8";
     ob_start();
     include 'examples.tpl.php';
     $response->body = ob_get_clean();
     return $response;
 }
开发者ID:PaulinaKowalczuk,项目名称:oc-server3,代码行数:12,代码来源:examples.php

示例4: call

 public static function call(OkapiRequest $request)
 {
     $result = array();
     $result['site_url'] = Settings::get('SITE_URL');
     $result['okapi_base_url'] = $result['site_url'] . "okapi/";
     $result['site_name'] = Okapi::get_normalized_site_name();
     $result['okapi_version_number'] = Okapi::$version_number;
     $result['okapi_revision'] = Okapi::$version_number;
     /* Important for backward-compatibility! */
     $result['okapi_git_revision'] = Okapi::$git_revision;
     return Okapi::formatted_response($request, $result);
 }
开发者ID:PaulinaKowalczuk,项目名称:oc-server3,代码行数:12,代码来源:installation.php

示例5: call

 public static function call()
 {
     require_once $GLOBALS['rootpath'] . 'okapi/views/menu.inc.php';
     require_once $GLOBALS['rootpath'] . 'okapi/views/changelog_helper.inc.php';
     $changelog = new Changelog();
     $vars = array('menu' => OkapiMenu::get_menu_html("changelog.html"), 'okapi_base_url' => Settings::get('SITE_URL') . "okapi/", 'site_url' => Settings::get('SITE_URL'), 'installations' => OkapiMenu::get_installations(), 'okapi_rev' => Okapi::$version_number, 'site_name' => Okapi::get_normalized_site_name(), 'changes' => array('unavailable' => $changelog->unavailable_changes, 'available' => $changelog->available_changes));
     $response = new OkapiHttpResponse();
     $response->content_type = "text/html; charset=utf-8";
     ob_start();
     include 'changelog.tpl.php';
     $response->body = ob_get_clean();
     return $response;
 }
开发者ID:kratenko,项目名称:oc-server3,代码行数:13,代码来源:changelog.php

示例6: call

 public static function call(OkapiRequest $request)
 {
     $result = array();
     $result['site_url'] = Settings::get('SITE_URL');
     $result['okapi_base_url'] = Okapi::get_recommended_base_url();
     $result['okapi_base_urls'] = Okapi::get_allowed_base_urls();
     $result['site_name'] = Okapi::get_normalized_site_name();
     $result['okapi_version_number'] = Okapi::$version_number;
     $result['okapi_revision'] = Okapi::$version_number;
     /* Important for backward-compatibility! */
     $result['okapi_git_revision'] = Okapi::$git_revision;
     $result['registration_url'] = Settings::get('REGISTRATION_URL');
     $result['mobile_registration_url'] = Settings::get('MOBILE_REGISTRATION_URL');
     $result['image_max_upload_size'] = Settings::get('IMAGE_MAX_UPLOAD_SIZE');
     $result['image_rcmd_max_pixels'] = Settings::get('IMAGE_MAX_PIXEL_COUNT');
     return Okapi::formatted_response($request, $result);
 }
开发者ID:kratenko,项目名称:oc-server3,代码行数:17,代码来源:installation.php

示例7: call

 public static function call()
 {
     if (isset($_REQUEST['posted'])) {
         $appname = isset($_REQUEST['appname']) ? $_REQUEST['appname'] : "";
         $appname = trim($appname);
         $appurl = isset($_REQUEST['appurl']) ? $_REQUEST['appurl'] : "";
         $email = isset($_REQUEST['email']) ? $_REQUEST['email'] : "";
         $accepted_terms = isset($_REQUEST['terms']) ? $_REQUEST['terms'] : "";
         $ok = false;
         if (!$appname) {
             $notice = "Please provide a valid application name.";
         } elseif (mb_strlen($appname) > 100) {
             $notice = "Application name should be less than 100 characters long.";
         } elseif (mb_strlen($appurl) > 250) {
             $notice = "Application URL should be less than 250 characters long.";
         } elseif ($appurl && substr($appurl, 0, 7) != "http://" && substr($appurl, 0, 8) != "https://") {
             $notice = "Application homepage URL should start with http(s)://. (Note: this URL is OPTIONAL and it is NOT for OAuth callback.)";
         } elseif (!$email) {
             $notice = "Please provide a valid email address.";
         } elseif (mb_strlen($email) > 70) {
             $notice = "Email address should be less than 70 characters long.";
         } elseif (!$accepted_terms) {
             $notice = "You have to read and accept OKAPI Terms of Use.";
         } else {
             $ok = true;
             Okapi::register_new_consumer($appname, $appurl, $email);
             $notice = "Consumer Key generated successfully.\nCheck your email!";
         }
         $response = new OkapiHttpResponse();
         $response->content_type = "application/json; charset=utf-8";
         $response->body = json_encode(array('ok' => $ok, 'notice' => $notice));
         return $response;
     }
     require_once $GLOBALS['rootpath'] . 'okapi/service_runner.php';
     require_once $GLOBALS['rootpath'] . 'okapi/views/menu.inc.php';
     $vars = array('menu' => OkapiMenu::get_menu_html("signup.html"), 'okapi_base_url' => Settings::get('SITE_URL') . "okapi/", 'site_url' => Settings::get('SITE_URL'), 'site_name' => Okapi::get_normalized_site_name(), 'installations' => OkapiMenu::get_installations(), 'okapi_rev' => Okapi::$version_number, 'data_license_html' => Settings::get('DATA_LICENSE_URL') ? "<a href='" . Settings::get('DATA_LICENSE_URL') . "'>Data License</a>" : "Data License");
     $response = new OkapiHttpResponse();
     $response->content_type = "text/html; charset=utf-8";
     ob_start();
     include 'signup.tpl.php';
     $response->body = ob_get_clean();
     return $response;
 }
开发者ID:PaulinaKowalczuk,项目名称:oc-server3,代码行数:43,代码来源:signup.php

示例8: 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;
 }
开发者ID:PaulinaKowalczuk,项目名称:oc-server3,代码行数:22,代码来源:authorized.php

示例9: call

 public static function call(OkapiRequest $request)
 {
     # The list of installations is periodically refreshed by contacting OKAPI
     # repository. This method usually displays the cached version of it.
     $cachekey = 'apisrv/installations';
     $backupkey = 'apisrv/installations-backup';
     $results = Cache::get($cachekey);
     if (!$results) {
         # Download the current list of OKAPI servers.
         try {
             $opts = array('http' => array('method' => "GET", 'timeout' => 5.0));
             $context = stream_context_create($opts);
             $xml = file_get_contents("http://opencaching-api.googlecode.com/svn/trunk/etc/installations.xml", false, $context);
             $doc = simplexml_load_string($xml);
             if (!$doc) {
                 throw new ErrorException();
                 # just to get to the catch block
             }
         } catch (ErrorException $e) {
             # Google failed on us. Try to respond with a backup list.
             $results = Cache::get($backupkey);
             if ($results) {
                 Cache::set($cachekey, $results, 12 * 3600);
                 # so to retry no earlier than after 12 hours
                 return Okapi::formatted_response($request, $results);
             }
             # Backup has expired (or have never been cached). If we're on a development
             # server then probably it's okay. In production this SHOULD NOT happen.
             $results = array(array('site_url' => Settings::get('SITE_URL'), 'site_name' => "Unable to retrieve!", 'okapi_base_url' => Settings::get('SITE_URL') . "okapi/"));
             Cache::set($cachekey, $results, 12 * 3600);
             # so to retry no earlier than after 12 hours
             return Okapi::formatted_response($request, $results);
         }
         $results = array();
         $i_was_included = false;
         foreach ($doc->installation as $inst) {
             $site_url = (string) $inst[0]['site_url'];
             if ($inst[0]['okapi_base_url']) {
                 $okapi_base_url = (string) $inst[0]['okapi_base_url'];
             } else {
                 $okapi_base_url = $site_url . "okapi/";
             }
             if ($inst[0]['site_name']) {
                 $site_name = (string) $inst[0]['site_name'];
             } else {
                 $site_name = Okapi::get_normalized_site_name($site_url);
             }
             $results[] = array('site_url' => $site_url, 'site_name' => $site_name, 'okapi_base_url' => $okapi_base_url);
             if ($site_url == Settings::get('SITE_URL')) {
                 $i_was_included = true;
             }
         }
         # If running on a local development installation, then include the local
         # installation URL.
         if (!$i_was_included) {
             $results[] = array('site_url' => Settings::get('SITE_URL'), 'site_name' => "DEVELSITE", 'okapi_base_url' => Settings::get('SITE_URL') . "okapi/");
             # Contact OKAPI developers in order to get added to the official sites list!
         }
         # Cache it for one day. Also, save a backup (valid for 30 days).
         Cache::set($cachekey, $results, 86400);
         Cache::set($backupkey, $results, 86400 * 30);
     }
     return Okapi::formatted_response($request, $results);
 }
开发者ID:4Vs,项目名称:oc-server3,代码行数:64,代码来源:installations.php

示例10: get_unknown_placeholder

 /**
  * Object to be used for forward-compatibility (see the attributes method).
  */
 public static function get_unknown_placeholder($acode)
 {
     return array('acode' => $acode, 'gc_equivs' => array(), 'internal_id' => null, 'names' => array('en' => "Unknown attribute"), 'descriptions' => array('en' => "This attribute ({$acode}) is unknown at " . Okapi::get_normalized_site_name() . ". It might not exist, or it may be a new attribute, recognized " . "only in newer OKAPI installations. Perhaps " . Okapi::get_normalized_site_name() . " needs to have its OKAPI updated?"), 'is_discontinued' => true);
 }
开发者ID:4Vs,项目名称:oc-server3,代码行数:7,代码来源:attr_helper.inc.php

示例11: call

 public static function call()
 {
     $token_key = isset($_GET['oauth_token']) ? $_GET['oauth_token'] : '';
     $langpref = isset($_GET['langpref']) ? $_GET['langpref'] : Settings::get('SITELANG');
     $langprefs = explode("|", $langpref);
     $locales = array();
     foreach (Locales::$languages as $lang => $attrs) {
         $locales[$attrs['locale']] = $attrs;
     }
     # Current implementation of the "interactivity" parameter is: If developer
     # wants to "confirm_user", then just log out the current user before we
     # continue.
     $force_relogin = isset($_GET['interactivity']) && $_GET['interactivity'] == 'confirm_user';
     $token = Db::select_row("\n            select\n                t.`key` as `key`,\n                c.`key` as consumer_key,\n                c.name as consumer_name,\n                c.url as consumer_url,\n                t.callback,\n                t.verifier\n            from\n                okapi_consumers c,\n                okapi_tokens t\n            where\n                t.`key` = '" . Db::escape_string($token_key) . "'\n                and t.consumer_key = c.`key`\n                and t.user_id is null\n        ");
     $callback_concat_char = strpos($token['callback'], '?') === false ? "?" : "&";
     if (!$token) {
         # Probably Request Token has expired. This will be usually viewed
         # by the user, who knows nothing on tokens and OAuth. Let's be nice then!
         $vars = array('okapi_base_url' => Settings::get('SITE_URL') . "okapi/", 'token' => $token, 'token_expired' => true, 'site_name' => Okapi::get_normalized_site_name(), 'site_url' => Settings::get('SITE_URL'), 'site_logo' => Settings::get('SITE_LOGO'), 'locales' => $locales);
         $response = new OkapiHttpResponse();
         $response->content_type = "text/html; charset=utf-8";
         ob_start();
         $vars['locale_displayed'] = Okapi::gettext_domain_init($langprefs);
         include 'authorize.tpl.php';
         $response->body = ob_get_clean();
         Okapi::gettext_domain_restore();
         return $response;
     }
     # 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 (or force re-login).
     if ($force_relogin || $OC_user_id == null) {
         # TODO: confirm_user should first ask the user if he's "the proper one",
         # and then offer to sign in as a different user.
         $login_page = 'login.php?';
         if ($OC_user_id !== null) {
             if (Settings::get('OC_BRANCH') == 'oc.de') {
                 # OCDE login.php?action=logout&target=... will NOT logout and
                 # then redirect to the target, but it will log out, prompt for
                 # login and then redirect to the target after logging in -
                 # that's exactly the relogin that we want.
                 $login_page .= 'action=logout&';
             } else {
                 # OCPL uses REAL MAGIC for session handling. I don't get ANY of it.
                 # The logout.php DOES NOT support the "target" parameter, so we
                 # can't just call it. The only thing that comes to mind is...
                 # Try to destroy EVERYTHING. (This still won't necessarilly work,
                 # because OC may store cookies in separate paths, but hopefully
                 # they won't).
                 if (isset($_SERVER['HTTP_COOKIE'])) {
                     $cookies = explode(';', $_SERVER['HTTP_COOKIE']);
                     foreach ($cookies as $cookie) {
                         $parts = explode('=', $cookie);
                         $name = trim($parts[0]);
                         setcookie($name, '', time() - 1000);
                         setcookie($name, '', time() - 1000, '/');
                         foreach (self::getPossibleCookieDomains() as $domain) {
                             setcookie($name, '', time() - 1000, '/', $domain);
                         }
                     }
                 }
                 # We should be logged out now. Let's login again.
             }
         }
         $after_login = "okapi/apps/authorize?oauth_token={$token_key}" . ($langpref != Settings::get('SITELANG') ? "&langpref=" . $langpref : "");
         $login_url = Settings::get('SITE_URL') . $login_page . "target=" . urlencode($after_login) . "&langpref=" . $langpref;
         return new OkapiRedirectResponse($login_url);
     }
     # Check if this user has already authorized this Consumer. If he did,
     # then we will automatically authorize all subsequent Request Tokens
     # from this Consumer.
     $authorized = Db::select_value("\n            select 1\n            from okapi_authorizations\n            where\n                user_id = '" . Db::escape_string($OC_user_id) . "'\n                and consumer_key = '" . Db::escape_string($token['consumer_key']) . "'\n        ", 0);
     if (!$authorized) {
         if (isset($_POST['authorization_result'])) {
             # Not yet authorized, but user have just submitted the authorization form.
             # WRTODO: CSRF protection
             if ($_POST['authorization_result'] == 'granted') {
                 Db::execute("\n                        insert ignore into okapi_authorizations (consumer_key, user_id)\n                        values (\n                            '" . Db::escape_string($token['consumer_key']) . "',\n                            '" . Db::escape_string($OC_user_id) . "'\n                        );\n                    ");
                 $authorized = true;
             } else {
                 # User denied access. Nothing sensible to do now. Will try to report
                 # back to the Consumer application with an error.
                 if ($token['callback']) {
                     return new OkapiRedirectResponse($token['callback'] . $callback_concat_char . "error=access_denied" . "&oauth_token=" . $token['key']);
                 } else {
                     # Consumer did not provide a callback URL (oauth_callback=oob).
                     # We'll have to redirect to the Opencaching main page then...
                     return new OkapiRedirectResponse(Settings::get('SITE_URL') . "index.php");
                 }
             }
         } else {
             # Not yet authorized. Display an authorization request.
             $vars = array('okapi_base_url' => Settings::get('SITE_URL') . "okapi/", 'token' => $token, 'site_name' => Okapi::get_normalized_site_name(), 'site_url' => Settings::get('SITE_URL'), 'site_logo' => Settings::get('SITE_LOGO'), 'locales' => $locales);
             $response = new OkapiHttpResponse();
             $response->content_type = "text/html; charset=utf-8";
             ob_start();
             $vars['locale_displayed'] = Okapi::gettext_domain_init($langprefs);
             include 'authorize.tpl.php';
             $response->body = ob_get_clean();
//.........这里部分代码省略.........
开发者ID:kratenko,项目名称:oc-server3,代码行数:101,代码来源:authorize.php

示例12: generate_fulldump

 /**
  * Generate a new fulldump file and put it into the OKAPI cache table.
  * Return the cache key.
  */
 public static function generate_fulldump()
 {
     # First we will create temporary files, then compress them in the end.
     $revision = self::get_revision();
     $generated_at = date('c', time());
     $dir = Okapi::get_var_dir() . "/okapi-db-dump";
     $i = 1;
     $json_files = array();
     # Cleanup (from a previous, possibly unsuccessful, execution)
     shell_exec("rm -f {$dir}/*");
     shell_exec("rmdir {$dir}");
     shell_exec("mkdir {$dir}");
     shell_exec("chmod 777 {$dir}");
     # Geocaches
     $cache_codes = Db::select_column("select wp_oc from caches");
     $cache_code_groups = Okapi::make_groups($cache_codes, self::$chunk_size);
     unset($cache_codes);
     foreach ($cache_code_groups as $cache_codes) {
         $basename = "part" . str_pad($i, 5, "0", STR_PAD_LEFT);
         $json_files[] = $basename . ".json";
         $entries = self::generate_changelog_entries('services/caches/geocaches', 'geocache', 'cache_codes', 'code', $cache_codes, self::$logged_cache_fields, true, false);
         $filtered = array();
         foreach ($entries as $entry) {
             if ($entry['change_type'] == 'replace') {
                 $filtered[] = $entry;
             }
         }
         unset($entries);
         file_put_contents("{$dir}/{$basename}.json", json_encode($filtered));
         unset($filtered);
         $i++;
     }
     unset($cache_code_groups);
     # Log entries. We cannot load all the uuids at one time, this would take
     # too much memory. Hence the offset/limit loop.
     $offset = 0;
     while (true) {
         $log_uuids = Db::select_column("\n                select uuid\n                from cache_logs\n                where " . (Settings::get('OC_BRANCH') == 'oc.pl' ? "deleted = 0" : "true") . "\n                order by uuid\n                limit {$offset}, 10000\n            ");
         if (count($log_uuids) == 0) {
             break;
         }
         $offset += 10000;
         $log_uuid_groups = Okapi::make_groups($log_uuids, 500);
         unset($log_uuids);
         foreach ($log_uuid_groups as $log_uuids) {
             $basename = "part" . str_pad($i, 5, "0", STR_PAD_LEFT);
             $json_files[] = $basename . ".json";
             $entries = self::generate_changelog_entries('services/logs/entries', 'log', 'log_uuids', 'uuid', $log_uuids, self::$logged_log_entry_fields, true, false);
             $filtered = array();
             foreach ($entries as $entry) {
                 if ($entry['change_type'] == 'replace') {
                     $filtered[] = $entry;
                 }
             }
             unset($entries);
             file_put_contents("{$dir}/{$basename}.json", json_encode($filtered));
             unset($filtered);
             $i++;
         }
     }
     # Package data.
     $metadata = array('revision' => $revision, 'data_files' => $json_files, 'meta' => array('site_name' => Okapi::get_normalized_site_name(), 'okapi_version_number' => Okapi::$version_number, 'okapi_revision' => Okapi::$version_number, 'okapi_git_revision' => Okapi::$git_revision, 'generated_at' => $generated_at));
     file_put_contents("{$dir}/index.json", json_encode($metadata));
     # Compute uncompressed size.
     $size = filesize("{$dir}/index.json");
     foreach ($json_files as $filename) {
         $size += filesize("{$dir}/{$filename}");
     }
     # Create JSON archive. We use tar options: -j for bzip2, -z for gzip
     # (bzip2 is MUCH slower).
     $use_bzip2 = true;
     $dumpfilename = "okapi-dump.tar." . ($use_bzip2 ? "bz2" : "gz");
     shell_exec("tar --directory {$dir} -c" . ($use_bzip2 ? "j" : "z") . "f {$dir}/{$dumpfilename} index.json " . implode(" ", $json_files) . " 2>&1");
     # Delete temporary files.
     shell_exec("rm -f {$dir}/*.json");
     # Move the archive one directory upwards, replacing the previous one.
     # Remove the temporary directory.
     shell_exec("mv -f {$dir}/{$dumpfilename} " . Okapi::get_var_dir());
     shell_exec("rmdir {$dir}");
     # Update the database info.
     $metadata['meta']['filepath'] = Okapi::get_var_dir() . '/' . $dumpfilename;
     $metadata['meta']['content_type'] = $use_bzip2 ? "application/octet-stream" : "application/x-gzip";
     $metadata['meta']['public_filename'] = 'okapi-dump-r' . $metadata['revision'] . '.tar.' . ($use_bzip2 ? "bz2" : "gz");
     $metadata['meta']['uncompressed_size'] = $size;
     $metadata['meta']['compressed_size'] = filesize($metadata['meta']['filepath']);
     Cache::set("last_fulldump", $metadata, 10 * 86400);
 }
开发者ID:PaulinaKowalczuk,项目名称:oc-server3,代码行数:91,代码来源:replicate_common.inc.php

示例13: get_cache_attribution_note

 /**
  * Return attribution note for the given geocache.
  *
  * The $lang parameter identifies the language of the cache description
  * to which the attribution note will be appended to (one cache may
  * have descriptions in multiple languages!).
  *
  * The $langpref parameter is *an array* of language preferences
  * extracted from the langpref parameter passed to the method by the
  * OKAPI Consumer.
  *
  * Both values ($lang and $langpref) will be taken into account when
  * generating the attribution note, but $lang will have a higher
  * priority than $langpref (we don't want to mix the languages in the
  * descriptions if we don't have to).
  *
  * $owner is in object describing the user, it has the same format as
  * defined in "geocache" method specs (see the "owner" field).
  *
  * The $type is either "full" or "static". Full attributions may contain
  * dates and are not suitable for the replicate module. Static attributions
  * don't change that frequently.
  */
 public static function get_cache_attribution_note($cache_id, $lang, array $langpref, $owner, $type)
 {
     $site_url = Settings::get('SITE_URL');
     $site_name = Okapi::get_normalized_site_name();
     $cache_url = $site_url . "viewcache.php?cacheid={$cache_id}";
     Okapi::gettext_domain_init(array_merge(array($lang), $langpref));
     if (Settings::get('OC_BRANCH') == 'oc.pl') {
         # This does not vary on $type (yet).
         $note = sprintf(_("This <a href='%s'>geocache</a> description comes from the <a href='%s'>%s</a> site."), $cache_url, $site_url, $site_name);
     } else {
         # OC.de wants the tld in lowercase here
         $site_name = ucfirst(strtolower($site_name));
         if ($type == 'full') {
             $note = sprintf(_("&copy; <a href='%s'>%s</a>, <a href='%s'>%s</a>, " . "<a href='http://creativecommons.org/licenses/by-nc-nd/3.0/de/deed.en'>CC-BY-NC-ND</a>, " . "as of %s; all log entries &copy; their authors"), $owner['profile_url'], $owner['username'], $cache_url, $site_name, strftime('%x'));
         } elseif ($type == 'static') {
             $note = sprintf(_("&copy; <a href='%s'>%s</a>, <a href='%s'>%s</a>, " . "<a href='http://creativecommons.org/licenses/by-nc-nd/3.0/de/deed.en'>CC-BY-NC-ND</a>; " . "all log entries &copy; their authors"), $owner['profile_url'], $owner['username'], $cache_url, $site_name);
         }
     }
     Okapi::gettext_domain_restore();
     return $note;
 }
开发者ID:Slini11,项目名称:okapi,代码行数:44,代码来源:geocaches.php

示例14: _call

 /**
  * Publish a new log entry and return log entry uuid. Throws
  * CannotPublishException or BadRequest on errors.
  */
 private static function _call(OkapiRequest $request)
 {
     # Developers! Please notice the fundamental difference between throwing
     # CannotPublishException and standard BadRequest/InvalidParam exceptions!
     # Notice, that this is "_call" method, not the usual "call" (see below
     # for "call").
     $cache_code = $request->get_parameter('cache_code');
     if (!$cache_code) {
         throw new ParamMissing('cache_code');
     }
     $logtype = $request->get_parameter('logtype');
     if (!$logtype) {
         throw new ParamMissing('logtype');
     }
     if (!in_array($logtype, array('Found it', "Didn't find it", 'Comment', 'Will attend', 'Attended'))) {
         throw new InvalidParam('logtype', "'{$logtype}' in not a valid logtype code.");
     }
     $comment = $request->get_parameter('comment');
     if (!$comment) {
         $comment = "";
     }
     $comment_format = $request->get_parameter('comment_format');
     if (!$comment_format) {
         $comment_format = "auto";
     }
     if (!in_array($comment_format, array('auto', 'html', 'plaintext'))) {
         throw new InvalidParam('comment_format', $comment_format);
     }
     $tmp = $request->get_parameter('when');
     if ($tmp) {
         $when = strtotime($tmp);
         if (!$when) {
             throw new InvalidParam('when', "'{$tmp}' is not in a valid format or is not a valid date.");
         }
         if ($when > time() + 5 * 60) {
             throw new CannotPublishException(_("You are trying to publish a log entry with a date in future. " . "Cache log entries are allowed to be published in the past, but NOT in the future."));
         }
     } else {
         $when = time();
     }
     $on_duplicate = $request->get_parameter('on_duplicate');
     if (!$on_duplicate) {
         $on_duplicate = "silent_success";
     }
     if (!in_array($on_duplicate, array('silent_success', 'user_error', 'continue'))) {
         throw new InvalidParam('on_duplicate', "Unknown option: '{$on_duplicate}'.");
     }
     $rating = $request->get_parameter('rating');
     if ($rating !== null && !in_array($rating, array(1, 2, 3, 4, 5))) {
         throw new InvalidParam('rating', "If present, it must be an integer in the 1..5 scale.");
     }
     if ($rating && $logtype != 'Found it' && $logtype != 'Attended') {
         throw new BadRequest("Rating is allowed only for 'Found it' and 'Attended' logtypes.");
     }
     if ($rating !== null && Settings::get('OC_BRANCH') == 'oc.de') {
         # We will remove the rating request and change the success message
         # (which will be returned IF the rest of the query will meet all the
         # requirements).
         self::$success_message .= " " . sprintf(_("However, your cache rating was ignored, because %s does not have a rating system."), Okapi::get_normalized_site_name());
         $rating = null;
     }
     $recommend = $request->get_parameter('recommend');
     if (!$recommend) {
         $recommend = 'false';
     }
     if (!in_array($recommend, array('true', 'false'))) {
         throw new InvalidParam('recommend', "Unknown option: '{$recommend}'.");
     }
     $recommend = $recommend == 'true';
     if ($recommend && $logtype != 'Found it') {
         if ($logtype != 'Attended') {
             throw new BadRequest("Recommending is allowed only for 'Found it' and 'Attended' logs.");
         } else {
             if (Settings::get('OC_BRANCH') == 'oc.pl') {
                 # We will remove the recommendation request and change the success message
                 # (which will be returned IF the rest of the query will meet all the
                 # requirements).
                 self::$success_message .= " " . sprintf(_("However, your cache recommendation was ignored, because %s does not allow recommending event caches."), Okapi::get_normalized_site_name());
                 $recommend = null;
             }
         }
     }
     $needs_maintenance = $request->get_parameter('needs_maintenance');
     if (!$needs_maintenance) {
         $needs_maintenance = 'false';
     }
     if (!in_array($needs_maintenance, array('true', 'false'))) {
         throw new InvalidParam('needs_maintenance', "Unknown option: '{$needs_maintenance}'.");
     }
     $needs_maintenance = $needs_maintenance == 'true';
     if ($needs_maintenance && !Settings::get('SUPPORTS_LOGTYPE_NEEDS_MAINTENANCE')) {
         # If not supported, just ignore it.
         self::$success_message .= " " . sprintf(_("However, your \"needs maintenance\" flag was ignored, because %s does not support this feature."), Okapi::get_normalized_site_name());
         $needs_maintenance = false;
     }
     # Check if cache exists and retrieve cache internal ID (this will throw
//.........这里部分代码省略.........
开发者ID:4Vs,项目名称:oc-server3,代码行数:101,代码来源:submit.php

示例15: _call

 /**
  * Edit an log entry image and return its (new) position.
  * Throws CannotPublishException or BadRequest on errors.
  */
 private static function _call(OkapiRequest $request)
 {
     # Developers! Please notice the fundamental difference between throwing
     # CannotPublishException and the "standard" BadRequest/InvalidParam
     # exceptions. CannotPublishException will be caught by the service's
     # call() function and returns a message to be displayed to the user.
     require_once 'log_images_common.inc.php';
     # validate the 'image_uuid' parameter
     list($image_uuid, $log_internal_id) = LogImagesCommon::validate_image_uuid($request);
     # validate the 'caption', 'is_spoiler' and 'position' parameters
     $caption = $request->get_parameter('caption');
     if ($caption !== null && $caption == '') {
         throw new CannotPublishException(sprintf(_("Please enter an image caption."), Okapi::get_normalized_site_name()));
     }
     $is_spoiler = $request->get_parameter('is_spoiler');
     if ($is_spoiler !== null) {
         if (!in_array($is_spoiler, array('true', 'false'))) {
             throw new InvalidParam('is_spoiler');
         }
     }
     $position = LogImagesCommon::validate_position($request);
     if ($caption === null && $is_spoiler === null && $position === null) {
         # If no-params were allowed, what would be the success message?
         # It's more reasonable to assume that this was a developer's error.
         throw new BadRequest("At least one of the parameters 'caption', 'is_spoiler' and 'position' must be supplied");
     }
     $image_uuid_escaped = Db::escape_string($image_uuid);
     $log_entry_modified = false;
     # update caption
     if ($caption !== null) {
         Db::execute("\n                update pictures\n                set title = '" . Db::escape_string($caption) . "'\n                where uuid = '" . $image_uuid_escaped . "'\n            ");
         $log_entry_modified = true;
     }
     # update spoiler flag
     if ($is_spoiler !== null) {
         Db::execute("\n                update pictures\n                set spoiler = " . ($is_spoiler == 'true' ? 1 : 0) . "\n                where uuid = '" . $image_uuid_escaped . "'\n            ");
         $log_entry_modified = true;
     }
     # update position
     if ($position !== null) {
         if (Settings::get('OC_BRANCH') == 'oc.pl') {
             # OCPL as no arbitrary log picture ordering => ignore position parameter
             # and return the picture's current position.
             $image_uuids = Db::select_column("\n                    select uuid from pictures\n                    where object_type = 1 and object_id = '" . Db::escape_string($log_internal_id) . "'\n                    order by date_created\n                ");
             $position = array_search($image_uuid, $image_uuids);
         } else {
             list($position, $seq) = LogImagesCommon::prepare_position($log_internal_id, $position, 0);
             # For OCDE the pictures table is write locked now.
             $old_seq = DB::select_value("\n                    select seq from pictures where uuid = '" . $image_uuid_escaped . "'\n                ");
             if ($seq != $old_seq) {
                 # First move the edited picture to the end, to make space for rotating.
                 # Remember that we have no transactions at OC.de. If something goes wrong,
                 # the image will stay at the end of the list.
                 $max_seq = Db::select_value("\n                        select max(seq)\n                        from pictures\n                        where object_type = 1 and object_id = '" . Db::escape_string($log_internal_id) . "'\n                    ");
                 Db::query("\n                        update pictures\n                        set seq = '" . Db::escape_string($max_seq + 1) . "'\n                        where uuid = '" . $image_uuid_escaped . "'\n                    ");
                 # now move the pictures inbetween
                 if ($seq < $old_seq) {
                     Db::execute("\n                            update pictures\n                            set seq = seq + 1\n                            where\n                                object_type = 1\n                                and object_id = '" . Db::escape_string($log_internal_id) . "'\n                                and seq >= '" . Db::escape_string($seq) . "'\n                                and seq < '" . Db::escape_string($old_seq) . "'\n                            order by seq desc\n                        ");
                 } else {
                     Db::execute("\n                            update pictures\n                            set seq = seq - 1\n                            where\n                                object_type = 1\n                                and object_id = '" . Db::escape_string($log_internal_id) . "'\n                                and seq <= '" . Db::escape_string($seq) . "'\n                                and seq > '" . Db::escape_string($old_seq) . "'\n                            order by seq asc\n                        ");
                 }
                 # and finally move the edited picture into place
                 Db::query("\n                        update pictures\n                        set seq = '" . Db::escape_string($seq) . "'\n                        where uuid = '" . $image_uuid_escaped . "'\n                    ");
             }
             Db::execute('unlock tables');
             $log_entry_modified = true;
         }
     }
     if (Settings::get('OC_BRANCH') == 'oc.pl' && $log_entry_modified) {
         # OCDE touches the log entry via trigger, OCPL needs an explicit update.
         # This will also update okapi_syncbase.
         Db::query("\n                update cache_logs\n                set last_modified = NOW()\n                where id = '" . Db::escape_string($log_internal_id) . "'\n            ");
         # OCPL code currently does not update pictures.last_modified when
         # editing, but that is a bug, see
         # https://github.com/opencaching/opencaching-pl/issues/341.
     }
     return $position;
 }
开发者ID:kratenko,项目名称:oc-server3,代码行数:82,代码来源:edit.php


注:本文中的okapi\Okapi::get_normalized_site_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。