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


PHP elgg_log函数代码示例

本文整理汇总了PHP中elgg_log函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_log函数的具体用法?PHP elgg_log怎么用?PHP elgg_log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了elgg_log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: wizard_replace_profile_fields

/**
 * Replace profile field placeholders with input fields
 *
 * @param string $text the text to replace in
 *
 * @return false|string
 */
function wizard_replace_profile_fields($text)
{
    if (empty($text) || !is_string($text)) {
        return false;
    }
    $regex = '/{{profile_([a-z0-9_-]+)}}/i';
    $matches = array();
    preg_match_all($regex, $text, $matches);
    if (empty($matches)) {
        return $text;
    }
    $placeholders = $matches[0];
    $profile_names = $matches[1];
    foreach ($placeholders as $index => $placeholder) {
        if (strpos($text, $placeholder) === false) {
            // already replaced
            continue;
        }
        $input = elgg_view('input/profile_field', array('name' => $profile_names[$index]));
        if (empty($input)) {
            elgg_log("Wizard unable to replace profile placeholder: {$placeholder}", 'WARNING');
        } else {
            elgg_log("Wizard replace profile placeholder: {$placeholder}");
        }
        $text = str_replace($placeholder, $input, $text);
    }
    return $text;
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:35,代码来源:functions.php

示例2: elasticsearch_get_client

/**
 * Get a working ElasticSearch client for further use
 *
 * @return false|ColdTrick\ElasticSearch\Client
 */
function elasticsearch_get_client()
{
    static $client;
    if (!isset($client)) {
        $client = false;
        // Check if the function 'curl_multi_exec' isn't blocked (for security reasons), this prevents error_log overflow
        // this isn't caught by the \Elasticseach\Client
        if (!function_exists('curl_multi_exec')) {
            return false;
        }
        $host = elasticsearch_get_setting('host');
        if (!empty($host)) {
            $params = array();
            $hosts = explode(',', $host);
            array_walk($hosts, 'elasticsearch_cleanup_host');
            $params['hosts'] = $hosts;
            $params['logging'] = true;
            $params['logObject'] = new ColdTrick\ElasticSearch\DatarootLogger('log');
            // trigger hook so other plugins can infuence the params
            $params = elgg_trigger_plugin_hook('params', 'elasticsearch', $params, $params);
            try {
                $client = new ColdTrick\ElasticSearch\Client($params);
            } catch (Exception $e) {
                elgg_log("Unable to create ElasticSearch client: {$e->getMessage()}", 'ERROR');
            }
        }
    }
    return $client;
}
开发者ID:coldtrick,项目名称:elasticsearch,代码行数:34,代码来源:functions.php

示例3: email

 /**
  * Prevent outgoing e-mail to non test panel members
  *
  * @param string $hook        the name of the hook
  * @param string $type        the type of the hook
  * @param array  $returnvalue the current return value
  * @param array  $params      supplied params
  *
  * @return void|false
  */
 public static function email($hook, $type, $returnvalue, $params)
 {
     if (empty($returnvalue) || !is_array($returnvalue)) {
         // someone else already send the emails
         return;
     }
     if (!test_panel_limit_notifications()) {
         // don't limit e-mails
         return;
     }
     $to = elgg_extract('to', $returnvalue);
     if (empty($to) || !is_string($to)) {
         // don't know how to handle this
         return;
     }
     $to = EmailHandler::sanitizeEmail($to);
     elgg_log("Test panel processing: {$to}", 'INFO');
     $allowed_emails = test_panel_get_panel_members_email_addresses();
     if (empty($allowed_emails) || !is_array($allowed_emails)) {
         // nobody is allowed (shouldn't happen)
         return false;
     }
     if (!in_array($to, $allowed_emails)) {
         // user is not allowed to get e-mails
         elgg_log("Test panel blocked: {$to}", 'NOTICE');
         return false;
     }
     // user is a panel member, so can receive e-mails
 }
开发者ID:coldtrick,项目名称:test_panel,代码行数:39,代码来源:EmailHandler.php

示例4: resolveIP

 /**
  * Resolve an IP address to location
  *
  * @param string $ip IP Address
  * @param mixed $format Format for an output string, or false to output result object
  * @return mixed
  */
 public static function resolveIP($ip = '', $format = "%S %n, %z %L, %C")
 {
     if (!$ip) {
         return false;
     }
     if (!isset(self::$geocoder)) {
         new ElggGeocoder();
     }
     $geocoder = self::$geocoder;
     if (!$geocoder) {
         return false;
     }
     try {
         $data = $geocoder->geocode($ip);
     } catch (Exception $e) {
         elgg_log("ElggIPResolver::resolveIP failed with the following message: " . $e->getMessage(), 'WARNING');
     }
     if ($data) {
         if ($format) {
             $formatter = new Formatter($data);
             return $formatter->format($format);
         } else {
             return $data;
         }
     } else {
         return false;
     }
 }
开发者ID:hypejunction,项目名称:hypegeo,代码行数:35,代码来源:ElggIPResolver.php

示例5: send_api_call

/**
 * Send a raw API call to an elgg api endpoint.
 *
 * @param array  $keys         The api keys.
 * @param string $url          URL of the endpoint.
 * @param array  $call         Associated array of "variable" => "value"
 * @param string $method       GET or POST
 * @param string $post_data    The post data
 * @param string $content_type The content type
 *
 * @return string
 */
function send_api_call(array $keys, $url, array $call, $method = 'GET', $post_data = '', $content_type = 'application/octet-stream')
{
    global $CONFIG;
    $headers = array();
    $encoded_params = array();
    $method = strtoupper($method);
    switch (strtoupper($method)) {
        case 'GET':
        case 'POST':
            break;
        default:
            $msg = elgg_echo('NotImplementedException:CallMethodNotImplemented', array($method));
            throw new NotImplementedException($msg);
    }
    // Time
    $time = time();
    // Nonce
    $nonce = uniqid('');
    // URL encode all the parameters
    foreach ($call as $k => $v) {
        $encoded_params[] = urlencode($k) . '=' . urlencode($v);
    }
    $params = implode('&', $encoded_params);
    // Put together the query string
    $url = $url . "?" . $params;
    // Construct headers
    $posthash = "";
    if ($method == 'POST') {
        $posthash = calculate_posthash($post_data, 'md5');
    }
    if (isset($keys['public']) && isset($keys['private'])) {
        $headers['X-Elgg-apikey'] = $keys['public'];
        $headers['X-Elgg-time'] = $time;
        $headers['X-Elgg-nonce'] = $nonce;
        $headers['X-Elgg-hmac-algo'] = 'sha1';
        $headers['X-Elgg-hmac'] = calculate_hmac('sha1', $time, $nonce, $keys['public'], $keys['private'], $params, $posthash);
    }
    if ($method == 'POST') {
        $headers['X-Elgg-posthash'] = $posthash;
        $headers['X-Elgg-posthash-algo'] = 'md5';
        $headers['Content-type'] = $content_type;
        $headers['Content-Length'] = strlen($post_data);
    }
    // Opt array
    $http_opts = array('method' => $method, 'header' => serialise_api_headers($headers));
    if ($method == 'POST') {
        $http_opts['content'] = $post_data;
    }
    $opts = array('http' => $http_opts);
    // Send context
    $context = stream_context_create($opts);
    // Send the query and get the result and decode.
    elgg_log("APICALL: {$url}");
    $results = file_get_contents($url, false, $context);
    return $results;
}
开发者ID:ibou77,项目名称:elgg,代码行数:68,代码来源:client.php

示例6: setSearchLocation

 /**
  * Set the search location
  * @param string $location		Location address
  * @param integer $radius		Radius in the unit of preset metric system (kilometer or mile)
  */
 public function setSearchLocation($location = '', $radius = 0)
 {
     $this->setRadius($radius);
     $this->setLocation($location);
     try {
         $query = new ElggMapQuery('proximity', array('location' => $this->getLocation(), 'latitude' => $this->getLatitude(), 'longitude' => $this->getLongitude(), 'radius' => $this->radius));
         $this->options = $query->sqlGetOptions($this->options);
     } catch (Exception $e) {
         elgg_log($e->getMessage(), 'ERROR');
     }
     return $this;
 }
开发者ID:hypejunction,项目名称:hypemaps,代码行数:17,代码来源:ElggMap.php

示例7: delete

 public function delete()
 {
     $result = false;
     $event = get_entity($this->event_guid);
     $result = remove_entity_relationship($this->event_guid, ZHAOHU_MANAGER_RELATION_ATTENDING, $this->user_guid);
     if (!$result) {
         elgg_log("ZHError ,coupon:delete, failed to remove_entity_relationship, coupon_id {$this->guid}", "ERROR");
         return false;
     }
     parent::delete();
     return true;
 }
开发者ID:pingwangcs,项目名称:51zhaohu,代码行数:12,代码来源:Coupon.php

示例8: read

 /**
  * Get contents of the page
  *
  * @param string $url     URL of the resource
  * @param array  $options HTTP request options
  * @return string
  */
 public function read($url = '', $options = array())
 {
     $body = '';
     if (!$this->exists($url)) {
         return $body;
     }
     try {
         $response = $this->client->get($url, $options)->send();
         $body = $response->getBody(true);
     } catch (Exception $ex) {
         elgg_log($ex->getMessage(), 'ERROR');
     }
     return $body;
 }
开发者ID:n8b,项目名称:VMN,代码行数:21,代码来源:Resource.php

示例9: myicon_avatar_hook

/**
 * This hooks into the getIcon API and returns a myicon icon
 */
function myicon_avatar_hook($hook, $type, $url, $params)
{
    $entity = $params['entity'];
    // check if user already has an icon
    if (!$entity->icontime) {
        $size = $params['size'];
        $icon = pickIcon($entity);
        if (!$icon) {
            elgg_log("ZHError ,myicon_avatar_hook, entity_id {$entity->guid}, user id " . elgg_get_logged_in_user_guid(), "ERROR");
            return false;
        }
        return "mod/myicon/icon.php?size={$size}&icon={$icon}";
    }
}
开发者ID:pingwangcs,项目名称:51zhaohu,代码行数:17,代码来源:start.php

示例10: deleteFormat

 /**
  * Delete a single version of the video
  */
 public function deleteFormat($format, $resolution = 0)
 {
     if (empty($resolution)) {
         // Use resolution of the original file as default
         $resolution = $this->resolution;
     }
     $sources = elgg_get_entities_from_metadata(array('type' => 'object', 'subtype' => 'video_source', 'container_guid' => $this->getGUID(), 'metadata_name_value_pairs' => array('format' => $format, 'resolution' => $resolution)));
     foreach ($sources as $source) {
         if ($source->delete()) {
             return true;
         } else {
             elgg_log("Video removal failed. Remove {$filepath} manually, please.", 'WARNING');
             return false;
         }
     }
 }
开发者ID:juho-jaakkola,项目名称:elgg-videos,代码行数:19,代码来源:Video.php

示例11: execute

 /**
  * Executes an action
  * Triggers 'action:after', $ation hook that allows you to filter the Result object
  * 
  * @param mixed $controller Action name or instance of Action
  * @param bool  $feedback   Display errors and messages
  * @return ActionResult
  */
 public function execute($controller = null, $feedback = true)
 {
     try {
         $action = $this->parseActionName($controller);
         elgg_make_sticky_form($action);
         if (!$controller instanceof Action) {
             $controller = $this->getController($action);
         }
         if (!$controller instanceof Action) {
             throw new Exception("Not a valid action controller");
         }
         $controller->setup();
         if ($controller->validate() === false) {
             throw new ActionValidationException("Invalid input for action {$action}");
         }
         $controller->execute();
         $this->result = $controller->getResult();
     } catch (ActionValidationException $ex) {
         $this->result->addError($ex->getMessage());
         elgg_log($ex->getMessage(), 'ERROR');
     } catch (PermissionsException $ex) {
         $this->result->addError(elgg_echo('apps:permissions:error'));
         elgg_log($ex->getMessage(), 'ERROR');
     } catch (InvalidEntityException $ex) {
         $this->result->addError(elgg_echo('apps:entity:error'));
         elgg_log($ex->getMessage(), 'ERROR');
     } catch (Exception $ex) {
         $this->result->addError(elgg_echo('apps:action:error'));
         elgg_log($ex->getMessage(), 'ERROR');
     }
     $errors = $this->result->getErrors();
     $messages = $this->result->getMessages();
     if (empty($errors)) {
         elgg_clear_sticky_form($action);
     } else {
         $this->result->setForwardURL(REFERRER);
     }
     if ($feedback) {
         foreach ($errors as $error) {
             register_error($error);
         }
         foreach ($messages as $message) {
             system_message($message);
         }
     }
     return elgg_trigger_plugin_hook('action:after', $action, null, $this->result);
 }
开发者ID:n8b,项目名称:VMN,代码行数:55,代码来源:Actions.php

示例12: validateGroupDefaultAccess

 /**
  * Validate that the group default access isn't above the group settings for content
  *
  * @param string $hook         the name of the hook
  * @param string $type         the type of the hook
  * @param int    $return_value current return value
  * @param array  $params       supplied params
  *
  * @return void|int
  */
 public static function validateGroupDefaultAccess($hook, $type, $return_value, $params)
 {
     // check if the page owner is a group
     $page_owner = elgg_get_page_owner_entity();
     if (!$page_owner instanceof \ElggGroup) {
         return;
     }
     if ($page_owner->getContentAccessMode() !== \ElggGroup::CONTENT_ACCESS_MODE_MEMBERS_ONLY) {
         return;
     }
     if ($return_value !== ACCESS_PUBLIC && $return_value !== ACCESS_LOGGED_IN) {
         return;
     }
     // default access is higher than content access level, so lower
     elgg_log("Default access for the group {$page_owner->name} is set more public than the content access level", 'NOTICE');
     return (int) $page_owner->group_acl;
 }
开发者ID:coldtrick,项目名称:group_tools,代码行数:27,代码来源:Access.php

示例13: smf_register

function smf_register($user, $password)
{
    $api = new SmfRestClient(simple_auth(SMF_SEC_KEY, 'ENCODE'));
    $find = $api->get_user($user->username);
    if ($find->data != 'false') {
        return;
    }
    $code = simple_auth($password, 'ENCODE');
    $regOptions = array("member_name" => "{$user->username}", "real_name" => "{$user->name}", "email" => "{$user->email}", "password" => "{$code}", "require" => "nothing");
    // if use api call directly
    //$mem_id = smfapi_registerMember ( $regOptions );
    $mem_id = $api->register_member($regOptions);
    if (!$mem_id) {
        elgg_log("ZHError smf_register failed, user_id {$user->guid}", "ERROR");
    }
    return $mem_id;
}
开发者ID:pingwangcs,项目名称:51zhaohu,代码行数:17,代码来源:start.php

示例14: elgg_register_menu_item

/**
 * Register an item for an Elgg menu
 *
 * @warning Generally you should not use this in response to the plugin hook:
 * 'register', 'menu:<menu_name>'. If you do, you may end up with many incorrect
 * links on a dynamic menu.
 *
 * @warning A menu item's name must be unique per menu. If more than one menu
 * item with the same name are registered, the last menu item takes priority.
 *
 * @see elgg_view_menu() for the plugin hooks available for modifying a menu as
 * it is being rendered.
 *
 * @see ElggMenuItem::factory() is used to turn an array value of $menu_item into an
 * ElggMenuItem object.
 *
 * @param string $menu_name The name of the menu: site, page, userhover,
 *                          userprofile, groupprofile, or any custom menu
 * @param mixed  $menu_item An ElggMenuItem or options for ElggMenuItem::factory()
 *
 * @return bool False if the item could not be added
 * @since 1.8.0
 */
function elgg_register_menu_item($menu_name, $menu_item)
{
    global $CONFIG;
    if (!isset($CONFIG->menus[$menu_name])) {
        $CONFIG->menus[$menu_name] = array();
    }
    if (is_array($menu_item)) {
        $item = ElggMenuItem::factory($menu_item);
        if (!$item) {
            elgg_log("Unable to add menu item '{$menu_item['name']}' to '{$menu_name}' menu", 'WARNING');
            return false;
        }
    } else {
        $item = $menu_item;
    }
    $CONFIG->menus[$menu_name][] = $item;
    return true;
}
开发者ID:gzachos,项目名称:elgg_ellak,代码行数:41,代码来源:navigation.php

示例15: __construct

 /**
  * Loads the plugin by GUID or path.
  *
  * @warning Unlike other ElggEntity objects, you cannot null instantiate
  *          ElggPlugin. You must point it to an actual plugin GUID or location.
  *
  * @param mixed $plugin The GUID of the ElggPlugin object or the path of
  *                      the plugin to load.
  */
 public function __construct($plugin)
 {
     if (!$plugin) {
         throw new PluginException(elgg_echo('PluginException:NullInstantiated'));
     }
     // ElggEntity can be instantiated with a guid or an object.
     // @todo plugins w/id 12345
     if (is_numeric($plugin) || is_object($plugin)) {
         parent::__construct($plugin);
         $this->path = elgg_get_plugins_path() . $this->getID();
     } else {
         $plugin_path = elgg_get_plugins_path();
         // not a full path, so assume an id
         // use the default path
         if (strpos($plugin, $plugin_path) !== 0) {
             $plugin = $plugin_path . $plugin;
         }
         // path checking is done in the package
         $plugin = sanitise_filepath($plugin);
         $this->path = $plugin;
         $path_parts = explode('/', rtrim($plugin, '/'));
         $plugin_id = array_pop($path_parts);
         $this->pluginID = $plugin_id;
         // check if we're loading an existing plugin
         $existing_plugin = elgg_get_plugin_from_id($this->pluginID);
         $existing_guid = null;
         if ($existing_plugin) {
             $existing_guid = $existing_plugin->guid;
         }
         // load the rest of the plugin
         parent::__construct($existing_guid);
     }
     // We have to let the entity load so we can manipulate it with the API.
     // If the path is wrong or would cause an exception, catch it,
     // disable the plugin, and emit an error.
     try {
         $this->package = new ElggPluginPackage($this->path, false);
         $this->manifest = $this->package->getManifest();
     } catch (Exception $e) {
         // we always have to allow the entity to load.
         elgg_log("Failed to load {$this->guid} as a plugin. " . $e->getMessage(), 'WARNING');
         $this->errorMsg = $e->getmessage();
     }
 }
开发者ID:rasul,项目名称:Elgg,代码行数:53,代码来源:ElggPlugin.php


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