本文整理汇总了PHP中is_nxt_error函数的典型用法代码示例。如果您正苦于以下问题:PHP is_nxt_error函数的具体用法?PHP is_nxt_error怎么用?PHP is_nxt_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_nxt_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _purge_content
/**
* Purge content
*
* @param string $path
* @param int $type
* @param string $error
* @return boolean
*/
function _purge_content($path, $type, &$error)
{
$url = sprintf(W3TC_CDN_EDGECAST_PURGE_URL, $this->_config['account']);
$args = array('method' => 'PUT', 'user-agent' => W3TC_POWERED_BY, 'headers' => array('Accept' => 'application/json', 'Content-Type' => 'application/json', 'Authorization' => sprintf('TOK:%s', $this->_config['token'])), 'body' => json_encode(array('MediaPath' => $path, 'MediaType' => $type)));
$response = nxt_remote_request($url, $args);
if (is_nxt_error($response)) {
$error = implode('; ', $response->get_error_messages());
return false;
}
switch ($response['response']['code']) {
case 200:
return true;
case 400:
$error = 'Invalid Request Parameter';
return false;
case 403:
$error = 'Authentication Failure or Insufficient Access Rights';
return false;
case 404:
$error = 'Invalid Request URI';
return false;
case 405:
$error = 'Invalid Request';
return false;
case 500:
$error = 'Server Error';
return false;
}
$error = 'Unknown error';
return false;
}
示例2: __construct
function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false)
{
$this->url = $url;
$this->timeout = $timeout;
$this->redirects = $redirects;
$this->headers = $headers;
$this->useragent = $useragent;
$this->method = SIMPLEPIE_FILE_SOURCE_REMOTE;
if (preg_match('/^http(s)?:\\/\\//i', $url)) {
$args = array('timeout' => $this->timeout, 'redirection' => $this->redirects);
if (!empty($this->headers)) {
$args['headers'] = $this->headers;
}
if (SIMPLEPIE_USERAGENT != $this->useragent) {
//Use default nxt user agent unless custom has been specified
$args['user-agent'] = $this->useragent;
}
$res = nxt_remote_request($url, $args);
if (is_nxt_error($res)) {
$this->error = 'nxt HTTP Error: ' . $res->get_error_message();
$this->success = false;
} else {
$this->headers = nxt_remote_retrieve_headers($res);
$this->body = nxt_remote_retrieve_body($res);
$this->status_code = nxt_remote_retrieve_response_code($res);
}
} else {
if (!($this->body = file_get_contents($url))) {
$this->error = 'file_get_contents could not read the file';
$this->success = false;
}
}
}
示例3: register_importer
/**
* Register importer for NXTClass.
*
* @since 2.0.0
*
* @param string $id Importer tag. Used to uniquely identify importer.
* @param string $name Importer name and title.
* @param string $description Importer description.
* @param callback $callback Callback to run.
* @return nxt_Error Returns nxt_Error when $callback is nxt_Error.
*/
function register_importer($id, $name, $description, $callback)
{
global $nxt_importers;
if (is_nxt_error($callback)) {
return $callback;
}
$nxt_importers[$id] = array($name, $description, $callback);
}
示例4: get_nxt_title_rss
/**
* Retrieve the blog title for the feed title.
*
* @package NXTClass
* @subpackage Feed
* @since 2.2.0
* @uses apply_filters() Calls 'get_nxt_title_rss' hook on title.
* @uses nxt_title() See function for $sep parameter usage.
*
* @param string $sep Optional.How to separate the title. See nxt_title() for more info.
* @return string Error message on failure or blog title on success.
*/
function get_nxt_title_rss($sep = '»')
{
$title = nxt_title($sep, false);
if (is_nxt_error($title)) {
return $title->get_error_message();
}
$title = apply_filters('get_nxt_title_rss', $title);
return $title;
}
示例5: add
/**
* Append to XML response based on given arguments.
*
* The arguments that can be passed in the $args parameter are below. It is
* also possible to pass a nxt_Error object in either the 'id' or 'data'
* argument. The parameter isn't actually optional, content should be given
* in order to send the correct response.
*
* 'what' argument is a string that is the XMLRPC response type.
* 'action' argument is a boolean or string that acts like a nonce.
* 'id' argument can be nxt_Error or an integer.
* 'old_id' argument is false by default or an integer of the previous ID.
* 'position' argument is an integer or a string with -1 = top, 1 = bottom,
* html ID = after, -html ID = before.
* 'data' argument is a string with the content or message.
* 'supplemental' argument is an array of strings that will be children of
* the supplemental element.
*
* @since 2.1.0
*
* @param string|array $args Override defaults.
* @return string XML response.
*/
function add($args = '')
{
$defaults = array('what' => 'object', 'action' => false, 'id' => '0', 'old_id' => false, 'position' => 1, 'data' => '', 'supplemental' => array());
$r = nxt_parse_args($args, $defaults);
extract($r, EXTR_SKIP);
$position = preg_replace('/[^a-z0-9:_-]/i', '', $position);
if (is_nxt_error($id)) {
$data = $id;
$id = 0;
}
$response = '';
if (is_nxt_error($data)) {
foreach ((array) $data->get_error_codes() as $code) {
$response .= "<nxt_error code='{$code}'><![CDATA[" . $data->get_error_message($code) . "]]></nxt_error>";
if (!($error_data = $data->get_error_data($code))) {
continue;
}
$class = '';
if (is_object($error_data)) {
$class = ' class="' . get_class($error_data) . '"';
$error_data = get_object_vars($error_data);
}
$response .= "<nxt_error_data code='{$code}'{$class}>";
if (is_scalar($error_data)) {
$response .= "<![CDATA[{$error_data}]]>";
} elseif (is_array($error_data)) {
foreach ($error_data as $k => $v) {
$response .= "<{$k}><![CDATA[{$v}]]></{$k}>";
}
}
$response .= "</nxt_error_data>";
}
} else {
$response = "<response_data><![CDATA[{$data}]]></response_data>";
}
$s = '';
if (is_array($supplemental)) {
foreach ($supplemental as $k => $v) {
$s .= "<{$k}><![CDATA[{$v}]]></{$k}>";
}
$s = "<supplemental>{$s}</supplemental>";
}
if (false === $action) {
$action = $_POST['action'];
}
$x = '';
$x .= "<response action='{$action}_{$id}'>";
// The action attribute in the xml output is formatted like a nonce action
$x .= "<{$what} id='{$id}' " . (false === $old_id ? '' : "old_id='{$old_id}' ") . "position='{$position}'>";
$x .= $response;
$x .= $s;
$x .= "</{$what}>";
$x .= "</response>";
$this->responses[] = $x;
return $x;
}
示例6: external_event
/**
* Makes external event request
*
* @param string $type
* @param string $value
* @return array
*/
function external_event($type, $value)
{
require_once W3TC_INC_DIR . '/functions/http.php';
$url = sprintf('%s?u=%s&tkn=%s&evnt_t=%s&evnt_v=%s', W3TC_CLOUDFLARE_EXTERNAL_EVENT_URL, urlencode($this->_config['email']), urlencode($this->_config['key']), urlencode($type), urlencode($value));
$response = w3_http_get($url);
if (!is_nxt_error($response)) {
return json_decode($response['body']);
}
return false;
}
示例7: w3_download
/**
* Downloads URL into a file
*
* @param string $url
* @param string $file
* @return boolean
*/
function w3_download($url, $file)
{
if (strpos($url, '//') === 0) {
$url = (w3_is_https() ? 'https:' : 'http:') . $url;
}
$response = w3_http_get($url);
if (!is_nxt_error($response) && $response['response']['code'] == 200) {
return @file_put_contents($file, $response['body']);
}
return false;
}
示例8: huddle_bp_show_blog_signup_form
function huddle_bp_show_blog_signup_form($blogname = '', $blog_title = '', $errors = '')
{
global $current_user, $current_site;
global $bp;
if (isset($_POST['submit'])) {
huddle_bp_blogs_validate_blog_signup();
} else {
if (!is_nxt_error($errors)) {
$errors = new nxt_Error();
}
// allow definition of default variables
$filtered_results = apply_filters('signup_another_blog_init', array('blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $errors));
$blogname = $filtered_results['blogname'];
$blog_title = $filtered_results['blog_title'];
$errors = $filtered_results['errors'];
if ($errors->get_error_code()) {
echo "<p>" . __('There was a problem, please correct the form below and try again.', 'buddypress') . "</p>";
}
?>
<p><?php
printf(__("By filling out the form below, you can <strong>add a site to your account</strong>. There is no limit to the number of sites that you can have, so create to your heart's content, but blog responsibly!", 'buddypress'), $current_user->display_name);
?>
</p>
<p><?php
_e("If you’re not going to use a great domain, leave it for a new user. Now have at it!", 'buddypress');
?>
</p>
<form class="standard-form" id="setupform" method="post" action="">
<input type="hidden" name="stage" value="gimmeanotherblog" />
<?php
do_action('signup_hidden_fields');
?>
<?php
huddle_bp_blogs_signup_blog($blogname, $blog_title, $errors);
?>
<p class="editfield">
<input id="submit" type="submit" name="submit" class="btn-gray submit" value="<?php
_e('Create Site', 'buddypress');
?>
" />
</p>
<?php
nxt_nonce_field('bp_blog_signup_form');
?>
</form>
<?php
}
}
示例9: _request
/**
* Make API request
*
* @param string $url
* @return string
*/
function _request($url)
{
require_once W3TC_INC_DIR . '/functions/http.php';
require_once W3TC_INC_DIR . '/functions/url.php';
$request_url = w3_url_format(W3TC_PAGESPEED_API_URL, array('url' => $url, 'key' => $this->key));
$response = w3_http_get($request_url);
if (!is_nxt_error($response) && $response['response']['code'] == 200) {
return $response['body'];
}
return false;
}
示例10: bb_update_meta
/**
* Adds and updates meta data in the database
*
* @internal
*/
function bb_update_meta($object_id = 0, $meta_key, $meta_value, $type, $global = false)
{
global $bbdb;
if (!is_numeric($object_id) || empty($object_id) && !$global) {
return false;
}
$cache_object_id = $object_id = (int) $object_id;
switch ($type) {
case 'option':
$object_type = 'bb_option';
break;
case 'user':
global $nxt_users_object;
$id = $object_id;
$return = $nxt_users_object->update_meta(compact('id', 'meta_key', 'meta_value'));
if (is_nxt_error($return)) {
return false;
}
return $return;
break;
case 'forum':
$object_type = 'bb_forum';
break;
case 'topic':
$object_type = 'bb_topic';
break;
case 'post':
$object_type = 'bb_post';
break;
default:
$object_type = $type;
break;
}
$meta_key = bb_sanitize_meta_key($meta_key);
$meta_tuple = compact('object_type', 'object_id', 'meta_key', 'meta_value', 'type');
$meta_tuple = apply_filters('bb_update_meta', $meta_tuple);
extract($meta_tuple, EXTR_OVERWRITE);
$meta_value = $_meta_value = maybe_serialize($meta_value);
$meta_value = maybe_unserialize($meta_value);
$cur = $bbdb->get_row($bbdb->prepare("SELECT * FROM `{$bbdb->meta}` WHERE `object_type` = %s AND `object_id` = %d AND `meta_key` = %s", $object_type, $object_id, $meta_key));
if (!$cur) {
$bbdb->query($bbdb->prepare("INSERT INTO `{$bbdb->meta}` ( `object_type`, `object_id`, `meta_key`, `meta_value` ) VALUES( %s, %d, %s, %s )\n\t\t\tON DUPLICATE KEY UPDATE `meta_value` = VALUES( `meta_value` )", $object_type, $object_id, $meta_key, $_meta_value));
} elseif ($cur->meta_value != $meta_value) {
$bbdb->update($bbdb->meta, array('meta_value' => $_meta_value), array('object_type' => $object_type, 'object_id' => $object_id, 'meta_key' => $meta_key));
}
if ($object_type === 'bb_option') {
$cache_object_id = $meta_key;
nxt_cache_delete($cache_object_id, 'bb_option_not_set');
}
nxt_cache_delete($cache_object_id, $object_type);
if (!$cur) {
return true;
}
}
示例11: membership_is_active
function membership_is_active($userdata, $password)
{
global $nxtdb;
// Checks if this member is an active one.
if (!empty($userdata) && !is_nxt_error($userdata)) {
$id = $userdata->ID;
if (get_usermeta($id, $nxtdb->prefix . 'membership_active', true) == 'no') {
return new nxt_Error('member_inactive', __('Sorry, this account is not active.', 'membership'));
}
}
return $userdata;
}
示例12: query
function query()
{
$args = func_get_args();
$method = array_shift($args);
$request = new IXR_Request($method, $args);
$xml = $request->getXml();
$url = $this->scheme . '://' . $this->server . ':' . $this->port . $this->path;
$args = array('headers' => array('Content-Type' => 'text/xml'), 'user-agent' => $this->useragent, 'body' => $xml);
// Merge Custom headers ala #8145
foreach ($this->headers as $header => $value) {
$args['headers'][$header] = $value;
}
if ($this->timeout !== false) {
$args['timeout'] = $this->timeout;
}
// Now send the request
if ($this->debug) {
echo '<pre class="ixr_request">' . htmlspecialchars($xml) . "\n</pre>\n\n";
}
$response = nxt_remote_post($url, $args);
if (is_nxt_error($response)) {
$errno = $response->get_error_code();
$errorstr = $response->get_error_message();
$this->error = new IXR_Error(-32300, "transport error: {$errno} {$errstr}");
return false;
}
$code = $response['response']['code'];
if ($code != 200) {
$this->error = new IXR_Error(-32301, "transport error - HTTP status code was not 200 ({$code})");
return false;
}
if ($this->debug) {
echo '<pre class="ixr_response">' . htmlspecialchars($response['body']) . "\n</pre>\n\n";
}
// Now parse what we've got back
$this->message = new IXR_Message($response['body']);
if (!$this->message->parse()) {
// XML error
$this->error = new IXR_Error(-32700, 'parse error. not well formed');
return false;
}
// Is the message a fault?
if ($this->message->messageType == 'fault') {
$this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
return false;
}
// Message must be OK
return true;
}
示例13: get_bookmark_field
/**
* Retrieve single bookmark data item or field.
*
* @since 2.3.0
* @uses get_bookmark() Gets bookmark object using $bookmark as ID
* @uses sanitize_bookmark_field() Sanitizes Bookmark field based on $context.
*
* @param string $field The name of the data field to return
* @param int $bookmark The bookmark ID to get field
* @param string $context Optional. The context of how the field will be used.
* @return string
*/
function get_bookmark_field($field, $bookmark, $context = 'display')
{
$bookmark = (int) $bookmark;
$bookmark = get_bookmark($bookmark);
if (is_nxt_error($bookmark)) {
return $bookmark;
}
if (!is_object($bookmark)) {
return '';
}
if (!isset($bookmark->{$field})) {
return '';
}
return sanitize_bookmark_field($field, $bookmark->{$field}, $bookmark->link_id, $context);
}
示例14: nxt_credits
function nxt_credits()
{
global $nxt_version;
$locale = get_locale();
$results = get_site_transient('nxtclass_credits_' . $locale);
if (!is_array($results)) {
$response = nxt_remote_get("http://api.nxtclass.org/core/credits/1.0/?version={$nxt_version}&locale={$locale}");
if (is_nxt_error($response) || 200 != nxt_remote_retrieve_response_code($response)) {
return false;
}
$results = maybe_unserialize(nxt_remote_retrieve_body($response));
if (!is_array($results)) {
return false;
}
set_site_transient('nxtclass_credits_' . $locale, $results, 86400);
// One day
}
return $results;
}
示例15: set_prefix
/**
* Sets the prefix of the database tables
* @param string prefix
* @param false|array tables (optional: false)
* table identifiers are array keys
* array values
* empty: set prefix: array( 'posts' => false, 'users' => false, ... )
* string: set to that array value: array( 'posts' => 'my_posts', 'users' => 'my_users' )
* array: array[0] is DB identifier, array[1] is table name: array( 'posts' => array( 'global', 'my_posts' ), 'users' => array( 'users', 'my_users' ) )
* OR array values (with numeric keys): array( 'posts', 'users', ... )
*
* @return string the previous prefix (mostly only meaningful if all $table parameter was false)
*/
function set_prefix($prefix, $tables = false)
{
$old_prefix = parent::set_prefix($prefix, $tables);
if (!$old_prefix || is_nxt_error($old_prefix)) {
return $old_prefix;
}
if ($tables && is_array($tables)) {
$_tables = $tables;
} else {
$_tables = $this->tables;
}
foreach ($_tables as $key => $value) {
// array( 'posts' => array( 'global', 'my_posts' ), 'users' => array( 'users', 'my_users' ) )
if (is_array($value) && isset($this->db_servers['dbh_' . $value[0]])) {
$this->add_db_table($value[0], $value[1]);
$this->{$key} = $value[1];
}
}
return $old_prefix;
}